|
|
@@ -2,16 +2,24 @@ package com.ydtech.modules.order.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ydtech.constants.enums.FileType;
|
|
|
+import com.ydtech.core.page.HttpResult;
|
|
|
import com.ydtech.exception.SystemException;
|
|
|
import com.ydtech.modules.order.dao.InsUploadFilesMapper;
|
|
|
+import com.ydtech.modules.order.entity.api.pingan.utils.PDFUtil;
|
|
|
+import com.ydtech.modules.order.entity.po.InsOrderReadPdf;
|
|
|
import com.ydtech.modules.order.entity.po.InsUploadFiles;
|
|
|
+import com.ydtech.modules.order.service.InsOrderReadPdfService;
|
|
|
import com.ydtech.modules.order.service.InsUploadFilesService;
|
|
|
import com.ydtech.utils.ImageCompressionUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
@@ -19,7 +27,11 @@ import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @author wenks
|
|
|
@@ -39,6 +51,10 @@ public class InsUploadFilesServiceImpl extends ServiceImpl<InsUploadFilesMapper,
|
|
|
|
|
|
private static final int desFileSize = 300;
|
|
|
|
|
|
+ @Lazy
|
|
|
+ @Autowired
|
|
|
+ private InsOrderReadPdfService insOrderReadPdfService;
|
|
|
+
|
|
|
@Override
|
|
|
public InsUploadFiles uploadFile(MultipartFile multipartFile, String username, String type) throws IOException {
|
|
|
String fileMD5 = DigestUtils.md5Hex(multipartFile.getBytes());
|
|
|
@@ -99,8 +115,6 @@ public class InsUploadFilesServiceImpl extends ServiceImpl<InsUploadFilesMapper,
|
|
|
throw new SystemException("上传过程中出错" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 自动生成目录
|
|
|
*
|
|
|
@@ -126,6 +140,58 @@ public class InsUploadFilesServiceImpl extends ServiceImpl<InsUploadFilesMapper,
|
|
|
return stringBuilder.toString();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2025/6/25 8:52
|
|
|
+ * @Description: 上传文件并解析签单时间
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public HttpResult uploadFileToTraferSignDateTime(MultipartFile multipartFile, String userName, String type, String companyId,String fileType) {
|
|
|
+
|
|
|
+ InsUploadFiles insUploadFiles =null;
|
|
|
+ try {
|
|
|
+ insUploadFiles = uploadFile(multipartFile, userName, type);
|
|
|
+ }catch (Exception e){
|
|
|
+ return HttpResult.error("上传文件失败!");
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(fileType) &&("1".equals(fileType) || "2".equals(fileType))){
|
|
|
+ if(StringUtils.isBlank(companyId)){
|
|
|
+ return HttpResult.error("保险公司不能为空!");
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(fileType)){
|
|
|
+ return HttpResult.error("保单类型不能为空!");
|
|
|
+ }
|
|
|
+ if(insUploadFiles!=null){
|
|
|
+ //通过保险公司配置读取截取的前缀和后缀
|
|
|
+ LambdaQueryWrapper<InsOrderReadPdf> qws = new LambdaQueryWrapper<>();
|
|
|
+ qws.eq(InsOrderReadPdf::getCompanyId, companyId);
|
|
|
+ qws.eq(InsOrderReadPdf::getType, fileType);
|
|
|
+ List<InsOrderReadPdf> list = insOrderReadPdfService.list(qws);
|
|
|
+ HashMap<String, LocalDateTime> map = new HashMap<>();
|
|
|
+ String pdfText = PDFUtil.getPdfText(insUploadFiles.getFilePath());
|
|
|
+ if (StringUtils.isNotBlank(pdfText)) {
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ for (InsOrderReadPdf insOrderReadPdf : list) {
|
|
|
+ LocalDateTime pdfContentDate =null;
|
|
|
+ try{
|
|
|
+ pdfContentDate = PDFUtil.getPdfContentDate(pdfText, insOrderReadPdf.getReadBegin(), insOrderReadPdf.getReadEnd(), insOrderReadPdf.getReadType());
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+ map.put(insOrderReadPdf.getOrderMsg(), pdfContentDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(map.get("signingTime")!=null){
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String signingTimeStr = map.get("signingTime").format(formatter);
|
|
|
+ insUploadFiles.setSignTime(signingTimeStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return HttpResult.ok(insUploadFiles);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|