package com.ruoyi.project.tr.specialCheck.controller; import com.ruoyi.common.utils.BeanCopyUtils; import com.ruoyi.doublePrevention.vo.ResultVO; 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.tr.riskList.domain.RiskList; import com.ruoyi.project.tr.riskList.service.IRiskListService; import com.ruoyi.project.tr.specialCheck.domin.BO.*; import com.ruoyi.project.tr.specialCheck.domin.DTO.TbSpecialCheckTaskLogDTO; import com.ruoyi.project.tr.specialCheck.domin.DTO.TbSpecialCheckTaskLogDateDTO; import com.ruoyi.project.tr.specialCheck.domin.TbBaseCheckTask; import com.ruoyi.project.tr.specialCheck.domin.TbSpecialCheckTaskLog; import com.ruoyi.project.tr.specialCheck.service.SpecialCheckTaskService; import com.ruoyi.project.tr.specialCheck.service.TbBaseCheckService; 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.sql.Date; import java.time.Instant; import java.time.ZoneId; import java.util.List; /** * 隐患列表Controller * * @date 2020-05-08 */ @Controller @RequestMapping("/tr/specialCheckTaskLog") public class TBSpecialCheckTaskLogController extends BaseController { private String prefix = "tr/specialCheckTaskLog"; @Autowired private SpecialCheckTaskService specialCheckTaskService; @Autowired private IRiskListService riskListService; @Autowired private TbBaseCheckService tbBaseCheckService; // @GetMapping() // public String selectTbBaseCheckTaskPage(ModelMap mmap) // { // return prefix + "/specialCheckTaskLog"; // } @GetMapping("{id}") public String specialCheckTaskLog(@PathVariable("id")String id,ModelMap modelMap) { modelMap.put("id",id); return prefix + "/specialCheckTaskLog"; } @PostMapping("/list") @ResponseBody public TableDataInfo selectSpecialCheckTaskLogPage(TbSpecialCheckTaskLogBO specialCheckTaskLogBO) { ResultVO> resultVO = specialCheckTaskService.selectSpecialCheckTaskLogPage(specialCheckTaskLogBO); List data = (List) resultVO.getData(); TableDataInfo dataTable = getDataTable(data); dataTable.setTotal(resultVO.getCount()); return dataTable; } /** * 新增任务 */ @GetMapping("/add") public String add(ModelMap mmap) { List riskList = riskListService.listHazardSource(); mmap.put("hazardList", riskList); List listResult = tbBaseCheckService.listTbBaseCheckTask(); mmap.put("tbBaseCheckTask", listResult); return prefix + "/add"; } /** * 新增任务保存 */ @PostMapping("/add") @ResponseBody public AjaxResult addSpecialTask(TbSpecialCheckTaskLogEditBO taskLogEditBO){ ResultVO resultVO = specialCheckTaskService.addSpecialTask(taskLogEditBO); String code = resultVO.getCode(); if ("200".equals(code)){ return toAjax(1); }else { return AjaxResult.error(resultVO.getMsg()); } } @GetMapping("/edit/{indexId}") public String edit(@PathVariable("indexId") Long indexId, ModelMap mmap) { TbSpecialCheckTaskLog specialCheckTaskLog = specialCheckTaskService.getSpecialCheckTaskLogByIndexId(indexId); TbSpecialCheckTaskLogDateDTO tbSpecialCheckTaskLogDateDTO = BeanCopyUtils.copyBean(specialCheckTaskLog, TbSpecialCheckTaskLogDateDTO.class); Instant instant = specialCheckTaskLog.getCheckDate().atZone(ZoneId.systemDefault()).toInstant(); tbSpecialCheckTaskLogDateDTO.setCheckDate(Date.from(instant)); mmap.put("specialCheckTaskLog",tbSpecialCheckTaskLogDateDTO); List riskList = riskListService.listHazardSource(); mmap.put("hazardList", riskList); List listResult = tbBaseCheckService.listTbBaseCheckTask(); mmap.put("tbBaseCheckTask", listResult); return prefix + "/edit"; } /** * */ @GetMapping("/detail/{indexId}") public String detail(@PathVariable("indexId") Long indexId, ModelMap mmap) { TbSpecialCheckTaskLog specialCheckTaskLog = specialCheckTaskService.getSpecialCheckTaskLogByIndexId(indexId); TbSpecialCheckTaskLogDateDTO tbSpecialCheckTaskLogDateDTO = BeanCopyUtils.copyBean(specialCheckTaskLog, TbSpecialCheckTaskLogDateDTO.class); Instant instant = specialCheckTaskLog.getCheckDate().atZone(ZoneId.systemDefault()).toInstant(); tbSpecialCheckTaskLogDateDTO.setCheckDate(Date.from(instant)); mmap.put("specialCheckTaskLog",tbSpecialCheckTaskLogDateDTO); List riskList = riskListService.listHazardSource(); mmap.put("hazardList", riskList); List listResult = tbBaseCheckService.listTbBaseCheckTask(); mmap.put("tbBaseCheckTask", listResult); return prefix + "/detail"; } /** * 修改保存 */ @PostMapping("/edit") @ResponseBody public AjaxResult editSave(TbSpecialCheckTaskLogEditBO taskLogEditBO) { ResultVO resultVO = specialCheckTaskService.updateSpecialCheckTaskLog(taskLogEditBO); String code = resultVO.getCode(); if ("200".equals(code)){ return toAjax(1); }else { return AjaxResult.error(resultVO.getMsg()); } } @PostMapping("/remove") @ResponseBody public AjaxResult remove(TbSpecialCheckTaskLogUpdateBO updateBO){ ResultVO resultVO = specialCheckTaskService.deleteTbSpecialCheckTaskLog(updateBO); String code = resultVO.getCode(); if ("200".equals(code)){ return toAjax(1); }else { return AjaxResult.error(resultVO.getMsg()); } } // // @Autowired // private DealDataTask dealDataTask; // // @GetMapping("/dealDataTask") // public AjaxResult dealDataTask() // { // dealDataTask.dealData(); // return success(); // } }