|
|
@@ -113,9 +113,26 @@ public class StorageDeviceInputController {
|
|
113
|
113
|
ObjectMapper mapper = new ObjectMapper();
|
|
114
|
114
|
try {
|
|
115
|
115
|
StorageDeviceinput storageDeviceinput = (StorageDeviceinput)mapper.readValue(deviceInputJson, StorageDeviceinput.class);
|
|
116
|
|
- storageDeviceinput.setStatus(0);
|
|
117
|
|
- deviceInputService.save(storageDeviceinput);
|
|
118
|
|
- modelMap.put("status", "success");
|
|
|
116
|
+ //校验同一类型同一名称同一规格型号的编号是否重复
|
|
|
117
|
+ StorageDeviceinputExample storageDeviceinputExample=new StorageDeviceinputExample();
|
|
|
118
|
+ StorageDeviceinputExample.Criteria criteria=storageDeviceinputExample.createCriteria();
|
|
|
119
|
+ criteria.andDeviceTypeEqualTo(storageDeviceinput.getDeviceType());
|
|
|
120
|
+ criteria.andDeviceNameEqualTo(storageDeviceinput.getDeviceName());
|
|
|
121
|
+ criteria.andModelEqualTo(storageDeviceinput.getModel());
|
|
|
122
|
+ criteria.andNumberEqualTo(storageDeviceinput.getNumber());
|
|
|
123
|
+ criteria.andOrgIdEqualTo(storageDeviceinput.getOrgId());
|
|
|
124
|
+ List<StorageDeviceinput> list = deviceInputService.queryByDevice(storageDeviceinputExample);
|
|
|
125
|
+ if (null != list && list.size() > 0) {
|
|
|
126
|
+ // 获取自己数据的ID
|
|
|
127
|
+ modelMap.put("status", "error");
|
|
|
128
|
+ modelMap.put("msg", "同一类型同一名称同一规格型号的设备资产编号已重复!");
|
|
|
129
|
+ return modelMap;
|
|
|
130
|
+ }else{//新增
|
|
|
131
|
+ storageDeviceinput.setStatus(0);
|
|
|
132
|
+ deviceInputService.save(storageDeviceinput);
|
|
|
133
|
+ modelMap.put("status", "success");
|
|
|
134
|
+ }
|
|
|
135
|
+
|
|
119
|
136
|
} catch (IOException e) {
|
|
120
|
137
|
modelMap.put("status", "error");
|
|
121
|
138
|
modelMap.put("msg", "保存失败!");
|