Commit d6c11b44 authored by hongguangwu's avatar hongguangwu

MVP1.7.3-shuiyou 测试提交

parent 570ba99d
package com.yifu.cloud.plus.v1.yifu.social.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @Author: hgw
* @Date: 2024-12-6 17:01:23
* @Description:
* @return: 税友配置
**/
@Configuration
@Data
@Slf4j
public class SocialFriendConfig {
// appKey
@Value("${socialFriend.appKey}")
private String appKey;
// appSecret
@Value("${socialFriend.appSecret}")
private String appSecret;
// url前缀
@Value("${socialFriend.urlPre}")
private String urlPre;
// url推
@Value("${socialFriend.urlPush}")
private String urlPush;
// url拉结果数据
@Value("${socialFriend.urlGetInfo}")
private String urlGetInfo;
// 税友——1功能列表的KEY
private final String APP_GET_MODULE_DETAIL = "APP_GET_MODULE_DETAIL";
// 税友——2可执行设备
private final String TERMINALS_BY_FUNCTION = "TERMINALS_BY_FUNCTION";
// 税友——5查看结果
private final String GET_FIVE_JOB = "GET_FIVE_JOB";
@Autowired
private RedisTemplate redisTemplate;
/**
* @Description: 4:推送任务接口
* @Author: hgw
* @Date: 2024-5-8 15:07:45
* @return: java.lang.String
**/
public String getFourAppAdd(RestTemplate restTemplate, String jobFile, String moduleDetailId, String terminalId) {
String addId = "";
String appAddUrl = urlPre + urlPush;
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("accept", MediaType.TEXT_PLAIN.toString());
headers.add("appKey", appKey);
headers.add("appSecret", appSecret);
JSONObject json = new JSONObject();
json.put("bizNo", "e5150440add340158e6b258bf8c60e7c");
json.put("qymc", "安徽测试企业");
json.put("nsrsbh", "91340100634561365L");
json.put("areaid", "340100");
JSONArray ywblzhlbArr = new JSONArray();
JSONObject jsonYwblzhlbYgs = new JSONObject();
jsonYwblzhlbYgs.put("mm", "Aa123456");
jsonYwblzhlbYgs.put("blxm", "社保");
jsonYwblzhlbYgs.put("dwbh", "123456");
jsonYwblzhlbYgs.put("zh", "1234567");
jsonYwblzhlbYgs.put("mmlx", "4");
JSONObject jsonYwblzhlbYsd = new JSONObject();
jsonYwblzhlbYsd.put("mm", "Aa123456");
jsonYwblzhlbYsd.put("blxm", "医保");
jsonYwblzhlbYsd.put("dwbh", "123456");
jsonYwblzhlbYsd.put("zh", "1234567");
jsonYwblzhlbYsd.put("mmlx", "4");
ywblzhlbArr.add(jsonYwblzhlbYgs);
ywblzhlbArr.add(jsonYwblzhlbYsd);
json.put("ywblzhlb", ywblzhlbArr);
JSONArray cbrymdArr = new JSONArray();
JSONObject cbrymdOne = new JSONObject();
cbrymdOne.put("csrq", "2009-08-21");
cbrymdOne.put("gj", "中国");
cbrymdOne.put("whcd", "大学本科");
cbrymdOne.put("sjhm", "10000340997");
cbrymdOne.put("xb", "男");
cbrymdOne.put("hkszdxzq", "浙江省|杭州市|滨江区");
cbrymdOne.put("mz", "汉族");
cbrymdOne.put("cjgzrq", "2017-06-14");
JSONArray blxmlbArr = new JSONArray();
JSONObject blxmlbOne = new JSONObject();
String[] strArr = {"企业职工养老"};
blxmlbOne.put("xzlb", strArr);
blxmlbOne.put("blxm", "社保");
blxmlbOne.put("bccbrq", "2024-05-30");
blxmlbOne.put("sbgz", "4000");
JSONObject blxmlbTwo = new JSONObject();
String[] strArrTwo = {"生育保险"};
blxmlbTwo.put("xzlb", strArrTwo);
blxmlbTwo.put("blxm", "医保");
blxmlbTwo.put("bccbrq", "2024-04-30");
blxmlbTwo.put("sbgz", "4000");
blxmlbArr.add(blxmlbOne);
blxmlbArr.add(blxmlbTwo);
cbrymdOne.put("blxmlb", blxmlbArr);
cbrymdOne.put("jzdz", "滨江区南环路3738号");
cbrymdOne.put("xm", "测试金辰");
cbrymdOne.put("zzlx", "居民身份证");
cbrymdOne.put("zzhm", "828888200908213819");
cbrymdOne.put("hkxz", "外地居民户口");
JSONObject tszdxx = new JSONObject();
tszdxx.put("dwjyqssj", "2028-08-07");
tszdxx.put("ygxs", "订立固定期限劳动合同");
tszdxx.put("gzsjzd", "标准工作时间制度");
tszdxx.put("jydjsj", "2023-08-01");
tszdxx.put("zygz", "专业技术人员");
tszdxx.put("ldhtqsqk", "初签");
tszdxx.put("grsf", "企业管理人员");
cbrymdOne.put("tszdxx", tszdxx);
cbrymdOne.put("jzdzxzq", "浙江省|杭州市|滨江区");
cbrymdOne.put("hkszddz", "滨江区南环路3738号");
JSONObject jyxx = new JSONObject();
jyxx.put("ldhtqsrq", "2023-08-20");
jyxx.put("ldhtjzrq", "2030-12-30");
jyxx.put("ldhtlx", "固定期限劳动合同");
cbrymdOne.put("jyxx", jyxx);
cbrymdArr.add(cbrymdOne);
json.put("cbrymd", cbrymdArr);
HttpEntity<String> formEntity = new HttpEntity<>(json.toString(), headers);
String dataResultList = restTemplate.postForObject(appAddUrl, formEntity, String.class);
// {"head":{"code":"00000000","description":"成功","msg":"成功","time":"2024-12-06 17:10:26","status":"Y"}
// ,"body":{"requestId":"85440b327d71466abcd9c5c81d5bb172"}}
if (Common.isNotNull(dataResultList)) {
JSONObject dataObject = JSON.parseObject(dataResultList);
String head = dataObject.getString("head");
if (Common.isNotNull(head)) {
JSONObject headObject = JSON.parseObject(head);
String status = headObject.getString("status");
if ("Y".equals(status)) {
String body = dataObject.getString("body");
JSONObject bodyObject = JSON.parseObject(body);
addId = bodyObject.getString("requestId");
System.out.println(addId);
} else {
System.out.println("失败");
}
}
}
return addId;
}
/**
* @param: fileKey : resultFile 查看文件; resultAnnex 查看附件
* @Description: 5:任务查询接口
* @Author: hgw
* @Date: 2024-5-8 15:07:45
* @return: java.lang.String
**/
public R<String> getFiveJob(RestTemplate restTemplate, String addId, String fileKey) {
if (Common.isEmpty(addId)) {
return null;
}
String resultFile = null;
String moduleDetailUrl = urlPre + urlGetInfo;
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("accept", MediaType.TEXT_PLAIN.toString());
headers.add("appKey", appKey);
headers.add("appSecret", appSecret);
HttpEntity<String> formEntity = new HttpEntity<>(headers);
ResponseEntity response = restTemplate.exchange(moduleDetailUrl, HttpMethod.GET, formEntity, String.class);
if (Common.isEmpty(response) || Common.isEmpty(response.getBody())) {
throw new CheckedException("获取税友【任务查询接口】失败");
}
int status = response.getStatusCodeValue();
if (status != 200) {
throw new CheckedException("获取税友【任务查询接口】失败,status="+status);
}
String body = (String) response.getBody();
JSONObject bodyObject = JSON.parseObject(body);
JSONObject dataObject = (JSONObject) bodyObject.get("data");
String statusStr = dataObject.getString("status");
if (!"完成".equals(statusStr)) {
return R.failed(statusStr);
}
resultFile = dataObject.getString(fileKey);
if (Common.isEmpty(resultFile)) {
return R.failed(resultFile);
}
return R.ok(resultFile);
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.controller;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import com.yifu.cloud.plus.v1.yifu.social.service.TSocialFriendPushService;
import com.yifu.cloud.plus.v1.yifu.social.service.TSocialFriendService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 税友
*
* @author hgw
* @date 2024-12-6 15:46:04
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/tsocialfriend")
@Tag(name = "税友")
public class TSocialFriendController {
private final TSocialFriendService tSocialFriendService;
private final TSocialFriendPushService tSocialFriendPushService;
@Operation(description = "推送税友Test")
@PostMapping("/pushFriendTest")
public R<String> pushFriendTest(@RequestBody(required = false) List<String> dispatchIdList) {
return tSocialFriendPushService.pushFriendTest(dispatchIdList);
}
/**
* @param addId 任务id,可为空
* @Description: 1获取税友状态
* @Author: hgw
* @Date: 2024/5/11 19:25
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Operation(description = "获取税友状态")
@GetMapping("/getFiveJob")
public R<String> getFiveJob(@RequestParam(required = false) String addId) {
return tSocialFriendService.getFiveJob(addId);
}
/**
* @param dispatchIdList 派单id
* @Description: 推送税友
* @Author: hgw
* @Date: 2024/5/11 19:25
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Operation(description = "推送税友")
@PostMapping("/pushSoldier")
public R<String> pushSoldier(@RequestBody(required = false) List<String> dispatchIdList) {
return tSocialFriendPushService.pushSoldier(dispatchIdList);
}
/**
* @Description: 1定时任务获取税友状态
* @Author: hgw
* @Date: 2024/5/11 19:26
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Operation(description = "1定时任务获取税友状态")
@PostMapping("/inner/doInnerGetFiveJob")
@SysLog("1每日定时任务获取税友状态")
@Inner
public R<String> doInnerGetFiveJob() {
return tSocialFriendService.getFiveJob(null);
}
/**
* @Description: 2定时任务推送税友
* @Author: hgw
* @Date: 2024/5/11 19:26
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Operation(description = "2定时任务推送税友")
@PostMapping("/inner/doInnerPushSoldier")
@SysLog("2每日定时任务推送税友")
@Inner
public R<String> doInnerPushSoldier() {
return tSocialFriendPushService.pushSoldier(null);
}
/**
* @Description: 3每日定时任务推送税友审核结果查询
* @Author: hgw
* @Date: 2024-5-24 17:01:56
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Operation(description = "3每日定时任务推送税友审核结果查询")
@PostMapping("/inner/doInnerPushSoldierByAudit")
@SysLog("4每日定时任务推送税友审核结果查询")
@Inner
public R<String> doInnerPushSoldierByAudit() {
return tSocialFriendPushService.pushSoldierByAudit();
}
/**
* @Description: 4每日定时任务获取税友审核结果查询
* @Author: hgw
* @Date: 2024-5-24 17:02:00
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Operation(description = "4每日定时任务获取税友审核结果查询")
@PostMapping("/inner/doInnerGetSixJobByAudit")
@SysLog("4每日定时任务获取税友审核结果查询")
@Inner
public R<String> doInnerGetSixJobByAudit() {
return tSocialFriendService.getSixJobByAudit();
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialInfo;
import com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYgsAddVo;
import com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYgsAuditVo;
import com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYsdAddVo;
import com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYsdAuditVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 税友Mapper
*
* @author hgw
* @date 2024-5-13 11:54:57
*/
@Mapper
public interface TSocialFriendMapper extends BaseMapper<TSocialInfo> {
/**
* 社保士兵养工失增加模板
*
* @Author hgw
* @Date 2024-5-10 21:16:41
**/
List<SocialSoldierYgsAddVo> getSocialSoldierYgsAddVoList(@Param("idsStr") List<String> idsStr);
/**
* 社保士兵养工失减少模板
*
* @Author hgw
* @Date 2024-5-10 21:16:41
**/
List<SocialSoldierYgsAddVo> getSocialSoldierYgsReduceVoList(@Param("idsStr") List<String> idsStr);
/**
* 社保士兵医生大增加模板
*
* @Author hgw
* @Date 2024-5-10 21:16:41
**/
List<SocialSoldierYsdAddVo> getSocialSoldierYsdAddVoList(@Param("idsStr") List<String> idsStr);
/**
* 社保士兵医生大减少模板
*
* @Author hgw
* @Date 2024-5-10 21:16:41
**/
List<SocialSoldierYsdAddVo> getSocialSoldierYsdReduceVoList(@Param("idsStr") List<String> idsStr);
/**
* 社保士兵养工失审核模板
*
* @Author hgw
* @Date 2024-5-24 16:39:43
**/
List<SocialSoldierYgsAuditVo> getSocialSoldierYgsAuditVoList();
/**
* 社保士兵医生大审核续保模板
*
* @Author hgw
* @Date 2024-5-24 16:39:43
**/
List<SocialSoldierYsdAuditVo> getSocialSoldierYsdAuditVoList();
/**
* 社保士兵养工失审核模板——推送给社保士兵的归总模板
*
* @Author hgw
* @Date 2024-9-2 18:03:04
**/
List<SocialSoldierYgsAuditVo> getSocialSoldierYgsAuditVoListByGroupBy();
/**
* 社保士兵医生大审核续保模板——推送给社保士兵的归总模板
*
* @Author hgw
* @Date 2024-9-2 18:03:07
**/
List<SocialSoldierYsdAuditVo> getSocialSoldierYsdAuditVoListByGroupBy();
/**
* 社保士兵医生大审核新增模板
*
* @Author hgw
* @Date 2024-5-24 16:39:43
**/
List<SocialSoldierYsdAuditVo> getSocialSoldierYsdAddAuditVoList();
/**
* 社保士兵医生大审核新增模板
*
* @Author hgw
* @Date 2024-5-24 16:39:43
**/
List<SocialSoldierYsdAuditVo> getSocialSoldierYsdAddAuditVoListByGroupBy();
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialInfo;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* 税友-推送
*
* @author hgw
* @date 2024-12-6 15:43:28
*/
public interface TSocialFriendPushService extends IService<TSocialInfo> {
/**
* @Description: 根据文件,推送到社保士兵。注意社保id别搞错了,否则塞值到社保里就塞错了
* @Author: hgw
* @Date: 2024/5/11 14:46
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
R<String> getOneAppGetModuleDetail(List<TSocialInfo> socialIdList, MultipartFile file, String type);
/**
* @param dispatchIdList
* @Description: 根据派单id,获取要派增派减的社保、医保数据,生成文件,推送到社保士兵
* @Author: hgw
* @Date: 2024/5/10 17:52
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
R<String> pushSoldier(List<String> dispatchIdList);
R<String> pushFriendTest(List<String> dispatchIdList);
/**
* @param
* @Description: 推送当月所有提交社保局后,待社保局审核的查询任务
* @Author: hgw
* @Date: 2024/5/23 18:14
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
R<String> pushSoldierByAudit();
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialInfo;
/**
* 社保士兵
*
* @author hgw
* @date 2024-5-8 14:55:24
*/
public interface TSocialFriendService extends IService<TSocialInfo> {
/**
* @param addId
* @Description: 查看社保士兵反馈情况
* @Author: hgw
* @Date: 2024/5/11 14:45
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
R<String> getFiveJob(String addId);
/**
* @Description: 查看社保士兵审核结果查询的反馈情况
* @Author: hgw
* @Date: 2024-5-24 17:02:34
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
R<String> getSixJobByAudit();
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.service.impl;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.social.config.SocialConfig;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialDeadlineInfo;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialInfo;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialSoldierLog;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialSoldierShenBaoTask;
import com.yifu.cloud.plus.v1.yifu.social.mapper.TSocialFriendMapper;
import com.yifu.cloud.plus.v1.yifu.social.service.*;
import com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYgsAddVo;
import com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYgsAuditVo;
import com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYsdAddVo;
import com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYsdAuditVo;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 税友-推送
*
* @author hgw
* @date 2024-12-6 15:43:23
*/
@AllArgsConstructor
@Log4j2
@Service
public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMapper, TSocialInfo> implements TSocialFriendPushService {
private RestTemplate restTemplate = new RestTemplate();
private final SocialConfig socialConfig;
private final TSocialInfoService tSocialInfoService;
private final TSocialSoldierShenBaoTaskService tSocialSoldierShenBaoTaskService;
private final TSocialDeadlineInfoService tSocialDeadlineInfoService;
private final TSocialSoldierLogService tSocialSoldierLogService;
/**
* @param socialList
* @param file
* @param type
* @Description: 推送到社保士兵,更新社保表的任务id与状态
* @Author: hgw
* @Date: 2024/5/11 15:24
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Override
public R<String> getOneAppGetModuleDetail(List<TSocialInfo> socialList, MultipartFile file, String type) {
// 1获取模板id——社保增员、社保减员、医保增员、医保减员
Map<String, String> moduleDetailMap = socialConfig.getOneModuleDetailMap(restTemplate);
if (moduleDetailMap != null && !moduleDetailMap.isEmpty() && moduleDetailMap.get(type) != null) {
// 2获取机器id
String terminalId = socialConfig.getTwoTerminalId(restTemplate, moduleDetailMap.get(type));
if (Common.isNotNull(terminalId)) {
// 3上传文件,获取文件地址
String fileAddUrl = socialConfig.getThreeTerminalId(restTemplate, file);
// 4 推送办理任务,返回任务id:
String addId = socialConfig.getFourAppAdd(restTemplate, fileAddUrl, moduleDetailMap.get(type), terminalId);
for (TSocialInfo socialInfo : socialList) {
if ("社保增员".equals(type) || "社保减员".equals(type)) {
socialInfo.setYgsAddId(addId);
socialInfo.setYgsHandleStatus(CommonConstants.TWO_STRING);
} else {
socialInfo.setYsdAddId(addId);
socialInfo.setYsdHandleStatus(CommonConstants.TWO_STRING);
}
}
tSocialInfoService.updateBatchById(socialList);
}
}
return R.ok("推送成功!");
}
/**
* @Description: 组装社保与医保的文件流
* @Author: hgw
* @Date: 2024/5/23 17:59
* @return: org.springframework.web.multipart.MultipartFile
**/
public MultipartFile getFileYgs(List<SocialSoldierYgsAddVo> list) {
if (list != null) {
String fileName = "soldierFileYgs" + DateUtil.getThisTime() + new Date().getTime() + CommonConstants.XLSX;
ExcelWriter excelWriter = EasyExcelFactory.write(fileName).build();
WriteSheet writeSheet = EasyExcelFactory.writerSheet("社保明细").head(SocialSoldierYgsAddVo.class).build();
excelWriter.write(list, writeSheet);
File file = new File(fileName);
excelWriter.finish();
return getMultipartFile(file);
}
return null;
}
/**
* @Description: 组装社保与医保的文件流
* @Author: hgw
* @Date: 2024/5/23 17:59
* @return: org.springframework.web.multipart.MultipartFile
**/
public MultipartFile getFileYsd(List<SocialSoldierYsdAddVo> list) {
if (list != null) {
String fileName = "soldierFileYsd" + DateUtil.getThisTime() + new Date().getTime() + CommonConstants.XLSX;
ExcelWriter excelWriter = EasyExcelFactory.write(fileName).build();
WriteSheet writeSheet = EasyExcelFactory.writerSheet("医保明细").head(SocialSoldierYsdAddVo.class).build();
excelWriter.write(list, writeSheet);
File file = new File(fileName);
excelWriter.finish();
return getMultipartFile(file);
}
return null;
}
public static MultipartFile getMultipartFile(File file) {
FileItem item = new DiskFileItemFactory().createItem("file", MediaType.MULTIPART_FORM_DATA_VALUE, true, file.getName());
try (InputStream input = new FileInputStream(file); OutputStream os = item.getOutputStream()) {
// 流转移
IOUtils.copy(input, os);
} catch (Exception e) {
throw new IllegalArgumentException("Invalid file: " + e, e);
} finally {
//删除临时文件
try {
org.apache.commons.io.FileUtils.forceDelete(file);
} catch (IOException e) {
e.printStackTrace();
}
}
return new CommonsMultipartFile(item);
}
/**
* @Description: 推送到社保士兵
* @Author: hgw
* @Date: 2024/5/10 17:53
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Override
public R<String> pushFriendTest(List<String> dispatchIdList) {
// 获取时间限制配置(获取 当月启用 的配置)
Map<String, TSocialDeadlineInfo> socialsetMap = tSocialDeadlineInfoService.getSocialSet();
// 社保增员、社保减员、医保增员、医保减员
// 养工失新增列表
List<SocialSoldierYgsAddVo> ygsAddlist = baseMapper.getSocialSoldierYgsAddVoList(dispatchIdList);
if (ygsAddlist != null && !ygsAddlist.isEmpty()) {
this.doPushSocialAndLogYgs(socialsetMap, ygsAddlist, "社保增员");
}
if ((ygsAddlist == null || ygsAddlist.isEmpty())) {
return R.failed("无数据,推送结束!");
}
return R.ok("推送成功!!");
}
/**
* @Description: 推送到社保士兵
* @Author: hgw
* @Date: 2024/5/10 17:53
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Override
public R<String> pushSoldier(List<String> dispatchIdList) {
// 获取时间限制配置(获取 当月启用 的配置)
Map<String, TSocialDeadlineInfo> socialsetMap = tSocialDeadlineInfoService.getSocialSet();
// 社保增员、社保减员、医保增员、医保减员
// 养工失新增列表
List<SocialSoldierYgsAddVo> ygsAddlist = baseMapper.getSocialSoldierYgsAddVoList(dispatchIdList);
if (ygsAddlist != null && !ygsAddlist.isEmpty()) {
this.doPushSocialAndLogYgs(socialsetMap, ygsAddlist, "社保增员");
}
// 养工失减少列表
List<SocialSoldierYgsAddVo> ygsReducelist = baseMapper.getSocialSoldierYgsReduceVoList(dispatchIdList);
if (ygsReducelist != null && !ygsReducelist.isEmpty()) {
this.doPushSocialAndLogYgs(socialsetMap, ygsReducelist, "社保减员");
}
// 医生大新增列表
List<SocialSoldierYsdAddVo> ysdAddlist = baseMapper.getSocialSoldierYsdAddVoList(dispatchIdList);
if (ysdAddlist != null && !ysdAddlist.isEmpty()) {
this.doPushSocialAndLogYsd(socialsetMap, ysdAddlist, "医保增员");
}
// 医生大减少列表
List<SocialSoldierYsdAddVo> ysdReducelist = baseMapper.getSocialSoldierYsdReduceVoList(dispatchIdList);
if (ysdReducelist != null && !ysdReducelist.isEmpty()) {
this.doPushSocialAndLogYsd(socialsetMap, ysdReducelist, "医保减员");
}
if ((ygsAddlist == null || ygsAddlist.isEmpty())
&& (ygsReducelist == null || ygsReducelist.isEmpty())
&& (ysdAddlist == null || ysdAddlist.isEmpty())
&& (ysdReducelist == null || ysdReducelist.isEmpty())
) {
return R.failed("无数据,推送结束!");
}
return R.ok("推送成功!!");
}
/**
* @Description: 推送社保和记录日志
* @Author: hgw
* @Date: 2024/9/2 17:21
* @return: void
**/
private void doPushSocialAndLogYgs(Map<String, TSocialDeadlineInfo> socialsetMap
, List<SocialSoldierYgsAddVo> ygsAddlist, String socialType) {
List<TSocialInfo> socialIdList = new ArrayList<>();
int canPushType;
TSocialInfo socialInfo;
List<SocialSoldierYgsAddVo> ygsAddlistCopy = new ArrayList<>();
String type = "提交";
List<TSocialSoldierLog> logList = new ArrayList<>();
TSocialSoldierLog socialLog;
String remark;
List<TSocialInfo> renGongList = new ArrayList<>();
for (SocialSoldierYgsAddVo vo : ygsAddlist) {
// 0:未到时间不动; 1:推送; 2:转人工
canPushType = this.getCanPushType(socialsetMap, vo);
if (1 == canPushType) {
socialInfo = new TSocialInfo();
socialInfo.setId(vo.getSocialId());
socialIdList.add(socialInfo);
ygsAddlistCopy.add(vo);
remark = "已推送提交任务!";
} else {
if (0 == canPushType) {
remark = "未到时间,不推送!";
} else {
remark = "无时间配置或超出办理截止时间,转人工!";
socialInfo = new TSocialInfo();
socialInfo.setId(vo.getSocialId());
socialInfo.setYgsHandleStatus(CommonConstants.FIVE_STRING);
renGongList.add(socialInfo);
}
}
socialLog = tSocialSoldierLogService.getYgsSoldierLog(vo, type, remark);
if (socialLog != null) {
logList.add(socialLog);
}
}
if (!renGongList.isEmpty()) {
tSocialInfoService.updateBatchById(renGongList);
}
if (!logList.isEmpty()) {
tSocialSoldierLogService.saveBatch(logList);
}
// 3如果没有要办理的数据,就不需要推送
if (!socialIdList.isEmpty()) {
try {
MultipartFile file = this.getFileYgs(ygsAddlistCopy);
if (Common.isNotNull(file)) {
this.getOneAppGetModuleDetail(socialIdList, file, socialType);
}
} catch (Exception e) {
log.error("提交社保士兵异常2:", e);
if (!logList.isEmpty()) {
for (TSocialSoldierLog logTemp : logList) {
logTemp.setRemark("提交社保士兵异常!");
}
tSocialSoldierLogService.updateBatchById(logList);
}
}
}
}
/**
* @Description: 推送医保和记录日志
* @Author: hgw
* @Date: 2024/9/2 17:21
* @return: void
**/
private void doPushSocialAndLogYsd(Map<String, TSocialDeadlineInfo> socialsetMap
, List<SocialSoldierYsdAddVo> ysdAddlist, String socialType) {
List<TSocialInfo> socialIdList = new ArrayList<>();
int canPushType;
TSocialInfo socialInfo;
List<SocialSoldierYsdAddVo> ysdAddlistCopy = new ArrayList<>();
String type = "提交";
List<TSocialSoldierLog> logList = new ArrayList<>();
TSocialSoldierLog socialLog;
List<TSocialInfo> renGongList = new ArrayList<>();
String remark;
for (SocialSoldierYsdAddVo vo : ysdAddlist) {
// 0:未到时间不动; 1:推送; 2:转人工
canPushType = this.getCanPushTypeYsd(socialsetMap, vo);
if (1 == canPushType) {
socialInfo = new TSocialInfo();
socialInfo.setId(vo.getSocialId());
socialIdList.add(socialInfo);
ysdAddlistCopy.add(vo);
remark = "已推送提交任务!";
} else {
if (0 == canPushType) {
remark = "未到时间,不推送!";
} else {
remark = "无时间配置或超出办理截止时间,转人工!";
socialInfo = new TSocialInfo();
socialInfo.setId(vo.getSocialId());
socialInfo.setYsdHandleStatus(CommonConstants.FIVE_STRING);
renGongList.add(socialInfo);
}
}
socialLog = tSocialSoldierLogService.getYsdSoldierLog(vo, type, remark);
if (socialLog != null) {
logList.add(socialLog);
}
}
if (!renGongList.isEmpty()) {
tSocialInfoService.updateBatchById(renGongList);
}
if (!logList.isEmpty()) {
tSocialSoldierLogService.saveBatch(logList);
}
// 3如果没有要办理的数据,就不需要推送
if (!socialIdList.isEmpty()) {
try {
MultipartFile file = this.getFileYsd(ysdAddlistCopy);
if (Common.isNotNull(file)) {
this.getOneAppGetModuleDetail(socialIdList, file, socialType);
}
} catch (Exception e) {
log.error("提交社保士兵异常1:", e);
if (!logList.isEmpty()) {
for (TSocialSoldierLog logTemp : logList) {
logTemp.setRemark("提交社保士兵异常!");
}
tSocialSoldierLogService.updateBatchById(logList);
}
}
}
}
/**
* @param socialsetMap 时间限制配置Map
* @param vo 社保或医保
* @Description:
* @Author: hgw
* @Date: 2024/9/2 16:00
* @return: int
**/
private int getCanPushType(Map<String, TSocialDeadlineInfo> socialsetMap, SocialSoldierYgsAddVo vo) {
// 0:未到时间不动; 1:推送; 2:转人工
int canPushType = 0;
if (socialsetMap != null) {
TSocialDeadlineInfo socialSet;
StringBuilder addressKey;
Date nowTime = new Date();
if (Common.isNotNull(vo.getSocialProvince())) {
addressKey = new StringBuilder(vo.getSocialProvince()).append(CommonConstants.DOWN_LINE_STRING);
if (Common.isEmpty(vo.getSocialCity())) {
addressKey.append(CommonConstants.CENTER_SPLIT_LINE_STRING);
} else {
addressKey.append(vo.getSocialCity());
}
addressKey.append(CommonConstants.DOWN_LINE_STRING);
if (Common.isEmpty(vo.getSocialTown())) {
addressKey.append(CommonConstants.CENTER_SPLIT_LINE_STRING);
} else {
addressKey.append(vo.getSocialTown());
}
socialSet = socialsetMap.get(addressKey.toString());
if (socialSet != null) {
Date start = socialSet.getSocialStartDate();
Date end = socialSet.getSocialEndDate();
if ("派减".equals(vo.getType())) {
start = socialSet.getSocialStartDateReduce();
end = socialSet.getSocialEndDateReduce();
}
if (Common.isNotNull(start) && Common.isNotNull(end)) {
if (nowTime.before(start)) {
canPushType = 0;
} else if (nowTime.after(end)) {
canPushType = 2;
} else {
canPushType = 1;
}
} else {
// 无配置或配置时间为空
canPushType = 2;
}
} else {
// 无配置或配置时间为空
canPushType = 2;
}
}
} else {
// 2无时间限制的转人工
canPushType = 2;
}
return canPushType;
}
private int getCanPushTypeYsd(Map<String, TSocialDeadlineInfo> socialsetMap, SocialSoldierYsdAddVo vo) {
// 0:未到时间不动; 1:推送; 2:转人工
int canPushType = 0;
if (socialsetMap != null) {
TSocialDeadlineInfo socialSet;
StringBuilder addressKey;
Date nowTime = new Date();
if (Common.isNotNull(vo.getSocialProvince())) {
addressKey = new StringBuilder(vo.getSocialProvince()).append(CommonConstants.DOWN_LINE_STRING);
if (Common.isEmpty(vo.getSocialCity())) {
addressKey.append(CommonConstants.CENTER_SPLIT_LINE_STRING);
} else {
addressKey.append(vo.getSocialCity());
}
addressKey.append(CommonConstants.DOWN_LINE_STRING);
if (Common.isEmpty(vo.getSocialTown())) {
addressKey.append(CommonConstants.CENTER_SPLIT_LINE_STRING);
} else {
addressKey.append(vo.getSocialTown());
}
socialSet = socialsetMap.get(addressKey.toString());
if (socialSet != null) {
Date start = socialSet.getMedicalStartDate();
Date end = socialSet.getMedicalEndDate();
if ("派减".equals(vo.getType())) {
start = socialSet.getMedicalStartDateReduce();
end = socialSet.getMedicalEndDateReduce();
}
if (Common.isNotNull(start) && Common.isNotNull(end)) {
if (nowTime.before(start)) {
canPushType = 0;
} else if (nowTime.after(end)) {
canPushType = 2;
} else {
canPushType = 1;
}
} else {
// 无配置或配置时间为空
canPushType = 2;
}
} else {
// 无配置或配置时间为空
canPushType = 2;
}
}
} else {
// 2无时间限制的转人工
canPushType = 2;
}
return canPushType;
}
/**
* @Description: 推送社保士兵审核结果查询文件
* @Author: hgw
* @Date: 2024-5-23 18:02:27
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Override
public R<String> pushSoldierByAudit() {
// 养工失待审核列表
List<SocialSoldierYgsAuditVo> ygsAddlist = baseMapper.getSocialSoldierYgsAuditVoList();
List<SocialSoldierYgsAuditVo> ygsAddByGroupBylist = baseMapper.getSocialSoldierYgsAuditVoListByGroupBy();
String sheetName = "审核数据查询";
String type = "审核";
String remark = "已推送审核任务!";
String errorRemark = "推送社保士兵审核异常!";
TSocialSoldierLog socialLog;
List<TSocialSoldierLog> logList = new ArrayList<>();
if (ygsAddlist != null && !ygsAddlist.isEmpty()) {
MultipartFile file = this.getFileByAudit(ygsAddByGroupBylist, null, sheetName);
if (Common.isNotNull(file)) {
List<TSocialInfo> socialIdList = new ArrayList<>();
TSocialInfo socialInfo;
for (SocialSoldierYgsAuditVo vo : ygsAddlist) {
socialInfo = new TSocialInfo();
socialInfo.setId(vo.getSocialId());
socialIdList.add(socialInfo);
// 组装日志
socialLog = tSocialSoldierLogService.getYgsSoldierAuditLog(vo, type, remark);
if (socialLog != null) {
logList.add(socialLog);
}
}
// 保存
if (!logList.isEmpty()) {
tSocialSoldierLogService.saveBatch(logList);
}
try {
this.getOneAppGetModuleDetailByAudit(socialIdList, file, sheetName);
} catch (Exception e) {
log.error(errorRemark + "2:", e);
if (!logList.isEmpty()) {
// 异常时,更新日志
for (TSocialSoldierLog logTemp : logList) {
logTemp.setRemark(errorRemark);
}
tSocialSoldierLogService.updateBatchById(logList);
}
}
}
}
// 医生大【续保】待审核列表
List<SocialSoldierYsdAuditVo> ysdXuBaolist = baseMapper.getSocialSoldierYsdAuditVoList();
List<SocialSoldierYsdAuditVo> ysdXuBaoByGroupBylist = baseMapper.getSocialSoldierYsdAuditVoListByGroupBy();
sheetName = "审核数据信息查询";
logList = new ArrayList<>();
if (ysdXuBaolist != null && !ysdXuBaolist.isEmpty()) {
MultipartFile file = this.getFileByAudit(null, ysdXuBaoByGroupBylist, sheetName);
if (Common.isNotNull(file)) {
List<TSocialInfo> socialIdList = new ArrayList<>();
TSocialInfo socialInfo;
for (SocialSoldierYsdAuditVo vo : ysdXuBaolist) {
socialInfo = new TSocialInfo();
socialInfo.setId(vo.getSocialId());
socialIdList.add(socialInfo);
// 组装日志
socialLog = tSocialSoldierLogService.getYsdSoldierAuditLog(vo, type, remark);
if (socialLog != null) {
logList.add(socialLog);
}
}
// 保存
if (!logList.isEmpty()) {
tSocialSoldierLogService.saveBatch(logList);
}
try {
this.getOneAppGetModuleDetailByAudit(socialIdList, file, sheetName);
} catch (Exception e) {
log.error(errorRemark + "1:", e);
if (!logList.isEmpty()) {
// 异常时,更新日志
for (TSocialSoldierLog logTemp : logList) {
logTemp.setRemark(errorRemark);
}
tSocialSoldierLogService.updateBatchById(logList);
}
}
}
}
// 医生大【新增】待审核列表
List<SocialSoldierYsdAuditVo> ysdAddlist = baseMapper.getSocialSoldierYsdAddAuditVoList();
List<SocialSoldierYsdAuditVo> ysdAddByGroupBylist = baseMapper.getSocialSoldierYsdAddAuditVoListByGroupBy();
logList = new ArrayList<>();
if (ysdAddlist != null && !ysdAddlist.isEmpty()) {
MultipartFile file = this.getFileByAudit(null, ysdAddByGroupBylist, sheetName);
if (Common.isNotNull(file)) {
List<TSocialInfo> socialIdList = new ArrayList<>();
TSocialInfo socialInfo;
for (SocialSoldierYsdAuditVo vo : ysdAddlist) {
socialInfo = new TSocialInfo();
socialInfo.setId(vo.getSocialId());
socialIdList.add(socialInfo);
// 组装日志
socialLog = tSocialSoldierLogService.getYsdSoldierAuditLog(vo, type, remark);
if (socialLog != null) {
logList.add(socialLog);
}
}
// 保存
if (!logList.isEmpty()) {
tSocialSoldierLogService.saveBatch(logList);
}
try {
this.getOneAppGetModuleDetailByAudit(socialIdList, file, sheetName);
} catch (Exception e) {
log.error(errorRemark + "3:", e);
if (!logList.isEmpty()) {
// 异常时,更新日志
for (TSocialSoldierLog logTemp : logList) {
logTemp.setRemark(errorRemark);
}
tSocialSoldierLogService.updateBatchById(logList);
}
}
}
}
if (ygsAddlist == null && ysdXuBaolist == null && ysdAddlist == null) {
return R.failed("无数据,推送结束!");
}
return R.ok("推送成功!!");
}
/**
* @Description: 推送审核结果的查询
* @Author: hgw
* @Date: 2024/5/23 18:09
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
public R<String> getOneAppGetModuleDetailByShenBao(TSocialSoldierShenBaoTask task, MultipartFile file, String type) {
// 1获取模板id——社保增员、社保减员、医保增员、医保减员
Map<String, String> moduleDetailMap = socialConfig.getOneModuleDetailMap(restTemplate);
if (moduleDetailMap != null && !moduleDetailMap.isEmpty() && moduleDetailMap.get(type) != null) {
// 2获取机器id
String terminalId = socialConfig.getTwoTerminalId(restTemplate, moduleDetailMap.get(type));
if (Common.isNotNull(terminalId)) {
// 3上传文件,获取文件地址
String fileAddUrl = socialConfig.getThreeTerminalId(restTemplate, file);
// 4 推送办理任务,返回任务id:
String addId = socialConfig.getFourAppAdd(restTemplate, fileAddUrl, moduleDetailMap.get(type), terminalId);
task.setAddId(addId);
tSocialSoldierShenBaoTaskService.save(task);
}
}
return R.ok("推送成功!");
}
/**
* @Description: 推送审核结果的查询
* @Author: hgw
* @Date: 2024/5/23 18:09
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
public R<String> getOneAppGetModuleDetailByAudit(List<TSocialInfo> socialList, MultipartFile file, String type) {
// 1获取模板id——社保增员、社保减员、医保增员、医保减员
Map<String, String> moduleDetailMap = socialConfig.getOneModuleDetailMap(restTemplate);
if (moduleDetailMap != null && !moduleDetailMap.isEmpty() && moduleDetailMap.get(type) != null) {
// 2获取机器id
String terminalId = socialConfig.getTwoTerminalId(restTemplate, moduleDetailMap.get(type));
if (Common.isNotNull(terminalId)) {
// 3上传文件,获取文件地址
String fileAddUrl = socialConfig.getThreeTerminalId(restTemplate, file);
// 4 推送办理任务,返回任务id:
String addId = socialConfig.getFourAppAdd(restTemplate, fileAddUrl, moduleDetailMap.get(type), terminalId);
for (TSocialInfo socialInfo : socialList) {
if ("审核数据查询".equals(type)) {
socialInfo.setYgsAddId(addId);
} else {
socialInfo.setYsdAddId(addId);
}
}
tSocialInfoService.updateBatchById(socialList);
}
}
return R.ok("推送成功!");
}
/**
* @Description: 组装社保与医保的文件流
* @Author: hgw
* @Date: 2024/5/23 17:59
* @return: org.springframework.web.multipart.MultipartFile
**/
public MultipartFile getFile(List list, Class clazz, String sheetName) {
String fileName = "soldierFile" + DateUtil.getThisTime() + new Date().getTime() + CommonConstants.XLSX;
if (list != null) {
EasyExcelFactory.write(fileName, clazz).sheet(sheetName).doWrite(list);
File file = new File(fileName);
return getMultipartFile(file);
}
return null;
}
/**
* @Description: 组装社保与医保的文件流
* @Author: hgw
* @Date: 2024/5/23 17:59
* @return: org.springframework.web.multipart.MultipartFile
**/
public MultipartFile getFileByAudit(List<SocialSoldierYgsAuditVo> listYgs, List<SocialSoldierYsdAuditVo> listYsd, String sheetName) {
String fileName = "soldierAuditFile" + DateUtil.getThisTime() + new Date().getTime() + CommonConstants.XLSX;
if (listYgs != null) {
EasyExcelFactory.write(fileName, SocialSoldierYgsAuditVo.class).sheet(sheetName).doWrite(listYgs);
} else {
EasyExcelFactory.write(fileName, SocialSoldierYsdAuditVo.class).sheet(sheetName).doWrite(listYsd);
}
File file = new File(fileName);
return getMultipartFile(file);
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.CharsetUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.social.config.SocialConfig;
import com.yifu.cloud.plus.v1.yifu.social.entity.FailReasonConfig;
import com.yifu.cloud.plus.v1.yifu.social.entity.TAuditInfo;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialInfo;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialSoldierLog;
import com.yifu.cloud.plus.v1.yifu.social.mapper.TSocialFriendMapper;
import com.yifu.cloud.plus.v1.yifu.social.service.*;
import com.yifu.cloud.plus.v1.yifu.social.vo.TSocialSoldierReturnAuditErrorVo;
import com.yifu.cloud.plus.v1.yifu.social.vo.TSocialSoldierReturnErrorVo;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
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.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.io.*;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/**
* 社保士兵
*
* @author hgw
* @date 2024-5-8 14:55:36
*/
@AllArgsConstructor
@Log4j2
@Service
public class TSocialFriendServiceImpl extends ServiceImpl<TSocialFriendMapper, TSocialInfo> implements TSocialFriendService {
private RestTemplate restTemplate = new RestTemplate();
private final SocialConfig socialConfig;
private final TDispatchInfoService tDispatchInfoService;
private final TSocialInfoService tSocialInfoService;
private final FailReasonConfigService failReasonConfigService;
private final TAuditInfoService tAuditInfoService;
private final TSocialSoldierLogService tSocialSoldierLogService;
// 附件
private final String RESULT_ANNEX = "resultAnnex";
/**
* 根据路径删除指定的目录或文件,无论存在与否
*
* @param path 要删除的目录或文件路径
* @return 删除成功返回 true,否则返回 false
*/
public static void deleteFolder(String path) {
File file = new File(path);
// 判断目录或文件是否存在
if (file.exists()) {
// 判断是否为文件
if (file.isFile()) { // 为文件时调用删除文件方法
deleteFile(path);
} else { // 为目录时调用删除目录方法
deleteDirectory(path);
}
}
}
/**
* 删除单个文件
*/
private static boolean deleteFile(String path) {
File file = new File(path);
// 路径为文件且不为空则进行删除
if (file.isFile() && file.exists()) {
file.delete();
return true;
}
return false;
}
/**
* 删除目录(文件夹)以及目录下的文件
*/
private static boolean deleteDirectory(String path) {
//如果path不以文件分隔符结尾,自动添加文件分隔符
if (!path.endsWith(File.separator)) {
path = path + File.separator;
}
File dirFile = new File(path);
//如果dir对应的文件不存在,或者不是一个目录,则退出
if (!dirFile.exists() || !dirFile.isDirectory()) {
return false;
}
boolean flag = true;
//删除文件夹下的所有文件(包括子目录)
File[] files = dirFile.listFiles();
for (File file : files) {
//删除子文件
if (file.isFile()) {
flag = deleteFile(file.getAbsolutePath());
} //删除子目录
else {
flag = deleteDirectory(file.getAbsolutePath());
}
if (!flag) {
break;
}
}
if (!flag) {
return false;
}
//删除当前目录
return dirFile.delete();
}
private BigDecimal getBigDecimal(String paymentBase) {
if (paymentBase.contains(",")) {
paymentBase = paymentBase.replace(",", "");
}
try {
return new BigDecimal(paymentBase);
} catch (Exception e) {
log.error("社保士兵的文件里有错误的数字,需要调整代码:" + paymentBase);
return new BigDecimal("-1");
}
}
/**
* @Description: 解码URL
* @Author: hgw
* @Date: 2024/6/3 11:01
* @return: java.lang.String
**/
private String getEncodeUrl(String fileTeturnUrl) {
String dowloadUrl = fileTeturnUrl;
int indexOf = fileTeturnUrl.lastIndexOf("/") + 1;
fileTeturnUrl = fileTeturnUrl.substring(indexOf);
try {
fileTeturnUrl = URLEncoder.encode(fileTeturnUrl, "UTF-8");
} catch (UnsupportedEncodingException e) {
log.info("编码异常!");
}
dowloadUrl = dowloadUrl.substring(0, indexOf) + fileTeturnUrl;
return dowloadUrl;
}
/**
* @Description: 6 查看社保士兵审核结果查询的反馈情况
* @Author: hgw
* @Date: 2024/5/11 15:08
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Override
public R<String> getSixJobByAudit() {
// 获取所有需要反馈的任务id
// 社保 type 1:社保;2:医保
List<TSocialInfo> socialList = tSocialInfoService.getSocialSoldierYgsByAudit();
if (socialList != null && !socialList.isEmpty()) {
this.doAuditCoreByType(socialList, CommonConstants.ONE_INT);
}
// 医保
List<TSocialInfo> socialYsdList = tSocialInfoService.getSocialSoldierYsdByAudit();
if (socialYsdList != null && !socialYsdList.isEmpty()) {
this.doAuditCoreByType(socialYsdList, CommonConstants.TWO_INT);
}
return R.ok();
}
/**
* @param socialList
* @param type 1:社保;2:医保
* @Description: 整合社保与医保
* @Author: hgw
* @Date: 2024/8/16 17:43
* @return: void
**/
private void doAuditCoreByType(List<TSocialInfo> socialList, int type) {
Map<String, TSocialInfo> idCardMap = new HashMap<>();
Set<String> addIdSet = new HashSet<>();
for (TSocialInfo socialInfo : socialList) {
if (type == 1 && Common.isNotNull(socialInfo.getYgsAddId())) {
addIdSet.add(socialInfo.getYgsAddId());
idCardMap.put(socialInfo.getYgsAddId() + CommonConstants.DOWN_LINE_STRING + socialInfo.getEmpIdcard(), socialInfo);
} else if (type == 2 && Common.isNotNull(socialInfo.getYsdAddId())) {
addIdSet.add(socialInfo.getYsdAddId());
idCardMap.put(socialInfo.getYsdAddId() + CommonConstants.DOWN_LINE_STRING + socialInfo.getEmpIdcard(), socialInfo);
}
}
HttpURLConnection conn;
InputStream in = null;
Map<String, FailReasonConfig> errorMap = failReasonConfigService.getFailReasonMap();
if (!addIdSet.isEmpty()) {
for (String doAddId : addIdSet) {
R<String> resultFile = socialConfig.getFiveJob(restTemplate, doAddId, RESULT_ANNEX);
log.info("resultFileByAudit=" + resultFile);
try {
// 解决中文文件名的乱码问题
String fileTeturnUrl = resultFile.getData();
if (Common.isNotNull(fileTeturnUrl)) {
fileTeturnUrl = this.getEncodeUrl(fileTeturnUrl);
URL url = new URL(fileTeturnUrl);
conn = (HttpURLConnection) url.openConnection();
//设置超时间为30秒
conn.setConnectTimeout(30 * 1000);
in = conn.getInputStream();
// 实际读取文件内容
this.readZip(in, idCardMap, errorMap, doAddId, type);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
}
public R<List<TSocialSoldierReturnAuditErrorVo>> readZip(InputStream inputStream, Map<String, TSocialInfo> idCardMap
, Map<String, FailReasonConfig> errorMap, String doAddId, int type) {
TSocialSoldierReturnAuditErrorVo vo;
List<TSocialSoldierReturnAuditErrorVo> voList = new ArrayList<>();
XSSFWorkbook sheets = null;
ZipInputStream zin = null;
BufferedInputStream bs = null;
try {
zin = new ZipInputStream(inputStream, CharsetUtil.CHARSET_GBK);
bs = new BufferedInputStream(zin);
byte[] bytes;
ZipEntry ze;
//循环读取压缩包里面的文件
while ((ze = zin.getNextEntry()) != null) {
String name = ze.getName();
if ((ze.toString().endsWith(".xls") || ze.toString().endsWith(".xlsx")) && Common.isNotNull(name) && name.contains("汇总")) {
//读取每个文件的字节,并放进数组
bytes = new byte[(int) ze.getSize()];
bs.read(bytes, 0, (int) ze.getSize());
//将文件转成流
InputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
sheets = new XSSFWorkbook(byteArrayInputStream);
// sheet
XSSFSheet sheetAt = sheets.getSheetAt(0);
XSSFRow row;
// 每个单元格内容
String cellValue;
XSSFCell cell;
// 循环每个sheet
if (sheetAt != null && Common.isNotNull(sheetAt.getSheetName())) {
// 错误信息 所在列
Integer errorInfoNum = null;
// 企业名称 所在列
Integer companyNameNum = null;
// 证件号码 所在列
Integer idCardNum = null;
// 姓名 所在列
Integer empNameNum = null;
// 审核状态 所在列
Integer auditStatusNum = null;
// 审核意见 所在列
Integer ysdRemarkNum = null;
// 操作 所在列
Integer ygsOperationNum = null;
// 错误信息
String errorInfo;
// 企业名称
String companyName;
// 证件号码
String idCard;
// 姓名
String empName;
// 审核状态 : // 空、待审核、撤回或作废数据、审核不通过、审核通过
String auditStatus;
// 审核意见
String ysdRemark;
// 操作
String ygsOperation;
for (int rowNum = 0; rowNum <= sheetAt.getLastRowNum(); rowNum++) {
row = sheetAt.getRow(rowNum);
if (row != null) {
// 初始化
ysdRemark = null;
ygsOperation = null;
// 循环当前行的内容
if (rowNum == 0) {
for (int cellNum = 0; cellNum < row.getLastCellNum(); cellNum++) {
// 标题行
cellValue = this.getCellValue(row, cellNum);
if ("错误信息".equals(cellValue)) {
errorInfoNum = cellNum;
} else if ("企业名称".equals(cellValue)) {
companyNameNum = cellNum;
} else if ("证件号码".equals(cellValue)) {
idCardNum = cellNum;
} else if ("姓名".equals(cellValue)) {
empNameNum = cellNum;
} else if ("审核状态".equals(cellValue)) {
auditStatusNum = cellNum;
} else if ("审核意见".equals(cellValue)) {
// 医保
ysdRemarkNum = cellNum;
} else if ("操作".equals(cellValue)) {
// 社保
ygsOperationNum = cellNum;
}
}
} else {
if (Common.isEmpty(auditStatusNum) && Common.isEmpty(idCardNum)) {
return R.failed("未找到对应表头!");
} else {
if (Common.isNotNull(errorInfoNum)) {
errorInfo = getCellValue(row, errorInfoNum);
vo = new TSocialSoldierReturnAuditErrorVo();
vo.setErrorInfo(errorInfo);
voList.add(vo);
return R.failed("数据错误!!");
} else {
if (Common.isNotNull(idCardNum) && Common.isNotNull(companyNameNum)
&& Common.isNotNull(empNameNum) && Common.isNotNull(auditStatusNum)) {
companyName = getCellValue(row, companyNameNum);
idCard = getCellValue(row, idCardNum);
empName = getCellValue(row, empNameNum);
auditStatus = getCellValue(row, auditStatusNum);
if (Common.isNotNull(ysdRemarkNum)) {
ysdRemark = getCellValue(row, ysdRemarkNum);
}
if (Common.isNotNull(ygsOperationNum)) {
ygsOperation = getCellValue(row, ygsOperationNum);
}
vo = new TSocialSoldierReturnAuditErrorVo();
vo.setCompanyName(companyName);
vo.setIdCard(idCard);
vo.setEmpName(empName);
vo.setAuditStatus(auditStatus);
vo.setYsdRemark(ysdRemark);
vo.setYgsOperation(ygsOperation);
voList.add(vo);
}
}
}
}
}
}
}
}
}
zin.closeEntry();
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
if (sheets != null) {
try {
sheets.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
} finally {
try {
if (sheets != null) {
sheets.close();
}
if (zin != null) {
zin.close();
}
if (bs != null) {
bs.close();
}
if (inputStream != null) {
inputStream.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
if (!voList.isEmpty()) {
importTSocialSoldierByAudit(voList, idCardMap, errorMap, doAddId, type);
}
return R.ok(voList);
}
/**
* @param addId
* @Description: 5 查看任务进度
* @Author: hgw
* @Date: 2024/5/11 15:08
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Override
public R<String> getFiveJob(String addId) {
List<TSocialInfo> socialList;
if (Common.isEmpty(addId)) {
// 获取所有需要反馈的任务id
socialList = tSocialInfoService.getSocialSoldierYgsAll();
List<TSocialInfo> socialYsdList = tSocialInfoService.getSocialSoldierYsdAll();
if (socialYsdList != null && !socialYsdList.isEmpty()) {
if (socialList != null && !socialList.isEmpty()) {
socialList.addAll(socialYsdList);
} else {
socialList = socialYsdList;
}
}
} else {
socialList = tSocialInfoService.getSocialSoldierByAddId(addId);
}
if (socialList != null && !socialList.isEmpty()) {
Map<String, TSocialInfo> idCardMap = new HashMap<>();
Set<String> addIdSet = new HashSet<>();
for (TSocialInfo socialInfo : socialList) {
if (Common.isNotNull(socialInfo.getYgsAddId())) {
addIdSet.add(socialInfo.getYgsAddId());
idCardMap.put(socialInfo.getYgsAddId() + CommonConstants.DOWN_LINE_STRING + socialInfo.getEmpIdcard(), socialInfo);
}
if (Common.isNotNull(socialInfo.getYsdAddId())) {
addIdSet.add(socialInfo.getYsdAddId());
idCardMap.put(socialInfo.getYsdAddId() + CommonConstants.DOWN_LINE_STRING + socialInfo.getEmpIdcard(), socialInfo);
}
}
HttpURLConnection conn;
InputStream in = null;
Map<String, FailReasonConfig> errorMap = failReasonConfigService.getFailReasonMap();
if (!addIdSet.isEmpty()) {
for (String doAddId : addIdSet) {
R<String> resultFile = socialConfig.getFiveJob(restTemplate, doAddId, "resultFile");
log.info("resultFile=" + resultFile);
try {
// 解决中文文件名的乱码问题
String fileTeturnUrl = resultFile.getData();
if (Common.isNotNull(fileTeturnUrl)) {
fileTeturnUrl = this.getEncodeUrl(fileTeturnUrl);
URL url = new URL(fileTeturnUrl);
conn = (HttpURLConnection) url.openConnection();
//设置超时间为30秒
conn.setConnectTimeout(30 * 1000);
in = conn.getInputStream();
// 实际读取文件内容
this.readXls(in, idCardMap, errorMap, doAddId);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
}
return R.ok();
}
public R<List<TSocialSoldierReturnErrorVo>> readXls(InputStream inputStream, Map<String, TSocialInfo> idCardMap
, Map<String, FailReasonConfig> errorMap, String doAddId) {
TSocialSoldierReturnErrorVo vo;
List<TSocialSoldierReturnErrorVo> voList = new ArrayList<>();
HSSFWorkbook sheets = null;
try {
sheets = new HSSFWorkbook(inputStream);
// sheet
HSSFSheet sheetAt = sheets.getSheetAt(0);
HSSFRow row;
// 每个单元格内容
String cellValue;
// 内容行
int dataRow;
HSSFCell cell;
// 循环每个sheet
if (sheetAt != null && Common.isNotNull(sheetAt.getSheetName())) {
// 初始化每个sheet的数据行
dataRow = 0;
// 错误信息 所在列
Integer errorInfoNum = null;
// 是否处理完成 所在列
Integer isDoCompletedNum = null;
// 是否成功 所在列
Integer isSuccessNum = null;
// 反馈结果 所在列
Integer msgNum = null;
// 身份证号码 所在列
Integer idCardNum = null;
// 证件号码 所在列
Integer empIdCardNum = null;
// 错误信息
String errorInfo = null;
// 是否处理完成
String isDoCompleted = null;
// 是否成功
String isSuccess = null;
// 反馈结果
String msg = null;
// 身份证号码
String idCard = null;
// 证件号码
String empIdCard = null;
for (int rowNum = 0; rowNum <= sheetAt.getLastRowNum(); rowNum++) {
row = sheetAt.getRow(rowNum);
if (row != null) {
// 循环当前行的内容
if (rowNum == 0) {
for (int cellNum = 0; cellNum < row.getLastCellNum(); cellNum++) {
// 标题行
cell = row.getCell(cellNum);
cellValue = "";
try {
if (cell != null) {
if (CellType.STRING == cell.getCellType()) {
cellValue = row.getCell(cellNum).getStringCellValue();
} else if (CellType.NUMERIC == cell.getCellType()) {
cellValue = String.valueOf(row.getCell(cellNum).getNumericCellValue());
if (cellValue.contains("E")) {
cellValue = String.valueOf(new DecimalFormat("#").format(row.getCell(cellNum).getNumericCellValue()));
}
}
}
} catch (NumberFormatException e) {
cell.setCellType(CellType.STRING);
cellValue = String.valueOf(row.getCell(cellNum).getStringCellValue());
}
if ("错误信息".equals(cellValue)) {
errorInfoNum = cellNum;
} else if ("是否处理完成".equals(cellValue)) {
isDoCompletedNum = cellNum;
} else if ("是否成功".equals(cellValue)) {
isSuccessNum = cellNum;
} else if ("反馈结果".equals(cellValue)) {
msgNum = cellNum;
} else if ("身份证号码".equals(cellValue)) {
idCardNum = cellNum;
} else if ("证件号码".equals(cellValue)) {
empIdCardNum = cellNum;
}
}
} else {
if (Common.isEmpty(errorInfoNum) && Common.isEmpty(isDoCompletedNum)) {
return R.failed("未找到对应表头!");
} else {
if (Common.isNotNull(errorInfoNum)) {
errorInfo = getCellValue(row, errorInfoNum);
vo = new TSocialSoldierReturnErrorVo();
vo.setErrorInfo(errorInfo);
voList.add(vo);
return R.failed("数据错误!!");
} else {
if (Common.isNotNull(isDoCompletedNum) && Common.isNotNull(isSuccessNum)
&& Common.isNotNull(msgNum)) {
isDoCompleted = getCellValue(row, isDoCompletedNum);
isSuccess = getCellValue(row, isSuccessNum);
msg = getCellValue(row, msgNum);
if (Common.isNotNull(idCardNum)) {
idCard = getCellValue(row, idCardNum);
} else if (Common.isNotNull(empIdCardNum)) {
empIdCard = getCellValue(row, empIdCardNum);
}
vo = new TSocialSoldierReturnErrorVo();
vo.setIsDoCompleted(isDoCompleted);
vo.setIsSuccess(isSuccess);
vo.setMsg(msg);
vo.setIdCard(idCard);
vo.setEmpIdCard(empIdCard);
voList.add(vo);
}
}
}
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
if (sheets != null) {
try {
sheets.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
} finally {
if (sheets != null) {
try {
sheets.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
if (!voList.isEmpty()) {
importTSocialInfo(voList, idCardMap, errorMap, doAddId);
}
return R.ok(voList);
}
/**
* @Description: 获取单元格内容
* @Author: hgw
* @Date: 2024/5/13 16:34
* @return: java.lang.String
**/
private String getCellValue(HSSFRow row, int cellNum) {
HSSFCell cell = row.getCell(cellNum);
String cellValue = "";
try {
if (cell != null) {
if (CellType.STRING == cell.getCellType()) {
cellValue = row.getCell(cellNum).getStringCellValue();
} else if (CellType.NUMERIC == cell.getCellType()) {
cellValue = String.valueOf(row.getCell(cellNum).getNumericCellValue());
if (cellValue.contains("E")) {
cellValue = String.valueOf(new DecimalFormat("#").format(row.getCell(cellNum).getNumericCellValue()));
}
}
}
} catch (NumberFormatException e) {
cell.setCellType(CellType.STRING);
cellValue = String.valueOf(row.getCell(cellNum).getStringCellValue());
}
return cellValue;
}
private String getCellValue(XSSFRow row, int cellNum) {
XSSFCell cell = row.getCell(cellNum);
String cellValue = "";
try {
if (cell != null) {
if (CellType.STRING == cell.getCellType()) {
cellValue = row.getCell(cellNum).getStringCellValue();
} else if (CellType.NUMERIC == cell.getCellType()) {
cellValue = String.valueOf(row.getCell(cellNum).getNumericCellValue());
if (cellValue.contains("E")) {
cellValue = String.valueOf(new DecimalFormat("#").format(row.getCell(cellNum).getNumericCellValue()));
}
}
}
} catch (NumberFormatException e) {
cell.setCellType(CellType.STRING);
cellValue = String.valueOf(row.getCell(cellNum).getStringCellValue());
}
return cellValue;
}
/**
* @Description: 社保士兵审核结果的处理
* @Author: hgw
* @Date: 2024/5/27 11:30
* @return: void
**/
private void importTSocialSoldierByAudit(List<TSocialSoldierReturnAuditErrorVo> excelVOList, Map<String, TSocialInfo> idCardMap
, Map<String, FailReasonConfig> errorMap, String doAddId, int type) {
// 个性化校验逻辑
// 执行数据插入操作 组装
TSocialSoldierReturnAuditErrorVo excel;
String empIdCard;
String auditRemark;
TSocialInfo socialInfo;
List<TSocialInfo> updateSocialList = new ArrayList<>();
TSocialInfo updateSocial;
// true养工失 false 医生大
boolean typeFlag = true;
if (type == 2) {
typeFlag = false;
}
FailReasonConfig failConfig;
String ygsHandleStatus;
String ysdHandleStatus;
// 养工失办理成功的单子
List<String> ygsList = new ArrayList<>();
// 养工失办理失败的单子
List<String> ygsFailList = new ArrayList<>();
// 医生大办理成功的单子
List<String> ysdList = new ArrayList<>();
// 医生大办理失败的单子
List<String> ysdFailList = new ArrayList<>();
Map<String, TSocialInfo> socialMap = new HashMap<>();
// 处理社保办理成功后的状态同步-成功
String typeSub = CommonConstants.ZERO_STRING;
String handleStatus;
String title = null;
String handleRemark = null;
String remark = null;
String socialType;
Set<String> dbAuthsSet = new HashSet<>();
Collection<? extends GrantedAuthority> authorities = AuthorityUtils
.createAuthorityList(dbAuthsSet.toArray(new String[0]));
YifuUser user = new YifuUser("1", 1L, "", "社保士兵",
"社保士兵", "0", SecurityConstants.BCRYPT + "123456",
"12345678911", true, true, true,
true,
"1", authorities, "1",
null, null,
null);
// 记录日志
List<TSocialSoldierLog> logList = new ArrayList<>();
TSocialSoldierLog socialLog;
for (int i = 0; i < excelVOList.size(); i++) {
excel = excelVOList.get(i);
empIdCard = excel.getIdCard();
auditRemark = excel.getYgsOperation();
if (Common.isEmpty(auditRemark)) {
auditRemark = excel.getYsdRemark();
}
if (Common.isNotNull(empIdCard)) {
title = "社保";
socialInfo = idCardMap.get(doAddId + CommonConstants.DOWN_LINE_STRING + empIdCard);
if (socialInfo != null) {
ygsHandleStatus = CommonConstants.SEVEN_STRING;
ysdHandleStatus = CommonConstants.SEVEN_STRING;
if (typeFlag && CommonConstants.SEVEN_STRING.equals(socialInfo.getYgsHandleStatus())) {
updateSocial = socialMap.get(socialInfo.getId());
if (updateSocial == null) {
updateSocial = new TSocialInfo();
updateSocial.setId(socialInfo.getId());
}
// 空、待审核、撤回或作废数据、审核不通过、审核通过
if ("审核通过".equals(excel.getAuditStatus())) {
ygsHandleStatus = CommonConstants.SIX_STRING;
ygsList = new ArrayList<>();
ygsList.add(socialInfo.getDispatchId());
handleRemark = "社保士兵自动办理成功!";
remark = handleRemark;
updateSocial.setYgsRemark(handleRemark);
updateSocial.setYgsRemarkOld(auditRemark);
} else if ("审核不通过".equals(excel.getAuditStatus())) {
// 如果找到了失败原因配置:
failConfig = getConfig(auditRemark, errorMap);
if (failConfig != null) {
updateSocial.setYgsRemark(failConfig.getSimpleReason());
// failConfig.getReplay() 1 继续办理 2 中止办理 3 人工办理
// setYgsHandleStatus 3继续办理、4终止办理、5人工处理
if (CommonConstants.ONE_STRING.equals(failConfig.getReplay())) {
ygsHandleStatus = CommonConstants.THREE_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "养老、工伤、失业审核不通过!继续办理:" + failConfig.getSimpleReason();
this.doSocialTAuditInfo(socialInfo, title, title, failConfig.getSimpleReason(), user);
} else if (CommonConstants.TWO_STRING.equals(failConfig.getReplay())) {
ygsHandleStatus = CommonConstants.FOUR_STRING;
ygsFailList = new ArrayList<>();
ygsFailList.add(socialInfo.getDispatchId());
handleRemark = "中止办理:" + failConfig.getSimpleReason();
remark = "中止办理:" + failConfig.getSimpleReason();
} else if (CommonConstants.THREE_STRING.equals(failConfig.getReplay())) {
ygsHandleStatus = CommonConstants.FIVE_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "养老、工伤、失业审核不通过!人工处理:" + failConfig.getSimpleReason();
this.doSocialTAuditInfo(socialInfo, title, title, failConfig.getSimpleReason(), user);
}
} else {
handleRemark = "社保士兵审核不通过转人工处理!";
remark = auditRemark;
handleRemark += remark;
updateSocial.setYgsRemark(handleRemark);
updateSocial.setYgsRemarkOld(auditRemark);
ygsHandleStatus = CommonConstants.FIVE_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "养老、工伤、失业" + handleRemark;
this.doSocialTAuditInfo(socialInfo, title, title, title, user);
}
} else {
updateSocial.setYgsRemark(auditRemark);
updateSocial.setYgsRemarkOld(auditRemark);
handleRemark = "社保士兵审核结果:" + excel.getAuditStatus();
remark = auditRemark;
handleRemark += remark;
updateSocial.setYgsRemark(handleRemark);
updateSocial.setYgsRemarkOld(handleRemark);
ygsHandleStatus = CommonConstants.SEVEN_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "养老、工伤、失业" + handleRemark;
this.doSocialTAuditInfo(socialInfo, title, title, title, user);
}
updateSocial.setYgsHandleStatus(ygsHandleStatus);
updateSocialList.add(updateSocial);
socialMap.put(updateSocial.getId(), updateSocial);
// 拉取审核结果,加日志
if (Common.isNotNull(ygsHandleStatus)) {
socialLog = tSocialSoldierLogService.getSocialSoldierLog(socialInfo, "审核", "社保"
, getStatusName(Integer.parseInt(ygsHandleStatus)));
logList.add(socialLog);
}
} else if (!typeFlag && CommonConstants.SEVEN_STRING.equals(socialInfo.getYsdHandleStatus())) {
updateSocial = socialMap.get(socialInfo.getId());
if (updateSocial == null) {
updateSocial = new TSocialInfo();
updateSocial.setId(socialInfo.getId());
}
// 空、待审核、撤回或作废数据、审核不通过、审核通过
if ("审核通过".equals(excel.getAuditStatus())) {
ysdHandleStatus = CommonConstants.SIX_STRING;
ysdList = new ArrayList<>();
ysdList.add(socialInfo.getDispatchId());
handleRemark = "社保士兵自动办理成功!";
remark = handleRemark;
updateSocial.setYsdRemark(handleRemark);
updateSocial.setYsdRemarkOld(auditRemark);
} else if ("审核不通过".equals(excel.getAuditStatus())) {
// 如果找到了失败原因配置:
failConfig = getConfig(auditRemark, errorMap);
if (failConfig != null) {
updateSocial.setYsdRemark(failConfig.getSimpleReason());
// failConfig.getReplay() 1 继续办理 2 中止办理 3 人工办理
// ysdHandleStatus 3继续办理、4终止办理、5人工处理
if (CommonConstants.ONE_STRING.equals(failConfig.getReplay())) {
ysdHandleStatus = CommonConstants.THREE_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "医疗、生育、大病审核不通过!继续办理:" + failConfig.getSimpleReason();
this.doSocialTAuditInfo(socialInfo, title, title, failConfig.getSimpleReason(), user);
} else if (CommonConstants.TWO_STRING.equals(failConfig.getReplay())) {
ysdHandleStatus = CommonConstants.FOUR_STRING;
ysdFailList = new ArrayList<>();
ysdFailList.add(socialInfo.getDispatchId());
handleRemark = "中止办理:" + failConfig.getSimpleReason();
remark = "中止办理:" + failConfig.getSimpleReason();
} else if (CommonConstants.THREE_STRING.equals(failConfig.getReplay())) {
ysdHandleStatus = CommonConstants.FIVE_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "医疗、生育、大病审核不通过!人工处理:" + failConfig.getSimpleReason();
this.doSocialTAuditInfo(socialInfo, title, title, failConfig.getSimpleReason(), user);
}
} else {
handleRemark = "社保士兵审核不通过转人工处理!";
remark = auditRemark;
handleRemark += remark;
updateSocial.setYsdRemark(handleRemark);
updateSocial.setYsdRemarkOld(auditRemark);
ysdHandleStatus = CommonConstants.FIVE_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "医疗、生育、大病" + handleRemark;
this.doSocialTAuditInfo(socialInfo, title, title, title, user);
}
} else {
updateSocial.setYsdRemark(auditRemark);
handleRemark = "社保士兵审核结果:" + excel.getAuditStatus();
remark = auditRemark;
handleRemark += remark;
updateSocial.setYsdRemark(handleRemark);
// 此时不能更新old,因为医疗要判断是新增还是续期,要根据这个字段来判断
// updateSocial setYgsRemarkOld(handleRemark)
ysdHandleStatus = CommonConstants.SEVEN_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "医疗、生育、大病" + handleRemark;
this.doSocialTAuditInfo(socialInfo, title, title, title, user);
}
updateSocial.setYsdHandleStatus(ysdHandleStatus);
updateSocialList.add(updateSocial);
socialMap.put(updateSocial.getId(), updateSocial);
// 拉取审核结果,加日志
if (Common.isNotNull(ysdHandleStatus)) {
socialLog = tSocialSoldierLogService.getSocialSoldierLog(socialInfo, "审核", "医保"
, getStatusName(Integer.parseInt(ysdHandleStatus)));
logList.add(socialLog);
}
}
// 处理社保办理成功或失败,
if (!updateSocialList.isEmpty()) {
tSocialInfoService.updateBatchById(updateSocialList);
updateSocialList = new ArrayList<>();
}
handleStatus = CommonConstants.ONE_STRING;
// 处理社保办理成功后的状态同步-成功
if (!ygsList.isEmpty()) {
socialType = "1,4,3";
this.doSocialAndDispatch(ygsList, typeSub, handleStatus, handleRemark, socialType, remark, user);
}
if (!ysdList.isEmpty()) {
socialType = "2,5,6";
this.doSocialAndDispatch(ysdList, typeSub, handleStatus, handleRemark, socialType, remark, user);
}
// 处理社保办理成功后的状态同步-失败
handleStatus = CommonConstants.TWO_STRING;
if (!ygsFailList.isEmpty()) {
socialType = "1,4,3";
this.doSocialAndDispatch(ygsFailList, typeSub, handleStatus, handleRemark, socialType, remark, user);
}
if (!ysdFailList.isEmpty()) {
socialType = "2,5,6";
this.doSocialAndDispatch(ysdFailList, typeSub, handleStatus, handleRemark, socialType, remark, user);
}
}
}
}
if (!logList.isEmpty()) {
tSocialSoldierLogService.saveBatch(logList);
}
}
/**
* @Description: 社保士兵审核前的处理
* @Author: hgw
* @Date: 2024/5/27 11:29
* @return: void
**/
private void importTSocialInfo(List<TSocialSoldierReturnErrorVo> excelVOList, Map<String, TSocialInfo> idCardMap
, Map<String, FailReasonConfig> errorMap, String doAddId) {
// 个性化校验逻辑
// 执行数据插入操作 组装
TSocialSoldierReturnErrorVo excel;
String empIdCard;
TSocialInfo socialInfo;
List<TSocialInfo> updateSocialList = new ArrayList<>();
TSocialInfo updateSocial;
// true养工失 false 医生大
boolean typeFlag = true;
FailReasonConfig failConfig;
String ygsHandleStatus;
String ysdHandleStatus;
// 养工失办理成功的单子
List<String> ygsList = new ArrayList<>();
// 养工失办理失败的单子
List<String> ygsFailList = new ArrayList<>();
// 医生大办理成功的单子
List<String> ysdList = new ArrayList<>();
// 医生大办理失败的单子
List<String> ysdFailList = new ArrayList<>();
Map<String, TSocialInfo> socialMap = new HashMap<>();
// 处理社保办理成功后的状态同步-成功
String typeSub = CommonConstants.ZERO_STRING;
String handleStatus;
String title = null;
String handleRemark = null;
String remark = null;
String socialType;
Set<String> dbAuthsSet = new HashSet<>();
Collection<? extends GrantedAuthority> authorities = AuthorityUtils
.createAuthorityList(dbAuthsSet.toArray(new String[0]));
YifuUser user = new YifuUser("1", 1L, "", "社保士兵",
"社保士兵", "0", SecurityConstants.BCRYPT + "123456",
"12345678911", true, true, true,
true,
"1", authorities, "1",
null, null,
null);
// 记录日志
List<TSocialSoldierLog> logList = new ArrayList<>();
TSocialSoldierLog socialLog;
for (int i = 0; i < excelVOList.size(); i++) {
excel = excelVOList.get(i);
if ("是".equals(excel.getIsDoCompleted())) {
// 插入
empIdCard = excel.getIdCard();
if (Common.isEmpty(empIdCard)) {
empIdCard = excel.getEmpIdCard();
typeFlag = false;
}
if (Common.isNotNull(empIdCard)) {
// 初始化继续办理
ygsHandleStatus = CommonConstants.THREE_STRING;
ysdHandleStatus = CommonConstants.THREE_STRING;
title = "社保";
socialInfo = idCardMap.get(doAddId + CommonConstants.DOWN_LINE_STRING + empIdCard);
if (socialInfo != null) {
if (typeFlag &&
(CommonConstants.ONE_STRING.equals(socialInfo.getYgsHandleStatus())
|| CommonConstants.TWO_STRING.equals(socialInfo.getYgsHandleStatus())
|| CommonConstants.THREE_STRING.equals(socialInfo.getYgsHandleStatus()))) {
updateSocial = socialMap.get(socialInfo.getId());
if (updateSocial == null) {
updateSocial = new TSocialInfo();
updateSocial.setId(socialInfo.getId());
}
if ("是".equals(excel.getIsSuccess())) {
handleRemark = "社保士兵提交成功!";
remark = handleRemark;
updateSocial.setYgsRemark(handleRemark);
updateSocial.setYgsRemarkOld(handleRemark);
ygsHandleStatus = CommonConstants.SEVEN_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "养老、工伤、失业提交成功!";
this.doSocialTAuditInfo(socialInfo, title, title, title, user);
} else {
updateSocial.setYgsRemark(excel.getMsg());
updateSocial.setYgsRemarkOld(excel.getMsg());
// 过期自动变为终止
if (CommonConstants.ONE_STRING.equals(socialInfo.getYgsOverDueFlag())) {
handleRemark = "已过期,自动中止办理!";
updateSocial.setYgsRemarkOld(handleRemark);
ygsHandleStatus = CommonConstants.FOUR_STRING;
ygsFailList = new ArrayList<>();
ygsFailList.add(socialInfo.getDispatchId());
remark = handleRemark;
} else if (Common.isNotNull(excel.getMsg())) {
// 如果找到了失败原因配置:
failConfig = getConfig(excel.getMsg(), errorMap);
if (failConfig != null) {
updateSocial.setYgsRemark(failConfig.getSimpleReason());
// failConfig.getReplay() 1 继续办理 2 中止办理 3 人工办理
// setYgsHandleStatus 3继续办理、4终止办理、5人工处理
if (CommonConstants.ONE_STRING.equals(failConfig.getReplay())) {
ygsHandleStatus = CommonConstants.THREE_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "养老、工伤、失业办理失败!继续办理:" + failConfig.getSimpleReason();
this.doSocialTAuditInfo(socialInfo, title, title, failConfig.getSimpleReason(), user);
} else if (CommonConstants.TWO_STRING.equals(failConfig.getReplay())) {
ygsHandleStatus = CommonConstants.FOUR_STRING;
ygsFailList = new ArrayList<>();
ygsFailList.add(socialInfo.getDispatchId());
handleRemark = "中止办理:" + failConfig.getSimpleReason();
remark = "中止办理:" + failConfig.getSimpleReason();
} else if (CommonConstants.THREE_STRING.equals(failConfig.getReplay())) {
ygsHandleStatus = CommonConstants.FIVE_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "养老、工伤、失业办理失败!人工处理:" + failConfig.getSimpleReason();
this.doSocialTAuditInfo(socialInfo, title, title, failConfig.getSimpleReason(), user);
}
} else {
ygsHandleStatus = CommonConstants.FIVE_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "养老、工伤、失业办理失败!人工处理:" + excel.getMsg();
this.doSocialTAuditInfo(socialInfo, title, "养老、工伤、失业办理失败!人工处理:" + excel.getMsg(), excel.getMsg(), user);
}
}
}
updateSocial.setYgsHandleStatus(ygsHandleStatus);
updateSocialList.add(updateSocial);
socialMap.put(updateSocial.getId(), updateSocial);
// 拉取提交结果,加日志
if (Common.isNotNull(ygsHandleStatus)) {
socialLog = tSocialSoldierLogService.getSocialSoldierLog(socialInfo, "提交", "社保"
, getStatusName(Integer.parseInt(ygsHandleStatus)));
logList.add(socialLog);
}
} else if (!typeFlag &&
(CommonConstants.ONE_STRING.equals(socialInfo.getYsdHandleStatus())
|| CommonConstants.TWO_STRING.equals(socialInfo.getYsdHandleStatus())
|| CommonConstants.THREE_STRING.equals(socialInfo.getYsdHandleStatus()))) {
updateSocial = socialMap.get(socialInfo.getId());
if (updateSocial == null) {
updateSocial = new TSocialInfo();
updateSocial.setId(socialInfo.getId());
}
if ("是".equals(excel.getIsSuccess())) {
handleRemark = "社保士兵提交成功:" + excel.getMsg();
remark = handleRemark;
updateSocial.setYsdRemark(handleRemark);
updateSocial.setYsdRemarkOld("续保");
if (Common.isNotNull(excel.getMsg()) && excel.getMsg().contains("新增")) {
updateSocial.setYsdRemarkOld("新增");
}
ysdHandleStatus = CommonConstants.SEVEN_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "医疗、生育、大病提交成功!";
this.doSocialTAuditInfo(socialInfo, title, title, title, user);
} else {
updateSocial.setYsdRemark(excel.getMsg());
updateSocial.setYsdRemarkOld(excel.getMsg());
// 过期自动变为终止
if (CommonConstants.ONE_STRING.equals(socialInfo.getYsdOverDueFlag())) {
handleRemark = "已过期,自动中止办理!";
updateSocial.setYsdRemarkOld(handleRemark);
ysdHandleStatus = CommonConstants.FOUR_STRING;
ysdFailList = new ArrayList<>();
ysdFailList.add(socialInfo.getDispatchId());
remark = handleRemark;
} else if (Common.isNotNull(excel.getMsg())) {
// 如果找到了失败原因配置:
failConfig = getConfig(excel.getMsg(), errorMap);
if (failConfig != null) {
updateSocial.setYsdRemark(failConfig.getSimpleReason());
// failConfig.getReplay() 1 继续办理 2 中止办理 3 人工办理
// ysdHandleStatus 3继续办理、4终止办理、5人工处理
if (CommonConstants.ONE_STRING.equals(failConfig.getReplay())) {
ysdHandleStatus = CommonConstants.THREE_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "医疗、生育、大病办理失败!继续办理:" + failConfig.getSimpleReason();
this.doSocialTAuditInfo(socialInfo, title, title, failConfig.getSimpleReason(), user);
} else if (CommonConstants.TWO_STRING.equals(failConfig.getReplay())) {
ysdHandleStatus = CommonConstants.FOUR_STRING;
ysdFailList = new ArrayList<>();
ysdFailList.add(socialInfo.getDispatchId());
handleRemark = "中止办理:" + failConfig.getSimpleReason();
remark = "中止办理:" + failConfig.getSimpleReason();
} else if (CommonConstants.THREE_STRING.equals(failConfig.getReplay())) {
ysdHandleStatus = CommonConstants.FIVE_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "医疗、生育、大病办理失败!人工处理:" + failConfig.getSimpleReason();
this.doSocialTAuditInfo(socialInfo, title, title, failConfig.getSimpleReason(), user);
}
} else {
ysdHandleStatus = CommonConstants.FIVE_STRING;
// 新增流程进展明细
if (CommonConstants.ZERO_STRING.equals(socialInfo.getDispatchType())) {
title += "派增";
} else {
title += "派减";
}
title += "医疗、生育、大病办理失败!人工处理:" + excel.getMsg();
this.doSocialTAuditInfo(socialInfo, title, "医疗、生育、大病办理失败!人工处理:" + excel.getMsg(), excel.getMsg(), user);
}
}
}
updateSocial.setYsdHandleStatus(ysdHandleStatus);
updateSocialList.add(updateSocial);
socialMap.put(updateSocial.getId(), updateSocial);
// 拉取提交结果,加日志
if (Common.isNotNull(ysdHandleStatus)) {
socialLog = tSocialSoldierLogService.getSocialSoldierLog(socialInfo, "提交", "医保"
, getStatusName(Integer.parseInt(ysdHandleStatus)));
logList.add(socialLog);
}
}
// 处理社保办理成功或失败,
if (!updateSocialList.isEmpty()) {
tSocialInfoService.updateBatchById(updateSocialList);
updateSocialList = new ArrayList<>();
}
handleStatus = CommonConstants.ONE_STRING;
// 处理社保办理成功后的状态同步-成功
if (!ygsList.isEmpty()) {
socialType = "1,4,3";
this.doSocialAndDispatch(ygsList, typeSub, handleStatus, handleRemark, socialType, remark, user);
}
if (!ysdList.isEmpty()) {
socialType = "2,5,6";
this.doSocialAndDispatch(ysdList, typeSub, handleStatus, handleRemark, socialType, remark, user);
}
// 处理社保办理成功后的状态同步-失败
handleStatus = CommonConstants.TWO_STRING;
if (!ygsFailList.isEmpty()) {
socialType = "1,4,3";
this.doSocialAndDispatch(ygsFailList, typeSub, handleStatus, handleRemark, socialType, remark, user);
}
if (!ysdFailList.isEmpty()) {
socialType = "2,5,6";
this.doSocialAndDispatch(ysdFailList, typeSub, handleStatus, handleRemark, socialType, remark, user);
}
}
}
}
}
if (!logList.isEmpty()) {
tSocialSoldierLogService.saveBatch(logList);
}
}
/**
* @param status
* @Description: 返回对应文字
* @Author: hgw
* @Date: 2024/9/2 19:38
* @return: java.lang.String
**/
private String getStatusName(int status) {
String[] arr = {"空", "待办理", "自动办理中", "继续办理", "中止办理", "人工处理", "成功", "提交成功"};
return arr[status];
}
/**
* @Description: 查找失败原因的关键字
* @Author: hgw
* @Date: 2024/5/14 17:55
* @return: com.yifu.cloud.plus.v1.yifu.social.entity.FailReasonConfig
**/
private FailReasonConfig getConfig(String msg, Map<String, FailReasonConfig> errorMap) {
if (errorMap != null && Common.isNotNull(msg)) {
FailReasonConfig configTemp;
FailReasonConfig configReturn;
for (Map.Entry<String, FailReasonConfig> config : errorMap.entrySet()) {
if (msg.contains(config.getKey())) {
configTemp = config.getValue();
// 有截取且截取左右标识都在:
if (Common.isNotNull(configTemp.getIsReplace())
&& CommonConstants.ONE_STRING.equals(configTemp.getIsReplace())
&& Common.isNotNull(configTemp.getReplaceLeft())
&& Common.isNotNull(configTemp.getReplaceRight())
) {
String[] leftRes = msg.split(configTemp.getReplaceLeft());
if (leftRes.length > 1) {
String result = null;
for (int i = 1; i < leftRes.length; i++) {
if (leftRes[i].contains(configTemp.getReplaceRight())) {
String[] rightRes = leftRes[i].split(configTemp.getReplaceRight());
result = rightRes[0];
break;
}
}
if (Common.isNotNull(result) && leftRes.length > 2
&& configTemp.getReplaceLeft().equals(configTemp.getReplaceRight())) {
result = leftRes[1];
}
if (Common.isNotNull(result)) {
configReturn = new FailReasonConfig();
BeanUtil.copyProperties(configTemp, configReturn);
configReturn.setSimpleReason(configReturn.getSimpleReason()
+ configReturn.getReplaceLeft() + result + configReturn.getReplaceRight());
return configReturn;
}
}
}
return configTemp;
}
}
}
return null;
}
/**
* 调用成功的社保办理
*
* @param handleStatus 1 办理成功 2 办理失败
* @param handleRemark
* @param typeSub 0 社保 1 公积金
* @param socialType (1养老 2医疗 3失业 4工伤 5生育 6大病)
* @return
* @Author hgw
* @Date 2024-5-11 17:03:12
**/
public R<List<ErrorMessage>> doSocialAndDispatch(List<String> idList, String typeSub, String handleStatus
, String handleRemark, String socialType, String remark, YifuUser user) {
return tDispatchInfoService.addApplyHandle(idList, typeSub, handleStatus, handleRemark, socialType, remark, user, true);
}
/**
* 加办理记录
*
* @param handleRemark
* @Author hgw
* @Date 2024-5-16 11:43:33
**/
public void doSocialTAuditInfo(TSocialInfo social, String title, String handleRemark, String remark, YifuUser user) {
TAuditInfo auditInfo = new TAuditInfo();
auditInfo.setType(CommonConstants.ONE_STRING);
auditInfo.setId(null);
auditInfo.setAuditStatus(CommonConstants.TWO_STRING);
auditInfo.setAuditRemark(handleRemark);
auditInfo.setTitle(title);
auditInfo.setOrganName(user.getDeptName());
auditInfo.setAuditUser(user.getNickname());
auditInfo.setAuditTime(new Date());
auditInfo.setRemark(remark);
auditInfo.setIsCommision(CommonConstants.ONE_STRING);
auditInfo.setDispatchInfoId(social.getDispatchId());
auditInfo.setEmpIdcard(social.getEmpIdcard());
auditInfo.setSocialId(social.getId());
tAuditInfoService.save(auditInfo);
}
}
......@@ -58,4 +58,12 @@ soldier:
#线上社保士兵,一般不允许用,用之前要清理测试环境当月的社保自动化数据,否则有可能产生费用
#原先的老的 : authorizations: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI2MzcwYWIyZDRhZTI0NjQ2YTg0MTE0Mzk1Y2M2MTkzMiIsInN1YiI6IjQiLCJ1c2VyX3Bob25lIjoiIiwidXNlcl90eXBlIjoiMTAiLCJ1c2VyX25hbWUiOiLlkIjogqXnpL7kv53lo6vlhbVBUEkiLCJpc19hcHAiOiIxIiwiVXNlcklkIjoiNCIsIm5iZiI6MTcxNjE3OTIxOSwiZXhwIjoxNzI2NTQ3MjE5LCJpYXQiOjE3MTYxNzkyMTl9.Ei-52hRlfMLXLzpzmbP2xCVFZKE5sHHexzfX5PtmZ_M
#authorizations: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3ZmRjOGJmYWM0Yjg0NTkzYmMzNjllYzAwN2ExODgzZCIsInN1YiI6IjQiLCJ1c2VyX3Bob25lIjoiIiwidXNlcl90eXBlIjoiMTAiLCJ1c2VyX25hbWUiOiLlkIjogqXnpL7kv53lo6vlhbVBUEkiLCJpc19hcHAiOiIxIiwiVXNlcklkIjoiNCIsIm5iZiI6MTcyNjcxMjQzOSwiZXhwIjo1NTExMDMyNDM5LCJpYXQiOjE3MjY3MTI0Mzl9.o91Ay4hRJofg76WCColUaixuyOyWvsuMDTWZMKSThc0
#urlPre: http://60.168.131.18:55555
\ No newline at end of file
#urlPre: http://60.168.131.18:55555
#税友相关属性配置
socialFriend:
urlPre : https://test-openapi.17win.com
urlPush : /gateway/socins/hrss/employee/v2/register
urlGetInfo : /gateway/socins/hrss/employee/v2/getRegisterFeedback
appKey : 89357285571962202409230949030
appSecret : V52dkvxtFUgIvzlfNE9G8g==
\ No newline at end of file
......@@ -54,4 +54,12 @@ spring:
#社保士兵相关属性配置
soldier:
authorizations: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3ZmRjOGJmYWM0Yjg0NTkzYmMzNjllYzAwN2ExODgzZCIsInN1YiI6IjQiLCJ1c2VyX3Bob25lIjoiIiwidXNlcl90eXBlIjoiMTAiLCJ1c2VyX25hbWUiOiLlkIjogqXnpL7kv53lo6vlhbVBUEkiLCJpc19hcHAiOiIxIiwiVXNlcklkIjoiNCIsIm5iZiI6MTcyNjcxMjQzOSwiZXhwIjo1NTExMDMyNDM5LCJpYXQiOjE3MjY3MTI0Mzl9.o91Ay4hRJofg76WCColUaixuyOyWvsuMDTWZMKSThc0
urlPre: http://60.168.131.18:55555
\ No newline at end of file
urlPre: http://60.168.131.18:55555
#税友相关属性配置
socialFriend:
urlPre : https://test-openapi.17win.com
urlPush : /gateway/socins/hrss/employee/v2/register
urlGetInfo : /gateway/socins/hrss/employee/v2/getRegisterFeedback
appKey : 89357285571962202409230949030
appSecret : V52dkvxtFUgIvzlfNE9G8g==
\ No newline at end of file
......@@ -54,4 +54,11 @@ spring:
#社保士兵相关属性配置
soldier:
authorizations : Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJmODA2ZjRlYzYzZjY0NjVlOGFlZjRmZmVlOTYwMzcxNiIsInN1YiI6IjIiLCJ1c2VyX3Bob25lIjoiIiwidXNlcl90eXBlIjoiMTAiLCJ1c2VyX25hbWUiOiLmtYvor5UiLCJpc19hcHAiOiIxIiwiVXNlcklkIjoiMiIsIm5iZiI6MTcxMjg5Mjk1OCwiZXhwIjoxNzIzMjYwOTU4LCJpYXQiOjE3MTI4OTI5NTh9.oTmhLfv1tLq8aPOfO3LeqM1IDYT76YGXkqpz3dwBX4M
urlPre : http://36.7.147.29:55555
\ No newline at end of file
urlPre : http://36.7.147.29:55555
#税友相关属性配置
socialFriend:
urlPre : https://test-openapi.17win.com
urlPush : /gateway/socins/hrss/employee/v2/register
urlGetInfo : /gateway/socins/hrss/employee/v2/getRegisterFeedback
appKey : 89357285571962202409230949030
appSecret : V52dkvxtFUgIvzlfNE9G8g==
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.social.mapper.TSocialFriendMapper">
<!-- 税友基本查询-->
<sql id="getSocialSoldierBaseOne" >
SELECT
s.id as socialId,
if(a.TYPE='0','派增','派减') type,
case a.SOCIAL_HANDLE_STATUS when '0' then '未办理' when '1' then '全部办理成功' when '2' then '全部办理失败' when '3' then '部分办理成功' when '4' then '办理中' else '-' end socialHandleStatus,
case if(ifnull(h.id,0) != '0',h.PENSION_HANDLE,s.PENSION_HANDLE) when '0' then '派增待办理' when '1' then '派增办理成功' when '2' then '派增办理失败' when '3' then '派减-已派减' when '4' then '派减失败' when '5' then '派减待办理' else '——' end pensionHandle,
case if(ifnull(h.id,0) != '0',h.MEDICAL_HANDLE,s.MEDICAL_HANDLE) when '0' then '派增待办理' when '1' then '派增办理成功' when '2' then '派增办理失败' when '3' then '派减-已派减' when '4' then '派减失败' when '5' then '派减待办理' else '——' end medicalHandle,
case if(ifnull(h.id,0) != '0',h.UNEMPLOY_HANDLE,s.UNEMPLOY_HANDLE) when '0' then '派增待办理' when '1' then '派增办理成功' when '2' then '派增办理失败' when '3' then '派减-已派减' when '4' then '派减失败' when '5' then '派减待办理' else '——' end unemployHandle,
case if(ifnull(h.id,0) != '0',h.WORK_INJURY_HANDLE,s.WORK_INJURY_HANDLE) when '0' then '派增待办理' when '1' then '派增办理成功' when '2' then '派增办理失败' when '3' then '派减-已派减' when '4' then '派减失败' when '5' then '派减待办理' else '——' end workInjuryHandle,
case if(ifnull(h.id,0) != '0',h.BIRTH_HANDLE,s.BIRTH_HANDLE) when '0' then '派增待办理' when '1' then '派增办理成功' when '2' then '派增办理失败' when '3' then '派减-已派减' when '4' then '派减失败' when '5' then '派减待办理' else '——' end birthHandle,
case if(ifnull(h.id,0) != '0',h.BIGAILMENT_HANDLE,s.BIGAILMENT_HANDLE) when '0' then '派增待办理' when '1' then '派增办理成功' when '2' then '派增办理失败' when '3' then '派减-已派减' when '4' then '派减失败' when '5' then '派减待办理' else '——' end bigailmentHandle,
a.EMP_NAME empName,
a.EMP_IDCARD empIdcard,
a.EDUCATION_NAME educationName,
a.BELONG_UNIT_NAME belongUnit,
a.SETTLE_DOMAIN_NAME settleDomain,
emp_natrue.label empType,
a.POST post,
a.EMP_MOBILE empMobile,
a.ID_CARD_ADDRESS idCardAddress,
a.CONTACT_ADDRESS contactAddress,
registype.label regisType,
nation.label empNational,
workingHours.label workingHours,
a.CONTRACT_TERM contractTerm,
s.SOCIAL_START_DATE contractStart,
a.CONTRACT_END contractEnd,
a.CREATE_NAME createUserName,
s.RECORD_BASE recordBase,
case s.PAYMENT_TYPE when '0' then '最低' when '1' then '自定义' when '2' then '最高' else '-' end paymentType,
a.SOCIAL_HOUSEHOLD_NAME socialHouseholdName,
if(ifnull(h.id,0) != '0',sp1.AREA_NAME,sp2.AREA_NAME) socialProvince,
if(ifnull(h.id,0) != '0',sc1.AREA_NAME,sc2.AREA_NAME) socialCity,
if(ifnull(h.id,0) != '0',st1.AREA_NAME,st2.AREA_NAME) socialTown,
if(ifnull(h.id,0) != '0',h.PENSION_START,s.PENSION_START) pensionStart,
if(ifnull(h.id,0) != '0',h.UNIT_PENSION_CARDINAL,s.UNIT_PENSION_CARDINAL) unitPensionCardinal,
if(ifnull(h.id,0) != '0',h.MEDICAL_START,s.MEDICAL_START) medicalStart,
if(ifnull(h.id,0) != '0',h.UNIT_MEDICAL_CARDINAL,s.UNIT_MEDICAL_CARDINAL) unitMedicalCardinal,
if(ifnull(h.id,0) != '0',h.UNEMPLOY_START,s.UNEMPLOY_START) unemployStart,
if(ifnull(h.id,0) != '0',h.UNIT_UNEMPLOYMENT_CARDINAL,s.UNIT_UNEMPLOYMENT_CARDINAL) unitUnemploymentCardinal,
if(ifnull(h.id,0) != '0',h.WORK_INJURY_START,s.WORK_INJURY_START) workInjuryStart,
if(ifnull(h.id,0) != '0',h.UNIT_WORK_INJURY_CARDINAL,s.UNIT_WORK_INJURY_CARDINAL) unitWorkInjuryCardinal,
if(ifnull(h.id,0) != '0',h.BIRTH_START,s.BIRTH_START) birthStart,
if(ifnull(h.id,0) != '0',h.UNIT_BIRTH_CARDINAL,s.UNIT_BIRTH_CARDINAL) unitBirthCardinal,
if(ifnull(h.id,0) != '0',h.BIGAILMENT_START,s.BIGAILMENT_START) bigailmentStart,
if(ifnull(h.id,0) != '0',h.UNIT_BIGAILMENT_CARDINAL,s.UNIT_BIGAILMENT_CARDINAL) unitBigailmentCardinal,
if(ifnull(h.id,0) != '0',h.UNIT_BIGAILMENT_MONEY,s.UNIT_BIGAILMENT_MONEY) unitBigailmentMoney,
if(ifnull(h.id,0) != '0',h.PERSONAL_BIGAILMENT_MONEY,s.PERSONAL_BIGAILMENT_MONEY) personalBigailmentMoney,
a.TRUST_REMARK socailTrustRemark,
reduceReason.label reduceReason,
'1' as exportSocialFlag,
a.SCHOOL_NAME schoolName,
a.MAJOR major,
a.FIRST_PAY_TIME graduationTime,
a.GRADUATION_TIME firstPayTime
</sql>
<!-- 税友基本查询-->
<sql id="getSocialSoldierBaseTwo" >
FROM t_dispatch_info a
left join t_social_info s on a.SOCIAL_ID = s.id
left join t_dispatch_social_fund_info h on a.id = h.REDUCE_SOCIAL_FUND_ID
left join view_sys_dict_item emp_natrue on emp_natrue.value=a.EMP_TYPE and emp_natrue.type='emp_natrue'
left join view_sys_dict_item registype on registype.value=a.EMP_REGIS_TYPE and registype.type='emp_registype'
left join view_sys_dict_item nation on nation.value=a.EMP_NATIONAL and nation.type='emp_national'
left join view_sys_dict_item workingHours on workingHours.value=a.WORKING_HOURS and workingHours.type='working_hours'
left join view_sys_dict_item reduceReason on reduceReason.value=a.REDUCE_REASON and reduceReason.type='social_reduce_reason'
left join sys_area sp1 on sp1.id = h.SOCIAL_PROVINCE
left join sys_area sp2 on sp2.id = s.SOCIAL_PROVINCE
left join sys_area sc1 on sc1.id = h.SOCIAL_CITY
left join sys_area sc2 on sc2.id = s.SOCIAL_CITY
left join sys_area st1 on st1.id = h.SOCIAL_TOWN
left join sys_area st2 on st2.id = s.SOCIAL_TOWN
<include refid="where_getSocialSoldier_base_handler"/>
and DATE_FORMAT(a.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m')
</sql>
<!-- 税友养工失增加模板-->
<select id="getSocialSoldierYgsAddVoList" resultType="com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYgsAddVo">
<include refid="getSocialSoldierBaseOne"/>
,'是' isAutoSubmit,'是' isAutoInsert,'是' isAutoUpload,'是' isDoShenBao,'' isDanShenBao
<include refid="getSocialSoldierBaseTwo"/>
and a.type = '0' and s.YGS_HANDLE_STATUS in ('0','1','2','3')
and (
if(ifnull(h.id,0) != '0',h.PENSION_HANDLE,s.PENSION_HANDLE) = '0' or
if(ifnull(h.id,0) != '0',h.WORK_INJURY_HANDLE,s.WORK_INJURY_HANDLE) = '0' or
if(ifnull(h.id,0) != '0',h.UNEMPLOY_HANDLE,s.UNEMPLOY_HANDLE) = '0'
)
group by s.id
</select>
<sql id="where_getSocialSoldier_base_handler">
<where>
a.DELETE_FLAG = '0'
<if test="idsStr != null and idsStr.size > 0">
AND a.ID in
<foreach item="items" index="index" collection="idsStr" open="(" separator="," close=")">
#{items}
</foreach>
</if>
/** 社保办理状态:0待办理/1已办理2办理失败3已派减4 办理中 5 部分办理失败 派单社保办理状态 0 未办理 1 全部办理成功(原-已办理) 2 全部办理失败(原-办理失败) 3 部分办理成功 4 办理中 **/
/*社保代办理 1.派单审核通过 2.派增(type=0):待办理(social_handle_status='0') or 派减(type=1):已办理完成或部分办理失败 且已派减*/
AND a.social_id is not null
AND a.STATUS = "2"
and (( a.type = '0' AND (s.HANDLE_STATUS = "0" or s.HANDLE_STATUS = "4") ) or ( a.type ='1' AND (if(ifnull(h.id,0) != '0',h.HANDLE_STATUS,s.HANDLE_STATUS) in ('1','5','6','3','7') or (s.HANDLE_STATUS in ('1','5','6','3','7') and s.REDUCE_CAN = '1')) ))
and a.SOCIAL_HANDLE_STATUS in ('0','4')
and a.AUTO_FLAG = '0'
</where>
</sql>
<!-- 税友养工失减少模板-->
<select id="getSocialSoldierYgsReduceVoList" resultType="com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYgsAddVo">
<include refid="getSocialSoldierBaseOne"/>
,'是' isAutoSubmit,'是' isAutoInsert,'是' isAutoUpload,'是' isDoShenBao,'' isDanShenBao
<include refid="getSocialSoldierBaseTwo"/>
and a.type = '1' and s.YGS_HANDLE_STATUS in ('0','1','2','3')
and (
if(ifnull(h.id,0) != '0',h.PENSION_HANDLE,s.PENSION_HANDLE) = '5' or
if(ifnull(h.id,0) != '0',h.WORK_INJURY_HANDLE,s.WORK_INJURY_HANDLE) = '5' or
if(ifnull(h.id,0) != '0',h.UNEMPLOY_HANDLE,s.UNEMPLOY_HANDLE) = '5'
)
group by a.id
</select>
<!-- 税友医生大增加模板-->
<select id="getSocialSoldierYsdAddVoList" resultType="com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYsdAddVo">
<include refid="getSocialSoldierBaseOne"/>
,'' isBatch,'是' isAutoMonth,'' isAdd,'' isXu,'是' isShen
<include refid="getSocialSoldierBaseTwo"/>
and a.type = '0' and s.YSD_HANDLE_STATUS in ('0','1','2','3')
and (
if(ifnull(h.id,0) != '0',h.MEDICAL_HANDLE,s.MEDICAL_HANDLE) = '0' or
if(ifnull(h.id,0) != '0',h.BIRTH_HANDLE,s.BIRTH_HANDLE) = '0' or
if(ifnull(h.id,0) != '0',h.BIGAILMENT_HANDLE,s.BIGAILMENT_HANDLE) = '0'
)
group by s.id
</select>
<!-- 税友医生大减少模板-->
<select id="getSocialSoldierYsdReduceVoList" resultType="com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYsdAddVo">
<include refid="getSocialSoldierBaseOne"/>
,'' isBatch,'是' isAutoMonth,'' isAdd,'' isXu,'是' isShen
<include refid="getSocialSoldierBaseTwo"/>
and a.type = '1' and s.YSD_HANDLE_STATUS in ('0','1','2','3')
and (
if(ifnull(h.id,0) != '0',h.MEDICAL_HANDLE,s.MEDICAL_HANDLE) = '5' or
if(ifnull(h.id,0) != '0',h.BIRTH_HANDLE,s.BIRTH_HANDLE) = '5' or
if(ifnull(h.id,0) != '0',h.BIGAILMENT_HANDLE,s.BIGAILMENT_HANDLE) = '5'
)
group by s.id
</select>
<!-- 税友养工失审核结果查询的模板-->
<select id="getSocialSoldierYgsAuditVoList" resultType="com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYgsAuditVo">
SELECT
s.id as socialId,
a.EMP_NAME empName,
a.EMP_IDCARD empIdcard,
a.SOCIAL_HOUSEHOLD_NAME socialHouseholdName,
if(a.TYPE='0','增员','减员') type,
DATE_FORMAT(a.AUDIT_TIME,'%Y%m%d') startDate,
DATE_FORMAT(now(),'%Y%m%d') endDate,
'' backInfo,'' backInfoOne,'' backInfoTwo
FROM t_dispatch_info a
left join t_social_info s on a.SOCIAL_ID = s.id
where a.DELETE_FLAG = '0' AND a.social_id is not null AND a.STATUS = "2" AND s.YGS_HANDLE_STATUS = '7'
and a.AUTO_FLAG = '0' and DATE_FORMAT(a.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m')
group by s.id
</select>
<!-- 税友医生大审核结果【续保】查询的模板-->
<select id="getSocialSoldierYsdAuditVoList" resultType="com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYsdAuditVo">
SELECT
s.id as socialId,
a.EMP_NAME empName,
a.EMP_IDCARD empIdcard,
a.SOCIAL_HOUSEHOLD_NAME socialHouseholdName,
if(a.TYPE='0','参保人员增员申报','参保人员减员申报') type,
DATE_FORMAT(a.AUDIT_TIME,'%Y%m%d') startDate,
DATE_FORMAT(now(),'%Y%m%d') endDate,
'' backInfo,'' backInfoOne,'' backInfoTwo
FROM t_dispatch_info a
left join t_social_info s on a.SOCIAL_ID = s.id
where a.DELETE_FLAG = '0' AND a.social_id is not null AND a.STATUS = "2" AND s.YSD_HANDLE_STATUS = '7'
and a.AUTO_FLAG = '0' and DATE_FORMAT(a.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m')
and s.YSD_REMARK_OLD != "新增"
group by s.id
</select>
<!-- 税友养工失审核结果查询的模板-->
<select id="getSocialSoldierYgsAuditVoListByGroupBy" resultType="com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYgsAuditVo">
SELECT
a.SOCIAL_HOUSEHOLD_NAME socialHouseholdName,
if(a.TYPE='0','增员','减员') type,
DATE_FORMAT(min(a.AUDIT_TIME),'%Y%m%d') startDate,
DATE_FORMAT(now(),'%Y%m%d') endDate,
'' backInfo,'' backInfoOne,'' backInfoTwo
FROM t_dispatch_info a
left join t_social_info s on a.SOCIAL_ID = s.id
where a.DELETE_FLAG = '0' AND a.social_id is not null AND a.STATUS = "2" AND s.YGS_HANDLE_STATUS = '7'
and a.AUTO_FLAG = '0' and DATE_FORMAT(a.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m')
group by a.SOCIAL_HOUSEHOLD_NAME,a.TYPE
</select>
<!-- 税友医生大审核结果【续保】查询的模板-->
<select id="getSocialSoldierYsdAuditVoListByGroupBy" resultType="com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYsdAuditVo">
SELECT
a.SOCIAL_HOUSEHOLD_NAME socialHouseholdName,
if(a.TYPE='0','参保人员增员申报','参保人员减员申报') type,
DATE_FORMAT(min(a.AUDIT_TIME),'%Y%m%d') startDate,
DATE_FORMAT(now(),'%Y%m%d') endDate,
'' backInfo,'' backInfoOne,'' backInfoTwo
FROM t_dispatch_info a
left join t_social_info s on a.SOCIAL_ID = s.id
where a.DELETE_FLAG = '0' AND a.social_id is not null AND a.STATUS = "2" AND s.YSD_HANDLE_STATUS = '7'
and a.AUTO_FLAG = '0' and DATE_FORMAT(a.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m')
and s.YSD_REMARK_OLD != "新增"
group by a.SOCIAL_HOUSEHOLD_NAME,a.TYPE
</select>
<!-- 税友医生大审核结果【新增】查询的模板-->
<select id="getSocialSoldierYsdAddAuditVoList" resultType="com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYsdAuditVo">
SELECT
s.id as socialId,
a.EMP_NAME empName,
a.EMP_IDCARD empIdcard,
a.SOCIAL_HOUSEHOLD_NAME socialHouseholdName,
if(a.TYPE='0','职工新参保登记','参保人员减员申报') type,
DATE_FORMAT(a.AUDIT_TIME,'%Y%m%d') startDate,
DATE_FORMAT(now(),'%Y%m%d') endDate,
'' backInfo,'' backInfoOne,'' backInfoTwo
FROM t_dispatch_info a
left join t_social_info s on a.SOCIAL_ID = s.id
where a.DELETE_FLAG = '0' AND a.social_id is not null AND a.STATUS = "2" AND s.YSD_HANDLE_STATUS = '7'
and a.AUTO_FLAG = '0' and DATE_FORMAT(a.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m')
and s.YSD_REMARK_OLD = "新增"
group by s.id
</select>
<!-- 税友医生大审核结果【新增】查询的模板-->
<select id="getSocialSoldierYsdAddAuditVoListByGroupBy" resultType="com.yifu.cloud.plus.v1.yifu.social.vo.SocialSoldierYsdAuditVo">
SELECT
a.SOCIAL_HOUSEHOLD_NAME socialHouseholdName,
if(a.TYPE='0','职工新参保登记','参保人员减员申报') type,
DATE_FORMAT(min(a.AUDIT_TIME),'%Y%m%d') startDate,
DATE_FORMAT(now(),'%Y%m%d') endDate,
'' backInfo,'' backInfoOne,'' backInfoTwo
FROM t_dispatch_info a
left join t_social_info s on a.SOCIAL_ID = s.id
where a.DELETE_FLAG = '0' AND a.social_id is not null AND a.STATUS = "2" AND s.YSD_HANDLE_STATUS = '7'
and a.AUTO_FLAG = '0' and DATE_FORMAT(a.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m')
and s.YSD_REMARK_OLD = "新增"
group by a.SOCIAL_HOUSEHOLD_NAME,a.TYPE
</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