模块数据隔离,bug修改

Signed-off-by: lSun <15893999301@qq.com>
This commit is contained in:
lSun 2024-12-27 00:25:16 +08:00
parent dbcb1c4d98
commit 7c34233279
16 changed files with 169 additions and 20 deletions

View File

@ -178,4 +178,6 @@ public class SysUser extends BaseEntity {
*/
private String roleType;
private String orgListId;
private List<Long> orgListIds;
}

View File

@ -70,4 +70,6 @@ public interface OrgChangeDao {
void updateAttGroupByUserId(OrgChangeBean item);
void updateOrgChangeIsApply(OrgChangeBean item);
void updateOrgByUserIdAndOldOrgId(OrgChangeBean o);
}

View File

@ -92,6 +92,10 @@ public class OrgChangeServiceImpl implements OrgChangeService {
}
i = orgChangeDao.orgChangeCheck(o);
if ("1".equals(o.getIsCheck())) {
orgChangeDao.updateOrgByUserIdAndOldOrgId(o);
// orgChangeDao.updateOrgByUserId(o);
}
}
return i;
}

View File

@ -59,8 +59,8 @@ public class AttTasks {
private static final int THREAD_POOL_SIZE = 5; // 线程池大小
private volatile boolean executed = false; // 标志位表示任务是否已经执行过
// @Scheduled(cron = "0 0/10 * * * ?")
@Scheduled(initialDelay = 6000, fixedDelay = 60000 * 10)
// @Scheduled(cron = "0 0/10 * * * ?")
@Scheduled(initialDelay = 60000, fixedDelay = 60000 * 10)
@Async
public void getAttTasks() {
log.info("--------考勤定时器开启------");
@ -72,7 +72,7 @@ public class AttTasks {
/**
* 历史考勤数据
*/
@Scheduled(initialDelay = 60000 * 4,fixedDelay = 60000 * 30)
// @Scheduled(initialDelay = 60000 * 4,fixedDelay = 60000 * 30)
@Async
public void getHisAttTasks() {
log.info("--------考勤定时器开启------");

View File

@ -76,8 +76,8 @@ public class WechatTasks {
/**
* 人员基础数据同步定时器
*/
@Scheduled(cron = "0 0/10 * * * ?")
// @Scheduled(initialDelay = 6000,fixedDelay = 60000 * 10)
// @Scheduled(cron = "0 0/10 * * * ?")
@Scheduled(initialDelay = 60000,fixedDelay = 60000 * 10)
@Async
public void pushPersonTask() {
log.info("--------人员基础数据同步定时器开启------");

View File

@ -14,7 +14,7 @@ public class IpAndPathConfig {
*/
// @Value("${environment}")
// public static String environment;
public static String environment = "test";
public static String environment = "prod";
/**
* 小程序相关

View File

@ -177,6 +177,9 @@ public class SysUserController extends BaseController {
return error("修改用户'" + user.getUserName() + "'失败,用户名已存在");
}
user.setUpdateBy(String.valueOf(SecurityUtils.getLoginUser().getSysUser().getUserId()));
// 修改leave_apply中的org_id
return toAjax(userService.updateUser(user));
} catch (Exception e) {
logger.error(e.toString(),e);

View File

@ -5,12 +5,14 @@ import com.bonus.system.api.domain.MapVo;
import com.bonus.system.api.domain.SysDictData;
import com.bonus.system.api.domain.SysRole;
import com.bonus.system.att.entity.OrgChangeBean;
import com.bonus.system.basic.domain.SysOrg;
import com.bonus.system.basic.domain.SysUserOrg;
import com.bonus.system.basic.domain.SysUserPost;
import com.bonus.system.basic.domain.SysUserRole;
import com.bonus.system.holiday.entity.HolidayKeyBean;
import org.apache.ibatis.annotations.Mapper;
import com.bonus.system.api.domain.SysUser;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -234,4 +236,10 @@ public interface SysUserMapper
String getUserIdList(String userIdList);
List<SysRole> getManagerList(Long userId);
void updateOrgIdByUserId(SysUser users);
void updateOrgIdByUserIdWithOutSame(@Param("user") SysUser users);
SysOrg findOrgByOrgId(SysUser users);
}

View File

@ -15,6 +15,7 @@ import com.bonus.system.api.domain.SysRole;
import com.bonus.system.api.model.LoginUser;
import com.bonus.system.att.entity.OrgChangeBean;
import com.bonus.system.att.service.OrgChangeService;
import com.bonus.system.basic.domain.SysOrg;
import com.bonus.system.basic.domain.SysUserOrg;
import com.bonus.system.basic.domain.SysUserPost;
import com.bonus.system.basic.domain.SysUserRole;
@ -324,13 +325,118 @@ public class SysUserServiceImpl implements SysUserService
}
userMapper.deleteUserOrgByUserId(userId);
insertUserOrg(user);
return userMapper.updateUser(user);
//处理人员组织变更休假/外出/等审批组织
dealOrgUserLeave(orgIdsByUserId,user);
return userMapper.updateUser(user);
} catch (Exception e) {
log.error(e.toString(),e);
log.error(e.toString(),e);
return 0;
}
}
private static Map<String,List<Long>> compareMaps(Map<Long, Long> A, Map<Long, Long> B) {
Set<Long> allKeys = new HashSet<>(A.keySet());
allKeys.addAll(B.keySet());
Map<String,List<Long>> map = new HashMap<>();
List<Long> orgIds = new ArrayList<>();
List<Long> sameList = new ArrayList<>();
for (Long key : allKeys) {
Long valueA = A.get(key);
Long valueB = B.get(key);
if (valueA == null) {
orgIds.add(valueB);
System.out.println("Key " + key + " is added in B with value " + valueB);
} else if (valueB == null) {
System.out.println("Key " + key + " is removed from A");
} else if (!valueA.equals(valueB)) {
orgIds.add(valueB);
System.out.println("Key " + key + ": Changed from " + valueA + " to " + valueB);
} else if (valueA.equals(valueB)) {
sameList.add(valueB);
System.out.println("Key " + key + ": no Changed from " + valueA + " to " + valueB);
}
}
map.put("same",sameList);
map.put("notSame",orgIds);
return map;
}
private static boolean compareSameMaps(Map<Long, Long> A, Map<Long, Long> B) {
Set<Long> allKeys = new HashSet<>(A.keySet());
allKeys.addAll(B.keySet());
List<Long> orgIds = new ArrayList<>();
for (Long key : allKeys) {
Long valueA = A.get(key);
Long valueB = B.get(key);
if (valueA == null) {
System.out.println("Key " + key + " is added in B with value " + valueB);
} else if (valueB == null) {
System.out.println("Key " + key + " is removed from A");
} else if (!valueA.equals(valueB)) {
System.out.println("Key " + key + ": Changed from " + valueA + " to " + valueB);
} else if (valueA.equals(valueB)) {
orgIds.add(valueB);
System.out.println("Key " + key + ": no Changed from " + valueA + " to " + valueB);
}
}
if(!orgIds.isEmpty() && orgIds.size() == A.size()){
return true;
}
return false;
}
private static Map<Long, Long> arrayToMapUsingElementToList(Long[] array) {
Map<Long, Long> map = new HashMap<>();
for (int i = 0; i < array.length; i++) {
// 这里我们简单地使用元素自身作为值
map.put(array[i], array[i]);
}
return map;
}
/**
* 处理用户退出组织时的逻辑
* 当用户退出组织时需要更新或处理与该用户相关的组织信息
* 此方法旨在根据用户ID获取其相关的组织ID列表并执行相应的处理逻辑
*
* @param orgIdsByUserId 用户相关的组织ID列表表示该用户属于哪些组织
* @param user 退出组织的用户信息包含用户ID等必要数据
*/
private void dealOrgUserLeave(Long[] orgIdsByUserId, SysUser user) {
//比较老旧组织的是否发生改变
Map<Long, Long> oldOrgArray = arrayToMapUsingElementToList(orgIdsByUserId);
Map<Long, Long> newOrgArray = arrayToMapUsingElementToList(user.getOrgIds());
boolean isSame = compareSameMaps(oldOrgArray, newOrgArray);
if(isSame){
//无变化集合
}else{
//有变化的集合
Map<String,List<Long>> map = compareMaps(oldOrgArray, newOrgArray);
if(user.getOrgIds().length == 1){
//A -> B,AB -> A,AB -> C
SysUser users = new SysUser();
users.setUserId(user.getUserId());
users.setOrgId(user.getOrgIds()[0] + "");
SysOrg orgBean = userMapper.findOrgByOrgId(users);
users.setOrgName(orgBean.getOrgName());
userMapper.updateOrgIdByUserId(users);
}else{
//A -> BC,AB -> AC,AB -> CD
List<Long> sameList = map.get("same");
List<Long> notSameList = map.get("notSame");
SysUser users = new SysUser();
users.setUserId(user.getUserId());
users.setOrgId(notSameList.get(0) + "");
users.setOrgListIds(sameList);
SysOrg orgBean = userMapper.findOrgByOrgId(users);
users.setOrgName(orgBean.getOrgName());
userMapper.updateOrgIdByUserIdWithOutSame(users);
}
}
}
public static boolean containsOrgId(Long[] orgIds, Long orgId) {
// 将数组转换为 List
return Arrays.asList(orgIds).contains(orgId);

View File

@ -204,13 +204,13 @@ public class HolidayServiceImpl implements HolidayService {
} else if (ownStatus.contains(o.getExamineStatus())) {
o.setUpdateUserId(updateUserId);
}
i = holidayDao.changeHolidayStatus(o);
if (i > 0 && examineStatus.contains(o.getExamineStatus())) {
i = holidayDao.changeHolidayStatus(o);
if (i > 0 && examineStatus.contains(o.getExamineStatus())) {
//获取提交请假的人
List<Long> userList =holidayDao.getUserIdById(o.getId());
// List 转换为数组
if(!userList.isEmpty()){
if (userList.size() > 1) { // 检查是否有多个元素
if (userList.size() > 1) { // 检查是否有多个元素
// 如果有多个元素检查并移除值为1的元素
while (userList.contains(updateUserId)) {
userList.remove(Long.valueOf(updateUserId));

View File

@ -127,7 +127,7 @@
attendance_date as attCurrentDay, attendance_time as attCurrentTime,
CASE attendance_type WHEN '上班' THEN 1 ELSE 2 END as attType,
'0' as attAddress, lon as attLon, lat as attLat, '1' as dataSource
from gz_cloud_test.fc_sup_attendance sup
from gz_cloud.fc_sup_attendance sup
where sup.attendance_date
<if test=' pushType == "1" '>
>= #{pushDate}

View File

@ -128,4 +128,8 @@
<update id="updateOrgChangeIsApply">
update org_change set is_apply = #{isApply} where id = #{id}
</update>
<update id="updateOrgByUserIdAndOldOrgId">
UPDATE leave_apply SET org_id = #{newOrgId},org_name = #{newOrgName}
WHERE user_id = #{userId} and org_id = #{oldOrgId}
</update>
</mapper>

View File

@ -33,7 +33,7 @@
<insert id="pushAttDataToQsy">
<foreach collection="list" item="item" separator=";">
replace INTO gz_cloud_test.fc_sup_attendance (
replace INTO gz_cloud.fc_sup_attendance (
name,
id_number,
org_id,
@ -164,7 +164,7 @@
If(PROJECT_ID is null,0,PROJECT_ID) AS proId,
If(ORG_ID is null,0,ORG_ID) AS orgId
FROM
gz_cloud_test.bm_sup_attend_history
gz_cloud.bm_sup_attend_history
WHERE
ID_NUMBER = #{idNumber}
limit 1

View File

@ -98,6 +98,21 @@
where user_id = #{userId}
and org_id = #{oldOrgId};
</update>
<update id="updateOrgIdByUserId">
UPDATE leave_apply SET org_id = #{orgId},org_name = #{orgName}
WHERE user_id = #{userId}
</update>
<update id="updateOrgIdByUserIdWithOutSame">
UPDATE leave_apply SET org_id = #{user.orgId},org_name = #{user.orgName}
WHERE user_id = #{user.userId}
<if test='user.orgListIds.size != null and user.orgListIds.size > 0'>
and org_id not in
<foreach item="id" index="index" collection="user.orgListIds"
open="(" separator="," close=")">
#{id}
</foreach>
</if>
</update>
<select id="selectUserByUserName" resultType="com.bonus.system.api.domain.SysUser">
select *
@ -332,4 +347,9 @@
AND user_id = #{userId}
)
</select>
<select id="findOrgByOrgId" resultType="com.bonus.system.basic.domain.SysOrg">
SELECT org_name as orgName
FROM sys_organization
WHERE id = #{orgId}
</select>
</mapper>

View File

@ -38,9 +38,9 @@
<if test="params.params.endTime != null and params.params.endTime != ''"><!-- 结束时间检索 -->
and date_format(l.leave_end_date,'%y%m%d') &lt;= date_format(#{params.params.endTime},'%y%m%d')
</if>
<if test='bean.orgList != null and bean.orgList.size() > 0'>
<if test='params.orgList != null and bean.orgList.size() > 0'>
and l.org_id in (
<foreach collection="bean.orgList" item="item" separator=",">
<foreach collection="params.orgList" item="item" separator=",">
#{item}
</foreach>
)

View File

@ -28,12 +28,12 @@
WHERE ad.is_active = '1'
AND ad.data_source = '3'
AND sd.dict_value IN ('1', '2', '4', '7', '8', '9', '10', '19')
<if test="userName!=null and userName!=''">
AND su.user_name like concat('%', #{userName}, '%')
<if test="bean.userName!=null and bean.userName!=''">
AND su.user_name like concat('%', #{bean.userName}, '%')
</if>
<if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
AND ad.att_current_day BETWEEN #{startDate} AND #{endDate}
<if test="bean.startDate!=null and bean.startDate!='' and bean.endDate!=null and bean.endDate!=''">
AND ad.att_current_day BETWEEN #{bean.startDate} AND #{bean.endDate}
</if>
<if test='bean.orgList != null and bean.orgList.size() > 0'>