| | |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.security.ShiroUtils; |
| | | import com.ruoyi.doublePrevention.entity.PreventRiskDangerInfo; |
| | | import com.ruoyi.doublePrevention.service.RiskService; |
| | | import com.ruoyi.doublePrevention.service.baseService.PreventRiskDangerCheckAndMeasureService; |
| | | import com.ruoyi.doublePrevention.service.baseService.PreventRiskDangerConfirmLogService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.project.mobile.domain.ApiRequestHeader; |
| | | import com.ruoyi.project.mobile.domain.ApiResult; |
| | |
| | | import com.ruoyi.project.tr.hiddenDangerCheck.service.IHiddenDangerCheckService; |
| | | import com.ruoyi.project.tr.hiddenDangerCheckPoint.domain.HiddenDangerCheckPoint; |
| | | import com.ruoyi.project.tr.hiddenDangerCheckPoint.service.IHiddenDangerCheckPointService; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.connection.ReactiveListCommands; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.ui.ModelMap; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | |
| | | IHiddenDangerCheckPointService hdcpService;//隐患检查点Service |
| | | |
| | | @Autowired |
| | | private PreventRiskDangerCheckAndMeasureService riskDangerCheckAndMeasureService;//隐患检查点Service |
| | | |
| | | @Autowired |
| | | IUserService userService;//用户Service |
| | | |
| | | @Autowired |
| | | private RiskService riskService; |
| | | |
| | | @Autowired |
| | | private PreventRiskDangerConfirmLogService confirmLogService; |
| | | |
| | | |
| | | @Autowired |
| | | private IHiddenDangerCheckPointService hiddenDangerCheckPointService; |
| | | |
| | | /** |
| | | * 获取隐患列表 |
| | |
| | | return ApiResult.success("传输hiddenDangerCheckType有误", new ArrayList<HiddenDangerCheck>()); |
| | | } |
| | | List<HiddenDangerCheckPoint> resultList = hdcpService.selectHiddenDangerCheckPointList(hdcp); |
| | | for (HiddenDangerCheckPoint dangerCheckPoint : resultList) { |
| | | PreventRiskDangerInfo dangerInfo = riskService.getDangerInfoByDangerCheckPointId(dangerCheckPoint.getId()); |
| | | if (ObjectUtils.isNotEmpty(dangerInfo)){ |
| | | if (ObjectUtils.isNotEmpty(dangerInfo.getDangerSrc())){ |
| | | dangerCheckPoint.setDangerSrc(dangerInfo.getDangerSrc()); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(dangerInfo.getReportTime())){ |
| | | dangerCheckPoint.setReportTime(dangerInfo.getReportTime()); |
| | | } |
| | | } |
| | | } |
| | | return ApiResult.success("请求数据成功", resultList); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 隐患核查--再次核查 |
| | | */ |
| | | @Transactional |
| | | public ApiResult editNextConfirmSave(String str, ApiRequestHeader header) { |
| | | //验证userId,loginName,token,deviceType,deviceId,appType 是否一致 |
| | | ApiRequestHeader requestHeader = getHeader(header); |
| | | if (!(header.equals(requestHeader))) { |
| | | return ApiResult.errorToken("验证userId,loginName,token,deviceType,deviceId,appType 不一致"); |
| | | } |
| | | try { |
| | | Map<String, String> map = new ObjectMapper().readValue(str, HashMap.class); |
| | | HiddenDangerCheckPoint hdcp = new ObjectMapper().readValue(str, HiddenDangerCheckPoint.class); |
| | | // todo-2022 中间核查,插入多人核查附属表 |
| | | if(ObjectUtils.isEmpty(hdcp.getId())){ |
| | | throw new RuntimeException("id不能为空"); |
| | | } |
| | | // report_status , 上报判定结果(0未判定 1不是隐患 2是隐患) |
| | | // if(ObjectUtils.isEmpty(hdcp.getReportStatus())){ |
| | | // throw new RuntimeException("判定结果不能为空"); |
| | | // } |
| | | // examine_user_id , 核查人id |
| | | if(ObjectUtils.isEmpty(hdcp.getExamineUserId())){ |
| | | throw new RuntimeException("核查人Id不能为空"); |
| | | } |
| | | // examine_user_name |
| | | if(ObjectUtils.isEmpty(hdcp.getExamineUserName())){ |
| | | throw new RuntimeException("核查人姓名不能为空"); |
| | | } |
| | | // examine_opinion 意见 |
| | | // if(ObjectUtils.isEmpty(hdcp.getRectifyDeadlineTime())){ |
| | | // throw new RuntimeException("核查意见不能为空"); |
| | | // } |
| | | int confirmResult = confirmLogService.saveConfirmLog(hdcp); |
| | | if (confirmResult < 1){ |
| | | throw new RuntimeException("操作失败"); |
| | | } |
| | | return ApiResult.success("隐患核查保存成功"); |
| | | } catch (Exception e) { |
| | | return ApiResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | /** |
| | | * 隐患核查--保存 |
| | | */ |
| | | @Transactional |
| | | public ApiResult editDangerExamineSave(String str, ApiRequestHeader header) { |
| | | //验证userId,loginName,token,deviceType,deviceId,appType 是否一致 |
| | | ApiRequestHeader requestHeader = getHeader(header); |
| | |
| | | try { |
| | | Map<String, String> map = new ObjectMapper().readValue(str, HashMap.class); |
| | | HiddenDangerCheckPoint hdcp = new ObjectMapper().readValue(str, HiddenDangerCheckPoint.class); |
| | | // todo-2023 |
| | | hdcp.setUpdateBy(header.loginName); |
| | | hdcp.setUpdateTime(DateUtils.getNowDate()); |
| | | hdcp.setExamineCreateTime(DateUtils.getNowDate());//设置核查时间 |
| | |
| | | hdcp.setWhetherDanger(TrHiddenDangerCheckConstants.WHETHER_DANGER_NOT);//是否为隐患(正常) |
| | | } |
| | | } |
| | | |
| | | hdcpService.updateHiddenDangerCheckPoint(hdcp); |
| | | //20250623 修改此处 |
| | | PreventRiskDangerInfo dangerInfoByDangerCheckPointId = riskService.getDangerInfoByDangerCheckPointId(hdcp.getId()); |
| | | if (ObjectUtils.isNotEmpty(dangerInfoByDangerCheckPointId)){ |
| | | //此处插入隐患附属表 |
| | | int result = riskService.updateDangerInfo(hdcp); |
| | | if (result < 1){ |
| | | throw new RuntimeException("修改失败"); |
| | | } |
| | | }else { |
| | | //此处插入隐患附属表 |
| | | int result = riskService.insertDangerInfo(hdcp.getId(), hdcp); |
| | | if (result < 1){ |
| | | throw new RuntimeException("添加隐患附属信息失败"); |
| | | } |
| | | } |
| | | // //此处插入隐患附属表 |
| | | // int result = riskService.updateCheckLog(hdcp.getId(), hdcp); |
| | | // if (result< 1){ |
| | | // throw new RuntimeException("添加隐患附属信息失败"); |
| | | // } |
| | | |
| | | |
| | | HiddenDangerCheckPoint hiddenDangerCheckPoint = hiddenDangerCheckPointService.getHiddenDangerCheckPointById(hdcp.getId()); |
| | | int confirmResult = confirmLogService.saveConfirmLog(hiddenDangerCheckPoint); |
| | | if (confirmResult < 1){ |
| | | throw new RuntimeException("操作失败"); |
| | | } |
| | | |
| | | hdcpService.getTaskCountTotal(Long.valueOf(header.userId));//查询未执行任务总数量并推送 |
| | | |
| | | return ApiResult.success("隐患核查保存成功"); |
| | | } catch (Exception e) { |
| | | return ApiResult.error("异常"); |
| | | return ApiResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 隐患整改--保存 |
| | | */ |
| | | @Transactional |
| | | public ApiResult editDangerRectifySave(String str, ApiRequestHeader header) { |
| | | //验证userId,loginName,token,deviceType,deviceId,appType 是否一致 |
| | | ApiRequestHeader requestHeader = getHeader(header); |
| | |
| | | |
| | | hdcpService.getTaskCountTotal(Long.valueOf(header.userId));//查询未执行任务总数量并推送 |
| | | |
| | | // todo-2022 隐患信息附属表 |
| | | int result = riskService.updateDangerInfoRectify(hdcp); |
| | | if (result < 1){ |
| | | throw new RuntimeException("整改信息保存失败"); |
| | | } |
| | | return ApiResult.success("隐患整改保存成功"); |
| | | } catch (Exception e) { |
| | | return ApiResult.error("异常"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 隐患验收--保存 |
| | | * 整改延期--保存 |
| | | */ |
| | | public ApiResult editDangerAcceptSave(String str, ApiRequestHeader header) { |
| | | @Transactional |
| | | public ApiResult rectifyTimeOutSave(String str, ApiRequestHeader header) { |
| | | //验证userId,loginName,token,deviceType,deviceId,appType 是否一致 |
| | | ApiRequestHeader requestHeader = getHeader(header); |
| | | if (!(header.equals(requestHeader))) { |
| | |
| | | HiddenDangerCheckPoint hdcp = new ObjectMapper().readValue(str, HiddenDangerCheckPoint.class); |
| | | hdcp.setUpdateBy(header.loginName); |
| | | hdcp.setUpdateTime(DateUtils.getNowDate()); |
| | | |
| | | int result = hdcpService.rectifyTimeOut(hdcp.getId(), hdcp.getRectifyDeadlineTime()); |
| | | if (result < 1) { |
| | | return ApiResult.error("延期失败"); |
| | | } |
| | | |
| | | return ApiResult.success("延期成功"); |
| | | } catch (Exception e) { |
| | | return ApiResult.error("异常"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 隐患验收--保存 |
| | | */ |
| | | @Transactional |
| | | public ApiResult editDangerAcceptSave(String str, ApiRequestHeader header) { |
| | | //验证userId,loginName,token,deviceType,deviceId,appType 是否一致 |
| | | ApiRequestHeader requestHeader = getHeader(header); |
| | | if (!(header.equals(requestHeader))) { |
| | | return ApiResult.errorToken("验证userId,loginName,token,deviceType,deviceId,appType 不一致"); |
| | | } |
| | | try { |
| | | new ObjectMapper().readValue(str, HiddenDangerCheckPoint.class); |
| | | HiddenDangerCheckPoint hdcp = new ObjectMapper().readValue(str, HiddenDangerCheckPoint.class); |
| | | hdcp.setUpdateBy(header.loginName); |
| | | hdcp.setUpdateTime(DateUtils.getNowDate()); |
| | | if (ObjectUtils.isEmpty(hdcp.getAcceptCreateTime())){ |
| | | throw new RuntimeException("请填写验收时间"); |
| | | } |
| | | if (!StringUtils.isEmpty(hdcp.getAcceptResult())) { |
| | | //验收结果 (0不通过 打回上一级整改阶段 1通过) |
| | | if ("0".equals(hdcp.getAcceptResult())) { |
| | | hdcp.setAcceptCreateTime(DateUtils.getNowDate());//设置验收时间 |
| | | hdcp.setAcceptCreateTime(hdcp.getAcceptCreateTime());//设置验收时间 |
| | | hdcp.setStage(TrHiddenDangerCheckConstants.DANGER_STAGE_PLAN_RECTIFY);//隐患整改阶段(数据进入到隐患整改阶段) |
| | | hdcp.setRectifyStatus(TrHiddenDangerCheckConstants.RECTIFY_STATUS_NOT_RECTIFY);//整改状态(未整改) |
| | | hdcp.setAcceptStatus(TrHiddenDangerCheckConstants.ACCEPT_STATUS_ALREADY_ACCEPT_NOT_PASS);//验收状态(验收未通过) |
| | | } else if ("1".equals(hdcp.getAcceptResult())) { |
| | | hdcp.setAcceptCreateTime(DateUtils.getNowDate());//设置验收时间 |
| | | hdcp.setAcceptCreateTime(hdcp.getAcceptCreateTime());//设置验收时间 |
| | | hdcp.setAcceptStatus(TrHiddenDangerCheckConstants.ACCEPT_STATUS_ALREADY_ACCEPT_PASS);//验收状态(验收通过) |
| | | } |
| | | } |
| | | hdcpService.updateHiddenDangerCheckPoint(hdcp); |
| | | |
| | | hdcpService.getTaskCountTotal(Long.valueOf(header.userId));//查询未执行任务总数量并推送 |
| | | |
| | | // todo-2022 验收通过,修改为已验收状态 |
| | | int result = riskService.updateDangerInfoAccept(hdcp); |
| | | if (result < 1){ |
| | | throw new RuntimeException("隐患验收信息保存失败"); |
| | | } |
| | | |
| | | return ApiResult.success("隐患验收保存成功"); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | try { |
| | | HiddenDangerCheckPoint hdcp = new ObjectMapper().readValue(str, HiddenDangerCheckPoint.class); |
| | | if (ObjectUtils.isEmpty(hdcp.getCheckPerson())){ |
| | | throw new RuntimeException("检查人不能为空"); |
| | | } |
| | | if (ObjectUtils.isEmpty(hdcp.getFindTime())){ |
| | | throw new RuntimeException("发现时间不能为空"); |
| | | } |
| | | hdcp.setRegisterCreateTime(DateUtils.getNowDate());//设置隐患登记上报创建时间 |
| | | hdcp.setRegisterUserId(Long.valueOf(header.userId));//设置隐患登记上报创建人ID |
| | | User user = userService.selectUserById(Long.valueOf(header.userId)); |
| | |
| | | |
| | | hdcp.setCompanyId(user.getCompanyId()); |
| | | i = hdcpService.insertHiddenDangerCheckPoint(hdcp); |
| | | //20250623增加此逻辑 |
| | | 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); |
| | | //20250623增加此逻辑 |
| | | int result = riskService.updateDangerInfo(hdcp); |
| | | if (result < 1){ |
| | | throw new RuntimeException("修改失败"); |
| | | } |
| | | } |
| | | |
| | | hdcpService.getTaskCountTotal(Long.valueOf(header.userId));//查询未执行任务总数量并推送 |
| | |
| | | try { |
| | | HiddenDangerCheckPoint hdcp = new ObjectMapper().readValue(str, HiddenDangerCheckPoint.class); |
| | | HiddenDangerCheckPoint hiddenDangerCheckPoint = hdcpService.selectHiddenDangerCheckPointById(hdcp.getId()); |
| | | PreventRiskDangerInfo dangerInfo = riskService.getDangerInfoByDangerCheckPointId(hiddenDangerCheckPoint.getId()); |
| | | if (ObjectUtils.isNotEmpty(dangerInfo.getReportTime())){ |
| | | hiddenDangerCheckPoint.setReportTime(dangerInfo.getReportTime()); |
| | | } |
| | | return ApiResult.success("隐患查看--成功",hiddenDangerCheckPoint); |
| | | } catch (Exception e) { |
| | | return ApiResult.error("异常"); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (HiddenDangerCheckPoint dangerCheckPoint : resultList) { |
| | | PreventRiskDangerInfo dangerInfo = riskService.getDangerInfoByDangerCheckPointId(dangerCheckPoint.getId()); |
| | | if (ObjectUtils.isNotEmpty(dangerInfo)){ |
| | | if (ObjectUtils.isNotEmpty(dangerInfo.getReportTime())){ |
| | | dangerCheckPoint.setReportTime(dangerInfo.getReportTime()); |
| | | } |
| | | } |
| | | } |
| | | resultMap.put("resultList", resultList); |
| | | |
| | | //companyId下总的数据统计 |
| | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | } |