package com.chinaweal.aiccs.aiccs.punishment.util;

import com.chinaweal.aicorg.model.AICUser;
import org.apache.commons.lang.StringUtils;

import java.util.HashMap;
import java.util.Map;

public class ParamUtils {

    public static Map<String, Object> getRegorg(Map<String, Object> customParamMap, AICUser curUser) {
        String regionId = curUser.getRegionID();
        if (StringUtils.isNotBlank(regionId)) regionId = regionId.substring(0, 6);
        if (customParamMap == null) {
            customParamMap = new HashMap<>(20);
        }
        customParamMap.put("regorg1", regionId);
        return customParamMap;
    }

    /**
     * 根据用户获得登记机关筛选参数
     *
     * @param customParamMap
     * @param curUser
     * @return
     */
    public static Map<String, Object> getRegorg2(Map<String, Object> customParamMap, AICUser curUser) {
        String regionId = curUser.getRegionID();
        //regorg2为准确查询，regorg1为模糊查询(包括子级)
        if (regionId.equals("440100")) { //药局
            customParamMap.put("regorg2", regionId);
        } else if (!regionId.equals("44010000")) {
            if (regionId.endsWith("00")) { //区级
                regionId = regionId.substring(0, 6);
                customParamMap.put("regorg1", regionId);
            } else { //所
                customParamMap.put("regorg2", regionId);
            }
        }
        return customParamMap;
    }
}
