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