Commit 2438b968 by 翁国栋

导入被保人员

parent 9c5fb399
......@@ -878,6 +878,7 @@ public class InsureContorll {
return ResultUtil.error("请上传文件");
}
List<YgglMainEmp> yg = Lists.newArrayList();
List<YgglMainEmp> selectUserList=Lists.newArrayList();
try {
XSSFWorkbook xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0);
......@@ -898,10 +899,10 @@ public class InsureContorll {
continue;
}
switch (ExcelUtils.getString(titleCell)) {
case "姓名":
case "姓名(必填)":
y.setName(Optional.ofNullable(ExcelUtils.getString(cell)).orElse(""));
break;
case "手机号":
case "手机号":
y.setPhone(Optional.ofNullable(ExcelUtils.getString(cell)).orElse(""));
break;
// case "性别":
......@@ -910,7 +911,7 @@ public class InsureContorll {
// case "证件类型":
// y.setZjType(Optional.ofNullable(ExcelUtils.getString(cell)).orElse(""));
// break;
case "证件号":
case "证件号(必填)":
String idNo = Optional.ofNullable(ExcelUtils.getString(cell)).orElse("");
if (Strings.isNullOrEmpty(idNo) && idNo.length() != 18) {
return ResultUtil.error(y.getName() + "身份证格式不正确");
......@@ -950,6 +951,7 @@ public class InsureContorll {
if (newList.size() > 0) {
newList.forEach(u -> u.insert());
}
selectUserList=ygglMainEmpMapper.selectListByIZjNum(yg.stream().map(YgglMainEmp::getZjNum).toArray(String[]::new),company.getId()).stream().filter(s->s.getIsInsure()==0).collect(Collectors.toList());
//假期规则初始化
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));
......@@ -957,19 +959,19 @@ public class InsureContorll {
} catch (IOException e) {
e.printStackTrace();
}
return ResultUtil.data("成功添加");
return ResultUtil.data(selectUserList,selectUserList.stream().filter(s->s.getIsInsure()==1).map(YgglMainEmp::getName).collect(Collectors.toList()).toString()+"已投过保");
}
@PostMapping(value = "/importPolicy")
@ApiOperation(value = "导入保单--运营后台", httpMethod = "POST", notes = "导入用户")
public Result<Object> importPolicy(@RequestParam("file") MultipartFile file,@RequestParam("productId") String productId) {
public Result<Object> importPolicy(@RequestParam("file") MultipartFile file, @RequestParam("productId") String productId) {
SimpleDateFormat dtf = new SimpleDateFormat("yyyyMMdd");
if (file.getSize() <= 0) {
return ResultUtil.error("请上传文件");
}
InsureProduct insureProduct = InsureProduct.builder().id(Integer.parseInt(productId)).build().selectById();
if(insureProduct == null){
if (insureProduct == null) {
return ResultUtil.error("产品不存在");
}
try {
......@@ -1076,28 +1078,30 @@ public class InsureContorll {
}
//TODO 验证保单的状态
long timestamp = System.currentTimeMillis() / 1000;
Map map = Maps.newHashMap();
map.put("pid",appid);
map.put("policy_no",policy.getPolicyNo());
map.put("sign",DigestUtils.md5Hex(appid + secret + timestamp));
map.put("timestamp",String.valueOf(timestamp));
Map map = Maps.newHashMap();
map.put("pid", appid);
map.put("policy_no", policy.getPolicyNo());
map.put("sign", DigestUtils.md5Hex(appid + secret + timestamp));
map.put("timestamp", String.valueOf(timestamp));
String data = HttpUtils.sendGet(policyDetailUrl, map);
Map returnMap = JSONObject.parseObject(data,Map.class);
if(returnMap.get("errcode").toString().equals("suc")){
Map returnMap = JSONObject.parseObject(data, Map.class);
if (returnMap.get("errcode").toString().equals("suc")) {
Map dataMap = JSONObject.parseObject(JSONObject.toJSONString(returnMap.get("data")), Map.class);
policy.setProductId(insureProduct.getId());
policy.setPolicyFile(dataMap.get("policy_file").toString());
policy.setStatus("1");
}else{
return ResultUtil.error("保单不存在,请检查保单号是否正确");
} else {
return ResultUtil.error("保单不存在,请检查保单号是否正确");
}
InsurePolicy oldPolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getPolicyNo, policy.getPolicyNo()));
if (oldPolicy == null) {
policy.setSchemeName(insureProduct.getName());
policy.setUpdateTime(new Date());
policy.insert();
} else {
oldPolicy.setPolicyFile(policy.getPolicyFile());
policy.setUpdateTime(new Date());
policy = oldPolicy;
policy.updateById();
}
......@@ -1111,16 +1115,16 @@ public class InsureContorll {
.eq(YgglMainEmp::getZjNum, insureUser.getInsuredNo())
.eq(YgglMainEmp::getOrgCode, insureUser.getOrgCode()));
if (ygglMainEmp != null) {
ygglMainEmp.setIsInsure(1);
insureUser.setInsuredMobile(ygglMainEmp.getPhone());
} else {
/*如果不存在员工就创建一名员工*/
ygglMainEmp=new YgglMainEmp();
ygglMainEmp = new YgglMainEmp();
ygglMainEmp.setName(insureUser.getInsuredEContact());
ygglMainEmp.setZjType(0);
ygglMainEmp.setZjNum(insureUser.getInsuredNo());
ygglMainEmp.setOrgCode(insureUser.getOrgCode());
}
ygglMainEmp.setIsInsure(1);
ygglMainEmp.insertOrUpdate();
insureUser.setInsuredName(company.getAttestName());
insureUser.setPolicyId(policy.getId());
......@@ -1137,4 +1141,105 @@ public class InsureContorll {
return ResultUtil.data("成功导入");
}
@PostMapping(value = "/importUserPolicy")
@ApiOperation(value = "导入被保人员--运营后台", httpMethod = "POST", notes = "导入用户")
public Result<Object> importUserPolicy(@RequestParam("file") MultipartFile file,@RequestParam("orgCode") Integer orgCode) {
if(file.getSize()<=0){
return ResultUtil.error("未上传文件");
}
if(orgCode==null){
return ResultUtil.error("企业不存在");
}
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(orgCode).build().selectById();
if(qyzxEntInfoM==null){
return ResultUtil.error("企业不存在");
}
XSSFWorkbook xw = null;
Map<String,String> map = Maps.newHashMap();
try {
xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0);
//默认第一行为标题行,i = 0
XSSFRow titleRow = sheetAt.getRow(0);
InsureUser user;
List<InsureUser> userList = Lists.newArrayList();
// 循环获取每一行数据
for (int i = 1; i < sheetAt.getPhysicalNumberOfRows(); i++) {
XSSFRow row = sheetAt.getRow(i);
user = InsureUser.builder().build();
// 读取每一格内容
for (int index = 0; index < row.getPhysicalNumberOfCells(); index++) {
XSSFCell titleCell = titleRow.getCell(index);
XSSFCell cell = row.getCell(index);
cell.setCellType(CellType.STRING);
switch (ExcelUtils.getString(titleCell)) {
case "被保人姓名(必填)":
if(StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))){
return ResultUtil.error("第"+i+"行第"+index+"列被保人姓名不能为空");
}
user.setInsuredEContact(ExcelUtils.getString(cell));
break;
case "被保人身份证(必填)":
if(StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))){
return ResultUtil.error("第"+i+"行第"+index+"列被保人身份证不能为空");
}
user.setInsuredNo(ExcelUtils.getString(cell));
break;
case "基础计划":
if(ExcelUtils.getString(cell).equals("30万意外/3万医疗/扩展24小时")){
user.setBenefitBasicPlan("36968");
}else if (ExcelUtils.getString(cell).equals("50万意外/5万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36969");
}else if (ExcelUtils.getString(cell).equals("80万意外/10万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36970");
}else if (ExcelUtils.getString(cell).equals("80万雇主/20万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36971");
}else if (ExcelUtils.getString(cell).equals("100万意外/10万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36972");
}else{
return ResultUtil.error("第"+i+"行第"+index+"基础计划不能为空");
}
break;
case "职业类型":
if (ExcelUtils.getString(cell).equals("A类")) {
user.setBenefitOccupationCategory("63119");
} else if (ExcelUtils.getString(cell).equals("B类")) {
user.setBenefitOccupationCategory("63120");
} else if (ExcelUtils.getString(cell).equals("C类")) {
user.setBenefitOccupationCategory("63121");
}
break;
case "二、三轮车车架号":
user.setTricycleFrameNumber(StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))==true?"无":ExcelUtils.getString(cell));
break;
}
}
userList.add(user);
}
YgglMainEmp y;
for(InsureUser iu:userList){
y = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getZjNum,iu.getInsuredNo())
.eq(YgglMainEmp::getName,iu.getInsuredEContact()).eq(YgglMainEmp::getOrgCode,qyzxEntInfoM.getId()));
if(y==null){
y = new YgglMainEmp();
y.setName(iu.getInsuredEContact());
y.setZjType(0);
y.setZjNum(iu.getInsuredNo());
y.setOrgCode(qyzxEntInfoM.getId());
y.setIsInsure(0);
y.insert();
}else{
if(y.getIsInsure()==1){
return ResultUtil.error(y.getName()+"已经投保");
}
}
iu.setOrgCode(qyzxEntInfoM.getId());
iu.setUserId(y.getId());
}
return ResultUtil.data(userList);
} catch (IOException e) {
e.printStackTrace();
}
return ResultUtil.error("导入失败");
}
}
......@@ -133,4 +133,6 @@ public interface YgglMainEmpMapper extends BaseMapper<YgglMainEmp> {
List<DepartmentStaffDto> DepartmentStaff(Integer orgcode,Integer upid);
List<YgglMainEmp> selectListByIds(@Param("array")String[] ids);
List<YgglMainEmp> selectListByIZjNum(@Param("array")String[] zjNum,@Param("orgCode") Integer orgCode);
}
......@@ -77,4 +77,7 @@ public class YgQueryDto extends Page {
@ApiModelProperty(value="是否已购买保险",example = "0")
private Integer isInsure;
@ApiModelProperty(value="证件号码 ",example="证件号码")
private String zjNum;
}
......@@ -241,7 +241,8 @@
a.job_status jobStatus,
a.head_url headUrl,
a.sex sex,
a.is_insure isInsure
a.is_insure isInsure,
a.zj_num zjNum
FROM
yggl_main_emp a
LEFT JOIN zzgl_bmgw_m b ON a.bmgw_id = b.id
......@@ -412,4 +413,13 @@
</foreach>
</select>
<select id="selectListByIZjNum" resultType="cn.timer.api.bean.yggl.YgglMainEmp">
SELECT
<include refid="Base_Column_List"/>
FROM yggl_main_emp
WHERE org_code = #{orgCode} and zj_num IN
<foreach item="zjnum" collection="array" open="(" separator="," close=")">
#{zjnum}
</foreach>
</select>
</mapper>
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