3 changed files with 69 additions and 4 deletions
@ -0,0 +1,65 @@ |
|||||
|
package com.zdxt.code.task; |
||||
|
|
||||
|
|
||||
|
import cn.hutool.core.util.IdUtil; |
||||
|
import com.zdxt.auth.dto.UserBean; |
||||
|
import com.zdxt.auth.feign.UserApi; |
||||
|
import com.zdxt.code.domain.EnforceRegCount; |
||||
|
import com.zdxt.code.domain.EnforcementRegistration; |
||||
|
import com.zdxt.code.domain.LawEnforcementWarningList; |
||||
|
import com.zdxt.code.service.IEnforcementRegistrationService; |
||||
|
import com.zdxt.code.service.ILawEnforcementWarningListService; |
||||
|
import com.zdxt.common.util.DateUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 预警任务 |
||||
|
*/ |
||||
|
@Component("earlyWarningTask") |
||||
|
public class EarlyWarningTask { |
||||
|
|
||||
|
@Autowired private IEnforcementRegistrationService iEnforcementRegistrationService; |
||||
|
@Autowired private ILawEnforcementWarningListService lawEnforcementWarningListService; |
||||
|
|
||||
|
@Autowired private UserApi userApi; |
||||
|
|
||||
|
|
||||
|
public void run(){ |
||||
|
this.earlyWarning(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 预警任务 |
||||
|
*/ |
||||
|
public void earlyWarning(){ |
||||
|
try{ |
||||
|
List<EnforceRegCount> list = iEnforcementRegistrationService.queryEarlyWarning(null); |
||||
|
for (EnforceRegCount warn : list) { |
||||
|
LawEnforcementWarningList params = new LawEnforcementWarningList(); |
||||
|
params.setEnterpriseNumber(warn.getEnterpriseNumber()); |
||||
|
params.setWarningLevel(Integer.parseInt(warn.getLevel())); |
||||
|
List<LawEnforcementWarningList> res = lawEnforcementWarningListService.selectLawEnforcementWarningListList(params); |
||||
|
if (null == res || res.size() < 1) { |
||||
|
LawEnforcementWarningList warning = new LawEnforcementWarningList(); |
||||
|
warning.setWarningTime(DateUtils.getNowDate()); |
||||
|
warning.setWarningCause("本月对该企业已检查" + warn.getNum() + "次"); |
||||
|
warning.setWarningLevel(Integer.parseInt(warn.getLevel())); |
||||
|
warning.setEnterpriseName(warn.getLawEnforcement()); |
||||
|
warning.setEnterpriseNumber(warn.getEnterpriseNumber()); |
||||
|
warning.setEnforcementNumber(warn.getNum()); |
||||
|
|
||||
|
warning.setId(IdUtil.simpleUUID()); |
||||
|
warning.setCreateTime(DateUtils.getNowDate()); |
||||
|
lawEnforcementWarningListService.insertLawEnforcementWarningList(warning); |
||||
|
} |
||||
|
} |
||||
|
}catch (Exception e){ |
||||
|
System.out.println("预警任务异常!"); |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue