|
@@ -321,6 +321,16 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
|
|
|
*/
|
|
*/
|
|
|
public int elementEdit(IotSfElementfactorEditReqVo reqVo) {
|
|
public int elementEdit(IotSfElementfactorEditReqVo reqVo) {
|
|
|
String devBid = reqVo.getDevBid();
|
|
String devBid = reqVo.getDevBid();
|
|
|
|
|
+ String sfType = reqVo.getSfType();
|
|
|
|
|
+ Integer index = reqVo.getIndex();
|
|
|
|
|
+
|
|
|
|
|
+ if(sfType == null){
|
|
|
|
|
+ throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"类型不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(sfType.equals(EnumSfElementType.GROUP.getCode()) && index == null){
|
|
|
|
|
+ throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"排序索引不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(devBid)) {
|
|
if (StringUtils.isEmpty(devBid)) {
|
|
|
throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
|
|
throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
|
|
@@ -348,13 +358,30 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
|
|
|
selectReqVo.setSfBidList(sfBidLit);
|
|
selectReqVo.setSfBidList(sfBidLit);
|
|
|
selectReqVo.setDevBid(devBid);
|
|
selectReqVo.setDevBid(devBid);
|
|
|
List<IotSfElementfactor> factorList = iotSfElementfactorService.selectIotSfElementfactorList(selectReqVo);
|
|
List<IotSfElementfactor> factorList = iotSfElementfactorService.selectIotSfElementfactorList(selectReqVo);
|
|
|
|
|
+
|
|
|
Map<String, IotSfElementfactor> factorMap = new HashMap<>();
|
|
Map<String, IotSfElementfactor> factorMap = new HashMap<>();
|
|
|
for (IotSfElementfactor factor : factorList) {
|
|
for (IotSfElementfactor factor : factorList) {
|
|
|
factorMap.put(factor.getSfBid(), factor);
|
|
factorMap.put(factor.getSfBid(), factor);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ List<IotSfElementfactor> groupList = new LinkedList<>();
|
|
|
|
|
+ if(Objects.equals(sfType, EnumSfElementType.GROUP.getCode())){
|
|
|
|
|
+ IotSfElementfactorListReqVo groupVo = new IotSfElementfactorListReqVo();
|
|
|
|
|
+ groupVo.setDevBid(devBid);
|
|
|
|
|
+ List<IotSfElementfactor> groupVoList = iotSfElementfactorService.selectIotSfElementfactorListByGroup(groupVo);
|
|
|
|
|
+ for (IotSfElementfactor group : groupVoList) {
|
|
|
|
|
+ if(!group.getSfBid().equals(reqVo.getSfBid())){
|
|
|
|
|
+ groupList.add(group);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
String sfModifieddate = DateUtils.dateTimeNow();
|
|
String sfModifieddate = DateUtils.dateTimeNow();
|
|
|
List<IotSfElementfactor> updateList = new ArrayList<>();
|
|
List<IotSfElementfactor> updateList = new ArrayList<>();
|
|
|
|
|
+
|
|
|
for (IotSfElementfactorEditReqVo req : reqList) {
|
|
for (IotSfElementfactorEditReqVo req : reqList) {
|
|
|
if (StringUtils.isEmpty(req.getSfDisplayname())) {
|
|
if (StringUtils.isEmpty(req.getSfDisplayname())) {
|
|
|
throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "名称不能为空");
|
|
throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "名称不能为空");
|
|
@@ -376,7 +403,19 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
|
|
|
iotSfElementfactor.setSfModifieddate(sfModifieddate);
|
|
iotSfElementfactor.setSfModifieddate(sfModifieddate);
|
|
|
iotSfElementfactor.setSfModifier(SecurityUtils.getUserId());
|
|
iotSfElementfactor.setSfModifier(SecurityUtils.getUserId());
|
|
|
|
|
|
|
|
- updateList.add(iotSfElementfactor);
|
|
|
|
|
|
|
+ if(Objects.equals(sfType, EnumSfElementType.GROUP.getCode())){
|
|
|
|
|
+ groupList.add(index, iotSfElementfactor);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ updateList.add(iotSfElementfactor);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(sfType.equals(EnumSfElementType.GROUP.getCode())){
|
|
|
|
|
+ for(int i = 0; i < groupList.size(); i++){
|
|
|
|
|
+ IotSfElementfactor factor = groupList.get(i);
|
|
|
|
|
+ factor.setSfSequence(i);
|
|
|
|
|
+ updateList.add(factor);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return iotSfElementfactorService.batchUpdateIotSfElementfactor(updateList);
|
|
return iotSfElementfactorService.batchUpdateIotSfElementfactor(updateList);
|