|
@@ -70,11 +70,9 @@ public class KprAimTapWaterBizFun {
|
|
|
//TODO 循环获取该天该水厂每个设备数据
|
|
|
|
|
|
//TODO 查询当前天日期内每小时的设备数据
|
|
|
- System.out.println(Integer.valueOf(String.valueOf(Duration.between(startDateTime, today.withMinute(0).withSecond(0)).toHours())));
|
|
|
for (int i = 0; i < Integer.valueOf(String.valueOf(Duration.between(startDateTime, today.withMinute(0).withSecond(0)).toHours())); i++) {
|
|
|
String startTime = newStartDateTime.minusHours(-i).format(formater);
|
|
|
String endTime = newStartDateTime.minusHours(-(i + 1)).format(formater);
|
|
|
-
|
|
|
Map<String, Object> recordAllEntity = new HashMap<>();//需要添加的实体数据
|
|
|
recordAllEntity.put("org_name", key.toString());//水厂
|
|
|
recordAllEntity.put("time", endTime);//采集时间(小时的最后时间)
|
|
@@ -84,26 +82,53 @@ public class KprAimTapWaterBizFun {
|
|
|
Double value = null;
|
|
|
//TODO 此循环计算该小时所有设备的用水量
|
|
|
for (Map<String, Object> item : deviceList) {
|
|
|
- Integer itemCount = getWaterTapWaterApi().getTabWaterHistoryCount(
|
|
|
- " WHERE TAG_CODE = '" + item.get("collcation_tag") + "' " +
|
|
|
- " and QCQUISITION_TIME >= to_date('" + startDate + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
- " and QCQUISITION_TIME < to_date('" + endDate + "', 'yyyy-mm-dd hh24:mi:ss')");
|
|
|
- if (itemCount != null && itemCount > 0) {
|
|
|
- List<Map<String, Object>> tapWaterHistoryList = getWaterTapWaterApi().getPageZILAISHUI_HISTORY2(itemCount, 0,
|
|
|
- " AND TAG_CODE = '" + item.get("collcation_tag") + "' " +
|
|
|
- " and QCQUISITION_TIME >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
- " and QCQUISITION_TIME < to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
- " order by QCQUISITION_TIME");
|
|
|
- //TODO tapWaterHistoryList此集合为该设备该小时内的数据,取第一条和最后一条的相差值作为用水量
|
|
|
- if (!CollectionUtils.isEmpty(tapWaterHistoryList) && tapWaterHistoryList.size() > 1) {
|
|
|
- Double firstValue = tapWaterHistoryList.get(0).get("VAL") != null ? Double.valueOf(tapWaterHistoryList.get(0).get("val").toString()) : null;
|
|
|
- Double lastValue = tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("VAL") != null ? Double.valueOf(tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("val").toString()) : null;
|
|
|
- if (firstValue != null && lastValue != null) {
|
|
|
- //到此处是该小时一个设备的用水量已加上
|
|
|
+ //TODO 和尚山水厂的三个OPC的设备0点到1点的数据特殊处理,直接取最后一条数据作为0点到1点的用水量
|
|
|
+ // 定义字符串日期时间的格式
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // 解析字符串以创建 LocalDateTime 实例
|
|
|
+ LocalDateTime dateTime = LocalDateTime.parse(endTime, formatter);
|
|
|
+ if (dateTime.getHour()==1&&("OPC_SC.HSS.HSS1.AI.LJLL1.F_CV".equals(item.get("collcation_tag").toString()) ||
|
|
|
+ "OPC_SC.HSS.HSS1.AI.LJLL2.F_CV".equals(item.get("collcation_tag").toString()) ||
|
|
|
+ "OPC_SC.HSS.HSS1.AI.LJLL3.F_CV".equals(item.get("collcation_tag").toString()))) {
|
|
|
+ Integer itemCount = getWaterTapWaterApi().getTabWaterHistoryCount(
|
|
|
+ " WHERE TAG_CODE = '" + item.get("collcation_tag") + "' " +
|
|
|
+ " and QCQUISITION_TIME >= to_date('" + startDate + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
+ " and QCQUISITION_TIME < to_date('" + endDate + "', 'yyyy-mm-dd hh24:mi:ss')");
|
|
|
+ if(itemCount!=null&&itemCount>0) {
|
|
|
+ List<Map<String, Object>> tapWaterHistoryList = getWaterTapWaterApi().getPageZILAISHUI_HISTORY2(itemCount, 0,
|
|
|
+ " AND TAG_CODE = '" + item.get("collcation_tag") + "' " +
|
|
|
+ " and QCQUISITION_TIME >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
+ " and QCQUISITION_TIME < to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
+ " order by QCQUISITION_TIME");
|
|
|
+ if (!CollectionUtils.isEmpty(tapWaterHistoryList) && tapWaterHistoryList.size() > 1) {
|
|
|
if (value == null) {
|
|
|
value = 0.00;
|
|
|
}
|
|
|
- value += Math.abs(lastValue - firstValue);
|
|
|
+ value += tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("VAL") != null ? Double.valueOf(tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("val").toString()) : null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ Integer itemCount = getWaterTapWaterApi().getTabWaterHistoryCount(
|
|
|
+ " WHERE TAG_CODE = '" + item.get("collcation_tag") + "' " +
|
|
|
+ " and QCQUISITION_TIME >= to_date('" + startDate + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
+ " and QCQUISITION_TIME < to_date('" + endDate + "', 'yyyy-mm-dd hh24:mi:ss')");
|
|
|
+ if (itemCount != null && itemCount > 0) {
|
|
|
+ List<Map<String, Object>> tapWaterHistoryList = getWaterTapWaterApi().getPageZILAISHUI_HISTORY2(itemCount, 0,
|
|
|
+ " AND TAG_CODE = '" + item.get("collcation_tag") + "' " +
|
|
|
+ " and QCQUISITION_TIME >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
+ " and QCQUISITION_TIME < to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
+ " order by QCQUISITION_TIME");
|
|
|
+ //TODO tapWaterHistoryList此集合为该设备该小时内的数据,取第一条和最后一条的相差值作为用水量
|
|
|
+ if (!CollectionUtils.isEmpty(tapWaterHistoryList) && tapWaterHistoryList.size() > 1) {
|
|
|
+ Double firstValue = tapWaterHistoryList.get(0).get("VAL") != null ? Double.valueOf(tapWaterHistoryList.get(0).get("val").toString()) : null;
|
|
|
+ Double lastValue = tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("VAL") != null ? Double.valueOf(tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("val").toString()) : null;
|
|
|
+ if (firstValue != null && lastValue != null) {
|
|
|
+ //到此处是该小时一个设备的用水量已加上
|
|
|
+ if (value == null) {
|
|
|
+ value = 0.00;
|
|
|
+ }
|
|
|
+ value += Math.abs(lastValue - firstValue);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -399,26 +424,53 @@ public class KprAimTapWaterBizFun {
|
|
|
Double value = null;
|
|
|
//TODO 此循环计算该小时所有设备的用水量
|
|
|
for (Map<String, Object> item : deviceList) {
|
|
|
- Integer itemCount = getWaterTapWaterApi().getTabWaterHistoryCount(
|
|
|
- " WHERE TAG_CODE = '" + item.get("collcation_tag") + "' " +
|
|
|
- " and QCQUISITION_TIME >= to_date('" + startDate + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
- " and QCQUISITION_TIME < to_date('" + endDate + "', 'yyyy-mm-dd hh24:mi:ss')");
|
|
|
- if (itemCount != null && itemCount > 0) {
|
|
|
- List<Map<String, Object>> tapWaterHistoryList = getWaterTapWaterApi().getPageZILAISHUI_HISTORY2(itemCount, 0,
|
|
|
- " AND TAG_CODE = '" + item.get("collcation_tag") + "' " +
|
|
|
- " and QCQUISITION_TIME >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
- " and QCQUISITION_TIME < to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
- " order by QCQUISITION_TIME");
|
|
|
- //TODO tapWaterHistoryList此集合为该设备该小时内的数据,取第一条和最后一条的相差值作为用水量
|
|
|
- if (!CollectionUtils.isEmpty(tapWaterHistoryList) && tapWaterHistoryList.size() > 1) {
|
|
|
- Double firstValue = tapWaterHistoryList.get(0).get("VAL") != null ? Double.valueOf(tapWaterHistoryList.get(0).get("val").toString()) : null;
|
|
|
- Double lastValue = tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("VAL") != null ? Double.valueOf(tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("val").toString()) : null;
|
|
|
- if (firstValue != null && lastValue != null) {
|
|
|
- //到此处是该小时一个设备的用水量已加上
|
|
|
+ //TODO 和尚山水厂的三个OPC的设备0点到1点的数据特殊处理,直接取最后一条数据作为0点到1点的用水量
|
|
|
+ // 定义字符串日期时间的格式
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // 解析字符串以创建 LocalDateTime 实例
|
|
|
+ LocalDateTime dateTime = LocalDateTime.parse(endTime, formatter);
|
|
|
+ if (dateTime.getHour()==1&&("OPC_SC.HSS.HSS1.AI.LJLL1.F_CV".equals(item.get("collcation_tag").toString()) ||
|
|
|
+ "OPC_SC.HSS.HSS1.AI.LJLL2.F_CV".equals(item.get("collcation_tag").toString()) ||
|
|
|
+ "OPC_SC.HSS.HSS1.AI.LJLL3.F_CV".equals(item.get("collcation_tag").toString()))) {
|
|
|
+ Integer itemCount = getWaterTapWaterApi().getTabWaterHistoryCount(
|
|
|
+ " WHERE TAG_CODE = '" + item.get("collcation_tag") + "' " +
|
|
|
+ " and QCQUISITION_TIME >= to_date('" + startDate + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
+ " and QCQUISITION_TIME < to_date('" + endDate + "', 'yyyy-mm-dd hh24:mi:ss')");
|
|
|
+ if(itemCount!=null&&itemCount>0) {
|
|
|
+ List<Map<String, Object>> tapWaterHistoryList = getWaterTapWaterApi().getPageZILAISHUI_HISTORY2(itemCount, 0,
|
|
|
+ " AND TAG_CODE = '" + item.get("collcation_tag") + "' " +
|
|
|
+ " and QCQUISITION_TIME >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
+ " and QCQUISITION_TIME < to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
+ " order by QCQUISITION_TIME");
|
|
|
+ if (!CollectionUtils.isEmpty(tapWaterHistoryList) && tapWaterHistoryList.size() > 1) {
|
|
|
if (value == null) {
|
|
|
value = 0.00;
|
|
|
}
|
|
|
- value += Math.abs(lastValue - firstValue);
|
|
|
+ value += tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("VAL") != null ? Double.valueOf(tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("val").toString()) : null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ Integer itemCount = getWaterTapWaterApi().getTabWaterHistoryCount(
|
|
|
+ " WHERE TAG_CODE = '" + item.get("collcation_tag") + "' " +
|
|
|
+ " and QCQUISITION_TIME >= to_date('" + startDate + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
+ " and QCQUISITION_TIME < to_date('" + endDate + "', 'yyyy-mm-dd hh24:mi:ss')");
|
|
|
+ if (itemCount != null && itemCount > 0) {
|
|
|
+ List<Map<String, Object>> tapWaterHistoryList = getWaterTapWaterApi().getPageZILAISHUI_HISTORY2(itemCount, 0,
|
|
|
+ " AND TAG_CODE = '" + item.get("collcation_tag") + "' " +
|
|
|
+ " and QCQUISITION_TIME >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
+ " and QCQUISITION_TIME < to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss')" +
|
|
|
+ " order by QCQUISITION_TIME");
|
|
|
+ //TODO tapWaterHistoryList此集合为该设备该小时内的数据,取第一条和最后一条的相差值作为用水量
|
|
|
+ if (!CollectionUtils.isEmpty(tapWaterHistoryList) && tapWaterHistoryList.size() > 1) {
|
|
|
+ Double firstValue = tapWaterHistoryList.get(0).get("VAL") != null ? Double.valueOf(tapWaterHistoryList.get(0).get("val").toString()) : null;
|
|
|
+ Double lastValue = tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("VAL") != null ? Double.valueOf(tapWaterHistoryList.get((tapWaterHistoryList.size() - 1)).get("val").toString()) : null;
|
|
|
+ if (firstValue != null && lastValue != null) {
|
|
|
+ //到此处是该小时一个设备的用水量已加上
|
|
|
+ if (value == null) {
|
|
|
+ value = 0.00;
|
|
|
+ }
|
|
|
+ value += Math.abs(lastValue - firstValue);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|