数据互通

This commit is contained in:
fl 2024-12-04 00:03:55 +08:00
parent b85e63b51a
commit 0ca399d0f7
12 changed files with 780 additions and 10 deletions

View File

@ -133,4 +133,9 @@ public class SysUser extends BaseEntity {
*/
private String isPd;
/**
* 是否项目部
*/
private String isFace;
}

View File

@ -0,0 +1,79 @@
package com.bonus.system.att.dao;
import com.bonus.system.api.domain.MapVo;
import com.bonus.system.api.domain.SysUser;
import com.bonus.system.att.entity.AttFaceBean;
import com.bonus.system.att.entity.AttSourceDataBean;
import com.bonus.system.att.entity.LeaveBean;
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 org.springframework.stereotype.Repository;
import java.util.List;
/**
* 小程序同步定时器
* @author fly
*/
@Repository("WechatPushDao")
public interface WechatPushDao {
List<SysUser> getPersonList();
List<SysUser> getWeChatPersonList();
void insertWechatPerson(SysUser user);
void updateWechatPerson(SysUser user);
void updateWebPassword(SysUser wechatUser);
void updateWebOpenId(SysUser wechatUser);
void updateWechatIsPd(SysUser user);
List<AttFaceBean> getWeChatFaceList();
List<AttFaceBean> getWebFaceList();
void insertWebFace(AttFaceBean user);
void updateWebFace(AttFaceBean user);
/**
* 授予人脸重新录入权限时调用
* @param user
*/
void updateWechatIsFace(SysUser user);
/**
* 审核人脸时调用
* @String isCheck
*/
void checkWechatIsFace(String isCheck);
/**
* 查询请假数据
* @return
*/
List<EvectionBean> getWechatLeaveList();
SysOrg getOrgInfoByUserId(Long userId);
void insertWebLeave(EvectionBean bean);
void updateWechatLeave(EvectionBean bean);
void deleteWechatLeave();
List<EvectionBean> getWebLeaveList();
void insertWechatLeave(EvectionBean bean);
List<AttSourceDataBean> getWechatAttList();
SysOrg getOrgInfoByUserName(String userName);
}

View File

@ -0,0 +1,48 @@
package com.bonus.system.att.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 考勤数据
* @author zys
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AttFaceBean {
/**
* id
*/
private Long userId;
/**
* 应用人脸
*/
private String appliedFace;
/**
* 应用人脸
*/
private byte[] appliedFaceFeatures;
/**
* 新人脸
*/
private String newFace;
/**
* 新人脸
*/
private byte[] newFaceFeatures;
/**
* 是否需要更新人脸
*/
private String isFace;
/**
* 是否审核通过 0 未通过 1 已通过
*/
private String isCheck;
}

View File

