Commit eafa36adf2d200c7e52eda053e8a2997363c7cce
Merge remote-tracking branch 'origin/master_0929' into master_0929
Showing
1 changed file
with
65 additions
and
6 deletions
| ... | ... | @@ -3,26 +3,29 @@ package com.lframework.xingyun.sc.impl.customer; |
| 3 | 3 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 4 | 4 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| 5 | 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 | 11 | import com.lframework.starter.web.core.components.security.SecurityUtil; |
| 12 | +import com.lframework.starter.web.core.utils.*; | |
| 7 | 13 | import com.lframework.starter.web.inner.bo.system.user.GetSysUserBo; |
| 8 | 14 | import com.lframework.starter.web.inner.entity.SysDept; |
| 9 | 15 | import com.lframework.starter.web.inner.entity.SysUser; |
| 10 | 16 | import com.lframework.starter.web.inner.service.system.SysDeptService; |
| 11 | 17 | import com.lframework.starter.web.inner.service.system.SysUserService; |
| 12 | 18 | import com.lframework.starter.web.inner.vo.system.user.QuerySysUserVo; |
| 19 | +import com.lframework.xingyun.sc.bo.customer.credit.GetCustomerCreditBo; | |
| 13 | 20 | import com.lframework.xingyun.sc.entity.CorePersonnel; |
| 14 | 21 | import com.lframework.xingyun.sc.entity.CustomerCredit; |
| 15 | 22 | import com.lframework.starter.web.core.impl.BaseMpServiceImpl; |
| 16 | -import com.lframework.starter.web.core.utils.PageResultUtil; | |
| 17 | 23 | import com.lframework.starter.web.core.components.resp.PageResult; |
| 18 | -import com.lframework.starter.web.core.utils.OpLogUtil; | |
| 19 | 24 | import com.lframework.starter.common.utils.StringUtil; |
| 20 | 25 | import java.io.Serializable; |
| 21 | 26 | import com.lframework.starter.common.exceptions.impl.DefaultClientException; |
| 22 | -import com.lframework.starter.web.core.utils.IdUtil; | |
| 23 | 27 | import com.lframework.starter.common.utils.ObjectUtil; |
| 24 | 28 | import com.lframework.starter.web.core.annotations.oplog.OpLog; |
| 25 | -import com.lframework.starter.web.core.utils.PageHelperUtil; | |
| 26 | 29 | import com.lframework.starter.common.utils.Assert; |
| 27 | 30 | import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; |
| 28 | 31 | import com.lframework.xingyun.sc.entity.CustomerCreditHistory; |
| ... | ... | @@ -33,6 +36,9 @@ import com.lframework.xingyun.sc.service.customer.CustomerCreditHistoryService; |
| 33 | 36 | import com.lframework.xingyun.sc.service.customer.CustomerCreditService; |
| 34 | 37 | import com.lframework.xingyun.sc.vo.customer.credit.*; |
| 35 | 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 | 42 | import org.springframework.cache.annotation.CacheEvict; |
| 37 | 43 | import org.springframework.cache.annotation.Cacheable; |
| 38 | 44 | import org.springframework.stereotype.Service; |
| ... | ... | @@ -49,6 +55,7 @@ import java.util.stream.IntStream; |
| 49 | 55 | |
| 50 | 56 | @Service |
| 51 | 57 | public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditMapper, CustomerCredit> implements CustomerCreditService { |
| 58 | + private static final String BPM_FLAG = "CUSTOMER_CREDIT"; | |
| 52 | 59 | |
| 53 | 60 | @Resource |
| 54 | 61 | private CorePersonnelService corePersonnelService; |
| ... | ... | @@ -62,6 +69,10 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM |
| 62 | 69 | private CorePersonnelHistoryService corePersonnelHistoryService; |
| 63 | 70 | @Resource |
| 64 | 71 | private SysDeptService sysDeptService; |
| 72 | + @Resource | |
| 73 | + private FlowDefinitionWrapperService flowDefinitionWrapperService; | |
| 74 | + @Resource | |
| 75 | + private InsService insService; | |
| 65 | 76 | |
| 66 | 77 | @Override |
| 67 | 78 | public PageResult<CustomerCredit> query(Integer pageIndex, Integer pageSize, QueryCustomerCreditVo vo) { |
| ... | ... | @@ -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 | 281 | return data.getId(); |
| 259 | 282 | } |
| 260 | 283 | |
| ... | ... | @@ -529,12 +552,11 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM |
| 529 | 552 | .set(CustomerCredit::getCompanyCreditLimit, StringUtil.isBlank(vo.getCompanyCreditLimit()) ? null : vo.getCompanyCreditLimit()) |
| 530 | 553 | .set(CustomerCredit::getCompanyMaterialSupplyPlan, StringUtil.isBlank(vo.getCompanyMaterialSupplyPlan()) ? null : vo.getCompanyMaterialSupplyPlan()) |
| 531 | 554 | .set(CustomerCredit::getCompanySuggestedCategory, vo.getCompanySuggestedCategory()) |
| 532 | - .set(CustomerCredit::getStatus, vo.getStatus()) | |
| 555 | + .set(CustomerCredit::getStatus, "AUDIT") | |
| 533 | 556 | .eq(CustomerCredit::getId, vo.getId()); |
| 534 | 557 | |
| 535 | 558 | getBaseMapper().update(updateWrapper); |
| 536 | 559 | //更新核心人员 |
| 537 | - //todo fys 考虑删除怎么做 | |
| 538 | 560 | List<UpdateCorePersonnelVo> corePersonnelListNew = vo.getCorePersonnelList(); |
| 539 | 561 | if (CollectionUtils.isNotEmpty(corePersonnelListNew)) { |
| 540 | 562 | Set<String> oldIds = corePersonnelList.stream().map(CorePersonnel::getId).collect(Collectors.toSet()); |
| ... | ... | @@ -613,6 +635,18 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM |
| 613 | 635 | } |
| 614 | 636 | OpLogUtil.setVariable("id", data.getId()); |
| 615 | 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 | 652 | @OpLog(type = OtherOpLogType.class, name = "删除客户资信表,ID:{}", params = {"#id"}) |
| ... | ... | @@ -790,6 +824,31 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM |
| 790 | 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 | 852 | @CacheEvict(value = CustomerCredit.CACHE_NAME, key = "@cacheVariables.tenantId() + #key") |
| 794 | 853 | @Override |
| 795 | 854 | public void cleanCacheByKey(Serializable key) { | ... | ... |