|
|
@@ -80,6 +80,9 @@ public class IIotXycbCommService extends IotDeviceBaseServiceImpl implements Iot
|
|
|
case IotDeviceDictConst.TYPE_YF_XYCB_III:
|
|
|
tableClass = IotYfXycbIIIdata.class;
|
|
|
break;
|
|
|
+ case IotDeviceDictConst.TYPE_YF_XYCB_2:
|
|
|
+ tableClass = IotYfXycb2data.class;
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
@@ -101,7 +104,7 @@ public class IIotXycbCommService extends IotDeviceBaseServiceImpl implements Iot
|
|
|
throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "请输入正确的起止时间");
|
|
|
}
|
|
|
|
|
|
- IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
|
|
|
+ IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(devBid);
|
|
|
if (findDevice == null) {
|
|
|
throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "设备不存在");
|
|
|
}
|
|
|
@@ -155,6 +158,12 @@ public class IIotXycbCommService extends IotDeviceBaseServiceImpl implements Iot
|
|
|
if (StringUtils.isEmpty(devBid)) {
|
|
|
throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
|
|
|
}
|
|
|
+
|
|
|
+ IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
|
|
|
+ if (findDevice == null) {
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "设备不存在");
|
|
|
+ }
|
|
|
+
|
|
|
String startDate = reqVo.getStartTime();
|
|
|
String endDate = reqVo.getEndTime();
|
|
|
String unit = "day";
|
|
|
@@ -177,7 +186,7 @@ public class IIotXycbCommService extends IotDeviceBaseServiceImpl implements Iot
|
|
|
ProjectionOperation projectionOperation = Aggregation.project()
|
|
|
.and("xycbdataContent.ah").as("ah")
|
|
|
.and("xycbdataContent.at").as("at")
|
|
|
- .and("xycbdataContent.ct").as("ct")
|
|
|
+ .and("xycbdataContent.infr_ct").as("ct")
|
|
|
.and("xycbdataCreatedDate").as("createDate");
|
|
|
|
|
|
ProjectionOperation projectionOperation2 = Aggregation.project()
|
|
|
@@ -206,9 +215,9 @@ public class IIotXycbCommService extends IotDeviceBaseServiceImpl implements Iot
|
|
|
projectionOperation3,
|
|
|
sortOperation
|
|
|
);
|
|
|
-
|
|
|
+ Class tableClass = getTableClass(findDevice.getDevtypeBid());
|
|
|
List<IotXycbPolylineResVo> iotXycbPolylineResVos = mongoService.aggregate(
|
|
|
- IotYfXycbIIIdata.class, aggregation, IotXycbPolylineResVo.class
|
|
|
+ tableClass, aggregation, IotXycbPolylineResVo.class
|
|
|
);
|
|
|
return iotXycbPolylineResVos;
|
|
|
}
|
|
|
@@ -223,6 +232,13 @@ public class IIotXycbCommService extends IotDeviceBaseServiceImpl implements Iot
|
|
|
if (StringUtils.isEmpty(devBid)) {
|
|
|
throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
|
|
|
}
|
|
|
+ String startDate = reqVo.getStartTime();
|
|
|
+ String endDate = reqVo.getEndTime();
|
|
|
+
|
|
|
+ if(!(StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate))){
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "请输入正确的起止时间");
|
|
|
+ }
|
|
|
+
|
|
|
IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devBid);
|
|
|
if(iotDevice == null){
|
|
|
throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
|
|
|
@@ -230,6 +246,8 @@ public class IIotXycbCommService extends IotDeviceBaseServiceImpl implements Iot
|
|
|
|
|
|
IotXycbInfoResVo iotXycbInfoResVo = new IotXycbInfoResVo();
|
|
|
iotXycbInfoResVo.setDevStatus(iotDevice.getDevStatus());
|
|
|
+ iotXycbInfoResVo.setDevBid(devBid);
|
|
|
+ iotXycbInfoResVo.setDevtypeBid(iotDevice.getDevtypeBid());
|
|
|
|
|
|
IotXyinfoDto iotXyinfoDto = iIotXyinfoService.selectIotXyinfoByDevBid(devBid);
|
|
|
if(iotXyinfoDto != null){
|
|
|
@@ -249,23 +267,47 @@ public class IIotXycbCommService extends IotDeviceBaseServiceImpl implements Iot
|
|
|
iotXycbInfoResVo.setRainStatusName(rainStatusName);
|
|
|
}
|
|
|
|
|
|
- HashMap<String, String> params = new HashMap<>();
|
|
|
- params.put("devBid", devBid);
|
|
|
+ Criteria criteria = new Criteria()
|
|
|
+ .and("devBid").is(devBid)
|
|
|
+ .andOperator(
|
|
|
+ Criteria.where("xycbdataCreatedDate").gte(startDate),
|
|
|
+ Criteria.where("xycbdataCreatedDate").lte(endDate)
|
|
|
+ );
|
|
|
+ MatchOperation matchOperation = Aggregation.match(criteria);
|
|
|
+ SortOperation sortOperation = Aggregation.sort(Sort.Direction.DESC, "xycbdataCreatedDate");
|
|
|
|
|
|
- Class tableClass = getTableClass(iotDevice.getDevtypeBid());
|
|
|
- IotYfXycbdata iotYfXycbdata = (IotYfXycbdata) mongoService.findOne(tableClass, params, "xycbdataCreatedDate", "desc");
|
|
|
- if(iotYfXycbdata != null){
|
|
|
- JSONObject xyData = iotYfXycbdata.getXycbdataContent();
|
|
|
- iotXycbInfoResVo.setAt(xyData.getString("at"));
|
|
|
- iotXycbInfoResVo.setAh(xyData.getString("ah"));
|
|
|
- }
|
|
|
+ ProjectionOperation projectionOperation = Aggregation.project()
|
|
|
+ .and("at").as("at")
|
|
|
+ .and("ah").as("ah")
|
|
|
+ .andExpression("{$convert: {input: '$xycbdataContent.infr_ct', to: 'int', onError: 0, onNull: 0}}").as("ct");
|
|
|
|
|
|
- List<String> devBidList = new ArrayList<>();
|
|
|
- devBidList.add(devBid);
|
|
|
+ GroupOperation groupOperation = Aggregation.group()
|
|
|
+ .first("at").as("at")
|
|
|
+ .first("ah").as("ah")
|
|
|
+ .sum("ct").as("pestTotal");
|
|
|
|
|
|
- Map<String, IotXyinfoPestTotalDto> iotXyinfoPestTotalDtoMap = iIotPestrecogService.getIotXyIIIinfoPestTotalMap(devBidList);
|
|
|
- if(iotXyinfoPestTotalDtoMap.containsKey(devBid)){
|
|
|
- iotXycbInfoResVo.setPestTotal(String.valueOf(iotXyinfoPestTotalDtoMap.get(devBid).getPestTotal()));
|
|
|
+ ProjectionOperation projectionOperation2 = Aggregation.project()
|
|
|
+ .and("at").as("at")
|
|
|
+ .and("ah").as("ah")
|
|
|
+ .and("pestTotal").as("pestTotal");
|
|
|
+
|
|
|
+ Class tableClass = getTableClass(iotDevice.getDevtypeBid());
|
|
|
+ Aggregation aggregation = Aggregation.newAggregation(
|
|
|
+ matchOperation,
|
|
|
+ sortOperation,
|
|
|
+ projectionOperation,
|
|
|
+ groupOperation,
|
|
|
+ projectionOperation2
|
|
|
+ );
|
|
|
+
|
|
|
+ List<IotXycbInfoResVo> iotXyinfoTotalResList = mongoService.aggregate(
|
|
|
+ tableClass, aggregation, IotXycbInfoResVo.class
|
|
|
+ );
|
|
|
+ if(!iotXyinfoTotalResList.isEmpty()){
|
|
|
+ IotXycbInfoResVo iotXyinfoTotalRes = iotXyinfoTotalResList.get(0);
|
|
|
+ iotXycbInfoResVo.setAt(iotXyinfoTotalRes.getAt());
|
|
|
+ iotXycbInfoResVo.setAh(iotXyinfoTotalRes.getAh());
|
|
|
+ iotXycbInfoResVo.setPestTotal(String.valueOf(iotXyinfoTotalRes.getPestTotal()));
|
|
|
}
|
|
|
return iotXycbInfoResVo;
|
|
|
}
|
|
|
@@ -311,24 +353,13 @@ public class IIotXycbCommService extends IotDeviceBaseServiceImpl implements Iot
|
|
|
HttpServletResponse response = iotDeviceExportReqVo.getResponse();
|
|
|
IotDeviceDataListReqVo reqVo = iotDeviceExportReqVo.getReqVo();
|
|
|
|
|
|
- String devBid = reqVo.getDevBid();
|
|
|
- String startTime = reqVo.getStartTime();
|
|
|
- String endTime = reqVo.getEndTime();
|
|
|
- String[] params = {devBid, startTime, endTime};
|
|
|
- for (String k : params) {
|
|
|
- if (StringUtils.isEmpty(k)) {
|
|
|
- throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "参数不能为空");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devBid);
|
|
|
-
|
|
|
- //性诱III 数据导出
|
|
|
- IotXycbReqVo reqVo1 = new IotXycbReqVo();
|
|
|
+ IotDeviceDataListReqVo reqVo1 = new IotDeviceDataListReqVo();
|
|
|
reqVo1.setDevBid(reqVo.getDevBid());
|
|
|
- reqVo1.setStartDate(reqVo.getStartTime());
|
|
|
- reqVo1.setEndDate(reqVo.getEndTime());
|
|
|
- List<IotYfXycbDataListRspVo> list = iIotXycbService.exportXYIIIDataList(reqVo1,iotDevice);
|
|
|
+ reqVo1.setStartTime(reqVo.getStartTime());
|
|
|
+ reqVo1.setEndTime(reqVo.getEndTime());
|
|
|
+
|
|
|
+ TableDataInfo tableDataInfo = dataList(reqVo1);
|
|
|
+ List<IotYfXycbDataListRspVo> list = (List<IotYfXycbDataListRspVo>) tableDataInfo.getData();
|
|
|
ExcelUtil util = new ExcelUtil<>(IotYfXycbDataListRspVo.class);
|
|
|
util.exportExcel(response, list, "设备数据");
|
|
|
}
|