|
|
@ -26,11 +26,26 @@ |
|
|
|
package com.yxt.anrui.scm.biz.scmcollectionrebatewithapply; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
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.flow.UpdateFlowFieldVo; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.FlowTaskFeign; |
|
|
|
import com.yxt.anrui.flowable.api.utils.ProcDefEnum; |
|
|
|
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; |
|
|
|
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrg; |
|
|
|
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserVo; |
|
|
|
import com.yxt.anrui.scm.api.flow.FlowTaskVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatewith.ScmCollectionRebateWith; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatewith.ScmCollectionRebateWithDetailsVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatewith.ScmCollectionRebateWithDto; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatewithapply.flow.GetNodeQuery; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatewithapply.flow.GetNodeVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatewithapply.flow.SubmitScmCollectionRebateWithApplyDto; |
|
|
|
import com.yxt.anrui.scm.biz.scmcollectionrebate.ScmCollectionRebateService; |
|
|
|
import com.yxt.anrui.scm.biz.scmcollectionrebatewith.ScmCollectionRebateWithService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
@ -48,8 +63,8 @@ import com.yxt.anrui.scm.api.scmcollectionrebatewithapply.ScmCollectionRebateWit |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* Project: anrui-scm(回款返利) <br/> |
|
|
@ -67,131 +82,371 @@ import java.util.List; |
|
|
|
@Service |
|
|
|
public class ScmCollectionRebateWithApplyService extends MybatisBaseService<ScmCollectionRebateWithApplyMapper, ScmCollectionRebateWithApply> { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ScmCollectionRebateWithService scmCollectionRebateWithService; |
|
|
|
|
|
|
|
private QueryWrapper<ScmCollectionRebateWithApply> createQueryWrapper(ScmCollectionRebateWithApplyQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<ScmCollectionRebateWithApply> qw = new QueryWrapper<>(); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<ScmCollectionRebateWithApplyVo> listPageVo(PagerQuery<ScmCollectionRebateWithApplyQuery> pq) { |
|
|
|
ScmCollectionRebateWithApplyQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmCollectionRebateWithApply> qw = new QueryWrapper<>(); |
|
|
|
if (StringUtils.isNotBlank(query.getBrandSid())) { |
|
|
|
qw.eq("scrwa.brandSid", query.getBrandSid()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCollectionApply())) { |
|
|
|
qw.like("scrwa.withApply", query.getCollectionApply()); |
|
|
|
} |
|
|
|
String createStartTime = query.getCreateStartTime(); |
|
|
|
String createEndTime = query.getCreateEndTime(); |
|
|
|
qw.apply(StringUtils.isNotBlank(createStartTime), "date_format (scrwa.createTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(createEndTime), "date_format (scrwa.createTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
qw.eq("scrwa.createOrgSid", query.getCreateOrgSid()); |
|
|
|
qw.groupBy("scrwa.sid"); |
|
|
|
qw.orderByDesc("scrwa.createTime"); |
|
|
|
IPage<ScmCollectionRebateWithApply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ScmCollectionRebateWithApplyVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<ScmCollectionRebateWithApplyVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean saveOrUpdateDto(ScmCollectionRebateWithApplyDto dto){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
List<ScmCollectionRebateWithDto> scmCollectionRebateWiths = dto.getScmCollectionRebateWiths(); |
|
|
|
if (scmCollectionRebateWiths == null) { |
|
|
|
return rb.setMsg("请选择回款返利信息"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
String sid = this.insertByDto(dto).getData(); |
|
|
|
for (ScmCollectionRebateWithDto scmCollectionRebateWithDto : scmCollectionRebateWiths) { |
|
|
|
List<String> collectionRebateSids = scmCollectionRebateWithDto.getCollectionRebateSids(); |
|
|
|
for (String collectionRebateSid : collectionRebateSids) { |
|
|
|
ScmCollectionRebateWith scmCollectionRebateWith = new ScmCollectionRebateWith(); |
|
|
|
scmCollectionRebateWith.setCollectionRebateSid(collectionRebateSid); |
|
|
|
scmCollectionRebateWith.setMainSid(sid); |
|
|
|
scmCollectionRebateWithService.save(scmCollectionRebateWith); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("添加成功").setData(sid); |
|
|
|
} |
|
|
|
ScmCollectionRebateWithApply scmCollectionRebateWithApply = fetchBySid(dtoSid); |
|
|
|
if (scmCollectionRebateWithApply == null) { |
|
|
|
rb.setMsg("该回款返利预提申请单不存在"); |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
scmCollectionRebateWithService.delByMainSid(dtoSid); |
|
|
|
for (ScmCollectionRebateWithDto scmCollectionRebateWithDto : scmCollectionRebateWiths) { |
|
|
|
List<String> collectionRebateSids = scmCollectionRebateWithDto.getCollectionRebateSids(); |
|
|
|
for (String collectionRebateSid : collectionRebateSids) { |
|
|
|
ScmCollectionRebateWith scmCollectionRebateWith = new ScmCollectionRebateWith(); |
|
|
|
scmCollectionRebateWith.setCollectionRebateSid(collectionRebateSid); |
|
|
|
scmCollectionRebateWith.setMainSid(dtoSid); |
|
|
|
scmCollectionRebateWithService.save(scmCollectionRebateWith); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("修改成功").setData(dtoSid); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<String> insertByDto(ScmCollectionRebateWithApplyDto dto){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
ScmCollectionRebateWithApply entity = new ScmCollectionRebateWithApply(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
entity.setNodeState("待提交"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
return rb.success().setData(entity.getSid()); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(ScmCollectionRebateWithApplyDto dto){ |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
@Autowired |
|
|
|
private ScmCollectionRebateWithService scmCollectionRebateWithService; |
|
|
|
@Autowired |
|
|
|
private ScmCollectionRebateService scmCollectionRebateService; |
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private FlowableFeign flowableFeign; |
|
|
|
@Autowired |
|
|
|
private FlowTaskFeign flowTaskFeign; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
|
|
|
|
private QueryWrapper<ScmCollectionRebateWithApply> createQueryWrapper(ScmCollectionRebateWithApplyQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<ScmCollectionRebateWithApply> qw = new QueryWrapper<>(); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<ScmCollectionRebateWithApplyVo> listPageVo(PagerQuery<ScmCollectionRebateWithApplyQuery> pq) { |
|
|
|
ScmCollectionRebateWithApplyQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmCollectionRebateWithApply> qw = new QueryWrapper<>(); |
|
|
|
if (StringUtils.isNotBlank(query.getBrandSid())) { |
|
|
|
qw.eq("scrwa.brandSid", query.getBrandSid()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCollectionApply())) { |
|
|
|
qw.like("scrwa.withApply", query.getCollectionApply()); |
|
|
|
} |
|
|
|
String createStartTime = query.getCreateStartTime(); |
|
|
|
String createEndTime = query.getCreateEndTime(); |
|
|
|
qw.apply(StringUtils.isNotBlank(createStartTime), "date_format (scrwa.createTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(createEndTime), "date_format (scrwa.createTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
qw.eq("scrwa.createOrgSid", query.getCreateOrgSid()); |
|
|
|
qw.groupBy("scrwa.sid"); |
|
|
|
qw.orderByDesc("scrwa.createTime"); |
|
|
|
IPage<ScmCollectionRebateWithApply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ScmCollectionRebateWithApplyVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<ScmCollectionRebateWithApplyVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean saveOrUpdateDto(ScmCollectionRebateWithApplyDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
List<ScmCollectionRebateWithDto> scmCollectionRebateWiths = dto.getScmCollectionRebateWiths(); |
|
|
|
if (scmCollectionRebateWiths == null) { |
|
|
|
return rb.setMsg("请选择回款返利信息"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
String sid = this.insertByDto(dto).getData(); |
|
|
|
for (ScmCollectionRebateWithDto scmCollectionRebateWithDto : scmCollectionRebateWiths) { |
|
|
|
List<String> collectionRebateSids = scmCollectionRebateWithDto.getCollectionRebateSids(); |
|
|
|
for (String collectionRebateSid : collectionRebateSids) { |
|
|
|
ScmCollectionRebateWith scmCollectionRebateWith = new ScmCollectionRebateWith(); |
|
|
|
scmCollectionRebateWith.setCollectionRebateSid(collectionRebateSid); |
|
|
|
scmCollectionRebateWith.setMainSid(sid); |
|
|
|
scmCollectionRebateWithService.save(scmCollectionRebateWith); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("添加成功").setData(sid); |
|
|
|
} |
|
|
|
ScmCollectionRebateWithApply scmCollectionRebateWithApply = fetchBySid(dtoSid); |
|
|
|
if (scmCollectionRebateWithApply == null) { |
|
|
|
rb.setMsg("该回款返利预提申请单不存在"); |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
scmCollectionRebateWithService.delByMainSid(dtoSid); |
|
|
|
for (ScmCollectionRebateWithDto scmCollectionRebateWithDto : scmCollectionRebateWiths) { |
|
|
|
List<String> collectionRebateSids = scmCollectionRebateWithDto.getCollectionRebateSids(); |
|
|
|
for (String collectionRebateSid : collectionRebateSids) { |
|
|
|
ScmCollectionRebateWith scmCollectionRebateWith = new ScmCollectionRebateWith(); |
|
|
|
scmCollectionRebateWith.setCollectionRebateSid(collectionRebateSid); |
|
|
|
scmCollectionRebateWith.setMainSid(dtoSid); |
|
|
|
scmCollectionRebateWithService.save(scmCollectionRebateWith); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("修改成功").setData(dtoSid); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<String> insertByDto(ScmCollectionRebateWithApplyDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
ScmCollectionRebateWithApply entity = new ScmCollectionRebateWithApply(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
entity.setNodeState("待提交"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
return rb.success().setData(entity.getSid()); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(ScmCollectionRebateWithApplyDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ScmCollectionRebateWithApply entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public ScmCollectionRebateWithApplyDetailsVo fetchDetailsVoBySid(String sid){ |
|
|
|
ScmCollectionRebateWithApply entity = fetchBySid(sid); |
|
|
|
ScmCollectionRebateWithApplyDetailsVo vo = new ScmCollectionRebateWithApplyDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean delAll(String[] sids) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
//查询该sid中是否有流程不是待提交的
|
|
|
|
int count = baseMapper.selectBySid(StringUtils.join(sids, ",")); |
|
|
|
if (count > 0) { |
|
|
|
return rb.setMsg("删除的数据中包含已经提交审批的数据,删除失败"); |
|
|
|
} |
|
|
|
delBySids(sids); |
|
|
|
for (String sid : sids) { |
|
|
|
scmCollectionRebateWithService.delByMainSid(sid); |
|
|
|
} |
|
|
|
return rb.success().setMsg("删除成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<ScmCollectionRebateWithApplyDetailsVo> fetchAllDetailsVo(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
ScmCollectionRebateWithApplyDetailsVo scmCollectionRebateWithApplyDetailsVo = new ScmCollectionRebateWithApplyDetailsVo(); |
|
|
|
ScmCollectionRebateWithApply scmCollectionRebateWithApply = fetchBySid(sid); |
|
|
|
BeanUtil.copyProperties(scmCollectionRebateWithApply, scmCollectionRebateWithApplyDetailsVo); |
|
|
|
List<ScmCollectionRebateWithDetailsVo> scmCollectionRebateWithDetailsVos = scmCollectionRebateWithService.fetchByMainSid(sid); |
|
|
|
for (ScmCollectionRebateWithDetailsVo scmCollectionRebateWithDetailsVo : scmCollectionRebateWithDetailsVos) { |
|
|
|
String[] specialRebateSids = scmCollectionRebateWithDetailsVo.getCollectionRebateSid().split(","); |
|
|
|
scmCollectionRebateWithDetailsVo.setCollectionRebateSids(Arrays.asList(specialRebateSids)); |
|
|
|
String withRebate = scmCollectionRebateWithDetailsVo.getWithRebate(); |
|
|
|
withRebate = withRebate.substring(0, withRebate.lastIndexOf(".")); |
|
|
|
scmCollectionRebateWithDetailsVo.setWithRebate(withRebate); |
|
|
|
} |
|
|
|
scmCollectionRebateWithApplyDetailsVo.setScmCollectionRebateWiths(scmCollectionRebateWithDetailsVos); |
|
|
|
return rb.success().setData(scmCollectionRebateWithApplyDetailsVo); |
|
|
|
} |
|
|
|
} |
|
|
|
ScmCollectionRebateWithApply entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public ScmCollectionRebateWithApplyDetailsVo fetchDetailsVoBySid(String sid) { |
|
|
|
ScmCollectionRebateWithApply entity = fetchBySid(sid); |
|
|
|
ScmCollectionRebateWithApplyDetailsVo vo = new ScmCollectionRebateWithApplyDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean delAll(String[] sids) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
//查询该sid中是否有流程不是待提交的
|
|
|
|
int count = baseMapper.selectBySid(StringUtils.join(sids, ",")); |
|
|
|
if (count > 0) { |
|
|
|
return rb.setMsg("删除的数据中包含已经提交审批的数据,删除失败"); |
|
|
|
} |
|
|
|
delBySids(sids); |
|
|
|
for (String sid : sids) { |
|
|
|
scmCollectionRebateWithService.delByMainSid(sid); |
|
|
|
} |
|
|
|
return rb.success().setMsg("删除成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<ScmCollectionRebateWithApplyDetailsVo> fetchAllDetailsVo(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
ScmCollectionRebateWithApplyDetailsVo scmCollectionRebateWithApplyDetailsVo = new ScmCollectionRebateWithApplyDetailsVo(); |
|
|
|
ScmCollectionRebateWithApply scmCollectionRebateWithApply = fetchBySid(sid); |
|
|
|
BeanUtil.copyProperties(scmCollectionRebateWithApply, scmCollectionRebateWithApplyDetailsVo); |
|
|
|
List<ScmCollectionRebateWithDetailsVo> scmCollectionRebateWithDetailsVos = scmCollectionRebateWithService.fetchByMainSid(sid); |
|
|
|
for (ScmCollectionRebateWithDetailsVo scmCollectionRebateWithDetailsVo : scmCollectionRebateWithDetailsVos) { |
|
|
|
String[] collectionRebateSids = scmCollectionRebateWithDetailsVo.getCollectionRebateSid().split(","); |
|
|
|
scmCollectionRebateWithDetailsVo.setCollectionRebateSids(Arrays.asList(collectionRebateSids)); |
|
|
|
String withRebate = scmCollectionRebateWithDetailsVo.getWithRebate(); |
|
|
|
withRebate = withRebate.substring(0, withRebate.lastIndexOf(".")); |
|
|
|
scmCollectionRebateWithDetailsVo.setWithRebate(withRebate); |
|
|
|
} |
|
|
|
scmCollectionRebateWithApplyDetailsVo.setScmCollectionRebateWiths(scmCollectionRebateWithDetailsVos); |
|
|
|
return rb.success().setData(scmCollectionRebateWithApplyDetailsVo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean submitCollectionRebateWithApply(SubmitScmCollectionRebateWithApplyDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
//根据用户sid获取staffSid
|
|
|
|
ResultBean<SysUserVo> userVoResultBean = sysUserFeign.fetchBySid(dto.getCreateBySid()); |
|
|
|
if (!userVoResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(userVoResultBean.getMsg()); |
|
|
|
} |
|
|
|
//根据staffSid获取用户的组织全路径
|
|
|
|
ResultBean<SysStaffOrg> orgByStaffSid = sysStaffOrgFeign.getOrgByStaffSid(userVoResultBean.getData().getStaffSid()); |
|
|
|
if (!orgByStaffSid.getSuccess()) { |
|
|
|
return rb.setMsg(orgByStaffSid.getMsg()); |
|
|
|
} |
|
|
|
//用户的组织全路径
|
|
|
|
String orgSidPath = orgByStaffSid.getData().getOrgSidPath(); |
|
|
|
ScmCollectionRebateWithApply scmCollectionRebateWithApply = fetchBySid(dto.getSid()); |
|
|
|
int r = submitBusinessData(dto, scmCollectionRebateWithApply); |
|
|
|
if (r == 3) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
if (r == 0) { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
//新增修改保存
|
|
|
|
ResultBean<String> resultBean = saveOrUpdateDto(dto); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
String businessSid = resultBean.getData(); |
|
|
|
//创建BusinessVariables实体对象
|
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
//流程中的参数赋值
|
|
|
|
Map<String, Object> variables = BeanUtil.beanToMap(dto); |
|
|
|
//若有网关,则赋值网关中判断的字段。
|
|
|
|
variables.put("businessSid", businessSid); |
|
|
|
//=====================添加app所需参数
|
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
//用户的部门全路径sid
|
|
|
|
bv.setOrgSidPath(orgSidPath); |
|
|
|
//业务sid
|
|
|
|
bv.setBusinessSid(businessSid); |
|
|
|
//用户sid
|
|
|
|
bv.setUserSid(dto.getCreateBySid()); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
//流程定义id
|
|
|
|
bv.setModelId(ProcDefEnum.SCMCOLLECTIONREBATEWITHAPPLY.getProDefId()); |
|
|
|
//获取回款返利sid
|
|
|
|
List<ScmCollectionRebateWithDto> scmCollectionRebateWiths = dto.getScmCollectionRebateWiths(); |
|
|
|
for (ScmCollectionRebateWithDto scmCollectionRebateWith : scmCollectionRebateWiths) { |
|
|
|
List<String> collectionRebateSids = scmCollectionRebateWith.getCollectionRebateSids(); |
|
|
|
for (String collectionRebateSid : collectionRebateSids) { |
|
|
|
scmCollectionRebateService.updateWithholdingDateBySid(collectionRebateSid); |
|
|
|
} |
|
|
|
} |
|
|
|
if (r == 1) { |
|
|
|
ResultBean<UpdateFlowFieldVo> voResultBean = flowableFeign.startProcess(bv); |
|
|
|
UpdateFlowFieldVo ufVo = voResultBean.getData(); |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(ufVo)); |
|
|
|
|
|
|
|
return voResultBean; |
|
|
|
} |
|
|
|
if (r == 2) { |
|
|
|
// ToDo:驳回到发起人后再次提交
|
|
|
|
if (StringUtils.isBlank(dto.getInstanceId())) { |
|
|
|
return rb.setMsg("参数错误:instanceId"); |
|
|
|
} |
|
|
|
bv.setTaskId(scmCollectionRebateWithApply.getTaskId()); |
|
|
|
bv.setTaskDefKey(scmCollectionRebateWithApply.getNodeSid()); |
|
|
|
bv.setComment(StringUtils.isNotBlank(dto.getComment()) ? dto.getComment() : "重新提交"); |
|
|
|
bv.setInstanceId(dto.getInstanceId()); |
|
|
|
return complete(bv); |
|
|
|
} |
|
|
|
return rb; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 判断提交的流程是否被允许 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private synchronized int submitBusinessData(SubmitScmCollectionRebateWithApplyDto dto, ScmCollectionRebateWithApply scmCollectionRebateWithApply) { |
|
|
|
int r = 0; |
|
|
|
if (StringUtils.isBlank(dto.getSid())) { |
|
|
|
r = 1; |
|
|
|
} else { |
|
|
|
if (scmCollectionRebateWithApply != null) { |
|
|
|
String businessTaskId = scmCollectionRebateWithApply.getTaskId(); |
|
|
|
if (StringUtils.isBlank(businessTaskId) && StringUtils.isBlank(dto.getTaskId())) { |
|
|
|
//新提交
|
|
|
|
r = 1; |
|
|
|
} else if (StringUtils.isNotBlank(businessTaskId) && businessTaskId.equals(dto.getTaskId())) { |
|
|
|
//二次提交//只有数据一致的时候才能进行下一步
|
|
|
|
r = 2; |
|
|
|
} |
|
|
|
} else { |
|
|
|
r = 3; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return r; |
|
|
|
} |
|
|
|
|
|
|
|
private int updateFlowFiled(Map<String, Object> beanToMap) { |
|
|
|
return baseMapper.updateFlowFiled(beanToMap); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean complete(BusinessVariables bv) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
ScmCollectionRebateWithApply scmCollectionRebateWithApply = fetchBySid(bv.getBusinessSid()); |
|
|
|
List<String> collectionRebateSids = scmCollectionRebateWithService.fetchCollectionReBateSidByMainSid(bv.getBusinessSid()); |
|
|
|
if (bv.getTaskId().equals(scmCollectionRebateWithApply.getTaskId())) { |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.handleProsess(bv); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
if ("Event_end".equals(resultBean.getData().getTaskDefKey())) { |
|
|
|
for (String collectionRebateSid : collectionRebateSids) { |
|
|
|
scmCollectionRebateService.updateState(collectionRebateSid); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean revokeProcess(FlowTaskVo query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
//根据业务sid查询排内购申请
|
|
|
|
ScmCollectionRebateWithApply scmCollectionRebateWithApply = fetchBySid(query.getBusinessSid()); |
|
|
|
String businessTaskId = scmCollectionRebateWithApply.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (businessTaskId.equals(query.getTaskId())) { |
|
|
|
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo flowTaskVo = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(query, flowTaskVo); |
|
|
|
flowTaskVo.setValues(BeanUtil.beanToMap(scmCollectionRebateWithApply)); |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.revokeProcess(flowTaskVo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.setMsg("操作失败,提交的数据不一致!"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean taskReject(FlowTaskVo query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
ScmCollectionRebateWithApply scmCollectionRebateWithApply = fetchBySid(query.getBusinessSid()); |
|
|
|
if (scmCollectionRebateWithApply == null) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
String businessTaskId = scmCollectionRebateWithApply.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (businessTaskId.equals(query.getTaskId())) { |
|
|
|
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo flowTaskVo = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(query, flowTaskVo); |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.taskReject(flowTaskVo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
Map<String, Object> map = BeanUtil.beanToMap(resultBean.getData()); |
|
|
|
//更新业务中的流程相关的参数
|
|
|
|
updateFlowFiled(map); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致!"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean breakProcess(FlowTaskVo query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(query.getInstanceId())) { |
|
|
|
return rb.setMsg("参数错误:instanceId"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
ScmCollectionRebateWithApply scmCollectionRebateWithApply = fetchBySid(query.getBusinessSid()); |
|
|
|
String businessTaskId = scmCollectionRebateWithApply.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (businessTaskId.equals(query.getTaskId())) { |
|
|
|
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo flowTaskVo = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(query, flowTaskVo); |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.breakProcess(flowTaskVo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致!"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean flowRecord(String procInsId) { |
|
|
|
return flowTaskFeign.businessFlowRecord(procInsId); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<GetNodeVo>> getNextNodesForSubmit(GetNodeQuery query) { |
|
|
|
ResultBean<List<GetNodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
bv.setModelId(ProcDefEnum.SCMCOLLECTIONREBATEWITHAPPLY.getProDefId()); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getNextNodesForSubmit(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|
|
|
List<GetNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), GetNodeVo.class)).collect(Collectors.toList()); |
|
|
|
// List<GetNodeVo> voList = resultBean.getData().stream().map(m -> JSON.parseObject(JSON.toJSONString(m), GetNodeVo.class)).collect(Collectors.toList());
|
|
|
|
return rb.success().setData(voList); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<GetNodeVo>> getPreviousNodesForReject(GetNodeQuery query) { |
|
|
|
ResultBean<List<GetNodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
bv.setModelId(ProcDefEnum.SCMCOLLECTIONREBATEWITHAPPLY.getProDefId()); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getPreviousNodesForReject(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|
|
|
List<GetNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), GetNodeVo.class)).collect(Collectors.toList()); |
|
|
|
// List<GetNodeVo> voList = resultBean.getData().stream().map(m -> JSON.parseObject(JSON.toJSONString(m), GetNodeVo.class)).collect(Collectors.toList());
|
|
|
|
return rb.success().setData(voList); |
|
|
|
} |
|
|
|
} |