From 28f6c716269ce5435b103137dd7ec1f1f9ab19ba Mon Sep 17 00:00:00 2001
From: 16639036659 <577530412@qq.com>
Date: Mon, 26 Jun 2023 09:16:56 +0800
Subject: [PATCH] 临时提交-已经与app端对接完成
---
src/main/java/com/ruoyi/project/mobile/service/ApiDangerScheduleService.java | 45 ++++++++++++++++++++++++++++++++++++++-------
1 files changed, 38 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/ruoyi/project/mobile/service/ApiDangerScheduleService.java b/src/main/java/com/ruoyi/project/mobile/service/ApiDangerScheduleService.java
index 95c1949..ac26a21 100644
--- a/src/main/java/com/ruoyi/project/mobile/service/ApiDangerScheduleService.java
+++ b/src/main/java/com/ruoyi/project/mobile/service/ApiDangerScheduleService.java
@@ -7,7 +7,10 @@
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
+import com.ruoyi.doublePrevention.entity.PreventRiskDangerCheckAndMeasure;
+import com.ruoyi.doublePrevention.entity.PreventRiskDangerCheckLog;
import com.ruoyi.doublePrevention.service.RiskService;
+import com.ruoyi.doublePrevention.service.baseService.PreventRiskDangerCheckAndMeasureService;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.mobile.domain.ApiRequestHeader;
import com.ruoyi.project.mobile.domain.ApiResult;
@@ -22,6 +25,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.HashMap;
@@ -46,6 +50,8 @@
@Autowired
private RiskService riskService;
+ @Autowired
+ private PreventRiskDangerCheckAndMeasureService preventRiskDangerCheckAndMeasureService;
/**
* 获取定时任务隐患列表
*
@@ -97,7 +103,7 @@
/**
- * 定时隐患排查保存
+ * 定时隐患排查保存 -- todo
*/
public ApiResult editDangerScheduleSave(String str, ApiRequestHeader header) {
//验证userId,loginName,token,deviceType,deviceId,appType 是否一致
@@ -138,7 +144,6 @@
});
-
hiddenDangerCheckService.updateHiddenDangerCheck(hiddenDangerCheck);
hdcpService.getTaskCountTotal(Long.valueOf(header.userId));//查询未执行任务总数量并推送
@@ -153,7 +158,7 @@
/**
- * 设置为记录正常
+ * 设置为记录正常 // todo
*/
public ApiResult editPointScheduleSetNormal(String str, ApiRequestHeader header) {
//验证userId,loginName,token,deviceType,deviceId,appType 是否一致
@@ -168,6 +173,12 @@
hdcp.setWhetherDanger(TrHiddenDangerCheckConstants.WHETHER_DANGER_NOT);//是否为隐患(正常)
hdcp.setScheduleCheckStatus(TrHiddenDangerCheckConstants.CHECK_STATUS_ALREADY_CHECK);//排查状态(已排查)
hdcpService.updateHiddenDangerCheckPoint(hdcp);
+
+ PreventRiskDangerCheckAndMeasure dangerCheckPointInfo = preventRiskDangerCheckAndMeasureService.getByDangerCheckPointId(hdcp.getId());
+ int result = riskService.updateCheckLog(dangerCheckPointInfo.getCheckId(), hdcp);// todo
+ if (result < 1){
+ return ApiResult.error("隐患排查记录附属表:写入手机识别码错误");
+ }
hdcpService.getTaskCountTotal(Long.valueOf(header.userId));//查询未执行任务总数量并推送
@@ -209,8 +220,15 @@
queryExist.setWhetherDanger(TrHiddenDangerCheckConstants.WHETHER_DANGER_YES);//是否为隐患(是隐患)
queryExist.setCheckPointId(hdcp.getCheckPointId());
queryExist.setCheckId(hdcp.getCheckId());
+
+ /**
+ * 本次查询结果 :如果未上报过隐患,必定为空
+ * 同一个检查任务,同一个排查点,可能多次上报隐患。
+ * 本次查询未用到id,导致数据不唯一
+ * */
List<HiddenDangerCheckPoint> queryExistList = hdcpService.selectHiddenDangerCheckPointList(queryExist);
int i=0;
+ //如果隐患信息已经存在,就新插入一条;如果不存在,就修改隐患信息
if(queryExistList.size()>0){
hdcp.setId(null);
hdcp.setCheckTime(DateUtils.getNowDate());
@@ -219,6 +237,9 @@
hdcp.setCompanyId(user.getCompanyId());
i = hdcpService.insertHiddenDangerCheckPoint(hdcp);
+ if (i< 1){
+ throw new RuntimeException("添加隐患附属信息失败");
+ }
// todo-2022 此处插入附属表
//获取Id返回值
@@ -228,16 +249,26 @@
throw new RuntimeException("添加隐患附属信息失败");
}
+ PreventRiskDangerCheckAndMeasure dangerCheckPointInfo = preventRiskDangerCheckAndMeasureService.getByDangerCheckPointId(hdcp.getId());
+ riskService.updateCheckLog(dangerCheckPointInfo.getCheckId(), hdcp);
+
}else{
hdcp.setUpdateBy(user.getLoginName());
hdcp.setUpdateTime(DateUtils.getNowDate());
i = hdcpService.updateHiddenDangerCheckPoint(hdcp);
- // todo-2022 此处修改附属表
- int result = riskService.updateDangerInfo(hdcp);
- if (result < 1){
- throw new RuntimeException("修改失败");
+ // todo-2022 此处修改附属表,注释:
+// int result = riskService.updateDangerInfo(hdcp);
+// if (result < 1){
+// throw new RuntimeException("修改失败");
+// }
+ int result = riskService.insertDangerInfo(hdcp.getId(), hdcp);
+ if (result< 1){
+ throw new RuntimeException("添加隐患附属信息失败");
}
+
+ PreventRiskDangerCheckAndMeasure dangerCheckPointInfo = preventRiskDangerCheckAndMeasureService.getByDangerCheckPointId(hdcp.getId());
+ riskService.updateCheckLog(dangerCheckPointInfo.getCheckId(), hdcp);
}
hdcpService.getTaskCountTotal(Long.valueOf(header.userId));//查询未执行任务总数量并推送
--
Gitblit v1.9.2