双重预防项目-国泰新华二开定制版
16639036659
2022-10-31 a72ac436263a8f41dd85635153dfdf204ae6eaa0
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
package com.ruoyi.project.tr.baseCheckPoint.controller;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import com.github.pagehelper.util.StringUtil;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.doublePrevention.entity.PreventRiskCheckUnit;
import com.ruoyi.doublePrevention.repository.param.PreventPointAndMeasureParams;
import com.ruoyi.doublePrevention.service.RiskService;
import com.ruoyi.doublePrevention.service.baseService.PreventRiskDangerInfoService;
import com.ruoyi.project.enumerate.TrEvaluationMethodDetailsEnum;
import com.ruoyi.project.enumerate.TrEvaluationMethodTypeEnum;
import com.ruoyi.project.system.dept.domain.Dept;
import com.ruoyi.project.system.user.domain.User;
import com.ruoyi.project.system.user.service.IUserService;
import com.ruoyi.project.tr.criterionDetail.domain.CriterionDetail;
import com.ruoyi.project.tr.region.domain.Region;
import com.ruoyi.project.tr.riskCheckPoint.domain.RiskCheckPoint;
import com.ruoyi.project.tr.riskEvaluationPlan.domain.RiskEvaluationPlan;
import com.ruoyi.project.tr.riskEvaluationPlan.domain.dto.RiskEvaluationDTO;
import com.ruoyi.project.tr.riskList.domain.RiskList;
import com.ruoyi.project.tr.riskType.domain.RiskType;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.tr.baseCheckPoint.domain.BaseCheckPoint;
import com.ruoyi.project.tr.baseCheckPoint.service.IBaseCheckPointService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
 
/**
 * 基础清单检查点Controller
 * 
 * @author wm
 * @date 2020-07-21
 */
@Controller
@RequestMapping("/tr/baseCheckPoint")
public class BaseCheckPointController extends BaseController
{
    private String prefix = "tr/baseCheckPoint";
 
    @Autowired
    private IBaseCheckPointService baseCheckPointService;
 
    @Autowired
    private IUserService userService;
 
    @Autowired
    private RiskService riskService;
 
    @GetMapping("{riskId}")
    public String baseCheckPoint(@PathVariable("riskId")Long riskId,ModelMap modelMap)
    {
        modelMap.put("riskId",riskId);
        return prefix + "/baseCheckPoint";
    }
 
