Commit ab2abc4c284568339b321fd6b90294661f906da7

Authored by 房远帅
1 parent c3e93c3f

楚江ERP:客户资信审核流程

@@ -3,26 +3,29 @@ package com.lframework.xingyun.sc.impl.customer; @@ -3,26 +3,29 @@ package com.lframework.xingyun.sc.impl.customer;
3 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 3 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
4 import com.baomidou.mybatisplus.core.toolkit.Wrappers; 4 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5 import com.github.pagehelper.PageInfo; 5 import com.github.pagehelper.PageInfo;
  6 +import com.lframework.starter.bpm.dto.FlowInstanceExtDto;
  7 +import com.lframework.starter.bpm.entity.FlowDefinitionWrapper;
  8 +import com.lframework.starter.bpm.enums.FlowDefinitionExtBizType;
  9 +import com.lframework.starter.bpm.enums.FlowDefinitionIsPublish;
  10 +import com.lframework.starter.bpm.service.FlowDefinitionWrapperService;
6 import com.lframework.starter.web.core.components.security.SecurityUtil; 11 import com.lframework.starter.web.core.components.security.SecurityUtil;
  12 +import com.lframework.starter.web.core.utils.*;
7 import com.lframework.starter.web.inner.bo.system.user.GetSysUserBo; 13 import com.lframework.starter.web.inner.bo.system.user.GetSysUserBo;
8 import com.lframework.starter.web.inner.entity.SysDept; 14 import com.lframework.starter.web.inner.entity.SysDept;
9 import com.lframework.starter.web.inner.entity.SysUser; 15 import com.lframework.starter.web.inner.entity.SysUser;
10 import com.lframework.starter.web.inner.service.system.SysDeptService; 16 import com.lframework.starter.web.inner.service.system.SysDeptService;
11 import com.lframework.starter.web.inner.service.system.SysUserService; 17 import com.lframework.starter.web.inner.service.system.SysUserService;
12 import com.lframework.starter.web.inner.vo.system.user.QuerySysUserVo; 18 import com.lframework.starter.web.inner.vo.system.user.QuerySysUserVo;
  19 +import com.lframework.xingyun.sc.bo.customer.credit.GetCustomerCreditBo;
13 import com.lframework.xingyun.sc.entity.CorePersonnel; 20 import com.lframework.xingyun.sc.entity.CorePersonnel;
14 import com.lframework.xingyun.sc.entity.CustomerCredit; 21 import com.lframework.xingyun.sc.entity.CustomerCredit;
15 import com.lframework.starter.web.core.impl.BaseMpServiceImpl; 22 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
16 -import com.lframework.starter.web.core.utils.PageResultUtil;  
17 import com.lframework.starter.web.core.components.resp.PageResult; 23 import com.lframework.starter.web.core.components.resp.PageResult;
18 -import com.lframework.starter.web.core.utils.OpLogUtil;  
19 import com.lframework.starter.common.utils.StringUtil; 24 import com.lframework.starter.common.utils.StringUtil;
20 import java.io.Serializable; 25 import java.io.Serializable;
21 import com.lframework.starter.common.exceptions.impl.DefaultClientException; 26 import com.lframework.starter.common.exceptions.impl.DefaultClientException;
22 -import com.lframework.starter.web.core.utils.IdUtil;  
23 import com.lframework.starter.common.utils.ObjectUtil; 27 import com.lframework.starter.common.utils.ObjectUtil;
24 import com.lframework.starter.web.core.annotations.oplog.OpLog; 28 import com.lframework.starter.web.core.annotations.oplog.OpLog;
25 -import com.lframework.starter.web.core.utils.PageHelperUtil;  
26 import com.lframework.starter.common.utils.Assert; 29 import com.lframework.starter.common.utils.Assert;
27 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; 30 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
28 import com.lframework.xingyun.sc.entity.CustomerCreditHistory; 31 import com.lframework.xingyun.sc.entity.CustomerCreditHistory;
@@ -33,6 +36,9 @@ import com.lframework.xingyun.sc.service.customer.CustomerCreditHistoryService; @@ -33,6 +36,9 @@ import com.lframework.xingyun.sc.service.customer.CustomerCreditHistoryService;
33 import com.lframework.xingyun.sc.service.customer.CustomerCreditService; 36 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
34 import com.lframework.xingyun.sc.vo.customer.credit.*; 37 import com.lframework.xingyun.sc.vo.customer.credit.*;
35 import org.apache.commons.collections.CollectionUtils; 38 import org.apache.commons.collections.CollectionUtils;
  39 +import org.dromara.warm.flow.core.dto.FlowParams;
  40 +import org.dromara.warm.flow.core.entity.Instance;
  41 +import org.dromara.warm.flow.core.service.InsService;
