Commit fd7a88f6 by 翁国栋

运营后台--

更改为匹配跨域下载
parent 56fad829
...@@ -130,6 +130,10 @@ public class InsureContorll { ...@@ -130,6 +130,10 @@ public class InsureContorll {
@ApiOperation(value = "1.投保申请", httpMethod = "Post", notes = "投保申请") @ApiOperation(value = "1.投保申请", httpMethod = "Post", notes = "投保申请")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public Result<Object> insured_add(@RequestBody InsureDto insureDto) throws ParseException { public Result<Object> insured_add(@RequestBody InsureDto insureDto) throws ParseException {
InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getOrgCode,insureDto.getOrgCode()));
if(insurePolicy!=null){
return ResultUtil.error("企业已存在");
}
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(Integer.parseInt(insureDto.getOrgCode())).build().selectById(); // 企业信息 QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(Integer.parseInt(insureDto.getOrgCode())).build().selectById(); // 企业信息
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
...@@ -211,13 +215,16 @@ public class InsureContorll { ...@@ -211,13 +215,16 @@ public class InsureContorll {
Map dataMap = requestAgent(bodyMap); Map dataMap = requestAgent(bodyMap);
if (dataMap != null) { if (dataMap != null) {
if(!dataMap.get("errcode").toString().equals("suc")){
return ResultUtil.error(dataMap.get("errmsg").toString());
}
Object o = dataMap.get("data"); Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o)); Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds()); List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds());
Map policyMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("policy")), Map.class); Map policyMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("policy")), Map.class);
Map batchMap = JSONObject.parseObject(JSONObject.toJSONString(policyMap.get("batch")), Map.class); ArrayList<Map> batchMap = JSONObject.parseObject(JSONObject.toJSONString(policyMap.get("batch")), ArrayList.class);
InsureUser insureUser; InsureUser insureUser;
InsurePolicy insurePolicy = InsurePolicy.builder().build(); insurePolicy = InsurePolicy.builder().build();
insurePolicy.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart())); insurePolicy.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insurePolicy.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd())); insurePolicy.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insurePolicy.setPolicyNo(policyMap.get("policy_no").toString()); insurePolicy.setPolicyNo(policyMap.get("policy_no").toString());
...@@ -239,7 +246,7 @@ public class InsureContorll { ...@@ -239,7 +246,7 @@ public class InsureContorll {
insureUser.setPrice(price.toString());/*前端获取的保费*/ insureUser.setPrice(price.toString());/*前端获取的保费*/
insureUser.setTransId("P_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now)); insureUser.setTransId("P_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now));
insureUser.setPremium(String.valueOf(ygglMainEmpList.size() * price)); insureUser.setPremium(String.valueOf(ygglMainEmpList.size() * price));
insureUser.setBatchNo(batchMap.get("batch_no").toString()); insureUser.setBatchNo(batchMap.get(0).get("batch_no").toString());
insureUser.setBenefitBasicPlan(insureDto.getBenefitBasicPlan()); insureUser.setBenefitBasicPlan(insureDto.getBenefitBasicPlan());
insureUser.setPolicyNo(policyMap.get("policy_no").toString()); insureUser.setPolicyNo(policyMap.get("policy_no").toString());
insureUser.setUserId(y.getId()); insureUser.setUserId(y.getId());
...@@ -254,6 +261,7 @@ public class InsureContorll { ...@@ -254,6 +261,7 @@ public class InsureContorll {
insureUser.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd())); insureUser.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insureUser.setStatus("1"); insureUser.setStatus("1");
insureUser.setPolicyId(insurePolicy.getId()); insureUser.setPolicyId(insurePolicy.getId());
insureUser.setApplyType(1);
y.setIsInsure(1); y.setIsInsure(1);
y.insertOrUpdate(); y.insertOrUpdate();
insureUser.insert(); insureUser.insert();
...@@ -283,7 +291,7 @@ public class InsureContorll { ...@@ -283,7 +291,7 @@ public class InsureContorll {
} }
} }
return null; return dataMap;
} }
} }
...@@ -507,34 +515,36 @@ public class InsureContorll { ...@@ -507,34 +515,36 @@ public class InsureContorll {
if(insurePolicy==null|| StringUtils.isNullOrEmpty(insurePolicy.getPolicyFile())){ if(insurePolicy==null|| StringUtils.isNullOrEmpty(insurePolicy.getPolicyFile())){
return; return;
} }
BufferedInputStream in = null; OutputStream sos = null;
OutputStream os = null; BufferedInputStream bis = null;
try { try {
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
response.setHeader("content-disposition", "attachment; filename=" + new String((insurePolicy.getPolicyNo()+".pdf").getBytes("UTF8"), "ISO-8859-1")); response.setHeader("content-disposition", "attachment; filename=" + new String((insurePolicy.getPolicyNo()+".pdf").getBytes("UTF8"), "ISO-8859-1"));
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
URL url = new URL(insurePolicy.getPolicyFile()); sos = response.getOutputStream();
in = new BufferedInputStream(url.openStream()); String destUrl = insurePolicy.getPolicyFile();
os = response.getOutputStream(); URL url = new URL(destUrl);
int i; HttpURLConnection httpUrl = (HttpURLConnection) url.openConnection();
while ((i = in.read()) != -1) { //连接指定的网络资源
os.write(i); httpUrl.connect();
//获取网络输入流
bis = new BufferedInputStream(httpUrl.getInputStream());
int b;
while ((b = bis.read()) != -1) {
sos.write(b);
} }
os.flush();
in.close();
response.getOutputStream();
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { try {
if (in != null) { sos.close();
in.close(); } catch (IOException e) {
} e.printStackTrace();
if (os != null) { }
os.close(); try {
} bis.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -603,6 +613,7 @@ public class InsureContorll { ...@@ -603,6 +613,7 @@ public class InsureContorll {
.applicantEmployeeList(data.get("file_url").toString()) .applicantEmployeeList(data.get("file_url").toString())
.policyDateStart(dtf3.parse(insureDto.getPolicyDateStart())) .policyDateStart(dtf3.parse(insureDto.getPolicyDateStart()))
.policyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd())) .policyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()))
.applyType(3)
.status("1").insureStatus(3).policyId(insurePolicy.getId()).build().insert(); .status("1").insureStatus(3).policyId(insurePolicy.getId()).build().insert();
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -755,7 +766,7 @@ public class InsureContorll { ...@@ -755,7 +766,7 @@ public class InsureContorll {
} }
@GetMapping(value = "/isInsured") @GetMapping(value = "/isInsured")
@ApiOperation(value = "10.保单统计列表", httpMethod = "Post", notes = "保单统计列表") @ApiOperation(value = "10.企业是否已投保", httpMethod = "Post", notes = "企业是否已投保")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public Result<Object> isInsured(@RequestParam("orgCode")String orgCode) { public Result<Object> isInsured(@RequestParam("orgCode")String orgCode) {
InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getOrgCode,orgCode)); InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getOrgCode,orgCode));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment