|
|
@@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
|
|
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
|
|
+import cn.iocoder.yudao.module.pms.annotation.AntiDuplicateSubmit;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotmodeltemplateattrs.vo.IotModelTemplateAttrsRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.*;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportSaveReqVO;
|
|
|
@@ -304,6 +305,8 @@ public class IotOpeationFillController {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@PostMapping("/insertDataList")
|
|
|
@Operation(summary = "创建运行记录工单设备集填写信息")
|
|
|
+ // 添加防刷注解,5秒内不允许重复请求
|
|
|
+ @AntiDuplicateSubmit(timeout = 5, message = "5秒内不允许重复提交,请稍后再试")
|
|
|
public CommonResult<Integer> insertDataList(@Valid @RequestBody List<IotOperationSaveInfoVO> createReqVO) {
|
|
|
|
|
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
|
@@ -1343,11 +1346,18 @@ public class IotOpeationFillController {
|
|
|
if (deviceVO != null) {
|
|
|
// 数采设备逻辑
|
|
|
double diff = Double.parseDouble(deviceVO.getLatestData()) - Double.parseDouble(deviceVO.getEarliestData());
|
|
|
- attrsDO.setFillContent(String.valueOf(diff));
|
|
|
- attrsDO.setTotalRunTime(BigDecimal.valueOf(Double.parseDouble(deviceVO.getLatestData())));
|
|
|
- attrsDO.setIsCollection(1);
|
|
|
+ //如果当日差值为0,则证明该设备虽然是数采,但累计有问题,执行非数采逻辑
|
|
|
+ if(diff==0.0){
|
|
|
+ unCollectionDev(logInfoMap, maxLogMap, attrsDO, attrName);
|
|
|
+ }else{
|
|
|
+ attrsDO.setFillContent(String.valueOf(diff));
|
|
|
+ attrsDO.setTotalRunTime(BigDecimal.valueOf(Double.parseDouble(deviceVO.getLatestData())));
|
|
|
+ attrsDO.setIsCollection(1);
|
|
|
+ }
|
|
|
}else{
|
|
|
- IotDeviceRunLogDO logInfo = logInfoMap.get(attrName);
|
|
|
+ // 非数采设备逻辑
|
|
|
+ unCollectionDev(logInfoMap, maxLogMap, attrsDO, attrName);
|
|
|
+ /*IotDeviceRunLogDO logInfo = logInfoMap.get(attrName);
|
|
|
IotDeviceRunLogDO maxLog = maxLogMap.get(attrName);
|
|
|
|
|
|
if (logInfo != null) {
|
|
|
@@ -1357,11 +1367,12 @@ public class IotOpeationFillController {
|
|
|
attrsDO.setFillContent("");
|
|
|
attrsDO.setTotalRunTime(maxLog != null ? maxLog.getTotalRunTime() : BigDecimal.ZERO);
|
|
|
}
|
|
|
- attrsDO.setIsCollection(0);
|
|
|
+ attrsDO.setIsCollection(0);*/
|
|
|
}
|
|
|
}else{
|
|
|
// 非数采设备逻辑
|
|
|
- IotDeviceRunLogDO logInfo = logInfoMap.get(attrName);
|
|
|
+ unCollectionDev(logInfoMap, maxLogMap, attrsDO, attrName);
|
|
|
+ /*IotDeviceRunLogDO logInfo = logInfoMap.get(attrName);
|
|
|
IotDeviceRunLogDO maxLog = maxLogMap.get(attrName);
|
|
|
|
|
|
if (logInfo != null) {
|
|
|
@@ -1371,13 +1382,26 @@ public class IotOpeationFillController {
|
|
|
attrsDO.setFillContent("");
|
|
|
attrsDO.setTotalRunTime(maxLog != null ? maxLog.getTotalRunTime() : BigDecimal.ZERO);
|
|
|
}
|
|
|
- attrsDO.setIsCollection(0);
|
|
|
+ attrsDO.setIsCollection(0);*/
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //非数采设备处理逻辑
|
|
|
+ private void unCollectionDev(Map<String, IotDeviceRunLogDO> logInfoMap, Map<String, IotDeviceRunLogDO> maxLogMap, IotModelTemplateAttrsDO attrsDO, String attrName) {
|
|
|
+ IotDeviceRunLogDO logInfo = logInfoMap.get(attrName);
|
|
|
+ IotDeviceRunLogDO maxLog = maxLogMap.get(attrName);
|
|
|
+ if (logInfo != null) {
|
|
|
+ attrsDO.setFillContent(logInfo.getFillContent());
|
|
|
+ attrsDO.setTotalRunTime(logInfo.getTotalRunTime() != null ? logInfo.getTotalRunTime() : BigDecimal.ZERO);
|
|
|
+ } else {
|
|
|
+ attrsDO.setFillContent("");
|
|
|
+ attrsDO.setTotalRunTime(maxLog != null ? maxLog.getTotalRunTime() : BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ attrsDO.setIsCollection(0);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
//**************
|
|
|
@@ -1615,16 +1639,27 @@ public class IotOpeationFillController {
|
|
|
|
|
|
DeviceVO deviceVO = iDeviceService.getYesInfo(dv);
|
|
|
|
|
|
- if(!StringUtils.isEmpty(deviceVO) && !deviceVO.getEarliestData().equals("0.0")){
|
|
|
- attrsDO.setFillContent(
|
|
|
+ if(!StringUtils.isEmpty(deviceVO)){
|
|
|
+
|
|
|
+ double diff = Double.parseDouble(deviceVO.getLatestData()) - Double.parseDouble(deviceVO.getEarliestData());
|
|
|
+
|
|
|
+ if(diff==0.0){
|
|
|
+ extracted(logDO1, attrsDO);
|
|
|
+ }else{
|
|
|
+ attrsDO.setFillContent(String.valueOf(diff));
|
|
|
+ attrsDO.setTotalRunTime(BigDecimal.valueOf(Double.parseDouble(deviceVO.getLatestData())));
|
|
|
+ /**
|
|
|
+ * 设置为数采
|
|
|
+ */
|
|
|
+ attrsDO.setIsCollection(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*attrsDO.setFillContent(
|
|
|
String.valueOf(Double.parseDouble(deviceVO.getLatestData())-Double.parseDouble(deviceVO.getEarliestData())));
|
|
|
- attrsDO.setTotalRunTime(BigDecimal.valueOf(Double.parseDouble(deviceVO.getLatestData())));
|
|
|
- /**
|
|
|
- * 设置为数采
|
|
|
- */
|
|
|
- attrsDO.setIsCollection(1);
|
|
|
+ attrsDO.setTotalRunTime(BigDecimal.valueOf(Double.parseDouble(deviceVO.getLatestData())));*/
|
|
|
+
|
|
|
}else{
|
|
|
- logDO1.setPointName(attrsDO.getName());
|
|
|
+ /*logDO1.setPointName(attrsDO.getName());
|
|
|
IotDeviceRunLogDO logInfo = iotOpeationFillService.getLogInfo(logDO1);
|
|
|
IotDeviceRunLogDO maxLog = iotOpeationFillService.getMaxFillInfo(logDO1);
|
|
|
if(!StringUtils.isEmpty(logInfo)){
|
|
|
@@ -1636,12 +1671,10 @@ public class IotOpeationFillController {
|
|
|
}else{
|
|
|
attrsDO.setTotalRunTime(maxLog.getTotalRunTime());
|
|
|
}
|
|
|
- /**
|
|
|
+ *//**
|
|
|
* 设置为非数采
|
|
|
- */
|
|
|
+ *//*
|
|
|
attrsDO.setIsCollection(0);
|
|
|
-
|
|
|
-
|
|
|
}else{
|
|
|
attrsDO.setFillContent("");
|
|
|
if(StringUtils.isEmpty(maxLog)){
|
|
|
@@ -1649,11 +1682,12 @@ public class IotOpeationFillController {
|
|
|
}else{
|
|
|
attrsDO.setTotalRunTime(maxLog.getTotalRunTime());
|
|
|
}
|
|
|
- /**
|
|
|
+ *//**
|
|
|
* 设置为非数采
|
|
|
- */
|
|
|
+ *//*
|
|
|
attrsDO.setIsCollection(0);
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ extracted(logDO1, attrsDO);
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
@@ -1711,6 +1745,37 @@ public class IotOpeationFillController {
|
|
|
return success(BeanUtils.toBean(resut,IotModelTemplateAttrsDO1.class));
|
|
|
}
|
|
|
|
|
|
+ private void extracted(IotDeviceRunLogDO logDO1, IotModelTemplateAttrsDO attrsDO) {
|
|
|
+ logDO1.setPointName(attrsDO.getName());
|
|
|
+ IotDeviceRunLogDO logInfo = iotOpeationFillService.getLogInfo(logDO1);
|
|
|
+ IotDeviceRunLogDO maxLog = iotOpeationFillService.getMaxFillInfo(logDO1);
|
|
|
+ if(!StringUtils.isEmpty(logInfo)){
|
|
|
+
|
|
|
+ attrsDO.setFillContent(logInfo.getFillContent());
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(maxLog)){
|
|
|
+ attrsDO.setTotalRunTime(BigDecimal.valueOf(0));
|
|
|
+ }else{
|
|
|
+ attrsDO.setTotalRunTime(maxLog.getTotalRunTime());
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 设置为非数采
|
|
|
+ */
|
|
|
+ attrsDO.setIsCollection(0);
|
|
|
+ }else{
|
|
|
+ attrsDO.setFillContent("");
|
|
|
+ if(StringUtils.isEmpty(maxLog)){
|
|
|
+ attrsDO.setTotalRunTime(BigDecimal.valueOf(0));
|
|
|
+ }else{
|
|
|
+ attrsDO.setTotalRunTime(maxLog.getTotalRunTime());
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 设置为非数采
|
|
|
+ */
|
|
|
+ attrsDO.setIsCollection(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 工具方法:将字符串转换为整数,空字符串视为0
|
|
|
private double safeParseInt(String str) {
|
|
|
if (str == null || str.trim().isEmpty()) {
|