|  |  |  | 
|---|
|  |  |  | package com.ld.igds.sh.service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.ld.igds.constant.RedisConst; | 
|---|
|  |  |  | import com.ld.igds.log.service.InteStatusLogService; | 
|---|
|  |  |  | import com.ld.igds.models.Grain; | 
|---|
|  |  |  | import com.ld.igds.models.InteStatusLog; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.ld.igds.sh.param.BaseParam; | 
|---|
|  |  |  | import com.ld.igds.sh.service.impl.HApiShServiceImpl; | 
|---|
|  |  |  | import com.ld.igds.sh.util.ApiShConst; | 
|---|
|  |  |  | import com.ld.igds.sh.util.ApiShUtil; | 
|---|
|  |  |  | import com.ld.igds.sh.util.RespCodeEnum; | 
|---|
|  |  |  | import com.ld.igds.sh.util.RespUtil; | 
|---|
|  |  |  | import com.ld.igds.util.ContextUtil; | 
|---|
|  |  |  | import com.ld.igds.util.DateUtil; | 
|---|
|  |  |  | import com.ld.igds.util.RedisUtil; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.text.ParseException; | 
|---|
|  |  |  | import java.text.SimpleDateFormat; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Calendar; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 温湿度检测接口 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String companyId = ContextUtil.getDefaultCompanyId(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String key = RedisConst.buildKey(companyId, ApiShConst.API_SH_1401); | 
|---|
|  |  |  | Date startTime = (Date) redisUtil.get(key); | 
|---|
|  |  |  | if(null == startTime){ | 
|---|
|  |  |  | startTime = DateUtils.addDays(param.getEndTime(), -30); | 
|---|
|  |  |  | //        String key = RedisConst.buildKey(companyId, ApiShConst.API_SH_1112); | 
|---|
|  |  |  | //        Date startTime = (Date) redisUtil.get(key); | 
|---|
|  |  |  | //        if(null == startTime){ | 
|---|
|  |  |  | //            startTime = DateUtils.addDays(param.getEndTime(), -30); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        redisUtil.set(key, param.getEndTime()); | 
|---|
|  |  |  | if(null == param.getStartTime()){ | 
|---|
|  |  |  | param.setStartTime(DateUtils.addDays(param.getEndTime(), -1)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | redisUtil.set(key, param.getEndTime()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询温湿度信息,即粮情信息 | 
|---|
|  |  |  | List<Grain> dataList = hApiShServiceImpl.listGrain(companyId, | 
|---|
|  |  |  | param.getDepotId(), startTime, param.getEndTime()); | 
|---|
|  |  |  | param.getDepotId(), param.getStartTime(), param.getEndTime()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //响应数据为空则直接返回响应码2000 | 
|---|
|  |  |  | if (dataList == null || dataList.isEmpty()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | //封装数据信息 | 
|---|
|  |  |  | for (Grain grain : dataList) { | 
|---|
|  |  |  | dto1401 = new Dto1401(); | 
|---|
|  |  |  | dto1401.setLqjcbm(grain.getDepotId() + grain.getBatchId()); | 
|---|
|  |  |  | dto1401.setLqjcbm(ApiShUtil.getGbDepotId(grain.getDepotId()) + grain.getBatchId()); | 
|---|
|  |  |  | dto1401.setJcsj(DateFormatUtils.format(grain.getReceiveDate(), "yyyy-MM-dd HH:mm:ss")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | dto1401.setHwbm(grain.getDepotId()); | 
|---|
|  |  |  | dto1401.setHwbm(ApiShUtil.getGbDepotId(grain.getDepotId()) + "01"); | 
|---|
|  |  |  | dto1401.setCfww(String.valueOf(grain.getTempOut())); | 
|---|
|  |  |  | dto1401.setCfws(String.valueOf(grain.getHumidityOut())); | 
|---|
|  |  |  | dto1401.setCfnw(String.valueOf(grain.getTempIn())); | 
|---|
|  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | dto1401.setLswdzjh(getPointList2(grain.getPoints(), grain.getCable(), grain.getCableCir())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | dto1401.setNm(grain.getDepotId().substring(0, 21)); | 
|---|
|  |  |  | dto1401.setZznm(grain.getDepotId().substring(0, 21)); | 
|---|
|  |  |  | dto1401.setCfnm(grain.getDepotId().substring(0, 21)); | 
|---|
|  |  |  | dto1401.setNm(ApiShUtil.getGbDepotId(grain.getDepotId()).substring(0, 21)); | 
|---|
|  |  |  | dto1401.setZznm(ApiShUtil.getGbDepotId(grain.getDepotId()).substring(0, 21)); | 
|---|
|  |  |  | dto1401.setCfnm(ApiShUtil.getGbDepotId(grain.getDepotId()).substring(0, 25)); | 
|---|
|  |  |  | dto1401.setDqwd(String.valueOf(grain.getTempOut())); | 
|---|
|  |  |  | dto1401.setDqsd(String.valueOf(grain.getHumidityOut())); | 
|---|
|  |  |  | dto1401.setCnwd(String.valueOf(grain.getTempIn())); | 
|---|