|
|
@ -3,10 +3,19 @@ package com.yxt.anrui.scm.biz.scmapplyinbound; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.FlowTaskFeign; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo; |
|
|
|
import com.yxt.anrui.flowable.api.sysformlink.SysFormLinkFlowStateEnum; |
|
|
|
import com.yxt.anrui.flowable.api.utils.ProcDefEnum; |
|
|
|
import com.yxt.anrui.flowable.api.utils.ProcessStateEnum; |
|
|
|
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; |
|
|
|
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.scm.api.flow.FlowTaskVo; |
|
|
|
import com.yxt.anrui.scm.api.scmapplyinbound.*; |
|
|
|
import com.yxt.anrui.scm.api.scmapplyinboundvehicle.ScmApplyInboundVehicle; |
|
|
|
import com.yxt.anrui.scm.api.scmapplyinboundvehicle.ScmApplyInboundVehicleDto; |
|
|
|
import com.yxt.anrui.scm.api.scmapplyinboundvehicle.ScmApplyInboundVehicleVo; |
|
|
|
import com.yxt.anrui.scm.biz.flow.FlowableService; |
|
|
|
import com.yxt.anrui.scm.biz.scmapplyinboundvehicle.ScmApplyInboundVehicleService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
@ -19,7 +28,9 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -41,6 +52,14 @@ public class ScmApplyInboundService extends MybatisBaseService<ScmApplyInboundMa |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ScmApplyInboundVehicleService scmApplyInboundVehicleService; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private FlowableService flowableService; |
|
|
|
@Autowired |
|
|
|
private FlowTaskFeign flowTaskFeign; |
|
|
|
|
|
|
|
public PagerVo<ScmApplyInbound> listPage(PagerQuery<ScmApplyInboundQuery> pq) { |
|
|
|
ScmApplyInboundQuery query = pq.getParams(); |
|
|
@ -119,7 +138,7 @@ public class ScmApplyInboundService extends MybatisBaseService<ScmApplyInboundMa |
|
|
|
save(inboundVehicle); |
|
|
|
// 保存车辆列表
|
|
|
|
scmApplyInboundVehicleService.saveApplyInboundVehicleList(vehicleList, inboundVehicle.getSid(), inboundVehicle.getModelSid()); |
|
|
|
return new ResultBean().success().setMsg("保存成功"); |
|
|
|
return new ResultBean().success().setMsg("保存成功").setData(inboundVehicle.getSid()); |
|
|
|
} else { // 修改
|
|
|
|
// 采购订单下线日期一旦维护,二次确认,则不能修改 TODO
|
|
|
|
// 验证数据库是否重复
|
|
|
@ -134,7 +153,7 @@ public class ScmApplyInboundService extends MybatisBaseService<ScmApplyInboundMa |
|
|
|
updateById(scmApplyInbound); |
|
|
|
// 更新车辆列表信息
|
|
|
|
scmApplyInboundVehicleService.updateApplyInboundVehicleList(vehicleList); |
|
|
|
return new ResultBean().success().setMsg("修改成功"); |
|
|
|
return new ResultBean().success().setMsg("修改成功").setData(dto.getSid()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -151,4 +170,190 @@ public class ScmApplyInboundService extends MybatisBaseService<ScmApplyInboundMa |
|
|
|
vo.setInboundVehicleList(list); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查用户是否设置部门 |
|
|
|
* |
|
|
|
* @param userSid |
|
|
|
* @return 返回部门sid |
|
|
|
*/ |
|
|
|
private String checkUserOrg(String userSid) { |
|
|
|
String orgSid = ""; |
|
|
|
String staffSid = sysUserFeign.selectBySid(userSid).getData().getStaffSid(); |
|
|
|
ResultBean<String> resultBean = sysStaffOrgFeign.getSysStaffOrgSidListByStaffSid(staffSid); |
|
|
|
if (resultBean.getSuccess()) { |
|
|
|
orgSid = resultBean.getData(); |
|
|
|
} |
|
|
|
return orgSid; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新流程相关的状态 |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private int updateFlowFiled(Map<String, Object> map) { |
|
|
|
return baseMapper.updateFlowFiled(map); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 提交入账申请 |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean submitRecordApplication(SubmitScmApplyInboundDto dto) { |
|
|
|
String orgSid = checkUserOrg(dto.getUserSid()); |
|
|
|
ResultBean resultBean = saveOrUpdateApplyInBound(dto); |
|
|
|
String businessSid = resultBean.getData().toString(); |
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
variables.put("businessSid", businessSid); |
|
|
|
variables.put("orgSid", orgSid); //部门sid
|
|
|
|
if (StringUtils.isBlank(dto.getTaskId())) { // 新提交
|
|
|
|
ResultBean resultBean1 = flowableService.businessStart(ProcDefEnum.RECORDAPPLICATION.getProDefId(), dto.getUserSid(), variables); |
|
|
|
if (resultBean1.getSuccess() && resultBean1.getData() != null) { |
|
|
|
Map<String, String> map = (Map<String, String>) resultBean1.getData(); |
|
|
|
//更新业务表中的流程状态
|
|
|
|
Map<String, Object> paramMap = new HashMap<>(); |
|
|
|
paramMap.put("sid", businessSid); |
|
|
|
paramMap.put("procDefId", ProcDefEnum.RECORDAPPLICATION.getProDefId()); |
|
|
|
paramMap.put("nodeState", map.get("nodeState")); |
|
|
|
paramMap.put("procInsId", map.get("procInsId")); |
|
|
|
paramMap.put("taskDefKey", map.get("taskDefKey")); |
|
|
|
updateFlowFiled(paramMap); |
|
|
|
} |
|
|
|
return resultBean1; |
|
|
|
} else { // 驳回到发起人后再次提交
|
|
|
|
variables.put("comment", StringUtils.isNotBlank(dto.getComment()) ? dto.getComment() : "重新提交"); |
|
|
|
variables.put("instanceId", dto.getInstanceId()); |
|
|
|
variables.put("taskId", dto.getTaskId()); |
|
|
|
variables.put("userSid", dto.getUserSid()); |
|
|
|
return complete(variables); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 办理 |
|
|
|
* @param variables |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean complete(Map<String, Object> variables) { |
|
|
|
BusinessVariables bv= BusinessVariables.builder().build(); |
|
|
|
bv.setDetailUrl(""); |
|
|
|
bv.setHandleUrl(""); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
ResultBean<com.yxt.anrui.flowable.api.flowtask.FlowTask> resultBean = flowTaskFeign.businessComplete(bv); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
String nodeState = ""; |
|
|
|
String taskDefKey = ""; |
|
|
|
Map<String, Object> paramMap = new HashMap<>(); |
|
|
|
paramMap.put("sid", variables.get("businessSid").toString()); |
|
|
|
if (resultBean.getData() != null) { |
|
|
|
ResultBean<List<LatestTaskVo>> listResultBean = flowTaskFeign.getLatestTasks(resultBean.getData().getProcInsId()); |
|
|
|
if (listResultBean.getSuccess() && listResultBean.getData() != null && listResultBean.getData().size() != 0) { |
|
|
|
nodeState = listResultBean.getData().get(0).getName_(); |
|
|
|
taskDefKey = listResultBean.getData().get(0).getTask_def_key_(); |
|
|
|
} else { |
|
|
|
nodeState = ProcessStateEnum.FINISHED.getStateName(); |
|
|
|
taskDefKey = "Event_end"; |
|
|
|
paramMap.put("flowState", SysFormLinkFlowStateEnum.FINISH.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
paramMap.put("nodeState", nodeState); |
|
|
|
paramMap.put("taskDefKey", taskDefKey); |
|
|
|
updateFlowFiled(paramMap); |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 撤回 |
|
|
|
* @param userSid |
|
|
|
* @param businessSid |
|
|
|
* @param flowTaskVo |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean revokeProcess(String userSid, String businessSid, FlowTaskVo flowTaskVo) { |
|
|
|
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl=new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(flowTaskVo,fl); |
|
|
|
fl.setUserSid(userSid); |
|
|
|
ResultBean<List<LatestTaskVo>> resultBean = flowTaskFeign.revokeProcess(fl); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
String nodeState = resultBean.getData().get(0).getName_(); |
|
|
|
String taskDefKey = resultBean.getData().get(0).getTask_def_key_(); |
|
|
|
String incomingSourceRef = resultBean.getData().get(0).getIncomingSourceRef(); |
|
|
|
Map<String, Object> paramMap = new HashMap<>(); |
|
|
|
paramMap.put("sid", businessSid); |
|
|
|
if (incomingSourceRef.contains("start")) { |
|
|
|
paramMap.put("nodeState", SysFormLinkFlowStateEnum.UNCOMMITTED.getState()); |
|
|
|
paramMap.put("taskDefKey", taskDefKey); |
|
|
|
paramMap.put("flowState", SysFormLinkFlowStateEnum.UNCOMMITTED.getCode()); |
|
|
|
} else { |
|
|
|
paramMap.put("nodeState",nodeState ); |
|
|
|
paramMap.put("taskDefKey",taskDefKey ); |
|
|
|
} |
|
|
|
updateFlowFiled(paramMap); |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 驳回 |
|
|
|
* @param businessSid |
|
|
|
* @param flowTaskVo |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean taskReject(String businessSid, FlowTaskVo flowTaskVo) { |
|
|
|
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl=new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(flowTaskVo,fl); |
|
|
|
ResultBean<List<LatestTaskVo>> resultBean = flowTaskFeign.taskReject(fl); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
String nodeState = resultBean.getData().get(0).getName_(); |
|
|
|
String taskDefKey = resultBean.getData().get(0).getTask_def_key_(); |
|
|
|
String incomingSourceRef = resultBean.getData().get(0).getIncomingSourceRef(); |
|
|
|
Map<String, Object> paramMap = new HashMap<>(); |
|
|
|
paramMap.put("sid", businessSid); |
|
|
|
paramMap.put("nodeState", nodeState); |
|
|
|
paramMap.put("taskDefKey", taskDefKey); |
|
|
|
if (incomingSourceRef.contains("start")) { |
|
|
|
paramMap.put("flowState", SysFormLinkFlowStateEnum.REJECT.getCode()); |
|
|
|
} |
|
|
|
updateFlowFiled(paramMap); |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 终止流程 |
|
|
|
* @param businessSid |
|
|
|
* @param flowTaskVo |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean breakProcess(String businessSid, FlowTaskVo flowTaskVo) { |
|
|
|
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl=new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(flowTaskVo,fl); |
|
|
|
ResultBean resultBean = flowTaskFeign.breakProcess(fl); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
Map<String, Object> paramMap = new HashMap<>(); |
|
|
|
paramMap.put("sid", businessSid); |
|
|
|
paramMap.put("nodeState", String.valueOf(resultBean.getData())); |
|
|
|
paramMap.put("taskDefKey", "Event_end"); |
|
|
|
paramMap.put("flowState", SysFormLinkFlowStateEnum.BREAK.getCode()); |
|
|
|
updateFlowFiled(paramMap); |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 流程历史流转记录 |
|
|
|
* @param procInsId |
|
|
|
* @param deployId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean flowRecord(String procInsId, String deployId) { |
|
|
|
return flowTaskFeign.businessFlowRecord(procInsId,deployId); |
|
|
|
} |
|
|
|
} |