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