Commit cf9bcc6e by 王炜晨

Merge branch 'develop' of…

Merge branch 'develop' of https://gitlab.beecode.cn/kunlun/xyst_dinas/xyst_dinas_backend into develop
parents 8edf824c 01acdcd9
......@@ -15,6 +15,7 @@ import com.xyst.dinas.biz.internal.service.StationServiceImpl;
import com.xyst.dinas.biz.service.PositionService;
import com.xyst.dinas.biz.service.StationService;
import com.xyst.dinas.biz.web.PositionController;
import com.xyst.dinas.biz.web.Station2Controller;
import com.xyst.dinas.biz.web.StationController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
......@@ -68,6 +69,11 @@ public class StationConfiguration {
return new StationController();
}
@Bean
public Station2Controller station2Controller(){
return new Station2Controller();
}
@Bean(StationConstant.ENTITY)
public KClass stationInfoEntity() {
......
......@@ -82,7 +82,6 @@ public class WarningServiceImpl implements WarningService{
Boolean isOpen = warnSetting.isOpen();
if(isOpen != null) warSettingIdObj.set(WarnSettingConstant.isOpen, isOpen);
warnSettingDao.update(warSettingIdObj);
//修改后触发预警
BaseBusinessWarn baseBusinessWarn = new BaseBusinessWarn(warSettingId);
baseBusinessWarn.warn();
......@@ -111,14 +110,12 @@ public class WarningServiceImpl implements WarningService{
@Override
public void updateWarnExe(WarnExeRecord warnExeRecord) {
KClass type = Amino.getApplicationMetadataContext().getBean(WarnSettingConstant.ENTITY_WARNINGEXE, KClass.class);
JsonNode json = JSONObjectUtils.toJson(warnExeRecord);
KObject object = JSONObjectUtils.toObject(json, type);
object.set("recentlyTime", warnExeRecord.getRecentlyTime());
object.set("endTime", warnExeRecord.getEndTime());
object.set("warnState", warnExeRecord.getWarnState());
object.set("actualValue", warnExeRecord.getActualValue());
warnSettingDao.update(object);
KObject object = warnSettingDao.queryWarningExeById(warnExeRecord.getId());
if(warnExeRecord.getRecentlyTime()!=null) object.set("recentlyTime", warnExeRecord.getRecentlyTime());
if(warnExeRecord.getEndTime()!=null) object.set("endTime", warnExeRecord.getEndTime());
if(warnExeRecord.getWarnState()!=null) object.set("warnState", warnExeRecord.getWarnState());
if(warnExeRecord.getActualValue()!=null) object.set("actualValue", warnExeRecord.getActualValue());
warnSettingDao.update(object);
}
/**
......
......@@ -16,31 +16,37 @@ import com.xyst.dinas.contract.service.ContractService;
* @author Jackpot
* @date 2021年4月22日
*/
public class ContractExpireWarningCalculator implements IWarningCalculator{
public class ContractExpireWarningCalculator implements IWarningCalculator{
private int days;
private int diffDays;
private String warnMessage;
@Autowired
private ContractService contractService;
private final int millisOfDay = 1000 * 3600 * 24;
@Override
public boolean isWarning(WarnSetting warnSetting) {
String min = warnSetting.getMin();
String target = warnSetting.getTarget();
if(min==null || min.trim().length()==0) return false;
KObject contract = contractService.queryContract(warnSetting.getBillId());
Date endDate = contract.getDate(ContractConstant.endDate);
Date now = new Date();
int diff = now.compareTo(endDate);
if (diff > Integer.valueOf(min)) {
diffDays = (int) ((endDate.getTime() -now.getTime()) / millisOfDay);
if (diffDays < Integer.valueOf(min)) {
int value = diffDays - Integer.valueOf(min);
String contractCode = contract.getString(ContractConstant.CONTRACT_CODE);
// warnMessage = "编号["+contractCode+"]"+"的合同"+target+"为"+advanceBalance+",已不足"+min+"!";
if (value>= 0) {
warnMessage = "编号["+contractCode+"]"+"的合同还有"+value+"天到期!";
}else {
warnMessage = "编号["+contractCode+"]"+"的合同已经过期"+Math.abs(value)+"天!";
}
return true;
}
return false;
......@@ -53,7 +59,7 @@ public class ContractExpireWarningCalculator implements IWarningCalculator{
@Override
public String getActualValue() {
return days+"";
return diffDays+"";
}
}
......@@ -113,6 +113,12 @@ public class DischargingServiceImpl implements DischargingService {
businessWarn.warn();
}
@Override
public Double getAllDischargingWeightByNowAndSandAreaId(UUID billId){
return dischargingDao.getAllDischargingWeightByYearAndSandAreaId(new Date(), billId);
}
@Override
public KObject getById(UUID id) {
......
......@@ -38,8 +38,7 @@ public class SandAreaDinasCountWarningCalculate implements IWarningCalculator{
return false;
}
//业务数据与设置的阀值做比较,计算是否预警
//开采量乘10000
if (dischargingWeight >= Double.parseDouble(max)*10000) {
if (dischargingWeight >= Double.parseDouble(max)) {
warnMessage = "["+target+"]"+sandAreaName+"开采量已经达到"+dischargingWeight+",超出预警值"+max;
return true;
}
......
......@@ -2,6 +2,8 @@ package com.xyst.dinas.production.processor;
import com.xyst.dinas.biz.warn.IWarningCalculator;
import com.xyst.dinas.biz.warn.WarnSetting;
import com.xyst.dinas.production.service.DischargingService;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 上岸量比较
......@@ -19,6 +21,8 @@ public class SandAreaDinasCountWarningCalculator implements IWarningCalculator{
private String warnMessage;
@Autowired
private DischargingService dischargingService;
@Override
......@@ -30,8 +34,14 @@ public class SandAreaDinasCountWarningCalculator implements IWarningCalculator{
return false;
}
//TODO
return false;
this.dischargingWeight= dischargingService.getAllDischargingWeightByNowAndSandAreaId(warnSetting.getBillId());
//业务数据与设置的阀值做比较,计算是否预警
if (dischargingWeight >= Double.parseDouble(max)) {
warnMessage = "["+target+"]"+sandAreaName+"开采量已经达到"+dischargingWeight+",超出预警值"+max;
return true;
}
return false;
}
public double getDinasCount() {
......
......@@ -13,6 +13,8 @@ public interface DischargingService {
UUID addDischarging(KObject kObject);
Double getAllDischargingWeightByNowAndSandAreaId(UUID billId);
KObject getById(UUID id);
KObject getByCodeNum(String name, UUID id);
......
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