Commit 4290eeca by 王衍超

预警功能bug修复;

parent cdcb7b0e
...@@ -82,7 +82,6 @@ public class WarningServiceImpl implements WarningService{ ...@@ -82,7 +82,6 @@ public class WarningServiceImpl implements WarningService{
Boolean isOpen = warnSetting.isOpen(); Boolean isOpen = warnSetting.isOpen();
if(isOpen != null) warSettingIdObj.set(WarnSettingConstant.isOpen, isOpen); if(isOpen != null) warSettingIdObj.set(WarnSettingConstant.isOpen, isOpen);
warnSettingDao.update(warSettingIdObj); warnSettingDao.update(warSettingIdObj);
//修改后触发预警 //修改后触发预警
BaseBusinessWarn baseBusinessWarn = new BaseBusinessWarn(warSettingId); BaseBusinessWarn baseBusinessWarn = new BaseBusinessWarn(warSettingId);
baseBusinessWarn.warn(); baseBusinessWarn.warn();
...@@ -111,9 +110,7 @@ public class WarningServiceImpl implements WarningService{ ...@@ -111,9 +110,7 @@ public class WarningServiceImpl implements WarningService{
@Override @Override
public void updateWarnExe(WarnExeRecord warnExeRecord) { public void updateWarnExe(WarnExeRecord warnExeRecord) {
KClass type = Amino.getApplicationMetadataContext().getBean(WarnSettingConstant.ENTITY_WARNINGEXE, KClass.class); KObject object = warnSettingDao.queryWarningExeById(warnExeRecord.getId());
JsonNode json = JSONObjectUtils.toJson(warnExeRecord);
KObject object = JSONObjectUtils.toObject(json, type);
object.set("recentlyTime", warnExeRecord.getRecentlyTime()); object.set("recentlyTime", warnExeRecord.getRecentlyTime());
object.set("endTime", warnExeRecord.getEndTime()); object.set("endTime", warnExeRecord.getEndTime());
object.set("warnState", warnExeRecord.getWarnState()); object.set("warnState", warnExeRecord.getWarnState());
......
...@@ -16,7 +16,7 @@ import com.xyst.dinas.contract.service.ContractService; ...@@ -16,7 +16,7 @@ import com.xyst.dinas.contract.service.ContractService;
* @author Jackpot * @author Jackpot
* @date 2021年4月22日 * @date 2021年4月22日
*/ */
public class ContractExpireWarningCalculator implements IWarningCalculator{ public class ContractExpireWarningCalculator implements IWarningCalculator{
private int days; private int days;
...@@ -26,21 +26,27 @@ public class ContractExpireWarningCalculator implements IWarningCalculator{ ...@@ -26,21 +26,27 @@ public class ContractExpireWarningCalculator implements IWarningCalculator{
@Autowired @Autowired
private ContractService contractService; private ContractService contractService;
private final int millisOfDay = 1000 * 3600 * 24;
@Override @Override
public boolean isWarning(WarnSetting warnSetting) { public boolean isWarning(WarnSetting warnSetting) {
String min = warnSetting.getMin(); String min = warnSetting.getMin();
String target = warnSetting.getTarget();
if(min==null || min.trim().length()==0) return false; if(min==null || min.trim().length()==0) return false;
KObject contract = contractService.queryContract(warnSetting.getBillId()); KObject contract = contractService.queryContract(warnSetting.getBillId());
Date endDate = contract.getDate(ContractConstant.endDate); Date endDate = contract.getDate(ContractConstant.endDate);
Date now = new Date(); Date now = new Date();
int diff = now.compareTo(endDate); int diff = (int) ((endDate.getTime() -now.getTime()) / millisOfDay);
if (diff > Integer.valueOf(min)) {
if (diff < Integer.valueOf(min)) {
int value = diff - Integer.valueOf(min);
String contractCode = contract.getString(ContractConstant.CONTRACT_CODE); String contractCode = contract.getString(ContractConstant.CONTRACT_CODE);
if (value>= 0) {
// warnMessage = "编号["+contractCode+"]"+"的合同"+target+"为"+advanceBalance+",已不足"+min+"!"; warnMessage = "编号["+contractCode+"]"+"的合同还有"+value+"天到期!";
}else {
warnMessage = "编号["+contractCode+"]"+"的合同已经过期"+Math.abs(value)+"天!";
}
return true; return true;
} }
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment