|
|
@ -27,28 +27,50 @@ package com.yxt.anrui.crm.biz.crmmaintenanceenterpriserecord; |
|
|
|
|
|
|
|
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.base.common.enums.BillTypeEnum; |
|
|
|
import com.yxt.anrui.base.common.utils.Rule; |
|
|
|
import com.yxt.anrui.base.common.utils.domain.BillNo; |
|
|
|
import com.yxt.anrui.crm.api.crmcustomertemp.AsCustomerListVo; |
|
|
|
import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTemp; |
|
|
|
import com.yxt.anrui.crm.api.crmdockingpeople.CrmDockingPeople; |
|
|
|
import com.yxt.anrui.crm.api.crmfile.CrmFile; |
|
|
|
import com.yxt.anrui.crm.api.crmfile.CrmFileDetailsVo; |
|
|
|
import com.yxt.anrui.crm.api.crmmaintenanceenterpriseperson.CrmMaintenanceenterprisePerson; |
|
|
|
import com.yxt.anrui.crm.api.crmmaintenanceenterpriserecord.*; |
|
|
|
import com.yxt.anrui.crm.api.crmmaintenanceenterpriserecord.flowable.*; |
|
|
|
import com.yxt.anrui.crm.api.crmmaintenanceenterpriseveh.CrmMaintenanceenterpriseVeh; |
|
|
|
import com.yxt.anrui.crm.biz.crmcustomertemp.CrmCustomerTempService; |
|
|
|
import com.yxt.anrui.crm.biz.crmdockingpeople.CrmDockingPeopleService; |
|
|
|
import com.yxt.anrui.crm.biz.crmfile.CrmFileService; |
|
|
|
import com.yxt.anrui.crm.biz.crmmaintenanceenterpriseperson.CrmMaintenanceenterprisePersonService; |
|
|
|
import com.yxt.anrui.crm.biz.crmmaintenanceenterpriseveh.CrmMaintenanceenterpriseVehService; |
|
|
|
import com.yxt.anrui.crm.fegin.as.AsCustomerVehicleDto; |
|
|
|
import com.yxt.anrui.crm.fegin.as.AsCustomerVehicleFeign; |
|
|
|
import com.yxt.anrui.flowable.api.flow.FlowableFeign; |
|
|
|
import com.yxt.anrui.flowable.api.flow.UpdateFlowFieldVo; |
|
|
|
import com.yxt.anrui.flowable.api.flow2.FlowDelegateQuery; |
|
|
|
import com.yxt.anrui.flowable.api.flow2.FlowFeign; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.FlowTaskFeign; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.FlowTaskVo; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo; |
|
|
|
import com.yxt.anrui.flowable.api.utils.ProcDefEnum; |
|
|
|
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationVo; |
|
|
|
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrg; |
|
|
|
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.PrivilegeQuery; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loantransferpaymentapply.LoanTransferPaymentApply; |
|
|
|
import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
|
import com.yxt.messagecenter.api.message.MessageFeign; |
|
|
|
import com.yxt.messagecenter.api.message.MessageFlowVo; |
|
|
|
import com.yxt.messagecenter.api.message.MessageFlowableQuery; |
|
|
|
import com.yxt.messagecenter.api.messagelist.MessageListFeign; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
@ -60,11 +82,13 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
import java.util.function.Predicate; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* Project: crm(crm) <br/> |
|
|
@ -82,6 +106,20 @@ import java.util.List; |
|
|
|
@Service |
|
|
|
public class CrmMaintenanceenterpriseRecordService extends MybatisBaseService<CrmMaintenanceenterpriseRecordMapper, CrmMaintenanceenterpriseRecord> { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AsCustomerVehicleFeign asCustomerVehicleFeign; |
|
|
|
@Autowired |
|
|
|
private MessageListFeign messageListFeign; |
|
|
|
@Autowired |
|
|
|
private com.yxt.anrui.portal.api.flow.FlowableFeign flowableFeignPro; |
|
|
|
@Resource |
|
|
|
private FlowFeign flowFeign; |
|
|
|
@Resource |
|
|
|
private FlowableFeign flowableFeign; |
|
|
|
@Resource |
|
|
|
private FlowTaskFeign flowTaskFeign; |
|
|
|
@Autowired |
|
|
|
private MessageFeign messageFeign; |
|
|
|
@Autowired |
|
|
|
private CrmFileService crmFileService; |
|
|
|
@Autowired |
|
|
@ -92,14 +130,14 @@ public class CrmMaintenanceenterpriseRecordService extends MybatisBaseService<Cr |
|
|
|
private CrmMaintenanceenterpriseVehService crmMaintenanceenterpriseVehService; |
|
|
|
@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
@Resource |
|
|
|
private AsCustomerVehicleFeign asCustomerVehicleFeign; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private CrmCustomerTempService crmCustomerTempService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private CrmDockingPeopleService crmDockingPeopleService; |
|
|
|
private QueryWrapper<CrmMaintenanceenterpriseRecord> createQueryWrapper(CrmMaintenanceenterpriseRecordQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
@ -493,4 +531,463 @@ public class CrmMaintenanceenterpriseRecordService extends MybatisBaseService<Cr |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------流程------------------------------------------------/
|
|
|
|
|
|
|
|
/** |
|
|
|
* 判断提交的流程是否被允许 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private synchronized int submitBusinessData(SubmitEnterpriseDto dto, CrmMaintenanceenterpriseRecord crmMaintenanceenterpriseRecord) { |
|
|
|
int r = 0; |
|
|
|
if (StringUtils.isBlank(dto.getSid())) { |
|
|
|
r = 1; |
|
|
|
} else { |
|
|
|
if (crmMaintenanceenterpriseRecord != null) { |
|
|
|
String businessTaskId = crmMaintenanceenterpriseRecord.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; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新流程相关的状态 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private int updateFlowFiled(Map<String, Object> map) { |
|
|
|
return baseMapper.updateFlowFiled(map); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean submitRecordApplication(SubmitEnterpriseDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
CrmMaintenanceenterpriseRecord apply = fetchBySid(dto.getSid()); |
|
|
|
int r = submitBusinessData(dto, apply); |
|
|
|
if (r == 3) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
if (r == 0) { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
//新增修改保存
|
|
|
|
String businessSid = saveOrUpdateDto(dto); |
|
|
|
CrmMaintenanceenterpriseRecord entity = fetchBySid(businessSid); |
|
|
|
String orgSidPath = ""; |
|
|
|
SysOrganizationVo organizationVo = sysOrganizationFeign.fetchBySid(entity.getDeptSid()).getData(); |
|
|
|
if (null != organizationVo) { |
|
|
|
orgSidPath = organizationVo.getOrgSidPath(); |
|
|
|
} else { |
|
|
|
SysUserVo data = sysUserFeign.fetchBySid(entity.getCreateBySid()).getData(); |
|
|
|
if (null != data) { |
|
|
|
//根据staffSid获取用户的组织全路径
|
|
|
|
ResultBean<SysStaffOrg> staffOrgResultBean = sysStaffOrgFeign.getOrgByStaffSid(data.getStaffSid()); |
|
|
|
if (!staffOrgResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(staffOrgResultBean.getMsg()); |
|
|
|
} |
|
|
|
//用户的组织全路径
|
|
|
|
orgSidPath = staffOrgResultBean.getData().getOrgSidPath(); |
|
|
|
} |
|
|
|
} |
|
|
|
List<String> orgPathList = Arrays.asList(orgSidPath.split("/")); |
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(orgPathList.get(orgPathList.size() - 1)).getData(); |
|
|
|
if (sysOrganization == null) { |
|
|
|
return rb.setMsg("当前所在的组织机构不存在"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(sysOrganization.getManagerSid())) { |
|
|
|
// return rb.setMsg("当前所在的组织机构未设置主管人员");
|
|
|
|
sysOrganization.setManagerSid(ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId()); |
|
|
|
} |
|
|
|
//创建BusinessVariables实体对象
|
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
//流程中的参数赋值
|
|
|
|
Map<String, Object> variables = BeanUtil.beanToMap(dto); |
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
//若有网关,则赋值网关中判断的字段。
|
|
|
|
// boolean isTure = true;
|
|
|
|
// //去查询是否同意
|
|
|
|
// if (StringUtils.isNotBlank(entity.getSalesUserSid())) {
|
|
|
|
// if (!entity.getCreateBySid().equals(entity.getSalesUserSid())) {
|
|
|
|
// isTure = false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// variables.put("isTure", isTure);
|
|
|
|
variables.put("businessSid", businessSid); |
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
// String orderNames = "<" + entity.getCustomer() + ">" + "欠款客户备案";
|
|
|
|
// variables.put("orderNames", orderNames);
|
|
|
|
CrmMaintenanceenterpriseRecord record = fetchBySid(businessSid); |
|
|
|
String msgBusinessSid = record.getSid(); |
|
|
|
//用户的部门全路径sid
|
|
|
|
bv.setOrgSidPath(orgSidPath); |
|
|
|
//业务sid
|
|
|
|
bv.setBusinessSid(businessSid); |
|
|
|
//用户sid
|
|
|
|
bv.setUserSid(dto.getCreateBySid()); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
// String nextNodeUserSids_ = sysOrganization.getManagerSid();
|
|
|
|
// if (isTure) {
|
|
|
|
// bv.setNextNodeUserSids(nextNodeUserSids_);
|
|
|
|
// } else {
|
|
|
|
// bv.setNextNodeUserSids(entity.getSalesUserSid());
|
|
|
|
// }
|
|
|
|
//流程定义id
|
|
|
|
bv.setModelId(ProcDefEnum.ENTERPRISEAPPLY.getProDefId()); |
|
|
|
if (r == 1) { |
|
|
|
//流程定义id
|
|
|
|
bv.setModelId(ProcDefEnum.ENTERPRISEAPPLY.getProDefId()); |
|
|
|
ResultBean<UpdateFlowFieldVo> voResultBean = flowFeign.startProcess(bv); |
|
|
|
if (!voResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(voResultBean.getMsg()); |
|
|
|
} |
|
|
|
UpdateFlowFieldVo ufVo = voResultBean.getData(); |
|
|
|
int i = updateFlowFiled(BeanUtil.beanToMap(ufVo)); |
|
|
|
//==================================添加线程
|
|
|
|
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()); |
|
|
|
Future future1 = pool.submit(() -> { |
|
|
|
//极光推送
|
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap(appMap); |
|
|
|
messageFlowableQuery.setBusinessSid(msgBusinessSid); |
|
|
|
messageFlowableQuery.setModuleName("定点维修月结欠款备案申请"); |
|
|
|
SysUserVo userVo = sysUserFeign.fetchBySid(record.getCreateBySid()).getData(); |
|
|
|
if (userVo != null) { |
|
|
|
if (StringUtils.isNotBlank(userVo.getName())) { |
|
|
|
messageFlowableQuery.setMsgContent(userVo.getName() + "提交的" + 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"); |
|
|
|
} |
|
|
|
CrmMaintenanceenterpriseRecord record1 = fetchBySid(dto.getSid()); |
|
|
|
bv.setTaskId(dto.getTaskId()); |
|
|
|
bv.setTaskDefKey(record1.getNodeSid()); |
|
|
|
bv.setComment("重新提交"); |
|
|
|
bv.setInstanceId(dto.getInstanceId()); |
|
|
|
return complete(bv); |
|
|
|
} |
|
|
|
return rb; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean complete(BusinessVariables bv) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String businessSid = bv.getBusinessSid(); |
|
|
|
CrmMaintenanceenterpriseRecord record = this.fetchBySid(businessSid); |
|
|
|
if (bv.getTaskId().equals(record.getTaskId())) { |
|
|
|
String orgSidPath = ""; |
|
|
|
SysOrganizationVo organizationVo = sysOrganizationFeign.fetchBySid(record.getDeptSid()).getData(); |
|
|
|
if (null != organizationVo) { |
|
|
|
orgSidPath = organizationVo.getOrgSidPath(); |
|
|
|
} |
|
|
|
bv.setOrgSidPath(orgSidPath); |
|
|
|
//流程中的参数赋值
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
//若有网关,则赋值网关中判断的字段。
|
|
|
|
variables.put("businessSid", businessSid); |
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
ResultBean<UpdateFlowFieldVo> resultBean = flowFeign.handleProsess(bv); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
int i = updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
if ("Event_end".equals(resultBean.getData().getTaskDefKey())) { |
|
|
|
CrmMaintenanceenterpriseRecord entity = fetchBySid(businessSid); |
|
|
|
entity.setClosingDate(new Date()); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
Date filingIndate = entity.getFilingIndate(); |
|
|
|
String customerSid = entity.getCustomerSid(); |
|
|
|
List<CrmMaintenanceenterprisePerson> personList = crmMaintenanceenterprisePersonService.selByBillSid(businessSid); |
|
|
|
if (!personList.isEmpty()) { |
|
|
|
crmDockingPeopleService.delByCustomerSid(customerSid); |
|
|
|
for (CrmMaintenanceenterprisePerson person : personList) { |
|
|
|
CrmDockingPeople crmDockingPeople = new CrmDockingPeople(); |
|
|
|
if (StringUtils.isNotBlank(person.getName())) { |
|
|
|
crmDockingPeople.setName(person.getName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(person.getMobile())) { |
|
|
|
crmDockingPeople.setMobile(person.getMobile()); |
|
|
|
} |
|
|
|
crmDockingPeople.setCustomerSid(customerSid); |
|
|
|
crmDockingPeopleService.insert(crmDockingPeople); |
|
|
|
} |
|
|
|
} |
|
|
|
List<CrmMaintenanceenterpriseVeh> vehs = crmMaintenanceenterpriseVehService.selByBillSid(businessSid); |
|
|
|
if (!vehs.isEmpty()) { |
|
|
|
for (CrmMaintenanceenterpriseVeh veh : vehs) { |
|
|
|
if (StringUtils.isNotBlank(veh.getAsVinSid())) { |
|
|
|
AsCustomerVehicleDto v = new AsCustomerVehicleDto(); |
|
|
|
v.setSid(veh.getAsVinSid()); |
|
|
|
if (StringUtils.isNotBlank(veh.getVehMark())) { |
|
|
|
v.setVehMark(veh.getVehMark()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(veh.getVinNo())) { |
|
|
|
v.setVinNo(veh.getVinNo()); |
|
|
|
} |
|
|
|
v.setCustomerSid(customerSid); |
|
|
|
asCustomerVehicleFeign.save(v); |
|
|
|
} else { |
|
|
|
AsCustomerVehicleDto v = new AsCustomerVehicleDto(); |
|
|
|
if (StringUtils.isNotBlank(veh.getVehMark())) { |
|
|
|
v.setVehMark(veh.getVehMark()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(veh.getVinNo())) { |
|
|
|
v.setVinNo(veh.getVinNo()); |
|
|
|
} |
|
|
|
v.setCustomerSid(customerSid); |
|
|
|
asCustomerVehicleFeign.save(v); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
CrmCustomerTemp customerTemp = crmCustomerTempService.fetchBySid(customerSid); |
|
|
|
customerTemp.setFilingIndate(filingIndate); |
|
|
|
customerTemp.setIsEnable(1); |
|
|
|
customerTemp.setIsDesignatedEnterprise(1); |
|
|
|
crmCustomerTempService.updateById(customerTemp); |
|
|
|
} |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ResultBean revokeProcess(EnterpriseTaskQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
CrmMaintenanceenterpriseRecord paymentApply = fetchBySid(query.getBusinessSid()); |
|
|
|
String businessTaskId = paymentApply.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 taskReject(EnterpriseTaskQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String businessSid = query.getBusinessSid(); |
|
|
|
CrmMaintenanceenterpriseRecord paymentApply = fetchBySid(businessSid); |
|
|
|
if (paymentApply == null) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
String businessTaskId = paymentApply.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (businessTaskId.equals(query.getTaskId())) { |
|
|
|
if (StringUtils.isBlank(query.getComment())) { |
|
|
|
return rb.setMsg("请填写意见"); |
|
|
|
} |
|
|
|
if (org.apache.commons.lang3.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); |
|
|
|
//若有网关,则赋值网关中判断的字段。
|
|
|
|
// boolean isTure = true;
|
|
|
|
// //去查询是否同意
|
|
|
|
// if (StringUtils.isNotBlank(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// if (!loanCustomerRecord.getCreateBySid().equals(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// isTure = false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// variables.put("isTure", isTure);
|
|
|
|
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); |
|
|
|
//极光推送
|
|
|
|
paymentApply = fetchBySid(businessSid); |
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
String procId = paymentApply.getProcInstId(); |
|
|
|
messageFlowVo.setProcInsId(procId); |
|
|
|
messageFlowVo.setProcDefId(paymentApply.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_(); |
|
|
|
List<String> receiveSidList = Arrays.asList(nextNodeUserSids.split(",")); |
|
|
|
// if (receiveSidList.size() == 1 && receiveSidList.get(0).equals(busVehicleApply.getCreateBySid())) {
|
|
|
|
if ("发起申请".equals(nextName)) { |
|
|
|
messageFlowableQuery.setMsgContent("您提交的" + messageFlowableQuery.getModuleName() + "已被驳回,请重新提交"); |
|
|
|
} else { |
|
|
|
SysUserVo userVo = sysUserFeign.fetchBySid(paymentApply.getCreateBySid()).getData(); |
|
|
|
if (userVo != null) { |
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(userVo.getName())) { |
|
|
|
messageFlowableQuery.setMsgContent(userVo.getName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
messageFlowableQuery.setMsgTitle("定点维修月结欠款备案申请"); |
|
|
|
ResultBean<String> stringResultBean = messageFeign.pushMessage(messageFlowableQuery); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致!"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean breakProcess(EnterpriseTaskQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(query.getInstanceId())) { |
|
|
|
return rb.setMsg("参数错误:instanceId"); |
|
|
|
} |
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(query.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(query.getComment())) { |
|
|
|
return rb.setMsg("请填写意见"); |
|
|
|
} |
|
|
|
CrmMaintenanceenterpriseRecord paymentApply = fetchBySid(query.getBusinessSid()); |
|
|
|
String businessTaskId = paymentApply.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (query.getUserSid().equals(paymentApply.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 flowRecord(String procInsId) { |
|
|
|
return flowTaskFeign.businessFlowRecord(procInsId); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<EnterpriseNodeVo>> getNextNodesForSubmit(EnterpriseNodeQuery query) { |
|
|
|
ResultBean<List<EnterpriseNodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
|
|
|
|
//根据业务sid查询排产信息
|
|
|
|
CrmMaintenanceenterpriseRecord paymentApply = fetchBySid(query.getBusinessSid()); |
|
|
|
//若有网关,则赋值网关中判断的字段。
|
|
|
|
// boolean isTure = true;
|
|
|
|
// //去查询是否同意
|
|
|
|
// if (StringUtils.isNotBlank(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// if (!loanCustomerRecord.getCreateBySid().equals(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// isTure = false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// variables.put("isTure", isTure);
|
|
|
|
bv.setFormVariables(variables); |
|
|
|
bv.setModelId(paymentApply.getProcDefId()); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getNextNodesForSubmit(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|
|
|
List<EnterpriseNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), EnterpriseNodeVo.class)).collect(Collectors.toList()); |
|
|
|
return rb.success().setData(voList); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<EnterpriseNodeVo>> getPreviousNodesForReject(EnterpriseNodeQuery query) { |
|
|
|
ResultBean<List<EnterpriseNodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
//根据业务sid查询排产信息
|
|
|
|
CrmMaintenanceenterpriseRecord paymentApply = fetchBySid(query.getBusinessSid()); |
|
|
|
// //若有网关,则赋值网关中判断的字段。
|
|
|
|
// boolean isTure = true;
|
|
|
|
// //去查询是否同意
|
|
|
|
// if (StringUtils.isNotBlank(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// if (!loanCustomerRecord.getCreateBySid().equals(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// isTure = false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// variables.put("isTure", isTure);
|
|
|
|
bv.setFormVariables(variables); |
|
|
|
bv.setModelId(paymentApply.getProcDefId()); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getPreviousNodesForReject(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|
|
|
List<EnterpriseNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), EnterpriseNodeVo.class)).collect(Collectors.toList()); |
|
|
|
return rb.success().setData(voList); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean delegate(EnterpriseDelegateQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
FlowDelegateQuery delegateQuery = new FlowDelegateQuery(); |
|
|
|
BeanUtil.copyProperties(query, delegateQuery); |
|
|
|
flowFeign.delegate(delegateQuery); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|