36 import org.springframework.cache.annotation.CacheEvict; 42 import org.springframework.cache.annotation.CacheEvict;
37 import org.springframework.cache.annotation.Cacheable; 43 import org.springframework.cache.annotation.Cacheable;
38 import org.springframework.stereotype.Service; 44 import org.springframework.stereotype.Service;
@@ -49,6 +55,7 @@ import java.util.stream.IntStream; @@ -49,6 +55,7 @@ import java.util.stream.IntStream;
49 55
50 @Service 56 @Service
51 public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditMapper, CustomerCredit> implements CustomerCreditService { 57 public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditMapper, CustomerCredit> implements CustomerCreditService {
  58 + private static final String BPM_FLAG = "CUSTOMER_CREDIT";
52 59
53 @Resource 60 @Resource
54 private CorePersonnelService corePersonnelService; 61 private CorePersonnelService corePersonnelService;
@@ -62,6 +69,10 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM @@ -62,6 +69,10 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
62 private CorePersonnelHistoryService corePersonnelHistoryService; 69 private CorePersonnelHistoryService corePersonnelHistoryService;
63 @Resource 70 @Resource
64 private SysDeptService sysDeptService; 71 private SysDeptService sysDeptService;
  72 + @Resource
  73 + private FlowDefinitionWrapperService flowDefinitionWrapperService;
  74 + @Resource
  75 + private InsService insService;
65 76
66 @Override 77 @Override
67 public PageResult<CustomerCredit> query(Integer pageIndex, Integer pageSize, QueryCustomerCreditVo vo) { 78 public PageResult<CustomerCredit> query(Integer pageIndex, Integer pageSize, QueryCustomerCreditVo vo) {
@@ -255,6 +266,18 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM @@ -255,6 +266,18 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
255 } 266 }
256 } 267 }
257 268
  269 + // 流程处理
  270 + FlowDefinitionWrapper flowDefinitionWrapper = flowDefinitionWrapperService.getBaseMapper().selectOne(
  271 + Wrappers.<FlowDefinitionWrapper>query()
  272 + .eq("mode", "CUSTOMER_CREDIT")
  273 + .eq("is_publish", FlowDefinitionIsPublish.Y.getCode())
  274 + .select("id", "flow_code")
  275 + );
  276 + if (flowDefinitionWrapper == null) {
  277 + throw new DefaultClientException("客户资信未设计审核流程或流程未发布!");
  278 + }
  279 + this.startCustomerCreditInstance(flowDefinitionWrapper.getFlowCode(), data.getId());
  280 +
