|
|
@@ -777,6 +777,14 @@ public class itemgroup extends Controller {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ colormap=jsonArraySortByField(colormap.toJSONString(),"parm","0");
|
|
|
+ specmap=jsonArraySortByField(specmap.toJSONString(),"parm","0");
|
|
|
+ materialmap=jsonArraySortByField(materialmap.toJSONString(),"parm","0");
|
|
|
+ cheekmap=jsonArraySortByField(cheekmap.toJSONString(),"parm","0");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
for (Object object:colormap) {
|
|
|
boolean flag=false;
|
|
|
parm parm =JSON.parseObject(((JSONObject)object).toJSONString(),parm.class);
|
|
|
@@ -836,7 +844,7 @@ public class itemgroup extends Controller {
|
|
|
rows = dbConnect.runSqlQuery(factory.getSQL());
|
|
|
String itemno = "";
|
|
|
if(!rows.isEmpty()){
|
|
|
- itemno=rows.get(0).getString("itemno");
|
|
|
+ // itemno=rows.get(0).getString("itemno");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -901,4 +909,65 @@ public class itemgroup extends Controller {
|
|
|
return getSucReturnObject().setData(oject).toString();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按照JSONArray中的对象的某个字段进行排序(采用fastJson)
|
|
|
+ *
|
|
|
+ * @param jsonArrayStr json数组字符串
|
|
|
+ * @param sortkeyname 根据哪个字段进行排序
|
|
|
+ * @param order 倒序:0;非0顺序
|
|
|
+ * @return 排序后的jsonarray
|
|
|
+ */
|
|
|
+ public JSONArray jsonArraySortByField(String jsonArrayStr,String sortkeyname, String order) throws YosException {
|
|
|
+
|
|
|
+ JSONArray sortedJsonArray = new JSONArray();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ JSONArray jsonArray = JSON.parseArray(jsonArrayStr);
|
|
|
+
|
|
|
+ List<JSONObject> jsonList = new ArrayList<JSONObject>();
|
|
|
+
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ jsonList.add(jsonArray.getJSONObject(i));
|
|
|
+ }
|
|
|
+
|
|
|
+ Collections.sort(jsonList, new Comparator<JSONObject>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(JSONObject a, JSONObject b) {
|
|
|
+
|
|
|
+ String strA = new String();
|
|
|
+ String strB = new String();
|
|
|
+
|
|
|
+ String regEx="[\n`~!@#$%^&*()+=|{}':;',\\-_\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]";
|
|
|
+
|
|
|
+ String aStr = a.getStringValue(sortkeyname);
|
|
|
+ strA = aStr.replaceAll(regEx, "");
|
|
|
+ String bStr = b.getStringValue(sortkeyname);
|
|
|
+ strB = bStr.replaceAll(regEx, "");
|
|
|
+
|
|
|
+ if ("0".equals(order)) {
|
|
|
+ return -strA.compareTo(strB);
|
|
|
+ }else {
|
|
|
+ return strA.compareTo(strB);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ sortedJsonArray.add(jsonList.get(i));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return sortedJsonArray;
|
|
|
+ }
|
|
|
+
|
|
|
}
|