Commit 4e68f989 authored by hongguangwu's avatar hongguangwu

MVP1.6.2-工资原表识别-优化

parent ec9092bb
package com.yifu.cloud.plus.v1.check.vo;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @Author hgw
* @Date 2024-4-16 19:39:51
*/
@Data
public class CheckIdCardListVo implements Serializable {
// 200:成功; 其他:失败
private int code;
// 错误信息
private String errorMsg;
// 其他内容
private List<TCheckIdCard> checkList = new ArrayList<>();
}
......@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.service.TCheckIdCardService;
import com.yifu.cloud.plus.v1.check.vo.CheckIdCardListVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
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;
......@@ -176,4 +178,35 @@ public class TCheckIdCardController {
public R<List<TCheckIdCard>> checkSalaryIdCard(@RequestBody List<TCheckIdCard> checkList) {
return tCheckIdCardService.checkSalaryIdCard(checkList);
}
/**
* @Description: 批量校验姓名身份证
* @Author: hgw
* @Date: 2024-4-16 19:47:20
* @return: com.yifu.cloud.v1.common.core.util.R
**/
@Operation(description = "批量校验姓名身份证")
@SysLog("批量校验姓名身份证")
@Inner
@PostMapping("/inner/checkIdCardList")
public CheckIdCardListVo checkIdCardList(@RequestBody CheckIdCardListVo vo) {
CheckIdCardListVo returnVo = new CheckIdCardListVo();
R<List<TCheckIdCard>> checkR = tCheckIdCardService.checkSalaryIdCard(vo.getCheckList());
if (checkR != null) {
if (checkR.getCode() == CommonConstants.SUCCESS) {
returnVo.setCode(CommonConstants.SUCCESS);
return returnVo;
} else {
returnVo.setCode(checkR.getCode());
returnVo.setErrorMsg(checkR.getMsg());
returnVo.setCheckList(checkR.getData());
return returnVo;
}
} else {
returnVo.setCode(CommonConstants.FAIL);
returnVo.setErrorMsg("校验服务无返回!");
return returnVo;
}
}
}
......@@ -20,10 +20,15 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.vo.CheckIdCardListVo;
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.dapr.config.DaprCheckProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginalDetail;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryStandardOriginalMapper;
......@@ -43,6 +48,8 @@ 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.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
......@@ -66,9 +73,11 @@ import java.util.regex.Pattern;
@Log4j2
@Service
@AllArgsConstructor
@EnableConfigurationProperties({DaprCheckProperties.class})
public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStandardOriginalMapper, TSalaryStandardOriginal>
implements TSalaryStandardOriginalService {
private DaprCheckProperties checkProperties;
private final SalaryUploadService salaryUploadService;
private final TSalaryStandardOriginalDetailService tSalaryStandardOriginalDetailService;
......@@ -732,9 +741,13 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
String value;
String oldValue;
int i = 0;
List<TCheckIdCard> checkList = new ArrayList<>();
TCheckIdCard check;
StringBuilder errMsg = new StringBuilder();
for (Map<String, String> rowMap : vo.getContentList()) {
i++;
newRowMap = new HashMap<>();
check = new TCheckIdCard();
for (Map.Entry<String, String> column : rowMap.entrySet()) {
detail = detailMap.get(column.getKey());
if (detail != null && Common.isNotNull(detail.getModelName())) {
......@@ -752,10 +765,69 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
return R.failed("第 " + i + " 行,第 " + (Integer.parseInt(column.getKey()) + 1) + " 列 不是金额,不可以进行加减计算!");
}
newRowMap.put(detail.getModelName(), value);
if (SalaryConstants.ID_NUMBER.equals(detail.getModelName())) {
check.setIdCard(value);
}
if (SalaryConstants.EMP_NAME2.equals(detail.getModelName())) {
check.setName(value);
}
}
}
if (Common.isEmpty(check.getIdCard())) {
return R.failed("第 " + i + " 行,无身份证号!");
}
if (Common.isEmpty(check.getName())) {
return R.failed("第 " + i + " 行,无员工姓名!");
}
// 调用校验服务
String pre = "姓名与身份证验证:";
R<TCheckIdCard> checkListR = HttpDaprUtil.invokeMethodPost(checkProperties.getAppUrl(), checkProperties.getAppId()
, "/tcheckidcard/inner/checkIdCardSingle", check, TCheckIdCard.class, SecurityConstants.FROM_IN);
if (checkListR != null && checkListR.getData() != null) {
TCheckIdCard checkR = checkListR.getData();
if (checkR == null || Common.isEmpty(checkR.getIsTrue())) {
errMsg.append("第 ").append(i).append(" 行:").append(check.getIdCard()).append(pre).append("校验服务器未返回,请联系管理员!");
} else if (checkR.getIsTrue() == CommonConstants.ZERO_INT) {
errMsg.append("第 ").append(i).append(" 行:").append(check.getIdCard()).append(pre).append(check.getReason());
}
} else {
errMsg.append("第 ").append(i).append(" 行:").append(check.getIdCard()).append(pre).append("校验服务器未返回,请联系管理员!!");
}
checkList.add(check);
contentList.add(newRowMap);
}
if (Common.isNotNull(errMsg) && Common.isNotNull(errMsg.toString())) {
return R.failed(errMsg.toString());
}
/*// 调用校验服务
CheckIdCardListVo checkVo = new CheckIdCardListVo();
checkVo.setCheckList(checkList);
R<CheckIdCardListVo> checkListR = HttpDaprUtil.invokeMethodPost(checkProperties.getAppUrl(), checkProperties.getAppId()
, "/tcheckidcard/inner/checkIdCardList", checkVo, CheckIdCardListVo.class, SecurityConstants.FROM_IN);
if (checkListR != null && checkListR.getData() != null) {
CheckIdCardListVo checkReturnVo = checkListR.getData();
if (checkReturnVo.getCode() != CommonConstants.SUCCESS) {
if (checkReturnVo.getCheckList() != null && !checkReturnVo.getCheckList().isEmpty()) {
int cardRow = 0;
StringBuilder errMsg = new StringBuilder();
for (TCheckIdCard card : checkReturnVo.getCheckList()) {
cardRow++;
if (card.getIsTrue() == 0) {
errMsg.append(" 第").append(cardRow).append("行:").append(card.getIdCard()).append(",姓名身份证校验错误! ");
}
}
return R.failed(errMsg.toString());
} else {
return R.failed(checkReturnVo.getErrorMsg());
}
}
} else {
return R.failed("原表识别校验姓名身份证,但是校验服务器未返回,请联系管理员!");
}*/
// 最后转化为jsonString
jsonString = JSON.toJSON(contentList).toString();
}
......
......@@ -39,6 +39,7 @@ public class SalaryConstants {
//模板列必填
public static final String IS_MUST = "1";
public static final String EMP_NAME = "姓名";
public static final String EMP_NAME2 = "员工姓名";
public static final String IF_NEW_EMPLOYEE = "是否新员工(默认否)";
public static final String IS_NEW_EMPLOYEE = "是否新员工";
public static final String IS_NEW = "是";
......
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