双重预防项目-国泰新华二开定制版
16639036659
2022-09-27 7e7195766eb018b4ba00b2d0663f6dcb11adefc8
src/main/java/com/ruoyi/project/tr/hiddenDangerCheck/controller/DangerReportController.java
@@ -5,6 +5,7 @@
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
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;
@@ -20,6 +21,7 @@
import com.ruoyi.project.tr.hiddenTroubleType.service.IHiddenTroubleTypeService;
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.*;
@@ -49,6 +51,9 @@
    @Autowired
    private IUserService userService;
    @Autowired
    private RiskService riskService;
    @GetMapping()
    public String hiddenDangerCheck(ModelMap mmap) {
@@ -130,10 +135,12 @@
    /**
     * 新增保存隐患上报
     * todo-2022 隐患上报   需要检查对分别对两张表做了什么,然后添加附属表(tr_hidden_danger_check_point)
     */
    @Log(title = "隐患上报", businessType = BusinessType.INSERT)
    @PostMapping("/addDangerReportSave")
    @ResponseBody
    @Transactional
    public AjaxResult addDangerReportSave(HiddenDangerCheckPoint hdcp) {
        HiddenDangerCheck hiddenDangerCheck  = new HiddenDangerCheck();
        hiddenDangerCheck.setCreateBy(ShiroUtils.getLoginName());//创建者
@@ -154,13 +161,23 @@
        hdcp.setCompanyId(getSysUser().getCompanyId());
        int i = hiddenDangerCheckPointService.insertHiddenDangerCheckPoint(hdcp);
        if (i< 1){
            throw new RuntimeException("添加隐患信息失败");
        }
        // todo-2022 此处插入附属表
        //获取Id返回值
        hdcp.getId();
        int result = riskService.insertDangerInfo(hdcp.getId(), hdcp);
        if (result< 1){
            throw new RuntimeException("添加隐患附属信息失败");
        }
        hiddenDangerCheckPointService.getTaskCountTotal(getSysUser().getUserId());//查询未执行任务总数量并推送
        return toAjax(i);
    }
    /**
@@ -317,6 +334,7 @@
    @Log(title = "隐患上报", businessType = BusinessType.UPDATE)
    @PostMapping("/editDangerReportSave")
    @ResponseBody
    @Transactional
    public AjaxResult editDangerReportSave(HiddenDangerCheckPoint hiddenDangerCheckPoint) {
        HiddenDangerCheckPoint hdcp = hiddenDangerCheckPointService.selectHiddenDangerCheckPointById(hiddenDangerCheckPoint.getId());
        if(hdcp!=null&&hdcp.getCheckId()!=null){
@@ -332,6 +350,12 @@
            hiddenDangerCheckPoint.setUpdateBy(ShiroUtils.getLoginName());//更新者
            hiddenDangerCheckPoint.setUpdateTime(DateUtils.getNowDate());//设置更新时间
            hiddenDangerCheckPointService.updateHiddenDangerCheckPoint(hiddenDangerCheckPoint);
            // todo-2022 此处修改附属表
            int result = riskService.updateDangerInfo(hiddenDangerCheckPoint);
            if (result < 1){
                throw new RuntimeException("修改失败");
            }
            hiddenDangerCheckPointService.getTaskCountTotal(getSysUser().getUserId());//查询未执行任务总数量并推送
            return AjaxResult.success();
@@ -402,6 +426,7 @@
    @Log(title = "隐患上报", businessType = BusinessType.DELETE)
    @PostMapping("/removeDangerReport")
    @ResponseBody
    @Transactional
    public AjaxResult removeDangerReport(String ids) {
        if(StringUtils.isEmpty(ids)){
            return AjaxResult.error("id不能为空");
@@ -410,6 +435,14 @@
        if(hdcp.getCheckId()!=null){
            hiddenDangerCheckPointService.deleteHiddenDangerCheckPointById(hdcp.getId());
            hiddenDangerCheckService.deleteHiddenDangerCheckById(hdcp.getCheckId());
            // todo-2022 此处删除附属表
            int result = riskService.deleteDangerInfo(hdcp.getId());
            if (result < 1){
                throw  new RuntimeException("删除失败");
            }
            hiddenDangerCheckPointService.getTaskCountTotal(getSysUser().getUserId());//查询未执行任务总数量并推送
            return AjaxResult.success();
        }
@@ -419,6 +452,7 @@
    /**
     * 隐患上报--提交
     * 隐患信息提交,此处不改。思路:使用stage 进行阶段判断。只有认定后的隐患,才需要上报。
     */
    @Log(title = "隐患上报--提交")
    @PostMapping("/submitDangerReport")