提交修改

This commit is contained in:
quyixiao 2020-08-20 19:23:32 +08:00
parent 00ed287025
commit 9b9ed98db6
17 changed files with 254 additions and 137 deletions

View File

@ -106,13 +106,11 @@ public class ResultRecordController extends AbstractController {
@RequestMapping("/getStaffResultDetail") @RequestMapping("/getStaffResultDetail")
public R getStaffResultDetail(ResultRecordReq req) { public R getStaffResultDetail(ResultRecordReq req) {
int firstRowspan = 0; int firstRowspan = 0;
int secondRowspan = 0; int secondRowspan = 0;
int threeRowspan = 0; int threeRowspan = 0;
int fourRowspan = 0; int fourRowspan = 0;
int fiveRowspan = 0; int fiveRowspan = 0;
int recordType = req.getRecordType(); int recordType = req.getRecordType();
ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId()); ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId());
StaffEntity staffEntity = staffService.getById(resultRecord != null ? resultRecord.getStaffId() : getUserId()); StaffEntity staffEntity = staffService.getById(resultRecord != null ? resultRecord.getStaffId() : getUserId());
@ -255,12 +253,13 @@ public class ResultRecordController extends AbstractController {
public R commitApproval(ResultRecordReq req) { public R commitApproval(ResultRecordReq req) {
ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId()); ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId());
StaffEntity staffEntity = staffService.selectStaffById(resultRecord.getStaffId()); StaffEntity staffEntity = staffService.selectStaffById(resultRecord.getStaffId());
StaffEntity mySelf = staffService.selectStaffById(getUserId());
FlowDepartment flowDepartment = flowDepartmentService.selectByStaffId(staffEntity.getId()); FlowDepartment flowDepartment = flowDepartmentService.selectByStaffId(staffEntity.getId());
Long flowId =flowDepartment !=null ? flowDepartment.getSelfFlowId() : 0l; // 表示是部门主管自己 Long flowId = flowDepartment != null ? flowDepartment.getSelfFlowId() : 0l; // 表示是部门主管自己
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(staffEntity.getId());
if (flowDepartment == null) { if (flowDepartment == null) {
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(staffEntity.getId());
DepartmentsStaffRelateEntity leader = departmentsStaffRelateService.selectLeaderByDepartmentId(departmentsStaffRelateEntity.getDepartmentId()); DepartmentsStaffRelateEntity leader = departmentsStaffRelateService.selectLeaderByDepartmentId(departmentsStaffRelateEntity.getDepartmentId());
flowDepartment = flowDepartmentService.selectByStaffId(leader.getId()); flowDepartment = flowDepartmentService.selectByStaffId(leader.getStaffId());
flowId = flowDepartment.getChildFlowId();//表示是部门下的普通员工 flowId = flowDepartment.getChildFlowId();//表示是部门下的普通员工
} }
List<FlowDepartment> list = new ArrayList<>(); List<FlowDepartment> list = new ArrayList<>();
@ -268,6 +267,9 @@ public class ResultRecordController extends AbstractController {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
if (flowDepartment.getParentId() != null && flowDepartment.getParentId() > 0) { if (flowDepartment.getParentId() != null && flowDepartment.getParentId() > 0) {
flowDepartment = flowDepartmentService.selectFlowDepartmentById(flowDepartment.getParentId()); flowDepartment = flowDepartmentService.selectFlowDepartmentById(flowDepartment.getParentId());
list.add(flowDepartment);
} else {
break;
} }
} }
List<FlowRelation> flowRelations = flowRelationService.selectFlowRelationAll(); List<FlowRelation> flowRelations = flowRelationService.selectFlowRelationAll();
@ -280,28 +282,31 @@ public class ResultRecordController extends AbstractController {
approvalList.add(flowRelation.getChild()); approvalList.add(flowRelation.getChild());
} }
} }
List<Flow> flows = flowService.selectByFlowId(flowId); List<Flow> flows = flowService.selectByFlowId(flowId);
FlowRecord lastFlowRecord = flowRecordService.selectLastFlowRecordByRecordId(req.getRecordResultId()); FlowRecord lastFlowRecord = flowRecordService.selectLastFlowRecordByRecordId(req.getRecordResultId());
FlowRecord notFlowRecord = flowRecordService.selectNotApprovalStaffIdFlowRecords(resultRecord.getId()); FlowRecord notFlowRecord = flowRecordService.selectNotApprovalStaffIdFlowRecords(resultRecord.getId());
if (notFlowRecord != null) { if (notFlowRecord != null) {
notFlowRecord.setApprovalStaffId(getUserId()); 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()); StaffEntity staff = staffService.selectStaffById(resultRecord.getStaffId());
int flowIndex = lastFlowRecord != null ? lastFlowRecord.getFlowIndex() + 1 : 1;
int index = getDepartmentLevelIndex(flows, flowIndex);
if (index < 0) { //表示流程己经结束
lastFlowRecord.setFlowName(mySelf.getName() + "-审批通过");
flowRecordService.updateCoverFlowRecordById(lastFlowRecord);
resultRecordService.updateFlowStaffIdRoleToNull(resultRecord.getId());// 更新用户权限
return R.ok("流程审批结束");
}
FlowRecord flowRecord = new FlowRecord(); FlowRecord flowRecord = new FlowRecord();
flowRecord.setRecordId(req.getRecordResultId()); flowRecord.setRecordId(req.getRecordResultId());
flowRecord.setRecordStaffId(resultRecord.getStaffId()); flowRecord.setRecordStaffId(resultRecord.getStaffId());
flowRecord.setDepartmentId(departmentsStaffRelateEntity.getDepartmentId()); flowRecord.setFlowIndex(flowIndex);
int flowIndex = lastFlowRecord != null ? lastFlowRecord.getFlowIndex() + 1 : 1; flowRecord.setFlowId(flowId);
int index = getDepartmentLevelIndex(flows, flowIndex);
String departmentLevel = approvalList.get(index); String departmentLevel = approvalList.get(index);
flowRecord.setDepartmentLevel(departmentLevel); flowRecord.setDepartmentLevel(departmentLevel);
flowRecord.setFlowIndex(flowIndex);
StaffEntity approvalStaff = null; StaffEntity approvalStaff = null;
List<StaffRoleDto> staffRoleDtos = new ArrayList<>(); List<StaffRoleDto> staffRoleDtos = new ArrayList<>();
if (Constant.ME.equals(departmentLevel)) { //如果是自己 if (Constant.ME.equals(departmentLevel)) { //如果是自己
@ -314,11 +319,11 @@ public class ResultRecordController extends AbstractController {
List<StaffRole> staffRoles = staffRoleService.selectByRole(departmentLevel); List<StaffRole> staffRoles = staffRoleService.selectByRole(departmentLevel);
for(StaffRole staffRole: staffRoles ){ for(StaffRole staffRole: staffRoles ){
List<StaffRoleDepartment> staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId()); List<StaffRoleDepartment> staffRoleDepartments = staffRoleDepartmentService.selectStaffRoleDepartmentByStaffRoleId(staffRole.getId());
Map<String, String> departmentIdMap = departmentsService.selectUserAllDepartmentIds(departmentsStaffRelateEntity.getDepartmentId()); Map<String, String> departmentIdMap = departmentsService.selectUserAllDepartmentIds(resultRecord.getDepartmentId());
for (StaffRoleDepartment staffRoleDepartment : staffRoleDepartments) { for (StaffRoleDepartment staffRoleDepartment : staffRoleDepartments) {
String value = departmentIdMap.get(staffRoleDepartment.getDepartmentId()); String value = departmentIdMap.get(staffRoleDepartment.getDepartmentId());
if(StringUtil.isNotBlank(value) ){ if(StringUtil.isNotBlank(value) ){
StaffRoleDto staffRoleDto = new StaffRoleDto(staffRole.getStaffId(),staffRole.getRecordRoleId()); StaffRoleDto staffRoleDto = new StaffRoleDto(staffRole.getStaffId(),staffRole.getRoleId());
staffRoleDtos.add(staffRoleDto); staffRoleDtos.add(staffRoleDto);
} }
} }
@ -328,14 +333,13 @@ public class ResultRecordController extends AbstractController {
} }
} else { } else {
approvalStaff = staffService.selectStaffById(flowD.getStaffId()); approvalStaff = staffService.selectStaffById(flowD.getStaffId());
StaffRoleDto staffRoleDto = new StaffRoleDto(approvalStaff.getId(),flows.get(flowIndex-1).getRoleId()); StaffRoleDto staffRoleDto = new StaffRoleDto(approvalStaff.getId(), flows.get(flowIndex - 1).getRoleId());
staffRoleDtos.add(staffRoleDto); staffRoleDtos.add(staffRoleDto);
} }
} }
flowRecord.setFlowName((approvalStaff !=null ? approvalStaff.getName() : "")+ flows.get(flowIndex-1).getOptDesc()); flowRecord.setFlowName(mySelf.getName() + "-" + flows.get(flowIndex - 1).getOptDesc());
flowRecord.setApprovalStaffId(approvalStaff != null ? approvalStaff.getId() : null); flowRecord.setApprovalStaffId(approvalStaff != null ? approvalStaff.getId() : null);
flowRecord.setApprovalStaffName(approvalStaff !=null ? approvalStaff.getName() : null); flowRecord.setApprovalStaffName(approvalStaff != null ? approvalStaff.getName() : null);
flowRecordService.insertFlowRecord(flowRecord); flowRecordService.insertFlowRecord(flowRecord);
resultRecord.setFlowStaffIdRole(JSON.toJSONString(staffRoleDtos)); resultRecord.setFlowStaffIdRole(JSON.toJSONString(staffRoleDtos));
resultRecordService.updateResultRecordById(resultRecord);// 更新用户权限 resultRecordService.updateResultRecordById(resultRecord);// 更新用户权限
@ -343,6 +347,9 @@ public class ResultRecordController extends AbstractController {
} }
public int getDepartmentLevelIndex(List<Flow> list,int flowIndex) { public int getDepartmentLevelIndex(List<Flow> list,int flowIndex) {
if(flowIndex > list.size()){
return -1 ;
}
List<Flow> flows = new ArrayList<>(); List<Flow> flows = new ArrayList<>();
for(int i = 0 ;i < flowIndex ;i ++){ for(int i = 0 ;i < flowIndex ;i ++){
flows.add(list.get(i)); flows.add(list.get(i));
@ -612,6 +619,4 @@ public class ResultRecordController extends AbstractController {
return R.ok(); return R.ok();
} }
} }

View File

@ -22,8 +22,8 @@ public class ResultRecordReq {
private String name; private String name;
private String remark; private String remark;
private List<Long> departmentStaffIds; private List<String> departmentIds;
private List<Long> staffIds;
private Long recordResultId; private Long recordResultId;
private BigDecimal weight = new BigDecimal(0); private BigDecimal weight = new BigDecimal(0);
private Integer type; private Integer type;
@ -31,4 +31,5 @@ public class ResultRecordReq {
private Integer isSelf = 1; private Integer isSelf = 1;
private Long staffId; private Long staffId;
private Integer recordType; private Integer recordType;
private String departmentLevel ;
} }

View File

@ -35,5 +35,5 @@ public interface StaffRoleMapper extends BaseMapper<StaffRole> {
StaffRole selectByStaffId(@Param("staffId") Long staffId); StaffRole selectByStaffId(@Param("staffId") Long staffId);
List<StaffRole> selectByRole(@Param("role") String role); List<StaffRole> selectByRole(@Param("departmentLevel") String departmentLevel);
} }

