package jnpf.model.personnels.req.transfer;

import cn.hutool.core.date.DateUtil;
import jnpf.model.personnels.dto.salary.BaseSalaryStructureDTO;
import jnpf.model.personnels.dto.turnover.FtbPersonnelsTurnoverHandoverDTO;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

@Data
public class FtbHandleTransferOAAddDTO extends BaseSalaryStructureDTO {

    /**
     * 调动类型0调岗1晋升2降职3调店
     */
    @NotNull(message = "调动类型不能为空")
    private Integer state;

    /**
     * 调动人用户id
     */
    @NotNull(message = "用户id不能为空")
    private List<String> userId;

    /**
     * 调动前组织id
     */
    @NotBlank(message = "调动前组织id不能为空")
    private String beforeOrgId;
    /**
     * 调动前组织名称
     */
    private String beforeOrgName;
    /**
     * 调动前岗位id
     */
    @NotBlank(message = "调动前岗位id不能为空")
    private String beforePostId;
    /**
     * 调动前岗位名称
     */
    private String beforePostName;
    /**
     * 调动前职级id
     */
    private String beforeRankId;
    /**
     * 调动前职级名称
     */
    private String beforeRankName;
    /**
     * 调动后组织id
     */
    @NotBlank(message = "调动后组织id不能为空")
    private String afterOrgId;
    /**
     * 调动后组织名称
     */
    private String afterOrgName;

    /**
     * 调动后岗位id
     */
    @NotBlank(message = "调动后岗位id不能为空")
    private String afterPostId;
    /**
     * 调动后岗位名称
     */
    private String afterPostName;
    /**
     * 调动后职级id
     */
    private String afterRankId;
    /**
     * 调动后职级名称
     */
    private String afterRankName;

    /**
     * 生效时间
     */
    @NotNull(message = "生效时间不能为空")
    private Date effectiveDate;

    /**
     * 调动前班组id
     */
    private String beforeTeamId;

    /**
     * 调动后班组id
     */
    private String afterTeamId;
    /**
     * 调动备注
     */
    private String remarks;

    /**
     * 附件
     */
    private String files;

    /**
     * 工作/物品交接列表
     */
    private List<FtbPersonnelsTurnoverHandoverDTO> workerPositionHandoverList;

    /**
     * 调动前班组名称
     */
    private String beforeTeamName;

    /**
     * 调动后班组名称
     */
    private String afterTeamName;


    /**
     * 调动前直属主管id
     */
    private String beforeDirectSupervisorId;
    /**
     * 调动前直属主管名称
     */
    private String beforeDirectSupervisorName;

    /**
     * 调动后直属主管id
     */
    private String afterDirectSupervisorId;
    /**
     * 调动后直属主管名称
     */
    private String afterDirectSupervisorName;

    /**
     * 来源0非员工申请1员工申请
     */
    private Integer source;

