Преглед на файлове

feature: 智能控制V2版本 第八版(调试)

Jayhaw преди 2 седмици
родител
ревизия
f361f2261f

+ 1 - 1
src/main/java/cn/sciento/farm/automationv2/app/handler/DeviceControlHelper.java

@@ -50,7 +50,7 @@ public class DeviceControlHelper {
 //        dto.setNode(device.getNode());
 //        dto.setNode(device.getNode());
 //        dto.setCircuit(device.getCircuit());
 //        dto.setCircuit(device.getCircuit());
         dto.setSwitchId(device.getSwitchId());
         dto.setSwitchId(device.getSwitchId());
-        dto.setSw(1); // 球阀控制开启
+        dto.setSw(device.getSw()); // 球阀控制开启
         dto.setTenantId(tenantId);
         dto.setTenantId(tenantId);
         dto.setBallValuePercent(targetAngle); // 设置角度百分比
         dto.setBallValuePercent(targetAngle); // 设置角度百分比
         dto.setRemark("本次控制由智能控制V2调用 - 球阀角度控制");
         dto.setRemark("本次控制由智能控制V2调用 - 球阀角度控制");

+ 11 - 6
src/main/java/cn/sciento/farm/automationv2/app/service/SafeShutdownService.java

@@ -4,8 +4,10 @@ import cn.sciento.farm.automationv2.api.dto.GatewayControlDto;
 import cn.sciento.farm.automationv2.app.handler.DeviceControlHelper;
 import cn.sciento.farm.automationv2.app.handler.DeviceControlHelper;
 import cn.sciento.farm.automationv2.domain.business.DeviceBusiness;
 import cn.sciento.farm.automationv2.domain.business.DeviceBusiness;
 import cn.sciento.farm.automationv2.domain.entity.TaskExecution;
 import cn.sciento.farm.automationv2.domain.entity.TaskExecution;
+import cn.sciento.farm.automationv2.domain.entity.mongo.IrrigationTaskLog;
 import cn.sciento.farm.automationv2.domain.entity.mongo.IrrigationTaskMainVO;
 import cn.sciento.farm.automationv2.domain.entity.mongo.IrrigationTaskMainVO;
 import cn.sciento.farm.automationv2.domain.enums.AckStatus;
 import cn.sciento.farm.automationv2.domain.enums.AckStatus;
+import cn.sciento.farm.automationv2.domain.repository.IrrigationTaskLogRepository;
 import cn.sciento.farm.automationv2.domain.repository.TaskExecutionRepository;
 import cn.sciento.farm.automationv2.domain.repository.TaskExecutionRepository;
 import cn.sciento.farm.automationv2.domain.valueobject.DeviceInfo;
 import cn.sciento.farm.automationv2.domain.valueobject.DeviceInfo;
 import cn.sciento.farm.automationv2.domain.valueobject.ExecutionNode;
 import cn.sciento.farm.automationv2.domain.valueobject.ExecutionNode;
@@ -40,6 +42,7 @@ public class SafeShutdownService {
     private final AckManager ackManager;
     private final AckManager ackManager;
     private final ExecutionPlanStore executionPlanStore;
     private final ExecutionPlanStore executionPlanStore;
     private final TaskLogService logService;
     private final TaskLogService logService;
+    private final IrrigationTaskLogRepository taskLogRepository;
 
 
     /**
     /**
      * 安全关闭所有已开启的设备
      * 安全关闭所有已开启的设备
@@ -47,15 +50,16 @@ public class SafeShutdownService {
      * @param executionId 执行实例ID
      * @param executionId 执行实例ID
      * @return 关闭结果摘要
      * @return 关闭结果摘要
      */
      */
-    public ShutdownResult shutdown(Long executionId) {
+    public ShutdownResult shutdown(TaskExecution execution) {
+        Long executionId = execution.getId();
         log.info("开始安全关闭设备,executionId={}", executionId);
         log.info("开始安全关闭设备,executionId={}", executionId);
 
 
         // 加载执行实例
         // 加载执行实例
-        TaskExecution execution = taskExecutionRepository.selectByPrimaryKey(executionId);
-        if (execution == null) {
-            log.error("执行实例不存在,executionId={}", executionId);
-            return ShutdownResult.error("执行实例不存在");
-        }
+//        TaskExecution execution = taskExecutionRepository.selectByPrimaryKey(executionId);
+//        if (execution == null) {
+//            log.error("执行实例不存在,executionId={}", executionId);
+//            return ShutdownResult.error("执行实例不存在");
+//        }
 
 
         // 提取已开启的设备
         // 提取已开启的设备
         OpenedDevices openedDevices = extractOpenedDevices(executionId);
         OpenedDevices openedDevices = extractOpenedDevices(executionId);
@@ -225,6 +229,7 @@ public class SafeShutdownService {
                                     "BALL_VALVE".equals(d.getDeviceType()))
                                     "BALL_VALVE".equals(d.getDeviceType()))
                             .collect(Collectors.toList());
                             .collect(Collectors.toList());
                     result.valves.addAll(valves);
                     result.valves.addAll(valves);
+                    // 如果存在同灌区ack部分成功的,需要额外查出
                     break;
                     break;
 
 
                 default:
                 default:

+ 3 - 0
src/main/java/cn/sciento/farm/automationv2/app/service/TaskLogService.java

@@ -91,6 +91,7 @@ public class TaskLogService {
             mainData.setGroupName("预启动中");
             mainData.setGroupName("预启动中");
             mainData.setTotalGroup(zones.size());
             mainData.setTotalGroup(zones.size());
             mainData.setGroupNum(0);
             mainData.setGroupNum(0);
+            mainData.setPumpId(task.getPumpDeviceId());
             // 存缓存
             // 存缓存
             saveMain(task.getId(),mainData);
             saveMain(task.getId(),mainData);
 
 
@@ -392,6 +393,8 @@ public class TaskLogService {
                 nodeVO.setDeviceId(device.getDeviceId().toString());
                 nodeVO.setDeviceId(device.getDeviceId().toString());
                 nodeVO.setDeviceName(device.getDeviceName());
                 nodeVO.setDeviceName(device.getDeviceName());
                 nodeVO.setDeviceType(device.getDeviceType());
                 nodeVO.setDeviceType(device.getDeviceType());
+                nodeVO.setBrand(device.getBrand());
+                nodeVO.setVtype(device.getVtype());
                 nodeVO.setSw(device.getSw());
                 nodeVO.setSw(device.getSw());
                 nodeVO.setAction(node.getNodeType());
                 nodeVO.setAction(node.getNodeType());
                 nodeVO.setStatus("PENDING");
                 nodeVO.setStatus("PENDING");

+ 1 - 1
src/main/java/cn/sciento/farm/automationv2/app/service/irrigationTask/impl/IrrigationTaskServiceImpl.java

@@ -219,7 +219,7 @@ public class IrrigationTaskServiceImpl implements IrrigationTaskService {
         taskExecutionRepository.updateByPrimaryKeySelective(execution);
         taskExecutionRepository.updateByPrimaryKeySelective(execution);
 
 
         // 触发安全关闭
         // 触发安全关闭
-        SafeShutdownService.ShutdownResult result = safeShutdownService.shutdown(executionId);
+        SafeShutdownService.ShutdownResult result = safeShutdownService.shutdown(execution);
 
 
         // 更新安全关闭结果
         // 更新安全关闭结果
         execution.setSafeCloseStatus(result.isSuccess() ? "SUCCESS" : "PARTIAL");
         execution.setSafeCloseStatus(result.isSuccess() ? "SUCCESS" : "PARTIAL");

+ 8 - 0
src/main/java/cn/sciento/farm/automationv2/domain/entity/mongo/IrrigationTaskGroupNodeVO.java

@@ -36,5 +36,13 @@ public class IrrigationTaskGroupNodeVO {
     @ApiModelProperty("设备结束时间")
     @ApiModelProperty("设备结束时间")
     private LocalDateTime deviceEndTime;
     private LocalDateTime deviceEndTime;
 
 
+    /**
+     * 球阀类型:直通/三通
+     */
+    private Integer vtype;
+
+    @ApiModelProperty("品牌")
+    private String brand;
+
     
     
 }
 }

+ 4 - 0
src/main/java/cn/sciento/farm/automationv2/domain/entity/mongo/IrrigationTaskMainVO.java

@@ -67,4 +67,8 @@ public class IrrigationTaskMainVO {
 
 
     @ApiModelProperty("当前轮灌组")
     @ApiModelProperty("当前轮灌组")
     private Integer groupNum;
     private Integer groupNum;
+
+    @ApiModelProperty("水泵Id")
+    private Long pumpId;
+
 }
 }

+ 2 - 0
src/main/java/cn/sciento/farm/automationv2/domain/valueobject/ExecutionNode.java

@@ -103,6 +103,8 @@ public class ExecutionNode {
                 return (Integer) seconds;
                 return (Integer) seconds;
             } else if (seconds instanceof String) {
             } else if (seconds instanceof String) {
                 return Integer.parseInt((String) seconds);
                 return Integer.parseInt((String) seconds);
+            }else if (seconds instanceof Long){
+                return ((Long) seconds).intValue();
             }
             }
         }
         }
         return 0;
         return 0;