|
|
@@ -8,7 +8,6 @@ import me.zhengjie.base.util.DateUtils;
|
|
|
import me.zhengjie.base.util.FileUploadUtil;
|
|
|
import me.zhengjie.base.util.StatusEnum.SexStatusEnum;
|
|
|
import me.zhengjie.base.util.TextTempletUtil;
|
|
|
-import me.zhengjie.dao.mybatis.BankRepository;
|
|
|
import me.zhengjie.dao.mybatis.ModelRepository;
|
|
|
import me.zhengjie.dao.mybatis.OrderFileRepository;
|
|
|
import me.zhengjie.dao.mybatis.OrderRepository;
|
|
|
@@ -45,38 +44,46 @@ public class RedisReceiver implements MessageListener {
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void onMessage(Message message, byte[] pattern) {
|
|
|
+ System.out.println("Redis message receiver for generate common doc is beginnig ...");
|
|
|
String text = new String(message.getBody());
|
|
|
+ System.out.println(text);
|
|
|
if (StringUtils.isNotBlank(text)) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(text);
|
|
|
- String userId = jsonObject.getString("userId");
|
|
|
- String businessNo = jsonObject.getString("businessNo");
|
|
|
+ generateCommonDoc(jsonObject);
|
|
|
+ }
|
|
|
+ System.out.println("Redis message receiver for generate common doc is end.");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void generateCommonDoc(JSONObject jsonObject) {
|
|
|
+ String userId = jsonObject.getString("userId");
|
|
|
+ String businessNo = jsonObject.getString("businessNo");
|
|
|
+ //
|
|
|
+ OrderEntity orderEntity = orderRepository.getOrderByBizNo(businessNo);
|
|
|
+ List<ModelEntity> models = modelRepository.getCommonModel(orderEntity.getProdId(), orderEntity.getNotaryOfficeId());
|
|
|
+ // 在保存之前先删除数据
|
|
|
+ orderFileRepository.delFileWithBizNO(businessNo);
|
|
|
+ for (ModelEntity m : models) {
|
|
|
+ OrderFileEntity fileEntity = new OrderFileEntity();
|
|
|
+ fileEntity.setBusinessNo(businessNo);
|
|
|
+ fileEntity.setCode(m.getCode());
|
|
|
+ fileEntity.setSortNum(m.getSort());
|
|
|
+ String html = replaceFlag(m.getContent(), orderEntity);
|
|
|
+ String htmlPath = FileUploadUtil.saveHtml(html, businessNo);
|
|
|
+ String pdfPath = FileUploadUtil.savePdf(html, businessNo);
|
|
|
+ fileEntity.setHtmlUrl(htmlPath);
|
|
|
+ fileEntity.setPdfUrl(pdfPath);
|
|
|
+ fileEntity.setCreateTime(new Date());
|
|
|
+ fileEntity.setCreatorId(Long.parseLong(userId));
|
|
|
+ fileEntity.setFileName(m.getTitle());
|
|
|
+ fileEntity.setProdId(m.getProductType());
|
|
|
//
|
|
|
- OrderEntity orderEntity = orderRepository.getOrderByBizNo(businessNo);
|
|
|
- List<ModelEntity> models = modelRepository.getCommonModel(orderEntity.getProdId(), orderEntity.getNotaryOfficeId());
|
|
|
- // 在保存之前先删除数据
|
|
|
- orderFileRepository.delFileWithBizNO(businessNo);
|
|
|
- for (ModelEntity m : models) {
|
|
|
- OrderFileEntity fileEntity = new OrderFileEntity();
|
|
|
- fileEntity.setBusinessNo(businessNo);
|
|
|
- fileEntity.setCode(m.getCode());
|
|
|
- fileEntity.setSortNum(m.getSort());
|
|
|
- String html = replaceFlag(m.getContent(), orderEntity);
|
|
|
- String htmlPath = FileUploadUtil.saveHtml(html, businessNo);
|
|
|
- String pdfPath = FileUploadUtil.savePdf(html, businessNo);
|
|
|
- fileEntity.setHtmlUrl(htmlPath);
|
|
|
- fileEntity.setPdfUrl(pdfPath);
|
|
|
- fileEntity.setCreateTime(new Date());
|
|
|
- fileEntity.setCreatorId(Long.parseLong(userId));
|
|
|
- fileEntity.setFileName(m.getTitle());
|
|
|
- fileEntity.setProdId(m.getProductType());
|
|
|
- //
|
|
|
- orderFileMapper.insert(fileEntity);
|
|
|
- }
|
|
|
+ orderFileMapper.insert(fileEntity);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 替换文本标记
|
|
|
+ *
|
|
|
* @param content
|
|
|
* @param orderEntity
|
|
|
* @return
|
|
|
@@ -84,9 +91,8 @@ public class RedisReceiver implements MessageListener {
|
|
|
private String replaceFlag(String content, OrderEntity orderEntity) {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
map.put("$Date$", DateUtils.date2String(new Date(), 1));
|
|
|
- map.put("$Bank$", orderEntity.getBankName());
|
|
|
map.put("$BusinessOrderNo$", orderEntity.getBusinessNo());
|
|
|
- //
|
|
|
+ // 准备借款人信息
|
|
|
BorrowerEntity borrower = orderRepository.getBorrowerByBizNo(orderEntity.getBusinessNo());
|
|
|
if (borrower != null) {
|
|
|
map.put("$LoanName$", borrower.getUsername());
|
|
|
@@ -98,10 +104,10 @@ public class RedisReceiver implements MessageListener {
|
|
|
if (borrower.getJointFlag() == 1) {
|
|
|
try {
|
|
|
SimpleDateFormat dateSrcFormatter = new SimpleDateFormat("yyyyMMdd");
|
|
|
- SimpleDateFormat dateDestFormatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat dateDestFormatter = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
Date date = dateSrcFormatter.parse(borrower.getIdCard().substring(6, 14));
|
|
|
map.put("$MateName$", borrower.getSpouseName());
|
|
|
- map.put("$MateSex$", "1".equals(borrower.getSpouseSex()) ? "男" : "女");
|
|
|
+ map.put("$MateSex$", SexStatusEnum.getValue(borrower.getSpouseSex()));
|
|
|
map.put("$MateBirthday$", dateDestFormatter.format(date));
|
|
|
map.put("$MateAddr$", borrower.getResidence());
|
|
|
map.put("$MatePhone$", borrower.getSpousePhone());
|
|
|
@@ -117,6 +123,7 @@ public class RedisReceiver implements MessageListener {
|
|
|
map.put("$MatePhone$", "无");
|
|
|
}
|
|
|
}
|
|
|
+ // 准备抵押人信息
|
|
|
MortgageEntity mortgage = orderRepository.getMortgageByBizNo(orderEntity.getBusinessNo());
|
|
|
if (mortgage != null) {
|
|
|
map.put("$MortgageName$", mortgage.getUsername());
|
|
|
@@ -126,6 +133,7 @@ public class RedisReceiver implements MessageListener {
|
|
|
map.put("$MortgageIDNo$", mortgage.getIdCard());
|
|
|
map.put("$MortgagePhone$", mortgage.getPhone());
|
|
|
}
|
|
|
+ // 准备担保人信息
|
|
|
GuaranteeEntity guarantee = orderRepository.getGuaranteeByBizNo(orderEntity.getBusinessNo());
|
|
|
if (guarantee != null) {
|
|
|
map.put("$GuaranteeName$", guarantee.getUsername());
|
|
|
@@ -135,16 +143,18 @@ public class RedisReceiver implements MessageListener {
|
|
|
map.put("$GuaranteeIDNo$", guarantee.getIdCard());
|
|
|
map.put("$GuaranteePhone$", guarantee.getPhone());
|
|
|
}
|
|
|
+ // 准备银行信息
|
|
|
BankEntity bank = bankMapper.selectById(orderEntity.getBankId());
|
|
|
+ map.put("$Bank$", bank.getBankName());
|
|
|
map.put("$BankAddr$", bank.getAddress());
|
|
|
map.put("$BankLeader$", bank.getPrincipal());
|
|
|
map.put("$BankPhone$", bank.getPhone());
|
|
|
- //
|
|
|
+ // 准备客户经理信息
|
|
|
SysUserEntity user = sysUserMapper.selectById(orderEntity.getCustomerId());
|
|
|
map.put("$PBName$", user.getNickName());
|
|
|
map.put("$PBSex$", user.getGender());
|
|
|
map.put("$PBPhone$", user.getPhone());
|
|
|
- //
|
|
|
+ // 准备公证处信息
|
|
|
NotaryOfficeEntity office = notaryOfficeMapper.selectById(orderEntity.getNotaryOfficeId());
|
|
|
String[] areas = office.getAreaCodesStr().split(",");
|
|
|
QueryWrapper<ProvinceEntity> provinceQW = new QueryWrapper<>();
|