    public FtbHandleTransferDTO convert(FtbHandleTransferOAAddDTO ftbHandleTransferOAAddDTO) {
        if (ftbHandleTransferOAAddDTO == null) {
            return null;
        }
        // 生效日期取当天23:59:59
        ftbHandleTransferOAAddDTO.setEffectiveDate(DateUtil.endOfDay(ftbHandleTransferOAAddDTO.getEffectiveDate()));
        FtbHandleTransferDTO ftbHandleTransferDTO = new FtbHandleTransferDTO();
        ftbHandleTransferDTO.setState(ftbHandleTransferOAAddDTO.getState());
        ftbHandleTransferDTO.setUserId(ftbHandleTransferOAAddDTO.getUserId().get(0));
        ftbHandleTransferDTO.setBeforeOrgId(ftbHandleTransferOAAddDTO.getBeforeOrgId());
        ftbHandleTransferDTO.setBeforeOrgName(ftbHandleTransferOAAddDTO.getBeforeOrgName());
        ftbHandleTransferDTO.setBeforePostId(ftbHandleTransferOAAddDTO.getBeforePostId());
        ftbHandleTransferDTO.setBeforePostName(ftbHandleTransferOAAddDTO.getBeforePostName());
        ftbHandleTransferDTO.setBeforeRankId(ftbHandleTransferOAAddDTO.getBeforeRankId());
        ftbHandleTransferDTO.setBeforeRankName(ftbHandleTransferOAAddDTO.getBeforeRankName());
        ftbHandleTransferDTO.setAfterOrgId(ftbHandleTransferOAAddDTO.getAfterOrgId());
        ftbHandleTransferDTO.setAfterOrgName(ftbHandleTransferOAAddDTO.getAfterOrgName());
        ftbHandleTransferDTO.setAfterPostId(ftbHandleTransferOAAddDTO.getAfterPostId());
        ftbHandleTransferDTO.setAfterPostName(ftbHandleTransferOAAddDTO.getAfterPostName());
        ftbHandleTransferDTO.setAfterRankId(ftbHandleTransferOAAddDTO.getAfterRankId());
        ftbHandleTransferDTO.setAfterRankName(ftbHandleTransferOAAddDTO.getAfterRankName());
        ftbHandleTransferDTO.setEffectiveDate(ftbHandleTransferOAAddDTO.getEffectiveDate());
        ftbHandleTransferDTO.setBeforeTeamId(ftbHandleTransferOAAddDTO.getBeforeTeamId());
        ftbHandleTransferDTO.setAfterTeamId(ftbHandleTransferOAAddDTO.getAfterTeamId());
        ftbHandleTransferDTO.setRemarks(ftbHandleTransferOAAddDTO.getRemarks());
        ftbHandleTransferDTO.setFiles(ftbHandleTransferOAAddDTO.getFiles());
        ftbHandleTransferDTO.setWorkerPositionHandoverList(ftbHandleTransferOAAddDTO.getWorkerPositionHandoverList());
        ftbHandleTransferDTO.setBeforeTeamName(ftbHandleTransferOAAddDTO.getBeforeTeamName());
        ftbHandleTransferDTO.setAfterTeamName(ftbHandleTransferOAAddDTO.getAfterTeamName());
        ftbHandleTransferDTO.setIsAdjustSalary(ftbHandleTransferOAAddDTO.getIsAdjustSalary());
        ftbHandleTransferDTO.setPayrollSequence(ftbHandleTransferOAAddDTO.getPayrollSequence());
        ftbHandleTransferDTO.setSalaryType(ftbHandleTransferOAAddDTO.getSalaryType());
        ftbHandleTransferDTO.setPayrollSequenceId(ftbHandleTransferOAAddDTO.getPayrollSequenceId());
        ftbHandleTransferDTO.setSalaryList(ftbHandleTransferOAAddDTO.getSalaryList());
        ftbHandleTransferDTO.setSalaryTotal(ftbHandleTransferOAAddDTO.getSalaryTotal());
        ftbHandleTransferDTO.setUserIds(ftbHandleTransferOAAddDTO.getUserIds());
        ftbHandleTransferDTO.setTaskId(ftbHandleTransferOAAddDTO.getTaskId());
        ftbHandleTransferDTO.setSpecialBusinessId(ftbHandleTransferOAAddDTO.getSpecialBusinessId());
        ftbHandleTransferDTO.setSourcePhone(ftbHandleTransferOAAddDTO.getSourcePhone());
        ftbHandleTransferDTO.setRecipientOfTheItemUserId(ftbHandleTransferOAAddDTO.getRecipientOfTheItemUserId());
        ftbHandleTransferDTO.setRecipientOfTheItemInfo(ftbHandleTransferOAAddDTO.getRecipientOfTheItemInfo());
        ftbHandleTransferDTO.setRecipientOfTheWorkUserId(ftbHandleTransferOAAddDTO.getRecipientOfTheWorkUserId());
        ftbHandleTransferDTO.setRecipientOfTheWorkInfo(ftbHandleTransferOAAddDTO.getRecipientOfTheWorkInfo());
        ftbHandleTransferDTO.setTaskFlag(ftbHandleTransferOAAddDTO.getTaskFlag());
        ftbHandleTransferDTO.setBeforeDirectSupervisorId(ftbHandleTransferOAAddDTO.getBeforeDirectSupervisorId());
        ftbHandleTransferDTO.setBeforeDirectSupervisorName(ftbHandleTransferOAAddDTO.getBeforeDirectSupervisorName());
        ftbHandleTransferDTO.setAfterDirectSupervisorId(ftbHandleTransferOAAddDTO.getAfterDirectSupervisorId());
        ftbHandleTransferDTO.setAfterDirectSupervisorName(ftbHandleTransferOAAddDTO.getAfterDirectSupervisorName());
        ftbHandleTransferDTO.setSource(ftbHandleTransferOAAddDTO.getSource());
        return ftbHandleTransferDTO;
    }

}
