Commit dd3bef47 authored by hongguangwu's avatar hongguangwu

继续优化薪资导入

parent e0283015
......@@ -1033,7 +1033,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
// 调用区域服务,渲染区域值
/*R<Map<String, Map<String, String>>> areaR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(), daprUpmsProperties.getAppId()
, "/area/inner/getAreaToName", null, Map.class, SecurityConstants.FROM_IN);*/
, "/area/inner/getAreaToName", null, Map.class, SecurityConstants.FROM_IN)*/
TEmployeeInfo checkPhone;
List<TEmployeeInfo> phoneEmpList;
......@@ -1190,7 +1190,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
}
if (Common.isNotNull(excel.getIdCity())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getIdCity() + CommonConstants.DOWN_LINE_STRING + excel.getIdProvince().trim());
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getIdCity().trim() + CommonConstants.DOWN_LINE_STRING + excel.getIdProvince().trim());
if (Common.isEmpty(areaStr)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_AREA_ERROR, excel.getEmpIdcard()));
} else {
......@@ -1198,7 +1198,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
}
if (Common.isNotNull(excel.getIdTown())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getIdTown() + CommonConstants.DOWN_LINE_STRING + excel.getIdCity().trim());
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getIdTown().trim() + CommonConstants.DOWN_LINE_STRING + excel.getIdCity().trim());
if (Common.isEmpty(areaStr)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_AREA_ERROR, excel.getEmpIdcard()));
} else {
......@@ -1215,7 +1215,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
}
if (Common.isNotNull(excel.getFileCity())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getFileCity() + CommonConstants.DOWN_LINE_STRING + excel.getFileProvince().trim());
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getFileCity().trim() + CommonConstants.DOWN_LINE_STRING + excel.getFileProvince().trim());
if (Common.isEmpty(areaStr)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_FILE_AREA_ERROR, excel.getEmpIdcard()));
} else {
......@@ -1223,7 +1223,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
}
if (Common.isNotNull(excel.getFileTown())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getFileTown() + CommonConstants.DOWN_LINE_STRING + excel.getFileCity().trim());
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getFileTown().trim() + CommonConstants.DOWN_LINE_STRING + excel.getFileCity().trim());
if (Common.isEmpty(areaStr)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_FILE_AREA_ERROR, excel.getEmpIdcard()));
} else {
......@@ -1701,7 +1701,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
}
if (Common.isNotNull(excel.getIdCity())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getIdCity() + CommonConstants.DOWN_LINE_STRING + excel.getIdProvince().trim());
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getIdCity().trim() + CommonConstants.DOWN_LINE_STRING + excel.getIdProvince().trim());
if (Common.isEmpty(areaStr)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_AREA_ERROR, excel.getEmpIdcard()));
} else {
......@@ -1709,7 +1709,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
}
if (Common.isNotNull(excel.getIdTown())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getIdTown() + CommonConstants.DOWN_LINE_STRING + excel.getIdCity().trim());
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getIdTown().trim() + CommonConstants.DOWN_LINE_STRING + excel.getIdCity().trim());
if (Common.isEmpty(areaStr)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_AREA_ERROR, excel.getEmpIdcard()));
} else {
......@@ -1726,7 +1726,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
}
if (Common.isNotNull(excel.getFileCity())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getFileCity() + CommonConstants.DOWN_LINE_STRING + excel.getFileProvince().trim());
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getFileCity().trim() + CommonConstants.DOWN_LINE_STRING + excel.getFileProvince().trim());
if (Common.isEmpty(areaStr)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_FILE_AREA_ERROR, excel.getEmpIdcard()));
} else {
......@@ -1734,7 +1734,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
}
if (Common.isNotNull(excel.getFileTown())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getFileTown() + CommonConstants.DOWN_LINE_STRING + excel.getFileCity().trim());
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + excel.getFileTown().trim() + CommonConstants.DOWN_LINE_STRING + excel.getFileCity().trim());
if (Common.isEmpty(areaStr)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_FILE_AREA_ERROR, excel.getEmpIdcard()));
} else {
......
......@@ -23,10 +23,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
......
package com.yifu.cloud.plus.v1.yifu.salary.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
......@@ -19,13 +22,6 @@ import java.util.List;
public class TSalaryAccountVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 计税月份
*/
@Length(max = 32, message = "计税月份不能超过6个字符")
@ExcelAttribute(name = "计税月份", maxLength = 6)
private String taxMonth;
/**
* 封面抬头
*/
......@@ -41,12 +37,13 @@ public class TSalaryAccountVo implements Serializable {
@ExcelAttribute(name = "工资表ID", maxLength = 32)
private String salaryFormId;
/**
* 工资月份000
* 薪酬月份
*/
@Length(max = 6, message = "工资月份不能超过6个字符")
@NotBlank(message = "工资月份不能为空")
@ExcelAttribute(name = "工资月份", isNotEmpty = true, errorInfo = "工资月份不能为空", maxLength = 6)
private String salaryDate;
@ExcelAttribute(name = "薪酬月份", isNotEmpty = true, errorInfo = "薪酬月份不能为空", maxLength = 6)
@NotBlank(message = "薪酬月份不能为空")
@Length(max = 6, message = "薪酬月份不能超过6个字符")
@ExcelProperty("薪酬月份")
private String salaryMonth;
/**
* 员工 ID
*/
......@@ -61,64 +58,54 @@ public class TSalaryAccountVo implements Serializable {
@NotBlank(message = "员工姓名不能为空")
@ExcelAttribute(name = "员工姓名", maxLength = 50)
private String empName;
/**
* 员工编码
*/
@Length(max = 32, message = "员工编码不能超过32个字符")
@NotBlank(message = "员工编码不能为空")
@ExcelAttribute(name = "员工编码", maxLength = 32)
private String empNo;
/**
* 结算部门id
*/
@Length(max = 32, message = "结算部门id不能超过32个字符")
@NotBlank(message = "结算部门id不能为空")
@ExcelAttribute(name = "结算部门id", isNotEmpty = true, errorInfo = "结算部门id不能为空", maxLength = 32)
private String settleDepartId;
/**
* 结算部门no
* 银行卡号000
*/
@Length(max = 50, message = "结算部门No不能超过50个字符")
@NotBlank(message = "结算部门No不能为空")
@ExcelAttribute(name = "结算部门No", isNotEmpty = true, errorInfo = "结算部门No不能为空", maxLength = 50)
private String settleDepartNo;
@Length(max = 30, message = "银行卡号不能超过30个字符")
@ExcelAttribute(name = "银行卡号", maxLength = 30)
private String bankNo;
/**
* 结算部门name
* 开户行总行
*/
@Length(max = 50, message = "结算部门Name不能超过50个字符")
@NotBlank(message = "结算部门No不能为空")
@ExcelAttribute(name = "结算部门No", isNotEmpty = true, errorInfo = "结算部门Name不能为空", maxLength = 50)
private String settleDepartName;
@ExcelAttribute(name = "开户行总行", maxLength = 50)
@Length(max = 50, message = "开户行总行不能超过50个字符")
@ExcelProperty("开户行总行")
private String bankName;
/**
* 员工身份证号
* 项目id
*/
@Length(max = 18, message = "员工身份证号不能超过18个字符")
@NotBlank(message = "员工身份证号不能为空")
@ExcelAttribute(name = "员工身份证号", maxLength = 18)
private String empIdcard;
@ExcelAttribute(name = "项目id", isNotEmpty = true, errorInfo = "项目id不能为空", maxLength = 32)
@NotBlank(message = "项目id不能为空")
@Length(max = 32, message = "项目id不能超过32个字符")
@ExcelProperty("项目id")
private String deptId;
/**
* 银行卡号000
* 项目no
*/
@Length(max = 30, message = "银行卡号不能超过30个字符")
@ExcelAttribute(name = "银行卡号", maxLength = 30)
private String bankNo;
@ExcelAttribute(name = "项目编码", isNotEmpty = true, errorInfo = "项目no不能为空", maxLength = 50)
@NotBlank(message = "项目编码不能为空")
@Length(max = 50, message = "项目编码不能超过50个字符")
@ExcelProperty("项目编码")
private String deptNo;
/**
* 开户行000
* 项目name
*/
@Length(max = 50, message = "开户行不能超过50个字符")
@ExcelAttribute(name = "开户行", maxLength = 50)
private String bankName;
@ExcelAttribute(name = "项目名称", isNotEmpty = true, errorInfo = "项目name不能为空", maxLength = 50)
@NotBlank(message = "项目名称不能为空")
@Length(max = 50, message = "项目名称不能超过50个字符")
@ExcelProperty("项目名称")
private String deptName;
/**
* 发工资次数-
* 弃用
* 身份证号
*/
//@NotBlank(message = "发工资次数不能为空")
@ExcelAttribute(name = "发工资次数")
private Integer salaryCount;
@Length(max = 18, message = "身份证号不能超过18个字符")
@NotBlank(message = "身份证号不能为空")
@ExcelAttribute(name = "身份证号", maxLength = 18)
private String empIdcard;
/**
* 工资发放方式(0现金/1银行)/2线下000
*/
......@@ -150,19 +137,13 @@ public class TSalaryAccountVo implements Serializable {
@ExcelAttribute(name = "公积金扣缴月份", maxLength = 6)
private String deduProvidentMonth;
/**
* 财务类型(数据字典)
*/
@Length(max = 1, message = "财务类型不能超过1个字符")
@NotBlank(message = "财务类型不能为空")
@ExcelAttribute(name = "财务类型", isNotEmpty = true, errorInfo = "财务类型(数据字典)不能为空", maxLength = 1)
private String salaryType;
/**
* 是否薪资扣税:0否 1是000
* 报表类型0:薪资;1:绩效;2:其他;3:劳务费;4:稿酬
*/
@Length(max = 1, message = "是否薪资扣税不能超过1个字符")
@NotBlank(message = "是否薪资扣税:0否 1是不能为空")
@ExcelAttribute(name = "是否薪资扣税:0否 1是", isNotEmpty = true, errorInfo = "是否薪资扣税:0否 1是不能为空")
private String salaryTaxFlag;
@ExcelAttribute(name = "报表类型", readConverterExp = "0=薪资,1=绩效,2=其他,3=劳务费,4=稿酬")
@NotBlank(message = "报表类型不能为空")
@Length(max = 32, message = "报表类型不能超过32个字符")
@ExcelProperty("报表类型")
private String formType;
/**
* 结算月
......@@ -205,6 +186,13 @@ public class TSalaryAccountVo implements Serializable {
@ExcelAttribute(name = "年终奖扣税方案0:合并;1:单独", isNotEmpty = true, errorInfo = "年终奖扣税方案0:合并;1:单独不能为空", maxLength = 1)
private String annualBonusType;
/**
* 计税月份
*/
@Length(max = 32, message = "计税月份不能超过6个字符")
@ExcelAttribute(name = "计税月份", maxLength = 6)
private String taxMonth;
//000
@ExcelAttribute(name = "是否扣除社保 0:否,1:是", maxLength = 1)
private String isDeductSocial;
......@@ -235,7 +223,7 @@ public class TSalaryAccountVo implements Serializable {
/**
* 手机号
*/
@ExcelAttribute(name = "手机号", maxLength = 11)
@ExcelAttribute(name = "手机号", maxLength = 11)
private String empPhone;
/**
......@@ -245,6 +233,16 @@ public class TSalaryAccountVo implements Serializable {
@ExcelAttribute(name = "是否自有员工", maxLength = 1)
private Integer ownFlag;
@Schema(description = "劳务费、稿酬是否含有发薪0:否;1:是")
@ExcelAttribute(name = "劳务费、稿酬是否含有发薪")
@ExcelProperty("劳务费、稿酬是否含有发薪")
private Integer haveSalaryFlag;
@Schema(description = "是否含有特殊金额0:否;1:是")
@ExcelAttribute(name = "是否含有特殊金额")
@ExcelProperty("是否含有特殊金额")
private Integer haveSpecialFlag;
/**
* 本月是否重复金额0:否;1:是重复导入的
*/
......@@ -252,5 +250,63 @@ public class TSalaryAccountVo implements Serializable {
@ExcelAttribute(name = "本月是否重复金额", maxLength = 1)
private Integer isRepeat;
/**
* 开户行支行
*/
@ExcelAttribute(name = "开户行支行", maxLength = 50)
@Length(max = 50, message = "开户行支行不能超过50个字符")
@ExcelProperty("开户行支行")
private String bankSubName;
/**
* 开户行省
*/
@ExcelAttribute(name = "开户行省", isArea = true)
@ExcelProperty("开户行省")
private String bankProvince;
/**
* 开户行市
*/
@ExcelAttribute(name = "开户行市", isArea = true, parentField = "bankProvince")
@ExcelProperty("开户行市")
private String bankCity;
/**
* 是否个人承担部分税费:0否1是
*/
@ExcelAttribute(name = "是否个人承担部分税费:0否1是", maxLength = 1)
@Length(max = 1, message = "是否个人承担部分税费:0否1是不能超过1个字符")
@ExcelProperty("是否个人承担部分税费:0否1是")
private String isPersonTax;
/**
* 应发薪酬(劳务费、稿酬)
*/
@ExcelAttribute(name = "应发薪酬")
@ExcelProperty("应发薪酬")
private BigDecimal relaySalary;
/**
* 实发(个人实收)
*/
@ExcelAttribute(name = "实发(个人实收)")
@ExcelProperty("实发(个人实收)")
private BigDecimal actualSalary;
/**
* 个税金额(个人承担)
*/
@ExcelAttribute(name = "个税金额")
@ExcelProperty("个税金额")
private BigDecimal salaryTax;
/**
* 公司应发
*/
@ExcelAttribute(name = "公司应发")
@ExcelProperty("公司应发")
private BigDecimal relaySalaryUnit;
/**
* 个税-单位承担
*/
@ExcelAttribute(name = "个税-单位承担")
@ExcelProperty("个税-单位承担")
private BigDecimal salaryTaxUnit;
private List<TSalaryAccountItemVo> saiList = new ArrayList<>(); //工资组成部分明细
}
......@@ -135,29 +135,29 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
empSearch.setUnitId(dept.getCustomerId());
List<TSalaryEmployee> empList = employeeService.list(Wrappers.<TSalaryEmployee>query().lambda()
.eq(TSalaryEmployee::getUnitId, dept.getCustomerId()));
if (empList == null) {
return R.failed("该结算主体下无档案人员,请去档案添加!");
}
Map<String, TSalaryEmployee> empIdCardMap = new HashMap<>();
Map<String, TSalaryEmployee> empNameMap = new HashMap<>();
boolean isDuplicateName = true;
boolean isDuplicateName = false;
if (empList != null) {
TSalaryEmployee es;//筛选人员,添加判断:非在职,或开户行为空,或 结算主体等于选择的结算主体且在职,都可以存入Map优先备用
for (TSalaryEmployee e : empList) {
es = empIdCardMap.get(e.getEmpIdcard());
if (es == null || CommonConstants.ZERO_INT != es.getFileStatus() || Common.isEmpty(es.getBankName())
|| (e.getDeptId().equals(settleDepart) && CommonConstants.ZERO_INT == e.getFileStatus()
&& Common.isNotNull(e.getBankName()))) {
empIdCardMap.put(e.getEmpIdcard(), e);
empNameMap.put(e.getEmpName().replace(" ", ""), e);
}
}
if (empNameMap.size() == empIdCardMap.size()) {
isDuplicateName = true;
}
}
// 自有员工结算主体id,新员工使用
Map<String, Integer> ownDeptMap = tOwnDeptService.getOwnDeptMap();
// 自有员工所在结算主体Map
Map<String, Integer> ownEmployeeMap = tOwnDeptService.getOwnEmpMap();
TSalaryEmployee es;//筛选人员,添加判断:非在职,或开户行为空,或 结算主体等于选择的结算主体且在职,都可以存入Map优先备用
for (TSalaryEmployee e : empList) {
es = empIdCardMap.get(e.getEmpIdcard());
if (es == null || CommonConstants.ZERO_INT != es.getFileStatus() || Common.isEmpty(es.getBankName())
|| (e.getDeptId().equals(settleDepart) && CommonConstants.ZERO_INT == e.getFileStatus()
&& Common.isNotNull(e.getBankName()))) {
empIdCardMap.put(e.getEmpIdcard(), e);
empNameMap.put(e.getEmpName().replace(" ", ""), e);
}
}
if (empNameMap.size() != empIdCardMap.size()) {
isDuplicateName = false;
}
// 2.6.6:校验导入数据重复的Map格式:#身份证号_工资月份_报表类型_应发金额
Map<String, Integer> checkMap = tSalaryAccountService.getAccountCheckMap(dept.getId(), DateUtil.addMonth(configSalary.getSettleMonth()));
util1.getJsonStringToList(user, jsonString,
......@@ -254,9 +254,9 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
if (dept.getTown() != null) {
s.setTown(dept.getTown());
}
s.setFormType(sav.getSalaryType());
s.setFormType(sav.getFormType());
s.setMoneyFrom(CommonConstants.ZERO_INT);
s.setSalaryMonth(sav.getSalaryDate());
s.setSalaryMonth(sav.getSalaryMonth());
s.setSettlementMonth(sav.getSettlementMonth());
//s.setSettlementAmount()
s.setStatus(SalaryConstants.AUDIT_STATUS[0]);
......@@ -278,7 +278,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
List<TSalaryAccountItem> saiList = null; //报账明细List
TSalaryAccountItem sai = null; //报账明细
R<TSettleDomainSelectVo> sdr = HttpDaprUtil.invokeMethodPost(archivesProperties.getAppUrl(), archivesProperties.getAppId()
, "/tsettledomain/inner/getSettleDomainVoById", salaryAccountVo.getSettleDepartId(), TSettleDomainSelectVo.class, SecurityConstants.FROM_IN);
, "/tsettledomain/inner/getSettleDomainVoById", salaryAccountVo.getDeptId(), TSettleDomainSelectVo.class, SecurityConstants.FROM_IN);
//结算主体
TSettleDomainSelectVo dept = null;
if (sdr != null && sdr.getData() != null) {
......@@ -513,7 +513,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
// 是否劳务费,true:是
boolean isLabor = false;
if ("3".equals(salaryAccountVo.getSalaryType())) {
if ("3".equals(salaryAccountVo.getFormType())) {
isLabor = true;
}
for (int i = CommonConstants.ZERO_INT; i < size; i++) {
......
......@@ -2,9 +2,11 @@ package com.yifu.cloud.plus.v1.yifu.salary.util;
import com.alibaba.fastjson.JSONObject;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo;
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.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ValidityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ExcelException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
......@@ -17,6 +19,7 @@ import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryEmployeeService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryAccountItemVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryAccountVo;
import lombok.Data;
import lombok.extern.log4j.Log4j2;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
......@@ -34,7 +37,7 @@ import static com.yifu.cloud.plus.v1.yifu.salary.util.SalaryCommonUtil.setFields
* @Description: EXCEL内容转化为TSalaryAccount
*/
@Data
@Slf4j
@Log4j2
public class SalaryAccountUtil implements Serializable {
/**
......@@ -51,7 +54,6 @@ public class SalaryAccountUtil implements Serializable {
/**
* @param jsonStr 客户原表json内容
* @param dicMap 字典Map
* @param dept 项目
* @param configSalary 当前项目下的配置(结算月等
* @param salaryConfigMap 客户原表-工资模板配置Map
......@@ -95,7 +97,6 @@ public class SalaryAccountUtil implements Serializable {
}
}
String error; //校验字段是否符合要求 返回错误信息
String tempStr; //临时存储单元格数据
TSalaryAccountVo entity; // 从第1行开始取数据
HashMap temp; // 得到一行中的所有单元格对象.
ExcelAttribute attr; //获取属性对应的注解属性
......@@ -111,8 +112,8 @@ public class SalaryAccountUtil implements Serializable {
BigDecimal cellValueBig;
Map<String, Integer> checkIdNumberMap = new HashMap<>(); //验证身份证重复性的Map
boolean salaryGiveTimeFlag; //salaryGiveTime == true :立即发;false:暂停发:则不考虑开户行等
boolean isNewEmployee; //是否新员工:是:true;否:false;
R<TSalaryEmployee> empR;
//是否新员工:是:true;否:false
boolean isNewEmployee;
String empName;
String salaryStyle;//工资发放方式(0现金/1银行)/2线下
BigDecimal relaySalary; //应发工资
......@@ -124,6 +125,8 @@ public class SalaryAccountUtil implements Serializable {
int nowYear = Integer.parseInt(nowMonth.substring(0, 4));
// 当前结算年,已有工资的最小计税月
String minTaxMonth;
// 开户行省市的区域暂存
String areaStr;
for (int i = 0; i < rows; i++) {
error = "";
temp = list.get(i);
......@@ -180,7 +183,7 @@ public class SalaryAccountUtil implements Serializable {
}
}
if (SalaryConstants.EMP_NAME.equals(dbFiedName)) {
empName = cellValueStr = cellValueStr.replaceAll(" ", "");
empName = cellValueStr = cellValueStr.replace(" ", "");
if (isDuplicateName) {
emp = empNameMap.get(empName);
}
......@@ -198,7 +201,7 @@ public class SalaryAccountUtil implements Serializable {
errorList.add(new ErrorMessage((i + 2), error));
break;
}
if (cellValueStr.indexOf("x") >= 0) {
if (cellValueStr.contains("x")) {
cellValueStr = cellValueStr.toUpperCase();
}
emp = empIdCardMap.get(cellValueStr);
......@@ -290,11 +293,6 @@ public class SalaryAccountUtil implements Serializable {
}
}
if (null == error) {
if (Common.isNotNull(entity.getSalaryTaxFlag()) && entity.getSalaryTaxFlag().length() > 1) {
error = "第" + (i + 2) + "行:请检查‘薪资扣税(默认是)’列,允许值:(否/是/不填写),您的值:" + entity.getSalaryTaxFlag();
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
if (Common.isNotNull(entity.getSalaryStyle())) {
salaryStyle = entity.getSalaryStyle();
} else if (configSalary.getGrantType() != null) {
......@@ -352,19 +350,33 @@ public class SalaryAccountUtil implements Serializable {
//银行+立即发,则考虑和开户行卡号
if (SalaryConstants.SALARY_STYLE_BANK.equals(salaryStyle) && salaryGiveTimeFlag) {
if (Common.isEmpty(entity.getBankName())) {
error = "第" + (i + 2) + "行:新员工-开户行-不可为空!";
error = "第" + (i + 2) + "行:新员工-开户行总行-不可为空!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
} else {
newEmp.setBankName(entity.getBankName());
}
if (Common.isEmpty(entity.getBankProvince()) || Common.isEmpty(entity.getBankCity())) {
error = "第" + (i + 2) + "行:新员工-开户行省、市-不可为空!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
} else {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + entity.getBankProvince().trim());
newEmp.setBankProvince(Integer.parseInt(areaStr));
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + entity.getBankCity().trim()
+ CommonConstants.DOWN_LINE_STRING + entity.getBankProvince().trim());
newEmp.setBankCity(Integer.parseInt(areaStr));
}
if (Common.isEmpty(entity.getBankNo())) {
error = "第" + (i + 2) + "行:新员工-卡号-不可为空!";
error = "第" + (i + 2) + "行:新员工-银行卡号-不可为空!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
} else {
newEmp.setBankNo(entity.getBankNo());
}
if (Common.isNotNull(entity.getBankSubName())) {
newEmp.setBankSubName(entity.getBankSubName());
}
} else {
if (Common.isNotNull(entity.getBankName())) {
newEmp.setBankName(entity.getBankName());
......@@ -372,6 +384,18 @@ public class SalaryAccountUtil implements Serializable {
if (Common.isNotNull(entity.getBankNo())) {
newEmp.setBankNo(entity.getBankNo());
}
if (Common.isNotNull(entity.getBankSubName())) {
newEmp.setBankSubName(entity.getBankSubName());
}
if (Common.isNotNull(entity.getBankProvince())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + entity.getBankProvince().trim());
newEmp.setBankProvince(Integer.parseInt(areaStr));
if (Common.isNotNull(entity.getBankCity())) {
areaStr = ExcelUtil.getRedisAreaValue(CacheConstants.AREA_VALUE + entity.getBankCity().trim()
+ CommonConstants.DOWN_LINE_STRING + entity.getBankProvince().trim());
newEmp.setBankCity(Integer.parseInt(areaStr));
}
}
}
}
newEmp.setFileStatus(CommonConstants.ZERO_INT); //临时
......@@ -395,31 +419,31 @@ public class SalaryAccountUtil implements Serializable {
tSalaryEmployeeService.save(newEmp);
emp = newEmp;
} else {
error = "第" + (i + 2) + "行:该项目下无此员工,请添加<是否新员工(默认否)>列,并录入身份证号、开户行总行、卡号、计税月份、手机号码!!";
error = "第" + (i + 2) + "行:薪酬人员档案中,该客户下无此员工,请添加<是否新员工(默认否)>列,并录入身份证号、开户行总行、开户行省、开户行市、银行卡号、计税月份、手机号码!!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
}
if (emp != null) {
if (Common.isEmpty(emp.getEmpName())) {
error = "第" + (i + 2) + "行:档案员工-姓名-为空,请去档案更新!";
error = "第" + (i + 2) + "行:薪酬人员档案-员工姓名-为空,请去薪酬人员档案更新!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
} else if (Common.isEmpty(empName)) {
error = "第" + (i + 2) + "行:模板-员工姓名-为空,请添加姓名列!";
error = "第" + (i + 2) + "行:模板-员工姓名-为空,请添加员工姓名列!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
} else if (!empName.equals(emp.getEmpName())) {
error = "第" + (i + 2) + "行:员工-姓名与身份证-不匹配,请确认员工信息!";
error = "第" + (i + 2) + "行:员工-姓名与身份证-不匹配,请确认薪酬人员档案信息!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
if (Common.isEmpty(emp.getEmpPhone())) {
error = "第" + (i + 2) + "行:档案员工-手机号码-为空,请去档案更新!";
error = "第" + (i + 2) + "行:薪酬人员档案-手机号码-为空,请去档案更新!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
} else if (!ValidityUtil.validateEmpPhone(emp.getEmpPhone())) {
error = "第" + (i + 2) + "行:档案员工-手机号码格式错误,请去档案更新:" + emp.getEmpPhone();
error = "第" + (i + 2) + "行:薪酬人员档案-手机号码格式错误,请去档案更新:" + emp.getEmpPhone();
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
......@@ -440,7 +464,7 @@ public class SalaryAccountUtil implements Serializable {
emp.setTaxMonth(entity.getTaxMonth());
tSalaryEmployeeService.updateById(emp);
} else {
error = "第" + (i + 2) + "行:档案员工-计税月份-为空,请在工资模板填写-计税月份-列的内容!";
error = "第" + (i + 2) + "行:薪酬人员档案-计税月份-为空,请在工资模板填写-计税月份-列的内容!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
......@@ -490,14 +514,14 @@ public class SalaryAccountUtil implements Serializable {
if (emp.getTaxMonth().length() > CommonConstants.dingleDigitIntArray[6]) {
entity.setTaxMonth(emp.getTaxMonth().substring(0, 6));
} else if (emp.getTaxMonth().length() < CommonConstants.dingleDigitIntArray[6]) {
error = "第" + (i + 2) + "行:档案员工-计税月份-长度小于6:" + entity.getTaxMonth() + ",请去档案更新!在工资模板修改无效!";
error = "第" + (i + 2) + "行:薪酬人员档案-计税月份-长度小于6:" + entity.getTaxMonth() + ",请去档案更新!在工资模板修改无效!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
} else {
entity.setTaxMonth(emp.getTaxMonth());
}
if (DateUtil.compareYearMonth(entity.getTaxMonth(), nowMonth)) {
error = "第" + (i + 2) + "行:档案员工-计税月份-大于当前年月或错误,请调整:" + entity.getTaxMonth();
error = "第" + (i + 2) + "行:薪酬人员档案-计税月份-大于当前年月或错误,请调整:" + entity.getTaxMonth();
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
......@@ -509,7 +533,7 @@ public class SalaryAccountUtil implements Serializable {
saiList.add(sai);
}
} else {
error = "第" + (i + 2) + "行:该项目下无此员工,请去档案添加,或添加<是否新员工(默认否)>列,并录入身份证、开户行、卡号、计税月份、手机号码!";
error = "第" + (i + 2) + "行:薪酬人员档案中,该客户下无此员工,请添加<是否新员工(默认否)>列,并录入身份证号、开户行总行、开户行省、开户行市、银行卡号、计税月份、手机号码!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
......@@ -545,8 +569,6 @@ public class SalaryAccountUtil implements Serializable {
continue;
}
entity.setInvoiceTitle(invoiceTitle);
// 2022-4-29 19:31:52 hgw五一前,运营中心先发公告,紧急更新:
entity.setSalaryTaxFlag("1");
if (entity != null) {
tList.add(entity);
}
......@@ -608,111 +630,6 @@ public class SalaryAccountUtil implements Serializable {
}
}
/**
* @param fieldName 字段名
* @param o 对象
* @return 字段值
* @MethodName : getFieldValueByName
* @Description : 根据字段名获取字段值
*/
public static Object getFieldValueByName(String fieldName, Object o, String dateFormat) {
Object value = null;
Field field = null;
if (o == null) {
return "";
}
field = getFieldByName(fieldName, o.getClass());
String type = getFieldType(fieldName, o.getClass());
if (field != null) {
field.setAccessible(true);
try {
if (null != type && type.equals("Date")) {
Date date = (Date) field.get(o);
return DateUtil.dateToString(date, dateFormat == null ? "yyyy-MM-dd" : dateFormat);
} else {
value = field.get(o);
}
} catch (IllegalAccessException e) {
log.error("根据字段名获取字段值异常:", e);
e.printStackTrace();
}
} else {
log.info(o.getClass().getSimpleName() + "类不存在字段名 " + fieldName);
}
return value;
}
/**
* @param fieldName 字段名
* @param clazz 包含该字段的类
* @return 字段
* @MethodName : getFieldByName
* @Description : 根据字段名获取字段
*/
private static Field getFieldByName(String fieldName, Class<?> clazz) {
// 拿到本类的所有字段
Field[] selfFields = clazz.getDeclaredFields();
// 如果本类中存在该字段,则返回
for (Field field : selfFields) {
if (field.getName().equals(fieldName)) {
return field;
}
}
// 否则,查看父类中是否存在此字段,如果有则返回
Class<?> superClazz = clazz.getSuperclass();
if (superClazz != null && superClazz != Object.class) {
return getFieldByName(fieldName, superClazz);
}
// 如果本类和父类都没有,则返回空
return null;
}
/**
* @param fieldName 字段名
* @param clazz 包含该字段的类
* @return 字段
* @MethodName : getFieldType
* @Description : 根据字段名获取字段类型
*/
private static String getFieldType(String fieldName, Class<?> clazz) {
// 拿到本类的所有字段
Field[] selfFields = clazz.getDeclaredFields();
// 如果本类中存在该字段,则返回
for (Field field : selfFields) {
if (field.getName().equals(fieldName)) {
//如果type是类类型,则前面包含"class ",后面跟类名
String type = field.getGenericType().toString();
if (type.equals("class java.lang.String")) {
return "String";
} else if (type.equals("class java.lang.Integer")) {
return "Integer";
} else if (type.equals("class java.lang.Short")) {
return "Short";
} else if (type.equals("class java.lang.Double")) {
return "Double";
} else if (type.equals("class java.lang.Boolean")) {
return "Boolean";
} else if (type.equals("class java.util.Date")) {
return "Date";
} else {
return null;
}
}
}
// 否则,查看父类中是否存在此字段,如果有则返回
Class<?> superClazz = clazz.getSuperclass();
if (superClazz != null && superClazz != Object.class) {
return getFieldType(fieldName, superClazz);
}
// 如果本类和父类都没有,则返回空
return null;
}
/**
* 输出错误数据
*
......
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