|
@@ -93,13 +93,11 @@ public class DeviceService {
|
|
|
KwsDeviceReferenceMapper deviceReferenceMapper;
|
|
KwsDeviceReferenceMapper deviceReferenceMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public HttpResult dels(String ids, HttpServletRequest response) {
|
|
public HttpResult dels(String ids, HttpServletRequest response) {
|
|
|
KwsDevice device = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
|
|
KwsDevice device = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
|
|
|
.eq(KwsDevice::getId, ids));
|
|
.eq(KwsDevice::getId, ids));
|
|
|
- if(Objects.isNull(device)){
|
|
|
|
|
|
|
+ if (Objects.isNull(device)) {
|
|
|
throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.DEVICE_NOT_EXISTS);
|
|
throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.DEVICE_NOT_EXISTS);
|
|
|
}
|
|
}
|
|
|
//List<Long> list = StringUtils.splitStrToList(ids, Long.class);
|
|
//List<Long> list = StringUtils.splitStrToList(ids, Long.class);
|
|
@@ -247,7 +245,7 @@ public class DeviceService {
|
|
|
//获取基础要数
|
|
//获取基础要数
|
|
|
List<DevicePartModelVo> partData = new ArrayList<>();
|
|
List<DevicePartModelVo> partData = new ArrayList<>();
|
|
|
partData = deviceModelPartMapper.selectByModelId(deviceModel.getId());
|
|
partData = deviceModelPartMapper.selectByModelId(deviceModel.getId());
|
|
|
- if(!Objects.isNull(partData)){//首先在kws_device_model_part获取数据,然后到字典中查询
|
|
|
|
|
|
|
+ if (!Objects.isNull(partData)) {//首先在kws_device_model_part获取数据,然后到字典中查询
|
|
|
for (DevicePartModelVo part : partData) {
|
|
for (DevicePartModelVo part : partData) {
|
|
|
for (SystemDict value : dictList.values()) {
|
|
for (SystemDict value : dictList.values()) {
|
|
|
if (part.getPartName().equals(value.getValue())) {
|
|
if (part.getPartName().equals(value.getValue())) {
|
|
@@ -255,14 +253,14 @@ public class DeviceService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
references.forEach(re -> {
|
|
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());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ 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());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
vo.setPart(partData);
|
|
vo.setPart(partData);
|
|
@@ -271,13 +269,13 @@ public class DeviceService {
|
|
|
//获取集成要素
|
|
//获取集成要素
|
|
|
List<DeviceIntegrationVo> intergData = new ArrayList<>();
|
|
List<DeviceIntegrationVo> intergData = new ArrayList<>();
|
|
|
intergData = deviceIntegrationMapper.selectListByParmsAndInterName(vo);
|
|
intergData = deviceIntegrationMapper.selectListByParmsAndInterName(vo);
|
|
|
- if(!Objects.isNull(intergData)){
|
|
|
|
|
|
|
+ if (!Objects.isNull(intergData)) {
|
|
|
for (DeviceIntegrationVo inter : intergData) {
|
|
for (DeviceIntegrationVo inter : intergData) {
|
|
|
references.forEach(re -> {
|
|
references.forEach(re -> {
|
|
|
if (inter.getIntegrationName().equals(re.getItem())) {
|
|
if (inter.getIntegrationName().equals(re.getItem())) {
|
|
|
SlopeData slopeData = slopeDataMapper.selectListByLine(snCode, re.getItem());//获取到当前测量值
|
|
SlopeData slopeData = slopeDataMapper.selectListByLine(snCode, re.getItem());//获取到当前测量值
|
|
|
inter.setIntegrationBaseData(re.getOriginalValue().toString());
|
|
inter.setIntegrationBaseData(re.getOriginalValue().toString());
|
|
|
- if(!Objects.isNull(slopeData)){
|
|
|
|
|
|
|
+ if (!Objects.isNull(slopeData)) {
|
|
|
inter.setCurrentData(slopeData.getVal());
|
|
inter.setCurrentData(slopeData.getVal());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -288,8 +286,6 @@ public class DeviceService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
return HttpResult.ok(vo);
|
|
return HttpResult.ok(vo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -353,20 +349,20 @@ public class DeviceService {
|
|
|
device.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
|
|
device.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
|
|
|
device.setUpdateTime(now);
|
|
device.setUpdateTime(now);
|
|
|
Integer updateStatus = deviceMapper.updateById(device);
|
|
Integer updateStatus = deviceMapper.updateById(device);
|
|
|
- if(updateStatus == 1){
|
|
|
|
|
|
|
+ if (updateStatus == 1) {
|
|
|
int update = deviceIntegrationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceIntegration>()
|
|
int update = deviceIntegrationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceIntegration>()
|
|
|
.eq(KwsDeviceIntegration::getDeviceId, deviceAdd.getId())
|
|
.eq(KwsDeviceIntegration::getDeviceId, deviceAdd.getId())
|
|
|
.set(KwsDeviceIntegration::getDelFlag, NumberConstant.ONE)
|
|
.set(KwsDeviceIntegration::getDelFlag, NumberConstant.ONE)
|
|
|
- .set(KwsDeviceIntegration::getUpdateBy,Long.parseLong(headerData.getUpdateBy()) )
|
|
|
|
|
|
|
+ .set(KwsDeviceIntegration::getUpdateBy, Long.parseLong(headerData.getUpdateBy()))
|
|
|
.set(KwsDeviceIntegration::getUpdateTime, now));
|
|
.set(KwsDeviceIntegration::getUpdateTime, now));
|
|
|
//if (update < 1) {
|
|
//if (update < 1) {
|
|
|
- //throw new BusinessException("删除设备集成要素异常");
|
|
|
|
|
|
|
+ //throw new BusinessException("删除设备集成要素异常");
|
|
|
//}
|
|
//}
|
|
|
|
|
|
|
|
//新增到数据表kws_device_Integration
|
|
//新增到数据表kws_device_Integration
|
|
|
KwsDeviceIntegration deIntergration = new KwsDeviceIntegration();
|
|
KwsDeviceIntegration deIntergration = new KwsDeviceIntegration();
|
|
|
String[] temp;//接收分割后的数组
|
|
String[] temp;//接收分割后的数组
|
|
|
- if(!deviceAdd.getIntegrationId().isEmpty()){
|
|
|
|
|
|
|
+ if (!deviceAdd.getIntegrationId().isEmpty()) {
|
|
|
temp = deviceAdd.getIntegrationId().split(Global.COMMA);
|
|
temp = deviceAdd.getIntegrationId().split(Global.COMMA);
|
|
|
|
|
|
|
|
for (int i = 0; i < temp.length; i++) {
|
|
for (int i = 0; i < temp.length; i++) {
|
|
@@ -419,7 +415,7 @@ public class DeviceService {
|
|
|
headerData.getMountainId(), status, Long.parseLong(deviceId));
|
|
headerData.getMountainId(), status, Long.parseLong(deviceId));
|
|
|
|
|
|
|
|
|
|
|
|
|
- List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(headerData.getMountainId(), Long.parseLong(projectId), Long.parseLong(deviceId),null);
|
|
|
|
|
|
|
+ List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(headerData.getMountainId(), Long.parseLong(projectId), Long.parseLong(deviceId), null);
|
|
|
List<String> deviceIds = new ArrayList<>();
|
|
List<String> deviceIds = new ArrayList<>();
|
|
|
if (!CollectionUtils.isEmpty(projectDeviceList)) {
|
|
if (!CollectionUtils.isEmpty(projectDeviceList)) {
|
|
|
deviceIds = projectDeviceList.stream().map(ProjectDeviceVO::getId).distinct().collect(Collectors.toList());
|
|
deviceIds = projectDeviceList.stream().map(ProjectDeviceVO::getId).distinct().collect(Collectors.toList());
|
|
@@ -499,7 +495,7 @@ public class DeviceService {
|
|
|
if (itemList.contains(re.getItem())) {
|
|
if (itemList.contains(re.getItem())) {
|
|
|
BigDecimal offsetValue = new BigDecimal("0.00");
|
|
BigDecimal offsetValue = new BigDecimal("0.00");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
|
|
|
- offsetValue = new BigDecimal(val).divide(new BigDecimal(1000),12,BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
|
+ offsetValue = new BigDecimal(val).divide(new BigDecimal(1000), 12, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
}
|
|
|
// currentMeasurement.put(itemName, offsetValue);
|
|
// currentMeasurement.put(itemName, offsetValue);
|
|
|
vo.setCurrentMeasurementValue(offsetValue == null ? null : offsetValue.toString());
|
|
vo.setCurrentMeasurementValue(offsetValue == null ? null : offsetValue.toString());
|
|
@@ -548,10 +544,13 @@ public class DeviceService {
|
|
|
if (!CollectionUtils.isEmpty(stringList)) {
|
|
if (!CollectionUtils.isEmpty(stringList)) {
|
|
|
for (int i = 0; i < stringList.size(); i++) {
|
|
for (int i = 0; i < stringList.size(); i++) {
|
|
|
String snCode = kwsDevice.getSnCode();
|
|
String snCode = kwsDevice.getSnCode();
|
|
|
- InsTables insTables = insTablesMapper.selectTableIsExit("devicesv2" + snCode);
|
|
|
|
|
|
|
+ InsTables insTables = insTablesMapper.selectTableIsExit("devices" + snCode);
|
|
|
if (insTables == null) {
|
|
if (insTables == null) {
|
|
|
- insTablesMapper.createTable("devicesv2" + snCode);
|
|
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
|
|
+// if (insTables == null) {
|
|
|
|
|
+// insTablesMapper.createTable("devices_" + snCode);
|
|
|
|
|
+// }
|
|
|
List<SlopeData> selected = slopeDataMapper.selectListByLineOrderByCreateTime(snCode, stringList.get(i));
|
|
List<SlopeData> selected = slopeDataMapper.selectListByLineOrderByCreateTime(snCode, stringList.get(i));
|
|
|
if (!CollectionUtils.isEmpty(selected)) {
|
|
if (!CollectionUtils.isEmpty(selected)) {
|
|
|
if (selected.size() == 2) {
|
|
if (selected.size() == 2) {
|
|
@@ -569,7 +568,7 @@ public class DeviceService {
|
|
|
// long epochMilli1 = date1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
// long epochMilli1 = date1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
|
|
long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
|
|
|
long val = Long.parseLong(currSlopeData.getVal()) - Long.parseLong(lastSlopeData.getVal());
|
|
long val = Long.parseLong(currSlopeData.getVal()) - Long.parseLong(lastSlopeData.getVal());
|
|
|
- decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))),12,BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
|
+ decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 12, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -595,8 +594,8 @@ public class DeviceService {
|
|
|
JSONArray array = JSON.parseArray(listData);
|
|
JSONArray array = JSON.parseArray(listData);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
BigDecimal zero = new BigDecimal("0");
|
|
BigDecimal zero = new BigDecimal("0");
|
|
|
- for(Object object : array){
|
|
|
|
|
- JSONObject obj = (JSONObject)object;
|
|
|
|
|
|
|
+ for (Object object : array) {
|
|
|
|
|
+ JSONObject obj = (JSONObject) object;
|
|
|
KwsDeviceReference reference = deviceReferenceMapper.selectOne(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
KwsDeviceReference reference = deviceReferenceMapper.selectOne(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
.eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
|
|
.eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
|
|
|
.eq(KwsDeviceReference::getDeviceId, deviceId)
|
|
.eq(KwsDeviceReference::getDeviceId, deviceId)
|
|
@@ -605,13 +604,13 @@ public class DeviceService {
|
|
|
);
|
|
);
|
|
|
long interId = new IdWorker(NumberConstant.ONE).nextId();
|
|
long interId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
KwsDeviceReference kwsDeviceReference = new KwsDeviceReference();
|
|
KwsDeviceReference kwsDeviceReference = new KwsDeviceReference();
|
|
|
- BigDecimal value = new BigDecimal(obj.get("value").toString());
|
|
|
|
|
|
|
+ BigDecimal value = new BigDecimal(obj.get("value").toString());
|
|
|
|
|
|
|
|
- if(Objects.isNull(reference)){
|
|
|
|
|
|
|
+ if (Objects.isNull(reference)) {
|
|
|
kwsDeviceReference.setOffset(zero);
|
|
kwsDeviceReference.setOffset(zero);
|
|
|
kwsDeviceReference.setOriginalValue(zero);
|
|
kwsDeviceReference.setOriginalValue(zero);
|
|
|
kwsDeviceReference.setCurrentValue(value);
|
|
kwsDeviceReference.setCurrentValue(value);
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
//如果有数据,则先删除原有数据。
|
|
//如果有数据,则先删除原有数据。
|
|
|
deviceReferenceMapper.update(null, new LambdaUpdateWrapper<KwsDeviceReference>()
|
|
deviceReferenceMapper.update(null, new LambdaUpdateWrapper<KwsDeviceReference>()
|
|
|
.eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
|
|
.eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
|
|
@@ -623,13 +622,13 @@ public class DeviceService {
|
|
|
//BigDecimal offset = value.subtract(reference.getValue());
|
|
//BigDecimal offset = value.subtract(reference.getValue());
|
|
|
kwsDeviceReference.setOriginalValue(reference.getOriginalValue());//原始基准不变
|
|
kwsDeviceReference.setOriginalValue(reference.getOriginalValue());//原始基准不变
|
|
|
//调整经纬度
|
|
//调整经纬度
|
|
|
- if(type.equals(NumberConstant.ONE)){
|
|
|
|
|
|
|
+ if (type.equals(NumberConstant.ONE)) {
|
|
|
BigDecimal offset = commonService.computeOffset(value.toString(), obj.get("item").toString(), reference);
|
|
BigDecimal offset = commonService.computeOffset(value.toString(), obj.get("item").toString(), reference);
|
|
|
kwsDeviceReference.setOffset(offset);//当前位置-上一次的位置的距离的距离
|
|
kwsDeviceReference.setOffset(offset);//当前位置-上一次的位置的距离的距离
|
|
|
kwsDeviceReference.setCurrentValue(value);
|
|
kwsDeviceReference.setCurrentValue(value);
|
|
|
kwsDeviceReference.setValue(reference.getCurrentValue());
|
|
kwsDeviceReference.setValue(reference.getCurrentValue());
|
|
|
|
|
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
BigDecimal currentValue = commonService.computeOffset(value.toString(), obj.get("item").toString(), reference);
|
|
BigDecimal currentValue = commonService.computeOffset(value.toString(), obj.get("item").toString(), reference);
|
|
|
kwsDeviceReference.setValue(reference.getCurrentValue());
|
|
kwsDeviceReference.setValue(reference.getCurrentValue());
|
|
|
kwsDeviceReference.setOffset(value);
|
|
kwsDeviceReference.setOffset(value);
|
|
@@ -661,6 +660,15 @@ public class DeviceService {
|
|
|
String companyId = commonService.getHeaderData(request).getCompanyId();
|
|
String companyId = commonService.getHeaderData(request).getCompanyId();
|
|
|
//查询基本要素
|
|
//查询基本要素
|
|
|
List<BaseItemDTO> baseItem = projectDeviceMapper.selectDataByDeviceId(Long.parseLong(id));
|
|
List<BaseItemDTO> baseItem = projectDeviceMapper.selectDataByDeviceId(Long.parseLong(id));
|
|
|
|
|
+ Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(baseItem)) {
|
|
|
|
|
+ for (BaseItemDTO baseItemDTO : baseItem) {
|
|
|
|
|
+ baseItemDTO.setPartNameLabel(baseItemDTO.getPartName() == null ? null :
|
|
|
|
|
+ (dictByDictCode == null ? baseItemDTO.getPartName() :
|
|
|
|
|
+ (dictByDictCode.get(baseItemDTO.getPartName()) == null ?
|
|
|
|
|
+ (baseItemDTO.getPartName()) : dictByDictCode.get(baseItemDTO.getPartName()).getLabel())));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
List<IntegrationItemVO> integrationItem = projectDeviceMapper.selectIntegrationItemByDeviceId(Long.parseLong(id));
|
|
List<IntegrationItemVO> integrationItem = projectDeviceMapper.selectIntegrationItemByDeviceId(Long.parseLong(id));
|
|
|
com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject();
|
|
com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject();
|
|
|
jsonObject.put("baseItem", baseItem);
|
|
jsonObject.put("baseItem", baseItem);
|