|
@@ -152,18 +152,18 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
updateEartagLiveStatus(earmark, deviceCode, todayDateText, todayDate, nowTimestamp, dataJo, farmId);
|
|
|
|
|
|
//{更新耳标设备在线关联统计}
|
|
|
- updateEartagDeviceOnlineCount(earmark, deviceCode, todayDateText, todayDate, nowTimestamp, farmId);
|
|
|
+// updateEartagDeviceOnlineCount(earmark, deviceCode, todayDateText, todayDate, nowTimestamp, farmId);
|
|
|
|
|
|
//{异常统计和异常报警}
|
|
|
// abnormalCountAndAlarm(dataJo, todayDate, nowTimestamp, farmId);
|
|
|
|
|
|
- //判断该设备编号是否存在牧场缓存在线集合当中;
|
|
|
- if (!cacheService.isExistEartagOnlineSet(farmId, earmark, todayDateText)) {
|
|
|
- //更新总状态数据
|
|
|
- updateEartagPropertyOfAllStatus(farmId, todayDateText, todayDate, nowTimestamp);
|
|
|
- //将耳标号加入到耳标在线集合当中
|
|
|
- cacheService.putEartagToOnlineInSet(farmId, earmark, todayDateText);
|
|
|
- }
|
|
|
+ //判断该设备编号是否存在牧场缓存在线集合当中; 修改结束
|
|
|
+// if (!cacheService.isExistEartagOnlineSet(farmId, earmark, todayDateText)) {
|
|
|
+// //更新总状态数据
|
|
|
+// updateEartagPropertyOfAllStatus(farmId, todayDateText, todayDate, nowTimestamp);
|
|
|
+// //将耳标号加入到耳标在线集合当中
|
|
|
+// cacheService.putEartagToOnlineInSet(farmId, earmark, todayDateText);
|
|
|
+// }
|
|
|
System.out.println("## END 耳标数据。 " + new DateUtil().getTodayMissionText());
|
|
|
} else {
|
|
|
log.error("出错:该请求的FarmId为空.请检查该设备编码[" + deviceCode + "]是否存在FarmId.");
|
|
@@ -171,6 +171,25 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void updateEartagPropertyOfAllStatus(JSONObject dataJo) throws ParseException {
|
|
|
+ String farmId = dataJo.getString("farmId");
|
|
|
+ String earmark = dataJo.getString("earmark");
|
|
|
+
|
|
|
+ String todayDateText = new DateUtil().getTodayDateText();
|
|
|
+ Date now = new Date();
|
|
|
+
|
|
|
+ if (!cacheService.isExistEartagOnlineSet(farmId, earmark, todayDateText)) {
|
|
|
+ //更新总状态数据
|
|
|
+ updateEartagPropertyOfAllStatus(farmId, todayDateText, now);
|
|
|
+ //将耳标号加入到耳标在线集合当中
|
|
|
+ cacheService.putEartagToOnlineInSet(farmId, earmark, todayDateText);
|
|
|
+ }
|
|
|
+ log.info("判断该设备编号是否存在牧场缓存在线集合当中 end");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
public void sendSowProvincePlatform(JSONObject dataJo, String askText) {
|
|
|
// =====================================================================
|
|
|
// 判断耳标-->采集器(基站)-->判断该牧场是否被允许发送耳标数据到省平台;
|
|
@@ -996,15 +1015,18 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
}
|
|
|
|
|
|
//更新耳标设备在线次数
|
|
|
- private void updateEartagDeviceOnlineCount(String earmark, String deviceCode, String todayDateText, java.sql.Date todayDate, Timestamp nowTimestamp, String farmId) {
|
|
|
- //从缓存读取耳标关联数据
|
|
|
-// Map timesMap = cacheService.getEartagDeviceOnlineCountEntries(earmark,deviceCode,todayDateText);
|
|
|
-// System.out.println("###################### timesMap>>"+timesMap);
|
|
|
-// if(timesMap.size()==0){
|
|
|
-// System.out.println("==0");
|
|
|
-// }else{
|
|
|
-// System.out.println("!=0");
|
|
|
-// }
|
|
|
+ @Override
|
|
|
+ public void updateEartagDeviceOnlineCount(JSONObject dataJo) {
|
|
|
+ //设备编码
|
|
|
+ String deviceCode = dataJo.getString("device");
|
|
|
+ //耳标号
|
|
|
+ String earmark = dataJo.getString("earmark");
|
|
|
+
|
|
|
+ String farmId = dataJo.getString("farmId");
|
|
|
+ String todayDateText = new DateUtil().getTodayDateText();
|
|
|
+ java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
|
|
|
+ Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
|
|
|
+
|
|
|
//{读取耳标设备关联统计}
|
|
|
List<EartagDeviceEartagCountEntity> deviceEartagCountEntityList = deviceEartagCountRepo.getEartagDeviceCount(earmark, deviceCode, todayDateText);
|
|
|
if (deviceEartagCountEntityList.size() == 0) {
|
|
@@ -1039,7 +1061,8 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
}
|
|
|
|
|
|
//更新设备环境信息
|
|
|
- public void updateEartagPropertyOfAllStatus(String farmId, String todayDateText, java.sql.Date todayDate, Timestamp nowTimestamp) throws ParseException {
|
|
|
+ public void updateEartagPropertyOfAllStatus(String farmId, String todayDateText, Date todayDate ) {
|
|
|
+
|
|
|
//{获取处于工作状态的设备数量}
|
|
|
Integer deviceTotal = deviceService.getDeviceTotalByFarmIdFromDeviceRegister(farmId);
|
|
|
//设备在线数量
|
|
@@ -1056,7 +1079,7 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
Integer deviceCancelSum = deviceService.getDeviceCancelTotalFromDeviceRegister(farmId);
|
|
|
//耳标总数量 eartagService.
|
|
|
Integer eartagTotal = getEartagRegTotalByFarmId(farmId);
|
|
|
- System.out.println("## eartagTotal>>" + eartagTotal);
|
|
|
+ log.info("## eartagTotal>>" + eartagTotal);
|
|
|
Integer eartagOnlineSum = 0;
|
|
|
Float eartagOnlineRate = 0F;
|
|
|
if (eartagTotal != 0) {
|
|
@@ -1071,7 +1094,7 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
EartarFarmAllStatusEntity farmAllStatusEntity = eartagFarmAllStatusRepo.getOneByFarmIdAndCreateDate(farmId, todayDateText);
|
|
|
if (farmAllStatusEntity == null) {
|
|
|
//{新建设备状态记录并更新缓存cache}
|
|
|
- newFarmAllStatus(farmId, todayDate, nowTimestamp, deviceTotal, deviceOnlineSum, deviceOfflineSum, deviceCancelSum, deviceOnlineRate, eartagTotal, eartagOnlineSum, eartagOnlineRate);
|
|
|
+ newFarmAllStatus(farmId, todayDate, deviceTotal, deviceOnlineSum, deviceOfflineSum, deviceCancelSum, deviceOnlineRate, eartagTotal, eartagOnlineSum, eartagOnlineRate);
|
|
|
} else {
|
|
|
//计算设备状态并更新缓存cache(在线数+1,离线数-1,计算设备在线率)
|
|
|
farmAllStatusEntity.setDeviceTotal(deviceTotal);
|
|
@@ -1082,7 +1105,7 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
farmAllStatusEntity.setEartagTotal(eartagTotal);
|
|
|
farmAllStatusEntity.setEartagOnline(eartagOnlineSum);
|
|
|
farmAllStatusEntity.setEartagRate(eartagOnlineRate);
|
|
|
- farmAllStatusEntity.setUpdateTime(nowTimestamp);
|
|
|
+ farmAllStatusEntity.setUpdateTime(todayDate);
|
|
|
eartagFarmAllStatusRepo.saveAndFlush(farmAllStatusEntity);
|
|
|
//{同步更新牧场总状态缓存相关字段}
|
|
|
cacheService.flashAllStatusCache(farmId, farmAllStatusEntity);
|
|
@@ -1090,7 +1113,7 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
}
|
|
|
|
|
|
//# 新建总状态记录 #
|
|
|
- private void newFarmAllStatus(String farmId, java.sql.Date todayDate, Timestamp nowTimestamp, Integer deviceTotal, Integer deviceOnlineSum, Integer deviceOfflineSum, Integer deviceCancelSum, Float deviceOnlineRate, Integer eartagTotal, Integer eartagOnlineSum, Float eartagOnlineRate) {
|
|
|
+ private void newFarmAllStatus(String farmId, Date todayDate , Integer deviceTotal, Integer deviceOnlineSum, Integer deviceOfflineSum, Integer deviceCancelSum, Float deviceOnlineRate, Integer eartagTotal, Integer eartagOnlineSum, Float eartagOnlineRate) {
|
|
|
Integer liveStatus = 1;
|
|
|
if (deviceService.getDeviceSum(farmId, liveStatus) == 0) {
|
|
|
log.error("该牧场没有任何处于工作状态的采集器设备.");
|
|
@@ -1106,7 +1129,7 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
farmAllStatusEntity.setEartagOnline(eartagOnlineSum);
|
|
|
farmAllStatusEntity.setEartagRate(eartagOnlineRate);
|
|
|
farmAllStatusEntity.setFarmId(farmId);
|
|
|
- farmAllStatusEntity.setUpdateTime(nowTimestamp);
|
|
|
+ farmAllStatusEntity.setUpdateTime(todayDate);
|
|
|
farmAllStatusEntity.setCreateDate(todayDate);
|
|
|
eartagFarmAllStatusRepo.saveAndFlush(farmAllStatusEntity);
|
|
|
//设置总状态缓存
|