wujian
2024-04-15 4fe66d4f3ac6888b10f9b0e5e0f2ab555c650d7d
提交 | 用户 | 时间
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);
64         }
1df825 65         return AjaxResult.success(resultMap);
e20d73 66     }
67
1df825 68     @PostMapping("/updateItemsProjectResults")
69     public AjaxResult updateItemsProjectResults(@RequestBody EmInspectionPlanItemsProject emInspectionPlanItemsProject)
70     {
71         EmInspectionPlanItemsProject itemsProject = emInspectionPlanItemsProjectService.getById(emInspectionPlanItemsProject.getId());
72         itemsProject.setResults(emInspectionPlanItemsProject.getResults());
73         emInspectionPlanItemsProjectService.saveOrUpdate(itemsProject);
74
75         List<EmInspectionPlanItemsProject> list = emInspectionPlanItemsProjectService.list(new LambdaQueryWrapper<EmInspectionPlanItemsProject>()
76                 .eq(EmInspectionPlanItemsProject::getPlanTaskId, itemsProject.getPlanTaskId()));
77
8241dd 78         List<String> collect = list.stream()
W 79                 .map(EmInspectionPlanItemsProject::getResults)
80                 .filter(x-> !"1".equals(x)).collect(Collectors.toList());
81         if(CollUtil.isEmpty(collect)){
1df825 82             EmInspectionPlanTask planTaskById = emInspectionPlanTaskService.getById(itemsProject.getPlanTaskId());
8241dd 83             planTaskById.setState("1");
1df825 84             emInspectionPlanTaskService.saveOrUpdate(planTaskById);
85         }
86         return AjaxResult.success();
87     }
88
89
90
523903 91     /**
92      * 查询点检任务-项目列表
93      */
94     @PreAuthorize("@ss.hasPermi('em:inspectionPlanItemsProject:list')")
95     @GetMapping("/list")
96     public TableDataInfo list(EmInspectionPlanItemsProject emInspectionPlanItemsProject)
97     {
98         startPage();
99         List<EmInspectionPlanItemsProject> list = emInspectionPlanItemsProjectService.selectEmInspectionPlanItemsProjectList(emInspectionPlanItemsProject);
100         return getDataTable(list);
101     }
102
103     /**
104      * 导出点检任务-项目列表
105      */
106     @PreAuthorize("@ss.hasPermi('em:inspectionPlanItemsProject:export')")
107     @Log(title = "点检任务-项目", businessType = BusinessType.EXPORT)
108     @PostMapping("/export")
109     public void export(HttpServletResponse response, EmInspectionPlanItemsProject emInspectionPlanItemsProject)
110     {
111         List<EmInspectionPlanItemsProject> list = emInspectionPlanItemsProjectService.selectEmInspectionPlanItemsProjectList(emInspectionPlanItemsProject);
112         ExcelUtil<EmInspectionPlanItemsProject> util = new ExcelUtil<EmInspectionPlanItemsProject>(EmInspectionPlanItemsProject.class);
113         util.exportExcel(response, list, "点检任务-项目数据");
114     }
115
116     /**
117      * 获取点检任务-项目详细信息
118      */
119     @PreAuthorize("@ss.hasPermi('em:inspectionPlanItemsProject:query')")
120     @GetMapping(value = "/{id}")
121     public AjaxResult getInfo(@PathVariable("id") Long id)
122     {
123         return success(emInspectionPlanItemsProjectService.selectEmInspectionPlanItemsProjectById(id));
124     }
125
126     /**
127      * 新增点检任务-项目
128      */
129     @PreAuthorize("@ss.hasPermi('em:inspectionPlanItemsProject:add')")
130     @Log(title = "点检任务-项目", businessType = BusinessType.INSERT)
131     @PostMapping
132     public AjaxResult add(@RequestBody EmInspectionPlanItemsProject emInspectionPlanItemsProject)
133     {
134         return toAjax(emInspectionPlanItemsProjectService.insertEmInspectionPlanItemsProject(emInspectionPlanItemsProject));
135     }
136
137     /**
138      * 修改点检任务-项目
139      */
140     @PreAuthorize("@ss.hasPermi('em:inspectionPlanItemsProject:edit')")
141     @Log(title = "点检任务-项目", businessType = BusinessType.UPDATE)
142     @PutMapping
143     public AjaxResult edit(@RequestBody EmInspectionPlanItemsProject emInspectionPlanItemsProject)
144     {
145         return toAjax(emInspectionPlanItemsProjectService.updateEmInspectionPlanItemsProject(emInspectionPlanItemsProject));
146     }
147
148     /**
149      * 删除点检任务-项目
150      */
151     @PreAuthorize("@ss.hasPermi('em:inspectionPlanItemsProject:remove')")
152     @Log(title = "点检任务-项目", businessType = BusinessType.DELETE)
153     @DeleteMapping("/{ids}")
154     public AjaxResult remove(@PathVariable Long[] ids)
155     {
156         return toAjax(emInspectionPlanItemsProjectService.deleteEmInspectionPlanItemsProjectByIds(ids));
157     }
158 }