Commit 60787f3e by 翁国栋

运营后台--

保险列表
parent 8c5c01e1
...@@ -3,6 +3,7 @@ package cn.timer.api.bean.insure; ...@@ -3,6 +3,7 @@ package cn.timer.api.bean.insure;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* @Description TODO * @Description TODO
...@@ -21,4 +22,6 @@ public class CallBack implements Serializable { ...@@ -21,4 +22,6 @@ public class CallBack implements Serializable {
private String serial_no; private String serial_no;
private String policy_file; private String policy_file;
private String total_expenditure; private String total_expenditure;
private String endorsement_file;
private OrderImportInfo order_import_info;
} }
...@@ -142,7 +142,13 @@ public class InsureUser extends Model<InsureUser> { ...@@ -142,7 +142,13 @@ public class InsureUser extends Model<InsureUser> {
@ApiModelProperty(value = "失效日期") @ApiModelProperty(value = "失效日期")
private Date policyDateEnd; 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 { ...@@ -36,7 +36,8 @@ public class WebSecurityConfig implements WebMvcConfigurer {
registry.addInterceptor(getSessionInterceptor()) registry.addInterceptor(getSessionInterceptor())
.addPathPatterns("/**") .addPathPatterns("/**")
.excludePathPatterns("/callback/**") .excludePathPatterns("/callback/**")
.excludePathPatterns("/callBack/policy/**") .excludePathPatterns("/callBack/policy/CallBack")
.excludePathPatterns("/callBack/policy/insuredCallBack")
.excludePathPatterns("/superLogin/**") .excludePathPatterns("/superLogin/**")
.excludePathPatterns("/actuator/*") .excludePathPatterns("/actuator/*")
.excludePathPatterns("/doc*") .excludePathPatterns("/doc*")
......
package cn.timer.api.controller.insure; 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.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.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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; 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 * @Description TODO
...@@ -22,12 +43,72 @@ import javax.security.auth.callback.Callback; ...@@ -22,12 +43,72 @@ import javax.security.auth.callback.Callback;
@RequestMapping(value = "/callBack/policy", produces = {"application/json"}) @RequestMapping(value = "/callBack/policy", produces = {"application/json"})
public class CallBackContorll { public class CallBackContorll {
private static final Logger log = LoggerFactory.getLogger(CallBackContorll.class); private static final Logger log = LoggerFactory.getLogger(CallBackContorll.class);
/*保全测试用*/
private static String appidq = "1000115041006006938";
/*保全测试用*/
private static String secretq = "6ba1bf4aa0bd14368c95ff0b9934a17b";
@PostMapping(value = "/insuredCallBack") @PostMapping(value = "/insuredCallBack")
@ApiOperation(value = "6.投保申请回调", httpMethod = "Post", notes = "投保申请回调") @ApiOperation(value = "6.投保申请回调", httpMethod = "Post", notes = "投保申请回调")
@ApiOperationSupport(order = 2) @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)); 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; 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.InsureApplicant;
import cn.timer.api.bean.insure.InsureLog;
import cn.timer.api.bean.insure.InsurePolicy; import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.bean.insure.InsureUser; import cn.timer.api.bean.insure.InsureUser;
import cn.timer.api.bean.qyzx.QyzxEntInfoM; import cn.timer.api.bean.qyzx.QyzxEntInfoM;
...@@ -10,6 +9,7 @@ import cn.timer.api.bean.yggl.YgglMainEmp; ...@@ -10,6 +9,7 @@ import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser; import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean; import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.controller.insure.bean.ExcelBean; 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.InsurePolicyMapper;
import cn.timer.api.dao.insure.InsureUserMapper; import cn.timer.api.dao.insure.InsureUserMapper;
import cn.timer.api.dao.yggl.YgglMainEmpMapper; import cn.timer.api.dao.yggl.YgglMainEmpMapper;
...@@ -17,16 +17,13 @@ import cn.timer.api.dto.insure.InsureDto; ...@@ -17,16 +17,13 @@ import cn.timer.api.dto.insure.InsureDto;
import cn.timer.api.dto.insure.PolicyDto; import cn.timer.api.dto.insure.PolicyDto;
import cn.timer.api.utils.*; import cn.timer.api.utils.*;
import com.alibaba.druid.util.Base64; import com.alibaba.druid.util.Base64;
import com.alibaba.fastjson.TypeReference; import com.aliyun.oss.common.utils.StringUtils;
import com.aliyuncs.http.HttpRequest;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.beust.jcommander.internal.Lists; import com.beust.jcommander.internal.Lists;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.JsonObject;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
...@@ -39,15 +36,18 @@ import org.springframework.web.bind.annotation.*; ...@@ -39,15 +36,18 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.*; import java.io.*;
import java.net.URLEncoder; import java.net.HttpURLConnection;
import java.security.Policy; import java.net.MalformedURLException;
import java.net.URL;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -72,9 +72,9 @@ public class InsureContorll { ...@@ -72,9 +72,9 @@ public class InsureContorll {
private static String secret = "acb329868c31d5b3ba03de40dac13dd9"; 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 { ...@@ -86,6 +86,8 @@ public class InsureContorll {
/*测试用保全申请地址*/ /*测试用保全申请地址*/
private static String batchUrl = "http://sandbox.portal.unistar-ins.com/fuli/Home/WelfareProduct/batch_declare"; 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 @Autowired
private YgglMainEmpMapper ygglMainEmpMapper; private YgglMainEmpMapper ygglMainEmpMapper;
...@@ -98,58 +100,63 @@ public class InsureContorll { ...@@ -98,58 +100,63 @@ public class InsureContorll {
/** /**
* 设置请求参数 * 设置请求参数
*
* @param sign * @param sign
* @return * @return
*/ */
private Map setParams(String sign,String appid,String secret){ private Map setParams(String sign, String appid, String secret) {
/*当前时间戳*/ /*当前时间戳*/
long timestamp =System.currentTimeMillis()/1000; long timestamp = System.currentTimeMillis() / 1000;
log.info("时间戳"+timestamp); log.info("时间戳" + timestamp);
Map paramsMap = Maps.newHashMap(); Map paramsMap = Maps.newHashMap();
paramsMap.put("pid",appid); paramsMap.put("pid", appid);
paramsMap.put("timestamp",String.valueOf(timestamp)); paramsMap.put("timestamp", String.valueOf(timestamp));
paramsMap.put("trace_id",appid+timestamp+ new Random().nextInt((9999 - 100) + 1) + 10); paramsMap.put("trace_id", appid + timestamp + new Random().nextInt((9999 - 100) + 1) + 10);
// paramsMap.put("sign",Md5.md5(appid+secret+timestamp+sign.trim())); // paramsMap.put("sign",Md5.md5(appid+secret+timestamp+sign.trim()));
String value=appid+secret+timestamp+sign; String value = appid + secret + timestamp + sign;
log.info("body参数======"+sign); log.info("body参数======" + sign);
paramsMap.put("sign", DigestUtils.md5Hex(value)); paramsMap.put("sign", DigestUtils.md5Hex(value));
log.info("params参数======"+JSONObject.toJSONString(paramsMap)); log.info("params参数======" + JSONObject.toJSONString(paramsMap));
return paramsMap; return paramsMap;
} }
@PostMapping(value = "/insured_add") @PostMapping(value = "/insured_add")
@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) { public Result<Object> insured_add(@RequestBody InsureDto insureDto) throws ParseException {
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");
DateFormat dtf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
Date date = Date.from(now.atZone(ZoneId.systemDefault()).toInstant());
Map bodyMap = Maps.newHashMap(); Map bodyMap = Maps.newHashMap();
ArrayList<Map> quotationsArry = new ArrayList<Map>(); ArrayList<Map> quotationsArry = new ArrayList<Map>();
bodyMap.put("is_ss",0); bodyMap.put("is_ss", 0);
Map quotations=Maps.newHashMap(); Map quotations = Maps.newHashMap();
quotations.put("trans_id","MB_"+dtf2.format(now));/*报价请求流水号*/ Integer price = getPrice(insureDto.getBenefitBasicPlan(),insureDto.getBenefitOccupationCategory());
quotations.put("applicant_type","2");/*投保人类型:2-企业*/ if(price==0){
quotations.put("quotation_type",3);/*报价类型:3-投保申请*/ return ResultUtil.error("报价不存在");
quotations.put("currency","5");/*币种:5人民币*/ }
quotations.put("source_type","");/*币种:5人民币*/ quotations.put("trans_id", "MB_" + dtf2.format(now));/*报价请求流水号*/
quotations.put("cps_email","");/*币种:5人民币*/ quotations.put("applicant_type", "2");/*投保人类型:2-企业*/
quotations.put("cps_tel","");/*币种:5人民币*/ quotations.put("quotation_type", 3);/*报价类型:3-投保申请*/
quotations.put("last_serial_number","");/*币种:5人民币*/ quotations.put("currency", "5");/*币种:5人民币*/
quotations.put("from_source","");/*币种:5人民币*/ quotations.put("source_type", "");/*币种:5人民币*/
quotations.put("operator_name","");/*币种: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(); InsureApplicant insureApplicant = InsureApplicant.builder().id(1).build().selectById();
if(insureApplicant==null){ if (insureApplicant == null) {
return ResultUtil.error("未设置投保人"); return ResultUtil.error("未设置投保人");
} }
Map companyApplicantMap = Maps.newHashMap(); Map companyApplicantMap = Maps.newHashMap();
companyApplicantMap.put("applicant_e_name",insureApplicant.getApplicantEName());/*企业/网点名称*/ companyApplicantMap.put("applicant_e_name", insureApplicant.getApplicantEName());/*企业/网点名称*/
companyApplicantMap.put("applicant_e_address",insureApplicant.getApplicantEAddress());/*企业/网点地址*/ companyApplicantMap.put("applicant_e_address", insureApplicant.getApplicantEAddress());/*企业/网点地址*/
companyApplicantMap.put("applicant_e_contacts", insureApplicant.getApplicantEContacts());/*企业授权操作人姓名*/ companyApplicantMap.put("applicant_e_contacts", insureApplicant.getApplicantEContacts());/*企业授权操作人姓名*/
companyApplicantMap.put("applicant_e_phone", insureApplicant.getApplicantEPhone());/*操作人的联系电话*/ companyApplicantMap.put("applicant_e_phone", insureApplicant.getApplicantEPhone());/*操作人的联系电话*/
companyApplicantMap.put("applicant_e_no_type", insureApplicant.getApplicantENoType());/*企业证件类型*/ companyApplicantMap.put("applicant_e_no_type", insureApplicant.getApplicantENoType());/*企业证件类型*/
...@@ -157,30 +164,30 @@ public class InsureContorll { ...@@ -157,30 +164,30 @@ public class InsureContorll {
companyApplicantMap.put("applicant_e_mail", insureApplicant.getApplicantEMail());/*企业邮箱*/ companyApplicantMap.put("applicant_e_mail", insureApplicant.getApplicantEMail());/*企业邮箱*/
companyApplicantMap.put("applicant_province_city", "21721");/*省市区*/ companyApplicantMap.put("applicant_province_city", "21721");/*省市区*/
/*人员清单填被保人员*/ /*人员清单填被保人员*/
String url= creaXSSFWorkbook(insureDto.getUserIds()); String url = creaXSSFWorkbook(insureDto.getUserIds(),price);
if(!StringUtil.isNotBlank(url)){ if (!StringUtil.isNotBlank(url)) {
return ResultUtil.error("文件错误"); return ResultUtil.error("文件错误");
} }
companyApplicantMap.put("applicant_employee_list",url); companyApplicantMap.put("applicant_employee_list", url);
quotations.put("company_applicant",companyApplicantMap); quotations.put("company_applicant", companyApplicantMap);
Map basicMap = Maps.newHashMap(); Map basicMap = Maps.newHashMap();
basicMap.put("partner_pid","1231");/*分销商pid*/ basicMap.put("partner_pid", "1231");/*分销商pid*/
basicMap.put("plan_code_id","61b85207b73d2ab09fb2959");/*计划代码,选项值:61b85207b73d2ab09fb2959 (生产环境) 61b85207b73d2ab09fb2959 (沙箱环境)*/ basicMap.put("plan_code_id", "61b85207b73d2ab09fb2959");/*计划代码,选项值:61b85207b73d2ab09fb2959 (生产环境) 61b85207b73d2ab09fb2959 (沙箱环境)*/
basicMap.put("product_code_id","61b85207a9f87da19fb5986");/*产品代码,选项值:61b85207a9f87da19fb5986 (生产环境) 61b85207a9f87da19fb5986 (沙箱环境)*/ basicMap.put("product_code_id", "61b85207a9f87da19fb5986");/*产品代码,选项值:61b85207a9f87da19fb5986 (生产环境) 61b85207a9f87da19fb5986 (沙箱环境)*/
basicMap.put("policy_date_start",insureDto.getPolicyDateStart()); basicMap.put("policy_date_start",insureDto.getPolicyDateStart());
basicMap.put("policy_date_end",insureDto.getPolicyDateEnd()); basicMap.put("policy_date_end", insureDto.getPolicyDateEnd());
basicMap.put("channel",""); basicMap.put("channel", "");
basicMap.put("fee",""); basicMap.put("fee", "");
basicMap.put("partner_user_rate",""); basicMap.put("partner_user_rate", "");
basicMap.put("promotion_fee",""); basicMap.put("promotion_fee", "");
basicMap.put("agent_id",""); basicMap.put("agent_id", "");
basicMap.put("policy_insure_notify",""); basicMap.put("policy_insure_notify", "");
basicMap.put("promotion_id",0); basicMap.put("promotion_id", 0);
basicMap.put("policy_number_last_year",""); basicMap.put("policy_number_last_year", "");
quotations.put("basic",basicMap); quotations.put("basic", basicMap);
quotations.put("individual_applicant",Maps.newHashMap()); quotations.put("individual_applicant", Maps.newHashMap());
...@@ -188,42 +195,59 @@ public class InsureContorll { ...@@ -188,42 +195,59 @@ public class InsureContorll {
/*被保人员 填被保企业信息*/ /*被保人员 填被保企业信息*/
ArrayList<Map> insuredArray = new ArrayList<>(); ArrayList<Map> insuredArray = new ArrayList<>();
Map insured = Maps.newHashMap(); Map insured = Maps.newHashMap();
insured.put("trans_id","P_"+qyzxEntInfoM.getId()+"_"+dtf2.format(now)); insured.put("trans_id", "PI_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now));
insured.put("price",insureDto.getUserIds().length*15);/*根据基础计划生成*/ insured.put("price", insureDto.getUserIds().length * price);/*根据基础计划生成*/
insured.put("insured_applicant_relations", "36960"); insured.put("insured_applicant_relations", "36960");
insured.put("insured_mobile", qyzxEntInfoM.getLinkManPhone()); insured.put("insured_mobile", qyzxEntInfoM.getPhone());
insured.put("insured_e_contact", qyzxEntInfoM.getLinkMan()); insured.put("insured_e_contact", qyzxEntInfoM.getOperName());
insured.put("insured_name", qyzxEntInfoM.getName()); insured.put("insured_name", qyzxEntInfoM.getName());
insured.put("insured_no_type", "3306"); insured.put("insured_no_type", "3306");
insured.put("insured_no", qyzxEntInfoM.getCreditCode()); insured.put("insured_no", qyzxEntInfoM.getCreditCode());
insured.put("insured_zm_openid", ""); insured.put("insured_zm_openid", "");
insured.put("benefit_basic_plan", insureDto.getBenefitBasicPlan());/*基础计划写死*/ insured.put("benefit_basic_plan", insureDto.getBenefitBasicPlan());/*基础计划写死*/
insured.put("benefit_occupation_category", insureDto.getBenefitOccupationCategory()); 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); insuredArray.add(insured);
quotations.put("insured",insuredArray); quotations.put("insured", insuredArray);
quotations.put("file",Lists.newArrayList()); quotations.put("file", Lists.newArrayList());
quotations.put("specifically_agreed_file", Lists.newArrayList()); quotations.put("specifically_agreed_file", Lists.newArrayList());
quotations.put("policy_no", ""); quotations.put("policy_no", "");
quotations.put("callback_policy", "/callBack/insuredCallBack"); quotations.put("callback_policy", "/callBack/policy/insuredCallBack");
quotations.put("insured",insuredArray); quotations.put("insured", insuredArray);
quotationsArry.add(quotations); quotationsArry.add(quotations);
bodyMap.put("quotations",quotationsArry); bodyMap.put("quotations", quotationsArry);
log.info(JSONObject.toJSONString(bodyMap)); log.info(JSONObject.toJSONString(bodyMap));
Map dataMap = requestAgent(bodyMap); Map dataMap = requestAgent(bodyMap);
if(dataMap!=null) {
if (dataMap != null) {
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);
InsureUser insureUser; 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 = InsureUser.builder().build();
insureUser.setUserId(y.getId()); insureUser.setUserId(y.getId());
insureUser.setInsuredName(qyzxEntInfoM.getName()); insureUser.setInsuredName(qyzxEntInfoM.getName());
insureUser.setPrice("15");/*前端获取的保费*/ insureUser.setPrice(price.toString());/*前端获取的保费*/
insureUser.setTransId("MB_"+dtf2.format(now)); insureUser.setTransId("MB_" + dtf2.format(now));
insureUser.setBatchNo("P_"+qyzxEntInfoM.getId()+"_"+dtf2.format(now)); insureUser.setPremium(String.valueOf(ygglMainEmpList.size() * price));
insureUser.setBatchNo("P_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now));
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());
...@@ -233,42 +257,32 @@ public class InsureContorll { ...@@ -233,42 +257,32 @@ public class InsureContorll {
insureUser.setInsuredNo(y.getZjNum()); insureUser.setInsuredNo(y.getZjNum());
insureUser.setInsuredEContact(y.getName()); insureUser.setInsuredEContact(y.getName());
insureUser.setApplicantEmployeeList(url); insureUser.setApplicantEmployeeList(url);
insureUser.setInsureStatus(1);
insureUser.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insureUser.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insureUser.setStatus("1"); insureUser.setStatus("1");
insureUser.setPolicyId(insurePolicy.getId());
y.setIsInsure(1); y.setIsInsure(1);
y.insertOrUpdate(); y.insertOrUpdate();
insureUser.insert(); 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(""); return ResultUtil.error("");
} }
/*测试用生产环境不需要*/ /*测试用生产环境不需要*/
synchronized private Map requestAgent(Map bodyMap ){ synchronized private Map requestAgent(Map bodyMap) {
String data=HttpUtils.sendPost(insuredUrl,setParams(JSONObject.toJSONString(bodyMap),appid,secret),bodyMap); String data = HttpUtils.sendPost(insuredUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
Map dataMap = JSONObject.parseObject(data,Map.class); 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")) { if (dataMap.get("errcode").toString().equals("suc")) {
return dataMap; return dataMap;
}else{ } else {
if(dataMap.get("errcode").toString().equals("e1")&&(dataMap.get("errmsg").toString().equals("出单中")||dataMap.get("errmsg").toString().equals("系统正在处理中,请稍候再试"))){ if (dataMap.get("errcode").toString().equals("e1") && (dataMap.get("errmsg").toString().equals("出单中") || dataMap.get("errmsg").toString().equals("系统正在处理中,请稍候再试"))) {
try { try {
Thread.sleep(30000); Thread.sleep(30000);
return requestAgent(bodyMap); return requestAgent(bodyMap);
...@@ -282,90 +296,55 @@ public class InsureContorll { ...@@ -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 * @param ids
* @return * @return
*/ */
public String creaXSSFWorkbook(String[] ids){ public String creaXSSFWorkbook(String[] ids,Integer price) {
if(ids.length<=0){ if (ids.length <= 0) {
return "error"; return "error";
} }
LocalDate localDate = LocalDate.now(); LocalDate localDate = LocalDate.now();
List<YgglMainEmp> ygglMainEmpList=ygglMainEmpMapper.selectListByIds(ids); Date date = new Date();
List list=Lists.newArrayList(); List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(ids);
for (YgglMainEmp y:ygglMainEmpList) { List list = Lists.newArrayList();
String[] arr =new String[]{String.valueOf(y.getId()),y.getName(),"身份证",y.getZjNum(),"50万意外/5万医疗/扩展24小时(A类)","","深圳名邦人力资源管理有限公司","无","A类"}; 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); 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 { try {
xssfWorkbook.write(byteArrayOutputStream); xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray(); byte[] bytes = byteArrayOutputStream.toByteArray();
String fileBase64= Base64.byteArrayToBase64(bytes); String fileBase64 = Base64.byteArrayToBase64(bytes);
/*body参数 begin*/ /*body参数 begin*/
Map bodyMap= Maps.newHashMap(); Map bodyMap = Maps.newHashMap();
bodyMap.put("app","mall"); bodyMap.put("app", "mall");
bodyMap.put("name",localDate+"_"+list.size()+"名人员清单.xlsx"); bodyMap.put("name", localDate + "_" + list.size() + "名人员清单.xlsx");
bodyMap.put("file",fileBase64); bodyMap.put("file", fileBase64);
/*end*/ /*end*/
String data=HttpUtils.sendPost(uploadUrl,setParams(JSONObject.toJSONString(bodyMap),appid,secret),bodyMap); String data = HttpUtils.sendPost(uploadUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
Map<String,Object> dataMap = JSONObject.parseObject(data); 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")) { if (dataMap.get("errcode").toString().equals("suc")) {
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));
return map.get("url").toString(); return map.get("url").toString();
} }
/*文件流base64*/ /*文件流base64*/
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
try { try {
xssfWorkbook.close(); xssfWorkbook.close();
byteArrayOutputStream.close(); byteArrayOutputStream.close();
...@@ -377,97 +356,156 @@ public class InsureContorll { ...@@ -377,97 +356,156 @@ public class InsureContorll {
return "suc"; return "suc";
} }
@PostMapping(value = "/policyList") @PostMapping(value = "/policyList")
@ApiOperation(value = "3.保单列表", httpMethod = "Post", notes = "保单列表") @ApiOperation(value = "3.保单列表", httpMethod = "Post", notes = "保单列表")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public Result<Object> policyList(@RequestBody PolicyDto policyDto) { public Result<Object> policyList(@RequestBody PolicyDto policyDto) {
List<PolicyDto> list = insureUserMapper.selectPolicyList(String.valueOf(policyDto.getId())); Map map = Maps.newHashMap();
return ResultUtil.data(Optional.ofNullable(list).orElse(Lists.newArrayList())); 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") @PostMapping(value = "/policyListAdmin")
@ApiOperation(value = "4.保单列表--运营后台端", httpMethod = "Post", notes = "保单列表") @ApiOperation(value = "4.保单列表--运营后台端", httpMethod = "Post", notes = "保单列表--运营后台端")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public Result<Object> policyListAdmin(@RequestBody InsurePolicy insurePolicy) { public Result<Object> policyListAdmin(@RequestBody cn.timer.api.utils.Page page) {
List<PolicyDto> list = insurePolicyMapper.policyList(); Map map = Maps.newHashMap();
return ResultUtil.data(list); List<PolicyDto> list = insurePolicyMapper.policyList(page);
map.put("list", list);
map.put("total", insurePolicyMapper.totalPolicy());
return ResultUtil.data(map);
} }
@GetMapping(value = "/policyDetail") @GetMapping(value = "/policyDetail")
@ApiOperation(value = "5.保单信息", httpMethod = "Get", notes = "保单列表") @ApiOperation(value = "5.保单信息", httpMethod = "Get", notes = "保单信息")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public Result<Object> policyDetail(@RequestParam("policyId") Integer policyId) { public Result<Object> policyDetail(@RequestParam("policyId") Integer policyId) {
PolicyDto policyDto=insurePolicyMapper.getPolicyDetail(policyId); PolicyDto policyDto = insurePolicyMapper.getPolicyDetail(policyId);
if(policyDto==null){ if (policyDto == null) {
return ResultUtil.error("保单不存在"); return ResultUtil.error("保单不存在");
} }
return ResultUtil.data(policyDto); return ResultUtil.data(policyDto);
} }
@PostMapping(value = "/joinUser") @PostMapping(value = "/joinUser")
@ApiOperation(value = "5.增员", httpMethod = "Post", notes = "增员") @ApiOperation(value = "2.增员", httpMethod = "Post", notes = "增员")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public Result<Object> policyDetail(@RequestBody InsureDto insureDto) { public Result<Object> joinUser(@RequestBody InsureDto insureDto) throws ParseException {
InsurePolicy insurePolicy=InsurePolicy.builder().id(Integer.parseInt(insureDto.getId())).build().selectById();
if(insurePolicy==null){ InsurePolicy insurePolicy = InsurePolicy.builder().id(Integer.parseInt(insureDto.getId())).build().selectById();
if (insurePolicy == null) {
return ResultUtil.error("保单不存在"); return ResultUtil.error("保单不存在");
} }
Integer price = getPrice(insureDto.getBenefitBasicPlan(),insureDto.getBenefitOccupationCategory());
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String url = creaXSSFWorkbook1(insureDto.getUserIds()); String url = creaXSSFWorkbook1(insureDto.getUserIds(), insureDto.getPolicyDateStart(),price);
log.info("保全增员文件地址",url); log.info("保全增员文件地址", url);
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
Map bodyMap = Maps.newHashMap(); Map bodyMap = Maps.newHashMap();
bodyMap.put("contract_no",insurePolicy.getPolicyNo()); bodyMap.put("contract_no", insurePolicy.getPolicyNo());
bodyMap.put("order_status","1"); bodyMap.put("order_status", "1");
bodyMap.put("callback_plan",""); bodyMap.put("callback_plan", "");
bodyMap.put("file_url",url); bodyMap.put("file_url", url);
bodyMap.put("from_source","API"); bodyMap.put("from_source", "API");
bodyMap.put("import_review_callback",""); bodyMap.put("import_review_callback", "");
bodyMap.put("import_callback",""); bodyMap.put("import_callback", "http://vdr75zl.nat.ipyingshe.com/callBack/policy/CallBack");
bodyMap.put("third_uuid","BQ_"+insurePolicy.getOrgCode()+"_"+dtf2.format(now)); bodyMap.put("third_uuid", "IS_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now));
String data=HttpUtils.sendPost(batchUrl,setParams(JSONObject.toJSONString(bodyMap),appidq,secretq),bodyMap); String responData = HttpUtils.sendPost(batchUrl, setParams(JSONObject.toJSONString(bodyMap), appidq, secretq), bodyMap);
log.info("保全增员返回",data); Map<String, Object> dataMap = JSONObject.parseObject(responData);
return ResultUtil.data(""); 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 * @param ids
* @return * @return
*/ */
public String creaXSSFWorkbook1(String[] ids){ public String creaXSSFWorkbook1(String[] ids, String date,Integer price) {
if(ids.length<=0){ if (ids.length <= 0) {
return "error"; return "error";
} }
LocalDate localDate = LocalDate.now(); LocalDate localDate = LocalDate.now();
List<YgglMainEmp> ygglMainEmpList=ygglMainEmpMapper.selectListByIds(ids); List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(ids);
List list=Lists.newArrayList(); List list = Lists.newArrayList();
for (YgglMainEmp y:ygglMainEmpList) { for (YgglMainEmp y : ygglMainEmpList) {
String[] arr =new String[]{String.valueOf(y.getId()),y.getName(),"身份证",y.getZjNum(),"50万意外/5万医疗/扩展24小时(A类)","","深圳名邦人力资源管理有限公司","无","A类"}; String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), InsuranceEnum.getEnum(price).getName(), date, "深圳名邦人力资源管理有限公司", "无", InsuranceEnum.getEnum(price).getType()};
list.add(arr); 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 { try {
xssfWorkbook.write(byteArrayOutputStream); xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray(); byte[] bytes = byteArrayOutputStream.toByteArray();
String fileBase64= Base64.byteArrayToBase64(bytes); String fileBase64 = Base64.byteArrayToBase64(bytes);
/*body参数 begin*/ /*body参数 begin*/
Map bodyMap= Maps.newHashMap(); Map bodyMap = Maps.newHashMap();
bodyMap.put("media",fileBase64); bodyMap.put("media", fileBase64);
/*end*/ /*end*/
String data=HttpUtils.sendPost(uploadUrl2,setParams(JSONObject.toJSONString(bodyMap),appidq,secretq),bodyMap); String data = HttpUtils.sendPost(uploadUrl2, setParams(JSONObject.toJSONString(bodyMap), appidq, secretq), bodyMap);
Map<String,Object> dataMap = JSONObject.parseObject(data); 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")) { if (dataMap.get("errcode").toString().equals("suc")) {
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));
return map.get("file_url").toString(); return map.get("file_url").toString();
} }
/*文件流base64*/ /*文件流base64*/
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
try { try {
xssfWorkbook.close(); xssfWorkbook.close();
byteArrayOutputStream.close(); byteArrayOutputStream.close();
...@@ -475,8 +513,256 @@ public class InsureContorll { ...@@ -475,8 +513,256 @@ public class InsureContorll {
e.printStackTrace(); e.printStackTrace();
} }
} }
return "suc"; 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 { ...@@ -34,7 +34,7 @@ public class SuperLoginController {
@Autowired @Autowired
private HttpSession session; private HttpSession session;
@PostMapping(value = "/adminLogin") @PostMapping(value = "/adminLogin")
@ApiOperation(value = "运营后台登录", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "运营后台登录", httpMethod = "Post", notes = "接口发布说明")
public Result<Object> adminLogin(@RequestBody EntRegisterDto entRegisterDto, HttpServletRequest request){ public Result<Object> adminLogin(@RequestBody EntRegisterDto entRegisterDto, HttpServletRequest request){
String ip = UserIp.getIpAddr(request); String ip = UserIp.getIpAddr(request);
AdminAccount adminAccount = AdminAccount.builder().build().selectOne(new QueryWrapper<AdminAccount>().lambda() AdminAccount adminAccount = AdminAccount.builder().build().selectOne(new QueryWrapper<AdminAccount>().lambda()
...@@ -49,7 +49,7 @@ public class SuperLoginController { ...@@ -49,7 +49,7 @@ public class SuperLoginController {
return ResultUtil.data(adminAccount); return ResultUtil.data(adminAccount);
}; };
@PostMapping(value = "/adminOutLogin") @PostMapping(value = "/adminOutLogin")
@ApiOperation(value = "运营后台退出", httpMethod = "POST", notes = "接口发布说明") @ApiOperation(value = "运营后台退出", httpMethod = "Post", notes = "接口发布说明")
public Result<String> adminOutLogin(HttpServletRequest request){ public Result<String> adminOutLogin(HttpServletRequest request){
session= request.getSession(); session= request.getSession();
session.removeAttribute("ai"); session.removeAttribute("ai");
......
...@@ -2,7 +2,9 @@ package cn.timer.api.dao.insure; ...@@ -2,7 +2,9 @@ package cn.timer.api.dao.insure;
import cn.timer.api.bean.insure.InsurePolicy; import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.dto.insure.PolicyDto; import cn.timer.api.dto.insure.PolicyDto;
import cn.timer.api.utils.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -17,7 +19,8 @@ import java.util.List; ...@@ -17,7 +19,8 @@ import java.util.List;
*/ */
@Repository @Repository
public interface InsurePolicyMapper extends BaseMapper<InsurePolicy> { public interface InsurePolicyMapper extends BaseMapper<InsurePolicy> {
public List<PolicyDto> policyList(); public List<PolicyDto> policyList(@Param("page") Page page);
PolicyDto getPolicyDetail(@Param("id")Integer id); PolicyDto getPolicyDetail(@Param("id")Integer id);
Integer totalPolicy();
} }
package cn.timer.api.dao.insure; package cn.timer.api.dao.insure;
import cn.timer.api.bean.insure.InsureUser; 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.dto.insure.PolicyDto;
import cn.timer.api.utils.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
...@@ -16,6 +19,8 @@ import java.util.List; ...@@ -16,6 +19,8 @@ import java.util.List;
*/ */
@Repository @Repository
public interface InsureUserMapper extends BaseMapper<InsureUser> { 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; package cn.timer.api.dto.insure;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
...@@ -28,5 +29,7 @@ public class InsureDto { ...@@ -28,5 +29,7 @@ public class InsureDto {
private String benefitBasicPlan;/*方案名称*/ private String benefitBasicPlan;/*方案名称*/
private String benefitOccupationCategory; private String benefitOccupationCategory;
private String tricycleFrameNumber; private String tricycleFrameNumber;
private Integer type;/*类型 1是新增 3是替换*/
private String[] oldIds;
// private String // private String
} }
package cn.timer.api.dto.insure; package cn.timer.api.dto.insure;
import cn.timer.api.utils.Page;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
...@@ -31,5 +32,9 @@ public class PolicyDto { ...@@ -31,5 +32,9 @@ public class PolicyDto {
private String benefitBasicPlan; private String benefitBasicPlan;
private String price; private String price;
private String orgCode; private String orgCode;
private Page page;
private String policyFile;
private String benefitOccupationCategory;
private Integer userId;
} }
...@@ -259,44 +259,6 @@ ...@@ -259,44 +259,6 @@
</foreach> </foreach>
</insert> </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 id="deleteBatch">
delete from insure_applicant where id in delete from insure_applicant where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
......
...@@ -224,36 +224,6 @@ ...@@ -224,36 +224,6 @@
</insert> </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 id="deleteBatch">
delete from insure_policy where id in delete from insure_policy where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
...@@ -264,12 +234,20 @@ ...@@ -264,12 +234,20 @@
<select id="policyList" resultType="cn.timer.api.dto.insure.PolicyDto"> <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, 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, 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 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
GROUP BY ip.policy_no 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>
<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 id="getPolicyDetail" resultType="cn.timer.api.dto.insure.PolicyDto">
SELECT SELECT
...@@ -280,10 +258,11 @@ ...@@ -280,10 +258,11 @@
ip.policy_no as policyNo, ip.policy_no as policyNo,
ip.org_code as orgCode, ip.org_code as orgCode,
iu.insured_name as insuredName, iu.insured_name as insuredName,
iu.benefit_basic_plan as benefitBasicPlan iu.benefit_basic_plan as benefitBasicPlan,
iu.benefit_occupation_category as benefitOccupationCategory
FROM FROM
insure_policy ip 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 WHERE
ip.id = #{id} ip.id = #{id}
LIMIT 1 LIMIT 1
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
<result property="applicantEmployeeList" column="applicant_employee_list"/> <result property="applicantEmployeeList" column="applicant_employee_list"/>
<result property="policyDateStart" column="policy_date_start"/> <result property="policyDateStart" column="policy_date_start"/>
<result property="policyDateEnd" column="policy_date_end"/> <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> </resultMap>
<select id="queryObject" resultType="cn.timer.api.bean.insure.InsureUser"> <select id="queryObject" resultType="cn.timer.api.bean.insure.InsureUser">
...@@ -66,6 +69,8 @@ ...@@ -66,6 +69,8 @@
<if test="applicantEmployeeList != null and applicantEmployeeList != ''">AND `applicant_employee_list` = <if test="applicantEmployeeList != null and applicantEmployeeList != ''">AND `applicant_employee_list` =
#{applicantEmployeeList} #{applicantEmployeeList}
</if> </if>
<if test="insureStatus != null and insureStatus != ''">AND `insure_status` = #{insureStatus}</if>
<if test="policyId != null and policyId != ''">AND `policy_id` = #{policyId}</if>
</where> </where>
<choose> <choose>
<when test="sidx != null and sidx.trim() != ''"> <when test="sidx != null and sidx.trim() != ''">
...@@ -112,6 +117,8 @@ ...@@ -112,6 +117,8 @@
<if test="applicantEmployeeList != null and applicantEmployeeList != ''">AND `applicant_employee_list` = <if test="applicantEmployeeList != null and applicantEmployeeList != ''">AND `applicant_employee_list` =
#{applicantEmployeeList} #{applicantEmployeeList}
</if> </if>
<if test="insureStatus != null and insureStatus != ''">AND `insure_status` = #{insureStatus}</if>
<if test="policyId != null and policyId != ''">AND `policy_id` = #{policyId}</if>
</where> </where>
</select> </select>
...@@ -134,7 +141,9 @@ ...@@ -134,7 +141,9 @@
`type`, `type`,
`org_code`, `org_code`,
`user_id`, `user_id`,
`applicant_employee_list`) `applicant_employee_list`,
`insure_status`,
`policy_id`)
values (#{transId}, values (#{transId},
#{price}, #{price},
#{insuredName}, #{insuredName},
...@@ -152,7 +161,8 @@ ...@@ -152,7 +161,8 @@
#{type}, #{type},
#{orgCode}, #{orgCode},
#{userId}, #{userId},
#{applicantEmployeeList}) #{applicantEmployeeList},
#{policyId})
</insert> </insert>
<insert id="saveSelective" parameterType="cn.timer.api.bean.insure.InsureUser" useGeneratedKeys="true" <insert id="saveSelective" parameterType="cn.timer.api.bean.insure.InsureUser" useGeneratedKeys="true"
...@@ -177,6 +187,8 @@ ...@@ -177,6 +187,8 @@
<if test="orgCode != null">,`org_code`</if> <if test="orgCode != null">,`org_code`</if>
<if test="userId != null">,`user_id`</if> <if test="userId != null">,`user_id`</if>
<if test="applicantEmployeeList != null">,`applicant_employee_list`</if> <if test="applicantEmployeeList != null">,`applicant_employee_list`</if>
<if test="insureStatus != null">,`insure_status`</if>
<if test="policyId != null">,`policy_id`</if>
) )
values values
( (
...@@ -198,6 +210,8 @@ ...@@ -198,6 +210,8 @@
<if test="orgCode != null">,#{orgCode}</if> <if test="orgCode != null">,#{orgCode}</if>
<if test="userId != null">,#{userId}</if> <if test="userId != null">,#{userId}</if>
<if test="applicantEmployeeList != null">,#{applicantEmployeeList}</if> <if test="applicantEmployeeList != null">,#{applicantEmployeeList}</if>
<if test="insureStatus != null">,#{insureStatus}</if>
<if test="policyId != null">,#{policyId}</if>
) )
</insert> </insert>
...@@ -222,7 +236,9 @@ ...@@ -222,7 +236,9 @@
`type`, `type`,
`org_code`, `org_code`,
`user_id`, `user_id`,
`applicant_employee_list` `applicant_employee_list`,
`insure_status`,
`policy_id`
) )
values values
<foreach collection="list" item="item" index="index" separator=","> <foreach collection="list" item="item" index="index" separator=",">
...@@ -244,45 +260,14 @@ ...@@ -244,45 +260,14 @@
#{item.type}, #{item.type},
#{item.orgCode}, #{item.orgCode},
#{item.userId}, #{item.userId},
#{item.applicantEmployeeList} #{item.applicantEmployeeList},
#{item.insureStatus},
#{item.policyId}
) )
</foreach> </foreach>
</insert> </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 id="deleteBatch">
delete from insure_user where id in delete from insure_user where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
...@@ -292,13 +277,38 @@ ...@@ -292,13 +277,38 @@
<select id="selectPolicyList" resultType="cn.timer.api.dto.insure.PolicyDto"> <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, 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.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 yggl_main_emp yme on yme.id=iu.user_id
LEFT JOIN insure_policy ip on ip.policy_no=iu.policy_no LEFT JOIN insure_policy ip on ip.id=iu.policy_id
where yme.org_code = 3 where yme.org_code = 3 AND iu.insure_status=1
<if test="id !=null and id !=''"> <if test="id !=null and id !=''">
and ip.id=#{id} and ip.id=#{id}
</if> </if>
</select> </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> </mapper>
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
AND AND
a.job_status in (0,1,2) a.job_status in (0,1,2)
<if test="isInsure!=null and isInsure != ''"> <if test="isInsure!=null and isInsure != ''">
AND a.is_insure=#{isInsure} AND a.is_insure in (1,2)
</if> </if>
ORDER BY ORDER BY
emp_num DESC 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