CredentialsReviewService.java
4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package com.zteits.pay.util;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSON;
import com.clouds.common.utils.MsgTemplateUtil;
import com.zteits.clouds.api.apibase.constants.*;
import com.zteits.clouds.api.apibase.exception.BizException;
import com.zteits.pay.dao.TdCCustPersonDao;
import com.zteits.pay.dao.TdCMsgTemplateDao;
import com.zteits.pay.dao.TdCPushMsgDao;
import com.zteits.pay.domain.TdCCarCheckRecord;
import com.zteits.pay.domain.TdCCustPerson;
import com.zteits.pay.domain.TdCMsgTemplate;
import com.zteits.pay.domain.TdCPushMsg;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* Copyright: Copyright (c) 2019 zteits
*
* @ClassName: CredentialsReviewService
* @Description:
* @version: v1.0.0
* @author: niueb
* @date: 2020/9/14 11:21
* Modification History:
* Date Author Version Description
* ---------------------------------------------------------*
* 2020/9/14 niueb v1.0.0 创建
*/
@Component
public class CredentialsReviewService {
private static final Logger logger = LoggerFactory.getLogger(CredentialsReviewService.class);
@Autowired
private TdCCustPersonDao tdCCustPersonDao;
@Autowired
private TdCMsgTemplateDao tdCMsgTemplateDao;
@Autowired
private TdCPushMsgDao tdCPushMsgDao;
/**
* 驾驶证审核结果推送
*
* @return
*/
@Async
public void driverLicenseResPush(TdCCarCheckRecord checkRecord) {
logger.info("driverLicenseResPush驾驶证审核结果推送请求参数:" + JSON.toJSONString(checkRecord));
logger.info("驾驶证审核结果-激光推送开始");
TdCCustPerson tdCCustPerson = tdCCustPersonDao.queryPersonByCustId(checkRecord.getCustId());
if (tdCCustPerson == null || tdCCustPerson.getMsgPushState() == null
|| tdCCustPerson.getMsgPushState() != 1 || StringUtils.isBlank(tdCCustPerson.getAlias())) {
logger.info("custId:" + checkRecord.getCustId() + "不需要推送消息");
return;
}
//消息模板
String templeteId = checkRecord.getCheckState() == 2 ? MSGTempleteEnum.DRIVER_LICENSE_PASS_TIPS.value() :
checkRecord.getCheckState() == 3 ? MSGTempleteEnum.DRIVER_LICENSE_FAILURE_TIPS.value() :
checkRecord.getCheckState() == 0 ? MSGTempleteEnum.DRIVER_LICENSE_REVOKE_TIPS.value() : null;
TdCMsgTemplate tdCMsgTemplate = tdCMsgTemplateDao.queryMsgTempleteByTempleteId(templeteId);
if (tdCMsgTemplate == null) {
logger.error("消息模板:" + templeteId + ",不存在,不发送激光消息");
return;
}
String content = tdCMsgTemplate.getTemplateContent();
String title = tdCMsgTemplate.getTemplateTitle();
//提示语拼接车牌
Map<String, String> datas = new HashMap<String, String>();
datas.put("carNumber", checkRecord.getCarNumber() + "");
datas.put("remark", checkRecord.getCheckRemark() + "");
content = MsgTemplateUtil.render(content, datas);
//处理消息并发送
TdCPushMsg record = new TdCPushMsg();
record.setMsgContent(content);
record.setMsgTitle(title);
record.setMsgType(MSGTypeEnum.MSG_TYPE_SYS.value());
record.setTempleteId(tdCMsgTemplate.getTemplateId());
record.setPushType(MSGTypeEnum.MSG_PUSH_TYPE_ONLY.value());
record.setReturnType(MSGTypeEnum.MSG_RETURN_YES.value());
record.setReadType(MSGTypeEnum.MSG_READ_NO.value());
record.setCustId(checkRecord.getCustId());
record.setDataState(1);
record.setCreateDate(new Date());
record.setModfiyDate(new Date());
record.setOutMsgNo(checkRecord.getCarNumber());
tdCPushMsgDao.insertSelective(record);
//激光推送
JPustUtil.sendPush(content, tdCCustPerson.getAlias(), MSGTypeEnum.MSG_TYPE_SYS.value() + "",
tdCCustPerson.getDeivceType());
logger.info("驾驶证审核结果-激光推送结束");
}
}