package com.engine.kq.biz;

import weaver.conn.RecordSet;
import weaver.general.Util;

/**
 * 公出规则
 */
public class KQExitRulesBiz {

    /**
     * 获取最小出差单位
     * 1-按天出差
     * 2-按半天出差
     * 3-按小时出差
     * 4-按整天出差
     * 其他：无效数据
     *
     * @return
     */
    public static String getMinimumUnit() {
        KQExitRulesComInfo kqExitRulesComInfo = new KQExitRulesComInfo();
        return kqExitRulesComInfo.getMinimumUnit("1");
    }

    /**
     * 获取换算比例
     * 当公出单位由天、半天、整天切换成小时或者由小时切换成天、半天、整天时，历史数据会按照此换算比例自动进行换算
     *
     * @return
     */
    public static String getProportion() {
        KQExitRulesComInfo kqExitRulesComInfo = new KQExitRulesComInfo();
        return String.format("%.2f", Util.getDoubleValue(kqExitRulesComInfo.getProportion("1")));
    }

    /**
     * 获取计算出差时长方式
     * 1-按工作日计算出差时长
     * 2-按自然日计算出差时长
     * 其他：无效数据
     *
     * @return
     */
    public static String getComputingMode() {
        KQExitRulesComInfo kqExitRulesComInfo = new KQExitRulesComInfo();
        return kqExitRulesComInfo.getComputingMode("1");
    }

    /**
     * 获取日折算时长
     *
     * @return
     */
    public static String getHoursToDay() {
        int minimumUnit = -1;//最小出差单位
        int computingMode = -1;//计算出差时长方式
        double hoursToDay = -1;//日折算时长
        KQExitRulesComInfo kqExitRulesComInfo = new KQExitRulesComInfo();
        minimumUnit = Util.getIntValue(kqExitRulesComInfo.getMinimumUnit("1"), -1);
        computingMode = Util.getIntValue(kqExitRulesComInfo.getComputingMode("1"), -1);
        hoursToDay = Util.getDoubleValue(kqExitRulesComInfo.getHoursToDay("1"), -1);
        return String.valueOf(hoursToDay);
    }

    /**
     * 获取半天显示类型，是时间还是下拉框
     * 半天单位 时间选择方式：1-下拉框选择 、2-具体时间
     * @return
     */
    public static String getTimeselection() {
      KQExitRulesComInfo kqExitRulesComInfo = new KQExitRulesComInfo();
      String timeSelection = kqExitRulesComInfo.getTimeSelection("1");
      if("1".equalsIgnoreCase(timeSelection) || "2".equalsIgnoreCase(timeSelection)){
        return timeSelection;
      }else{
        return "1";
      }
    }
}
