package com.engine.salary.wrapper; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.common.LocalDateRange; import com.engine.salary.entity.datacollection.dto.AttendQuoteListDTO; import com.engine.salary.entity.datacollection.param.AttendQuoteQueryParam; import com.engine.salary.entity.datacollection.param.QuerySalaryCycleAndAttendCycleParam; import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; import com.engine.salary.entity.salarysob.po.SalarySobPO; import com.engine.salary.enums.datacollection.AttendQuoteSourceTypeEnum; import com.engine.salary.service.AttendQuoteService; import com.engine.salary.service.SalaryAcctRecordService; import com.engine.salary.service.SalarySobService; import com.engine.salary.service.impl.AttendQuoteServiceImpl; import com.engine.salary.service.impl.SalaryAcctRecordServiceImpl; import com.engine.salary.service.impl.SalarySobServiceImpl; import com.engine.salary.util.page.PageInfo; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.math.NumberUtils; import weaver.hrm.User; import java.time.YearMonth; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * 考勤引用 *

Copyright: Copyright (c) 2022

*

Company: 泛微软件

* * @author qiantao * @version 1.0 **/ public class AttendQuoteWrapper extends Service { private AttendQuoteService getAttendQuoteService(User user) { return (AttendQuoteService) ServiceUtil.getService(AttendQuoteServiceImpl.class, user); } private SalarySobService getSalarySobService(User user) { return (SalarySobService) ServiceUtil.getService(SalarySobServiceImpl.class, user); } private SalaryAcctRecordService getSalaryAcctRecordService(User user) { return (SalaryAcctRecordService) ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); } /** * 考勤引用列表 * * @param queryParam * @return */ public PageInfo list(AttendQuoteQueryParam queryParam) { List declareMonth = queryParam.getSalaryYearMonth(); if (CollectionUtils.isNotEmpty(declareMonth)) { queryParam.setSalaryYearMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); } PageInfo page = getAttendQuoteService(user).listPage(queryParam); List list = page.getList(); list.forEach(m -> m.setSourceType(AttendQuoteSourceTypeEnum.getDefaultLabelByValue(Integer.valueOf(m.getSourceType())))); page.setList(list); return page; } /** * 获取引用考勤表单 * * @param employeeId * @return */ // public WeaForm getSyncForm(Long employeeId) { // // 查询所有启用的薪资账套 // List salarySobs = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO); // List salarySobOptions = salarySobs.stream() // .map(salarySobPO -> new WeaFormOption("" + salarySobPO.getId(), salarySobPO.getName())) // .collect(Collectors.toList()); // // 构建表单 // WeaForm weaForm = FormatManager.getInstance().genForm(AttendQuoteSyncDataFormDTO.class, AttendQuoteSyncDataFormDTO.builder().salarySobOptions(salarySobOptions).build()); // // WeaFormItem descriptionItem = weaForm.getItems().get("description"); // Map otherParams = Maps.newHashMap(); // otherParams.put("showCount", true); // otherParams.put("placeholder", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85987, "请输入")); // descriptionItem.setOtherParams(otherParams); // weaForm.getItems().put("description", descriptionItem); // // WeaFormItem salaryYearMonthItem = weaForm.getItems().get("salaryYearMonth"); // otherParams = Maps.newHashMap(); // otherParams.put("type", "month"); // salaryYearMonthItem.setOtherParams(otherParams); // weaForm.getItems().put("salaryYearMonth", salaryYearMonthItem); // // return weaForm; // } /** * 检查是否可以操作 * // todo 202203判断未核算 * * @param salaryYearMonth * @param salarySobId * @param tenantKey * @return */ public Boolean checkOperation(YearMonth salaryYearMonth, Long salarySobId, Long employeeId, String tenantKey) { return Boolean.TRUE;// getSalaryAcctRecordService(user).isAccountedByYearMonthAndSalarySobId(salaryYearMonth, salarySobId, tenantKey); } /** * 获取薪资周期和考勤周期 * * @return */ public Map getSalaryCycleAndAttendCycle(QuerySalaryCycleAndAttendCycleParam param) { Long salarySobId = param.getSalarySobId(); YearMonth salaryYearMonth = param.getSalaryYearMonth(); SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salarySobId, salaryYearMonth); LocalDateRange salaryCycleRange = salarySobCycleDTO.getSalaryCycle(); LocalDateRange attendCycleRange = salarySobCycleDTO.getAttendCycle(); Map salaryCycleAndAttendCycle = new HashMap<>(2); salaryCycleAndAttendCycle.put("salaryCycle", salaryCycleRange.getFromDate() + " ~ " + salaryCycleRange.getEndDate()); salaryCycleAndAttendCycle.put("attendCycle", attendCycleRange.getFromDate() + " ~ " + attendCycleRange.getEndDate()); return salaryCycleAndAttendCycle; } /** * 获取薪资账套下拉列表 * * @return */ public List> selectSalarySobList() { // 查询所有启用的薪资账套 List salarySobs = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO); return salarySobs.stream().map(m -> { Map map = new HashMap<>(2); map.put("id", String.valueOf(m.getId())); map.put("content", m.getName()); return map; }).collect(Collectors.toList()); } /** * 删除考勤引用 * * @param ids * @return */ public String delete(Collection ids) { return getAttendQuoteService(user).delete(ids); } }