|
|
@ -1,18 +1,33 @@ |
|
|
|
package com.yxt.anrui.scm.biz.scmvehiclereturn; |
|
|
|
|
|
|
|
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.sysformlink.SysFormLinkFeign; |
|
|
|
import com.yxt.anrui.flowable.api.sysformlink.SysFormStateVo; |
|
|
|
import com.yxt.anrui.flowable.api.utils.procDefEnum; |
|
|
|
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.scmvehiclereturndetails.ScmVehicleReturnDetails; |
|
|
|
import com.yxt.anrui.scm.biz.scmvehiclereturndetails.ScmVehicleReturnDetailsService; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
|
import com.yxt.common.base.utils.StringUtils; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
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; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author dimengzhe |
|
|
@ -24,6 +39,14 @@ public class ScmVehicleReturnService extends MybatisBaseService<ScmVehicleReturn |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ScmVehicleReturnDetailsService scmVehicleReturnDetailsService; |
|
|
|
@Autowired |
|
|
|
private SysFormLinkFeign sysFormLinkFeign; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private FlowableFeign flowableFeign; |
|
|
|
|
|
|
|
/** |
|
|
|
* 采购退库新增编辑 |
|
|
@ -78,4 +101,99 @@ public class ScmVehicleReturnService extends MybatisBaseService<ScmVehicleReturn |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 分页列表 |
|
|
|
* |
|
|
|
* @param pagerQuery 查询条件 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public PagerVo<ScmVehicleReturnVo> listPage(PagerQuery<ScmVehicleReturnQuery> pagerQuery) { |
|
|
|
IPage<ScmVehicleReturnVo> page = pagerList(pagerQuery); |
|
|
|
PagerVo<ScmVehicleReturnVo> pv = new PagerVo<>(); |
|
|
|
PagerVo<ScmVehicleReturnVo> pv1 = PagerUtil.pageToVo(page, pv); |
|
|
|
List<ScmVehicleReturnVo> voList = pv1.getRecords(); |
|
|
|
if (voList.size() > 0) { |
|
|
|
for (int i = 0; i < voList.size(); i++) { |
|
|
|
ResultBean<SysFormStateVo> resultBean = sysFormLinkFeign.selectStateByBusinessSid(voList.get(i).getSid()); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return pv1; |
|
|
|
} |
|
|
|
|
|
|
|
private IPage<ScmVehicleReturnVo> pagerList(PagerQuery<ScmVehicleReturnQuery> pagerQuery) { |
|
|
|
IPage<ScmVehicleReturnVo> page = PagerUtil.queryToPage(pagerQuery); |
|
|
|
QueryWrapper<ScmVehicleReturnVo> qw = buildQueryWrapper(pagerQuery.getParams()); |
|
|
|
return baseMapper.pagerList(page, qw); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<ScmVehicleReturnVo> buildQueryWrapper(ScmVehicleReturnQuery params) { |
|
|
|
QueryWrapper<ScmVehicleReturnVo> qw = new QueryWrapper<>(); |
|
|
|
if (params != null) { |
|
|
|
//申请日期
|
|
|
|
//状态
|
|
|
|
} |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean submitVehicleReturn(ScmVehicleReturnDto scmVehicleReturnDto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String orgSid = checkUserOrg(scmVehicleReturnDto.getUserSid()); |
|
|
|
ResultBean resultBean = saveOrUpdateVehicleReturn(scmVehicleReturnDto); |
|
|
|
if (resultBean.getSuccess()) { |
|
|
|
String businessSid = resultBean.getData().toString(); |
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
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(); |
|
|
|
//更新退库业务表中的流程状态
|
|
|
|
modifyFlowState(businessSid, |
|
|
|
procDefEnum.ORDERDEPOSITAPPROVE.getProDefId(),//procDefId
|
|
|
|
map.get("nodeState"),//state
|
|
|
|
map.get("procInsId"),//procInstSid
|
|
|
|
map.get("taskDefKey")//nodeSid
|
|
|
|
); |
|
|
|
} |
|
|
|
} else { |
|
|
|
return rb.setMsg("失败"); |
|
|
|
} |
|
|
|
|
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询用户是否设置了部门 |
|
|
|
* |
|
|
|
* @param userSid 用户sid |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
private void modifyFlowState(String businessSid, String proDefId, String nodeState, |
|
|
|
String procInsId, |
|
|
|
String taskDefKey) { |
|
|
|
baseMapper.modifyFlowState(businessSid, |
|
|
|
proDefId,//procDefId
|
|
|
|
nodeState,//state
|
|
|
|
procInsId,//procInstSid
|
|
|
|
taskDefKey); |
|
|
|
} |
|
|
|
} |
|
|
|