You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
5.6 KiB
149 lines
5.6 KiB
package com.kms.warn;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.jianwei.common.utils.StringUtils;
|
|
import com.kms.build.domain.*;
|
|
import com.kms.build.service.*;
|
|
import com.kms.warn.warnconfig.HolidayUtil;
|
|
import com.kms.warn.warnconfig.WarnRo;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.time.Instant;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
|
|
@Async
|
|
@Configuration
|
|
public class WarningJudgment<T> {
|
|
|
|
public static final String redisKey = "warn:queue";
|
|
|
|
@Autowired
|
|
WarnOperate warnOperate;
|
|
|
|
@Autowired
|
|
RedisTemplate redisTemplate;
|
|
|
|
@Autowired
|
|
BsSgcJsjdBuiSalaryEnsureService bsSgcJsjdBuiSalaryEnsureService;
|
|
@Autowired
|
|
BsSgcJsjdBuiConstrMeasService bsSgcJsjdBuiConstrMeasService;
|
|
@Autowired
|
|
BsSgcJsjdBuiChangeService bsSgcJsjdBuiChangeService;
|
|
@Autowired
|
|
BsSgcJsjdBuiSubProjectQualityService bsSgcJsjdBuiSubProjectQualityService;
|
|
@Autowired
|
|
BsSgcJsjdBuiContInfoService bsSgcJsjdBuiContInfoService;
|
|
|
|
/**
|
|
* 农民工工资保证金预警
|
|
* @param
|
|
* @param
|
|
*/
|
|
public void salaryEnsureWarn(BsSgcJsjdBuiSalaryEnsure salaryEnsure){
|
|
WarnType warnType = WarnType.MARGIN_PAYMENT_TIME;
|
|
String proCode = salaryEnsure.getProCode();
|
|
String proNo = salaryEnsure.getProNo();
|
|
BsSgcJsjdBuiConstrMeas one = bsSgcJsjdBuiConstrMeasService.getOne(Wrappers.lambdaQuery(BsSgcJsjdBuiConstrMeas.class)
|
|
.eq(BsSgcJsjdBuiConstrMeas::getProCode, proCode)
|
|
.eq(BsSgcJsjdBuiConstrMeas::getProNo, proNo),false);
|
|
Date reportTime1 = one.getReportTime1();
|
|
Date createTime = salaryEnsure.getCreateTime();
|
|
try {
|
|
Date workDayStart = HolidayUtil.getWorkDayStart("", createTime, 20);
|
|
if(workDayStart.compareTo(reportTime1)>0){
|
|
warnOperate.sendWarn(proNo,proCode,warnType,warnType.getWarnResult());
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 农名工工资保证金专用账户预警
|
|
* @param
|
|
* @param
|
|
*/
|
|
public void GzbzjWarn(BsSgcJsjdBuiGzbzj bsSgcJsjdBuiGzbzj){
|
|
WarnType warnType = WarnType.MARGIN_PAYMENT_TIME;
|
|
String proNo = bsSgcJsjdBuiGzbzj.getProNo();
|
|
String projectCode = bsSgcJsjdBuiGzbzj.getProjectCode();
|
|
String balance = bsSgcJsjdBuiGzbzj.getBalance();
|
|
String monthAmountTransferred = bsSgcJsjdBuiGzbzj.getMonthAmountTransferred();
|
|
BigDecimal subtract = new BigDecimal(balance).subtract(new BigDecimal(monthAmountTransferred));
|
|
if(subtract.compareTo(new BigDecimal(0))<=0){ //余额小于0
|
|
warnOperate.sendWarn(proNo,projectCode,warnType, warnType.replaceString(warnType.getWarnResult(),subtract.toString()));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 标段变更预警
|
|
*/
|
|
public void ChangeWarn(BsSgcJsjdBuiChange bsSgcJsjdBuiChange){
|
|
WarnType warnType = WarnType.SECTION_CHANGES;
|
|
String proCode = bsSgcJsjdBuiChange.getProCode();
|
|
String proNo = bsSgcJsjdBuiChange.getProNo();
|
|
QueryWrapper<BsSgcJsjdBuiChange> query = Wrappers.query();
|
|
query.lambda().eq(BsSgcJsjdBuiChange::getProCode,proCode)
|
|
.eq(BsSgcJsjdBuiChange::getProNo,proNo);
|
|
int count = bsSgcJsjdBuiChangeService.count(query);
|
|
if(count>20){
|
|
warnOperate.sendWarn(proNo,proCode,warnType, warnType.replaceString(warnType.getWarnResult(),String.valueOf(count)));
|
|
return;
|
|
}
|
|
query.lambda().eq(BsSgcJsjdBuiChange::getChangeType,"1");
|
|
int count1 = bsSgcJsjdBuiChangeService.count(query);
|
|
if(count1>10){
|
|
warnOperate.sendWarn(proNo,proCode,warnType, warnType.replaceString(warnType.getOtherResult(),String.valueOf(count)));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 检测结果合格率预警
|
|
*/
|
|
public void detectionWarn(BsSgcJsjdBuiSubProjectQuality bsSgcJsjdBuiSubProjectQuality){
|
|
WarnType warnType = WarnType.DETECTION_QUALIFICATION_RATE;
|
|
String cellProjectRate = bsSgcJsjdBuiSubProjectQuality.getCellProjectRate();
|
|
String proNo = bsSgcJsjdBuiSubProjectQuality.getProNo();
|
|
String proCode = bsSgcJsjdBuiSubProjectQuality.getProCode();
|
|
if(StringUtils.isNotEmpty(cellProjectRate)){
|
|
Double aDouble = Double.valueOf(cellProjectRate);
|
|
if(aDouble<90){
|
|
warnOperate.sendWarn(proNo,proCode,warnType, warnType.replaceString(warnType.getWarnResult(),cellProjectRate));
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 合同超期预警
|
|
*/
|
|
public void exceedingWarn(BsSgcJsjdBuiContInfo bsSgcJsjdBuiContInfo){
|
|
String proCode = bsSgcJsjdBuiContInfo.getProCode();
|
|
String proNo = bsSgcJsjdBuiContInfo.getProNo();
|
|
WarnType exceedingContractPeriod = WarnType.EXCEEDING_CONTRACT_PERIOD;
|
|
String contractDuration = bsSgcJsjdBuiContInfo.getContractDuration();
|
|
Integer integer = Integer.valueOf(contractDuration); //几月
|
|
|
|
Date commencementTime = bsSgcJsjdBuiContInfo.getCommencementTime();
|
|
Calendar instance = Calendar.getInstance();
|
|
instance.setTime(commencementTime);
|
|
instance.add(Calendar.MONTH,integer);
|
|
long timeInMillis = instance.getTimeInMillis();
|
|
WarnRo warnRo = new WarnRo(exceedingContractPeriod,proNo,proCode);
|
|
redisTemplate.opsForZSet().add(redisKey,warnRo,timeInMillis);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|