//排序
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;
}
}
<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 ) <= #{xq}
</if>
order by ${sortField}
</select>