同步檀树岗预警规则配置定时任务

master
yangzhe123 2025-12-08 14:11:44 +08:00
parent f4d59ed1e0
commit 0d1080affa
3 changed files with 24 additions and 14 deletions

View File

@ -58,7 +58,7 @@ public class RiceSupportBalance implements Serializable {
* 0-1-
*/
@TableField(value = "status")
@Schema(description = "状态0-计算中1-已完成")
@Schema(description = "状态0-计算中1-已完成 2-计算失败")
private Integer status;
/**
@ -71,9 +71,9 @@ public class RiceSupportBalance implements Serializable {
/**
* m³
*/
@TableField(value = "total_support")
@TableField(value = "total_plan")
@Schema(description = "总计划供水量万m³")
private BigDecimal totalSupport;
private BigDecimal totalPlan;
/**
*
@ -104,7 +104,13 @@ public class RiceSupportBalance implements Serializable {
@Schema(description = "来水预测主键")
private Long icWaterId;
@TableField(value = "fail_reason")
@Schema(description = "计算失败原因")
private String failReason;
@TableField(exist = false)
private List<RiceSupportBalanceDetail> details;
}

View File

@ -9,9 +9,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.hsz.common.model.JcskGnssR;
import com.gunshi.project.hsz.common.model.JcskSlR;
import com.gunshi.project.hsz.common.model.JcskSyR;
import com.gunshi.project.hsz.common.util.LocalDateTimeConverter;
import com.gunshi.project.hsz.entity.so.WarnRulePageSo;
import com.gunshi.project.hsz.mapper.OsmoticWarnRuleMapper;
import com.gunshi.project.hsz.model.*;
import com.gunshi.project.hsz.model.OsmoticWarnR;
import com.gunshi.project.hsz.model.OsmoticWarnRule;
import com.gunshi.project.hsz.service.OsmoticWarnRService;
import com.gunshi.project.hsz.util.DateTransforUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -103,7 +106,7 @@ public class OsmoticWarnRuleService extends ServiceImpl<OsmoticWarnRuleMapper, O
}
if (shoudWarn) {
insertWarn(stationCode, rule.getId(), flow.getSpprwl(), OsmoticWarnRule.Type.PRESS.getType(), rule.getLevel(),DateTransforUtil.transforLocalDateTimeToDate(flow.getMstm()),rule.getResolveSuggest());
insertWarn(stationCode, rule.getId(), flow.getSpprwl(), OsmoticWarnRule.Type.PRESS.getType(), rule.getLevel(),LocalDateTimeConverter.toDate(flow.getMstm()),rule.getResolveSuggest());
}
}
}
@ -215,7 +218,7 @@ public class OsmoticWarnRuleService extends ServiceImpl<OsmoticWarnRuleMapper, O
if (cond1value == null) continue;
boolean cond1Violating;
if(rule.getDirection().contains("x")){
cond1Violating = isViolating(valueXToCompare, cond1, cond1value);
cond1Violating = isViolating(valueXToCompare, cond1, cond1value);
}else if(rule.getDirection().contains("y")){
cond1Violating = isViolating(valueYToCompare, cond1, cond1value);
}else{
@ -256,11 +259,11 @@ public class OsmoticWarnRuleService extends ServiceImpl<OsmoticWarnRuleMapper, O
if (shoudWarn) {
if(rule.getDirection().contains("x")){
insertWarn(stationCode, rule.getId(), shift.getDe(), OsmoticWarnRule.Type.SHIFT.getType(), rule.getLevel(), DateTransforUtil.transforLocalDateTimeToDate(shift.getTm()), rule.getResolveSuggest());
insertWarn(stationCode, rule.getId(), shift.getDe(), OsmoticWarnRule.Type.SHIFT.getType(), rule.getLevel(), LocalDateTimeConverter.toDate(shift.getTm()), rule.getResolveSuggest());
}else if(rule.getDirection().contains("y")){
insertWarn(stationCode, rule.getId(), shift.getDn(), OsmoticWarnRule.Type.SHIFT.getType(), rule.getLevel(),DateTransforUtil.transforLocalDateTimeToDate(shift.getTm()), rule.getResolveSuggest());
insertWarn(stationCode, rule.getId(), shift.getDn(), OsmoticWarnRule.Type.SHIFT.getType(), rule.getLevel(),LocalDateTimeConverter.toDate(shift.getTm()), rule.getResolveSuggest());
}else{
insertWarn(stationCode, rule.getId(), shift.getDu(), OsmoticWarnRule.Type.SHIFT.getType(), rule.getLevel(),DateTransforUtil.transforLocalDateTimeToDate(shift.getTm()), rule.getResolveSuggest());
insertWarn(stationCode, rule.getId(), shift.getDu(), OsmoticWarnRule.Type.SHIFT.getType(), rule.getLevel(),LocalDateTimeConverter.toDate(shift.getTm()), rule.getResolveSuggest());
}
}
@ -321,7 +324,7 @@ public class OsmoticWarnRuleService extends ServiceImpl<OsmoticWarnRuleMapper, O
}
if (shoudWarn) {
insertWarn(stationCode, rule.getId(), flow.getSpqn(), OsmoticWarnRule.Type.FLOW.getType(), rule.getLevel(),DateTransforUtil.transforLocalDateTimeToDate(flow.getMstm()), rule.getResolveSuggest());
insertWarn(stationCode, rule.getId(), flow.getSpqn(), OsmoticWarnRule.Type.FLOW.getType(), rule.getLevel(),LocalDateTimeConverter.toDate(flow.getMstm()), rule.getResolveSuggest());
}
}
}

View File

@ -76,9 +76,6 @@ public class RiceSupportBalanceService extends ServiceImpl<RiceSupportBalanceMap
BigDecimal deadW = stZvarlBService.getWByZvarl(list, deadLev);//死水位库容
Integer year = riceRqWater.getRiceGrowConfig().getYear();//获取相似年
if(dto.getStartTime().isAfter(today)){
// 总来水量 = 当前~开始时间这一段时间的来水量 + 来回方案来水
//方案来水量的时间范围 今天1号开始时间4号需要计算1-3号共3天
Integer gapDay = LocalDateTimeUtils.getTotalDayByRangeDate(today, dto.getStartTime().minusDays(1)); // 注意:这里应该是到开始时间前一天
//获取降雨相似年资料
BigDecimal totalRainfallWater = BigDecimal.ZERO;
for (TyYearRainfallVo tyYearRainfallVo : tyYearRainfallService.queryList()) {
@ -186,7 +183,7 @@ public class RiceSupportBalanceService extends ServiceImpl<RiceSupportBalanceMap
riceSupportBalance.setStartTime(dto.getStartTime());
riceSupportBalance.setEndTime(dto.getEndTime());
riceSupportBalance.setCreateTime(LocalDateTime.now());
riceSupportBalance.setTotalSupport(totalPlan);//实际供水量
riceSupportBalance.setTotalPlan(totalPlan);//实际供水量
riceSupportBalance.setTotalCost(totalNeedWater);//计划供水量
riceSupportBalance.setCreateName(dto.getCreateName());
riceSupportBalance.setStatus(0);
@ -281,6 +278,9 @@ public class RiceSupportBalanceService extends ServiceImpl<RiceSupportBalanceMap
updateById(riceSupportBalance);
} catch (Exception e) {
log.error("保存水稻平衡供水明细失败", e);
riceSupportBalance.setStatus(2);
riceSupportBalance.setFailReason(e.getMessage());
updateById(riceSupportBalance);
}
}).start();
// 主线程立即返回,不等待明细计算完成
@ -341,6 +341,7 @@ public class RiceSupportBalanceService extends ServiceImpl<RiceSupportBalanceMap
if(!StringUtils.isBlank(page.getPlanName())){
queryWrapper.like(RiceSupportBalance::getPlanName, page.getPlanName());
}
queryWrapper.orderByDesc(RiceSupportBalance::getCreateTime);
Page<RiceSupportBalance> riceSupportBalancePage = this.baseMapper.selectPage(page.getPageSo().toPage(), queryWrapper);
for (RiceSupportBalance record : riceSupportBalancePage.getRecords()) {
List<RiceSupportBalanceDetail> details = riceSupportBalanceDetailService.selectByRCId(record.getId());