@ -108,6 +108,11 @@ public class AttSourceDataBean {
*/
private String groupType;
/**
* 考勤组类型
*/
private String isOutsideAtt;
public AttSourceDataBean(Long userId, String orgId, String attCurrentDay, String attType) {
this.userId = userId;
this.orgId = orgId;

View File

@ -166,7 +166,7 @@ public class AttTasks {
*
* @param c
*/
private void changeAttCurrentDay(AttSourceDataBean c) {
public void changeAttCurrentDay(AttSourceDataBean c) {
// 定义时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 解析传入的时间字符串

View File

@ -0,0 +1,294 @@
package com.bonus.system.att.tasks;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson2.JSONObject;
import com.bonus.common.core.utils.DateTimeHelper;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.FastJsonHelper;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.system.api.domain.SysUser;
import com.bonus.system.att.dao.AttGroupDao;
import com.bonus.system.att.dao.AttSourceDataDao;
import com.bonus.system.att.dao.WechatPushDao;
import com.bonus.system.att.entity.*;
import com.bonus.system.att.utils.AddressCoordinateFormatUtil;
import com.bonus.system.att.utils.DistanceCalculator;
import com.bonus.system.att.utils.IpAndPathConfig;
import com.bonus.system.att.utils.WorkdayCalculator;
import com.bonus.system.basic.domain.SysOrg;
import com.bonus.system.evection.entity.EvectionBean;
import com.bonus.system.holiday.entity.HolidayBean;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import static com.bonus.system.att.utils.DistanceCalculator.calculateDistance;
/**
* @author fly
* 微信小程序数据同步接口
*/
@Configuration
@EnableScheduling
@Slf4j
@EnableAsync
public class WechatTasks {
@Resource(name = "WechatPushDao")
private WechatPushDao dao;
@Resource(name = "sqlSessionTemplate")
private SqlSessionTemplate sqlSessionTemplate;
@Resource(name = "attGroupDao")
private AttGroupDao attGroupDao;
/**
* 人员基础数据同步定时器
*/
// @Scheduled(cron = "0 0/10 * * * ?")
// @Scheduled(fixedDelay = 60000 * 10)
@Async
public void pushPersonTask() {
log.info("--------人员基础数据同步定时器开启------");
//考勤库人员
List<SysUser> list = dao.getPersonList();
//考勤小程序库人员
// List<SysUser> wechatList = dao.getWeChatPersonList();
String jsonStr = "{}";
String method = "getWeChatPersonList";
String string = httpPost(method, jsonStr);
List<SysUser> wechatList = FastJsonHelper.jsonArrStrToBeanList(string, SysUser.class);
// //所有字段同步
syncListsToDatabase(list, wechatList);
// //人脸更新
// List<AttFaceBean> faceList = dao.getWebFaceList();
// List<AttFaceBean> wechatFaceList = dao.getWeChatFaceList();
// syncFaceToDatabase(faceList, wechatFaceList);
log.info("--------人员基础数据同步定时器完毕------");
}
/**
* 休假出差数据同步定时器
*/
// @Scheduled(fixedDelay = 60000 * 10)
@Async
public void leaveTask() {
log.info("--------休假出差数据定时器开启------");
//小程序库人员
// List<EvectionBean> list = dao.getWechatLeaveList();
String jsonStr = "{}";
String method = "getWechatLeaveList";
String string = httpPost(method, jsonStr);
List<EvectionBean> list = FastJsonHelper.jsonArrStrToBeanList(string, EvectionBean.class);
//将所有人数据更新组织机构
for (EvectionBean bean : list) {
// 如果Map中没有该userId的组织机构信息则从数据库查询
SysOrg orgInfo = dao.getOrgInfoByUserId(bean.getUserId());
if(orgInfo != null){
bean.setOrgId(orgInfo.getId());
bean.setOrgName(orgInfo.getOrgName());
}
dao.insertWebLeave(bean);
// dao.updateWechatLeave(bean);
String jsonStr2 = FastJsonHelper.beanToJsonStr(bean);
String method2 = "updateWechatLeave";
String string2 = httpPost(method2, jsonStr2);
}
//删除所有已经同步过去的数据
// dao.deleteWechatLeave();
String jsonStr3 = "{}";
String method3 = "deleteWechatLeave";
String string3 = httpPost(method3, jsonStr3);
//在将所有数据同步过去
List<EvectionBean> webList = dao.getWebLeaveList();
webList.forEach(bean -> {
// dao.insertWechatLeave(bean);
bean.setUuid(UUID.randomUUID().toString());
String jsonStr2 = FastJsonHelper.beanToJsonStr(bean);
String method2 = "insertWechatLeave";
String string2 = httpPost(method2, jsonStr2);
});
log.info("--------休假出差数据定时器完毕------");
}
@Resource
private AttTasks attTasks;
/**
* 考勤数据同步定时器
*/
@Scheduled(fixedDelay = 60000 * 10)
@Async
public void wechatAttTask() {
log.info("--------考勤数据定时器开启------");
// //小程序库人员考勤
// List<AttSourceDataBean> attSourceList = dao.getWechatAttList();
String jsonStr = "{}";
String method = "getWechatAttList";
String string = httpPost(method, jsonStr);
List<AttSourceDataBean> attSourceList = FastJsonHelper.jsonArrStrToBeanList(string, AttSourceDataBean.class);
attSourceList.forEach(bean -> {
//判断是否外勤
//1.0获取考勤规则的组织的
String userName = bean.getName();
// 如果Map中没有该userId的组织机构信息则从数据库查询
SysOrg orgInfo = dao.getOrgInfoByUserName(userName);
if(orgInfo != null){
double distanceMeters = calculateDistance(bean.getAttLat(), bean.getAttLon(), orgInfo.getLat().longValue(), orgInfo.getLon().longValue(), DistanceCalculator.Unit.METERS);
if (distanceMeters>orgInfo.getAttRange()){
//外勤
bean.setIsOutsideAtt("1");
}else{
//正常
bean.setIsOutsideAtt("2");
}
}else{
//外勤
bean.setIsOutsideAtt("1");
}
});
//新增数据
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);
//将是否外勤更新到小程序库
// dao.updateWechatAttList(attSourceList);
String jsonStr2 = FastJsonHelper.beanListToJsonArrStr(attSourceList);
String method2 = "updateWechatAttList";
String string2 = httpPost(method2, jsonStr2);
log.info("--------考勤数据定时器完毕------");
}
private void syncFaceToDatabase(List<AttFaceBean> faceList, List<AttFaceBean> wechatFaceList) {
Map<Long, AttFaceBean> wechatUserMap = faceList.stream()
.collect(Collectors.toMap(AttFaceBean::getUserId, user -> user, (existing, replacement) -> existing));
for (AttFaceBean user : wechatFaceList) {
Long userId = user.getUserId();
if (!wechatUserMap.containsKey(userId)) {
//第一次录入人脸
dao.insertWebFace(user);
}else {
//将未审核通过的数据更新到考勤库审核
dao.updateWebFace(user);
}
}
}
private void syncListsToDatabase(List<SysUser> list, List<SysUser> wechatList) {
// wechatList 转换为 Map以便快速查找
Map<Long, SysUser> wechatUserMap = wechatList.stream()
.collect(Collectors.toMap(SysUser::getUserId, user -> user, (existing, replacement) -> existing));
// 遍历 list检查每个用户是否存在于 wechatList
for (SysUser user : list) {
Long userId = user.getUserId();
if (!wechatUserMap.containsKey(userId)) {
// 如果 userId 不存在于 wechatList则插入到数据库 a
// dao.insertWechatPerson(user);
String jsonStr = FastJsonHelper.beanToJsonStr(user);
String method = "insertWechatPerson";
String string = httpPost(method, jsonStr);
}else {
// 如果存在则判断时间是否后于小程序时间
// 如果 userId 存在于 wechatList则比较 updateTime
SysUser wechatUser = wechatUserMap.get(userId);
if (user.getUpdateTime().after(wechatUser.getUpdateTime())) {
// 如果 list 中的 updateTime 更新则更新数据库 a
// dao.updateWechatPerson(user);
String jsonStr = FastJsonHelper.beanToJsonStr(user);
String method = "updateWechatPerson";
String string = httpPost(method, jsonStr);
}else if (wechatUser.getUpdateTime().after(user.getUpdateTime())){
//更新后端密码
dao.updateWebPassword(wechatUser);
}
//openId 单向更新
if (StringUtils.isNotEmpty(wechatUser.getOpenId()) && !wechatUser.getOpenId().equals(user.getOpenId())){
//更新后端openId
dao.updateWebOpenId(wechatUser);
}
//单项更新 isPd
if (StringUtils.isNotEmpty(user.getIsPd()) && !user.getIsPd().equals(wechatUser.getIsPd())){
//更新小程序isPd
// dao.updateWechatIsPd(user);
String jsonStr = FastJsonHelper.beanToJsonStr(user);
String method = "updateWechatIsPd";
String string = httpPost(method, jsonStr);
}
}
}
}
/**
* 休假出差数据同步定时器
*/
// @Scheduled(cron = "0 0/10 * * * ?")
@Scheduled(fixedDelay = 60000 * 10)
@Async
public void getAttTasks() {
log.info("--------休假出差数据同步定时器开启------");
String today = DateUtil.today();
log.info("--------休假出差数据同步定时器完毕------");
}
//人脸更新是调用的方法
private String httpPost(String method, String jsonStr) {
try {
HttpResponse response = HttpRequest.post(IpAndPathConfig.getWechatUrl() + "/" + method)
.header("Content-Type", "application/json")
.body(jsonStr)
.execute();
int statusCode = response.getStatus();
JSONObject jsonObject = FastJsonHelper.jsonStrToJsonObj(response.body());
return jsonObject.getString("obj");
} catch (Exception e) {
e.printStackTrace();
// 处理异常例如记录日志或抛出自定义异常
return "";
}
}
}

View File

@ -0,0 +1,97 @@
package com.bonus.system.att.utils;
import java.util.Locale;
public class DistanceCalculator {
// 地球半径单位公里
private static final double EARTH_RADIUS_KM = 6371.0;
// 地球半径单位英里
private static final double EARTH_RADIUS_MILES = 3958.8;
// 地球半径单位
private static final double EARTH_RADIUS_METERS = EARTH_RADIUS_KM * 1000.0;
/**
* 计算两点之间的距离单位公里
*
* @param lat1 第一个点的纬度
* @param lon1 第一个点的经度
* @param lat2 第二个点的纬度
* @param lon2 第二个点的经度
* @return 两点之间的距离单位公里
*/
public static double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
return calculateDistance(lat1, lon1, lat2, lon2, Unit.KILOMETERS);
}
/**
* 计算两点之间的距离
*
* @param lat1 第一个点的纬度
* @param lon1 第一个点的经度
* @param lat2 第二个点的纬度
* @param lon2 第二个点的经度
* @param unit 距离单位公里英里或米
* @return 两点之间的距离
*/
public static double calculateDistance(double lat1, double lon1, double lat2, double lon2, Unit unit) {
// 将纬度和经度从度转换为弧度
double lat1Rad = Math.toRadians(lat1);
double lon1Rad = Math.toRadians(lon1);
double lat2Rad = Math.toRadians(lat2);
double lon2Rad = Math.toRadians(lon2);
// Haversine 公式
double dLat = lat2Rad - lat1Rad;
double dLon = lon2Rad - lon1Rad;
double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(lat1Rad) * Math.cos(lat2Rad) *
Math.sin(dLon / 2) * Math.sin(dLon / 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
// 计算距离
double distance;
switch (unit) {
case KILOMETERS:
distance = EARTH_RADIUS_KM * c;
break;
case MILES:
distance = EARTH_RADIUS_MILES * c;
break;
case METERS:
distance = EARTH_RADIUS_METERS * c;
break;
default:
throw new IllegalArgumentException("Unsupported unit: " + unit);
}
return distance;
}
/**
* 距离单位枚举
*/
public enum Unit {
KILOMETERS,
MILES,
METERS
}
/**
* 测试方法
*/
public static void main(String[] args) {
// 示例计算北京 (39.9042, 116.4074) 和上海 (31.2304, 121.4737) 之间的距离
double lat1 = 39.9042;
double lon1 = 116.4074;
double lat2 = 31.2304;
double lon2 = 121.4737;
double distanceKm = calculateDistance(lat1, lon1, lat2, lon2, Unit.KILOMETERS);
double distanceMiles = calculateDistance(lat1, lon1, lat2, lon2, Unit.MILES);
double distanceMeters = calculateDistance(lat1, lon1, lat2, lon2, Unit.METERS);
System.out.printf(Locale.US, "Distance between Beijing and Shanghai: %.2f km\n", distanceKm);
System.out.printf(Locale.US, "Distance between Beijing and Shanghai: %.2f miles\n", distanceMiles);
System.out.printf(Locale.US, "Distance between Beijing and Shanghai: %.2f meters\n", distanceMeters);
}
}

View File

@ -0,0 +1,38 @@
package com.bonus.system.att.utils;
/**
* @author fly
*/
//@Component
public class IpAndPathConfig {
/**
* 当前环境
* location 本地
* test 测试
* prod 固定
*/
// @Value("${environment}")
// public static String environment;
public static String environment = "location";
/**
* 小程序相关
*/
public static String wechatDevUrl = "http://127.0.0.1:1907/gz_att_wechat/wechatData";
public static String wechatTestUrl = "http://192.168.0.14:21880/wcd/getWorkerCard";
public static String wechatProdUrl = "http://112.29.103.165:21880/wcd/getWorkerCard";
public static String getWechatUrl(){
if(environment.contains("prod")){
return wechatProdUrl;
}else if(environment.contains("test")){
return wechatTestUrl;
}else{
return wechatDevUrl;
}
}
}

View File

@ -93,6 +93,11 @@ public class SysOrg {
*/
private Long updateUserId;
/**
* 修改人
*/
private int attRange;
/** 子菜单 */
private List<SysOrg> children = new ArrayList<SysOrg>();
}

View File

@ -25,7 +25,17 @@ public class EvectionBean extends BaseBean {
/**
* 请假单的uuid
*/
private String leaveFromId;
private String leaveFormId;
/**
* 是否外勤
*/
private String isOutsideAtt;
/**
* 备注
*/
private String remark;
/**
* 所属部门编号
@ -138,11 +148,6 @@ public class EvectionBean extends BaseBean {
*/
private String isAgree;
/**
* 备注
*/
private String remark;
/**
* 代理主持工作人员多个自动隔开
*/
@ -161,7 +166,7 @@ public class EvectionBean extends BaseBean {
/**
* 请假单的uuid
*/
private String uuId;
private String uuid;
/**
* 出行人Travelers
@ -178,4 +183,9 @@ public class EvectionBean extends BaseBean {
* 自己项目部所在分公司下的所有项目部id
*/
private List<String> orgList;
private Long submitId;
private String hostUserName;
}

View File

@ -46,7 +46,7 @@ public class EvectionServiceImpl implements EvectionService {
// String cadre = SecurityUtils.getLoginUser().getSysUser().getIsCadre();
// o.setIsCadre(cadre);
String uuId = UUID.randomUUID().toString();
o.setUuId(uuId);
o.setUuid(uuId);
o.setCreateUserId(userId);
o.setSource("1");
String travelers = o.getTravelers();
@ -72,7 +72,7 @@ public class EvectionServiceImpl implements EvectionService {
@Override
public int updateEvection(EvectionBean o) {
//先删除之前的出行人
int i = evectionDao.deleteEvectionById(o.getUuId());
int i = evectionDao.deleteEvectionById(o.getUuid());
int k = 0;
if(i>0){
o.setUpdateUserId(SecurityUtils.getLoginUser().getSysUser().getUserId());

View File

@ -0,0 +1,189 @@
<?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.system.att.dao.WechatPushDao">
<insert id="insertWechatPerson">
insert into gz_attendance_wechat.sys_user_wechat(user_id,user_name,phone,password,is_pd,is_face,update_time,is_cadre)
values(#{userId},#{userName},#{phone},#{password},#{isPd},#{isFace},#{updateTime},#{isCadre})
</insert>
<insert id="insertWebFace">
insert into sys_user_face(user_id,applied_face,applied_face_features,new_face,new_face_features,is_face,is_check)
values(#{userId},#{appliedFace},#{appliedFaceFeatures},#{newFace},#{newFaceFeatures},#{isCheck})
</insert>
<insert id="insertWebLeave" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
insert into leave_apply(leave_form_id,submit_id,user_id,user_name,org_id,org_name,type,
leave_type,leave_reason,leave_start_date,leave_start_interval,leave_end_date,leave_end_interval,
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(#{leaveFormId},#{submitId},#{userId},#{userName},#{orgId},#{orgName},#{type},
#{leaveType},#{leaveReason},#{leaveStartDate},#{leaveStartInterval},#{leaveEndDate},
#{leaveEndInterval},#{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,leave_start_interval,leave_end_date,leave_end_interval,
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},#{leaveStartInterval},#{leaveEndDate},
#{leaveEndInterval},#{leaveDuration},#{examineUserId},#{examineOpinion},#{examineTime},
#{examineStatus},#{hostUserId},#{hostUserName},#{isAgree},#{location},#{source},
#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{remark})
</insert>
<update id="updateWechatPerson">
update gz_attendance_wechat.sys_user_wechat set user_name = #{userName},phone = #{phone},
password = #{password},update_time = #{updateTime},is_cadre = #{isCadre},is_face = #{isFace}
where user_id = #{userId}
</update>
<update id="updateWebPassword">
update sys_user set password = #{password} where user_id = #{userId}
</update>
<update id="updateWebOpenId">
update sys_user set open_id = #{openId} where user_id = #{userId}
</update>
<update id="updateWechatIsPd">
update gz_attendance_wechat.sys_user_wechat set is_pd = #{isPd} where user_id = #{userId}
</update>
<update id="updateWebFace">
update sys_user_face set new_face = #{newFace},new_face_features = #{newFaceFeatures},is_check = #{isCheck}
where user_id = #{userId}
</update>
<update id="updateWechatIsFace">
update gz_attendance_wechat.sys_user_wechat set is_face = #{isFace} where user_id = #{userId}
</update>
<update id="checkWechatIsFace">
update gz_attendance_wechat.sys_user_face_wechat
<if test="isCheck == '1'">
set is_check = #{isCheck},applied_face = new_face,applied_face_features = new_face_features
</if>
<if test="isCheck == '2'">
set is_check = #{isCheck},new_face = null,new_face_features = null
</if>
where user_id = #{userId};
update sys_user_face
<if test="isCheck == '1'">
set is_check = #{isCheck},applied_face = new_face,applied_face_features = new_face_features
</if>
<if test="isCheck == '2'">
set is_check = #{isCheck},new_face = null,new_face_features = null
</if>
where user_id = #{userId};
</update>
<update id="updateWechatLeave">
update gz_attendance_wechat.leave_apply_wechat set id = #{id} where uuid = #{uuid}
</update>
<delete id="deleteWechatLeave">
delete gz_attendance_wechat.leave_apply_wechat where id is not null And uuid is not null
</delete>
<select id="getPersonList" resultType="com.bonus.system.api.domain.SysUser">
SELECT
su.user_id,
su.user_name,
su.phone,
su.`password`,
IF(applied_face is null,1,su.is_face) as isFace,
pd.org_id,
IF
( pd.org_id IS NOT NULL, 1, 0 ) isPd,
su.update_time,
su.open_id
FROM
sys_user su
LEFT JOIN (
SELECT
suo.user_id,
suo.org_id
FROM
sys_user_org suo
INNER JOIN sys_organization so ON so.id = suo.org_id
LEFT JOIN att_group_person_relation ag on ag.user_id = suo.user_id and ag.is_active = '1'
WHERE
so.is_active = '1'
AND suo.is_active = '1'
AND so.is_department = '1' and ag.group_id is not null
) pd ON pd.user_id = su.user_id
LEFT JOIN sys_user_face sw ON sw.user_id = su.user_id
WHERE
is_active = '1'
GROUP BY
user_id
</select>
<select id="getWeChatPersonList" resultType="com.bonus.system.api.domain.SysUser">
SELECT
*
FROM
gz_attendance_wechat.sys_user_wechat
WHERE is_active = '1'
</select>
<select id="getWeChatFaceList" resultType="com.bonus.system.att.entity.AttFaceBean">
SELECT
*
FROM
gz_attendance_wechat.sys_user_face_wechat
</select>
<select id="getWebFaceList" resultType="com.bonus.system.att.entity.AttFaceBean">
SELECT
*
FROM
sys_user_face
</select>
<select id="getWechatLeaveList" resultType="com.bonus.system.evection.entity.EvectionBean">
select * from gz_attendance_wechat.leave_apply_wechat where is_active = '1' and id is null
</select>
<select id="getOrgInfoByUserId" resultType="com.bonus.system.basic.domain.SysOrg">
SELECT
user_id,
org_id AS id,
org_name,
att_range,
so.lon,
so.lat
FROM
att_group_person_relation ag
LEFT JOIN sys_organization so ON so.id = ag.org_id
LEFT JOIN att_group_setting agt on agt.group_id = ag.group_id and agt.is_active = '1'
AND so.is_active = '1'
WHERE
ag.is_active = '1'
AND ag.user_id = #{userId}
</select>
<select id="getWebLeaveList" resultType="com.bonus.system.evection.entity.EvectionBean">
SELECT
*
from
leave_apply
where is_active = '1'
</select>
<select id="getWechatAttList" resultType="com.bonus.system.att.entity.AttSourceDataBean">
SELECT
*
from
gz_attendance_wechat.att_source_data_wechat
where is_active = '1' and is_outside_att = '0'
</select>
<select id="getOrgInfoByUserName" resultType="com.bonus.system.basic.domain.SysOrg">
SELECT
ag.user_id,
ag.org_id AS id,
so.org_name,
agt.att_range,
so.lon,
so.lat
FROM
att_group_person_relation ag
LEFT JOIN sys_organization so ON so.id = ag.org_id AND so.is_active = '1'
LEFT JOIN att_group_setting agt on agt.group_id = ag.group_id and agt.is_active = '1'
LEFT JOIN sys_user su ON su.user_id = ag.user_id AND su.is_active = '1'
WHERE
su.user_name = #{userName}
</select>
</mapper>