/*
 *    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.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.mapper.TSocialSoldierMapper;
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.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
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 TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper, TSocialInfo> implements TSocialSoldierService {

	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;


	/**
	 * @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
		List<TSocialInfo> socialList = tSocialInfoService.getSocialSoldierYgsByAudit();
		List<TSocialInfo> socialYsdList = tSocialInfoService.getSocialSoldierYsdByAudit();
		if (socialYsdList != null && !socialYsdList.isEmpty()) {
			if (socialList != null && !socialList.isEmpty()) {
				socialList.addAll(socialYsdList);
			} else {
				socialList = socialYsdList;
			}
		}

		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, "resultAnnex");
					log.info("resultFileByAudit=" + resultFile);
					try {
						// 解决中文文件名的乱码问题
						String fileTeturnUrl = resultFile.getData();
						if (Common.isNotNull(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;
							URL url = new URL(dowloadUrl);
							conn = (HttpURLConnection) url.openConnection();
							//设置超时间为30秒
							conn.setConnectTimeout(30 * 1000);
							in = conn.getInputStream();
							// 实际读取文件内容
							this.readZip(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<TSocialSoldierReturnAuditErrorVo>> readZip(InputStream inputStream, Map<String, TSocialInfo> idCardMap
			, Map<String, FailReasonConfig> errorMap, String doAddId) {
		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 = null;
			ZipEntry ze;
			//循环读取压缩包里面的文件
			while ((ze = zin.getNextEntry()) != null) {
				String name = ze.getName();
				if (ze.toString().endsWith(".xls") && 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++) {
										// 标题行
										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)) {
											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);
		}
		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)) {
							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;
							URL url = new URL(dowloadUrl);
							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) {
		// 个性化校验逻辑
		// 执行数据插入操作 组装
		TSocialSoldierReturnAuditErrorVo excel;
		String empIdCard;
		String auditRemark;
		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);
		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();
				typeFlag = false;
			}
			if (Common.isNotNull(empIdCard)) {
				title = "社保";
				socialInfo = idCardMap.get(doAddId + CommonConstants.DOWN_LINE_STRING + empIdCard);
				if (socialInfo != null) {

					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;
							if (Common.isNotNull(auditRemark)) {
								failConfig = getConfig(auditRemark, errorMap);
								if (failConfig != null) {
									updateSocial.setYgsRemark(failConfig.getSimpleReason());
								}
								updateSocial.setYgsRemarkOld(handleRemark);
							} else {
								updateSocial.setYgsRemark(handleRemark);
								updateSocial.setYgsRemarkOld(auditRemark);
							}
						} else if ("审核不通过".equals(excel.getAuditStatus())) {
							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);
							/*// 过期自动变为终止
							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(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);
					} 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;
							if (Common.isNotNull(auditRemark)) {
								failConfig = getConfig(auditRemark, errorMap);
								if (failConfig != null) {
									updateSocial.setYsdRemark(failConfig.getSimpleReason());
								}
								updateSocial.setYsdRemarkOld(handleRemark);
							} else {
								updateSocial.setYsdRemark(handleRemark);
								updateSocial.setYsdRemarkOld(auditRemark);
							}
						} else if ("审核不通过".equals(excel.getAuditStatus())) {
							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);
							// 过期自动变为终止——这块加查询sql影响性能，且暂时没有这要求 hgw 2024-5-27 15:54:24
							/*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(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 (!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);
					}
				}
			}
		}
	}

	/**
	 * @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);
		for (int i = 0; i < excelVOList.size(); i++) {
			excel = excelVOList.get(i);
			if ("是".equals(excel.getIsDoCompleted())) {
				// 插入
				log.info(excel.getErrorInfo());
				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())) {
								/*ygsHandleStatus = CommonConstants.SIX_STRING;
								ygsList = new ArrayList<>();
								ygsList.add(socialInfo.getDispatchId());
								handleRemark = "社保士兵自动办理成功！";
								remark = "社保士兵自动办理成功！！";
								if (Common.isNotNull(excel.getMsg())) {
									failConfig = getConfig(excel.getMsg(),errorMap);
									if (failConfig != null) {
										updateSocial.setYgsRemark(failConfig.getSimpleReason());
									}
									updateSocial.setYgsRemarkOld(handleRemark);
								} else {
									updateSocial.setYgsRemark(handleRemark);
									updateSocial.setYgsRemarkOld(handleRemark);
								}*/

								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);
						} 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())) {
								// 2024-5-20 11:40:54 暂时将成功变为人工办理：
								/*ysdHandleStatus = CommonConstants.SIX_STRING;
								ysdList = new ArrayList<>();
								ysdList.add(socialInfo.getDispatchId());
								handleRemark = "社保士兵自动办理成功！";
								remark = "社保士兵自动办理成功！！";
								if (Common.isNotNull(excel.getMsg())) {
									failConfig = getConfig(excel.getMsg(),errorMap);
									if (failConfig != null) {
										updateSocial.setYsdRemark(failConfig.getSimpleReason());
									}
									updateSocial.setYsdRemarkOld(handleRemark);
								} else {
									updateSocial.setYsdRemark(handleRemark);
									updateSocial.setYsdRemarkOld(handleRemark);
								}*/
								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, "医疗、生育、大病办理失败！人工处理：" + failConfig.getSimpleReason(), 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 (!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);
						}
					}
				}
			}
		}
	}

	/**
	 * @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) {
			for (Map.Entry<String, FailReasonConfig> config : errorMap.entrySet()) {
				if (msg.contains(config.getKey())) {
					return config.getValue();
				}
			}
		}
		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);
	}

}
