Commit 80a7f367 by Kim Jinsung

Bug #36065【アプリ】【And】日付が変わってから報告タイプの作業を開くと前日の報告が一覧表示されていて編集も可能

parent 6ae8c30f
......@@ -131,4 +131,11 @@ public class ABookKeys {
public static final String TASK_DEVICE_TYPE_PARAM1 = "param1"; // CMSのインターフェースのパラメータ:param1 (デバイスID)
public static final String TASK_DEVICE_TYPE_PARAM2 = "param2"; // CMSのインターフェースのパラメータ:param2(1:温度、2:湿度)
public static final String KEY_TASK_REPLY = "taskReply";
public static final String KEY_QUESTION_NO = "questionNo";
public static final String KEY_VALUE = "value";
public static final String KEY_TASK_REPORT_0 = "taskReport_0";
}
......@@ -24,6 +24,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.SceneEntryJSON;
import jp.agentec.abook.abv.bl.acms.client.json.WorkerGroupJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetTaskFileParameters;
import jp.agentec.abook.abv.bl.acms.type.OperationType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.Callback;
......@@ -852,10 +853,32 @@ public class OperationLogic extends AbstractLogic {
* @throws IOException
*/
public void createHopSpotJson(Long operationId, String contentPath) throws IOException {
OperationDto operationDto = mOperationDao.getOperation(operationId);
//営業日変更時間チェックにより、除外されたhotsport情報作成しない。
boolean routineTaskFlg = operationDto.reportType == Constant.ReportType.RoutineTask ? true : false;
List<String> taskKeyArray = new ArrayList<String>();
if (!routineTaskFlg) {
String jsonText = FileUtil.readTextFile(contentPath + "/" + ABookKeys.TASK_REPORT + ".json");
JSONObject jsonObject = new JSONObject(jsonText);
JSONArray taskReportJsonArray = jsonObject.getJSONArray(ABookKeys.KEY_TASK_REPORT_0);
for (int i = 0; i < taskReportJsonArray.length(); i++) {
JSONObject taskReportJsonObject = taskReportJsonArray.getJSONObject(i);
String taskKey = taskReportJsonObject.getString(ABookKeys.TASK_KEY);
if (taskKey != null) {
taskKeyArray.add(taskKey);
}
}
}
List<JSONObject> taskJsonList = new ArrayList<JSONObject>();
JSONObject hotspotJson = new JSONObject();
List<TaskDto> taskDtoList = mTaskDao.selectTaskByOperationId(operationId);
for (TaskDto dto : taskDtoList) {
if (!routineTaskFlg && !taskKeyArray.contains(dto.taskKey)) {
continue;
}
if (!StringUtil.isNullOrEmpty(dto.taskHotSpotInfo)) {
JSONObject taskHotSpot = new JSONObject(dto.taskHotSpotInfo);
taskHotSpot.put(OperationDataJSON.TaskCode, dto.taskCode);
......@@ -893,8 +916,12 @@ public class OperationLogic extends AbstractLogic {
}
if(dto.jsonData != null && dto.jsonData.length() > 0) {
JSONObject editJson = new JSONObject(dto.jsonData);
//営業日変更時間チェックを行う
if (checkWorkdayChangeTime(editJson)) {
continue;
}
if (operationDto.reportType == Constant.ReportType.ReportReply) {
JSONObject editJson = new JSONObject(dto.jsonData);
editJson.put(ABookKeys.HAS_AUTHORITY, dto.enableReport);
editJson.put(ABookKeys.LOCAL_SAVE_FLG, dto.localSavedFlg);
taskReportJsonList.add(editJson);
......@@ -910,13 +937,13 @@ public class OperationLogic extends AbstractLogic {
}
taskReportJsonList.add(emptyTaskReportJson);
}
// 最後の時、taskReport_{level}でセット
if (listCount == taskReportDtoList.size()) {
taskReportJson.put(String.format("taskReport_%s", String.valueOf(level)), taskReportJsonList);
}
}
// データが存在しない場合、
if (taskReportDtoList.size() <= 0) {
taskReportJson.put("taskReport_0", taskReportJsonList);
......@@ -929,6 +956,76 @@ public class OperationLogic extends AbstractLogic {
}
/**
* 営業日変更時間と報告日時をチェックし、営業日変更時間が過ぎた場合、報告表示しないように処理
* @param jsonObject 報告回答のJson文字列
* @return true: 報告非表示、false:報告表示
*/
private boolean checkWorkdayChangeTime(JSONObject jsonObject) {
JSONArray taskReplyArray = jsonObject.getJSONArray(ABookKeys.KEY_TASK_REPLY);
boolean workdayChangeTimeflg = true;
for (int i = 0; i < taskReplyArray.length(); i++) {
JSONObject taskReplyJSONObject = taskReplyArray.getJSONObject(i);
String pageNo = taskReplyJSONObject.getString(ABookKeys.KEY_QUESTION_NO);
if (pageNo.equals("6")) {
//報告日付を取得し、Date型に変換
String createReportDateStr = taskReplyJSONObject.getString(ABookKeys.KEY_VALUE);
Date createReportDate = DateTimeUtil.toDate(createReportDateStr, "Asia/Tokyo", DateTimeFormat.yyyyMMddHHmm_hyphen);
//チェック用の営業日変更開始日取得
Date workdayStartChangeDate = workdayChangeDateStartDate();
if (createReportDate == null || workdayStartChangeDate == null) {
Logger.e(TAG, "checkWorkdayChangeTime createReportDate or workdayStartChangeDate null");
return false;
}
//チェック用の営業日変更終了日計算
Calendar calendar = Calendar.getInstance(); // creates calendar
calendar.setTime(workdayStartChangeDate); // sets calendar time/date
int day = calendar.get(Calendar.DATE);
calendar.set(Calendar.DATE, day + 1);
Date workdayEndChangeDate = calendar.getTime();
//作業報告作成日が営業日変更開始日と終了日の間にあるかチェック
if (workdayStartChangeDate.compareTo(createReportDate) == 0 ||
(workdayStartChangeDate.before(createReportDate) && workdayEndChangeDate.after(createReportDate))) {
workdayChangeTimeflg = false;
}
}
}
return workdayChangeTimeflg;
}
/**
* 営業日変更時間を元にして営業日変更開始日を計算
* @return 営業日変更開始日
*/
private Date workdayChangeDateStartDate() {
String operationChangeTime = ABVDataCache.getInstance().serviceOption.operationChangeTime();
String[] timeArray = operationChangeTime.split(":", 0);
if (timeArray.length != 2) { //データ形式が異常
return null;
}
// 営業日変更時間
int hour = Integer.valueOf(timeArray[0]); //時間
int minute = Integer.valueOf(timeArray[1]); //分
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date workdayStartChangeDate = calendar.getTime();
if (hour != 0) { //「00:00」以外設定時
Date nowDate = new Date();
if (nowDate.before(workdayStartChangeDate)) {
int day = calendar.get(Calendar.DATE);
calendar.set(Calendar.DATE, day - 1);
workdayStartChangeDate = calendar.getTime();
}
}
return workdayStartChangeDate;
}
/**
* 定期点検用のJSON作成
* @param operationId
* @param contentPath
......@@ -1064,12 +1161,6 @@ public class OperationLogic extends AbstractLogic {
if (StringUtil.isNullOrEmpty(operationDto.reportPeriod)) {
updateFlg = true;
}
} else {
// 定期点検以外
// 同期処理を行った日付が営業日を超えているかチェック
if (syncedDate != null && checkServiceOptionOperaionChangeTime(syncedDate)) {
updateFlg = true;
}
}
if (updateFlg) {
......
......@@ -164,7 +164,9 @@ public class DateTimeUtil {
SimpleDateFormat sdf = new SimpleDateFormat(format);
sdf.setTimeZone(TimeZone.getTimeZone(timeZone));
dt = new Date(sdf.parse(time).getTime());
} catch (Exception e) {}
} catch (Exception e) {
Logger.e(e.toString());
}
}
return dt;
......
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