|
|
@@ -11,6 +11,8 @@ import me.zhengjie.application.bank.service.OrderService;
|
|
|
import me.zhengjie.base.AppBaseResponse;
|
|
|
import me.zhengjie.base.util.*;
|
|
|
import me.zhengjie.dao.mybatis.ModelRepository;
|
|
|
+import me.zhengjie.dao.mybatis.OrderFileRepository;
|
|
|
+import me.zhengjie.dao.mybatis.OrderRepository;
|
|
|
import me.zhengjie.dao.mybatis.entity.*;
|
|
|
import me.zhengjie.dao.mybatis.mapper.*;
|
|
|
import me.zhengjie.domain.order.OrderBizCodeMessage;
|
|
|
@@ -55,6 +57,18 @@ public class NotaryNoteServiceImpl extends ServiceImpl<INotaryNoteDao, NotaryNot
|
|
|
OrderFileMapper orderFileMapper;
|
|
|
@Autowired
|
|
|
ApplicationContextUtil contextUtil;
|
|
|
+ @Autowired
|
|
|
+ OrderRepository orderRepository;
|
|
|
+ @Autowired
|
|
|
+ BankMapper bankMapper;
|
|
|
+ @Autowired
|
|
|
+ SysUserMapper sysUserMapper;
|
|
|
+ @Autowired
|
|
|
+ IProvinceDao provinceDao;
|
|
|
+ @Autowired
|
|
|
+ ICityDao cityDao;
|
|
|
+ @Autowired
|
|
|
+ OrderFileRepository orderFileRepository;
|
|
|
|
|
|
@Override
|
|
|
public JSONObject getNotaryNoteByType(NotaryNoteVo notary) {
|
|
|
@@ -176,7 +190,7 @@ public class NotaryNoteServiceImpl extends ServiceImpl<INotaryNoteDao, NotaryNot
|
|
|
.concat(noteDto.getQuestion()).concat("<br>").concat(noteDto.getAnswer()).concat("</li>");
|
|
|
}
|
|
|
htmlContent = modelContent.replace("${QuestionAnswerList}", htmlContent).replace("${yyyyMMdd}",
|
|
|
- formatter.format(new Date()));
|
|
|
+ formatter.format(new Date())).replace("${NotaryUserName}",userDto.getNickName()).replace("${QueryUsers}",getQueryUsers(notary.getBusinessNo()));
|
|
|
String htmlpath = FileUploadUtil.saveHtml(htmlContent, notary.getBusinessNo());
|
|
|
String pdfPath = FileUploadUtil.savePdf(htmlContent, notary.getBusinessNo());
|
|
|
//
|
|
|
@@ -191,8 +205,16 @@ public class NotaryNoteServiceImpl extends ServiceImpl<INotaryNoteDao, NotaryNot
|
|
|
orderFile.setCreateTime(new Date());
|
|
|
orderFile.setCreatorId(userDto.getId());
|
|
|
orderFile.setFileName(modelEntity.getTitle());
|
|
|
- orderFileMapper.insert(orderFile);
|
|
|
+ orderFile.setProdId(notary.getProdId());
|
|
|
+ OrderFileEntity orderFileEntity = orderFileRepository.getOrderFileWithCode(notary.getProdId(), notary.getBusinessNo(), "6");
|
|
|
+ if (orderFileEntity == null) {
|
|
|
+ orderFileMapper.insert(orderFile);
|
|
|
+ } else {
|
|
|
+ orderFile.setId(orderFileEntity.getId());
|
|
|
+ orderFileMapper.updateById(orderFile);
|
|
|
+ }
|
|
|
saveNotaryUserId(notary.getBusinessNo());
|
|
|
+ recreateApplyDoc(notary.getBusinessNo());
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
@@ -211,14 +233,14 @@ public class NotaryNoteServiceImpl extends ServiceImpl<INotaryNoteDao, NotaryNot
|
|
|
saveBorrower.setUpdateTime(LocalDateTime.now());
|
|
|
saveBorrower.setNotaryUserId(currentUserId);
|
|
|
borrowerMapper.updateById(saveBorrower);
|
|
|
- QueryWrapper<GuaranteeEntity> guaranteeQw = new QueryWrapper<>();
|
|
|
- guaranteeQw.eq("business_no", businessNo);
|
|
|
- GuaranteeEntity guaranteeEntity = guaranteeMapper.selectOne(guaranteeQw);
|
|
|
- GuaranteeEntity saveGuarantee = new GuaranteeEntity();
|
|
|
- saveGuarantee.setId(guaranteeEntity.getId());
|
|
|
- saveGuarantee.setUpdateTime(LocalDateTime.now());
|
|
|
- saveGuarantee.setNotaryUserId(currentUserId);
|
|
|
- guaranteeMapper.updateById(saveGuarantee);
|
|
|
+// QueryWrapper<GuaranteeEntity> guaranteeQw = new QueryWrapper<>();
|
|
|
+// guaranteeQw.eq("business_no", businessNo);
|
|
|
+// GuaranteeEntity guaranteeEntity = guaranteeMapper.selectOne(guaranteeQw);
|
|
|
+// GuaranteeEntity saveGuarantee = new GuaranteeEntity();
|
|
|
+// saveGuarantee.setId(guaranteeEntity.getId());
|
|
|
+// saveGuarantee.setUpdateTime(LocalDateTime.now());
|
|
|
+// saveGuarantee.setNotaryUserId(currentUserId);
|
|
|
+// guaranteeMapper.updateById(saveGuarantee);
|
|
|
QueryWrapper<MortgageEntity> mortgageQw = new QueryWrapper<>();
|
|
|
mortgageQw.eq("business_no", businessNo);
|
|
|
// 非空
|
|
|
@@ -249,4 +271,162 @@ public class NotaryNoteServiceImpl extends ServiceImpl<INotaryNoteDao, NotaryNot
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 拼接询问人字符串
|
|
|
+ * @param businessNo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getQueryUsers(String businessNo) {
|
|
|
+ List<Map<String, String>> userList = new ArrayList<>();
|
|
|
+ OrderEntity order = orderRepository.getOrderByBizNo(businessNo);
|
|
|
+ BankEntity bank = bankMapper.selectById(order.getBankId());
|
|
|
+ String lender = "贷款人:" + bank.getBankName() + ",住所:" + bank.getAddress() + ",负责人:" + bank.getPrincipal() + "<br/>";
|
|
|
+ //
|
|
|
+ SysUserEntity user = sysUserMapper.selectById(order.getCustomerId());
|
|
|
+ Map<String, String> customerMap = new HashMap<>();
|
|
|
+ customerMap.put("title", "委托代理人");
|
|
|
+ customerMap.put("name", user.getNickName());
|
|
|
+ customerMap.put("sex", user.getGender());
|
|
|
+ customerMap.put("birth", user.getIdCard().substring(6, 8));
|
|
|
+ customerMap.put("idCard", user.getIdCard());
|
|
|
+ customerMap.put("phone", user.getPhone());
|
|
|
+ userList.add(customerMap);
|
|
|
+ BorrowerEntity borrower = orderRepository.getBorrowerByBizNo(businessNo);
|
|
|
+ Map<String, String> borrowerMap = new HashMap<>();
|
|
|
+ borrowerMap.put("title", "借款人");
|
|
|
+ borrowerMap.put("name", borrower.getUsername());
|
|
|
+ borrowerMap.put("sex", "1".equals(borrower.getSex()) ? "男" : "女");
|
|
|
+ borrowerMap.put("birth", borrower.getBirth());
|
|
|
+ borrowerMap.put("idCard", borrower.getIdCard());
|
|
|
+ borrowerMap.put("phone", borrower.getPhone());
|
|
|
+ userList.add(borrowerMap);
|
|
|
+ if (borrower.getJointFlag() == 1) {
|
|
|
+ borrowerMap = new HashMap<>();
|
|
|
+ borrowerMap.put("title", "借款人");
|
|
|
+ borrowerMap.put("name", borrower.getSpouseName());
|
|
|
+ borrowerMap.put("sex", Integer.parseInt(borrower.getSpouseIdCard().substring(15, 1)) % 2 == 1 ? "男" : "女");
|
|
|
+ borrowerMap.put("birth", borrower.getSpouseIdCard().substring(6, 8));
|
|
|
+ borrowerMap.put("idCard", borrower.getSpouseIdCard());
|
|
|
+ borrowerMap.put("phone", borrower.getSpousePhone());
|
|
|
+ userList.add(borrowerMap);
|
|
|
+ }
|
|
|
+ MortgageEntity mortgage = orderRepository.getMortgageByBizNo(businessNo);
|
|
|
+ if (mortgage != null) {
|
|
|
+ Map<String, String> mortgageMap = new HashMap<>();
|
|
|
+ mortgageMap.put("title", "抵押人");
|
|
|
+ mortgageMap.put("name", mortgage.getUsername());
|
|
|
+ mortgageMap.put("sex", "1".equals(mortgage.getSex()) ? "男" : "女");
|
|
|
+ mortgageMap.put("birth", mortgage.getBirth());
|
|
|
+ mortgageMap.put("idCard", mortgage.getIdCard());
|
|
|
+ mortgageMap.put("phone", mortgage.getPhone());
|
|
|
+ userList.add(mortgageMap);
|
|
|
+ if (mortgage.getJointFlag() == 1) {
|
|
|
+ mortgageMap = new HashMap<>();
|
|
|
+ mortgageMap.put("title", "抵押人");
|
|
|
+ mortgageMap.put("name", mortgage.getSpouseName());
|
|
|
+ mortgageMap.put("sex", Integer.parseInt(mortgage.getSpouseIdCard().substring(15, 1)) % 2 == 1 ? "男" : "女");
|
|
|
+ mortgageMap.put("birth", mortgage.getSpouseIdCard().substring(6, 8));
|
|
|
+ mortgageMap.put("idCard", mortgage.getSpouseIdCard());
|
|
|
+ mortgageMap.put("phone", mortgage.getSpousePhone());
|
|
|
+ userList.add(mortgageMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String template = "$title:$name,$sex,$birth出生,公民身份证号码:$idCard,联系电话:$phone<br/>";
|
|
|
+ String users = lender;
|
|
|
+ for (Map<String, String> map : userList) {
|
|
|
+ users += template.replace("$title", map.get("title")).replace("$name", map.get("name"))
|
|
|
+ .replace("$sex", map.get("sex")).replace("$birth", map.get("birth")).replace("$idCard", map.get("idCard"))
|
|
|
+ .replace("$phone", map.get("phone"));
|
|
|
+ }
|
|
|
+ return users;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重新生成申请表
|
|
|
+ *
|
|
|
+ * @param businessNo
|
|
|
+ */
|
|
|
+ public void recreateApplyDoc(String businessNo) {
|
|
|
+ OrderEntity orderEntity = orderRepository.getOrderByBizNo(businessNo);
|
|
|
+ ModelEntity model = modelRepository.getModelEntity(orderEntity.getProdId(), orderEntity.getNotaryOfficeId(), "1", "1");
|
|
|
+ OrderFileEntity fileEntity = orderFileRepository.getOrderFileWithCode(orderEntity.getProdId(), businessNo, "1");
|
|
|
+ OrderFileEntity saveFile = new OrderFileEntity();
|
|
|
+ saveFile.setId(fileEntity.getId());
|
|
|
+ String html = replaceFlag(model.getContent(), orderEntity);
|
|
|
+ String htmlPath = FileUploadUtil.saveHtml(html, businessNo);
|
|
|
+ String pdfPath = FileUploadUtil.savePdf(html, businessNo);
|
|
|
+ fileEntity.setHtmlUrl(htmlPath);
|
|
|
+ fileEntity.setPdfUrl(pdfPath);
|
|
|
+ orderFileMapper.updateById(fileEntity);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 替换文本标记
|
|
|
+ * @param content
|
|
|
+ * @param orderEntity
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ 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("$Greffier$", contextUtil.getCurrentUser().getNickName());
|
|
|
+ //
|
|
|
+ BorrowerEntity borrower = orderRepository.getBorrowerByBizNo(orderEntity.getBusinessNo());
|
|
|
+ if (borrower != null) {
|
|
|
+ map.put("$LoanName$", borrower.getUsername());
|
|
|
+ map.put("$LoanSex$", StatusEnum.SexStatusEnum.getValue(borrower.getSex()));
|
|
|
+ map.put("$LoanBirthdday$", borrower.getBirth());
|
|
|
+ map.put("$LoanHomeAddr$", borrower.getResidence());
|
|
|
+ map.put("$LoanIDNo$", borrower.getIdCard());
|
|
|
+ map.put("$LoanPhone$", borrower.getPhone());
|
|
|
+ }
|
|
|
+ MortgageEntity mortgage = orderRepository.getMortgageByBizNo(orderEntity.getBusinessNo());
|
|
|
+ if (mortgage != null) {
|
|
|
+ map.put("$MortgageName$", mortgage.getUsername());
|
|
|
+ map.put("$MortgageSex$", StatusEnum.SexStatusEnum.getValue(mortgage.getSex()));
|
|
|
+ map.put("$MortgageBirthdday$", mortgage.getBirth());
|
|
|
+ map.put("$MortgageHomeAddr$", mortgage.getResidence());
|
|
|
+ map.put("$MortgageIDNo$", mortgage.getIdCard());
|
|
|
+ map.put("$MortgagePhone$", mortgage.getPhone());
|
|
|
+ }
|
|
|
+ GuaranteeEntity guarantee = orderRepository.getGuaranteeByBizNo(orderEntity.getBusinessNo());
|
|
|
+ if (guarantee != null) {
|
|
|
+ map.put("$GuaranteeName$", guarantee.getUsername());
|
|
|
+ map.put("$GuaranteeSex$", StatusEnum.SexStatusEnum.getValue(guarantee.getSex()));
|
|
|
+ map.put("$GuaranteeBirthdday$", guarantee.getBirth());
|
|
|
+ map.put("$GuaranteeHomeAddr$", guarantee.getResidence());
|
|
|
+ map.put("$GuaranteeIDNo$", guarantee.getIdCard());
|
|
|
+ map.put("$GuaranteePhone$", guarantee.getPhone());
|
|
|
+ }
|
|
|
+ //
|
|
|
+ NotaryOfficeEntity office = notaryOfficeMapper.selectById(orderEntity.getNotaryOfficeId());
|
|
|
+ String[] areas = office.getAreaCodesStr().split(",");
|
|
|
+ QueryWrapper<ProvinceEntity> provinceQW = new QueryWrapper<>();
|
|
|
+ provinceQW.eq("code", areas[0]);
|
|
|
+
|
|
|
+ ProvinceEntity provinceEntity = provinceDao.selectOne(provinceQW);
|
|
|
+ String cityCodeZX = "110000,120000,310000,500000";
|
|
|
+ String cityName = "";
|
|
|
+ if (cityCodeZX.indexOf(provinceEntity.getCode()) <= -1) {
|
|
|
+ QueryWrapper<CityEntity> cityQW = new QueryWrapper<>();
|
|
|
+ cityQW.eq("code", areas[1]);
|
|
|
+ CityEntity cityEntity = cityDao.selectOne(cityQW);
|
|
|
+ cityName = cityEntity.getCityName();
|
|
|
+ }
|
|
|
+ String usedLocation = provinceEntity.getProvinceName().concat(cityName);
|
|
|
+ map.put("$NotaryOffice$", office.getName());
|
|
|
+ map.put("$UsedLocation$", usedLocation);
|
|
|
+
|
|
|
+ String replaceContent = TextTempletUtil.replaceContent(content, map);
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ InputStream inputStream = NotaryNoteServiceImpl.class.getClassLoader().getResourceAsStream("template/note/notary-model.html");
|
|
|
+ result = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return result.replace("${ModelContent}", replaceContent);
|
|
|
+ }
|
|
|
}
|