Commit 60787f3e by 翁国栋

运营后台--

保险列表
parent 8c5c01e1
......@@ -3,6 +3,7 @@ package cn.timer.api.bean.insure;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description TODO
......@@ -21,4 +22,6 @@ public class CallBack implements Serializable {
private String serial_no;
private String policy_file;
private String total_expenditure;
private String endorsement_file;
private OrderImportInfo order_import_info;
}
......@@ -142,7 +142,13 @@ public class InsureUser extends Model<InsureUser> {
@ApiModelProperty(value = "失效日期")
private Date policyDateEnd;
@Transient
private String[] userIds;
@ApiModelProperty(value = "投保状态:1成功 2失败 3待更新")
private Integer insureStatus;
@ApiModelProperty(value = "保单id")
private Integer policyId;
@ApiModelProperty(value = "替换流水号,使用trans_id,RP_开头")
private String replaceTransId;
}
......@@ -36,7 +36,8 @@ public class WebSecurityConfig implements WebMvcConfigurer {
registry.addInterceptor(getSessionInterceptor())
.addPathPatterns("/**")
.excludePathPatterns("/callback/**")
.excludePathPatterns("/callBack/policy/**")
.excludePathPatterns("/callBack/policy/CallBack")
.excludePathPatterns("/callBack/policy/insuredCallBack")
.excludePathPatterns("/superLogin/**")
.excludePathPatterns("/actuator/*")
.excludePathPatterns("/doc*")
......
package cn.timer.api.controller.insure;
import cn.timer.api.bean.admin.AdminAssoTxjlb;
import cn.timer.api.bean.insure.CallBack;
import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.bean.insure.InsureUser;
import cn.timer.api.bean.yggl.YgglMainEmp;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.http.HttpRequest;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.collect.Maps;
import com.google.gson.JsonObject;
import com.mysql.cj.util.StringUtils;
import com.sun.xml.internal.bind.v2.TODO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.security.auth.callback.Callback;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @Description TODO
......@@ -22,12 +43,72 @@ import javax.security.auth.callback.Callback;
@RequestMapping(value = "/callBack/policy", produces = {"application/json"})
public class CallBackContorll {
private static final Logger log = LoggerFactory.getLogger(CallBackContorll.class);
/*保全测试用*/
private static String appidq = "1000115041006006938";
/*保全测试用*/
private static String secretq = "6ba1bf4aa0bd14368c95ff0b9934a17b";
@PostMapping(value = "/insuredCallBack")
@ApiOperation(value = "6.投保申请回调", httpMethod = "Post", notes = "投保申请回调")
@ApiOperationSupport(order = 2)
private Integer callBack(@RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp, @RequestBody CallBack callBack){
private String insuredCallBack(@RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp, @RequestBody CallBack callBack){
log.info(String.valueOf(callBack));
return 1;
return "1";
}
@PostMapping(value = "/CallBack")
@ApiOperation(value = "7.保全增员申请回调", httpMethod = "Post", notes = "投保申请回调")
@ApiOperationSupport(order = 2)
private Map callBack(HttpServletRequest request, @RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp) throws IOException {
Map map = Maps.newHashMap();
map.put("status","error");
if(StringUtils.isNullOrEmpty(pid)||StringUtils.isNullOrEmpty(sign)&&StringUtils.isNullOrEmpty(timestamp)){
return map;
}
if(!pid.equals(appidq)){
return map;
}
InputStream is = null;
is = request.getInputStream();
StringBuilder sb = new StringBuilder();
byte[] b = new byte[4096];
for (int n; (n = is.read(b)) != -1;)
{
sb.append(new String(b, 0, n));
}
String value = DigestUtils.md5Hex(appidq + secretq + timestamp + sb.toString());
if(!value.equals(sign)){
return map;
}
CallBack callBack=JSONObject.parseObject(sb.toString(), CallBack.class);
if(callBack.getStatus().equals("1")) {
log.info("callBack" + JSONObject.toJSONString(callBack));
List<InsureUser> list = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getBatchNo, callBack.getOrder_import_info().getUuid()));
list.forEach(i -> {
i.setInsureStatus(1);
i.updateById();
YgglMainEmp.builder().isInsure(1).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId, i.getUserId()));
});
List<InsureUser> oldlist = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getReplaceTransId, callBack.getOrder_import_info().getUuid()));
if(oldlist!=null||oldlist.size()>0) {
oldlist.forEach(i -> {
i.setInsureStatus(4);
i.updateById();
YgglMainEmp.builder().isInsure(3).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId, i.getUserId()));
});
}
InsurePolicy insurePolicy= InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getPolicyNo,list.get(0).getPolicyNo()));
if(oldlist==null||oldlist.size()==0) {
insurePolicy.setTotalPremium(String.valueOf(Double.valueOf(insurePolicy.getTotalPremium()) + Double.valueOf(callBack.getOrder_import_info().getTotal_money())));
}
insurePolicy.setPolicyFile(callBack.getOrder_import_info().getEndorsement_file());
insurePolicy.setUpdateTime(new Date());
insurePolicy.updateById();
}else{
//TODO 写入日志
}
Map trueMap = Maps.newHashMap();
trueMap.put("status","1");
return trueMap;
}
}
package cn.timer.api.controller.insure;
//import cn.timer.api.bean.insure.InsuredUser;
import cn.timer.api.bean.crm.CrmBusinessGroupMember;
import cn.timer.api.bean.insure.InsureApplicant;
import cn.timer.api.bean.insure.InsureLog;
import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.bean.insure.InsureUser;
import cn.timer.api.bean.qyzx.QyzxEntInfoM;
......@@ -10,6 +9,7 @@ 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.bean.ExcelBean;
import cn.timer.api.controller.insure.enums.InsuranceEnum;
import cn.timer.api.dao.insure.InsurePolicyMapper;
import cn.timer.api.dao.insure.InsureUserMapper;
import cn.timer.api.dao.yggl.YgglMainEmpMapper;
......@@ -17,16 +17,13 @@ import cn.timer.api.dto.insure.InsureDto;
import cn.timer.api.dto.insure.PolicyDto;
import cn.timer.api.utils.*;
import com.alibaba.druid.util.Base64;
import com.alibaba.fastjson.TypeReference;
import com.aliyuncs.http.HttpRequest;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.aliyun.oss.common.utils.StringUtils;
import com.beust.jcommander.internal.Lists;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.collect.Maps;
import com.google.gson.JsonObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
......@@ -39,15 +36,18 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.net.URLEncoder;
import java.security.Policy;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
......@@ -72,9 +72,9 @@ public class InsureContorll {
private static String secret = "acb329868c31d5b3ba03de40dac13dd9";
/*保全测试用*/
private static String appidq="1000115041006006938";
private static String appidq = "1000115041006006938";
/*保全测试用*/
private static String secretq="6ba1bf4aa0bd14368c95ff0b9934a17b";
private static String secretq = "6ba1bf4aa0bd14368c95ff0b9934a17b";
/*测试用投保上传文件地址*/
......@@ -86,6 +86,8 @@ public class InsureContorll {
/*测试用保全申请地址*/
private static String batchUrl = "http://sandbox.portal.unistar-ins.com/fuli/Home/WelfareProduct/batch_declare";
private static SimpleDateFormat dtf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Autowired
private YgglMainEmpMapper ygglMainEmpMapper;
......@@ -98,58 +100,63 @@ public class InsureContorll {
/**
* 设置请求参数
*
* @param sign
* @return
*/
private Map setParams(String sign,String appid,String secret){
private Map setParams(String sign, String appid, String secret) {
/*当前时间戳*/
long timestamp =System.currentTimeMillis()/1000;
log.info("时间戳"+timestamp);
long timestamp = System.currentTimeMillis() / 1000;
log.info("时间戳" + timestamp);
Map paramsMap = Maps.newHashMap();
paramsMap.put("pid",appid);
paramsMap.put("timestamp",String.valueOf(timestamp));
paramsMap.put("trace_id",appid+timestamp+ new Random().nextInt((9999 - 100) + 1) + 10);
paramsMap.put("pid", appid);
paramsMap.put("timestamp", String.valueOf(timestamp));
paramsMap.put("trace_id", appid + timestamp + new Random().nextInt((9999 - 100) + 1) + 10);
// paramsMap.put("sign",Md5.md5(appid+secret+timestamp+sign.trim()));
String value=appid+secret+timestamp+sign;
log.info("body参数======"+sign);
String value = appid + secret + timestamp + sign;
log.info("body参数======" + sign);
paramsMap.put("sign", DigestUtils.md5Hex(value));
log.info("params参数======"+JSONObject.toJSONString(paramsMap));
log.info("params参数======" + JSONObject.toJSONString(paramsMap));
return paramsMap;
}
@PostMapping(value = "/insured_add")
@ApiOperation(value = "1.投保申请", httpMethod = "Post", notes = "投保申请")
@ApiOperationSupport(order = 2)
public Result<Object> insured_add(@RequestBody InsureDto insureDto) {
public Result<Object> insured_add(@RequestBody InsureDto insureDto) throws ParseException {
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(Integer.parseInt(insureDto.getOrgCode())).build().selectById(); // 企业信息
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
DateFormat dtf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
Date date = Date.from(now.atZone(ZoneId.systemDefault()).toInstant());
Map bodyMap = Maps.newHashMap();
ArrayList<Map> quotationsArry = new ArrayList<Map>();
bodyMap.put("is_ss",0);
Map quotations=Maps.newHashMap();
quotations.put("trans_id","MB_"+dtf2.format(now));/*报价请求流水号*/
quotations.put("applicant_type","2");/*投保人类型:2-企业*/
quotations.put("quotation_type",3);/*报价类型:3-投保申请*/
quotations.put("currency","5");/*币种:5人民币*/
quotations.put("source_type","");/*币种:5人民币*/
quotations.put("cps_email","");/*币种:5人民币*/
quotations.put("cps_tel","");/*币种:5人民币*/
quotations.put("last_serial_number","");/*币种:5人民币*/
quotations.put("from_source","");/*币种:5人民币*/
quotations.put("operator_name","");/*币种:5人民币*/
bodyMap.put("is_ss", 0);
Map quotations = Maps.newHashMap();
Integer price = getPrice(insureDto.getBenefitBasicPlan(),insureDto.getBenefitOccupationCategory());
if(price==0){
return ResultUtil.error("报价不存在");
}
quotations.put("trans_id", "MB_" + dtf2.format(now));/*报价请求流水号*/
quotations.put("applicant_type", "2");/*投保人类型:2-企业*/
quotations.put("quotation_type", 3);/*报价类型:3-投保申请*/
quotations.put("currency", "5");/*币种:5人民币*/
quotations.put("source_type", "");/*币种:5人民币*/
quotations.put("cps_email", "");/*币种:5人民币*/
quotations.put("cps_tel", "");/*币种:5人民币*/
quotations.put("last_serial_number", "");/*币种:5人民币*/
quotations.put("from_source", "");/*币种:5人民币*/
quotations.put("operator_name", "");/*币种:5人民币*/
/*企业信息*/
InsureApplicant insureApplicant = InsureApplicant.builder().id(1).build().selectById();
if(insureApplicant==null){
if (insureApplicant == null) {
return ResultUtil.error("未设置投保人");
}
Map companyApplicantMap = Maps.newHashMap();
companyApplicantMap.put("applicant_e_name",insureApplicant.getApplicantEName());/*企业/网点名称*/
companyApplicantMap.put("applicant_e_address",insureApplicant.getApplicantEAddress());/*企业/网点地址*/
companyApplicantMap.put("applicant_e_name", insureApplicant.getApplicantEName());/*企业/网点名称*/
companyApplicantMap.put("applicant_e_address", insureApplicant.getApplicantEAddress());/*企业/网点地址*/
companyApplicantMap.put("applicant_e_contacts", insureApplicant.getApplicantEContacts());/*企业授权操作人姓名*/
companyApplicantMap.put("applicant_e_phone", insureApplicant.getApplicantEPhone());/*操作人的联系电话*/
companyApplicantMap.put("applicant_e_no_type", insureApplicant.getApplicantENoType());/*企业证件类型*/
......@@ -157,30 +164,30 @@ public class InsureContorll {
companyApplicantMap.put("applicant_e_mail", insureApplicant.getApplicantEMail());/*企业邮箱*/
companyApplicantMap.put("applicant_province_city", "21721");/*省市区*/
/*人员清单填被保人员*/
String url= creaXSSFWorkbook(insureDto.getUserIds());
if(!StringUtil.isNotBlank(url)){
String url = creaXSSFWorkbook(insureDto.getUserIds(),price);
if (!StringUtil.isNotBlank(url)) {
return ResultUtil.error("文件错误");
}
companyApplicantMap.put("applicant_employee_list",url);
quotations.put("company_applicant",companyApplicantMap);
companyApplicantMap.put("applicant_employee_list", url);
quotations.put("company_applicant", companyApplicantMap);
Map basicMap = Maps.newHashMap();
basicMap.put("partner_pid","1231");/*分销商pid*/
basicMap.put("plan_code_id","61b85207b73d2ab09fb2959");/*计划代码,选项值:61b85207b73d2ab09fb2959 (生产环境) 61b85207b73d2ab09fb2959 (沙箱环境)*/
basicMap.put("product_code_id","61b85207a9f87da19fb5986");/*产品代码,选项值:61b85207a9f87da19fb5986 (生产环境) 61b85207a9f87da19fb5986 (沙箱环境)*/
basicMap.put("partner_pid", "1231");/*分销商pid*/
basicMap.put("plan_code_id", "61b85207b73d2ab09fb2959");/*计划代码,选项值:61b85207b73d2ab09fb2959 (生产环境) 61b85207b73d2ab09fb2959 (沙箱环境)*/
basicMap.put("product_code_id", "61b85207a9f87da19fb5986");/*产品代码,选项值:61b85207a9f87da19fb5986 (生产环境) 61b85207a9f87da19fb5986 (沙箱环境)*/
basicMap.put("policy_date_start",insureDto.getPolicyDateStart());
basicMap.put("policy_date_end",insureDto.getPolicyDateEnd());
basicMap.put("channel","");
basicMap.put("fee","");
basicMap.put("partner_user_rate","");
basicMap.put("promotion_fee","");
basicMap.put("agent_id","");
basicMap.put("policy_insure_notify","");
basicMap.put("promotion_id",0);
basicMap.put("policy_number_last_year","");
quotations.put("basic",basicMap);
quotations.put("individual_applicant",Maps.newHashMap());
basicMap.put("policy_date_end", insureDto.getPolicyDateEnd());
basicMap.put("channel", "");
basicMap.put("fee", "");
basicMap.put("partner_user_rate", "");
basicMap.put("promotion_fee", "");
basicMap.put("agent_id", "");
basicMap.put("policy_insure_notify", "");
basicMap.put("promotion_id", 0);
basicMap.put("policy_number_last_year", "");
quotations.put("basic", basicMap);
quotations.put("individual_applicant", Maps.newHashMap());
......@@ -188,42 +195,59 @@ public class InsureContorll {
/*被保人员 填被保企业信息*/
ArrayList<Map> insuredArray = new ArrayList<>();
Map insured = Maps.newHashMap();
insured.put("trans_id","P_"+qyzxEntInfoM.getId()+"_"+dtf2.format(now));
insured.put("price",insureDto.getUserIds().length*15);/*根据基础计划生成*/
insured.put("trans_id", "PI_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now));
insured.put("price", insureDto.getUserIds().length * price);/*根据基础计划生成*/
insured.put("insured_applicant_relations", "36960");
insured.put("insured_mobile", qyzxEntInfoM.getLinkManPhone());
insured.put("insured_e_contact", qyzxEntInfoM.getLinkMan());
insured.put("insured_mobile", qyzxEntInfoM.getPhone());
insured.put("insured_e_contact", qyzxEntInfoM.getOperName());
insured.put("insured_name", qyzxEntInfoM.getName());
insured.put("insured_no_type", "3306");
insured.put("insured_no", qyzxEntInfoM.getCreditCode());
insured.put("insured_zm_openid", "");
insured.put("benefit_basic_plan", insureDto.getBenefitBasicPlan());/*基础计划写死*/
insured.put("benefit_occupation_category", insureDto.getBenefitOccupationCategory());
insured.put("benefit_EL_employee_number_t",insureDto.getUserIds().length);
insured.put("benefit_EL_employee_number_t", insureDto.getUserIds().length);
insuredArray.add(insured);
quotations.put("insured",insuredArray);
quotations.put("file",Lists.newArrayList());
quotations.put("insured", insuredArray);
quotations.put("file", Lists.newArrayList());
quotations.put("specifically_agreed_file", Lists.newArrayList());
quotations.put("policy_no", "");
quotations.put("callback_policy", "/callBack/insuredCallBack");
quotations.put("insured",insuredArray);
quotations.put("callback_policy", "/callBack/policy/insuredCallBack");
quotations.put("insured", insuredArray);
quotationsArry.add(quotations);
bodyMap.put("quotations",quotationsArry);
bodyMap.put("quotations", quotationsArry);
log.info(JSONObject.toJSONString(bodyMap));
Map dataMap = requestAgent(bodyMap);
if(dataMap!=null) {
Object o = dataMap.get("data");
Map <String,Object> map= JSONObject.parseObject(JSONObject.toJSONString(o));;
List<YgglMainEmp> ygglMainEmpList=ygglMainEmpMapper.selectListByIds(insureDto.getUserIds());
Map policyMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("policy")), Map.class);
if (dataMap != null) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds());
Map policyMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("policy")), Map.class);
InsureUser insureUser;
for (YgglMainEmp y:ygglMainEmpList) {
InsurePolicy insurePolicy = InsurePolicy.builder().build();
insurePolicy.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insurePolicy.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insurePolicy.setPolicyNo(policyMap.get("policy_no").toString());
insurePolicy.setType(2);/*年单或者月单*/
insurePolicy.setCurrency("5");
insurePolicy.setStatus("1");
insurePolicy.setPolicyFile(policyMap.get("policy_file").toString());
insurePolicy.setKitUrl(policyMap.get("kit_url").toString());
insurePolicy.setOrgCode(qyzxEntInfoM.getId());
insurePolicy.setCreateTime(date);
insurePolicy.setUpdateTime(date);
insurePolicy.setSchemeName("【新】-安诚-雇主责任险(劳务公司)预付款");/*先写死*/
insurePolicy.setTotalPremium(String.valueOf(insureDto.getUserIds().length * price));
insurePolicy.insert();
for (YgglMainEmp y : ygglMainEmpList) {
insureUser = InsureUser.builder().build();
insureUser.setUserId(y.getId());
insureUser.setInsuredName(qyzxEntInfoM.getName());
insureUser.setPrice("15");/*前端获取的保费*/
insureUser.setTransId("MB_"+dtf2.format(now));
insureUser.setBatchNo("P_"+qyzxEntInfoM.getId()+"_"+dtf2.format(now));
insureUser.setPrice(price.toString());/*前端获取的保费*/
insureUser.setTransId("MB_" + dtf2.format(now));
insureUser.setPremium(String.valueOf(ygglMainEmpList.size() * price));
insureUser.setBatchNo("P_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now));
insureUser.setBenefitBasicPlan(insureDto.getBenefitBasicPlan());
insureUser.setPolicyNo(policyMap.get("policy_no").toString());
insureUser.setUserId(y.getId());
......@@ -233,42 +257,32 @@ public class InsureContorll {
insureUser.setInsuredNo(y.getZjNum());
insureUser.setInsuredEContact(y.getName());
insureUser.setApplicantEmployeeList(url);
insureUser.setInsureStatus(1);
insureUser.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insureUser.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insureUser.setStatus("1");
insureUser.setPolicyId(insurePolicy.getId());
y.setIsInsure(1);
y.insertOrUpdate();
insureUser.insert();
}
InsurePolicy insurePolicy = InsurePolicy.builder().build();
try {
insurePolicy.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insurePolicy.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insurePolicy.setPolicyNo(policyMap.get("policy_no").toString());
insurePolicy.setType(2);/*年单或者月单*/
insurePolicy.setCurrency("5");
insurePolicy.setStatus("1");
insurePolicy.setPolicyFile(policyMap.get("policy_file").toString());
insurePolicy.setKitUrl(policyMap.get("kit_url").toString());
insurePolicy.setOrgCode(qyzxEntInfoM.getId());
insurePolicy.setCreateTime(new Date());
insurePolicy.setSchemeName("【新】-安诚-雇主责任险(劳务公司)预付款");/*先写死*/
insurePolicy.insert();
} catch (ParseException e) {
insurePolicy.setPolicyDateStart(null);
insurePolicy.setPolicyDateEnd(null);
e.printStackTrace();
}
}
return ResultUtil.error("");
}
/*测试用生产环境不需要*/
synchronized private Map requestAgent(Map bodyMap ){
String data=HttpUtils.sendPost(insuredUrl,setParams(JSONObject.toJSONString(bodyMap),appid,secret),bodyMap);
Map dataMap = JSONObject.parseObject(data,Map.class);
synchronized private Map requestAgent(Map bodyMap) {
String data = HttpUtils.sendPost(insuredUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
Map dataMap = JSONObject.parseObject(data, Map.class);
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(1)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(insuredUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
if (dataMap.get("errcode").toString().equals("suc")) {
return dataMap;
}else{
if(dataMap.get("errcode").toString().equals("e1")&&(dataMap.get("errmsg").toString().equals("出单中")||dataMap.get("errmsg").toString().equals("系统正在处理中,请稍候再试"))){
} else {
if (dataMap.get("errcode").toString().equals("e1") && (dataMap.get("errmsg").toString().equals("出单中") || dataMap.get("errmsg").toString().equals("系统正在处理中,请稍候再试"))) {
try {
Thread.sleep(30000);
return requestAgent(bodyMap);
......@@ -282,90 +296,55 @@ public class InsureContorll {
}
@PostMapping (value = "/file_upload")
@ApiOperation(value = "3.投保上传文件", httpMethod = "Post", notes = "上传文件")
@ApiOperationSupport(order = 2)
public Result<Object> fileUpload(@CurrentUser UserBean userBean, @RequestParam(required = true) MultipartFile file) {
if (file == null) {
return ResultUtil.error("上传失败,请选择上传文件");
}
byte[] bytes =null;
try {
bytes=file.getBytes();
} catch (IOException e) {
e.printStackTrace();
log.warn("文件转换Base64异常");
}
String fileBase64= Base64.byteArrayToBase64(bytes);
/*body参数 begin*/
Map bodyMap= Maps.newHashMap();
bodyMap.put("app","mall");
bodyMap.put("name",file.getName());
bodyMap.put("file",fileBase64);
/*end*/
String data=HttpUtils.sendPost(uploadUrl,setParams(JSONObject.toJSONString(bodyMap),appid,secret),bodyMap);
log.info("请求返回的结果====="+data);
/*文件流base64*/
return ResultUtil.data(message(data));
};
/**
* 设置错误信息
* @param data
* @return
*/
private Object message(String data){
Map<String,Object> dataMap = JSONObject.parseObject(data);
if (dataMap.get("errcode").toString().equals("suc")) {
return dataMap.get("data");
}
return dataMap.get("errmsg");
}
/**
* 生成投保问文件
*
* @param ids
* @return
*/
public String creaXSSFWorkbook(String[] ids){
if(ids.length<=0){
public String creaXSSFWorkbook(String[] ids,Integer price) {
if (ids.length <= 0) {
return "error";
}
LocalDate localDate = LocalDate.now();
List<YgglMainEmp> ygglMainEmpList=ygglMainEmpMapper.selectListByIds(ids);
List list=Lists.newArrayList();
for (YgglMainEmp y:ygglMainEmpList) {
String[] arr =new String[]{String.valueOf(y.getId()),y.getName(),"身份证",y.getZjNum(),"50万意外/5万医疗/扩展24小时(A类)","","深圳名邦人力资源管理有限公司","无","A类"};
Date date = new Date();
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(ids);
List list = Lists.newArrayList();
for (YgglMainEmp y : ygglMainEmpList) {
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), InsuranceEnum.getEnum(price).getName(), "", "深圳名邦人力资源管理有限公司", "无", InsuranceEnum.getEnum(price).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"};
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(localDate+"_"+list.size()+"名人员清单.xlsx",rowName,list);
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel(localDate + "_投保" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
String fileBase64= Base64.byteArrayToBase64(bytes);
String fileBase64 = Base64.byteArrayToBase64(bytes);
/*body参数 begin*/
Map bodyMap= Maps.newHashMap();
bodyMap.put("app","mall");
bodyMap.put("name",localDate+"_"+list.size()+"名人员清单.xlsx");
bodyMap.put("file",fileBase64);
Map bodyMap = Maps.newHashMap();
bodyMap.put("app", "mall");
bodyMap.put("name", localDate + "_" + list.size() + "名人员清单.xlsx");
bodyMap.put("file", fileBase64);
/*end*/
String data=HttpUtils.sendPost(uploadUrl,setParams(JSONObject.toJSONString(bodyMap),appid,secret),bodyMap);
Map<String,Object> dataMap = JSONObject.parseObject(data);
String data = HttpUtils.sendPost(uploadUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(data);
/*创建日志*/
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(4)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map <String,Object> map= JSONObject.parseObject(JSONObject.toJSONString(o));
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
return map.get("url").toString();
}
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
}finally {
} finally {
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
......@@ -377,97 +356,156 @@ public class InsureContorll {
return "suc";
}
@PostMapping(value = "/policyList")
@ApiOperation(value = "3.保单列表", httpMethod = "Post", notes = "保单列表")
@ApiOperationSupport(order = 2)
public Result<Object> policyList(@RequestBody PolicyDto policyDto) {
List<PolicyDto> list = insureUserMapper.selectPolicyList(String.valueOf(policyDto.getId()));
return ResultUtil.data(Optional.ofNullable(list).orElse(Lists.newArrayList()));
Map map = Maps.newHashMap();
List<PolicyDto> list = insureUserMapper.selectPolicyList(policyDto.getPage(), String.valueOf(policyDto.getId()));
map.put("list", Optional.ofNullable(list).orElse(Lists.newArrayList()));
map.put("total", insureUserMapper.totalUser(String.valueOf(policyDto.getId())));
return ResultUtil.data(map);
}
@PostMapping(value = "/policyListAdmin")
@ApiOperation(value = "4.保单列表--运营后台端", httpMethod = "Post", notes = "保单列表")
@ApiOperation(value = "4.保单列表--运营后台端", httpMethod = "Post", notes = "保单列表--运营后台端")
@ApiOperationSupport(order = 2)
public Result<Object> policyListAdmin(@RequestBody InsurePolicy insurePolicy) {
List<PolicyDto> list = insurePolicyMapper.policyList();
return ResultUtil.data(list);
public Result<Object> policyListAdmin(@RequestBody cn.timer.api.utils.Page page) {
Map map = Maps.newHashMap();
List<PolicyDto> list = insurePolicyMapper.policyList(page);
map.put("list", list);
map.put("total", insurePolicyMapper.totalPolicy());
return ResultUtil.data(map);
}
@GetMapping(value = "/policyDetail")
@ApiOperation(value = "5.保单信息", httpMethod = "Get", notes = "保单列表")
@ApiOperation(value = "5.保单信息", httpMethod = "Get", notes = "保单信息")
@ApiOperationSupport(order = 2)
public Result<Object> policyDetail(@RequestParam("policyId") Integer policyId) {
PolicyDto policyDto=insurePolicyMapper.getPolicyDetail(policyId);
if(policyDto==null){
PolicyDto policyDto = insurePolicyMapper.getPolicyDetail(policyId);
if (policyDto == null) {
return ResultUtil.error("保单不存在");
}
return ResultUtil.data(policyDto);
}
@PostMapping(value = "/joinUser")
@ApiOperation(value = "5.增员", httpMethod = "Post", notes = "增员")
@ApiOperation(value = "2.增员", httpMethod = "Post", notes = "增员")
@ApiOperationSupport(order = 2)
public Result<Object> policyDetail(@RequestBody InsureDto insureDto) {
InsurePolicy insurePolicy=InsurePolicy.builder().id(Integer.parseInt(insureDto.getId())).build().selectById();
if(insurePolicy==null){
public Result<Object> joinUser(@RequestBody InsureDto insureDto) throws ParseException {
InsurePolicy insurePolicy = InsurePolicy.builder().id(Integer.parseInt(insureDto.getId())).build().selectById();
if (insurePolicy == null) {
return ResultUtil.error("保单不存在");
}
Integer price = getPrice(insureDto.getBenefitBasicPlan(),insureDto.getBenefitOccupationCategory());
LocalDateTime now = LocalDateTime.now();
String url = creaXSSFWorkbook1(insureDto.getUserIds());
log.info("保全增员文件地址",url);
String url = creaXSSFWorkbook1(insureDto.getUserIds(), insureDto.getPolicyDateStart(),price);
log.info("保全增员文件地址", url);
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
Map bodyMap = Maps.newHashMap();
bodyMap.put("contract_no",insurePolicy.getPolicyNo());
bodyMap.put("order_status","1");
bodyMap.put("callback_plan","");
bodyMap.put("file_url",url);
bodyMap.put("from_source","API");
bodyMap.put("import_review_callback","");
bodyMap.put("import_callback","");
bodyMap.put("third_uuid","BQ_"+insurePolicy.getOrgCode()+"_"+dtf2.format(now));
String data=HttpUtils.sendPost(batchUrl,setParams(JSONObject.toJSONString(bodyMap),appidq,secretq),bodyMap);
log.info("保全增员返回",data);
return ResultUtil.data("");
bodyMap.put("contract_no", insurePolicy.getPolicyNo());
bodyMap.put("order_status", "1");
bodyMap.put("callback_plan", "");
bodyMap.put("file_url", url);
bodyMap.put("from_source", "API");
bodyMap.put("import_review_callback", "");
bodyMap.put("import_callback", "http://vdr75zl.nat.ipyingshe.com/callBack/policy/CallBack");
bodyMap.put("third_uuid", "IS_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now));
String responData = HttpUtils.sendPost(batchUrl, setParams(JSONObject.toJSONString(bodyMap), appidq, secretq), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(responData);
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(2)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(responData).requestPath(batchUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
if (dataMap.get("errcode").toString().equals("suc")) {
Map<String, Object> data = JSONObject.parseObject(JSONObject.toJSONString(dataMap.get("data")));
Map<String, Object> orderImportInfo = JSONObject.parseObject(JSONObject.toJSONString(data.get("order_import_info")));
String status = orderImportInfo.get("status").toString();
if (status.equals("5") || status.equals("6") || status.equals("7")) {
//TODO 写入日志
return ResultUtil.error("信息填写错误,请查看日志");
} else {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds());
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(Integer.parseInt(insureDto.getOrgCode())).build().selectById();
ygglMainEmpList.forEach(y -> {
try {
InsureUser.builder()
.transId("IS_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now))
.insuredName(qyzxEntInfoM.getName())
.price(price.toString())/*前端获取的保费*/
.premium(String.valueOf(price * ygglMainEmpList.size()))
.batchNo(data.get("import_uuid").toString())
.benefitBasicPlan(insureDto.getBenefitBasicPlan())
.policyNo(orderImportInfo.get("contract_no").toString())
.userId(y.getId())
.orgCode(y.getOrgCode())
.benefitOccupationCategory(insureDto.getBenefitOccupationCategory())
.insuredMobile(y.getPhone())
.benefitOccupationCategory(insureDto.getBenefitOccupationCategory())
.insuredNo(y.getZjNum())
.insuredEContact(y.getName())
.applicantEmployeeList(data.get("file_url").toString())
.policyDateStart(dtf3.parse(insureDto.getPolicyDateStart()))
.policyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()))
.status("1").insureStatus(3).policyId(insurePolicy.getId()).build().insert();
} catch (ParseException e) {
e.printStackTrace();
}
y.setIsInsure(2);
y.insertOrUpdate();
});
return ResultUtil.data("核保成功,等待系统更新");
}
}
return ResultUtil.error(dataMap.get("请求异常"));
}
/**
* 生成保全增员文件
*
* @param ids
* @return
*/
public String creaXSSFWorkbook1(String[] ids){
if(ids.length<=0){
public String creaXSSFWorkbook1(String[] ids, String date,Integer price) {
if (ids.length <= 0) {
return "error";
}
LocalDate localDate = LocalDate.now();
List<YgglMainEmp> ygglMainEmpList=ygglMainEmpMapper.selectListByIds(ids);
List list=Lists.newArrayList();
for (YgglMainEmp y:ygglMainEmpList) {
String[] arr =new String[]{String.valueOf(y.getId()),y.getName(),"身份证",y.getZjNum(),"50万意外/5万医疗/扩展24小时(A类)","","深圳名邦人力资源管理有限公司","无","A类"};
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(ids);
List list = Lists.newArrayList();
for (YgglMainEmp y : ygglMainEmpList) {
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), InsuranceEnum.getEnum(price).getName(), date, "深圳名邦人力资源管理有限公司", "无", InsuranceEnum.getEnum(price).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"};
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(localDate+"_"+list.size()+"名人员清单.xlsx",rowName,list);
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel( localDate + "_补充" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
String fileBase64= Base64.byteArrayToBase64(bytes);
String fileBase64 = Base64.byteArrayToBase64(bytes);
/*body参数 begin*/
Map bodyMap= Maps.newHashMap();
bodyMap.put("media",fileBase64);
Map bodyMap = Maps.newHashMap();
bodyMap.put("media", fileBase64);
/*end*/
String data=HttpUtils.sendPost(uploadUrl2,setParams(JSONObject.toJSONString(bodyMap),appidq,secretq),bodyMap);
Map<String,Object> dataMap = JSONObject.parseObject(data);
String data = HttpUtils.sendPost(uploadUrl2, setParams(JSONObject.toJSONString(bodyMap), appidq, secretq), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(data);
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(5)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl2)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map <String,Object> map= JSONObject.parseObject(JSONObject.toJSONString(o));
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
return map.get("file_url").toString();
}
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
}finally {
} finally {
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
......@@ -475,8 +513,256 @@ public class InsureContorll {
e.printStackTrace();
}
}
return "suc";
}
@GetMapping(value = "/downPolicyFile")
@ApiOperation(value = "7.下载电子表单", httpMethod = "Get", notes = "下载电子表单")
@ApiOperationSupport(order = 2)
public void downPolicyFile(@RequestParam("policyId") String policyId, HttpServletRequest request, HttpServletResponse response) {
InsurePolicy insurePolicy = InsurePolicy.builder().id(Integer.parseInt(policyId)).build().selectById();
if(insurePolicy==null|| StringUtils.isNullOrEmpty(insurePolicy.getPolicyFile())){
return;
}
BufferedInputStream in = null;
OutputStream os = null;
try {
response.setContentType("application/octet-stream");
response.setHeader("content-disposition", "attachment; filename=" + new String((insurePolicy.getPolicyNo()+".pdf").getBytes("UTF8"), "ISO-8859-1"));
response.setCharacterEncoding("UTF-8");
URL url = new URL(insurePolicy.getPolicyFile());
in = new BufferedInputStream(url.openStream());
os = response.getOutputStream();
int i;
while ((i = in.read()) != -1) {
os.write(i);
}
os.flush();
in.close();
response.getOutputStream();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (in != null) {
in.close();
}
if (os != null) {
os.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
@PostMapping(value = "/replaceUser")
@ApiOperation(value = "6.保全替换", httpMethod = "Post", notes = "保全替换")
@ApiOperationSupport(order = 2)
public Result<Object> replaceUser(@RequestBody InsureDto insureDto) {
InsurePolicy insurePolicy = InsurePolicy.builder().id(Integer.parseInt(insureDto.getId())).build().selectById();
if (insurePolicy == null) {
return ResultUtil.error("保单不存在");
}
List<InsureUser> oldInsureUserList = insureUserMapper.selectListByIds(insureDto.getOldIds());
String [] oldUser = new String[oldInsureUserList.size()];
for (int i=0;i<oldInsureUserList.size();i++) {
oldUser[i]=oldInsureUserList.get(i).getUserId().toString();
}
Integer price = getPrice(insureDto.getBenefitBasicPlan(),insureDto.getBenefitOccupationCategory());
LocalDateTime now = LocalDateTime.now();
String url = creaXSSFWorkbook2(insureDto.getUserIds(), insureDto.getPolicyDateStart(),oldUser,insureDto.getBenefitOccupationCategory());
log.info("保全替换文件地址", url);
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
Map bodyMap = Maps.newHashMap();
bodyMap.put("contract_no", insurePolicy.getPolicyNo());
bodyMap.put("order_status", "3");
bodyMap.put("callback_plan", "");
bodyMap.put("file_url", url);
bodyMap.put("from_source", "API");
bodyMap.put("import_review_callback", "");
bodyMap.put("import_callback", "http://vdr75zl.nat.ipyingshe.com/callBack/policy/CallBack");
bodyMap.put("third_uuid", "RP_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now));
String responData = HttpUtils.sendPost(batchUrl, setParams(JSONObject.toJSONString(bodyMap), appidq, secretq), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(responData);
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(3)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(responData).requestPath(batchUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
if (dataMap.get("errcode").toString().equals("suc")) {
Map<String, Object> data = JSONObject.parseObject(JSONObject.toJSONString(dataMap.get("data")));
Map<String, Object> orderImportInfo = JSONObject.parseObject(JSONObject.toJSONString(data.get("order_import_info")));
String status = orderImportInfo.get("status").toString();
if (status.equals("5") || status.equals("6") || status.equals("7")) {
//TODO 写入日志
return ResultUtil.error("信息填写错误,请查看日志");
} else {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds());
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(Integer.parseInt(insureDto.getOrgCode())).build().selectById();
ygglMainEmpList.forEach(y -> {
try {
InsureUser.builder()
.transId("RP_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now))
.insuredName(qyzxEntInfoM.getName())
.price(price.toString())/*前端获取的保费*/
.premium(String.valueOf(price * ygglMainEmpList.size()))
.batchNo(data.get("import_uuid").toString())
.benefitBasicPlan(insureDto.getBenefitBasicPlan())
.policyNo(orderImportInfo.get("contract_no").toString())
.userId(y.getId())
.orgCode(y.getOrgCode())
.benefitOccupationCategory(insureDto.getBenefitOccupationCategory())
.insuredMobile(y.getPhone())
.benefitOccupationCategory(insureDto.getBenefitOccupationCategory())
.insuredNo(y.getZjNum())
.insuredEContact(y.getName())
.applicantEmployeeList(data.get("file_url").toString())
.policyDateStart(dtf3.parse(insureDto.getPolicyDateStart()))
.policyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()))
.status("1").insureStatus(3).policyId(insurePolicy.getId()).build().insert();
} catch (ParseException e) {
e.printStackTrace();
}
y.setIsInsure(2);
y.insertOrUpdate();
});
oldInsureUserList.forEach(o->{
o.setReplaceTransId(data.get("import_uuid").toString());
o.updateById();
});
return ResultUtil.data("核保成功,等待系统更新");
}
}
return ResultUtil.data("成功");
}
/**
* 生成保全替换文件
*
* @param ids
* @return
*/
public String creaXSSFWorkbook2(String[] ids,String date,String[] oldIds,String type) {
if (ids.length <= 0||oldIds.length<=0) {
return "error";
}
LocalDate localDate = LocalDate.now();
List<YgglMainEmp> newList = ygglMainEmpMapper.selectListByIds(ids);
List<YgglMainEmp> oldList = ygglMainEmpMapper.selectListByIds(oldIds);
if (newList.size()!=oldList.size()){
return "error";
}
List list = Lists.newArrayList();
for (int i=0;i<newList.size();i++) {
String[] arr = new String[]{String.valueOf(oldList.get(i).getId()),
oldList.get(i).getName(),
"身份证",
oldList.get(i).getZjNum(),
date.substring(0,10),
newList.get(i).getName(),
"身份证",
newList.get(i).getZjNum(),
"","","","","","","无","1",type.equals("63119")?"A类":type.equals("63120")?"B类":"C类"};
list.add(arr);
}
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Update_date", "replace_name", "replace_ID_type",
"replace_ID_number", "Date_of_birth","insured_type","insured_relationship","cert_type_related_insured","insured_relationship_id","Branch",
"Tricycle_frame_number","insured_number","benefit_occupation_category"};
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel( localDate + "_替换" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
String fileBase64 = Base64.byteArrayToBase64(bytes);
/*body参数 begin*/
Map bodyMap = Maps.newHashMap();
bodyMap.put("media", fileBase64);
/*end*/
String data = HttpUtils.sendPost(uploadUrl2, setParams(JSONObject.toJSONString(bodyMap), appidq, secretq), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(data);
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(6)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl2)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
return map.get("file_url").toString();
}
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return "suc";
}
/*获取基础计划的价格*/
private Integer getPrice(String plan,String type){
/*
基础计划
30万雇主/3万医疗 36968,
50万雇主/5万医疗 36969,
80万雇主/10万医疗 36970,
80万雇主/20万医疗 36971,
100万雇主/10万医疗 36972
*/
/*行业类型
* A类 63119
* B类 63120
* C类 63121\
* */
switch (plan){
case "36968":
if(type.equals("63119")){
return 12;
}else if(type.equals("63120")){
return 18;
}
break;
case"36969":
if(type.equals("63119")){
return 15;
}else if(type.equals("63120")){
return 20;
}else if(type.equals("63121")){
return 60;
}
break;
case "36970":
if(type.equals("63119")){
return 18;
}else if(type.equals("63120")){
return 35;
}else if(type.equals("63121")){
return 75;
}
break;
case "36971":
if(type.equals("63119")){
return 25;
}else if(type.equals("63120")){
return 38;
}
break;
case "36972":
if(type.equals("63119")){
return 28;
}else if(type.equals("63120")){
return 40;
}
break;
}
return 0;
}
}
......@@ -34,7 +34,7 @@ public class SuperLoginController {
@Autowired
private HttpSession session;
@PostMapping(value = "/adminLogin")
@ApiOperation(value = "运营后台登录", httpMethod = "POST", notes = "接口发布说明")
@ApiOperation(value = "运营后台登录", httpMethod = "Post", notes = "接口发布说明")
public Result<Object> adminLogin(@RequestBody EntRegisterDto entRegisterDto, HttpServletRequest request){
String ip = UserIp.getIpAddr(request);
AdminAccount adminAccount = AdminAccount.builder().build().selectOne(new QueryWrapper<AdminAccount>().lambda()
......@@ -49,7 +49,7 @@ public class SuperLoginController {
return ResultUtil.data(adminAccount);
};
@PostMapping(value = "/adminOutLogin")
@ApiOperation(value = "运营后台退出", httpMethod = "POST", notes = "接口发布说明")
@ApiOperation(value = "运营后台退出", httpMethod = "Post", notes = "接口发布说明")
public Result<String> adminOutLogin(HttpServletRequest request){
session= request.getSession();
session.removeAttribute("ai");
......
......@@ -2,7 +2,9 @@ package cn.timer.api.dao.insure;
import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.dto.insure.PolicyDto;
import cn.timer.api.utils.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -17,7 +19,8 @@ import java.util.List;
*/
@Repository
public interface InsurePolicyMapper extends BaseMapper<InsurePolicy> {
public List<PolicyDto> policyList();
public List<PolicyDto> policyList(@Param("page") Page page);
PolicyDto getPolicyDetail(@Param("id")Integer id);
Integer totalPolicy();
}
package cn.timer.api.dao.insure;
import cn.timer.api.bean.insure.InsureUser;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.dto.insure.PolicyDto;
import cn.timer.api.utils.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -16,6 +19,8 @@ import java.util.List;
*/
@Repository
public interface InsureUserMapper extends BaseMapper<InsureUser> {
public List<PolicyDto> selectPolicyList(String id);
List<PolicyDto> selectPolicyList(@Param("page") Page page,@Param("id") String id);
Integer totalUser(@Param("id")String id);
List<InsureUser> selectListByIds(@Param("array")String[] ids);
}
package cn.timer.api.dto.insure;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
......@@ -28,5 +29,7 @@ public class InsureDto {
private String benefitBasicPlan;/*方案名称*/
private String benefitOccupationCategory;
private String tricycleFrameNumber;
private Integer type;/*类型 1是新增 3是替换*/
private String[] oldIds;
// private String
}
package cn.timer.api.dto.insure;
import cn.timer.api.utils.Page;
import lombok.Data;
import java.util.Date;
......@@ -31,5 +32,9 @@ public class PolicyDto {
private String benefitBasicPlan;
private String price;
private String orgCode;
private Page page;
private String policyFile;
private String benefitOccupationCategory;
private Integer userId;
}
......@@ -259,44 +259,6 @@
</foreach>
</insert>
<update id="update" parameterType="cn.timer.api.bean.insure.InsureApplicant">
update insure_applicant
<set>
<if test="applicantEName != null">`applicant_e_name` = #{applicantEName},</if>
<if test="applicantEAddress != null">`applicant_e_address` = #{applicantEAddress},</if>
<if test="applicantEmployeeList != null">`applicant_employee_list` = #{applicantEmployeeList},</if>
<if test="applicantEContacts != null">`applicant_e_contacts` = #{applicantEContacts},</if>
<if test="applicantEPhone != null">`applicant_e_phone` = #{applicantEPhone},</if>
<if test="applicantENoType != null">`applicant_e_no_type` = #{applicantENoType},</if>
<if test="applicantENo != null">`applicant_e_no` = #{applicantENo},</if>
<if test="applicantEMail != null">`applicant_e_mail` = #{applicantEMail},</if>
<if test="applicantProvinceCity != null">`applicant_province_city` = #{applicantProvinceCity},</if>
<if test="applicantInvoiceReceivingAddress != null">`applicant_invoice_receiving_address` =
#{applicantInvoiceReceivingAddress},
</if>
<if test="applicantInvoiceBillingPhone != null">`applicant_invoice_billing_phone` =
#{applicantInvoiceBillingPhone},
</if>
<if test="applicantBusinessBankName != null">`applicant_business_bank_name` =
#{applicantBusinessBankName},
</if>
<if test="policyNo != null">`policy_no` = #{policyNo},</if>
<if test="applicantType != null">`applicant_type` = #{applicantType},</if>
<if test="transId != null">`trans_id` = #{transId},</if>
<if test="currency != null">`currency` = #{currency},</if>
<if test="applicantInvoicedAmount != null">`applicant_invoiced_amount` = #{applicantInvoicedAmount}</if>
<if test="applicantCorporateBankAccount != null">`applicant_corporate_bank_account` = #{applicantCorporateBankAccount}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete
from insure_applicant
where id = #{value}
</delete>
<delete id="deleteBatch">
delete from insure_applicant where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
......
......@@ -224,36 +224,6 @@
</insert>
<update id="update" parameterType="cn.timer.api.bean.insure.InsurePolicy">
update insure_policy
<set>
<if test="schemeName != null">`scheme_name` = #{schemeName},</if>
<if test="policyDateStart != null">`policy_date_start` = #{policyDateStart},</if>
<if test="policyDateEnd != null">`policy_date_end` = #{policyDateEnd},</if>
<if test="productCodeId != null">`product_code_id` = #{productCodeId},</if>
<if test="planCodeId != null">`plan_code_id` = #{planCodeId},</if>
<if test="partnerPid != null">`partner_pid` = #{partnerPid},</if>
<if test="policyNo != null">`policy_no` = #{policyNo},</if>
<if test="type != null">`type` = #{type},</if>
<if test="currency != null">`currency` = #{currency},</if>
<if test="totalPremium != null">`total_premium` = #{totalPremium},</if>
<if test="status != null">`status` = #{status},</if>
<if test="policyFile != null">`policy_file` = #{policyFile},</if>
<if test="kitUrl != null">`kit_url` = #{kitUrl},</if>
<if test="insureApplicantId != null">`insure_applicant_id` = #{insureApplicantId},</if>
<if test="orgCode != null">`org_code` = #{orgCode},</if>
<if test="createTime != null">`create_time` = #{createTime}</if>
<if test="updateTime != null">`update_time` = #{updateTime}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete
from insure_policy
where id = #{value}
</delete>
<delete id="deleteBatch">
delete from insure_policy where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
......@@ -264,12 +234,20 @@
<select id="policyList" resultType="cn.timer.api.dto.insure.PolicyDto">
select ip.id AS id, ip.scheme_name AS schemeName, ip.type AS type, count(iu.id) AS totaPolicy,
count(iu.org_code) AS totalCompany, count(iu.id) AS totalUser, ip.total_premium AS totalPremium,
ip.update_time AS updateTime
ip.update_time AS updateTime,ip.policy_file AS policyFile
from insure_policy ip
LEFT JOIN insure_user iu on iu.policy_no = ip.policy_no
GROUP BY ip.policy_no
LEFT JOIN insure_user iu on iu.policy_id = ip.id
where iu.insure_status=1
GROUP BY ip.id
<if test="page.offset != null and page.totalPage !=null">
limit #{page.offset},#{page.totalPage}
</if>
</select>
<select id="totalPolicy" resultType="java.lang.Integer">
select count(ip.id)
from insure_policy ip
</select>
<select id="getPolicyDetail" resultType="cn.timer.api.dto.insure.PolicyDto">
SELECT
......@@ -280,10 +258,11 @@
ip.policy_no as policyNo,
ip.org_code as orgCode,
iu.insured_name as insuredName,
iu.benefit_basic_plan as benefitBasicPlan
iu.benefit_basic_plan as benefitBasicPlan,
iu.benefit_occupation_category as benefitOccupationCategory
FROM
insure_policy ip
LEFT JOIN insure_user iu ON iu.policy_no = ip.policy_no
LEFT JOIN insure_user iu ON iu.policy_id = ip.id
WHERE
ip.id = #{id}
LIMIT 1
......
......@@ -26,6 +26,9 @@
<result property="applicantEmployeeList" column="applicant_employee_list"/>
<result property="policyDateStart" column="policy_date_start"/>
<result property="policyDateEnd" column="policy_date_end"/>
<result property="insureStatus" column="insure_status"/>
<result property="policyId" column="policy_id"/>
<result property="replaceTransId" column="replace_trans_id"/>
</resultMap>
<select id="queryObject" resultType="cn.timer.api.bean.insure.InsureUser">
......@@ -66,6 +69,8 @@
<if test="applicantEmployeeList != null and applicantEmployeeList != ''">AND `applicant_employee_list` =
#{applicantEmployeeList}
</if>
<if test="insureStatus != null and insureStatus != ''">AND `insure_status` = #{insureStatus}</if>
<if test="policyId != null and policyId != ''">AND `policy_id` = #{policyId}</if>
</where>
<choose>
<when test="sidx != null and sidx.trim() != ''">
......@@ -112,6 +117,8 @@
<if test="applicantEmployeeList != null and applicantEmployeeList != ''">AND `applicant_employee_list` =
#{applicantEmployeeList}
</if>
<if test="insureStatus != null and insureStatus != ''">AND `insure_status` = #{insureStatus}</if>
<if test="policyId != null and policyId != ''">AND `policy_id` = #{policyId}</if>
</where>
</select>
......@@ -134,7 +141,9 @@
`type`,
`org_code`,
`user_id`,
`applicant_employee_list`)
`applicant_employee_list`,
`insure_status`,
`policy_id`)
values (#{transId},
#{price},
#{insuredName},
......@@ -152,7 +161,8 @@
#{type},
#{orgCode},
#{userId},
#{applicantEmployeeList})
#{applicantEmployeeList},
#{policyId})
</insert>
<insert id="saveSelective" parameterType="cn.timer.api.bean.insure.InsureUser" useGeneratedKeys="true"
......@@ -177,6 +187,8 @@
<if test="orgCode != null">,`org_code`</if>
<if test="userId != null">,`user_id`</if>
<if test="applicantEmployeeList != null">,`applicant_employee_list`</if>
<if test="insureStatus != null">,`insure_status`</if>
<if test="policyId != null">,`policy_id`</if>
)
values
(
......@@ -198,6 +210,8 @@
<if test="orgCode != null">,#{orgCode}</if>
<if test="userId != null">,#{userId}</if>
<if test="applicantEmployeeList != null">,#{applicantEmployeeList}</if>
<if test="insureStatus != null">,#{insureStatus}</if>
<if test="policyId != null">,#{policyId}</if>
)
</insert>
......@@ -222,7 +236,9 @@
`type`,
`org_code`,
`user_id`,
`applicant_employee_list`
`applicant_employee_list`,
`insure_status`,
`policy_id`
)
values
<foreach collection="list" item="item" index="index" separator=",">
......@@ -244,45 +260,14 @@
#{item.type},
#{item.orgCode},
#{item.userId},
#{item.applicantEmployeeList}
#{item.applicantEmployeeList},
#{item.insureStatus},
#{item.policyId}
)
</foreach>
</insert>
<update id="update" parameterType="cn.timer.api.bean.insure.InsureUser">
update insure_user
<set>
<if test="transId != null">`trans_id` = #{transId},</if>
<if test="price != null">`price` = #{price},</if>
<if test="insuredName != null">`insured_name` = #{insuredName},</if>
<if test="batchNo != null">`batch_no` = #{batchNo},</if>
<if test="premium != null">`premium` = #{premium},</if>
<if test="insuredMobile != null">`insured_mobile` = #{insuredMobile},</if>
<if test="insuredNo != null">`insured_no` = #{insuredNo},</if>
<if test="insuredEContact != null">`insured_e_contact` = #{insuredEContact},</if>
<if test="benefitBasicPlan != null">`benefit_basic_plan` = #{benefitBasicPlan},</if>
<if test="benefitOccupationCategory != null">`benefit_occupation_category` = #{benefitOccupationCategory},
</if>
<if test="benefitElEmployeeNumberT != null">`benefit_EL_employee_number_t` = #{benefitElEmployeeNumberT},
</if>
<if test="tricycleFrameNumber != null">`Tricycle_frame_number` = #{tricycleFrameNumber},</if>
<if test="policyNo != null">`policy_no` = #{policyNo},</if>
<if test="status != null">`status` = #{status},</if>
<if test="type != null">`type` = #{type},</if>
<if test="orgCode != null">`org_code` = #{orgCode},</if>
<if test="userId != null">`user_id` = #{userId},</if>
<if test="applicantEmployeeList != null">`applicant_employee_list` = #{applicantEmployeeList}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete
from insure_user
where id = #{value}
</delete>
<delete id="deleteBatch">
delete from insure_user where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
......@@ -292,13 +277,38 @@
<select id="selectPolicyList" resultType="cn.timer.api.dto.insure.PolicyDto">
select iu.id,yme.`name`,yme.zj_type,yme.zj_num,iu.policy_no,iu.`status`,ip.scheme_name,iu.policy_date_start,
iu.policy_date_end,ip.create_time,iu.insured_name,iu.benefit_basic_plan AS benefitBasicPlan,iu.price AS price from insure_user iu
iu.policy_date_end,ip.create_time,iu.insured_name,iu.benefit_basic_plan AS benefitBasicPlan,iu.price AS price,
iu.user_id as userId
from insure_user iu
LEFT JOIN yggl_main_emp yme on yme.id=iu.user_id
LEFT JOIN insure_policy ip on ip.policy_no=iu.policy_no
where yme.org_code = 3
LEFT JOIN insure_policy ip on ip.id=iu.policy_id
where yme.org_code = 3 AND iu.insure_status=1
<if test="id !=null and id !=''">
and ip.id=#{id}
</if>
<if test="page.offset != null and page.totalPage !=null">
limit #{page.offset},#{page.totalPage}
</if>
</select>
<select id="totalUser" resultType="java.lang.Integer">
select count(iu.id) from insure_user iu
LEFT JOIN yggl_main_emp yme on yme.id=iu.user_id
LEFT JOIN insure_policy ip on ip.id=iu.policy_id
where yme.org_code = 3 AND iu.insure_status=1
<if test="id !=null and id !=''">
and ip.id=#{id}
</if>
</select>
<!--根据id数组查询员工-->
<select id="selectListByIds" resultType="cn.timer.api.bean.insure.InsureUser">
SELECT
*
FROM insure_user
WHERE id IN
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>
......@@ -250,7 +250,7 @@
AND
a.job_status in (0,1,2)
<if test="isInsure!=null and isInsure != ''">
AND a.is_insure=#{isInsure}
AND a.is_insure in (1,2)
</if>
ORDER BY
emp_num DESC
......
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