五院,部门排序和合计行

This commit is contained in:
钱涛 2025-12-01 18:09:19 +08:00
parent 6672dfdd69
commit 17c8969314
6 changed files with 84 additions and 1 deletions

View File

@ -181,4 +181,9 @@ public interface EmployMapper {
List<Long> listByDepartment(@Param("departmentIds") List<Long> departmentIds);
List<Long> listByJob(@Param("jobIds") List<Long> jobIds);
List<Long> listDepartment(@Param("departmentIds") List<Long> departmentIds);
}

View File

@ -672,4 +672,17 @@
from hrmjobcall job
where job.id = #{jobCallId}
</select>
<select id="listDepartment" resultType="long">
select id from hrmdepartment
where id IN
<foreach collection="departmentIds" open="(" item="departmentId" separator="," close=")">
#{departmentId}
</foreach>
ORDER BY ShowOrder
</select>
</mapper>

View File

@ -194,4 +194,6 @@ public interface SalaryEmployeeService {
JobCallInfo getJobCallInfoById(Long jobCallId);
List<DataCollectionEmployee> snapshot(List<Long> employeeIds, Date snapshotTime);
List<Long> listDepartment(List<Long> departmentIds);
}

View File

@ -681,4 +681,9 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
return SalaryI18nUtil.i18nList(employees);
}
@Override
public List<Long> listDepartment(List<Long> departmentIds) {
return getEmployMapper().listDepartment(departmentIds);
}
}

View File

@ -462,6 +462,14 @@ public class SalaryAcctController {
return new ResponseResult<SalaryAcctResultQueryParam, Map<String, Object>>(user).run(getSalaryAcctResultWrapper(user)::departmentListPage, param);
}
@POST
@Path("/acctresult/department/sum")
@Produces(MediaType.APPLICATION_JSON)
public String sumDepartmentListPage(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultQueryParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SalaryAcctResultQueryParam, Map<String, Object>>(user).run(getSalaryAcctResultWrapper(user)::sumDepartmentListPage, param);
}
//合计行
@POST
@Path("/acctresult/sum")

View File

@ -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;
}
/**
* 合计行
*