|
@@ -9,6 +9,7 @@ import com.jpsoft.picc.modules.base.service.CompanyService;
|
|
import com.jpsoft.picc.modules.base.service.InsuranceDefinitionLimitService;
|
|
import com.jpsoft.picc.modules.base.service.InsuranceDefinitionLimitService;
|
|
import com.jpsoft.picc.modules.business.entity.InsuranceApplication;
|
|
import com.jpsoft.picc.modules.business.entity.InsuranceApplication;
|
|
import com.jpsoft.picc.modules.business.entity.InsurancePolicyMember;
|
|
import com.jpsoft.picc.modules.business.entity.InsurancePolicyMember;
|
|
|
|
+import com.jpsoft.picc.modules.business.service.ApplicationPolicyService;
|
|
import com.jpsoft.picc.modules.business.service.InsuranceApplicationService;
|
|
import com.jpsoft.picc.modules.business.service.InsuranceApplicationService;
|
|
import com.jpsoft.picc.modules.business.service.InsurancePolicyMemberService;
|
|
import com.jpsoft.picc.modules.business.service.InsurancePolicyMemberService;
|
|
import com.jpsoft.picc.modules.common.config.OSSConfig;
|
|
import com.jpsoft.picc.modules.common.config.OSSConfig;
|
|
@@ -30,12 +31,10 @@ import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
@@ -63,6 +62,9 @@ public class AttachmentController {
|
|
@Autowired
|
|
@Autowired
|
|
private InsurancePolicyMemberService insurancePolicyMemberService;
|
|
private InsurancePolicyMemberService insurancePolicyMemberService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ApplicationPolicyService applicationPolicyService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private CompanyService companyService;
|
|
private CompanyService companyService;
|
|
|
|
|
|
@@ -70,6 +72,7 @@ public class AttachmentController {
|
|
private CompanyMemberService companyMemberService;
|
|
private CompanyMemberService companyMemberService;
|
|
|
|
|
|
@PostMapping("/base/attachment/upload")
|
|
@PostMapping("/base/attachment/upload")
|
|
|
|
+ @ResponseBody
|
|
@ApiOperation(value="附件上传")
|
|
@ApiOperation(value="附件上传")
|
|
@ApiImplicitParams({
|
|
@ApiImplicitParams({
|
|
@ApiImplicitParam(name = "fileName",value = "文件名", required = false, paramType = "form"),
|
|
@ApiImplicitParam(name = "fileName",value = "文件名", required = false, paramType = "form"),
|
|
@@ -100,17 +103,29 @@ public class AttachmentController {
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value="pdf文档生成与下载")
|
|
@ApiOperation(value="pdf文档生成与下载")
|
|
- @RequestMapping(value = "/pub/attachment/downloadPolicyPDF",method = RequestMethod.GET)
|
|
|
|
|
|
+ @RequestMapping(value = "/pub/attachment/downloadPolicyPdf",method = RequestMethod.GET)
|
|
@ApiImplicitParams({
|
|
@ApiImplicitParams({
|
|
- @ApiImplicitParam(name="applicationId",value = "投保单ID",required = true,paramType = "query"),
|
|
|
|
|
|
+ @ApiImplicitParam(name="applicationId",value = "投保单ID",required = false,paramType = "query"),
|
|
@ApiImplicitParam(name="policyId",value = "每月投保单ID",required = true,paramType = "query")
|
|
@ApiImplicitParam(name="policyId",value = "每月投保单ID",required = true,paramType = "query")
|
|
})
|
|
})
|
|
- public ResponseEntity downloadPolicyPDF(String applicationId, String policyId){
|
|
|
|
|
|
+ public ResponseEntity downloadPolicyPdf(String applicationId, String policyId){
|
|
String logoUrl = pdfConfig.getLogoUrl();
|
|
String logoUrl = pdfConfig.getLogoUrl();
|
|
ResponseEntity entity;
|
|
ResponseEntity entity;
|
|
|
|
|
|
try {
|
|
try {
|
|
- InsuranceApplication insuranceApplication = insuranceApplicationService.get(applicationId);
|
|
|
|
|
|
+ InsuranceApplication insuranceApplication = null;
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isEmpty(applicationId)){
|
|
|
|
+ List<InsuranceApplication> applicationList = applicationPolicyService.findApplicationByPolicyId(policyId);
|
|
|
|
+
|
|
|
|
+ if (applicationList.size()>0){
|
|
|
|
+ insuranceApplication = applicationList.get(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ insuranceApplication = insuranceApplicationService.get(applicationId);
|
|
|
|
+ }
|
|
|
|
+
|
|
Company company = companyService.get(insuranceApplication.getCompanyId());
|
|
Company company = companyService.get(insuranceApplication.getCompanyId());
|
|
|
|
|
|
List<InsuranceDefinitionLimit> insuranceDefinitionLimitList = insuranceDefinitionLimitService.findByDefinitionId(insuranceApplication.getDefinitionId());
|
|
List<InsuranceDefinitionLimit> insuranceDefinitionLimitList = insuranceDefinitionLimitService.findByDefinitionId(insuranceApplication.getDefinitionId());
|
|
@@ -216,4 +231,96 @@ public class AttachmentController {
|
|
log.error(ex.getMessage(),ex);
|
|
log.error(ex.getMessage(),ex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="打包下载申请资料")
|
|
|
|
+ @RequestMapping(value = "/pub/attachment/downloadPolicyZip",method = RequestMethod.GET)
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
+ @ApiImplicitParam(name="policyId",value = "每月投保单ID",required = true,paramType = "query")
|
|
|
|
+ })
|
|
|
|
+ public void downloadPolicyZip(String policyId, HttpServletRequest request, HttpServletResponse response){
|
|
|
|
+ try {
|
|
|
|
+ String path = request.getContextPath();
|
|
|
|
+ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
|
|
|
|
+
|
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
|
+ response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
|
+
|
|
|
|
+ //设置编码 为了解决中文名称乱码问题
|
|
|
|
+ String fileName = "投保申请资料";
|
|
|
|
+ String zipFileName = new String(fileName.getBytes("UTF-8"), "iso-8859-1");
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment;fileName=" + zipFileName + ".zip");
|
|
|
|
+
|
|
|
|
+ //打包文件
|
|
|
|
+ List<Map<String,String>> fileList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ //营业执照
|
|
|
|
+ InsuranceApplication insuranceApplication = null;
|
|
|
|
+
|
|
|
|
+ List<InsuranceApplication> applicationList = applicationPolicyService.findApplicationByPolicyId(policyId);
|
|
|
|
+
|
|
|
|
+ if (applicationList.size()>0){
|
|
|
|
+ insuranceApplication = applicationList.get(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (insuranceApplication!=null){
|
|
|
|
+ Company company = companyService.get(insuranceApplication.getCompanyId());
|
|
|
|
+ String url = company.getUsccFiles();
|
|
|
|
+
|
|
|
|
+ Map<String,String> fileMap = new HashMap<>();
|
|
|
|
+ fileMap.put("fileUrl", url);
|
|
|
|
+ fileMap.put("fileName", "营业执照" + url.substring(url.lastIndexOf(".")));
|
|
|
|
+
|
|
|
|
+ fileList.add(fileMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //电子投保文件
|
|
|
|
+ if(insuranceApplication!=null){
|
|
|
|
+ Map<String,String> fileMap = new HashMap<>();
|
|
|
|
+ fileMap.put("fileUrl",basePath + "pub/attachment/downloadPolicyPdf?applicationId="
|
|
|
|
+ + insuranceApplication.getId()
|
|
|
|
+ + "&policyId=" + policyId);
|
|
|
|
+
|
|
|
|
+ fileMap.put("fileName", "投保文件电子版.pdf");
|
|
|
|
+
|
|
|
|
+ fileList.add(fileMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //身份证
|
|
|
|
+ List<InsurancePolicyMember> policyMemberList = insurancePolicyMemberService.findByPolicyId(policyId);
|
|
|
|
+
|
|
|
|
+ for (InsurancePolicyMember policyMember : policyMemberList) {
|
|
|
|
+ CompanyMember member = companyMemberService.get(policyMember.getMemberId());
|
|
|
|
+
|
|
|
|
+ String urls = member.getCardFiles();
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotEmpty(urls)){
|
|
|
|
+ String[] arr = urls.split("\\|");
|
|
|
|
+
|
|
|
|
+ for(int i=0;i<arr.length;i++) {
|
|
|
|
+ String url = arr[i];
|
|
|
|
+
|
|
|
|
+ String ext = url.substring(url.lastIndexOf("."));
|
|
|
|
+
|
|
|
|
+ Map<String,String> fileMap = new HashMap<>();
|
|
|
|
+ fileMap.put("fileUrl",url + "?x-oss-process=image/resize,l_1024,limit_1");
|
|
|
|
+ fileMap.put("filePath", "身份证/");
|
|
|
|
+ fileMap.put("fileName", member.getCardNo() + "-" + (i+1) + ext);
|
|
|
|
+
|
|
|
|
+ fileList.add(fileMap);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ OutputStream output = response.getOutputStream();
|
|
|
|
+
|
|
|
|
+ OSSUtil.batchDownload(fileList,output);
|
|
|
|
+
|
|
|
|
+ output.flush();
|
|
|
|
+ output.close();
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex){
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|