Browse Source

执法预警,预警原因文字描述修改,本月对该企业已检查xx次,定时任务也要开启,测试

v2
蟑螂恶霸 2 years ago
parent
commit
ea73706991
  1. 6
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementRegistrationServiceImpl.java
  2. 65
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/task/EarlyWarningTask.java
  3. 2
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml

6
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementRegistrationServiceImpl.java

@ -208,9 +208,9 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat
results.add(reg);
}
//添加预警信息
for (LawEnforcementWarningList lawEnforcementWarningList : lawEnforcementWarningLists) {
lawEnforcementWarningListService.insertLawEnforcementWarningList(lawEnforcementWarningList);
}
// for (LawEnforcementWarningList lawEnforcementWarningList : lawEnforcementWarningLists) {
// lawEnforcementWarningListService.insertLawEnforcementWarningList(lawEnforcementWarningList);
// }
return results;
}

65
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/task/EarlyWarningTask.java

@ -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();
}
}
}

2
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml

@ -225,7 +225,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="countMentByTime" resultMap="EnforceRegCountResult"
resultType="com.zdxt.code.domain.EnforceRegCount">
SELECT law_enforcement, law_enforcement_id,enterprise_number COUNT(law_enforcement_id) AS num
SELECT law_enforcement, law_enforcement_id,enterprise_number, COUNT(law_enforcement_id) AS num
FROM enforcement_registration
WHERE create_time >= DATE_SUB(CURDATE(), INTERVAL #{timeMonth} MONTH)
<if test="searchValue != null and searchValue != ''">AND law_enforcement like concat(concat('%',#{searchValue}),'%')</if>

Loading…
Cancel
Save