Commit c0485493 authored by huyuchen's avatar huyuchen

劳务费导入修改

parent a6a2a0d5
......@@ -128,11 +128,15 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
if (null == user || null == user.getId()) {
return R.failed("获取登录用户信息失败!");
}
//薪资导入
if (CommonConstants.ZERO_STRING.equals(salaryType) && Common.isNotNull(configId)) {
TConfigSalary configSalary = new TConfigSalary();
if (Common.isNotNull(configId)) {
// 薪资配置-结算月、社保月等信息
TConfigSalary configSalary = configSalaryService.getById(configId);
configSalary = configSalaryService.getById(configId);
} else {
configSalary = configSalaryService.getById(CommonConstants.ONE_STRING);
}
try {
jsonString = URLDecoder.decode(jsonString, "UTF-8").replace("=", "");
SalaryAccountUtil util1 = new SalaryAccountUtil();
......@@ -166,80 +170,33 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
// 2.6.6:校验导入数据重复的Map格式:#身份证号_工资月份_报表类型_应发金额
Map<String, Integer> checkMap = tSalaryAccountService.getAccountCheckMap(dept.getId(), DateUtil.addMonth(configSalary.getSalaryMonth()));
util1.getJsonStringToList(user, jsonString,
dept, configSalary, salaryConfigMap, isMustMap, empIdCardMap, empNameMap, isDuplicateName
, salaryType, null,invoiceTitle, employeeService, checkMap, ownEmployeeMap, ownDeptMap, tSalaryAccountService);
List<TSalaryAccountVo> saList = util1.getEntityList();
if ((null != util1.getErrorInfo() && !util1.getErrorInfo().isEmpty())) {
return R.failed(util1.getErrorInfo());
} else {
if (null != saList && !saList.isEmpty()) {
// return R.ok(saList)
return this.saveAndSubmit(saList);
} else {
return R.failed("导入数据不可为空");
}
}
} catch (Exception e) {
log.error(e.getMessage());
return R.failed("数据导入解析失败!");
}
//劳务费导入
} else if (CommonConstants.THREE_STRING.equals(salaryType)) {
TConfigSalary configSalary = new TConfigSalary();
// 薪资配置-结算月、社保月等信息
configSalary = configSalaryService.getById(CommonConstants.ONE_STRING);
try {
jsonString = URLDecoder.decode(jsonString, "UTF-8").replace("=", "");
SalaryAccountUtil util1 = new SalaryAccountUtil();
List<TSalaryEmployee> empList = employeeService.list(Wrappers.<TSalaryEmployee>query().lambda()
.eq(TSalaryEmployee::getUnitId, dept.getCustomerId()));
Map<String, TSalaryEmployee> empIdCardMap = new HashMap<>();
Map<String, TSalaryEmployee> empNameMap = new HashMap<>();
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();
// 薪资类型互斥校验Map格式:本年度#身份证号_报表类型
List<String> checkListY = new ArrayList<>();
if (CommonConstants.THREE_STRING.equals(salaryType)) {
// 薪资类型互斥校验Map格式:本年度#身份证号_报表类型
if (Common.isNotNull(configSalary)) {
checkListY = tSalaryAccountService.getAccountYearCheckMap(dept.getId());
}
// 校验导入数据重复的Map格式:#身份证号_工资月份_报表类型_应发金额
Map<String, Integer> checkMap = new HashMap<>();
if (Common.isNotNull(configSalary)) {
checkMap = tSalaryAccountService.getAccountCheckMap(dept.getId(), DateUtil.addMonth(configSalary.getSalaryMonth()));
}
util1.getJsonStringToList(user, jsonString, dept, !Common.isNotNull(configSalary) ? null: configSalary,
salaryConfigMap, isMustMap, empIdCardMap, empNameMap, isDuplicateName, salaryType,checkListY
,null, employeeService, checkMap, ownEmployeeMap, ownDeptMap, tSalaryAccountService);
util1.getJsonStringToList(user, jsonString, dept, configSalary, salaryConfigMap, isMustMap,
empIdCardMap, empNameMap, isDuplicateName, salaryType, checkListY, invoiceTitle,
employeeService, checkMap, ownEmployeeMap, ownDeptMap, tSalaryAccountService);
List<TSalaryAccountVo> saList = util1.getEntityList();
if ((null != util1.getErrorInfo() && !util1.getErrorInfo().isEmpty())) {
return R.failed(util1.getErrorInfo());
} else {
if (null != saList && !saList.isEmpty()) {
// return R.ok(saList)
//薪资导入
if (CommonConstants.ZERO_STRING.equals(salaryType)) {
return this.saveAndSubmit(saList);
}
//劳务费导入
if (CommonConstants.THREE_STRING.equals(salaryType)) {
return this.saveLaborSubmit(saList, dept);
}
} else {
return R.failed("导入数据不可为空");
}
......@@ -248,7 +205,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
log.error(e.getMessage());
return R.failed("数据导入解析失败!");
}
}
}
return R.failed("导入数据不可为空");
}
......@@ -825,7 +782,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
salary.setHaveSpecialFlag(CommonConstants.ZERO_INT);
salary.setIsRepeat(CommonConstants.ZERO_INT);
salary.setStatus(SalaryConstants.AUDIT_STATUS[0]);
if (haveSalaryFlag || haveSpecialFlag || ownNum>0 || repeatFlag) {
if (haveSalaryFlag || haveSpecialFlag || ownNum > 0 || repeatFlag) {
if (haveSalaryFlag) {
salary.setHaveSalaryFlag(CommonConstants.ONE_INT);
}
......@@ -1529,7 +1486,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
TSalaryLock lockUpdate;
try {
// 薪资核心导入代码
return this.doLaborCoreSalary(savList, saiList, sai, dept, invoiceTitle, salary);
return this.doLaborCoreSalary(savList, saiList, sai, dept, invoiceTitle, salary, user);
} catch (Exception e) {
lockUpdate = new TSalaryLock();
lockUpdate.setId(lock.getId());
......@@ -1560,7 +1517,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
* @return: com.yifu.cloud.v1.common.core.util.R
**/
public R doLaborCoreSalary(List<TSalaryAccountVo> savList, List<TSalaryAccountItem> saiList, TSalaryAccountItem sai,
TSettleDomainSelectVo dept, String invoiceTitle, TSalaryStandard salary) {
TSettleDomainSelectVo dept, String invoiceTitle, TSalaryStandard salary, YifuUser user) {
List<TSalaryAccount> aList = new ArrayList<>();
TSalaryAccount a;//定库:
BigDecimal money = new BigDecimal(CommonConstants.ZERO_STRING); //初始化金额备用
......@@ -1642,7 +1599,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
this.saveNewItems(sai, saiList, SalaryConstants.SALARY_TAX,
SalaryConstants.SALARY_TAX_JAVA,
calculationLabor(saiList, asList
, saiList,a), CommonConstants.ZERO_INT);
, saiList, a), CommonConstants.ZERO_INT);
a.setSaiList(saiList);
aList.add(a);
......@@ -1659,7 +1616,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
salary.setHaveSpecialFlag(CommonConstants.ZERO_INT);
salary.setIsRepeat(CommonConstants.ZERO_INT);
salary.setStatus(SalaryConstants.AUDIT_STATUS[0]);
if (haveSalaryFlag || haveSpecialFlag || ownNum>0 || repeatFlag) {
if (haveSalaryFlag || haveSpecialFlag || ownNum > 0 || repeatFlag) {
if (haveSalaryFlag) {
salary.setHaveSalaryFlag(CommonConstants.ONE_INT);
}
......@@ -1673,6 +1630,9 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
//保存工资表
tSalaryStandardService.save(salary);
// 获取上一个工资条顺序,复制:
tSalaryStandardSetService.copyLastSetByDeptId(salary.getId(), dept.getId(), String.valueOf(user.getId()));
salaryDetailVo.setSalary(salary);
for (TSalaryAccount account : aList) {
......@@ -1733,10 +1693,10 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
nowTaxY = getNowTax(actualSalarySum);
relaySalary = BigDecimalUtils.safeAdd(actualSalarySumNow, nowTaxT).setScale(SalaryConstants.PLACES, BigDecimal.ROUND_HALF_UP);
BigDecimal salaryTax = BigDecimalUtils.safeSubtract(nowTaxY,BigDecimalUtils.safeAdd(nowTaxT,sumTax));
BigDecimal salaryTax = BigDecimalUtils.safeSubtract(nowTaxY, BigDecimalUtils.safeAdd(nowTaxT, sumTax));
a.setSalaryTax(salaryTax);
a.setSalaryTaxUnit(nowTaxT);
a.setActualSalary(BigDecimalUtils.safeSubtract(actualSalarySumNow,salaryTax));
a.setActualSalary(BigDecimalUtils.safeSubtract(actualSalarySumNow, salaryTax));
} else {
nowTaxY = getNowTax(actualSalarySum);
if (sumTax.compareTo(BigDecimal.ZERO) != 0) {
......@@ -1757,7 +1717,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
return nowTaxT;
}
public static BigDecimal getNowTax (BigDecimal actualSalarySum) {
public static BigDecimal getNowTax(BigDecimal actualSalarySum) {
BigDecimal nowTax;
// 2022-3-3 11:24:20 运营中心郭华照提供的公式:
// ROUND(IF(B7<=800,0,IF(B7<=3360,(B7-800)/4,IF(B7<=21000,0.16*B7/0.84,IF(B7<=49500,(0.24*B7-2000)/0.76,(0.32*B7-7000)/0.68)))),2)
......
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