hdy
2024-04-18 e2670e7912ea7316d1f9fb518d980b8a4ef94055
提交 | 用户 | 时间
523903 1 package com.jcdm.main.em.inspectionPlanItemsProject.controller;
2
1df825 3 import java.util.HashMap;
523903 4 import java.util.List;
1df825 5 import java.util.Map;
6 import java.util.stream.Collectors;
523903 7 import javax.servlet.http.HttpServletResponse;
e20d73 8
8241dd 9 import cn.hutool.core.collection.CollUtil;
4fe66d 10 import cn.hutool.core.util.StrUtil;
1e39c5 11 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
e20d73 12 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4fe66d 13 import com.jcdm.common.exception.ServiceException;
1df825 14 import com.jcdm.framework.websocket.WebSocketUsers;
15 import com.jcdm.main.em.inspectionPlanTask.domain.EmInspectionPlanTask;
16 import com.jcdm.main.em.inspectionPlanTask.service.IEmInspectionPlanTaskService;
e20d73 17 import org.aspectj.weaver.loadtime.Aj;
523903 18 import org.springframework.security.access.prepost.PreAuthorize;
19 import org.springframework.beans.factory.annotation.Autowired;
e20d73 20 import org.springframework.web.bind.annotation.*;
523903 21 import com.jcdm.common.annotation.Log;
22 import com.jcdm.common.core.controller.BaseController;
23 import com.jcdm.common.core.domain.AjaxResult;
24 import com.jcdm.common.enums.BusinessType;
25 import com.jcdm.main.em.inspectionPlanItemsProject.domain.EmInspectionPlanItemsProject;
26 import com.jcdm.main.em.inspectionPlanItemsProject.service.IEmInspectionPlanItemsProjectService;
27 import com.jcdm.common.utils.poi.ExcelUtil;
28 import com.jcdm.common.core.page.TableDataInfo;
29
30 /**
31  * 点检任务-项目Controller
32  * 
33  * @author Yi
34  * @date 2024-03-23
35  */
36 @RestController
37 @RequestMapping("/em/inspectionPlanItemsProject")
38 public class EmInspectionPlanItemsProjectController extends BaseController
39 {
40     @Autowired
41     private IEmInspectionPlanItemsProjectService emInspectionPlanItemsProjectService;
42
1df825 43     @Autowired
44     private IEmInspectionPlanTaskService emInspectionPlanTaskService;
45
1e39c5 46     @GetMapping("/findPlanItemsProjectByPlanId")
W 47     public AjaxResult list2(EmInspectionPlanItemsProject emInspectionPlanItemsProject)
e20d73 48     {
4fe66d 49         if (StrUtil.isBlank(emInspectionPlanItemsProject.getPlanTaskCode())){
W 50             throw new ServiceException("未获取到计划编号,请重试!");
51         }
1df825 52         Map<String,Object> resultMap = new HashMap<>();
4fe66d 53         List<EmInspectionPlanTask> list = emInspectionPlanTaskService.list(new LambdaQueryWrapper<EmInspectionPlanTask>()
W 54                 .eq(EmInspectionPlanTask::getPlanCode, emInspectionPlanItemsProject.getPlanTaskCode()));
55         if (CollUtil.isNotEmpty(list)){
56             EmInspectionPlanTask byId = list.get(0);
57             List<EmInspectionPlanItemsProject> planTaskIdList = emInspectionPlanItemsProjectService
58                     .list(new LambdaQueryWrapper<EmInspectionPlanItemsProject>()
59                             .eq(EmInspectionPlanItemsProject::getPlanTaskId,byId.getId())
60                             .eq(EmInspectionPlanItemsProject::getItemsType,emInspectionPlanItemsProject.getItemsType()));
61
62             resultMap.put("planItemsProject", planTaskIdList);
63             resultMap.put("planTask",byId);
8c05d8 64         }else {
W 65             throw new ServiceException("未获取到计划数据!");
4fe66d 66         }
1df825 67         return AjaxResult.success(resultMap);
e20d73 68     }
69
1df825 70     @PostMapping("/updateItemsProjectResults")
71     public AjaxResult updateItemsProjectResults(@RequestBody EmInspectionPlanItemsProject emInspectionPlanItemsProject)
72     {
73         EmInspectionPlanItemsProject itemsProject = emInspectionPlanItemsProjectService.getById(emInspectionPlanItemsProject.getId());
74         itemsProject.setResults(emInspectionPlanItemsProject.getResults());
75         emInspectionPlanItemsProjectService.saveOrUpdate(itemsProject);
76
77         List<EmInspectionPlanItemsProject> list = emInspectionPlanItemsProjectService.list(new LambdaQueryWrapper<EmInspectionPlanItemsProject>()
78                 .eq(EmInspectionPlanItemsProject::getPlanTaskId, itemsProject.getPlanTaskId()));
79
8241dd 80         List<String> collect = list.stream()
W 81                 .map(EmInspectionPlanItemsProject::getResults)
82                 .filter(x-> !"1".equals(x)).collect(Collectors.toList());
83         if(CollUtil.isEmpty(collect)){
1df825 84             EmInspectionPlanTask planTaskById = emInspectionPlanTaskService.getById(itemsProject.getPlanTaskId());
8241dd 85             planTaskById.setState("1");
1df825 86             emInspectionPlanTaskService.saveOrUpdate(planTaskById);
87         }
88         return AjaxResult.success();
89     }
90
91
92
523903 93     /**
94      * 查询点检任务-项目列表
95      */
96     @PreAuthorize("@ss.hasPermi('em:inspectionPlanItemsProject:list')")
97     @GetMapping("/list")
98     public TableDataInfo list(EmInspectionPlanItemsProject emInspectionPlanItemsProject)
99     {
100         startPage();
101         List<EmInspectionPlanItemsProject> list = emInspectionPlanItemsProjectService.selectEmInspectionPlanItemsProjectList(emInspectionPlanItemsProject);
102         return getDataTable(list);
103     }
104
105     /**
106      * 导出点检任务-项目列表
107      */
108     @PreAuthorize("@ss.hasPermi('em:inspectionPlanItemsProject:export')")
109     @Log(title = "点检任务-项目", businessType = BusinessType.EXPORT)
110     @PostMapping("/export")
111     public void export(HttpServletResponse response, EmInspectionPlanItemsProject emInspectionPlanItemsProject)
112     {
113         List<EmInspectionPlanItemsProject> list = emInspectionPlanItemsProjectService.selectEmInspectionPlanItemsProjectList(emInspectionPlanItemsProject);
114         ExcelUtil<EmInspectionPlanItemsProject> util = new ExcelUtil<EmInspectionPlanItemsProject>(EmInspectionPlanItemsProject.class);
115         util.exportExcel(response, list, "点检任务-项目数据");
116     }
117
118     /**
119      * 获取点检任务-项目详细信息
120      */
121     @PreAuthorize("@ss.hasPermi('em:inspectionPlanItemsProject:query')")
122     @GetMapping(value = "/{id}")
123     public AjaxResult getInfo(@PathVariable("id") Long id)
124     {
125         return success(emInspectionPlanItemsProjectService.selectEmInspectionPlanItemsProjectById(id));
126     }
127
128     /**
129      * 新增点检任务-项目
130      */
131     @PreAuthorize("@ss.hasPermi('em:inspectionPlanItemsProject:add')")
132     @Log(title = "点检任务-项目", businessType = BusinessType.INSERT)
133     @PostMapping
134     public AjaxResult add(@RequestBody EmInspectionPlanItemsProject emInspectionPlanItemsProject)
135     {
136         return toAjax(emInspectionPlanItemsProjectService.insertEmInspectionPlanItemsProject(emInspectionPlanItemsProject));
137     }
138
139     /**
140      * 修改点检任务-项目
141      */
142     @PreAuthorize("@ss.hasPermi('em:inspectionPlanItemsProject:edit')")
143     @Log(title = "点检任务-项目", businessType = BusinessType.UPDATE)
144     @PutMapping
145     public AjaxResult edit(@RequestBody EmInspectionPlanItemsProject emInspectionPlanItemsProject)
146     {
147         return toAjax(emInspectionPlanItemsProjectService.updateEmInspectionPlanItemsProject(emInspectionPlanItemsProject));
148     }
149
150     /**
151      * 删除点检任务-项目
152      */
153     @PreAuthorize("@ss.hasPermi('em:inspectionPlanItemsProject:remove')")
154     @Log(title = "点检任务-项目", businessType = BusinessType.DELETE)
155     @DeleteMapping("/{ids}")
156     public AjaxResult remove(@PathVariable Long[] ids)
157     {
158         return toAjax(emInspectionPlanItemsProjectService.deleteEmInspectionPlanItemsProjectByIds(ids));
159     }
160 }