|
|
@@ -13,7 +13,6 @@ import com.yunfeiyun.agmp.iot.common.constant.devicetype.ServiceNameConst;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotRunHaoSfdata;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotSfElementfactor;
|
|
|
-import com.yunfeiyun.agmp.iot.common.domain.IotSfIrrigationRecord;
|
|
|
import com.yunfeiyun.agmp.iot.common.enums.EnumIrrigationRecord;
|
|
|
import com.yunfeiyun.agmp.iot.common.enums.EnumSfElementType;
|
|
|
import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
|
|
|
@@ -24,6 +23,7 @@ import com.yunfeiyun.agmp.iotm.device.sf.domain.*;
|
|
|
import com.yunfeiyun.agmp.iotm.device.sf.service.IIotSfCommService;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotSfElementfactorService;
|
|
|
+import com.yunfeiyun.agmp.iotm.web.service.IIotSfIrrigationOprecordService;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotSfIrrigationRecordService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
@@ -51,6 +51,9 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
@Autowired
|
|
|
private IIotSfIrrigationRecordService iotSfIrrigationRecordService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IIotSfIrrigationOprecordService iotSfIrrigationOprecordService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取设备状态
|
|
|
*
|
|
|
@@ -741,6 +744,8 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
sfTypeMap.put(runMode, null);
|
|
|
|
|
|
Map<EnumSfElementType, Integer> sfTypeValueMap = new HashMap<>();
|
|
|
+ IotSfElementfactorAlreadyListResVo groupResVo = null;
|
|
|
+
|
|
|
for(IotSfElementfactorInfoVo element : resultList){
|
|
|
EnumSfElementType elementType = EnumSfElementType.findEnumByCode(element.getSfType());
|
|
|
if(elementType == null){
|
|
|
@@ -757,6 +762,18 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
if(childType == null || !typeSet.contains(childType)){
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
+ if(childType == EnumSfElementType.SOLENOID_VALVE) {
|
|
|
+ groupResVo = new IotSfElementfactorAlreadyListResVo();
|
|
|
+ BeanUtils.copyProperties(element, groupResVo);
|
|
|
+ groupResVo.setChildrenList(new ArrayList<>());
|
|
|
+
|
|
|
+ IotSfElementfactorAlreadyListResVo childResVo = new IotSfElementfactorAlreadyListResVo();
|
|
|
+ BeanUtils.copyProperties(child, childResVo);
|
|
|
+
|
|
|
+ groupResVo.getChildrenList().add(childResVo);
|
|
|
+ }
|
|
|
+
|
|
|
sfTypeValueMap.put(childType, sfTypeValueMap.getOrDefault(childType, 0) + Integer.parseInt(child.getValue()));
|
|
|
sfTypeMap.put(child.getSfCode(), childType);
|
|
|
}
|
|
|
@@ -810,6 +827,23 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+//
|
|
|
+// if(groupResVo != null){
|
|
|
+// String v = "0";
|
|
|
+// for(IotSfElementfactorAlreadyListResVo child : groupResVo.getChildrenList()){
|
|
|
+// String key = child.getSfCode();
|
|
|
+// v = devConfig.getString(key);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if(Objects.equals(v, "1")){
|
|
|
+// String sfdataBid = runStatusData.getString("sfdataBid");
|
|
|
+// List<IotSfElementfactorAlreadyListResVo> groupList = new ArrayList<>();
|
|
|
+// groupList.add(groupResVo);
|
|
|
+// iotSfIrrigationRecordService.createIotSfIrrigationRecordList(groupList, EnumIrrigationRecord.MODE_MANUAL.getCode(), sfdataBid);
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
// 切换到自动模式,先重置状态
|
|
|
String value = devConfig.getString(runMode);
|
|
|
if("1".equals(value)){
|
|
|
@@ -1039,43 +1073,8 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- String tid = SecurityUtils.getTid();
|
|
|
- String userId = SecurityUtils.getUserId();
|
|
|
- String userLoginName = SecurityUtils.getLoginLogName();
|
|
|
- String rcdStartdate = DateUtils.dateTimeNow();
|
|
|
- List<IotSfIrrigationRecord> irrigationRecordList = new ArrayList<>();
|
|
|
- for(IotSfElementfactorAlreadyListResVo group : groupList){
|
|
|
- StringBuilder rcdContent = new StringBuilder();
|
|
|
- List<IotSfElementfactorAlreadyListResVo> childrenList = group.getChildrenList();
|
|
|
- for(IotSfElementfactorAlreadyListResVo child : childrenList){
|
|
|
- rcdContent.append(child.getSfDisplayname()).append(",");
|
|
|
- }
|
|
|
- if(rcdContent.length() > 0){
|
|
|
- rcdContent.deleteCharAt(rcdContent.length() - 1);
|
|
|
- }
|
|
|
- rcdContent.append(EnumIrrigationRecord.STATUS_RUNNING.getName());
|
|
|
-
|
|
|
- IotSfIrrigationRecord record = new IotSfIrrigationRecord();
|
|
|
- record.setRcdBid(record.getUUId());
|
|
|
- record.setDevBid(devBid);
|
|
|
- record.setRcdGroupbid(group.getSfBid());
|
|
|
- record.setRcdGroupName(group.getSfDisplayname());
|
|
|
- record.setRcdStatus(EnumIrrigationRecord.STATUS_RUNNING.getCode());
|
|
|
- record.setRcdMode(EnumIrrigationRecord.MODE_AUTO.getCode());
|
|
|
- record.setRcdContent(rcdContent.toString());
|
|
|
- record.setSfdataBid(runStatusData.getString("sfdataBid"));
|
|
|
- record.setRcdCreator(userId);
|
|
|
- record.setRcdCreatorName(userLoginName);
|
|
|
- record.setRcdStartdate(rcdStartdate);
|
|
|
- record.setRcdCreateddate(rcdStartdate);
|
|
|
- record.setTid(tid);
|
|
|
-
|
|
|
- irrigationRecordList.add(record);
|
|
|
- }
|
|
|
-
|
|
|
- if(!irrigationRecordList.isEmpty()){
|
|
|
- iotSfIrrigationRecordService.batchInsertIotSfIrrigationRecord(irrigationRecordList);
|
|
|
- }
|
|
|
+ String sfdataBid = runStatusData.getString("sfdataBid");
|
|
|
+ iotSfIrrigationRecordService.createIotSfIrrigationRecordList(groupList, EnumIrrigationRecord.MODE_AUTO.getCode(), sfdataBid);
|
|
|
|
|
|
IotSfConfigCmdReqVo cmdReqVo = new IotSfConfigCmdReqVo();
|
|
|
cmdReqVo.setDevBid(devBid);
|
|
|
@@ -1138,6 +1137,8 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
JSONObject sendJson = resetStatus(devBid);
|
|
|
sendJson.put("Btn-yjqd", "0");
|
|
|
|
|
|
+ iotSfIrrigationOprecordService.createIotSfIrrigationOprecord(devBid, "自动灌溉", "停止", "0");
|
|
|
+
|
|
|
IotSfConfigCmdReqVo cmdReqVo = new IotSfConfigCmdReqVo();
|
|
|
cmdReqVo.setDevBid(devBid);
|
|
|
cmdReqVo.setCmd(CmdDef.RunHaoSfCmdDef.CMD_CONFIG);
|