258 return data.getId(); 281 return data.getId();
259 } 282 }
260 283
@@ -529,12 +552,11 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM @@ -529,12 +552,11 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
529 .set(CustomerCredit::getCompanyCreditLimit, StringUtil.isBlank(vo.getCompanyCreditLimit()) ? null : vo.getCompanyCreditLimit()) 552 .set(CustomerCredit::getCompanyCreditLimit, StringUtil.isBlank(vo.getCompanyCreditLimit()) ? null : vo.getCompanyCreditLimit())
530 .set(CustomerCredit::getCompanyMaterialSupplyPlan, StringUtil.isBlank(vo.getCompanyMaterialSupplyPlan()) ? null : vo.getCompanyMaterialSupplyPlan()) 553 .set(CustomerCredit::getCompanyMaterialSupplyPlan, StringUtil.isBlank(vo.getCompanyMaterialSupplyPlan()) ? null : vo.getCompanyMaterialSupplyPlan())
531 .set(CustomerCredit::getCompanySuggestedCategory, vo.getCompanySuggestedCategory()) 554 .set(CustomerCredit::getCompanySuggestedCategory, vo.getCompanySuggestedCategory())
532 - .set(CustomerCredit::getStatus, vo.getStatus()) 555 + .set(CustomerCredit::getStatus, "AUDIT")
533 .eq(CustomerCredit::getId, vo.getId()); 556 .eq(CustomerCredit::getId, vo.getId());
534 557
535 getBaseMapper().update(updateWrapper); 558 getBaseMapper().update(updateWrapper);
536 //更新核心人员 559 //更新核心人员
537 - //todo fys 考虑删除怎么做  
538 List<UpdateCorePersonnelVo> corePersonnelListNew = vo.getCorePersonnelList(); 560 List<UpdateCorePersonnelVo> corePersonnelListNew = vo.getCorePersonnelList();
539 if (CollectionUtils.isNotEmpty(corePersonnelListNew)) { 561 if (CollectionUtils.isNotEmpty(corePersonnelListNew)) {
540 Set<String> oldIds = corePersonnelList.stream().map(CorePersonnel::getId).collect(Collectors.toSet()); 562 Set<String> oldIds = corePersonnelList.stream().map(CorePersonnel::getId).collect(Collectors.toSet());
@@ -613,6 +635,18 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM @@ -613,6 +635,18 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
613 } 635 }
614 OpLogUtil.setVariable("id", data.getId()); 636 OpLogUtil.setVariable("id", data.getId());
615 OpLogUtil.setExtra(vo); 637 OpLogUtil.setExtra(vo);
  638 +
  639 + // 流程处理
  640 + FlowDefinitionWrapper flowDefinitionWrapper = flowDefinitionWrapperService.getBaseMapper().selectOne(
  641 + Wrappers.<FlowDefinitionWrapper>query()
  642 + .eq("mode", "CUSTOMER_CREDIT")
  643 + .eq("is_publish", FlowDefinitionIsPublish.Y.getCode())
  644 + .select("id", "flow_code")
  645 + );
  646 + if (flowDefinitionWrapper == null) {
  647 + throw new DefaultClientException("客户资信未设计审核流程或流程未发布!");
  648 + }
  649 + this.startCustomerCreditInstance(flowDefinitionWrapper.getFlowCode(), data.getId());
616 } 650 }
617 651
618 @OpLog(type = OtherOpLogType.class, name = "删除客户资信表,ID:{}", params = {"#id"}) 652 @OpLog(type = OtherOpLogType.class, name = "删除客户资信表,ID:{}", params = {"#id"})
@@ -790,6 +824,31 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM @@ -790,6 +824,31 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
790 .orElseThrow(() -> new RuntimeException("办事处 " + prefix + " 的编号已用尽 (001-999)")); 824 .orElseThrow(() -> new RuntimeException("办事处 " + prefix + " 的编号已用尽 (001-999)"));
791 } 825 }
792 826
  827 + /**
  828 + * 发起流程实例
  829 + *
  830 + * @param processCode 流程code
  831 + * @param businessId 业务ID
  832 + * @return Instance
  833 + */
  834 + public Instance startCustomerCreditInstance(String processCode, String businessId) {
  835 + if (this.getById(businessId) != null) {
  836 + throw new DefaultClientException("客户资信已办理完成,无法重新发起!");
  837 + }
  838 + FlowParams flowParams = new FlowParams();
  839 + flowParams.flowCode(processCode);
  840 +
  841 + FlowInstanceExtDto ext = new FlowInstanceExtDto();
  842 + ext.setBizType(FlowDefinitionExtBizType.SYSTEM.getCode());
  843 + ext.setBizFlag(BPM_FLAG);
  844 + flowParams.ext(JsonUtil.toJsonString(ext));
  845 + // 需要传入表单变量
  846 + GetCustomerCreditBo detail = new GetCustomerCreditBo(this.findById(businessId));
  847 + flowParams.variable(JsonUtil.parseMap(JsonUtil.toJsonString(detail), String.class, Object.class));
  848 +
  849 + return insService.start(businessId, flowParams);
  850 + }
  851 +
793 @CacheEvict(value = CustomerCredit.CACHE_NAME, key = "@cacheVariables.tenantId() + #key") 852 @CacheEvict(value = CustomerCredit.CACHE_NAME, key = "@cacheVariables.tenantId() + #key")
794 @Override 853 @Override
795 public void cleanCacheByKey(Serializable key) { 854 public void cleanCacheByKey(Serializable key) {