package com.ruoyi.project.tr.hiddenDangerCheck.controller; import com.ruoyi.common.constant.TrHiddenDangerCheckConstants; 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; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.project.system.user.domain.User; import com.ruoyi.project.tr.hiddenDangerCheckPoint.domain.HiddenDangerCheckPoint; import com.ruoyi.project.tr.hiddenDangerCheckPoint.service.IHiddenDangerCheckPointService; 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.*; import java.util.List; /** * 隐患验收Controller * * * @date 2020-05-08 */ @Controller @RequestMapping("/tr/hiddenDangerCheck/dangerAccept") public class DangerAcceptController extends BaseController { private String prefix = "tr/hiddenDangerCheck/dangerAccept"; @Autowired private IHiddenDangerCheckPointService hiddenDangerCheckPointService; @Autowired private RiskService riskService; @GetMapping() public String hiddenDangerCheckPoint() { return prefix + "/dangerAccept"; } /** * 查询隐患排查列表 */ @PostMapping("/list") @ResponseBody public TableDataInfo list(HiddenDangerCheckPoint hiddenDangerCheckPoint) { startPage(); hiddenDangerCheckPoint.setAcceptUserId(getSysUser().getUserId());//验收人为本登录帐号userId的 List list = hiddenDangerCheckPointService.selectHiddenDangerCheckPointList(hiddenDangerCheckPoint); return getDataTable(list); } /** * 隐患验收--验收 */ @Log(title = "隐患验收--验收") @GetMapping("/editDangerAccept/{id}") public String editDangerAccept(@PathVariable("id") Long id, ModelMap mmap) { //隐患排查实体 HiddenDangerCheckPoint hiddenDangerCheckPoint = hiddenDangerCheckPointService.selectHiddenDangerCheckPointById(Long.valueOf(id)); mmap.put("hdcp", hiddenDangerCheckPoint); return prefix + "/editDangerAccept"; } /** * 隐患验收--保存 */ @Log(title = "隐患验收--保存", businessType = BusinessType.UPDATE) @PostMapping("/editDangerAcceptSave") @ResponseBody @Transactional public AjaxResult editDangerAcceptSave(HiddenDangerCheckPoint hiddenDangerCheckPoint) { //获取当前更新用户信息 User sysUser = getSysUser(); hiddenDangerCheckPoint.setUpdateBy(ShiroUtils.getLoginName()); hiddenDangerCheckPoint.setUpdateTime(DateUtils.getNowDate()); if (!StringUtils.isEmpty(hiddenDangerCheckPoint.getAcceptResult())) { //验收结果 (0不通过 打回上一级整改阶段 1通过) if ("0".equals(hiddenDangerCheckPoint.getAcceptResult())) { hiddenDangerCheckPoint.setAcceptCreateTime(DateUtils.getNowDate());//设置验收时间 hiddenDangerCheckPoint.setStage(TrHiddenDangerCheckConstants.DANGER_STAGE_PLAN_RECTIFY);//隐患整改阶段(数据进入到隐患整改阶段) hiddenDangerCheckPoint.setRectifyStatus(TrHiddenDangerCheckConstants.RECTIFY_STATUS_NOT_RECTIFY);//整改状态(未整改) hiddenDangerCheckPoint.setAcceptStatus(TrHiddenDangerCheckConstants.ACCEPT_STATUS_ALREADY_ACCEPT_NOT_PASS);//验收状态(验收未通过) } else if ("1".equals(hiddenDangerCheckPoint.getAcceptResult())) { hiddenDangerCheckPoint.setAcceptCreateTime(DateUtils.getNowDate());//设置验收时间 hiddenDangerCheckPoint.setAcceptStatus(TrHiddenDangerCheckConstants.ACCEPT_STATUS_ALREADY_ACCEPT_PASS);//验收状态(验收通过) } } int i = hiddenDangerCheckPointService.updateHiddenDangerCheckPoint(hiddenDangerCheckPoint); // todo-2022 验收通过 int result = riskService.updateDangerInfoAccept(hiddenDangerCheckPoint); if (result < 1){ throw new RuntimeException("隐患验收信息保存失败"); } hiddenDangerCheckPointService.getTaskCountTotal(getSysUser().getUserId());//查询未执行任务总数量并推送 return toAjax(i); } /** * 隐患验收--查看 */ @Log(title = "隐患验收--查看") @GetMapping("/detailDangerAccept/{id}") public String detailDangerAccept(@PathVariable("id") Long id, ModelMap mmap) { //隐患排查实体 HiddenDangerCheckPoint hiddenDangerCheckPoint = hiddenDangerCheckPointService.selectHiddenDangerCheckPointById(Long.valueOf(id)); mmap.put("hdcp", hiddenDangerCheckPoint); return prefix + "/detailDangerAccept"; } }