View File

@ -24,8 +24,6 @@ public class FlowRecord implements java.io.Serializable {
private Date gmtCreate; private Date gmtCreate;
//最后修改时间 //最后修改时间
private Date gmtModified; private Date gmtModified;
//部门 id
private String departmentId;
// //
private String departmentLevel; private String departmentLevel;
//记录 id //记录 id
@ -104,21 +102,6 @@ public class FlowRecord implements java.io.Serializable {
this.gmtModified = gmtModified; this.gmtModified = gmtModified;
} }
/**
* 部门 id
* @return
*/
public String getDepartmentId() {
return departmentId;
}
/**
* 部门 id
* @param departmentId
*/
public void setDepartmentId(String departmentId) {
this.departmentId = departmentId;
}
/** /**
* *
* @return * @return
@ -261,7 +244,6 @@ public class FlowRecord implements java.io.Serializable {
",isDelete=" + isDelete + ",isDelete=" + isDelete +
",gmtCreate=" + gmtCreate + ",gmtCreate=" + gmtCreate +
",gmtModified=" + gmtModified + ",gmtModified=" + gmtModified +
",departmentId=" + departmentId +
",departmentLevel=" + departmentLevel + ",departmentLevel=" + departmentLevel +
",recordId=" + recordId + ",recordId=" + recordId +
",approvalStaffId=" + approvalStaffId + ",approvalStaffId=" + approvalStaffId +

View File

@ -27,9 +27,9 @@ public class StaffRole implements java.io.Serializable {
//员工 id //员工 id
private Long staffId; private Long staffId;
//角色 //角色
private String role; private String departmentLevel;
//角色 id //角色 id
private Long recordRoleId; private Long roleId;
/** /**
* *
* @return * @return
@ -109,30 +109,30 @@ public class StaffRole implements java.io.Serializable {
* 角色 * 角色
* @return * @return
*/ */
public String getRole() { public String getDepartmentLevel() {
return role; return departmentLevel;
} }
/** /**
* 角色 * 角色
* @param role * @param departmentLevel
*/ */
public void setRole(String role) { public void setDepartmentLevel(String departmentLevel) {
this.role = role; this.departmentLevel = departmentLevel;
} }
/** /**
* 角色 id * 角色 id
* @return * @return
*/ */
public Long getRecordRoleId() { public Long getRoleId() {
return recordRoleId; return roleId;
} }
/** /**
* 角色 id * 角色 id
* @param recordRoleId * @param roleId
*/ */
public void setRecordRoleId(Long recordRoleId) { public void setRoleId(Long roleId) {
this.recordRoleId = recordRoleId; this.roleId = roleId;
} }
@Override @Override
@ -143,8 +143,8 @@ public class StaffRole implements java.io.Serializable {
",gmtCreate=" + gmtCreate + ",gmtCreate=" + gmtCreate +
",gmtModified=" + gmtModified + ",gmtModified=" + gmtModified +
",staffId=" + staffId + ",staffId=" + staffId +
",role=" + role + ",departmentLevel=" + departmentLevel +
",recordRoleId=" + recordRoleId + ",roleId=" + roleId +
"}"; "}";
} }
} }

