修改一键催办逻辑

This commit is contained in:
wulin 2020-12-17 10:24:32 +08:00
parent a6cd4a34bd
commit dc8a5f406f
7 changed files with 88 additions and 8 deletions

View File

@ -105,4 +105,8 @@ public interface FlowRecordMapper extends BaseMapper<FlowRecord> {
FlowRecord selectPreFlowRecordByRecordIdMinIdStatusList(@Param("recordId") Long recordId, @Param("flowIndex") Integer flowIndex, @Param("statusList") List<Integer> statusList);
List<FlowRecord> selectFlowRecordByRecordIdFlowIndexStatusList(@Param("recordId") Long recordId, @Param("flowIndex") Integer flowIndex, @Param("statusList") List<Integer> statusList);
List<FlowRecord> selectFlowRecordByRecordIdsFlowProcess(@Param("recordIds") List<Long> recordIds, @Param("flowProcess") Long flowProcess);
List<FlowRecord> selectFlowRecordByRecordIdsStatus(@Param("recordIds") List<Long> recordIds, @Param("status") int status);
}

View File

@ -101,4 +101,8 @@ public interface FlowRecordService extends IService<FlowRecord> {
List<FlowRecord> selectFlowRecordByRecordIdFlowIndexStatusList(Long recordId, Integer flowIndex, List<Integer> statusList);
List<FlowRecord> selectFlowRecordByRecordIdLeFlowIndex(Long resultRecordId, Integer flowIndex);
List<FlowRecord> selectFlowRecordByRecordIdsFlowProcess(List<Long> recordIds, Long flowProcess);
List<FlowRecord> selectFlowRecordByRecordIdsStatus(List<Long> recordIds, int status);
}

View File

@ -266,4 +266,14 @@ public class FlowRecordServiceImpl extends ServiceImpl<FlowRecordMapper, FlowRec
return flowRecordMapper.selectFlowRecordByRecordIdLeFlowIndex(resultRecordId,flowIndex);
}
@Override
public List<FlowRecord> selectFlowRecordByRecordIdsFlowProcess(List<Long> recordIds, Long flowProcess){
return flowRecordMapper.selectFlowRecordByRecordIdsFlowProcess(recordIds,flowProcess);
}
@Override
public List<FlowRecord> selectFlowRecordByRecordIdsStatus(List<Long> recordIds, int status){
return flowRecordMapper.selectFlowRecordByRecordIdsStatus(recordIds,status);
}
}

View File

