/**
* 我的待办
* @param pn
* @param ps
* @return
* @throws IOException
*/
@SieMethodOperation(code = "attendance.myProcess.toDoList.search" , name = "考勤服务我的待办查询",type = "search",url= "/process/td")
@PostMapping(value = "/process/td/{pn}/{ps}")
public PageResultVO processToDoList(@RequestBody MyProcessParamVO paramVO, @PathVariable Integer pn, @PathVariable Integer ps) throws IOException,ParseException {
//通过userId获取中文名
String userId = SecurityUtils.getCurrentUserLogin();
if(null == paramVO.getTitle() || paramVO.getTitle().isEmpty()){
paramVO.setTitle("%");
}else {
paramVO.setTitle("%" + paramVO.getTitle() + "%");
}
//查询查出我的待办
List<Task> list = taskService.createTaskQuery()
.taskAssignee(userId)
.processVariableValueLike("title",paramVO.getTitle())
.processInstanceId(paramVO.getInstanceId())
.taskCreatedAfter(null == paramVO.getStart() ? null : DtmStringFormat.strYmdToDate(paramVO.getStart()))
.taskCreatedBefore(null == paramVO.getEnd() ? null : DtmStringFormat.strYmdToDate(paramVO.getEnd()))
.listPage(pn * ps,ps);
long count = taskService.createTaskQuery()
.taskAssignee(userId)
.processVariableValueLike("title",paramVO.getTitle())
.processInstanceId(paramVO.getInstanceId())
.taskCreatedAfter(null == paramVO.getStart() ? null : DtmStringFormat.strYmdToDate(paramVO.getStart()))
.taskCreatedBefore(null == paramVO.getEnd() ? null : DtmStringFormat.strYmdToDate(paramVO.getEnd()))
.count();
//初始化结果集
List<ProcessMyCommonVO> dataList = new ArrayList<ProcessMyCommonVO>();
for(Task task : list){
HistoricProcessInstance historic = historyService
.createHistoricProcessInstanceQuery()
.processInstanceId(task.getProcessInstanceId())
.singleResult();
if(null != historic){
//初始化
ProcessMyCommonVO processVO = new ProcessMyCommonVO(task.getProcessInstanceId(),
historyService.createHistoricVariableInstanceQuery().processInstanceId(historic.getId()).variableName("appName").singleResult().getValue().toString(),
task.getId(),
AttendanceUtil.resolveTypeByBusinessKey(historic.getBusinessKey()),
historyService.createHistoricVariableInstanceQuery().processInstanceId(historic.getId()).variableName("instanceFormType").singleResult().getValue().toString(),
historic.getBusinessKey(),
historyService.createHistoricVariableInstanceQuery().processInstanceId(task.getProcessInstanceId()).variableName("title").singleResult().getValue().toString(),
historic.getStartUserId(),
sendGet(UrlConstant.GET_ZHNAME_BY_UID+historic.getStartUserId(),null),
DtmStringFormat.dateTimeToStrYmdHms(historic.getStartTime()),
null
);
//设置状态
if("completed".equals(historic.getState().toLowerCase())){
processVO.setWfState("completed");
}
if("active".equals(historic.getState().toLowerCase())){
//驳回状态
initActiveProcessInfo(historic, task, processVO);
}
dataList.add(processVO);
}
}
return new PageResultVO(GlobalReturnCode.SUCCESS_CODE, "SUCCESS",ps,pn,(int)count,AttendanceUtil.processSortByStartDateDesc(dataList));
}复制代码
界面实例: