16639036659
2023-05-16 5f1ab44b47d1e28121ecf6983fada2bc628a69fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
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<RiskCheckPoint>());
        }
        //分页查询检查点
        startPage();
        RiskCheckPoint checkPoint = new RiskCheckPoint();
        checkPoint.setPlanId(plan.getPlanId());
        List<RiskCheckPoint> checkPointList = riskCheckPointService.selectRiskCheckPointList(checkPoint);
 
        return getDataTable(checkPointList);
    }
 
 
    /**
     * 根据隐患排查checkId获取风险单元下的检查点
     */
    @PostMapping("/selectRiskCheckPointListByCheckId")
    @ResponseBody
    public TableDataInfo selectRiskCheckPointListByCheckId(RiskCheckPointDTO riskCheckPointDTO) {
        List<RiskCheckPointDTO> list = hiddenDangerCheckPointService.selectRiskCheckPointListByCheckId(riskCheckPointDTO);
        return getDataTable(list);
    }
 
 
    /**
     * 根据隐患排查checkId获取风险单元下的检查点,并合并检查内容相同的行
     */
    @PostMapping("/selectRiskCheckPointListByCheckIdAndMergeSamePoint")
    @ResponseBody
    public TableDataInfo selectRiskCheckPointListByCheckIdAndMergeSamePoint(RiskCheckPointDTO riskCheckPointDTO) {
        List<RiskCheckPointDTO> list = hiddenDangerCheckPointService.selectRiskCheckPointListByCheckId(riskCheckPointDTO);
        List<RiskCheckPointDTO> listLast = new ArrayList<>();
        Set<Long> checkPointIds = new HashSet<Long>();
        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<Long> hiddenDangerCheckPointIds = listLast.get(a).getHiddenDangerCheckPointIds();
                            hiddenDangerCheckPointIds.add(list.get(i).getId());
                            listLast.get(a).setHiddenDangerCheckPointIds(hiddenDangerCheckPointIds);
                            break;
                        }
                    }
                } else {
                    List<Long> 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<BaseCheckPointDTO> list = hiddenDangerCheckPointService.selectBaseCheckPointListByCheckId(baseCheckPointDTO);
        return getDataTable(list);
    }
 
 
    /**
     * 根据隐患排查checkId获取基础清单下的检查点,并合并检查内容相同的行  todo
     */
    @PostMapping("/selectBaseCheckPointListByCheckIdAndMergeSamePoint")
    @ResponseBody
    public TableDataInfo selectBaseCheckPointListByCheckIdAndMergeSamePoint(BaseCheckPointDTO baseCheckPointDTO) {
        List<BaseCheckPointDTO> list = hiddenDangerCheckPointService.selectBaseCheckPointListByCheckId(baseCheckPointDTO);
        List<BaseCheckPointDTO> listLast = new ArrayList<>();
        Set<Long> checkPointIds = new HashSet<Long>();
        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<Long> hiddenDangerCheckPointIds = listLast.get(a).getHiddenDangerCheckPointIds();
                            hiddenDangerCheckPointIds.add(list.get(i).getId());
                            listLast.get(a).setHiddenDangerCheckPointIds(hiddenDangerCheckPointIds);
                            break;
                        }
                    }
                } else {
                    List<Long> 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";
    }
 
 
}