浏览代码

1.打包下载投保申请资料完善。
2.审批流程测试。

tomatozq 5 年之前
父节点
当前提交
5b416eb9d7

+ 115 - 8
picc-admin-server/src/main/java/com/jpsoft/picc/modules/base/controller/AttachmentController.java

@@ -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.business.entity.InsuranceApplication;
 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.InsurancePolicyMemberService;
 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.ResponseEntity;
 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 javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.OutputStream;
@@ -63,6 +62,9 @@ public class AttachmentController {
     @Autowired
     private InsurancePolicyMemberService insurancePolicyMemberService;
 
+    @Autowired
+    private ApplicationPolicyService applicationPolicyService;
+
     @Autowired
     private CompanyService companyService;
 
@@ -70,6 +72,7 @@ public class AttachmentController {
     private CompanyMemberService companyMemberService;
 
     @PostMapping("/base/attachment/upload")
+    @ResponseBody
     @ApiOperation(value="附件上传")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "fileName",value = "文件名", required = false, paramType = "form"),
@@ -100,17 +103,29 @@ public class AttachmentController {
     }
 
     @ApiOperation(value="pdf文档生成与下载")
-    @RequestMapping(value = "/pub/attachment/downloadPolicyPDF",method = RequestMethod.GET)
+    @RequestMapping(value = "/pub/attachment/downloadPolicyPdf",method = RequestMethod.GET)
     @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")
     })
-    public ResponseEntity downloadPolicyPDF(String applicationId, String policyId){
+    public ResponseEntity downloadPolicyPdf(String applicationId, String policyId){
         String logoUrl = pdfConfig.getLogoUrl();
         ResponseEntity entity;
 
         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());
 
             List<InsuranceDefinitionLimit> insuranceDefinitionLimitList = insuranceDefinitionLimitService.findByDefinitionId(insuranceApplication.getDefinitionId());
@@ -216,4 +231,96 @@ public class AttachmentController {
             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);
+        }
+    }
 }

+ 55 - 28
picc-admin-server/src/main/java/com/jpsoft/picc/modules/business/controller/InsurancePolicyController.java

@@ -38,6 +38,7 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
 import java.io.File;
 import java.security.Policy;
 import java.util.*;
