|
|
@@ -97,14 +97,27 @@ public class DeviceService {
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
- public HttpResult dels(String ids) {
|
|
|
- List<Long> list = StringUtils.splitStrToList(ids, Long.class);
|
|
|
+ public HttpResult dels(String ids, HttpServletRequest response) {
|
|
|
+ KwsDevice device = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
|
|
|
+ .eq(KwsDevice::getId, ids));
|
|
|
+ if(Objects.isNull(device)){
|
|
|
+ throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.DEVICE_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ //List<Long> list = StringUtils.splitStrToList(ids, Long.class);
|
|
|
int update = deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
|
|
|
- .in(KwsDevice::getId, list)
|
|
|
+ .in(KwsDevice::getId, ids)
|
|
|
.set(KwsDevice::getDelFlag, NumberConstant.ONE));
|
|
|
if (update < 1) {
|
|
|
throw new BusinessException("删除设备异常");
|
|
|
}
|
|
|
+ //获取新增设备的型号
|
|
|
+ HeaderData headerData = commonService.getHeaderData(response);
|
|
|
+ KwsDeviceModel model = deviceModelMapper.selectOne(new LambdaQueryWrapper<KwsDeviceModel>()
|
|
|
+ .eq(KwsDeviceModel::getId, device.getModelId()));
|
|
|
+ Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ logMap.put("name", device.getName());
|
|
|
+ logMap.put("type", model.getName());
|
|
|
+ commonService.insertLog(MessageLogEnum.DEVICE_DELETE, headerData, logMap, Long.parseLong(headerData.getUpdateBy()));
|
|
|
return HttpResult.ok("删除设备成功");
|
|
|
}
|
|
|
|
|
|
@@ -137,7 +150,7 @@ public class DeviceService {
|
|
|
if (!CollectionUtils.isEmpty(alarmData)) {
|
|
|
for (int i = 0; i < alarmData.size(); i++) {
|
|
|
Map<String, Long> map = alarmData.get(i);
|
|
|
- if (map.get("pid").toString().equals(vo.getId().toString())) {
|
|
|
+ if (map.get("device_id").toString().equals(vo.getId().toString())) {
|
|
|
vo.setDataErrorCount(map.get("count"));
|
|
|
vo.setDeviceErrorCount(map.get("count"));
|
|
|
}
|
|
|
@@ -194,6 +207,15 @@ public class DeviceService {
|
|
|
deIntergration.setUpdateTime(now);
|
|
|
deviceIntegrationMapper.insert(deIntergration);
|
|
|
}
|
|
|
+
|
|
|
+ //新增log
|
|
|
+ //获取新增设备的型号
|
|
|
+ KwsDeviceModel model = deviceModelMapper.selectOne(new LambdaQueryWrapper<KwsDeviceModel>()
|
|
|
+ .eq(KwsDeviceModel::getId, device.getModelId()));
|
|
|
+ Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ logMap.put("name", device.getName());
|
|
|
+ logMap.put("type", model.getName());
|
|
|
+ commonService.insertLog(MessageLogEnum.DEVICE_ADD, headerData, logMap, Long.parseLong(headerData.getUpdateBy()));
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
|
|
|
@@ -268,49 +290,7 @@ public class DeviceService {
|
|
|
|
|
|
|
|
|
|
|
|
- //vo.setReference(references);
|
|
|
- //获取td里面的要数数据
|
|
|
- /*List<Map<String, DeviceOutputValueVO>> mapList = new ArrayList<>();
|
|
|
- if (!CollectionUtils.isEmpty(references)) {
|
|
|
- vo.setReference(references);
|
|
|
- references.forEach(re -> {
|
|
|
- String snCode = device.getSnCode();
|
|
|
- String item = re.getItem();
|
|
|
- Date date = new Date();
|
|
|
- BigDecimal decimal = new BigDecimal("0.00");
|
|
|
- String dateStart = DateUtil.getLastWeekDateEndToString(6);
|
|
|
- String dateEnd = LocalDateTime.now().toString();
|
|
|
- List<SlopeData> selected = slopeDataMapper.selectLineList(snCode, item, dateStart,dateEnd);
|
|
|
- List<Map<String, Object>> mapListXy = new ArrayList<>();
|
|
|
- if (!CollectionUtils.isEmpty(selected)) {
|
|
|
- for (int i = 0; i < selected.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- SlopeData currSlopeData = selected.get(i);
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
|
|
|
- String key = simpleDateFormat.format(currSlopeData.getTs());
|
|
|
- SlopeData lastSlopeData = selected.get(i + 1);
|
|
|
- Date localDateTime = currSlopeData.getTs();
|
|
|
- long epochMilli1 = 0L;
|
|
|
- String val2 = "0";
|
|
|
- Date localDateTime1 = lastSlopeData.getTs();
|
|
|
- if (lastSlopeData != null) {
|
|
|
- epochMilli1 = localDateTime1.getTime();
|
|
|
- val2 = lastSlopeData.getVal();
|
|
|
- }
|
|
|
- long epochMilli = localDateTime.getTime();
|
|
|
- epochMilli1 = localDateTime1.getTime();
|
|
|
- String val1 = currSlopeData.getVal();
|
|
|
- long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
|
|
|
- long val = Long.parseLong(val1) - Long.parseLong(val2);
|
|
|
- decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 9, BigDecimal.ROUND_HALF_UP);
|
|
|
- map.put(key, decimal);
|
|
|
- mapListXy.add(map);
|
|
|
- }
|
|
|
- }
|
|
|
- vo.setMonitor(mapListXy);
|
|
|
- });
|
|
|
|
|
|
- }*/
|
|
|
return HttpResult.ok(vo);
|
|
|
}
|
|
|
|
|
|
@@ -380,28 +360,39 @@ public class DeviceService {
|
|
|
.set(KwsDeviceIntegration::getDelFlag, NumberConstant.ONE)
|
|
|
.set(KwsDeviceIntegration::getUpdateBy,Long.parseLong(headerData.getUpdateBy()) )
|
|
|
.set(KwsDeviceIntegration::getUpdateTime, now));
|
|
|
- if (update < 1) {
|
|
|
- throw new BusinessException("删除设备集成要素异常");
|
|
|
- }
|
|
|
+ //if (update < 1) {
|
|
|
+ //throw new BusinessException("删除设备集成要素异常");
|
|
|
+ //}
|
|
|
|
|
|
//新增到数据表kws_device_Integration
|
|
|
KwsDeviceIntegration deIntergration = new KwsDeviceIntegration();
|
|
|
String[] temp;//接收分割后的数组
|
|
|
- temp = deviceAdd.getIntegrationId().split(Global.COMMA);
|
|
|
-
|
|
|
- for (int i = 0; i < temp.length; i++) {
|
|
|
- long interId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
- deIntergration.setId(interId);
|
|
|
- deIntergration.setDeviceId(Long.parseLong(deviceAdd.getId()));
|
|
|
- deIntergration.setMountainId(headerData.getCompanyId());
|
|
|
- deIntergration.setIntegrationId(Long.parseLong(temp[i]));
|
|
|
- deIntergration.setCreateBy(Long.parseLong(headerData.getCreateBy()));
|
|
|
- deIntergration.setCreateTime(now);
|
|
|
- deIntergration.setStatus(NumberConstant.ZERO);
|
|
|
- deIntergration.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
|
|
|
- deIntergration.setUpdateTime(now);
|
|
|
- deviceIntegrationMapper.insert(deIntergration);
|
|
|
+ if(!deviceAdd.getIntegrationId().isEmpty()){
|
|
|
+ temp = deviceAdd.getIntegrationId().split(Global.COMMA);
|
|
|
+
|
|
|
+ for (int i = 0; i < temp.length; i++) {
|
|
|
+ long interId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
+ deIntergration.setId(interId);
|
|
|
+ deIntergration.setDeviceId(Long.parseLong(deviceAdd.getId()));
|
|
|
+ deIntergration.setMountainId(headerData.getCompanyId());
|
|
|
+ deIntergration.setIntegrationId(Long.parseLong(temp[i]));
|
|
|
+ deIntergration.setCreateBy(Long.parseLong(headerData.getCreateBy()));
|
|
|
+ deIntergration.setCreateTime(now);
|
|
|
+ deIntergration.setStatus(NumberConstant.ZERO);
|
|
|
+ deIntergration.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
|
|
|
+ deIntergration.setUpdateTime(now);
|
|
|
+ deviceIntegrationMapper.insert(deIntergration);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ //新增log
|
|
|
+ //获取新增设备的型号
|
|
|
+ KwsDeviceModel model = deviceModelMapper.selectOne(new LambdaQueryWrapper<KwsDeviceModel>()
|
|
|
+ .eq(KwsDeviceModel::getId, device.getModelId()));
|
|
|
+ Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ logMap.put("name", device.getName());
|
|
|
+ logMap.put("type", model.getName());
|
|
|
+ commonService.insertLog(MessageLogEnum.DEVICE_UPDATE, headerData, logMap, Long.parseLong(headerData.getUpdateBy()));
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
|
|
|
@@ -633,7 +624,7 @@ public class DeviceService {
|
|
|
BigDecimal offset = value.subtract(reference.getValue());
|
|
|
kwsDeviceReference.setOffset(offset);
|
|
|
kwsDeviceReference.setCurrentValue(reference.getValue());
|
|
|
- kwsDeviceReference.setOriginalValue(value);
|
|
|
+ kwsDeviceReference.setOriginalValue(reference.getOriginalValue());
|
|
|
}
|
|
|
kwsDeviceReference.setId(interId);
|
|
|
kwsDeviceReference.setDeviceId(deviceId);
|