|
...
|
...
|
@@ -4,6 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
4
|
4
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
5
|
5
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
6
|
6
|
import com.github.pagehelper.PageInfo;
|
|
|
7
|
+import com.lframework.starter.bpm.dto.FlowTaskDto;
|
|
|
8
|
+import com.lframework.starter.bpm.entity.FlowInstanceWrapper;
|
|
|
9
|
+import com.lframework.starter.bpm.mappers.FlowTaskWrapperMapper;
|
|
|
10
|
+import com.lframework.starter.bpm.service.FlowInstanceWrapperService;
|
|
|
11
|
+import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo;
|
|
7
|
12
|
import com.lframework.starter.common.exceptions.impl.DefaultClientException;
|
|
8
|
13
|
import com.lframework.starter.common.utils.Assert;
|
|
9
|
14
|
import com.lframework.starter.common.utils.CollectionUtil;
|
|
...
|
...
|
@@ -17,7 +22,9 @@ import com.lframework.starter.web.core.utils.OpLogUtil; |
|
17
|
22
|
import com.lframework.starter.web.core.utils.PageHelperUtil;
|
|
18
|
23
|
import com.lframework.starter.web.core.utils.PageResultUtil;
|
|
19
|
24
|
import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
|
|
|
25
|
+import com.lframework.starter.web.inner.entity.SysRole;
|
|
20
|
26
|
import com.lframework.starter.web.inner.entity.SysUser;
|
|
|
27
|
+import com.lframework.starter.web.inner.service.system.SysRoleService;
|
|
21
|
28
|
import com.lframework.starter.web.inner.service.system.SysUserService;
|
|
22
|
29
|
import com.lframework.xingyun.basedata.entity.BreedRelationship;
|
|
23
|
30
|
import com.lframework.xingyun.basedata.service.breed.BreedRelationshipService;
|
|
...
|
...
|
@@ -43,8 +50,11 @@ import java.time.LocalDateTime; |
|
43
|
50
|
import java.time.format.DateTimeFormatter;
|
|
44
|
51
|
import java.util.ArrayList;
|
|
45
|
52
|
import java.util.Collections;
|
|
|
53
|
+import java.util.HashSet;
|
|
46
|
54
|
import java.util.List;
|
|
47
|
55
|
import java.util.Map;
|
|
|
56
|
+import java.util.Objects;
|
|
|
57
|
+import java.util.Set;
|
|
48
|
58
|
import java.util.stream.Collectors;
|
|
49
|
59
|
import org.apache.commons.lang3.StringUtils;
|
|
50
|
60
|
import org.springframework.stereotype.Service;
|
|
...
|
...
|
@@ -58,14 +68,26 @@ import javax.annotation.Resource; |
|
58
|
68
|
public class SalesmanQuotationServiceImpl
|
|
59
|
69
|
extends BaseMpServiceImpl<SalesmanQuotationMapper, SalesmanQuotation>
|
|
60
|
70
|
implements SalesmanQuotationService {
|
|
|
71
|
+
|
|
|
72
|
+ /**
|
|
|
73
|
+ * 流程标识
|
|
|
74
|
+ */
|
|
|
75
|
+ private static final String BPM_FLAG = "SALESMAN_QUOTATION";
|
|
|
76
|
+
|
|
61
|
77
|
@Resource
|
|
62
|
78
|
private SysUserService sysUserService;
|
|
63
|
79
|
@Resource
|
|
|
80
|
+ private FlowInstanceWrapperService flowInstanceWrapperService;
|
|
|
81
|
+ @Resource
|
|
|
82
|
+ private FlowTaskWrapperMapper flowTaskWrapperMapper;
|
|
|
83
|
+ @Resource
|
|
64
|
84
|
private ProcurementDomesticCustomerCreditService procurementDomesticCustomerCreditService;
|
|
65
|
85
|
@Resource
|
|
66
|
86
|
private BreedRelationshipService breedRelationshipService;
|
|
67
|
87
|
@Resource
|
|
68
|
88
|
private SalesmanQuotationLineService salesmanQuotationLineService;
|
|
|
89
|
+ @Resource
|
|
|
90
|
+ private SysRoleService sysRoleService;
|
|
69
|
91
|
|
|
70
|
92
|
/**
|
|
71
|
93
|
* 编号前缀
|
|
...
|
...
|
@@ -97,6 +119,7 @@ public class SalesmanQuotationServiceImpl |
|
97
|
119
|
|
|
98
|
120
|
PageHelperUtil.startPage(pageIndex, pageSize);
|
|
99
|
121
|
List<SalesmanQuotation> datas = this.query(vo);
|
|
|
122
|
+ fillShowExamineInfo(datas);
|
|
100
|
123
|
return PageResultUtil.convert(new PageInfo<>(datas));
|
|
101
|
124
|
}
|
|
102
|
125
|
|
|
...
|
...
|
@@ -127,6 +150,7 @@ public class SalesmanQuotationServiceImpl |
|
127
|
150
|
QuerySalesmanQuotationLineVo lineQueryVo = new QuerySalesmanQuotationLineVo();
|
|
128
|
151
|
lineQueryVo.setQuotationId(id);
|
|
129
|
152
|
data.setQuotationLineList(salesmanQuotationLineService.query(lineQueryVo));
|
|
|
153
|
+ fillShowExamineInfo(Collections.singletonList(data));
|
|
130
|
154
|
|
|
131
|
155
|
return data;
|
|
132
|
156
|
}
|
|
...
|
...
|
@@ -153,6 +177,33 @@ public class SalesmanQuotationServiceImpl |
|
153
|
177
|
getBaseMapper().insert(data);
|
|
154
|
178
|
|
|
155
|
179
|
saveCreateLines(data.getId(), vo.getQuotationLineList(), quotationBreedMap, vo.getPriced());
|
|
|
180
|
+ SalesmanQuotation salesmanQuotation = getBaseMapper().findById(data.getId());
|
|
|
181
|
+ List<SysRole> sysRoleList = sysRoleService.getByUserId(SecurityUtil.getCurrentUser().getId());
|
|
|
182
|
+ String roleCode = null;
|
|
|
183
|
+ if (CollectionUtil.isNotEmpty(sysRoleList)) {
|
|
|
184
|
+ // 1. 提取角色列表中的所有 code,转换为 Set 集合,提升后续判断效率
|
|
|
185
|
+ Set<String> roleCodeSet = sysRoleList.stream()
|
|
|
186
|
+ .map(SysRole::getCode)
|
|
|
187
|
+ .collect(Collectors.toSet());
|
|
|
188
|
+
|
|
|
189
|
+ // 2. 判断是否包含采购主管相关的角色
|
|
|
190
|
+ if (roleCodeSet.contains("htcgeczg") || roleCodeSet.contains("htcgyczg")
|
|
|
191
|
+ || roleCodeSet.contains("ltcgczg") || roleCodeSet.contains("ztcgczg")) {
|
|
|
192
|
+ roleCode = "cgczg";
|
|
|
193
|
+ } else if (roleCodeSet.contains("qyjl")) {
|
|
|
194
|
+ // 3. 如果没有,继续判断是否包含区域经理
|
|
|
195
|
+ roleCode = "qyjl";
|
|
|
196
|
+ } else if (roleCodeSet.contains("nmcgkywy")) {
|
|
|
197
|
+ // 4. 如果还没有,继续判断是否包含内贸采购科业务员
|
|
|
198
|
+ roleCode = "nmcgkywy";
|
|
|
199
|
+ } else {
|
|
|
200
|
+ throw new DefaultClientException("当前角色无法发起报价!");
|
|
|
201
|
+ }
|
|
|
202
|
+ } else {
|
|
|
203
|
+ throw new DefaultClientException("当前角色无法发起报价!");
|
|
|
204
|
+ }
|
|
|
205
|
+ salesmanQuotation.setRoleCode(roleCode);
|
|
|
206
|
+ flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, salesmanQuotation);
|
|
156
|
207
|
|
|
157
|
208
|
OpLogUtil.setVariable("id", data.getId());
|
|
158
|
209
|
OpLogUtil.setExtra(vo);
|
|
...
|
...
|
@@ -183,6 +234,33 @@ public class SalesmanQuotationServiceImpl |
|
183
|
234
|
getBaseMapper().updateById(data);
|
|
184
|
235
|
|
|
185
|
236
|
saveOrUpdateLines(data.getId(), vo.getQuotationLineList(), quotationBreedMap, vo.getPriced());
|
|
|
237
|
+ SalesmanQuotation salesmanQuotation = getBaseMapper().findById(data.getId());
|
|
|
238
|
+ List<SysRole> sysRoleList = sysRoleService.getByUserId(SecurityUtil.getCurrentUser().getId());
|
|
|
239
|
+ String roleCode = null;
|
|
|
240
|
+ if (CollectionUtil.isNotEmpty(sysRoleList)) {
|
|
|
241
|
+ // 1. 提取角色列表中的所有 code,转换为 Set 集合,提升后续判断效率
|
|
|
242
|
+ Set<String> roleCodeSet = sysRoleList.stream()
|
|
|
243
|
+ .map(SysRole::getCode)
|
|
|
244
|
+ .collect(Collectors.toSet());
|
|
|
245
|
+
|
|
|
246
|
+ // 2. 判断是否包含采购主管相关的角色
|
|
|
247
|
+ if (roleCodeSet.contains("htcgeczg") || roleCodeSet.contains("htcgyczg")
|
|
|
248
|
+ || roleCodeSet.contains("ltcgczg") || roleCodeSet.contains("ztcgczg")) {
|
|
|
249
|
+ roleCode = "cgczg";
|
|
|
250
|
+ } else if (roleCodeSet.contains("qyjl")) {
|
|
|
251
|
+ // 3. 如果没有,继续判断是否包含区域经理
|
|
|
252
|
+ roleCode = "qyjl";
|
|
|
253
|
+ } else if (roleCodeSet.contains("nmcgkywy")) {
|
|
|
254
|
+ // 4. 如果还没有,继续判断是否包含内贸采购科业务员
|
|
|
255
|
+ roleCode = "nmcgkywy";
|
|
|
256
|
+ } else {
|
|
|
257
|
+ throw new DefaultClientException("当前角色无法发起报价!");
|
|
|
258
|
+ }
|
|
|
259
|
+ } else {
|
|
|
260
|
+ throw new DefaultClientException("当前角色无法发起报价!");
|
|
|
261
|
+ }
|
|
|
262
|
+ salesmanQuotation.setRoleCode(roleCode);
|
|
|
263
|
+ flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, salesmanQuotation);
|
|
186
|
264
|
|
|
187
|
265
|
OpLogUtil.setVariable("id", data.getId());
|
|
188
|
266
|
OpLogUtil.setExtra(vo);
|
|
...
|
...
|
@@ -209,6 +287,24 @@ public class SalesmanQuotationServiceImpl |
|
209
|
287
|
OpLogUtil.setExtra(data);
|
|
210
|
288
|
}
|
|
211
|
289
|
|
|
|
290
|
+ /**
|
|
|
291
|
+ * 更新审核状态
|
|
|
292
|
+ *
|
|
|
293
|
+ * @param id 主键ID
|
|
|
294
|
+ * @param approvalStatus 审核状态
|
|
|
295
|
+ */
|
|
|
296
|
+ @Override
|
|
|
297
|
+ public void updateApprovalStatus(String id, String approvalStatus) {
|
|
|
298
|
+ if (StringUtils.isBlank(id) || StringUtils.isBlank(approvalStatus)) {
|
|
|
299
|
+ throw new DefaultClientException("业务员报价ID、审核状态不能为空!");
|
|
|
300
|
+ }
|
|
|
301
|
+
|
|
|
302
|
+ Wrapper<SalesmanQuotation> wrapper = Wrappers.lambdaUpdate(SalesmanQuotation.class)
|
|
|
303
|
+ .set(SalesmanQuotation::getApprovalStatus, approvalStatus)
|
|
|
304
|
+ .eq(SalesmanQuotation::getId, id);
|
|
|
305
|
+ getBaseMapper().update(wrapper);
|
|
|
306
|
+ }
|
|
|
307
|
+
|
|
212
|
308
|
|
|
213
|
309
|
/**
|
|
214
|
310
|
* 构建新增实体
|
|
...
|
...
|
@@ -242,6 +338,7 @@ public class SalesmanQuotationServiceImpl |
|
242
|
338
|
data.setSupplierId(supplier.getId());
|
|
243
|
339
|
data.setPurchaseDepartment(supplier.getPurchaseDepartment());
|
|
244
|
340
|
data.setRegion(supplier.getRegion());
|
|
|
341
|
+ data.setApprovalStatus(CustomerDevelopStatus.AUDIT.name());
|
|
245
|
342
|
data.setValidityPeriod(vo.getValidityPeriod());
|
|
246
|
343
|
data.setLongTermOperation(vo.getLongTermOperation());
|
|
247
|
344
|
data.setTerminalCustomer(vo.getTerminalCustomer());
|
|
...
|
...
|
@@ -284,6 +381,7 @@ public class SalesmanQuotationServiceImpl |
|
284
|
381
|
data.setSupplierId(supplier.getId());
|
|
285
|
382
|
data.setPurchaseDepartment(supplier.getPurchaseDepartment());
|
|
286
|
383
|
data.setRegion(supplier.getRegion());
|
|
|
384
|
+ data.setApprovalStatus(CustomerDevelopStatus.AUDIT.name());
|
|
287
|
385
|
data.setValidityPeriod(vo.getValidityPeriod());
|
|
288
|
386
|
data.setLongTermOperation(vo.getLongTermOperation());
|
|
289
|
387
|
data.setTerminalCustomer(vo.getTerminalCustomer());
|
|
...
|
...
|
@@ -587,6 +685,43 @@ public class SalesmanQuotationServiceImpl |
|
587
|
685
|
}
|
|
588
|
686
|
|
|
589
|
687
|
/**
|
|
|
688
|
+ * 回填审核按钮展示信息
|
|
|
689
|
+ *
|
|
|
690
|
+ * @param datas 数据列表
|
|
|
691
|
+ */
|
|
|
692
|
+ private void fillShowExamineInfo(List<SalesmanQuotation> datas) {
|
|
|
693
|
+ if (CollectionUtil.isEmpty(datas)) {
|
|
|
694
|
+ return;
|
|
|
695
|
+ }
|
|
|
696
|
+
|
|
|
697
|
+ List<SalesmanQuotation> validDatas = datas.stream()
|
|
|
698
|
+ .filter(Objects::nonNull)
|
|
|
699
|
+ .collect(Collectors.toList());
|
|
|
700
|
+ if (CollectionUtil.isEmpty(validDatas)) {
|
|
|
701
|
+ return;
|
|
|
702
|
+ }
|
|
|
703
|
+
|
|
|
704
|
+ List<String> businessIds = validDatas.stream().map(SalesmanQuotation::getId).collect(Collectors.toList());
|
|
|
705
|
+ List<FlowInstanceWrapper> flowList = flowInstanceWrapperService.getFlowByBusinessIdList(businessIds);
|
|
|
706
|
+ Set<String> flowBusinessIdSet = CollectionUtil.isNotEmpty(flowList)
|
|
|
707
|
+ ? flowList.stream().map(FlowInstanceWrapper::getBusinessId).collect(Collectors.toSet())
|
|
|
708
|
+ : new HashSet<>();
|
|
|
709
|
+
|
|
|
710
|
+ List<FlowTaskDto> todoFlowTaskList = flowTaskWrapperMapper.queryTodoList(
|
|
|
711
|
+ new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId());
|
|
|
712
|
+ Set<String> todoBusinessIdSet = CollectionUtil.isNotEmpty(todoFlowTaskList)
|
|
|
713
|
+ ? todoFlowTaskList.stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toSet())
|
|
|
714
|
+ : new HashSet<>();
|
|
|
715
|
+
|
|
|
716
|
+ for (SalesmanQuotation data : validDatas) {
|
|
|
717
|
+ boolean hasFlow = flowBusinessIdSet.contains(data.getId());
|
|
|
718
|
+ boolean hasTodo = todoBusinessIdSet.contains(data.getId());
|
|
|
719
|
+ data.setShowExamineDetail(hasFlow && StringUtils.isNotBlank(data.getApprovalStatus()));
|
|
|
720
|
+ data.setShowExamine(hasTodo && CustomerDevelopStatus.AUDIT.name().equals(data.getApprovalStatus()));
|
|
|
721
|
+ }
|
|
|
722
|
+ }
|
|
|
723
|
+
|
|
|
724
|
+ /**
|
|
590
|
725
|
* 清理缓存
|
|
591
|
726
|
*
|
|
592
|
727
|
* @param key 缓存键
|
...
|
...
|
|