|
@@ -15,8 +15,11 @@ import com.shkpr.service.aimodelpower.dto.TraceRunnable;
|
|
|
import com.shkpr.service.aimodelpower.dto.zilaishuiModel.InPumpModel;
|
|
|
import com.shkpr.service.aimodelpower.globalmgr.ThreadTaskMgr;
|
|
|
import com.shkpr.service.aimodelpower.globalmgr.TraceLogMgr;
|
|
|
+import com.shkpr.service.aimodelpower.jsonbean.zilaishui.JP3TPDay;
|
|
|
+import com.shkpr.service.aimodelpower.jsonbean.zilaishui.JP3TPHour;
|
|
|
import com.shkpr.service.aimodelpower.jsonbean.zilaishui.JPTbMHourWater;
|
|
|
import com.shkpr.service.aimodelpower.jsonbean.zilaishui.JPTbMWater;
|
|
|
+import com.shkpr.service.aimodelpower.services.ServiceMgrProxy;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
@@ -638,13 +641,40 @@ public class KprAimWaterCollecationBizFun {
|
|
|
}
|
|
|
numAll += Double.valueOf(mapEntity.get("value").toString());
|
|
|
}
|
|
|
- //TODO 数据库操作
|
|
|
- Map<String, Object> recordAllEntity = new LinkedHashMap<>();//需要添加的实体数据,此处要用有序map
|
|
|
+ //TODO 数据库操作 A 调用对应时间预测接口 B 在修改实际值
|
|
|
+
|
|
|
DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- recordAllEntity.put("Date", dateNow.withYear(LocalDateTime.now().getYear()).toLocalDate().format(formatter2));
|
|
|
+ String dateStr = dateNow.withYear(LocalDateTime.now().getYear()).toLocalDate().format(formatter2);
|
|
|
+
|
|
|
+ //TODO A
|
|
|
+ JP3TPDay tpDay = new JP3TPDay();
|
|
|
+ tpDay.setOrgId(orgId);
|
|
|
+ tpDay.setSdate(dateStr);
|
|
|
+ tpDay.setEndate(dateStr);
|
|
|
+ try {
|
|
|
+ ResponseRes<String> tpRes = ServiceMgrProxy.getInstance()
|
|
|
+ .applyCloud3tpServiceApi().dayDataPredictSupply(tpDay);
|
|
|
+ if(ResponseCode.RESULT_BAD.toStrCode().equals(tpRes.getRescode())){
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR
|
|
|
+ , mStrClassName
|
|
|
+ , mStrClassName
|
|
|
+ , String.format("预测日数据"+dateStr+"调用失败 ERROR:{%s} ",
|
|
|
+ tpRes.getResdata()));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }catch(Exception ex){
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR
|
|
|
+ , mStrClassName
|
|
|
+ , mStrClassName
|
|
|
+ , String.format("预测日数据"+dateStr+"调用异常 ERROR:{%s} ",
|
|
|
+ ex.getLocalizedMessage()));
|
|
|
+ }
|
|
|
+ //TODO B
|
|
|
+ Map<String, Object> recordAllEntity = new LinkedHashMap<>();//需要添加的实体数据,此处要用有序map
|
|
|
+ recordAllEntity.put("Date", dateStr);
|
|
|
recordAllEntity.put("Month", dateNow.withYear(LocalDateTime.now().getYear()).getMonth().getValue());
|
|
|
recordAllEntity.put("Week", dateNow.withYear(LocalDateTime.now().getYear()).getDayOfWeek().getValue());
|
|
|
- recordAllEntity.put("ActualWaterWithdrawals", "");
|
|
|
+// recordAllEntity.put("ActualWaterWithdrawals", "");
|
|
|
|
|
|
//实际从该时间查询结果中得出(当前年当前日的实际数据)
|
|
|
String newStartDate = dateNow.withYear(LocalDateTime.now().getYear()).format(formatter);
|
|
@@ -675,15 +705,15 @@ public class KprAimWaterCollecationBizFun {
|
|
|
}
|
|
|
|
|
|
recordAllEntity.put("ActualWaterSupply", actualWaterSupply);
|
|
|
- recordAllEntity.put("ForecastWaterWithdrawals", "");
|
|
|
+// recordAllEntity.put("ForecastWaterWithdrawals", "");
|
|
|
//TODO 随机数逻辑
|
|
|
int randomUpOrDown = ThreadLocalRandom.current().nextInt(2);//随机向上或者向下 0表示向下 1表示向上
|
|
|
Double randomWater = randomUpOrDown == 0 ?
|
|
|
numAge - (numAge * (randomCode / 100)) :
|
|
|
numAge + (numAge * (randomCode / 100));
|
|
|
- recordAllEntity.put("ForecastActualWaterSupply", randomWater);
|
|
|
+// recordAllEntity.put("ForecastActualWaterSupply", randomWater);
|
|
|
recordAllEntity.put("isAbnormal", 0);
|
|
|
- recordAllEntity.put("isForecast", 0);
|
|
|
+ recordAllEntity.put("isForecast", 1);
|
|
|
recordAllEntity.put("LastModifyTime", LocalDateTime.now().format(formatter));
|
|
|
// 如果找到了org_id,就将其赋值给orgId,否则orgId为null
|
|
|
recordAllEntity.put("orgId", orgId);
|
|
@@ -797,23 +827,51 @@ public class KprAimWaterCollecationBizFun {
|
|
|
JSONArray pumpArray = ((JSONObject)pumpItem.get("outRoom")).getJSONArray("pumps");
|
|
|
//TODO 一天24小时
|
|
|
for (int j = 0;j<24;j++) {
|
|
|
- //TODO 数据库操作
|
|
|
- Map<String, Object> recordAllEntity = new LinkedHashMap<>();//需要添加的实体数据,此处要用有序map
|
|
|
+ //TODO 数据库操作 A 调用对应时间预测接口 B 在修改实际值
|
|
|
DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- recordAllEntity.put("Date", dateNow.withYear(LocalDateTime.now().getYear()).toLocalDate().format(formatter2));
|
|
|
+ DateTimeFormatter formatter3 = DateTimeFormatter.ofPattern("HH:mm:ss");
|
|
|
+ String dateStr = dateNow.withYear(LocalDateTime.now().getYear()).toLocalDate().format(formatter2);
|
|
|
// 创建一个LocalTime实例,设置为指定小时,分钟和秒数为0
|
|
|
LocalTime time = LocalTime.of(j, 0, 0);
|
|
|
// 创建一个DateTimeFormatter用于格式化时间
|
|
|
- DateTimeFormatter formatter3 = DateTimeFormatter.ofPattern("HH:mm:ss");
|
|
|
- recordAllEntity.put("Hour", time.format(formatter3));
|
|
|
- recordAllEntity.put("HourForecastWaterWithdrawals", null);
|
|
|
+ String timeStr = time.format(formatter3);
|
|
|
+
|
|
|
+ //TODO A
|
|
|
+ JP3TPHour tpHour = new JP3TPHour();
|
|
|
+ tpHour.setOrgId(orgId);
|
|
|
+ tpHour.setDate(dateStr);
|
|
|
+ try {
|
|
|
+ ResponseRes<String> tpRes = ServiceMgrProxy.getInstance()
|
|
|
+ .applyCloud3tpServiceApi().dayHourPredictSupply(tpHour);
|
|
|
+ if(ResponseCode.RESULT_BAD.toStrCode().equals(tpRes.getRescode())){
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR
|
|
|
+ , mStrClassName
|
|
|
+ , mStrClassName
|
|
|
+ , String.format("预测小时数据"+dateStr+"调用失败 ERROR:{%s} ",
|
|
|
+ tpRes.getResdata()));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }catch(Exception ex){
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR
|
|
|
+ , mStrClassName
|
|
|
+ , mStrClassName
|
|
|
+ , String.format("预测小时数据"+dateStr+"调用异常 ERROR:{%s} ",
|
|
|
+ ex.getLocalizedMessage()));
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO B
|
|
|
+ Map<String, Object> recordAllEntity = new LinkedHashMap<>();//需要添加的实体数据,此处要用有序map
|
|
|
+
|
|
|
+ recordAllEntity.put("Date", dateStr);
|
|
|
+ recordAllEntity.put("Hour", timeStr);
|
|
|
+// recordAllEntity.put("HourForecastWaterWithdrawals", null);
|
|
|
//TODO 随机数逻辑
|
|
|
int randomUpOrDown = ThreadLocalRandom.current().nextInt(2);//随机向上或者向下 0表示向下 1表示向上
|
|
|
Double randomWater = randomUpOrDown == 0 ?
|
|
|
numAge - (numAge * (randomCode / 100)) :
|
|
|
numAge + (numAge * (randomCode / 100));
|
|
|
- recordAllEntity.put("HourForecastActualWaterSupply", randomWater);
|
|
|
- recordAllEntity.put("HourActualWaterWithdrawals", "");
|
|
|
+// recordAllEntity.put("HourForecastActualWaterSupply", randomWater);
|
|
|
+// recordAllEntity.put("HourActualWaterWithdrawals", "");
|
|
|
//实际从该时间查询结果中得出
|
|
|
List<Map<String,Object>> newRecordAllRes = getWaterTapApi()
|
|
|
.getWaterCollectionRecordAllListAll(" WHERE 1=1 " +
|