TTaskInspectionPlanController.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. package com.ruoyi.project.task.controller;
  2. import java.sql.Time;
  3. import java.util.*;
  4. import javax.servlet.http.HttpServletResponse;
  5. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  6. import com.ruoyi.common.utils.DateUtils;
  7. import com.ruoyi.project.base.domain.TBaseDevice;
  8. import com.ruoyi.project.base.domain.TBasePlant;
  9. import com.ruoyi.project.base.domain.TBasePoint;
  10. import com.ruoyi.project.base.domain.TBaseRegion;
  11. import com.ruoyi.project.base.mapper.TBasePointMapper;
  12. import com.ruoyi.project.base.mapper.TBaseRegionMapper;
  13. import com.ruoyi.project.base.service.ITBaseDeviceService;
  14. import com.ruoyi.project.base.service.ITBasePlantService;
  15. import com.ruoyi.project.base.service.ITBasePointService;
  16. import com.ruoyi.project.base.service.ITBaseRegionService;
  17. import com.ruoyi.project.check.domain.TCheckCheckpoints;
  18. import com.ruoyi.project.check.domain.TCheckLawitems;
  19. import com.ruoyi.project.check.mapper.TCheckCheckpointsMapper;
  20. import com.ruoyi.project.check.service.ITCheckCheckpointsService;
  21. import com.ruoyi.project.check.service.ITCheckLawitemsService;
  22. import com.ruoyi.project.task.domain.TTaskInspection;
  23. import com.ruoyi.project.task.mapper.TTaskInspectionPlanMapper;
  24. import com.ruoyi.project.task.service.ITTaskInspectionService;
  25. import com.ruoyi.system.service.ISysDictTypeService;
  26. import org.apache.commons.collections4.CollectionUtils;
  27. import org.springframework.security.access.prepost.PreAuthorize;
  28. import org.springframework.beans.factory.annotation.Autowired;
  29. import org.springframework.web.bind.annotation.GetMapping;
  30. import org.springframework.web.bind.annotation.PostMapping;
  31. import org.springframework.web.bind.annotation.PutMapping;
  32. import org.springframework.web.bind.annotation.DeleteMapping;
  33. import org.springframework.web.bind.annotation.PathVariable;
  34. import org.springframework.web.bind.annotation.RequestBody;
  35. import org.springframework.web.bind.annotation.RequestMapping;
  36. import org.springframework.web.bind.annotation.RestController;
  37. import com.ruoyi.common.annotation.Log;
  38. import com.ruoyi.common.core.controller.BaseController;
  39. import com.ruoyi.common.core.domain.AjaxResult;
  40. import com.ruoyi.common.enums.BusinessType;
  41. import com.ruoyi.project.task.domain.TTaskInspectionPlan;
  42. import com.ruoyi.project.task.service.ITTaskInspectionPlanService;
  43. import com.ruoyi.common.utils.poi.ExcelUtil;
  44. import com.ruoyi.common.core.page.TableDataInfo;
  45. /**
  46. * 检测计划Controller
  47. *
  48. * @author ruoyi
  49. * @date 2022-11-17
  50. */
  51. @RestController
  52. @RequestMapping("/task/plan")
  53. public class TTaskInspectionPlanController extends BaseController {
  54. @Autowired
  55. private ITTaskInspectionPlanService tTaskInspectionPlanService;
  56. @Autowired
  57. private ITTaskInspectionService tTaskInspectionService;
  58. @Autowired
  59. private TTaskInspectionPlanMapper tTaskInspectionPlanMapper;
  60. @Autowired
  61. private ITBasePlantService tBasePlantService;
  62. @Autowired
  63. private ISysDictTypeService isysDictTypeService;
  64. @Autowired
  65. private TBasePointMapper tBasePointMapper;
  66. @Autowired
  67. private ITBaseRegionService tBaseRegionService;
  68. @Autowired
  69. private ITBaseDeviceService tBaseDeviceService;
  70. @Autowired
  71. private ITCheckCheckpointsService tCheckCheckpointsService;
  72. @Autowired
  73. private TCheckCheckpointsMapper tCheckCheckpointsMapper;
  74. @Autowired
  75. private ITCheckLawitemsService tCheckLawitemsService;
  76. /**
  77. * 查询检测计划列表
  78. */
  79. @PreAuthorize("@ss.hasPermi('task:plan:list')")
  80. @GetMapping("/list")
  81. public TableDataInfo list(TTaskInspectionPlan tTaskInspectionPlan) {
  82. startPage();
  83. List<TTaskInspectionPlan> list = tTaskInspectionPlanService.selectTTaskInspectionPlanList(tTaskInspectionPlan);
  84. list.forEach(item -> {
  85. TTaskInspection tTaskInspection = new TTaskInspection();
  86. tTaskInspection.setPlanId(item.getId());
  87. if (CollectionUtils.isNotEmpty(tTaskInspectionService.selectTTaskInspectionList(tTaskInspection))) {
  88. item.setHaveSub("1");
  89. } else {
  90. item.setHaveSub("0");
  91. }
  92. });
  93. return getDataTable(list);
  94. }
  95. @GetMapping("/allPlan")
  96. public AjaxResult selectAllPlan() {
  97. return AjaxResult.success(tTaskInspectionPlanService.selectAllPlan());
  98. }
  99. @GetMapping("/pointList")
  100. public TableDataInfo pointList(TBasePoint tBasePoint){
  101. startPage();
  102. List<TBasePoint> list = tBasePointMapper.selectTBasePointListNotInPlan(tBasePoint);
  103. return getDataTable(list);
  104. }
  105. /**
  106. * 导出检测计划列表
  107. */
  108. @PreAuthorize("@ss.hasPermi('task:plan:export')")
  109. @Log(title = "检测计划导出", businessType = BusinessType.EXPORT)
  110. @PostMapping("/export")
  111. public void export(HttpServletResponse response, TTaskInspectionPlan tTaskInspectionPlan) {
  112. List<TTaskInspectionPlan> list = tTaskInspectionPlanService.selectTTaskInspectionPlanList(tTaskInspectionPlan);
  113. ExcelUtil<TTaskInspectionPlan> util = new ExcelUtil<TTaskInspectionPlan>(TTaskInspectionPlan.class);
  114. util.exportExcel(response, list, "检测计划数据");
  115. }
  116. /**
  117. * 获取检测计划详细信息
  118. */
  119. @PreAuthorize("@ss.hasPermi('task:plan:query')")
  120. @GetMapping(value = "/{id}")
  121. public AjaxResult getInfo(@PathVariable("id") Long id) {
  122. return AjaxResult.success(tTaskInspectionPlanService.selectTTaskInspectionPlanById(id));
  123. }
  124. /**
  125. * 新增检测计划
  126. */
  127. @PreAuthorize("@ss.hasPermi('task:plan:add')")
  128. @Log(title = "检测计划新增", businessType = BusinessType.INSERT)
  129. @PostMapping
  130. public AjaxResult add(@RequestBody TTaskInspectionPlan tTaskInspectionPlan) {
  131. tTaskInspectionPlan.setCreaterCode(getUserId());
  132. if (tTaskInspectionPlanService.insertTTaskInspectionPlan(tTaskInspectionPlan) > 0 && !"5".equals(tTaskInspectionPlan.getDetectionFrequency())) {
  133. TBasePlant tBasePlant = tBasePlantService.selectTBasePlantById(tTaskInspectionPlan.getPlantId());
  134. // 统计当前装置下的所有(动)密封点
  135. QueryWrapper<TBasePoint> points = new QueryWrapper<TBasePoint>().eq("plant_id", tTaskInspectionPlan.getPlantId()).eq("del_flag", 0).eq("approve_status", 2);
  136. List<TCheckLawitems> tCheckLawitems = tCheckLawitemsService.selectTCheckLawitemsByLawStatus();
  137. // 匹配法规标准
  138. if ("2".equals(tTaskInspectionPlan.getDetectionFrequency())) {
  139. Set<String> pointTypes = new HashSet<>();
  140. for (TCheckLawitems lawitem : tCheckLawitems) {
  141. if (lawitem.getPlantType().equals(tBasePlant.getPlantType()) && lawitem.getDetectionFrequency().equals("2")) {
  142. pointTypes.add(lawitem.getPointType());
  143. }
  144. }
  145. if (CollectionUtils.isEmpty(pointTypes)){
  146. return AjaxResult.success();
  147. }
  148. points.in("point_type", pointTypes);
  149. }
  150. Integer count = tBasePointMapper.selectCount(points);
  151. tTaskInspectionPlan.setPointNum(count.toString());
  152. tTaskInspectionPlan.setCreaterCode(getUserId());
  153. tTaskInspectionPlan.setCreatedate(new Date());
  154. tTaskInspectionPlan.setUpdaterCode(getUserId());
  155. tTaskInspectionPlan.setUpdatedate(new Date());
  156. // 新增检测点
  157. List<TCheckCheckpoints> tCheckCheckpoints = new ArrayList<>();
  158. List<TBasePoint> tBasePoints = tBasePointMapper.selectList(points);
  159. for (TBasePoint tBasePoint : tBasePoints) {
  160. TCheckCheckpoints tCheckCheckpoint = new TCheckCheckpoints();
  161. tCheckCheckpoint.setPlanId(tTaskInspectionPlan.getId());
  162. tCheckCheckpoint.setPointId(tBasePoint.getPointId());
  163. tCheckCheckpoint.setPlantName(tBasePlant.getPlantName());
  164. tCheckCheckpoint.setPlantId(tBasePlant.getPlantId());
  165. // TODO:需要优化,将区域名称和设备信息在新增密封点时直接存进去
  166. // tCheckCheckpoint.setRegionName(tBaseRegionService.selectTBaseRegionById(tBasePoint.getRegionId()).getRegionName());
  167. tCheckCheckpoint.setRegionId(tBasePoint.getRegionId());
  168. tCheckCheckpoint.setLayer(tBasePoint.getLayer());
  169. // TBaseDevice tBaseDevice = tBaseDeviceService.selectTBaseDeviceById(tBasePoint.getDevId());
  170. // tCheckCheckpoint.setDevName(tBaseDevice.getDevDescribe());
  171. // tCheckCheckpoint.setDevCode(tBaseDevice.getDevCode());
  172. tCheckCheckpoint.setDevId(tBasePoint.getDevId());
  173. tCheckCheckpoint.setGroupCode(tBasePoint.getGroupCode());
  174. tCheckCheckpoint.setExtendCode(tBasePoint.getExtendCode());
  175. tCheckCheckpoint.setPointType(tBasePoint.getPointType());
  176. tCheckCheckpoint.setCreaterCode(getUserId());
  177. tCheckCheckpoint.setCreatedate(new Date());
  178. tCheckCheckpoint.setUpdaterCode(getUserId());
  179. tCheckCheckpoint.setUpdatedate(new Date());
  180. tCheckCheckpoint.setPlantType(tBasePlant.getPlantType());
  181. tCheckCheckpoint.setMediumType(tBasePoint.getMediumType());
  182. tCheckCheckpoints.add(tCheckCheckpoint);
  183. }
  184. if (CollectionUtils.isNotEmpty(tCheckCheckpoints))
  185. tCheckCheckpointsService.insertTCheckCheckpointsByList(tCheckCheckpoints);
  186. return toAjax(tTaskInspectionPlanService.updateTTaskInspectionPlan(tTaskInspectionPlan));
  187. }
  188. return AjaxResult.success();
  189. }
  190. @PostMapping("/addCheckpoints")
  191. @Log(title = "检测计划新增临时计划添加检测点", businessType = BusinessType.INSERT)
  192. public AjaxResult addCheckpoints(@RequestBody TTaskInspectionPlan tTaskInspectionPlan) {
  193. TTaskInspection tTaskInspection = new TTaskInspection();
  194. tTaskInspection.setPlanId(tTaskInspectionPlan.getId());
  195. if (CollectionUtils.isNotEmpty(tTaskInspectionService.selectTTaskInspectionList(tTaskInspection))) {
  196. return AjaxResult.error();
  197. }
  198. QueryWrapper<TBasePoint> points = new QueryWrapper<TBasePoint>().eq("del_flag", 0).eq("approve_status", 2).in("point_id", tTaskInspectionPlan.getPointIds());
  199. List<TBasePoint> tBasePoints = tBasePointMapper.selectList(points);
  200. TBasePlant tBasePlant = tBasePlantService.selectTBasePlantById(tTaskInspectionPlan.getPlantId());
  201. // 新增检测点
  202. List<TCheckCheckpoints> tCheckCheckpoints = new ArrayList<>();
  203. for (TBasePoint tBasePoint : tBasePoints) {
  204. TCheckCheckpoints tCheckCheckpoint = new TCheckCheckpoints();
  205. tCheckCheckpoint.setPointId(tBasePoint.getPointId());
  206. tCheckCheckpoint.setPlantName(tTaskInspectionPlan.getPlantName());
  207. tCheckCheckpoint.setPlantId(tBasePoint.getPlantId());
  208. // TODO:需要优化,将区域名称和设备信息在新增密封点时直接存进去
  209. // tCheckCheckpoint.setRegionName(tBaseRegionService.selectTBaseRegionById(tBasePoint.getRegionId()).getRegionName());
  210. tCheckCheckpoint.setRegionId(tBasePoint.getRegionId());
  211. tCheckCheckpoint.setLayer(tBasePoint.getLayer());
  212. // TBaseDevice tBaseDevice = tBaseDeviceService.selectTBaseDeviceById(tBasePoint.getDevId());
  213. // tCheckCheckpoint.setDevName(tBaseDevice.getDevDescribe());
  214. // tCheckCheckpoint.setDevCode(tBaseDevice.getDevCode());
  215. tCheckCheckpoint.setDevId(tBasePoint.getDevId());
  216. tCheckCheckpoint.setGroupCode(tBasePoint.getGroupCode());
  217. tCheckCheckpoint.setExtendCode(tBasePoint.getExtendCode());
  218. tCheckCheckpoint.setPointType(tBasePoint.getPointType());
  219. tCheckCheckpoint.setCreaterCode(getUserId());
  220. tCheckCheckpoint.setCreatedate(new Date());
  221. tCheckCheckpoint.setUpdaterCode(getUserId());
  222. tCheckCheckpoint.setUpdatedate(new Date());
  223. tCheckCheckpoint.setPlantType(tBasePlant.getPlantType());
  224. tCheckCheckpoint.setMediumType(tBasePoint.getMediumType());
  225. tCheckCheckpoint.setPlanId(tTaskInspectionPlan.getId());
  226. tCheckCheckpoints.add(tCheckCheckpoint);
  227. }
  228. if (CollectionUtils.isNotEmpty(tCheckCheckpoints))
  229. tCheckCheckpointsService.insertTCheckCheckpointsByList(tCheckCheckpoints);
  230. QueryWrapper<TCheckCheckpoints> wrapper = new QueryWrapper<TCheckCheckpoints>().eq("plan_id", tTaskInspectionPlan.getId());
  231. Integer count = tCheckCheckpointsMapper.selectCount(wrapper);
  232. tTaskInspectionPlan.setPointNum(count.toString());
  233. tTaskInspectionPlan.setUpdaterCode(getUserId());
  234. tTaskInspectionPlan.setUpdatedate(new Date());
  235. return AjaxResult.success(tTaskInspectionPlanService.updateTTaskInspectionPlan(tTaskInspectionPlan));
  236. }
  237. @DeleteMapping("/removeCheckPoints")
  238. @Log(title = "检测计划删除", businessType = BusinessType.DELETE)
  239. public AjaxResult removeCheckPoints(@RequestBody TCheckCheckpoints tCheckCheckpoints) {
  240. tCheckCheckpointsService.deleteCheckpoints(tCheckCheckpoints);
  241. QueryWrapper<TCheckCheckpoints> wrapper = new QueryWrapper<TCheckCheckpoints>().eq("plan_id", tCheckCheckpoints.getPlanId());
  242. Integer count = tCheckCheckpointsMapper.selectCount(wrapper);
  243. TTaskInspectionPlan tTaskInspectionPlan = new TTaskInspectionPlan();
  244. tTaskInspectionPlan.setId(tCheckCheckpoints.getPlanId());
  245. tTaskInspectionPlan.setPointNum(count.toString());
  246. tTaskInspectionPlan.setUpdaterCode(getUserId());
  247. tTaskInspectionPlan.setUpdatedate(new Date());
  248. return AjaxResult.success(tTaskInspectionPlanService.updateTTaskInspectionPlan(tTaskInspectionPlan));
  249. }
  250. @PreAuthorize("@ss.hasPermi('task:plan:add')")
  251. @Log(title = "校验检测计划", businessType = BusinessType.INSERT)
  252. @PostMapping("/checkPlan")
  253. public AjaxResult checkPlan() {
  254. List<TTaskInspectionPlan> tTaskInspectionPlans = new ArrayList<>();
  255. int nowQuarter = DateUtils.getNowQuarter(); // 获取当前季度
  256. Calendar calendar = Calendar.getInstance(); // 获取当前时间
  257. String year = String.valueOf(calendar.get(Calendar.YEAR)); // 获取当前年份
  258. List<TCheckLawitems> tCheckLawitems = tCheckLawitemsService.selectTCheckLawitemsByLawStatus();
  259. for (TBasePlant tBasePlant : tBasePlantService.selectAllPlantName()) {// 查询已审核所有装置
  260. // 查询今年当前季度是否有监测计划
  261. QueryWrapper<TTaskInspectionPlan> plansWrapper = new QueryWrapper<TTaskInspectionPlan>().eq("plan_year", year).eq("plan_quarter", nowQuarter).eq("plant_id", tBasePlant.getPlantId()).eq("del_flag", 0);
  262. List<TTaskInspectionPlan> plans = tTaskInspectionPlanService.list(plansWrapper);
  263. if (CollectionUtils.isNotEmpty(plans)) {// 有则跳过
  264. continue;
  265. }
  266. TTaskInspectionPlan tTaskInspectionPlan = new TTaskInspectionPlan();
  267. tTaskInspectionPlan.setPlantId(tBasePlant.getPlantId());
  268. // 查询最后一个计划编号
  269. plansWrapper.clear();
  270. plansWrapper.eq("del_flag", 0).orderByDesc("plan_code");
  271. plans = tTaskInspectionPlanMapper.selectList(plansWrapper);
  272. int code = 0;
  273. if (CollectionUtils.isNotEmpty(plans)) {
  274. code = plans.get(0).getPlanCode() + 1;// 当前计划编号为前一个计划编号+1
  275. }
  276. // 检测计划编号
  277. tTaskInspectionPlan.setInspectionPlanNo("LTP_" + year + "_" + "0" + nowQuarter + "_" + code);
  278. // 检测计划名称
  279. tTaskInspectionPlan.setInspectionPlanName(tBasePlant.getPlantName() + "_" + year + "第" + nowQuarter + "季度检测计划");
  280. if (nowQuarter == 1 && nowQuarter == 3) {
  281. // 当前季度为1、3季度时,检测频次为一季一次
  282. tTaskInspectionPlan.setDetectionFrequency("2");
  283. // 检测结束时间为开始时间+3个月
  284. tTaskInspectionPlan.setEndTime(DateUtils.addTime(new Date(), Calendar.MONTH, 3));
  285. } else {
  286. // 当前季度为2、4季度时,检测频次为半年一次
  287. tTaskInspectionPlan.setDetectionFrequency("3");
  288. // 检测结束时间为开始时间+6个月
  289. tTaskInspectionPlan.setEndTime(DateUtils.addTime(new Date(), Calendar.MONTH, 6));
  290. }
  291. // 检测开始时间 TODO:改成传过来的
  292. tTaskInspectionPlan.setStartTime(new Date());
  293. // 统计当前装置下的所有(动)密封点
  294. QueryWrapper<TBasePoint> points = new QueryWrapper<TBasePoint>().eq("plant_id", tBasePlant.getPlantId()).eq("del_flag", 0).eq("approve_status", 2);
  295. // 当1、3季度时仅查询动密封点
  296. // 匹配法规标准
  297. if (nowQuarter == 1 && nowQuarter == 3) {
  298. Set<String> pointTypes = new HashSet<>();
  299. for (TCheckLawitems lawitem : tCheckLawitems) {
  300. if (lawitem.getPlantType().equals(tBasePlant.getPlantType()) && lawitem.getDetectionFrequency().equals("2")) {
  301. pointTypes.add(lawitem.getPointType());
  302. }
  303. }
  304. points.in("point_type", pointTypes);
  305. }
  306. Integer count = tBasePointMapper.selectCount(points);
  307. if (count == 0) {
  308. // 当前计划中没有密封点时,跳过此计划
  309. continue;
  310. }
  311. tTaskInspectionPlan.setPointNum(count.toString());
  312. tTaskInspectionPlan.setCreaterCode(getUserId());
  313. tTaskInspectionPlan.setCreatedate(new Date());
  314. tTaskInspectionPlan.setUpdaterCode(getUserId());
  315. tTaskInspectionPlan.setUpdatedate(new Date());
  316. tTaskInspectionPlan.setPlanCode(code);
  317. tTaskInspectionPlan.setPlanYear(year);
  318. tTaskInspectionPlan.setPlanQuarter(String.valueOf(nowQuarter));
  319. tTaskInspectionPlans.add(tTaskInspectionPlan);
  320. // 新增检测点
  321. List<TCheckCheckpoints> tCheckCheckpoints = new ArrayList<>();
  322. List<TBasePoint> tBasePoints = tBasePointMapper.selectList(points);
  323. for (TBasePoint tBasePoint : tBasePoints) {
  324. TCheckCheckpoints tCheckCheckpoint = new TCheckCheckpoints();
  325. tCheckCheckpoint.setPointId(tBasePoint.getPointId());
  326. tCheckCheckpoint.setPlantName(tBasePlant.getPlantName());
  327. tCheckCheckpoint.setPlantId(tBasePlant.getPlantId());
  328. // TODO:需要优化,将区域名称和设备信息在新增密封点时直接存进去
  329. // tCheckCheckpoint.setRegionName(tBaseRegionService.selectTBaseRegionById(tBasePoint.getRegionId()).getRegionName());
  330. tCheckCheckpoint.setRegionId(tBasePoint.getRegionId());
  331. tCheckCheckpoint.setLayer(tBasePoint.getLayer());
  332. // TBaseDevice tBaseDevice = tBaseDeviceService.selectTBaseDeviceById(tBasePoint.getDevId());
  333. // tCheckCheckpoint.setDevName(tBaseDevice.getDevDescribe());
  334. // tCheckCheckpoint.setDevCode(tBaseDevice.getDevCode());
  335. tCheckCheckpoint.setDevId(tBasePoint.getDevId());
  336. tCheckCheckpoint.setGroupCode(tBasePoint.getGroupCode());
  337. tCheckCheckpoint.setExtendCode(tBasePoint.getExtendCode());
  338. tCheckCheckpoint.setPointType(tBasePoint.getPointType());
  339. tCheckCheckpoint.setCreaterCode(getUserId());
  340. tCheckCheckpoint.setCreatedate(new Date());
  341. tCheckCheckpoint.setUpdaterCode(getUserId());
  342. tCheckCheckpoint.setUpdatedate(new Date());
  343. tCheckCheckpoint.setPlantType(tBasePlant.getPlantType());
  344. tCheckCheckpoint.setMediumType(tBasePoint.getMediumType());
  345. tCheckCheckpoints.add(tCheckCheckpoint);
  346. }
  347. if (CollectionUtils.isNotEmpty(tCheckCheckpoints))
  348. tCheckCheckpointsService.insertTCheckCheckpointsByList(tCheckCheckpoints);
  349. }
  350. if (CollectionUtils.isNotEmpty(tTaskInspectionPlans)) {
  351. return toAjax(tTaskInspectionPlanService.insertTTaskInspectionPlanByList(tTaskInspectionPlans));
  352. }
  353. return AjaxResult.success();
  354. }
  355. /**
  356. * 修改检测计划
  357. */
  358. @PreAuthorize("@ss.hasPermi('task:plan:edit')")
  359. @Log(title = "检测计划修改", businessType = BusinessType.UPDATE)
  360. @PutMapping
  361. public AjaxResult edit(@RequestBody TTaskInspectionPlan tTaskInspectionPlan) {
  362. tTaskInspectionPlan.setUpdaterCode(getUserId());
  363. return toAjax(tTaskInspectionPlanService.updateTTaskInspectionPlan(tTaskInspectionPlan));
  364. }
  365. /**
  366. * 删除检测计划
  367. */
  368. @PreAuthorize("@ss.hasPermi('task:plan:remove')")
  369. @Log(title = "检测计划删除", businessType = BusinessType.DELETE)
  370. @DeleteMapping("/{ids}")
  371. public AjaxResult remove(@PathVariable Long[] ids) {
  372. for (Long id : ids) {
  373. TTaskInspection tTaskInspection = new TTaskInspection();
  374. tTaskInspection.setPlanId(id);
  375. if (CollectionUtils.isNotEmpty(tTaskInspectionService.selectTTaskInspectionList(tTaskInspection))) {
  376. return AjaxResult.error("不可删除已存在检测任务的计划!");
  377. }
  378. }
  379. return toAjax(tTaskInspectionPlanService.deleteTTaskInspectionPlanByIds(ids));
  380. }
  381. }