Commit 6e7cbbf87b876ac193cbfcd9bae2917a14b98f84

Authored by yeqianyong
1 parent a2ec12c4

楚江ERP-客户开发审核流程相关逻辑开发

... ... @@ -48,7 +48,7 @@ public class GetCustomerDevelopPlanBo extends BaseBo<CustomerDevelopPlan> {
48 48 * 客户类型
49 49 */
50 50 @ApiModelProperty("客户类型")
51   - private TypeInfo customerType;
  51 + private String customerType;
52 52
53 53 /**
54 54 * 产品品种
... ... @@ -141,10 +141,10 @@ public class GetCustomerDevelopPlanBo extends BaseBo<CustomerDevelopPlan> {
141 141 private Integer status;
142 142
143 143 /**
144   - * 状态字典值
  144 + * 流程任务ID
145 145 */
146   - @ApiModelProperty("状态字典值")
147   - private String statusDicValue;
  146 + @ApiModelProperty("流程任务ID")
  147 + private Long flowTaskId;
148 148
149 149 /**
150 150 * 创建人
... ...
1 1 package com.lframework.xingyun.sc.controller.customer;
2 2
  3 +import com.lframework.starter.bpm.dto.FlowTaskDto;
  4 +import com.lframework.starter.bpm.mappers.FlowTaskWrapperMapper;
  5 +import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo;
3 6 import com.lframework.starter.web.core.annotations.security.HasPermission;
  7 +import com.lframework.starter.web.core.components.security.SecurityUtil;
4 8 import com.lframework.starter.web.core.controller.DefaultBaseController;
5 9 import com.lframework.starter.web.inner.entity.SysUser;
6 10 import com.lframework.starter.web.inner.service.system.SysUserService;
... ... @@ -62,7 +66,7 @@ public class CustomerDevelopPlanController extends DefaultBaseController {
62 66 @Resource
63 67 private OfficeService officeService;
64 68 @Resource
65   - private TypeInfoService typeInfoService;
  69 + private FlowTaskWrapperMapper flowTaskWrapperMapper;
66 70 @Resource
67 71 private ProductVarietyService productVarietyService;
68 72 @Resource
... ... @@ -160,14 +164,12 @@ public class CustomerDevelopPlanController extends DefaultBaseController {
160 164 List<String> customerIds = new ArrayList<>();
161 165 List<String> workshopIds = new ArrayList<>();
162 166 List<String> officeIds = new ArrayList<>();
163   - List<String> typeIds = new ArrayList<>();
164 167 List<String> productVarietyIds = new ArrayList<>();
165 168 List<String> chargeUserIds = new ArrayList<>();
166 169 for (CustomerDevelopPlan plan : dataList) {
167 170 String customerId = plan.getCustomerId();
168 171 String workshopId = plan.getWorkshopId();
169 172 String officeId = plan.getOfficeId();
170   - String customerTypeId = plan.getCustomerTypeId();
171 173 String productVarietyId = plan.getProductVarietyId();
172 174 String chargeUserId = plan.getChargeUserId();
173 175 if (StringUtils.isNotBlank(customerId) && !customerIds.contains(customerId)) {
... ... @@ -179,9 +181,6 @@ public class CustomerDevelopPlanController extends DefaultBaseController {
179 181 if (StringUtils.isNotBlank(officeId) && !officeIds.contains(officeId)) {
180 182 officeIds.add(officeId);
181 183 }
182   - if (StringUtils.isNotBlank(customerTypeId) && !typeIds.contains(customerTypeId)) {
183   - typeIds.add(customerTypeId);
184   - }
185 184 if (StringUtils.isNotBlank(productVarietyId) && !productVarietyIds.contains(productVarietyId)) {
186 185 productVarietyIds.add(productVarietyId);
187 186 }
... ... @@ -207,11 +206,12 @@ public class CustomerDevelopPlanController extends DefaultBaseController {
207 206 if (CollectionUtils.isNotEmpty(officeList)) {
208 207 officeMap = officeList.stream().collect(Collectors.toMap(Office::getId, Function.identity()));
209 208 }
210   - // 获取客户类型信息
211   - List<TypeInfo> typeInfoList = typeInfoService.listByIds(typeIds);
212   - Map<String, TypeInfo> typeInfoMap = new HashMap<>();
213   - if (CollectionUtils.isNotEmpty(typeInfoList)) {
214   - typeInfoMap = typeInfoList.stream().collect(Collectors.toMap(TypeInfo::getId, Function.identity()));
  209 + // 获取流程任务数据
  210 + List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo()
  211 + , SecurityUtil.getCurrentUser().getId());
  212 + Map<String, FlowTaskDto> flowTaskMap = new HashMap<>();
  213 + if (CollectionUtils.isNotEmpty(flowTaskList)) {
  214 + flowTaskMap = flowTaskList.stream().collect(Collectors.toMap(FlowTaskDto::getBusinessId, Function.identity()));
215 215 }
216 216 // 获取产品品种信息
217 217 List<ProductVariety> productVarietyList = productVarietyService.listByIds(productVarietyIds);
... ... @@ -237,9 +237,9 @@ public class CustomerDevelopPlanController extends DefaultBaseController {
237 237 // 办事处/科办
238 238 Office office = officeMap.get(plan.getOfficeId());
239 239 data.setOffice(office);
240   - // 客户类型
241   - TypeInfo typeInfo = typeInfoMap.get(plan.getCustomerTypeId());
242   - data.setCustomerType(typeInfo);
  240 + // 流程任务
  241 + FlowTaskDto task = flowTaskMap.get(plan.getId());
  242 + data.setFlowTaskId(task == null ? null : task.getTaskId());
243 243 // 产品品种
244 244 ProductVariety productVariety = productVarietyMap.get(plan.getProductVarietyId());
245 245 data.setProductVariety(productVariety);
... ... @@ -264,7 +264,6 @@ public class CustomerDevelopPlanController extends DefaultBaseController {
264 264 String customerId = plan.getCustomerId();
265 265 String workshopId = plan.getWorkshopId();
266 266 String officeId = plan.getOfficeId();
267   - String customerTypeId = plan.getCustomerTypeId();
268 267 String productVarietyId = plan.getProductVarietyId();
269 268 String chargeUserId = plan.getChargeUserId();
270 269
... ... @@ -278,9 +277,6 @@ public class CustomerDevelopPlanController extends DefaultBaseController {
278 277 // 获取办事处/科办信息
279 278 Office office = officeService.findById(officeId);
280 279 data.setOffice(office);
281   - // 获取客户类型信息
282   - TypeInfo customerType = typeInfoService.findById(customerTypeId);
283   - data.setCustomerType(customerType);
284 280 // 获取产品品种信息
285 281 ProductVariety productVariety = productVarietyService.findById(productVarietyId);
286 282 data.setProductVariety(productVariety);
... ...
... ... @@ -48,7 +48,7 @@ public class CustomerDevelopPlan extends BaseEntity implements BaseDto {
48 48 /**
49 49 * 客户类型ID
50 50 */
51   - private String customerTypeId;
  51 + private String customerType;
52 52
53 53 /**
54 54 * 产品品种ID
... ... @@ -121,6 +121,11 @@ public class CustomerDevelopPlan extends BaseEntity implements BaseDto {
121 121 private CustomerDevelopStatus status;
122 122
123 123 /**
  124 + * 关联的审批流程ID
  125 + */
  126 + private Long flowInstanceId;
  127 +
  128 + /**
124 129 * 创建人ID
125 130 */
126 131 @TableField(fill = FieldFill.INSERT)
... ...
... ... @@ -3,21 +3,32 @@ 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.dto.FlowTaskDto;
  8 +import com.lframework.starter.bpm.entity.FlowDefinitionWrapper;
  9 +import com.lframework.starter.bpm.enums.FlowDefinitionExtBizType;
  10 +import com.lframework.starter.bpm.enums.FlowDefinitionIsPublish;
  11 +import com.lframework.starter.bpm.mappers.FlowTaskWrapperMapper;
  12 +import com.lframework.starter.bpm.service.FlowDefinitionWrapperService;
  13 +import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo;
  14 +import com.lframework.starter.web.core.components.security.SecurityUtil;
  15 +import com.lframework.starter.web.core.utils.*;
  16 +import com.lframework.xingyun.sc.bo.customer.develop.GetCustomerDevelopPlanBo;
6 17 import com.lframework.xingyun.sc.entity.CustomerDevelopPlan;
7 18 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
8   -import com.lframework.starter.web.core.utils.PageResultUtil;
9 19 import com.lframework.starter.web.core.components.resp.PageResult;
10   -import com.lframework.starter.web.core.utils.OpLogUtil;
11 20 import com.lframework.starter.common.utils.StringUtil;
12 21 import com.lframework.starter.common.exceptions.impl.DefaultClientException;
13   -import com.lframework.starter.web.core.utils.IdUtil;
14 22 import com.lframework.starter.common.utils.ObjectUtil;
15 23 import com.lframework.starter.web.core.annotations.oplog.OpLog;
16   -import com.lframework.starter.web.core.utils.PageHelperUtil;
17 24 import com.lframework.starter.common.utils.Assert;
18 25 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
19 26 import com.lframework.xingyun.sc.enums.CustomerDevelopStatus;
  27 +import org.apache.commons.collections4.CollectionUtils;
20 28 import org.apache.commons.lang3.StringUtils;
  29 +import org.dromara.warm.flow.core.dto.FlowParams;
  30 +import org.dromara.warm.flow.core.entity.Instance;
  31 +import org.dromara.warm.flow.core.service.InsService;
21 32 import org.springframework.transaction.annotation.Transactional;
22 33 import com.lframework.xingyun.sc.mappers.CustomerDevelopPlanMapper;
23 34 import com.lframework.xingyun.sc.service.customer.CustomerDevelopPlanService;
... ... @@ -26,13 +37,26 @@ import com.lframework.xingyun.sc.vo.customer.develop.QueryCustomerDevelopPlanVo;
26 37 import com.lframework.xingyun.sc.vo.customer.develop.UpdateCustomerDevelopPlanVo;
27 38 import org.springframework.stereotype.Service;
28 39
  40 +import javax.annotation.Resource;
29 41 import java.util.ArrayList;
30 42 import java.util.List;
  43 +import java.util.stream.Collectors;
31 44
32 45 @Service
33 46 public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDevelopPlanMapper, CustomerDevelopPlan> implements CustomerDevelopPlanService {
34 47
35 48
  49 + private static final String BPM_FLAG = "CustomerDevelop";
  50 +
  51 +
  52 + @Resource
  53 + private FlowDefinitionWrapperService flowDefinitionWrapperService;
  54 + @Resource
  55 + private InsService insService;
  56 + @Resource
  57 + private FlowTaskWrapperMapper flowTaskWrapperMapper;
  58 +
  59 +
36 60
37 61 @Override
38 62 public PageResult<CustomerDevelopPlan> query(Integer pageIndex, Integer pageSize, QueryCustomerDevelopPlanVo vo) {
... ... @@ -58,12 +82,19 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe
58 82 workshopNameList.add("紫铜分厂");
59 83 vo.setWorkshopNames(workshopNameList);
60 84 }
  85 + List<String> ids = new ArrayList<>();
61 86 // 待办类型
62 87 String todoType = vo.getTodoType();
63 88 if ("COMPLETED".equals(todoType)) {
64 89
65 90 } else if ("WAIT".equals(todoType)) {
66   -
  91 + // 获取当前人员的待办任务数据
  92 + List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId());
  93 + if (CollectionUtils.isEmpty(flowTaskList)) {
  94 + return PageResultUtil.convert(new PageInfo<>());
  95 + }
  96 + ids = flowTaskList.stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toList());
  97 + vo.setIds(ids);
67 98 }
68 99 PageHelperUtil.startPage(pageIndex, pageSize);
69 100 List<CustomerDevelopPlan> dataList = this.query(vo);
... ... @@ -98,7 +129,8 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe
98 129 @Override
99 130 public String create(CreateCustomerDevelopPlanVo vo) {
100 131 CustomerDevelopPlan data = new CustomerDevelopPlan();
101   - data.setId(IdUtil.getId());
  132 + String id = IdUtil.getId();
  133 + data.setId(id);
102 134 // 审核中
103 135 data.setStatus(CustomerDevelopStatus.AUDIT);
104 136 data.setCustomerId(vo.getCustomerId());
... ... @@ -108,9 +140,6 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe
108 140 if (!StringUtil.isBlank(vo.getOfficeId())) {
109 141 data.setOfficeId(vo.getOfficeId());
110 142 }
111   - if (!StringUtil.isBlank(vo.getCustomerTypeId())) {
112   - data.setCustomerTypeId(vo.getCustomerTypeId());
113   - }
114 143 if (!StringUtil.isBlank(vo.getProductVarietyId())) {
115 144 data.setProductVarietyId(vo.getProductVarietyId());
116 145 }
... ... @@ -148,6 +177,18 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe
148 177 data.setSettleDays(vo.getSettleDays());
149 178 }
150 179 data.setChargeUserId(vo.getChargeUserId());
  180 + // 流程处理
  181 + FlowDefinitionWrapper flowDefinitionWrapper = flowDefinitionWrapperService.getBaseMapper().selectOne(
  182 + Wrappers.<FlowDefinitionWrapper>query()
  183 + .eq("mode", "CUSTOMER_DEVELOP")
  184 + .eq("is_publish", FlowDefinitionIsPublish.Y.getCode())
  185 + .select("id", "flow_code")
  186 + );
  187 + if (flowDefinitionWrapper == null) {
  188 + throw new DefaultClientException("客户开发未设计审核流程或流程未发布!");
  189 + }
  190 + Instance instance = this.startCustomerDevelopInstance(flowDefinitionWrapper.getFlowCode(), id);
  191 + data.setFlowInstanceId(instance.getId());
