提交 | 用户 | 时间
|
71e81e
|
1 |
package cn.stylefeng.guns.modular.em.equipmentMaintainTask.controller; |
懒 |
2 |
|
|
3 |
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; |
|
4 |
import cn.stylefeng.guns.modular.em.equipmentMaintainContentPlan.entity.EquipmentMaintainContentPlan; |
|
5 |
import cn.stylefeng.guns.modular.em.equipmentMaintainContentPlan.model.params.EquipmentMaintainContentPlanParam; |
|
6 |
import cn.stylefeng.guns.modular.em.equipmentMaintainContentPlan.service.EquipmentMaintainContentPlanService; |
|
7 |
import cn.stylefeng.guns.modular.em.equipmentMaintainContentTask.entity.EquipmentMaintainContentTask; |
|
8 |
import cn.stylefeng.guns.modular.em.equipmentMaintainContentTask.model.params.EquipmentMaintainContentTaskParam; |
|
9 |
import cn.stylefeng.guns.modular.em.equipmentMaintainContentTask.service.EquipmentMaintainContentTaskService; |
|
10 |
import cn.stylefeng.guns.modular.em.equipmentMaintainTask.entity.EquipmentMaintainTask; |
|
11 |
import cn.stylefeng.guns.modular.em.equipmentMaintainTask.model.params.EquipmentMaintainTaskParam; |
|
12 |
import cn.stylefeng.guns.modular.em.equipmentMaintainTask.service.EquipmentMaintainTaskService; |
|
13 |
import cn.stylefeng.roses.core.base.controller.BaseController; |
|
14 |
import cn.stylefeng.roses.kernel.model.response.ResponseData; |
|
15 |
import com.alibaba.fastjson.JSONArray; |
|
16 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
17 |
import com.fasterxml.jackson.databind.ObjectMapper; |
|
18 |
import org.springframework.beans.factory.annotation.Autowired; |
|
19 |
import org.springframework.stereotype.Controller; |
|
20 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
21 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
22 |
|
|
23 |
import java.util.Arrays; |
|
24 |
import java.util.List; |
|
25 |
import java.util.Objects; |
|
26 |
|
|
27 |
|
|
28 |
/** |
|
29 |
* 保养任务控制器 |
|
30 |
* |
|
31 |
* @author ruimin |
|
32 |
* @Date 2023-02-21 15:50:38 |
|
33 |
*/ |
|
34 |
@Controller |
|
35 |
@RequestMapping("/equipmentMaintainTask") |
|
36 |
public class EquipmentMaintainTaskController extends BaseController { |
|
37 |
|
|
38 |
private String PREFIX = "modular/em/equipmentMaintainTask"; |
|
39 |
|
|
40 |
@Autowired |
|
41 |
private EquipmentMaintainTaskService equipmentMaintainTaskService; |
|
42 |
|
|
43 |
@Autowired |
|
44 |
private EquipmentMaintainContentTaskService taskService; |
|
45 |
|
|
46 |
private ObjectMapper objectMapper = new ObjectMapper(); |
|
47 |
|
|
48 |
/** |
|
49 |
* 跳转到主页面 |
|
50 |
* |
|
51 |
* @author ruimin |
|
52 |
* @Date 2023-02-21 |
|
53 |
*/ |
|
54 |
@RequestMapping("") |
|
55 |
public String index() { |
|
56 |
return PREFIX + "/equipmentMaintainTask.html"; |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* 新增页面 |
|
61 |
* |
|
62 |
* @author ruimin |
|
63 |
* @Date 2023-02-21 |
|
64 |
*/ |
|
65 |
@RequestMapping("/add") |
|
66 |
public String add() { |
|
67 |
return PREFIX + "/equipmentMaintainTask_add.html"; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* 编辑页面 |
|
72 |
* |
|
73 |
* @author ruimin |
|
74 |
* @Date 2023-02-21 |
|
75 |
*/ |
|
76 |
@RequestMapping("/edit") |
|
77 |
public String edit() { |
|
78 |
return PREFIX + "/equipmentMaintainTask_edit.html"; |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* 新增接口 |
|
83 |
* |
|
84 |
* @author ruimin |
|
85 |
* @Date 2023-02-21 |
|
86 |
*/ |
|
87 |
@RequestMapping("/addItem") |
|
88 |
@ResponseBody |
|
89 |
public ResponseData addItem(EquipmentMaintainTaskParam equipmentMaintainTaskParam,String dataList) { |
|
90 |
this.equipmentMaintainTaskService.add(equipmentMaintainTaskParam); |
|
91 |
if (!Objects.equals(null, dataList)) { |
|
92 |
Object jsonArr = JSONArray.parse(dataList); |
|
93 |
List<EquipmentMaintainContentTaskParam> list = Arrays.asList(objectMapper.convertValue(jsonArr, EquipmentMaintainContentTaskParam[].class)); |
|
94 |
for (EquipmentMaintainContentTaskParam planParm : list) { |
|
95 |
planParm.setTaskNo(equipmentMaintainTaskParam.getPlanNo()); |
|
96 |
taskService.add(planParm); |
|
97 |
} |
|
98 |
} |
|
99 |
return ResponseData.success(); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* 编辑接口 |
|
104 |
* |
|
105 |
* @author ruimin |
|
106 |
* @Date 2023-02-21 |
|
107 |
*/ |
|
108 |
@RequestMapping("/editItem") |
|
109 |
@ResponseBody |
|
110 |
public ResponseData editItem(EquipmentMaintainTaskParam equipmentMaintainTaskParam,String dataList) { |
|
111 |
this.equipmentMaintainTaskService.update(equipmentMaintainTaskParam); |
|
112 |
if (!Objects.equals(null, dataList)) { |
|
113 |
Object jsonArr = JSONArray.parse(dataList); |
|
114 |
List<EquipmentMaintainContentTaskParam> list = Arrays.asList(objectMapper.convertValue(jsonArr, EquipmentMaintainContentTaskParam[].class)); |
|
115 |
for (EquipmentMaintainContentTaskParam eqParam : list) { |
|
116 |
taskService.remove(new QueryWrapper<EquipmentMaintainContentTask>().eq("task_no",equipmentMaintainTaskParam.getTaskNo())); |
|
117 |
} |
|
118 |
for (EquipmentMaintainContentTaskParam planParm : list) { |
|
119 |
planParm.setTaskNo(equipmentMaintainTaskParam.getTaskNo()); |
|
120 |
taskService.add(planParm); |
|
121 |
} |
|
122 |
} |
|
123 |
return ResponseData.success(); |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* 删除接口 |
|
128 |
* |
|
129 |
* @author ruimin |
|
130 |
* @Date 2023-02-21 |
|
131 |
*/ |
|
132 |
@RequestMapping("/delete") |
|
133 |
@ResponseBody |
|
134 |
public ResponseData delete(EquipmentMaintainTaskParam equipmentMaintainTaskParam) { |
|
135 |
this.equipmentMaintainTaskService.delete(equipmentMaintainTaskParam); |
|
136 |
return ResponseData.success(); |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* 查看详情接口 |
|
141 |
* |
|
142 |
* @author ruimin |
|
143 |
* @Date 2023-02-21 |
|
144 |
*/ |
|
145 |
@RequestMapping("/detail") |
|
146 |
@ResponseBody |
|
147 |
public ResponseData detail(EquipmentMaintainTaskParam equipmentMaintainTaskParam) { |
|
148 |
EquipmentMaintainTask detail = this.equipmentMaintainTaskService.getById(equipmentMaintainTaskParam.getId()); |
|
149 |
return ResponseData.success(detail); |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* 查询列表 |
|
154 |
* |
|
155 |
* @author ruimin |
|
156 |
* @Date 2023-02-21 |
|
157 |
*/ |
|
158 |
@ResponseBody |
|
159 |
@RequestMapping("/list") |
|
160 |
public LayuiPageInfo list(EquipmentMaintainTaskParam equipmentMaintainTaskParam) { |
|
161 |
return this.equipmentMaintainTaskService.findPageBySpec(equipmentMaintainTaskParam); |
|
162 |
} |
|
163 |
|
|
164 |
} |
|
165 |
|
|
166 |
|