|
@@ -36,6 +36,7 @@ import javax.validation.*;
|
|
|
import javax.servlet.http.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.sql.SQLException;
|
|
|
+import java.sql.Timestamp;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
@@ -84,6 +85,8 @@ public class IotOpeationFillController {
|
|
|
for (IotOpeationFillSaveReqVO fill:fillList) {
|
|
|
IotDeviceRunLogDO logDO1 = new IotDeviceRunLogDO();
|
|
|
logDO1.setDeviceId(fill.getDeviceId());
|
|
|
+ LocalTime localTime = LocalTime.of(0,0);
|
|
|
+ logDO1.setCreateTime(LocalDateTime.of(fill.getCreateTime(),localTime));
|
|
|
List<IotDeviceRunLogDO> logList = iotOpeationFillService.getDeivceFillInfo(logDO1);
|
|
|
|
|
|
IotDeviceRunLogDO deviceRunLogDO = new IotDeviceRunLogDO();
|
|
@@ -93,7 +96,7 @@ public class IotOpeationFillController {
|
|
|
deviceRunLogDO.setFillContent(fill.getFillContent());
|
|
|
deviceRunLogDO.setPointCode(fill.getModelAttr());
|
|
|
deviceRunLogDO.setDeptId(fill.getDeptId());
|
|
|
- deviceRunLogDO.setCreateTime(LocalDateTime.now());
|
|
|
+ deviceRunLogDO.setCreateTime(LocalDateTime.of(fill.getCreateTime(),localTime));
|
|
|
deviceRunLogDO.setPointName(fill.getPointName());
|
|
|
if(logList.size()>0){
|
|
|
BigDecimal num1 = logList.get(0).getTotalRunTime();
|
|
@@ -120,14 +123,14 @@ public class IotOpeationFillController {
|
|
|
List<IotOpeationFillRespVO> fillList1 = iotOpeationFillService.getFillList(respVO);
|
|
|
|
|
|
boolean result = fillList1.stream().allMatch(e->e.getIsFill()==1);
|
|
|
- boolean result1 = fillList1.stream().allMatch(e->e.getIsFill()==0);
|
|
|
|
|
|
- if(result){
|
|
|
-
|
|
|
- }else if(result1){
|
|
|
+ IotDeviceRunLogDO deviceRunLogDO = new IotDeviceRunLogDO();
|
|
|
+ deviceRunLogDO.setId(createReqVO.get(0).getId());
|
|
|
|
|
|
+ if(result){
|
|
|
+ iotOpeationFillService.updateFillOrder(deviceRunLogDO);
|
|
|
}else{
|
|
|
-
|
|
|
+ iotOpeationFillService.updateFillOrder1(deviceRunLogDO);
|
|
|
}
|
|
|
|
|
|
return success(iotOpeationFillService.insertLog(logDO));
|
|
@@ -198,49 +201,90 @@ public class IotOpeationFillController {
|
|
|
@Operation(summary = "获得PMS 功能优化 设备模板属性")
|
|
|
@Parameter(name = "deviceCategoryName", description = "名称", required = true, example = "1024")
|
|
|
public CommonResult<List<IotModelTemplateAttrsDO>> getModelAttrs(@Valid IotModelTemplateAttrsRespVO vo) throws SQLException{
|
|
|
+
|
|
|
List<IotModelTemplateAttrsDO> list = iotOpeationFillService.getAttrsById(vo );
|
|
|
|
|
|
- /**
|
|
|
- * 根据设备名称和物属性名称查询时序数据库
|
|
|
- * 1、数采有值,已填写
|
|
|
- * 2、数采有值,未填写 满足
|
|
|
- * 3、数采无值,已填写 满足
|
|
|
- * 4、数采无值,未填写 满足
|
|
|
- */
|
|
|
+
|
|
|
List<YfDeviceDO> allDevice = yfDeviceService.getAllDevice();
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ LocalTime localTime = LocalTime.of(0,0,0);
|
|
|
+ LocalTime localTime1 = LocalTime.of(23,59,59);
|
|
|
+
|
|
|
+ LocalDateTime start = LocalDateTime.of(vo.getCreateTime(),localTime);
|
|
|
+ LocalDateTime end = LocalDateTime.of(vo.getCreateTime(),localTime1);
|
|
|
+
|
|
|
+ Timestamp startTime = Timestamp.valueOf(start);
|
|
|
+ Timestamp endTime = Timestamp.valueOf(end);
|
|
|
+
|
|
|
+
|
|
|
boolean exists = allDevice.stream()
|
|
|
.anyMatch(yfDeviceDO -> yfDeviceDO.getSerialNumber().equals(vo.getDeviceCode()));
|
|
|
|
|
|
+
|
|
|
+ IotDeviceRunLogDO logDO1 = new IotDeviceRunLogDO();
|
|
|
+ logDO1.setDeviceId(vo.getDeviceId());
|
|
|
+ LocalTime local = LocalTime.of(12, 0);
|
|
|
+ logDO1.setCreateTime(LocalDateTime.of(vo.getCreateTime(),local));
|
|
|
+ List<IotDeviceRunLogDO> logList = iotOpeationFillService.getDeivceFillInfo(logDO1);
|
|
|
+
|
|
|
+
|
|
|
if(exists){
|
|
|
for (IotModelTemplateAttrsDO attrsDO:list) {
|
|
|
DeviceVO dv= new DeviceVO();
|
|
|
+
|
|
|
dv.setDeviceName(vo.getDeviceCode().toLowerCase());
|
|
|
dv.setColName(attrsDO.getModelAttr());
|
|
|
+ dv.setTs(startTime);
|
|
|
+ dv.setTs1(endTime);
|
|
|
+
|
|
|
DeviceVO deviceVO = iDeviceService.getYesInfo(dv);
|
|
|
- if(!StringUtils.isEmpty(deviceVO)){
|
|
|
+
|
|
|
+ if(!StringUtils.isEmpty(deviceVO) && !deviceVO.getEarliestData().equals("0.0")){
|
|
|
attrsDO.setFillContent(
|
|
|
String.valueOf(Double.parseDouble(deviceVO.getLatestData())-Double.parseDouble(deviceVO.getEarliestData())));
|
|
|
attrsDO.setTotalRunTime(BigDecimal.valueOf(Double.parseDouble(deviceVO.getLatestData())));
|
|
|
+ /**
|
|
|
+ * 设置为数采
|
|
|
+ */
|
|
|
+ attrsDO.setIsCollection(1);
|
|
|
+ }else{
|
|
|
+ if(logList.size()>0){
|
|
|
+ for (IotDeviceRunLogDO log:logList) {
|
|
|
+ if(log.getPointName().equals(attrsDO.getName())){
|
|
|
+ attrsDO.setFillContent(log.getFillContent());
|
|
|
+ attrsDO.setTotalRunTime(log.getTotalRunTime());
|
|
|
+ /**
|
|
|
+ * 设置为非数采
|
|
|
+ */
|
|
|
+ attrsDO.setIsCollection(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- IotDeviceRunLogDO logDO1 = new IotDeviceRunLogDO();
|
|
|
- logDO1.setDeviceId(vo.getDeviceId());
|
|
|
- LocalTime localTime = LocalTime.of(12, 0);
|
|
|
- logDO1.setCreateTime(LocalDateTime.of(vo.getCreateTime(),localTime));
|
|
|
- List<IotDeviceRunLogDO> logList = iotOpeationFillService.getDeivceFillInfo(logDO1);
|
|
|
- if(logList.size()>0){
|
|
|
- for (IotDeviceRunLogDO log:logList) {
|
|
|
+ }else{
|
|
|
+ if(logList.size()>0){
|
|
|
for (IotModelTemplateAttrsDO attrsDO:list) {
|
|
|
- if(log.getPointName().equals(attrsDO.getName())){
|
|
|
- attrsDO.setFillContent(log.getFillContent());
|
|
|
- attrsDO.setTotalRunTime(log.getTotalRunTime());
|
|
|
+ for (IotDeviceRunLogDO log:logList) {
|
|
|
+ if(log.getPointName().equals(attrsDO.getName())){
|
|
|
+ attrsDO.setFillContent(log.getFillContent());
|
|
|
+ attrsDO.setTotalRunTime(log.getTotalRunTime());
|
|
|
+ /**
|
|
|
+ * 设置为非数采
|
|
|
+ */
|
|
|
+ attrsDO.setIsCollection(0);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return success(BeanUtils.toBean(list,IotModelTemplateAttrsDO.class));
|
|
|
}
|
|
|
|