|
|
|
|
@ -8,6 +8,7 @@ import com.engine.salary.cache.SalaryCacheKey;
|
|
|
|
|
import com.engine.salary.component.WeaTableColumnGroup;
|
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
|
|
|
|
import com.engine.salary.entity.progress.ProgressDTO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.bo.SalaryAcctFormulaBO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO;
|
|
|
|
|
@ -16,6 +17,7 @@ import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
|
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
|
|
|
|
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
|
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
|
|
|
|
import com.engine.salary.service.*;
|
|
|
|
|
import com.engine.salary.service.impl.*;
|
|
|
|
|
@ -26,6 +28,7 @@ import com.engine.salary.util.SalaryI18nUtil;
|
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
import com.engine.salary.util.valid.ValidUtil;
|
|
|
|
|
import com.engine.salary.wrapper.proxy.SalaryAcctResultWrapperProxy;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang.math.NumberUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
@ -156,7 +159,9 @@ public class SalaryAcctResultWrapper extends Service implements SalaryAcctResult
|
|
|
|
|
//按部门分组
|
|
|
|
|
List<Map<String, String>> result = new ArrayList<>();
|
|
|
|
|
Map<Long, List<SalaryAcctEmployeePO>> departmentEmpMap = SalaryEntityUtil.group2Map(employeePOS, SalaryAcctEmployeePO::getDepartmentId);
|
|
|
|
|
for (Long departmentId : departmentEmpMap.keySet()) {
|
|
|
|
|
|
|
|
|
|
List<Long> departmentList = getSalaryEmployeeService(user).listDepartment(Lists.newArrayList(departmentEmpMap.keySet()));
|
|
|
|
|
for (Long departmentId : departmentList) {
|
|
|
|
|
List<SalaryAcctEmployeePO> departmentEmps = departmentEmpMap.get(departmentId);
|
|
|
|
|
List<Long> departmentEmpIds = SalaryEntityUtil.properties(departmentEmps, SalaryAcctEmployeePO::getId, Collectors.toList());
|
|
|
|
|
Map<Long, List<SalaryAcctResultPO>> resultMap = acctEmpIdMap.keySet().stream().filter(departmentEmpIds::contains).map(acctEmpIdMap::get).flatMap(Collection::stream).collect(Collectors.groupingBy(SalaryAcctResultPO::getSalaryItemId));
|
|
|
|
|
@ -179,6 +184,51 @@ public class SalaryAcctResultWrapper extends Service implements SalaryAcctResult
|
|
|
|
|
return datas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 合计行
|
|
|
|
|
*
|
|
|
|
|
* @param queryParam 列表查询条件
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, Object> sumDepartmentListPage(SalaryAcctResultQueryParam queryParam) {
|
|
|
|
|
Map<String, Object> datas = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
// 查询薪资核算记录
|
|
|
|
|
Long salaryAcctRecordId = queryParam.getSalaryAcctRecordId();
|
|
|
|
|
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId);
|
|
|
|
|
if (Objects.isNull(salaryAcctRecordPO)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询配置的薪资项目
|
|
|
|
|
String salaryItemIdsStr = new BaseBean().getPropValue("hrmSalaryWuYuan", "departmentReportSalaryItemIds");
|
|
|
|
|
if (StringUtils.isBlank(salaryItemIdsStr)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资项ID不能为空"));
|
|
|
|
|
}
|
|
|
|
|
List<Long> salaryItemIds = Arrays.stream(salaryItemIdsStr.split(",")).map(Long::valueOf).collect(Collectors.toList());
|
|
|
|
|
List<SalaryItemPO> salaryItemPOList = getSalaryItemService(user).listByIds(salaryItemIds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//核算内的人员
|
|
|
|
|
List<SalaryAcctEmployeePO> employeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordId);
|
|
|
|
|
List<Long> salaryAcctEmpIds = SalaryEntityUtil.properties(employeePOS, SalaryAcctEmployeePO::getId, Collectors.toList());
|
|
|
|
|
|
|
|
|
|
//核算数据结果
|
|
|
|
|
List<SalaryAcctResultPO> list = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, salaryItemIds);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
Map<Long, List<SalaryAcctResultPO>> acctResultMap = SalaryEntityUtil.group2Map(list, SalaryAcctResultPO::getSalaryItemId);
|
|
|
|
|
salaryItemPOList.stream().filter(item -> SalaryDataTypeEnum.NUMBER.getValue().equals(item.getDataType())).forEach(item -> {
|
|
|
|
|
BigDecimal sum = Optional.ofNullable(acctResultMap.get(item.getId())).orElse(new ArrayList<>()).stream().map(SalaryAcctResultPO::getResultValue).filter(org.apache.commons.lang3.math.NumberUtils::isCreatable).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
map.put(item.getId().toString(), SalaryAcctFormulaBO.roundResultValue(sum.toString(), item, Collections.emptyList(), Collections.emptyMap(), new HashMap<>()));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Map<String, Object> sumRow = getSalaryAcctResultService(user).sumRow(queryParam);
|
|
|
|
|
datas.put("sumRow", sumRow);
|
|
|
|
|
return datas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 合计行
|
|
|
|
|
*
|
|
|
|
|
|