|
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
8
|
8
|
import com.cn.esermis.dpld.entity.AnalyticalInstruments;
|
9
|
9
|
import com.cn.esermis.dpld.entity.DataAcquisitionInstrument;
|
10
|
10
|
import com.cn.esermis.dpld.entity.DetectMonitoringFactor;
|
|
11
|
+import com.cn.esermis.dpld.mapper.DataAcquisitionInstrumentMapper;
|
11
|
12
|
import com.cn.esermis.dpld.model.AjaxResult;
|
12
|
13
|
import com.cn.esermis.dpld.model.AnalyticalInstrumentsVo;
|
13
|
14
|
import com.cn.esermis.dpld.model.DataAcquisitionInstrumentVo;
|
|
@@ -42,52 +43,72 @@ public class DataAcquisitionInstrumentController {
|
42
|
43
|
private IDetectMonitoringFactorService detectMonitoringFactorService;
|
43
|
44
|
@Resource
|
44
|
45
|
private IDataAcquisitionInstrumentService dataAcquisitionInstrumentService;
|
|
46
|
+ @Resource
|
|
47
|
+ private DataAcquisitionInstrumentMapper dataAcquisitionInstrumentMapper;
|
45
|
48
|
@Autowired
|
46
|
49
|
private RedisTemplate<String, Object> redisTemplate;
|
|
50
|
+
|
47
|
51
|
/**
|
48
|
52
|
* 获取数采仪信息表
|
49
|
53
|
*/
|
50
|
54
|
@GetMapping("/list")
|
51
|
|
- public AjaxResult list(DataAcquisitionInstrumentVo vo, HttpServletRequest request)
|
52
|
|
- {
|
|
55
|
+ public AjaxResult list(DataAcquisitionInstrumentVo vo, HttpServletRequest request) {
|
53
|
56
|
IPage<DataAcquisitionInstrument> page = new Page<>(vo.getPageNum(), vo.getPageSize());
|
54
|
57
|
QueryWrapper<DataAcquisitionInstrument> wrapper = new QueryWrapper<>();
|
55
|
58
|
BaseUser userInfo = TokenUtils.getUserInfo(extractToken(request));
|
56
|
|
-// wrapper.eq("company_code",userInfo.getCompanyId());
|
|
59
|
+ String verifyCompany = dataAcquisitionInstrumentMapper.verifyCompany(userInfo.getCompanyId());
|
|
60
|
+ if (vo.getCompanyName() != null) {
|
|
61
|
+ String companyId = userInfo.getCompanyId();
|
|
62
|
+ if (verifyCompany != null && verifyCompany.length() < 5) {
|
|
63
|
+ List<String> companyCodes = dataAcquisitionInstrumentService.getComponyListAll(vo.getCompanyName());
|
|
64
|
+ if (!companyCodes.isEmpty()) {
|
|
65
|
+ wrapper.in("company_code", companyCodes);
|
|
66
|
+ }
|
|
67
|
+ }else{
|
|
68
|
+ List<String> companyCodes = dataAcquisitionInstrumentService.getComponyList(vo.getCompanyName(), companyId);
|
|
69
|
+ if (!companyCodes.isEmpty()) {
|
|
70
|
+ wrapper.in("company_code", companyCodes);
|
|
71
|
+ }
|
|
72
|
+ }
|
|
73
|
+ }
|
|
74
|
+ if (vo.getOutletName() != null) {
|
|
75
|
+ wrapper.like("outlet_name", vo.getOutletName());
|
|
76
|
+ }
|
57
|
77
|
wrapper.orderByDesc("department_code");
|
58
|
78
|
IPage<DataAcquisitionInstrument> pageList = dataAcquisitionInstrumentService.page(page, wrapper);
|
59
|
79
|
IPage<DataAcquisitionInstrumentVo> volits = new Page<>();
|
60
|
|
- if (!pageList.getRecords().isEmpty()){
|
|
80
|
+ if (!pageList.getRecords().isEmpty()) {
|
61
|
81
|
volits.setTotal(pageList.getTotal());
|
62
|
82
|
volits.setCurrent(pageList.getCurrent());
|
63
|
83
|
volits.setSize(pageList.getSize());
|
64
|
84
|
List<DataAcquisitionInstrument> records = pageList.getRecords();
|
65
|
85
|
List<DataAcquisitionInstrumentVo> revoList = new ArrayList<>();
|
66
|
86
|
// 查询企业
|
67
|
|
- Map<String,Object> componyMap = dataAcquisitionInstrumentService.getComponyMap();
|
|
87
|
+ Map<String, Object> componyMap = dataAcquisitionInstrumentService.getComponyMap();
|
68
|
88
|
// 查询工厂
|
69
|
89
|
Map<String, Object> departmentMap = dataAcquisitionInstrumentService.getDepartmentMap();
|
70
|
|
- records.forEach(x->{
|
|
90
|
+ records.forEach(x -> {
|
71
|
91
|
DataAcquisitionInstrumentVo instrumentVo = new DataAcquisitionInstrumentVo();
|
72
|
92
|
List<AnalyticalInstruments> analyticalInstruments = analyticalInstrumentsService.getByDataAcquisitionInstrumentid(x.getId());
|
73
|
93
|
BeanUtils.copyProperties(x, instrumentVo);
|
74
|
|
- if (instrumentVo.getCompanyCode()!=null && componyMap.get(instrumentVo.getCompanyCode())!=null){
|
75
|
|
- Map componyMapobj = (Map)componyMap.get(instrumentVo.getCompanyCode());
|
|
94
|
+ if (instrumentVo.getCompanyCode() != null && componyMap.get(instrumentVo.getCompanyCode()) != null) {
|
|
95
|
+ Map componyMapobj = (Map) componyMap.get(instrumentVo.getCompanyCode());
|
76
|
96
|
instrumentVo.setCompanyName(componyMapobj.get("companylongname").toString());
|
77
|
97
|
}
|
78
|
|
- if (instrumentVo.getDepartmentCode()!=null && departmentMap.get(instrumentVo.getDepartmentCode())!=null){
|
79
|
|
- Map componyMapobj = (Map)departmentMap.get(instrumentVo.getDepartmentCode());
|
|
98
|
+ if (instrumentVo.getDepartmentCode() != null && departmentMap.get(instrumentVo.getDepartmentCode()) != null) {
|
|
99
|
+ Map componyMapobj = (Map) departmentMap.get(instrumentVo.getDepartmentCode());
|
80
|
100
|
instrumentVo.setDepartmentName(componyMapobj.get("departmentname").toString());
|
81
|
|
- };
|
82
|
|
- if (!analyticalInstruments.isEmpty()){
|
|
101
|
+ }
|
|
102
|
+ ;
|
|
103
|
+ if (!analyticalInstruments.isEmpty()) {
|
83
|
104
|
List<AnalyticalInstrumentsVo> analyticalInstrumentList = new ArrayList<>();
|
84
|
|
- analyticalInstruments.forEach(y->{
|
|
105
|
+ analyticalInstruments.forEach(y -> {
|
85
|
106
|
AnalyticalInstrumentsVo analyticalInstrumentsVo = new AnalyticalInstrumentsVo();
|
86
|
107
|
BeanUtils.copyProperties(y, analyticalInstrumentsVo);
|
87
|
108
|
analyticalInstrumentList.add(analyticalInstrumentsVo);
|
88
|
109
|
List<DetectMonitoringFactor> analyticalInstrumentId = detectMonitoringFactorService.listByParentId(y.getId());
|
89
|
|
- if (!analyticalInstrumentId.isEmpty()){
|
90
|
|
- analyticalInstrumentId.forEach(z->{
|
|
110
|
+ if (!analyticalInstrumentId.isEmpty()) {
|
|
111
|
+ analyticalInstrumentId.forEach(z -> {
|
91
|
112
|
analyticalInstrumentsVo.getDetectMonitoringFactors().add(z);
|
92
|
113
|
});
|
93
|
114
|
}
|
|
@@ -107,21 +128,20 @@ public class DataAcquisitionInstrumentController {
|
107
|
128
|
* 根据菜单编号获取详细信息
|
108
|
129
|
*/
|
109
|
130
|
@GetMapping(value = "delete/{id}")
|
110
|
|
- public AjaxResult delete(@PathVariable String id)
|
111
|
|
- {
|
|
131
|
+ public AjaxResult delete(@PathVariable String id) {
|
112
|
132
|
DataAcquisitionInstrument dataAcquisitionInstrument = dataAcquisitionInstrumentService.getById(id);
|
113
|
133
|
DataAcquisitionInstrumentVo instrumentVo = new DataAcquisitionInstrumentVo();
|
114
|
|
- if (dataAcquisitionInstrument != null){
|
|
134
|
+ if (dataAcquisitionInstrument != null) {
|
115
|
135
|
BeanUtils.copyProperties(dataAcquisitionInstrument, instrumentVo);
|
116
|
136
|
List<AnalyticalInstruments> analyticalInstruments = analyticalInstrumentsService.getByDataAcquisitionInstrumentid(dataAcquisitionInstrument.getId());
|
117
|
|
- if (!analyticalInstruments.isEmpty()){
|
|
137
|
+ if (!analyticalInstruments.isEmpty()) {
|
118
|
138
|
List<AnalyticalInstrumentsVo> analyticalInstrumentList = new ArrayList<>();
|
119
|
|
- analyticalInstruments.forEach(y->{
|
|
139
|
+ analyticalInstruments.forEach(y -> {
|
120
|
140
|
if (y.getId() != null)
|
121
|
|
- detectMonitoringFactorService.remove(new QueryWrapper<DetectMonitoringFactor>().eq("analytical_instrument_id", y.getId()));
|
|
141
|
+ detectMonitoringFactorService.remove(new QueryWrapper<DetectMonitoringFactor>().eq("analytical_instrument_id", y.getId()));
|
122
|
142
|
});
|
123
|
143
|
if (analyticalInstruments.isEmpty())
|
124
|
|
- analyticalInstrumentsService.remove(new QueryWrapper<AnalyticalInstruments>().eq("data_acquisition_instrument_id", dataAcquisitionInstrument.getId()));
|
|
144
|
+ analyticalInstrumentsService.remove(new QueryWrapper<AnalyticalInstruments>().eq("data_acquisition_instrument_id", dataAcquisitionInstrument.getId()));
|
125
|
145
|
instrumentVo.setAnalyticalInstruments(analyticalInstrumentList);
|
126
|
146
|
}
|
127
|
147
|
}
|
|
@@ -135,27 +155,26 @@ public class DataAcquisitionInstrumentController {
|
135
|
155
|
* 根据菜单编号获取详细信息
|
136
|
156
|
*/
|
137
|
157
|
@GetMapping(value = "/{id}")
|
138
|
|
- public AjaxResult getInfo(@PathVariable String id)
|
139
|
|
- {
|
|
158
|
+ public AjaxResult getInfo(@PathVariable String id) {
|
140
|
159
|
DataAcquisitionInstrument dataAcquisitionInstrument = dataAcquisitionInstrumentService.getById(id);
|
141
|
160
|
DataAcquisitionInstrumentVo instrumentVo = new DataAcquisitionInstrumentVo();
|
142
|
|
- if (dataAcquisitionInstrument != null){
|
|
161
|
+ if (dataAcquisitionInstrument != null) {
|
143
|
162
|
BeanUtils.copyProperties(dataAcquisitionInstrument, instrumentVo);
|
144
|
163
|
List<AnalyticalInstruments> analyticalInstruments = analyticalInstrumentsService.getByDataAcquisitionInstrumentid(dataAcquisitionInstrument.getId());
|
145
|
|
- if (!analyticalInstruments.isEmpty()){
|
|
164
|
+ if (!analyticalInstruments.isEmpty()) {
|
146
|
165
|
List<AnalyticalInstrumentsVo> analyticalInstrumentList = new ArrayList<>();
|
147
|
|
- analyticalInstruments.forEach(x->{
|
148
|
|
- AnalyticalInstrumentsVo analyticalInstrumentsVo = new AnalyticalInstrumentsVo();
|
149
|
|
- BeanUtils.copyProperties(x, analyticalInstrumentsVo);
|
|
166
|
+ analyticalInstruments.forEach(x -> {
|
|
167
|
+ AnalyticalInstrumentsVo analyticalInstrumentsVo = new AnalyticalInstrumentsVo();
|
|
168
|
+ BeanUtils.copyProperties(x, analyticalInstrumentsVo);
|
150
|
169
|
|
151
|
|
- List<DetectMonitoringFactor> analyticalInstrumentId = detectMonitoringFactorService.listByParentId(x.getId());
|
152
|
|
- if (!analyticalInstrumentId.isEmpty()){
|
153
|
|
- analyticalInstrumentId.forEach(z->{
|
154
|
|
- analyticalInstrumentsVo.getDetectMonitoringFactors().add(z);
|
155
|
|
- });
|
156
|
|
- }
|
157
|
|
- analyticalInstrumentList.add(analyticalInstrumentsVo);
|
158
|
|
- });
|
|
170
|
+ List<DetectMonitoringFactor> analyticalInstrumentId = detectMonitoringFactorService.listByParentId(x.getId());
|
|
171
|
+ if (!analyticalInstrumentId.isEmpty()) {
|
|
172
|
+ analyticalInstrumentId.forEach(z -> {
|
|
173
|
+ analyticalInstrumentsVo.getDetectMonitoringFactors().add(z);
|
|
174
|
+ });
|
|
175
|
+ }
|
|
176
|
+ analyticalInstrumentList.add(analyticalInstrumentsVo);
|
|
177
|
+ });
|
159
|
178
|
instrumentVo.setAnalyticalInstruments(analyticalInstrumentList);
|
160
|
179
|
}
|
161
|
180
|
}
|
|
@@ -170,19 +189,18 @@ public class DataAcquisitionInstrumentController {
|
170
|
189
|
*/
|
171
|
190
|
@PostMapping("/save")
|
172
|
191
|
@Transactional
|
173
|
|
- public AjaxResult save(@Validated @RequestBody DataAcquisitionInstrumentVo vo)
|
174
|
|
- {
|
|
192
|
+ public AjaxResult save(@Validated @RequestBody DataAcquisitionInstrumentVo vo) {
|
175
|
193
|
DataAcquisitionInstrument dataAcquisitionInstrument = new DataAcquisitionInstrument();
|
176
|
194
|
BeanUtils.copyProperties(vo, dataAcquisitionInstrument);
|
177
|
195
|
boolean save = dataAcquisitionInstrumentService.saveOrUpdate(dataAcquisitionInstrument);
|
178
|
|
- if (save && vo.getAnalyticalInstruments()!=null){
|
|
196
|
+ if (save && vo.getAnalyticalInstruments() != null) {
|
179
|
197
|
List<AnalyticalInstrumentsVo> analyticalInstrumentList = vo.getAnalyticalInstruments();
|
180
|
198
|
// 删除子项 全删全增操作
|
181
|
199
|
{
|
182
|
|
- if (dataAcquisitionInstrument.getId() != null){
|
|
200
|
+ if (dataAcquisitionInstrument.getId() != null) {
|
183
|
201
|
List<AnalyticalInstruments> dataAcquisitionInstrumentId = analyticalInstrumentsService.getByDataAcquisitionInstrumentid(dataAcquisitionInstrument.getId());
|
184
|
|
- if (!dataAcquisitionInstrumentId.isEmpty()){
|
185
|
|
- analyticalInstrumentList.forEach(y->{
|
|
202
|
+ if (!dataAcquisitionInstrumentId.isEmpty()) {
|
|
203
|
+ analyticalInstrumentList.forEach(y -> {
|
186
|
204
|
detectMonitoringFactorService.remove(new QueryWrapper<DetectMonitoringFactor>().eq("analytical_instrument_id", y.getId()));
|
187
|
205
|
});
|
188
|
206
|
analyticalInstrumentsService.remove(new QueryWrapper<AnalyticalInstruments>().eq("data_acquisition_instrument_id", dataAcquisitionInstrument.getId()));
|
|
@@ -190,22 +208,22 @@ public class DataAcquisitionInstrumentController {
|
190
|
208
|
}
|
191
|
209
|
}
|
192
|
210
|
// 新增子表
|
193
|
|
- analyticalInstrumentList.forEach(x->{
|
|
211
|
+ analyticalInstrumentList.forEach(x -> {
|
194
|
212
|
AnalyticalInstruments analyticalInstruments = new AnalyticalInstruments();
|
195
|
213
|
BeanUtils.copyProperties(x, analyticalInstruments);
|
196
|
214
|
analyticalInstruments.setDataAcquisitionInstrumentId(dataAcquisitionInstrument.getId());
|
197
|
215
|
boolean save1 = analyticalInstrumentsService.save(analyticalInstruments);
|
198
|
|
- if (x.getDetectMonitoringFactors()!=null && save1){
|
|
216
|
+ if (x.getDetectMonitoringFactors() != null && save1) {
|
199
|
217
|
List<DetectMonitoringFactor> detectMonitoringFactors = x.getDetectMonitoringFactors();
|
200
|
|
- detectMonitoringFactors.forEach(y->{
|
|
218
|
+ detectMonitoringFactors.forEach(y -> {
|
201
|
219
|
y.setAnalyticalInstrumentId(analyticalInstruments.getId());
|
202
|
220
|
y.setDataAcquisitionInstrumentId(dataAcquisitionInstrument.getId());
|
203
|
221
|
boolean save2 = detectMonitoringFactorService.save(y);
|
204
|
|
- if (!save2){
|
|
222
|
+ if (!save2) {
|
205
|
223
|
throw new RuntimeException("添加失败");
|
206
|
224
|
}
|
207
|
225
|
});
|
208
|
|
- }
|
|
226
|
+ }
|
209
|
227
|
});
|
210
|
228
|
}
|
211
|
229
|
List<OutletAndFactorVo> selectlist = dataAcquisitionInstrumentService.selectlist();
|
|
@@ -214,39 +232,36 @@ public class DataAcquisitionInstrumentController {
|
214
|
232
|
}
|
215
|
233
|
|
216
|
234
|
@GetMapping(value = "getCompony")
|
217
|
|
- public AjaxResult getCompony()
|
218
|
|
- {
|
219
|
|
- List<Map<String,Object>> list = dataAcquisitionInstrumentService.getCompony();
|
|
235
|
+ public AjaxResult getCompony() {
|
|
236
|
+ List<Map<String, Object>> list = dataAcquisitionInstrumentService.getCompony();
|
220
|
237
|
return success(list);
|
221
|
238
|
}
|
222
|
239
|
|
223
|
240
|
|
224
|
241
|
/**
|
225
|
242
|
* 部门
|
|
243
|
+ *
|
226
|
244
|
* @return
|
227
|
245
|
*/
|
228
|
246
|
@GetMapping(value = "getDepartment/{componyid}")
|
229
|
|
- public AjaxResult getDepartment(@PathVariable String componyid)
|
230
|
|
- {
|
231
|
|
- List<Map<String,Object>> list = dataAcquisitionInstrumentService.getDepartment(componyid);
|
|
247
|
+ public AjaxResult getDepartment(@PathVariable String componyid) {
|
|
248
|
+ List<Map<String, Object>> list = dataAcquisitionInstrumentService.getDepartment(componyid);
|
232
|
249
|
return success(list);
|
233
|
250
|
}
|
234
|
251
|
|
235
|
252
|
|
236
|
|
-
|
237
|
253
|
/**
|
238
|
254
|
* 获取数采仪信息表
|
239
|
255
|
*/
|
240
|
256
|
@GetMapping("/listByCode")
|
241
|
|
- public AjaxResult listByCode(HttpServletRequest request)
|
242
|
|
- {
|
|
257
|
+ public AjaxResult listByCode(HttpServletRequest request) {
|
243
|
258
|
QueryWrapper<DataAcquisitionInstrument> wrapper = new QueryWrapper<>();
|
244
|
259
|
BaseUser userInfo = TokenUtils.getUserInfo(extractToken(request));
|
245
|
|
- if (userInfo==null){
|
|
260
|
+ if (userInfo == null) {
|
246
|
261
|
return error("无数据");
|
247
|
262
|
}
|
248
|
|
- wrapper.eq(userInfo.getCompanyId()!=null,"department_code", userInfo.getCompanyId());
|
249
|
|
- wrapper.eq(userInfo.getFactoryId()!=null,"company_code", userInfo.getFactoryId());
|
|
263
|
+ wrapper.eq(userInfo.getCompanyId() != null, "department_code", userInfo.getCompanyId());
|
|
264
|
+ wrapper.eq(userInfo.getFactoryId() != null, "company_code", userInfo.getFactoryId());
|
250
|
265
|
// List<DataAcquisitionInstrument> dataAcquisitionInstruments = dataAcquisitionInstrumentService.listByCode(vo);
|
251
|
266
|
List<DataAcquisitionInstrument> dataAcquisitionInstruments = dataAcquisitionInstrumentService.list(wrapper);
|
252
|
267
|
return success(dataAcquisitionInstruments);
|