|
@@ -3,17 +3,26 @@ package com.huimv.admin.service.impl;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.huimv.admin.common.token.TokenSign;
|
|
|
import com.huimv.admin.common.utils.Result;
|
|
|
import com.huimv.admin.common.utils.ResultCode;
|
|
|
import com.huimv.admin.entity.EnvWarningThreshold;
|
|
|
+import com.huimv.admin.entity.SysAccountMultilevel;
|
|
|
import com.huimv.admin.mapper.EnvWarningThresholdMapper;
|
|
|
+import com.huimv.admin.mapper.SysAccountMultilevelMapper;
|
|
|
import com.huimv.admin.service.IEnvWarningThresholdService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.huimv.admin.service.ISysAccountMultilevelService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -28,13 +37,27 @@ public class EnvWarningThresholdServiceImpl extends ServiceImpl<EnvWarningThresh
|
|
|
|
|
|
@Autowired
|
|
|
EnvWarningThresholdMapper envWarningThresholdMapper;
|
|
|
+ @Autowired
|
|
|
+ ISysAccountMultilevelService accountMultilevelService;
|
|
|
@Override
|
|
|
public Result list(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
|
|
|
String farmId = paramsMap.get("farmId");
|
|
|
+ Integer userId = TokenSign.getMemberIdByJwtToken(httpServletRequest);
|
|
|
+ QueryWrapper<SysAccountMultilevel> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.like("pids",userId);
|
|
|
+ wrapper.like("farm_ids",farmId);
|
|
|
+ List<SysAccountMultilevel> page = accountMultilevelService.list( wrapper);
|
|
|
+ List<Integer> userIds = page.stream().map(SysAccountMultilevel::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Integer> collect =new ArrayList<>();
|
|
|
QueryWrapper<EnvWarningThreshold> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("farm_id", farmId);
|
|
|
EnvWarningThreshold envWarningThreshold = envWarningThresholdMapper.selectOne(queryWrapper);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
+ String userIds1 = envWarningThreshold.getUserIds();
|
|
|
+ if (StringUtils.isNotBlank(userIds1)){
|
|
|
+ collect = Arrays.stream(userIds1.split(",")).map(Integer::valueOf).filter(userIds::contains).collect(Collectors.toList());
|
|
|
+ }
|
|
|
if (ObjectUtil.isEmpty(envWarningThreshold)) {
|
|
|
jsonObject.put("maxTem", 0);
|
|
|
jsonObject.put("minTem", 0);
|
|
@@ -42,7 +65,7 @@ public class EnvWarningThresholdServiceImpl extends ServiceImpl<EnvWarningThresh
|
|
|
jsonObject.put("minHum", 0);
|
|
|
jsonObject.put("maxNh3", 0);
|
|
|
jsonObject.put("maxCo", 0);
|
|
|
- jsonObject.put("userIds", 0);
|
|
|
+ jsonObject.put("userIds", null);
|
|
|
} else {
|
|
|
jsonObject.put("maxTem", envWarningThreshold.getMaxTem());
|
|
|
jsonObject.put("minTem", envWarningThreshold.getMinTem());
|
|
@@ -50,7 +73,7 @@ public class EnvWarningThresholdServiceImpl extends ServiceImpl<EnvWarningThresh
|
|
|
jsonObject.put("minHum", envWarningThreshold.getMinHum());
|
|
|
jsonObject.put("maxNh3", envWarningThreshold.getMaxNh3());
|
|
|
jsonObject.put("maxCo", envWarningThreshold.getMaxCo());
|
|
|
- jsonObject.put("userIds", envWarningThreshold.getUserIds());
|
|
|
+ jsonObject.put("userIds", collect);
|
|
|
}
|
|
|
return new Result(ResultCode.SUCCESS,jsonObject);
|
|
|
}
|