|
@@ -38,7 +38,19 @@ public class EnvironmentServiceImpl implements IEnvironmentService {
|
|
|
private SjHkSdEntityRepository sdEntityRepo;
|
|
|
@Autowired
|
|
|
private SjHkWdEntityRepository wdEntityRepo;
|
|
|
+ @Autowired
|
|
|
+ private EnvironmentDataEntityRepository environmentDataRepo;
|
|
|
|
|
|
+ /**
|
|
|
+ * @Method : getLastEnvData
|
|
|
+ * @Description :
|
|
|
+ * @Params : [mcid]
|
|
|
+ * @Return : com.huimv.common.utils.Result
|
|
|
+ *
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Date : 2020/12/29
|
|
|
+ * @Time : 13:29
|
|
|
+ */
|
|
|
@Override
|
|
|
@DS("slave")
|
|
|
public Result getLastEnvData(int mcid) {
|
|
@@ -173,7 +185,7 @@ public class EnvironmentServiceImpl implements IEnvironmentService {
|
|
|
// System.out.println("栏期length>>"+lqdaEntityList.size());
|
|
|
if (lqdaEntityList.size() == 0) {
|
|
|
//返回出错.
|
|
|
- return new Result(10002, "这个牧场(" + mcid + ")中的猪舍暂无相关任何栏期", false);
|
|
|
+ return new Result(10002, "这个牧场(" + mcid + ")中的猪舍暂未设置相关栏期", false);
|
|
|
}
|
|
|
List lqidList = new ArrayList();
|
|
|
for (DaLqdaEntity lqdaEntity : lqdaEntityList) {
|
|
@@ -200,6 +212,7 @@ public class EnvironmentServiceImpl implements IEnvironmentService {
|
|
|
JSONObject envJo = new JSONObject();
|
|
|
envJa.add(envJo);
|
|
|
envJo.put("id",zsdaEntity.getID());
|
|
|
+ envJo.put("lqid",lqid);
|
|
|
envJo.put("zsmc",zsdaEntity.getZSMC());
|
|
|
//--读取最新氨气
|
|
|
SjHkAqEntity aqEntity = aqEntityRepo.getLastAq(lqid, todayDate);
|
|
@@ -273,7 +286,7 @@ public class EnvironmentServiceImpl implements IEnvironmentService {
|
|
|
zsJo.put("zsmc", zsdaEntity.getZSMC());
|
|
|
for (DaLqdaEntity lqdaEntity : lqdaEntityList) {
|
|
|
if (lqdaEntity.getZSID() == zsid) {
|
|
|
- zsJo.put("lqid", zsdaEntity.getID());
|
|
|
+ zsJo.put("lqid", lqdaEntity.getID());
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -295,9 +308,9 @@ public class EnvironmentServiceImpl implements IEnvironmentService {
|
|
|
@DS("slave")
|
|
|
public Result getLastEnvByLq(Integer lqid) {
|
|
|
String todayDate = new DateUtil().formatDate(new Date());
|
|
|
-// JSONArray envJa = new JSONArray();
|
|
|
+ System.out.println(" todayDate>>"+todayDate);
|
|
|
+ System.out.println(" lqid>>"+lqid);
|
|
|
JSONObject envJo = new JSONObject();
|
|
|
-// envJa.add(envJo);
|
|
|
envJo.put("lqid",lqid);
|
|
|
//--读取最新氨气
|
|
|
SjHkAqEntity aqEntity = aqEntityRepo.getLastAq(lqid, todayDate);
|
|
@@ -324,5 +337,117 @@ public class EnvironmentServiceImpl implements IEnvironmentService {
|
|
|
return new Result(ResultCode.SUCCESS, envJo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Method : getTemperatureOnToday
|
|
|
+ * @Description : 获取今天温度
|
|
|
+ * @Params : [lqid]
|
|
|
+ * @Return : com.huimv.common.utils.Result
|
|
|
+ *
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Date : 2020/12/29
|
|
|
+ * @Time : 13:29
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @DS("slave")
|
|
|
+ public Result getTemperatureOnToday(Integer lqid) {
|
|
|
+ String beforeDateTime = new DateUtil().beforeTime(1);
|
|
|
+ JSONObject dataJo = new JSONObject();
|
|
|
+ //--读取最新温度
|
|
|
+// List<SjHkWdEntity> wdEntityList = wdEntityRepo.getTemperatureOnToday(lqid, beforeDateTime);
|
|
|
+ List<SjHkWdEntity> wdEntityList = wdEntityRepo.getTemperature(lqid, beforeDateTime);
|
|
|
+ List<SjHkWdEntity> newList = new ArrayList();
|
|
|
+ for(int a=wdEntityList.size()-1;a>=0;a--){
|
|
|
+ SjHkWdEntity wdEntity = wdEntityList.get(a);
|
|
|
+ newList.add(wdEntity);
|
|
|
+ }
|
|
|
+ if (newList.size()>0) {
|
|
|
+ JSONArray tempJa = new JSONArray();
|
|
|
+ JSONArray timeJa = new JSONArray();
|
|
|
+ for(SjHkWdEntity wdEntity: newList){
|
|
|
+ System.out.println(""+wdEntity.getCJSJ()+","+wdEntity.getDQWD());
|
|
|
+ String dateTime = wdEntity.getCJSJ().toString();
|
|
|
+ String hourAndMin = dateTime.substring(11,16);
|
|
|
+ timeJa.add(hourAndMin);
|
|
|
+ tempJa.add(wdEntity.getDQWD());
|
|
|
+ }
|
|
|
+ dataJo.put("timeData",timeJa);
|
|
|
+ dataJo.put("wenduList",tempJa);
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS, dataJo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Method : getAmmoniaAndHumidityOnToday
|
|
|
+ * @Description : 获取今天氨气和湿度
|
|
|
+ * @Params : [lqid]
|
|
|
+ * @Return : com.huimv.common.utils.Result
|
|
|
+ *
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Date : 2020/12/29
|
|
|
+ * @Time : 13:28
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @DS("slave")
|
|
|
+ public Result getAmmoniaAndHumidityOnToday(Integer lqid) {
|
|
|
+ String beforeDateTime = new DateUtil().beforeTime(3);
|
|
|
+ JSONArray timeJa = new JSONArray();
|
|
|
+ JSONObject dataJo = new JSONObject();
|
|
|
+ System.out.println("lqid>>"+lqid);
|
|
|
+ System.out.println("beforeDateTime>>"+beforeDateTime);
|
|
|
+ //--读取最新氨气
|
|
|
+// List<SjHkAqEntity> aqEntityList = aqEntityRepo.getAmmoniaOnToday(lqid, beforeDateTime);
|
|
|
+ List<SjHkAqEntity> aqEntityList = aqEntityRepo.getAmmonia(lqid, beforeDateTime);
|
|
|
+ System.out.println("读取最新氨气>>"+aqEntityList.size());
|
|
|
+ List<SjHkAqEntity> newList = new ArrayList();
|
|
|
+ for(int a=aqEntityList.size()-1;a>=0;a--){
|
|
|
+ SjHkAqEntity aqEntity = aqEntityList.get(a);
|
|
|
+ newList.add(aqEntity);
|
|
|
+ }
|
|
|
+ System.out.println("读取最新氨气 newList>>"+newList.size());
|
|
|
+
|
|
|
+ if (newList.size()>0) {
|
|
|
+ JSONArray ammoniaJa = new JSONArray();
|
|
|
+ for(SjHkAqEntity aqEntity:newList){
|
|
|
+ String dateTime = aqEntity.getCJSJ().toString();
|
|
|
+ String hourAndMin = dateTime.substring(11,16);
|
|
|
+ timeJa.add(hourAndMin);
|
|
|
+ ammoniaJa.add(aqEntity.getDQAQ());
|
|
|
+ }
|
|
|
+ dataJo.put("timeData",timeJa);
|
|
|
+ dataJo.put("anqiList",ammoniaJa);
|
|
|
+ }
|
|
|
+ //--读取最新湿度
|
|
|
+// List<SjHkSdEntity> sdEntityList = sdEntityRepo.getHumidityOnToday(lqid, beforeDateTime);
|
|
|
+ List<SjHkSdEntity> sdEntityList = sdEntityRepo.getHumidity(lqid, beforeDateTime);
|
|
|
+ System.out.println("读取最新氨气>>"+sdEntityList.size());
|
|
|
+ List<SjHkSdEntity> newList2 = new ArrayList();
|
|
|
+ for(int a=sdEntityList.size()-1;a>=0;a--){
|
|
|
+ SjHkSdEntity sdEntity = sdEntityList.get(a);
|
|
|
+ newList2.add(sdEntity);
|
|
|
+ }
|
|
|
+ System.out.println("读取最新氨气 newList2>>"+newList2.size());
|
|
|
+ if (newList2.size()>0) {
|
|
|
+ JSONArray humidityJa = new JSONArray();
|
|
|
+ for(SjHkSdEntity sdEntity:newList2){
|
|
|
+ humidityJa.add(sdEntity.getDQSD());
|
|
|
+ }
|
|
|
+ dataJo.put("shiduList",humidityJa);
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS, dataJo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @DS("third")
|
|
|
+ public Result getEnvDetails() {
|
|
|
+ /** */
|
|
|
+ EnvironmentDataEntity environmentData = environmentDataRepo.getOneLastEnvData();
|
|
|
+ System.out.println("environmentData:" + environmentData);
|
|
|
+ if (environmentData == null) {
|
|
|
+ return new Result(10003,"没有环控数据",false);
|
|
|
+ } else {
|
|
|
+ return new Result(ResultCode.SUCCESS,environmentData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|