Commit 61a1cd6e by 284718418@qq.com

Merge remote-tracking branch 'origin/feature_20220317_policy' into develop

# Conflicts:
#	src/main/java/cn/timer/api/utils/HttpUtils.java
parents bc3319a7 64ec8190
package cn.timer.api.controller.insure;
import cn.timer.api.bean.insure.*;
import cn.timer.api.bean.kqmk.KqglAssoLeaveEmployeeBalance;
import cn.timer.api.bean.kqmk.KqglAssoLeaveRules;
import cn.timer.api.bean.qyzx.QyzxEntInfoM;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.controller.insure.enums.InsuranceEnum;
import cn.timer.api.controller.insure.enums.PlanEnum;
import cn.timer.api.dao.insure.InsureLogMapper;
import cn.timer.api.dao.insure.InsurePolicyMapper;
import cn.timer.api.dao.insure.InsureUserMapper;
......@@ -90,6 +89,8 @@ public class InsureContorll {
private String uploadUrl2;
@Value("${insure.batchUrl}")
private String batchUrl;
@Value("${insure.policyDetail}")
private String policyDetailUrl;
private static SimpleDateFormat dtf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
......@@ -331,7 +332,7 @@ public class InsureContorll {
plansList.forEach(p -> {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(p.getUserIds());
for (YgglMainEmp y : ygglMainEmpList) {
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), InsuranceEnum.getEnum(p.getBenefitBasicPlan(), p.getBenefitOccupationCategory()).getName(), createDate, "深圳名邦人力资源管理有限公司", StringUtils.isNullOrEmpty(p.getTricycleFrameNumber()) ? "无" : p.getTricycleFrameNumber(), InsuranceEnum.getEnum(p.getBenefitBasicPlan(), p.getBenefitOccupationCategory()).getType()};
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), PlanEnum.getEnum(p.getBenefitBasicPlan(), p.getBenefitOccupationCategory()).getName(), createDate, "深圳名邦人力资源管理有限公司", StringUtils.isNullOrEmpty(p.getTricycleFrameNumber()) ? "无" : p.getTricycleFrameNumber(), PlanEnum.getEnum(p.getBenefitBasicPlan(), p.getBenefitOccupationCategory()).getType()};
list.add(arr);
}
});
......@@ -447,8 +448,8 @@ public class InsureContorll {
InsureUser.builder()
.transId("IS_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now))
.insuredName(qyzxEntInfoM.getName())
.price(String.valueOf(InsuranceEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getPrice()))/*前端获取的保费*/
.premium(String.valueOf(InsuranceEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getPrice() * insureDto.getUserIds().length))
.price(String.valueOf(PlanEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getPrice()))/*前端获取的保费*/
.premium(String.valueOf(PlanEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getPrice() * insureDto.getUserIds().length))
.batchNo(data.get("import_uuid").toString())
.benefitBasicPlan(insureDto.getBenefitBasicPlan())
.policyNo(orderImportInfo.get("contract_no").toString())
......@@ -496,7 +497,7 @@ public class InsureContorll {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds());
List list = Lists.newArrayList();
for (YgglMainEmp y : ygglMainEmpList) {
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), InsuranceEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getName(), insureDto.getPolicyDateStart(), "深圳名邦人力资源管理有限公司", StringUtils.isNullOrEmpty(insureDto.getTricycleFrameNumber()) ? "无" : insureDto.getTricycleFrameNumber(), InsuranceEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getType()};
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), PlanEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getName(), insureDto.getPolicyDateStart(), "深圳名邦人力资源管理有限公司", StringUtils.isNullOrEmpty(insureDto.getTricycleFrameNumber()) ? "无" : insureDto.getTricycleFrameNumber(), PlanEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getType()};
list.add(arr);
}
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Scheme_name", "Date_start", "Branch", "Tricycle_frame_number", "benefit_occupation_category"};
......@@ -754,41 +755,41 @@ public class InsureContorll {
switch (plan) {
case "36968":
if (type.equals("63119")) {
return InsuranceEnum.A_30.getPrice();
return PlanEnum.A_30.getPrice();
} else if (type.equals("63120")) {
return InsuranceEnum.B_30.getPrice();
return PlanEnum.B_30.getPrice();
}
break;
case "36969":
if (type.equals("63119")) {
return InsuranceEnum.A_30.getPrice();
return PlanEnum.A_30.getPrice();
} else if (type.equals("63120")) {
return InsuranceEnum.B_50.getPrice();
return PlanEnum.B_50.getPrice();
} else if (type.equals("63121")) {
return InsuranceEnum.C_50.getPrice();
return PlanEnum.C_50.getPrice();
}
break;
case "36970":
if (type.equals("63119")) {
return InsuranceEnum.A_80.getPrice();
return PlanEnum.A_80.getPrice();
} else if (type.equals("63120")) {
return InsuranceEnum.B_80.getPrice();
return PlanEnum.B_80.getPrice();
} else if (type.equals("63121")) {
return InsuranceEnum.C_80.getPrice();
return PlanEnum.C_80.getPrice();
}
break;
case "36971":
if (type.equals("63119")) {
return InsuranceEnum.A_80_20.getPrice();
return PlanEnum.A_80_20.getPrice();
} else if (type.equals("63120")) {
return InsuranceEnum.B_80_20.getPrice();
return PlanEnum.B_80_20.getPrice();
}
break;
case "36972":
if (type.equals("63119")) {
return InsuranceEnum.A_100.getPrice();
return PlanEnum.A_100.getPrice();
} else if (type.equals("63120")) {
return InsuranceEnum.B_100.getPrice();
return PlanEnum.B_100.getPrice();
}
break;
}
......@@ -856,8 +857,6 @@ public class InsureContorll {
return ResultUtil.success();
}
;
@PostMapping(value = "/policyTotalList")
@ApiOperation(value = "11.保单统计列表 -- 8小时端", httpMethod = "POST", notes = "保单统计列表")
......@@ -1010,8 +1009,11 @@ public class InsureContorll {
}
break;
case "方案名称":
PlanEnum plan = PlanEnum.getEnumOfName(ExcelUtils.getString(cell).trim());
user.setBenefitBasicPlan(plan.getPlan());
user.setBenefitOccupationCategory(plan.getCategory());
break;
case "有效时间":
case "有效期起":
Date start = null;
try {
start = dtf3.parse(ExcelUtils.getString(cell));
......@@ -1028,8 +1030,8 @@ public class InsureContorll {
} catch (ParseException e) {
e.printStackTrace();
}
user.setPolicyDateStart(end);
policy.setPolicyDateStart(end);
user.setPolicyDateEnd(end);
policy.setPolicyDateEnd(end);
break;
case "被保险人姓名":
user.setInsuredEContact(ExcelUtils.getString(cell));
......@@ -1060,6 +1062,7 @@ public class InsureContorll {
return ResultUtil.error("企业不存在");
}
user.setOrgCode(company.getId());
policy.setOrgCode(company.getId());
break;
case "总保费":
user.setPrice(ExcelUtils.getString(cell));
......@@ -1068,11 +1071,31 @@ public class InsureContorll {
}
userList.add(user);
}
//TODO 验证保单的状态
long timestamp = System.currentTimeMillis() / 1000;
Map map = Maps.newHashMap();
map.put("pid",appid);
map.put("policy_no",policy.getPolicyNo());
map.put("sign",DigestUtils.md5Hex(appid + secret + timestamp));
map.put("timestamp",String.valueOf(timestamp));
String data = HttpUtils.sendGet(policyDetailUrl, map);
Map returnMap = JSONObject.parseObject(data,Map.class);
if(returnMap.get("errcode").toString().equals("suc")){
Map dataMap = JSONObject.parseObject(JSONObject.toJSONString(returnMap.get("data")), Map.class);
policy.setPolicyFile(dataMap.get("policy_file").toString());
policy.setStatus("1");
}else{
return ResultUtil.error("保单不存在,请检查保单号是否正确");
}
InsurePolicy oldPolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getPolicyNo, policy.getPolicyNo()));
if (oldPolicy == null) {
policy.setSchemeName(InsureProduct.builder().id(1).build().selectById().getName());
policy.insert();
} else {
oldPolicy.setPolicyFile(policy.getPolicyFile());
policy = oldPolicy;
policy.updateById();
}
if (userList.size() <= 0) {
return ResultUtil.error("导入错误,保单已存在");
......@@ -1085,18 +1108,25 @@ public class InsureContorll {
.eq(YgglMainEmp::getOrgCode, insureUser.getOrgCode()));
if (ygglMainEmp != null) {
ygglMainEmp.setIsInsure(1);
insureUser.setInsuredMobile(ygglMainEmp.getPhone());
} else {
/*如果不存在员工就创建一名员工*/
ygglMainEmp.builder().build();
ygglMainEmp=new YgglMainEmp();
ygglMainEmp.setName(insureUser.getInsuredEContact());
ygglMainEmp.setZjType(0);
ygglMainEmp.setZjNum(insureUser.getInsuredNo());
ygglMainEmp.setOrgCode(insureUser.getOrgCode());
}
insureUser.setPolicyId(policy.getId());
ygglMainEmp.insertOrUpdate();
insureUser.setInsuredName(company.getAttestName());
insureUser.setPolicyId(policy.getId());
insureUser.setInsureStatus(1);
insureUser.setUserId(ygglMainEmp.getId());
insureUser.setStatus("1");
insureUser.insert();
}
InsureLog.builder().requestParam(JSONObject.toJSONString(map)).type(6).createTime(new Date()).requestType(2).returnBody(data).requestPath(policyDetailUrl)
.returnCode(returnMap.get("errcode").toString()).returnMsg(returnMap.get("errmsg").toString()).policyId(policy.getId()).build().insert();
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -13,6 +13,7 @@ import cn.timer.api.dao.insure.InsureUserMapper;
import cn.timer.api.dto.insure.InsureDto;
import cn.timer.api.dto.insure.InsureUserDto;
import cn.timer.api.dto.insure.PolicyDto;
import cn.timer.api.utils.ExcelUtils;
import cn.timer.api.utils.Page;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
......@@ -22,6 +23,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.collect.Maps;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
......@@ -91,4 +93,23 @@ public class InsureUserController{
return ResultUtil.data(userList);
}
@PostMapping(value = "/exportUserList")
@ApiOperation(value = "导出列表", httpMethod = "GET", notes = "导出列表")
public void exportUserList(@RequestParam("policyId") String policyId,
@RequestParam("status") String status,
@RequestParam("name") String name,
@RequestParam("policyDateStart") String policyDateStart,
@RequestParam("planId") String planId,
@RequestParam("categoryId") String categoryId){
PolicyDto policyDto = new PolicyDto();
policyDto.setId(Integer.parseInt(policyId));
policyDto.setStatus(status);
policyDto.setName(name);
policyDto.setPolicyDateStart(policyDateStart);
policyDto.setPlanId(planId);
policyDto.setCategoryId(categoryId);
List<PolicyDto> list = insureUserMapper.selectPolicyList(policyDto);
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Scheme_name", "Date_start", "Branch", "Tricycle_frame_number", "benefit_occupation_category"};
/*XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel("导出人员清单.xlsx", rowName, list);*/
}
}
package cn.timer.api.controller.insure.enums;
import io.swagger.models.auth.In;
import lombok.Data;
import cn.timer.api.utils.ExcelUtils;
/**
* @Description TODO
* @Author wgd
* @Date 2022/3/24 17:20
*/
public enum InsuranceEnum {
public enum PlanEnum {
A_30(12,"30万意外/3万医疗/扩展24小时(A类)","A类","36968","63119"),
A_50(15,"50万意外/5万医疗/扩展24小时(A类)","A类","36969","63119"),
A_80(18,"80万意外/10万医疗/扩展24小时(A类)","A类","36970","63119"),
......@@ -27,7 +26,7 @@ public enum InsuranceEnum {
private String plan;
private String category;
InsuranceEnum(Integer price, String name,String type,String plan,String category) {
PlanEnum(Integer price, String name, String type, String plan, String category) {
this.price = price;
this.name = name;
this.type=type;
......@@ -75,11 +74,14 @@ public enum InsuranceEnum {
this.category = category;
}
public static InsuranceEnum getEnum(String plan,String category) {
for(InsuranceEnum v : values())
public static PlanEnum getEnum(String plan, String category) {
for(PlanEnum v : values())
if(v.getPlan().equals(plan)&&v.getCategory().equals(category)) return v;
throw new IllegalArgumentException();
}
public static PlanEnum getEnumOfName(String name){
for(PlanEnum v : values())
if(v.getName().equals(name)) return v;
throw new IllegalArgumentException();
}
}
package cn.timer.api.utils;
import java.io.*;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.security.cert.X509Certificate;
import java.util.Map;
......@@ -14,6 +11,15 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -35,59 +41,44 @@ public class HttpUtils
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果
*/
public static String sendGet(String url, String param)
{
StringBuilder result = new StringBuilder();
BufferedReader in = null;
try
{
String urlNameString = url + "?" + param;
log.info("sendGet - {}", urlNameString);
URL realUrl = new URL(urlNameString);
HttpsURLConnection connection = (HttpsURLConnection)realUrl.openConnection();
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36)");
connection.connect();
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null)
{
result.append(line);
}
log.info("recv - {}", result);
}
catch (ConnectException e)
{
log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e);
}
catch (SocketTimeoutException e)
{
log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e);
}
catch (IOException e)
{
log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e);
public static String sendGet(String url, Map<String, String> param)
{ // 创建Httpclient对象
CloseableHttpClient httpclient = HttpClients.createDefault();
String resultString = "";
CloseableHttpResponse response = null;
try {
// 创建uri
URIBuilder builder = new URIBuilder(url);
if (param != null) {
for (String key : param.keySet()) {
builder.addParameter(key, param.get(key));
}
catch (Exception e)
{
log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e);
}
finally
{
try
{
if (in != null)
{
in.close();
URI uri = builder.build();
// 创建http GET请求
HttpGet httpGet = new HttpGet(uri);
// 执行请求
response = httpclient.execute(httpGet);
// 判断返回状态是否为200
if (response.getStatusLine().getStatusCode() == 200) {
resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (response != null) {
response.close();
}
catch (Exception ex)
{
log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
httpclient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result.toString();
return resultString;
}
/**
......
......@@ -244,6 +244,9 @@ insure:
secret: 'acb329868c31d5b3ba03de40dac13dd9'
uploadUrl: 'http://sandbox.portal.unistar-ins.com/service/Home/Index/fileUpload'
insuredUrl: 'http://sandbox.portal.unistar-ins.com/mall/Home/Index/createQuotePolicy'
#查询保单信息
policyDetail: 'http://sandbox.portal.unistar-ins.com/issuing/Home/Index/policy'
#保全
appidq: '1000115041006006938'
secretq: '6ba1bf4aa0bd14368c95ff0b9934a17b'
......@@ -252,3 +255,19 @@ insure:
# base_api_url
BASE_API_URL: 'http://test-8timer-api.youlingrc.com'
#sftp 配置
sftp:
client:
protocol: 'sftp'
host: '120.78.162.177'
port: '22'
username: 'root'
password: 'fksdlfjs(*&&%HGgjfkdjsfhksh9781283KFHFFGHghhndbv##2@'
root: '/home'
sessionStrictHostKeyChecking: 'no'
sessionConnectTimeout: '15000'
channelConnectedTimeout: '15000'
serverUrl: 'https://test-img.8timer.cn'
targetPath: '/disk'
reservedName: false
......@@ -245,6 +245,8 @@ insure:
secret: '1ef7b79471be7f6b5489832c65109f81'
uploadUrl: 'https://portal-unistar-ins.com /service/Home/Index/fileUpload'
insuredUrl: 'https://portal.unistar-ins.com/mall/Home/Index/createQuotePolicy'
#查询保单信息
policyDetail: 'https://portal.unistar-ins.com/issuing/Home/Index/policy'
#保全
appidq: '1000711000604326196'
secretq: 'a2da17a2797c63dff9172df50af9da65'
......
......@@ -244,6 +244,9 @@ insure:
secret: 'acb329868c31d5b3ba03de40dac13dd9'
uploadUrl: 'http://sandbox.portal.unistar-ins.com/service/Home/Index/fileUpload'
insuredUrl: 'http://sandbox.portal.unistar-ins.com/mall/Home/Index/createQuotePolicy'
#查询保单信息
policyDetail: 'http://sandbox.portal.unistar-ins.com/issuing/Home/Index/policy'
#保全
appidq: '1000115041006006938'
secretq: '6ba1bf4aa0bd14368c95ff0b9934a17b'
......
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