|
|
@ -1,18 +1,26 @@ |
|
|
|
package com.yxt.anrui.scm.biz.scmvehiclereturn; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.convert.Convert; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.flowable.api.flow.FlowableFeign; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.FlowTask; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.FlowTaskFeign; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.FlowTaskVo; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo; |
|
|
|
import com.yxt.anrui.flowable.api.sysformlink.SysFormLinkFeign; |
|
|
|
import com.yxt.anrui.flowable.api.sysformlink.SysFormLinkFlowStateEnum; |
|
|
|
import com.yxt.anrui.flowable.api.sysformlink.SysFormStateVo; |
|
|
|
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.scmvehiclereturn.ScmVehicleReturn; |
|
|
|
import com.yxt.anrui.scm.api.scmvehiclereturn.ScmVehicleReturnDto; |
|
|
|
import com.yxt.anrui.scm.api.scmvehiclereturn.ScmVehicleReturnQuery; |
|
|
|
import com.yxt.anrui.scm.api.scmvehiclereturn.ScmVehicleReturnVo; |
|
|
|
import com.yxt.anrui.scm.api.scmvehiclereturn.*; |
|
|
|
import com.yxt.anrui.scm.api.scmvehiclereturndetails.ScmVehicleReturnDetails; |
|
|
|
import com.yxt.anrui.scm.api.scmvehiclereturndetails.ScmVehicleReturnDetailssVo; |
|
|
|
import com.yxt.anrui.scm.biz.scmvehiclereturndetails.ScmVehicleReturnDetailsService; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
@ -25,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@ -47,6 +56,8 @@ public class ScmVehicleReturnService extends MybatisBaseService<ScmVehicleReturn |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private FlowableFeign flowableFeign; |
|
|
|
@Autowired |
|
|
|
private FlowTaskFeign flowTaskFeign; |
|
|
|
|
|
|
|
/** |
|
|
|
* 采购退库新增编辑 |
|
|
@ -61,7 +72,11 @@ public class ScmVehicleReturnService extends MybatisBaseService<ScmVehicleReturn |
|
|
|
if (StringUtils.isBlank(sid)) { |
|
|
|
//新增
|
|
|
|
ScmVehicleReturn scmVehicleReturn = new ScmVehicleReturn(); |
|
|
|
BeanUtils.copyProperties(scmVehicleReturnDto, scmVehicleReturn, scmVehicleReturn.getSid()); |
|
|
|
BeanUtils.copyProperties(scmVehicleReturnDto, scmVehicleReturn, "sid"); |
|
|
|
String money = scmVehicleReturnDto.getMoney(); |
|
|
|
BigDecimal mo = new BigDecimal(money); |
|
|
|
scmVehicleReturn.setMoney(mo); |
|
|
|
scmVehicleReturn.setApplicationName(scmVehicleReturnDto.getName()); |
|
|
|
boolean isSave = save(scmVehicleReturn); |
|
|
|
if (!isSave) { |
|
|
|
return rb.setMsg("保存失败"); |
|
|
@ -77,7 +92,16 @@ public class ScmVehicleReturnService extends MybatisBaseService<ScmVehicleReturn |
|
|
|
if (checkCouldChange(sid)) { |
|
|
|
return rb.setMsg("该条信息不可更改"); |
|
|
|
} |
|
|
|
int i = updateBySid(scmVehicleReturnDto, sid); |
|
|
|
ScmVehicleReturn scmVehicleReturn = fetchBySid(sid); |
|
|
|
if (scmVehicleReturn == null) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
BeanUtil.copyProperties(scmVehicleReturnDto, scmVehicleReturn, "id", "sid"); |
|
|
|
String money = scmVehicleReturnDto.getMoney(); |
|
|
|
BigDecimal mo = new BigDecimal(money); |
|
|
|
scmVehicleReturn.setMoney(mo); |
|
|
|
scmVehicleReturn.setApplicationName(scmVehicleReturnDto.getName()); |
|
|
|
baseMapper.updateById(scmVehicleReturn); |
|
|
|
//查询details中是否有关于return的该条sid数据
|
|
|
|
List<ScmVehicleReturnDetails> scmVehicleReturnDetailsList = scmVehicleReturnDetailsService.selectByReturnSid(sid); |
|
|
|
if (scmVehicleReturnDetailsList.size() > 0) { |
|
|
@ -119,9 +143,6 @@ public class ScmVehicleReturnService extends MybatisBaseService<ScmVehicleReturn |
|
|
|
if (resultBean.getSuccess() && resultBean.getData() != null) { |
|
|
|
SysFormStateVo formState = resultBean.getData(); |
|
|
|
voList.get(i).setNodeState(formState.getNodeState()); |
|
|
|
voList.get(i).setFlowState(formState.getFlowState()); |
|
|
|
} else { |
|
|
|
voList.get(i).setFlowState(0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -138,7 +159,14 @@ public class ScmVehicleReturnService extends MybatisBaseService<ScmVehicleReturn |
|
|
|
QueryWrapper<ScmVehicleReturnVo> qw = new QueryWrapper<>(); |
|
|
|
if (params != null) { |
|
|
|
//申请日期
|
|
|
|
//状态
|
|
|
|
qw.apply(StringUtils.isNotBlank(params.getApplyDateStart()), "date_format (sr.createTime,'%Y-%m-%d') >= date_format('" + params.getApplyDateStart() + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(params.getApplyDateEnd()), "date_format (sr.createTime,'%Y-%m-%d') <= date_format('" + params.getApplyDateEnd() + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
//状态:模糊查询
|
|
|
|
if(StringUtils.isNotBlank(params.getNodeState())){ |
|
|
|
qw.like("sr.nodeState", params.getNodeState()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return qw; |
|
|
|
} |
|
|
@ -153,12 +181,12 @@ public class ScmVehicleReturnService extends MybatisBaseService<ScmVehicleReturn |
|
|
|
variables.put("businessSid", businessSid); |
|
|
|
variables.put("isLoan", true); |
|
|
|
variables.put("orgSid", orgSid);//部门sid
|
|
|
|
ResultBean businessResultBean = flowableFeign.businessStart(ProcDefEnum.ORDERDEPOSITAPPROVE.getProDefId(), scmVehicleReturnDto.getUserSid(), variables); |
|
|
|
if (resultBean.getSuccess() && resultBean.getData() != null) { |
|
|
|
Map<String, String> map = (Map<String, String>) resultBean.getData(); |
|
|
|
ResultBean businessResultBean = flowableFeign.businessStart(ProcDefEnum.SCMVEHICLERETURN.getProDefId(), scmVehicleReturnDto.getUserSid(), variables); |
|
|
|
if (businessResultBean.getSuccess() && businessResultBean.getData() != null) { |
|
|
|
Map<String, String> map = (Map<String, String>) businessResultBean.getData(); |
|
|
|
//更新退库业务表中的流程状态
|
|
|
|
modifyFlowState(businessSid, |
|
|
|
ProcDefEnum.ORDERDEPOSITAPPROVE.getProDefId(),//procDefId
|
|
|
|
ProcDefEnum.SCMVEHICLERETURN.getProDefId(),//procDefId
|
|
|
|
map.get("nodeState"),//state
|
|
|
|
map.get("procInsId"),//procInstSid
|
|
|
|
map.get("taskDefKey")//nodeSid
|
|
|
@ -196,4 +224,127 @@ public class ScmVehicleReturnService extends MybatisBaseService<ScmVehicleReturn |
|
|
|
procInsId,//procInstSid
|
|
|
|
taskDefKey); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 办理流程 |
|
|
|
* |
|
|
|
* @param scmVehicleReturnFlowQuery 查询条件 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean complete(ScmVehicleReturnFlowQuery scmVehicleReturnFlowQuery) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
//查询对象转换为map集合
|
|
|
|
Map<String, Object> variables = Convert.toMap(String.class, Object.class, scmVehicleReturnFlowQuery); |
|
|
|
BusinessVariables bv = BusinessVariables.builder().build(); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
ResultBean<FlowTask> resultBean = flowTaskFeign.businessComplete(bv); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
String nodeState = ""; |
|
|
|
String taskDefKey = ""; |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("businessSid", 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"; |
|
|
|
map.put("flowState", SysFormLinkFlowStateEnum.FINISH.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
map.put("nodeState", nodeState); |
|
|
|
map.put("taskDefKey", taskDefKey); |
|
|
|
sysFormLinkFeign.updateFiled(map); |
|
|
|
return new ResultBean().success(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 驳回任务 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean reject(ScmVehicleReturnFlowDto dto) { |
|
|
|
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(dto, flowTaskVo); |
|
|
|
ResultBean<List<LatestTaskVo>> resultBean = flowTaskFeign.taskReject(flowTaskVo); |
|
|
|
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> map = new HashMap<>(); |
|
|
|
map.put("businessSid", dto.getBusinessSid()); |
|
|
|
map.put("nodeState", nodeState); |
|
|
|
map.put("taskDefKey", taskDefKey); |
|
|
|
if (incomingSourceRef.contains("start")) { |
|
|
|
map.put("flowState", SysFormLinkFlowStateEnum.REJECT.getCode()); |
|
|
|
} |
|
|
|
sysFormLinkFeign.updateFiled(map); |
|
|
|
return new ResultBean().success(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean breakProcess(ScmVehicleReturnFlowDto dto) { |
|
|
|
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(dto, flowTaskVo); |
|
|
|
ResultBean resultBean = flowTaskFeign.breakProcess(flowTaskVo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("businessSid", dto.getBusinessSid()); |
|
|
|
map.put("nodeState", String.valueOf(resultBean.getData())); |
|
|
|
map.put("taskDefKey", "Event_end"); |
|
|
|
map.put("flowState", SysFormLinkFlowStateEnum.BREAK.getCode()); |
|
|
|
sysFormLinkFeign.updateFiled(map); |
|
|
|
return resultBean.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean revokeProcess(ScmVehicleReturnFlowDto dto) { |
|
|
|
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(dto, flowTaskVo); |
|
|
|
ResultBean<List<LatestTaskVo>> resultBean = flowTaskFeign.revokeProcess(flowTaskVo); |
|
|
|
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> map = new HashMap<>(); |
|
|
|
map.put("businessSid", dto.getBusinessSid()); |
|
|
|
if (inComingSourceRef.contains("start")) { |
|
|
|
map.put("nodeState", SysFormLinkFlowStateEnum.UNCOMMITTED.getState()); |
|
|
|
map.put("taskDefKey", taskDefKey); |
|
|
|
map.put("flowState", SysFormLinkFlowStateEnum.UNCOMMITTED.getCode()); |
|
|
|
} else { |
|
|
|
map.put("nodeState", nodeState); |
|
|
|
map.put("taskDefKey", taskDefKey); |
|
|
|
} |
|
|
|
sysFormLinkFeign.updateFiled(map); |
|
|
|
return new ResultBean().success(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<ScmVehicleReturnDetailsVo> details(String sid) { |
|
|
|
ResultBean<ScmVehicleReturnDetailsVo> rb = ResultBean.fireFail(); |
|
|
|
ScmVehicleReturnDetailsVo vo = new ScmVehicleReturnDetailsVo(); |
|
|
|
if (StringUtils.isBlank(sid)) { |
|
|
|
//申请日期即为当天
|
|
|
|
vo.setCreateTime(DateUtil.today()); |
|
|
|
vo.setApplicationCode("CGTK" + DateUtil.format(DateUtil.date(), "yyyyMMdd")); |
|
|
|
} else { |
|
|
|
ScmVehicleReturn ScmVehicleReturn = fetchBySid(sid); |
|
|
|
if (ScmVehicleReturn == null) { |
|
|
|
return rb.setMsg("该采购退库申请不存在"); |
|
|
|
} |
|
|
|
vo = baseMapper.details(sid); |
|
|
|
List<ScmVehicleReturnDetailssVo> voList = scmVehicleReturnDetailsService.detailsList(sid); |
|
|
|
vo.setVoList(voList); |
|
|
|
} |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
} |
|
|
|