151 192
152 193 getBaseMapper().insert(data);
153 194
... ... @@ -168,7 +209,7 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe
168 209 .set(CustomerDevelopPlan::getCustomerId, vo.getCustomerId())
169 210 .set(CustomerDevelopPlan::getWorkshopId, StringUtil.isBlank(vo.getWorkshopId()) ? null : vo.getWorkshopId())
170 211 .set(CustomerDevelopPlan::getOfficeId, StringUtil.isBlank(vo.getOfficeId()) ? null : vo.getOfficeId())
171   - .set(CustomerDevelopPlan::getCustomerTypeId, StringUtil.isBlank(vo.getCustomerTypeId()) ? null : vo.getCustomerTypeId())
  212 + .set(CustomerDevelopPlan::getCustomerType, StringUtil.isBlank(vo.getCustomerType()) ? null : vo.getCustomerType())
172 213 .set(CustomerDevelopPlan::getProductVarietyId, StringUtil.isBlank(vo.getProductVarietyId()) ? null : vo.getProductVarietyId())
173 214 .set(CustomerDevelopPlan::getMonthlyUsage, vo.getMonthlyUsage() == null ? null : vo.getMonthlyUsage())
174 215 .set(CustomerDevelopPlan::getTargetQuantity, vo.getTargetQuantity() == null ? null : vo.getTargetQuantity())
... ... @@ -209,4 +250,30 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe
209 250 .eq(CustomerDevelopPlan::getId, id);
210 251 getBaseMapper().update(updateWrapper);
211 252 }
  253 +
  254 +
  255 + /**
  256 + * 发起流程实例
  257 + *
  258 + * @param processCode 流程code
  259 + * @param businessId 业务ID
  260 + * @return Instance
  261 + */
  262 + public Instance startCustomerDevelopInstance(String processCode, String businessId) {
  263 + if (this.getById(businessId) != null) {
  264 + throw new DefaultClientException("客户开发已办理完成,无法重新发起!");
  265 + }
  266 + FlowParams flowParams = new FlowParams();
  267 + flowParams.flowCode(processCode);
  268 +
  269 + FlowInstanceExtDto ext = new FlowInstanceExtDto();
  270 + ext.setBizType(FlowDefinitionExtBizType.SYSTEM.getCode());
  271 + ext.setBizFlag(BPM_FLAG);
  272 + flowParams.ext(JsonUtil.toJsonString(ext));
  273 + // 需要传入表单变量
  274 + GetCustomerDevelopPlanBo detail = new GetCustomerDevelopPlanBo(this.findById(businessId));
  275 + flowParams.variable(JsonUtil.parseMap(JsonUtil.toJsonString(detail), String.class, Object.class));
  276 +
  277 + return insService.start(businessId, flowParams);
  278 + }
212 279 }
... ...
... ... @@ -38,11 +38,11 @@ public class CreateCustomerDevelopPlanVo implements BaseVo, Serializable {
38 38 private String officeId;
39 39
40 40 /**
41   - * 客户类型ID
  41 + * 客户类型
42 42 */
43   - @ApiModelProperty("客户类型ID")
44   - @Length(message = "客户类型ID最多允许32个字符!")
45   - private String customerTypeId;
  43 + @ApiModelProperty("客户类型")
  44 + @Length(message = "客户类型最多允许20个字符!")
  45 + private String customerType;
46 46
47 47 /**
48 48 * 产品品种ID
... ...
... ... @@ -19,6 +19,12 @@ public class QueryCustomerDevelopPlanVo extends SortPageVo implements BaseVo, Se
19 19
20 20
21 21 /**
  22 + * ID集合
  23 + */
  24 + @ApiModelProperty("ID集合")
  25 + private List<String> ids;
  26 +
  27 + /**
22 28 * 客户ID
23 29 */
24 30 @ApiModelProperty("客户ID")
... ...
... ... @@ -45,11 +45,11 @@ public class UpdateCustomerDevelopPlanVo implements BaseVo, Serializable {
45 45 private String officeId;
46 46
47 47 /**
48   - * 客户类型ID
  48 + * 客户类型
49 49 */
50   - @ApiModelProperty("客户类型ID")
51   - @Length(message = "客户类型ID最多允许32个字符!")
52   - private String customerTypeId;
  50 + @ApiModelProperty("客户类型")
  51 + @Length(message = "客户类型最多允许20个字符!")
  52 + private String customerType;
53 53
54 54 /**
55 55 * 产品品种ID
... ...
... ... @@ -7,7 +7,7 @@
7 7 <result column="customer_id" property="customerId"/>
8 8 <result column="workshop_id" property="workshopId"/>
9 9 <result column="office_id" property="officeId"/>
10   - <result column="customer_type_id" property="customerTypeId"/>
  10 + <result column="customer_type" property="customerType"/>
11 11 <result column="product_variety_id" property="productVarietyId"/>
12 12 <result column="monthly_usage" property="monthlyUsage"/>
13 13 <result column="target_quantity" property="targetQuantity"/>
... ... @@ -22,6 +22,7 @@
22 22 <result column="settle_days" property="settleDays"/>
23 23 <result column="charge_user_id" property="chargeUserId"/>
24 24 <result column="status" property="status"/>
  25 + <result column="flow_instance_id" property="flowInstanceId"/>
25 26 <result column="create_by_id" property="createById"/>
26 27 <result column="create_by" property="createBy"/>
27 28 <result column="update_by_id" property="updateById"/>
... ... @@ -35,7 +36,7 @@
35 36 tb.customer_id,
36 37 tb.workshop_id,
37 38 tb.office_id,
38   - tb.customer_type_id,
  39 + tb.customer_type,
39 40 tb.product_variety_id,
40 41 tb.monthly_usage,
41 42 tb.target_quantity,
... ... @@ -50,6 +51,7 @@
50 51 tb.settle_days,
51 52 tb.charge_user_id,
52 53 tb.status,
  54 + tb.flow_instance_id,
53 55 tb.create_by_id,
54 56 tb.create_by,
55 57 tb.update_by_id,
... ... @@ -66,6 +68,12 @@
66 68 LEFT JOIN base_data_workshop w ON tb.workshop_id = w.id
67 69 </if>
68 70 <where>
  71 + <if test="vo.ids != null and vo.ids.size() > 0">
  72 + AND tb.id in
  73 + <foreach collection="vo.ids" open="(" separator="," close=")" item="id">
  74 + #{id}
  75 + </foreach>
  76 + </if>
69 77 <if test="vo.customerId != null and vo.customerId != ''">
70 78 AND tb.customer_id = #{vo.customerId}
71 79 </if>
... ...