wujian
2024-04-11 33eb8605dc409dec28346f8b92bcb7046911d12c
提交 | 用户 | 时间
523903 1 package com.jcdm.main.em.inspectionPlanTask.controller;
2
33eb86 3 import java.util.ArrayList;
W 4 import java.util.Comparator;
523903 5 import java.util.List;
55a52e 6 import java.util.stream.Collectors;
523903 7 import javax.servlet.http.HttpServletResponse;
55a52e 8
33eb86 9 import cn.hutool.core.collection.CollUtil;
W 10 import cn.hutool.core.util.StrUtil;
55a52e 11 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
33eb86 12 import com.jcdm.common.core.domain.BaseEntity;
W 13 import com.jcdm.main.em.inspectionPlanTask.vo.ProductSelectVO;
55a52e 14 import org.aspectj.weaver.loadtime.Aj;
523903 15 import org.springframework.security.access.prepost.PreAuthorize;
16 import org.springframework.beans.factory.annotation.Autowired;
17 import org.springframework.web.bind.annotation.GetMapping;
18 import org.springframework.web.bind.annotation.PostMapping;
19 import org.springframework.web.bind.annotation.PutMapping;
20 import org.springframework.web.bind.annotation.DeleteMapping;
21 import org.springframework.web.bind.annotation.PathVariable;
22 import org.springframework.web.bind.annotation.RequestBody;
23 import org.springframework.web.bind.annotation.RequestMapping;
24 import org.springframework.web.bind.annotation.RestController;
25 import com.jcdm.common.annotation.Log;
26 import com.jcdm.common.core.controller.BaseController;
27 import com.jcdm.common.core.domain.AjaxResult;
28 import com.jcdm.common.enums.BusinessType;
29 import com.jcdm.main.em.inspectionPlanTask.domain.EmInspectionPlanTask;
30 import com.jcdm.main.em.inspectionPlanTask.service.IEmInspectionPlanTaskService;
31 import com.jcdm.common.utils.poi.ExcelUtil;
32 import com.jcdm.common.core.page.TableDataInfo;
33
34 /**
35  * 点检任务Controller
36  * 
37  * @author Yi
38  * @date 2024-03-23
39  */
40 @RestController
41 @RequestMapping("/em/inspectionPlanTask")
42 public class EmInspectionPlanTaskController extends BaseController
43 {
44     @Autowired
45     private IEmInspectionPlanTaskService emInspectionPlanTaskService;
46
47     /**
e20d73 48      * 查询点检任务列表不分页
49      */
50     @PostMapping("/noPageList")
51     public AjaxResult noPageList()
52     {
53         List<EmInspectionPlanTask> list = emInspectionPlanTaskService.list();
54         return AjaxResult.success(list);
55     }
56
55a52e 57     @GetMapping("/getListLikeDevices")
58     public AjaxResult getListLikeDevices(EmInspectionPlanTask emInspectionPlanTask)
59     {
33eb86 60         List<ProductSelectVO> result = new ArrayList<>();
55a52e 61         List<EmInspectionPlanTask> list = emInspectionPlanTaskService.list(new LambdaQueryWrapper<EmInspectionPlanTask>()
33eb86 62                         .like(StrUtil.isNotBlank(emInspectionPlanTask.getDevicesCode()),EmInspectionPlanTask::getDevicesCode,emInspectionPlanTask.getDevicesCode())
W 63                         );
64         if (CollUtil.isNotEmpty(list)){
65             ProductSelectVO all = new ProductSelectVO();
66             all.setLabel("全部");
67             all.setValue(null);
68             result.add(all);
69             for (EmInspectionPlanTask inspectionPlanTask : list) {
70                 ProductSelectVO vo = new ProductSelectVO();
71                 vo.setLabel(inspectionPlanTask.getDevicesName());
72                 vo.setValue(inspectionPlanTask.getDevicesCode());
73                 result.add(vo);
74             }
75             result = result.stream().distinct().collect(Collectors.toList());
55a52e 76
33eb86 77
W 78         }
79
80
81         return AjaxResult.success(result);
55a52e 82     }
83
e20d73 84     /**
523903 85      * 查询点检任务列表
86      */
87     @PreAuthorize("@ss.hasPermi('em:inspectionPlanTask:list')")
88     @GetMapping("/list")
89     public TableDataInfo list(EmInspectionPlanTask emInspectionPlanTask)
90     {
91         startPage();
92         List<EmInspectionPlanTask> list = emInspectionPlanTaskService.selectEmInspectionPlanTaskList(emInspectionPlanTask);
93         return getDataTable(list);
94     }
95
96     /**
33eb86 97      * 查询点检任务列表
W 98      */
99     @PreAuthorize("@ss.hasPermi('em:inspectionPlanTask:list')")
100     @GetMapping("/list2")
101     public AjaxResult list2(EmInspectionPlanTask emInspectionPlanTask)
102     {
103         List<EmInspectionPlanTask> list = emInspectionPlanTaskService.selectEmInspectionPlanTaskList(emInspectionPlanTask);
104         if (StrUtil.isNotBlank(emInspectionPlanTask.getOrder())){
105             if ("1".equals(emInspectionPlanTask.getOrder())){
106                 //顺序
107                 list = list.stream().sorted(Comparator.comparing(BaseEntity::getCreateTime)).collect(Collectors.toList());
108             } else if ("0".equals(emInspectionPlanTask.getOrder())) {
109                 //逆序
110                 list = list.stream().sorted(Comparator.comparing(BaseEntity::getCreateTime).reversed()).collect(Collectors.toList());
111             }
112         }
113
114         return AjaxResult.success(list);
115     }
116
117     /**
523903 118      * 导出点检任务列表
119      */
120     @PreAuthorize("@ss.hasPermi('em:inspectionPlanTask:export')")
121     @Log(title = "点检任务", businessType = BusinessType.EXPORT)
122     @PostMapping("/export")
123     public void export(HttpServletResponse response, EmInspectionPlanTask emInspectionPlanTask)
124     {
125         List<EmInspectionPlanTask> list = emInspectionPlanTaskService.selectEmInspectionPlanTaskList(emInspectionPlanTask);
126         ExcelUtil<EmInspectionPlanTask> util = new ExcelUtil<EmInspectionPlanTask>(EmInspectionPlanTask.class);
127         util.exportExcel(response, list, "点检任务数据");
128     }
129
130     /**
131      * 获取点检任务详细信息
132      */
133     @PreAuthorize("@ss.hasPermi('em:inspectionPlanTask:query')")
134     @GetMapping(value = "/{id}")
135     public AjaxResult getInfo(@PathVariable("id") Long id)
136     {
137         return success(emInspectionPlanTaskService.selectEmInspectionPlanTaskById(id));
138     }
139
140     /**
141      * 新增点检任务
142      */
143     @PreAuthorize("@ss.hasPermi('em:inspectionPlanTask:add')")
144     @Log(title = "点检任务", businessType = BusinessType.INSERT)
145     @PostMapping
146     public AjaxResult add(@RequestBody EmInspectionPlanTask emInspectionPlanTask)
147     {
148         return toAjax(emInspectionPlanTaskService.insertEmInspectionPlanTask(emInspectionPlanTask));
149     }
150
151     /**
152      * 修改点检任务
153      */
154     @PreAuthorize("@ss.hasPermi('em:inspectionPlanTask:edit')")
155     @Log(title = "点检任务", businessType = BusinessType.UPDATE)
156     @PutMapping
157     public AjaxResult edit(@RequestBody EmInspectionPlanTask emInspectionPlanTask)
158     {
159         return toAjax(emInspectionPlanTaskService.updateEmInspectionPlanTask(emInspectionPlanTask));
160     }
161
162     /**
163      * 删除点检任务
164      */
165     @PreAuthorize("@ss.hasPermi('em:inspectionPlanTask:remove')")
166     @Log(title = "点检任务", businessType = BusinessType.DELETE)
167     @DeleteMapping("/{ids}")
168     public AjaxResult remove(@PathVariable Long[] ids)
169     {
170         return toAjax(emInspectionPlanTaskService.deleteEmInspectionPlanTaskByIds(ids));
171     }
172 }