Browse Source

服务工作项排序

hu 1 month ago
parent
commit
26edf73b46

+ 30 - 0
src/custom/restcontroller/webmanage/sale/workorder/SortByNum.java

@@ -0,0 +1,30 @@
+package restcontroller.webmanage.sale.workorder;
+
+import common.data.Row;
+import org.apache.commons.lang.StringUtils;
+
+import java.util.Comparator;
+
+public class SortByNum implements Comparator {
+    public int compare(Object o1, Object o2) {
+        Row s1 = (Row) o1;
+        Row s2 = (Row) o2;
+        double s1int = 0;
+        double s2int = 0;
+        //System.out.println("测试");
+        if (StringUtils.isBlank(s1.getString("sequence"))) {
+            s1int = 999;
+        } else {
+            s1int = Double.parseDouble(s1.getString("sequence"));
+        }
+        if (StringUtils.isBlank(s2.getString("sequence"))) {
+            s2int = 9999;
+        } else {
+            s2int = Double.parseDouble(s2.getString("sequence"));
+        }
+        // System.out.println(s1int + "," + s2int);
+        if (s1int > s2int)
+            return 1;
+        return -1;
+    }
+}

+ 4 - 0
src/custom/restcontroller/webmanage/sale/workorder/workorderTemplateWorks.java

@@ -1,6 +1,7 @@
 package restcontroller.webmanage.sale.workorder;
 
 import java.util.ArrayList;
+import java.util.Collections;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -16,6 +17,7 @@ import common.data.Rows;
 import common.data.RowsMap;
 import common.data.SQLFactory;
 import restcontroller.R;
+import restcontroller.webmanage.sale.itemclass.SortByNum;
 
 /**
  * 服务工单模板工作明细
@@ -88,6 +90,7 @@ public class workorderTemplateWorks extends Controller{
 		 * 获取所有一级分类
 		 */
 		Rows toprows = allrows.toRowsMap("parentid").get("0");
+		Collections.sort(toprows, new SortByNum());
 		/*
 		 * 递归查询
 		 */
@@ -137,6 +140,7 @@ public class workorderTemplateWorks extends Controller{
 	 */
 	private Rows getSubWorkorderTemplate(Row root, Rows allWorkorderTemplate) {
 		Rows childrenRows = allWorkorderTemplate.toRowsMap("parentid").get(root.getString("sa_workorder_template_worksid"));
+		Collections.sort(childrenRows, new SortByNum());
 		for (Row row : childrenRows) {
 			row.put("subdep", getSubWorkorderTemplate(row, allWorkorderTemplate));
 		}

+ 2 - 2
src/resources/application.yaml

@@ -9,7 +9,7 @@ system:
   db:
     driver: "com.mysql.cj.jdbc.Driver"
     username: "root"
-    password: "rootroot"
-    url: "jdbc:mysql://127.0.0.1:3306/mdyos"
+    password: "123456"
+    url: "jdbc:mysql://127.0.0.1:3306/yos3"
     #url: jdbc:mysql://host.docker.internal:3306/yos3
     servicename: "mysql80"