package nckd.jxccl.base.tsc.helper;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QFilter;
import kd.hr.hbp.business.servicehelper.HRBaseServiceHelper;
import kd.sdk.hr.hrpi.business.helper.HRPIEmployeeServiceHelper;
import kd.sdk.tsc.common.enums.ResumeTypeEnum;
import nckd.jxccl.base.wtc.helper.WTCHelper;

import java.util.Collections;
import java.util.Map;

public class TSCHelper {
    private static final Log logger = LogFactory.getLog(TSCHelper.class);

    private static final HRBaseServiceHelper EMPLOYEECV_HELPER = new HRBaseServiceHelper("tsirm_employeecv");


    /**
     * 根据当前用户获取人员ID
     * @param userId
     * @return
     */
    public Long getEmpId(Long userId) {
        Map<String, Object> resultMap = HRPIEmployeeServiceHelper.queryEmployeeByUserIds(Collections.singletonList(userId), "id,employee", "1");
        Map<String, Object> dataMap = (Map)resultMap.get("data");
        return dataMap == null ? 0L : (Long)dataMap.get("employee");
    }

    /**
     * 根据人员ID获取简历cvId
     * @param empId
     * @return
     */
    public DynamicObject[] getEmpCVDyByEmpId(long empId) {
        QFilter empFilter = new QFilter("employee", "=", empId);
        QFilter typeFilter = new QFilter("type", "=", ResumeTypeEnum.RESUME_CV.getType());
        String selectProperties = "id,createtime,modifytime,number,name,folk,nationality,gender,birthday,age,socialworkage,employee,type,empposorgrel,rsmremark";
        return EMPLOYEECV_HELPER.queryOriginalArray(selectProperties, new QFilter[]{empFilter, typeFilter}, "modifytime desc");
    }

}
