双重预防项目-国泰新华二开定制版
Your Name
2022-11-11 b47b351ba838b9ca0c70fae7cc3a64d4026e7356
src/main/java/com/ruoyi/project/mobile/service/ApiDangerScheduleService.java
@@ -7,6 +7,7 @@
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.doublePrevention.service.RiskService;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.mobile.domain.ApiRequestHeader;
import com.ruoyi.project.mobile.domain.ApiResult;
@@ -20,6 +21,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
@@ -40,6 +42,9 @@
    @Autowired
    IUserService userService;//用户Service
    @Autowired
    private RiskService riskService;
    /**
     * 获取定时任务隐患列表
@@ -176,7 +181,9 @@
    /**
     * 定时隐患排查---隐患登记
     * todo-2022 手机端-暂时未改动
     */
    @Transactional
    public ApiResult editPointScheduleDangerRegisterSave(String str, ApiRequestHeader header) {
        //验证userId,loginName,token,deviceType,deviceId,appType 是否一致
        ApiRequestHeader requestHeader = getHeader(header);
@@ -202,8 +209,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());
@@ -212,10 +226,32 @@
                hdcp.setCompanyId(user.getCompanyId());
                i = hdcpService.insertHiddenDangerCheckPoint(hdcp);
                if (i< 1){
                    throw new RuntimeException("添加隐患附属信息失败");
                }
                // todo-2022 此处插入附属表
                //获取Id返回值
                hdcp.getId();
                int result = riskService.insertDangerInfo(hdcp.getId(), hdcp);
                if (result< 1){
                    throw new RuntimeException("添加隐患附属信息失败");
                }
            }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("修改失败");
//                }
                int result = riskService.insertDangerInfo(hdcp.getId(), hdcp);
                if (result< 1){
                    throw new RuntimeException("添加隐患附属信息失败");
                }
            }
            hdcpService.getTaskCountTotal(Long.valueOf(header.userId));//查询未执行任务总数量并推送