@@ -281,36 +282,61 @@ public class InsurancePolicyController {
     @ApiImplicitParams({
             @ApiImplicitParam(name="id",value = "每月投保单ID",required = true,paramType = "query")
     })
-    public MessageResult<List<Map<String,Object>>> attachmentList(String id, @RequestAttribute String subject){
-
+    public MessageResult<List<Map<String,Object>>> attachmentList(
+            String id, @RequestAttribute String subject,
+            HttpServletRequest request){
         //当前用户ID
-        System.out.println(subject);
-
         MessageResult<List<Map<String,Object>>> msgResult = new MessageResult<List<Map<String,Object>>>();
 
         InsurancePolicy insurancePolicy = insurancePolicyService.get(id);
 
-        String file = insurancePolicy.getInsurancePolicyFile();
-
+//        String file = insurancePolicy.getInsurancePolicyFile();
         List<Map<String,Object>> fileList = new ArrayList<Map<String,Object>>();
-
-        if(StringUtils.isNotEmpty(file)){
-            String[] files = file.split(";");
-
-            int i=1;
-
-            for (String str:files) {
-                Map<String,Object> map = new HashMap<String,Object>();
-                map.put("index",i);
-                map.put("file",str);
-                String name = "";
-                if(StringUtils.isNotEmpty(str)){
-                    name = str.substring(str.lastIndexOf("/")+1);
-                }
-                map.put("name",name);
-                fileList.add(map);
-                i++;
-            }
+//        if(StringUtils.isNotEmpty(file)){
+//            String[] files = file.split(";");
+//
+//            int i=1;
+//
+//            for (String str:files) {
+//                Map<String,Object> map = new HashMap<String,Object>();
+//                map.put("index",i);
+//                map.put("file",str);
+//                String name = "";
+//                if(StringUtils.isNotEmpty(str)){
+//                    name = str.substring(str.lastIndexOf("/")+1);
+//                }
+//                map.put("name",name);
+//                fileList.add(map);
+//                i++;
+//            }
+//        }
+
+        String path = request.getContextPath();
+        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
+
+        List<InsuranceApplication> applicationList = applicationPolicyService.findApplicationByPolicyId(insurancePolicy.getId());
+
+        if (applicationList.size()>0) {
+            InsuranceApplication insuranceApplication = applicationList.get(0);
+
+            Company company = companyService.get(insuranceApplication.getCompanyId());
+
+            Map<String,Object> file1 = new HashMap<>();
+
+            String url = company.getUsccFiles();
+
+            file1.put("index","1");
+            file1.put("name", "营业执照" + url.substring(url.lastIndexOf(".")));
+            file1.put("url", url);
+
+            fileList.add(file1);
+
+            Map<String,Object> file2 = new HashMap<>();
+            file2.put("index","2");
+            file2.put("name","身份证.zip");
+            file2.put("url",basePath + "pub/attachment/downloadIdCardZip?policyId=" + id);
+
+            fileList.add(file2);
         }
 
         msgResult.setResult(true);
@@ -319,8 +345,6 @@ public class InsurancePolicyController {
         return msgResult;
     }
 
-
-
     @ApiOperation(value="读取推广信息")
     @RequestMapping(value = "loadInsuranceAgent",method = RequestMethod.POST)
     @ApiImplicitParams({
@@ -526,9 +550,9 @@ public class InsurancePolicyController {
 
                     //发送微信通知
                     sendWeixinMessage(applicationId, policyStatus);
-                } else {
-                    flag = true;
                 }
+
+                flag = true;
             }
 
             msgResult.setResult(flag);
@@ -714,6 +738,9 @@ public class InsurancePolicyController {
         destPolicy.setStartTime(startTime.toDate());
         destPolicy.setEndTime(startTime.plusMonths(1).toDate());
 
+        //下月状态为待初审
+        destPolicy.setStatus(PolicyStatus.PendingTrial.getValue() + "");
+
         //已经过期则不生成下月投保单
         if (destPolicy.getEndTime().after(insuranceApplication.getEndTime())){
             return;

+ 6 - 2
picc-admin-server/src/test/java/com/jpsoft/picc/test/OSSTest.java

@@ -12,7 +12,9 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest
@@ -41,9 +43,11 @@ public class OSSTest {
         //?x-oss-process=image/resize,l_1024,limit_1
         //String fileUrl = "picc/test/2020/2/身份证.png";
         String fileUrl = "http://vod.wzgh.org/picc/test/2020/2/身份证.png?x-oss-process=image/resize,l_800,limit_1";
+        Map<String,String> fileMap = new HashMap<>();
+        fileMap.put(fileUrl,fileUrl);
 
-        List<String> fileList = new ArrayList<>();
-        fileList.add(fileUrl);
+        List<Map> fileList = new ArrayList<>();
+        fileList.add(fileMap);
 
         FileOutputStream fos = null;
 

+ 77 - 66
picc-common/src/main/java/com/jpsoft/picc/modules/common/utils/OSSUtil.java

@@ -65,44 +65,52 @@ public class OSSUtil {
     }
 
     public static void batchDownload(List<Map<String,String>> fileList, OutputStream output){
-        BufferedInputStream bis = null;
-
         try{
             ZipOutputStream zos = new ZipOutputStream(output);
 
             for (Map<String,String> map : fileList) {
                 String fileUrl = map.get("fileUrl");
+                String filePath = map.get("filePath");
+                String fileName = map.get("fileName");
 
-                URL url = new URL(fileUrl);
-                URLConnection conn = url.openConnection();
-                InputStream inputStream = conn.getInputStream();
+                try {
+                    if (StringUtils.isEmpty(fileName)) {
+                        fileName = fileUrl;
+                    }
 
-                byte[] buffs = new byte[1024 * 10];
+                    if (fileName.indexOf("?") != -1) {
+                        fileName = fileName.substring(0, fileName.indexOf("?"));
+                    }
 
-                String fileName = map.get("fileName");
+                    fileName = fileName.substring(fileName.lastIndexOf("/") + 1);
 
-                if (StringUtils.isEmpty(fileName)){
-                    fileName = fileUrl;
-                }
+                    String zipFile = fileName;
 
-                if (fileName.indexOf("?")!=-1){
-                    fileName = fileName.substring(0,fileName.indexOf("?"));
-                }
+                    if(StringUtils.isNotEmpty(filePath)){
+                        zipFile = filePath + fileName;
+                    }
+
+                    ZipEntry zipEntry = new ZipEntry(zipFile);
+                    zos.putNextEntry(zipEntry);
 
-                fileName = fileName.substring(fileName.lastIndexOf("/") + 1);
+                    URL url = new URL(fileUrl);
+                    URLConnection conn = url.openConnection();
+                    InputStream inputStream = conn.getInputStream();
 
-                String zipFile = fileName;
+                    byte[] buffs = new byte[1024 * 10];
 
-                ZipEntry zipEntry = new ZipEntry(zipFile);
-                zos.putNextEntry(zipEntry);
-                bis = new BufferedInputStream(inputStream, 1024 * 10);
+                    BufferedInputStream bis = new BufferedInputStream(inputStream, 1024 * 10);
 
-                int read;
-                while ((read = bis.read(buffs, 0, 1024 * 10)) != -1) {
-                    zos.write(buffs, 0, read);
-                }
+                    int read;
+                    while ((read = bis.read(buffs, 0, 1024 * 10)) != -1) {
+                        zos.write(buffs, 0, read);
+                    }
 
-                inputStream.close();
+                    bis.close();
+                }
+                catch(Exception ex){
+                    log.error(ex.getMessage(),ex);
+                }
             }
 
             zos.close();
@@ -110,18 +118,9 @@ public class OSSUtil {
         catch(Exception ex){
             log.error(ex.getMessage(),ex);
         }
-        finally {
-            if(bis!=null){
-                try {
-                    bis.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
     }
 
-    public static void presignedDownload(OSSConfig ossConfig, List<String> fileList, OutputStream output){
+    public static void presignedDownload(OSSConfig ossConfig, List<Map> fileList, OutputStream output){
         BufferedInputStream bis = null;
 
         try{
@@ -129,51 +128,63 @@ public class OSSUtil {
 
             OSS ossClient = new OSSClientBuilder().build(ossConfig.getEndpoint(), ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret());
 
-            for (String filePath : fileList) {
-                Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000);
+            for (Map<String,String> map : fileList) {
+                try {
+                    String fileUrl = map.get("fileUrl");
+                    String filePath = map.get("filePath");
 
-                if (filePath.startsWith(ossConfig.getUrlPrefix())){
-                    filePath = filePath.substring(ossConfig.getUrlPrefix().length());
-                }
+                    Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000);
 
-                if(filePath.indexOf("?")!=-1){
-                    filePath = filePath.substring(0,filePath.indexOf("?"));
-                }
+                    if (fileUrl.startsWith(ossConfig.getUrlPrefix())) {
+                        fileUrl = fileUrl.substring(ossConfig.getUrlPrefix().length());
+                    }
 
-                if (filePath.startsWith("/")){
-                    filePath = filePath.substring(1);
-                }
+                    if (fileUrl.indexOf("?") != -1) {
+                        fileUrl = fileUrl.substring(0, fileUrl.indexOf("?"));
+                    }
 
-                GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(ossConfig.getBucketName(), filePath, HttpMethod.GET);
+                    if (fileUrl.startsWith("/")) {
+                        fileUrl = fileUrl.substring(1);
+                    }
 
-                // 设置过期时间。
-                request.setExpiration(expiration);
+                    GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(ossConfig.getBucketName(), fileUrl, HttpMethod.GET);
 
-                //设置缩放
-                request.setProcess("image/resize,l_1024,limit_1");
+                    // 设置过期时间。
+                    request.setExpiration(expiration);
 
-                // 生成签名URL(HTTP GET请求)。
-                URL signedUrl = ossClient.generatePresignedUrl(request);
+                    //设置缩放
+                    request.setProcess("image/resize,l_1024,limit_1");
 
-                // 使用签名URL发送请求
-                OSSObject ossObject = ossClient.getObject(signedUrl, new HashMap<>());
+                    // 生成签名URL(HTTP GET请求)
+                    URL signedUrl = ossClient.generatePresignedUrl(request);
 
-                if(ossObject!=null) {
-                    InputStream inputStream = ossObject.getObjectContent();
-                    byte[] buffs = new byte[1024 * 10];
-                    String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
-                    String zipFile = fileName;
+                    // 使用签名URL发送请求。
+                    OSSObject ossObject = ossClient.getObject(signedUrl, new HashMap<>());
 
-                    ZipEntry zipEntry = new ZipEntry(zipFile);
-                    zos.putNextEntry(zipEntry);
-                    bis = new BufferedInputStream(inputStream, 1024 * 10);
+                    if (ossObject != null) {
+                        InputStream inputStream = ossObject.getObjectContent();
+                        byte[] buffs = new byte[1024 * 10];
+                        String fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
+                        String zipFile = fileName;
 
-                    int read;
-                    while ((read = bis.read(buffs, 0, 1024 * 10)) != -1) {
-                        zos.write(buffs, 0, read);
-                    }
+                        if (StringUtils.isNotEmpty(filePath)){
+                            zipFile = filePath + fileName;
+                        }
+
+                        ZipEntry zipEntry = new ZipEntry(zipFile);
+                        zos.putNextEntry(zipEntry);
+                        bis = new BufferedInputStream(inputStream, 1024 * 10);
 
-                    ossObject.close();
+                        int read;
+                        while ((read = bis.read(buffs, 0, 1024 * 10)) != -1) {
+                            zos.write(buffs, 0, read);
+                        }
+
+                        ossObject.close();
+                    }
+                }
+                catch(Exception ex){
+                    log.error(ex.getMessage(),ex);
                 }
             }
 

+ 5 - 1
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/auth/controller/InsurancePolicyController.java

@@ -54,6 +54,9 @@ public class InsurancePolicyController {
     @Autowired
     private CompanyService companyService;
 
+    @Autowired
+    private CompanyUserService companyUserService;
+
     @Autowired
     private InsuranceApplicationService insuranceApplicationService;
 
@@ -95,7 +98,8 @@ public class InsurancePolicyController {
             String path = request.getContextPath();
             String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 
-            Company company = companyService.findByCreateBy(principal.getName());
+            CompanyUser companyUser = companyUserService.findByUserName(principal.getName());
+            Company company = companyService.get(companyUser.getCompanyId());
 
             List<Map> mapList = new ArrayList<>();
 

+ 5 - 5
picc-enterprise-server/src/main/resources/application-dev.yml

@@ -16,9 +16,9 @@ cas:
   validation-type: cas
 
 jpcloud:
-  notifyBackUrl: http://gyxm.jing-zhou.gov.cn/picc-enterprise-server/pay/orderNotifyBack
-  synchroBackUrl: http://gyxm.jing-zhou.gov.cn/picc-enterprise-server/pay/paySuccess
-  jpcloudUrl: http://gyxm.jing-zhou.gov.cn/jp-cloud-api/payment/tradingOrderPayPc
+  notifyBackUrl: http://localhost:7070/picc-enterprise-server/pay/orderNotifyBack
+  synchroBackUrl: http://localhost:7070/picc-enterprise-server/pay/paySuccess
+  jpcloudUrl: http://localhost:9081/jp-cloud-api/payment/tradingOrderPayPc
   sellerSerialNumber: '000001000020'
   platformCode: '0008'
 
@@ -29,7 +29,7 @@ logger:
 weixin:
   appId: wxc0ddd6a415c535d9
   appSecret: 042fe6c9c970c1d9fe585dccfca89221
-  tokenUrl: "http://localhost:8086/weixin-middleware/token"
-  createQrCodeUrl: "http://localhost:8086/weixin-middleware/qrcode/create"
+  tokenUrl: "http://www.jzrccs.com/weixin-middleware/token"
+  createQrCodeUrl: "http://www.jzrccs.com/weixin-middleware/qrcode/create"
   sendTmplMsgUrl: "https://api.weixin.qq.com/cgi-bin/message/template/send"
   sendTmplId: "6CMGIpbgZLtqdr9xOdyEAlrCWXh8nJ260jRdktnv7vE"