请假数据同步添加字段,更新同步流程

This commit is contained in:
fl 2025-02-20 16:11:11 +08:00
parent 6ccabe57b4
commit b37c6af313
5 changed files with 123 additions and 88 deletions

View File

@ -9,6 +9,7 @@ import com.bonus.system.att.entity.OrgChangeBean;
import com.bonus.system.basic.domain.SysOrg; import com.bonus.system.basic.domain.SysOrg;
import com.bonus.system.evection.entity.EvectionBean; import com.bonus.system.evection.entity.EvectionBean;
import com.bonus.system.holiday.entity.HolidayBean; import com.bonus.system.holiday.entity.HolidayBean;
import com.bonus.system.holiday.entity.WorkReportBean;
import com.bonus.system.index.entity.MapBean; import com.bonus.system.index.entity.MapBean;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -45,12 +46,16 @@ public interface WechatPushDao {
List<EvectionBean> getWebLeaveList(); List<EvectionBean> getWebLeaveList();
void insertWechatLeave(EvectionBean bean);
SysOrg getOrgInfoByUserName(String userName); SysOrg getOrgInfoByUserName(String userName);
void pushAttDataToQsy(@Param("list")List<AttSourceDataBean> attSourceList); void pushAttDataToQsy(@Param("list")List<AttSourceDataBean> attSourceList);
MapBean getProOrgToQsy(AttSourceDataBean c); MapBean getProOrgToQsy(AttSourceDataBean c);
/**
* 小程序修改请节请假数据
* @return
*/
void updateWechatLeave(EvectionBean bean);
List<WorkReportBean> getMonthCheckList();
} }

View File

@ -2,6 +2,7 @@ package com.bonus.system.att.service;
import com.bonus.system.att.entity.AttGroupBean; import com.bonus.system.att.entity.AttGroupBean;
import com.bonus.system.att.entity.AttMonthReportBean; import com.bonus.system.att.entity.AttMonthReportBean;
import com.bonus.system.att.entity.AttSourceDataBean;
import java.util.List; import java.util.List;
@ -116,4 +117,12 @@ public interface AttCalService {
* @return * @return
*/ */
List<AttMonthReportBean> getOrgDataByUserId(String userId); List<AttMonthReportBean> getOrgDataByUserId(String userId);
/**
* 新增考勤到数据库(考勤来源表)
* 处理过后的数据新增到考勤来源表
*
* @param attSourceList 考勤数据
*/
void insertAttSourceData(List<AttSourceDataBean> attSourceList);
} }

View File

