|
@@ -3,13 +3,8 @@ package com.huimv.eartag2.manage.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.huimv.eartag2.common.dao.entity.EartagDeviceOnlineEntity;
|
|
|
-import com.huimv.eartag2.common.dao.entity.EartagDeviceRegisterEntity;
|
|
|
-import com.huimv.eartag2.common.dao.entity.EartarFarmAllStatusEntity;
|
|
|
-import com.huimv.eartag2.common.dao.repo.EartagDeviceOnlineRepo;
|
|
|
-import com.huimv.eartag2.common.dao.repo.EartagDeviceRegisterRepo;
|
|
|
-import com.huimv.eartag2.common.dao.repo.EartagEartagRegisterRepo;
|
|
|
-import com.huimv.eartag2.common.dao.repo.EartarFarmAllStatusRepo;
|
|
|
+import com.huimv.eartag2.common.dao.entity.*;
|
|
|
+import com.huimv.eartag2.common.dao.repo.*;
|
|
|
//import com.huimv.eartag2.common.service.IDevice;
|
|
|
import com.huimv.eartag2.common.utils.BizConst;
|
|
|
import com.huimv.eartag2.common.utils.DateUtil;
|
|
@@ -52,8 +47,44 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
private String deviceOnlineAccessMode;
|
|
|
@Autowired
|
|
|
private EartagDeviceOnlineRepo deviceOnlineRepo;
|
|
|
+ @Autowired
|
|
|
+ private EartagEartagOnlineRepo eartagOnlineRepo;
|
|
|
+ @Autowired
|
|
|
+ private EartagDeviceEartagCountRepo deviceEartagCountRepo;
|
|
|
|
|
|
+ /**
|
|
|
+ * @Method : listDeviceEartagOnlineCountByDeviceCode
|
|
|
+ * @Description :
|
|
|
+ * @Params : [deviceCode]
|
|
|
+ * @Return : com.huimv.eartag2.common.utils.Result
|
|
|
+ *
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Date : 2022/3/7
|
|
|
+ * @Time : 17:13
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Result listDeviceEartagOnlineCountByDeviceCode(String deviceCode) throws ParseException {
|
|
|
+ DateUtil du = new DateUtil();
|
|
|
+ String todayDateText = du.getTodayDateText();
|
|
|
+ //
|
|
|
+ List<EartagDeviceEartagCountEntity> deviceEartagCountEntityList = deviceEartagCountRepo.getOnlineEartagByDeviceCode(deviceCode,todayDateText);
|
|
|
+ if(deviceEartagCountEntityList.size()==0){
|
|
|
+ return new Result(BizConst.CODE_DEVICE_EARTAG_COUNT_NO_EXIST,BizConst.MSG_DEVICE_EARTAG_COUNT_NO_EXIST,false);
|
|
|
+ }else{
|
|
|
+ return new Result(ResultCode.SUCCESS,JSONObject.toJSONString(deviceEartagCountEntityList));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * @Method : listDeviceOnlineStatusByDeviceCode
|
|
|
+ * @Description : 列表在线设备关联在线耳标统计
|
|
|
+ * @Params : [deviceCode, pastDays]
|
|
|
+ * @Return : com.huimv.eartag2.common.utils.Result
|
|
|
+ *
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Date : 2022/3/7
|
|
|
+ * @Time : 17:13
|
|
|
+ */
|
|
|
@Override
|
|
|
public Result listDeviceOnlineStatusByDeviceCode(String deviceCode, Integer pastDays) throws ParseException {
|
|
|
DateUtil du = new DateUtil();
|
|
@@ -66,7 +97,6 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
List<String> pastDateList = du.getPastIntervalsASC(pastDays);
|
|
|
JSONArray dataJa = new JSONArray();
|
|
|
for(String pastDayDate:pastDateList){
|
|
|
- int compareInt = du.parseDate(pastDayDate).compareTo(du.getTodayDate());
|
|
|
JSONObject newJo = new JSONObject();
|
|
|
dataJa.add(newJo);
|
|
|
newJo.put("time",pastDayDate);
|
|
@@ -74,7 +104,6 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
for(EartagDeviceOnlineEntity deviceOnlineEntity:deviceOnlineEntityList)
|
|
|
{
|
|
|
int compareTo = du.parseDate(pastDayDate).compareTo(deviceOnlineEntity.getAddDate());
|
|
|
-// System.out.println("compareTo>>"+compareTo+" "+du.formatDateText(deviceOnlineEntity.getAddDate()));
|
|
|
if(compareTo == 0){
|
|
|
newJo.put("value",1);
|
|
|
ieFound = true;
|
|
@@ -91,7 +120,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* @Method : listDeviceOnlineByDeviceCode
|
|
|
* @Description : 查询单个设备N天在线记录
|
|
|
* @Params : [deviceCode]
|