Просмотр исходного кода

新增sop列表动态表单排序

wangliang 1 год назад
Родитель
Сommit
f24d324aa2

+ 12 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/FormWidgetMetadataParam.java

@@ -2,6 +2,7 @@ package com.qmth.sop.business.bean.params;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.qmth.sop.common.enums.FormWidgetMetadataOperator;
+import com.qmth.sop.common.enums.FormWidgetMetadataOrder;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
@@ -23,9 +24,20 @@ public class FormWidgetMetadataParam implements Serializable {
     @ApiModelProperty(value = "运算符")
     private FormWidgetMetadataOperator operator;
 
+    @ApiModelProperty(value = "排序")
+    private FormWidgetMetadataOrder order;
+
     @ApiModelProperty(value = "字段值")
     private String fieldValue;
 
+    public FormWidgetMetadataOrder getOrder() {
+        return order;
+    }
+
+    public void setOrder(FormWidgetMetadataOrder order) {
+        this.order = order;
+    }
+
     public FormWidgetMetadataOperator getOperator() {
         return operator;
     }

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/SopInfoListParam.java

@@ -34,6 +34,9 @@ public class SopInfoListParam extends TBSopInfo implements Serializable {
     @ApiModelProperty(value = "元数据显示字段数组")
     private List<FormWidgetMetadataParam> formWidgetMetadataViewList;
 
+    @ApiModelProperty(value = "元数据排序字段数组")
+    private List<FormWidgetMetadataParam> formWidgetMetadataOrderList;
+
     @ApiModelProperty(value = "元数据筛选字段数组")
     private List<FormWidgetMetadataParam> formWidgetMetadataConditionList;
 
@@ -51,6 +54,14 @@ public class SopInfoListParam extends TBSopInfo implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private List<Long> userIdList;
 
+    public List<FormWidgetMetadataParam> getFormWidgetMetadataOrderList() {
+        return formWidgetMetadataOrderList;
+    }
+
+    public void setFormWidgetMetadataOrderList(List<FormWidgetMetadataParam> formWidgetMetadataOrderList) {
+        this.formWidgetMetadataOrderList = formWidgetMetadataOrderList;
+    }
+
     public List<Long> getUserIdList() {
         return userIdList;
     }

+ 3 - 1
sop-business/src/main/java/com/qmth/sop/business/mapper/TBSopInfoMapper.java

@@ -80,10 +80,12 @@ public interface TBSopInfoMapper extends BaseMapper<TBSopInfo> {
      * @param tableName
      * @param fieldName
      * @param fieldValue
+     * @param dpr
+     * @param fieldOrder
      * @return
      */
     @SuppressWarnings("MybatisXMapperMethodInspection")
-    IPage<Map> list(IPage<Map> iPage, @Param("type") String type, @Param("serviceId") Long serviceId, @Param("tableName") String tableName, @Param("fieldName") String fieldName, @Param("fieldValue") String fieldValue, @Param("dpr") DataPermissionDto dpr);
+    IPage<Map> list(IPage<Map> iPage, @Param("type") String type, @Param("serviceId") Long serviceId, @Param("tableName") String tableName, @Param("fieldName") String fieldName, @Param("fieldValue") String fieldValue, @Param("dpr") DataPermissionDto dpr, @Param("fieldOrder") String fieldOrder);
 
     /**
      * 根据crmNo查询在途的sop信息

+ 12 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -348,9 +348,10 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             throw ExceptionResultEnum.ERROR.exception("流程类型只能为教务处或研究生");
         }
         String tableName = sopInfoListParam.getType().getTableName() + "_" + sopInfoListParam.getVersion();
-        String fieldName = null, fieldValue = null;
+        String fieldName = null, fieldValue = null, fieldOrder = null;
         StringJoiner stringJoinerView = new StringJoiner(",");
         StringJoiner stringJoinerCondition = new StringJoiner("");
+        StringJoiner stringJoinerOrder = new StringJoiner("");
 
         //显示字段
         if (!CollectionUtils.isEmpty(sopInfoListParam.getFormWidgetMetadataViewList())) {
@@ -418,9 +419,18 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         }
         fieldValue = !Objects.equals(stringJoinerCondition.toString().trim(), "") ? stringJoinerCondition.toString().trim() : null;
 
+        //排序字段
+        if (!CollectionUtils.isEmpty(sopInfoListParam.getFormWidgetMetadataOrderList())) {
+            for (FormWidgetMetadataParam f : sopInfoListParam.getFormWidgetMetadataOrderList()) {
+                stringJoinerOrder.add(f.getFieldId()).add(f.getOrder().getCode()).add(",");
+            }
+            fieldOrder = stringJoinerOrder.toString();
+            fieldOrder = fieldOrder.substring(0, fieldOrder.length() - 1);
+        }
+
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        IPage<Map> list = this.baseMapper.list(new Page<>(sopInfoListParam.getPageNumber(), sopInfoListParam.getPageSize()), Objects.nonNull(sopInfoListParam.getType()) ? sopInfoListParam.getType().name() : null, sopInfoListParam.getServiceId(), tableName, fieldName, fieldValue, dpr);
+        IPage<Map> list = this.baseMapper.list(new Page<>(sopInfoListParam.getPageNumber(), sopInfoListParam.getPageSize()), Objects.nonNull(sopInfoListParam.getType()) ? sopInfoListParam.getType().name() : null, sopInfoListParam.getServiceId(), tableName, fieldName, fieldValue, dpr, fieldOrder);
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         for (Map m : list.getRecords()) {
             String regionUserId = (String) m.get("region_user_id_1");

+ 3 - 0
sop-business/src/main/resources/mapper/TBSopInfoMapper.xml

@@ -162,6 +162,9 @@
             </if>
             and ari.TYPE_ = 'candidate') t where t.flowId = art.PROC_INST_ID_)-->
          </where>
+         <if test="fieldOrder != null and fieldOrder != ''">
+            order by ${fieldOrder}
+         </if>
     </select>
 
     <select id="findFlowPassageByCrmNo" resultType="java.lang.String">

+ 32 - 0
sop-common/src/main/java/com/qmth/sop/common/enums/FormWidgetMetadataOrder.java

@@ -0,0 +1,32 @@
+package com.qmth.sop.common.enums;
+
+/**
+ * @Description: 动态表单排序enum
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2023/9/7
+ */
+public enum FormWidgetMetadataOrder {
+
+    ASC("升序", " ASC "),
+
+    DESC("降序", " DESC ");
+
+    private String title;
+
+    private String code;
+
+    private FormWidgetMetadataOrder(String title, String code) {
+        this.title = title;
+        this.code = code;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public String getCode() {
+        return code;
+    }
+}