Browse Source

添加用户和机构 角色的关联关系

pull/1/head
yulin 8 months ago
parent
commit
d8f1e4c6e3
3 changed files with 35 additions and 6 deletions
  1. +1
    -1
      mztb/src/main/java/cc/smtweb/biz/mztb/web/domian/PrePartyInfo.java
  2. +31
    -5
      mztb/src/main/java/cc/smtweb/biz/mztb/web/task/AddNewPartyAndAccountTask.java
  3. +3
    -0
      mztb/src/main/java/cc/smtweb/biz/mztb/web/task/PushTask.java

+ 1
- 1
mztb/src/main/java/cc/smtweb/biz/mztb/web/domian/PrePartyInfo.java View File

@@ -9,7 +9,7 @@ import cc.smtweb.framework.core.db.impl.DefaultEntity;
* 实体【[机构信息]PrePartyInfo * 实体【[机构信息]PrePartyInfo
*/ */
public class PrePartyInfo extends DefaultEntity { public class PrePartyInfo extends DefaultEntity {
public static final String ENTITY_NAME = "PRE_PARTY_INFO";
public static final String ENTITY_NAME = "pre_party_info";


public PrePartyInfo() { public PrePartyInfo() {
super(ENTITY_NAME); super(ENTITY_NAME);


+ 31
- 5
mztb/src/main/java/cc/smtweb/biz/mztb/web/task/AddNewPartyAndAccountTask.java View File

@@ -15,10 +15,7 @@ import cc.smtweb.system.bpm.web.sys.user.party.Party;
import cc.smtweb.system.bpm.web.sys.user.party.PartyCache; import cc.smtweb.system.bpm.web.sys.user.party.PartyCache;
import cc.smtweb.system.bpm.web.sys.user.role.group.RoleGroup; import cc.smtweb.system.bpm.web.sys.user.role.group.RoleGroup;
import cc.smtweb.system.bpm.web.sys.user.role.group.RoleGroupCache; import cc.smtweb.system.bpm.web.sys.user.role.group.RoleGroupCache;
import cc.smtweb.system.bpm.web.sys.user.user.User;
import cc.smtweb.system.bpm.web.sys.user.user.UserCache;
import cc.smtweb.system.bpm.web.sys.user.user.UserParty;
import cc.smtweb.system.bpm.web.sys.user.user.UserPartyCache;
import cc.smtweb.system.bpm.web.sys.user.user.*;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;


import java.sql.*; import java.sql.*;
@@ -28,6 +25,9 @@ import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;


/**
* 拉取前置库推送的机构信息 执行新增或修改 操作
*/
public class AddNewPartyAndAccountTask extends BaseJob { public class AddNewPartyAndAccountTask extends BaseJob {
private static final String PWD_SALT = "goodpj"; private static final String PWD_SALT = "goodpj";


@@ -45,6 +45,9 @@ public class AddNewPartyAndAccountTask extends BaseJob {
List<User> userList = new ArrayList<>(); List<User> userList = new ArrayList<>();
List<UserParty> userPartyList = new ArrayList<>(); List<UserParty> userPartyList = new ArrayList<>();
List<Dept> deptList = new ArrayList<>(); List<Dept> deptList = new ArrayList<>();
List<UserRole> userRoleList = new ArrayList<>();
List<UserStatu> userStatuList = new ArrayList<>();

List<String> ptIdList = new ArrayList<>(); List<String> ptIdList = new ArrayList<>();


// 记录重复数据 // 记录重复数据
@@ -54,6 +57,8 @@ public class AddNewPartyAndAccountTask extends BaseJob {
List<UserParty> userPartyListExist = new ArrayList<>(); List<UserParty> userPartyListExist = new ArrayList<>();
List<Dept> deptListExist = new ArrayList<>(); List<Dept> deptListExist = new ArrayList<>();
List<String> ptIdListExist = new ArrayList<>(); List<String> ptIdListExist = new ArrayList<>();
List<UserRole> userRoleListExist = new ArrayList<>();
List<UserStatu> userStatuListExist = new ArrayList<>();


SwMap existPartyMap = new SwMap(); SwMap existPartyMap = new SwMap();
int insertIndex = 0; int insertIndex = 0;
@@ -92,6 +97,8 @@ public class AddNewPartyAndAccountTask extends BaseJob {
userPartyListExist.add(userPartyList.get(index)); userPartyListExist.add(userPartyList.get(index));
sysPartyListExist.add(sysPartyList.get(index)); sysPartyListExist.add(sysPartyList.get(index));
deptListExist.add(deptList.get(index)); deptListExist.add(deptList.get(index));
userRoleListExist.add(userRoleList.get(index));
userStatuListExist.add(userStatuList.get(index));
ptIdListExist.add(ptIdList.get(index)); ptIdListExist.add(ptIdList.get(index));
} }
existPartyMap.put(resultSet.getString("pi_credit_code"), insertIndex); existPartyMap.put(resultSet.getString("pi_credit_code"), insertIndex);
@@ -135,12 +142,25 @@ public class AddNewPartyAndAccountTask extends BaseJob {
deptList.add(dept); deptList.add(dept);


UserParty userParty = new UserParty(); //用户机构关联表 UserParty userParty = new UserParty(); //用户机构关联表
userParty.setId(instance.nextId());
long userPartyId = instance.nextId();
userParty.setId(userPartyId);
userParty.setPartyId(ptId); userParty.setPartyId(ptId);
userParty.setUserId(userId); userParty.setUserId(userId);
userParty.setDeptId(deptId); // 关联部门表 userParty.setDeptId(deptId); // 关联部门表
userPartyList.add(userParty); userPartyList.add(userParty);


UserRole userRole = new UserRole(); // 用户角色
userRole.setId(instance.nextId());
userRole.setSupId(userPartyId);
userRole.setRoleGroupId(927515588790587392L); // 角色组id todo 先写死 一般不会变
userRoleList.add(userRole);

UserStatu userStatu = new UserStatu(); // 用户登录状态
userStatu.init();
userStatu.setId(userId);
userStatuList.add(userStatu);


} }
} }
// 删除重复新增的元素 // 删除重复新增的元素
@@ -149,6 +169,8 @@ public class AddNewPartyAndAccountTask extends BaseJob {
userList.removeAll(userListExist); userList.removeAll(userListExist);
userPartyList.removeAll(userPartyListExist); userPartyList.removeAll(userPartyListExist);
deptList.removeAll(deptListExist); deptList.removeAll(deptListExist);
userRoleList.removeAll(userRoleListExist);
userStatuList.removeAll(userStatuListExist);
ptIdList.removeAll(ptIdListExist); ptIdList.removeAll(ptIdListExist);


// 读取完成后 修改前置库推送数据的状态,再进行本系统数据入库处理 // 读取完成后 修改前置库推送数据的状态,再进行本系统数据入库处理
@@ -162,6 +184,8 @@ public class AddNewPartyAndAccountTask extends BaseJob {
instance.findDao(User.class).batchInsertEntity(userList); instance.findDao(User.class).batchInsertEntity(userList);
instance.findDao(UserParty.class).batchInsertEntity(userPartyList); instance.findDao(UserParty.class).batchInsertEntity(userPartyList);
instance.findDao(Dept.class).batchInsertEntity(deptList); instance.findDao(Dept.class).batchInsertEntity(deptList);
instance.findDao(UserRole.class).batchInsertEntity(userRoleList);
instance.findDao(UserStatu.class).batchInsertEntity(userStatuList);


// 将新增的机构 加入角色组的 机构字段 // 将新增的机构 加入角色组的 机构字段
if (ptIdList.size() > 0) { if (ptIdList.size() > 0) {
@@ -173,6 +197,8 @@ public class AddNewPartyAndAccountTask extends BaseJob {
UserCache.getInstance().putList(userList); UserCache.getInstance().putList(userList);
UserPartyCache.getInstance().putList(userPartyList); UserPartyCache.getInstance().putList(userPartyList);
DeptCache.getInstance().putList(deptList); DeptCache.getInstance().putList(deptList);
UserRoleCache.getInstance().putList(userRoleList);
UserStatuCache.getInstance().putList(userStatuList);
RoleGroupCache.getInstance().refresh(); RoleGroupCache.getInstance().refresh();
}); });
} catch (SQLException e) { } catch (SQLException e) {


+ 3
- 0
mztb/src/main/java/cc/smtweb/biz/mztb/web/task/PushTask.java View File

@@ -15,6 +15,9 @@ import java.sql.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;


/**
* 将填报信息推送到前置库
*/
public class PushTask extends BaseJob { public class PushTask extends BaseJob {


private String buildInsertSql(String tableName, DefaultEntity entity) { private String buildInsertSql(String tableName, DefaultEntity entity) {


Loading…
Cancel
Save