diff --git a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/controller/UserController.java b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/controller/UserController.java index 8ccad69f..dfdf1064 100644 --- a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/controller/UserController.java +++ b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/controller/UserController.java @@ -196,8 +196,10 @@ public class UserController extends BaseController{ //角色主键数组 String[] rolesid = request.getParameterValues("rolesid"); + String departmentIds = request.getParameter("departmentIds"); + //保存用户信息 - int isok = this.userService.save(tab, rolesid); + int isok = this.userService.save(tab, rolesid,departmentIds); if (isok > 0) { String[] tenantselect = request.getParameterValues("tenantselect"); @@ -252,8 +254,10 @@ public class UserController extends BaseController{ //角色主键数组 String[] rolesid = request.getParameterValues("rolesid"); + + String departmentIds = request.getParameter("departmentIds"); //保存用户信息 - int isok = this.userService.editUser(tab, rolesid); + int isok = this.userService.editUser(tab, rolesid,departmentIds); if (isok > 0) { String[] tenantselect = request.getParameterValues("tenantselect"); diff --git a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/dataobject/Department.java b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/dataobject/Department.java index a835cb6b..4b3311b5 100644 --- a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/dataobject/Department.java +++ b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/dataobject/Department.java @@ -52,6 +52,7 @@ public class Department implements BaseDto,java.io.Serializable { @Schema(description = "上一级部门主键,默认为0表示为第一级数据对象,非0情况表示为有上一级数据对象") @TableField(value="PARENTID") + @JsonSerialize(using = ToStringSerializer.class) private Long parentid; @Schema(description = "记录根级部门主键,用于记录子部门所属根节点主键,默认为0,只有一层节点记录上一级节点主键") @@ -129,7 +130,38 @@ public class Department implements BaseDto,java.io.Serializable { @Schema(description = "更新时间") @TableField(value="UPDATETIME") private Long updatetime; - + + @Schema(description = "对应的Service名,主要是spring的service名") + @TableField(value="SERVICENAME") + private String servicename; + + @Schema(description = "内置表单,使用flowable表单,0:使用本地数据,1:使用flowable表单,3:外置表单,4:其他自定义表单") + @TableField(value="BUILTFORM") + private Integer builtform; + + @Schema(description = "表单地址,用户展示用户表单使用") + @TableField(value="FORMURL") + private String formurl; + + @Schema(description = "表单详情") + @TableField(value="FORMDETAIL") + private String formdetail; + + @Schema(description = "表单分类") + @TableField(value="FORMTYPE") + private String formtype; + + @Schema(description = "流程定义id") + @TableField(value="PROCESSDEFINITIONID") + private String processdefinitionid; + + @Schema(description = "公司类型,0:租户,1:主体") + @TableField(value="TYPEDEPT") + private Integer typedept; + + @Schema(description = "对应的工作流编码,与工作流中的命名空间对应") + @TableField(value="CATEGORY") + private String category; //子集机构的集合 @TableField(exist = false) private List listchilddept; @@ -165,7 +197,15 @@ public class Department implements BaseDto,java.io.Serializable { new SimpleEntry<>("CREATEUSER","createuser"), new SimpleEntry<>("CREATEDATE","createdate"), new SimpleEntry<>("UPDATEUSER","updateuser"), - new SimpleEntry<>("UPDATETIME","updatetime") + new SimpleEntry<>("UPDATETIME","updatetime"), + new SimpleEntry<>("SERVICENAME","servicename"), + new SimpleEntry<>("BUILTFORM","builtform"), + new SimpleEntry<>("FORMURL","formurl"), + new SimpleEntry<>("FORMDETAIL","formdetail"), + new SimpleEntry<>("FORMTYPE","formtype"), + new SimpleEntry<>("PROCESSDEFINITIONID","processdefinitionid"), + new SimpleEntry<>("TYPEDEPT","typedept"), + new SimpleEntry<>("CATEGORY","category") ) .collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue)); @Override diff --git a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/dataobject/User.java b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/dataobject/User.java index 30fe879b..91a55a1c 100644 --- a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/dataobject/User.java +++ b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/dataobject/User.java @@ -172,12 +172,12 @@ public class User implements BaseDto,java.io.Serializable { //用于记录用户对应的顶级机构主键 @TableField(exist = false) private Long departmentRootId = 0L; - - //租户关系 - @TableField(exist = false) - List tenantList; +// +// //租户关系 +// @TableField(exist = false) +// List tenantList; //用户对应的部门信息,映射文件中对应的字段信息 - @JsonIgnore + @TableField(exist = false) private List deptlist = new ArrayList(0); @@ -215,7 +215,7 @@ public class User implements BaseDto,java.io.Serializable { Iterator it = deptlist.iterator(); StringBuffer sb = new StringBuffer(); - if (it.hasNext()) { + while (it.hasNext()) { Department dept = it.next(); if (null != sb && sb.length() > 0) { diff --git a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/DepartmentService.java b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/DepartmentService.java index 8dc9b014..1c991806 100644 --- a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/DepartmentService.java +++ b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/DepartmentService.java @@ -32,7 +32,13 @@ public interface DepartmentService extends BaseService { * 查询所用数据,根据参数查询是否展示禁用的机构,false表示不展示禁用的机构 */ public List listDepartByUser(User user, boolean enabled); - + + /** + * 根据机构下的“业务主体编码”查询 + * @param category + * @return + */ + List listByDeptNo(String deptno); /** * 根据机构主键,查询机构对象,并且保存到缓存中 * @param id 机构主键 diff --git a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/UserService.java b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/UserService.java index b999c962..3dec6afa 100644 --- a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/UserService.java +++ b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/UserService.java @@ -87,7 +87,7 @@ public interface UserService extends BaseService { * @param rolesid 角色主键集合 * @return 成功返回大于零的数字,否则返回零 */ - int save(User user, String[] rolesid); + int save(User user, String[] rolesid,String departmentIds); /** * 新增或者更新用户信息,并且初始化用户密码 @@ -108,7 +108,7 @@ public interface UserService extends BaseService { * @param user 用户对象 * @return 成功返回大于零的数字,否则返回零 */ - int editUser(User user, String[] rolesid); + int editUser(User user, String[] rolesid,String departmentIds); /** * 重置用户密码,根据配置文件userDefaultPassword,如果没有数据重置为123456 diff --git a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/impl/DepartmentServiceImpl.java b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/impl/DepartmentServiceImpl.java index b8455a17..27833568 100644 --- a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/impl/DepartmentServiceImpl.java +++ b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/impl/DepartmentServiceImpl.java @@ -205,7 +205,18 @@ public class DepartmentServiceImpl extends BaseServiceImpl listByDeptNo(String deptno){ + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("DEPTNO",deptno); + + return this.selectSearchList(queryWrapper); + } /** * 根据角色主键,查询角色中自定义的查询范围管理的机构主键集合 * @param roleid 角色主键 ,可以为空,为空查询所有 diff --git a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/impl/UserServiceImpl.java b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/impl/UserServiceImpl.java index ba68dfa8..44ecf7b2 100644 --- a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/impl/UserServiceImpl.java +++ b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/impl/UserServiceImpl.java @@ -105,7 +105,7 @@ public class UserServiceImpl extends BaseServiceImpl imple List departmentList = this.departmentMybatisDao.selectDeptByUserid(user.getId()); user.formatDeptlist(departmentList); - user.setTenantList(this.userTenantService.listUserTenant(user.getId())); + //user.setTenantList(this.userTenantService.listUserTenant(user.getId())); //返回用户前端菜单权限列表 List frontmenuTList1 = isFrontmenuTService.queryUserMenuById(user.getLoginname()); @@ -136,7 +136,7 @@ public class UserServiceImpl extends BaseServiceImpl imple List departmentList = this.departmentMybatisDao.selectDeptByUserid(user.getId()); user.formatDeptlist(departmentList); - user.setTenantList(this.userTenantService.listUserTenant(user.getId())); + //user.setTenantList(this.userTenantService.listUserTenant(user.getId())); //返回用户前端菜单权限列表 List frontmenuTList1 = isFrontmenuTService.queryUserMenuById(user.getLoginname()); @@ -283,7 +283,7 @@ public class UserServiceImpl extends BaseServiceImpl imple */ @Override @Transactional - public int save(User user, String[] rolesid){ + public int save(User user, String[] rolesid,String departmentIds){ //spring密码加密啊算法 BCryptPasswordEncoder bcryptPasswordEncoder = new BCryptPasswordEncoder(); @@ -299,12 +299,18 @@ public class UserServiceImpl extends BaseServiceImpl imple isok = this.usermybatisdao.insert(user); //保存用户是否成功 if(isok > 0){ - Userobject uo = new Userobject(); - uo.setUserid(user.getId()); - uo.setDepartid(user.getDepartmentId()); - //保存用户与部门的关系 + + String[] deptids = departmentIds.split(","); + + for(String dids:deptids){ + Userobject uo = new Userobject(); + uo.setUserid(user.getId()); + uo.setDepartid(Long.parseLong(dids)); + //保存用户与部门的关系 + + this.userobjectMybatisDao.insert(uo); + } - this.userobjectMybatisDao.insert(uo); //判断接收的角色是否为空,如果为空用户角色使用默认角色 if(null != rolesid && rolesid.length > 0){ @@ -426,7 +432,7 @@ public class UserServiceImpl extends BaseServiceImpl imple */ @Override @Transactional - public int editUser(User user,String[] rolesid){ + public int editUser(User user,String[] rolesid,String departmentIds){ //获得数据库中用户信息 User olduser = this.usermybatisdao.selectById(user.getId()); @@ -442,17 +448,27 @@ public class UserServiceImpl extends BaseServiceImpl imple queryWrapper.eq("USERID",user.getId()); //判断修改前用户的机构主键是否一致,如果不一致需要修改 - if(!user.getDepartmentId().equals(olduser.getDepartmentId())){ +// if(!user.getDepartmentId().equals(olduser.getDepartmentId())){ //删除原有用户与机构的关联关系 this.userobjectMybatisDao.delete(queryWrapper); - - Userobject uo = new Userobject(); - uo.setUserid(user.getId()); - uo.setDepartid(user.getDepartmentId()); - //保存用户与部门的关系 - this.userobjectMybatisDao.insert(uo); - } + + String[] deptids = departmentIds.split(","); + + for(String dids:deptids){ + Userobject uo = new Userobject(); + uo.setUserid(user.getId()); + uo.setDepartid(Long.parseLong(dids)); + //保存用户与部门的关系 + + this.userobjectMybatisDao.insert(uo); + } +// Userobject uo = new Userobject(); +// uo.setUserid(user.getId()); +// uo.setDepartid(user.getDepartmentId()); +// //保存用户与部门的关系 +// this.userobjectMybatisDao.insert(uo); +// } //判断接收的角色是否为空 if(null != rolesid && rolesid.length > 0){ @@ -616,7 +632,7 @@ public class UserServiceImpl extends BaseServiceImpl imple if(null != user){ List departmentList = this.departmentMybatisDao.selectDeptByUserid(user.getId()); user.formatDeptlist(departmentList); - user.setTenantList(this.userTenantService.listUserTenant(user.getId())); + //user.setTenantList(this.userTenantService.listUserTenant(user.getId())); } return user; diff --git a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/impl/UserTokenServiceImpl.java b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/impl/UserTokenServiceImpl.java index afbc855b..290678e0 100644 --- a/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/impl/UserTokenServiceImpl.java +++ b/jyjz-system/jyjz-system-admin/src/main/java/cn/jyjz/xiaoyao/admin/service/impl/UserTokenServiceImpl.java @@ -238,7 +238,7 @@ public class UserTokenServiceImpl implements UserTokenService { Map rolesShowleave = this.rolesService.getRolesConditionMap(user); SearchQuery searchQueryrolesShowleave = this.rolesService.getRolesCondition(rolesShowleave); user.setRolesShowleave(rolesShowleave); - user.setTenantList(this.userTenantService.listUserTenant(user.getId())); + //user.setTenantList(this.userTenantService.listUserTenant(user.getId())); user.setSearchQueryrolesShowleave(searchQueryrolesShowleave); userVo = BeanUtil.copyProperties(user,User.class); diff --git a/jyjz-system/jyjz-system-admin/src/main/resources/mapper/admin/DepartmentMapper.xml b/jyjz-system/jyjz-system-admin/src/main/resources/mapper/admin/DepartmentMapper.xml index 97580c34..972d8abd 100644 --- a/jyjz-system/jyjz-system-admin/src/main/resources/mapper/admin/DepartmentMapper.xml +++ b/jyjz-system/jyjz-system-admin/src/main/resources/mapper/admin/DepartmentMapper.xml @@ -26,6 +26,14 @@ + + + + + + + + @@ -53,6 +61,14 @@ + + + + + + + + @@ -79,7 +95,15 @@ CREATEUSER AS createuser, CREATEDATE AS createdate, UPDATEUSER AS updateuser, - UPDATETIME AS updatetime + UPDATETIME AS updatetime, + SERVICENAME AS servicename, + BUILTFORM AS builtform, + FORMURL AS formurl, + FORMDETAIL AS formdetail, + FORMTYPE AS formtype, + PROCESSDEFINITIONID AS processdefinitionid, + TYPEDEPT AS typedept, + CATEGORY AS category @@ -109,6 +133,14 @@ and CREATEDATE ${createdate.dataOp} ${createdate.likestar}#{createdate.value}${createdate.likeend} and UPDATEUSER ${updateuser.dataOp} ${updateuser.likestar}#{updateuser.value}${updateuser.likeend} and UPDATETIME ${updatetime.dataOp} ${updatetime.likestar}#{updatetime.value}${updatetime.likeend} + and SERVICENAME ${servicename.dataOp} ${servicename.likestar}#{servicename.value}${servicename.likeend} + and BUILTFORM ${builtform.dataOp} ${builtform.likestar}#{builtform.value}${builtform.likeend} + and FORMURL ${formurl.dataOp} ${formurl.likestar}#{formurl.value}${formurl.likeend} + and FORMDETAIL ${formdetail.dataOp} ${formdetail.likestar}#{formdetail.value}${formdetail.likeend} + and FORMTYPE ${formtype.dataOp} ${formtype.likestar}#{formtype.value}${formtype.likeend} + and PROCESSDEFINITIONID ${processdefinitionid.dataOp} ${processdefinitionid.likestar}#{processdefinitionid.value}${processdefinitionid.likeend} + and TYPEDEPT ${typedept.dataOp} ${typedept.likestar}#{typedept.value}${typedept.likeend} + and CATEGORY ${category.dataOp} ${category.likestar}#{category.value}${category.likeend} and USERID ${userid.dataOp} ${userid.likestar}#{userid.value}${userid.likeend} and DEPARTID in @@ -187,7 +219,15 @@ d.CREATEUSER AS createuser, d.CREATEDATE AS createdate, d.UPDATEUSER AS updateuser, - d.UPDATETIME AS updatetime + d.UPDATETIME AS updatetime, + d.SERVICENAME AS servicename, + d.BUILTFORM AS builtform, + d.FORMURL AS formurl, + d.FORMDETAIL AS formdetail, + d.FORMTYPE AS formtype, + d.PROCESSDEFINITIONID AS processdefinitionid, + d.TYPEDEPT AS typedept, + d.CATEGORY AS category from S_DEPARTMENT_T d,S_USEROBJECT_T uo where uo.DEPARTID=d.ID and uo.USERID=#{id} @@ -216,7 +256,15 @@ dm.CREATEUSER AS createuser, dm.CREATEDATE AS createdate, dm.UPDATEUSER AS updateuser, - dm.UPDATETIME AS updatetime + dm.UPDATETIME AS updatetime, + dm.SERVICENAME AS servicename, + dm.BUILTFORM AS builtform, + dm.FORMURL AS formurl, + dm.FORMDETAIL AS formdetail, + dm.FORMTYPE AS formtype, + dm.PROCESSDEFINITIONID AS processdefinitionid, + dm.TYPEDEPT AS typedept, + dm.CATEGORY AS category from S_DEPARTMENT_T dm,S_DEPARTMENTCHILD_T dmc where dm.ID = dmc.CHILDID and dmc.PARENTID = #{id} ORDER BY dm.SORTING DESC diff --git a/jyjz-system/jyjz-system-admin/src/main/resources/mapper/admin/UserMapper.xml b/jyjz-system/jyjz-system-admin/src/main/resources/mapper/admin/UserMapper.xml index 249729cf..e5fe6efc 100644 --- a/jyjz-system/jyjz-system-admin/src/main/resources/mapper/admin/UserMapper.xml +++ b/jyjz-system/jyjz-system-admin/src/main/resources/mapper/admin/UserMapper.xml @@ -107,7 +107,7 @@ u.UPDATEUSER AS updateuser, u.UPDATETIME AS updatetime, u.PSDUPDATETIME AS psdupdatetime - from S_USER_T u RIGHT JOIN S_USEROBJECT_T uo ON uo.USERID = u.ID + from S_USER_T u ${ew.customSqlSegment} diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/flowable/config/GlobalEntityInitListener.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/flowable/config/GlobalEntityInitListener.java index 6548d596..1420ce34 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/flowable/config/GlobalEntityInitListener.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/flowable/config/GlobalEntityInitListener.java @@ -1,5 +1,7 @@ package cn.jyjz.flowable.config; +import cn.jyjz.xiaoyao.admin.dataobject.Department; +import cn.jyjz.xiaoyao.admin.service.DepartmentService; import cn.jyjz.xiaoyao.oa.from.dataobject.Category; import cn.jyjz.xiaoyao.oa.from.service.CategoryService; import org.flowable.common.engine.api.delegate.event.FlowableEvent; @@ -21,11 +23,13 @@ public class GlobalEntityInitListener implements FlowableEventListener { @Autowired private CategoryService categoryService; + @Autowired + private DepartmentService departmentService; @Override public void onEvent(FlowableEvent flowableEvent) { FlowableEventType type = flowableEvent.getType(); FlowableEntityEventImpl flowableEntityEvent = (FlowableEntityEventImpl) flowableEvent; - + Object object = flowableEntityEvent.getEntity(); if(object instanceof ProcessDefinitionEntity){ ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity)object; @@ -37,9 +41,17 @@ public class GlobalEntityInitListener implements FlowableEventListener { categoryService.updateById(category); } - } - + + //更新机构与审批流的关联,使用“业务主体编码”与流程的“目标命名空间”字段保持一致 + List departmentList = departmentService.listByDeptNo(processDefinitionEntity.getCategory()); + if(null != departmentList && !departmentList.isEmpty()){ + for (Department department:departmentList){ + department.setServicename("taskchildPictureService"); + department.setProcessdefinitionid(processDefinitionEntity.getId()); + departmentService.updateDept(department); + } + } } }