|
|
@ -26,21 +26,47 @@ |
|
|
|
package com.yxt.sms.biz.smspricestrategybill; |
|
|
|
|
|
|
|
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.sms.biz.smspricestrategybill.flowable.*; |
|
|
|
import com.yxt.sms.biz.smspricestrategybilldetail.SmsPricestrategyBillDetailDetailsVo; |
|
|
|
import com.yxt.sms.biz.smspricestrategybilldetail.SmsPricestrategyBillDetailDto; |
|
|
|
import com.yxt.sms.biz.smspricestrategybilldetail.SmsPricestrategyBillDetailService; |
|
|
|
import com.yxt.sms.biz.smspricestrategybillgoodstypedetail.SmsPricestrategyBillGoodstypedetailDetailsVo; |
|
|
|
import com.yxt.sms.biz.smspricestrategybillgoodstypedetail.SmsPricestrategyBillGoodstypedetailDto; |
|
|
|
import com.yxt.sms.biz.smspricestrategybillgoodstypedetail.SmsPricestrategyBillGoodstypedetailService; |
|
|
|
import com.yxt.sms.feign.base.Rule; |
|
|
|
import com.yxt.sms.feign.flowable.flow.*; |
|
|
|
import com.yxt.sms.feign.flowable.flow2.FlowDelegateQuery; |
|
|
|
import com.yxt.sms.feign.flowable.flow2.FlowFeign; |
|
|
|
import com.yxt.sms.feign.flowable.flowtask.FlowTaskFeign; |
|
|
|
import com.yxt.sms.feign.flowable.flowtask.FlowTaskVo; |
|
|
|
import com.yxt.sms.feign.flowable.flowtask.LatestTaskVo; |
|
|
|
import com.yxt.sms.feign.message.MessageFeign; |
|
|
|
import com.yxt.sms.feign.message.MessageFlowVo; |
|
|
|
import com.yxt.sms.feign.message.MessageFlowableQuery; |
|
|
|
import com.yxt.sms.feign.portal.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.sms.feign.portal.sysorganization.SysOrganizationVo; |
|
|
|
import com.yxt.sms.feign.portal.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.sms.feign.privilege.PrivilegeQuery; |
|
|
|
import com.yxt.sms.feign.sysuser.SysUserFeign; |
|
|
|
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.List; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* Project: yxt-sms(价格策略) <br/> |
|
|
@ -60,38 +86,163 @@ public class SmsPricestrategyBillService extends MybatisBaseService<SmsPricestra |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SmsPricestrategyBillDetailService smsPricestrategyBillDetailService; |
|
|
|
@Autowired |
|
|
|
private SmsPricestrategyBillGoodstypedetailService smsPricestrategyBillGoodstypedetailService; |
|
|
|
@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private FlowableFeign flowableFeign; |
|
|
|
@Autowired |
|
|
|
private FlowTaskFeign flowTaskFeign; |
|
|
|
@Autowired |
|
|
|
private FlowFeign flowFeign; |
|
|
|
@Autowired |
|
|
|
private MessageFeign messageFeign; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
|
|
|
|
public PagerVo<SmsPricestrategyBillVo> listPageVo(PagerQuery<SmsPricestrategyBillQuery> pq) { |
|
|
|
SmsPricestrategyBillQuery query = pq.getParams(); |
|
|
|
QueryWrapper<SmsPricestrategyBill> 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("sb.createBySid", query.getUserSid()); |
|
|
|
} else { |
|
|
|
PagerVo<SmsPricestrategyBillVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} else { |
|
|
|
PagerVo<SmsPricestrategyBillVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getUseOrgName())) { |
|
|
|
qw.like("sb.useOrgName", query.getUseOrgName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getDeptName())) { |
|
|
|
qw.like("sb.deptName", query.getDeptName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCreateByName())) { |
|
|
|
qw.like("sb.createByName", query.getCreateByName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getBillNo())) { |
|
|
|
qw.like("sb.billNo", query.getBillNo()); |
|
|
|
} |
|
|
|
String createStartTime = query.getCreateStartTime(); |
|
|
|
String createEndTime = query.getCreateEndTime(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(createStartTime), "date_format (sb.createTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(createEndTime), "date_format (sb.createTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
String finishStartTime = query.getFinishStartTime(); |
|
|
|
String finishEndTime = query.getFinishEndTime(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(finishStartTime), "date_format (sb.finishTime,'%Y-%m-%d') >= date_format('" + finishStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(finishEndTime), "date_format (sb.finishTime,'%Y-%m-%d') <= date_format('" + finishEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
qw.orderByDesc("sb.createTime"); |
|
|
|
IPage<SmsPricestrategyBill> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<SmsPricestrategyBillVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<SmsPricestrategyBillVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(SmsPricestrategyBillDto dto){ |
|
|
|
public String saveOrUpdateDto(SmsPricestrategyBillDto dto){ |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
List<SmsPricestrategyBillDetailDto> smsPricestrategyBillDetailList = dto.getSmsPricestrategyBillDetailList(); |
|
|
|
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 = "JGCL" + 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 (SmsPricestrategyBillDetailDto smsPricestrategyBillDetailDto : smsPricestrategyBillDetailList) { |
|
|
|
smsPricestrategyBillDetailDto.setMainSid(sid); |
|
|
|
smsPricestrategyBillDetailService.saveOrUpdateDto(smsPricestrategyBillDetailDto); |
|
|
|
String sid1 = smsPricestrategyBillDetailService.saveOrUpdateDto(smsPricestrategyBillDetailDto); |
|
|
|
if (smsPricestrategyBillDetailDto.getStrategyType() == 0){ |
|
|
|
SmsPricestrategyBillGoodstypedetailDto smsPricestrategyBillGoodstypedetailDto = new SmsPricestrategyBillGoodstypedetailDto(); |
|
|
|
smsPricestrategyBillGoodstypedetailDto.setDetailSid(sid1); |
|
|
|
smsPricestrategyBillGoodstypedetailDto.setMarkupRate(smsPricestrategyBillDetailDto.getGdMarkupRate()); |
|
|
|
smsPricestrategyBillGoodstypedetailService.saveOrUpdateDto(smsPricestrategyBillGoodstypedetailDto); |
|
|
|
}else { |
|
|
|
List<SmsPricestrategyBillGoodstypedetailDto> smsPricestrategyBillGoodstypedetailList = smsPricestrategyBillDetailDto.getSmsPricestrategyBillGoodstypedetailList(); |
|
|
|
for (SmsPricestrategyBillGoodstypedetailDto smsPricestrategyBillGoodstypedetailDto : smsPricestrategyBillGoodstypedetailList) { |
|
|
|
smsPricestrategyBillGoodstypedetailDto.setDetailSid(sid1); |
|
|
|
smsPricestrategyBillGoodstypedetailService.saveOrUpdateDto(smsPricestrategyBillGoodstypedetailDto); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
return sid; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
List<SmsPricestrategyBillDetailDetailsVo> smsPricestrategyBillDetailDetailsVos = smsPricestrategyBillDetailService.selByMainSid(dtoSid); |
|
|
|
for (SmsPricestrategyBillDetailDetailsVo smsPricestrategyBillDetailDetailsVo : smsPricestrategyBillDetailDetailsVos) { |
|
|
|
smsPricestrategyBillGoodstypedetailService.delByMainSid(smsPricestrategyBillDetailDetailsVo.getSid()); |
|
|
|
} |
|
|
|
smsPricestrategyBillDetailService.delByMainSid(dtoSid); |
|
|
|
for (SmsPricestrategyBillDetailDto smsPricestrategyBillDetailDto : smsPricestrategyBillDetailList) { |
|
|
|
smsPricestrategyBillDetailDto.setMainSid(dtoSid); |
|
|
|
smsPricestrategyBillDetailService.saveOrUpdateDto(smsPricestrategyBillDetailDto); |
|
|
|
String sid1 = smsPricestrategyBillDetailService.saveOrUpdateDto(smsPricestrategyBillDetailDto); |
|
|
|
if (smsPricestrategyBillDetailDto.getStrategyType() == 0){ |
|
|
|
SmsPricestrategyBillGoodstypedetailDto smsPricestrategyBillGoodstypedetailDto = new SmsPricestrategyBillGoodstypedetailDto(); |
|
|
|
smsPricestrategyBillGoodstypedetailDto.setDetailSid(sid1); |
|
|
|
smsPricestrategyBillGoodstypedetailDto.setMarkupRate(smsPricestrategyBillDetailDto.getGdMarkupRate()); |
|
|
|
smsPricestrategyBillGoodstypedetailService.saveOrUpdateDto(smsPricestrategyBillGoodstypedetailDto); |
|
|
|
}else { |
|
|
|
List<SmsPricestrategyBillGoodstypedetailDto> smsPricestrategyBillGoodstypedetailList = smsPricestrategyBillDetailDto.getSmsPricestrategyBillGoodstypedetailList(); |
|
|
|
for (SmsPricestrategyBillGoodstypedetailDto smsPricestrategyBillGoodstypedetailDto : smsPricestrategyBillGoodstypedetailList) { |
|
|
|
smsPricestrategyBillGoodstypedetailDto.setDetailSid(sid1); |
|
|
|
smsPricestrategyBillGoodstypedetailService.saveOrUpdateDto(smsPricestrategyBillGoodstypedetailDto); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return dtoSid; |
|
|
|
} |
|
|
|
|
|
|
|
public String insertByDto(SmsPricestrategyBillDto dto){ |
|
|
|
SmsPricestrategyBill entity = new SmsPricestrategyBill(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
entity.setNodeState("待提交"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
return entity.getSid(); |
|
|
|
} |
|
|
@ -112,13 +263,372 @@ public class SmsPricestrategyBillService extends MybatisBaseService<SmsPricestra |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
List<SmsPricestrategyBillDetailDetailsVo> smsPricestrategyBillDetailDetailsVos = smsPricestrategyBillDetailService.selByMainSid(sid); |
|
|
|
vo.setSmsPricestrategyBillDetailList(smsPricestrategyBillDetailDetailsVos); |
|
|
|
for (SmsPricestrategyBillDetailDetailsVo smsPricestrategyBillDetailDetailsVo : smsPricestrategyBillDetailDetailsVos) { |
|
|
|
List<SmsPricestrategyBillGoodstypedetailDetailsVo> smsPricestrategyBillGoodstypedetailDetailsVos = smsPricestrategyBillGoodstypedetailService.selByMainSid(smsPricestrategyBillDetailDetailsVo.getSid()); |
|
|
|
if (smsPricestrategyBillDetailDetailsVo.getStrategyType() == 0){ |
|
|
|
SmsPricestrategyBillGoodstypedetailDetailsVo smsPricestrategyBillGoodstypedetailDetailsVo = smsPricestrategyBillGoodstypedetailDetailsVos.get(0); |
|
|
|
smsPricestrategyBillDetailDetailsVo.setGdMarkupRate(smsPricestrategyBillGoodstypedetailDetailsVo.getMarkupRate()); |
|
|
|
}else { |
|
|
|
smsPricestrategyBillDetailDetailsVo.setSmsPricestrategyBillGoodstypedetailList(smsPricestrategyBillGoodstypedetailDetailsVos); |
|
|
|
} |
|
|
|
} |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
public void delAll(String[] sids) { |
|
|
|
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) { |
|
|
|
List<SmsPricestrategyBillDetailDetailsVo> smsPricestrategyBillDetailDetailsVos = smsPricestrategyBillDetailService.selByMainSid(sid); |
|
|
|
for (SmsPricestrategyBillDetailDetailsVo smsPricestrategyBillDetailDetailsVo : smsPricestrategyBillDetailDetailsVos) { |
|
|
|
smsPricestrategyBillGoodstypedetailService.delByMainSid(smsPricestrategyBillDetailDetailsVo.getSid()); |
|
|
|
} |
|
|
|
smsPricestrategyBillDetailService.delByMainSid(sid); |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean submit(SubmitSmsPricestrategyBillDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
SmsPricestrategyBill smsPricestrategyBill = fetchBySid(dto.getSid()); |
|
|
|
int r = submitBusinessData(dto, smsPricestrategyBill); |
|
|
|
if (r == 3) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
if (r == 0) { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
//新增修改保存
|
|
|
|
String businessSid = saveOrUpdateDto(dto); |
|
|
|
smsPricestrategyBill = fetchBySid(businessSid); |
|
|
|
//创建BusinessVariables实体对象
|
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
//用户的部门全路径sid
|
|
|
|
SysOrganizationVo deptVo = sysOrganizationFeign.fetchBySid(smsPricestrategyBill.getDeptSid()).getData(); |
|
|
|
bv.setOrgSidPath(deptVo.getOrgSidPath()); |
|
|
|
//业务sid
|
|
|
|
bv.setBusinessSid(businessSid); |
|
|
|
//用户sid
|
|
|
|
bv.setUserSid(smsPricestrategyBill.getCreateBySid()); |
|
|
|
//若app移动端有此功能,则传递appMap参数
|
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
appMap.put("sid", businessSid); |
|
|
|
//需和移动端沟通业务sid保存的属性具体值:appMap中sid不是固定的。移动端提供具体字段。
|
|
|
|
variables.put("app", appMap); |
|
|
|
//流程定义id
|
|
|
|
bv.setModelId(ProcDefEnum.SMSPRICESTRATEGYBILL.getProDefId()); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
if (r == 1) { |
|
|
|
ResultBean<UpdateFlowFieldVo> voResultBean = flowFeign.startProcess(bv); |
|
|
|
UpdateFlowFieldVo ufVo = voResultBean.getData(); |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(ufVo)); |
|
|
|
//极光推送
|
|
|
|
smsPricestrategyBill = 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()); |
|
|
|
SmsPricestrategyBill pricestrategyBill = smsPricestrategyBill; |
|
|
|
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(pricestrategyBill.getCreateByName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
messageFlowableQuery.setMsgTitle("价格策略申请"); |
|
|
|
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(smsPricestrategyBill.getTaskId()); |
|
|
|
bv.setTaskDefKey(smsPricestrategyBill.getNodeId()); |
|
|
|
bv.setComment(StringUtils.isNotBlank(dto.getComment()) ? dto.getComment() : "重新提交"); |
|
|
|
bv.setInstanceId(dto.getInstanceId()); |
|
|
|
return complete(bv); |
|
|
|
} |
|
|
|
return rb; |
|
|
|
} |
|
|
|
|
|
|
|
private synchronized int submitBusinessData(SubmitSmsPricestrategyBillDto dto, SmsPricestrategyBill smsPricestrategyBill) { |
|
|
|
int r = 0; |
|
|
|
if (StringUtils.isBlank(dto.getSid())) { |
|
|
|
r = 1; |
|
|
|
} else { |
|
|
|
if (smsPricestrategyBill != null) { |
|
|
|
String businessTaskId = smsPricestrategyBill.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> map) { |
|
|
|
return baseMapper.updateFlowFiled(map); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean complete(BusinessVariables bv) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String businessSid = bv.getBusinessSid(); |
|
|
|
SmsPricestrategyBill smsPricestrategyBill = fetchBySid(businessSid); |
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
FlowProcessMapQuery flowProcessMapQuery = new FlowProcessMapQuery(); |
|
|
|
if (StringUtils.isBlank(smsPricestrategyBill.getProcDefId())) { |
|
|
|
flowProcessMapQuery.setProDefKey(bv.getModelId()); |
|
|
|
} else { |
|
|
|
flowProcessMapQuery.setProDefKey(smsPricestrategyBill.getProcDefId()); |
|
|
|
} |
|
|
|
flowProcessMapQuery.setVariables(variables); |
|
|
|
variables = flowableFeign.getMap(flowProcessMapQuery).getData(); |
|
|
|
//=======================================
|
|
|
|
bv.setFormVariables(variables); |
|
|
|
SysOrganizationVo deptVo = sysOrganizationFeign.fetchBySid(smsPricestrategyBill.getDeptSid()).getData(); |
|
|
|
bv.setOrgSidPath(deptVo.getOrgSidPath()); |
|
|
|
if (bv.getTaskId().equals(smsPricestrategyBill.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 { |
|
|
|
//极光推送
|
|
|
|
smsPricestrategyBill = 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()); |
|
|
|
SmsPricestrategyBill pricestrategyBill = smsPricestrategyBill; |
|
|
|
Future future1 = pool.submit(() -> { |
|
|
|
//极光推送
|
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
ufVo.setProcDefId(pricestrategyBill.getProcDefId()); |
|
|
|
ufVo.setProcInsId(pricestrategyBill.getProcInstId()); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap(appMap); |
|
|
|
messageFlowableQuery.setBusinessSid(businessSid); |
|
|
|
messageFlowableQuery.setModuleName("价格策略申请"); |
|
|
|
messageFlowableQuery.setMsgContent(pricestrategyBill.getCreateByName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
messageFlowableQuery.setMsgTitle("价格策略申请"); |
|
|
|
messageFeign.pushMessage(messageFlowableQuery); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
//==================================添加线程
|
|
|
|
} |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<SmsPricestrategyBillNodeVo>> getPreviousNodesForReject(SmsPricestrategyBillNodeQuery query) { |
|
|
|
ResultBean<List<SmsPricestrategyBillNodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
bv.setModelId(ProcDefEnum.SMSPRICESTRATEGYBILL.getProDefId()); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getPreviousNodesForReject(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|
|
|
List<SmsPricestrategyBillNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), SmsPricestrategyBillNodeVo.class)).collect(Collectors.toList()); |
|
|
|
return rb.success().setData(voList); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<SmsPricestrategyBillNodeVo>> getNextNodesForSubmit(SmsPricestrategyBillNodeQuery query) { |
|
|
|
ResultBean<List<SmsPricestrategyBillNodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
bv.setModelId(ProcDefEnum.SMSPRICESTRATEGYBILL.getProDefId()); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getNextNodesForSubmit(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|
|
|
List<SmsPricestrategyBillNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), SmsPricestrategyBillNodeVo.class)).collect(Collectors.toList()); |
|
|
|
return rb.success().setData(voList); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean reject(SmsPricestrategyBillTaskQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String businessSid = query.getBusinessSid(); |
|
|
|
SmsPricestrategyBill smsPricestrategyBill = fetchBySid(businessSid); |
|
|
|
if (smsPricestrategyBill == null) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
String businessTaskId = smsPricestrategyBill.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); |
|
|
|
flowTaskVo.setValues(variables); |
|
|
|
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); |
|
|
|
//极光推送
|
|
|
|
smsPricestrategyBill = 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()); |
|
|
|
SmsPricestrategyBill pricestrategyBill = smsPricestrategyBill; |
|
|
|
Future future1 = pool.submit(() -> { |
|
|
|
//极光推送
|
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
String procId = pricestrategyBill.getProcInstId(); |
|
|
|
ufVo.setProcInsId(procId); |
|
|
|
ufVo.setProcDefId(pricestrategyBill.getProcDefId()); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap(appMap); |
|
|
|
messageFlowableQuery.setBusinessSid(businessSid); |
|
|
|
messageFlowableQuery.setModuleName("价格策略申请"); |
|
|
|
ResultBean<List<LatestTaskVo>> listResultBean = flowTaskFeign.getLatestTasks(procId); |
|
|
|
String nextNodeUserSids = listResultBean.getData().get(0).getASSIGNEE_(); |
|
|
|
List<String> receiveSidList = Arrays.asList(nextNodeUserSids.split(",")); |
|
|
|
if (receiveSidList.size() == 1 && receiveSidList.get(0).equals(pricestrategyBill.getCreateBySid())) { |
|
|
|
messageFlowableQuery.setMsgContent("您提交的" + messageFlowableQuery.getModuleName() + "已被驳回,请重新提交"); |
|
|
|
} else { |
|
|
|
messageFlowableQuery.setMsgContent(pricestrategyBill.getCreateByName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
} |
|
|
|
messageFlowableQuery.setMsgTitle("价格策略申请"); |
|
|
|
messageFeign.pushMessage(messageFlowableQuery); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
//==================================添加线程
|
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致!"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean revokeProcess(SmsPricestrategyBillTaskQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
SmsPricestrategyBill smsPricestrategyBill = fetchBySid(query.getBusinessSid()); |
|
|
|
String businessTaskId = smsPricestrategyBill.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(SmsPricestrategyBillTaskQuery 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("请填写意见"); |
|
|
|
} |
|
|
|
SmsPricestrategyBill smsPricestrategyBill = fetchBySid(query.getBusinessSid()); |
|
|
|
String businessTaskId = smsPricestrategyBill.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (query.getUserSid().equals(smsPricestrategyBill.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(SmsPricestrategyBillDelegateQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
FlowDelegateQuery delegateQuery = new FlowDelegateQuery(); |
|
|
|
BeanUtil.copyProperties(query, delegateQuery); |
|
|
|
flowFeign.delegate(delegateQuery); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |