Commit 30f19b8b authored by hongguangwu's avatar hongguangwu

MVP1.4-export里面的薪资导入人员

parent 050420e6
package com.yifu.cloud.plus.v1.yifu.salary.vo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryEmployee;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* @author hgw
* @description 薪资人员导入vo
* @date 2023/1/17
*/
@Getter
@Setter
public class SalaryEmployeeImportVo {
private List<TSalaryEmployee> empList;
private TSettleDomain dept;
private String isUpdate;
}
...@@ -29,6 +29,7 @@ import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; ...@@ -29,6 +29,7 @@ import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils; import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryEmployee; import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryEmployee;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryEmployeeService; import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryEmployeeService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryEmployeeImportVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeExportVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeExportVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeSearchVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeSearchVo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
...@@ -180,4 +181,20 @@ public class TSalaryEmployeeController { ...@@ -180,4 +181,20 @@ public class TSalaryEmployeeController {
public R<List<ErrorMessage>> batchUpdateSalaryEmployee(@RequestBody MultipartFile file) { public R<List<ErrorMessage>> batchUpdateSalaryEmployee(@RequestBody MultipartFile file) {
return tSalaryEmployeeService.batchUpdateSalaryEmployee(file.getInputStream()); return tSalaryEmployeeService.batchUpdateSalaryEmployee(file.getInputStream());
} }
/**
* @param vo
* @Description: 批量新增或更新人员
* @Author: hgw
* @Date: 2023/1/17 15:35
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage>>
**/
@Operation(description = "批量新增或更新人员")
@SysLog("批量新增或更新人员")
@PostMapping("/importEmployee")
@PreAuthorize("@pms.hasPermission('tsalaryemployee_import_employee')")
public R<List<ErrorMessage>> importEmployee(@RequestBody SalaryEmployeeImportVo vo) {
return tSalaryEmployeeService.importEmployee(vo);
}
} }
...@@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; 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.util.R;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryEmployee; import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryEmployee;
import com.yifu.cloud.plus.v1.yifu.salary.vo.SalaryEmployeeImportVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeExportVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeExportVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeSearchVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeSearchVo;
...@@ -69,6 +70,15 @@ public interface TSalaryEmployeeService extends IService<TSalaryEmployee> { ...@@ -69,6 +70,15 @@ public interface TSalaryEmployeeService extends IService<TSalaryEmployee> {
**/ **/
R<List<ErrorMessage>> batchUpdateSalaryEmployee(InputStream inputStream); R<List<ErrorMessage>> batchUpdateSalaryEmployee(InputStream inputStream);
/**
* @param vo
* @Description: 批量新增或更新人员
* @Author: hgw
* @Date: 2023/1/17 15:38
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage>>
**/
R<List<ErrorMessage>> importEmployee(SalaryEmployeeImportVo vo);
TSalaryEmployee getByEmpIdCard(String empIdCard); TSalaryEmployee getByEmpIdCard(String empIdCard);
} }
...@@ -32,8 +32,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; ...@@ -32,8 +32,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.check.entity.TCheckBankNo; import com.yifu.cloud.plus.v1.check.entity.TCheckBankNo;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.entity.TCheckMobile; import com.yifu.cloud.plus.v1.check.entity.TCheckMobile;
import com.yifu.cloud.plus.v1.check.vo.CheckBankNoVo; import com.yifu.cloud.plus.v1.check.vo.CheckBankNoVo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; 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.constant.SecurityConstants;
...@@ -44,10 +46,7 @@ import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryEmployee; ...@@ -44,10 +46,7 @@ import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryEmployee;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryEmployeeMapper; import com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryEmployeeMapper;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryEmployeeService; import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryEmployeeService;
import com.yifu.cloud.plus.v1.yifu.salary.util.SalaryConstants; import com.yifu.cloud.plus.v1.yifu.salary.util.SalaryConstants;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeExportVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.*;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeSearchVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeUpdateVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryEmployeeVo;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
...@@ -283,15 +282,51 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe ...@@ -283,15 +282,51 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
**/ **/
@Override @Override
public String saveNewSalaryEmployee(boolean notLabour,TSalaryEmployee employee) { public String saveNewSalaryEmployee(boolean notLabour,TSalaryEmployee employee) {
String pre = this.checkNewEmpBankAndPhone(employee, false);
if (pre != null) return pre;
if (notLabour) {
this.save(employee);
}
return null;
}
/**
* @param employee
* @Description: 校验卡号与手机号
* @Author: hgw
* @Date: 2023/1/17 16:27
* @return: java.lang.String
**/
private String checkNewEmpBankAndPhone(TSalaryEmployee employee, boolean isCheckIdCard) {
if (Common.isNotNull(employee.getEmpName()) && Common.isNotNull(employee.getEmpIdcard())) { if (Common.isNotNull(employee.getEmpName()) && Common.isNotNull(employee.getEmpIdcard())) {
// 身份证校验(薪资人员导入才需要)
if (isCheckIdCard) {
// 调用校验服务
String pre = "姓名与身份证验证:";
TCheckIdCard checkIdCard = new TCheckIdCard();
checkIdCard.setName(employee.getEmpName());
checkIdCard.setIdCard(employee.getEmpIdcard());
R<TCheckIdCard> checkListR = HttpDaprUtil.invokeMethodPost(checkProperties.getAppUrl(), checkProperties.getAppId()
, "/tcheckidcard/inner/checkIdCardSingle", checkIdCard, TCheckIdCard.class, SecurityConstants.FROM_IN);
if (checkListR != null && checkListR.getData() != null) {
TCheckIdCard check = checkListR.getData();
if (check == null || Common.isEmpty(check.getIsTrue())) {
return pre + "校验服务器未返回,请联系管理员!";
} else if (check.getIsTrue() == CommonConstants.ZERO_INT) {
return pre + check.getReason();
}
} else {
return pre + "校验服务器未返回,请联系管理员!";
}
}
// 银行卡 // 银行卡
if (Common.isNotNull(employee.getBankNo())) { if (Common.isNotNull(employee.getBankNo())) {
// 调用校验服务 // 调用校验服务
TCheckBankNo checkIdCard = new TCheckBankNo(); TCheckBankNo checkBankNo = new TCheckBankNo();
checkIdCard.setName(employee.getEmpName()); checkBankNo.setName(employee.getEmpName());
checkIdCard.setBankNo(employee.getBankNo()); checkBankNo.setBankNo(employee.getBankNo());
R<CheckBankNoVo> checkListR = HttpDaprUtil.invokeMethodPost(checkProperties.getAppUrl(), checkProperties.getAppId() R<CheckBankNoVo> checkListR = HttpDaprUtil.invokeMethodPost(checkProperties.getAppUrl(), checkProperties.getAppId()
, "/tcheckbankno/inner/checkBankNo", checkIdCard, CheckBankNoVo.class, SecurityConstants.FROM_IN); , "/tcheckbankno/inner/checkBankNo", checkBankNo, CheckBankNoVo.class, SecurityConstants.FROM_IN);
String pre = "姓名与卡号验证:"; String pre = "姓名与卡号验证:";
if (checkListR != null && checkListR.getData() != null) { if (checkListR != null && checkListR.getData() != null) {
CheckBankNoVo vo = checkListR.getData(); CheckBankNoVo vo = checkListR.getData();
...@@ -327,19 +362,9 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe ...@@ -327,19 +362,9 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
} }
} }
} }
if (notLabour) {
this.save(employee);
}
return null; return null;
} }
/**
* @param inputStream
* @Description: 批量更新-薪资人员信息
* @Author: hgw
* @Date: 2022/10/10 17:17
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage>>
**/
@Override @Override
public R<List<ErrorMessage>> batchUpdateSalaryEmployee(InputStream inputStream) { public R<List<ErrorMessage>> batchUpdateSalaryEmployee(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>(); List<ErrorMessage> errorMessageList = new ArrayList<>();
...@@ -504,4 +529,157 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe ...@@ -504,4 +529,157 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
return baseMapper.getByEmpIdCard(empIdCard); return baseMapper.getByEmpIdCard(empIdCard);
} }
/**
* @param vo
* @Description: 批量更新-薪资人员信息
* @Author: hgw
* @Date: 2022/10/10 17:17
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage>>
**/
@Override
public R<List<ErrorMessage>> importEmployee(SalaryEmployeeImportVo vo) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
List<String> idCardList = new ArrayList<>();
// 执行数据插入操作 组装
List<TSalaryEmployee> excelVOList = vo.getEmpList();
for (TSalaryEmployee emp : excelVOList) {
idCardList.add(emp.getEmpIdcard());
}
List<TSalaryEmployee> empList = baseMapper.getListByIdCard(idCardList);
// 人员Map
Map<String, TSalaryEmployee> empMap = new HashMap<>();
for (TSalaryEmployee e : empList) {
empMap.put(e.getEmpIdcard(), e);
}
TSalaryEmployee emp;
// 开户行省市的区域暂存
String areaStr;
boolean curTaxMonth;
TSalaryEmployee excel;
// 是否可更新
boolean canUpdate = Common.isNotNull(vo.getIsUpdate()) && CommonConstants.ONE_STRING.equals(vo.getIsUpdate());
List<TSalaryEmployee> saveList = new ArrayList<>();
List<TSalaryEmployee> updateList = new ArrayList<>();
TSettleDomain dept = vo.getDept();
for (int i = 0; i < excelVOList.size(); i++) {
excel = excelVOList.get(i);
if (excel != null) {
if (Common.isNotNull(excel.getEmpIdcard())) {
emp = empMap.get(excel.getEmpIdcard());
if (Common.isNotNull(emp)) {
if (canUpdate) {
curTaxMonth = false;
if (Common.isNotNull(emp.getTaxMonth()) && Common.isNotNull(excel.getTaxMonth()) && emp.getTaxMonth().length() == 6) {
curTaxMonth = true;
} else if (Common.isNotNull(excel.getTaxMonth())) {
emp.setTaxMonth(excel.getTaxMonth());
}
if (Common.isNotNull(excel.getBankName())) {
emp.setBankName(excel.getBankName());
}
if (Common.isNotNull(excel.getBankSubName())) {
emp.setBankSubName(excel.getBankSubName());
}
if (Common.isNotNull(excel.getBankProvince())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getBankProvince().trim());
if (Common.isNotNull(areaStr)) {
emp.setBankProvince(areaStr);
if (Common.isNotNull(excel.getBankCity())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getBankCity().trim()
+ CommonConstants.DOWN_LINE_STRING + excel.getBankProvince().trim());
if (Common.isNotNull(areaStr)) {
emp.setBankCity(areaStr);
} else {
errorMessageList.add(new ErrorMessage((i + 2), SalaryConstants.CITY_ERROR));
continue;
}
}
} else {
errorMessageList.add(new ErrorMessage((i + 2), SalaryConstants.PROVINCE_ERROR));
continue;
}
}
if (Common.isNotNull(excel.getBankNo())) {
emp.setBankNo(excel.getBankNo());
}
if (Common.isNotNull(excel.getEmpPhone())) {
emp.setEmpPhone(excel.getEmpPhone());
}
if (Common.isNotNull(excel.getEmpName())) {
emp.setEmpName(excel.getEmpName());
}
updateList.add(emp);
if (curTaxMonth) {
errorMessageList.add(new ErrorMessage((i + 2), SalaryConstants.CUR_TAX_INFO));
} else {
errorMessageList.add(new ErrorMessage((i + 2), CommonConstants.SAVE_SUCCESS));
}
} else {
errorMessageList.add(new ErrorMessage((i + 2), "已存在,不可更新"));
}
} else {
// 新增人员
if (Common.isEmpty(excel.getEmpName()) || Common.isEmpty(excel.getEmpIdcard())
|| Common.isEmpty(excel.getEmpPhone()) || Common.isEmpty(excel.getBankName())
|| Common.isEmpty(excel.getBankNo()) || Common.isEmpty(excel.getBankProvince())
|| Common.isEmpty(excel.getBankCity()) || Common.isEmpty(excel.getTaxMonth())) {
errorMessageList.add(new ErrorMessage((i + 2), "新增员工,除了支行,其他必填"));
} else {
String pre = this.checkNewEmpBankAndPhone(excel, true);
if (pre != null) {
errorMessageList.add(new ErrorMessage((i + 2), "新增员工,除了支行,其他必填"));
} else {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getBankProvince().trim());
if (Common.isNotNull(areaStr)) {
emp.setBankProvince(areaStr);
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getBankCity().trim()
+ CommonConstants.DOWN_LINE_STRING + excel.getBankProvince().trim());
if (Common.isNotNull(areaStr)) {
emp.setBankCity(areaStr);
} else {
errorMessageList.add(new ErrorMessage((i + 2), SalaryConstants.CITY_ERROR));
continue;
}
} else {
errorMessageList.add(new ErrorMessage((i + 2), SalaryConstants.PROVINCE_ERROR));
continue;
}
excel.setUnitId(dept.getCustomerId());
excel.setUnitName(dept.getCustomerName());
excel.setUnitNo(dept.getCustomerNo());
excel.setDeptId(dept.getId());
excel.setDeptName(dept.getDepartName());
excel.setDeptNo(dept.getDepartNo());
saveList.add(excel);
errorMessageList.add(new ErrorMessage((i + 2), CommonConstants.SAVE_SUCCESS));
}
}
}
} else {
errorMessageList.add(new ErrorMessage((i+2), SalaryConstants.ID_CARD_MUST));
}
} else {
errorMessageList.add(new ErrorMessage(CommonConstants.ZERO_INT, SalaryConstants.DATA_MUST));
}
}
if (!updateList.isEmpty()) {
this.updateBatchById(updateList);
}
if (!saveList.isEmpty()) {
this.saveBatch(saveList);
}
boolean isTrue = true;
for (ErrorMessage message : errorMessageList) {
if (!CommonConstants.SAVE_SUCCESS.equals(message.getMessage())) {
isTrue = false;
break;
}
}
if (isTrue) {
return R.ok();
} else {
return R.ok(errorMessageList);
}
}
} }
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