This commit is contained in:
杜建超 2020-10-13 17:43:14 +08:00
parent 7ff9ceb1d5
commit 8d9d82da6d
6 changed files with 46 additions and 15 deletions

View File

@ -52,6 +52,6 @@ public interface FlowRecordMapper extends BaseMapper<FlowRecord> {
Long copyFlowRecord(FlowRecord flowRecord);
//查看自己要审批的记录 status为1代表流程走到了这里
List<FlowRecord> selectFlowRecordListByApprovalStaffId(@Param("approvalStaffId") Long approvalStaffId);
List<Long> selectFlowRecordIdsByApprovalStaffId(@Param("approvalStaffId") Long approvalStaffId);
}

View File

@ -53,5 +53,5 @@ public interface FlowRecordService extends IService<FlowRecord> {
Long copyFlowRecord(FlowRecord flowRecord);
List<FlowRecord> selectFlowRecordListByApprovalStaffId(Long approvalStaffId);
List<Long> selectFlowRecordIdsByApprovalStaffId(Long approvalStaffId);
}

View File

@ -139,7 +139,7 @@ public class FlowRecordServiceImpl extends ServiceImpl<FlowRecordMapper, FlowRec
}
@Override
public List<FlowRecord> selectFlowRecordListByApprovalStaffId(Long approvalStaffId) {
return flowRecordMapper.selectFlowRecordListByApprovalStaffId(approvalStaffId);
public List<Long> selectFlowRecordIdsByApprovalStaffId(Long approvalStaffId) {
return flowRecordMapper.selectFlowRecordIdsByApprovalStaffId(approvalStaffId);
}
}

View File

@ -1,8 +1,12 @@
package com.lz.modules.performance;
import com.lz.common.utils.R;
import com.lz.common.utils.StringUtil;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.flow.entity.FlowRecord;
import com.lz.modules.flow.service.FlowRecordService;
import com.lz.modules.performance.res.TaskListRes;
import com.lz.modules.sys.controller.AbstractController;
import com.lz.modules.sys.entity.app.ResultRecord;
import com.lz.modules.sys.service.app.ResultRecordService;
@ -11,8 +15,12 @@ import org.apache.commons.collections.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @Author: djc
@ -24,22 +32,26 @@ import java.util.function.Consumer;
public class TaskController extends AbstractController{
private FlowRecordService flowRecordService;
private ResultRecordService resultRecordService;
private StaffService staffService;
@RequestMapping("task/list")
public R list(){
List<TaskListRes> list = new ArrayList<>();
Long userId = getUserId();
List<FlowRecord> flowRecords = flowRecordService.selectFlowRecordListByApprovalStaffId(userId);
if(CollectionUtils.isEmpty(flowRecords)){
List<Long> flowRecordIds = flowRecordService.selectFlowRecordIdsByApprovalStaffId(userId);
if(CollectionUtils.isEmpty(flowRecordIds)){
return R.ok();
}
flowRecords.stream().forEach(flowRecord -> {
Long recordId = flowRecord.getRecordId();
flowRecordIds.stream().forEach(recordId -> {
TaskListRes res = new TaskListRes();
ResultRecord resultRecord = resultRecordService.selectResultRecordById(recordId);
StaffEntity staffEntity = staffService.selectStaffById(resultRecord.getStaffId());
res.setAvatar(Optional.ofNullable(staffEntity.getAvatar()).orElse(StringUtil.EMPTY));
//res.setTitle(); 根据状态拼接文案
//res.setTime();
//res.setUrl();
list.add(res);
});
ThreadLocal<Long> threadLocal = new ThreadLocal<>();
threadLocal.set(1L);
threadLocal.get();
return R.ok();
}
}

View File

@ -0,0 +1,20 @@
package com.lz.modules.performance.res;
import lombok.Data;
/**
* @Author: djc
* @Desc:
* @Date: 2020/10/13 17:15
*/
@Data
public class TaskListRes {
//头像
private String avatar;
//标题
private String title;
//时间
private String time;
//跳转路径
private String url;
}

View File

@ -200,10 +200,9 @@
select * from lz_flow_record where is_delete = 0 and record_id = #{recordResultId} and type = #{type} and status = #{status}
</select>
<select id="selectFlowRecordListByApprovalStaffId" resultType="com.lz.modules.flow.entity.FlowRecord">
select * from lz_flow_record where is_delete = 0 and approval_staff_id = #{approvalStaffId} and status = 1
<select id="selectFlowRecordIdsByApprovalStaffId" resultType="Long">
select distinct(record_id) from lz_flow_record where is_delete = 0 and approval_staff_id = #{approvalStaffId} and status = 1
</select>
</mapper>