| | |
| | | package com.ruoyi.project.tr.riskList.controller; |
| | | |
| | | import com.ruoyi.common.utils.BeanCopyUtils; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.utils.security.ShiroUtils; |
| | | import com.ruoyi.doublePrevention.entity.PreventRiskControlMeasure; |
| | | import com.ruoyi.doublePrevention.entity.dto.resp.PreventRiskCheckUnitRespDTO; |
| | | import com.ruoyi.doublePrevention.entity.dto.resp.PreventRiskUnitCodeAndNameListQueryRespDTO; |
| | | import com.ruoyi.doublePrevention.service.RiskService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | |
| | | import com.ruoyi.project.tr.riskType.service.IRiskTypeService; |
| | | 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.*; |
| | | |
| | |
| | | public class RiskListController extends BaseController { |
| | | private String prefix = "tr/riskList"; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private IRiskListService riskListService; |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private IRegionService regionService; |
| | | |
| | | @Autowired |
| | | private RiskService riskService; |
| | | |
| | | @GetMapping("/{name}") |
| | | public String riskList(@PathVariable("name") String name, ModelMap mmap) { |
| | |
| | | @Log(title = "风险清单", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | @ResponseBody |
| | | @Transactional |
| | | public AjaxResult addSave(RiskList riskList) { |
| | | //保存前获取用户名以及公司信息 |
| | | User sysUser = getSysUser(); |
| | |
| | | riskList.setCreateTime(nowDate); |
| | | riskList.setUpdateTime(nowDate); |
| | | riskList.setCompanyId(sysUser.getCompanyId()); |
| | | return toAjax(riskListService.insertRiskList(riskList)); |
| | | |
| | | int result = riskListService.insertRiskList(riskList); |
| | | riskList.getRiskListId(); |
| | | //todo-2022 |
| | | //新代码,为设施设备清单附属表添加uuid |
| | | int uuidResult = riskService.insertRiskUnitUuid(riskList.getRiskListId()); |
| | | if (uuidResult < 0){ |
| | | throw new RuntimeException("保存uuid对应关系失败"); |
| | | } |
| | | |
| | | return toAjax(result); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 修改保存风险清单 |
| | | */ |
| | | @Transactional |
| | | @Log(title = "风险清单", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/edit") |
| | | @ResponseBody |
| | |
| | | User sysUser = getSysUser(); |
| | | riskList.setUpdateBy(sysUser.getUserName()); |
| | | riskList.setUpdateTime(DateUtils.getNowDate()); |
| | | return toAjax(riskListService.updateRiskList(riskList)); |
| | | int result = riskListService.updateRiskList(riskList); |
| | | |
| | | //todo-2022 新代码,附属表变更 |
| | | riskService.updateRiskUnit(riskList.getRiskListId()); |
| | | |
| | | return toAjax(result); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ResponseBody |
| | | public AjaxResult remove(String ids) { |
| | | //删除风险清单的同时,删除评价计划, |
| | | return toAjax(riskListService.deleteRiskListByIds(ids)); |
| | | int result = riskListService.deleteRiskListByIds(ids); |
| | | |
| | | //todo-2022 新代码,附属表变更 |
| | | riskService.deleteRiskUnit(ids); |
| | | |
| | | return toAjax(result); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ResponseBody |
| | | public TableDataInfo list(RiskList riskList) { |
| | | startPage(); |
| | | List<RiskList> list = riskListService.selectRiskListList(riskList); |
| | | List<RiskList> riskLists = riskListService.selectRiskListList(riskList); |
| | | |
| | | List<PreventRiskCheckUnitRespDTO> list = new ArrayList<>(); |
| | | //todo-2022 新代码,使用DTO,封装进去措施数据 |
| | | for (RiskList risk : riskLists) { |
| | | PreventRiskCheckUnitRespDTO respDTO = BeanCopyUtils.copyBean(risk, PreventRiskCheckUnitRespDTO.class); |
| | | |
| | | //查询封装管控措施 |
| | | List<PreventRiskControlMeasure> riskControlMeasureList = riskService.getRiskControlMeasureByRiskId(risk.getRiskListId()); |
| | | if (riskControlMeasureList != null && riskControlMeasureList.size() > 1){ |
| | | respDTO.setRiskControlMeasures(riskControlMeasureList); |
| | | } |
| | | |
| | | list.add(respDTO); |
| | | } |
| | | |
| | | return getDataTable(list); |
| | | } |
| | | |