Commit 9922d073 by Kazuyuki Hida

Merge branch 'feature/contract/sato/1.0.300_52170_unlock_icon2' into 'contract/sato/1.0.300'

いろいろな不具合を修正

See merge request !299
parents 7a5fdf31 00fe6ff1
...@@ -533,4 +533,22 @@ public class TaskReportDao extends AbstractDao { ...@@ -533,4 +533,22 @@ public class TaskReportDao extends AbstractDao {
} }
return count > 0; return count > 0;
} }
public boolean isWorking(String taskKey, int taskReportId, String reportStartDate) {
int count;
StringBuilder sql = new StringBuilder();
sql.append("SELECT count(*) FROM t_task_report");
sql.append(" WHERE task_status = 1 ");
if (reportStartDate == null) {
// 報告
sql.append(" AND task_key=?");
count = rawQueryGetInt(sql.toString(), new String[] { taskKey });
} else {
// 点検
sql.append(" AND task_report_id=?");
sql.append(" AND datetime(report_start_date)=datetime(?, 'utc')");
count = rawQueryGetInt(sql.toString(), new String[] { String.valueOf(taskReportId), reportStartDate });
}
return count > 0;
}
} }
...@@ -65,6 +65,7 @@ import jp.agentec.adf.util.DateTimeUtil; ...@@ -65,6 +65,7 @@ import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.FileUtil; import jp.agentec.adf.util.FileUtil;
import jp.agentec.adf.util.StringUtil; import jp.agentec.adf.util.StringUtil;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.Task;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON.OperationEndDate; import static jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON.OperationEndDate;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON.OperationStartDate; import static jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON.OperationStartDate;
...@@ -949,7 +950,7 @@ public class OperationLogic extends AbstractLogic { ...@@ -949,7 +950,7 @@ public class OperationLogic extends AbstractLogic {
if (!routineTaskFlg) { if (!routineTaskFlg) {
String jsonText = FileUtil.readTextFile(contentPath + "/" + ABookKeys.TASK_REPORT + ".json"); String jsonText = FileUtil.readTextFile(contentPath + "/" + ABookKeys.TASK_REPORT + ".json");
JSONObject jsonObject = new JSONObject(jsonText); JSONObject jsonObject = new JSONObject(jsonText);
JSONArray taskReportJsonArray = jsonObject.getJSONArray(ABookKeys.KEY_TASK_REPORT_0); JSONArray taskReportJsonArray = jsonObject.has(ABookKeys.KEY_TASK_REPORT_0) ? jsonObject.getJSONArray(ABookKeys.KEY_TASK_REPORT_0) : new JSONArray();
for (int i = 0; i < taskReportJsonArray.length(); i++) { for (int i = 0; i < taskReportJsonArray.length(); i++) {
JSONObject taskReportJsonObject = taskReportJsonArray.getJSONObject(i); JSONObject taskReportJsonObject = taskReportJsonArray.getJSONObject(i);
String taskKey = taskReportJsonObject.getString(ABookKeys.TASK_KEY); String taskKey = taskReportJsonObject.getString(ABookKeys.TASK_KEY);
...@@ -1498,7 +1499,17 @@ public class OperationLogic extends AbstractLogic { ...@@ -1498,7 +1499,17 @@ public class OperationLogic extends AbstractLogic {
} }
throw ex; throw ex;
} catch (Exception ex) { } catch (Exception ex) {
Logger.e(TAG, ex);
if (ex instanceof NetworkDisconnectedException) {
// オフラインの場合、エラー扱いにしないで、設問の状況から、taskStatusを推測する
taskReportDto.taskStatus = recoveryTaskStatus(taskReportDto.jsonData);
taskReportDto.dataSendFlg = true;
mTaskReportDao.update(taskReportDto);
// CMSへの送信は打ち切り
return;
} else {
throw ex; throw ex;
}
} finally { } finally {
if (zipFile != null) { if (zipFile != null) {
zipFile.delete(); zipFile.delete();
...@@ -1522,6 +1533,27 @@ public class OperationLogic extends AbstractLogic { ...@@ -1522,6 +1533,27 @@ public class OperationLogic extends AbstractLogic {
} }
} }
private int recoveryTaskStatus(String taskReportInfo) {
JSONObject jsonObject = new JSONObject(taskReportInfo);
JSONObject taskObject = jsonObject.getJSONObject(Task);
Iterator<String> keys = taskObject.keys();
while (keys.hasNext()) {
String key = keys.next();
if (key.startsWith("q_3_")) { // 状況入力欄
try {
int taskStatus = Integer.parseInt(taskObject.getString(key));
if (taskStatus != 0 && taskStatus != 999) {
taskStatus = 1;
}
return taskStatus;
} catch (Throwable ignored) {
return 0;
}
}
}
return 0;
}
/** /**
* 作業関連ディレクトリ削除 * 作業関連ディレクトリ削除
* *
......
...@@ -27,7 +27,7 @@ public class UnlockReportLogic extends AbstractLogic { ...@@ -27,7 +27,7 @@ public class UnlockReportLogic extends AbstractLogic {
public Result unlock(String taskKey, Long taskReportId, Date reportStartDate) { public Result unlock(String taskKey, Long taskReportId, Date reportStartDate) {
Result r = sendUnlockReport(taskKey, taskReportId, reportStartDate); Result r = sendUnlockReport(taskKey, taskReportId, reportStartDate);
if (r.result == 0) { if (r.result == 0 || r.extParam.reportStatus == 3) {
updateLocalDB(taskKey, taskReportId, reportStartDate, r.extParam.getReportStatus()); updateLocalDB(taskKey, taskReportId, reportStartDate, r.extParam.getReportStatus());
} }
return r; return r;
......
...@@ -90,8 +90,10 @@ import jp.agentec.adf.util.FileUtil; ...@@ -90,8 +90,10 @@ import jp.agentec.adf.util.FileUtil;
import jp.agentec.adf.util.StringUtil; import jp.agentec.adf.util.StringUtil;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.Message; import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.Message;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStartDate;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStatus; import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStatus;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.TaskKey; import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.TaskKey;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.TaskReportId;
public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
...@@ -990,7 +992,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -990,7 +992,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
try { try {
logic.createJsonForOperationContent(operationDto.operationId, mContentPath, operationDto.reportType == Constant.ReportType.RoutineTask); logic.createJsonForOperationContent(operationDto.operationId, mContentPath, operationDto.reportType == Constant.ReportType.RoutineTask);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); Logger.e(TAG, e.getLocalizedMessage());
} }
// コールバック // コールバック
ReportStatusLogic.TaskReportExtParam extParam = ReportStatusLogic.TaskReportExtParam.pick(); ReportStatusLogic.TaskReportExtParam extParam = ReportStatusLogic.TaskReportExtParam.pick();
...@@ -1121,8 +1123,11 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1121,8 +1123,11 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// アンロック // アンロック
UnlockReportLogic.Result r = UnlockReportLogic.newInstance().unlock(taskKey, taskReportId, startDate); UnlockReportLogic.Result r = UnlockReportLogic.newInstance().unlock(taskKey, taskReportId, startDate);
// JSコールバック // JSコールバック
// アンロックの失敗は無視 JSONObject extParam = new JSONObject();
afterABookCheckApi(mCmd, mTaskKey, 0, "", "{'reportStatus':0}"); extParam.put(ReportStatus, 0);
extParam.put(TaskReportId, taskReportId);
extParam.put(ReportStartDate, DateTimeUtil.toStringInTimeZone(startDate, DateTimeFormat.yyyyMMddHHmmss_hyphen, "UTC"));
afterABookCheckApi(mCmd, mTaskKey, 0, "", extParam.toString());
} }
} }
......
...@@ -98,21 +98,27 @@ public class ABookCheckWebViewHelper extends ABookHelper { ...@@ -98,21 +98,27 @@ public class ABookCheckWebViewHelper extends ABookHelper {
case ABookKeys.CMD_UPDATE_TASK_REPORT: { case ABookKeys.CMD_UPDATE_TASK_REPORT: {
// もとから作業中だったかを調べる // もとから作業中だったかを調べる
TaskReportDao taskReportDao = AbstractDao.getDao(TaskReportDao.class); TaskReportDao taskReportDao = AbstractDao.getDao(TaskReportDao.class);
int rportId = Integer.parseInt(String.valueOf(param.getOrDefault(TaskReportId, "0"))); int reportId = Integer.parseInt(String.valueOf(param.getOrDefault(TaskReportId, "0")));
String startDate = param.getOrDefault(ReportStartDate, null); String startDate = param.getOrDefault(ReportStartDate, null);
boolean isLocalSaved = taskReportDao.isLocalSaved(taskKey, rportId, startDate); boolean isLocalSaved = taskReportDao.isLocalSaved(taskKey, reportId, startDate);
boolean isCompleted = taskReportDao.isCompleted(taskKey, rportId, startDate); boolean isCompleted = taskReportDao.isCompleted(taskKey, reportId, startDate);
boolean isWorking = taskReportDao.isWorking(taskKey, reportId, startDate);
// 報告書の更新 // 報告書の更新
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, reportType, taskReportLevel, false); insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, reportType, taskReportLevel, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel); copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
sendTaskData(context, operationId, taskKey, taskReportLevel); sendTaskData(context, operationId, taskKey, taskReportLevel);
// 作業ステータスのカウントを変える // 作業ステータスのカウントを変える todo:要リファクタリング(直すのはともかく動作確認する時間が惜しい)
OperationDao operationDao = AbstractDao.getDao(OperationDao.class); OperationDao operationDao = AbstractDao.getDao(OperationDao.class);
if (isLocalSaved) { if (isLocalSaved) {
operationDao.coutUpCompletedFromWorking(operationId); operationDao.coutUpCompletedFromWorking(operationId);
} else if (! isCompleted) { } else if (! isCompleted) {
boolean nowWorking = taskReportDao.isWorking(taskKey, reportId, startDate);
if (!isWorking && nowWorking) {
operationDao.countUpWorking(operationId);
} else {
operationDao.countUpCompleted(operationId); operationDao.countUpCompleted(operationId);
} }
}
break; break;
} }
case ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT: // 一時保存 case ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT: // 一時保存
......
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