View File

@ -27,7 +27,7 @@ public class StaffRoleDepartment implements java.io.Serializable {
// //
private Long staffRoleId; private Long staffRoleId;
// //
private Long departmentId; private String departmentId;
/** /**
* *
* @return * @return
@ -107,14 +107,14 @@ public class StaffRoleDepartment implements java.io.Serializable {
* *
* @return * @return
*/ */
public Long getDepartmentId() { public String getDepartmentId() {
return departmentId; return departmentId;
} }
/** /**
* *
* @param departmentId * @param departmentId
*/ */
public void setDepartmentId(Long departmentId) { public void setDepartmentId(String departmentId) {
this.departmentId = departmentId; this.departmentId = departmentId;
} }

View File

@ -0,0 +1,16 @@
package com.lz.modules.flow.model;
import com.lz.modules.sys.entity.app.ResultRecord;
import lombok.Data;
@Data
public class ResultRecordDto extends ResultRecord {
private String departmentLevel;
private String approvalStaffId;
private String approvalStaffName;
private String flowName;
private Integer flowId;
private Integer flowIndex;
}

View File

@ -1,7 +1,11 @@
package com.lz.modules.flow.model; package com.lz.modules.flow.model;
import com.alibaba.fastjson.JSON;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data @Data
public class StaffRoleDto { public class StaffRoleDto {
private Long staffId; private Long staffId;
@ -16,4 +20,11 @@ public class StaffRoleDto {
} }
public static void main(String[] args) {
List<StaffRoleDto> staffRoleDtoList = new ArrayList<>();
//StaffRoleDto staffRoleDto = new StaffRoleDto(314l,6l);
//staffRoleDtoList.add(staffRoleDto);
System.out.println(JSON.toJSONString(staffRoleDtoList));
}
} }

