|
|
@@ -439,16 +439,16 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
// 肥料桶是虚拟的,不需要检测code重复问题
|
|
|
if(!Objects.equals(sfType, EnumSfElementType.FERTILIZER_BUCKET.getCode())){
|
|
|
if (StringUtils.isEmpty(sfCode)) {
|
|
|
- throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "要素编码不能为空");
|
|
|
+ throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "编码不能为空");
|
|
|
}
|
|
|
}
|
|
|
String sfDisplayname = reqVo.getSfDisplayname();
|
|
|
if (StringUtils.isEmpty(sfType)) {
|
|
|
- throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "要素类型不能为空");
|
|
|
+ throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "类型不能为空");
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(sfDisplayname)) {
|
|
|
- throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "要素名称不能为空");
|
|
|
+ throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "名称不能为空");
|
|
|
}
|
|
|
List<IotSfElementfactorAddReqVo> childrenList = reqVo.getChildrenList();
|
|
|
if(Objects.equals(sfType, EnumSfElementType.GROUP.getCode())){
|
|
|
@@ -485,7 +485,7 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
|
|
|
for(IotSfElementfactor element : sfElementfactorList){
|
|
|
if(sfCodeSet.contains(element.getSfCode())){
|
|
|
- throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "要素编码重复");
|
|
|
+ throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "编码重复");
|
|
|
}
|
|
|
}
|
|
|
int status = iotSfElementfactorService.batchInsertIotSfElementfactor(sfElementfactorList);
|
|
|
@@ -527,126 +527,6 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
*
|
|
|
* @param reqVo 包含设备添加请求的参数,包括设备标识(devBid)等
|
|
|
*/
|
|
|
-// public int elementBatchAdd(IotSfElementfactorBatchAddReqVo reqVo) {
|
|
|
-// String devBid = reqVo.getDevBid();
|
|
|
-// if (StringUtils.isEmpty(devBid)) {
|
|
|
-// throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
|
|
|
-// }
|
|
|
-//
|
|
|
-// IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
|
|
|
-// if (findDevice == null) {
|
|
|
-// throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
|
|
|
-// }
|
|
|
-// List<IotSfElementfactorAddReqVo> elementList = reqVo.getElementList();
|
|
|
-// if(elementList == null || elementList.isEmpty()){
|
|
|
-// throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "元素列表不能为空");
|
|
|
-// }
|
|
|
-//
|
|
|
-// IotSfElementfactorListReqVo reqVo1 = new IotSfElementfactorListReqVo();
|
|
|
-// reqVo1.setDevBid(devBid);
|
|
|
-// List<IotSfElementfactor> dataList = iotSfElementfactorService.selectIotSfElementfactorList(reqVo1);
|
|
|
-// Set<String> sfCodeSet = new HashSet<>();
|
|
|
-// Map<String, IotSfElementfactor> elementMap = new HashMap<>();
|
|
|
-// for (IotSfElementfactor element : dataList) {
|
|
|
-// if(StringUtils.isNotEmpty(element.getSfCode())){
|
|
|
-// sfCodeSet.add(element.getSfCode());
|
|
|
-// elementMap.put(element.getSfBid(), element);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// String createDate = DateUtils.dateTimeNow();
|
|
|
-// List<IotSfElementfactor> sfElementfactorList = new ArrayList<>();
|
|
|
-// Set<String> sfCodeAlreadySet = new HashSet<>();
|
|
|
-// List<IotSfElementfactorAddReqVo> valveList = new ArrayList<>();
|
|
|
-// IotSfElementfactor parentElement = null;
|
|
|
-//
|
|
|
-// Map<String, List<String>> groupValveMap = new HashMap<>();
|
|
|
-// Map<String, String> params = new HashMap<>();
|
|
|
-// params.put("devBid", devBid);
|
|
|
-// IotRunHaoSfdata iotRunHaoSfdata = (IotRunHaoSfdata) mongoService.findOne(IotRunHaoSfdata.class, params, "sfdataCreatedDate", "desc");
|
|
|
-// if(iotRunHaoSfdata != null && iotRunHaoSfdata.getSfdataContent() !=null ){
|
|
|
-// groupValveMap = getGroupValveMap(iotRunHaoSfdata.getSfdataContent());
|
|
|
-// }
|
|
|
-// Set<String> sfTypeSet = new HashSet<>();
|
|
|
-// for(IotSfElementfactorAddReqVo element : elementList) {
|
|
|
-// String sfType = element.getSfType();
|
|
|
-// String sfCode = element.getSfCode();
|
|
|
-// String sfDisplayname = element.getSfDisplayname();
|
|
|
-// String sfParentBid = element.getSfParentBid();
|
|
|
-// if(sfCodeSet.contains(sfCode) || sfCodeAlreadySet.contains(sfCode)){
|
|
|
-// throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "已存在,请勿重复添加");
|
|
|
-// }
|
|
|
-// if (StringUtils.isEmpty(sfType)) {
|
|
|
-// throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "类型不能为空");
|
|
|
-// }
|
|
|
-// if (StringUtils.isEmpty(sfDisplayname)) {
|
|
|
-// throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "名称不能为空");
|
|
|
-// }
|
|
|
-//
|
|
|
-// sfTypeSet.add(sfType);
|
|
|
-//
|
|
|
-// IotSfElementfactor elementfactor = makeIotSfElementfactor(element, createDate);
|
|
|
-//
|
|
|
-// if(Objects.equals(sfType, EnumSfElementType.SOLENOID_VALVE.getCode())){
|
|
|
-// if(StringUtils.isEmpty(sfParentBid)){
|
|
|
-// throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "灌区标识不能为空");
|
|
|
-// }
|
|
|
-// parentElement = elementMap.get(sfParentBid);
|
|
|
-// if(parentElement == null || !Objects.equals(parentElement.getSfType(), EnumSfElementType.GROUP.getCode())){
|
|
|
-// throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "灌区不存在");
|
|
|
-// }
|
|
|
-// valveList.add(element);
|
|
|
-//
|
|
|
-// }else if(Objects.equals(sfType, EnumSfElementType.GROUP.getCode())){
|
|
|
-// List<String> valveCodeList = groupValveMap.get(sfCode);
|
|
|
-// if(valveCodeList!= null &&!valveCodeList.isEmpty()){
|
|
|
-// for(String valveCode : valveCodeList){
|
|
|
-// IotSfElementfactor valvefactor = RunHaoSfElementUtil.getValveElementFactor(valveCode);
|
|
|
-// if(valvefactor == null){
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// valvefactor.setSfParentBid(element.getSfBid());
|
|
|
-// valvefactor.setTid(element.getTid());
|
|
|
-// valvefactor.setDevBid(devBid);
|
|
|
-// valvefactor.setSfCreatedDate(createDate);
|
|
|
-// valvefactor.setSfCreator(SecurityUtils.getUserId());
|
|
|
-// valvefactor.setSfModifieddate(createDate);
|
|
|
-// valvefactor.setSfModifier(SecurityUtils.getUserId());
|
|
|
-//
|
|
|
-// sfElementfactorList.add(valvefactor);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// sfElementfactorList.add(elementfactor);
|
|
|
-//
|
|
|
-// sfCodeAlreadySet.add(sfCode);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(sfTypeSet.size() > 1){
|
|
|
-// throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "批量新增一次只能操作一种类型");
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(parentElement != null){
|
|
|
-// iotSfElementfactorService.deleteIotSfElementfactorBySfBid(parentElement.getSfBid());
|
|
|
-// }
|
|
|
-// int status = 0;
|
|
|
-// if(!sfElementfactorList.isEmpty()){
|
|
|
-// status = iotSfElementfactorService.batchInsertIotSfElementfactor(sfElementfactorList);
|
|
|
-// }
|
|
|
-// // 下发 灌区和阀的关联配置命令
|
|
|
-// if(parentElement != null){
|
|
|
-// IotSfElementfactorAddReqVo groupReqVo = new IotSfElementfactorAddReqVo();
|
|
|
-// BeanUtils.copyProperties(parentElement, groupReqVo);
|
|
|
-//
|
|
|
-// groupReqVo.setChildrenList(valveList);
|
|
|
-//
|
|
|
-// sendGroupConfig(groupReqVo, findDevice);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return status;
|
|
|
-// }
|
|
|
-
|
|
|
public int elementBatchAdd(IotSfElementfactorBatchAddReqVo reqVo) {
|
|
|
String devBid = reqVo.getDevBid();
|
|
|
if (StringUtils.isEmpty(devBid)) {
|
|
|
@@ -659,7 +539,7 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
}
|
|
|
List<IotSfElementfactorAddReqVo> elementList = reqVo.getElementList();
|
|
|
if(elementList == null || elementList.isEmpty()){
|
|
|
- throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "元素列表不能为空");
|
|
|
+ throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "列表不能为空");
|
|
|
}
|
|
|
|
|
|
IotSfElementfactorListReqVo reqVo1 = new IotSfElementfactorListReqVo();
|
|
|
@@ -687,7 +567,7 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
String sfParentBid = element.getSfParentBid();
|
|
|
|
|
|
if(sfCodeSet.contains(sfCode)){
|
|
|
- throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "要素已存在,请勿重复添加");
|
|
|
+ throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "已存在,请勿重复添加");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(sfType)) {
|
|
|
throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "类型不能为空");
|
|
|
@@ -896,7 +776,7 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
TableDataInfo tableDataInfo = getStatus(devBid);
|
|
|
List<IotSfElementfactorInfoVo> resultList = (List<IotSfElementfactorInfoVo>) tableDataInfo.getData();
|
|
|
if(resultList == null || resultList.isEmpty()){
|
|
|
- throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"未配置要素");
|
|
|
+ throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"未配置");
|
|
|
}
|
|
|
|
|
|
Map<String, EnumSfElementType> sfTypeMap = new HashMap<>();
|
|
|
@@ -999,22 +879,6 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
iotSfIrrigationOprecordService.createIotSfIrrigationOprecord(devBid, oprecdName, oprecdContent, oprecdStatus);
|
|
|
}
|
|
|
}
|
|
|
-//
|
|
|
-// 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);
|
|
|
@@ -1207,7 +1071,14 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
if(elementfactor.getChildrenList() == null || elementfactor.getChildrenList().isEmpty()){
|
|
|
throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "灌区未配置阀,无法开始灌溉");
|
|
|
}
|
|
|
+ // 打开灌区
|
|
|
sendJson.put(sfCode, "1");
|
|
|
+ // 打开灌区下发阀
|
|
|
+ List<IotSfElementfactorAlreadyListResVo> childrenList = elementfactor.getChildrenList();
|
|
|
+ for(IotSfElementfactorAlreadyListResVo child : childrenList){
|
|
|
+ String childSfCode = child.getSfCode();
|
|
|
+ sendJson.put(childSfCode, "1");
|
|
|
+ }
|
|
|
groupList.add(elementfactor);
|
|
|
if("0".equals(dqqf) && sfCode.startsWith("Btn-qx")){
|
|
|
try{
|
|
|
@@ -1218,11 +1089,25 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- sendJson.put("Num-dqqf", dqqf);
|
|
|
-
|
|
|
if(sendJson.isEmpty()){
|
|
|
throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "请先选择灌区");
|
|
|
}
|
|
|
+ IotSfElementfactorListReqVo pumpVo = new IotSfElementfactorListReqVo();
|
|
|
+ pumpVo.setDevBid(devBid);
|
|
|
+ pumpVo.setTid(SecurityUtils.getTid());
|
|
|
+ List<IotSfElementfactor> sfElementfactorList = iotSfElementfactorService.selectIotSfElementfactorListByPump(pumpVo);
|
|
|
+ if(sfElementfactorList != null &&!sfElementfactorList.isEmpty()){
|
|
|
+ for(IotSfElementfactor vo : sfElementfactorList){
|
|
|
+ String sfCode = vo.getSfCode();
|
|
|
+ String sfType = vo.getSfType();
|
|
|
+ if(Objects.equals(sfType, EnumSfElementType.FERTILIZER_BUCKET.getCode())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ sendJson.put(sfCode, "1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sendJson.put("Num-dqqf", dqqf);
|
|
|
String[] keys = new String[]{"Btn-dsdl", "Num-lgcs", "Num-lgjg"};
|
|
|
for(String key : keys){
|
|
|
sendJson.put(key, data.getString(key));
|