weaver-hrm-salary/src/com/engine/salary/wrapper/SalarySobItemWrapper.java

176 lines
6.8 KiB
Java
Raw Normal View History

2022-03-23 18:41:38 +08:00
package com.engine.salary.wrapper;
2022-03-23 20:54:08 +08:00
import com.engine.common.util.ServiceUtil;
2022-03-23 18:41:38 +08:00
import com.engine.core.impl.Service;
import com.engine.salary.annotation.SalaryFormulaVar;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
2022-04-19 20:33:06 +08:00
import com.engine.salary.entity.salaryformula.ExpressFormula;
import com.engine.salary.entity.salaryitem.bo.SalaryItemBO;
2022-03-23 18:41:38 +08:00
import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO;
import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
2022-04-19 20:33:06 +08:00
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
2022-03-23 18:41:38 +08:00
import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
import com.engine.salary.entity.salarysob.param.SalarySobItemSaveParam;
import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO;
import com.engine.salary.service.SalaryFormulaService;
import com.engine.salary.service.SalaryItemService;
import com.engine.salary.service.SalarySobItemGroupService;
import com.engine.salary.service.SalarySobItemService;
2022-04-19 20:33:06 +08:00
import com.engine.salary.service.impl.SalaryFormulaServiceImpl;
2022-03-23 20:54:08 +08:00
import com.engine.salary.service.impl.SalaryItemServiceImpl;
import com.engine.salary.service.impl.SalarySobItemGroupServiceImpl;
import com.engine.salary.service.impl.SalarySobItemServiceImpl;
2022-04-19 20:33:06 +08:00
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
2022-04-19 20:33:06 +08:00
import com.engine.salary.util.page.PageInfo;
import com.google.common.collect.Maps;
2022-04-19 20:33:06 +08:00
import org.apache.commons.collections4.CollectionUtils;
2022-03-23 20:54:08 +08:00
import weaver.hrm.User;
2022-03-23 18:41:38 +08:00
import java.lang.reflect.Field;
2022-03-25 18:05:07 +08:00
import java.util.*;
2022-03-23 18:41:38 +08:00
/**
* 薪资账套的薪资项目
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
2022-04-13 14:18:00 +08:00
2022-03-23 18:41:38 +08:00
public class SalarySobItemWrapper extends Service {
2022-03-23 20:54:08 +08:00
private SalarySobItemService getSalarySobItemService(User user) {
return (SalarySobItemService) ServiceUtil.getService(SalarySobItemServiceImpl.class, user);
}
private SalarySobItemGroupService getSalarySobItemGroupService(User user) {
return (SalarySobItemGroupService) ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user);
}
private SalaryItemService getSalaryItemService(User user) {
return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user);
}
2022-04-19 20:33:06 +08:00
private SalaryFormulaService getSalaryFormulaService(User user) {
return (SalaryFormulaService) ServiceUtil.getService(SalaryFormulaServiceImpl.class, user);
}
2022-03-23 18:41:38 +08:00
/**
* 薪资账套可选薪资项目列表
*
* @param queryParam 列表查询条件
* @return
*/
2022-04-19 20:33:06 +08:00
public PageInfo<SalaryItemListDTO> listPage4SalaryItem(SalaryItemSearchParam queryParam) {
// SalaryWeaTable<SalaryItemListDTO> table = new SalaryWeaTable<SalaryItemListDTO>(user, SalaryItemListDTO.class);
//
// String fields = " t.id" +
// " , t.name" +
// " , t.code" +
// " , t.system_type" +
// " , t.sys_salary_item_id" +
// " , t.category" +
// " , t.item_type as itemType" +
// " , t.use_default as useDefault" +
// " , t.use_in_employee_salary as useInEmployeeSalary" +
// " , t.rounding_mode as roundingMode" +
// " , t.pattern" +
// " , t.value_type as valueType" +
// " , t.datasource" +
// " , t.formula_id" +
// " , t.description" +
// " , t.can_edit" +
// " , t.can_delete";
//
// String from = "from hrsa_salary_item t";
//
// table.setBackfields(fields);
// table.setSqlform(from);
// table.setSqlwhere(SalaryItemSearchParam.makeSqlWhere(queryParam));
// table.setSqlorderby("t.id DESC");
// table.setSqlprimarykey("t.id");
// table.setSqlisdistinct("false");
//
// WeaResultMsg result = new WeaResultMsg(false);
// result.putAll(table.makeDataResult());
// result.success();
// return result.getResultMap();
// 分页查询薪资项目
PageInfo<SalaryItemPO> page = getSalaryItemService(user).listPageByParam(queryParam);
List<SalaryItemPO> salaryItemList = page.getList();
//最终返回的分页对象
PageInfo<SalaryItemListDTO> dtoPage = new PageInfo<>(SalaryItemListDTO.class);
dtoPage.setPageSize(page.getPageSize());
dtoPage.setPageNum(page.getPageNum());
dtoPage.setTotal(page.getTotal());
if (CollectionUtils.isNotEmpty(salaryItemList)) {
// 查询公式
Set<Long> formulaIds = SalaryEntityUtil.properties(salaryItemList, SalaryItemPO::getFormulaId);
List<ExpressFormula> expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds);
// 转换成薪资项目列表dto
dtoPage.setList(SalaryItemBO.convert2ListDTO(salaryItemList, expressFormulas));
}
return dtoPage;
2022-03-23 18:41:38 +08:00
}
/**
* 获取薪资账套的薪资项目详情
*
* @param salarySobItemGroupId 薪资账套的薪资项目的id
* @return
*/
public SalarySobItemGroupPO getGroupForm(Long salarySobItemGroupId) {
2022-03-23 20:54:08 +08:00
return getSalarySobItemGroupService(user).getById(salarySobItemGroupId);
2022-03-23 18:41:38 +08:00
}
/**
* 获取薪资账套的薪资项目详情
*
* @param salarySobId 薪资账套的id
* @return
*/
public SalarySobItemAggregateDTO getForm(Long salarySobId) {
2022-03-23 20:54:08 +08:00
return getSalarySobItemService(user).getAggregateBySalarySobId(salarySobId);
2022-03-23 18:41:38 +08:00
}
/**
* 保存
*
2022-03-25 18:05:07 +08:00
* @param saveParam 保存参数
2022-03-23 18:41:38 +08:00
*/
public void save(SalarySobItemSaveParam saveParam) {
2022-03-23 20:54:08 +08:00
getSalarySobItemService(user).save(saveParam);
2022-03-23 18:41:38 +08:00
}
2022-03-25 18:05:07 +08:00
/**
* 基础信息浏览按钮下拉框
* @return
*/
2022-03-25 18:05:07 +08:00
public Collection<Map<String, String>> empFieldList() {
Field[] declaredFields = DataCollectionEmployee.class.getDeclaredFields();
Map<String, String> empFieldMap = Maps.newHashMapWithExpectedSize(declaredFields.length);
2022-03-25 18:05:07 +08:00
List<Map<String, String>> list = new ArrayList();
for (Field declaredField : declaredFields) {
Map<String, String> item = new HashMap<>();
if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) {
continue;
}
SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class);
empFieldMap.put(declaredField.getName(), SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel()));
item.put("name", SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel()));
item.put("id", declaredField.getName());
list.add(item);
}
2022-03-25 18:05:07 +08:00
return list;
}
2022-03-23 18:41:38 +08:00
}