View File

@ -66,9 +66,8 @@ public class StaffRoleServiceImpl extends ServiceImpl<StaffRoleMapper, StaffRole
} }
@Override @Override
public List<StaffRole> selectByRole(String role) { public List<StaffRole> selectByRole(String departmentLevel) {
return staffRoleMapper.selectByRole(role); return staffRoleMapper.selectByRole(departmentLevel);
} }
} }

View File

@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lz.modules.app.req.ResultRecordReq; import com.lz.modules.app.req.ResultRecordReq;
import com.lz.modules.flow.model.ResultRecordDto;
import com.lz.modules.sys.entity.app.ResultRecord; import com.lz.modules.sys.entity.app.ResultRecord;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -43,4 +44,8 @@ public interface ResultRecordMapper extends BaseMapper<ResultRecord> {
List<ResultRecord> selectByConditionTest(ResultRecordReq req); List<ResultRecord> selectByConditionTest(ResultRecordReq req);
ResultRecord selectResultRecordByStaffId(@Param("staffId") Long staffId); ResultRecord selectResultRecordByStaffId(@Param("staffId") Long staffId);
List<ResultRecordDto> selectByConditionByLeader(@Param("page") IPage page, @Param("req") ResultRecordReq params);
void updateFlowStaffIdRoleToNull(@Param("id") Long id);
} }

View File

@ -42,6 +42,12 @@ public class ResultRecord implements java.io.Serializable {
private Integer type; private Integer type;
//当前审批流转所在员工 id //当前审批流转所在员工 id
private String flowStaffIdRole; private String flowStaffIdRole;
//员工所在部门 id
private String departmentId;
//员工所在部门名称
private String departmentName;
//员工姓名
private String staffName;
/** /**
* *
* @return * @return
@ -222,6 +228,55 @@ public class ResultRecord implements java.io.Serializable {
this.flowStaffIdRole = flowStaffIdRole; this.flowStaffIdRole = flowStaffIdRole;
} }
/**
* 员工所在部门 id
* @return
*/
public String getDepartmentId() {
return departmentId;
}
/**
* 员工所在部门 id
*
* @param departmentId
*/
public void setDepartmentId(String departmentId) {
this.departmentId = departmentId;
}
/**
* 员工所在部门名称
*
* @return
*/
public String getDepartmentName() {
return departmentName;
}
/**
* 员工所在部门名称
* @param departmentName
*/
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
/**
* 员工姓名
* @return
*/
public String getStaffName() {
return staffName;
}
/**
* 员工姓名
* @param staffName
*/
public void setStaffName(String staffName) {
this.staffName = staffName;
}
@Override @Override
public String toString() { public String toString() {
return "ResultRecord{" + return "ResultRecord{" +
@ -237,6 +292,9 @@ public class ResultRecord implements java.io.Serializable {
",staffId=" + staffId + ",staffId=" + staffId +
",type=" + type + ",type=" + type +
",flowStaffIdRole=" + flowStaffIdRole + ",flowStaffIdRole=" + flowStaffIdRole +
",departmentId=" + departmentId +
",departmentName=" + departmentName +
",staffName=" + staffName +
"}"; "}";
} }
} }

View File

@ -41,4 +41,6 @@ public interface ResultRecordService extends IService<ResultRecord> {
void deleteBatchIds(List<Long> asList); void deleteBatchIds(List<Long> asList);
ResultRecord selectResultRecordByStaffId(Long userId); ResultRecord selectResultRecordByStaffId(Long userId);
void updateFlowStaffIdRoleToNull(Long id);
} }

View File

