• 数据排序(多字段数据排序)


    java代码

    //排序
    entity.setSortField(BloodEnum.RkdSortEnum.valueOf(1).getField());
    if (ArrayUtil.isNotEmpty(dto.getFields())){
    String fields = “”;
    for (Integer sort:dto.getFields()){
    String field = BloodEnum.RkdSortEnum.valueOf(sort).getField();
    if (StrUtil.isNotEmpty(field)){
    fields = field + “,”;
    }
    }
    //除去最后的逗号
    fields = fields.substring(0,fields.length() -1);
    if (dto.getSortType() == 1){
    fields = fields + " DESC";
    }
    entity.setSortField(fields);
    }

    枚举类

    /**
     * 入库单动态排序枚举
     *  1入库日期2到期日期
     */
    @Getter
    @AllArgsConstructor
    public enum RkdSortEnum {
        //排序对应字段名
        one(1,"RKRQ "),
        two(2,"DQRQ");
    
        public Integer value;
        public String field;
    
        public static RkdSortEnum valueOf(Integer value){
            for (RkdSortEnum rKdenum : values()){
                if (rKdenum.getValue().equals(value)){
                    return rKdenum;
                }
            }
            return null;
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23

    sql

        <select id="listRkdsBySort" resultType="com.bsoft.lis.lab.core.entity.blood.BloodRkdEntity">
            select
            <include refid="Base_Column_List"/>
            from BLOOD_RKD
            where JGID = #{jgid}
            <if test="ckbj != null and ckbj != ''">
                AND CKBJ = #{ckbj}
            </if>
            <if test="rkfs != null and rkfs != ''">
                AND RKFS = #{rkfs}
            </if>
            <if test="ckrq != null">
                AND CKRQ = #{ckrq}
            </if>
            <if test="ybbh != null">
                AND YBBH = #{ybbh}
            </if>
            <if test="xylx != null and xylx !='' ">
                AND XYLX = #{xylx}
            </if>
            <if test="sfxj != null ">
                AND SFXJ = #{sfxj}
            </if>
            <if test="ztx != null ">
                AND ZTX = #{ztx}
            </if>
            <if test="abo != null and abo !=''">
                AND ABO = #{abo}
            </if>
            <if test="xdh != null and xdh != ''">
                AND XDH = #{xdh}
            </if>
            <if test="xdxh!=null and xdxh !=''">
                And XDXH = #{xdxh}
            </if>
            <if test="hosarea != null and hosarea != ''">
                AND HOSAREA = #{hosarea}
            </if>
            <if test="bfstartDate !=null and bfendDate !=null">
                AND (BFRQ BETWEEN #{bfstartDate} AND #{bfendDate})
            </if>
            <if test="xq != null and xq != ''">
                and TO_NUMBER(DQRQ -  sysdate ) &lt;= #{xq}
            </if>
    
            order by ${sortField}
        </select>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47

    前端效果

    在这里插入图片描述

  • 相关阅读:
    Acer宏碁掠夺者刀锋500笔记本PT515-51原装出厂Windows10系统工厂模式镜像
    实现自定义Spring Boot Starter
    ZTree自定义不可展开节点的折叠图标
    自定义注解打印日志与耗时
    WordPress供求插件API文档:用户登录
    android 修改输出apk的包名
    Java(八)----多线程
    Hive(16):Hive调优之HQL语法优化
    Java系列 —— 注解
    程序化交易的策略类型可以分为哪几种?
  • 原文地址:https://blog.csdn.net/weixin_46399670/article/details/127800176