Commit 410f9f4f by 翁国栋

8小时运营后台--

批量导入员工
更改日志排序
parent 8bfd49f1
package cn.timer.api.controller.insure;
import cn.timer.api.bean.insure.*;
import cn.timer.api.bean.kqmk.KqglAssoLeaveEmployeeBalance;
import cn.timer.api.bean.kqmk.KqglAssoLeaveRules;
import cn.timer.api.bean.qyzx.QyzxEntInfoM;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.controller.insure.bean.ExcelBean;
import cn.timer.api.controller.insure.enums.InsuranceEnum;
import cn.timer.api.dao.insure.InsureLogMapper;
import cn.timer.api.dao.insure.InsurePolicyMapper;
......@@ -20,13 +21,15 @@ import com.alibaba.druid.util.Base64;
import com.aliyun.oss.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.beust.jcommander.internal.Lists;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
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.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.eclipse.jetty.util.StringUtil;
import org.slf4j.Logger;
......@@ -41,7 +44,6 @@ import java.io.*;
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;
......@@ -89,7 +91,7 @@ public class InsureContorll {
@Value("${insure.batchUrl}")
private String batchUrl;
private static SimpleDateFormat dtf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static SimpleDateFormat dtf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Autowired
private YgglMainEmpMapper ygglMainEmpMapper;
......@@ -131,7 +133,7 @@ public class InsureContorll {
@ApiOperation(value = "1.投保申请", httpMethod = "Post", notes = "投保申请")
public Result<Object> insured_add(@RequestBody InsureDto insureDto) throws ParseException {
InsureProduct insureProduct = InsureProduct.builder().id(Integer.parseInt(insureDto.getProductId())).build().selectById();
if(insureProduct==null){
if (insureProduct == null) {
return ResultUtil.error("产品不存在");
}
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(Integer.parseInt(insureDto.getOrgCode())).build().selectById(); // 企业信息
......@@ -142,9 +144,9 @@ public class InsureContorll {
ArrayList<Map> quotationsArry = new ArrayList<Map>();
bodyMap.put("is_ss", 0);
Map quotations = Maps.newHashMap();
insureDto.getPlans().forEach(i->{
i.setPrice(getPrice(i.getBenefitBasicPlan(),i.getBenefitOccupationCategory()));
insureDto.setTotalPrice(i.getPrice()*i.getUserIds().length+(insureDto.getTotalPrice()==null?0:insureDto.getTotalPrice()));
insureDto.getPlans().forEach(i -> {
i.setPrice(getPrice(i.getBenefitBasicPlan(), i.getBenefitOccupationCategory()));
insureDto.setTotalPrice(i.getPrice() * i.getUserIds().length + (insureDto.getTotalPrice() == null ? 0 : insureDto.getTotalPrice()));
});
quotations.put("trans_id", "MB_" + dtf2.format(now));/*报价请求流水号*/
quotations.put("applicant_type", "2");/*投保人类型:2-企业*/
......@@ -173,7 +175,7 @@ public class InsureContorll {
companyApplicantMap.put("applicant_e_mail", insureApplicant.getApplicantEMail());/*企业邮箱*/
companyApplicantMap.put("applicant_province_city", "21024");/*省市区*/
/*人员清单填被保人员*/
String url = creaXSSFWorkbook(insureDto.getPlans(),insureDto.getPolicyDateStart());
String url = creaXSSFWorkbook(insureDto.getPlans(), insureDto.getPolicyDateStart());
if (!StringUtil.isNotBlank(url)) {
return ResultUtil.error("文件错误");
}
......@@ -185,7 +187,7 @@ public class InsureContorll {
basicMap.put("partner_pid", "1231");/*分销商pid*/
basicMap.put("plan_code_id", insureProduct.getPlanCodeId());/*计划代码,选项值:61b85207b73d2ab09fb2959 (生产环境) 61b85207b73d2ab09fb2959 (沙箱环境)*/
basicMap.put("product_code_id", insureProduct.getProductCodeId());/*产品代码,选项值: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("channel", "");
basicMap.put("fee", "");
......@@ -203,21 +205,21 @@ public class InsureContorll {
/*被保人员 填被保企业信息*/
ArrayList<Map> insuredArray = new ArrayList<>();
insureDto.getPlans().forEach(p->{
Map insured = Maps.newHashMap();
insured.put("trans_id", "PI_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now)+"_"+UUID.randomUUID().toString().replace("-",""));
insured.put("price", p.getUserIds().length*p.getPrice());/*根据基础计划生成*/
insured.put("insured_applicant_relations", "36960");
insured.put("insured_mobile", insureApplicant.getApplicantEPhone());
insured.put("insured_e_contact", insureApplicant.getApplicantEContacts());
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", p.getBenefitBasicPlan());/*基础计划写死*/
insured.put("benefit_occupation_category", p.getBenefitOccupationCategory());
insured.put("benefit_EL_employee_number_t", p.getUserIds().length);
insuredArray.add(insured);
insureDto.getPlans().forEach(p -> {
Map insured = Maps.newHashMap();
insured.put("trans_id", "PI_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now) + "_" + UUID.randomUUID().toString().replace("-", ""));
insured.put("price", p.getUserIds().length * p.getPrice());/*根据基础计划生成*/
insured.put("insured_applicant_relations", "36960");
insured.put("insured_mobile", insureApplicant.getApplicantEPhone());
insured.put("insured_e_contact", insureApplicant.getApplicantEContacts());
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", p.getBenefitBasicPlan());/*基础计划写死*/
insured.put("benefit_occupation_category", p.getBenefitOccupationCategory());
insured.put("benefit_EL_employee_number_t", p.getUserIds().length);
insuredArray.add(insured);
});
quotations.put("insured", insuredArray);
quotations.put("file", Lists.newArrayList());
......@@ -263,53 +265,53 @@ public class InsureContorll {
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(1)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(JSONObject.toJSONString(dataMap)).requestPath(insuredUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).policyId(insurePolicy.getId()).fileUrl(url).build().insert();
for (PlansDto p:insureDto.getPlans()) {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(p.getUserIds());
InsureUser insureUser;
for (YgglMainEmp y : ygglMainEmpList) {
insureUser = InsureUser.builder().build();
insureUser.setUserId(y.getId());
insureUser.setInsuredName(qyzxEntInfoM.getName());
insureUser.setPrice(String.valueOf(p.getPrice()));/*前端获取的保费*/
insureUser.setTransId("P_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now));
insureUser.setPremium(String.valueOf(insureDto.getTotalPrice()));
if (dataMap.get("errcode").toString().equals("suc")) {
insureUser.setBatchNo(batchMap.get(0).get("batch_no").toString());
insureUser.setPolicyNo(policyMap.get("policy_no").toString());
}
insureUser.setBenefitBasicPlan(p.getBenefitBasicPlan());
insureUser.setUserId(y.getId());
insureUser.setOrgCode(y.getOrgCode());
insureUser.setBenefitOccupationCategory(p.getBenefitOccupationCategory());
insureUser.setInsuredMobile(y.getPhone());
insureUser.setInsuredNo(y.getZjNum());
insureUser.setInsuredEContact(y.getName());
insureUser.setApplicantEmployeeList(url);
insureUser.setTricycleFrameNumber(p.getTricycleFrameNumber());
if (dataMap.get("errcode").toString().equals("suc")) {
insureUser.setInsureStatus(1);
insureUser.setStatus("1");
} else {
insureUser.setInsureStatus(3);
insureUser.setStatus("2");
}
insureUser.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insureUser.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insureUser.setApplyType(2);//投保类型
insureUser.setPolicyId(insurePolicy.getId());
insureUser.insert();
if (dataMap.get("errcode").toString().equals("suc")) {
y.setIsInsure(1);
y.insertOrUpdate();
}
for (PlansDto p : insureDto.getPlans()) {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(p.getUserIds());
InsureUser insureUser;
for (YgglMainEmp y : ygglMainEmpList) {
insureUser = InsureUser.builder().build();
insureUser.setUserId(y.getId());
insureUser.setInsuredName(qyzxEntInfoM.getName());
insureUser.setPrice(String.valueOf(p.getPrice()));/*前端获取的保费*/
insureUser.setTransId("P_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now));
insureUser.setPremium(String.valueOf(insureDto.getTotalPrice()));
if (dataMap.get("errcode").toString().equals("suc")) {
insureUser.setBatchNo(batchMap.get(0).get("batch_no").toString());
insureUser.setPolicyNo(policyMap.get("policy_no").toString());
}
insureUser.setBenefitBasicPlan(p.getBenefitBasicPlan());
insureUser.setUserId(y.getId());
insureUser.setOrgCode(y.getOrgCode());
insureUser.setBenefitOccupationCategory(p.getBenefitOccupationCategory());
insureUser.setInsuredMobile(y.getPhone());
insureUser.setInsuredNo(y.getZjNum());
insureUser.setInsuredEContact(y.getName());
insureUser.setApplicantEmployeeList(url);
insureUser.setTricycleFrameNumber(p.getTricycleFrameNumber());
if (dataMap.get("errcode").toString().equals("suc")) {
insureUser.setInsureStatus(1);
insureUser.setStatus("1");
} else {
insureUser.setInsureStatus(3);
insureUser.setStatus("2");
}
insureUser.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insureUser.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insureUser.setApplyType(2);//投保类型
insureUser.setPolicyId(insurePolicy.getId());
insureUser.insert();
if (dataMap.get("errcode").toString().equals("suc")) {
y.setIsInsure(1);
y.insertOrUpdate();
}
}
}
return ResultUtil.success(dataMap.get("errmsg").toString());
}
return ResultUtil.error(dataMap.get("errmsg").toString());
}
return ResultUtil.error("网络异常");
return ResultUtil.error("网络异常");
}
......@@ -326,10 +328,10 @@ public class InsureContorll {
LocalDate localDate = LocalDate.now();
Date date = new Date();
List list = Lists.newArrayList();
plansList.forEach(p->{
plansList.forEach(p -> {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(p.getUserIds());
for (YgglMainEmp y : ygglMainEmpList) {
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), InsuranceEnum.getEnum(p.getBenefitBasicPlan(),p.getBenefitOccupationCategory()).getName(), createDate, "深圳名邦人力资源管理有限公司", StringUtils.isNullOrEmpty(p.getTricycleFrameNumber())?"无":p.getTricycleFrameNumber(), InsuranceEnum.getEnum(p.getBenefitBasicPlan(),p.getBenefitOccupationCategory()).getType()};
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), InsuranceEnum.getEnum(p.getBenefitBasicPlan(), p.getBenefitOccupationCategory()).getName(), createDate, "深圳名邦人力资源管理有限公司", StringUtils.isNullOrEmpty(p.getTricycleFrameNumber()) ? "无" : p.getTricycleFrameNumber(), InsuranceEnum.getEnum(p.getBenefitBasicPlan(), p.getBenefitOccupationCategory()).getType()};
list.add(arr);
}
});
......@@ -355,7 +357,7 @@ public class InsureContorll {
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
url=map.get("url").toString();
url = map.get("url").toString();
}
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)
......@@ -377,7 +379,6 @@ public class InsureContorll {
}
@PostMapping(value = "/policyListAdmin")
@ApiOperation(value = "4.保单列表--运营后台端", httpMethod = "Post", notes = "保单列表--运营后台端")
public Result<Object> policyListAdmin(@RequestBody PolicyDto policyDto) {
......@@ -414,7 +415,7 @@ public class InsureContorll {
if (insurePolicy == null) {
return ResultUtil.error("保单不存在");
}
LocalDateTime now = LocalDateTime.now();
LocalDateTime now = LocalDateTime.now();
String url = creaXSSFWorkbook1(insureDto);
log.info("保全增员文件地址", url);
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
......@@ -425,7 +426,7 @@ public class InsureContorll {
bodyMap.put("file_url", url);
bodyMap.put("from_source", "API");
bodyMap.put("import_review_callback", "");
bodyMap.put("import_callback", base_api_url+"/callBack/policy/CallBack");
bodyMap.put("import_callback", base_api_url + "/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);
......@@ -439,36 +440,36 @@ public class InsureContorll {
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).policyId(insurePolicy.getId()).transId("IS_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now)).fileUrl(data.get("file_url").toString()).build().insert();
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(String.valueOf(InsuranceEnum.getEnum(insureDto.getBenefitBasicPlan(),insureDto.getBenefitOccupationCategory()).getPrice()))/*前端获取的保费*/
.premium(String.valueOf(InsuranceEnum.getEnum(insureDto.getBenefitBasicPlan(),insureDto.getBenefitOccupationCategory()).getPrice()*insureDto.getUserIds().length))
.batchNo(data.get("import_uuid").toString())
.benefitBasicPlan(insureDto.getBenefitBasicPlan())
.policyNo(orderImportInfo.get("contract_no").toString())
.userId(y.getId())
.orgCode(y.getOrgCode())
.insuredMobile(y.getPhone())
.benefitOccupationCategory(insureDto.getBenefitOccupationCategory())
.insuredNo(y.getZjNum())
.tricycleFrameNumber(insureDto.getTricycleFrameNumber())
.insuredEContact(y.getName())
.applyType(1)
.applicantEmployeeList(data.get("file_url").toString())
.policyDateStart(dtf3.parse(insureDto.getPolicyDateStart()))
.policyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()))
.insureStatus(3).policyId(insurePolicy.getId()).build().insert();
} catch (ParseException e) {
e.printStackTrace();
}
y.setIsInsure(1);
y.insertOrUpdate();
});
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(String.valueOf(InsuranceEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getPrice()))/*前端获取的保费*/
.premium(String.valueOf(InsuranceEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getPrice() * insureDto.getUserIds().length))
.batchNo(data.get("import_uuid").toString())
.benefitBasicPlan(insureDto.getBenefitBasicPlan())
.policyNo(orderImportInfo.get("contract_no").toString())
.userId(y.getId())
.orgCode(y.getOrgCode())
.insuredMobile(y.getPhone())
.benefitOccupationCategory(insureDto.getBenefitOccupationCategory())
.insuredNo(y.getZjNum())
.tricycleFrameNumber(insureDto.getTricycleFrameNumber())
.insuredEContact(y.getName())
.applyType(1)
.applicantEmployeeList(data.get("file_url").toString())
.policyDateStart(dtf3.parse(insureDto.getPolicyDateStart()))
.policyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()))
.insureStatus(3).policyId(insurePolicy.getId()).build().insert();
} catch (ParseException e) {
e.printStackTrace();
}
y.setIsInsure(1);
y.insertOrUpdate();
});
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()).policyId(insurePolicy.getId()).fileUrl(url).build().insert();
......@@ -495,15 +496,15 @@ public class InsureContorll {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds());
List list = Lists.newArrayList();
for (YgglMainEmp y : ygglMainEmpList) {
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), InsuranceEnum.getEnum(insureDto.getBenefitBasicPlan(),insureDto.getBenefitOccupationCategory()).getName(), insureDto.getPolicyDateStart(), "深圳名邦人力资源管理有限公司", StringUtils.isNullOrEmpty(insureDto.getTricycleFrameNumber())?"无":insureDto.getTricycleFrameNumber(), InsuranceEnum.getEnum(insureDto.getBenefitBasicPlan(),insureDto.getBenefitOccupationCategory()).getType()};
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), InsuranceEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getName(), insureDto.getPolicyDateStart(), "深圳名邦人力资源管理有限公司", StringUtils.isNullOrEmpty(insureDto.getTricycleFrameNumber()) ? "无" : insureDto.getTricycleFrameNumber(), InsuranceEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getType()};
list.add(arr);
}
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Scheme_name", "Date_start", "Branch", "Tricycle_frame_number", "benefit_occupation_category"};
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel( localDate + "_补充" + list.size() + "名人员清单.xlsx", rowName, list);
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel(localDate + "_补充" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String url="";
String url = "";
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
......@@ -518,7 +519,7 @@ public class InsureContorll {
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
url= map.get("file_url").toString();
url = map.get("file_url").toString();
}
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)
......@@ -541,14 +542,14 @@ public class InsureContorll {
@ApiOperation(value = "7.下载电子保单", httpMethod = "Get", notes = "下载电子保单")
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())){
if (insurePolicy == null || StringUtils.isNullOrEmpty(insurePolicy.getPolicyFile())) {
return;
}
OutputStream sos = null;
BufferedInputStream bis = null;
try {
response.setContentType("application/octet-stream");
response.setHeader("content-disposition", "attachment; filename=" + new String((insurePolicy.getPolicyNo()+".pdf").getBytes("UTF8"), "ISO-8859-1"));
response.setHeader("content-disposition", "attachment; filename=" + new String((insurePolicy.getPolicyNo() + ".pdf").getBytes("UTF8"), "ISO-8859-1"));
response.setCharacterEncoding("UTF-8");
sos = response.getOutputStream();
String destUrl = insurePolicy.getPolicyFile();
......@@ -588,13 +589,13 @@ public class InsureContorll {
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();
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());
Integer price = getPrice(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory());
LocalDateTime now = LocalDateTime.now();
String url = creaXSSFWorkbook2(insureDto.getUserIds(), insureDto.getPolicyDateStart(),oldUser,insureDto.getBenefitOccupationCategory(),insureDto.getTricycleFrameNumber());
String url = creaXSSFWorkbook2(insureDto.getUserIds(), insureDto.getPolicyDateStart(), oldUser, insureDto.getBenefitOccupationCategory(), insureDto.getTricycleFrameNumber());
log.info("保全替换文件地址", url);
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
Map bodyMap = Maps.newHashMap();
......@@ -604,7 +605,7 @@ public class InsureContorll {
bodyMap.put("file_url", url);
bodyMap.put("from_source", "API");
bodyMap.put("import_review_callback", "");
bodyMap.put("import_callback", base_api_url+"/callBack/policy/CallBack");
bodyMap.put("import_callback", base_api_url + "/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);
......@@ -653,7 +654,7 @@ public class InsureContorll {
y.setIsInsure(1);
y.insertOrUpdate();
});
oldInsureUserList.forEach(o->{
oldInsureUserList.forEach(o -> {
o.setReplaceTransId(data.get("import_uuid").toString());
o.updateById();
});
......@@ -663,43 +664,44 @@ public class InsureContorll {
}
return ResultUtil.data("成功");
}
/**
* 生成保全替换文件
*
* @param ids
* @return
*/
public String creaXSSFWorkbook2(String[] ids,String date,String[] oldIds,String type,String tricycleFrameNumber) {
if (ids.length <= 0||oldIds.length<=0) {
public String creaXSSFWorkbook2(String[] ids, String date, String[] oldIds, String type, String tricycleFrameNumber) {
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()){
if (newList.size() != oldList.size()) {
return "error";
}
List list = Lists.newArrayList();
for (int i=0;i<newList.size();i++) {
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),
date.substring(0, 10),
newList.get(i).getName(),
"身份证",
newList.get(i).getZjNum(),
"","","","","","",StringUtils.isNullOrEmpty(tricycleFrameNumber)?"无":tricycleFrameNumber,"1",type.equals("63119")?"A类":type.equals("63120")?"B类":"C类"};
"", "", "", "", "", "", StringUtils.isNullOrEmpty(tricycleFrameNumber) ? "无" : tricycleFrameNumber, "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"};
"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);
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel(localDate + "_替换" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String url="";
String url = "";
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
......@@ -715,7 +717,7 @@ public class InsureContorll {
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
url= map.get("file_url").toString();
url = map.get("file_url").toString();
}
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)
......@@ -733,8 +735,9 @@ public class InsureContorll {
}
return url;
}
/*获取基础计划的价格*/
private Integer getPrice(String plan,String type){
private Integer getPrice(String plan, String type) {
/*
基础计划
30万雇主/3万医疗 36968,
......@@ -744,53 +747,54 @@ public class InsureContorll {
100万雇主/10万医疗 36972
*/
/*行业类型
* A类 63119
* B类 63120
* C类 63121\
* */
switch (plan){
* A类 63119
* B类 63120
* C类 63121\
* */
switch (plan) {
case "36968":
if(type.equals("63119")){
if (type.equals("63119")) {
return InsuranceEnum.A_30.getPrice();
}else if(type.equals("63120")){
} else if (type.equals("63120")) {
return InsuranceEnum.B_30.getPrice();
}
break;
case"36969":
if(type.equals("63119")){
case "36969":
if (type.equals("63119")) {
return InsuranceEnum.A_30.getPrice();
}else if(type.equals("63120")){
} else if (type.equals("63120")) {
return InsuranceEnum.B_50.getPrice();
}else if(type.equals("63121")){
} else if (type.equals("63121")) {
return InsuranceEnum.C_50.getPrice();
}
break;
case "36970":
if(type.equals("63119")){
if (type.equals("63119")) {
return InsuranceEnum.A_80.getPrice();
}else if(type.equals("63120")){
} else if (type.equals("63120")) {
return InsuranceEnum.B_80.getPrice();
}else if(type.equals("63121")){
} else if (type.equals("63121")) {
return InsuranceEnum.C_80.getPrice();
}
break;
case "36971":
if(type.equals("63119")){
if (type.equals("63119")) {
return InsuranceEnum.A_80_20.getPrice();
}else if(type.equals("63120")){
} else if (type.equals("63120")) {
return InsuranceEnum.B_80_20.getPrice();
}
break;
case "36972":
if(type.equals("63119")){
if (type.equals("63119")) {
return InsuranceEnum.A_100.getPrice();
}else if(type.equals("63120")){
} else if (type.equals("63120")) {
return InsuranceEnum.B_100.getPrice();
}
break;
}
return 0;
}
@PostMapping(value = "/policyTotal")
@ApiOperation(value = "11.保单统计列表", httpMethod = "Post", notes = "保单统计列表")
public Result<Object> policyTotal() {
......@@ -800,10 +804,10 @@ public class InsureContorll {
@GetMapping(value = "/isInsured")
@ApiOperation(value = "10.企业是否已投保", httpMethod = "Post", notes = "企业是否已投保")
public Result<Object> isInsured(@RequestParam("orgCode")String orgCode) {
InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getOrgCode,orgCode).eq(InsurePolicy::getStatus,1));
if(insurePolicy!=null){
return ResultUtil.error("该企业已经投过保,保单号为"+insurePolicy.getPolicyNo());
public Result<Object> isInsured(@RequestParam("orgCode") String orgCode) {
InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getOrgCode, orgCode).eq(InsurePolicy::getStatus, 1));
if (insurePolicy != null) {
return ResultUtil.error("该企业已经投过保,保单号为" + insurePolicy.getPolicyNo());
}
return ResultUtil.success();
}
......@@ -812,12 +816,12 @@ public class InsureContorll {
@ApiOperation(value = "一键校验", httpMethod = "Post", notes = "一键校验")
public Result<Object> verification() {
/*校验投保*/
List<InsurePolicy> insurePolicies = InsurePolicy.builder().build().selectList(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getStatus,2));
insurePolicies.forEach(i->{
InsureLog insureLog = InsureLog.builder().build().selectOne(new QueryWrapper<InsureLog>().lambda().eq(InsureLog::getPolicyId,i.getId()).eq(InsureLog::getType,1));
List<InsurePolicy> insurePolicies = InsurePolicy.builder().build().selectList(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getStatus, 2));
insurePolicies.forEach(i -> {
InsureLog insureLog = InsureLog.builder().build().selectOne(new QueryWrapper<InsureLog>().lambda().eq(InsureLog::getPolicyId, i.getId()).eq(InsureLog::getType, 1));
Map bodyMap = JSONObject.parseObject(insureLog.getRequestData(), Map.class);
String data = HttpUtils.sendPost(insuredUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret),bodyMap );
log.info("校验结果:{}",data);
String data = HttpUtils.sendPost(insuredUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
log.info("校验结果:{}", data);
Map dataMap = JSONObject.parseObject(data, Map.class);
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(9)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(JSONObject.toJSONString(dataMap)).requestPath(insuredUrl)
......@@ -833,9 +837,9 @@ public class InsureContorll {
i.updateById();
/*批次信息*/
List<Map> batchMap = JSONObject.parseObject(JSONObject.toJSONString(policyMap.get("batch")), List.class);
List<InsureUser> insureUserList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getPolicyId,i.getId())
.eq(InsureUser::getApplyType,2));
insureUserList.forEach(user->{
List<InsureUser> insureUserList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getPolicyId, i.getId())
.eq(InsureUser::getApplyType, 2));
insureUserList.forEach(user -> {
user.setBatchNo(batchMap.get(0).get("batch_no").toString());
user.setPolicyNo(policyMap.get("policy_no").toString());
user.setInsureStatus(1);
......@@ -845,20 +849,116 @@ public class InsureContorll {
});
}
}
}
});
/*校验人员*/
return ResultUtil.success();
};
}
;
@PostMapping(value = "/policyTotalList")
@ApiOperation(value = "11.保单统计列表 -- 8小时端", httpMethod = "Post", notes = "保单统计列表")
public Result<Object> policyTotal(@CurrentUser UserBean userBean,@RequestBody Page page) {
public Result<Object> policyTotal(@CurrentUser UserBean userBean, @RequestBody Page page) {
List<InsureUserDto> list = insurePolicyMapper.selectPlansListByorgCode(userBean.getOrgCode());
return ResultUtil.data(list);
}
@PostMapping(value = "/importUser")
@ApiOperation(value = "导入用户--8小时端", httpMethod = "post", notes = "导入用户")
public Result<Object> importUser(@RequestParam("orgCode") String orgCode, @RequestParam("file") MultipartFile file) {
SimpleDateFormat dtf = new SimpleDateFormat("yyyyMMdd");
QyzxEntInfoM company = QyzxEntInfoM.builder().id(Integer.valueOf(orgCode)).build().selectById();
if (company == null) {
return ResultUtil.error("该企业不存在");
}
if (file.getSize() <= 0) {
return ResultUtil.error("请上传文件");
}
List<YgglMainEmp> yg = Lists.newArrayList();
try {
XSSFWorkbook xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0);
//默认第一行为标题行,i = 0
XSSFRow titleRow = sheetAt.getRow(0);
YgglMainEmp y;
// 循环获取每一行数据
for (int i = 1; i < sheetAt.getPhysicalNumberOfRows(); i++) {
XSSFRow row = sheetAt.getRow(i);
y = YgglMainEmp.builder().build();
y.setOrgCode(Integer.parseInt(orgCode));
// 读取每一格内容
for (int index = 0; index < row.getPhysicalNumberOfCells(); index++) {
XSSFCell titleCell = titleRow.getCell(index);
XSSFCell cell = row.getCell(index);
cell.setCellType(CellType.STRING);
if (cell.getStringCellValue().equals("")) {
continue;
}
switch (ExcelUtils.getString(titleCell)) {
case "姓名":
y.setName(Optional.ofNullable(ExcelUtils.getString(cell)).orElse(""));
break;
case "手机号码":
y.setPhone(Optional.ofNullable(ExcelUtils.getString(cell)).orElse(""));
break;
// case "性别":
// y.setSex(Optional.ofNullable(ExcelUtils.getString(cell)).orElse(""));
// break;
// case "证件类型":
// y.setZjType(Optional.ofNullable(ExcelUtils.getString(cell)).orElse(""));
// break;
case "证件号":
String idNo = Optional.ofNullable(ExcelUtils.getString(cell)).orElse("");
if (Strings.isNullOrEmpty(idNo) && idNo.length() != 18) {
return ResultUtil.error(y.getName()+"身份证格式不正确");
}
if(!idNo.matches("^(\\d{6})(\\d{4})(\\d{2})(\\d{2})(\\d{3})([0-9]|X)$")) {
return ResultUtil.error(y.getName()+"身份证格式不正确");
}
try {
y.setBirthday(dtf.parse(idNo.substring(6,14)));
} catch (ParseException e) {
e.printStackTrace();
}
y.setZjNum(idNo);
break;
// case "工作性质":
// y.setJobType(Optional.ofNullable(ExcelUtils.getString(cell)).orElse(""));
// break;
// case "试用期":
// y.setSyq(Optional.ofNullable(ExcelUtils.getString(cell)).orElse(""));
// break;
// case "入职日期":
// y.setRzTime(Optional.ofNullable(ExcelUtils.getString(cell)).orElse(""));
// break;
default:
break;
}
}
if (StringUtils.isNullOrEmpty(y.getName())||StringUtils.isNullOrEmpty(y.getZjNum())) {
continue;
}
yg.add(y);
}
List<YgglMainEmp> userList = YgglMainEmp.builder().build().selectList(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, orgCode));
List<String> idNumList=userList.stream().map(YgglMainEmp::getZjNum).collect(Collectors.toList());
List<YgglMainEmp> newList= yg.stream().filter(v->!idNumList.contains(v.getZjNum())).collect(Collectors.toList());
if(newList.size()>0) {
newList.forEach(u -> u.insert());
}
//假期规则初始化
String current_time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
List<KqglAssoLeaveRules> rul = KqglAssoLeaveRules.builder().build().selectList(new QueryWrapper<KqglAssoLeaveRules>().lambda().eq(KqglAssoLeaveRules::getOrgCode, orgCode));
} catch (IOException e) {
e.printStackTrace();
}
return ResultUtil.data("成功添加");
}
}
......@@ -14,9 +14,11 @@ import java.util.Map;
import cn.timer.api.bean.insure.InsureLog;
import cn.timer.api.bean.insure.InsureProduct;
import cn.timer.api.bean.qyzx.QyzxEntInfoM;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.dao.insure.InsureLogMapper;
import cn.timer.api.dto.insure.InsureDto;
import cn.timer.api.dto.insure.PolicyLogDto;
import cn.timer.api.utils.Page;
import cn.timer.api.utils.Result;
......@@ -27,11 +29,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -114,4 +118,5 @@ public class InsureLogController {
return ResultUtil.data(map);
}
}
......@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
......@@ -19,7 +20,7 @@ import java.util.List;
@AllArgsConstructor
public class InsureDto {
private String id;
private String orgCode;/*劳动合同*/
private String orgCode;/*企业id*/
private String companyName;/*用工单位实际工作单位*/
private String policyDateStart;
private String policyDateEnd;
......@@ -32,6 +33,7 @@ public class InsureDto {
private String[] oldIds;
private String[] userIds;
private Double totalPrice;
private MultipartFile file;
// private String
}
......@@ -41,27 +41,25 @@ public class ExcelUtils {
* @param sheetNum 开始解析的sheet序号,如果不指定,默认传值为-1,则会解析所有sheet
* @return
*/
public static List<List<Map<String, Object>>> importExcel(String filePath, int startRow, int startCol, int sheetNum) {
public static List<List<Map<String, Object>>> importExcel(XSSFWorkbook workbook, int startRow, int startCol, int sheetNum) {
logger.info("========================= ExcelUtils.java ->> importExcel()从Excel表格中获取数据 ->> 开始 =========================");
// 用于存储最终整个Excel表格的数据
// // 用于存储最终整个Excel表格的数据
List<List<Map<String, Object>>> resultList = new ArrayList<>();
// 得到指定路径的文件File对象
File file = new File(filePath);
// 如果不存在
if (!file.exists()) {
logger.info("ExcelUtils.java ->> importExcel() ->> 错误操作:要读取Excel文件在指定路径(" + filePath + ")下找不到");
throw new RuntimeException("错误操作:要读取Excel文件在指定路径(" + filePath + ")下找不到");
}
//
// // 得到指定路径的文件File对象
// File file = new File(filePath);
// // 如果不存在
// if (!file.exists()) {
// logger.info("ExcelUtils.java ->> importExcel() ->> 错误操作:要读取Excel文件在指定路径(" + filePath + ")下找不到");
// throw new RuntimeException("错误操作:要读取Excel文件在指定路径(" + filePath + ")下找不到");
// }
InputStream input = null;
Workbook workbook = null;
try {
// 得到文件的资源输入流
input = new FileInputStream(file);
// input = new FileInputStream(file);
// 得到处理excel的Workbook对象
workbook = ExcelUtils.getWorkbookByExtensionName(input, filePath);
// 创建一个公式计算器,用于计算并得到Excel中的公式结果
FormulaEvaluator formulaEvaluator = workbook.getCreationHelper().createFormulaEvaluator();
......@@ -491,6 +489,23 @@ public class ExcelUtils {
// 设置垂直对齐的样式为居中对齐
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
}
/**
* 把单元格的内容转为字符串
*
* @param xssfCell 单元格
* @return String
*/
public static String getString(XSSFCell xssfCell) {
if (xssfCell == null) {
return "";
}
if (xssfCell.getCellTypeEnum() == CellType.NUMERIC) {
return String.valueOf(xssfCell.getNumericCellValue());
} else if (xssfCell.getCellTypeEnum() == CellType.BOOLEAN) {
return String.valueOf(xssfCell.getBooleanCellValue());
} else {
return xssfCell.getStringCellValue();
}
}
}
......@@ -187,7 +187,8 @@
<select id="selectLogListByOrgCode" resultType="cn.timer.api.dto.insure.PolicyLogDto">
select ip.policy_no as policyNo,il.return_code as returnCode,il.return_msg as returnMsg,il.type as type,il.create_time as createTime from insure_log il
LEFT JOIN insure_policy ip on ip.id=il.policy_id
WHERE ip.org_code = #{orgCode}
WHERE ip.org_code = #{orgCode
order by ip.create_time
<if test="page.currentPage != null and page.totalPage != null">
limit #{page.offset}, #{page.totalPage}
</if>
......
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