diff --git a/src/main/java/com/lz/common/utils/Constant.java b/src/main/java/com/lz/common/utils/Constant.java index 9dd512c3..5bf4b6e2 100644 --- a/src/main/java/com/lz/common/utils/Constant.java +++ b/src/main/java/com/lz/common/utils/Constant.java @@ -153,6 +153,7 @@ public class Constant { public static final String INVELOMENT_TYPE_ONLINE = "online"; public static final String INVELOMENT_TYPE_PRE_ENV = "preissue"; public static final String FORMAL_APP_IDENTIFY = "www"; + public static final String ME = "ME"; } diff --git a/src/main/java/com/lz/modules/app/controller/ResultRecordController.java b/src/main/java/com/lz/modules/app/controller/ResultRecordController.java index 6dc2df41..967ace03 100644 --- a/src/main/java/com/lz/modules/app/controller/ResultRecordController.java +++ b/src/main/java/com/lz/modules/app/controller/ResultRecordController.java @@ -1,5 +1,6 @@ package com.lz.modules.app.controller; +import com.alibaba.fastjson.JSON; import com.lz.common.utils.*; import com.lz.modules.app.dto.DepartmentsDto; import com.lz.modules.app.dto.StaffDepartmentDto; @@ -10,16 +11,11 @@ import com.lz.modules.app.resp.ResultDetailResp; import com.lz.modules.app.service.DepartmentsService; import com.lz.modules.app.service.DepartmentsStaffRelateService; import com.lz.modules.app.service.StaffService; -import com.lz.modules.flow.entity.Flow; -import com.lz.modules.flow.entity.FlowDepartment; -import com.lz.modules.flow.entity.FlowRelation; -import com.lz.modules.flow.entity.RecordAuth; +import com.lz.modules.flow.entity.*; import com.lz.modules.flow.model.Auth; +import com.lz.modules.flow.model.StaffRoleDto; import com.lz.modules.flow.req.ResultDetailReq; -import com.lz.modules.flow.service.FlowDepartmentService; -import com.lz.modules.flow.service.FlowRelationService; -import com.lz.modules.flow.service.FlowService; -import com.lz.modules.flow.service.RecordAuthService; +import com.lz.modules.flow.service.*; import com.lz.modules.sys.controller.AbstractController; import com.lz.modules.sys.entity.SysUserEntity; import com.lz.modules.sys.entity.app.ResultDetail; @@ -79,6 +75,15 @@ public class ResultRecordController extends AbstractController { @Autowired private FlowService flowService; + @Autowired + private FlowRecordService flowRecordService; + + @Autowired + private StaffRoleService staffRoleService; + + @Autowired + private StaffRoleDepartmentService staffRoleDepartmentService; + /** * 列表 */ @@ -101,11 +106,13 @@ public class ResultRecordController extends AbstractController { @RequestMapping("/getStaffResultDetail") public R getStaffResultDetail(ResultRecordReq req) { + int firstRowspan = 0; int secondRowspan = 0; int threeRowspan = 0; int fourRowspan = 0; int fiveRowspan = 0; + int recordType = req.getRecordType(); ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId()); StaffEntity staffEntity = staffService.getById(resultRecord != null ? resultRecord.getStaffId() : getUserId()); @@ -130,7 +137,7 @@ public class ResultRecordController extends AbstractController { if (resultRecordOld != null) { Long recordId = resultRecordOld.getId(); resultRecordOld.setId(null); - resultRecordOld.setInitRoleId(8l); + resultRecordOld.setFlowStaffIdRole(initRole(resultRecordOld.getStaffId(), 8l)); resultRecordService.insertResultRecord(resultRecordOld); resultRecordNew = resultRecordOld; List resultDetails = resultDetailService.selectByRecordId(recordId); @@ -142,18 +149,17 @@ public class ResultRecordController extends AbstractController { resultDetailService.insertResultDetail(resultDetail); } } - } else { - resultRecordNew = createResultRecord(2); + resultRecordNew = createResultRecord(getUserId(),2); } - //保存文件价值观 recordType = 3; insertWenHuaJiaZhiGua("做人:相信、包容、担当", resultRecordNew.getId(), getUserId()); insertWenHuaJiaZhiGua("做事:用户第一、求真、极致", resultRecordNew.getId(), getUserId()); recordResultId = resultRecordNew.getId(); } else if (resultRecord != null) { - listAuth = recordAuthService.selectAuthInfo(resultRecord.getInitRoleId()); + Map staffRoleMap = recordAuthService.selectRoleIdByStaffRoleInfo(resultRecord.getFlowStaffIdRole()); + listAuth = recordAuthService.selectAuthInfo(staffRoleMap.get(getUserId())); auth = getAuth(listAuth); } List resultDetails = resultDetailService.selectByRecordId(recordResultId); @@ -235,14 +241,24 @@ public class ResultRecordController extends AbstractController { .put("recordResultId", recordResultId); } + + public String initRole(Long staffId,Long roleId){ + List staffRoles = new ArrayList<>(); + StaffRoleDto staffRole = new StaffRoleDto() ; + staffRole.setStaffId(staffId); + staffRole.setRoleId(roleId); + staffRoles.add(staffRole); + return JSON.toJSONString(staffRoles); + } + @RequestMapping("/commitApproval") public R commitApproval(ResultRecordReq req) { ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId()); StaffEntity staffEntity = staffService.selectStaffById(resultRecord.getStaffId()); - FlowDepartment flowDepartment = flowDepartmentService.selectByStaffId(staffEntity.getId()); - Long flowId = flowDepartment.getSelfFlowId(); // 表示是部门主管自己 - if(flowDepartment == null){ - DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(staffEntity.getId()); + FlowDepartment flowDepartment = flowDepartmentService.selectByStaffId(staffEntity.getId()); + Long flowId =flowDepartment !=null ? flowDepartment.getSelfFlowId() : 0l; // 表示是部门主管自己 + DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(staffEntity.getId()); + if (flowDepartment == null) { DepartmentsStaffRelateEntity leader = departmentsStaffRelateService.selectLeaderByDepartmentId(departmentsStaffRelateEntity.getDepartmentId()); flowDepartment = flowDepartmentService.selectByStaffId(leader.getId()); flowId = flowDepartment.getChildFlowId();//表示是部门下的普通员工 @@ -255,18 +271,96 @@ public class ResultRecordController extends AbstractController { } } List flowRelations = flowRelationService.selectFlowRelationAll(); - Map staffEntityMap = list.stream().collect(Collectors.toMap(FlowDepartment::getDepartmentLevel, p -> p)); - // approvalList = [ONE_D,TWO_D,HR,BOSS] + Map staffEntityMap = list.stream().collect(Collectors.toMap(FlowDepartment::getDepartmentLevel, p -> p)); + // approvalList = [ME,ONE_D,TWO_D,HR,BOSS] List approvalList = new ArrayList<>(); - for(FlowRelation flowRelation : flowRelations){ - if(staffEntityMap.get(flowRelation.getChild()) != null || flowRelation.getCanReplace() == 0){ + approvalList.add("ME"); + for (FlowRelation flowRelation : flowRelations) { + if (staffEntityMap.get(flowRelation.getChild()) != null || flowRelation.getCanReplace() == 0) { approvalList.add(flowRelation.getChild()); } } List flows = flowService.selectByFlowId(flowId); + FlowRecord lastFlowRecord = flowRecordService.selectLastFlowRecordByRecordId(req.getRecordResultId()); + + FlowRecord notFlowRecord = flowRecordService.selectNotApprovalStaffIdFlowRecords(resultRecord.getId()); + if (notFlowRecord != null) { + notFlowRecord.setApprovalStaffId(getUserId()); + StaffEntity mySelf = staffService.selectStaffById(resultRecord.getStaffId()); + notFlowRecord.setFlowName(mySelf.getName() + flows.get(notFlowRecord.getFlowIndex() - 1).getOptDesc()); + } + + StaffEntity staff = staffService.selectStaffById(resultRecord.getStaffId()); + FlowRecord flowRecord = new FlowRecord(); + flowRecord.setRecordId(req.getRecordResultId()); + flowRecord.setRecordStaffId(resultRecord.getStaffId()); + flowRecord.setDepartmentId(departmentsStaffRelateEntity.getDepartmentId()); + int flowIndex = lastFlowRecord != null ? lastFlowRecord.getFlowIndex() + 1 : 1; + int index = getDepartmentLevelIndex(flows, flowIndex); + + String departmentLevel = approvalList.get(index); + flowRecord.setDepartmentLevel(departmentLevel); + flowRecord.setFlowIndex(flowIndex); + + StaffEntity approvalStaff = null; + List staffRoleDtos = new ArrayList<>(); + if (Constant.ME.equals(departmentLevel)) { //如果是自己 + approvalStaff = staff; // 是自己进行审批 + StaffRoleDto staffRoleDto = new StaffRoleDto(staff.getId(),flows.get(flowIndex-1).getRoleId()); + staffRoleDtos.add(staffRoleDto); + } else { + FlowDepartment flowD = staffEntityMap.get(departmentLevel); + if (flowD == null) { + List staffRoles = staffRoleService.selectByRole(departmentLevel); + for(StaffRole staffRole: staffRoles ){ + List staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId()); + Map departmentIdMap = departmentsService.selectUserAllDepartmentIds(departmentsStaffRelateEntity.getDepartmentId()); + for (StaffRoleDepartment staffRoleDepartment : staffRoleDepartments) { + String value = departmentIdMap.get(staffRoleDepartment.getDepartmentId()); + if(StringUtil.isNotBlank(value) ){ + StaffRoleDto staffRoleDto = new StaffRoleDto(staffRole.getStaffId(),staffRole.getRecordRoleId()); + staffRoleDtos.add(staffRoleDto); + } + } + } + if(staffRoleDtos.size() == 1 ){ //表示只有一个审批的用户 + approvalStaff = staffService.selectStaffById(staffRoleDtos.get(0).getStaffId()); + } + } else { + approvalStaff = staffService.selectStaffById(flowD.getStaffId()); + StaffRoleDto staffRoleDto = new StaffRoleDto(approvalStaff.getId(),flows.get(flowIndex-1).getRoleId()); + staffRoleDtos.add(staffRoleDto); + } + } + flowRecord.setFlowName((approvalStaff !=null ? approvalStaff.getName() : "")+ flows.get(flowIndex-1).getOptDesc()); + flowRecord.setApprovalStaffId(approvalStaff != null ? approvalStaff.getId() : null); + flowRecord.setApprovalStaffName(approvalStaff !=null ? approvalStaff.getName() : null); + + flowRecordService.insertFlowRecord(flowRecord); + resultRecord.setFlowStaffIdRole(JSON.toJSONString(staffRoleDtos)); + resultRecordService.updateResultRecordById(resultRecord);// 更新用户权限 return R.ok("提交审批成功"); } + public int getDepartmentLevelIndex(List list,int flowIndex) { + List flows = new ArrayList<>(); + for(int i = 0 ;i < flowIndex ;i ++){ + flows.add(list.get(i)); + } + int index = 0; + for (Flow flow : flows) { + String opt = flow.getOpt(); + String opts[] = opt.split(""); + for (String p : opts) { + if ("+".equals(p)) { + index++; + } else { + index--; + } + } + } + return index; + } public void insertWenHuaJiaZhiGua(String target, Long recordId, Long staffId) { ResultDetail wenhua1 = new ResultDetail(); @@ -457,7 +551,7 @@ public class ResultRecordController extends AbstractController { } else { ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordId()); if (resultRecord == null) { - createResultRecord(req.getRecordType()); + createResultRecord(getUserId(), req.getRecordType()); } recordId = resultRecord.getId(); req.setKeyResult(StringUtil.decodeBase64(req.getKeyResult())); @@ -472,14 +566,13 @@ public class ResultRecordController extends AbstractController { return R.ok("保存成功").put("recordId", recordId); } - public ResultRecord createResultRecord(int type) { + public ResultRecord createResultRecord(Long staffId ,int type) { ResultRecord resultRecord = new ResultRecord(); resultRecord.setMonthTime(new Date()); - resultRecord.setCurrentFlowStaffId(getUserId()); if (type == 1) { - resultRecord.setInitRoleId(7l); + resultRecord.setFlowStaffIdRole(initRole(staffId,7l)); } else { - resultRecord.setInitRoleId(8l); + resultRecord.setFlowStaffIdRole(initRole(staffId,8l)); } resultRecord.setStaffId(getUserId()); resultRecord.setStatus(0); @@ -519,4 +612,6 @@ public class ResultRecordController extends AbstractController { return R.ok(); } + + } diff --git a/src/main/java/com/lz/modules/app/dao/DepartmentsDao.java b/src/main/java/com/lz/modules/app/dao/DepartmentsDao.java index 142cfe19..b792bb26 100644 --- a/src/main/java/com/lz/modules/app/dao/DepartmentsDao.java +++ b/src/main/java/com/lz/modules/app/dao/DepartmentsDao.java @@ -1,5 +1,6 @@ package com.lz.modules.app.dao; +import com.lz.modules.app.dto.DepartmentInfos; import com.lz.modules.app.dto.DepartmentsDto; import com.lz.modules.app.dto.StaffDepartmentDto; import com.lz.modules.app.entity.DepartmentsEntity; @@ -39,4 +40,6 @@ public interface DepartmentsDao extends BaseMapper { StaffDepartmentDto selectStaffAllDepartments(@Param("departmentId") String departmentId); int addDepartment(@Param("departments") DepartmentsEntity departments); + + DepartmentInfos selectUserAllDepartmentIds(@Param("departmentId") String departmentId); } diff --git a/src/main/java/com/lz/modules/app/dto/DepartmentInfos.java b/src/main/java/com/lz/modules/app/dto/DepartmentInfos.java new file mode 100644 index 00000000..fad3f271 --- /dev/null +++ b/src/main/java/com/lz/modules/app/dto/DepartmentInfos.java @@ -0,0 +1,18 @@ +package com.lz.modules.app.dto; + +import lombok.Data; + +@Data +public class DepartmentInfos { + private String dd1; + private String dn1; + private String dd2; + private String dn2; + private String dd3; + private String dn3; + private String dd4; + private String dn4; + private String dd5; + private String dn5; + +} diff --git a/src/main/java/com/lz/modules/app/service/DepartmentsService.java b/src/main/java/com/lz/modules/app/service/DepartmentsService.java index 52829f36..b235576c 100644 --- a/src/main/java/com/lz/modules/app/service/DepartmentsService.java +++ b/src/main/java/com/lz/modules/app/service/DepartmentsService.java @@ -38,5 +38,7 @@ public interface DepartmentsService extends IService { StaffDepartmentDto selectStaffAllDepartments(String departmentId); void updateDepartmentInfo(DepartmentInfosBo departmentInfosBo); + + Map selectUserAllDepartmentIds(String departmentId); } diff --git a/src/main/java/com/lz/modules/app/service/impl/DepartmentsServiceImpl.java b/src/main/java/com/lz/modules/app/service/impl/DepartmentsServiceImpl.java index 3e9dc04b..9b77cac1 100644 --- a/src/main/java/com/lz/modules/app/service/impl/DepartmentsServiceImpl.java +++ b/src/main/java/com/lz/modules/app/service/impl/DepartmentsServiceImpl.java @@ -7,8 +7,9 @@ import com.google.common.collect.Lists; import com.lz.common.utils.PageUtils; import com.lz.common.utils.Query; import com.lz.common.utils.StringUtil; -import com.lz.modules.app.dto.DepartmentsDto; import com.lz.modules.app.dao.DepartmentsDao; +import com.lz.modules.app.dto.DepartmentInfos; +import com.lz.modules.app.dto.DepartmentsDto; import com.lz.modules.app.dto.StaffDepartmentDto; import com.lz.modules.app.entity.DepartmentsEntity; import com.lz.modules.app.service.DepartmentsService; @@ -17,6 +18,7 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -142,5 +144,27 @@ public class DepartmentsServiceImpl extends ServiceImpl selectUserAllDepartmentIds(String departmentId) { + DepartmentInfos departmentInfos = departmentsDao.selectUserAllDepartmentIds(departmentId); + Map map = new HashMap<>(); + if (StringUtil.isNotBlank(departmentInfos.getDd1())) { + map.put(departmentInfos.getDd1(), departmentInfos.getDn1()); + } + if (StringUtil.isNotBlank(departmentInfos.getDd2())) { + map.put(departmentInfos.getDd2(), departmentInfos.getDn2()); + } + if (StringUtil.isNotBlank(departmentInfos.getDd3())) { + map.put(departmentInfos.getDd3(), departmentInfos.getDn3()); + } + if (StringUtil.isNotBlank(departmentInfos.getDd4())) { + map.put(departmentInfos.getDd4(), departmentInfos.getDn4()); + } + if (StringUtil.isNotBlank(departmentInfos.getDd5())) { + map.put(departmentInfos.getDd5(), departmentInfos.getDn5()); + } + return map; + } + } diff --git a/src/main/java/com/lz/modules/flow/dao/FlowRecordMapper.java b/src/main/java/com/lz/modules/flow/dao/FlowRecordMapper.java index 7e34085b..1d814b4a 100644 --- a/src/main/java/com/lz/modules/flow/dao/FlowRecordMapper.java +++ b/src/main/java/com/lz/modules/flow/dao/FlowRecordMapper.java @@ -30,4 +30,7 @@ public interface FlowRecordMapper extends BaseMapper { int deleteFlowRecordById(@Param("id")Long id); + FlowRecord selectLastFlowRecordByRecordId(@Param("recordId") Long recordId); + + FlowRecord selectNotApprovalStaffIdFlowRecords(@Param("recordId") Long recordId); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/dao/StaffRoleDepartmentMapper.java b/src/main/java/com/lz/modules/flow/dao/StaffRoleDepartmentMapper.java index 93cea6c5..2986d417 100644 --- a/src/main/java/com/lz/modules/flow/dao/StaffRoleDepartmentMapper.java +++ b/src/main/java/com/lz/modules/flow/dao/StaffRoleDepartmentMapper.java @@ -11,6 +11,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.lz.modules.flow.entity.StaffRoleDepartment; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; + +import java.util.List; + @Mapper public interface StaffRoleDepartmentMapper extends BaseMapper { @@ -30,4 +33,5 @@ public interface StaffRoleDepartmentMapper extends BaseMapper selectStaffRoleDepartmentByStaffRoleId(@Param("staffRoleId") Long staffRoleId); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/dao/StaffRoleMapper.java b/src/main/java/com/lz/modules/flow/dao/StaffRoleMapper.java index e9734d3e..4fc0e08b 100644 --- a/src/main/java/com/lz/modules/flow/dao/StaffRoleMapper.java +++ b/src/main/java/com/lz/modules/flow/dao/StaffRoleMapper.java @@ -11,6 +11,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.lz.modules.flow.entity.StaffRole; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; + +import java.util.List; + @Mapper public interface StaffRoleMapper extends BaseMapper { @@ -31,4 +34,6 @@ public interface StaffRoleMapper extends BaseMapper { StaffRole selectByStaffId(@Param("staffId") Long staffId); + + List selectByRole(@Param("role") String role); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/entity/FlowDepartment.java b/src/main/java/com/lz/modules/flow/entity/FlowDepartment.java index 788cfa52..73cdd977 100644 --- a/src/main/java/com/lz/modules/flow/entity/FlowDepartment.java +++ b/src/main/java/com/lz/modules/flow/entity/FlowDepartment.java @@ -9,7 +9,7 @@ import java.util.Date; * 菜单权限表 *

*流转关系表 * @author quyixiao -* @since 2020-08-19 +* @since 2020-08-20 */ @Data @@ -25,7 +25,7 @@ public class FlowDepartment implements java.io.Serializable { //最后修改时间 private Date gmtModified; //员工 id - private Long taffId; + private Long staffId; //自己部门小伙伴 走的 流程id private Long childFlowId; //自己走的流程 id @@ -98,15 +98,15 @@ public class FlowDepartment implements java.io.Serializable { * 员工 id * @return */ - public Long getTaffId() { - return taffId; + public Long getStaffId() { + return staffId; } /** * 员工 id - * @param taffId + * @param staffId */ - public void setTaffId(Long taffId) { - this.taffId = taffId; + public void setStaffId(Long staffId) { + this.staffId = staffId; } /** @@ -176,7 +176,7 @@ public class FlowDepartment implements java.io.Serializable { ",isDelete=" + isDelete + ",gmtCreate=" + gmtCreate + ",gmtModified=" + gmtModified + - ",taffId=" + taffId + + ",staffId=" + staffId + ",childFlowId=" + childFlowId + ",selfFlowId=" + selfFlowId + ",departmentLevel=" + departmentLevel + diff --git a/src/main/java/com/lz/modules/flow/entity/FlowRecord.java b/src/main/java/com/lz/modules/flow/entity/FlowRecord.java index a3bdf9dc..35d765dc 100644 --- a/src/main/java/com/lz/modules/flow/entity/FlowRecord.java +++ b/src/main/java/com/lz/modules/flow/entity/FlowRecord.java @@ -9,7 +9,7 @@ import java.util.Date; * 菜单权限表 *

*流转记录表 * @author quyixiao -* @since 2020-08-18 +* @since 2020-08-20 */ @Data @@ -25,7 +25,7 @@ public class FlowRecord implements java.io.Serializable { //最后修改时间 private Date gmtModified; //部门 id - private Long departmentId; + private String departmentId; // private String departmentLevel; //记录 id @@ -34,8 +34,6 @@ public class FlowRecord implements java.io.Serializable { private Long approvalStaffId; //审批员工名称 private String approvalStaffName; - //角色 id - private Long roleId; //流程名称 private String flowName; //record 表中的员工 id @@ -44,8 +42,8 @@ public class FlowRecord implements java.io.Serializable { private Long flowId; //流程中的第几个步骤 private Integer flowIndex; - //在人员关系中的第几步 - private Integer relationIndex; + //0表示正常状态,1 表示被驳回无用的流程 + private Integer status; /** * * @return @@ -110,14 +108,14 @@ public class FlowRecord implements java.io.Serializable { * 部门 id * @return */ - public Long getDepartmentId() { + public String getDepartmentId() { return departmentId; } /** * 部门 id * @param departmentId */ - public void setDepartmentId(Long departmentId) { + public void setDepartmentId(String departmentId) { this.departmentId = departmentId; } @@ -181,21 +179,6 @@ public class FlowRecord implements java.io.Serializable { this.approvalStaffName = approvalStaffName; } - /** - * 角色 id - * @return - */ - public Long getRoleId() { - return roleId; - } - /** - * 角色 id - * @param roleId - */ - public void setRoleId(Long roleId) { - this.roleId = roleId; - } - /** * 流程名称 * @return @@ -257,18 +240,18 @@ public class FlowRecord implements java.io.Serializable { } /** - * 在人员关系中的第几步 + * 0表示正常状态,1 表示被驳回无用的流程 * @return */ - public Integer getRelationIndex() { - return relationIndex; + public Integer getStatus() { + return status; } /** - * 在人员关系中的第几步 - * @param relationIndex + * 0表示正常状态,1 表示被驳回无用的流程 + * @param status */ - public void setRelationIndex(Integer relationIndex) { - this.relationIndex = relationIndex; + public void setStatus(Integer status) { + this.status = status; } @Override @@ -283,12 +266,11 @@ public class FlowRecord implements java.io.Serializable { ",recordId=" + recordId + ",approvalStaffId=" + approvalStaffId + ",approvalStaffName=" + approvalStaffName + - ",roleId=" + roleId + ",flowName=" + flowName + ",recordStaffId=" + recordStaffId + ",flowId=" + flowId + ",flowIndex=" + flowIndex + - ",relationIndex=" + relationIndex + + ",status=" + status + "}"; } } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/entity/StaffRole.java b/src/main/java/com/lz/modules/flow/entity/StaffRole.java index 79508d20..09d73476 100644 --- a/src/main/java/com/lz/modules/flow/entity/StaffRole.java +++ b/src/main/java/com/lz/modules/flow/entity/StaffRole.java @@ -9,7 +9,7 @@ import java.util.Date; * 菜单权限表 *

*流转关系表 * @author quyixiao -* @since 2020-08-18 +* @since 2020-08-20 */ @Data @@ -28,6 +28,8 @@ public class StaffRole implements java.io.Serializable { private Long staffId; //角色 private String role; + //角色 id + private Long recordRoleId; /** * * @return @@ -118,6 +120,21 @@ public class StaffRole implements java.io.Serializable { this.role = role; } + /** + * 角色 id + * @return + */ + public Long getRecordRoleId() { + return recordRoleId; + } + /** + * 角色 id + * @param recordRoleId + */ + public void setRecordRoleId(Long recordRoleId) { + this.recordRoleId = recordRoleId; + } + @Override public String toString() { return "StaffRole{" + @@ -127,6 +144,7 @@ public class StaffRole implements java.io.Serializable { ",gmtModified=" + gmtModified + ",staffId=" + staffId + ",role=" + role + + ",recordRoleId=" + recordRoleId + "}"; } } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/model/StaffRoleDto.java b/src/main/java/com/lz/modules/flow/model/StaffRoleDto.java new file mode 100644 index 00000000..326b255b --- /dev/null +++ b/src/main/java/com/lz/modules/flow/model/StaffRoleDto.java @@ -0,0 +1,19 @@ +package com.lz.modules.flow.model; + +import lombok.Data; + +@Data +public class StaffRoleDto { + private Long staffId; + private Long roleId; + + public StaffRoleDto() { + } + + public StaffRoleDto(Long staffId, Long roleId) { + this.staffId = staffId; + this.roleId = roleId; + } + + +} diff --git a/src/main/java/com/lz/modules/flow/service/FlowRecordService.java b/src/main/java/com/lz/modules/flow/service/FlowRecordService.java index 056fb5a9..5611fc00 100644 --- a/src/main/java/com/lz/modules/flow/service/FlowRecordService.java +++ b/src/main/java/com/lz/modules/flow/service/FlowRecordService.java @@ -30,5 +30,7 @@ public interface FlowRecordService extends IService { int deleteFlowRecordById(Long id); + FlowRecord selectLastFlowRecordByRecordId(Long recordResultId); + FlowRecord selectNotApprovalStaffIdFlowRecords(Long recordId); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/service/RecordAuthService.java b/src/main/java/com/lz/modules/flow/service/RecordAuthService.java index 25c0b576..4e87d5f1 100644 --- a/src/main/java/com/lz/modules/flow/service/RecordAuthService.java +++ b/src/main/java/com/lz/modules/flow/service/RecordAuthService.java @@ -34,4 +34,6 @@ public interface RecordAuthService extends IService { List selectAuthInfo(Long roldId); + + Map selectRoleIdByStaffRoleInfo(String flowStaffIdRole); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/service/StaffRoleDepartmentService.java b/src/main/java/com/lz/modules/flow/service/StaffRoleDepartmentService.java index 5cc53085..8a04ae95 100644 --- a/src/main/java/com/lz/modules/flow/service/StaffRoleDepartmentService.java +++ b/src/main/java/com/lz/modules/flow/service/StaffRoleDepartmentService.java @@ -3,6 +3,8 @@ package com.lz.modules.flow.service; import com.baomidou.mybatisplus.extension.service.IService; import com.lz.modules.flow.entity.StaffRoleDepartment; +import java.util.List; + /** *

* 流转关系表 服务类 @@ -30,4 +32,5 @@ public interface StaffRoleDepartmentService extends IService selectStaffRoleDepartmentByStaffRoleId(Long staffRoleId); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/service/StaffRoleService.java b/src/main/java/com/lz/modules/flow/service/StaffRoleService.java index 249945d5..552413ee 100644 --- a/src/main/java/com/lz/modules/flow/service/StaffRoleService.java +++ b/src/main/java/com/lz/modules/flow/service/StaffRoleService.java @@ -3,6 +3,8 @@ package com.lz.modules.flow.service; import com.baomidou.mybatisplus.extension.service.IService; import com.lz.modules.flow.entity.StaffRole; +import java.util.List; + /** *

* 流转关系表 服务类 @@ -31,4 +33,6 @@ public interface StaffRoleService extends IService { StaffRole selectByStaffId(Long staffId); + + List selectByRole(String departmentLevel); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/service/impl/FlowRecordServiceImpl.java b/src/main/java/com/lz/modules/flow/service/impl/FlowRecordServiceImpl.java index ccbda6ec..af24e959 100644 --- a/src/main/java/com/lz/modules/flow/service/impl/FlowRecordServiceImpl.java +++ b/src/main/java/com/lz/modules/flow/service/impl/FlowRecordServiceImpl.java @@ -51,14 +51,20 @@ public class FlowRecordServiceImpl extends ServiceImpl @@ -64,5 +70,17 @@ public class RecordAuthServiceImpl extends ServiceImpl selectRoleIdByStaffRoleInfo(String flowStaffIdRole) { + Map staffEntityMap = new HashMap<>(); + if (StringUtil.isNotBlank(flowStaffIdRole)) { + List list = JSONObject.parseArray(flowStaffIdRole, StaffRoleDto.class); + if (CollectionUtils.isNotEmpty(list)) { + staffEntityMap = list.stream().collect(Collectors.toMap(StaffRoleDto::getStaffId, StaffRoleDto::getRole)); + } + } + return staffEntityMap; + } + } diff --git a/src/main/java/com/lz/modules/flow/service/impl/StaffRoleDepartmentServiceImpl.java b/src/main/java/com/lz/modules/flow/service/impl/StaffRoleDepartmentServiceImpl.java index dcb7d7cd..227d8dcb 100644 --- a/src/main/java/com/lz/modules/flow/service/impl/StaffRoleDepartmentServiceImpl.java +++ b/src/main/java/com/lz/modules/flow/service/impl/StaffRoleDepartmentServiceImpl.java @@ -7,6 +7,8 @@ import com.lz.modules.flow.service.StaffRoleDepartmentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** *

* 流转关系表 服务类 @@ -58,8 +60,10 @@ public class StaffRoleDepartmentServiceImpl extends ServiceImpl selectStaffRoleDepartmentByStaffRoleId(Long staffRoleId) { + return staffRoleDepartmentMapper.selectStaffRoleDepartmentByStaffRoleId(staffRoleId); + } } diff --git a/src/main/java/com/lz/modules/flow/service/impl/StaffRoleServiceImpl.java b/src/main/java/com/lz/modules/flow/service/impl/StaffRoleServiceImpl.java index 30ad54db..0215080a 100644 --- a/src/main/java/com/lz/modules/flow/service/impl/StaffRoleServiceImpl.java +++ b/src/main/java/com/lz/modules/flow/service/impl/StaffRoleServiceImpl.java @@ -7,6 +7,8 @@ import com.lz.modules.flow.service.StaffRoleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** *

* 流转关系表 服务类 @@ -63,5 +65,10 @@ public class StaffRoleServiceImpl extends ServiceImpl selectByRole(String role) { + return staffRoleMapper.selectByRole(role); + } + } diff --git a/src/main/java/com/lz/modules/sys/entity/app/ResultRecord.java b/src/main/java/com/lz/modules/sys/entity/app/ResultRecord.java index 8e9f1aea..eb7f5813 100644 --- a/src/main/java/com/lz/modules/sys/entity/app/ResultRecord.java +++ b/src/main/java/com/lz/modules/sys/entity/app/ResultRecord.java @@ -11,7 +11,7 @@ import java.util.Date; * 菜单权限表 *

*业绩记录表 * @author quyixiao -* @since 2020-08-18 +* @since 2020-08-20 */ @Data @@ -40,10 +40,8 @@ public class ResultRecord implements java.io.Serializable { private Long staffId; //类型 ,1 表示提交目标,2 表示提交结果 private Integer type; - //在新建时的角色 id - private Long initRoleId; //当前审批流转所在员工 id - private Long currentFlowStaffId; + private String flowStaffIdRole; /** * * @return @@ -209,34 +207,19 @@ public class ResultRecord implements java.io.Serializable { this.type = type; } - /** - * 在新建时的角色 id - * @return - */ - public Long getInitRoleId() { - return initRoleId; - } - /** - * 在新建时的角色 id - * @param initRoleId - */ - public void setInitRoleId(Long initRoleId) { - this.initRoleId = initRoleId; - } - /** * 当前审批流转所在员工 id * @return */ - public Long getCurrentFlowStaffId() { - return currentFlowStaffId; + public String getFlowStaffIdRole() { + return flowStaffIdRole; } /** * 当前审批流转所在员工 id - * @param currentFlowStaffId + * @param flowStaffIdRole */ - public void setCurrentFlowStaffId(Long currentFlowStaffId) { - this.currentFlowStaffId = currentFlowStaffId; + public void setFlowStaffIdRole(String flowStaffIdRole) { + this.flowStaffIdRole = flowStaffIdRole; } @Override @@ -253,8 +236,7 @@ public class ResultRecord implements java.io.Serializable { ",remark=" + remark + ",staffId=" + staffId + ",type=" + type + - ",initRoleId=" + initRoleId + - ",currentFlowStaffId=" + currentFlowStaffId + + ",flowStaffIdRole=" + flowStaffIdRole + "}"; } } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/sys/service/app/impl/ResultRecordServiceImpl.java b/src/main/java/com/lz/modules/sys/service/app/impl/ResultRecordServiceImpl.java index bf8240ba..0bdc6ae5 100644 --- a/src/main/java/com/lz/modules/sys/service/app/impl/ResultRecordServiceImpl.java +++ b/src/main/java/com/lz/modules/sys/service/app/impl/ResultRecordServiceImpl.java @@ -97,6 +97,7 @@ public class ResultRecordServiceImpl extends ServiceImpl> departmentMap = null; + if(employeesDto == null || employeesDto.getExpire() < new Date().getTime()){ departmentMap = getStringListMap(tDepartments); Date expire = DateUtils.addMinute(new Date(),30); diff --git a/src/main/resources/mapper/app/ResultRecordMapper.xml b/src/main/resources/mapper/app/ResultRecordMapper.xml index 2aca7878..c6b540ab 100644 --- a/src/main/resources/mapper/app/ResultRecordMapper.xml +++ b/src/main/resources/mapper/app/ResultRecordMapper.xml @@ -15,16 +15,18 @@ - - + - id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, month_time AS monthTime, status AS status, last_score AS lastScore, all_score AS allScore, remark AS remark, staff_id AS staffId, type AS type, init_role_id AS initRoleId, current_flow_staff_id AS currentFlowStaffId + id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, month_time AS monthTime, status AS status, last_score AS lastScore, all_score AS allScore, remark AS remark, staff_id AS staffId, type AS type, flow_staff_id_role AS flowStaffIdRole + + + @@ -39,8 +41,7 @@ remark, staff_id, type, - init_role_id, - current_flow_staff_id, + flow_staff_id_role, is_delete, gmt_create, gmt_modified @@ -52,8 +53,7 @@ #{ remark}, #{ staffId}, #{ type}, - #{ initRoleId}, - #{ currentFlowStaffId}, + #{ flowStaffIdRole}, 0, now(), now() @@ -74,8 +74,7 @@ remark = #{remark}, staff_id = #{staffId}, type = #{type}, - init_role_id = #{initRoleId}, - current_flow_staff_id = #{currentFlowStaffId} + flow_staff_id_role = #{flowStaffIdRole} ,gmt_modified = now() where id = #{id} @@ -95,18 +94,16 @@ remark = #{remark}, staff_id = #{staffId}, type = #{type}, - init_role_id = #{initRoleId}, - current_flow_staff_id = #{currentFlowStaffId} + flow_staff_id_role = #{flowStaffIdRole} ,gmt_modified = now() where id = #{id} - update lz_result_record set is_delete = 1 where id=#{id} limit 1 + update lz_result_record set is_delete = 1 where id=#{id} limit 1 - select * from lz_flow_department where is_delete = 0 and taff_id = #{staffId} limit 1 diff --git a/src/main/resources/mapper/flow/FlowRecordMapper.xml b/src/main/resources/mapper/flow/FlowRecordMapper.xml index 9875db8b..0ca19c0f 100644 --- a/src/main/resources/mapper/flow/FlowRecordMapper.xml +++ b/src/main/resources/mapper/flow/FlowRecordMapper.xml @@ -13,66 +13,63 @@ - - + - id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, department_id AS departmentId, department_level AS departmentLevel, record_id AS recordId, approval_staff_id AS approvalStaffId, approval_staff_name AS approvalStaffName, role_id AS roleId, flow_name AS flowName, record_staff_id AS recordStaffId, flow_id AS flowId, flow_index AS flowIndex, relation_index AS relationIndex + id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, department_id AS departmentId, department_level AS departmentLevel, record_id AS recordId, approval_staff_id AS approvalStaffId, approval_staff_name AS approvalStaffName, flow_name AS flowName, record_staff_id AS recordStaffId, flow_id AS flowId, flow_index AS flowIndex, status AS status insert into lz_flow_record( - department_id, - department_level, - record_id, - approval_staff_id, - approval_staff_name, - role_id, - flow_name, - record_staff_id, - flow_id, - flow_index, - relation_index, - is_delete, - gmt_create, - gmt_modified + department_id, + department_level, + record_id, + approval_staff_id, + approval_staff_name, + flow_name, + record_staff_id, + flow_id, + flow_index, + status, + is_delete, + gmt_create, + gmt_modified )values( - #{ departmentId}, - #{ departmentLevel}, - #{ recordId}, - #{ approvalStaffId}, - #{ approvalStaffName}, - #{ roleId}, - #{ flowName}, - #{ recordStaffId}, - #{ flowId}, - #{ flowIndex}, - #{ relationIndex}, - 0, - now(), - now() + #{ departmentId}, + #{ departmentLevel}, + #{ recordId}, + #{ approvalStaffId}, + #{ approvalStaffName}, + #{ flowName}, + #{ recordStaffId}, + #{ flowId}, + #{ flowIndex}, + #{ status}, + 0, + now(), + now() ) update - lz_flow_record + lz_flow_record is_delete = #{isDelete}, gmt_create = #{gmtCreate}, @@ -81,12 +78,11 @@ record_id = #{recordId}, approval_staff_id = #{approvalStaffId}, approval_staff_name = #{approvalStaffName}, - role_id = #{roleId}, flow_name = #{flowName}, record_staff_id = #{recordStaffId}, flow_id = #{flowId}, flow_index = #{flowIndex}, - relation_index = #{relationIndex} + status = #{status} ,gmt_modified = now() where id = #{id} @@ -95,8 +91,8 @@ update - lz_flow_record - set + lz_flow_record + set is_delete = #{isDelete}, gmt_create = #{gmtCreate}, department_id = #{departmentId}, @@ -104,20 +100,29 @@ record_id = #{recordId}, approval_staff_id = #{approvalStaffId}, approval_staff_name = #{approvalStaffName}, - role_id = #{roleId}, flow_name = #{flowName}, record_staff_id = #{recordStaffId}, flow_id = #{flowId}, flow_index = #{flowIndex}, - relation_index = #{relationIndex} + status = #{status} ,gmt_modified = now() where id = #{id} - update lz_flow_record set is_delete = 1 where id=#{id} limit 1 + update lz_flow_record set is_delete = 1 where id=#{id} limit 1 + + + + + + diff --git a/src/main/resources/mapper/flow/StaffRoleDepartmentMapper.xml b/src/main/resources/mapper/flow/StaffRoleDepartmentMapper.xml index 8cc0acd3..000d5dbd 100644 --- a/src/main/resources/mapper/flow/StaffRoleDepartmentMapper.xml +++ b/src/main/resources/mapper/flow/StaffRoleDepartmentMapper.xml @@ -74,5 +74,13 @@ update lz_staff_role_department set is_delete = 1 where id=#{id} limit 1 + + + + + + diff --git a/src/main/resources/mapper/flow/StaffRoleMapper.xml b/src/main/resources/mapper/flow/StaffRoleMapper.xml index e258a2e9..5851817a 100644 --- a/src/main/resources/mapper/flow/StaffRoleMapper.xml +++ b/src/main/resources/mapper/flow/StaffRoleMapper.xml @@ -10,47 +10,51 @@ + - id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, staff_id AS staffId, role AS role + id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, staff_id AS staffId, role AS role, record_role_id AS recordRoleId insert into lz_staff_role( - staff_id, - role, - is_delete, - gmt_create, - gmt_modified + staff_id, + role, + record_role_id, + is_delete, + gmt_create, + gmt_modified )values( - #{ staffId}, - #{ role}, - 0, - now(), - now() + #{ staffId}, + #{ role}, + #{ recordRoleId}, + 0, + now(), + now() ) update - lz_staff_role + lz_staff_role is_delete = #{isDelete}, gmt_create = #{gmtCreate}, staff_id = #{staffId}, - role = #{role} + role = #{role}, + record_role_id = #{recordRoleId} ,gmt_modified = now() where id = #{id} @@ -59,23 +63,29 @@ update - lz_staff_role - set + lz_staff_role + set is_delete = #{isDelete}, gmt_create = #{gmtCreate}, staff_id = #{staffId}, - role = #{role} + role = #{role}, + record_role_id = #{recordRoleId} ,gmt_modified = now() where id = #{id} - update lz_staff_role set is_delete = 1 where id=#{id} limit 1 + update lz_staff_role set is_delete = 1 where id=#{id} limit 1 + + + diff --git a/src/main/resources/mapper/generator/DepartmentsDao.xml b/src/main/resources/mapper/generator/DepartmentsDao.xml index df137448..8a43c61b 100644 --- a/src/main/resources/mapper/generator/DepartmentsDao.xml +++ b/src/main/resources/mapper/generator/DepartmentsDao.xml @@ -91,6 +91,7 @@ where a.department_id = #{departmentId} + INSERT INTO lz_departments(department_id,department_parent_id,member_count,department_name,chat_id,leader_employee_id,leader_open_id,status) @@ -100,4 +101,19 @@ + + diff --git a/src/test/java/com/lz/mysql/MysqlMain.java b/src/test/java/com/lz/mysql/MysqlMain.java index 25d2366b..b76f4129 100644 --- a/src/test/java/com/lz/mysql/MysqlMain.java +++ b/src/test/java/com/lz/mysql/MysqlMain.java @@ -61,7 +61,8 @@ public class MysqlMain { } List list = new ArrayList(); - list.add(new TablesBean("lz_flow_department")); + list.add(new TablesBean("lz_staff_role")); + List list2 = new ArrayList(); Map map = MysqlUtil2ShowCreateTable.getComments();