@ -74,7 +74,7 @@ public class AttTasks {
* 历史考勤数据 * 历史考勤数据
*/ */
// @Scheduled(initialDelay = 6000,fixedDelay = 60000 * 30) // @Scheduled(initialDelay = 6000,fixedDelay = 60000 * 30)
@Scheduled(cron = "0 50 19 * * ?") // @Scheduled(cron = "0 50 19 * * ?")
@Async @Async
public void getHisAttTasks() { public void getHisAttTasks() {
log.info("--------考勤定时器开启------"); log.info("--------考勤定时器开启------");
@ -94,7 +94,7 @@ public class AttTasks {
/** /**
* 防止黔送离线数据每月前三天晚上将数据重新执行 * 防止黔送离线数据每月前三天晚上将数据重新执行
*/ */
@Scheduled(cron = "0 30 22 1-3 * *") // @Scheduled(cron = "0 30 22 1-3 * *")
@Async @Async
public void getHisMonthAttTask() { public void getHisMonthAttTask() {
// 获取当前日期 // 获取当前日期
@ -115,7 +115,7 @@ public class AttTasks {
/** /**
* 凌晨0-5点得到数据算作昨天将昨天的重新执行 * 凌晨0-5点得到数据算作昨天将昨天的重新执行
*/ */
@Scheduled(cron = "0 5 6 * * ?") // @Scheduled(cron = "0 5 6 * * ?")
@Async @Async
public void getHisYesterdayAttTask() { public void getHisYesterdayAttTask() {
// 获取今天的日期 // 获取今天的日期

View File

@ -11,10 +11,13 @@ import com.bonus.system.api.domain.SysUser;
import com.bonus.system.att.dao.WechatPushDao; import com.bonus.system.att.dao.WechatPushDao;
import com.bonus.system.att.entity.AttFaceBean; import com.bonus.system.att.entity.AttFaceBean;
import com.bonus.system.att.entity.AttSourceDataBean; import com.bonus.system.att.entity.AttSourceDataBean;
import com.bonus.system.att.service.AttCalService;
import com.bonus.system.att.utils.AttTimeUtil;
import com.bonus.system.att.utils.DistanceCalculator; import com.bonus.system.att.utils.DistanceCalculator;
import com.bonus.system.att.utils.IpAndPathConfig; import com.bonus.system.att.utils.IpAndPathConfig;
import com.bonus.system.basic.domain.SysOrg; import com.bonus.system.basic.domain.SysOrg;
import com.bonus.system.evection.entity.EvectionBean; import com.bonus.system.evection.entity.EvectionBean;
import com.bonus.system.holiday.entity.WorkReportBean;
import com.bonus.system.index.entity.MapBean; import com.bonus.system.index.entity.MapBean;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import okhttp3.*; import okhttp3.*;
@ -52,12 +55,11 @@ public class WechatTasks {
* 人员基础数据同步定时器 * 人员基础数据同步定时器
*/ */
// @Scheduled(cron = "0 0/10 * * * ?") // @Scheduled(cron = "0 0/10 * * * ?")
@Scheduled(initialDelay = 60000,fixedDelay = 60000 * 30) // @Scheduled(initialDelay = 60000, fixedDelay = 60000 * 30)
@Async @Async
public void pushPersonTask() { public void pushPersonTask() {
log.info("--------人员基础数据同步定时器开启------"); log.info("--------人员基础数据同步定时器开启------");
index = 4; index = 4;
//人脸更新 //人脸更新
List<AttFaceBean> faceList = dao.getWebFaceList(); List<AttFaceBean> faceList = dao.getWebFaceList();
String jsonStr2 = "{}"; String jsonStr2 = "{}";
@ -65,7 +67,6 @@ public class WechatTasks {
String string2 = httpPost(method2, jsonStr2); String string2 = httpPost(method2, jsonStr2);
List<AttFaceBean> wechatFaceList = FastJsonHelper.jsonArrStrToBeanList(string2, AttFaceBean.class); List<AttFaceBean> wechatFaceList = FastJsonHelper.jsonArrStrToBeanList(string2, AttFaceBean.class);
syncFaceToDatabase(faceList, wechatFaceList); syncFaceToDatabase(faceList, wechatFaceList);
//考勤库人员 //考勤库人员
List<SysUser> list = dao.getPersonList(); List<SysUser> list = dao.getPersonList();
//考勤小程序库人员 //考勤小程序库人员
@ -82,32 +83,45 @@ public class WechatTasks {
/** /**
* 休假出差数据同步定时器 * 休假出差数据同步定时器
*/ */
@Scheduled(initialDelay = 60000 * 2,fixedDelay = 60000 * 30) // @Scheduled(initialDelay = 60000 * 2, fixedDelay = 60000 * 30)
@Async @Async
public void leaveTask() { public void leaveTask() {
log.info("--------休假出差数据定时器开启------"); log.info("--------休假出差数据定时器开启------");
index = 4; index = 4;
//小程序库人员 //将月度核定表进行单向同步
String jsonStr = "{}"; List<WorkReportBean> listCheck = dao.getMonthCheckList();
String method = "getWechatLeaveList"; String jsonStrMonth = FastJsonHelper.beanListToJsonArrStr(listCheck);
//将所有数据同步限制解除
String methodMonth = "replaceMonthCheckList";
String stringMonth = httpPost(methodMonth, jsonStrMonth);
//获取小程序id为0或is_update为1数据同时将获取数据同步状态改为1
String jsonStr = "{\"id\":\"0\",\"isUpdate\":\"1\"}";
String method = "getWechatLeaveListById";
String string = httpPost(method, jsonStr); String string = httpPost(method, jsonStr);
List<EvectionBean> list = FastJsonHelper.jsonArrStrToBeanList(string, EvectionBean.class); List<EvectionBean> list = FastJsonHelper.jsonArrStrToBeanList(string, EvectionBean.class);
//将所有人数据更新组织机构 //将所有人数据更新组织机构
for (EvectionBean bean : list) { for (EvectionBean bean : list) {
if(bean.getId() != 0L){
continue;
}
// 如果Map中没有该userId的组织机构信息则从数据库查询 // 如果Map中没有该userId的组织机构信息则从数据库查询
SysOrg orgInfo = dao.getOrgInfoByUserId(bean.getUserId()); SysOrg orgInfo = dao.getOrgInfoByUserId(bean.getUserId());
if (orgInfo != null) { if (orgInfo != null) {
bean.setOrgId(orgInfo.getId()); bean.setOrgId(orgInfo.getId());
bean.setOrgName(orgInfo.getOrgName()); bean.setOrgName(orgInfo.getOrgName());
} }
dao.insertWebLeave(bean);
String jsonStr2 = FastJsonHelper.beanToJsonStr(bean); String jsonStr2 = FastJsonHelper.beanToJsonStr(bean);
if(bean.getId() != 0L){
//修改的数据
dao.updateWechatLeave(bean);
}else{
//首次推送的数据
dao.insertWebLeave(bean);
//根据uuid将小程序id换成考勤端id
String method2 = "updateWechatLeave"; String method2 = "updateWechatLeave";
String string2 = httpPost(method2, jsonStr2); String string2 = httpPost(method2, jsonStr2);
} }
//将所有数据同步限制解除
String method2 = "updateWechatIsSync";
String string3 = httpPost(method2, jsonStr2);
}
//在将所有数据同步过去 //在将所有数据同步过去
List<EvectionBean> webList = dao.getWebLeaveList(); List<EvectionBean> webList = dao.getWebLeaveList();
String jsonStr2 = "{}"; String jsonStr2 = "{}";
@ -146,14 +160,13 @@ public class WechatTasks {
} }
} }
@Resource(name = "AttCalService")
@Resource private AttCalService attCalService;
private AttTasks attTasks;
/** /**
* 考勤数据同步定时器 * 考勤数据同步定时器
*/ */
@Scheduled(initialDelay = 6000 * 3,fixedDelay = 60000 * 30) // @Scheduled(initialDelay = 6000 * 3, fixedDelay = 60000 * 30)
@Async @Async
public void wechatAttTask() { public void wechatAttTask() {
log.info("--------考勤数据定时器开启------"); log.info("--------考勤数据定时器开启------");
@ -191,23 +204,22 @@ public class WechatTasks {
} }
}); });
//新增数据 //新增数据
attSourceList.forEach(c -> {
if ("0".equals(c.getAttType())) {
int i = attTasks.checkTime(c.getAttCurrentTime());
c.setAttType(String.valueOf(i));
}
//将00:00:00 04:59:59 时间变成att_current_day上一天的
attTasks.changeAttCurrentDay(c);
});
//新增考勤到考勤来源表(数据过多时分批次插入) //新增考勤到考勤来源表(数据过多时分批次插入)
attTasks.insertAttSourceData(attSourceList); attCalService.insertAttSourceData(attSourceList);
//将是否外勤更新到小程序库 //将是否外勤更新到小程序库
// dao.updateWechatAttList(attSourceList);
String jsonStr2 = FastJsonHelper.beanListToJsonArrStr(attSourceList); String jsonStr2 = FastJsonHelper.beanListToJsonArrStr(attSourceList);
String method2 = "updateWechatAttList"; String method2 = "updateWechatAttList";
String string2 = httpPost(method2, jsonStr2); String string2 = httpPost(method2, jsonStr2);
//将数据同步到黔送云库 //将数据同步到黔送云库
//1.先从黔送云库获取到在场人员的组织工程 //1.先从黔送云库获取到在场人员的组织工程
attSourceList.forEach(c -> {
if ("0".equals(c.getAttType())) {
int i = AttTimeUtil.getAttTypeByTime(c.getAttCurrentTime());
c.setAttType(String.valueOf(i));
}
//将00:00:00 04:59:59 时间变成att_current_day上一天的
AttTimeUtil.changeAttCurrentDay(c);
});
attSourceList.forEach(c -> { attSourceList.forEach(c -> {
if (c.getIdNumber() != null) { if (c.getIdNumber() != null) {
MapBean mapBean = dao.getProOrgToQsy(c); MapBean mapBean = dao.getProOrgToQsy(c);
@ -338,6 +350,7 @@ public class WechatTasks {
/** /**
* 授予人脸重新录入权限时调用 * 授予人脸重新录入权限时调用
*
* @param user * @param user
*/ */
public int updateWechatIsFace(SysUser user) { public int updateWechatIsFace(SysUser user) {
@ -354,6 +367,7 @@ public class WechatTasks {
/** /**
* 审核人脸时调用 * 审核人脸时调用
*
* @String isCheck * @String isCheck
*/ */
public int checkWechatIsFace(SysUser user) { public int checkWechatIsFace(SysUser user) {

View File

@ -20,7 +20,7 @@
leave_end_interval, leave_end_interval,
</if> </if>
leave_duration,examine_user_id,examine_opinion,examine_time,examine_status,host_user_id, leave_duration,examine_user_id,examine_opinion,examine_time,examine_status,host_user_id,
host_user_name,is_agree,location,source,create_user_id,create_time,update_user_id,update_time,remark) host_user_name,is_agree,location,source,create_user_id,create_time,update_user_id,update_time,remark,is_plateau,plateau_subsidy)
values(#{leaveFormId},#{submitId},#{userId},#{userName},#{orgId},#{orgName},#{type}, values(#{leaveFormId},#{submitId},#{userId},#{userName},#{orgId},#{orgName},#{type},
#{leaveType},#{leaveReason}, #{leaveType},#{leaveReason},
#{leaveStartDate}, #{leaveStartDate},
@ -33,34 +33,7 @@
</if> </if>
#{leaveDuration},#{examineUserId},#{examineOpinion},#{examineTime}, #{leaveDuration},#{examineUserId},#{examineOpinion},#{examineTime},
#{examineStatus},#{hostUserId},#{hostUserName},#{isAgree},#{location},#{source}, #{examineStatus},#{hostUserId},#{hostUserName},#{isAgree},#{location},#{source},
#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{remark}) #{createUserId},#{createTime},#{updateUserId},#{updateTime},#{remark},#{isPlateau},#{plateauSubsidy})
</insert>
<insert id="insertWechatLeave">
insert IGNORE into leave_apply(id,leave_form_id,submit_id,user_id,user_name,org_id,org_name,type,
leave_type,leave_reason,
leave_start_date,
<if test="leaveStartInterval != null">
leave_start_interval,
</if>
leave_end_date,
<if test="leaveEndInterval != null">
leave_end_interval,
</if>
leave_duration,examine_user_id,examine_opinion,examine_time,examine_status,host_user_id,
host_user_name,is_agree,location,source,create_user_id,create_time,update_user_id,update_time,remark)
values(#{id}#{leaveFormId},#{submitId},#{userId},#{userName},#{orgId},#{orgName},#{type},
#{leaveType},#{leaveReason},
#{leaveStartDate},
<if test="leaveStartInterval != null">
#{leaveStartInterval},
</if>
#{leaveEndDate},
<if test="leaveEndInterval != null">
#{leaveEndInterval},
</if>
#{leaveDuration},#{examineUserId},#{examineOpinion},#{examineTime},
#{examineStatus},#{hostUserId},#{hostUserName},#{isAgree},#{location},#{source},
#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{remark})
</insert> </insert>
<insert id="pushAttDataToQsy"> <insert id="pushAttDataToQsy">
@ -115,6 +88,32 @@
collection_time = #{collectionTime},examine_time = #{examineTime} collection_time = #{collectionTime},examine_time = #{examineTime}
where user_id = #{userId} where user_id = #{userId}
</update> </update>
<update id="updateWechatLeave">
update leave_apply set
leave_reason = #{leaveReason},
leave_start_date = #{leaveStartDate},
leave_start_interval = #{leaveStartInterval},
leave_end_date = #{leaveEndDate},
leave_end_interval = #{leaveEndInterval},
leave_duration = #{leaveDuration},
examine_user_id = #{examineUserId},
examine_opinion = #{examineOpinion},
examine_time = #{examineTime},
examine_status = #{examineStatus},
host_user_id = #{hostUserId},
host_user_name = #{hostUserName},
is_agree = #{isAgree},
location = #{location},
source = #{source},
create_user_id = #{createUserId},
create_time = #{createTime},
update_user_id = #{updateUserId},
update_time = #{updateTime},
remark = #{remark},
is_plateau = #{isPlateau},
plateau_subsidy = #{plateauSubsidy}
where id = #{id}
</update>
<select id="getPersonList" resultType="com.bonus.system.api.domain.SysUser"> <select id="getPersonList" resultType="com.bonus.system.api.domain.SysUser">
SELECT distinct SELECT distinct
@ -198,6 +197,14 @@
ID_NUMBER = #{idNumber} ID_NUMBER = #{idNumber}
limit 1 limit 1
</select> </select>
<select id="getMonthCheckList" resultType="com.bonus.system.holiday.entity.WorkReportBean">
SELECT
*
FROM
leave_check
WHERE
is_active = '1'
</select>
</mapper> </mapper>