@ -1,20 +1,20 @@
package com.lz.modules.sys.service.app.impl; package com.lz.modules.sys.service.app.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lz.common.utils.DateUtils; import com.lz.common.utils.DateUtils;
import com.lz.common.utils.ISelect;
import com.lz.common.utils.PageUtils; import com.lz.common.utils.PageUtils;
import com.lz.common.utils.StringUtil; import com.lz.common.utils.StringUtil;
import com.lz.modules.app.dao.DepartmentsDao; import com.lz.modules.app.dao.DepartmentsDao;
import com.lz.modules.app.dao.DepartmentsStaffRelateDao; import com.lz.modules.app.dao.DepartmentsStaffRelateDao;
import com.lz.modules.app.dto.EmployeesDto; import com.lz.modules.app.dto.EmployeesDto;
import com.lz.modules.app.entity.DepartmentsEntity; import com.lz.modules.app.entity.DepartmentsEntity;
import com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.req.ResultRecordReq; import com.lz.modules.app.req.ResultRecordReq;
import com.lz.modules.app.resp.ResultRecordResp; import com.lz.modules.app.resp.ResultRecordResp;
import com.lz.modules.app.service.StaffService; import com.lz.modules.app.service.StaffService;
import com.lz.modules.flow.entity.FlowDepartment;
import com.lz.modules.flow.entity.StaffRole;
import com.lz.modules.flow.service.FlowDepartmentService;
import com.lz.modules.flow.service.StaffRoleService;
import com.lz.modules.sys.dao.app.ResultRecordMapper; import com.lz.modules.sys.dao.app.ResultRecordMapper;
import com.lz.modules.sys.entity.SysUserEntity; import com.lz.modules.sys.entity.SysUserEntity;
import com.lz.modules.sys.entity.app.ResultRecord; import com.lz.modules.sys.entity.app.ResultRecord;
@ -26,7 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@ -57,6 +56,12 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
@Autowired @Autowired
private StaffService staffService; private StaffService staffService;
@Autowired
private FlowDepartmentService flowDepartmentService;
@Autowired
private StaffRoleService staffRoleService;
@ -90,14 +95,11 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
@Override @Override
public PageUtils queryPage(ResultRecordReq params, SysUserEntity user) { public PageUtils queryPage(ResultRecordReq params, SysUserEntity user) {
List<Long> departmentStaffIds = new ArrayList<>();
List<Long> staffIds = new ArrayList<>();
List<String> departmentIds = new ArrayList<>(); List<String> departmentIds = new ArrayList<>();
List<DepartmentsEntity> tDepartments = departmentsDao.selectAll(); List<DepartmentsEntity> tDepartments = departmentsDao.selectAll();
if (StringUtil.isNotBlank(params.getDepartment1()) || StringUtil.isNotBlank(params.getDepartment2()) if (StringUtil.isNotBlank(params.getDepartment1()) || StringUtil.isNotBlank(params.getDepartment2())
|| StringUtil.isNotBlank(params.getDepartment3())) { || StringUtil.isNotBlank(params.getDepartment3())) {
Map<String,List<DepartmentsEntity>> departmentMap = null; Map<String,List<DepartmentsEntity>> departmentMap = null;
if(employeesDto == null || employeesDto.getExpire() < new Date().getTime()){ if(employeesDto == null || employeesDto.getExpire() < new Date().getTime()){
departmentMap = getStringListMap(tDepartments); departmentMap = getStringListMap(tDepartments);
Date expire = DateUtils.addMinute(new Date(),30); Date expire = DateUtils.addMinute(new Date(),30);
@ -116,53 +118,35 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
getChildIds(departmentIds, params.getDepartment1(), departmentMap); getChildIds(departmentIds, params.getDepartment1(), departmentMap);
} }
} }
params.setDepartmentIds(departmentIds);
if (departmentIds != null && departmentIds.size() > 0) {
List<DepartmentsStaffRelateEntity> departmentsStaffRelateEntities = departmentsStaffRelateDao.selectByDepartmentIds(departmentIds);
if(CollectionUtils.isNotEmpty(departmentsStaffRelateEntities)){
Set<Long> setStaffId = departmentsStaffRelateEntities.stream().map(p->p.getStaffId()).collect(Collectors.toSet());
departmentStaffIds = new ArrayList<>(setStaffId);
}
}
if(StringUtil.isNotBlank(params.getName())){
List<StaffEntity> staffEntities = staffService.selectByName(params.getName());
if(CollectionUtils.isNotEmpty(staffEntities)){
staffIds = staffEntities.stream().map(p->p.getId()).collect(Collectors.toList());
}
}
params.setDepartmentStaffIds(departmentStaffIds);
params.setStaffIds(staffIds);
PageUtils pageUtils = null; PageUtils pageUtils = null;
if(params.getIsSelf() == 1){ // 我的业绩 if(params.getIsSelf() == 1){ // 我的业绩
params.setStaffId(user.getUserId()); params.setStaffId(user.getUserId());
pageUtils = PageUtils.startPage(params.getPage(), params.getLimit() ).doSelect( pageUtils = PageUtils.startPage(params.getPage(), params.getLimit() ).doSelect(
page -> resultRecordMapper.selectByCondition(page, params) page -> resultRecordMapper.selectByCondition(page, params)
); );
}else{ // 我们审批 }else{ // 部门审批
String departmentLevel = "";
FlowDepartment flowDepartment = flowDepartmentService.selectByStaffId(user.getUserId());
if(flowDepartment !=null){
departmentLevel = flowDepartment.getDepartmentLevel();
}else{
StaffRole staffRole = staffRoleService.selectByStaffId(user.getUserId());
departmentLevel= staffRole.getDepartmentLevel();
}
params.setDepartmentLevel(departmentLevel);
pageUtils = PageUtils.startPage(params.getPage(), params.getLimit() ).doSelect( pageUtils = PageUtils.startPage(params.getPage(), params.getLimit() ).doSelect(
page -> resultRecordMapper.selectByCondition(page, params) page -> resultRecordMapper.selectByConditionByLeader(page, params)
); );
} }
List<ResultRecord> resultRecords = pageUtils.getList(); List<ResultRecord> resultRecords = pageUtils.getList();
if(CollectionUtils.isNotEmpty(resultRecords)){ if(CollectionUtils.isNotEmpty(resultRecords)){
List<ResultRecordResp> list = new ArrayList<>(); List<ResultRecordResp> list = new ArrayList<>();
Set<Long> viewStaffIdSet = resultRecords.stream().map(p->p.getStaffId()).collect(Collectors.toSet());
List<Long> viewStaffId = new ArrayList<>(viewStaffIdSet);
List<StaffEntity> staffEntities = staffService.selectByIds(viewStaffId);
List<DepartmentsStaffRelateEntity> staffRelateEntities = departmentsStaffRelateDao.selectByStaffIds(viewStaffId);
Map<Long ,StaffEntity> staffEntityMap = staffEntities.stream().collect(Collectors.toMap(StaffEntity::getId, p -> p));
Map<String, DepartmentsEntity> departmentsEntityMap = tDepartments.stream().collect(Collectors.toMap(p -> p.getDepartmentId(), p -> p));
Map<Long, DepartmentsStaffRelateEntity> staffRelateEntityMap = staffRelateEntities.stream().collect(Collectors.toMap(p -> p.getStaffId(), p -> p));
for (ResultRecord resultRecord : resultRecords) { for (ResultRecord resultRecord : resultRecords) {
ResultRecordResp resp = new ResultRecordResp(); ResultRecordResp resp = new ResultRecordResp();
BeanUtils.copyProperties(resultRecord, resp); BeanUtils.copyProperties(resultRecord, resp);
resp.setStaffName(staffEntityMap.get(resp.getStaffId()) != null ? staffEntityMap.get(resp.getStaffId()).getName() : "");
DepartmentsStaffRelateEntity relate = staffRelateEntityMap.get(resp.getStaffId());
resp.setDepartmentName(relate != null && departmentsEntityMap.get(relate.getDepartmentId()) != null ?
departmentsEntityMap.get(relate.getDepartmentId()).getDepartmentName() : "");
list.add(resp); list.add(resp);
} }
pageUtils.setList(list); pageUtils.setList(list);
@ -206,5 +190,10 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
return resultRecordMapper.selectResultRecordByStaffId(staffId); return resultRecordMapper.selectResultRecordByStaffId(staffId);
} }
@Override
public void updateFlowStaffIdRoleToNull(Long id) {
resultRecordMapper.updateFlowStaffIdRoleToNull(id);
}
} }

View File

@ -16,12 +16,15 @@
<result column="staff_id" property="staffId"/> <result column="staff_id" property="staffId"/>
<result column="type" property="type"/> <result column="type" property="type"/>
<result column="flow_staff_id_role" property="flowStaffIdRole"/> <result column="flow_staff_id_role" property="flowStaffIdRole"/>
<result column="department_id" property="departmentId"/>
<result column="department_name" property="departmentName"/>
<result column="staff_name" property="staffName"/>
</resultMap> </resultMap>
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
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 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, department_id AS departmentId, department_name AS departmentName, staff_name AS staffName
</sql> </sql>
@ -42,6 +45,9 @@
<if test="staffId != null">staff_id, </if> <if test="staffId != null">staff_id, </if>
<if test="type != null">type, </if> <if test="type != null">type, </if>
<if test="flowStaffIdRole != null">flow_staff_id_role, </if> <if test="flowStaffIdRole != null">flow_staff_id_role, </if>
<if test="departmentId != null">department_id, </if>
<if test="departmentName != null">department_name, </if>
<if test="staffName != null">staff_name, </if>
is_delete, is_delete,
gmt_create, gmt_create,
gmt_modified gmt_modified
@ -54,6 +60,9 @@
<if test="staffId != null">#{ staffId}, </if> <if test="staffId != null">#{ staffId}, </if>
<if test="type != null">#{ type}, </if> <if test="type != null">#{ type}, </if>
<if test="flowStaffIdRole != null">#{ flowStaffIdRole}, </if> <if test="flowStaffIdRole != null">#{ flowStaffIdRole}, </if>
<if test="departmentId != null">#{ departmentId}, </if>
<if test="departmentName != null">#{ departmentName}, </if>
<if test="staffName != null">#{ staffName}, </if>
0, 0,
now(), now(),
now() now()
@ -74,7 +83,10 @@
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="staffId != null">staff_id = #{staffId},</if> <if test="staffId != null">staff_id = #{staffId},</if>
<if test="type != null">type = #{type},</if> <if test="type != null">type = #{type},</if>
<if test="flowStaffIdRole != null">flow_staff_id_role = #{flowStaffIdRole}</if> <if test="flowStaffIdRole != null">flow_staff_id_role = #{flowStaffIdRole},</if>
<if test="departmentId != null">department_id = #{departmentId},</if>
<if test="departmentName != null">department_name = #{departmentName},</if>
<if test="staffName != null">staff_name = #{staffName}</if>
</trim> </trim>
,gmt_modified = now() ,gmt_modified = now()
where id = #{id} where id = #{id}
@ -94,7 +106,10 @@
remark = #{remark}, remark = #{remark},
staff_id = #{staffId}, staff_id = #{staffId},
type = #{type}, type = #{type},
flow_staff_id_role = #{flowStaffIdRole} flow_staff_id_role = #{flowStaffIdRole},
department_id = #{departmentId},
department_name = #{departmentName},
staff_name = #{staffName}
,gmt_modified = now() ,gmt_modified = now()
where id = #{id} where id = #{id}
</update> </update>
@ -104,6 +119,7 @@
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
</update> </update>
<select id="selectByCondition" resultType="com.lz.modules.sys.entity.app.ResultRecord"> <select id="selectByCondition" resultType="com.lz.modules.sys.entity.app.ResultRecord">
select * from lz_result_record where is_delete = 0 select * from lz_result_record where is_delete = 0
<if test="req.monthBeginDate != null and req.monthBeginDate != '' "> <if test="req.monthBeginDate != null and req.monthBeginDate != '' ">
@ -118,19 +134,21 @@
<if test="req.remark != null and req.remark !='' "> <if test="req.remark != null and req.remark !='' ">
AND remark LIKE CONCAT('%',#{req.remark},'%') AND remark LIKE CONCAT('%',#{req.remark},'%')
</if> </if>
<if test="req.departmentStaffIds != null and req.departmentStaffIds.size() > 0 ">
and staff_id in <if test="req.name != null and req.name !='' ">
<foreach collection="req.departmentStaffIds" item="item" index="index" separator="," open="(" close=")"> AND staff_name LIKE CONCAT('%',#{req.name},'%')
#{item} </if>
</foreach>
</if> <if test="req.departmentIds != null and req.departmentIds.size() > 0 ">
<if test="req.staffIds != null and req.staffIds.size() > 0 "> and department_id in
and staff_id in <foreach collection="req.departmentIds" item="item" index="index" separator="," open="(" close=")">
<foreach collection="req.staffIds" item="item" index="index" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="req.staffId != null and req.staffId !='' ">
and staff_id = #{req.staffId} and staff_id = #{req.staffId}
</if>
order by id desc order by id desc
</select> </select>
@ -147,10 +165,48 @@
order by id desc order by id desc
</select> </select>
<select id="selectResultRecordByStaffId" resultType="com.lz.modules.sys.entity.app.ResultRecord"> <select id="selectResultRecordByStaffId" resultType="com.lz.modules.sys.entity.app.ResultRecord">
select * from lz_result_record where is_delete = 0 and staff_id = #{staffId} and type = 1 order by id desc limit 1 select * from lz_result_record where is_delete = 0 and staff_id = #{staffId} and type = 1 order by id desc limit 1
</select> </select>
<select id="selectByConditionByLeader" resultType="com.lz.modules.flow.model.ResultRecordDto">
select * from (
select rd.*,department_level,approval_staff_id,approval_staff_name,flow_name,flow_id,flow_index
from lz_flow_record fr left join lz_result_record rd on fr.record_id= rd.id
where department_level = #{req.departmentLevel}
<if test="req.monthBeginDate != null and req.monthBeginDate != '' ">
AND DATE_FORMAT(rd.month_time, '%Y-%m-%d %H:%i:%S') <![CDATA[ >= ]]> DATE_FORMAT(#{req.monthBeginDate}, '%Y-%m-%d %H:%i:%S')
</if>
<if test="req.monthEndDate != null and req.monthEndDate != '' ">
AND DATE_FORMAT(rd.month_time, '%Y-%m-%d %H:%i:%S') <![CDATA[ >= ]]> DATE_FORMAT(#{req.monthEndDate}, '%Y-%m-%d %H:%i:%S')
</if>
<if test="req.status != null">
and rd.status = #{req.status}
</if>
<if test="req.remark != null and req.remark !='' ">
AND rd.remark LIKE CONCAT('%',#{req.remark},'%')
</if>
<if test="req.name != null and req.name !='' ">
AND rd.staff_name LIKE CONCAT('%',#{req.name},'%')
</if>
<if test="req.departmentIds != null and req.departmentIds.size() > 0 ">
and rd.department_id in
<foreach collection="req.departmentIds" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="req.staffId != null and req.staffId !='' ">
and rd.staff_id = #{req.staffId}
</if>
order by fr.id desc )
a GROUP BY department_id and id
</select>
<update id="updateFlowStaffIdRoleToNull">
update lz_result_record set flow_staff_id_role = '[]' where id = #{id}
</update>
</mapper> </mapper>

View File

@ -8,7 +8,6 @@
<result column="is_delete" property="isDelete"/> <result column="is_delete" property="isDelete"/>
<result column="gmt_create" property="gmtCreate"/> <result column="gmt_create" property="gmtCreate"/>
<result column="gmt_modified" property="gmtModified"/> <result column="gmt_modified" property="gmtModified"/>
<result column="department_id" property="departmentId"/>
<result column="department_level" property="departmentLevel"/> <result column="department_level" property="departmentLevel"/>
<result column="record_id" property="recordId"/> <result column="record_id" property="recordId"/>
<result column="approval_staff_id" property="approvalStaffId"/> <result column="approval_staff_id" property="approvalStaffId"/>
@ -23,20 +22,15 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
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 id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, 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
</sql> </sql>
<select id="selectFlowRecordById" resultType="FlowRecord" > <select id="selectFlowRecordById" resultType="FlowRecord" >
select * from lz_flow_record where id=#{id} and is_delete = 0 limit 1 select * from lz_flow_record where id=#{id} and is_delete = 0 limit 1
</select> </select>
<insert id="insertFlowRecord" parameterType="FlowRecord" useGeneratedKeys="true" keyProperty="id" > <insert id="insertFlowRecord" parameterType="FlowRecord" useGeneratedKeys="true" keyProperty="id" >
insert into lz_flow_record( insert into lz_flow_record(
<if test="departmentId != null">department_id, </if>
<if test="departmentLevel != null">department_level, </if> <if test="departmentLevel != null">department_level, </if>
<if test="recordId != null">record_id, </if> <if test="recordId != null">record_id, </if>
<if test="approvalStaffId != null">approval_staff_id, </if> <if test="approvalStaffId != null">approval_staff_id, </if>
@ -50,7 +44,6 @@
gmt_create, gmt_create,
gmt_modified gmt_modified
)values( )values(
<if test="departmentId != null">#{ departmentId}, </if>
<if test="departmentLevel != null">#{ departmentLevel}, </if> <if test="departmentLevel != null">#{ departmentLevel}, </if>
<if test="recordId != null">#{ recordId}, </if> <if test="recordId != null">#{ recordId}, </if>
<if test="approvalStaffId != null">#{ approvalStaffId}, </if> <if test="approvalStaffId != null">#{ approvalStaffId}, </if>
@ -73,7 +66,6 @@
<trim prefix="set" suffixOverrides=","> <trim prefix="set" suffixOverrides=",">
<if test="isDelete != null">is_delete = #{isDelete},</if> <if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="gmtCreate != null">gmt_create = #{gmtCreate},</if> <if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
<if test="departmentId != null">department_id = #{departmentId},</if>
<if test="departmentLevel != null">department_level = #{departmentLevel},</if> <if test="departmentLevel != null">department_level = #{departmentLevel},</if>
<if test="recordId != null">record_id = #{recordId},</if> <if test="recordId != null">record_id = #{recordId},</if>
<if test="approvalStaffId != null">approval_staff_id = #{approvalStaffId},</if> <if test="approvalStaffId != null">approval_staff_id = #{approvalStaffId},</if>
@ -95,7 +87,6 @@
set set
is_delete = #{isDelete}, is_delete = #{isDelete},
gmt_create = #{gmtCreate}, gmt_create = #{gmtCreate},
department_id = #{departmentId},
department_level = #{departmentLevel}, department_level = #{departmentLevel},
record_id = #{recordId}, record_id = #{recordId},
approval_staff_id = #{approvalStaffId}, approval_staff_id = #{approvalStaffId},
@ -115,6 +106,7 @@
</update> </update>
<select id="selectLastFlowRecordByRecordId" resultType="com.lz.modules.flow.entity.FlowRecord"> <select id="selectLastFlowRecordByRecordId" resultType="com.lz.modules.flow.entity.FlowRecord">
select * from lz_flow_record where is_delete = 0 and record_id = #{recordId} and status = 0 order by id desc limit 1 select * from lz_flow_record where is_delete = 0 and record_id = #{recordId} and status = 0 order by id desc limit 1
</select> </select>

View File

@ -78,7 +78,7 @@
<select id="selectStaffRoleDepartmentByStaffRoleId" resultType="com.lz.modules.flow.entity.StaffRoleDepartment"> <select id="selectStaffRoleDepartmentByStaffRoleId" resultType="com.lz.modules.flow.entity.StaffRoleDepartment">
select * from lz_staff_role_department where staff_role_id=#{staffRoleId} and is_delete = 0 limit 1 select * from lz_staff_role_department where staff_role_id=#{staffRoleId} and is_delete = 0
</select> </select>

View File

@ -9,14 +9,14 @@
<result column="gmt_create" property="gmtCreate"/> <result column="gmt_create" property="gmtCreate"/>
<result column="gmt_modified" property="gmtModified"/> <result column="gmt_modified" property="gmtModified"/>
<result column="staff_id" property="staffId"/> <result column="staff_id" property="staffId"/>
<result column="role" property="role"/> <result column="department_level" property="departmentLevel"/>
<result column="record_role_id" property="recordRoleId"/> <result column="role_id" property="roleId"/>
</resultMap> </resultMap>
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
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 id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, staff_id AS staffId, department_level AS departmentLevel, role_id AS roleId
</sql> </sql>
@ -30,15 +30,15 @@
<insert id="insertStaffRole" parameterType="StaffRole" useGeneratedKeys="true" keyProperty="id" > <insert id="insertStaffRole" parameterType="StaffRole" useGeneratedKeys="true" keyProperty="id" >
insert into lz_staff_role( insert into lz_staff_role(
<if test="staffId != null">staff_id, </if> <if test="staffId != null">staff_id, </if>
<if test="role != null">role, </if> <if test="departmentLevel != null">department_level, </if>
<if test="recordRoleId != null">record_role_id, </if> <if test="roleId != null">role_id, </if>
is_delete, is_delete,
gmt_create, gmt_create,
gmt_modified gmt_modified
)values( )values(
<if test="staffId != null">#{ staffId}, </if> <if test="staffId != null">#{ staffId}, </if>
<if test="role != null">#{ role}, </if> <if test="departmentLevel != null">#{ departmentLevel}, </if>
<if test="recordRoleId != null">#{ recordRoleId}, </if> <if test="roleId != null">#{ roleId}, </if>
0, 0,
now(), now(),
now() now()
@ -53,8 +53,8 @@
<if test="isDelete != null">is_delete = #{isDelete},</if> <if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="gmtCreate != null">gmt_create = #{gmtCreate},</if> <if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
<if test="staffId != null">staff_id = #{staffId},</if> <if test="staffId != null">staff_id = #{staffId},</if>
<if test="role != null">role = #{role},</if> <if test="departmentLevel != null">department_level = #{departmentLevel},</if>
<if test="recordRoleId != null">record_role_id = #{recordRoleId}</if> <if test="roleId != null">role_id = #{roleId}</if>
</trim> </trim>
,gmt_modified = now() ,gmt_modified = now()
where id = #{id} where id = #{id}
@ -68,8 +68,8 @@
is_delete = #{isDelete}, is_delete = #{isDelete},
gmt_create = #{gmtCreate}, gmt_create = #{gmtCreate},
staff_id = #{staffId}, staff_id = #{staffId},
role = #{role}, department_level = #{departmentLevel},
record_role_id = #{recordRoleId} role_id = #{roleId}
,gmt_modified = now() ,gmt_modified = now()
where id = #{id} where id = #{id}
</update> </update>
@ -80,12 +80,13 @@
</update> </update>
<select id="selectByStaffId" resultType="com.lz.modules.flow.entity.StaffRole"> <select id="selectByStaffId" resultType="com.lz.modules.flow.entity.StaffRole">
select * from lz_staff_role where is_delete = 0 and staff_id = #{staffId} limit 1 select * from lz_staff_role where is_delete = 0 and staff_id = #{staffId} limit 1
</select> </select>
<select id="selectByRole" resultType="com.lz.modules.flow.entity.StaffRole"> <select id="selectByRole" resultType="com.lz.modules.flow.entity.StaffRole">
select * from lz_staff_role where is_delete = 0 and role = #{role} select * from lz_staff_role where is_delete = 0 and department_level = #{departmentLevel}
</select> </select>