diff --git a/doc/sql/用户初始化.sql b/doc/sql/用户初始化.sql index d506c0238..ebf015d73 100644 --- a/doc/sql/用户初始化.sql +++ b/doc/sql/用户初始化.sql @@ -5,7 +5,7 @@ INSERT INTO epmet_gov_org.customer_staff_grid ( ID, CUSTOMER_ID, USER_ID, GRID_ID, DEL_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME ) SELECT t1.id, -'bb19419e365cf97567dc0520cdcfba9e', +'b09527201c4409e19d1dbc5e3c3429a1', t1.id AS USER_ID, t1.dept_id AS GRID_ID, t1.del_flag, @@ -32,7 +32,7 @@ INSERT INTO epmet_gov_org.customer_staff_department ( UPDATED_TIME ) SELECT t1.id , -'bb19419e365cf97567dc0520cdcfba9e', +'b09527201c4409e19d1dbc5e3c3429a1', t1.id as USER_ID, t1.dept_id as DEPARTMENT_ID, t1.del_flag, @@ -60,7 +60,7 @@ INSERT INTO epmet_gov_org.customer_staff_agency ( UPDATED_TIME ) SELECT t1.id , -'bb19419e365cf97567dc0520cdcfba9e', +'b09527201c4409e19d1dbc5e3c3429a1', t1.id as USER_ID, t1.dept_id as AGENCY_ID, t1.del_flag, @@ -73,4 +73,96 @@ left join esua_epdc_admin.sys_dept t2 on t1.dept_id = t2.id WHERE t2.type_key = 'district_party' OR t2.type_key = 'street_party' - OR t2.type_key = 'community_party'; \ No newline at end of file + OR t2.type_key = 'community_party'; + +INSERT INTO epmet_user.customer_staff ( ID, CUSTOMER_ID,USER_ID,REAL_NAME,GENDER,EMAIL,MOBILE,HEAD_PHOTO,PASSWORD,DEL_FLAG,REVISION,CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME) SELECT +t1.id as ID, +'b09527201c4409e19d1dbc5e3c3429a1', +t1.id AS USER_ID, +t1.real_name as REAL_NAME, +t1.gender as GENDER, +t1.email as EMAIL, +t1.mobile as MOBILE, +t1.head_url as HEAD_PHOTO, +t1.password as PASSWORD, +t1.del_flag as DEL_FLAG, +'0' as REVISION, +t1.creator AS CREATED_BY, +t1.create_date AS CREATED_TIME, +t1.updater AS UPDATED_BY, +t1.update_date AS UPDATED_TIME +FROM + esua_epdc_admin.sys_user t1 +where t1.user_tag_key ='offers'; + +INSERT INTO epmet_user.USER (ID, CUSTOMER_ID, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME ) SELECT +t1.id AS ID, +'b09527201c4409e19d1dbc5e3c3429a1' AS CUSTOMER_ID, +t1.del_flag AS DEL_FLAG, +'0' AS REVISION, +t1.creator AS CREATED_BY, +t1.create_date AS CREATED_TIME, +t1.updater AS UPDATED_BY, +t1.update_date AS UPDATED_TIME +FROM + esua_epdc_admin.sys_user t1 +where t1.user_tag_key ='offers'; + + +INSERT INTO epmet_gov_org.staff_org_relation ( ID, CUSTOMER_ID, PIDS, STAFF_ID, ORG_ID, ORG_TYPE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME ) SELECT +t1.id AS ID, +'b09527201c4409e19d1dbc5e3c3429a1' AS CUSTOMER_ID, +CASE + t2.type_key + WHEN 'district_party' THEN + t2.pids + WHEN 'street_party' THEN + t2.pids + WHEN 'community_party' THEN + concat( + SUBSTRING_INDEX( t2.pids, ',', 1 ), + ':', + SUBSTRING_INDEX( t2.pids, ',',- 1 )) + WHEN 'district_dept' THEN + t2.pids + WHEN 'street_dept' THEN + concat( + SUBSTRING_INDEX( t2.pids, ',', 1 ), + ':', + SUBSTRING_INDEX( t2.pids, ',',- 1 )) + WHEN 'grid_party' THEN + concat( + SUBSTRING_INDEX( t2.pids, ',', 1 ), + ':', + SUBSTRING_INDEX( SUBSTRING_INDEX( t2.pids, ',', 2 ), ',',- 1 ), + ':', + SUBSTRING_INDEX( t2.pids, ',',- 1 )) + END AS PIDS, + t1.id AS STAFF_ID, + t2.id AS ORG_ID, +CASE + t2.type_key + WHEN 'district_party' THEN + 'agency' + WHEN 'street_party' THEN + 'agency' + WHEN 'community_party' THEN + 'agency' + WHEN 'district_dept' THEN + 'dept' + WHEN 'street_dept' THEN + 'dept' + WHEN 'grid_party' THEN + 'grid' + END AS ORG_TYPE, + t1.del_flag AS DEL_FLAG, + '0' AS REVISION, + t1.creator AS CREATED_BY, + t1.create_date AS CREATED_TIME, + t1.updater AS UPDATED_BY, + t1.update_date AS UPDATED_TIME +FROM + esua_epdc_admin.sys_user t1 + LEFT JOIN esua_epdc_admin.sys_dept t2 ON t1.dept_id = t2.id +WHERE + t1.user_tag_key = 'offers'; \ No newline at end of file diff --git a/doc/sql/部门组织初始化.sql b/doc/sql/部门组织初始化.sql index bbd75b2b8..110564b02 100644 --- a/doc/sql/部门组织初始化.sql +++ b/doc/sql/部门组织初始化.sql @@ -5,7 +5,7 @@ INSERT INTO epmet_gov_org.customer_grid ( ID, CUSTOMER_ID, GRID_NAME, SYNC_FLAG, DEL_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, MANAGE_DISTRICT, TOTAL_USER, PID, PIDS ) SELECT t1.id, -'bb19419e365cf97567dc0520cdcfba9e', +'b09527201c4409e19d1dbc5e3c3429a1', t1.NAME AS GRID_NAME, '1', t1.del_flag, @@ -45,7 +45,7 @@ INSERT INTO epmet_gov_org.customer_agency ( TOTAL_USER ) SELECT t1.id, -'bb19419e365cf97567dc0520cdcfba9e', +'b09527201c4409e19d1dbc5e3c3429a1', t1.pid, CASE t1.type_key @@ -112,7 +112,7 @@ INSERT INTO epmet_gov_org.customer_department ( UPDATED_TIME ) SELECT t1.id, -'bb19419e365cf97567dc0520cdcfba9e', +'b09527201c4409e19d1dbc5e3c3429a1', t1.pid as AGENCY_ID, t1.name as DEPARTMENT_NAME, t2.total AS TOTAL_USER, diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/StaffOrgRelationDao.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/StaffOrgRelationDao.java new file mode 100644 index 000000000..bc6326729 --- /dev/null +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/StaffOrgRelationDao.java @@ -0,0 +1,37 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.entity.StaffOrgRelationEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 工作人员注册组织关系表 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2022-01-19 + */ +@Mapper +public interface StaffOrgRelationDao extends BaseDao { + + void deleteBatchStaffIds(@Param("idLists")List idLists); +} diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/entity/StaffOrgRelationEntity.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/entity/StaffOrgRelationEntity.java new file mode 100644 index 000000000..fbe06a11a --- /dev/null +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/entity/StaffOrgRelationEntity.java @@ -0,0 +1,66 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 工作人员注册组织关系表 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2022-01-19 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epmet_gov_org.staff_org_relation") +public class StaffOrgRelationEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 所有上级组织机构ID(以英文:隔开)部门/网格得拼上所属组织Id + */ + private String pids; + + /** + * 工作人员Id + */ + private String staffId; + + /** + * 工作人员添加入口Id(agencyId;deptId;gridId) + */ + private String orgId; + + /** + * 工作人员添加入口类型(组织:agency;部门:dept;网格:gridId) + */ + private String orgType; + +} diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysUserServiceImpl.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysUserServiceImpl.java index ab1151dac..7abf194f4 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysUserServiceImpl.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysUserServiceImpl.java @@ -86,6 +86,8 @@ public class SysUserServiceImpl extends BaseServiceImpl page(Map params) { @@ -158,6 +160,8 @@ public class SysUserServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); @@ -244,11 +265,25 @@ public class SysUserServiceImpl extends BaseServiceImpl wrapper = new QueryWrapper<>(); + wrapper.eq("STAFF_ID",dto.getId().toString()); + StaffOrgRelationEntity staffOrgRelationEntity = staffOrgRelationDao.selectOne(wrapper); + String typeKey = deptEntity.getTypeKey(); + staffOrgRelationEntity.setPids(StringUtils.join(StringUtils.split(deptEntity.getPids(), ","), ":")); + staffOrgRelationEntity.setOrgId(deptEntity.getId().toString()); + if (OrganizationTypeConstant.ORG_TYPE_GRID_PARTY.equals(typeKey)) { + staffOrgRelationEntity.setOrgType("grid"); + } else if (OrganizationTypeConstant.ORG_TYPE_DISTRICT_DEPT.equals(typeKey) || OrganizationTypeConstant.ORG_TYPE_STREET_DEPT.equals(typeKey)) { + staffOrgRelationEntity.setOrgType("dept"); + } else { + staffOrgRelationEntity.setOrgType("agency"); + } + staffOrgRelationDao.updateById(staffOrgRelationEntity); } if (!sysUserEntity.getDeptId().equals(entity.getDeptId())) { //更新后用户的机构信息 - SysDeptEntity deptEntity = sysDeptDao.select(entity.getDeptId()); if (sysDeptEntity.getTypeKey().equals(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY)) { //原来的组织部门totol_user -1 updateGridTotalUserBefore(sysDeptEntity); @@ -411,10 +446,11 @@ public class SysUserServiceImpl extends BaseServiceImpl idLists = Arrays.asList(ids).stream().map(x -> x.toString()).collect(Collectors.toList()); userDao.deleteBatchIds(idLists); customerStaffDao.deleteBatchUserIds(idLists); + staffOrgRelationDao.deleteBatchStaffIds(idLists); //物理删除组织用户 List sysUserEntities = baseDao.selectBatchIds(Arrays.asList(ids)); List deptIds = sysUserEntities.stream().map(x -> x.getDeptId().toString()).collect(Collectors.toList()); diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/StaffOrgRelationDao.xml b/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/StaffOrgRelationDao.xml new file mode 100644 index 000000000..d68aeaa8a --- /dev/null +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/StaffOrgRelationDao.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + update epmet_gov_org.staff_org_relation set DEL_FLAG = '1' where STAFF_ID in + + #{staffId} + + + +