|
|
@ -26,41 +26,187 @@ |
|
|
|
package com.yxt.wms.biz.inventory.wmsinventoryprofitout; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventoryprofitin.WmsInventoryProfitin; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventoryprofitin.WmsInventoryProfitinVo; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventoryprofitin.flowable.*; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventoryprofitindetail.WmsInventoryProfitinDetailDto; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventoryprofitindetail.WmsInventoryProfitinDetailService; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventoryprofitout.flowable.*; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventoryprofitoutdetail.WmsInventoryProfitoutDetailDetailsVo; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventoryprofitoutdetail.WmsInventoryProfitoutDetailDto; |
|
|
|
import com.yxt.wms.biz.inventory.wmsinventoryprofitoutdetail.WmsInventoryProfitoutDetailService; |
|
|
|
import com.yxt.wms.feign.flowable.flow.BusinessVariables; |
|
|
|
import com.yxt.wms.feign.flowable.flow.FlowableFeign; |
|
|
|
import com.yxt.wms.feign.flowable.flow.ProcDefEnum; |
|
|
|
import com.yxt.wms.feign.flowable.flow.UpdateFlowFieldVo; |
|
|
|
import com.yxt.wms.feign.flowable.flow2.FlowDelegateQuery; |
|
|
|
import com.yxt.wms.feign.flowable.flow2.FlowFeign; |
|
|
|
import com.yxt.wms.feign.flowable.flowtask.FlowTaskFeign; |
|
|
|
import com.yxt.wms.feign.flowable.flowtask.FlowTaskVo; |
|
|
|
import com.yxt.wms.feign.flowable.flowtask.LatestTaskVo; |
|
|
|
import com.yxt.wms.feign.message.MessageFeign; |
|
|
|
import com.yxt.wms.feign.message.MessageFlowVo; |
|
|
|
import com.yxt.wms.feign.message.MessageFlowableQuery; |
|
|
|
import com.yxt.wms.feign.portal.privilege.PrivilegeQuery; |
|
|
|
import com.yxt.wms.feign.portal.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.wms.feign.portal.sysorganization.SysOrganizationVo; |
|
|
|
import com.yxt.wms.feign.portal.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.wms.feign.portal.sysuser.SysUserFeign; |
|
|
|
import com.yxt.wms.utils.Rule; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
|
|
|
|
import org.apache.tomcat.util.threads.ThreadPoolExecutor; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class WmsInventoryProfitoutService extends MybatisBaseService<WmsInventoryProfitoutMapper, WmsInventoryProfitout> { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private FlowableFeign flowableFeign; |
|
|
|
@Autowired |
|
|
|
private FlowTaskFeign flowTaskFeign; |
|
|
|
@Autowired |
|
|
|
private FlowFeign flowFeign; |
|
|
|
@Autowired |
|
|
|
private MessageFeign messageFeign; |
|
|
|
@Autowired |
|
|
|
private WmsInventoryProfitoutDetailService wmsInventoryProfitoutDetailService; |
|
|
|
|
|
|
|
public PagerVo<WmsInventoryProfitoutVo> listPageVo(PagerQuery<WmsInventoryProfitoutQuery> pq) { |
|
|
|
WmsInventoryProfitoutQuery query = pq.getParams(); |
|
|
|
QueryWrapper<WmsInventoryProfitout> qw = new QueryWrapper<>(); |
|
|
|
//========================================数据授权开始
|
|
|
|
if (StringUtils.isNotBlank(query.getMenuUrl())) { |
|
|
|
PrivilegeQuery privilegeQuery = new PrivilegeQuery(); |
|
|
|
privilegeQuery.setOrgPath(query.getOrgPath()); |
|
|
|
privilegeQuery.setMenuUrl(query.getMenuUrl()); |
|
|
|
privilegeQuery.setUserSid(query.getUserSid()); |
|
|
|
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery); |
|
|
|
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) { |
|
|
|
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
|
|
|
|
String orgSidPath = query.getOrgPath(); |
|
|
|
orgSidPath = orgSidPath + "/"; |
|
|
|
int i1 = orgSidPath.indexOf("/"); |
|
|
|
int i2 = orgSidPath.indexOf("/", i1 + 1); |
|
|
|
int i3 = orgSidPath.indexOf("/", i2 + 1); |
|
|
|
int i4 = orgSidPath.indexOf("/", i3 + 1); |
|
|
|
String orgLevelKey = defaultIdReltBean.getData(); |
|
|
|
if ("1".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i1); |
|
|
|
qw.like("s.orgSidPath", orgSidPath); |
|
|
|
} else if ("2".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i2); |
|
|
|
qw.like("s.orgSidPath", orgSidPath); |
|
|
|
} else if ("3".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i3); |
|
|
|
qw.like("s.orgSidPath", orgSidPath); |
|
|
|
} else if ("4".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i4); |
|
|
|
qw.like("s.orgSidPath", orgSidPath); |
|
|
|
} else if ("5".equals(orgLevelKey)) { |
|
|
|
qw.eq("wip.createBySid", query.getUserSid()); |
|
|
|
} else { |
|
|
|
PagerVo<WmsInventoryProfitoutVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} else { |
|
|
|
PagerVo<WmsInventoryProfitoutVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getDeptName())) { |
|
|
|
qw.like("wip.deptName", query.getDeptName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCreateByName())) { |
|
|
|
qw.like("wip.createByName", query.getCreateByName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getBillNo())) { |
|
|
|
qw.like("wip.billNo", query.getBillNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCheckBillNo())){ |
|
|
|
qw.like("wip.checkBillNo",query.getCheckBillNo()); |
|
|
|
} |
|
|
|
String createTimeStart = query.getCreateTimeStart(); |
|
|
|
String createTimeEnd = query.getCreateTimeEnd(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(createTimeStart), "date_format (wip.createTime,'%Y-%m-%d') >= date_format('" + createTimeStart + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(createTimeEnd), "date_format (wip.createTime,'%Y-%m-%d') <= date_format('" + createTimeEnd + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
String finishTimeStart = query.getFinishTimeStart(); |
|
|
|
String finishTimeEnd = query.getFinishTimeEnd(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(finishTimeStart), "date_format (wip.finishTime,'%Y-%m-%d') >= date_format('" + finishTimeStart + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(finishTimeEnd), "date_format (wip.finishTime,'%Y-%m-%d') <= date_format('" + finishTimeEnd + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
IPage<WmsInventoryProfitout> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<WmsInventoryProfitoutVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<WmsInventoryProfitoutVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(WmsInventoryProfitoutDto dto){ |
|
|
|
public ResultBean<String> saveOrUpdateDto(WmsInventoryProfitoutDto dto){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
List<WmsInventoryProfitoutDetailDto> wmsInventoryProfitoutDetailList = dto.getWmsInventoryProfitoutDetailList(); |
|
|
|
String deptSid = dto.getDeptSid(); |
|
|
|
SysOrganizationVo deptVo = sysOrganizationFeign.fetchBySid(deptSid).getData(); |
|
|
|
String createOrgSid = sysStaffOrgFeign.getOrgSidByPath(deptVo.getOrgSidPath()).getData(); |
|
|
|
SysOrganizationVo organizationVo = sysOrganizationFeign.fetchBySid(createOrgSid).getData(); |
|
|
|
dto.setCreateOrgSid(createOrgSid); |
|
|
|
dto.setCreateOrgName(organizationVo.getName()); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
this.insertByDto(dto); |
|
|
|
return; |
|
|
|
//生成单据编号
|
|
|
|
String billNo = ""; |
|
|
|
String date = DateUtil.format(DateUtil.date(), "yyyyMM"); |
|
|
|
billNo = "PKCK" + organizationVo.getOrgCode() + date; |
|
|
|
String i = baseMapper.selectNum(billNo); |
|
|
|
if (StringUtils.isNotBlank(i)) { |
|
|
|
billNo = Rule.getBillNo(billNo, Integer.valueOf(i).intValue()); |
|
|
|
} else { |
|
|
|
billNo = Rule.getBillNo(billNo, 0); |
|
|
|
} |
|
|
|
dto.setBillNo(billNo); |
|
|
|
String sid = this.insertByDto(dto); |
|
|
|
for (WmsInventoryProfitoutDetailDto wmsInventoryProfitoutDetailDto : wmsInventoryProfitoutDetailList) { |
|
|
|
wmsInventoryProfitoutDetailDto.setMainSid(sid); |
|
|
|
wmsInventoryProfitoutDetailService.insertByDto(wmsInventoryProfitoutDetailDto); |
|
|
|
} |
|
|
|
return rb.success().setData(sid); |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
wmsInventoryProfitoutDetailService.delByMainSid(dtoSid); |
|
|
|
for (WmsInventoryProfitoutDetailDto wmsInventoryProfitoutDetailDto : wmsInventoryProfitoutDetailList) { |
|
|
|
wmsInventoryProfitoutDetailDto.setMainSid(dtoSid); |
|
|
|
wmsInventoryProfitoutDetailService.insertByDto(wmsInventoryProfitoutDetailDto); |
|
|
|
} |
|
|
|
return rb.success().setData(dtoSid); |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(WmsInventoryProfitoutDto dto){ |
|
|
|
public String insertByDto(WmsInventoryProfitoutDto dto){ |
|
|
|
WmsInventoryProfitout entity = new WmsInventoryProfitout(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
entity.setNodeState("待提交"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
return entity.getSid(); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(WmsInventoryProfitoutDto dto){ |
|
|
@ -77,6 +223,325 @@ public class WmsInventoryProfitoutService extends MybatisBaseService<WmsInventor |
|
|
|
WmsInventoryProfitout entity = fetchBySid(sid); |
|
|
|
WmsInventoryProfitoutDetailsVo vo = new WmsInventoryProfitoutDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
List<WmsInventoryProfitoutDetailDetailsVo> wmsInventoryProfitoutDetailDetailsVos = wmsInventoryProfitoutDetailService.selByMainSid(sid); |
|
|
|
vo.setWmsInventoryProfitoutDetailList(wmsInventoryProfitoutDetailDetailsVos); |
|
|
|
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) { |
|
|
|
wmsInventoryProfitoutDetailService.delByMainSid(sid); |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean submitApply(SubmitInventoryProfitoutDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
WmsInventoryProfitout wmsInventoryProfitout = fetchBySid(dto.getSid()); |
|
|
|
int r = submitBusinessData(dto, wmsInventoryProfitout); |
|
|
|
if (r == 3) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
if (r == 0) { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
String businessSid = saveOrUpdateDto(dto).getData(); |
|
|
|
wmsInventoryProfitout = fetchBySid(businessSid); |
|
|
|
//创建BusinessVariables实体对象
|
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
//用户的部门全路径sid
|
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(wmsInventoryProfitout.getDeptSid()).getData(); |
|
|
|
if (sysOrganization != null) { |
|
|
|
bv.setOrgSidPath(sysOrganization.getOrgSidPath()); |
|
|
|
} |
|
|
|
bv.setBusinessSid(businessSid); |
|
|
|
bv.setUserSid(dto.getCreateBySid()); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
if (r == 1) { |
|
|
|
//ToDo:流程定义id
|
|
|
|
bv.setModelId(ProcDefEnum.WMSINVENTORYPROFITOUT.getProDefId()); |
|
|
|
ResultBean<UpdateFlowFieldVo> voResultBean = flowFeign.startProcess(bv); |
|
|
|
if (!voResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(voResultBean.getMsg()); |
|
|
|
} |
|
|
|
UpdateFlowFieldVo ufVo = voResultBean.getData(); |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(ufVo)); |
|
|
|
wmsInventoryProfitout = fetchBySid(businessSid); |
|
|
|
//==================================添加线程
|
|
|
|
try { |
|
|
|
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() |
|
|
|
.setNameFormat("demo-pool-%d").build(); |
|
|
|
ExecutorService pool = new ThreadPoolExecutor(2, 100, |
|
|
|
0L, TimeUnit.MILLISECONDS, |
|
|
|
new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); |
|
|
|
WmsInventoryProfitout finalWmsInventoryProfitout = wmsInventoryProfitout; |
|
|
|
Future future1 = pool.submit(() -> { |
|
|
|
//极光推送
|
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap(appMap); |
|
|
|
messageFlowableQuery.setBusinessSid(businessSid); |
|
|
|
messageFlowableQuery.setModuleName("盘亏出库申请"); |
|
|
|
messageFlowableQuery.setMsgContent(finalWmsInventoryProfitout.getCreateByName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
messageFlowableQuery.setMsgTitle("盘亏出库申请"); |
|
|
|
ResultBean<String> stringResultBean = messageFeign.pushMessage(messageFlowableQuery); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
//==================================添加线程
|
|
|
|
return voResultBean; |
|
|
|
} |
|
|
|
if (r == 2) { |
|
|
|
// ToDo:驳回到发起人后再次提交
|
|
|
|
if (StringUtils.isBlank(dto.getInstanceId())) { |
|
|
|
return rb.setMsg("参数错误:instanceId"); |
|
|
|
} |
|
|
|
bv.setTaskId(wmsInventoryProfitout.getTaskId()); |
|
|
|
bv.setTaskDefKey(wmsInventoryProfitout.getNodeId()); |
|
|
|
bv.setComment("重新提交"); |
|
|
|
bv.setInstanceId(dto.getInstanceId()); |
|
|
|
return complete(bv); |
|
|
|
} |
|
|
|
return rb; |
|
|
|
} |
|
|
|
|
|
|
|
private int updateFlowFiled(Map<String, Object> beanToMap) { |
|
|
|
return baseMapper.updateFlowFiled(beanToMap); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int submitBusinessData(SubmitInventoryProfitoutDto dto, WmsInventoryProfitout wmsInventoryProfitout) { |
|
|
|
int r = 0; |
|
|
|
if (StringUtils.isBlank(dto.getSid())) { |
|
|
|
r = 1; |
|
|
|
} else { |
|
|
|
if (wmsInventoryProfitout != null) { |
|
|
|
String businessTaskId = wmsInventoryProfitout.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; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean complete(BusinessVariables bv) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String businessSid = bv.getBusinessSid(); |
|
|
|
WmsInventoryProfitout wmsInventoryProfitout = fetchBySid(businessSid); |
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(wmsInventoryProfitout.getDeptSid()).getData(); |
|
|
|
if (sysOrganization != null) { |
|
|
|
bv.setOrgSidPath(sysOrganization.getOrgSidPath()); |
|
|
|
} |
|
|
|
bv.setModelId(wmsInventoryProfitout.getProcDefId()); |
|
|
|
if (bv.getTaskId().equals(wmsInventoryProfitout.getTaskId())) { |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowFeign.handleProsess(bv); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
UpdateFlowFieldVo ufVo = resultBean.getData(); |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
if ("Event_end".equals(resultBean.getData().getTaskDefKey())) { |
|
|
|
|
|
|
|
} else { |
|
|
|
//极光推送
|
|
|
|
wmsInventoryProfitout = fetchBySid(businessSid); |
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
messageFlowVo.setProcDefId(wmsInventoryProfitout.getProcDefId()); |
|
|
|
messageFlowVo.setProcInsId(wmsInventoryProfitout.getProcInstId()); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap(appMap); |
|
|
|
messageFlowableQuery.setBusinessSid(businessSid); |
|
|
|
messageFlowableQuery.setModuleName("盘亏出库申请"); |
|
|
|
messageFlowableQuery.setMsgContent(wmsInventoryProfitout.getCreateByName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
messageFlowableQuery.setMsgTitle("盘亏出库申请"); |
|
|
|
ResultBean<String> stringResultBean = messageFeign.pushMessage(messageFlowableQuery); |
|
|
|
} |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<InventoryProfitoutNodeVo>> getPreviousNodesForReject(InventoryProfitoutNodeQuery query) { |
|
|
|
ResultBean<List<InventoryProfitoutNodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
WmsInventoryProfitout wmsInventoryProfitout = fetchBySid(query.getBusinessSid()); |
|
|
|
bv.setModelId(wmsInventoryProfitout.getProcDefId()); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getPreviousNodesForReject(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给TemplateApplyNodeVo
|
|
|
|
List<InventoryProfitoutNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), InventoryProfitoutNodeVo.class)).collect(Collectors.toList()); |
|
|
|
return rb.success().setData(voList); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<InventoryProfitoutNodeVo>> getNextNodesForSubmit(InventoryProfitoutNodeQuery query) { |
|
|
|
ResultBean<List<InventoryProfitoutNodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
WmsInventoryProfitout wmsInventoryProfitout = fetchBySid(query.getBusinessSid()); |
|
|
|
bv.setModelId(wmsInventoryProfitout.getProcDefId()); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getNextNodesForSubmit(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给TemplateApplyNodeVo
|
|
|
|
List<InventoryProfitoutNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), InventoryProfitoutNodeVo.class)).collect(Collectors.toList()); |
|
|
|
return rb.success().setData(voList); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean taskReject(InventoryProfitoutTaskQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String businessSid = query.getBusinessSid(); |
|
|
|
WmsInventoryProfitout wmsInventoryProfitout = fetchBySid(businessSid); |
|
|
|
if (wmsInventoryProfitout == null) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
String businessTaskId = wmsInventoryProfitout.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (businessTaskId.equals(query.getTaskId())) { |
|
|
|
if (StringUtils.isBlank(query.getComment())) { |
|
|
|
return rb.setMsg("请填写意见"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(query, flowTaskVo); |
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.taskReject(flowTaskVo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
UpdateFlowFieldVo ufVo = resultBean.getData(); |
|
|
|
Map<String, Object> map = BeanUtil.beanToMap(ufVo); |
|
|
|
//更新业务中的流程相关的参数
|
|
|
|
updateFlowFiled(map); |
|
|
|
//极光推送
|
|
|
|
wmsInventoryProfitout = fetchBySid(businessSid); |
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
String procId = wmsInventoryProfitout.getProcInstId(); |
|
|
|
messageFlowVo.setProcInsId(procId); |
|
|
|
messageFlowVo.setProcDefId(wmsInventoryProfitout.getProcDefId()); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap(appMap); |
|
|
|
messageFlowableQuery.setBusinessSid(businessSid); |
|
|
|
messageFlowableQuery.setModuleName("盘亏出库申请"); |
|
|
|
ResultBean<List<LatestTaskVo>> listResultBean = flowTaskFeign.getLatestTasks(procId); |
|
|
|
String nextName = listResultBean.getData().get(0).getName_(); |
|
|
|
String nextNodeUserSids = listResultBean.getData().get(0).getASSIGNEE_(); |
|
|
|
if ("发起申请".equals(nextName)) { |
|
|
|
messageFlowableQuery.setMsgContent("您提交的" + messageFlowableQuery.getModuleName() + "已被驳回,请重新提交"); |
|
|
|
} else { |
|
|
|
messageFlowableQuery.setMsgContent(wmsInventoryProfitout.getCreateByName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
} |
|
|
|
|
|
|
|
messageFlowableQuery.setMsgTitle("盘亏出库申请"); |
|
|
|
ResultBean<String> stringResultBean = messageFeign.pushMessage(messageFlowableQuery); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致!"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean revokeProcess(InventoryProfitoutTaskQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
WmsInventoryProfitout wmsInventoryProfitout = fetchBySid(query.getBusinessSid()); |
|
|
|
String businessTaskId = wmsInventoryProfitout.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (businessTaskId.equals(query.getTaskId())) { |
|
|
|
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(query, flowTaskVo); |
|
|
|
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 breakProcess(InventoryProfitoutTaskQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(query.getInstanceId())) { |
|
|
|
return rb.setMsg("参数错误:instanceId"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(query.getComment())) { |
|
|
|
return rb.setMsg("请填写意见"); |
|
|
|
} |
|
|
|
WmsInventoryProfitout wmsInventoryProfitout = fetchBySid(query.getBusinessSid()); |
|
|
|
String businessTaskId = wmsInventoryProfitout.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (query.getUserSid().equals(wmsInventoryProfitout.getCreateBySid())) { |
|
|
|
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(query, flowTaskVo); |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.breakProcess(flowTaskVo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
Map<String, Object> map = BeanUtil.beanToMap(resultBean.getData()); |
|
|
|
updateFlowFiled(map); |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} else { |
|
|
|
if (businessTaskId.equals(query.getTaskId())) { |
|
|
|
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|
|
|
BeanUtil.copyProperties(query, flowTaskVo); |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.breakProcess(flowTaskVo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
Map<String, Object> map = BeanUtil.beanToMap(resultBean.getData()); |
|
|
|
updateFlowFiled(map); |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致!"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean delegate(InventoryProfitoutDelegateQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
FlowDelegateQuery delegateQuery = new FlowDelegateQuery(); |
|
|
|
BeanUtil.copyProperties(query, delegateQuery); |
|
|
|
flowFeign.delegate(delegateQuery); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |