package com.ruoyi.project.tr.hiddenDangerCheck.controller; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.project.tr.hiddenDangerCheckPoint.domain.BaseCheckPointDTO; import com.ruoyi.project.tr.hiddenDangerCheckPoint.domain.HiddenDangerCheckPoint; import com.ruoyi.project.tr.hiddenDangerCheckPoint.domain.RiskCheckPointDTO; import com.ruoyi.project.tr.hiddenDangerCheckPoint.service.IHiddenDangerCheckPointService; import com.ruoyi.project.tr.riskCheckPoint.domain.RiskCheckPoint; import com.ruoyi.project.tr.riskCheckPoint.service.IRiskCheckPointService; import com.ruoyi.project.tr.riskEvaluationPlan.domain.RiskEvaluationPlan; import com.ruoyi.project.tr.riskEvaluationPlan.service.IRiskEvaluationPlanService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; import java.util.*; /** * 隐患排查基础Controller * * @date 2020-05-08 */ @Controller @RequestMapping("/tr/hiddenDangerCheck/dangerBase") public class DangerBaseController extends BaseController { private String prefix = "tr/hiddenDangerCheck/dangerBase"; @Autowired private IRiskEvaluationPlanService riskEvaluationPlanService; @Autowired private IRiskCheckPointService riskCheckPointService; @Autowired private IHiddenDangerCheckPointService hiddenDangerCheckPointService; /** * 查询风险单元的检查点列表 */ @PostMapping("/getCheckPointByRiskId") @ResponseBody public TableDataInfo getCheckPointByRiskId(RiskCheckPoint riskCheckPoint, Long riskId) { //查询该风险单元最近的评价计划 RiskEvaluationPlan plan = riskEvaluationPlanService.getRiskEvaluationPlanByRecent(riskId); if (plan == null) { return getDataTable(new ArrayList()); } //分页查询检查点 startPage(); RiskCheckPoint checkPoint = new RiskCheckPoint(); checkPoint.setPlanId(plan.getPlanId()); List checkPointList = riskCheckPointService.selectRiskCheckPointList(checkPoint); return getDataTable(checkPointList); } /** * 根据隐患排查checkId获取风险单元下的检查点 */ @PostMapping("/selectRiskCheckPointListByCheckId") @ResponseBody public TableDataInfo selectRiskCheckPointListByCheckId(RiskCheckPointDTO riskCheckPointDTO) { List list = hiddenDangerCheckPointService.selectRiskCheckPointListByCheckId(riskCheckPointDTO); return getDataTable(list); } /** * 根据隐患排查checkId获取风险单元下的检查点,并合并检查内容相同的行 */ @PostMapping("/selectRiskCheckPointListByCheckIdAndMergeSamePoint") @ResponseBody public TableDataInfo selectRiskCheckPointListByCheckIdAndMergeSamePoint(RiskCheckPointDTO riskCheckPointDTO) { List list = hiddenDangerCheckPointService.selectRiskCheckPointListByCheckId(riskCheckPointDTO); List listLast = new ArrayList<>(); Set checkPointIds = new HashSet(); for (int i = 0; i < list.size(); i++) { if ("0".equals(list.get(i).getWhetherDanger())) { listLast.add(list.get(i)); checkPointIds.add(list.get(i).getCheckPointId()); } else if ("1".equals(list.get(i).getWhetherDanger())) { if (checkPointIds.contains(list.get(i).getCheckPointId())) { for (int a = 0; a < listLast.size(); a++) { RiskCheckPointDTO riskCheckPointDTOTemp = listLast.get(a); if ((list.get(i).getCheckPointId()).equals(riskCheckPointDTOTemp.getCheckPointId())) { List hiddenDangerCheckPointIds = listLast.get(a).getHiddenDangerCheckPointIds(); hiddenDangerCheckPointIds.add(list.get(i).getId()); listLast.get(a).setHiddenDangerCheckPointIds(hiddenDangerCheckPointIds); break; } } } else { List hiddenDangerCheckPointIds = new ArrayList<>(); hiddenDangerCheckPointIds.add(list.get(i).getId()); list.get(i).setHiddenDangerCheckPointIds(hiddenDangerCheckPointIds); listLast.add(list.get(i)); checkPointIds.add(list.get(i).getCheckPointId()); } } else { listLast.add(list.get(i)); checkPointIds.add(list.get(i).getCheckPointId()); } } return getDataTable(listLast); } /** * 根据隐患排查checkId获取基础清单下的检查点 */ @PostMapping("/selectBaseCheckPointListByCheckId") @ResponseBody public TableDataInfo selectBaseCheckPointListByCheckId(BaseCheckPointDTO baseCheckPointDTO) { List list = hiddenDangerCheckPointService.selectBaseCheckPointListByCheckId(baseCheckPointDTO); return getDataTable(list); } /** * 根据隐患排查checkId获取基础清单下的检查点,并合并检查内容相同的行 todo */ @PostMapping("/selectBaseCheckPointListByCheckIdAndMergeSamePoint") @ResponseBody public TableDataInfo selectBaseCheckPointListByCheckIdAndMergeSamePoint(BaseCheckPointDTO baseCheckPointDTO) { List list = hiddenDangerCheckPointService.selectBaseCheckPointListByCheckId(baseCheckPointDTO); List listLast = new ArrayList<>(); Set checkPointIds = new HashSet(); for (int i = 0; i < list.size(); i++) { if ("0".equals(list.get(i).getWhetherDanger())) { listLast.add(list.get(i)); checkPointIds.add(list.get(i).getCheckPointId()); } else if ("1".equals(list.get(i).getWhetherDanger())) { if (checkPointIds.contains(list.get(i).getCheckPointId())) { for (int a = 0; a < listLast.size(); a++) { BaseCheckPointDTO baseCheckPointDTOTemp = listLast.get(a); if ((list.get(i).getCheckPointId()).equals(baseCheckPointDTOTemp.getCheckPointId())) { List hiddenDangerCheckPointIds = listLast.get(a).getHiddenDangerCheckPointIds(); hiddenDangerCheckPointIds.add(list.get(i).getId()); listLast.get(a).setHiddenDangerCheckPointIds(hiddenDangerCheckPointIds); break; } } } else { List hiddenDangerCheckPointIds = new ArrayList<>(); hiddenDangerCheckPointIds.add(list.get(i).getId()); list.get(i).setHiddenDangerCheckPointIds(hiddenDangerCheckPointIds); listLast.add(list.get(i)); checkPointIds.add(list.get(i).getCheckPointId()); } } else { listLast.add(list.get(i)); checkPointIds.add(list.get(i).getCheckPointId()); } } return getDataTable(listLast); } /** * 图片--查看 */ @Log(title = "图片--查看") @GetMapping("/showPicture/{type}/{id}") public String showPicture(@PathVariable("type") String type, @PathVariable("id") String id, ModelMap mmap) { HiddenDangerCheckPoint hiddenDangerCheckPoint = hiddenDangerCheckPointService.selectHiddenDangerCheckPointById(Long.valueOf(id)); mmap.put("hiddenDangerCheckPoint", hiddenDangerCheckPoint); if (!StringUtils.isEmpty(type)) { if ("preRectifyPhoto".equals(type)) { mmap.put("imageUrl", hiddenDangerCheckPoint.getPreRectifyPhoto()); } else if ("postRectifyPhoto".equals(type)) { mmap.put("imageUrl", hiddenDangerCheckPoint.getPostRectifyPhoto()); } } return prefix + "/showPicture"; } }