TTaskInspectionPlanController.java 22 KB

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