Commit a940b67b authored by chenhao's avatar chenhao

添加查询当前流程的代码

parent deb70718
......@@ -76,5 +76,20 @@ public interface WorkflowFeignService {
*/
@RequestMapping(value = "/activitiHistory/historyTask/{processInstanceId}", method = RequestMethod.GET)
JSONObject queryHistoryTasksByProcessInstanceId(@PathVariable("processInstanceId") String processInstanceId);
/**
* 拾取任务
* @param taskID
* @return
*/
@RequestMapping(value = "/task/pickuptask/{taskID}", method = RequestMethod.GET)
JSONObject pickuptask(@PathVariable("taskID") String taskID) ;
/**
* 直接完成任务
* @param taskId
* @param variable
* @return
*/
@RequestMapping(value = "/task/complete/{taskId}", method = RequestMethod.POST)
JSONObject completeByVariable(@PathVariable("taskId") String taskId, @RequestBody HashMap<String, Object> variable);
}
......@@ -194,4 +194,11 @@ public class FailureDetailsController extends BaseController {
return ResponseHelper.buildResponse(failureDetailsServiceImpl.getExcuteTaskAuthButton(sequenceNbr, getSelectedOrgInfo()));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "查询当前任务详情", notes = "查询当前任务详情")
@GetMapping(value = "/getCurrentTask{sequenceNbr}")
public ResponseModel<Object> getCurrentTask(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(failureDetailsServiceImpl.getCurrentTask(sequenceNbr));
}
}
package com.yeejoin.amos.boot.module.common.biz.service.impl;
import java.lang.reflect.InvocationTargetException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
......@@ -11,7 +10,6 @@ import java.util.Map;
import java.util.Random;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -19,7 +17,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.alibaba.fastjson.JSONArray;
......@@ -27,9 +24,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import com.yeejoin.amos.boot.module.common.api.dto.FailureDetailsDto;
......@@ -78,7 +73,7 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
IFailureRepairlogService failureRepairlog;
public static String EMERGENCY_COMMAND = "应急指挥科";
public static String[] PROCESS_NAME = { "提交维修单", "审核", "维修", "验收" };
public static String[] PROCESS_NAME = { "提交维修单", "审核", "维修", "验收", "维修中" };
private final Logger logger = LoggerFactory.getLogger(FailureDetailsServiceImpl.class);
......@@ -341,14 +336,43 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
return false;
}
public boolean excuteTask(Long sequenceNbr, ReginParams userInfo, String condition) {
@Transactional
public boolean excuteTask(Long sequenceNbr, ReginParams userInfo, String condition) throws Exception {
HashMap<String, Object> conditionMap = new HashMap<String, Object>();
conditionMap.put("condition", Integer.parseInt(condition));
Map<String, Object> map = checkExcuteTaskAuthMap(sequenceNbr, userInfo);
try {
if (Boolean.parseBoolean(map.get("checkFlag").toString())) {
if (Boolean.parseBoolean(map.get("checkFlag").toString())) {
if (map.get("name").toString().startsWith(PROCESS_NAME[4])) {
workflowFeignService.completeByVariable(map.get("taskId").toString(), conditionMap);
} else {
workflowFeignService.pickupAndCompleteTask(map.get("taskId").toString(), conditionMap);
}
// 判断下一个节点是不是维修中,如果是则添加当前任务的执行人
String nextTaskId = checkIsInMaintenance(sequenceNbr);
if (nextTaskId != null) {
workflowFeignService.pickuptask(nextTaskId);
}
}
return true;
}
/**
* 已经存在的操作人的任务执行,用于维修中节点完成任务
*
* @param sequenceNbr
* @param userInfo
* @param condition
* @return
*/
public boolean excuteTaskOnlyOperation(Long sequenceNbr, ReginParams userInfo) {
Map<String, Object> map = checkExcuteTaskAuthMap(sequenceNbr, userInfo);
try {
if (Boolean.parseBoolean(map.get("checkFlag").toString())
&& map.get("checkFlag").toString().startsWith(PROCESS_NAME[4])) {
workflowFeignService.completeByVariable(map.get("taskId").toString(), null);
}
} catch (Exception e) {
e.printStackTrace();
return false;
......@@ -390,6 +414,23 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
return Boolean.parseBoolean(map.get("checkFlag").toString());
}
public String checkIsInMaintenance(Long sequenceNbr) {
FailureDetails details = this.baseMapper.selectById(sequenceNbr);
String procressId = details.getProcessId();
JSONObject teskObject = workflowFeignService.getTaskList(procressId);
if (ObjectUtils.isNotEmpty(teskObject)) {
JSONArray taskDetailArray = teskObject.getJSONArray("data");
for (Object obj : taskDetailArray) {
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj));
String name = detail.getString("name");
if (name.startsWith(PROCESS_NAME[4])) {
return detail.getString("id");
}
}
}
return null;
}
public Map<String, Object> checkExcuteTaskAuthMap(Long sequenceNbr, ReginParams userInfo) {
// 获取当前登录用户的角色
String currentLoginUserRole = userInfo.getRole().getRoleName();
......@@ -398,7 +439,6 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
FailureDetailsDto failureDetailsDto = this.queryBySeq(sequenceNbr);
// 获取送达部门的ID
Long failureEquipmentId = failureDetailsDto.getSubmissionBranchId();
// 获取上一级操作部门的Id
FailureDetails details = this.baseMapper.selectById(sequenceNbr);
String procressId = details.getProcessId();
Long seq = userInfo.getDepartment().getSequenceNbr();
......@@ -502,8 +542,9 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
// 从流程记录表中拿到处理人的名称
FailureRepairlog failureRepairlog = failureRepairlogService
.findByprocessAuditor(detail.getString("operator"));
if(failureRepairlog!=null) {
detail.replace("operator", failureRepairlog.getProcessAuditorName()==null?"":failureRepairlog.getProcessAuditorName());
if (failureRepairlog != null) {
detail.replace("operator", failureRepairlog.getProcessAuditorName() == null ? ""
: failureRepairlog.getProcessAuditorName());
}
}
list.add(detail);
......@@ -570,4 +611,16 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
return flag;
}
public Object getCurrentTask(Long sequenceNbr) {
JSONArray taskDetailArray = null;
FailureDetails details = this.baseMapper.selectById(sequenceNbr);
String procressId = details.getProcessId();
JSONObject teskObject = workflowFeignService.getTaskList(procressId);
if (ObjectUtils.isNotEmpty(teskObject)) {
taskDetailArray = teskObject.getJSONArray("data");
}
return taskDetailArray;
}
}
\ No newline at end of file
......@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.common.biz.service.impl;
import java.util.Date;
import java.util.List;
import com.yeejoin.amos.boot.module.common.api.dto.FailureAuditDto;
import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -13,7 +12,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.common.api.dto.FailureDetailsDto;
......@@ -159,7 +157,12 @@ public class FailureMaintainServiceImpl extends BaseService<FailureMaintainDto,F
Integer processAuditorId = Integer.parseInt(failureMaintainDto.getRecUserId());
repairlog(failureMaintainDto.getFaultId(),failureMaintainDto.getMaintainMan(),processAuditorId, userInfo.getDepartment().getSequenceNbr(),failureMaintainDto.getMaintainTime(),
failureMaintainDto.getDepartment(),processResult);
failureDetailsService.excuteTask(failureMaintainDto.getFaultId(), userInfo, condition);
try {
failureDetailsService.excuteTask(failureMaintainDto.getFaultId(), userInfo, condition);
}catch (Exception e) {
return false;
}
return true;
}
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment