Commit 4b1f20ac by yuichiro ogawa

#36026

parent c2abc033
......@@ -106,6 +106,9 @@ public class ABVEnvironment {
public static final String LogHProfPath = "log/UncaughtErrReport.hprof";
public static final String LogUncaughtErrorEncName = "UncaughtErrReport.zip";
// KAGOME対応 ラベルフォーマットファイル
public static final String LabelFormatFileName = "ItemLabel.spfmtz";
public static final String BackupFileDirectoryFormat = "%s/ABook/backup";
public static final String TimeFileDirectoryFormat = "%s/ABook/time";
......
......@@ -34,6 +34,7 @@ public class ABookKeys {
public static final String CMD_MOVE_PAGE = "movePage";
public static final String CMD_SHOW_RELATED_CONTENT = "showRelatedContent";
public static final String CMD_PAGE_NUM = "pageNum";
public static final String CMD_LABEL_PRINT = "labelPrint";
public static final String GPS_TYPE = "gpsType";
public static final String STATUS_CODE = "statusCode";
......@@ -45,6 +46,14 @@ public class ABookKeys {
public static final String ATTACHED_CHANGE_FLAG = "attachedChangeFlag";
public static final String ROUTINE_TASK_FLAG = "routineTaskFlag";
public static final String UPDATE_HOTSPOT_ONLY_FLAG = "updateHotSpotOnlyFlag";
// KAGOME対応 ラベル印刷パラメータstart
public static final String LABEL_ITEM_NAME = "itemName";
public static final String LABEL_LOT_NUMBER = "lotNumber";
public static final String LABEL_OPERATION_NO = "operationNo";
public static final String LABEL_LOT_NUMBER_QR = "lotNumberQR";
// KAGOME対応 ラベル印刷パラメータend
// #32782 指示者テーブル関連削除 start
// TODO change TASK_DIRECTIONS 削除が必要
// public static final String TASK_DIRECTIONS = "taskReport";
......
......@@ -10,6 +10,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.provider.MediaStore;
import android.util.Xml;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
......@@ -25,12 +26,22 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.adf.JSONObject;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
......@@ -45,6 +56,7 @@ import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.bl.data.DatabaseExporter;
import jp.agentec.abook.abv.bl.download.ContentFileExtractor;
import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.MydataDto;
......@@ -1088,10 +1100,17 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger.e(TAG, "startContentActivity failed.", e);
ErrorMessage.showErrorMessageToast(getApplicationContext(), ErrorCode.E107);
}
} else if (mCmd.equals(ABookKeys.CMD_LABEL_PRINT)) { // KAGOME対応 ラベル印刷
labelPrint(abookCheckParam.get(ABookKeys.LABEL_ITEM_NAME),
abookCheckParam.get(ABookKeys.LABEL_LOT_NUMBER),
abookCheckParam.get(ABookKeys.LABEL_OPERATION_NO),
abookCheckParam.get(ABookKeys.LABEL_LOT_NUMBER_QR));
}
}
public void commonAttachedDataUrl (String taskKey, String data) {
boolean isError = false;
if (data != null) {
......@@ -1224,6 +1243,122 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
}
/**
* KAGOME対応 ラベル印刷
* @param itemName
* @param lotNumber
* @param operationNo
* @param lotNumberQR
*/
private void labelPrint(String itemName, String lotNumber, String operationNo, String lotNumberQR) {
//HTTP GET リクエスト処理
Uri.Builder uriBuilder = new Uri.Builder();
//SmaPriDriverのアドレス、フォーマット印刷のアクションパスを指定
uriBuilder.path("http://localhost:8080/Format/Print");
// ContentsProviderはプリンター側の仕とが出来ないため、
// ラベル用のフォーマットファイルを外部ストレージにコピーする
String labelFormatFilePath = ABVEnvironment.getInstance().cacheDirectory + "/" + contentId + "/" + ABVEnvironment.LabelFormatFileName;
try {
DatabaseExporter.fileExport(labelFormatFilePath, "/sdcard/" + contentId + "/" + ABVEnvironment.LabelFormatFileName);
} catch (Exception e) {
Logger.w(TAG, "[exportSend]: fail send to /sdcard/" + contentId + "/");
}
//__format_archive_urlパラメータにフォーマットアーカイブファイルのコンテンツプロバイダURLを指定
//String labelFormatPath = ABVEnvironment.getInstance().getTaskPdfDirName(ContentFileExtractor.getInstance().getContentCacheDirWithExtract(operationDto.contentId)) + "/" + ABookKeys.LABEL_FORMAT_NAME;
uriBuilder.appendQueryParameter("__format_archive_url", "file:///sdcard/" + contentId + "/" + ABVEnvironment.LabelFormatFileName);
//__format_id_numberパラメータに呼出し番号を指定
uriBuilder.appendQueryParameter("__format_id_number", "1");
//__format_archive_updateパラメータにフォーマット変更時の更新を指示
uriBuilder.appendQueryParameter("__format_archive_update", "update");
// // ロットNoの成形
// StringBuilder sb;
// sb = new StringBuilder(lotNumberQR);
// sb.insert(7, "-");
// sb.insert(4, "-");
//フォーマットの入力項目にeditTextの入力データを設定
uriBuilder.appendQueryParameter(Uri.encode("itemName"), Uri.encode(itemName));
uriBuilder.appendQueryParameter(Uri.encode("lotNumber"),Uri.encode(lotNumber));
uriBuilder.appendQueryParameter(Uri.encode("operationNo"), Uri.encode(operationNo));
uriBuilder.appendQueryParameter(Uri.encode("lotNumberQR"),Uri.encode(lotNumberQR));
final String uri = Uri.decode(uriBuilder.build().toString());//urlを生成
// HTTP GET リクエスト
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
HttpUriRequest httpGet = new HttpGet(uri);
DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
try {
HttpResponse httpResponse = defaultHttpClient.execute(httpGet);
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
// HTTPレスポンス
String html_string = EntityUtils.toString(httpResponse.getEntity(),"UTF-8");
//editText.setText(html_string);
//XMLパーサを生成
XmlPullParser xmlPullParser = Xml.newPullParser();
//XMLパーサにHTTPレスポンスを設定
xmlPullParser.setInput(new StringReader(html_string));
//XML解析
String tagText1="";
String tagText2="";
for(int eventType = xmlPullParser.getEventType();eventType != XmlPullParser.END_DOCUMENT; eventType = xmlPullParser.next()){
String tagName;
if(eventType == XmlPullParser.START_TAG){
tagName = xmlPullParser.getName();
//処理結果を取得(OK/NG)
if(tagName.equals("result")){
xmlPullParser.next();
if(xmlPullParser.getEventType() == XmlPullParser.TEXT){
tagText1 = xmlPullParser.getText();
}
}
//処理結果のメッセージを取得
if(tagName.equals("message")){
xmlPullParser.next();
if(xmlPullParser.getEventType() == XmlPullParser.TEXT){
tagText2 = xmlPullParser.getText();
}
}
}
}
//結果判定とエラー表示
if (tagText1.toString().equals("OK")){
Logger.w(TAG,"label print complete");
afterABookCheckApi(mCmd, "", 0, tagText1 + ":印刷指示が完了しました。", null);
}
else{
Logger.w(TAG,"label print error");
afterABookCheckApi(mCmd, "", 1, tagText1 + tagText2, null);
}
}
} catch (XmlPullParserException e) {
Logger.w(TAG,"label print exception");
afterABookCheckApi(mCmd, "", 1, PatternStringUtil.patternToString(getApplicationContext(),
R.string.msg_location_search_fail,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)), null);
} catch (IOException e) {
Logger.w(TAG,"label print exception");
afterABookCheckApi(mCmd, "", 1, PatternStringUtil.patternToString(getApplicationContext(),
R.string.msg_location_search_fail,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)), null);
}
}
});
}
protected boolean isOperationPdf() {
return isOperationPdf;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment