This commit is contained in:
wulin 2020-08-28 08:40:07 +08:00
commit 9c44780537
4 changed files with 23 additions and 22 deletions

View File

@ -425,7 +425,7 @@ public class ResultRecordController extends AbstractController {
@RequestMapping("/recordIdsSubmit") @RequestMapping("/recordIdsSubmit")
public R recordIdsSubmit(String recordIds) { public R recordIdsSubmit(String recordIds) {
if (StringUtil.isBlank(recordIds)) { if (StringUtil.isBlank(recordIds)) {
return R.error("请选择状态为待提交的记录"); return R.error("请选择提交");
} }
List<Long> records = new ArrayList<>(); List<Long> records = new ArrayList<>();
String ids[] = recordIds.split(","); String ids[] = recordIds.split(",");
@ -436,7 +436,7 @@ public class ResultRecordController extends AbstractController {
} }
} }
} }
if (recordIds == null) { if (records == null) {
return R.error("请选择状态为待提交的记录"); return R.error("请选择状态为待提交的记录");
} }
List<ResultRecord> resultRecords = resultRecordService.selectResultRecordByIds(records); List<ResultRecord> resultRecords = resultRecordService.selectResultRecordByIds(records);
@ -447,16 +447,18 @@ public class ResultRecordController extends AbstractController {
} }
R r = null; R r = null;
for (ResultRecord resultRecord : resultRecords) { for (ResultRecord resultRecord : resultRecords) {
r = resultRecordService.approval(resultRecord.getId(), getUserId()); r = resultRecordService.approval(resultRecord.getId(), getUserId());
if (!r.isSuccess()) {
return r;
}
} }
if(r != null && r.isSuccess()){//批量提交 if (r != null && r.isSuccess()) {//批量提交
StaffEntity mySelf = (StaffEntity)r.get("from"); StaffEntity mySelf = (StaffEntity) r.get("from");
StaffEntity toSelf = (StaffEntity)r.get("to"); StaffEntity toSelf = (StaffEntity) r.get("to");
WorkMsgTypeEnum workMsgTypeEnum = (WorkMsgTypeEnum)r.get("type"); WorkMsgTypeEnum workMsgTypeEnum = (WorkMsgTypeEnum) r.get("type");
sendWorkMSG(mySelf, toSelf, workMsgTypeEnum, 0L, 2); sendWorkMSG(mySelf, toSelf, workMsgTypeEnum, 0L, 2);
} }

View File

@ -143,8 +143,11 @@ public class RecordAuthServiceImpl extends ServiceImpl<RecordAuthMapper, RecordA
return ""; return "";
} else { } else {
DepartmentsStaffRelateEntity leader = departmentsStaffRelateService.selectLeaderByDepartmentId(departmentsStaffRelateEntity.getDepartmentId()); DepartmentsStaffRelateEntity leader = departmentsStaffRelateService.selectLeaderByDepartmentId(departmentsStaffRelateEntity.getDepartmentId());
StaffEntity staffEntity = staffService.selectStaffById(leader.getStaffId()); if (leader != null) {
return staffEntity.getName(); StaffEntity staffEntity = staffService.selectStaffById(leader.getStaffId());
return staffEntity.getName();
}
return "";
} }
} }

View File

@ -331,7 +331,6 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
return R.error("recordId为[" + recordId + "]业绩权重之和必需等于0.7。"); return R.error("recordId为[" + recordId + "]业绩权重之和必需等于0.7。");
} }
return R.ok(); return R.ok();
} }
@Override @Override
@ -347,7 +346,7 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
List<FlowDepartment> list = flowInfo.getSecond(); List<FlowDepartment> list = flowInfo.getSecond();
List<FlowRelation> flowRelations = flowRelationService.selectFlowRelationAll(); List<FlowRelation> flowRelations = flowRelationService.selectFlowRelationAll();
Map<String, FlowDepartment> staffEntityMap = list.stream().collect(Collectors.toMap(FlowDepartment::getDepartmentLevel, p -> p)); Map<String, FlowDepartment> staffEntityMap = list.stream().collect(Collectors.toMap(FlowDepartment::getDepartmentLevel, p -> p));
// approvalList = [ME,ONE_D,TWO_D,HR,BOSS] //approvalList = [ME,ONE_D,TWO_D,HR,BOSS]
List<String> approvalList = new ArrayList<>(); List<String> approvalList = new ArrayList<>();
approvalList.add("ME"); approvalList.add("ME");
for (FlowRelation flowRelation : flowRelations) { for (FlowRelation flowRelation : flowRelations) {
@ -364,19 +363,15 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
StaffEntity staff = staffService.selectStaffById(resultRecord.getStaffId()); StaffEntity staff = staffService.selectStaffById(resultRecord.getStaffId());
int flowIndex = lastFlowRecord != null ? lastFlowRecord.getFlowIndex() + 1 : 1; int flowIndex = lastFlowRecord != null ? lastFlowRecord.getFlowIndex() + 1 : 1;
int index = getDepartmentLevelIndex(flows, flowIndex); int index = getDepartmentLevelIndex(flows, flowIndex);
if (index < 0) { //表示流程己经结束 if (index < 0 || index >= approvalList.size()) { //表示流程己经结束
lastFlowRecord.setFlowName(mySelf.getName() + "-审批通过"); lastFlowRecord.setFlowName(mySelf.getName() + "-审批通过");
flowRecordService.updateCoverFlowRecordById(lastFlowRecord); flowRecordService.updateCoverFlowRecordById(lastFlowRecord);
resultRecordService.updateFlowStaffIdRoleToNull(resultRecord.getId());// 更新用户权限 resultRecordService.updateFlowStaffIdRoleToNull(resultRecord.getId());// 更新用户权限
return R.ok("流程审批结束") return R.ok("流程审批结束")
.put("from", staff) .put("from", staff)
.put("to", staff) .put("to", staff)
.put("type", WorkMsgTypeEnum.PASS); .put("type", WorkMsgTypeEnum.PASS);
} }
FlowRecord flowRecord = new FlowRecord(); FlowRecord flowRecord = new FlowRecord();
flowRecord.setRecordId(resultRecordId); flowRecord.setRecordId(resultRecordId);
flowRecord.setRecordStaffId(resultRecord.getStaffId()); flowRecord.setRecordStaffId(resultRecord.getStaffId());
@ -384,35 +379,36 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
flowRecord.setFlowId(flowId); flowRecord.setFlowId(flowId);
String departmentLevel = approvalList.get(index); String departmentLevel = approvalList.get(index);
flowRecord.setDepartmentLevel(departmentLevel); flowRecord.setDepartmentLevel(departmentLevel);
StaffEntity approvalStaff = null; StaffEntity approvalStaff = null;
List<StaffRoleDto> staffRoleDtos = new ArrayList<>(); List<StaffRoleDto> staffRoleDtos = new ArrayList<>();
Long roleId = flows.get(flowIndex - 1).getRoleId();
if (Constant.ME.equals(departmentLevel)) { //如果是自己 if (Constant.ME.equals(departmentLevel)) { //如果是自己
approvalStaff = staff; // 是自己进行审批 approvalStaff = staff; // 是自己进行审批
StaffRoleDto staffRoleDto = new StaffRoleDto(staff.getId(), flows.get(flowIndex - 1).getRoleId()); StaffRoleDto staffRoleDto = new StaffRoleDto(staff.getId(), roleId);
staffRoleDtos.add(staffRoleDto); staffRoleDtos.add(staffRoleDto);
} else { } else {
FlowDepartment flowD = staffEntityMap.get(departmentLevel); FlowDepartment flowD = staffEntityMap.get(departmentLevel);
if (flowD == null) { if (flowD == null) {
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(resultRecord.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(), TypeRoleDto.getRoleId(staffRole.getTypeRoleIds(), resultRecord.getType())); StaffRoleDto staffRoleDto = new StaffRoleDto(staffRole.getStaffId(), roleId != null && roleId > 0 ? roleId :
TypeRoleDto.getRoleId(staffRole.getTypeRoleIds(), resultRecord.getType()));
staffRoleDtos.add(staffRoleDto); staffRoleDtos.add(staffRoleDto);
} }
} }
} }
if (staffRoleDtos.size() >= 1) { //表示只有一个审批的用户 if (staffRoleDtos.size() >= 1) { //表示只有一个审批的用户
approvalStaff = staffService.selectStaffById(staffRoleDtos.get(0).getStaffId()); approvalStaff = staffService.selectStaffById(staffRoleDtos.get(0).getStaffId());
} }
} 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(), roleId);
staffRoleDtos.add(staffRoleDto); staffRoleDtos.add(staffRoleDto);
} }
} }

View File

@ -3,7 +3,7 @@
<!--<include resource="org/springframework/boot/logging/logback/base.xml"/>--> <!--<include resource="org/springframework/boot/logging/logback/base.xml"/>-->
<!-- 定义log文件的目录 --> <!-- 定义log文件的目录 -->
<property name="LOG_HOME" value="/home/admin/logs/lzmanagement"></property> <property name="LOG_HOME" value="lzmanagement"></property>
<conversionRule conversionWord="sampleClass" converterClass="com.lz.common.layouts.SampleClassConverter" /> <conversionRule conversionWord="sampleClass" converterClass="com.lz.common.layouts.SampleClassConverter" />