提交 | 用户 | 时间
|
71e81e
|
1 |
package cn.stylefeng.guns.modular.em.equipmentMaintainPlan.controller; |
懒 |
2 |
|
|
3 |
import cn.stylefeng.guns.base.auth.context.LoginContextHolder; |
|
4 |
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; |
|
5 |
import cn.stylefeng.guns.modular.em.equipmentMaintainContentConf.model.params.EquipmentMaintainContentConfParam; |
|
6 |
import cn.stylefeng.guns.modular.em.equipmentMaintainContentPlan.entity.EquipmentMaintainContentPlan; |
|
7 |
import cn.stylefeng.guns.modular.em.equipmentMaintainContentPlan.model.params.EquipmentMaintainContentPlanParam; |
|
8 |
import cn.stylefeng.guns.modular.em.equipmentMaintainContentPlan.service.EquipmentMaintainContentPlanService; |
|
9 |
import cn.stylefeng.guns.modular.em.equipmentMaintainPlan.entity.EquipmentMaintainPlan; |
|
10 |
import cn.stylefeng.guns.modular.em.equipmentMaintainPlan.model.params.EquipmentMaintainPlanParam; |
|
11 |
import cn.stylefeng.guns.modular.em.equipmentMaintainPlan.service.EquipmentMaintainPlanService; |
|
12 |
import cn.stylefeng.guns.sys.modular.system.entity.Dict; |
|
13 |
import cn.stylefeng.guns.sys.modular.system.service.DictService; |
|
14 |
import cn.stylefeng.roses.core.base.controller.BaseController; |
|
15 |
import cn.stylefeng.roses.kernel.model.response.ResponseData; |
|
16 |
import com.alibaba.fastjson.JSONArray; |
|
17 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
18 |
import com.fasterxml.jackson.databind.ObjectMapper; |
|
19 |
import org.springframework.beans.factory.annotation.Autowired; |
|
20 |
import org.springframework.stereotype.Controller; |
|
21 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
22 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
23 |
|
|
24 |
import java.util.Arrays; |
|
25 |
import java.util.Date; |
|
26 |
import java.util.List; |
|
27 |
import java.util.Objects; |
|
28 |
|
|
29 |
|
|
30 |
/** |
|
31 |
* 保养计划控制器 |
|
32 |
* |
|
33 |
* @author ruimin |
|
34 |
* @Date 2023-02-20 13:26:15 |
|
35 |
*/ |
|
36 |
@Controller |
|
37 |
@RequestMapping("/equipmentMaintainPlan") |
|
38 |
public class EquipmentMaintainPlanController extends BaseController { |
|
39 |
|
|
40 |
private String PREFIX = "modular/em/equipmentMaintainPlan"; |
|
41 |
|
|
42 |
@Autowired |
|
43 |
private EquipmentMaintainPlanService equipmentMaintainPlanService; |
|
44 |
|
|
45 |
@Autowired |
|
46 |
private EquipmentMaintainContentPlanService planService; |
|
47 |
|
|
48 |
@Autowired |
|
49 |
private DictService dictService; |
|
50 |
|
|
51 |
private ObjectMapper objectMapper = new ObjectMapper(); |
|
52 |
|
|
53 |
|
|
54 |
/** |
|
55 |
* 跳转到主页面 |
|
56 |
* |
|
57 |
* @author ruimin |
|
58 |
* @Date 2023-02-20 |
|
59 |
*/ |
|
60 |
@RequestMapping("") |
|
61 |
public String index() { |
|
62 |
return PREFIX + "/equipmentMaintainPlan.html"; |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* 新增页面 |
|
67 |
* |
|
68 |
* @author ruimin |
|
69 |
* @Date 2023-02-20 |
|
70 |
*/ |
|
71 |
@RequestMapping("/add") |
|
72 |
public String add() { |
|
73 |
return PREFIX + "/equipmentMaintainPlan_add.html"; |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* 编辑页面 |
|
78 |
* |
|
79 |
* @author ruimin |
|
80 |
* @Date 2023-02-20 |
|
81 |
*/ |
|
82 |
@RequestMapping("/edit") |
|
83 |
public String edit() { |
|
84 |
return PREFIX + "/equipmentMaintainPlan_edit.html"; |
|
85 |
} |
|
86 |
|
|
87 |
@RequestMapping("/eqList") |
|
88 |
public String eqList() { |
|
89 |
return PREFIX + "/equipmentList.html"; |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* 新增接口 |
|
94 |
* |
|
95 |
* @author ruimin |
|
96 |
* @Date 2023-02-20 |
|
97 |
*/ |
|
98 |
@RequestMapping("/addItem") |
|
99 |
@ResponseBody |
|
100 |
public ResponseData addItem(EquipmentMaintainPlanParam equipmentMaintainPlanParam,String dataList) { |
|
101 |
this.equipmentMaintainPlanService.add(equipmentMaintainPlanParam); |
|
102 |
if (!Objects.equals(null, dataList)) { |
|
103 |
Object jsonArr = JSONArray.parse(dataList); |
|
104 |
List<EquipmentMaintainContentPlanParam> list = Arrays.asList(objectMapper.convertValue(jsonArr, EquipmentMaintainContentPlanParam[].class)); |
|
105 |
for (EquipmentMaintainContentPlanParam planParm : list) { |
|
106 |
planParm.setPlanNo(equipmentMaintainPlanParam.getPlanNo()); |
|
107 |
planService.add(planParm); |
|
108 |
} |
|
109 |
} |
|
110 |
return ResponseData.success(); |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* 编辑接口 |
|
115 |
* |
|
116 |
* @author ruimin |
|
117 |
* @Date 2023-02-20 |
|
118 |
*/ |
|
119 |
@RequestMapping("/editItem") |
|
120 |
@ResponseBody |
|
121 |
public ResponseData editItem(EquipmentMaintainPlanParam equipmentMaintainPlanParam,String dataList) { |
|
122 |
this.equipmentMaintainPlanService.update(equipmentMaintainPlanParam); |
|
123 |
if (!Objects.equals(null, dataList)) { |
|
124 |
Object jsonArr = JSONArray.parse(dataList); |
|
125 |
List<EquipmentMaintainContentPlanParam> list = Arrays.asList(objectMapper.convertValue(jsonArr, EquipmentMaintainContentPlanParam[].class)); |
|
126 |
for (EquipmentMaintainContentPlanParam eqParam : list) { |
|
127 |
planService.remove(new QueryWrapper<EquipmentMaintainContentPlan>().eq("plan_no",equipmentMaintainPlanParam.getPlanNo())); |
|
128 |
} |
|
129 |
for (EquipmentMaintainContentPlanParam planParm : list) { |
|
130 |
planParm.setPlanNo(equipmentMaintainPlanParam.getPlanNo()); |
|
131 |
planService.add(planParm); |
|
132 |
} |
|
133 |
} |
|
134 |
return ResponseData.success(); |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* 删除接口 |
|
139 |
* |
|
140 |
* @author ruimin |
|
141 |
* @Date 2023-02-20 |
|
142 |
*/ |
|
143 |
@RequestMapping("/delete") |
|
144 |
@ResponseBody |
|
145 |
public ResponseData delete(EquipmentMaintainPlanParam equipmentMaintainPlanParam) { |
|
146 |
this.equipmentMaintainPlanService.delete(equipmentMaintainPlanParam); |
|
147 |
return ResponseData.success(); |
|
148 |
} |
|
149 |
|
|
150 |
/** |
|
151 |
* 查看详情接口 |
|
152 |
* |
|
153 |
* @author ruimin |
|
154 |
* @Date 2023-02-20 |
|
155 |
*/ |
|
156 |
@RequestMapping("/detail") |
|
157 |
@ResponseBody |
|
158 |
public ResponseData detail(EquipmentMaintainPlanParam equipmentMaintainPlanParam) { |
|
159 |
EquipmentMaintainPlan detail = this.equipmentMaintainPlanService.getById(equipmentMaintainPlanParam.getId()); |
|
160 |
return ResponseData.success(detail); |
|
161 |
} |
|
162 |
|
|
163 |
/** |
|
164 |
* 查询列表 |
|
165 |
* |
|
166 |
* @author ruimin |
|
167 |
* @Date 2023-02-20 |
|
168 |
*/ |
|
169 |
@ResponseBody |
|
170 |
@RequestMapping("/list") |
|
171 |
public LayuiPageInfo list(EquipmentMaintainPlanParam equipmentMaintainPlanParam) { |
|
172 |
return this.equipmentMaintainPlanService.findPageBySpec(equipmentMaintainPlanParam); |
|
173 |
} |
|
174 |
|
|
175 |
/** |
|
176 |
* 计划编号自动生成 |
|
177 |
* |
|
178 |
* @author ruimin |
|
179 |
* @Date 2023-02-20 |
|
180 |
*/ |
|
181 |
@ResponseBody |
|
182 |
@RequestMapping("/planNumberGenerate") |
|
183 |
public ResponseData planNumberGenerate(EquipmentMaintainPlanParam equipmentMaintainPlanParam) { |
|
184 |
String planNum = equipmentMaintainPlanService.planNumberGenerate(equipmentMaintainPlanParam); |
|
185 |
return ResponseData.success(planNum); |
|
186 |
} |
|
187 |
|
|
188 |
@ResponseBody |
|
189 |
@RequestMapping("/getIntervalUnit") |
|
190 |
public ResponseData getIntervalUnit() { |
|
191 |
List<Dict> dicts = dictService.listDicts(Long.valueOf("1640181177561346049")); |
|
192 |
return ResponseData.success(dicts); |
|
193 |
} |
|
194 |
|
|
195 |
} |
|
196 |
|
|
197 |
|