Commit eaf05ff2 authored by tianyiming's avatar tianyiming

转办功能实现

parent 7db82815
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
......@@ -26,5 +27,9 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
List<Map<String,Object>> getEnterpriseEmployee(String unitCode);
String getOrgCodeByCompanyCode(String companyCode);
String selectBusinessData(String tableName, String instanceId);
void updateBusinessData(String tableName,String assignee, String transferToUserIds, String instanceId);
}
......@@ -66,4 +66,17 @@
<select id="getOrgCodeByCompanyCode" resultType="java.lang.String">
select org_code from privilege_company where company_code = #{companyCode} limit 1
</select>
<select id="selectBusinessData" resultType="java.lang.String">
select transfer_to_user_ids
from ${tableName}
where instance_id = #{instanceId}
</select>
<update id="updateBusinessData">
update ${tableName}
set transfer_to_user_ids = #{transferToUserIds},
next_execute_user_ids = #{assignee}
where instance_id = #{instanceId}
</update>
</mapper>
......@@ -14,6 +14,7 @@ import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -230,4 +231,18 @@ public class CommonController extends BaseController {
return ResponseHelper.buildResponse(commonService.creatTree());
}
/**
* 公共转办接口
* /jg/common/transfer
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/transfer")
@ApiOperation(httpMethod = "POST", value = "公共转办接口", notes = "公共转办接口")
public ResponseModel<Object> transfer(@RequestBody Map<String, Object> map) {
Object result = commonService.transfer(map);
return ResponseHelper.buildResponse(result);
}
}
......@@ -13,4 +13,6 @@ public interface ICmWorkflowService {
ProcessTaskDTO completeOrReject(String taskId, TaskResultDTO data, String operate);
ProcessTaskDTO rollBack(String processInstanceId);
String assign(FlowTaskVo taskVo);
}
......@@ -45,4 +45,6 @@ public interface ICommonService {
Object invokeBusinessProcess(String submitType, Map<String, Object> obj, ReginParams reginParams);
Object getCompanyUser(Long companyId);
Object transfer(Map<String, Object> obj);
}
......@@ -8,12 +8,14 @@ import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO;
import com.yeejoin.amos.feign.workflow.model.FlowTaskVo;
import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO;
import com.yeejoin.amos.feign.workflow.model.TaskResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @author Administrator
......@@ -88,4 +90,24 @@ public class CmWorkflowServiceImpl implements ICmWorkflowService {
log.info("开始请求工作流撤回接口:/rollBack/standard/{processInstanceId},请求参数:{}", processInstanceId);
return FeignUtil.remoteCall(() -> Workflow.taskV2Client.rollBackTask(processInstanceId));
}
@Override
public String assign(FlowTaskVo taskVo) {
String result;
try {
log.info("开始请求工作流转办任务接口:/assign/{taskVo},请求参数:{},{}", taskVo);
result = Workflow.taskV2Client.assign(taskVo).getResult();
} catch (InnerInvokException e) {
//拦截无审核人异常信息
String devMessage = e.getDevMessage();
devMessage = devMessage.contains(";") ? devMessage.split(";")[0] : devMessage;
log.error(devMessage);
throw new LocalBadRequest(devMessage);
} catch (Exception e) {
log.error("调用工作流转办任务接口失败", e);
throw new RuntimeException("调用工作流转办任务接口失败");
}
return result;
}
}
......@@ -20,6 +20,7 @@ import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationTransfer
import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService;
import com.yeejoin.amos.boot.module.jg.api.service.IJgMaintainNoticeService;
import com.yeejoin.amos.boot.module.jg.api.service.IJgTransferNoticeService;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService;
import com.yeejoin.amos.boot.module.jg.biz.utils.FileExporter;
import com.yeejoin.amos.boot.module.jg.biz.utils.ImageUtils;
......@@ -35,6 +36,7 @@ import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import com.yeejoin.amos.feign.workflow.model.ActTaskDTO;
import com.yeejoin.amos.feign.workflow.model.FlowTaskVo;
import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -48,6 +50,7 @@ import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
......@@ -183,6 +186,10 @@ public class CommonServiceImpl implements ICommonService {
@Autowired
JgScrapCancelServiceImpl jgScrapCancelService;
@Autowired
ICmWorkflowService cmWorkflowService;
public static byte[] file2byte(File file) {
try {
FileInputStream in = new FileInputStream(file);
......@@ -631,6 +638,58 @@ public class CommonServiceImpl implements ICommonService {
}
return null;
}
@Override
public Object transfer(Map<String, Object> map) {
if (ObjectUtils.isEmpty(map.get("nextTaskId")) || map.get("nextTaskId") == null) {
throw new BadRequest("nextTaskId不能为空");
}
if (ObjectUtils.isEmpty(map.get("instanceId")) || map.get("instanceId") == null) {
throw new BadRequest("instanceId不能为空");
}
String taskId = map.get("nextTaskId").toString();
String instanceId = map.get("instanceId").toString();
String tableName = map.get("tableName").toString();
String assignee = map.get("assignee").toString();
FlowTaskVo flowTaskVo = new FlowTaskVo();
flowTaskVo.setTaskId(taskId);
flowTaskVo.setAssignee(assignee);
cmWorkflowService.assign(flowTaskVo);
//修改待办
List<TaskV2Model> result = Systemctl.taskV2Client.selectListByRelationId(instanceId).getResult();
TaskV2Model taskV2Model = result.stream().filter(r -> r.getFlowCode().equals(taskId)).findFirst().orElse(null);
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
taskV2Model.setExecuteUserIds(reginParams.getUserModel().getUserId());
taskV2Model.setTaskStatus(FlowStatusEnum.TO_BE_TRANSFER.getCode());
taskV2Model.setTaskStatusLabel(FlowStatusEnum.TO_BE_TRANSFER.getName());
taskV2Model.setEndUserId(reginParams.getUserModel().getUserId());
Date createDate = taskV2Model.getCreateDate();
taskV2Model.setCreateDate(new Date());
taskV2Model.setEndDate(new Date());
String routhPath = taskV2Model.getRoutePath().replace("nextExecuteUserIds", "executeUserId") + "&nextExecuteUserIds=" + assignee;
taskV2Model.setRoutePath(routhPath);
Systemctl.taskV2Client.update(taskV2Model, taskV2Model.getSequenceNbr());
//创建新待办
taskV2Model.setExecuteUserIds(assignee);
taskV2Model.setCreateDate(createDate);
taskV2Model.setTaskStatus(0);
taskV2Model.setTaskStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskV2Model.setEndUserId(null);
taskV2Model.setEndDate(null);
taskV2Model.setSequenceNbr(null);
Systemctl.taskV2Client.create(taskV2Model);
String id = commonMapper.selectBusinessData(tableName, instanceId);
if ("null".equals(id)) {
id = assignee;
} else {
id = id + "," + assignee;
}
//修改业务数据
commonMapper.updateBusinessData(tableName, assignee, id, instanceId);
return Boolean.TRUE;
}
public void deleteTaskModel(String id) {
......
......@@ -7,6 +7,12 @@ import lombok.Getter;
*/
@Getter
public enum FlowStatusEnum {
/**
* 已转办
*/
TO_BE_TRANSFER(6621, "已转办"),
/**
* 待提交
*/
......
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