|
@@ -9,9 +9,11 @@ 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.OSSConfig;
|
|
|
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.OSSUtil;
|
|
|
import com.jpsoft.picc.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.picc.modules.sys.entity.User;
|
|
|
import com.jpsoft.picc.modules.sys.service.DataDictionaryService;
|
|
@@ -22,6 +24,10 @@ import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.jasig.cas.client.authentication.AttributePrincipal;
|
|
|
import org.joda.time.DateTime;
|
|
|
import org.joda.time.Interval;
|
|
@@ -33,6 +39,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@@ -42,6 +50,8 @@ import java.util.*;
|
|
|
@RestController
|
|
|
@RequestMapping("/auth/insurancePolicy")
|
|
|
public class InsurancePolicyController {
|
|
|
+ @Autowired
|
|
|
+ private OSSConfig ossConfig;
|
|
|
@Autowired
|
|
|
private InsurancePolicyService insurancePolicyService;
|
|
|
|
|
@@ -754,4 +764,229 @@ public class InsurancePolicyController {
|
|
|
|
|
|
return messageResult;
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value="我的保单-分页列表")
|
|
|
+ @RequestMapping(value = "pageListMyPolicy",method = RequestMethod.POST)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "status",value = "状态:已出单70/已过期100", required = false, paramType = "form",dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "definitionId",value = "险种编号", required = false, paramType = "form",dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "startTime",value = "创建起始时间", required = false, paramType = "form",dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "endTime",value = "创建结束时间", required = false, paramType = "form",dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "startFinishTime",value = "出单起始时间", required = false, paramType = "form",dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "endFinishTime",value = "出单结束时间", required = false, paramType = "form",dataType = "String")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> pageListMyPolicy(
|
|
|
+ String status,String definitionId,
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime,
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date startFinishTime,
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date endFinishTime,
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
+ HttpServletRequest request){
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
|
|
|
+ CompanyUser companyUser = companyUserService.findByUserName(principal.getName());
|
|
|
+ Company company = null;
|
|
|
+
|
|
|
+ if (companyUser!=null && StringUtils.isNotEmpty(companyUser.getCompanyId())) {
|
|
|
+ company = companyService.get(companyUser.getCompanyId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (company==null){
|
|
|
+ throw new Exception("请先填写企业信息!");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(company.getId())) {
|
|
|
+ searchParams.put("companyId", company.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(definitionId)) {
|
|
|
+ searchParams.put("definitionId", definitionId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(status)) {
|
|
|
+ searchParams.put("status", status);
|
|
|
+ }else{
|
|
|
+ searchParams.put("myStatus", "true");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (startTime != null) {
|
|
|
+ searchParams.put("startTime", startTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (endTime != null) {
|
|
|
+ searchParams.put("endTime", endTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (startFinishTime != null) {
|
|
|
+ searchParams.put("startFinishTime", startFinishTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (endFinishTime != null) {
|
|
|
+ searchParams.put("endFinishTime", endFinishTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<InsurancePolicy> page = insurancePolicyService.myPageSearch(searchParams, pageIndex, pageSize,sortList);
|
|
|
+
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
+ msgResult.setResult(true);
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="导出")
|
|
|
+ @PostMapping("exportXls")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "status",value = "状态:已出单70/已过期100", required = false, paramType = "form",dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "definitionId",value = "险种编号", required = false, paramType = "form",dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "startTime",value = "创建起始时间", required = false, paramType = "form",dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "endTime",value = "创建结束时间", required = false, paramType = "form",dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "startFinishTime",value = "出单起始时间", required = false, paramType = "form",dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "endFinishTime",value = "出单结束时间", required = false, paramType = "form",dataType = "String")
|
|
|
+ })
|
|
|
+ public MessageResult<String> exportXls(String status,String definitionId,
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime,
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date startFinishTime,
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date endFinishTime,
|
|
|
+ HttpServletRequest request){
|
|
|
+ MessageResult<String> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
+ HSSFSheet sheet = workbook.createSheet();
|
|
|
+ //表头
|
|
|
+ HSSFRow rowTitle = sheet.createRow(0);
|
|
|
+ HSSFCell cellTitle1 = rowTitle.createCell(0);
|
|
|
+ cellTitle1.setCellValue("序号");
|
|
|
+ HSSFCell cellTitle2 = rowTitle.createCell(1);
|
|
|
+ cellTitle2.setCellValue("投保单号");
|
|
|
+ HSSFCell cellTitle3 = rowTitle.createCell(2);
|
|
|
+ cellTitle3.setCellValue("投保险种");
|
|
|
+ HSSFCell cellTitle4 = rowTitle.createCell(3);
|
|
|
+ cellTitle4.setCellValue("投保人数");
|
|
|
+ HSSFCell cellTitle5 = rowTitle.createCell(4);
|
|
|
+ cellTitle5.setCellValue("投保期间");
|
|
|
+ HSSFCell cellTitle6 = rowTitle.createCell(5);
|
|
|
+ cellTitle6.setCellValue("创建时间");
|
|
|
+ HSSFCell cellTitle7 = rowTitle.createCell(6);
|
|
|
+ cellTitle7.setCellValue("出单时间");
|
|
|
+ HSSFCell cellTitle8 = rowTitle.createCell(7);
|
|
|
+ cellTitle8.setCellValue("保单金额");
|
|
|
+ HSSFCell cellTitle9 = rowTitle.createCell(8);
|
|
|
+ cellTitle9.setCellValue("保单状态");
|
|
|
+
|
|
|
+ //内容-获取数据
|
|
|
+ AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
|
|
|
+ CompanyUser companyUser = companyUserService.findByUserName(principal.getName());
|
|
|
+ Company company = null;
|
|
|
+
|
|
|
+ if (companyUser!=null && StringUtils.isNotEmpty(companyUser.getCompanyId())) {
|
|
|
+ company = companyService.get(companyUser.getCompanyId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (company==null){
|
|
|
+ throw new Exception("请先填写企业信息!");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(company.getId())) {
|
|
|
+ searchParams.put("companyId", company.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(definitionId)) {
|
|
|
+ searchParams.put("definitionId", definitionId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(status)) {
|
|
|
+ searchParams.put("status", status);
|
|
|
+ }else{
|
|
|
+ searchParams.put("myStatus", "true");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (startTime != null) {
|
|
|
+ searchParams.put("startTime", startTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (endTime != null) {
|
|
|
+ searchParams.put("endTime", endTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (startFinishTime != null) {
|
|
|
+ searchParams.put("startFinishTime", startFinishTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (endFinishTime != null) {
|
|
|
+ searchParams.put("endFinishTime", endFinishTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<InsurancePolicy> page = insurancePolicyService.myPageSearch(searchParams, 1, 1000,sortList);
|
|
|
+
|
|
|
+ //内容-写入数据
|
|
|
+ for(int i=0;i<page.size();i++){
|
|
|
+ InsurancePolicy insurancePolicy = page.get(i);
|
|
|
+
|
|
|
+ HSSFRow rowContent = sheet.createRow(i + 1);
|
|
|
+ HSSFCell cellContent1 = rowContent.createCell(0);
|
|
|
+ cellContent1.setCellValue(i+1);
|
|
|
+ HSSFCell cellContent2 = rowContent.createCell(1);
|
|
|
+ if(insurancePolicy.getSinglNumber() != null) cellContent2.setCellValue(insurancePolicy.getSinglNumber());
|
|
|
+ HSSFCell cellContent3 = rowContent.createCell(2);
|
|
|
+ if(insurancePolicy.getDefinitionName() != null) cellContent3.setCellValue(insurancePolicy.getDefinitionName());
|
|
|
+ HSSFCell cellContent4 = rowContent.createCell(3);
|
|
|
+ if(insurancePolicy.getNumber() != null) cellContent4.setCellValue(insurancePolicy.getNumber());
|
|
|
+ HSSFCell cellContent5 = rowContent.createCell(4);
|
|
|
+ if(insurancePolicy.getStartTime() != null && insurancePolicy.getEndTime() != null) cellContent5.setCellValue(insurancePolicy.getStartTime() + " - " + insurancePolicy.getEndTime());
|
|
|
+ HSSFCell cellContent6 = rowContent.createCell(5);
|
|
|
+ if(insurancePolicy.getCreateTime() != null) cellContent6.setCellValue(insurancePolicy.getCreateTime());
|
|
|
+ HSSFCell cellContent7 = rowContent.createCell(6);
|
|
|
+ if(insurancePolicy.getFinishTime() != null) cellContent7.setCellValue(insurancePolicy.getFinishTime());
|
|
|
+ HSSFCell cellContent8 = rowContent.createCell(7);
|
|
|
+ if(insurancePolicy.getInsuranceFee() != null) cellContent8.setCellValue(insurancePolicy.getInsuranceFee().floatValue());
|
|
|
+ HSSFCell cellContent9 = rowContent.createCell(8);
|
|
|
+ if(insurancePolicy.getStatus() != null) cellContent9.setCellValue(insurancePolicy.getStatusN());
|
|
|
+ }
|
|
|
+
|
|
|
+ //todo 将wb保存到oss
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
+ workbook.write(output);
|
|
|
+
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
+
|
|
|
+ String downloadUrl = OSSUtil.upload(ossConfig,"import","InsurancePolicy.xls",input);
|
|
|
+
|
|
|
+ //todo 返回导入失败报表下载链接
|
|
|
+
|
|
|
+ msgResult.setData(downloadUrl);
|
|
|
+ msgResult.setResult(true);
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
}
|