|
@@ -1,5 +1,6 @@
|
|
package com.jpsoft.picc.modules.business.controller;
|
|
package com.jpsoft.picc.modules.business.controller;
|
|
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
import com.jpsoft.picc.modules.base.entity.InsuranceAgent;
|
|
import com.jpsoft.picc.modules.base.entity.InsuranceAgent;
|
|
import com.jpsoft.picc.modules.base.entity.InsuranceDefinitionLimit;
|
|
import com.jpsoft.picc.modules.base.entity.InsuranceDefinitionLimit;
|
|
@@ -22,9 +23,14 @@ import org.joda.time.DateTime;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
+import org.springframework.http.MediaType;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@@ -33,12 +39,6 @@ import java.util.*;
|
|
public class InsurancePolicyController {
|
|
public class InsurancePolicyController {
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
- /*@Autowired
|
|
|
|
- private ItextPDFUtil itextPDFUtil;*/
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private PdfConfig pdfConfig;
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private InsurancePolicyService insurancePolicyService;
|
|
private InsurancePolicyService insurancePolicyService;
|
|
|
|
|
|
@@ -60,8 +60,6 @@ public class InsurancePolicyController {
|
|
@Autowired
|
|
@Autowired
|
|
private InsuranceDefinitionLimitService insuranceDefinitionLimitService;
|
|
private InsuranceDefinitionLimitService insuranceDefinitionLimitService;
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
@ApiOperation(value="创建空记录")
|
|
@ApiOperation(value="创建空记录")
|
|
@GetMapping("create")
|
|
@GetMapping("create")
|
|
public MessageResult<InsurancePolicy> create(){
|
|
public MessageResult<InsurancePolicy> create(){
|
|
@@ -549,57 +547,6 @@ public class InsurancePolicyController {
|
|
return msgResult;
|
|
return msgResult;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- @ApiOperation(value="pdf文档生成与下载")
|
|
|
|
- @RequestMapping(value = "downloadApplicationData",method = RequestMethod.POST)
|
|
|
|
- @ApiImplicitParams({
|
|
|
|
- @ApiImplicitParam(name="applicationId",value = "投保单ID",required = true,paramType = "query"),
|
|
|
|
- @ApiImplicitParam(name="policyId",value = "每月投保单ID",required = true,paramType = "query")
|
|
|
|
-
|
|
|
|
- })
|
|
|
|
- public MessageResult<Integer> downloadApplicationData(String applicationId,String policyId){
|
|
|
|
-
|
|
|
|
- MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
- String logoUrl = pdfConfig.getLogoUrl();
|
|
|
|
- String downloadFilePath = pdfConfig.getDownloadFilePath();
|
|
|
|
-
|
|
|
|
- try{
|
|
|
|
- InsuranceApplication insuranceApplication = insuranceApplicationService.get(applicationId);
|
|
|
|
- List<InsuranceDefinitionLimit> insuranceDefinitionLimitList = insuranceDefinitionLimitService.findByDefinitionId(insuranceApplication.getDefinitionId());
|
|
|
|
-
|
|
|
|
- List<Map<String,Object>> mapList = new ArrayList<Map<String,Object>>();
|
|
|
|
-
|
|
|
|
- for(InsuranceDefinitionLimit insuranceDefinitionLimit:insuranceDefinitionLimitList){
|
|
|
|
- Map<String,Object> map1 = new HashMap<String,Object>();
|
|
|
|
- map1.put("id",insuranceDefinitionLimit.getId());
|
|
|
|
- map1.put("name",insuranceDefinitionLimit.getName());
|
|
|
|
- map1.put("limit",insuranceDefinitionLimit.getLimit());
|
|
|
|
- map1.put("unit",insuranceDefinitionLimit.getUnit());
|
|
|
|
- mapList.add(map1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<InsurancePolicyMember> list = insurancePolicyMemberService.findByPolicyId(policyId);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- ItextPDFUtil.createPdf(insuranceApplication,mapList,list,logoUrl,downloadFilePath);
|
|
|
|
- msgResult.setMessage("pdf文档生成成功");
|
|
|
|
- msgResult.setResult(true);
|
|
|
|
-
|
|
|
|
- }catch (Exception ex){
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
- msgResult.setMessage(ex.getMessage());
|
|
|
|
- msgResult.setResult(false);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return msgResult;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
private Integer approval(String applicationId,String id,String processStatus,String opinion,String status,String subject){
|
|
private Integer approval(String applicationId,String id,String processStatus,String opinion,String status,String subject){
|
|
|
|
|
|
int affectCount = 0;
|
|
int affectCount = 0;
|
|
@@ -655,17 +602,24 @@ public class InsurancePolicyController {
|
|
srcPolicy.setStatus(PolicyStatus.SendOutPolicy.getValue() + "");
|
|
srcPolicy.setStatus(PolicyStatus.SendOutPolicy.getValue() + "");
|
|
srcPolicy.setUpdateTime(new Date());
|
|
srcPolicy.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
+ InsuranceApplication insuranceApplication = insuranceApplicationService.get(applicationId);
|
|
|
|
+
|
|
insurancePolicyService.update(srcPolicy);
|
|
insurancePolicyService.update(srcPolicy);
|
|
|
|
|
|
InsurancePolicy destPolicy = new InsurancePolicy();
|
|
InsurancePolicy destPolicy = new InsurancePolicy();
|
|
|
|
|
|
PojoUtils.map(srcPolicy,destPolicy);
|
|
PojoUtils.map(srcPolicy,destPolicy);
|
|
|
|
|
|
- DateTime startTime = new DateTime(srcPolicy.getEndTime()).plusDays(1);
|
|
|
|
|
|
+ DateTime startTime = new DateTime(srcPolicy.getEndTime());
|
|
|
|
|
|
destPolicy.setStartTime(startTime.toDate());
|
|
destPolicy.setStartTime(startTime.toDate());
|
|
destPolicy.setEndTime(startTime.plusMonths(1).toDate());
|
|
destPolicy.setEndTime(startTime.plusMonths(1).toDate());
|
|
|
|
|
|
|
|
+ //已经过期则不生成下月投保单
|
|
|
|
+ if (destPolicy.getEndTime().after(insuranceApplication.getEndTime())){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
destPolicy.setEffectiveDate(startTime.toString("yyyyMM"));
|
|
destPolicy.setEffectiveDate(startTime.toString("yyyyMM"));
|
|
|
|
|
|
boolean exist = insurancePolicyService.existByApplicationIdAndEffectiveDate(applicationId,destPolicy.getEffectiveDate());
|
|
boolean exist = insurancePolicyService.existByApplicationIdAndEffectiveDate(applicationId,destPolicy.getEffectiveDate());
|