|
|
@@ -1,5 +1,7 @@
|
|
|
package com.sckw.slope.detection.service;
|
|
|
-
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
@@ -27,6 +29,7 @@ import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
|
|
|
import com.sckw.slope.detection.model.dto.*;
|
|
|
import com.sckw.slope.detection.model.param.DeviceAdd;
|
|
|
import com.sckw.slope.detection.model.param.DeviceQuery;
|
|
|
+import com.sckw.slope.detection.model.param.DeviceReferenceAdd;
|
|
|
import com.sckw.slope.detection.model.vo.*;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -217,6 +220,7 @@ public class DeviceService {
|
|
|
.eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
|
|
|
.eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
|
|
|
);
|
|
|
+ String snCode = device.getSnCode();
|
|
|
//获取基础要数
|
|
|
List<DevicePartModelVo> partData = new ArrayList<>();
|
|
|
partData = deviceModelPartMapper.selectByModelId(deviceModel.getId());
|
|
|
@@ -229,7 +233,12 @@ public class DeviceService {
|
|
|
}
|
|
|
references.forEach(re -> {
|
|
|
if (part.getPartName().equals(re.getItem())) {
|
|
|
+ SlopeData slopeData = slopeDataMapper.selectListByLine(snCode, re.getItem());//获取到当前测量值
|
|
|
part.setPartBaseData(re.getOriginalValue().toString());
|
|
|
+ if(!Objects.isNull(slopeData)){
|
|
|
+ part.setCurrentData(slopeData.getVal());
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -243,7 +252,12 @@ public class DeviceService {
|
|
|
for (DeviceIntegrationVo inter : intergData) {
|
|
|
references.forEach(re -> {
|
|
|
if (inter.getIntegrationName().equals(re.getItem())) {
|
|
|
+ SlopeData slopeData = slopeDataMapper.selectListByLine(snCode, re.getItem());//获取到当前测量值
|
|
|
inter.setIntegrationBaseData(re.getOriginalValue().toString());
|
|
|
+ if(!Objects.isNull(slopeData)){
|
|
|
+ inter.setCurrentData(slopeData.getVal());
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -580,5 +594,63 @@ public class DeviceService {
|
|
|
return HttpResult.ok(mapList);
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
+ public HttpResult referenceEdit(DeviceReferenceAdd deviceReference, HttpServletRequest response) {
|
|
|
+
|
|
|
+ HeaderData headerData = commonService.getHeaderData(response);
|
|
|
+ String listData = deviceReference.getReferceData();
|
|
|
+ Long deviceId = deviceReference.getDeviceId();
|
|
|
+ JSONArray array = JSON.parseArray(listData);
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ BigDecimal zero = new BigDecimal("0");
|
|
|
+ for(Object object : array){
|
|
|
+ JSONObject obj = (JSONObject)object;
|
|
|
+ KwsDeviceReference reference = deviceReferenceMapper.selectOne(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
+ .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
|
|
|
+ .eq(KwsDeviceReference::getDeviceId, deviceId)
|
|
|
+ .eq(KwsDeviceReference::getDelFlag, 0)
|
|
|
+ .eq(KwsDeviceReference::getItem, obj.get("item"))
|
|
|
+ );
|
|
|
+ long interId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
+ KwsDeviceReference kwsDeviceReference = new KwsDeviceReference();
|
|
|
+ BigDecimal value = new BigDecimal(obj.get("value").toString());
|
|
|
+
|
|
|
+ if(Objects.isNull(reference)){
|
|
|
+ kwsDeviceReference.setOffset(zero);
|
|
|
+ kwsDeviceReference.setOriginalValue(zero);
|
|
|
+ kwsDeviceReference.setCurrentValue(value);
|
|
|
+ }else{
|
|
|
+ //如果有数据,则先删除原有数据。
|
|
|
+ deviceReferenceMapper.update(null, new LambdaUpdateWrapper<KwsDeviceReference>()
|
|
|
+ .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
|
|
|
+ .eq(KwsDeviceReference::getDeviceId, deviceId)
|
|
|
+ .eq(KwsDeviceReference::getDelFlag, 0)
|
|
|
+ .eq(KwsDeviceReference::getItem, obj.get("item"))
|
|
|
+ .set(KwsDeviceReference::getDelFlag, NumberConstant.ONE)
|
|
|
+ );
|
|
|
+ BigDecimal offset = value.subtract(reference.getValue());
|
|
|
+ kwsDeviceReference.setOffset(offset);
|
|
|
+ kwsDeviceReference.setCurrentValue(reference.getValue());
|
|
|
+ kwsDeviceReference.setOriginalValue(value);
|
|
|
+ }
|
|
|
+ kwsDeviceReference.setId(interId);
|
|
|
+ kwsDeviceReference.setDeviceId(deviceId);
|
|
|
+ kwsDeviceReference.setMountainId(headerData.getCompanyId());
|
|
|
+ kwsDeviceReference.setType(Integer.parseInt(obj.get("type").toString()));
|
|
|
+ kwsDeviceReference.setItem(obj.get("item").toString());
|
|
|
+ kwsDeviceReference.setValue(value);
|
|
|
+
|
|
|
+
|
|
|
+ kwsDeviceReference.setCreateBy(Long.parseLong(headerData.getCreateBy()));
|
|
|
+ kwsDeviceReference.setCreateTime(now);
|
|
|
+ kwsDeviceReference.setStatus(NumberConstant.ONE);
|
|
|
+ kwsDeviceReference.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
|
|
|
+ kwsDeviceReference.setUpdateTime(now);
|
|
|
+ deviceReferenceMapper.insert(kwsDeviceReference);
|
|
|
+ }
|
|
|
+
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|