|
@@ -17,6 +17,7 @@ import com.huimv.admin.service.IProtThresholdService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.ArrayList;
|
|
@@ -51,7 +52,10 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
|
|
|
Integer userId = TokenSign.getMemberIdByJwtToken(httpServletRequest);
|
|
|
List<Integer> userIds =sysAccountMultilevelMapper.getLowerLevel( userId,farmId);
|
|
|
List<Integer> collect =new ArrayList<>();
|
|
|
- String userIds1 = protThresholdList.get(0).getUserIds();
|
|
|
+ String userIds1 = "";
|
|
|
+ if (ObjectUtil.isNotEmpty(protThresholdList)){
|
|
|
+ userIds1 = protThresholdList.get(0).getUserIds();
|
|
|
+ }
|
|
|
if (StringUtils.isNotBlank(userIds1)){
|
|
|
collect = Arrays.stream(userIds1.split(",")).map(Integer::valueOf).filter(userIds::contains).collect(Collectors.toList());
|
|
|
}
|
|
@@ -71,6 +75,7 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
|
|
|
jsonObject.put("FLOW1", 0);
|
|
|
jsonObject.put("FLOW2", 0);
|
|
|
jsonObject.put("userIds", 0);
|
|
|
+ jsonObject.put("protType", 0);
|
|
|
jsonObject.put("dataType", 0);
|
|
|
return new Result(ResultCode.SUCCESS, jsonObject);
|
|
|
} else {
|
|
@@ -84,13 +89,14 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
|
|
|
jsonObject.put("out", protThresholdList.get(i));
|
|
|
}
|
|
|
}
|
|
|
- jsonObject.put("userIds", protThresholdList.get(1).getUserIds());
|
|
|
- return new Result(ResultCode.SUCCESS,collect);
|
|
|
+ jsonObject.put("userIds",collect);
|
|
|
+ return new Result(ResultCode.SUCCESS,jsonObject);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public Result add(HttpServletRequest httpServletRequest, List<ProtThreshold> protThresholds) {
|
|
|
for (ProtThreshold protThreshold : protThresholds) {
|
|
|
if (ObjectUtil.isNotEmpty(protThreshold)) {
|
|
@@ -110,10 +116,12 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
|
|
|
uoloadIds = Arrays.stream(userIds.split(",")).map(Integer::valueOf).collect(Collectors.toList());
|
|
|
}
|
|
|
//现有id
|
|
|
- String oldUserIds = threshold.getUserIds();
|
|
|
List<Integer> oldUsersIds = new ArrayList<>();
|
|
|
- if (StringUtils.isNotBlank(oldUserIds)){
|
|
|
- oldUsersIds = Arrays.stream(oldUserIds.split(",")).map(Integer::valueOf).collect(Collectors.toList());
|
|
|
+ if(ObjectUtil.isNotEmpty(threshold)){
|
|
|
+ String oldUserIds = threshold.getUserIds();
|
|
|
+ if (StringUtils.isNotBlank(oldUserIds)){
|
|
|
+ oldUsersIds = Arrays.stream(oldUserIds.split(",")).map(Integer::valueOf).collect(Collectors.toList());
|
|
|
+ }
|
|
|
}
|
|
|
// 现有 -下属 + 上传
|
|
|
oldUsersIds.removeAll(lowerLevelIds);
|
|
@@ -151,7 +159,6 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
|
|
|
} else if (Integer.parseInt(protThreshold.getFlow2()) < Integer.parseInt(protThreshold.getFlow1())) {
|
|
|
return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
} else {
|
|
|
-
|
|
|
if (ObjectUtil.isEmpty(threshold)) {
|
|
|
protThresholdMapper.insert(protThreshold1);
|
|
|
} else {
|