    /**
     * 查询基础清单检查点列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BaseCheckPoint baseCheckPoint)
    {
        startPage();
        List<BaseCheckPoint> list = baseCheckPointService.selectBaseCheckPointList(baseCheckPoint);
        List<BaseCheckPoint> resultList = new ArrayList<>();
 
        //todo-2022 ,此处改造,查询措施相关信息
        for (BaseCheckPoint checkPoint : list) {
            PreventRiskCheckUnit measureByCheckPointId = riskService.getRiskControlMeasureByCheckPointId(checkPoint.getCheckPointId());
            checkPoint.setControlMeasureId(measureByCheckPointId.getControlMeasureId());
            resultList.add(checkPoint);
        }
 
        return getDataTable(resultList);
    }
 
    /**
     * 基础清单检查点的导入
     * @param file
     * @return
     * @throws Exception
     */
    @Log(title = "基础清单检查点导入", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    @ResponseBody
    @Transactional
    public AjaxResult importData(MultipartFile file,String riskId) throws Exception {
        if(StringUtils.isEmpty(riskId)){
            return AjaxResult.error("参数有误,基础清单不能为空!");
        }else {
            ExcelUtil<BaseCheckPoint> util = new ExcelUtil<BaseCheckPoint>(BaseCheckPoint.class);
            List<BaseCheckPoint> baseCheckPointList = util.importExcel(file.getInputStream());
            Boolean judgeDataBlean = Boolean.TRUE;
            String errorMessage = "";
            for (int i = 0; i < baseCheckPointList.size(); i++) {
                BaseCheckPoint baseCheckPoint = baseCheckPointList.get(i);
                if (StringUtil.isEmpty(baseCheckPoint.getCheckContent())) {
                    judgeDataBlean = Boolean.FALSE;
                    errorMessage +=
                            StringUtils.isEmpty(errorMessage)?
                            "第" + (i + 1) + "行,该[检查内容]不能为空" :"<br/> 第" + (i + 1) + "行,该[检查内容]不能为空";
                }
            }
            if(!judgeDataBlean){
                return AjaxResult.error(errorMessage);
            }
            for (int i = 0; i < baseCheckPointList.size(); i++) {
                BaseCheckPoint baseCheckPoint = baseCheckPointList.get(i);
                baseCheckPoint.setRiskId(Long.valueOf(riskId));
                baseCheckPoint.setCreateBy(ShiroUtils.getLoginName());
                baseCheckPoint.setCreateTime(DateUtils.getNowDate());
                baseCheckPointService.insertBaseCheckPoint(baseCheckPoint);
            }
            return AjaxResult.success("导入成功!");
        }
    }
 
 
 
 
    /**
     * 导出基础清单检查点列表
     */
    @Log(title = "基础清单检查点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BaseCheckPoint baseCheckPoint)
    {
        List<BaseCheckPoint> list = baseCheckPointService.selectBaseCheckPointList(baseCheckPoint);
        ExcelUtil<BaseCheckPoint> util = new ExcelUtil<BaseCheckPoint>(BaseCheckPoint.class);
        return util.exportExcel(list, "baseCheckPoint");
    }
 
    /**
     * 新增基础清单检查点
     */
    @GetMapping("/add/{riskId}")
    public String add(@PathVariable("riskId")Long riskId ,ModelMap modelMap)
    {
        modelMap.put("riksId",riskId);
        return prefix + "/add";
    }
 
    /**
     * 新增保存基础清单检查点
     */
    @Log(title = "基础清单检查点", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    @Transactional
    public AjaxResult addSave(BaseCheckPoint baseCheckPoint)
    {
      //老代码改造
        int result = baseCheckPointService.insertBaseCheckPoint(baseCheckPoint);
 
        //todo-2022 ,此处改造,嵌入管控措施
        baseCheckPoint.getCheckPointId();
 
        //使用baseCheckPointId进行查询
//        BaseCheckPoint baseCheckPointById = baseCheckPointService.getBaseCheckPointById(baseCheckPoint.getCheckPointId());
 
        PreventPointAndMeasureParams pointAndMeasureParams = new PreventPointAndMeasureParams();
        //封装参数
        pointAndMeasureParams.setBaseCheckPointId(baseCheckPoint.getCheckPointId());
        pointAndMeasureParams.setControlMeasureId(baseCheckPoint.getControlMeasureId());// todo,该参数页面尚未封装进去
        pointAndMeasureParams.setRiskId(baseCheckPoint.getRiskId());
 
        int result1 = riskService.insertPointAndMeasure(pointAndMeasureParams);
 
        if (result1 < 1){
            throw new RuntimeException("新增异常,保存管控措施关系失败");
        }
 
        return toAjax(result);
    }
 
    /**
     * 修改基础清单检查点
     */
    @GetMapping("/edit/{checkPointId}")
    public String edit(@PathVariable("checkPointId") Long checkPointId, ModelMap mmap)
    {
        BaseCheckPoint baseCheckPoint = baseCheckPointService.selectBaseCheckPointById(checkPointId);
        mmap.put("baseCheckPoint", baseCheckPoint);
        return prefix + "/edit";
    }
 
    /**
     * 修改保存基础清单检查点
     */
    @Log(title = "基础清单检查点", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    @Transactional
    public AjaxResult editSave(BaseCheckPoint baseCheckPoint)
    {
        int result = baseCheckPointService.updateBaseCheckPoint(baseCheckPoint);
 
        //todo-2022 ,此处改造,修改检查点与管控措施的关系----注,删除点,重加点
//        int result1 = riskService.updatePointAndMeasure(baseCheckPoint);
//        if (result1 < 1){
//            throw new RuntimeException("保存管控措施关系失败");
//        }
 
        return toAjax(result);
    }
 
    /**
     * 删除基础清单检查点
     */
    @Transactional
    @Log(title = "基础清单检查点", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        //老代码
        int result = baseCheckPointService.deleteBaseCheckPointByIds(ids);
 
        //todo-2022 ,此处改造,删除检查点与管控措施的关系
        int result1 = riskService.deletePointAndMeasure(ids);
        if (result1 < 1){
            throw new RuntimeException("新增异常,保存管控措施关系失败");
        }
 
        return toAjax(result);
    }
}