|
1
|
package com.lframework.xingyun.sc.procurement.impl.credit;
|
1
|
package com.lframework.xingyun.sc.procurement.impl.credit;
|
|
2
|
|
2
|
|
|
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
3
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
4
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
4
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
5
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
5
|
import com.github.pagehelper.PageInfo;
|
6
|
import com.github.pagehelper.PageInfo;
|
|
@@ -11,6 +12,7 @@ import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo; |
|
@@ -11,6 +12,7 @@ import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo; |
|
11
|
import com.lframework.starter.common.exceptions.impl.DefaultClientException;
|
12
|
import com.lframework.starter.common.exceptions.impl.DefaultClientException;
|
|
12
|
import com.lframework.starter.common.utils.Assert;
|
13
|
import com.lframework.starter.common.utils.Assert;
|
|
13
|
import com.lframework.starter.common.utils.ObjectUtil;
|
14
|
import com.lframework.starter.common.utils.ObjectUtil;
|
|
|
|
15
|
+import com.lframework.starter.mq.core.service.MqProducerService;
|
|
14
|
import com.lframework.starter.web.core.components.redis.RedisHandler;
|
16
|
import com.lframework.starter.web.core.components.redis.RedisHandler;
|
|
15
|
import com.lframework.starter.web.core.components.security.SecurityUtil;
|
17
|
import com.lframework.starter.web.core.components.security.SecurityUtil;
|
|
16
|
import com.lframework.starter.web.core.annotations.oplog.OpLog;
|
18
|
import com.lframework.starter.web.core.annotations.oplog.OpLog;
|
|
@@ -22,6 +24,7 @@ import com.lframework.starter.web.core.utils.OpLogUtil; |
|
@@ -22,6 +24,7 @@ import com.lframework.starter.web.core.utils.OpLogUtil; |
|
22
|
import com.lframework.starter.web.core.utils.PageHelperUtil;
|
24
|
import com.lframework.starter.web.core.utils.PageHelperUtil;
|
|
23
|
import com.lframework.starter.web.core.utils.PageResultUtil;
|
25
|
import com.lframework.starter.web.core.utils.PageResultUtil;
|
|
24
|
import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
|
26
|
import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
|
|
|
|
27
|
+import com.lframework.starter.web.inner.dto.message.SysSiteMessageDto;
|
|
25
|
import com.lframework.starter.web.inner.entity.SysUser;
|
28
|
import com.lframework.starter.web.inner.entity.SysUser;
|
|
26
|
import com.lframework.starter.web.inner.service.system.SysUserService;
|
29
|
import com.lframework.starter.web.inner.service.system.SysUserService;
|
|
27
|
import com.lframework.xingyun.sc.procurement.dto.ForeignTradeReviewerDto;
|
30
|
import com.lframework.xingyun.sc.procurement.dto.ForeignTradeReviewerDto;
|
|
@@ -33,12 +36,17 @@ import com.lframework.xingyun.sc.procurement.vo.credit.QueryProcurementForeignTr |
|
@@ -33,12 +36,17 @@ import com.lframework.xingyun.sc.procurement.vo.credit.QueryProcurementForeignTr |
|
33
|
import com.lframework.xingyun.sc.procurement.vo.credit.UpdateProcurementForeignTradeCreditVo;
|
36
|
import com.lframework.xingyun.sc.procurement.vo.credit.UpdateProcurementForeignTradeCreditVo;
|
|
34
|
import org.apache.commons.lang3.StringUtils;
|
37
|
import org.apache.commons.lang3.StringUtils;
|
|
35
|
import org.springframework.beans.factory.annotation.Autowired;
|
38
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
39
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
36
|
import org.springframework.stereotype.Service;
|
40
|
import org.springframework.stereotype.Service;
|
|
37
|
import org.springframework.transaction.annotation.Transactional;
|
41
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
42
|
+import org.springframework.util.CollectionUtils;
|
|
38
|
|
43
|
|
|
39
|
import javax.annotation.Resource;
|
44
|
import javax.annotation.Resource;
|
|
|
|
45
|
+import java.time.LocalDate;
|
|
40
|
import java.util.ArrayList;
|
46
|
import java.util.ArrayList;
|
|
|
|
47
|
+import java.util.HashSet;
|
|
41
|
import java.util.List;
|
48
|
import java.util.List;
|
|
|
|
49
|
+import java.util.Set;
|
|
42
|
import java.util.stream.Collectors;
|
50
|
import java.util.stream.Collectors;
|
|
43
|
|
51
|
|
|
44
|
@Service
|
52
|
@Service
|
|
@@ -46,6 +54,7 @@ public class ProcurementForeignTradeCreditServiceImpl |
|
@@ -46,6 +54,7 @@ public class ProcurementForeignTradeCreditServiceImpl |
|
46
|
extends BaseMpServiceImpl<ProcurementForeignTradeCreditMapper, ProcurementForeignTradeCredit>
|
54
|
extends BaseMpServiceImpl<ProcurementForeignTradeCreditMapper, ProcurementForeignTradeCredit>
|
|
47
|
implements ProcurementForeignTradeCreditService {
|
55
|
implements ProcurementForeignTradeCreditService {
|
|
48
|
private static final String BPM_FLAG = "CUSTOMER_CREDIT_OUT";
|
56
|
private static final String BPM_FLAG = "CUSTOMER_CREDIT_OUT";
|
|
|
|
57
|
+ private static final int REVIEW_REMIND_DAYS = 15;
|
|
49
|
|
58
|
|
|
50
|
@Resource
|
59
|
@Resource
|
|
51
|
private FlowInstanceWrapperService flowInstanceWrapperService;
|
60
|
private FlowInstanceWrapperService flowInstanceWrapperService;
|
|
@@ -55,6 +64,8 @@ public class ProcurementForeignTradeCreditServiceImpl |
|
@@ -55,6 +64,8 @@ public class ProcurementForeignTradeCreditServiceImpl |
|
55
|
private FlowTaskWrapperMapper flowTaskWrapperMapper;
|
64
|
private FlowTaskWrapperMapper flowTaskWrapperMapper;
|
|
56
|
@Resource
|
65
|
@Resource
|
|
57
|
private SysUserService sysUserService;
|
66
|
private SysUserService sysUserService;
|
|
|
|
67
|
+ @Autowired
|
|
|
|
68
|
+ private MqProducerService mqProducerService;
|
|
58
|
|
69
|
|
|
59
|
@Override
|
70
|
@Override
|
|
60
|
public PageResult<ProcurementForeignTradeCredit> query(Integer pageIndex, Integer pageSize,
|
71
|
public PageResult<ProcurementForeignTradeCredit> query(Integer pageIndex, Integer pageSize,
|
|
@@ -185,6 +196,17 @@ public class ProcurementForeignTradeCreditServiceImpl |
|
@@ -185,6 +196,17 @@ public class ProcurementForeignTradeCreditServiceImpl |
|
185
|
}
|
196
|
}
|
|
186
|
|
197
|
|
|
187
|
@Override
|
198
|
@Override
|
|
|
|
199
|
+ public void updateFreeze(List<String> ids, Boolean freeze) {
|
|
|
|
200
|
+ if (CollectionUtils.isEmpty(ids) || freeze == null) {
|
|
|
|
201
|
+ throw new DefaultClientException("资信IDs、冻结状态不能为空!");
|
|
|
|
202
|
+ }
|
|
|
|
203
|
+ LambdaUpdateWrapper<ProcurementForeignTradeCredit> updateWrapper = Wrappers.lambdaUpdate(ProcurementForeignTradeCredit.class)
|
|
|
|
204
|
+ .set(ProcurementForeignTradeCredit::getFreeze, freeze)
|
|
|
|
205
|
+ .in(ProcurementForeignTradeCredit::getId, ids);
|
|
|
|
206
|
+ getBaseMapper().update(updateWrapper);
|
|
|
|
207
|
+ }
|
|
|
|
208
|
+
|
|
|
|
209
|
+ @Override
|
|
188
|
public void updateNoFlowInstance(ProcurementForeignTradeCredit customerCredit) {
|
210
|
public void updateNoFlowInstance(ProcurementForeignTradeCredit customerCredit) {
|
|
189
|
if (ObjectUtil.isNull(customerCredit.getId())) {
|
211
|
if (ObjectUtil.isNull(customerCredit.getId())) {
|
|
190
|
throw new DefaultClientException("资信ID不能为空!");
|
212
|
throw new DefaultClientException("资信ID不能为空!");
|
|
@@ -208,6 +230,54 @@ public class ProcurementForeignTradeCreditServiceImpl |
|
@@ -208,6 +230,54 @@ public class ProcurementForeignTradeCreditServiceImpl |
|
208
|
return reviewer == null ? new ForeignTradeReviewerDto() : reviewer;
|
230
|
return reviewer == null ? new ForeignTradeReviewerDto() : reviewer;
|
|
209
|
}
|
231
|
}
|
|
210
|
|
232
|
|
|
|
|
233
|
+ /**
|
|
|
|
234
|
+ * 每天早上八点检查外贸资信下次评审时间提醒
|
|
|
|
235
|
+ */
|
|
|
|
236
|
+ @Scheduled(cron = "0 0 8 * * ?")
|
|
|
|
237
|
+ public void nextReviewTimeReminder() {
|
|
|
|
238
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
|
239
|
+ LocalDate remindEndDate = currentDate.plusDays(REVIEW_REMIND_DAYS);
|
|
|
|
240
|
+
|
|
|
|
241
|
+ LambdaQueryWrapper<ProcurementForeignTradeCredit> reminderWrapper =
|
|
|
|
242
|
+ Wrappers.lambdaQuery(ProcurementForeignTradeCredit.class)
|
|
|
|
243
|
+ .eq(ProcurementForeignTradeCredit::getStatus, "PASS")
|
|
|
|
244
|
+ .eq(ProcurementForeignTradeCredit::getFreeze, Boolean.FALSE)
|
|
|
|
245
|
+ .ge(ProcurementForeignTradeCredit::getNextReviewTime, currentDate)
|
|
|
|
246
|
+ .le(ProcurementForeignTradeCredit::getNextReviewTime, remindEndDate);
|
|
|
|
247
|
+ List<ProcurementForeignTradeCredit> reminderList = list(reminderWrapper);
|
|
|
|
248
|
+ for (ProcurementForeignTradeCredit customerCredit : reminderList) {
|
|
|
|
249
|
+ sendReminderMessage(customerCredit);
|
|
|
|
250
|
+ }
|
|
|
|
251
|
+ }
|
|
|
|
252
|
+
|
|
|
|
253
|
+ /**
|
|
|
|
254
|
+ * 每天凌晨检查外贸资信处理到期冻结。
|
|
|
|
255
|
+ */
|
|
|
|
256
|
+ @Scheduled(cron = "0 0 0 * * ?")
|
|
|
|
257
|
+ public void freezeReminder() {
|
|
|
|
258
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
|
259
|
+
|
|
|
|
260
|
+ LambdaQueryWrapper<ProcurementForeignTradeCredit> freezeWrapper =
|
|
|
|
261
|
+ Wrappers.lambdaQuery(ProcurementForeignTradeCredit.class)
|
|
|
|
262
|
+ .eq(ProcurementForeignTradeCredit::getStatus, "PASS")
|
|
|
|
263
|
+ .eq(ProcurementForeignTradeCredit::getFreeze, Boolean.FALSE)
|
|
|
|
264
|
+ .lt(ProcurementForeignTradeCredit::getNextReviewTime, currentDate);
|
|
|
|
265
|
+ List<ProcurementForeignTradeCredit> freezeList = list(freezeWrapper);
|
|
|
|
266
|
+ List<String> freezeIds = new ArrayList<>();
|
|
|
|
267
|
+ List<ProcurementForeignTradeCredit> needFreezeList = new ArrayList<>();
|
|
|
|
268
|
+ for (ProcurementForeignTradeCredit customerCredit : freezeList) {
|
|
|
|
269
|
+ freezeIds.add(customerCredit.getId());
|
|
|
|
270
|
+ needFreezeList.add(customerCredit);
|
|
|
|
271
|
+ }
|
|
|
|
272
|
+
|
|
|
|
273
|
+ if (!freezeIds.isEmpty()) {
|
|
|
|
274
|
+ updateFreeze(freezeIds, Boolean.TRUE);
|
|
|
|
275
|
+ for (ProcurementForeignTradeCredit customerCredit : needFreezeList) {
|
|
|
|
276
|
+ sendFreezeMessage(customerCredit);
|
|
|
|
277
|
+ }
|
|
|
|
278
|
+ }
|
|
|
|
279
|
+ }
|
|
|
|
280
|
+
|
|
211
|
private void fillData(ProcurementForeignTradeCredit data, CreateProcurementForeignTradeCreditVo vo, SysUser investigator) {
|
281
|
private void fillData(ProcurementForeignTradeCredit data, CreateProcurementForeignTradeCreditVo vo, SysUser investigator) {
|
|
212
|
data.setUnitName(vo.getUnitName());
|
282
|
data.setUnitName(vo.getUnitName());
|
|
213
|
data.setCompanyNature(vo.getCompanyNature());
|
283
|
data.setCompanyNature(vo.getCompanyNature());
|
|
@@ -304,4 +374,52 @@ public class ProcurementForeignTradeCreditServiceImpl |
|
@@ -304,4 +374,52 @@ public class ProcurementForeignTradeCreditServiceImpl |
|
304
|
}
|
374
|
}
|
|
305
|
return investigator;
|
375
|
return investigator;
|
|
306
|
}
|
376
|
}
|
|
|
|
377
|
+
|
|
|
|
378
|
+ /**
|
|
|
|
379
|
+ * 发送下次评审时间提醒消息。
|
|
|
|
380
|
+ *
|
|
|
|
381
|
+ * @param customerCredit 外贸资信
|
|
|
|
382
|
+ */
|
|
|
|
383
|
+ private void sendReminderMessage(ProcurementForeignTradeCredit customerCredit) {
|
|
|
|
384
|
+ if (customerCredit == null || StringUtils.isBlank(customerCredit.getCreateById())
|
|
|
|
385
|
+ || customerCredit.getNextReviewTime() == null) {
|
|
|
|
386
|
+ return;
|
|
|
|
387
|
+ }
|
|
|
|
388
|
+
|
|
|
|
389
|
+ Set<String> userIdSet = new HashSet<>();
|
|
|
|
390
|
+ userIdSet.add(customerCredit.getCreateById());
|
|
|
|
391
|
+ SysSiteMessageDto messageDto = new SysSiteMessageDto();
|
|
|
|
392
|
+ messageDto.setUserIdList(new ArrayList<>(userIdSet));
|
|
|
|
393
|
+ messageDto.setTitle("采购外贸客户资信评审到期提醒");
|
|
|
|
394
|
+ messageDto.setContent("您创建的客户资信单位【" + StringUtils.defaultString(customerCredit.getUnitName())
|
|
|
|
395
|
+ + "】下次评审时间将于" + customerCredit.getNextReviewTime()
|
|
|
|
396
|
+ + "到期,请及时发起变更,逾期未发起变更系统将自动冻结。");
|
|
|
|
397
|
+ messageDto.setBizKey(IdUtil.getId());
|
|
|
|
398
|
+ messageDto.setCreateUserId(null);
|
|
|
|
399
|
+ mqProducerService.createSysSiteMessage(messageDto);
|
|
|
|
400
|
+ }
|
|
|
|
401
|
+
|
|
|
|
402
|
+ /**
|
|
|
|
403
|
+ * 发送自动冻结提醒消息。
|
|
|
|
404
|
+ *
|
|
|
|
405
|
+ * @param customerCredit 外贸资信
|
|
|
|
406
|
+ */
|
|
|
|
407
|
+ private void sendFreezeMessage(ProcurementForeignTradeCredit customerCredit) {
|
|
|
|
408
|
+ if (customerCredit == null || StringUtils.isBlank(customerCredit.getCreateById())
|
|
|
|
409
|
+ || customerCredit.getNextReviewTime() == null) {
|
|
|
|
410
|
+ return;
|
|
|
|
411
|
+ }
|
|
|
|
412
|
+
|
|
|
|
413
|
+ Set<String> userIdSet = new HashSet<>();
|
|
|
|
414
|
+ userIdSet.add(customerCredit.getCreateById());
|
|
|
|
415
|
+ SysSiteMessageDto messageDto = new SysSiteMessageDto();
|
|
|
|
416
|
+ messageDto.setUserIdList(new ArrayList<>(userIdSet));
|
|
|
|
417
|
+ messageDto.setTitle("采购外贸客户资信自动冻结提醒");
|
|
|
|
418
|
+ messageDto.setContent("您创建的客户资信单位【" + StringUtils.defaultString(customerCredit.getUnitName())
|
|
|
|
419
|
+ + "】下次评审时间已于" + customerCredit.getNextReviewTime()
|
|
|
|
420
|
+ + "到期,且未发起变更,系统已自动冻结。");
|
|
|
|
421
|
+ messageDto.setBizKey(IdUtil.getId());
|
|
|
|
422
|
+ messageDto.setCreateUserId(null);
|
|
|
|
423
|
+ mqProducerService.createSysSiteMessage(messageDto);
|
|
|
|
424
|
+ }
|
|
307
|
} |
425
|
} |