@ -984,15 +984,17 @@ public class DingtalkBusiness {
return R.error("未授权登录");
}
public void urging(List<StaffEntity> staffEntities, Map<Long, ResultRecord> mapReords) {
public void urging(List<FlowRecord> flowRecords, Map<Long, StaffEntity> mapStaffs, Map<Long, ResultRecord> mapReords) {
logger.info("批量催办");
ThirdAppConfig thirdAppConfig = thirdAppConfigService.getByAppId(appid);
String token = dingTalkUtil.getAccessTokenWitchEntity(thirdAppConfig);
if(token != null && token.length() > 0){
for (StaffEntity info:staffEntities
for (FlowRecord flowRecord:flowRecords
) {
ResultRecord record = mapReords.get(info.getId());
if(record != null){
ResultRecord record = mapReords.get(flowRecord.getId());
StaffEntity info = mapStaffs.get(flowRecord.getApprovalStaffId());
if(record != null && info != null){
String url = homeUrl;
if(url.contains("?")){
url += "&halokit=" + System.currentTimeMillis();

View File

@ -11,10 +11,12 @@ 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.dao.FlowStartMapper;
import com.lz.modules.flow.entity.FlowRecord;
import com.lz.modules.flow.entity.FlowStart;
import com.lz.modules.flow.entity.StaffRole;
import com.lz.modules.flow.entity.StaffRoleDepartment;
import com.lz.modules.flow.service.EvaluationStartStaffService;
import com.lz.modules.flow.service.FlowRecordService;
import com.lz.modules.flow.service.StaffRoleDepartmentService;
import com.lz.modules.flow.service.StaffRoleService;
import com.lz.modules.job.business.DingtalkBusiness;
@ -80,6 +82,8 @@ public class AssessManagerController extends AbstractController{
@Autowired
private StaffService staffService;
@Autowired
private FlowRecordService flowRecordService;
@ -261,8 +265,6 @@ public class AssessManagerController extends AbstractController{
staffIds = departmentsStaffRelateService.selectLongStaffIdsByDepartments(departmentIds);
}
log.info("查询到有权限可以推送的人员数量为{} 如下{}", staffIds.size(), staffIds);
//下面查询当前startId当前flowProcess下面有多少人员id
List<ResultRecord> resultRecords = resultRecordMapper.selectStaffIdsByStartIdAndFlowProcess(startId, flowProcess);
@ -273,10 +275,47 @@ public class AssessManagerController extends AbstractController{
log.info("查询到在当前节点下的人数为{},如下{}", staffIds1.size(), staffIds1);
if(staffIds1.size() > 0 && staffIds.size() > 0){
staffIds.retainAll(staffIds1);//求交集
log.info("最终能推送人员个数{}", staffIds.size());
log.info("需要推送绩效个数{}", staffIds.size());
if(staffIds.size() > 0){
staffIds1 = mapReords.keySet().stream().collect(Collectors.toList());
staffIds1.retainAll(staffIds);
log.info("去掉排除的数据后数量{}", staffIds1.size());
for (Long id:staffIds1
) {
mapReords.remove(id);
}
//获取催办的节点的人员信息
List<Long> recordIds = resultRecords.stream().map(new Function<ResultRecord, Long>() {
@Override
public Long apply(ResultRecord resultRecord) {
return resultRecord.getId();
}
}).collect(Collectors.toList());
log.info("剩余需要处理record的数量{}", recordIds.size());
List<FlowRecord> flowRecords;
if(flowProcess == null){//催全部获取当前节点的人员信息
flowRecords =
flowRecordService.selectFlowRecordByRecordIdsStatus(recordIds, 2);
log.info("催当前节点的人员,数量{}", flowRecords.size());
}else{
flowRecords =
flowRecordService.selectFlowRecordByRecordIdsFlowProcess(recordIds, flowProcess);
log.info("催指定节点的人员,数量{}", flowRecords.size());
}
staffIds = flowRecords.stream().map(new Function<FlowRecord, Long>() {
@Override
public Long apply(FlowRecord flowRecord) {
return flowRecord.getApprovalStaffId();
}
}).collect(Collectors.toList());
log.info("最终能推送人员个数{}", staffIds.size());
mapReords = resultRecords.stream().collect(Collectors.toMap(ResultRecord::getId, Function.identity(), (e, r) -> e));
List<StaffEntity> staffEntities = staffService.selectByIds(staffIds);
dingtalkBusiness.urging(staffEntities, mapReords);
Map<Long, StaffEntity> mapStaffs = staffEntities.stream().collect(Collectors.toMap(StaffEntity::getId, Function.identity(), (e, r) -> e));
dingtalkBusiness.urging(flowRecords, mapStaffs, mapReords);
}
}
} catch (Exception e) {

View File

@ -656,6 +656,7 @@
<select id="selectStaffIdsByStartIdAndFlowProcess" resultType="ResultRecord">
select * from lz_result_record where is_delete = 0 and start_id = #{startId}
<if test="flowProcess != null"> and flow_process = #{flowProcess}</if>
<if test="flowProcess != null"> and flow_process <![CDATA[<]]> 4</if>
</select>
</mapper>

View File

@ -364,5 +364,25 @@
update lz_flow_record set id = #{newId} where id = #{id}
</update>
<select id="selectFlowRecordByRecordIdsFlowProcess" resultType="com.lz.modules.flow.entity.FlowRecord">
select * from lz_flow_record where is_delete = 0
and record_id in
<foreach item="recordIds" collection="recordId" open="(" separator="," close=")">
#{recordId}
</foreach>
and flow_process = #{flowProcess}
</select>
<select id="selectFlowRecordByRecordIdsStatus" resultType="com.lz.modules.flow.entity.FlowRecord">
select * from lz_flow_record where is_delete = 0
and record_id in
<foreach item="recordIds" collection="recordId" open="(" separator="," close=")">
#{recordId}
</foreach>
and status = #{status}
</select>
</mapper>