Commit 08df2c37 by 翁国栋

8小时后台--

修改投保条件为不同月份可重复投递一个人
parent c5a0d90b
......@@ -10,7 +10,7 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Transient;
import javax.persistence.Transient;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
......@@ -167,4 +167,9 @@ public class InsureUser extends Model<InsureUser> {
@TableField(exist = false)
@ApiModelProperty(value = "导入备注")
private String remake;
@Transient
@TableField(exist = false)
@ApiModelProperty(value="新被保人",example="新被保人")
private InsureUser replaceUser;
}
......@@ -170,9 +170,22 @@ public class InsureContorll {
if (qyzxEntInfoM == null) {
return ResultUtil.error("企业不存在");
}
try {
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
DateTimeFormatter ym = DateTimeFormatter.ofPattern("yyyy-MM");
LocalDateTime now = LocalDateTime.now();
/*投保前验证人员当月是否已投保*/
for (PlansDto p : insureDto.getPlans()) {
List<InsureUser> insureUserList = insureUserMapper.selectListByIds(p.getUserIds(), null, insureDto.getPolicyDateStart().substring(0, 7));
if (insureUserList.size() > 0) {
String name = "";
for (InsureUser insureUser : insureUserList) {
name+=insureUser.getInsuredEContact()+',';
}
return ResultUtil.error("被保人"+name+"当月已投保");
}
}
Date date = Date.from(now.atZone(ZoneId.systemDefault()).toInstant());
Map bodyMap = Maps.newHashMap();
ArrayList<Map> quotationsArry = new ArrayList<Map>();
......@@ -564,7 +577,7 @@ public class InsureContorll {
insureDto.setUserIds(new String[]{String.valueOf(y.getId())});
}
}
List<InsureUser> oldInsureUserList = insureUserMapper.selectListByIds(insureDto.getOldIds());
List<InsureUser> oldInsureUserList = insureUserMapper.selectListByIds(insureDto.getOldIds(),insurePolicy.getId(),null);
String[] oldUser = new String[oldInsureUserList.size()];
for (int i = 0; i < oldInsureUserList.size(); i++) {
oldUser[i] = oldInsureUserList.get(i).getUserId().toString();
......@@ -1225,6 +1238,9 @@ public class InsureContorll {
@ApiOperation(value = "15.导入被保人员--运营后台", httpMethod = "POST", notes = "导入用户")
@Transactional(rollbackFor = Exception.class)
public Result<Object> importUserPolicy(@RequestParam("file") MultipartFile file, @RequestParam("orgCode") Integer orgCode) {
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
/*当前年月*/
if (file.getSize() <= 0) {
return ResultUtil.error("未上传文件");
}
......@@ -1310,7 +1326,7 @@ public class InsureContorll {
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) {
QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().pw(Md5.md5(pwd)).phone(String.valueOf(System.currentTimeMillis())).regTime(new Date()).orgId(qyzxEntInfoM.getId()).username(iu.getInsuredEContact()).sts(CommonEnum.U_STS_ON.getType()).build();
QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().pw(Md5.md5(pwd)).phone(String.valueOf(System.currentTimeMillis())).regTime(now).orgId(qyzxEntInfoM.getId()).username(iu.getInsuredEContact()).sts(CommonEnum.U_STS_ON.getType()).build();
qyzxEmpLogin.insert();
y = new YgglMainEmp();
y.setEmpNum(qyzxEmpLogin.getId());
......@@ -1320,10 +1336,6 @@ public class InsureContorll {
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());
......@@ -1554,7 +1566,7 @@ public class InsureContorll {
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
url = map.get("file_url").toString();
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(5)
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appidq, secretq))).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()).fileUrl(url).build().insert();
/*文件流base64*/
......@@ -1617,7 +1629,7 @@ public class InsureContorll {
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
url = map.get("file_url").toString();
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(6)
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appidq, secretq))).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()).fileUrl(url).build().insert();
/*文件流base64*/
......@@ -1687,103 +1699,158 @@ public class InsureContorll {
}
// @PostMapping(value = "/replaceUserPolicy")
// @ApiOperation(value = "18.导入替换人员", httpMethod = "POST", notes = "导入用户")
// @Transactional(rollbackFor = Exception.class)
// public Result<Object> replaceUserPolicy(@RequestParam("file") MultipartFile file, @RequestParam("policyId") Integer policyId){
// InsurePolicy insurePolicy = InsurePolicy.builder().id(policyId).build().selectById();
// try {
// XSSFWorkbook xw = new XSSFWorkbook(file.getInputStream());
// XSSFSheet sheetAt = xw.getSheetAt(0);
// //默认第一行为标题行,i = 0
// XSSFRow titleRow = sheetAt.getRow(0);
// YgglMainEmp y;
// InsureUser ru;
// /*原被保人*/
// List<InsureUser> originalList;
// List<InsureUser> replaceList;
// // 循环获取每一行数据
// for (int i = 1; i < sheetAt.getPhysicalNumberOfRows(); i++) {
// XSSFRow row = sheetAt.getRow(i);
// y = YgglMainEmp.builder().build();
// ru=InsureUser.builder().build();
// // 读取每一格内容
// for (int index = 0; index < row.getPhysicalNumberOfCells(); index++) {
// XSSFCell titleCell = titleRow.getCell(index);
// XSSFCell cell = row.getCell(index);
// if (cell == null) {
// continue;
// } else {
// cell.setCellType(CellType.STRING);
// }
// if (cell.getStringCellValue().equals("")) {
// continue;
// }
// switch (ExcelUtils.getString(titleCell)) {
@PostMapping(value = "/replaceUserPolicy")
@ApiOperation(value = "18.导入替换人员", httpMethod = "POST", notes = "导入用户")
@Transactional(rollbackFor = Exception.class)
public Result<Object> replaceUserPolicy(@RequestParam("file") MultipartFile file, @RequestParam("policyId") Integer policyId){
InsurePolicy insurePolicy = InsurePolicy.builder().id(policyId).build().selectById();
try {
XSSFWorkbook xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0);
//默认第一行为标题行,i = 0
XSSFRow titleRow = sheetAt.getRow(0);
InsureUser originalUser;
InsureUser replaceUser;
/*原被保人集合*/
List<InsureUser> originalList=Lists.newArrayList();
// 循环获取每一行数据
for (int i = 1; i < sheetAt.getPhysicalNumberOfRows(); i++) {
XSSFRow row = sheetAt.getRow(i);
originalUser=InsureUser.builder().build();
replaceUser=InsureUser.builder().build();
// 读取每一格内容
for (int index = 0; index < row.getPhysicalNumberOfCells(); index++) {
XSSFCell titleCell = titleRow.getCell(index);
XSSFCell cell = row.getCell(index);
if (cell == null) {
continue;
} else {
cell.setCellType(CellType.STRING);
}
if (cell.getStringCellValue().equals("")) {
continue;
}
switch (ExcelUtils.getString(titleCell)) {
// case "ID":/*不重要*/
// break;
// case "name":
// if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
// return ResultUtil.error("第" + i + "行第" + index + "列被保人姓名不能为空");
// }
// ru.setInsuredName(ExcelUtils.getString(cell).trim());
// break;
// case "ID_type":
// if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
// return ResultUtil.error("第" + i + "行第" + index + "列证件类型不能为空");
// }
// break;
// case "ID_number":
// if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
// return ResultUtil.error("第" + i + "行第" + index + "列证件号码不能为空");
// }
// ru.setInsuredNo(ExcelUtils.getString(cell));
// break;
// case "Update_date":
// if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
// return ResultUtil.error("第" + i + "行第" + index + "列批改生效日不能为空");
// }
// break;
// case "replace_name":
// if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
// return ResultUtil.error("第" + i + "行第" + index + "列新保人员姓名不能为空");
// }
// break;
// case "replace_ID_type":
// if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
// return ResultUtil.error("第" + i + "行第" + index + "列新保人员证件类型不能为空");
// }
// break;
// case "replace_ID_number":
// if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
// return ResultUtil.error("第" + i + "行第" + index + "列新保人员证件号不能为空");
// }
// break;
// case "Date_of_birth":
// break;
// case "insured_type":
// break;
// case "insured_relationship":
// break;
// case "cert_type_related_insured":
// break;
// case "insured_relationship_id":
// break;
// case "Branch":
// break;
// case "Tricycle_frame_number":
// break;
// case "insured_number":
// break;
// case "benefit_occupation_category":
// break;
//
// }
// }
// }
// }catch (Exception e){
// throw new CustomException("导入异常");
// }
// return ResultUtil.success();
// }
case "name":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列被保人姓名不能为空");
}
originalUser.setInsuredEContact(ExcelUtils.getString(cell).trim());
break;
case "ID_type":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列证件类型不能为空");
}
break;
case "ID_number":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列证件号码不能为空");
}
originalUser.setInsuredNo(ExcelUtils.getString(cell));
break;
case "Update_date":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列批改生效日不能为空");
}
break;
case "replace_name":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列新保人员姓名不能为空");
}
replaceUser.setInsuredEContact(ExcelUtils.getString(cell));
break;
case "replace_ID_type":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列新保人员证件类型不能为空");
}
break;
case "replace_ID_number":
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列新保人员证件号不能为空");
}
replaceUser.setInsuredNo(ExcelUtils.getString(cell));
break;
case "Date_of_birth":
break;
case "insured_type":
break;
case "insured_relationship":
break;
case "cert_type_related_insured":
break;
case "insured_relationship_id":
break;
case "Branch":
break;
case "Tricycle_frame_number":
replaceUser.setTricycleFrameNumber(ExcelUtils.getString(cell));
break;
case "insured_number":
break;
case "benefit_occupation_category":
replaceUser.setBenefitOccupationCategory(ExcelUtils.getString(cell));
break;
}
originalUser.setReplaceUser(replaceUser);
originalList.add(originalUser);
}
}
/*验证表格信息*/
for (InsureUser insureUser : originalList) {
InsureUser getInsureUser = InsureUser.builder().build().selectOne(new QueryWrapper<InsureUser>().lambda()
.eq(InsureUser::getInsuredEContact,insureUser.getInsuredEContact()).eq(InsureUser::getInsuredNo,insureUser.getInsuredNo())
.eq(InsureUser::getInsureStatus,1).eq(InsureUser::getStatus,1).eq(InsureUser::getPolicyId,policyId));
if(getInsureUser==null){
return ResultUtil.error(insureUser.getInsuredName()+"未投保");
}
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
.eq(YgglMainEmp::getName,insureUser.getReplaceUser().getInsuredName())
.eq(YgglMainEmp::getZjNum,insureUser.getReplaceUser().getInsuredNo()));
if(ygglMainEmp==null){
QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(String.valueOf(System.currentTimeMillis())).pw(Md5.md5(pwd)).regTime(new Date()).orgId(insurePolicy.getOrgCode()).username(insureUser.getInsuredEContact()).sts(CommonEnum.U_STS_ON.getType()).build();
qyzxEmpLogin.insert();
ygglMainEmp = new YgglMainEmp();
ygglMainEmp.setEmpNum(qyzxEmpLogin.getId());
ygglMainEmp.setName(insureUser.getInsuredEContact());
ygglMainEmp.setZjType(0);
ygglMainEmp.setZjNum(insureUser.getInsuredNo());
ygglMainEmp.setOrgCode(insurePolicy.getOrgCode());
ygglMainEmp.setIsInsure(0);
ygglMainEmp.insert();
}
}
/*上传替换文件到保司服务器*/
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
/*保司返回地址*/
String url = "";
xw.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);
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();
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appidq, secretq))).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()).fileUrl(url).build().insert();
/*替换逻辑*/
}catch (Exception e){
throw new CustomException("导入异常");
}
return ResultUtil.success();
}
}
......@@ -22,6 +22,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.transaction.Transactional;
import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.bean.yggl.*;
import cn.timer.api.bean.zzgl.ZzglLogDgjl;
import cn.timer.api.dao.zzgl.ZzglLogDgjlMapper;
......@@ -2084,8 +2085,16 @@ public class YgglController {
@GetMapping(value = "/getUserList")
@ApiOperation(value = "62-1.运营后台--查询员工列表", httpMethod = "GET", notes = "接口发布说明")
@ApiOperationSupport(order = 62)
public Result<List<YgQueryDto>> getUserList(@RequestParam("companyId") String companyId) {
List<YgQueryDto> ygQueryDto = ygglMainEmpMapper.queryEmpMessage(Integer.parseInt(companyId), 0);
public Result<List<YgQueryDto>> getUserList(@RequestParam("companyId") String companyId,@RequestParam("policyId")Integer policyId) {
SimpleDateFormat dtf3 = new SimpleDateFormat("yyyy-MM");
List<YgQueryDto> ygQueryDto=Lists.newArrayList();
if(policyId!=null && policyId>0){
InsurePolicy insurePolicy = InsurePolicy.builder().id(policyId).build().selectById();
insurePolicy.getPolicyDateStart();
ygQueryDto = ygglMainEmpMapper.getInusrtUser(Integer.parseInt(companyId), null,dtf3.format(insurePolicy.getPolicyDateEnd()));
}else {
ygQueryDto = ygglMainEmpMapper.queryEmpMessage(Integer.parseInt(companyId), null);
}
for (YgQueryDto yg : ygQueryDto) {
if (StringUtil.isEmpty(yg.getHeadUrl())) {
yg.setHeadUrl("");
......
......@@ -22,7 +22,7 @@ import java.util.List;
public interface InsureUserMapper extends BaseMapper<InsureUser> {
List<PolicyDto> selectPolicyList(@Param("policyDto") PolicyDto policyDto );
Integer totalUser(@Param("policyDto") PolicyDto policyDto);
List<InsureUser> selectListByIds(@Param("array")String[] ids);
List<InsureUser> selectListByIds(@Param("array")String[] ids,@Param("policyId") Integer policyId,@Param("createTime")String createTime);
List<InsureUserDto> selectPlansListByIds(@Param("array")String[] ids);
List<InsureUserDto> selectPlansListById(@Param("policyId")String id);
int updateInsure(@Param("array")Integer[] ids);
......
......@@ -146,4 +146,7 @@ public interface YgglMainEmpMapper extends BaseMapper<YgglMainEmp> {
List<YgglMainEmp> selectListByIZjNum(@Param("array")String[] zjNum,@Param("orgCode") Integer orgCode);
int updateInsure(@Param("array")Integer[] ids);
/*查询当月已投保人*/
List<YgQueryDto> getInusrtUser(@Param("orgCode") Integer orgCode, @Param("isInsure")Integer isInsure,@Param("createTime")String createTime);
}
......@@ -80,4 +80,6 @@ public class YgQueryDto extends Page {
@ApiModelProperty(value="证件号码 ",example="证件号码")
private String zjNum;
private Integer insureId;
}
......@@ -394,6 +394,13 @@
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
<if test="policyId!=null and policyId !=''">
and policy_id =#{policyId}
</if>
<if test="createTime!=null and createTime !=''">
and date_format(create_time,'%Y-%m') = #{createTime}
</if>
and status = 1 and insure_status = 1
</select>
<!--根据id数组查询员工-->
......
......@@ -483,4 +483,34 @@
</foreach>
</update>
<select id="getInusrtUser" resultType="cn.timer.api.dto.yggl.YgQueryDto">
SELECT
a.id id,
a.name empName,
a.emp_num empNum,
b.name deptName,
a.rz_time rzTime,
a.job_type jobType,
a.phone phone,
a.job_status jobStatus,
a.head_url headUrl,
a.sex sex,
a.is_insure isInsure,
a.zj_num zjNum,
iu.id insureId
FROM
yggl_main_emp a
LEFT JOIN zzgl_bmgw_m b ON a.bmgw_id = b.id
LEFT JOIN insure_user iu on iu.user_id=a.id AND date_format(iu.create_time,'%Y-%m') = #{createTime} and iu.insure_status=1 and iu.`status`=1
WHERE
a.org_code = #{orgCode}
AND
a.job_status in (0,1,2)
<if test="isInsure!=null and isInsure != ''">
AND a.is_insure=#{isInsure}
</if>
ORDER BY
emp_num DESC
</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