Merge branch 'release/个税版本' into custom/艾志工业

# Conflicts:
#	src/com/engine/salary/entity/datacollection/AddUpSituation.java
This commit is contained in:
钱涛 2024-05-21 13:28:13 +08:00
commit bb751c0df3
38 changed files with 408 additions and 151 deletions

View File

@ -1,5 +1,5 @@
log=false
defaultCloseNonStandard149=true
AESEncryptScrect=990EB004A1C862721C1513AE90038C9E
version=2.13.1.2404.02
version=2.14.1.2405.01
openFormulaForcedEditing=false

View File

@ -57,6 +57,6 @@ select id, create_time, update_time, creator, delete_type, tenant_key, salary_so
from hrsa_salary_sob_item
where delete_type = 0
and income_category = 1
and salary_item_code in ('addUpTaxableIncome');
and salary_item_code in ('addUpTaxableIncome','addUpTaxFreeIncome','addUpTaxDeduction');
/

View File

@ -57,6 +57,6 @@ select id, create_time, update_time, creator, delete_type, tenant_key, salary_so
from hrsa_salary_sob_item
where delete_type = 0
and income_category = 1
and salary_item_code in ('addUpTaxableIncome');
and salary_item_code in ('addUpTaxableIncome','addUpTaxFreeIncome','addUpTaxDeduction');
/

View File

@ -57,6 +57,6 @@ select id, create_time, update_time, creator, delete_type, tenant_key, salary_so
from hrsa_salary_sob_item
where delete_type = 0
and income_category = 1
and salary_item_code in ('addUpTaxableIncome');
and salary_item_code in ('addUpTaxableIncome','addUpTaxFreeIncome','addUpTaxDeduction');
/

View File

@ -54,5 +54,5 @@ select id, create_time, update_time, creator, delete_type, tenant_key, salary_so
from hrsa_salary_sob_item
where delete_type = 0
and income_category = 1
and salary_item_code in ('addUpTaxableIncome')
and salary_item_code in ('addUpTaxableIncome','addUpTaxFreeIncome','addUpTaxDeduction')
;

View File

@ -53,5 +53,5 @@ select id, create_time, update_time, creator, delete_type, tenant_key, salary_so
from hrsa_salary_sob_item
where delete_type = 0
and income_category = 1
and salary_item_code in ('addUpTaxableIncome')
and salary_item_code in ('addUpTaxableIncome','addUpTaxFreeIncome','addUpTaxDeduction')
/

View File

@ -57,5 +57,5 @@ select id, create_time, update_time, creator, delete_type, tenant_key, salary_so
from hrsa_salary_sob_item
where delete_type = 0
and income_category = 1
and salary_item_code in ('addUpTaxableIncome');
and salary_item_code in ('addUpTaxableIncome','addUpTaxFreeIncome','addUpTaxDeduction');
/

View File

@ -54,5 +54,5 @@ select id, create_time, update_time, creator, delete_type, tenant_key, salary_so
from hrsa_salary_sob_item
where delete_type = 0
and income_category = 1
and salary_item_code in ('addUpTaxableIncome')
and salary_item_code in ('addUpTaxableIncome','addUpTaxFreeIncome','addUpTaxDeduction')
GO

View File

@ -57,6 +57,6 @@ select id, create_time, update_time, creator, delete_type, tenant_key, salary_so
from hrsa_salary_sob_item
where delete_type = 0
and income_category = 1
and salary_item_code in ('addUpTaxableIncome');
and salary_item_code in ('addUpTaxableIncome','addUpTaxFreeIncome','addUpTaxDeduction');
/

View File

View File

@ -0,0 +1,59 @@
package com.customization.salary;
import com.engine.core.cfg.annotation.ServiceDynamicProxy;
import com.engine.core.impl.aop.AbstractServiceProxy;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctRecordListDTO;
import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordQueryParam;
import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordSaveParam;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.wrapper.SalaryAcctRecordWrapper;
import com.engine.salary.wrapper.proxy.SalaryAcctRecordWrapperProxy;
import java.util.Collection;
import java.util.Map;
/**
* 薪资核算记录
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@ServiceDynamicProxy(target = SalaryAcctRecordWrapper.class, desc = "核算记录")
public class CustomSalaryAcctRecordWrapper extends AbstractServiceProxy implements SalaryAcctRecordWrapperProxy {
@Override
@ServiceMethodDynamicProxy(desc = "拦截核算记录列表")
public PageInfo<SalaryAcctRecordListDTO> listPage(SalaryAcctRecordQueryParam queryParam) {
PageInfo<SalaryAcctRecordListDTO> salaryAcctRecordListDTOPageInfo = (PageInfo<SalaryAcctRecordListDTO>) executeMethod(queryParam);
//todo do some thing
return salaryAcctRecordListDTOPageInfo;
}
@Override
public Map<String, Object> getForm(Long id) {
return (Map<String, Object>)executeMethod(id);
}
@Override
public Long save(SalaryAcctRecordSaveParam saveParam) {
return (Long)executeMethod(saveParam);
}
@Override
public void delete(Collection<Long> ids) {
executeMethod(ids);
}
@Override
public void file(Long id) {
executeMethod(id);
}
@Override
public void reCalculate(Long id) {
executeMethod(id);
}
}

View File

@ -34,22 +34,6 @@ public class CustomSalarySendWrapper extends AbstractServiceProxy implements Sal
@Override
@ServiceMethodDynamicProxy(desc = "拦截工资单发送方法")
public Map<String, Object> grant(SalarySendGrantParam queryParam) {
Long salarySendId = queryParam.getSalarySendId();
List<Long> ids = queryParam.getIds();
if (queryParam.getSalarySendRangeIds() != null) {
//如果传了范围id则使用范围id发放
ids = getSalarySendRangeService(new User())
.getSendInfoIdsBySendId(queryParam.getSalarySendId(), queryParam.getSalarySendRangeIds(), SalarySendGrantTypeEnum.GRANT);
if (ids.isEmpty()) {// 由于查出来是空的会导致全部发放在此进行拦截
throw new SalaryRunTimeException("工资发放范围内没有匹配员工");
}
}
List<Map<String, Object>> sendInfoList = getSalaryBillService(new User()).getSendInfoList(salarySendId, ids);
//解析sendInfoList拼接短信内容
System.out.println("发送短信");
//todo do some thing
Map<String, Object> result = (Map<String, Object>) executeMethod(queryParam);

View File

@ -32,3 +32,14 @@ update hrsa_other_archives set delete_type=3 WHERE employee_id = ? and payment_
-- 删除薪资档案
update hrsa_salary_archive set delete_type=3 where employee_id = ? and tax_agent_id=?
update hrsa_salary_archive set delete_type=3;
update hrsa_insurance_base_info set delete_type=3;
update hrsa_social_archives set delete_type=3;
update hrsa_fund_archives set delete_type=3;
update hrsa_other_archives set delete_type=3;
update hrsa_tax_agent_emp set delete_type=3;

View File

@ -8,3 +8,14 @@ left join hrsa_salary_acct_result result on record.id = result.salary_acct_recor
left join hrsa_salary_item item on result.salary_item_id = item.id and item.delete_type = 0
left join hrsa_tax_agent agent on agent.id=sob.tax_agent_id and agent.delete_type=0
left join hrmresource e on e.id= result.employee_id
# 获取档案信息
select i.item_value from hrsa_salary_archive_item i
left join hrsa_salary_archive a on a.id = i.salary_archive_id
left join hrsa_salary_item c on c.id=i.salary_item_id
left join hrsa_tax_agent t on a.tax_agent_id=t.id
where a.delete_type=0 and i.delete_type=0 and t.delete_type=0 and c.delete_type=0
and a.employee_id=$main.ygid$ and t.name='$main.dzqgskjywr$'
and effective_time <= now() and c.name='基本工资' order by effective_time desc

View File

@ -24,4 +24,10 @@ public @interface SalaryFormulaVar {
String dataType();
String fieldId() default "";
/**
* 别名,用于属性名和项目名不匹配时场景
* @return
*/
String alias() default "";
}

View File

@ -22,7 +22,7 @@ import java.util.List;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@SalaryTable(pageId = "a4f83287-e3f9-4275-9527-7d06e54y6238", fields = "id,addUpSubtraction", operates = {@SalaryTableOperate(text = "删除",index = "0")})
@SalaryTable(pageId = "a4f83287-e3f9-4275-9527-7d06e54y6238", fields = "id,addUpSubtraction", operates = {@SalaryTableOperate(text = "删除", index = "0")})
//hrsa_add_up_situation
@ElogTransform(name = "往期累计情况")
public class AddUpSituation {
@ -59,6 +59,7 @@ public class AddUpSituation {
/**
* 人员类型
*
* @see DataCollectionEmployeeTypeEnum
*/
private Integer employeeType;
@ -162,8 +163,8 @@ public class AddUpSituation {
/**
* 累计企业职业年金及其他福利
*/
@ElogTransform(name = "累计企业(职业)年金及其他福利")
@SalaryFormulaVar(defaultLabel = "累计企业(职业)年金及其他福利", labelId = 90567, dataType = "number")
@ElogTransform(name = "累计企业(职业)年金及其他福利")
@Encrypt
private String addUpEnterpriseAndOther;
@ -178,8 +179,8 @@ public class AddUpSituation {
/**
* 累计免税收入
*/
@SalaryFormulaVar(defaultLabel = "累计免税收入", labelId = 86704, dataType = "number",alias = "addUpTaxFreeIncome")
@ElogTransform(name = "累计免税收入")
@SalaryFormulaVar(defaultLabel = "累计免税收入", labelId = 86704, dataType = "number")
@Encrypt
private String addUpTaxExemptIncome;
@ -194,8 +195,8 @@ public class AddUpSituation {
/**
* 累计减免税额
*/
@SalaryFormulaVar(defaultLabel = "累计减免税额", labelId = 105478, dataType = "number", alias = "addUpTaxDeduction")
@ElogTransform(name = "累计减免税额")
@SalaryFormulaVar(defaultLabel = "累计减免税额", labelId = 105478, dataType = "number")
@Encrypt
private String addUpTaxSavings;

View File

@ -101,6 +101,9 @@ public class DataCollectionEmployee {
@SalaryFormulaVar(defaultLabel = "职称", labelId = 98623, dataType = "string")
private String jobcall;
@SalaryFormulaVar(defaultLabel = "职称ID", labelId = 98623, dataType = "string")
private Long jobcallId;
//生日
@SalaryFormulaVar(defaultLabel = "出生日期", labelId = 98624, dataType = "string")
private String birthday;

View File

@ -33,6 +33,7 @@ import weaver.common.MessageUtil;
import weaver.conn.RecordSet;
import weaver.email.EmailWorkRunnable;
import weaver.file.ImageFileManager;
import weaver.general.Util;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.resource.ResourceComInfo;
@ -199,6 +200,7 @@ public class SalaryBillBO {
log.error("资源异常", e);
}
companyName = subCompanyComInfo.getSubCompanyname(resourceComInfo.getSubCompanyID(employeeId + ""));
companyName = Util.formatMultiLang(companyName);
}
}
@ -372,7 +374,7 @@ public class SalaryBillBO {
.replace("{薪资所属月}", SalaryDateUtil.getFormatYearMonth(salaryBillSendParam.getSalaryDate()));
for (SalaryTemplateSalaryItemListDTO item : salaryBillSendParam.getEmployeeInformation().getItems()) {
content = content.replace("{" + item.getName() + "}", item.getSalaryItemValue());
content = content.replace("{" + item.getName() + "}", Util.null2String(item.getSalaryItemValue()));
}
for (SalaryTemplateSalaryItemSetListDTO salaryTemplateSalaryItemSetListDTO : salaryBillSendParam.getSalaryItemSetList()) {

View File

@ -5,8 +5,6 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
/**
@ -62,4 +60,7 @@ public class SalaryMySalaryBillListDTO {
private Date sendTime;
private Long employeeId;
}

View File

@ -7,11 +7,14 @@ import com.engine.salary.entity.salaryformula.po.FormulaVar;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum;
import com.engine.salary.util.SalaryEntityUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -91,10 +94,9 @@ public class ExpressFormulaBO {
* @param formulaVarValueMap 公式变量的值
* @return
*/
public static List<FormulaVar> buildFormulaVar4Accounting(ExpressFormula expressFormula, Map<String, String> formulaVarValueMap) {
List<FormulaVar> formulaVars = Collections.emptyList();
formulaVars = expressFormula.getParameters();
for (FormulaVar formulaVar : formulaVars) {
public static List<FormulaVar> buildFormulaVar4Accounting(ExpressFormula expressFormula, Map<String, String> formulaVarValueMap) throws JsonProcessingException {
List<FormulaVar> formulaVars = new ArrayList<>();
for (FormulaVar formulaVar : expressFormula.getParameters()) {
// 公式变量的值
String formulaVarValue = formulaVarValueMap.getOrDefault(formulaVar.getFieldId(), StringUtils.EMPTY);
// 如果公式的返回值类型为number公式中的变量的值如果为空公式运行的时候会报错所以需要替换成0
@ -103,7 +105,11 @@ public class ExpressFormulaBO {
} else if (StringUtils.isEmpty(formulaVarValue) && "string".equals(formulaVar.getFieldType())) {
formulaVarValue = "";
}
formulaVar.setContent(formulaVarValue);
ObjectMapper objectMapper = new ObjectMapper();
FormulaVar copyVar = objectMapper.readValue(objectMapper.writeValueAsString(formulaVar), FormulaVar.class);
copyVar.setContent(formulaVarValue);
formulaVars.add(copyVar);
}
return formulaVars;
}

View File

@ -5,7 +5,6 @@ import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
import com.engine.salary.enums.SalaryRoundingModeEnum;
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
import com.engine.salary.util.JsonUtil;
import com.engine.salary.util.SalaryEntityUtil;
@ -14,8 +13,10 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* 薪资核算公式变量
@ -32,8 +33,8 @@ public class SalaryAcctFormulaBO {
*
* @param value
* @param salaryItem
* @param salarySobBackItems 薪资账套回算项目List
* @param salarySobBackItemMap 薪资账套回算项目Map
* @param salarySobBackItems 薪资账套回算项目List
* @param salarySobBackItemMap 薪资账套回算项目Map
* @param salaryItemIdKeySalarySobItemPOMap 薪资账套下薪资项目Map
* @return
*/
@ -55,33 +56,13 @@ public class SalaryAcctFormulaBO {
.orElse(salaryItem.getRoundingMode());
Integer salaryItemPattern = Optional.ofNullable(salaryItemIdKeySalarySobItemPOMap.get(salaryItem.getId())).map(SalarySobItemPO::getPattern)
.orElse(salaryItem.getPattern());
if(CollectionUtils.isNotEmpty(salarySobBackItems) && salarySobBackItemMap.containsKey(salaryItem.getId())){
if (CollectionUtils.isNotEmpty(salarySobBackItems) && salarySobBackItemMap.containsKey(salaryItem.getId())) {
// 薪资项目是回算项目
salaryItemRoundingMode = salarySobBackItemMap.get(salaryItem.getId()).getRoundingMode();
salaryItemPattern = salarySobBackItemMap.get(salaryItem.getId()).getPattern();
}
BigDecimal bigDecimalValue = SalaryEntityUtil.empty2Zero(value);
RoundingMode roundingMode = RoundingMode.HALF_UP;
if (Objects.equals(salaryItemRoundingMode, SalaryRoundingModeEnum.ROUND_UP.getValue())) {
roundingMode = RoundingMode.UP;
}
if (Objects.equals(salaryItemRoundingMode, SalaryRoundingModeEnum.ROUND_DOWN.getValue())) {
roundingMode = RoundingMode.DOWN;
}
//见分取角只取保留小数后一位向上舍入
if (Objects.equals(salaryItemRoundingMode, SalaryRoundingModeEnum.CEILING.getValue())) {
bigDecimalValue = bigDecimalValue.setScale(salaryItemPattern + 1, RoundingMode.FLOOR);
roundingMode = RoundingMode.UP;
}
//向上取偶
if (Objects.equals(salaryItemRoundingMode, SalaryRoundingModeEnum.UP_EVEN.getValue())) {
bigDecimalValue = bigDecimalValue.setScale(0, RoundingMode.UP);
int number = bigDecimalValue.intValue();
if (number % 2 != 0) {
bigDecimalValue = bigDecimalValue.add(BigDecimal.valueOf(1));
}
}
return bigDecimalValue.setScale(salaryItemPattern, roundingMode).toPlainString();
return SalaryEntityUtil.carryRule(salaryItemPattern, salaryItemRoundingMode, bigDecimalValue).toString();
}
/**
@ -113,6 +94,7 @@ public class SalaryAcctFormulaBO {
.jobtitleName(simpleEmployee.getJobtitleName())
.jobtitleId(simpleEmployee.getJobtitleId())
.jobcall(simpleEmployee.getJobcall())
.jobcallId(simpleEmployee.getJobcallId())
.companystartdate(simpleEmployee.getCompanystartdate())
.birthday(simpleEmployee.getBirthday())
.workcode(simpleEmployee.getWorkcode())

View File

@ -90,6 +90,8 @@ public class SalaryFormulaEmployeeDTO {
//职称
@SalaryFormulaVar(defaultLabel = "职称", labelId = 98623, dataType = "string")
private String jobcall;
@SalaryFormulaVar(defaultLabel = "职称ID", labelId = 98623, dataType = "string")
private Long jobcallId;
@SalaryFormulaVar(defaultLabel = "出生日期", labelId = 98624, dataType = "string")

View File

@ -315,7 +315,7 @@ public class SalaryAcctManager extends Service {
ProgressDTO initProgress = new ProgressDTO().setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")).setTitleLabelId(97515L).setTotalQuantity(salaryAcctEmployeePOS.size() * 2 + 1).setCalculatedQuantity(0).setProgress(BigDecimal.ZERO).setStatus(true).setMessage(StringUtils.EMPTY);
getSalaryAcctProgressService(user).initProgress("SUPPLEMENT_ACCT_PROGRESS_" + salaryAcctRecordId, initProgress);
// 12对薪资核算人员进行拆分
List<List<SalaryAcctEmployeePO>> partition = Lists.partition(salaryAcctEmployeePOS, 5000);
List<List<SalaryAcctEmployeePO>> partition = Lists.partition(salaryAcctEmployeePOS, 100);
// 12.1监控子线程的任务执行
CountDownLatch childMonitor = new CountDownLatch(partition.size());
// 12.2记录子线程的执行结果
@ -353,7 +353,7 @@ public class SalaryAcctManager extends Service {
getSalaryAcctCalculateService(user).calculate(salaryAcctCalculateBO, simpleEmployee, finalSalarySobBackItems);
}
};
ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.HRM, "salaryAcctCalculateV2", localRunnable);
ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.HRM, "salaryAcctCalculate", localRunnable);
}
// 13等待所有子线程执行完毕
childMonitor.await();

View File

@ -52,10 +52,10 @@
e.sex as sex,
e.email as email,
e.telephone as telephone,
e.jobcall as jobcall,
e.jobcall as jobcallId,
job.name as jobcall,
e.birthday as birthday,
e.certificatenum as idNo,
c.id as jobtitleId,
e.enddate as dismissdate,
e.workyear,
e.companyworkyear
@ -63,6 +63,7 @@
left join hrmdepartment d on e.departmentid = d.id
left join hrmjobtitles c on e.jobtitle = c.id
left join HrmSubCompany sc on e.SUBCOMPANYID1=sc.id
left join hrmjobcall job on e.jobcall=job.id
where e.status not in (7) and (e.accounttype is null or e.accounttype = 0)
<if test="collection != null and collection.size()>0">
AND e.id IN

View File

@ -23,6 +23,10 @@ public interface SalaryBillService {
*/
Map<String, Object> grant(SalarySendGrantParam queryParam);
Map<String, Object> reGenPdf(SalarySendGrantParam queryParam);
/**
* 获取内容
* @param sendId
@ -46,6 +50,8 @@ public interface SalaryBillService {
String exportPdf(SalaryExportPdfParam param);
String genPdfBeforeExport(SalaryExportPdfParam salaryExportPdfParam);
/**
* 工资单撤回
*

View File

@ -798,7 +798,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
String cacheKey = "addUpDeduction_autoAddAll_processing";
Object objVal = Util_DataCache.getObjVal(cacheKey);
if (objVal != null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(135788, "一键累计过于频繁,请稍后再试"));
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(135788, "一键累计过于频繁,请稍后再试 "));
}
try {
Util_DataCache.setObjVal(cacheKey, true);

View File

@ -402,28 +402,32 @@ public class EmployeeDeclareExcelServiceImpl extends Service implements Employee
}
}
} else if (StringUtils.equals(dataKey, SalaryI18nUtil.getI18nLabel(0, "首次入境时间"))) {
if (StringUtils.isNotBlank(dataValue) && dataValue.length() >= 10) {
dataValue = dataValue.substring(0, 10);
}
if (!SalaryDateUtil.checkDay(dataValue)) {
isError = true;
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(0, "日期格式不正确"));
errorData.add(errorMessageMap);
} else {
employeeDeclareExcel.setEntryDate(SalaryDateUtil.dateStrToLocalDate(dataValue));
if (StringUtils.isNotBlank(dataValue)) {
if (dataValue.length() >= 10) {
dataValue = dataValue.substring(0, 10);
}
if (!SalaryDateUtil.checkDay(dataValue)) {
isError = true;
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(0, "日期格式不正确"));
errorData.add(errorMessageMap);
} else {
employeeDeclareExcel.setEntryDate(SalaryDateUtil.dateStrToLocalDate(dataValue));
}
}
} else if (StringUtils.equals(dataKey, SalaryI18nUtil.getI18nLabel(0, "预计离境时间"))) {
if (StringUtils.isNotBlank(dataValue) && dataValue.length() >= 10) {
dataValue = dataValue.substring(0, 10);
}
if (!SalaryDateUtil.checkDay(dataValue)) {
isError = true;
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(0, "日期格式不正确"));
errorData.add(errorMessageMap);
} else {
employeeDeclareExcel.setDepartureDate(SalaryDateUtil.dateStrToLocalDate(dataValue));
if (StringUtils.isNotBlank(dataValue)) {
if (StringUtils.isNotBlank(dataValue) && dataValue.length() >= 10) {
dataValue = dataValue.substring(0, 10);
}
if (!SalaryDateUtil.checkDay(dataValue)) {
isError = true;
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(0, "日期格式不正确"));
errorData.add(errorMessageMap);
} else {
employeeDeclareExcel.setDepartureDate(SalaryDateUtil.dateStrToLocalDate(dataValue));
}
}
} else if (StringUtils.equals(dataKey, SalaryI18nUtil.getI18nLabel(0, "涉税事由"))) {
employeeDeclareExcel.setTaxReasons(dataValue);

View File

@ -112,23 +112,23 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
@Override
public void calculate(SalaryAcctCalculateBO salaryAcctCalculateBO, DataCollectionEmployee simpleEmployee, List<SalarySobBackItemPO> salarySobBackItems) {
StopWatch sw = new StopWatch(salaryAcctCalculateBO.getSalaryAcctRecordPO().getId()+"");
StopWatch sw = new StopWatch("核算耗时明细id"+salaryAcctCalculateBO.getSalaryAcctRecordPO().getId()+"");
Date now = new Date();
try {
// 数据库字段加密用
// 1查询人员信息
sw.start("核算耗时查询人员信息");
sw.start("查询人员信息");
List<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getEmployeeId, Collectors.toList());
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds);
SalarySobCycleDTO salarySobCycleDTO = salaryAcctCalculateBO.getSalarySobCycleDTO();
Long taxAgentId = salaryAcctCalculateBO.getSalarySobPO().getTaxAgentId();
sw.stop();
// 2查询薪资档案的数据
sw.start("核算耗时查询薪资档案的数据");
sw.start("查询薪资档案的数据");
List<SalaryArchiveDataDTO> salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId);
sw.stop();
// 3查询往期累计情况(查询的是上个税款所属期的的累计情况)
sw.start("核算耗时查询往期累计情况");
sw.start("查询往期累计情况");
List<AddUpSituation> addUpSituationPOS;
if (salarySobCycleDTO.getTaxCycle().getMonth() == Month.JANUARY) {
// 3.1如果当前税款所属期是本年度第一个税款所属期就不需要查询往期累计情况
@ -138,28 +138,28 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
}
sw.stop();
// 4查询累计专项附加扣除
sw.start("核算耗时查询累计专项附加扣除");
sw.start("查询累计专项附加扣除");
List<AddUpDeduction> addUpDeductionPOS = getAddUpDeductionService(user).getAddUpDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentId);
sw.stop();
// 5查询其他免税扣除
sw.start("核算耗时查询其他免税扣除");
sw.start("查询其他免税扣除");
List<OtherDeductionPO> otherDeductionPOS = getOtherDeductionService(user).getOtherDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentId);
sw.stop();
//6查询社保福利
sw.start("核算耗时查询社保福利");
sw.start("查询社保福利");
List<Map<String, Object>> welfareData = getSIAccountService(user).welfareData(salarySobCycleDTO.getSocialSecurityCycle().toString(), employeeIds, taxAgentId);
sw.stop();
// 7查询考勤数据
sw.start("核算耗时查询考勤数据");
sw.start("查询考勤数据");
List<AttendQuoteDataDTO> attendQuoteDataDTOS = getAttendQuoteDataService(user).getAttendQuoteData(salarySobCycleDTO.getSalaryMonth(), salarySobCycleDTO.getSalarySobId(), employeeIds);
sw.stop();
// 8查询薪资核算人员的薪资核算结果
sw.start("核算耗时查询薪资核算人员的薪资核算结果");
sw.start("查询薪资核算人员的薪资核算结果");
List<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getId, Collectors.toList());
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
sw.stop();
// 薪资回算时回算前的核算结果 (没有回算项)
sw.start("核算耗时查询薪资回算时回算前的核算结果");
sw.start("查询薪资回算时回算前的核算结果");
Map<String, List<SalaryAcctResultPO>> collect = salaryAcctResultPOS.stream().collect(Collectors.groupingBy(k -> k.getEmployeeId() + "-" + k.getTaxAgentId() + "-" + k.getSalaryItemId()));
Map<String, String> salaryAcctResultPOMap = new HashMap<>();
for (Map.Entry<String, List<SalaryAcctResultPO>> et : collect.entrySet()) {
@ -170,22 +170,22 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
List<Long> lockSalaryItemIds = ListUtils.emptyIfNull(salaryAcctCalculateBO.getLockSalaryItemIds());
sw.stop();
// 9查询相同税款所属期内涉及合并计税的其他薪资核算结果
sw.start("核算耗时查询相同税款所属期内涉及合并计税的其他薪资核算结果");
sw.start("查询相同税款所属期内涉及合并计税的其他薪资核算结果");
Set<Long> otherSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getOtherSalaryAcctRecordPOS(), SalaryAcctRecordPO::getId);
List<SalaryAcctResultPO> otherSalaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIdsAndEmployeeIds(otherSalaryAcctRecordIds, employeeIds);
Map<String, List<SalaryAcctResultPO>> otherSalaryAcctResultPOMap = SalaryEntityUtil.group2Map(otherSalaryAcctResultPOS, e -> e.getEmployeeId() + "_" + e.getTaxAgentId());
sw.stop();
// 9.1查询相同税款所属期内设计合并计税的其他薪资核算人员
sw.start("核算耗时查询相同税款所属期内设计合并计税的其他薪资核算人员");
sw.start("查询相同税款所属期内设计合并计税的其他薪资核算人员");
List<SalaryAcctEmployeePO> otherSalaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIdsAndEmployeeIds(otherSalaryAcctRecordIds, employeeIds);
Map<String, List<SalaryAcctEmployeePO>> otherSalaryAcctEmployeePOMap = SalaryEntityUtil.group2Map(otherSalaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId());
sw.stop();
// 10转换成公式编辑器中的变量
sw.start("核算耗时转换成公式编辑器中的变量");
sw.start("转换成公式编辑器中的变量");
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, salaryArchiveData, addUpSituationPOS, addUpDeductionPOS, otherDeductionPOS, welfareData, attendQuoteDataDTOS, salaryAcctResultPOS);
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO);
sw.stop();
sw.start("核算耗时数据结构准备");
sw.start("数据结构准备");
// 本次薪资核算所用的薪资账套下的薪资项目
Map<Long, SalarySobItemPO> salaryItemIdKeySalarySobItemPOMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalarySobItemPOS(), SalarySobItemPO::getSalaryItemId);
// 本次薪资核算所用的公式
@ -198,7 +198,7 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
List<SalaryAcctResultTempPO> salaryAcctResultTempPOS = Lists.newArrayList();
sw.stop();
// 开始核算
sw.start("核算耗时核算耗时");
sw.start("核算耗时");
StringBuffer noticeMsg = new StringBuffer();
for (SalaryAcctEmployeePO salaryAcctEmployeePO : salaryAcctCalculateBO.getSalaryAcctEmployeePOS()) {
Long salaryAcctEmployeePOId = salaryAcctEmployeePO.getId();
@ -288,7 +288,7 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
}
sw.stop();
// 保存新的薪资核算结果临时存储
sw.start("核算耗时保存新的薪资核算结果(临时存储)");
sw.start("保存新的薪资核算结果(临时存储)");
getSalaryAcctResultTempService(user).batchSave(salaryAcctResultTempPOS);
sw.stop();
// 更新薪资核算进度
@ -298,7 +298,7 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
noticeMsg.toString()
);
sw.stop();
log.info("核算耗时明细" + sw.prettyPrint());
log.info(sw.prettyPrint());
// 记录子线程执行结果
salaryAcctCalculateBO.getResults().add(new SalaryAcctCalculateBO.Result(true, StringUtils.EMPTY));
} catch (Exception e) {

View File

@ -461,7 +461,7 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
if (fixedNum == 0) {
fixedNum = 3;
}
for (int i = 0; i < fixedNum; i++) {
for (int i = 0; i < fixedNum && i < columnList.size(); i++) {
columnList.get(i).setFixed("left");
}
}

View File

@ -728,9 +728,9 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
@Override
public void calculate(SalaryAcctCalculateParam calculateParam, DataCollectionEmployee simpleEmployee) {
StopWatch stopWatch = new StopWatch(calculateParam.getSalaryAcctRecordId() + "");
StopWatch stopWatch = new StopWatch("总核算耗时id"+calculateParam.getSalaryAcctRecordId());
try {
stopWatch.start("核算总耗时数据准备");
stopWatch.start("数据准备");
// 1查询薪资核算记录
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(calculateParam.getSalaryAcctRecordId());
if (Objects.isNull(salaryAcctRecordPO)) {
@ -800,13 +800,13 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
}
stopWatch.stop();
stopWatch.start("核算完毕计");
stopWatch.start("核算");
// 11.1初始化进度
ProgressDTO initProgress = new ProgressDTO().setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")).setTitleLabelId(97515L).setTotalQuantity(salaryAcctEmployeePOS.size() * 2 + 1).setCalculatedQuantity(0).setProgress(BigDecimal.ZERO).setStatus(true).setMessage(StringUtils.EMPTY);
getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), initProgress);
// 12对薪资核算人员进行拆分
List<List<SalaryAcctEmployeePO>> partition = Lists.partition(salaryAcctEmployeePOS, 5000);
List<List<SalaryAcctEmployeePO>> partition = Lists.partition(salaryAcctEmployeePOS, 100);
// 12.1监控子线程的任务执行
CountDownLatch childMonitor = new CountDownLatch(partition.size());
// 12.2记录子线程的执行结果
@ -817,7 +817,26 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
TaxDeclarationFunctionEnum taxDeclarationFunction = getSalarySysConfService(user).getTaxDeclaration();
// 12.5多线程运算运算结果存放在临时表中
for (List<SalaryAcctEmployeePO> acctEmployeePOS : partition) {
SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO().setSalaryAcctRecordPO(salaryAcctRecordPO).setSalarySobPO(salarySobPO).setSalarySobCycleDTO(salarySobCycleDTO).setOtherSalaryAcctRecordPOS(otherSalaryAcctRecordPOS).setSalaryAcctLockResultPOS(MapUtils.emptyIfNull(acctResults)).setLockSalaryItemIds(lockSalaryItemIds).setSalarySobItemPOS(salarySobItemPOS).setSalaryItemIdWithPriorityList(salarySobItemsWithPriority).setExpressFormulas(expressFormulas).setSalaryItemPOS(salaryItemPOS).setSalarySobAdjustRulePOS(salarySobAdjustRulePOS).setWelfareColumns(MapUtils.emptyIfNull(welfareColumns)).setAttendQuoteFieldListDTOS(attendQuoteFieldListDTOS).setSalaryAcctEmployeePOS(acctEmployeePOS).setIssuedFieldIds(issuedFieldIds).setChildMonitor(childMonitor).setResults(calculateResults).setCalculateKey(calculateKey).setTaxDeclarationFunction(taxDeclarationFunction);
SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO()
.setSalaryAcctRecordPO(salaryAcctRecordPO)
.setSalarySobPO(salarySobPO)
.setSalarySobCycleDTO(salarySobCycleDTO)
.setOtherSalaryAcctRecordPOS(otherSalaryAcctRecordPOS)
.setSalaryAcctLockResultPOS(MapUtils.emptyIfNull(acctResults))
.setLockSalaryItemIds(lockSalaryItemIds)
.setSalarySobItemPOS(salarySobItemPOS)
.setSalaryItemIdWithPriorityList(salarySobItemsWithPriority)
.setExpressFormulas(expressFormulas)
.setSalaryItemPOS(salaryItemPOS)
.setSalarySobAdjustRulePOS(salarySobAdjustRulePOS)
.setWelfareColumns(MapUtils.emptyIfNull(welfareColumns))
.setAttendQuoteFieldListDTOS(attendQuoteFieldListDTOS)
.setSalaryAcctEmployeePOS(acctEmployeePOS)
.setIssuedFieldIds(issuedFieldIds)
.setChildMonitor(childMonitor)
.setResults(calculateResults)
.setCalculateKey(calculateKey)
.setTaxDeclarationFunction(taxDeclarationFunction);
List<SalarySobBackItemPO> finalSalarySobBackItems = salarySobBackItems;
LocalRunnable localRunnable = new LocalRunnable() {
@Override
@ -825,13 +844,13 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
getSalaryAcctCalculateService(user).calculate(salaryAcctCalculateBO, simpleEmployee, finalSalarySobBackItems);
}
};
ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.HRM, "salaryAcctCalculateV2", localRunnable);
ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.HRM, "salaryAcctCalculate", localRunnable);
}
// 13等待所有子线程执行完毕
childMonitor.await();
stopWatch.stop();
stopWatch.start("核算入库计");
stopWatch.start("数据写入耗");
// 14判断子线程执行结果
boolean allSuccess = calculateResults.stream().allMatch(SalaryAcctCalculateBO.Result::isStatus);

View File

@ -1,5 +1,6 @@
package com.engine.salary.service.impl;
import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.api.formmode.mybatis.util.SqlProxyHandle;
@ -37,6 +38,7 @@ import com.engine.salary.util.JsonUtil;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.pdf.HtmlToPdf;
import com.google.common.collect.Lists;
import com.weaver.util.threadPool.ThreadPoolUtil;
import com.weaver.util.threadPool.constant.ModulePoolEnum;
@ -200,6 +202,44 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService
return new HashMap<>();
}
/**
* 对于已经发送的工资单重新生成pdf
* @param param
* @return
*/
@Override
public Map<String, Object> reGenPdf(SalarySendGrantParam param) {
// 1.检查和获取工资单发放
SalarySendPO salarySend = checkAndGetSalarySend(param.getSalarySendId());
// 获取默认模板
SalarySobPO salarySob = getSalarySobService(user).getById(salarySend.getSalarySobId());
List<SalaryTemplatePO> salaryTemplates = salarySob == null ? Lists.newArrayList() : getSalaryTemplateService(user).getDefaultTemplates(Arrays.asList(salarySend.getSalarySobId(), salarySob.getId()));
SalaryTemplatePO salaryTemplate = salaryTemplates.get(0);
List<Long> ids = param.getIds();
if (param.getSalarySendRangeIds() != null) {
//如果传了范围id则使用范围id发放
ids = getSalarySendRangeService(user)
.getSendInfoIdsBySendId(salarySend.getId(), param.getSalarySendRangeIds(), SalarySendGrantTypeEnum.GRANT);
if (ids.isEmpty()) {// 由于查出来是空的会导致全部发放在此进行拦截
throw new SalaryRunTimeException("工资发放范围内没有匹配员工");
}
}
try {
TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salarySob.getTaxAgentId());
// 1.构建发送参数
SalaryBillSendDTO salaryBillSendParam = buildSendParams(salarySend, taxAgentPO.getName(), salaryTemplate);
// 2.获取可发送的列表此步最耗时需要解密核算数据
List<Integer> sendStatusList = Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue(), SalarySendStatusEnum.ALREADYSEND.getValue());
List<Map<String, Object>> enableSendList = getEnableSendList(salarySend, ids, salaryBillSendParam, sendStatusList);
//生成pdf
genPdf(salaryBillSendParam, enableSendList, true);
getProgressService(user).finish(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), true);
} catch (Exception e) {
log.info("发送出错:{}", e.getMessage(), e);
}
return new HashMap<>();
}
/**
* 处理发送
@ -221,13 +261,14 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService
SalaryBillSendDTO salaryBillSendParam = buildSendParams(salarySend, taxAgentPO.getName(), salaryTemplate);
// 2.获取可发送的列表此步最耗时需要解密核算数据
List<Map<String, Object>> enableSendList = getEnableSendList(salarySend, ids, salaryBillSendParam);
List<Integer> sendStatusList = Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue());
List<Map<String, Object>> enableSendList = getEnableSendList(salarySend, ids, salaryBillSendParam, sendStatusList);
// 3.发送消息先修改数据再发消息避免出错后无法撤回
List<Long> successIds = sendMessage(enableSendList, salaryBillSendParam);
//生成pdf
genPdf(salaryBillSendParam, enableSendList);
genPdf(salaryBillSendParam, enableSendList, false);
// 4.发放
grantSendInfo(successIds, salarySend, salaryTemplate, salaryBillSendParam);
@ -250,35 +291,44 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService
}
}
private void genPdf(SalaryBillSendDTO salaryBillSendParam, List<Map<String, Object>> enableSendList) {
private void genPdf(SalaryBillSendDTO salaryBillSendParam, List<Map<String, Object>> enableSendList, boolean isSync) {
if (GEN_PDF) {
LocalRunnable localRunnable = new LocalRunnable() {
@Override
public void execute() {
// 获取人员完整信息
Map<String, DataCollectionEmployee> allEmployeeMap = getEmployeeWholeInfo(enableSendList);
//生成工资单pdf
enableSendList.forEach(e -> {
// 构建人员信息
SalaryBillBO.buildEmployeeInfo(salaryBillSendParam, allEmployeeMap.get(e.get("employeeId").toString()));
SalaryBillBO.genPdf(e, salaryBillSendParam);
});
if (isSync) {
genPdf(salaryBillSendParam, enableSendList);
} else {
LocalRunnable localRunnable = new LocalRunnable() {
@Override
public void execute() {
genPdf(salaryBillSendParam, enableSendList);
}
};
ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryBillGenPdf", localRunnable);
}
//合并工资单pdf
//1先获取所有工资单
Long id = salaryBillSendParam.getSalarySend().getId();
List<SalarySendInfoPO> salarySendInfos = getSalarySendInfoMapper().listSome(SalarySendInfoPO.builder().salarySendId(id).sendStatus(1).build());
//2工资单pdf转为路径
String yyyyMM = SalaryDateUtil.getFormatYearMonth(salaryBillSendParam.getSalaryDate());
List<String> filesToMerge = salarySendInfos.stream().map(po -> HrmSalaryPayrollConf.GEN_PATH + yyyyMM + File.separator + id + File.separator + po.getId() + ".pdf").collect(Collectors.toList());
String pdfPath = HrmSalaryPayrollConf.GEN_PATH + yyyyMM + File.separator + id + File.separator + id + ".pdf";
SalaryBillBO.mergePdf(pdfPath, filesToMerge);
}
};
ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryBillGenPdf", localRunnable);
}
}
private void genPdf(SalaryBillSendDTO salaryBillSendParam, List<Map<String, Object>> enableSendList) {
// 获取人员完整信息
Map<String, DataCollectionEmployee> allEmployeeMap = getEmployeeWholeInfo(enableSendList);
//生成工资单pdf
enableSendList.forEach(e -> {
// 构建人员信息
SalaryBillBO.buildEmployeeInfo(salaryBillSendParam, allEmployeeMap.get(e.get("employeeId").toString()));
SalaryBillBO.genPdf(e, salaryBillSendParam);
});
//合并工资单pdf
//1先获取所有工资单
Long id = salaryBillSendParam.getSalarySend().getId();
List<SalarySendInfoPO> salarySendInfos = getSalarySendInfoMapper().listSome(SalarySendInfoPO.builder().salarySendId(id).sendStatus(1).build());
//2工资单pdf转为路径
String yyyyMM = SalaryDateUtil.getFormatYearMonth(salaryBillSendParam.getSalaryDate());
List<String> filesToMerge = salarySendInfos.stream().map(po -> HrmSalaryPayrollConf.GEN_PATH + yyyyMM + File.separator + id + File.separator + po.getId() + ".pdf").collect(Collectors.toList());
String pdfPath = HrmSalaryPayrollConf.GEN_PATH + yyyyMM + File.separator + id + File.separator + id + ".pdf";
SalaryBillBO.mergePdf(pdfPath, filesToMerge);
}
/**
* 构建发送参数
*
@ -394,12 +444,12 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService
* @param ids
* @return
*/
private List<Map<String, Object>> getEnableSendList(SalarySendPO salarySend, List<Long> ids, SalaryBillSendDTO salaryBillSendParam) {
private List<Map<String, Object>> getEnableSendList(SalarySendPO salarySend, List<Long> ids, SalaryBillSendDTO salaryBillSendParam, List<Integer> sendStatus) {
SalarySendInfoQueryParam queryParam = new SalarySendInfoQueryParam();
queryParam.setSalarySendId(salarySend.getId());
// 空就是所有
queryParam.setIds(ids);
queryParam.setSendStatuss(Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue()));
queryParam.setSendStatuss(sendStatus);
// 2.获取基本数据
List<SalarySendInfoListDTO> list = Lists.newArrayList();
if (CollectionUtils.isEmpty(ids)) {
@ -500,6 +550,57 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService
return path;
}
@Override
public String genPdfBeforeExport(SalaryExportPdfParam param) {
// 先判断对应路径下是否存在pdf
SalarySendPO salarySend = checkAndGetSalarySend(param.getSalarySendId());
String yearMonth = SalaryDateUtil.getFormatYearMonth(salarySend.getSalaryMonth());
String pdfPath = HrmSalaryPayrollConf.GEN_PATH + File.separator + yearMonth + File.separator + salarySend.getId() + File.separator + "%s" + ".pdf";
Long id = param.getId();
if (id == null) {
pdfPath = String.format(pdfPath, param.getSalarySendId());
} else {
pdfPath = String.format(pdfPath, id);
}
File file = new File(pdfPath);
if (file.exists()) {
return "success";
}
// 判断对应路径下是否存在html
String htmlPath = HrmSalaryPayrollConf.GEN_PATH + File.separator + yearMonth + File.separator + salarySend.getId() + File.separator + "%s" + ".html";
if (id == null) {
htmlPath = String.format(htmlPath, param.getSalarySendId());
} else {
htmlPath = String.format(htmlPath, id);
}
file = new File(htmlPath);
if (file.exists()) {
// 将html转成pdf
FileUtil.del(pdfPath);
HtmlToPdf.convert(HrmSalaryPayrollConf.TO_PDF_TOOL_PATH, htmlPath, pdfPath);
mergePdf(param, yearMonth);
return "success";
}
// 先生成html再生成pdf
SalarySendGrantParam grantParam = SalarySendGrantParam.builder().salarySendId(param.getSalarySendId()).ids(Collections.singletonList(param.getId())).build();
reGenPdf(grantParam);
return "success";
}
private void mergePdf(SalaryExportPdfParam param, String yearMonth) {
//合并工资单pdf
//1先获取所有工资单
Long salarySendId = param.getSalarySendId();
List<SalarySendInfoPO> salarySendInfos = getSalarySendInfoMapper().listSome(SalarySendInfoPO.builder().salarySendId(salarySendId).sendStatus(1).build());
//2工资单pdf转为路径
List<String> filesToMerge = salarySendInfos.stream().map(po -> HrmSalaryPayrollConf.GEN_PATH + yearMonth + File.separator + salarySendId + File.separator + po.getId() + ".pdf").collect(Collectors.toList());
String pdfPath = HrmSalaryPayrollConf.GEN_PATH + yearMonth + File.separator + salarySendId + File.separator + salarySendId + ".pdf";
SalaryBillBO.mergePdf(pdfPath, filesToMerge);
}
public List<Map<String, Object>> getSendInfoList(Long sendId, List<Long> ids) {
SalarySendPO salarySend = getSalarySendMapper().getById(sendId);

View File

@ -426,8 +426,11 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobItemList, SalarySobItemPO::getSalarySobId);
List<SalarySobPO> salarySobs = getSalarySobService(user).listByIds(salarySobIds);
// 获取能够管理的义务人
Set<Long> taxAgentIds = SalaryEntityUtil.properties(getTaxAgentService(user).listAllTaxAgentsAsAdmin(Long.valueOf(user.getUID())), TaxAgentPO::getId);
salarySobs = salarySobs.stream().filter(sob -> taxAgentIds.contains(sob.getTaxAgentId())).collect(Collectors.toList());
Boolean isChief = getTaxAgentService(user).isChief(Long.valueOf(user.getUID()));
if (!isChief) {
Set<Long> taxAgentIds = SalaryEntityUtil.properties(getTaxAgentService(user).listAllTaxAgentsAsAdmin(Long.valueOf(user.getUID())), TaxAgentPO::getId);
salarySobs = salarySobs.stream().filter(sob -> taxAgentIds.contains(sob.getTaxAgentId())).collect(Collectors.toList());
}
return salarySobs.stream().map(m -> {
Map<String, Object> map = new HashMap<>();
map.put("id", String.valueOf(m.getId()));

View File

@ -75,6 +75,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.common.MessageUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.resource.ResourceComInfo;
@ -807,7 +808,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
queryParam.setStartSalaryMonth(getLimitMonth());
List<SalaryMySalaryBillListDTO> list = salarySendInfoMapper.mySalaryBillList(queryParam);
list.forEach(dto -> dto.setEmployeeId(Long.valueOf(user.getUID())));
PageInfo<SalaryMySalaryBillListDTO> pageInfo = new PageInfo<>(list, SalaryMySalaryBillListDTO.class);
pageInfo.setTotal(list.size());
pageInfo.setPageNum(queryParam.getCurrent());
@ -933,6 +934,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
.subcompanyName(simpleEmployee.getSubcompanyName())
.email(StringUtils.isEmpty(simpleEmployee.getEmail()) ? "" : simpleEmployee.getEmail())
.jobcall(simpleEmployee.getJobcall())
.jobcallId(simpleEmployee.getJobcallId())
.companystartdate(simpleEmployee.getCompanystartdate())
.sex("0".equals(simpleEmployee.getSex()) ? "" : "")
.mobile(StringUtils.isEmpty(simpleEmployee.getMobile()) ? "" : simpleEmployee.getMobile())
@ -956,7 +958,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
try {
Method method = salaryFormulaEmployeeDTO.getClass().getMethod(getter);
Object invoke = method.invoke(salaryFormulaEmployeeDTO);
e.setSalaryItemValue(invoke.toString());
e.setSalaryItemValue(Util.null2String(invoke));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
log.error("no such method", e);
}

View File

@ -111,6 +111,10 @@ public class SalarySobAddUpRuleServiceImpl extends Service implements SalarySobA
addUpRuleDTO.setCanEdit(true);
Long salaryItemId = salarySobAddUpMap.get(incomeCategoryId + "-" + declaredField.getName());
if(salaryItemId == null){
//往期累计属性名和项目名不匹配采用别名
salaryItemId = salarySobAddUpMap.get(incomeCategoryId + "-" + annotation.alias());
}
SalaryItemPO salaryItem = idKeySalaryItemMap.get(salaryItemId);
if (Objects.nonNull(salaryItem)) {
Map<String, Object> dataMap = Maps.newHashMap();

View File

@ -3,7 +3,10 @@ package com.engine.salary.util.pdf;
import com.engine.workflow.biz.requestForm.HtmlToPdfInterceptor;
import lombok.extern.slf4j.Slf4j;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
@Slf4j
public class HtmlToPdf {
@ -11,9 +14,9 @@ public class HtmlToPdf {
/**
* html转pdf
*
* @param toPdfTool 工具路径
* @param srcPath html路径可以是硬盘上的路径也可以是网络路径
* @param destPath pdf保存路径
* @param toPdfTool 工具路径
* @param srcPath html路径可以是硬盘上的路径也可以是网络路径
* @param destPath pdf保存路径
* @return 转换成功返回true
*/
public static boolean convert(String toPdfTool, String srcPath, String destPath) {
@ -45,8 +48,26 @@ public class HtmlToPdf {
HtmlToPdfInterceptor output = new HtmlToPdfInterceptor(proc.getInputStream());
error.start();
output.start();
proc.waitFor();
BufferedInputStream err = new BufferedInputStream(proc.getErrorStream());
BufferedReader errBr = new BufferedReader(new InputStreamReader(err));
String lineStr = "";
while ((lineStr = errBr.readLine()) != null) {
//检查命令是否执行失败
log.info("pdf转换执行中! {}", lineStr);
}
if (proc.waitFor() != 0) {
//p.exitValue()==0表示正常结束1非正常结束
if (proc.exitValue() == 1) {
log.error("pdf转换命令执行失败!");
}
}
} catch (InterruptedException e) {
log.error("pdf转换出错!", e);
e.printStackTrace();
result = false;
} catch (Exception e) {
log.error("pdf转换出错!", e);
result = false;
e.printStackTrace();
}

View File

@ -560,6 +560,30 @@ public class SalaryBillController {
//
// }
/**
* 下载pdf前先进行校验 生成
* @param request
* @param response
* @return
*/
@GET
@Path("/genPdfBeforeExport")
@Produces(MediaType.APPLICATION_JSON)
public String genPdfBeforeExport(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
SalaryExportPdfParam salaryExportPdfParam = new SalaryExportPdfParam();
String id = request.getParameter("id");
if (StringUtils.isNotBlank(id)) {
salaryExportPdfParam.setId(Long.valueOf(id));
}
String salarySendId = request.getParameter("salarySendId");
if (StringUtils.isNotBlank(salarySendId)) {
salaryExportPdfParam.setSalarySendId(Long.valueOf(salarySendId));
}
return new ResponseResult<SalaryExportPdfParam, String>(user).run(getSalarySendWrapper(user)::genPdfBeforeExport, salaryExportPdfParam);
}
@GET
@Path("/exportPdf")
public Response downloadPdfFile(@Context HttpServletRequest request, @Context HttpServletResponse response) {

View File

@ -69,7 +69,7 @@ public class SalaryComparisonResultWrapper extends Service {
if (fixedNum == 0) {
fixedNum = 3;
}
for (int i = 0; i < fixedNum; i++) {
for (int i = 0; i < fixedNum && i < weaTableColumns.size(); i++) {
weaTableColumns.get(i).setFixed("left");
}
}

View File

@ -742,4 +742,8 @@ public class SalarySendWrapper extends Service implements SalarySendWrapperProxy
public Map<String, String> getToken(Long uid) {
return SalaryTokenUtil.GetToken( uid);
}
public String genPdfBeforeExport(SalaryExportPdfParam salaryExportPdfParam) {
return getSalaryBillService(user).genPdfBeforeExport(salaryExportPdfParam);
}
}