|
@@ -106,9 +106,6 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
//{更新设备注册信息}
|
|
|
updateDeviceRegister(deviceCode, nowTimestamp, todayDate, farmId);
|
|
|
|
|
|
- //{计算小时运动量}
|
|
|
-// countHourAct(dataJo,nowTimestamp, todayDate, farmId);
|
|
|
-
|
|
|
//{更新耳标注册信息}
|
|
|
// updateEartagRegister(earmark, deviceCode, bat, nowTimestamp, todayDate, farmId);
|
|
|
|
|
@@ -144,7 +141,6 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
private void countHourAct(JSONObject eartagJo, Timestamp nowTimestamp, java.sql.Date todayDate, String farmId) {
|
|
|
DateUtil du = new DateUtil();
|
|
|
int nowHour = du.getNowHour();
|
|
|
-
|
|
|
int eartagOffLineTime = 24;
|
|
|
Optional<SysBaseConfigEntity> optionalConfig = sysBaseConfigEntityRepo.getConfigValue("dropDataEartagOffLineTime");
|
|
|
if (optionalConfig.isPresent()) {
|
|
@@ -153,10 +149,8 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
} else {
|
|
|
log.error("耳标离线过程丢弃数据时长属性未配置.");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
String earmark = eartagJo.getString("earmark");
|
|
|
- int act = Integer.parseInt(eartagJo.getString("act"));
|
|
|
+ Long act = Long.parseLong(eartagJo.getString("act"));
|
|
|
System.out.println("本次运动量="+act);
|
|
|
//
|
|
|
Optional<EartagData2Entity> optionEartagData = eartagData2Repo.getLastByEarmark(earmark,farmId);
|
|
@@ -164,12 +158,13 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
log.info("该耳标号无相关数据.["+earmark+"]");
|
|
|
}
|
|
|
EartagData2Entity eartagData2Entity = optionEartagData.get();
|
|
|
- Integer lastAct = eartagData2Entity.getAct();
|
|
|
+ int lastId = eartagData2Entity.getId();
|
|
|
+ Long lastAct = eartagData2Entity.getAct();
|
|
|
System.out.println("上次运动量="+lastAct);
|
|
|
Timestamp lastAddTime = eartagData2Entity.getAddTime();
|
|
|
long timeDiff = nowTimestamp.getTime() - lastAddTime.getTime();
|
|
|
if(timeDiff/(1000*60*60) < eartagOffLineTime){
|
|
|
- int act1 = 0;
|
|
|
+ long act1 = 0;
|
|
|
boolean resetStatus = false;
|
|
|
if(act < lastAct){
|
|
|
act1 = act;
|
|
@@ -181,12 +176,12 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
//{保存耳标小时运动量}
|
|
|
saveEartagHourAct(farmId,earmark,act1,nowHour,todayDate);
|
|
|
//{保存耳标复位记录}
|
|
|
- saveEartagReset(resetStatus,farmId,earmark,nowTimestamp,todayDate);
|
|
|
+ saveEartagReset(resetStatus,farmId,earmark,nowTimestamp,todayDate,lastId,lastAct,act);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//{保存耳标复位记录}
|
|
|
- private void saveEartagReset(boolean resetStatus, String farmId, String earmark, Timestamp nowTimestamp, java.sql.Date todayDate) {
|
|
|
+ private void saveEartagReset(boolean resetStatus, String farmId, String earmark, Timestamp nowTimestamp, java.sql.Date todayDate, int lastId,Long lastAct,Long act) {
|
|
|
if(resetStatus){
|
|
|
// 保存复位记录
|
|
|
EartagResetEntity eartagResetEntity = new EartagResetEntity();
|
|
@@ -194,6 +189,9 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
eartagResetEntity.setAddDate(todayDate);
|
|
|
eartagResetEntity.setResetTime(nowTimestamp);
|
|
|
eartagResetEntity.setFarmCode(farmId);
|
|
|
+ eartagResetEntity.setLastId(lastId);
|
|
|
+ eartagResetEntity.setLastAct(lastAct);
|
|
|
+ eartagResetEntity.setAct(act);
|
|
|
eartagResetEntityRepo.save(eartagResetEntity);
|
|
|
|
|
|
// 泊村复位统计次数
|
|
@@ -215,7 +213,7 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
}
|
|
|
|
|
|
// {保存耳标小时运动量}
|
|
|
- private void saveEartagHourAct(String farmId, String earmark, int act1, int nowHour, java.sql.Date todayDate) {
|
|
|
+ private void saveEartagHourAct(String farmId, String earmark, long act1, int nowHour, java.sql.Date todayDate) {
|
|
|
Optional<EartagHourActEntity> optionalHourAct = eartagHourActEntityRepo.findByFarmIdAndEarmarkAndHourAndDate(farmId,earmark,nowHour,todayDate);
|
|
|
if(!optionalHourAct.isPresent()){
|
|
|
EartagHourActEntity newEartagHourActEntity = new EartagHourActEntity();
|
|
@@ -304,7 +302,7 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
} else {
|
|
|
EartagData2Entity eartagData2Entity = optionEartagData.get();
|
|
|
Timestamp addTime = eartagData2Entity.getAddTime();
|
|
|
- Integer act = eartagData2Entity.getAct();
|
|
|
+ long act = eartagData2Entity.getAct();
|
|
|
long timeDifference = nowTimestamp.getTime() - addTime.getTime();
|
|
|
int setTimeDiff = 5;
|
|
|
Optional<SysBaseConfigEntity> optionConfig = sysBaseConfigEntityRepo.getConfigValue("timeDifference");
|
|
@@ -908,7 +906,7 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
|
|
|
newEartagRegisterEntity.setEarTemp1(eartagJo.getFloat("earTemp1"));
|
|
|
newEartagRegisterEntity.setEnvTemp1(eartagJo.getFloat("envTemp1"));
|
|
|
- newEartagRegisterEntity.setAct(Integer.parseInt(eartagJo.getString("act1")));
|
|
|
+ newEartagRegisterEntity.setAct(Long.parseLong(eartagJo.getString("act1")));
|
|
|
newEartagRegisterEntity.setSignal1(Integer.parseInt(eartagJo.getString("signal")));
|
|
|
newEartagRegisterEntity.setAskTime(getAskTime(eartagJo.getString("askTime")));
|
|
|
newEartagRegisterEntity.setOther(eartagJo.getString("other"));
|
|
@@ -1044,15 +1042,15 @@ public class EartagServiceImpl implements IEartagService {
|
|
|
Boolean countTimes = Boolean.parseBoolean(countMap.get("countTimes").toString());
|
|
|
//true:设定过滤时间内无耳标数据上传入库;false:有数据入库;
|
|
|
if (countTimes) {
|
|
|
- Integer act = 0;
|
|
|
- Integer act1 = 0;
|
|
|
+ long act = 0;
|
|
|
+ long act1 = 0;
|
|
|
if (Boolean.parseBoolean(countMap.get("fisrtStatus").toString())) {
|
|
|
act = Integer.parseInt(eartagJo.getString("act"));
|
|
|
System.out.println("1 act="+act);
|
|
|
} else {
|
|
|
act = Integer.parseInt(eartagJo.getString("act"));
|
|
|
System.out.println("2 act="+act);
|
|
|
- Integer lastAct = Integer.parseInt(countMap.get("act").toString());
|
|
|
+ long lastAct = Long.parseLong(countMap.get("act").toString());
|
|
|
System.out.println("3 lastAct="+lastAct);
|
|
|
if (act > lastAct) {
|
|
|
act1 = act - lastAct;
|