|
@@ -1,18 +1,24 @@
|
|
|
package com.huimv.env.manage.saas.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.huimv.env.manage.saas.dao.entity.LampConfigAll;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.huimv.env.common.service.LampTempService;
|
|
|
import com.huimv.env.manage.mapper.LampConfigAllMapper;
|
|
|
+import com.huimv.env.manage.mapper.LampConfigMapper;
|
|
|
+import com.huimv.env.manage.saas.dao.entity.LampConfig;
|
|
|
+import com.huimv.env.manage.saas.dao.entity.LampConfigAll;
|
|
|
import com.huimv.env.manage.saas.service.ILampConfigAllService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.huimv.env.manage.utils.Result;
|
|
|
import com.huimv.env.manage.utils.ResultCode;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.ArrayList;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -27,9 +33,12 @@ import java.util.Map;
|
|
|
*/
|
|
|
@Service
|
|
|
public class LampConfigAllServiceImpl extends ServiceImpl<LampConfigAllMapper, LampConfigAll> implements ILampConfigAllService {
|
|
|
-
|
|
|
@Autowired
|
|
|
private LampConfigAllMapper lampConfigAllMapper;
|
|
|
+ @Autowired
|
|
|
+ private LampConfigMapper lampConfigMapper;
|
|
|
+ @Autowired
|
|
|
+ private LampTempService lampTempService;
|
|
|
|
|
|
@Override
|
|
|
public Result listByFarmCode(Map<String, String> map, HttpServletRequest request) {
|
|
@@ -54,4 +63,74 @@ public class LampConfigAllServiceImpl extends ServiceImpl<LampConfigAllMapper, L
|
|
|
|
|
|
return new Result(ResultCode.SUCCESS, endMap);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getPigletLampInfo(Map<String, String> map, HttpServletRequest request) {
|
|
|
+ String farmCode = map.get("farmCode");
|
|
|
+ //保温灯温度
|
|
|
+ BigDecimal lampTempBd = lampTempService.getLastLampTemp(farmCode);
|
|
|
+ //开启数量、关闭数量
|
|
|
+ int openCount = 0;
|
|
|
+ int closeCount = 0;
|
|
|
+ //获取设备开关数量
|
|
|
+ Map<String,Integer> lampConfigMap = _getLampConfigOpenCloseStatus(farmCode);
|
|
|
+ openCount = lampConfigMap.get("openCount");
|
|
|
+ closeCount = lampConfigMap.get("closeCount");
|
|
|
+ //任意一个单元的统一配置温度列表
|
|
|
+ JSONArray configTempList = _getConfigTempList(farmCode);
|
|
|
+ Map<String,Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("lampTemp",lampTempBd);
|
|
|
+ resultMap.put("openCount",openCount);
|
|
|
+ resultMap.put("closeCount",closeCount);
|
|
|
+ resultMap.put("configTempList",configTempList);
|
|
|
+ return new Result(ResultCode.SUCCESS,resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取任意统一配置
|
|
|
+ private JSONArray _getConfigTempList(String farmCode) {
|
|
|
+ QueryWrapper<LampConfigAll> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("farm_code",farmCode);
|
|
|
+ queryWrapper.last("LIMIT 1");
|
|
|
+ LampConfigAll lampConfigAll = lampConfigAllMapper.selectOne(queryWrapper);
|
|
|
+ if(lampConfigAll == null){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String listDayage = lampConfigAll.getListDayage();
|
|
|
+ if(StringUtils.isBlank(listDayage)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String[] listDayageArray = listDayage.split(";");
|
|
|
+ JSONArray resultJa = new JSONArray();
|
|
|
+ for(int a=0;a<listDayageArray.length;a++){
|
|
|
+ JSONObject newJo = new JSONObject();
|
|
|
+ resultJa.add(newJo);
|
|
|
+ String config = listDayageArray[a];
|
|
|
+ String[] configArray = config.split(",");
|
|
|
+ newJo.put("dayage",configArray[0]);
|
|
|
+ newJo.put("value",configArray[1]);
|
|
|
+ }
|
|
|
+ return resultJa;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取设备开关数量
|
|
|
+ private Map<String, Integer> _getLampConfigOpenCloseStatus(String farmCode) {
|
|
|
+ QueryWrapper<LampConfig> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("farm_code",farmCode);
|
|
|
+ List<Integer> lampConfigList = lampConfigMapper.getOpenCloseStatus(farmCode);
|
|
|
+ System.out.println("lampConfigList.size="+lampConfigList.size());
|
|
|
+ int openCount = 0;
|
|
|
+ int closeCount = 0;
|
|
|
+ for(int a=0;a<lampConfigList.size();a++){
|
|
|
+ int openStatus = lampConfigList.get(a);
|
|
|
+ if(openStatus == 0){
|
|
|
+ closeCount++;
|
|
|
+ }else{
|
|
|
+ openCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String,Integer> resultMap = new HashMap();
|
|
|
+ resultMap.put("openCount",openCount);
|
|
|
+ resultMap.put("closeCount",closeCount);
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
}
|