package cn.estsh.i3plus.pojo.platform.sqlpack;

import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.base.tool.HqlPack;
import cn.estsh.i3plus.pojo.platform.bean.*;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description : 平台对象封装
 * @Reference :
 * @Author : alwaysfrin
 * @CreateDate : 2018-10-23 21:15
 * @Modify:
 **/
public class CoreHqlPack {

    private CoreHqlPack() {
        throw new IllegalStateException("Utility class");
    }

    /**
     * In 参数封装
     *
     * @param columnName
     * @return
     */
    public static String packHqlIds(String columnName, String[] params) {
        StringBuffer result = new StringBuffer();
        HqlPack.getNumEqualPack(CommonEnumUtil.IS_VAILD.VAILD.getValue(), "isValid", result);
        HqlPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), "isDeleted", result);
        HqlPack.getInPack(String.join(",", params), columnName, result);
        return result.toString();
    }


    /**
     * In 参数封装
     *
     * @param columnName
     * @return
     */
    public static String packHqlIds(String columnName, Long[] params) {
        StringBuffer result = new StringBuffer();
        HqlPack.getNumEqualPack(CommonEnumUtil.IS_VAILD.VAILD.getValue(), "isValid", result);
        HqlPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), "isDeleted", result);

        // 参数数组 [1,2,3] -> "1,2,3"
        HqlPack.getInPack(StringUtils.join(params, ","), columnName, result);
        return result.toString();
    }


    /**
     * In 参数封装
     *
     * @param columnName
     * @return
     */
    public static DdlPackBean packHqlInStr(String columnName, String[] params) {
        DdlPackBean ddlPackBean = new DdlPackBean();
        DdlPreparedPack.getNumEqualPack(CommonEnumUtil.IS_VAILD.VAILD.getValue(), "isValid", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), "isDeleted", ddlPackBean);
        DdlPreparedPack.getInPack(params, columnName, ddlPackBean);
        return ddlPackBean;
    }

    /**
     * In 参数封装
     *
     * @param columnName
     * @return
     */
    public static DdlPackBean packHqlIn(String columnName, List params) {
        DdlPackBean ddlPackBean = new DdlPackBean();
        DdlPreparedPack.getNumEqualPack(CommonEnumUtil.IS_VAILD.VAILD.getValue(), "isValid", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), "isDeleted", ddlPackBean);
        DdlPreparedPack.getInPack(params, columnName, ddlPackBean);
        return ddlPackBean;
    }


    /**
     * 资源查询
     *
     * @param resource
     * @return
     */
    public static DdlPackBean packHqlSysLocaleResource(SysLocaleResource resource) {
        DdlPackBean result = DdlPackBean.getDdlPackBean();

        if (resource != null) {
            DdlPreparedPack.getNumEqualPack(resource.getResourceType(), "resourceType", result);
            // 是否多类型查询
            if (StringUtils.isNotBlank(resource.getResourceTypes())) {
                DdlPreparedPack.getInPackArray((Integer[]) ConvertUtils.convert(resource.getResourceTypes().split(","), Integer.class), "resourceType", result);
            }

            DdlPreparedPack.getNumEqualPack(resource.getSoftType(), "softType", result);
            DdlPreparedPack.getNumEqualPack(resource.getIsSystem(), "isSystem", result);
            DdlPreparedPack.getStringEqualPack(resource.getLanguageCode(), "languageCode", result);
            DdlPreparedPack.getStringLikerPack(resource.getResourceKey(), "resourceKey", result);
            DdlPreparedPack.getStringLikerPack(resource.getResourceValue(), "resourceValue", result);
        }

        return result;
    }

    /**
     * 语言
     *
     * @param localeLanguage
     * @return
     */
    public static String packHqlSysLocaleLanguage(SysLocaleLanguage localeLanguage) {
        StringBuffer result = new StringBuffer();

        //查询日期
//        HqlPack.timeBuilder(lang.getCreateDateTimeStart(),lang.getCreateDateTimeEnd(),
//                "createDateTime", result, false);
        //字符串类型封装
        HqlPack.getStringLikerPack(localeLanguage.getLanguageCode(), "languageCode", result);
        //字符串类型封装
        HqlPack.getStringLikerPack(localeLanguage.getLanguageName(), "languageName", result);

        // 添加默认排序
        HqlPack.getOrderDefault(localeLanguage);

        return result.toString();
    }

    /**
     * 岗位复杂查询
     *
     * @param position
     * @return
     */
    public static DdlPackBean packHqlSysPosition(SysPosition position) {
        return packHqlSysPosition(position, null);
    }

    public static DdlPackBean packHqlSysPosition(SysPosition position, List<Long> idList) {
        DdlPackBean result = DdlPackBean.getDdlPackBean(position.getOrganizeCode());

        // 查询参数封装
        DdlPreparedPack.getNumEqualPack(position.getParentId(), "parentId", result);
        // String Like
        DdlPreparedPack.getStringLikerPack(position.getName(), "name", result);
        DdlPreparedPack.getStringLikerPack(position.getPositionCode(), "positionCode", result);
        // In
        DdlPreparedPack.getInPackList(idList, "id", result);

        return result;
    }

    /**
     * 岗位复杂查询
     *
     * @param position
     * @return
     */
    public static DdlPackBean packHqlSysPositionList(SysPosition position) {
        DdlPackBean result = DdlPackBean.getDdlPackBean(position);

        // 查询参数封装
        DdlPreparedPack.getStringEqualPack(position.getOrganizeCode(), "organizeCode", result);

        return result;
    }


    /**
     * 岗位复杂查询
     *
     * @param bean
     * @return
     */
    public static DdlPackBean packHqlSysRefUserPosition(SysRefUserPosition bean) {
        DdlPackBean result = DdlPackBean.getDdlPackBean(bean);

        // 查询参数封装
        DdlPreparedPack.getNumEqualPack(bean.getUserId(), "userId", result);

        return result;
    }


    /**
     * 组织复杂查询
     *
     * @param organize
     * @return
     */
    public static String packHqlSysOrganize(SysOrganize organize) {
        StringBuffer result = new StringBuffer();

        // 查询参数封装
        if (organize.getChildIdList() != null) {
            HqlPack.getInPack(StringUtils.join(organize.getChildIdList(), ","), "parentId", result);
        }

        HqlPack.getStringLikerPack(organize.getName(), "name", result);
        HqlPack.getStringLikerPack(organize.getOrganizeCode(), "organizeCode", result);

        // 添加默认排序
        HqlPack.getOrderDefault(organize);

        return result.toString();
    }

    public static DdlPackBean packHqlSysOrganize(SysOrganize organize, List<Long> idList) {
        HqlPack.getOrderDefault(organize);

        DdlPackBean result = DdlPackBean.getDdlPackBean(organize);

        DdlPreparedPack.getStringLikerPack(organize.getName(), "name", result);
        DdlPreparedPack.getStringLikerPack(organize.getOrganizeCode(), "organizeCode", result);
        DdlPreparedPack.getNumEqualPack(organize.getParentId(), "parentId", result);

        // 查询参数封装
        if (organize.getChildIdList() != null) {
            DdlPreparedPack.getInPack(StringUtils.join(organize.getChildIdList(), ","), "parentId", result);
        }

        // Number In
        DdlPreparedPack.getInPackList(idList, "id", result);

        return result;
    }

    public static String packHqlSysOrganize(Long[] ids, Integer typeId) {
        StringBuffer result = new StringBuffer();

        // 查询参数封装
        HqlPack.getInPack(StringUtils.join(ids, ","), "id", result);
        HqlPack.getNumEqualPack(typeId, "organizeType", result);

        return result.toString();
    }

    /**
     * 部门复杂查询
     *
     * @param department
     * @return
     */
    @Deprecated
    public static String packHqlSysDepartment(SysDepartment department) {
        StringBuffer result = new StringBuffer();

//        if(department.getOrganizeId() != null && department.getOrganizeId() > 0){
//            department.setParentId(CommonEnumUtil.PARENT.DEFAULT.getValue());
//        }

        HqlPack.getNumEqualPack(department.getParentId(), "parentId", result);
//        HqlPack.getNumEqualPack(department.getOrganizeId(),"organizeId",result);
        HqlPack.getStringLikerPack(department.getName(), "name", result);
        HqlPack.getStringLikerPack(department.getDepartmentCode(), "departmentCode", result);

        // 添加默认排序
        HqlPack.getOrderDefault(department);

        return result.toString();
    }

    public static DdlPackBean packDdlBeanSysDepartment(SysDepartment department, List<Long> idList) {
        DdlPackBean result = DdlPackBean.getDdlPackBean(department);

        DdlPreparedPack.getStringLikerPack(department.getName(), "name", result);
        DdlPreparedPack.getNumEqualPack(department.getParentId(), "parentId", result);
        DdlPreparedPack.getNumEqualPack(department.getOrganizeId(), "organizeId", result);
        DdlPreparedPack.getStringLikerPack(department.getDepartmentCode(), "departmentCode", result);
        DdlPreparedPack.getInPackList(idList, "id", result);

        result.setOrderByStr(department.orderBy());
        return result;
    }

    public static DdlPackBean packDdlBeanSysMenu(SysMenu menu, List<Long> idList) {
        DdlPackBean result = DdlPackBean.getDdlPackBean(menu);

        DdlPreparedPack.getInPackList(idList, "id", result);
        if (menu != null) {
            DdlPreparedPack.getNumEqualPack(menu.getParentId(), "parentId", result);
            DdlPreparedPack.getNumEqualPack(menu.getMenuType(), "menuType", result);
            DdlPreparedPack.getNumEqualPack(menu.getMenuStatus(), "menuStatus", result);
            DdlPreparedPack.getStringLikerPack(menu.getName(), "name", result);
            DdlPreparedPack.getStringLikerPack(menu.getMenuCode(), "menuCode", result);

            result.setOrderByStr(menu.orderBy());
        } else {
            menu = new SysMenu();
        }

        if (!StringUtils.isNotBlank(menu.getOrderByParam())) {
            menu.setOrderByParam("menuSort");
            menu.setAscOrDesc(CommonEnumUtil.ASC_OR_DESC.DESC.getValue());
            result.setOrderByStr(menu.orderBy());
        }

        return result;
    }

    /**
     * 系统角色复杂查询
     *
     * @param role
     * @return
     */
    @Deprecated
    public static String packHqlSysRole(SysRole role) {
        StringBuffer result = new StringBuffer();

        // 查询参数封装
        HqlPack.getNumEqualPack(role.getRoleStatus(), "roleStatus", result);
        HqlPack.getStringLikerPack(role.getName(), "name", result);

        // 添加默认排序
        HqlPack.getOrderDefault(role);

        return result.toString();
    }

    /**
     * 系统角色复杂查询
     *
     * @param role
     * @return
     */
    public static DdlPackBean packDdlBeanSysRole(SysRole role) {
        return packDdlBeanSysRole(role, null);
    }

    /**
     * 唯一校验
     *
     * @param role
     * @return
     */
    public static DdlPackBean packDdlSysRoleCheckOnly(SysRole role) {
        DdlPackBean result = DdlPackBean.getDdlPackBean();

        DdlPreparedPack.getNumNOEqualPack(role.getId(), "id", result);
        DdlPreparedPack.getStringEqualPack(role.getName(), "name", result);
        return result;
    }

    public static DdlPackBean packDdlBeanSysRole(SysRole role, List<Long> idList) {
        DdlPackBean result = DdlPackBean.getDdlPackBean(role);

        DdlPreparedPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), "isDeleted", result);
        DdlPreparedPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), "isValid", result);
        DdlPreparedPack.getNumEqualPack(role.getRoleStatus(), "roleStatus", result);
        DdlPreparedPack.getStringLikerPack(role.getName(), "name", result);
        DdlPreparedPack.getInPackList(idList, "id", result);

        return result;
    }

    /**
     * 系统参数复杂查询
     *
     * @param config
     * @return
     */
    public static DdlPackBean packHqlSysConfig(SysConfig config) {
        DdlPackBean result = DdlPackBean.getDdlPackBean();

        // hql拼接
        DdlPreparedPack.getStringLikerPack(config.getName(), "name", result);
        DdlPreparedPack.getStringLikerPack(config.getConfigCode(), "configCode", result);
        DdlPreparedPack.getNumEqualPack(config.getConfigType(), "configType", result);
        DdlPreparedPack.getNumEqualPack(config.getConfigGroup(), "configGroup", result);

        // 添加默认排序
        DdlPreparedPack.getOrderDefault(config);

        return result;
    }

    /**
     * 字典信息复杂查询
     *
     * @param dictionary
     * @return
     */
    public static DdlPackBean packHqlSysDictionaryPage(SysDictionary dictionary) {
        DdlPackBean result = new DdlPackBean();

        // hql拼接
        DdlPreparedPack.getStringLikerPack(dictionary.getName(), "name", result);
        DdlPreparedPack.getStringLikerPack(dictionary.getDictionaryCode(), "dictionaryCode", result);
        DdlPreparedPack.getNumEqualPack(dictionary.getDictionarySoftType(), "dictionarySoftType", result);
        // 默认查询非顶级字典
        if (dictionary.getParentId() == null || dictionary.getParentId() < 1) {
            DdlPreparedPack.getNumNOEqualPack(CommonEnumUtil.PARENT.DEFAULT.getValue(), "parentId", result);
        }
        DdlPreparedPack.getNumEqualPack(dictionary.getParentId(), "parentId", result);
        DdlPreparedPack.getStringLikerPack(dictionary.getParentCodeRdd(), "parentCodeRdd", result);
        DdlPreparedPack.getStringLikerPack(dictionary.getParentNameRdd(), "parentNameRdd", result);
        DdlPreparedPack.getStringLikerPack(dictionary.getDictionaryValue(), "dictionaryValue", result);
        DdlPreparedPack.getNumEqualPack(dictionary.getDictionarySoftType(), "dictionarySoftType", result);

        // 添加默认排序
        DdlPreparedPack.getOrderDefault(dictionary);

        return result;
    }

    /**
     * 硬件类型复杂查询
     *
     * @param toolType
     * @return
     */
    public static String packHqlSysToolType(SysToolType toolType) {
        StringBuffer result = new StringBuffer();

        // hql拼接
        HqlPack.getStringLikerPack(toolType.getName(), "name", result);

        // 添加默认排序
        HqlPack.getOrderDefault(toolType);

        return result.toString();
    }

    /**
     * 硬件复杂查询
     *
     * @param tool
     * @return
     */
    public static String packHqlSysTool(SysTool tool) {
        StringBuffer result = new StringBuffer();

        // hql拼接
        HqlPack.getStringLikerPack(tool.getName(), "name", result);
        HqlPack.getNumEqualPack(tool.getToolTypeId(), "toolTypeId", result);
        HqlPack.getNumEqualPack(tool.getToolStatus(), "toolStatus", result);
        HqlPack.getNumEqualPack(tool.getToolDataType(), "toolDataType", result);
        HqlPack.getNumEqualPack(tool.getToolConnType(), "toolConnType", result);
        HqlPack.getStringLikerPack(tool.getToolIp(), "toolIp", result);
        HqlPack.getNumLikerPack(tool.getToolPort(), "toolPort", result);

        // 添加默认排序
        HqlPack.getOrderDefault(tool);

        return result.toString();
    }

    /**
     * 消息复杂查询
     *
     * @param message
     * @return
     */
    public static DdlPackBean packHqlSysMessage(SysMessage message) {
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(message);

        // hql拼接
        DdlPreparedPack.getStringLikerPack(message.getMessageTitle(), "messageTitle", ddlPackBean);
        DdlPreparedPack.getStringLikerPack(message.getMessageContent(), "messageContent", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(message.getMessageType(), "messageType", ddlPackBean);
        DdlPreparedPack.getStringLikerPack(message.getMessageSenderNameRdd(), "messageSenderNameRdd", ddlPackBean);
        DdlPreparedPack.getStringLikerPack(message.getMessageReceiversNameRdd(), "messageReceiversNameRdd", ddlPackBean);
        DdlPreparedPack.timeBuilder(message.getMessageSendTime(), "messageSendTime", ddlPackBean, false, false);
        DdlPreparedPack.getNumEqualPack(message.getMessageSenderId(), "messageSenderId", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(message.getIsUrgent(), "isUrgent", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(message.getMessageSoftType(), "messageSoftType", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(message.getSendStatus(), "sendStatus", ddlPackBean);

        DdlPreparedPack.getOrderDefault(message);
        ddlPackBean.setOrderByStr(message.orderBy());

        return ddlPackBean;
    }

    /**
     * 文件资源复杂查询
     *
     * @param file
     * @return
     */
    public static DdlPackBean packHqlSysFile(SysFile file) {
        DdlPreparedPack.getOrderDefault(file);
        DdlPackBean result = DdlPackBean.getDdlPackBean(file);

        // hql拼接
        DdlPreparedPack.getStringLikerPack(file.getFileOriginalName(), "fileOriginalName", result);
        DdlPreparedPack.getNumEqualPack(file.getFileTypeId(), "fileTypeId", result);
        DdlPreparedPack.getStringLikerPack(file.getCreateUser(), "createUser", result);
        DdlPreparedPack.getNumEqualPack(file.getFileSoftType(), "fileSoftType", result);
        DdlPreparedPack.getStringLikerPack(file.getFileCode(), "fileCode", result);
        DdlPreparedPack.timeBuilder(file.getCreateDatetime(), "createDatetime", result, false, false);

        return result;
    }

    /**
     * 任务周期复杂查询
     *
     * @param sysTaskCycle
     * @return
     */
    public static DdlPackBean packHqlSysTaskCycle(SysTaskCycle sysTaskCycle) {
        DdlPackBean result = DdlPackBean.getDdlPackBean(sysTaskCycle);

        // hql拼接
        DdlPreparedPack.getStringLikerPack(sysTaskCycle.getName(), "name", result);
        DdlPreparedPack.getStringEqualPack(sysTaskCycle.getOrganizeCode(), "organizeCode", result);

        return result;
    }

    /**
     * 定时任务复杂查询
     *
     * @param sysTaskPlan
     * @return
     */
    public static DdlPackBean packHqlSysTaskPlan(SysTaskPlan sysTaskPlan) {
        DdlPackBean result = DdlPackBean.getDdlPackBean();

        // hql拼接
        DdlPreparedPack.getStringLikerPack(sysTaskPlan.getName(), "name", result);
        DdlPreparedPack.getStringLikerPack(sysTaskPlan.getGroupName(), "groupName", result);
        DdlPreparedPack.getNumEqualPack(sysTaskPlan.getTaskPlanStatus(), "taskPlanStatus", result);
        DdlPreparedPack.getNumEqualPack(sysTaskPlan.getTaskCycleId(), "taskCycleId", result);
        DdlPreparedPack.getStringEqualPack(sysTaskPlan.getOrganizeCode(), "organizeCode", result);
        DdlPreparedPack.getNumEqualPack(sysTaskPlan.getTaskSoftTypeRdd(), "taskSoftTypeRdd", result);
        DdlPreparedPack.timeBuilder(sysTaskPlan.getLastRunDateTime(), "lastRunDateTime", result, false, true);

        // 添加默认排序
        DdlPreparedPack.getOrderDefault(sysTaskPlan);

        return result;
    }

    /**
     * 账号复杂查询
     *
     * @param user
     * @return
     */
    public static String packHqlSysUser(SysUser user) {
        StringBuffer result = new StringBuffer();

        // And X = X
        HqlPack.getNumEqualPack(CommonEnumUtil.IS_VAILD.VAILD.getValue(), "isValid", result);
        HqlPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), "isDeleted", result);
        HqlPack.getNumEqualPack(user.getDepartmentId(), "departmentId", result);
        HqlPack.getNumEqualPack(user.getUserStatus(), "userStatus", result);
        HqlPack.getStringEqualPack(user.getOrganizeCode(), "organizeCode", result);

        if (user.getRoleIdList() != null) {
            HqlPack.getInPack(StringUtils.join(user.getRoleIdList(), ","), "id", result);
        }

        if (user.getDepartmentIdList() != null) {
            HqlPack.getInPack(StringUtils.join(user.getDepartmentIdList(), ","), "id", result);
        }

        // And Like % %
        HqlPack.getStringLikerPack(user.getUserName(), "userName", result);
        HqlPack.getStringLikerPack(user.getUserLoginName(), "userLoginName", result);
        HqlPack.getStringLikerPack(user.getUserEmail(), "userEmail", result);
        HqlPack.getStringLikerPack(user.getUserPhone(), "userPhone", result);

        // 添加默认排序
        HqlPack.getOrderDefault(user);

        return result.toString();
    }

    public static DdlPackBean packDdlBeanSysUser(SysUser user, List<Long> idList) {
        DdlPackBean result = DdlPackBean.getDdlPackBean(user);

        DdlPreparedPack.getNumEqualPack(user.getUserStatus(), "userStatus", result);
//        DdlPreparedPack.getNumEqualPack(user.getDepartmentId(),"departmentId",result);

        DdlPreparedPack.getStringLikerPack(user.getUserLoginName(),"userLoginName",result);
        DdlPreparedPack.getStringLikerPack(user.getUserName(),"userName",result);
        DdlPreparedPack.getStringLikerPack(user.getUserEmail(),"userEmail",result);
        DdlPreparedPack.getStringLikerPack(user.getUserPhone(),"userPhone",result);
        DdlPreparedPack.getStringLikerPack(user.getUserEmpNo(),"userEmpNo",result);
//        DdlPreparedPack.getStringEqualPack(user.getOrganizeCode(),"organizeCode",result);

        DdlPreparedPack.getInPackList(idList, "id", result);
        result.setOrderByStr(user.orderBy());

        return result;
    }

    /**
     * 账号复杂查询
     *
     * @param user
     * @return
     */
    public static DdlPackBean packDdlSysUser(SysUser user) {
        DdlPackBean ddlPack = DdlPackBean.getDdlPackBean(user);

        // And X = X
        DdlPreparedPack.getNumEqualPack(CommonEnumUtil.IS_VAILD.VAILD.getValue(), "isValid", ddlPack);
        DdlPreparedPack.getNumEqualPack(user.getDepartmentId(), "departmentId", ddlPack);
        DdlPreparedPack.getNumEqualPack(user.getUserStatus(), "userStatus", ddlPack);

        if (user.getRoleIdList() != null) {
            DdlPreparedPack.getInPack(user.getRoleIdList(), "id", ddlPack);
        }

        if (user.getDepartmentIdList() != null) {
            DdlPreparedPack.getInPack(user.getDepartmentIdList(), "id", ddlPack);
        }

        // And Like % %
        DdlPreparedPack.getStringLikerPack(user.getUserName(), "userName", ddlPack);
        DdlPreparedPack.getStringLikerPack(user.getUserLoginName(), "userLoginName", ddlPack);
        DdlPreparedPack.getStringLikerPack(user.getUserEmail(), "userEmail", ddlPack);
        DdlPreparedPack.getStringLikerPack(user.getUserPhone(), "userPhone", ddlPack);

        // 添加默认排序
        DdlPreparedPack.getOrderDefault(user);
        DdlPreparedPack.getOrderByPack(new Object[]{1}, new String[]{"createDatetime"}, ddlPack);

        return ddlPack;
    }

    /**
     * 查询字典代码是否重复
     *
     * @param dictionary
     * @return
     */
    public static DdlPackBean packHqlSysDictionaryCode(SysDictionary dictionary) {
        DdlPackBean result = new DdlPackBean();

        // and
        DdlPreparedPack.getStringEqualPack(dictionary.getDictionaryCode(), "dictionaryCode", result);
        DdlPreparedPack.getNumEqualPack(dictionary.getParentId(), "parentId", result);
        DdlPreparedPack.getNumEqualPack(dictionary.getDictionarySoftType(), "dictionarySoftType", result);
        // not
        DdlPreparedPack.getNumNOEqualPack(dictionary.getId(), "id", result);

        // 添加默认排序
        DdlPreparedPack.getOrderDefault(dictionary);

        return result;
    }

    /**
     * 查询字典值是否重复
     *
     * @param dictionary
     * @return
     */
    public static DdlPackBean packHqlSysDictionaryValue(SysDictionary dictionary) {
        DdlPackBean result = new DdlPackBean();

        // and
        DdlPreparedPack.getStringEqualAndAllowBlankPack(dictionary.getDictionaryValue(), "dictionaryValue", result);
        DdlPreparedPack.getNumEqualPack(dictionary.getParentId(), "parentId", result);
        DdlPreparedPack.getNumEqualPack(dictionary.getDictionarySoftType(), "dictionarySoftType", result);
        // not
        DdlPreparedPack.getNumNOEqualPack(dictionary.getId(), "id", result);

        // 添加默认排序
        DdlPreparedPack.getOrderDefault(dictionary);

        return result;
    }

    /**
     * 用户信息 复杂查询拼接
     *
     * @param userInfo
     * @return
     */
    public static String packHqlSysUserInfo(SysUserInfo userInfo) {
        StringBuffer result = new StringBuffer();

        // And
        HqlPack.getNumEqualPack(CommonEnumUtil.IS_VAILD.VAILD.getValue(), "isValid", result);
        HqlPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), "isDeleted", result);
//        HqlPack.getNumEqualPack(userInfo.getOrganizeId(),"organizeId",result);
//        HqlPack.getNumEqualPack(userInfo.getDepartmentId(),"departmentId",result);
        HqlPack.getNumEqualPack(userInfo.getPositionId(), "positionId", result);
        HqlPack.getNumEqualPack(userInfo.getUserInfoStatus(), "userInfoStatus", result);
        HqlPack.getStringEqualPack(userInfo.getOrganizeCode(), "organizeCode", result);

        if (userInfo.getDepartmentIdList() != null && !userInfo.getDepartmentIdList().isEmpty()) {
            HqlPack.getInPack(StringUtils.join(userInfo.getDepartmentIdList(), ","), "departmentId", result);
        }

        // Like
        HqlPack.getStringLikerPack(userInfo.getName(), "name", result);
        HqlPack.getStringLikerPack(userInfo.getUserEmpNo(), "userEmpNo", result);

        // 添加默认排序
        HqlPack.getOrderDefault(userInfo);

        return result.toString();
    }

    public static DdlPackBean packDdlBeanSysUserInfo(SysUserInfo userInfo, List<Long> idList) {
        DdlPackBean result = DdlPackBean.getDdlPackBean(userInfo);

        // And
        DdlPreparedPack.getNumEqualPack(userInfo.getPositionId(), "positionId", result);
        DdlPreparedPack.getNumEqualPack(userInfo.getUserInfoStatus(), "userInfoStatus", result);
        DdlPreparedPack.getStringEqualPack(userInfo.getOrganizeCode(), "organizeCode", result);
        DdlPreparedPack.getInPackList(idList, "id", result);

        if (userInfo.getDepartmentIdList() != null && !userInfo.getDepartmentIdList().isEmpty()) {
            DdlPreparedPack.getInPackList(userInfo.getDepartmentIdList(), "departmentId", result);
        }

        // Like
        DdlPreparedPack.getStringLikerPack(userInfo.getName(), "name", result);
        DdlPreparedPack.getStringLikerPack(userInfo.getUserEmpNo(), "userEmpNo", result);

        // 添加默认排序
        result.setOrderByStr(userInfo.orderBy());

        return result;
    }

    /**
     * 用户信息 复杂查询拼接
     *
     * @param userInfo
     * @return
     */
    public static String packHqlSysUserInfo(SysUserInfo userInfo, List<Long> idList) {
        StringBuffer result = new StringBuffer();

        // And
        HqlPack.getNumEqualPack(userInfo.getUserInfoStatus(), "userInfoStatus", result);
        if (idList != null && !idList.isEmpty()) {
            HqlPack.getInPack(StringUtils.join(idList, ","), "id", result);
        }

        // Like
        HqlPack.getStringLikerPack(userInfo.getName(), "name", result);
        HqlPack.getStringLikerPack(userInfo.getUserEmpNo(), "userEmpNo", result);

        // 添加默认排序
        HqlPack.getOrderDefault(userInfo);

        return result.toString();
    }

    /**
     * 查询语言代码是否重复
     *
     * @param localeLanguage
     * @return
     */
    public static String packHqlSysLocaleLanguageCode(SysLocaleLanguage localeLanguage) {
        StringBuffer result = new StringBuffer();

        HqlPack.getStringEqualPack(localeLanguage.getLanguageCode(), "languageCode", result);
        HqlPack.getNumNOEqualPack(localeLanguage.getId(), "id", result);

        // 添加默认排序
        HqlPack.getOrderDefault(localeLanguage);

        return result.toString();
    }

    /**
     * 检查系统资源是否重复
     *
     * @param localeResource
     * @return
     */
    public static String packHqlSysLocaleResourceKey(SysLocaleResource localeResource) {
        StringBuffer result = new StringBuffer();

        HqlPack.getStringEqualPack(localeResource.getLanguageCode(), "languageCode", result);
        HqlPack.getStringEqualPack(localeResource.getResourceKey(), "resourceKey", result);
        HqlPack.getNumEqualPack(localeResource.getSoftType(), "softType", result);
        HqlPack.getNumNOEqualPack(localeResource.getId(), "id", result);

        // 添加默认排序
        HqlPack.getOrderDefault(localeResource);

        return result.toString();
    }

    /**
     * 查询规则代码是否重复
     *
     * @param orderNoRule
     * @return
     */
    public static String packHqlSysOrderNoRuleCode(SysOrderNoRule orderNoRule) {
        StringBuffer result = new StringBuffer();

        // and
        HqlPack.getStringEqualPack(orderNoRule.getOrderNoRuleCode(), "orderNoRuleCode", result);
        // not
        HqlPack.getNumNOEqualPack(orderNoRule.getId(), "id", result);

        // 添加默认排序
        HqlPack.getOrderDefault(orderNoRule);

        return result.toString();
    }

    /**
     * 单号规则复杂查询，分页，排序
     *
     * @param orderNoRule
     * @return
     */
    public static DdlPackBean packHqlSysOrderNoRule(SysOrderNoRule orderNoRule) {
        DdlPackBean result = DdlPackBean.getDdlPackBean();

        DdlPreparedPack.getStringLikerPack(orderNoRule.getName(), "name", result);
        DdlPreparedPack.getStringLikerPack(orderNoRule.getOrderNoRuleCode(), "orderNoRuleCode", result);
        DdlPreparedPack.getNumEqualPack(orderNoRule.getOrderNoRuleStatus(), "orderNoRuleStatus", result);
        DdlPreparedPack.getNumEqualPack(orderNoRule.getOrganizeCode(), "organizeCode", result);
        DdlPreparedPack.getStringLikerPack(orderNoRule.getOrderNoRuleCode(), "orderNoRuleCode", result);
        DdlPreparedPack.getStringLikerPack(orderNoRule.getOrderNo(), "orderNo", result);
        if (orderNoRule.getSerialNo() != null) {
            DdlPreparedPack.getNumEqualPack(String.valueOf(orderNoRule.getSerialNo()), "serialNo", result);
        }

        // 添加默认排序
        DdlPreparedPack.getOrderDefault(orderNoRule);

        return result;
    }

    /**
     * 用户消息关系表负责查询
     *
     * @param sysRefUserMessage
     * @return
     */
    public static String packHqlSysRefUserMessage(SysRefUserMessage sysRefUserMessage) {
        StringBuffer result = new StringBuffer();

        HqlPack.getNumEqualPack(sysRefUserMessage.getMessageId(), "messageId", result);
        HqlPack.getNumEqualPack(sysRefUserMessage.getMessageTypeRdd(), "messageTypeRdd", result);
        HqlPack.getNumEqualPack(sysRefUserMessage.getMessageSoftType(), "messageSoftType", result);
        HqlPack.getStringLikerPack(sysRefUserMessage.getMessageTitleRdd(), "messageTitleRdd", result);
        HqlPack.getStringLikerPack(sysRefUserMessage.getMessageSenderNameRdd(), "messageSenderNameRdd", result);
        HqlPack.getNumEqualPack(sysRefUserMessage.getMessageStatus(), "messageStatus", result);
        HqlPack.getStringLikerPack(sysRefUserMessage.getReceiverTime(), "receiverTime", result);
        HqlPack.getNumEqualPack(sysRefUserMessage.getReceiverId(), "receiverId", result);

        // 添加默认排序
        HqlPack.getOrderDefault(sysRefUserMessage);

        return result.toString();
    }

    /**
     * 任务复杂查询
     *
     * @param sysTask
     * @return
     */
    public static DdlPackBean packHqlSysTask(SysTask sysTask) {
        DdlPackBean result = DdlPackBean.getDdlPackBean();

        DdlPreparedPack.getStringLikerPack(sysTask.getName(), "name", result);
        DdlPreparedPack.getStringEqualPack(sysTask.getOrganizeCode(), "organizeCode", result);
        DdlPreparedPack.getNumEqualPack(sysTask.getTaskSoftType(), "taskSoftType", result);
        DdlPreparedPack.getStringLikerPack(sysTask.getTaskPackage(), "taskPackage", result);
        DdlPreparedPack.getStringLikerPack(sysTask.getTaskClass(), "taskClass", result);

        DdlPreparedPack.getOrderDefault(sysTask);

        return result;
    }


    /**
     * 任务复杂查询
     *
     * @param sysTask
     * @return
     */
    public static DdlPackBean packHqlCheckSysTaskOnly(SysTask sysTask) {
        DdlPackBean result = DdlPackBean.getDdlPackBean();

        DdlPreparedPack.getNumNOEqualPack(sysTask.getId(), "id", result);
        DdlPreparedPack.getStringEqualPack(sysTask.getName(), "name", result);
        DdlPreparedPack.getStringEqualPack(sysTask.getTaskCode(), "taskCode", result);

        return result;
    }

    public static String packHqlSysLocaleLanguageExistDefaultByIds(Long[] ids) {
        StringBuffer result = new StringBuffer();

        HqlPack.getInPack(StringUtils.join(ids, ","), "id", result);
        HqlPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), "isDefault", result);

        return result.toString();
    }

    /**
     * 大小区间比较
     *
     * @param columnName
     * @param min
     * @param max
     * @return
     */
    public static String packHqlByInterval(String columnName, Object min, Object max) {
        StringBuffer result = new StringBuffer();

        HqlPack.getNumSmallerPack(max, columnName, result);
        HqlPack.getNumBiggerPack(min, columnName, result);

        return result.toString();
    }


    /**
     * 字典信息查询id集合中是否存在默认数据
     *
     * @param ids
     * @return
     */
    public static DdlPackBean packHqlSysDictionaryByIdsAndIsDefault(Long[] ids) {
        DdlPackBean result = DdlPackBean.getDdlPackBean();

        // hql拼接
        DdlPreparedPack.getInPack(StringUtils.join(ids, ","), "id", result);
        DdlPreparedPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), "isDefault", result);

        return result;
    }

    /**
     * 条码规则代码是否存在
     *
     * @param sysBarcodeRule
     * @return
     */
    public static String packHqlSysBarcodeRuleCode(SysBarcodeRule sysBarcodeRule) {
        StringBuffer result = new StringBuffer();

        // and
        HqlPack.getStringEqualPack(sysBarcodeRule.getBarcodeRuleCode(), "barcodeRuleCode", result);
        // not
        HqlPack.getNumNOEqualPack(sysBarcodeRule.getId(), "id", result);

        return result.toString();
    }

    /**
     * 条码规则复杂查询
     *
     * @param sysBarcodeRule
     * @return
     */
    public static String packHqlSysBarcodeRule(SysBarcodeRule sysBarcodeRule) {
        StringBuffer result = new StringBuffer();

        HqlPack.getStringLikerPack(sysBarcodeRule.getName(), "name", result);
        HqlPack.getStringLikerPack(sysBarcodeRule.getBarcodeRuleCode(), "barcodeRuleCode", result);

        return result.toString();
    }

    /**
     * 打印模板复杂查询
     *
     * @param sysLabelTemplate
     * @return
     */
    public static DdlPackBean packHqlSysLabelTemplate(SysLabelTemplate sysLabelTemplate) {
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(sysLabelTemplate);

        // hql拼接
        DdlPreparedPack.getStringLikerPack(sysLabelTemplate.getTemplateName(), "templateName", ddlPackBean);
        DdlPreparedPack.getStringEqualPack(sysLabelTemplate.getTemplateCode(), "templateCode", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(sysLabelTemplate.getTemplateGroupId(), "templateGroupId", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(sysLabelTemplate.getTemplateSoftType(), "templateSoftType", ddlPackBean);

        // 添加默认排序
        ddlPackBean.setOrderByStr(sysLabelTemplate.orderBy());

        return ddlPackBean;
    }

    public static DdlPackBean packBeanSysLabelTemplate(SysLabelTemplate sysLabelTemplate) {
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(sysLabelTemplate);

        // hql拼接
        DdlPreparedPack.getStringEqualPack(sysLabelTemplate.getTemplateName(), "templateName", ddlPackBean);
        DdlPreparedPack.getStringEqualPack(sysLabelTemplate.getTemplateCode(), "templateCode", ddlPackBean);
        DdlPreparedPack.getStringEqualPack(sysLabelTemplate.getOrganizeCode(), "organizeCode", ddlPackBean);

        DdlPreparedPack.timeBuilder(sysLabelTemplate.getModifyDateTimeStart(), sysLabelTemplate.getModifyDateTimeEnd(), "modifyDatetime", ddlPackBean, true);

        // 添加默认排序
        HqlPack.getOrderDefault(sysLabelTemplate);

        return ddlPackBean;
    }

    /**
     * 打印模板参数复杂查询
     *
     * @param sysLabelTemplateParam
     * @return
     */
    public static String packHqlSysLabelTemplateParams(SysLabelTemplateParam sysLabelTemplateParam) {
        StringBuffer result = new StringBuffer();

        // hql拼接
        HqlPack.getNumEqualPack(sysLabelTemplateParam.getTemplateId(), "templateId", result);
        HqlPack.getStringEqualPack(sysLabelTemplateParam.getTemplateCode(), "templateCode", result);
        HqlPack.getNumEqualPack(sysLabelTemplateParam.getIsValid(), "isValid", result);
        HqlPack.getNumEqualPack(sysLabelTemplateParam.getIsDeleted(), "isDeleted", result);
        HqlPack.getStringEqualPack(sysLabelTemplateParam.getOrganizeCode(), "organizeCode", result);
        // 添加默认排序
        HqlPack.getOrderDefault(sysLabelTemplateParam);

        return result.toString();
    }


    /**
     * 文件代码是否存在
     *
     * @param sysFile 查询条件
     * @return DdlPackBean
     */
    public static DdlPackBean packHqlSysFileCode(SysFile sysFile) {
        DdlPackBean result = DdlPackBean.getDdlPackBean(sysFile);

        // and
        DdlPreparedPack.getStringEqualPack(sysFile.getFileCode(), "fileCode", result);
        // not
        DdlPreparedPack.getNumNOEqualPack(sysFile.getId(), "id", result);

        return result;
    }

    public static DdlPackBean packDdlBeanSysRefUserRole(SysRefUserRole ref) {
        DdlPackBean result = DdlPackBean.getDdlPackBean(ref);

        // Number Eq
        DdlPreparedPack.getNumEqualPack(ref.getUserId(), "userId", result);
        // String Eq
        DdlPreparedPack.getStringEqualPack(ref.getOrganizeCode(), "organizeCode", result);

        return result;
    }

    public static DdlPackBean packDdlBeanSysRefUserRole(Long userId, Long roleId, String organizeCode) {
        DdlPackBean result = DdlPackBean.getDdlPackBean();

        // Number Eq
        DdlPreparedPack.getNumEqualPack(userId, "userId", result);
        DdlPreparedPack.getNumEqualPack(roleId, "roleId", result);

        // String Eq
        DdlPreparedPack.getStringEqualPack(organizeCode, "organizeCode", result);

        return result;
    }

    /**
     * 查询当前用户所有组织数据
     *
     * @param sysRefUserDepartments
     * @return
     */
    public static DdlPackBean packHqlSysOrganize(List<SysRefUserDepartment> sysRefUserDepartments) {
        DdlPackBean packBean = DdlPackBean.getDdlPackBean();
        DdlPreparedPack.getInPackList(sysRefUserDepartments.stream().map(SysRefUserDepartment::getOrganizeId).collect(Collectors.toList()), "id", packBean);

        return packBean;
    }

    /**
     * 按条件查询字典
     *
     * @param sysDictionary
     * @return
     */
    public static DdlPackBean packHqlSysDictionary(SysDictionary sysDictionary) {
        DdlPackBean packBean = DdlPackBean.getDdlPackBean(sysDictionary);

        DdlPreparedPack.getStringEqualPack(sysDictionary.getName(), "name", packBean);
        DdlPreparedPack.getStringEqualPack(sysDictionary.getDictionaryCode(), "dictionaryCode", packBean);
        DdlPreparedPack.getStringEqualPack(sysDictionary.getParentNameRdd(), "parentNameRdd", packBean);
        DdlPreparedPack.getNumEqualPack(sysDictionary.getParentId(), "parentId", packBean);
        DdlPreparedPack.getNumEqualPack(sysDictionary.getDictionarySoftType(), "dictionarySoftType", packBean);
        DdlPreparedPack.getNumEqualPack(sysDictionary.getDictionaryGroup(), "dictionaryGroup", packBean);
        DdlPreparedPack.getNumEqualPack(sysDictionary.getDictionaryValue(), "dictionaryValue", packBean);

        return packBean;
    }

    /**
     * 按条件查询字典
     *
     * @param bean
     * @return
     */
    public static DdlPackBean packHqlSysPojoVersion(SysPojoVersion bean) {
        DdlPackBean packBean = DdlPackBean.getDdlPackBean(bean);

        DdlPreparedPack.getNumEqualPack(bean.getRefId(), "refId", packBean);
        DdlPreparedPack.getNumEqualPack(bean.getPlanId(), "planId", packBean);
        DdlPreparedPack.getNumEqualPack(bean.getOperateType(), "operateType", packBean);
        DdlPreparedPack.getStringLeftLikerPack(bean.getRefClass(), "refClass", packBean);
        DdlPreparedPack.getStringLeftLikerPack(bean.getVersionMethodName(), "versionMethodName", packBean);
        DdlPreparedPack.getStringLikerPack(bean.getPojoCompare(), "pojoCompare", packBean);
        DdlPreparedPack.timeBuilder(bean.getModifyDatetime(), "modifyDatetime", packBean, false, true);

        return packBean;
    }


    public static DdlPackBean packSysDataSource(SysDataSource bean) {
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(bean);

        DdlPreparedPack.getStringLikerPack(bean.getSourceHost(), "sourceHost", ddlPackBean);
        DdlPreparedPack.getStringLikerPack(bean.getSourceName(), "sourceName", ddlPackBean);
        DdlPreparedPack.getStringLikerPack(bean.getSourceCode(), "sourceCode", ddlPackBean);
        DdlPreparedPack.getStringLikerPack(bean.getSourceDataBaseName(), "sourceDataBaseName", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(bean.getSourceType(), "sourceType", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(bean.getSourceStatus(), "sourceStatus", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(bean.getSoftType(), "softType", ddlPackBean);

        return ddlPackBean;
    }

    public static DdlPackBean packHqlSysTaskPlanOnly(SysTaskPlan sysTaskPlan){
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(sysTaskPlan);

        DdlPreparedPack.getNumEqualPack(sysTaskPlan.getId(),"id",ddlPackBean);
        DdlPreparedPack.getStringEqualPack(sysTaskPlan.getName(),"name",ddlPackBean);
        DdlPreparedPack.getStringEqualPack(sysTaskPlan.getGroupName(),"groupName",ddlPackBean);

        return ddlPackBean;
    }
    public static DdlPackBean packHqlSysUserCustomizeConfigOnly(SysUserCustomizeConfig sysUserCustomizeConfig){
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(sysUserCustomizeConfig);

        DdlPreparedPack.getNumNOEqualPack(sysUserCustomizeConfig.getId(),"id",ddlPackBean);
        DdlPreparedPack.getNumEqualPack(sysUserCustomizeConfig.getUserId(),"userId",ddlPackBean);
        DdlPreparedPack.getStringEqualPack(sysUserCustomizeConfig.getConfigKey(),"configKey",ddlPackBean);
        DdlPreparedPack.getNumEqualPack(sysUserCustomizeConfig.getCustomizeConfigType(),"customizeConfigType",ddlPackBean);

        return ddlPackBean;
    }

    public static DdlPackBean packHqlGetSysUserCustomizeConfig(SysUserCustomizeConfig sysUserCustomizeConfig){
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(sysUserCustomizeConfig);

        DdlPreparedPack.getNumEqualPack(sysUserCustomizeConfig.getUserId(),"userId",ddlPackBean);
        DdlPreparedPack.getStringEqualPack(sysUserCustomizeConfig.getConfigKey(),"configKey",ddlPackBean);
        DdlPreparedPack.getNumEqualPack(sysUserCustomizeConfig.getCustomizeConfigType(),"customizeConfigType",ddlPackBean);

        return ddlPackBean;
    }

    public static DdlPackBean packHqlQuerySysLogUserLogin(SysLogUserLogin sysLogUserLogin){
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(sysLogUserLogin);

        DdlPreparedPack.getNumEqualPack(sysLogUserLogin.getLogLoginStatus(),"logLoginStatus",ddlPackBean);
        DdlPreparedPack.getNumEqualPack(sysLogUserLogin.getLogLoginPlatform(),"logLoginPlatform",ddlPackBean);
        DdlPreparedPack.getStringLikerPack(sysLogUserLogin.getLogLoginName(),"logLoginName",ddlPackBean);
        DdlPreparedPack.getStringLikerPack(sysLogUserLogin.getLogLoginHost(), "logLoginHost", ddlPackBean);
        DdlPreparedPack.timeBuilder(sysLogUserLogin.getLogLoginDateTime(), "logLoginDateTime", ddlPackBean, false, true);

        return ddlPackBean;
    }

    public static DdlPackBean packHqlFindUserIdByExternalRef(Integer externalRef,List<String> valueList){
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();

        DdlPreparedPack.getNumEqualPack(externalRef,"externalRef",ddlPackBean);
        DdlPreparedPack.getInPackList(valueList,"valueList",ddlPackBean);

        return ddlPackBean;
    }
    public static DdlPackBean packHqlFindExternalRefByUserId(Integer externalRef,List<Long> userIdList){
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();

        DdlPreparedPack.getNumEqualPack(externalRef,"externalRef",ddlPackBean);
        DdlPreparedPack.getInPackList(userIdList,"userId",ddlPackBean);

        return ddlPackBean;
    }

    public static DdlPackBean packHqlGetSysRefUserExternal(SysRefUserExternal sysRefUserExternal){
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(sysRefUserExternal);

        DdlPreparedPack.getNumEqualPack(sysRefUserExternal.getUserId(), "userId", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(sysRefUserExternal.getExternalRef(), "externalRef", ddlPackBean);
        DdlPreparedPack.getStringEqualPack(sysRefUserExternal.getRefValue(), "refValue", ddlPackBean);

        return ddlPackBean;
    }


    public static DdlPackBean packHqlQuerySysSoftUpdateRecord(SysSoftUpdateRecord sysSoftUpdateRecord){
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(sysSoftUpdateRecord);

        DdlPreparedPack.getNumEqualPack(sysSoftUpdateRecord.getSystemSoftType(), "systemSoftType", ddlPackBean);
        DdlPreparedPack.getStringEqualPack(sysSoftUpdateRecord.getSystemVersion(), "systemVersion", ddlPackBean);
        DdlPreparedPack.timeBuilder(sysSoftUpdateRecord.getFirstDeploymentTime(), "firstDeploymentTime", ddlPackBean, false,
                true);

        return ddlPackBean;
    }

    public static DdlPackBean packHqlCheckSysSoftUpdateRecordOnly(SysSoftUpdateRecord sysSoftUpdateRecord){
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(sysSoftUpdateRecord);

        DdlPreparedPack.getNumNOEqualPack(sysSoftUpdateRecord.getId(), "id", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(sysSoftUpdateRecord.getSystemSoftType(), "systemSoftType", ddlPackBean);
        DdlPreparedPack.getStringEqualPack(sysSoftUpdateRecord.getSystemVersion(), "systemVersion", ddlPackBean);

        return ddlPackBean;
    }


    public static DdlPackBean packHqlCheckSysDepartmentOnly(SysDepartment sysDepartment){
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(sysDepartment);

        DdlPreparedPack.getNumNOEqualPack(sysDepartment.getId(), "id", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(sysDepartment.getDepartmentCode(), "departmentCode", ddlPackBean);

        return ddlPackBean;
    }

    public static DdlPackBean packHqlCheckSysOrganizeOnly(SysOrganize sysOrganize){
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(sysOrganize);

        DdlPreparedPack.getNumNOEqualPack(sysOrganize.getId(), "id", ddlPackBean);
        DdlPreparedPack.getNumEqualPack(sysOrganize.getOrganizeCode(), "organizeCode", ddlPackBean);

        return ddlPackBean;
    }

}