|
|
@ -26,21 +26,57 @@ |
|
|
|
package com.yxt.anrui.as.biz.asserviceaccommapply; |
|
|
|
|
|
|
|
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.anrui.as.api.asappendix.AsAppendix; |
|
|
|
import com.yxt.anrui.as.api.asbwinvoiceapply.AsBwinvoiceapply; |
|
|
|
import com.yxt.anrui.as.api.asbwinvoiceapply.AsBwinvoiceapplyFile; |
|
|
|
import com.yxt.anrui.as.api.asbwinvoiceapply.flowable.*; |
|
|
|
import com.yxt.anrui.as.api.asserviceaccomm.AsServiceAccommVo; |
|
|
|
import com.yxt.anrui.as.api.asserviceaccommapply.*; |
|
|
|
import com.yxt.anrui.as.api.asserviceaccommapply.flowable.*; |
|
|
|
import com.yxt.anrui.as.api.asserviceaccommdetail.AsServiceAccommDetailDetailsVo; |
|
|
|
import com.yxt.anrui.as.api.asserviceaccommdetail.AsServiceAccommDetailDto; |
|
|
|
import com.yxt.anrui.as.biz.asappendix.AsAppendixService; |
|
|
|
import com.yxt.anrui.as.biz.asserviceaccommdetail.AsServiceAccommDetailService; |
|
|
|
import com.yxt.anrui.as.feign.base.billno.Rule; |
|
|
|
import com.yxt.anrui.as.feign.file.AsFileEnum; |
|
|
|
import com.yxt.anrui.as.feign.flowable.flow.BusinessVariables; |
|
|
|
import com.yxt.anrui.as.feign.flowable.flow.FlowableFeign; |
|
|
|
import com.yxt.anrui.as.feign.flowable.flow.ProcDefEnum; |
|
|
|
import com.yxt.anrui.as.feign.flowable.flow.UpdateFlowFieldVo; |
|
|
|
import com.yxt.anrui.as.feign.flowable.flow2.FlowDelegateQuery; |
|
|
|
import com.yxt.anrui.as.feign.flowable.flow2.FlowFeign; |
|
|
|
import com.yxt.anrui.as.feign.flowable.flowtask.FlowTaskFeign; |
|
|
|
import com.yxt.anrui.as.feign.flowable.flowtask.FlowTaskVo; |
|
|
|
import com.yxt.anrui.as.feign.flowable.flowtask.LatestTaskVo; |
|
|
|
import com.yxt.anrui.as.feign.message.MessageFeign; |
|
|
|
import com.yxt.anrui.as.feign.message.MessageFlowVo; |
|
|
|
import com.yxt.anrui.as.feign.message.MessageFlowableQuery; |
|
|
|
import com.yxt.anrui.as.feign.portal.privilege.PrivilegeQuery; |
|
|
|
import com.yxt.anrui.as.feign.portal.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.anrui.as.feign.portal.sysorganization.SysOrganizationVo; |
|
|
|
import com.yxt.anrui.as.feign.portal.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.anrui.as.feign.portal.sysuser.SysUserFeign; |
|
|
|
import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
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 com.yxt.anrui.as.api.asserviceaccommapply.AsServiceAccommApply; |
|
|
|
import com.yxt.anrui.as.api.asserviceaccommapply.AsServiceAccommApplyQuery; |
|
|
|
import com.yxt.anrui.as.api.asserviceaccommapply.AsServiceAccommApplyVo; |
|
|
|
import com.yxt.anrui.as.api.asserviceaccommapply.AsServiceAccommApplyDetailsVo; |
|
|
|
import com.yxt.anrui.as.api.asserviceaccommapply.AsServiceAccommApplyDto; |
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
/** |
|
|
|
* Project: yxt-as(销售配件提成) <br/> |
|
|
|
* File: AsServiceAccommApplyService.java <br/> |
|
|
@ -56,35 +92,158 @@ import org.springframework.stereotype.Service; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class AsServiceAccommApplyService extends MybatisBaseService<AsServiceAccommApplyMapper, AsServiceAccommApply> { |
|
|
|
private QueryWrapper<AsServiceAccommApply> createQueryWrapper(AsServiceAccommApplyQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<AsServiceAccommApply> qw = new QueryWrapper<>(); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
@Autowired |
|
|
|
private AsServiceAccommDetailService asServiceAccommDetailService; |
|
|
|
@Autowired |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
@Autowired |
|
|
|
private AsAppendixService asAppendixService; |
|
|
|
@Autowired |
|
|
|
private FlowableFeign flowableFeign; |
|
|
|
@Autowired |
|
|
|
private FlowTaskFeign flowTaskFeign; |
|
|
|
@Autowired |
|
|
|
private FlowFeign flowFeign; |
|
|
|
@Autowired |
|
|
|
private MessageFeign messageFeign; |
|
|
|
|
|
|
|
public PagerVo<AsServiceAccommApplyVo> listPageVo(PagerQuery<AsServiceAccommApplyQuery> pq) { |
|
|
|
AsServiceAccommApplyQuery query = pq.getParams(); |
|
|
|
QueryWrapper<AsServiceAccommApply> qw = createQueryWrapper(query); |
|
|
|
QueryWrapper<AsServiceAccommApply> 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("aaa.createBySid", query.getUserSid()); |
|
|
|
} else { |
|
|
|
PagerVo<AsServiceAccommApplyVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} else { |
|
|
|
PagerVo<AsServiceAccommApplyVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getUseOrgName())) { |
|
|
|
qw.like("aaa.useOrgName", query.getUseOrgName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getDeptName())) { |
|
|
|
qw.like("aaa.deptName", query.getDeptName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCreateByName())) { |
|
|
|
qw.like("aaa.createByName", query.getCreateByName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getBillNo())) { |
|
|
|
qw.like("aaa.billNo", query.getBillNo()); |
|
|
|
} |
|
|
|
String createTimeStart = query.getCreateTimeStart(); |
|
|
|
String createTimeEnd = query.getCreateTimeEnd(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(createTimeStart), "date_format (aaa.createTime,'%Y-%m-%d') >= date_format('" + createTimeStart + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(createTimeEnd), "date_format (aaa.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 (aaa.finishTime,'%Y-%m-%d') >= date_format('" + finishTimeStart + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(finishTimeEnd), "date_format (aaa.finishTime,'%Y-%m-%d') <= date_format('" + finishTimeEnd + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
IPage<AsServiceAccommApply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<AsServiceAccommApplyVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<AsServiceAccommApplyVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(AsServiceAccommApplyDto dto){ |
|
|
|
public String saveOrUpdateDto(AsServiceAccommApplyDto dto){ |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
this.insertByDto(dto); |
|
|
|
return; |
|
|
|
List<AsServiceAccommDetailDto> asServiceAccommDetailList = dto.getAsServiceAccommDetailList(); |
|
|
|
List<AsServiceAccommFile> fileList = dto.getFileList(); |
|
|
|
String deptSid = dto.getDeptSid(); |
|
|
|
SysOrganizationVo deptVo = sysOrganizationFeign.fetchBySid(deptSid).getData(); |
|
|
|
String useOrgSid = sysStaffOrgFeign.getOrgSidByPath(deptVo.getOrgSidPath()).getData(); |
|
|
|
SysOrganizationVo organizationVo = sysOrganizationFeign.fetchBySid(useOrgSid).getData(); |
|
|
|
dto.setUseOrgSid(useOrgSid); |
|
|
|
dto.setUseOrgName(organizationVo.getName()); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
//生成单据编号
|
|
|
|
String billNo = ""; |
|
|
|
String date = DateUtil.format(DateUtil.date(), "yyyyMM"); |
|
|
|
billNo = "PJXSTC" + 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 (AsServiceAccommDetailDto asServiceAccommDetailDto : asServiceAccommDetailList) { |
|
|
|
asServiceAccommDetailDto.setMainSid(sid); |
|
|
|
asServiceAccommDetailService.insertByDto(asServiceAccommDetailDto); |
|
|
|
} |
|
|
|
for (AsServiceAccommFile asServiceAccommFile : fileList) { |
|
|
|
String filePath = asServiceAccommFile.getUrl().replace(fileUploadComponent.getUrlPrefix(), ""); |
|
|
|
AsAppendix asAppendix = new AsAppendix(); |
|
|
|
asAppendix.setLinkSid(sid); |
|
|
|
asAppendix.setAttachType(AsFileEnum.ASSERVICEACCOMMAPPLY.getAttachType()); |
|
|
|
asAppendix.setFilePath(filePath); |
|
|
|
asAppendixService.save(asAppendix); |
|
|
|
} |
|
|
|
return sid; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
asServiceAccommDetailService.delByMainSid(dtoSid); |
|
|
|
for (AsServiceAccommDetailDto asServiceAccommDetailDto : asServiceAccommDetailList) { |
|
|
|
asServiceAccommDetailDto.setMainSid(dtoSid); |
|
|
|
asServiceAccommDetailService.insertByDto(asServiceAccommDetailDto); |
|
|
|
} |
|
|
|
asAppendixService.delByLinkSid(dtoSid); |
|
|
|
for (AsServiceAccommFile asServiceAccommFile : fileList) { |
|
|
|
String filePath = asServiceAccommFile.getUrl().replace(fileUploadComponent.getUrlPrefix(), ""); |
|
|
|
AsAppendix asAppendix = new AsAppendix(); |
|
|
|
asAppendix.setLinkSid(dtoSid); |
|
|
|
asAppendix.setAttachType(AsFileEnum.ASSERVICEACCOMMAPPLY.getAttachType()); |
|
|
|
asAppendix.setFilePath(filePath); |
|
|
|
asAppendixService.save(asAppendix); |
|
|
|
} |
|
|
|
return dtoSid; |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(AsServiceAccommApplyDto dto){ |
|
|
|
public String insertByDto(AsServiceAccommApplyDto dto){ |
|
|
|
AsServiceAccommApply entity = new AsServiceAccommApply(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
entity.setNodeState("待提交"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
return entity.getSid(); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(AsServiceAccommApplyDto dto){ |
|
|
@ -101,6 +260,335 @@ public class AsServiceAccommApplyService extends MybatisBaseService<AsServiceAcc |
|
|
|
AsServiceAccommApply entity = fetchBySid(sid); |
|
|
|
AsServiceAccommApplyDetailsVo vo = new AsServiceAccommApplyDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
List<AsServiceAccommDetailDetailsVo> asServiceAccommDetailDetailsVos = asServiceAccommDetailService.selByMainSid(sid); |
|
|
|
vo.setAsServiceAccommDetailList(asServiceAccommDetailDetailsVos); |
|
|
|
List<AsAppendix> asAppendices = asAppendixService.fetchByLinkSid(sid); |
|
|
|
List<AsServiceAccommFile> asServiceAccommFiles = new ArrayList<>(); |
|
|
|
for (AsAppendix asAppendix : asAppendices) { |
|
|
|
AsServiceAccommFile asServiceAccommFile = new AsServiceAccommFile(); |
|
|
|
String url = fileUploadComponent.getUrlPrefix() + asAppendix.getFilePath(); |
|
|
|
asServiceAccommFile.setUrl(url); |
|
|
|
asServiceAccommFiles.add(asServiceAccommFile); |
|
|
|
} |
|
|
|
vo.setFileList(asServiceAccommFiles); |
|
|
|
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) { |
|
|
|
asServiceAccommDetailService.delByMainSid(sid); |
|
|
|
asAppendixService.delByLinkSid(sid); |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean submitApply(SubmitServiceAccommDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
AsServiceAccommApply asServiceAccommApply = fetchBySid(dto.getSid()); |
|
|
|
int r = submitBusinessData(dto, asServiceAccommApply); |
|
|
|
if (r == 3) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
if (r == 0) { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
String businessSid = saveOrUpdateDto(dto); |
|
|
|
asServiceAccommApply = 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(asServiceAccommApply.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.ASBWINVOICEAPPLY.getProDefId()); |
|
|
|
ResultBean<UpdateFlowFieldVo> voResultBean = flowFeign.startProcess(bv); |
|
|
|
if (!voResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(voResultBean.getMsg()); |
|
|
|
} |
|
|
|
UpdateFlowFieldVo ufVo = voResultBean.getData(); |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(ufVo)); |
|
|
|
asServiceAccommApply = 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()); |
|
|
|
AsServiceAccommApply finalAsServiceAccommApply = asServiceAccommApply; |
|
|
|
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(finalAsServiceAccommApply.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(asServiceAccommApply.getTaskId()); |
|
|
|
bv.setTaskDefKey(asServiceAccommApply.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(SubmitServiceAccommDto dto, AsServiceAccommApply asServiceAccommApply) { |
|
|
|
int r = 0; |
|
|
|
if (StringUtils.isBlank(dto.getSid())) { |
|
|
|
r = 1; |
|
|
|
} else { |
|
|
|
if (asServiceAccommApply != null) { |
|
|
|
String businessTaskId = asServiceAccommApply.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(); |
|
|
|
AsServiceAccommApply asServiceAccommApply = 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(asServiceAccommApply.getDeptSid()).getData(); |
|
|
|
if (sysOrganization != null) { |
|
|
|
bv.setOrgSidPath(sysOrganization.getOrgSidPath()); |
|
|
|
} |
|
|
|
bv.setModelId(asServiceAccommApply.getProcDefId()); |
|
|
|
if (bv.getTaskId().equals(asServiceAccommApply.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 { |
|
|
|
//极光推送
|
|
|
|
asServiceAccommApply = fetchBySid(businessSid); |
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
messageFlowVo.setProcDefId(asServiceAccommApply.getProcDefId()); |
|
|
|
messageFlowVo.setProcInsId(asServiceAccommApply.getProcInstId()); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap(appMap); |
|
|
|
messageFlowableQuery.setBusinessSid(businessSid); |
|
|
|
messageFlowableQuery.setModuleName("配件销售提成备案申请"); |
|
|
|
messageFlowableQuery.setMsgContent(asServiceAccommApply.getCreateByName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
messageFlowableQuery.setMsgTitle("配件销售提成备案申请"); |
|
|
|
ResultBean<String> stringResultBean = messageFeign.pushMessage(messageFlowableQuery); |
|
|
|
} |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<ServiceAccommNodeVo>> getPreviousNodesForReject(ServiceAccommNodeQuery query) { |
|
|
|
ResultBean<List<ServiceAccommNodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
AsServiceAccommApply asServiceAccommApply = fetchBySid(query.getBusinessSid()); |
|
|
|
bv.setModelId(asServiceAccommApply.getProcDefId()); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getPreviousNodesForReject(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给TemplateApplyNodeVo
|
|
|
|
List<ServiceAccommNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), ServiceAccommNodeVo.class)).collect(Collectors.toList()); |
|
|
|
return rb.success().setData(voList); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<ServiceAccommNodeVo>> getNextNodesForSubmit(ServiceAccommNodeQuery query) { |
|
|
|
ResultBean<List<ServiceAccommNodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
AsServiceAccommApply asServiceAccommApply = fetchBySid(query.getBusinessSid()); |
|
|
|
bv.setModelId(asServiceAccommApply.getProcDefId()); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getNextNodesForSubmit(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给TemplateApplyNodeVo
|
|
|
|
List<ServiceAccommNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), ServiceAccommNodeVo.class)).collect(Collectors.toList()); |
|
|
|
return rb.success().setData(voList); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean taskReject(ServiceAccommTaskQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String businessSid = query.getBusinessSid(); |
|
|
|
AsServiceAccommApply asServiceAccommApply = fetchBySid(businessSid); |
|
|
|
if (asServiceAccommApply == null) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
String businessTaskId = asServiceAccommApply.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); |
|
|
|
//极光推送
|
|
|
|
asServiceAccommApply = fetchBySid(businessSid); |
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
String procId = asServiceAccommApply.getProcInstId(); |
|
|
|
messageFlowVo.setProcInsId(procId); |
|
|
|
messageFlowVo.setProcDefId(asServiceAccommApply.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(asServiceAccommApply.getCreateByName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
} |
|
|
|
|
|
|
|
messageFlowableQuery.setMsgTitle("配件销售提成备案申请"); |
|
|
|
ResultBean<String> stringResultBean = messageFeign.pushMessage(messageFlowableQuery); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致!"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean revokeProcess(ServiceAccommTaskQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
AsServiceAccommApply asServiceAccommApply = fetchBySid(query.getBusinessSid()); |
|
|
|
String businessTaskId = asServiceAccommApply.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(ServiceAccommTaskQuery 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("请填写意见"); |
|
|
|
} |
|
|
|
AsServiceAccommApply asServiceAccommApply = fetchBySid(query.getBusinessSid()); |
|
|
|
String businessTaskId = asServiceAccommApply.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (query.getUserSid().equals(asServiceAccommApply.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(ServiceAccommDelegateQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
FlowDelegateQuery delegateQuery = new FlowDelegateQuery(); |
|
|
|
BeanUtil.copyProperties(query, delegateQuery); |
|
|
|
flowFeign.delegate(delegateQuery); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |