commit
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package io.v.nutz.base.event;
|
||||
|
||||
public interface SysCommonDataChange {
|
||||
|
||||
|
||||
/**
|
||||
* 系统通用数据变更
|
||||
*
|
||||
* @param changeType 变更类型
|
||||
* @param tClass 数据类型 例如user、unit...............
|
||||
* @param bizId 业务ID
|
||||
*/
|
||||
void exec(SysCommonDataChangeType changeType, Class<?> tClass, String bizId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package io.v.nutz.base.event;
|
||||
|
||||
import org.nutz.mvc.Mvcs;
|
||||
|
||||
/**
|
||||
* @author zhf
|
||||
* @date 2025/8/14 17:23
|
||||
* @description
|
||||
*/
|
||||
public class SysCommonDataChangeCenter {
|
||||
|
||||
public static void publish(SysCommonDataChangeType changeType, Class<?> tClass, String bizId){
|
||||
String[] names = Mvcs.getIoc().getNamesByType(SysCommonDataChange.class);
|
||||
for (String listener : names) {
|
||||
SysCommonDataChange listenerBean = Mvcs.getIoc().get(SysCommonDataChange.class, listener);
|
||||
listenerBean.exec(changeType, tClass, bizId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package io.v.nutz.base.event;
|
||||
|
||||
/**
|
||||
* 数据变更类型
|
||||
*/
|
||||
public enum SysCommonDataChangeType {
|
||||
|
||||
INSERT(),
|
||||
UPDATE(),
|
||||
DELETE();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.v.nutz.base.event.user;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:UserChangeEventListener
|
||||
* @Date 2025/8/13 14:18
|
||||
* @注释
|
||||
*/
|
||||
public interface UserChangeEventListener {
|
||||
|
||||
void receive(UserChangeMsg message);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package io.v.nutz.base.event.user;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:UserChangeMsg
|
||||
* @Date 2025/8/13 11:51
|
||||
* @注释
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserChangeMsg {
|
||||
|
||||
/**
|
||||
* 变更资源,用户Id
|
||||
*/
|
||||
private List<String> userIds;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
private Integer operationType;
|
||||
|
||||
/**
|
||||
* 变更前的单位Id,当operationType值为1时,该字段有效
|
||||
*/
|
||||
private String sourceUnitId;
|
||||
|
||||
/**
|
||||
* 变更后的单位Id,当operationType值为1时,该字段有效
|
||||
*/
|
||||
private String targetUnitId;
|
||||
|
||||
/**
|
||||
* 单位变动
|
||||
*/
|
||||
public final static int UNIT_CHANGE_OPERATION = 1;
|
||||
|
||||
/**
|
||||
* 退休
|
||||
*/
|
||||
public final static int RETIRE_OPERATION = 2;
|
||||
|
||||
/**
|
||||
* 入会
|
||||
*/
|
||||
public final static int RESTORE_OPERATION = 3;
|
||||
|
||||
|
||||
public UserChangeMsg(List<String> userIds, Integer operationType) {
|
||||
super();
|
||||
this.userIds = userIds;
|
||||
this.operationType = operationType;
|
||||
}
|
||||
|
||||
public UserChangeMsg(List<String> userIds, Integer operationType, String sourceUnitId) {
|
||||
super();
|
||||
this.userIds = userIds;
|
||||
this.operationType = operationType;
|
||||
this.sourceUnitId = sourceUnitId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package io.v.nutz.base.event.user;
|
||||
|
||||
import org.nutz.mvc.Mvcs;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:UserChangePublisher
|
||||
* @Date 2025/8/13 14:23
|
||||
* @注释
|
||||
*/
|
||||
public class UserChangePublisher {
|
||||
|
||||
// 发送消息给所有订阅者
|
||||
public static void broadcast(UserChangeMsg msg) {
|
||||
String[] names = Mvcs.getIoc().getNamesByType(UserChangeEventListener.class);
|
||||
for (String listener : names) {
|
||||
UserChangeEventListener listenerBean = Mvcs.getIoc().get(UserChangeEventListener.class, listener);
|
||||
listenerBean.receive(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,10 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.event.SysCommonDataChangeCenter;
|
||||
import io.v.nutz.base.event.SysCommonDataChangeType;
|
||||
import io.v.nutz.base.event.user.UserChangeMsg;
|
||||
import io.v.nutz.base.event.user.UserChangePublisher;
|
||||
import io.v.nutz.base.page.Pagination;
|
||||
import io.v.nutz.base.utils.PageUtil;
|
||||
import io.v.nutz.base.utils.Roles;
|
||||
@@ -18,6 +22,7 @@ import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import lombok.Data;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
@@ -25,11 +30,13 @@ import org.nutz.dao.entity.Record;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.dao.util.cri.Static;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
@@ -38,10 +45,7 @@ import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.trans.Trans;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -230,9 +234,8 @@ public class SysUnionMangeCon {
|
||||
public Object doAddUnion(Sys_union union) {
|
||||
try {
|
||||
sysUnionService.insert(union);
|
||||
|
||||
// flushDict();
|
||||
|
||||
// 通知系统工会发生变更
|
||||
SysCommonDataChangeCenter.publish(SysCommonDataChangeType.INSERT, Sys_union.class, union.getId());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
@@ -267,6 +270,9 @@ public class SysUnionMangeCon {
|
||||
try {
|
||||
sysUnionService.update(union);
|
||||
|
||||
// 通知系统工会发生变更
|
||||
SysCommonDataChangeCenter.publish(SysCommonDataChangeType.UPDATE, Sys_union.class, union.getId());
|
||||
|
||||
// flushDict();
|
||||
|
||||
return Result.success();
|
||||
@@ -342,9 +348,37 @@ public class SysUnionMangeCon {
|
||||
try {
|
||||
//再删除工会负责人的权限
|
||||
sysUnionService.clear("sys_user_role", Cnd.where("unionid", "=", unionid).and("roleid", "=", Roles.UNION_MANGER));
|
||||
for (String id : Json.fromJsonAsList(String.class, userids)) {
|
||||
sysUnionService.clear("sys_user_role", Cnd.where("unionid", "is", null).and("roleid", "=", Roles.UNION_MANGER));
|
||||
List<String> strings = Json.fromJsonAsList(String.class, userids).stream().distinct().collect(Collectors.toList());
|
||||
for (String id : strings) {
|
||||
sysUnionService.insert("sys_user_role", Chain.make("roleid", Roles.UNION_MANGER).add("userid", id).add("unionid", unionid));
|
||||
}
|
||||
// 删除这个人在其他分工会的角色 096072
|
||||
sysUserService.dao().clear(Sys_user_role.class, Cnd.where("userId", "in", strings)
|
||||
.and("unionId", "!=", unionid));
|
||||
|
||||
// 找出分工会里面所有的工会干部,看这些人的工会与对应的分工会管理员是不是一致的,不一致的删除
|
||||
List<Sys_user_role> userRoleList = sysUserService.dao().query(Sys_user_role.class, Cnd.where("roleId", "=", Roles.UNION_MANGER));
|
||||
|
||||
// 去查询user中的unionid
|
||||
Set<String> userIds = userRoleList.stream().map(Sys_user_role::getUserId).collect(Collectors.toSet());
|
||||
Sql sql = Sqls.create("SELECT u.id,u.unionid from `user` u WHERE u.id in (@userIds)").setParam("userIds", userIds);
|
||||
sql.setCallback(Sqls.callback.maps());
|
||||
sysUserService.dao().execute(sql);
|
||||
List<NutMap> userList = (List<NutMap>) sql.getResult();
|
||||
// 转map,找差异
|
||||
Map<String, String> userMap = userList.stream().collect(Collectors.toMap(v -> v.getString("id"), v -> v.getString("unionid")));
|
||||
|
||||
List<Sys_user_role> diffUnionRoleList = userRoleList.stream().filter(v -> userMap.containsKey(v.getUserId())
|
||||
&& !v.getUnionid().equals(userMap.get(v.getUserId()))).collect(Collectors.toList());
|
||||
// 删除这些人的角色
|
||||
if (org.nutz.lang.Lang.isNotEmpty(diffUnionRoleList)) {
|
||||
sysUserService.dao().clear(Sys_user_role.class, Cnd.where("userId", "in", diffUnionRoleList.stream().map(Sys_user_role::getUserId).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
// 发送广播订阅
|
||||
UserChangePublisher.broadcast(new UserChangeMsg(List.of("1"), UserChangeMsg.UNIT_CHANGE_OPERATION));
|
||||
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
return Result.success();
|
||||
@@ -733,11 +767,20 @@ public class SysUnionMangeCon {
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Object doEditZcdw(String unionid, String unitids) {
|
||||
try {
|
||||
List<Sys_unit> oldUnitList = sysUnitService.query(Cnd.where("unionid", "=", unionid));
|
||||
sysUnitService.execute(Sqls.create("UPDATE sys_unit set unionid = null WHERE unionid=@id").setParam("id", unionid));
|
||||
for (String id : Json.fromJsonAsList(String.class, unitids)) {
|
||||
sysUnitService.update(Chain.make("unionid", unionid), Cnd.where("id", "=", id));
|
||||
SysCommonDataChangeCenter.publish(SysCommonDataChangeType.UPDATE, Sys_unit.class, id);
|
||||
}
|
||||
|
||||
// 排除出去的单位
|
||||
List<Sys_unit> deleteUnits = oldUnitList.stream().filter(v -> !unitids.contains(v.getId())).collect(Collectors.toList());
|
||||
for (Sys_unit deleteUnit : deleteUnits) {
|
||||
SysCommonDataChangeCenter.publish(SysCommonDataChangeType.UPDATE, Sys_unit.class, deleteUnit.getId());
|
||||
}
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -2,6 +2,8 @@ package io.v.nutz.sys.controllers.platform.sys;
|
||||
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.event.SysCommonDataChangeCenter;
|
||||
import io.v.nutz.base.event.SysCommonDataChangeType;
|
||||
import io.v.nutz.base.utils.Roles;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
@@ -134,11 +136,14 @@ public class SysUnitMangeController {
|
||||
sysUnitService.insert(sys_unit);
|
||||
|
||||
//添加承办单位
|
||||
ProposalUndertake proposalUndertake = new ProposalUndertake();
|
||||
proposalUndertake.setIsEnable(true);
|
||||
proposalUndertake.setUnitName(sys_unit.getName());
|
||||
proposalUndertake.setUnitCode(sys_unit.getUnitcode());
|
||||
dao.insert(proposalUndertake);
|
||||
// ProposalUndertake proposalUndertake = new ProposalUndertake();
|
||||
// proposalUndertake.setIsEnable(true);
|
||||
// proposalUndertake.setUnitName(sys_unit.getName());
|
||||
// proposalUndertake.setUnitCode(sys_unit.getUnitcode());
|
||||
// dao.insert(proposalUndertake);
|
||||
|
||||
// 通知系统单位发生变更
|
||||
SysCommonDataChangeCenter.publish(SysCommonDataChangeType.INSERT, Sys_unit.class, sys_unit.getId());
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -156,7 +161,11 @@ public class SysUnitMangeController {
|
||||
sysUnitService.update(sys_unit);
|
||||
|
||||
//更新承办单位
|
||||
dao.update(ProposalUndertake.class, Chain.make("unitName", sys_unit.getName()), Cnd.where("unitCode", "=", sys_unit.getUnitcode()));
|
||||
// dao.update(ProposalUndertake.class, Chain.make("unitName", sys_unit.getName()), Cnd.where("unitCode", "=", sys_unit.getUnitcode()));
|
||||
|
||||
// 通知系统单位发生变更
|
||||
SysCommonDataChangeCenter.publish(SysCommonDataChangeType.UPDATE, Sys_unit.class, sys_unit.getId());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package io.v.nutz.sys.listener;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import io.v.nutz.base.event.user.UserChangeEventListener;
|
||||
import io.v.nutz.base.event.user.UserChangeMsg;
|
||||
import io.v.nutz.sys.models.Sys_user_role;
|
||||
import io.v.nutz.sys.models.UnionCadre;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:SysUserChangeListener
|
||||
* @Date 2025/8/13 15:24
|
||||
* @注释 有关系统人员的广播监听
|
||||
*/
|
||||
@IocBean
|
||||
public class SysUserChangeListener implements UserChangeEventListener {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void receive(UserChangeMsg message) {
|
||||
if (ObjectUtil.equals(message.getOperationType(), UserChangeMsg.UNIT_CHANGE_OPERATION)) {
|
||||
// 单位变动,删除原单位的角色
|
||||
dao.clear(Sys_user_role.class, Cnd.where("userId", "in", message.getUserIds()).and("unitid", "=", message.getSourceUnitId()));
|
||||
|
||||
// 判断这两个单位是不是在一个工会,如果不是,删除原来工会的所有角色
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
(SELECT unionId FROM sys_unit WHERE id = @sourceUnitId) AS sourceUnionId,
|
||||
(SELECT unionId FROM sys_unit WHERE id = @targetUnitId) AS targetUnionId,
|
||||
CASE
|
||||
WHEN (SELECT unionId FROM sys_unit WHERE id = @sourceUnitId) IS NULL
|
||||
AND (SELECT unionId FROM sys_unit WHERE id = @targetUnitId) IS NULL THEN true
|
||||
WHEN (SELECT unionId FROM sys_unit WHERE id = @sourceUnitId) =
|
||||
(SELECT unionId FROM sys_unit WHERE id = @targetUnitId) THEN true
|
||||
ELSE false
|
||||
END AS result
|
||||
""").setParam("sourceUnitId", message.getSourceUnitId()).setParam("targetUnitId", message.getTargetUnitId());
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
dao.execute(sql);
|
||||
NutMap result = (NutMap) sql.getResult();
|
||||
|
||||
if (!result.getBoolean("result")) {
|
||||
dao.clear(Sys_user_role.class, Cnd.where("userId", "in", message.getUserIds()).and("unionid", "=", result.getString("sourceUnionId")));
|
||||
// 清空这个工会角色记录表
|
||||
dao.clear(UnionCadre.class, Cnd.where("userId", "in", message.getUserIds()).and("unionId", "=", result.getString("sourceUnionId")));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package io.v.nutz.zhgh.activity.listener;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.v.nutz.base.event.SysCommonDataChange;
|
||||
import io.v.nutz.base.event.SysCommonDataChangeType;
|
||||
import io.v.nutz.sys.models.Sys_union;
|
||||
import io.v.nutz.zhgh.activity.models.ActivityBasicUnion;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
/**
|
||||
* @author zhf
|
||||
* @date 2025/8/15 08:46
|
||||
* @description
|
||||
*/
|
||||
@IocBean
|
||||
public class SysActivityUnionListener implements SysCommonDataChange {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
|
||||
@Override
|
||||
public void exec(SysCommonDataChangeType changeType, Class<?> sysUnionClass, String bizId) {
|
||||
if (sysUnionClass.getSimpleName().equals(Sys_union.class.getSimpleName())) {
|
||||
switch (changeType) {
|
||||
case INSERT -> {
|
||||
Sys_union sys_union = dao.fetch(Sys_union.class, bizId);
|
||||
ActivityBasicUnion basicUnion = BeanUtil.copyProperties(sys_union, ActivityBasicUnion.class);
|
||||
dao.insert(basicUnion);
|
||||
}
|
||||
case UPDATE -> {
|
||||
Sys_union sys_union = dao.fetch(Sys_union.class, bizId);
|
||||
ActivityBasicUnion basicUnion = dao.fetch(ActivityBasicUnion.class, Cnd.where("id", "=", sys_union.getId()));
|
||||
sys_union.setEnable(true);
|
||||
BeanUtil.copyProperties(sys_union, basicUnion);
|
||||
dao.update(basicUnion);
|
||||
}
|
||||
case DELETE -> {
|
||||
dao.clear(ActivityBasicUnion.class, Cnd.where("id", "=", bizId));
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package io.v.nutz.zhgh.activity.listener;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.v.nutz.base.event.SysCommonDataChange;
|
||||
import io.v.nutz.base.event.SysCommonDataChangeType;
|
||||
import io.v.nutz.sys.models.Sys_unit;
|
||||
import io.v.nutz.zhgh.activity.models.ActivityBasicUnit;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
/**
|
||||
* @author zhf
|
||||
* @date 2025/8/14 17:30
|
||||
* @description
|
||||
*/
|
||||
@IocBean
|
||||
public class SysActivityUnitListener implements SysCommonDataChange {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Override
|
||||
public void exec(SysCommonDataChangeType changeType, Class<?> sysUnitClass, String bizId) {
|
||||
if (sysUnitClass.getSimpleName().equals(Sys_unit.class.getSimpleName())) {
|
||||
switch (changeType) {
|
||||
case INSERT -> {
|
||||
Sys_unit sys_unit = dao.fetch(Sys_unit.class, bizId);
|
||||
ActivityBasicUnit basicUnit = BeanUtil.copyProperties(sys_unit, ActivityBasicUnit.class);
|
||||
dao.insert(basicUnit);
|
||||
}
|
||||
case UPDATE -> {
|
||||
Sys_unit sys_unit = dao.fetch(Sys_unit.class, bizId);
|
||||
ActivityBasicUnit basicUnit = dao.fetch(ActivityBasicUnit.class, Cnd.where("id", "=", sys_unit.getId()));
|
||||
BeanUtil.copyProperties(sys_unit, basicUnit, "id");
|
||||
dao.update(basicUnit);
|
||||
}
|
||||
case DELETE -> {
|
||||
dao.clear(ActivityBasicUnit.class, Cnd.where("id", "=", bizId));
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package io.v.nutz.zhgh.proposal.listener;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.v.nutz.base.event.SysCommonDataChange;
|
||||
import io.v.nutz.base.event.SysCommonDataChangeType;
|
||||
import io.v.nutz.sys.models.Sys_unit;
|
||||
import io.v.nutz.zhgh.proposal.models.ProposalUndertake;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
/**
|
||||
* @author zhf
|
||||
* @date 2025/8/14 17:30
|
||||
* @description
|
||||
*/
|
||||
@IocBean
|
||||
public class ProposalUnderTakeListener implements SysCommonDataChange {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Override
|
||||
public void exec(SysCommonDataChangeType changeType, Class<?> sysUnitClass, String bizId) {
|
||||
if (sysUnitClass.getSimpleName().equals(Sys_unit.class.getSimpleName())) {
|
||||
switch (changeType) {
|
||||
case INSERT -> {
|
||||
Sys_unit sys_unit = dao.fetch(Sys_unit.class, bizId);
|
||||
ProposalUndertake basicUnit = BeanUtil.copyProperties(sys_unit, ProposalUndertake.class);
|
||||
dao.insert(basicUnit);
|
||||
}
|
||||
case UPDATE -> {
|
||||
Sys_unit sys_unit = dao.fetch(Sys_unit.class, bizId);
|
||||
ProposalUndertake undertake = dao.fetch(ProposalUndertake.class, Cnd.where("unitCode", "=", sys_unit.getUnitcode()));
|
||||
undertake.setUnitName(sys_unit.getName());
|
||||
dao.updateIgnoreNull(undertake);
|
||||
}
|
||||
case DELETE -> {
|
||||
dao.clear(ProposalUndertake.class, Cnd.where("id", "=", bizId));
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -6,6 +6,8 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HtmlUtil;
|
||||
import io.v.nutz.base.event.user.UserChangeMsg;
|
||||
import io.v.nutz.base.event.user.UserChangePublisher;
|
||||
import io.v.nutz.base.service.impl.BaseServiceImpl;
|
||||
import io.v.nutz.base.utils.MsgApi;
|
||||
import io.v.nutz.base.utils.Roles;
|
||||
@@ -251,6 +253,9 @@ public class SourceChangeManageServiceImpl extends BaseServiceImpl<SourceChangeM
|
||||
// 如果有单位异动,发送消息提醒分工会
|
||||
if (middleTable.getChangeTypes().contains(MemberChangeType.UNIT_CHANGE.name())){
|
||||
sendUnitChangeTeacher(middleTable, history);
|
||||
// 单位变更发送广播消息
|
||||
UserChangePublisher.broadcast(new UserChangeMsg(List.of(info.getId()),
|
||||
UserChangeMsg.UNIT_CHANGE_OPERATION, history.getUnitid(), middleTable.getUnitid()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user