package com.engine.salary.service;

import com.engine.salary.entity.salaryBill.dto.*;
import com.engine.salary.entity.salaryBill.param.*;
import com.engine.salary.entity.salaryBill.po.SalarySendInfoPO;
import com.engine.salary.entity.salaryBill.po.SalarySendPO;
import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO;
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.util.page.PageInfo;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Description: 工资单发放
 */
public interface SalarySendService {

    /**
     * 获取单个工资单发放
     *
     * @param salarySendId
     * @return
     */
    SalarySendPO getById(Long salarySendId);

    List<Long> findReAccountingIdsByAcctIds(List<Long> salaryAccountingIds, String tenantKey);

    /**
     * 薪资核算-归档生成工资单
     * @param salaryAccountingId
     * @return
     */
    String generateSalaryBill(Long salaryAccountingId);

    /**
     * 薪资核算-归档撤销工资单
     * @param salaryAcctRecord
     * @return
     */
    void revokeSalaryBill(SalaryAcctRecordPO salaryAcctRecord);

    /**
     * 工资单发放列表（分页）
     *
     * @param queryParam
     * @return
     */
    PageInfo<SalarySendListDTO> listPage(SalarySendQueryParam queryParam);

    /**
     * 工资单发放
     * @param queryParam
     * @return
     */
    Map<String, Object> grant(SalarySendGrantParam queryParam);

    /**
     * 工资单撤回
     * @param queryParam
     * @return
     */
    Map<String, Object> withdraw(SalarySendWithdrawParam queryParam);

    /**
     * 工资单发放基本信息
     * @param id
     * @return
     */
    SalarySendBaseInfoDTO getBaseInfo(Long id);

    /**
     * 我的工资单
     * @param salaryInfoId
     * @param currentEmployeeId
     * @return
     */
    Map<String, Object> mySalaryBill(Long salaryInfoId, Long currentEmployeeId);


    /**
     * 工资单发放信息列表（分页）
     * @param queryParam
     * @return
     */
    PageInfo<SalarySendInfoListDTO> salarySendInfoListPage(SalarySendInfoQueryParam queryParam);

    List<SalarySendInfoListDTO> salarySendInfoList(Long salarySendId);
    /**
     * 我的工资单列表详情
     *
     * @param queryParam
     * @return
     */
    PageInfo<SalaryMySalaryBillListDTO> mySalaryBillListPage(SalaryBillQueryParam queryParam);

    /**
     * 工资单发放详情列表
     * @param queryParam
     * @return
     */
    PageInfo<SalarySendDetailListDTO> salarySendInfoDetailListPage(SalarySendDetailQueryParam queryParam);

    /**
     * 获取薪资项目设置
     *
     * @param salaryTemplatePO
     * @return
     */
    List<SalaryTemplateSalaryItemListDTO> getSalaryItemsSetting(SalaryTemplatePO salaryTemplatePO,  boolean isReplenish);

    /**
     * 构建详情列表
     *
     * @param salaryItems
     * @param records
     * @param salaryAccountingId
     * @return
     */
    List<Map<String, Object>> buildDetailList(List<SalaryTemplateSalaryItemListDTO> salaryItems, List<SalarySendDetailListDTO> records, Long salaryAccountingId);

    /**
     * 构建详情列表
     *
     * @param records
     * @param salaryAcctResultValues
     * @return
     */
    List<Map<String, Object>> buildDetailList(List<SalarySendInfoListDTO> records,List<SalaryAcctEmployeePO> salaryAcctEmployees, List<SalaryAcctResultPO> salaryAcctResultValues);

    /**
     * 导出-工资单发放详情列表
     *
     * @param queryParam
     */
    XSSFWorkbook exportInfoList(SalarySendInfoQueryParam queryParam);

    /**
     * 导出-工资单发放详情列表
     * @param salarySend
     * @param queryParam
     */
    XSSFWorkbook exportDetailList(SalarySendPO salarySend, SalarySendDetailQueryParam queryParam);

    /**
     * 获取核算工资单发放结果
     *
     * @param salaryAcctRecordIds
     * @return
     */
    List<SalarySendCheckDTO> getSalarySendCheckResult(Set<Long> salaryAcctRecordIds);

    /**
     * @description 处理历史数据
     * @return null
     * @author Harryxzy
     * @date 2022/11/25 10:45
     */
    void handleHistory();

    /**
     * 合计行
     *
     * @param queryParam
     * @return
     */
    Map<String, Object> sumRow(SalarySendInfoQueryParam queryParam);

    /**
     * 根据薪资核算id删除 工资单
     * @param ids
     */
    void deleteBySalaryAcctRecordIds(Collection<Long> ids);

    /**
     * 发送短信验证码
     * @param param
     */
    void sendMobileCode(SMSCodeSendParam param);

    /**
     * 校验验证码
     * @param param
     */
    Boolean checkMobileCode(SMSCodeCheckParam param);

    /**
     * 获取工资单id下需要发放的工资单明细
     * @return
     */
    List<SalarySendInfoPO> getNeedSendInfoList(List<Long> salarySendIds);

    /**
     * 获取这些模板下未发放完的工资单
     * @param salarySobIds
     * @return
     */
    List<SalarySendPO> getNeedSendListBySalarySobIds(List<Long> salarySobIds);

    /**
     * 获取所有为确认的工资单
     * @return
     * @return
     */
    List<SalarySendInfoPO> listUnConfirmedSendInfo(List<Long> salarySobIds);

    /**
     * 自动确认工资单
     * @param needAutoIds
     */
    void autoConfirmSalaryBill(List<Long> needAutoIds);

    List<SalarySendPO> getByIds(List<Long> salarySendId);

    List<SalarySendPO> listSome(SalarySendPO param);
}
