|
@@ -1,25 +1,16 @@
|
|
|
package com.jpsoft.picc.modules.business.controller;
|
|
|
|
|
|
-import cn.hutool.core.io.FileUtil;
|
|
|
-import cn.hutool.json.JSON;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import com.github.pagehelper.Page;
|
|
|
-import com.jpsoft.picc.modules.base.entity.Company;
|
|
|
-import com.jpsoft.picc.modules.base.entity.CompanyUser;
|
|
|
-import com.jpsoft.picc.modules.base.entity.InsuranceAgent;
|
|
|
-import com.jpsoft.picc.modules.base.entity.InsuranceDefinitionLimit;
|
|
|
-import com.jpsoft.picc.modules.base.service.CompanyService;
|
|
|
-import com.jpsoft.picc.modules.base.service.CompanyUserService;
|
|
|
-import com.jpsoft.picc.modules.base.service.InsuranceAgentService;
|
|
|
-import com.jpsoft.picc.modules.base.service.InsuranceDefinitionLimitService;
|
|
|
+import com.jpsoft.picc.modules.base.entity.*;
|
|
|
+import com.jpsoft.picc.modules.base.service.*;
|
|
|
import com.jpsoft.picc.modules.business.entity.*;
|
|
|
import com.jpsoft.picc.modules.business.service.*;
|
|
|
-import com.jpsoft.picc.modules.common.config.PdfConfig;
|
|
|
import com.jpsoft.picc.modules.common.config.WeixinConfig;
|
|
|
import com.jpsoft.picc.modules.common.constant.PolicyStatus;
|
|
|
import com.jpsoft.picc.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.picc.modules.common.dto.Sort;
|
|
|
-import com.jpsoft.picc.modules.common.utils.ItextPDFUtil;
|
|
|
+import com.jpsoft.picc.modules.common.utils.NumberToCN;
|
|
|
import com.jpsoft.picc.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.picc.modules.common.utils.WeixinUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -28,21 +19,18 @@ import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.joda.time.DateTime;
|
|
|
+import org.joda.time.Months;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
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.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.io.File;
|
|
|
-import java.security.Policy;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.Executor;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/insurancePolicy")
|
|
@@ -80,6 +68,12 @@ public class InsurancePolicyController {
|
|
|
@Autowired
|
|
|
private WeixinConfig weixinConfig;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private InsuranceJobsService insuranceJobsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InsuranceDefinitionService insuranceDefinitionService;
|
|
|
+
|
|
|
@ApiOperation(value="创建空记录")
|
|
|
@GetMapping("create")
|
|
|
public MessageResult<InsurancePolicy> create(){
|
|
@@ -325,11 +319,13 @@ public class InsurancePolicyController {
|
|
|
|
|
|
String url = company.getUsccFiles();
|
|
|
|
|
|
- file1.put("index","1");
|
|
|
- file1.put("name", "营业执照" + url.substring(url.lastIndexOf(".")));
|
|
|
- file1.put("url", url);
|
|
|
+ if(StringUtils.isNotEmpty(url)) {
|
|
|
+ file1.put("index", "1");
|
|
|
+ file1.put("name", "营业执照" + url.substring(url.lastIndexOf(".")));
|
|
|
+ file1.put("url", url);
|
|
|
|
|
|
- fileList.add(file1);
|
|
|
+ fileList.add(file1);
|
|
|
+ }
|
|
|
|
|
|
Map<String,Object> file2 = new HashMap<>();
|
|
|
file2.put("index","2");
|
|
@@ -397,7 +393,7 @@ public class InsurancePolicyController {
|
|
|
|
|
|
int affectCount = approval(applicationId, policyId, processStatus, opinion, policyStatus.getValue() + "", subject);
|
|
|
|
|
|
- if (affectCount > 0) {
|
|
|
+ if (processStatus.equals("正常")) {
|
|
|
//修改花名册人员状态为初审
|
|
|
check(policyId, "1", subject);
|
|
|
}
|
|
@@ -482,7 +478,7 @@ public class InsurancePolicyController {
|
|
|
|
|
|
int affectCount = approval(applicationId, policyId, processStatus, opinion, policyStatus.getValue() + "", subject);
|
|
|
|
|
|
- if (affectCount > 0) {
|
|
|
+ if (processStatus.equals("正常")) {
|
|
|
//修改花名册人员状态为初审
|
|
|
check(policyId, "2", subject);
|
|
|
}
|
|
@@ -505,6 +501,7 @@ public class InsurancePolicyController {
|
|
|
|
|
|
@ApiOperation(value="PICC出单")
|
|
|
@RequestMapping(value = "issued",method = RequestMethod.POST)
|
|
|
+ @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name="applicationId",value = "投保单ID",required = true,paramType = "query"),
|
|
|
@ApiImplicitParam(name="policyId",value = "每月投保单ID",required = true,paramType = "query"),
|
|
@@ -519,7 +516,6 @@ public class InsurancePolicyController {
|
|
|
MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
-// String status ="";
|
|
|
PolicyStatus policyStatus;
|
|
|
|
|
|
if (processStatus.equals("正常")) {
|
|
@@ -538,32 +534,23 @@ public class InsurancePolicyController {
|
|
|
insurancePolicyService.update(insurancePolicy);
|
|
|
}
|
|
|
|
|
|
- int affectCount = approval(applicationId, policyId, processStatus, opinion, policyStatus.getValue() + "", subject);
|
|
|
-
|
|
|
- boolean flag = false;
|
|
|
- String msg = "";
|
|
|
-
|
|
|
- if (affectCount > 0) {
|
|
|
- if (processStatus.equals("正常")) {
|
|
|
- //生成下月投保单
|
|
|
- generatePolicyInTrans(applicationId, policyId, subject);
|
|
|
-
|
|
|
- //发送微信通知
|
|
|
- sendWeixinMessage(applicationId, policyStatus);
|
|
|
- }
|
|
|
+ //todo 审批并生成下月投保单
|
|
|
+ approveAndGenPolicyInTrans(applicationId, policyId,processStatus,opinion,policyStatus,subject);
|
|
|
|
|
|
- flag = true;
|
|
|
- }
|
|
|
+ //发送微信通知
|
|
|
+ sendWeixinMessage(applicationId, policyStatus);
|
|
|
|
|
|
- msgResult.setResult(flag);
|
|
|
- msgResult.setData(affectCount);
|
|
|
- msgResult.setMessage(msg);
|
|
|
+ msgResult.setResult(true);
|
|
|
}
|
|
|
catch (Exception ex) {
|
|
|
logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
|
+
|
|
|
+ //在实际开发中,我们往往需要在方法中进行异常的捕获,从而对异常进行判断,为客户端返回提示信息。
|
|
|
+ //但是此时由于异常的被捕获,导致事务的回滚没有被触发,导致事务的失败。
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
}
|
|
|
|
|
|
return msgResult;
|
|
@@ -670,64 +657,62 @@ public class InsurancePolicyController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- private Integer approval(String applicationId,String id,String processStatus,String opinion,String status,String subject){
|
|
|
-
|
|
|
+ private Integer approval(String applicationId,String policyId,String processStatus,String opinion,String status,String subject){
|
|
|
int affectCount = 0;
|
|
|
|
|
|
InsuranceApplication insuranceApplication = insuranceApplicationService.get(applicationId);
|
|
|
+ InsurancePolicy insurancePolicy = insurancePolicyService.get(policyId);
|
|
|
|
|
|
- List<InsurancePolicy> insurancePolicyList = applicationPolicyService.findNewPolicyByApplicationId(applicationId);
|
|
|
-
|
|
|
- if(insurancePolicyList.size()>0){
|
|
|
- int no = insurancePolicyList.get(0).getNo();
|
|
|
-
|
|
|
- //如果每月投保单为第一份,就修改投保单状态
|
|
|
- if(no == 1){
|
|
|
- insuranceApplication.setStatus(status);
|
|
|
- insuranceApplicationService.update(insuranceApplication);
|
|
|
- }
|
|
|
-
|
|
|
- InsurancePolicy insurancePolicy = insurancePolicyService.get(id);
|
|
|
-
|
|
|
- insurancePolicy.setProcessStatus(processStatus);
|
|
|
- insurancePolicy.setStatus(status);
|
|
|
- insurancePolicy.setUpdateBy(subject);
|
|
|
- insurancePolicy.setUpdateTime(new Date());
|
|
|
-
|
|
|
- int affectCount1 = insurancePolicyService.update(insurancePolicy);
|
|
|
+ String curStatus = insurancePolicy.getStatus();
|
|
|
|
|
|
- if(affectCount1 > 0){
|
|
|
- InsurancePolicyRecord insurancePolicyRecord = new InsurancePolicyRecord();
|
|
|
- insurancePolicyRecord.setPolicyId(insurancePolicy.getId());
|
|
|
- insurancePolicyRecord.setStatus(status);
|
|
|
- insurancePolicyRecord.setOpinion(opinion);
|
|
|
- insurancePolicyRecord.setProcessStatus(processStatus);
|
|
|
- insurancePolicyRecord.setId(UUID.randomUUID().toString());
|
|
|
- insurancePolicyRecord.setDelFlag(false);
|
|
|
- insurancePolicyRecord.setCreateBy(subject);
|
|
|
- insurancePolicyRecord.setCreateTime(new Date());
|
|
|
+ //首月投保单
|
|
|
+ if(insurancePolicy.getNo().equals(1)){
|
|
|
+ insuranceApplication.setStatus(status);
|
|
|
+ insuranceApplicationService.update(insuranceApplication);
|
|
|
+ }
|
|
|
|
|
|
- affectCount = insurancePolicyRecordService.insert(insurancePolicyRecord);
|
|
|
- }
|
|
|
+ insurancePolicy.setProcessStatus(processStatus);
|
|
|
+ insurancePolicy.setStatus(status);
|
|
|
+ insurancePolicy.setUpdateBy(subject);
|
|
|
+ insurancePolicy.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ int affectCount1 = insurancePolicyService.update(insurancePolicy);
|
|
|
+
|
|
|
+ if(affectCount1 > 0){
|
|
|
+ InsurancePolicyRecord insurancePolicyRecord = new InsurancePolicyRecord();
|
|
|
+ insurancePolicyRecord.setPolicyId(insurancePolicy.getId());
|
|
|
+ insurancePolicyRecord.setStatus(curStatus);
|
|
|
+ insurancePolicyRecord.setOpinion(opinion);
|
|
|
+ insurancePolicyRecord.setProcessStatus(processStatus);
|
|
|
+ insurancePolicyRecord.setId(UUID.randomUUID().toString());
|
|
|
+ insurancePolicyRecord.setDelFlag(false);
|
|
|
+ insurancePolicyRecord.setCreateBy(subject);
|
|
|
+ insurancePolicyRecord.setCreateTime(new Date());
|
|
|
+
|
|
|
+ affectCount = insurancePolicyRecordService.insert(insurancePolicyRecord);
|
|
|
}
|
|
|
|
|
|
return affectCount;
|
|
|
}
|
|
|
|
|
|
+ private void approveAndGenPolicyInTrans(String applicationId, String policyId,String processStatus,
|
|
|
+ String opinion,PolicyStatus policyStatus,
|
|
|
+ String subject) throws Exception {
|
|
|
+ approval(applicationId, policyId, processStatus, opinion, policyStatus.getValue() + "", subject);
|
|
|
|
|
|
+ if (!processStatus.equals("正常")) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- private void generatePolicyInTrans(String applicationId, String policyId, String subject) throws Exception {
|
|
|
- //添加下月投保单
|
|
|
+ //修改本月投保单状态为已出单
|
|
|
InsurancePolicy srcPolicy = insurancePolicyService.get(policyId);
|
|
|
- srcPolicy.setStatus(PolicyStatus.SendOutPolicy.getValue() + "");
|
|
|
- srcPolicy.setUpdateTime(new Date());
|
|
|
|
|
|
InsuranceApplication insuranceApplication = insuranceApplicationService.get(applicationId);
|
|
|
|
|
|
- insurancePolicyService.update(srcPolicy);
|
|
|
+ //如果是最后一个月则不再生成投保单
|
|
|
+ if(!srcPolicy.getEndTime().before(insuranceApplication.getEndTime())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
InsurancePolicy destPolicy = new InsurancePolicy();
|
|
|
|
|
@@ -741,57 +726,132 @@ public class InsurancePolicyController {
|
|
|
//下月状态为待初审
|
|
|
destPolicy.setStatus(PolicyStatus.PendingTrial.getValue() + "");
|
|
|
|
|
|
- //已经过期则不生成下月投保单
|
|
|
- if (destPolicy.getEndTime().after(insuranceApplication.getEndTime())){
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
destPolicy.setEffectiveDate(startTime.toString("yyyyMM"));
|
|
|
|
|
|
- boolean exist = insurancePolicyService.existByApplicationIdAndEffectiveDate(applicationId,destPolicy.getEffectiveDate());
|
|
|
+ //todo 相同企业、相同险种、截止时间相同 是否已经有下月参保记录(状态为草稿)
|
|
|
+ InsurancePolicy nextMonthPolicy = insurancePolicyService.findNextMonthPolicy(
|
|
|
+ insuranceApplication.getCompanyId(),
|
|
|
+ destPolicy.getDefinitionId(),
|
|
|
+ insuranceApplication.getEndTime(),
|
|
|
+ destPolicy.getEffectiveDate(),
|
|
|
+ PolicyStatus.Draft.getValue() + "");
|
|
|
+
|
|
|
+ if(nextMonthPolicy==null) {
|
|
|
+ //todo 如果没有则新建一条下月投保记录
|
|
|
+ destPolicy.setNo(srcPolicy.getNo() + 1);
|
|
|
+ destPolicy.setId(UUID.randomUUID().toString());
|
|
|
+ destPolicy.setStatus(PolicyStatus.Draft.getValue() + "");
|
|
|
+ destPolicy.setCreateBy(subject);
|
|
|
+ destPolicy.setCreateTime(new Date());
|
|
|
+ destPolicy.setUpdateBy(subject);
|
|
|
+ destPolicy.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ insurancePolicyService.insert(destPolicy);
|
|
|
+
|
|
|
+ //关联投保单及每月投保单
|
|
|
+ ApplicationPolicy applicationPolicy = new ApplicationPolicy();
|
|
|
+ applicationPolicy.setId(UUID.randomUUID().toString());
|
|
|
+ applicationPolicy.setApplicationId(applicationId);
|
|
|
+ applicationPolicy.setPolicyId(destPolicy.getId());
|
|
|
+
|
|
|
+ applicationPolicyService.insert(applicationPolicy);
|
|
|
+
|
|
|
+ //todo 关联参保人员
|
|
|
+ List<InsurancePolicyMember> memberList = insurancePolicyMemberService.findByPolicyId(policyId);
|
|
|
+
|
|
|
+ for (InsurancePolicyMember srcMember : memberList) {
|
|
|
+ InsurancePolicyMember destMember = new InsurancePolicyMember();
|
|
|
+
|
|
|
+ destMember.setId(UUID.randomUUID().toString());
|
|
|
+ destMember.setPolicyId(destPolicy.getId());
|
|
|
+ destMember.setMemberId(srcMember.getMemberId());
|
|
|
+ destMember.setDelFlag(false);
|
|
|
+ destMember.setCreateBy(subject);
|
|
|
+ destMember.setCreateTime(new Date());
|
|
|
+ destMember.setStatus(srcMember.getStatus());
|
|
|
+
|
|
|
+ insurancePolicyMemberService.insert(destMember);
|
|
|
+ }
|
|
|
|
|
|
- if (exist){
|
|
|
- throw new Exception(destPolicy.getEffectiveDate() + "投保单已存在!");
|
|
|
+ updatePolicyNumAndAmount(destPolicy,subject);
|
|
|
}
|
|
|
+ else{
|
|
|
+ //todo 如果有则判断关联当前投保单的下月投保记录是否存在
|
|
|
+ boolean exist = insurancePolicyService.existByApplicationIdAndEffectiveDate(applicationId, destPolicy.getEffectiveDate());
|
|
|
|
|
|
- destPolicy.setNo(srcPolicy.getNo()+1);
|
|
|
- destPolicy.setId(UUID.randomUUID().toString());
|
|
|
- destPolicy.setStatus(PolicyStatus.Draft.getValue() + "");
|
|
|
- destPolicy.setCreateBy(subject);
|
|
|
- destPolicy.setCreateTime(new Date());
|
|
|
- destPolicy.setUpdateBy(subject);
|
|
|
- destPolicy.setUpdateTime(new Date());
|
|
|
+ if (!exist) {
|
|
|
+ //todo 如果关联当前投保单的下月投保单不存在,但关联当前企业、相同险种的投保单存在则合并
|
|
|
|
|
|
- insurancePolicyService.insert(destPolicy);
|
|
|
+ //关联投保单及下月投保单
|
|
|
+ ApplicationPolicy applicationPolicy = new ApplicationPolicy();
|
|
|
+ applicationPolicy.setId(UUID.randomUUID().toString());
|
|
|
+ applicationPolicy.setApplicationId(applicationId);
|
|
|
|
|
|
- //关联投保单及每月投保单
|
|
|
- ApplicationPolicy applicationPolicy = new ApplicationPolicy();
|
|
|
- applicationPolicy.setId(UUID.randomUUID().toString());
|
|
|
- applicationPolicy.setApplicationId(applicationId);
|
|
|
- applicationPolicy.setPolicyId(destPolicy.getId());
|
|
|
+ //下月投保单已存在(创建时间)<当前投保单创建时间,所以排序要按照start_time
|
|
|
+ applicationPolicy.setPolicyId(nextMonthPolicy.getId());
|
|
|
|
|
|
- applicationPolicyService.insert(applicationPolicy);
|
|
|
+ applicationPolicyService.insert(applicationPolicy);
|
|
|
|
|
|
- //关联参保人员
|
|
|
- List<InsurancePolicyMember> memberList = insurancePolicyMemberService.findByPolicyId(policyId);
|
|
|
+ //todo 关联参保人员
|
|
|
+ List<InsurancePolicyMember> memberList = insurancePolicyMemberService.findByPolicyId(policyId);
|
|
|
|
|
|
- for (InsurancePolicyMember srcMember : memberList) {
|
|
|
- InsurancePolicyMember destMember = new InsurancePolicyMember();
|
|
|
+ for (InsurancePolicyMember srcMember : memberList) {
|
|
|
+ //人员不重复
|
|
|
+ if (!insurancePolicyMemberService.exist(nextMonthPolicy.getId(),srcMember.getMemberId())) {
|
|
|
+ InsurancePolicyMember destMember = new InsurancePolicyMember();
|
|
|
|
|
|
- destMember.setId(UUID.randomUUID().toString());
|
|
|
- destMember.setPolicyId(destPolicy.getId());
|
|
|
- destMember.setMemberId(srcMember.getMemberId());
|
|
|
- destMember.setDelFlag(false);
|
|
|
- destMember.setCreateBy(subject);
|
|
|
- destMember.setCreateTime(new Date());
|
|
|
- destMember.setStatus(srcMember.getStatus());
|
|
|
+ destMember.setId(UUID.randomUUID().toString());
|
|
|
+ destMember.setPolicyId(nextMonthPolicy.getId());
|
|
|
+ destMember.setMemberId(srcMember.getMemberId());
|
|
|
+ destMember.setDelFlag(false);
|
|
|
+ destMember.setCreateBy(subject);
|
|
|
+ destMember.setCreateTime(new Date());
|
|
|
+ destMember.setStatus(srcMember.getStatus());
|
|
|
|
|
|
- insurancePolicyMemberService.insert(destMember);
|
|
|
+ insurancePolicyMemberService.insert(destMember);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ updatePolicyNumAndAmount(nextMonthPolicy,subject);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ throw new Exception(destPolicy.getEffectiveDate() + "投保单已存在!");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新下月投保单的费用和人数
|
|
|
+ * @param insurancePolicy
|
|
|
+ * @param subject
|
|
|
+ */
|
|
|
+ private void updatePolicyNumAndAmount(InsurancePolicy insurancePolicy,String subject) {
|
|
|
+ List<InsuranceJobs> InsuranceJobsList = insuranceJobsService.findByDefinitionId(insurancePolicy.getDefinitionId());
|
|
|
+
|
|
|
+ int months = 1;
|
|
|
+
|
|
|
+ BigDecimal totalAmount = new BigDecimal(0);
|
|
|
+ long totalNumber = 0;
|
|
|
+
|
|
|
+ for (InsuranceJobs insuranceJobs:InsuranceJobsList) {
|
|
|
+ long count = insurancePolicyMemberService.countByPolicyIdAndJobsId(insurancePolicy.getId(),insuranceJobs.getJobsId());
|
|
|
+ BigDecimal money = insuranceJobs.getCharges().multiply(new BigDecimal(months)).multiply(new BigDecimal(count));
|
|
|
+ totalAmount = totalAmount.add(money);
|
|
|
+ totalNumber += count;
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新下月投保单的参保人数和参保费用
|
|
|
+ insurancePolicy.setInsuranceFee(totalAmount);
|
|
|
+ insurancePolicy.setNumber((int)totalNumber);
|
|
|
+ insurancePolicy.setUpdateTime(new Date());
|
|
|
+ insurancePolicy.setUpdateBy(subject);
|
|
|
+
|
|
|
+ insurancePolicyService.update(insurancePolicy);
|
|
|
+ }
|
|
|
+
|
|
|
private void check(String policyId,String status,String subject){
|
|
|
List<InsurancePolicyMember> insurancePolicyMemberList = insurancePolicyMemberService.findByPolicyId(policyId);
|
|
|
+
|
|
|
for (InsurancePolicyMember insurancePolicyMember:insurancePolicyMemberList) {
|
|
|
String statusMember = insurancePolicyMember.getStatus();
|
|
|
if(StringUtils.isEmpty(statusMember)||statusMember.equals("0")){
|
|
@@ -808,4 +868,126 @@ public class InsurancePolicyController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="获取投保信息")
|
|
|
+ @PostMapping("insureDetail")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="policyId",value = "下月投保单ID",required = true,paramType = "query")
|
|
|
+ })
|
|
|
+ public MessageResult<InsuranceApplication> insureDetail(String policyId){
|
|
|
+ MessageResult<InsuranceApplication> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ InsurancePolicy insurancePolicy = insurancePolicyService.get(policyId);
|
|
|
+
|
|
|
+ if (insurancePolicy != null) {
|
|
|
+ List<InsuranceApplication> applicationList = applicationPolicyService.findApplicationByPolicyId(policyId);
|
|
|
+
|
|
|
+ //首月投保
|
|
|
+ InsuranceApplication insuranceApplication = applicationList.get(0);
|
|
|
+
|
|
|
+ insuranceApplication.setInsurancePolicy(insurancePolicy);
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(insuranceApplication);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("数据库不存在该记录!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="获取承保信息")
|
|
|
+ @RequestMapping(value = "acceptDetail",method = RequestMethod.POST)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="policyId",value = "每月投保单ID",required = true,paramType = "query")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> acceptDetail(String policyId){
|
|
|
+
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<String,Object>();
|
|
|
+
|
|
|
+ //每月投保单
|
|
|
+ InsurancePolicy insurancePolicy = insurancePolicyService.get(policyId);
|
|
|
+
|
|
|
+ //险种
|
|
|
+ InsuranceDefinition insuranceDefinition = insuranceDefinitionService.get(insurancePolicy.getDefinitionId());
|
|
|
+
|
|
|
+ String definitionId = insuranceDefinition.getId();
|
|
|
+
|
|
|
+ map.put("id",insuranceDefinition.getId());
|
|
|
+ map.put("name",insuranceDefinition.getName());
|
|
|
+
|
|
|
+ List<InsuranceDefinitionLimit> insuranceDefinitionLimitList = insuranceDefinitionLimitService.findByDefinitionId(definitionId);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("insuranceDefinitionLimitList",mapList);
|
|
|
+
|
|
|
+ List<InsuranceJobs> InsuranceJobsList = insuranceJobsService.findByDefinitionId(insurancePolicy.getDefinitionId());
|
|
|
+
|
|
|
+ List<Map<String,Object>> mapList1 = new ArrayList<Map<String,Object>>();
|
|
|
+
|
|
|
+ DateTime startTime = new DateTime(insurancePolicy.getStartTime());
|
|
|
+ map.put("startTime",startTime.toString("yyyy-MM-dd"));
|
|
|
+
|
|
|
+ DateTime endTime = new DateTime(insurancePolicy.getEndTime());
|
|
|
+ map.put("endTime",endTime.toString("yyyy-MM-dd"));
|
|
|
+
|
|
|
+ //月份
|
|
|
+ int months = 1;
|
|
|
+
|
|
|
+ BigDecimal totalAmount = new BigDecimal(0);
|
|
|
+
|
|
|
+ for (InsuranceJobs insuranceJobs:InsuranceJobsList) {
|
|
|
+ Map<String,Object> map1 = new HashMap<String,Object>();
|
|
|
+ String jobId = insuranceJobs.getJobsId();
|
|
|
+ map1.put("id",jobId);
|
|
|
+ map1.put("name",insuranceJobs.getJobs().getName());
|
|
|
+ map1.put("content",insuranceJobs.getJobs().getContent());
|
|
|
+ map1.put("charges",insuranceJobs.getCharges());
|
|
|
+ map1.put("chargesY",insuranceJobs.getCharges().multiply(new BigDecimal(12)));
|
|
|
+ long memberCount = insurancePolicyMemberService.countByPolicyIdAndJobsId(policyId,insuranceJobs.getJobsId());
|
|
|
+ long number = Long.valueOf(memberCount).intValue();
|
|
|
+ map1.put("number",number);
|
|
|
+ BigDecimal money = insuranceJobs.getCharges().multiply(new BigDecimal(months)).multiply(new BigDecimal(number));
|
|
|
+ map1.put("money",money);
|
|
|
+
|
|
|
+ totalAmount = totalAmount.add(money);
|
|
|
+ mapList1.add(map1);
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("totalAmount",totalAmount);
|
|
|
+
|
|
|
+ String cnMontrayUnit = NumberToCN.number2CNMontrayUnit(totalAmount);
|
|
|
+ map.put("cnMontrayUnit",cnMontrayUnit);
|
|
|
+
|
|
|
+ map.put("jobsList",mapList1);
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(map);
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+
|
|
|
+ }
|
|
|
}
|