请假数据同步添加字段,更新同步流程
This commit is contained in:
parent
6ccabe57b4
commit
b37c6af313
|
|
@ -9,6 +9,7 @@ import com.bonus.system.att.entity.OrgChangeBean;
|
|||
import com.bonus.system.basic.domain.SysOrg;
|
||||
import com.bonus.system.evection.entity.EvectionBean;
|
||||
import com.bonus.system.holiday.entity.HolidayBean;
|
||||
import com.bonus.system.holiday.entity.WorkReportBean;
|
||||
import com.bonus.system.index.entity.MapBean;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
|
@ -45,12 +46,16 @@ public interface WechatPushDao {
|
|||
|
||||
List<EvectionBean> getWebLeaveList();
|
||||
|
||||
void insertWechatLeave(EvectionBean bean);
|
||||
|
||||
|
||||
SysOrg getOrgInfoByUserName(String userName);
|
||||
|
||||
void pushAttDataToQsy(@Param("list")List<AttSourceDataBean> attSourceList);
|
||||
|
||||
MapBean getProOrgToQsy(AttSourceDataBean c);
|
||||
/**
|
||||
* 小程序修改请节请假数据
|
||||
* @return
|
||||
*/
|
||||
void updateWechatLeave(EvectionBean bean);
|
||||
|
||||
List<WorkReportBean> getMonthCheckList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.system.att.service;
|
|||
|
||||
import com.bonus.system.att.entity.AttGroupBean;
|
||||
import com.bonus.system.att.entity.AttMonthReportBean;
|
||||
import com.bonus.system.att.entity.AttSourceDataBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -116,4 +117,12 @@ public interface AttCalService {
|
|||
* @return
|
||||
*/
|
||||
List<AttMonthReportBean> getOrgDataByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 新增考勤到数据库(考勤来源表)
|
||||
* 处理过后的数据新增到考勤来源表
|
||||
*
|
||||
* @param attSourceList 考勤数据
|
||||
*/
|
||||
void insertAttSourceData(List<AttSourceDataBean> attSourceList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class AttTasks {
|
|||
* 历史考勤数据
|
||||
*/
|
||||
// @Scheduled(initialDelay = 6000,fixedDelay = 60000 * 30)
|
||||
@Scheduled(cron = "0 50 19 * * ?")
|
||||
// @Scheduled(cron = "0 50 19 * * ?")
|
||||
@Async
|
||||
public void getHisAttTasks() {
|
||||
log.info("--------考勤定时器开启------");
|
||||
|
|
@ -94,7 +94,7 @@ public class AttTasks {
|
|||
/**
|
||||
* 防止黔送离线数据每月前三天晚上将数据重新执行
|
||||
*/
|
||||
@Scheduled(cron = "0 30 22 1-3 * *")
|
||||
// @Scheduled(cron = "0 30 22 1-3 * *")
|
||||
@Async
|
||||
public void getHisMonthAttTask() {
|
||||
// 获取当前日期
|
||||
|
|
@ -115,7 +115,7 @@ public class AttTasks {
|
|||
/**
|
||||
* 凌晨0-5点得到数据,算作昨天,将昨天的重新执行
|
||||
*/
|
||||
@Scheduled(cron = "0 5 6 * * ?")
|
||||
// @Scheduled(cron = "0 5 6 * * ?")
|
||||
@Async
|
||||
public void getHisYesterdayAttTask() {
|
||||
// 获取今天的日期
|
||||
|
|
|
|||
|
|
@ -11,10 +11,13 @@ import com.bonus.system.api.domain.SysUser;
|
|||
import com.bonus.system.att.dao.WechatPushDao;
|
||||
import com.bonus.system.att.entity.AttFaceBean;
|
||||
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.IpAndPathConfig;
|
||||
import com.bonus.system.basic.domain.SysOrg;
|
||||
import com.bonus.system.evection.entity.EvectionBean;
|
||||
import com.bonus.system.holiday.entity.WorkReportBean;
|
||||
import com.bonus.system.index.entity.MapBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
|
|
@ -52,12 +55,11 @@ public class WechatTasks {
|
|||
* 人员基础数据同步定时器
|
||||
*/
|
||||
// @Scheduled(cron = "0 0/10 * * * ?")
|
||||
@Scheduled(initialDelay = 60000,fixedDelay = 60000 * 30)
|
||||
// @Scheduled(initialDelay = 60000, fixedDelay = 60000 * 30)
|
||||
@Async
|
||||
public void pushPersonTask() {
|
||||
log.info("--------人员基础数据同步定时器开启------");
|
||||
index=4;
|
||||
|
||||
index = 4;
|
||||
//人脸更新
|
||||
List<AttFaceBean> faceList = dao.getWebFaceList();
|
||||
String jsonStr2 = "{}";
|
||||
|
|
@ -65,7 +67,6 @@ public class WechatTasks {
|
|||
String string2 = httpPost(method2, jsonStr2);
|
||||
List<AttFaceBean> wechatFaceList = FastJsonHelper.jsonArrStrToBeanList(string2, AttFaceBean.class);
|
||||
syncFaceToDatabase(faceList, wechatFaceList);
|
||||
|
||||
//考勤库人员
|
||||
List<SysUser> list = dao.getPersonList();
|
||||
//考勤小程序库人员
|
||||
|
|
@ -82,31 +83,44 @@ public class WechatTasks {
|
|||
/**
|
||||
* 休假出差数据同步定时器
|
||||
*/
|
||||
@Scheduled(initialDelay = 60000 * 2,fixedDelay = 60000 * 30)
|
||||
// @Scheduled(initialDelay = 60000 * 2, fixedDelay = 60000 * 30)
|
||||
@Async
|
||||
public void leaveTask() {
|
||||
log.info("--------休假出差数据定时器开启------");
|
||||
index=4;
|
||||
//小程序库人员
|
||||
String jsonStr = "{}";
|
||||
String method = "getWechatLeaveList";
|
||||
index = 4;
|
||||
//将月度核定表进行单向同步
|
||||
List<WorkReportBean> listCheck = dao.getMonthCheckList();
|
||||
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);
|
||||
List<EvectionBean> list = FastJsonHelper.jsonArrStrToBeanList(string, EvectionBean.class);
|
||||
//将所有人数据更新组织机构
|
||||
for (EvectionBean bean : list) {
|
||||
if(bean.getId() != 0L){
|
||||
continue;
|
||||
}
|
||||
// 如果Map中没有该userId的组织机构信息,则从数据库查询
|
||||
SysOrg orgInfo = dao.getOrgInfoByUserId(bean.getUserId());
|
||||
if (orgInfo != null) {
|
||||
bean.setOrgId(orgInfo.getId());
|
||||
bean.setOrgName(orgInfo.getOrgName());
|
||||
}
|
||||
dao.insertWebLeave(bean);
|
||||
String jsonStr2 = FastJsonHelper.beanToJsonStr(bean);
|
||||
String method2 = "updateWechatLeave";
|
||||
String string2 = httpPost(method2, jsonStr2);
|
||||
if(bean.getId() != 0L){
|
||||
//修改的数据
|
||||
dao.updateWechatLeave(bean);
|
||||
}else{
|
||||
//首次推送的数据
|
||||
dao.insertWebLeave(bean);
|
||||
//根据uuid将小程序id换成考勤端id
|
||||
String method2 = "updateWechatLeave";
|
||||
String string2 = httpPost(method2, jsonStr2);
|
||||
}
|
||||
//将所有数据同步限制解除
|
||||
String method2 = "updateWechatIsSync";
|
||||
String string3 = httpPost(method2, jsonStr2);
|
||||
}
|
||||
//在将所有数据同步过去
|
||||
List<EvectionBean> webList = dao.getWebLeaveList();
|
||||
|
|
@ -114,7 +128,7 @@ public class WechatTasks {
|
|||
String method2 = "getWechatLeaveList";
|
||||
String string2 = httpPost(method2, jsonStr2);
|
||||
List<EvectionBean> webchatList = FastJsonHelper.jsonArrStrToBeanList(string2, EvectionBean.class);
|
||||
syncLeaveToDatabase(webList,webchatList);
|
||||
syncLeaveToDatabase(webList, webchatList);
|
||||
log.info("--------休假出差数据定时器完毕------");
|
||||
}
|
||||
|
||||
|
|
@ -127,11 +141,11 @@ public class WechatTasks {
|
|||
Long id = bean.getId();
|
||||
if (!wechatUserMap.containsKey(id)) {
|
||||
// 如果 userId 不存在于 wechatList,则插入到数据库 a
|
||||
bean.setUuid(UUID.randomUUID().toString());
|
||||
String jsonStr2 = FastJsonHelper.beanToJsonStr(bean);
|
||||
String method2 = "insertWechatLeave";
|
||||
String string2 = httpPost(method2, jsonStr2);
|
||||
log.info("插入请假数据到小程序:"+string2);
|
||||
bean.setUuid(UUID.randomUUID().toString());
|
||||
String jsonStr2 = FastJsonHelper.beanToJsonStr(bean);
|
||||
String method2 = "insertWechatLeave";
|
||||
String string2 = httpPost(method2, jsonStr2);
|
||||
log.info("插入请假数据到小程序:" + string2);
|
||||
} else {
|
||||
// 如果存在,则判断时间是否后于小程序时间
|
||||
EvectionBean wechatUser = wechatUserMap.get(id);
|
||||
|
|
@ -146,18 +160,17 @@ public class WechatTasks {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Resource
|
||||
private AttTasks attTasks;
|
||||
@Resource(name = "AttCalService")
|
||||
private AttCalService attCalService;
|
||||
|
||||
/**
|
||||
* 考勤数据同步定时器
|
||||
*/
|
||||
@Scheduled(initialDelay = 6000 * 3,fixedDelay = 60000 * 30)
|
||||
// @Scheduled(initialDelay = 6000 * 3, fixedDelay = 60000 * 30)
|
||||
@Async
|
||||
public void wechatAttTask() {
|
||||
log.info("--------考勤数据定时器开启------");
|
||||
index=4;
|
||||
index = 4;
|
||||
// //小程序库人员考勤
|
||||
String jsonStr = "{}";
|
||||
String method = "getWechatAttList";
|
||||
|
|
@ -174,11 +187,11 @@ public class WechatTasks {
|
|||
double distanceMeters = 0;
|
||||
try {
|
||||
distanceMeters = calculateDistance(bean.getAttLat(), bean.getAttLon(), orgInfo.getLat().doubleValue(), orgInfo.getLon().doubleValue(), DistanceCalculator.Unit.METERS);
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
distanceMeters = 1000000;
|
||||
}
|
||||
if (distanceMeters > orgInfo.getAttRange()) {
|
||||
if (distanceMeters > orgInfo.getAttRange()) {
|
||||
//外勤
|
||||
bean.setIsOutsideAtt("1");
|
||||
} else {
|
||||
|
|
@ -191,34 +204,33 @@ 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 method2 = "updateWechatAttList";
|
||||
String string2 = httpPost(method2, jsonStr2);
|
||||
//将数据同步到黔送云库
|
||||
//1.先从黔送云库获取到在场人员的组织工程
|
||||
attSourceList.forEach(c -> {
|
||||
if(c.getIdNumber() != null){
|
||||
MapBean mapBean= dao.getProOrgToQsy(c);
|
||||
if(mapBean != null){
|
||||
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 -> {
|
||||
if (c.getIdNumber() != null) {
|
||||
MapBean mapBean = dao.getProOrgToQsy(c);
|
||||
if (mapBean != null) {
|
||||
c.setProId(mapBean.getProId());
|
||||
c.setOrgId(String.valueOf(mapBean.getOrgId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
//2.推送到人员考勤表
|
||||
if(!attSourceList.isEmpty()){
|
||||
if (!attSourceList.isEmpty()) {
|
||||
dao.pushAttDataToQsy(attSourceList);
|
||||
}
|
||||
log.info("--------考勤数据定时器完毕------");
|
||||
|
|
@ -309,21 +321,21 @@ public class WechatTasks {
|
|||
// .header("Content-Type", "application/json")
|
||||
// .body(jsonStr)
|
||||
// .execute();
|
||||
if(index > 0){
|
||||
if (index > 0) {
|
||||
HttpResponse response = HttpRequest.post(IpAndPathConfig.getWechatUrl() + "/wechatData/" + method)
|
||||
.header("Content-Type", "application/json")
|
||||
.header("token",token) // 添加Token到请求头
|
||||
.header("token", token) // 添加Token到请求头
|
||||
.body(jsonStr)
|
||||
.execute();
|
||||
int statusCode = response.getStatus();
|
||||
System.out.println(response.body());
|
||||
JSONObject jsonObject = FastJsonHelper.jsonStrToJsonObj(response.body());
|
||||
if("401".equals(jsonObject.getString("code"))){
|
||||
if ("401".equals(jsonObject.getString("code"))) {
|
||||
wechatLogin();
|
||||
index--;
|
||||
return httpPost(method, jsonStr);
|
||||
}
|
||||
if("200".equals(jsonObject.getString("code") ) ){
|
||||
if ("200".equals(jsonObject.getString("code"))) {
|
||||
index = 4;
|
||||
}
|
||||
return jsonObject.getString("obj");
|
||||
|
|
@ -338,31 +350,33 @@ public class WechatTasks {
|
|||
|
||||
/**
|
||||
* 授予人脸重新录入权限时调用
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
public int updateWechatIsFace(SysUser user){
|
||||
public int updateWechatIsFace(SysUser user) {
|
||||
// dao.updateWechatIsFace(user);
|
||||
String jsonStr = FastJsonHelper.beanToJsonStr(user);
|
||||
String method = "updateWechatIsFace";
|
||||
String string = httpPost(method, jsonStr);
|
||||
if("success".equals(string)){
|
||||
if ("success".equals(string)) {
|
||||
return 1;
|
||||
}else{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核人脸时调用
|
||||
*
|
||||
* @String isCheck
|
||||
*/
|
||||
public int checkWechatIsFace(SysUser user){
|
||||
public int checkWechatIsFace(SysUser user) {
|
||||
String jsonStr = FastJsonHelper.beanToJsonStr(user);
|
||||
String method = "checkWechatIsFace";
|
||||
String string = httpPost(method, jsonStr);
|
||||
if("success".equals(string)){
|
||||
if ("success".equals(string)) {
|
||||
return 1;
|
||||
}else{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -374,7 +388,7 @@ public class WechatTasks {
|
|||
RequestBody body = null;
|
||||
try {
|
||||
// body = RequestBody.create(mediaType, "username=15240004260&password=GZkq@123456!");
|
||||
body = RequestBody.create(mediaType, "username="+ AESCBCUtil.encrypt("15240004260wechat")+"&password="+AESCBCUtil.encrypt("GZkq@123456!"));
|
||||
body = RequestBody.create(mediaType, "username=" + AESCBCUtil.encrypt("15240004260wechat") + "&password=" + AESCBCUtil.encrypt("GZkq@123456!"));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
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)
|
||||
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},
|
||||
#{leaveType},#{leaveReason},
|
||||
#{leaveStartDate},
|
||||
|
|
@ -33,34 +33,7 @@
|
|||
</if>
|
||||
#{leaveDuration},#{examineUserId},#{examineOpinion},#{examineTime},
|
||||
#{examineStatus},#{hostUserId},#{hostUserName},#{isAgree},#{location},#{source},
|
||||
#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{remark})
|
||||
</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})
|
||||
#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{remark},#{isPlateau},#{plateauSubsidy})
|
||||
</insert>
|
||||
|
||||
<insert id="pushAttDataToQsy">
|
||||
|
|
@ -115,6 +88,32 @@
|
|||
collection_time = #{collectionTime},examine_time = #{examineTime}
|
||||
where user_id = #{userId}
|
||||
</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 distinct
|
||||
|
|
@ -198,6 +197,14 @@
|
|||
ID_NUMBER = #{idNumber}
|
||||
limit 1
|
||||
</select>
|
||||
<select id="getMonthCheckList" resultType="com.bonus.system.holiday.entity.WorkReportBean">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
leave_check
|
||||
WHERE
|
||||
is_active = '1'
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue