黑名单定时任务
This commit is contained in:
parent
2e599c75c6
commit
ac64c21e39
|
|
@ -0,0 +1,29 @@
|
|||
package com.bonus.ahsbs.base.dao;
|
||||
|
||||
|
||||
import com.bonus.ahsbs.base.entity.BlackListBean;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lsun
|
||||
*/
|
||||
@Repository(value = "BlackListDao")
|
||||
public interface BlackListDao {
|
||||
|
||||
/**
|
||||
* 获取黑名单列表-当天
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
List<BlackListBean> getList(String endTime);
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param idNumber,endTime
|
||||
*/
|
||||
void updateStatus(@Param("idNumber") String idNumber, @Param("endTime") String endTime);
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.bonus.ahsbs.base.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BlackListBean {
|
||||
public String name; //姓名
|
||||
public String idNumber; //身份证
|
||||
public String age;
|
||||
public String address;
|
||||
public String event;//事件
|
||||
public String remark;//备注(岗位)
|
||||
public String personType;//人员类型
|
||||
private String status; //是否生效
|
||||
private String dept;//所属分公司或者分包商
|
||||
private String post;
|
||||
private String proId;
|
||||
private String orgId;
|
||||
private String proName;
|
||||
private String orgName;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private Integer companyId;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BlackListBean{" +
|
||||
"name='" + name + '\'' +
|
||||
", idNumber='" + idNumber + '\'' +
|
||||
", age='" + age + '\'' +
|
||||
", address='" + address + '\'' +
|
||||
", event='" + event + '\'' +
|
||||
", remark='" + remark + '\'' +
|
||||
", personType='" + personType + '\'' +
|
||||
", status='" + status + '\'' +
|
||||
", dept='" + dept + '\'' +
|
||||
", post='" + post + '\'' +
|
||||
", proId='" + proId + '\'' +
|
||||
", orgId='" + orgId + '\'' +
|
||||
", proName='" + proName + '\'' +
|
||||
", orgName='" + orgName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.bonus.ahsbs.base.task;
|
||||
|
||||
import com.bonus.ahsbs.base.dao.BlackListDao;
|
||||
import com.bonus.ahsbs.base.entity.BlackListBean;
|
||||
import com.bonus.ahsbs.core.util.DateTimeHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* packageName com.bonus.ahsbs.base.task
|
||||
*
|
||||
* @author lsun
|
||||
* @version 1.0.0
|
||||
* @className BlackTask (此处以class为例)
|
||||
* @date 2025/8/5
|
||||
* @description 实名制黑名单定时任务
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@EnableScheduling
|
||||
@EnableAsync
|
||||
public class BlackTask {
|
||||
@Resource(name = "BlackListDao")
|
||||
private BlackListDao dao;
|
||||
|
||||
@Scheduled(cron = "0 0 23 * * ?")
|
||||
// @Scheduled(cron = "0 */3 * * * ?")
|
||||
public void attDataByWorkerADay() {
|
||||
log.info("黑名单定时任务开始执行");
|
||||
try {
|
||||
String endTime = DateTimeHelper.getNowDate();
|
||||
List<BlackListBean> list = dao.getList(endTime);
|
||||
if (list != null && list.size() > 0) {
|
||||
//获取list中所以的idNumber,进行循环修改
|
||||
for (BlackListBean bean : list) {
|
||||
System.err.println("黑名单:"+bean.getIdNumber());
|
||||
dao.updateStatus(bean.getIdNumber(), endTime);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
log.info("黑名单定时任务结束执行");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.ahsbs.base.dao.BlackListDao">
|
||||
<update id="updateStatus">
|
||||
UPDATE `bm_blacklist_worker`
|
||||
SET status = '2'
|
||||
WHERE id_number = #{idNumber}
|
||||
AND end_time = #{endTime}
|
||||
</update>
|
||||
|
||||
<select id="getList" resultType="com.bonus.ahsbs.base.entity.BlackListBean">
|
||||
SELECT id_number as idNumber FROM `bm_blacklist_worker`
|
||||
WHERE end_time = #{endTime}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue