itemgroup.java 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528
  1. package restcontroller.sale.itemgroup;
  2. import beans.Item.Item;
  3. import beans.datatag.DataTag;
  4. import beans.enterprise.Enterprise;
  5. import beans.itemclass.ItemClass;
  6. import beans.itemgroup.Itemgroup;
  7. import beans.itemprice.ItemPrice;
  8. import com.alibaba.fastjson.JSON;
  9. import com.alibaba.fastjson.JSONArray;
  10. import com.alibaba.fastjson.JSONObject;
  11. import common.Controller;
  12. import common.YosException;
  13. import common.annotation.API;
  14. import common.annotation.CACHEING;
  15. import common.data.Row;
  16. import common.data.Rows;
  17. import common.data.RowsMap;
  18. import common.data.SQLFactory;
  19. import org.apache.commons.lang.StringUtils;
  20. import restcontroller.R;
  21. import restcontroller.sale.promotion.promotion;
  22. import java.math.BigDecimal;
  23. import java.util.*;
  24. @API(title = "商品组")
  25. public class itemgroup extends Controller {
  26. public itemgroup(JSONObject arg0) throws YosException {
  27. super(arg0);
  28. // TODO Auto-generated constructor stub
  29. }
  30. /**
  31. * * 查询商品组
  32. *
  33. * @return
  34. */
  35. @API(title = "查询", apiversion = R.ID20221219113503.v1.class)
  36. @CACHEING
  37. public String queryItemSaleClasses() throws YosException {
  38. Long istool = content.getLongValue("istool");
  39. Rows itemclassRows = Enterprise.getItemSaleClasses(this, sys_enterpriseid, true, istool);
  40. return getSucReturnObject().setData(itemclassRows).toString();
  41. }
  42. /**
  43. * * 查询商品组
  44. *
  45. * @return
  46. */
  47. @API(title = "查询", apiversion = R.ID20220926142203.v1.class)
  48. @CACHEING
  49. public String queryItemgroup() throws YosException {
  50. Long istool = content.getLongValue("istool");
  51. //Rows itemclassRows = Enterprise.getItemSaleClasses(this, sys_enterpriseid, true, istool);
  52. if (content.containsKey("sys_enterpriseid")) {
  53. sys_enterpriseid = content.getLongValue("sys_enterpriseid");
  54. }
  55. /*
  56. * * 过滤条件设置
  57. */
  58. String where = " 1=1 ";
  59. String where1 = "";
  60. String itemclasssql = "select itemclassid from plm_itemclass where siteid='" + siteid + "'";
  61. if (sys_enterpriseid > 0) {
  62. Row enterpriseRow = Enterprise.getEnterprise(this, sys_enterpriseid);
  63. if (!enterpriseRow.isEmpty()) {
  64. //企业营销类别
  65. boolean saleclassauth = enterpriseRow.getBoolean("saleclassauth");
  66. if (saleclassauth) {
  67. itemclasssql = "select itemclassid from plm_itemclass where siteid='" + siteid + "' and itemclassid in ( SELECT itemclassid from sys_enterprise_saleclass WHERE sys_enterpriseid = " + sys_enterpriseid + " and siteid='" + siteid + "')";
  68. }
  69. //企业领域
  70. Rows tradefieldrows = dbConnect.runSqlQuery("SELECT tradefield from sys_enterprise_tradefield WHERE sys_enterpriseid =" + sys_enterpriseid + " and siteid ='" + siteid + "'");
  71. if (!tradefieldrows.isEmpty()) {
  72. for (Row row : tradefieldrows) {
  73. where1 = where1 + " (t1.tradefield like'%" + row.getString("tradefield") + "%') or ";
  74. }
  75. } else {
  76. where1 = where1 + " 1=2 ";
  77. }
  78. } else {
  79. where1 = " 1=2 ";
  80. }
  81. } else {
  82. where1 = " 1=1 ";
  83. }
  84. if (where1.contains("or")) {
  85. where1 = where1.substring(0, where1.lastIndexOf("or"));
  86. }
  87. Rows itemclassRows = dbConnect.runSqlQuery(itemclasssql);
  88. ArrayList<Long> itemclassList = new ArrayList<Long>();
  89. for (Row row : itemclassRows) {
  90. //System.out.println(row.getLong("itemclassid"));
  91. itemclassList.add(row.getLong("itemclassid"));
  92. itemclassList.addAll(ItemClass.getSubItemClassIds(this, row.getLong("itemclassid")));
  93. }
  94. SQLFactory factorygroupid = new SQLFactory(this, "查询授权范围内的商品组商品");
  95. factorygroupid.addParameter("siteid", siteid);
  96. if (content.containsKey("where")) {
  97. JSONObject whereObject = content.getJSONObject("where");
  98. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  99. where = where + " and (t1.groupname like'%" + whereObject.getString("condition")
  100. + "%' or t1.groupnum like'%" + whereObject.getString("condition")
  101. + "%' or exists(select 1 from sa_itemgroupmx s1 left join plm_item s2 on s1.itemid=s2.itemid and s1.siteid=s2.siteid where (s2.itemname like '%"
  102. + whereObject.getString("condition") + "%' or s2.itemno like '%" + whereObject.getString("condition")
  103. + "%' or s2.standards like '%" + whereObject.getString("condition")
  104. + "%' or s2.spec like '%" + whereObject.getString("condition")
  105. + "%' or s2.byname like '%" + whereObject.getString("condition")
  106. + "%' or s2.model like '%" + whereObject.getString("condition")
  107. + "%') and s1.sa_itemgroupid=t1.sa_itemgroupid) ) ";
  108. }
  109. if (whereObject.containsKey("tradefield") && !"".equals(whereObject.getString("tradefield"))) {
  110. where = where + " and (t1.tradefield like'%" + whereObject.getString("tradefield") + "%') ";
  111. }
  112. // else {
  113. // if (sys_enterpriseid > 0) {
  114. // where = where + " and (t1.tradefield in (SELECT tradefield from sys_enterprise_tradefield WHERE sys_enterpriseid = " + sys_enterpriseid + " and siteid='" + siteid + "') ) ";
  115. // }
  116. // }
  117. if (whereObject.containsKey("standards") && !"".equals(whereObject.getString("standards"))) {
  118. where = where
  119. + " and exists(select 1 from sa_itemgroupmx s1 left join plm_item s2 on s1.itemid=s2.itemid and s1.siteid=s2.siteid where s2.standards='"
  120. + whereObject.getString("standards") + "' and s1.sa_itemgroupid=t1.sa_itemgroupid) ";
  121. }
  122. if (whereObject.containsKey("itemclassid") && !"".equals(whereObject.getString("itemclassid"))) {
  123. ArrayList<Long> list = ItemClass.getSubItemClassIds(this, whereObject.getLong("itemclassid"));
  124. list.add(whereObject.getLong("itemclassid"));
  125. ArrayList<Long> listNew = new ArrayList<>();
  126. listNew.add((long) 0);
  127. for (long itemclassid : list) {
  128. if (itemclassList.contains(itemclassid)) {
  129. listNew.add(itemclassid);
  130. }
  131. }
  132. factorygroupid.addParameter_in("itemclassid", listNew);
  133. } else {
  134. factorygroupid.addParameter_in("itemclassid",
  135. itemclassList);
  136. }
  137. } else {
  138. factorygroupid.addParameter_in("itemclassid",
  139. itemclassList);
  140. }
  141. JSONArray brandids = content.getJSONArray("brandids");
  142. if (brandids.isEmpty()) {
  143. Rows rows;
  144. if (sys_enterpriseid > 0) {
  145. rows = Enterprise.getBrands(this, sys_enterpriseid);
  146. } else {
  147. rows = dbConnect.runSqlQuery("select sa_brandid from sa_brand where siteid='" + siteid + "'");
  148. }
  149. if (!rows.isEmpty()) {
  150. for (Row row : rows) {
  151. brandids.add(row.getLong("sa_brandid"));
  152. }
  153. } else {
  154. brandids.add(0);
  155. }
  156. }
  157. factorygroupid.addParameter("siteid", siteid);
  158. Enterprise.EnterpriseGrade enterpriseGrade = Enterprise.getEnterpriseGrade(this, sys_enterpriseid);
  159. if (enterpriseGrade != null) {
  160. factorygroupid.addParameter("pricegrade", enterpriseGrade.getPricegrade());
  161. }else {
  162. Rows siteParameterRows =dbConnect.runSqlQuery("select defaultlevelprice from sys_site_parameter where siteid='"+siteid+"'");
  163. if(!siteParameterRows.isEmpty()){
  164. if(StringUtils.isBlank(siteParameterRows.get(0).getString("defaultlevelprice"))){
  165. factorygroupid.addParameter("pricegrade", "1");
  166. }else{
  167. factorygroupid.addParameter("pricegrade", siteParameterRows.get(0).getString("defaultlevelprice"));
  168. }
  169. }else{
  170. factorygroupid.addParameter("pricegrade", "1");
  171. }
  172. }
  173. Rows rowsgroupids = dbConnect.runSqlQuery(factorygroupid.getSQL());
  174. RowsMap itemgroupRowMap = rowsgroupids.toRowsMap("sa_itemgroupid");
  175. /*
  176. * SQL查询参数设置并查询
  177. */
  178. SQLFactory factory = new SQLFactory(this, "商品组列表查询", pageSize, pageNumber, pageSorting);
  179. factory.addParameter("siteid", siteid);
  180. factory.addParameter_in("sa_brandid", brandids.toArray());
  181. factory.addParameter_in("sa_itemgroupids", rowsgroupids.toArrayList("sa_itemgroupid", new ArrayList<Long>()));
  182. factory.addParameter_SQL("where", where);
  183. factory.addParameter_SQL("where1", where1);
  184. String sql = factory.getSQL();
  185. //System.out.println(sql);
  186. Rows rows = dbConnect.runSqlQuery(sql);
  187. ArrayList<Long> itemgroupids = rows.toArrayList("sa_itemgroupid", new ArrayList<Long>());
  188. RowsMap itemgroupScemeRowsMap = Itemgroup.getItemgroupScemeid(this, itemgroupids);
  189. for (Row row2 : rows) {
  190. long sa_itemgroupid = row2.getLong("sa_itemgroupid");
  191. ArrayList<String> list = DataTag.queryTag(this, "sa_itemgroup", sa_itemgroupid, false);
  192. row2.put("tag1", JSONArray.parseArray(JSON.toJSONString(list)));
  193. // HashMap<Long, ItemPrice> ItemPriceList = ItemPrice.getItemGroupPrice(this, sys_enterpriseid,
  194. // row2.getLong("sa_itemgroupid"));
  195. // BigDecimal max = new BigDecimal(0);
  196. // BigDecimal min = ((ItemPrice) ItemPriceList.values().toArray()[0]).getPrice();
  197. // for (ItemPrice itemPrice : ItemPriceList.values()) {
  198. // BigDecimal itemprice = itemPrice.getPrice();
  199. // if (itemprice.compareTo(max) >0) {
  200. // max = itemprice;
  201. // }
  202. // if (itemprice.compareTo(min) <0) {
  203. // min = itemprice;
  204. // }
  205. // }
  206. Rows rows1 = itemgroupRowMap.get(String.valueOf(sa_itemgroupid));
  207. if (rows1.isEmpty()) {
  208. row2.put("maxprice", 0);
  209. row2.put("minprice", 0);
  210. } else {
  211. row2.put("maxprice", rows1.get(0).getBigDecimal("maxprice"));
  212. row2.put("minprice", rows1.get(0).getBigDecimal("minprice"));
  213. }
  214. Long id = sa_itemgroupid;
  215. if (itemgroupScemeRowsMap.get(id.toString()).isNotEmpty()) {
  216. if (itemgroupScemeRowsMap.get(id.toString()).get(0).getLong("sa_customschemeid") > 0) {
  217. row2.put("isscheme", true);
  218. } else {
  219. row2.put("isscheme", false);
  220. }
  221. } else {
  222. row2.put("isscheme", false);
  223. }
  224. }
  225. ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
  226. /**
  227. * 查询商品明细
  228. */
  229. SQLFactory sqlFactory = new SQLFactory(this, "查询商品列表");
  230. sqlFactory.addParameter_in("itemids", ids);
  231. sqlFactory.addParameter("siteid", siteid);
  232. sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
  233. Rows itemrows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  234. for (Row row : itemrows) {
  235. ItemPrice itemPrice = ItemPrice.getItemPrice(this, sys_enterpriseid, row.getLong("itemid"));
  236. row.put("oldprice", itemPrice.getPrice());
  237. if (sys_enterpriseid > 0 || (usertype == 21 || usertype == 22)) {
  238. row.put("gradeprice", itemPrice.getContractprice());
  239. } else {
  240. row.put("gradeprice", itemPrice.getMarketprice());
  241. }
  242. }
  243. RowsMap itemRowsMap = itemrows.toRowsMap("itemid");
  244. //默认商品图片
  245. Rows defaultImageRows = Item.getItemdefaultImage(this);
  246. // 封面cover
  247. RowsMap coverRowsMap = getAttachmentUrl("plm_item", ids, "cover");
  248. // 附件
  249. RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
  250. // 附件
  251. RowsMap itemgroupRowsMap = getAttachmentUrl("sa_itemgroup", itemgroupids);
  252. Rows rowsitemclass = dbConnect.runSqlQuery(
  253. " select t7.itemclassname,t6.itemid,t8.brandname,t7.itemclassfullname from sa_itemsaleclass t6 inner JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='"
  254. + siteid + "'");
  255. RowsMap itemclassRowsMap = rowsitemclass.toRowsMap("itemid");
  256. for (Row row : rows) {
  257. Rows itemRows = itemRowsMap.get(row.getString("itemid"));
  258. row.put("item", itemRows);
  259. Rows coverRows = coverRowsMap.get(row.getString("itemid"));
  260. if (coverRows.isEmpty()) {
  261. if (!defaultImageRows.isEmpty()) {
  262. row.put("cover", defaultImageRows.get(0).getString("url"));
  263. } else {
  264. row.put("cover", "");
  265. }
  266. } else {
  267. row.put("cover", coverRows.get(0).getString("url"));
  268. }
  269. if ((itemgroupRowsMap.getOrDefault(row.getString("sa_itemgroupid"), new Rows())).isNotEmpty()) {
  270. row.put("attinfos", itemgroupRowsMap.getOrDefault(row.getString("sa_itemgroupid"), new Rows()));
  271. } else {
  272. if ((attRowsMap.getOrDefault(row.getString("itemid"), new Rows())).isEmpty()) {
  273. row.put("attinfos", defaultImageRows);
  274. } else {
  275. row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
  276. }
  277. }
  278. row.put("itemclass", itemclassRowsMap.get(row.getString("itemid")));
  279. }
  280. return getSucReturnObject().setData(rows).toString();
  281. }
  282. @API(title = "商品组详情", apiversion = R.ID20220926142303.v1.class)
  283. public String queryItemgroupMain() throws YosException {
  284. Long sa_itemgroupid = content.getLong("sa_itemgroupid");
  285. SQLFactory sqlFactory = new SQLFactory(this, "商品组详情查询");
  286. sqlFactory.addParameter("sa_itemgroupid", sa_itemgroupid);
  287. Rows rows = dbConnect.runSqlQuery(sqlFactory);
  288. Rows rowsitemclass = dbConnect.runSqlQuery(
  289. " select t7.itemclassname,t6.itemid,t8.brandname from sa_itemsaleclass t6 inner JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='"
  290. + siteid + "'");
  291. RowsMap itemclassRowsMap = rowsitemclass.toRowsMap("itemid");
  292. if (!rows.isEmpty()) {
  293. ArrayList<String> list = DataTag.queryTag(this, "sa_itemgroup", rows.get(0).getLong("sa_itemgroupid"),
  294. false);
  295. rows.get(0).put("tag1", JSONArray.parseArray(JSON.toJSONString(list)));
  296. rows.get(0).put("itemclass", itemclassRowsMap.get(rows.get(0).getString("itemid")));
  297. }
  298. return getSucReturnObject().setData(rows.size() > 0 ? rows.get(0) : new Row()).toString();
  299. }
  300. @API(title = "商品组商品明细列表", apiversion = R.ID20220926142403.v1.class)
  301. @CACHEING
  302. public String queryItemgroupMxList() throws YosException {
  303. if (content.containsKey("sys_enterpriseid")) {
  304. sys_enterpriseid = content.getLongValue("sys_enterpriseid");
  305. }
  306. /*
  307. * 过滤条件设置
  308. */
  309. String where = " 1=1 ";
  310. if (content.containsKey("where")) {
  311. JSONObject whereObject = content.getJSONObject("where");
  312. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  313. where = where + "and t2.itemname like'%" + whereObject.getString("condition") + "%'";
  314. }
  315. }
  316. Long sa_itemgroupid = content.getLong("sa_itemgroupid");
  317. // String hrid = content.getString("hrid");
  318. SQLFactory sqlFactory = new SQLFactory(this, "商品组商品明细查询", pageSize, pageNumber, pageSorting);
  319. sqlFactory.addParameter_SQL("where", where);
  320. sqlFactory.addParameter("sa_itemgroupid", sa_itemgroupid);
  321. sqlFactory.addParameter("siteid", siteid);
  322. Rows rows = dbConnect.runSqlQuery(sqlFactory);
  323. ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
  324. //默认商品图片
  325. Rows defaultImageRows = Item.getItemdefaultImage(this);
  326. // 封面cover
  327. RowsMap coverRowsMap = getAttachmentUrl("plm_item", ids, "cover");
  328. // 附件
  329. RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
  330. Rows technicalinforows = dbConnect.runSqlQuery("select plm_technicalinfoid,itemid from plm_technicalinfo_item");
  331. RowsMap technicalinfoRowsMap = technicalinforows.toRowsMap("itemid");
  332. Rows technicalinforows1 = dbConnect.runSqlQuery("select plm_technicalinfoid from plm_technicalinfo");
  333. ArrayList<Long> plm_technicalinfoids = technicalinforows1.toArrayList("plm_technicalinfoid", new ArrayList<>());
  334. // 产品技术资料附件
  335. RowsMap plm_technicalinfoRowsMap = getAttachmentUrl("plm_technicalinfo", plm_technicalinfoids);
  336. // 商品领域
  337. RowsMap tradefieldRowsMap = beans.Item.Item.getTradefieldRowsMap(this, ids);
  338. Rows rowsitemclass = dbConnect.runSqlQuery(
  339. " select t7.itemclassname,t6.itemid,t8.brandname from sa_itemsaleclass t6 LEFT JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='"
  340. + siteid + "'");
  341. RowsMap itemclassRowsMap = rowsitemclass.toRowsMap("itemid");
  342. RowsMap itemextendRowsMap = dbConnect.runSqlQuery("select itemid,material,device,prodline,specalnote,pressure,connection,valveplatematerial,actuatortype,actuatorbrand,butterflyplatedrive from plm_itemextend where siteid='" + siteid + "'").toRowsMap("itemid");
  343. SQLFactory priceSqlFactory = new SQLFactory(this, "查询商品原价");
  344. priceSqlFactory.addParameter("sa_itemgroupid", sa_itemgroupid);
  345. priceSqlFactory.addParameter("siteid", siteid);
  346. Rows siteParameterRows =dbConnect.runSqlQuery("select defaultlevelprice from sys_site_parameter where siteid='"+siteid+"'");
  347. if(!siteParameterRows.isEmpty()){
  348. if(StringUtils.isBlank(siteParameterRows.get(0).getString("defaultlevelprice"))){
  349. priceSqlFactory.addParameter("pricegrade", "1");
  350. }else{
  351. priceSqlFactory.addParameter("pricegrade", siteParameterRows.get(0).getString("defaultlevelprice"));
  352. }
  353. }else{
  354. priceSqlFactory.addParameter("pricegrade", "1");
  355. }
  356. Rows pricerows = dbConnect.runSqlQuery(priceSqlFactory);
  357. RowsMap pricerowsMap = pricerows.toRowsMap("itemid");
  358. for (Row row : rows) {
  359. ItemPrice itemPrice = ItemPrice.getItemPrice(this, sys_enterpriseid, row.getLong("itemid"));
  360. row.put("oldprice", itemPrice.getMarketprice());
  361. if (sys_enterpriseid > 0 || (usertype == 21 || usertype == 22)) {
  362. row.put("gradeprice", itemPrice.getContractprice());
  363. } else {
  364. if(pricerowsMap.containsKey(row.getString("itemid"))){
  365. if(pricerowsMap.get(row.getString("itemid")).isNotEmpty()){
  366. row.put("gradeprice", pricerowsMap.get(row.getString("itemid")).get(0).getBigDecimal("price"));
  367. }else{
  368. row.put("gradeprice",0);
  369. }
  370. }else {
  371. row.put("gradeprice", 0);
  372. }
  373. }
  374. Rows jsonArray = new Rows();
  375. Rows coverRows = coverRowsMap.get(row.getString("itemid"));
  376. if (coverRows.isEmpty()) {
  377. row.put("cover", "");
  378. } else {
  379. row.put("cover", coverRows.get(0).getString("url"));
  380. }
  381. if ((attRowsMap.getOrDefault(row.getString("itemid"), new Rows())).isEmpty()) {
  382. row.put("attinfos", defaultImageRows);
  383. } else {
  384. row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
  385. }
  386. //row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
  387. row.put("itemclass", itemclassRowsMap.get(row.getString("itemid")));
  388. Rows technicalinforowsforitem = technicalinfoRowsMap.get(row.getString("itemid"));
  389. for (Row row2 : technicalinforowsforitem) {
  390. jsonArray.addAll(plm_technicalinfoRowsMap.get(row2.getString("plm_technicalinfoid")));
  391. }
  392. row.put("technicalinfo", jsonArray);
  393. row.put("tradefield", tradefieldRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
  394. if (itemextendRowsMap.containsKey(row.getString("itemid"))) {
  395. row.put("itemextend", itemextendRowsMap.get(row.getString("itemid")));
  396. } else {
  397. row.put("itemextend", new Rows());
  398. }
  399. }
  400. return getSucReturnObject().setData(rows).toString();
  401. }
  402. @API(title = "商品组列表", apiversion = R.ID20221223165503.v1.class)
  403. @CACHEING
  404. public String querymx() throws YosException {
  405. Set<String> listParmBlank = new LinkedHashSet<String>();
  406. Set<String> listParmNotBlank = new LinkedHashSet<String>();
  407. Set<String> firstcolorList = new LinkedHashSet();
  408. Set<String> firstspecList = new LinkedHashSet();
  409. Set<String> firstmaterialList = new LinkedHashSet();
  410. Set<String> firstcheekList = new LinkedHashSet();
  411. Set<parm> colorList = new LinkedHashSet();
  412. Set<parm> specList = new LinkedHashSet();
  413. Set<parm> materialList = new LinkedHashSet();
  414. Set<parm> cheekList = new LinkedHashSet();
  415. String color = content.getStringValue("color");
  416. String spec = content.getStringValue("spec");
  417. String material = content.getStringValue("material");
  418. String cheek = content.getStringValue("cheek");
  419. /**
  420. * SQL商品组明细查询参数设置并查询
  421. */
  422. Rows rows = null;
  423. SQLFactory factory = new SQLFactory(this, "商品组明细查询");
  424. factory.addParameter("sa_itemgroupid", content.getString("sa_itemgroupid"));
  425. factory.addParameter("siteid", siteid);
  426. String where1 = " 1=1 ";
  427. Rows tradefieldRows = dbConnect.runSqlQuery("SELECT DISTINCT t1.tradefield from sys_enterprise_tradefield t1 WHERE t1.sys_enterpriseid = " + sys_enterpriseid + " and t1.siteid='" + siteid + "'");
  428. if (!tradefieldRows.isEmpty()) {
  429. for (Row row : tradefieldRows) {
  430. where1 = where1 + " or t4.tradefield like '%" + row.getString("tradefield") + "%' ";
  431. }
  432. }
  433. factory.addParameter_SQL("where1", where1);
  434. Rows customschemeItems = dbConnect.runSqlQuery("select * from (select distinct value,description,isonlydisplay,sequence from sa_customscheme_items where sa_customschemeid in(select t2.sa_customschemeid from sa_itemgroupmx t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.siteid='" + siteid + "' and t1.sa_itemgroupid=" + content.getString("sa_itemgroupid") + "))t order by t.sequence asc");
  435. Rows customschemeItems1 = dbConnect.runSqlQuery("select * from (select distinct value,description,isonlydisplay,sequence from sa_customscheme_items where isonlydisplay=1 and sa_customschemeid in(select t2.sa_customschemeid from sa_itemgroupmx t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.siteid='" + siteid + "' and t1.sa_itemgroupid=" + content.getString("sa_itemgroupid") + "))t order by t.sequence asc");
  436. RowsMap customschemeItems1RowsMap = customschemeItems1.toRowsMap("value");
  437. if (!customschemeItems.isEmpty()) {
  438. for (Row row : customschemeItems) {
  439. if (StringUtils.isNotBlank(row.getString("value"))) {
  440. if (StringUtils.isNotBlank(content.getString(row.getString("value")))) {
  441. listParmNotBlank.add(row.getString("value"));
  442. } else {
  443. listParmBlank.add(row.getString("value"));
  444. }
  445. }
  446. }
  447. }
  448. Set<String> listAll = new LinkedHashSet<String>();
  449. listAll.addAll(listParmBlank);
  450. listAll.addAll(listParmNotBlank);
  451. factory.addParameter_SQL("where", "1=1");
  452. rows = dbConnect.runSqlQuery(factory.getSQL());
  453. Rows rowsall=rows;
  454. for (Row row : rows) {
  455. for (String value : listAll) {
  456. if (value.equals("color")) {
  457. firstcolorList.add(row.getString("color"));
  458. } else if (value.equals("spec")) {
  459. firstspecList.add(row.getString("spec"));
  460. } else if (value.equals("material")) {
  461. firstmaterialList.add(row.getString("material"));
  462. } else if (value.equals("cheek")) {
  463. firstcheekList.add(row.getString("cheek"));
  464. }
  465. }
  466. }
  467. JSONArray colormap = new JSONArray();
  468. JSONArray specmap = new JSONArray();
  469. JSONArray materialmap = new JSONArray();
  470. JSONArray cheekmap = new JSONArray();
  471. if (listParmNotBlank == null || listParmNotBlank.size() == 0) {
  472. factory.addParameter_SQL("where", "1=1");
  473. for (Row row : rows) {
  474. for (String value : listParmBlank) {
  475. if (value.equals("color")) {
  476. JSONObject jsonObject = new JSONObject();
  477. jsonObject.put("parm", row.getString("color"));
  478. jsonObject.put("flag", true);
  479. colormap.add(jsonObject);
  480. } else if (value.equals("spec")) {
  481. JSONObject jsonObject = new JSONObject();
  482. jsonObject.put("parm", row.getString("spec"));
  483. jsonObject.put("flag", true);
  484. specmap.add(jsonObject);
  485. } else if (value.equals("material")) {
  486. JSONObject jsonObject = new JSONObject();
  487. jsonObject.put("parm", row.getString("material"));
  488. jsonObject.put("flag", true);
  489. materialmap.add(jsonObject);
  490. } else if (value.equals("cheek")) {
  491. JSONObject jsonObject = new JSONObject();
  492. jsonObject.put("parm", row.getString("cheek"));
  493. jsonObject.put("flag", true);
  494. cheekmap.add(jsonObject);
  495. }
  496. }
  497. }
  498. } else if (listParmBlank == null || listParmBlank.size() == 0) {
  499. // for (Row row : rows) {
  500. // for (String value : listParmNotBlank) {
  501. // if (value.equals("color")) {
  502. // JSONObject jsonObject =new JSONObject();
  503. // jsonObject.put("parm", row.getString("color"));
  504. // jsonObject.put("flag", true);
  505. // colormap.add(jsonObject);
  506. // } else if (value.equals("spec")) {
  507. // JSONObject jsonObject =new JSONObject();
  508. // jsonObject.put("parm", row.getString("spec"));
  509. // jsonObject.put("flag", true);
  510. // specmap.add(jsonObject);
  511. // } else if (value.equals("material")) {
  512. // JSONObject jsonObject =new JSONObject();
  513. // jsonObject.put("parm", row.getString("material"));
  514. // jsonObject.put("flag", true);
  515. // materialmap.add(jsonObject);
  516. // } else if (value.equals("cheek")) {
  517. // JSONObject jsonObject =new JSONObject();
  518. // jsonObject.put("parm", row.getString("cheek"));
  519. // jsonObject.put("flag", true);
  520. // cheekmap.add(jsonObject);
  521. // }
  522. //
  523. // }
  524. // }
  525. String colorwhere = "";
  526. String specwhere = "";
  527. String materialwhere = "";
  528. String cheekwhere = "";
  529. for (String value : listParmNotBlank) {
  530. if (value.equals("color")) {
  531. colorwhere = " and " + value + "='" + content.getString(value) + "' ";
  532. } else if (value.equals("spec")) {
  533. specwhere = " and " + value + "='" + content.getString(value) + "' ";
  534. } else if (value.equals("material")) {
  535. materialwhere = " and " + value + "='" + content.getString(value) + "' ";
  536. } else if (value.equals("cheek")) {
  537. cheekwhere = " and " + value + "='" + content.getString(value) + "' ";
  538. }
  539. }
  540. for (String value : listAll) {
  541. if (value.equals("color")) {
  542. factory.addParameter_SQL("where", " 1=1 " + specwhere + materialwhere + cheekwhere);
  543. //System.out.println(" 1=1 " + specwhere + materialwhere + cheekwhere);
  544. rows = dbConnect.runSqlQuery(factory.getSQL());
  545. if (!rows.isEmpty()) {
  546. for (Row row : rows) {
  547. JSONObject jsonObject = new JSONObject();
  548. jsonObject.put("parm", row.getString("color"));
  549. jsonObject.put("flag", true);
  550. colormap.add(jsonObject);
  551. }
  552. }
  553. } else if (value.equals("spec")) {
  554. factory.addParameter_SQL("where", " 1=1 " + colorwhere + materialwhere + cheekwhere);
  555. rows = dbConnect.runSqlQuery(factory.getSQL());
  556. if (!rows.isEmpty()) {
  557. for (Row row : rows) {
  558. JSONObject jsonObject = new JSONObject();
  559. jsonObject.put("parm", row.getString("spec"));
  560. jsonObject.put("flag", true);
  561. specmap.add(jsonObject);
  562. }
  563. }
  564. } else if (value.equals("material")) {
  565. factory.addParameter_SQL("where", " 1=1 " + colorwhere + specwhere + cheekwhere);
  566. rows = dbConnect.runSqlQuery(factory.getSQL());
  567. if (!rows.isEmpty()) {
  568. for (Row row : rows) {
  569. JSONObject jsonObject = new JSONObject();
  570. jsonObject.put("parm", row.getString("material"));
  571. jsonObject.put("flag", true);
  572. materialmap.add(jsonObject);
  573. }
  574. }
  575. } else if (value.equals("cheek")) {
  576. factory.addParameter_SQL("where", " 1=1 " + colorwhere + specwhere + materialwhere);
  577. rows = dbConnect.runSqlQuery(factory.getSQL());
  578. if (!rows.isEmpty()) {
  579. for (Row row : rows) {
  580. JSONObject jsonObject = new JSONObject();
  581. jsonObject.put("parm", row.getString("cheek"));
  582. jsonObject.put("flag", true);
  583. cheekmap.add(jsonObject);
  584. }
  585. }
  586. }
  587. }
  588. for (String firstcolor : firstcolorList) {
  589. boolean isexistParm = false;
  590. for (Object object : colormap) {
  591. JSONObject jsonObject = (JSONObject) object;
  592. if (jsonObject.getString("parm").equals(firstcolor)) {
  593. isexistParm = true;
  594. break;
  595. }
  596. }
  597. if (!isexistParm) {
  598. JSONObject jsonObject = new JSONObject();
  599. jsonObject.put("parm", firstcolor);
  600. jsonObject.put("flag", false);
  601. colormap.add(jsonObject);
  602. }
  603. }
  604. for (String firstspec : firstspecList) {
  605. boolean isexistParm = false;
  606. for (Object object : specmap) {
  607. JSONObject jsonObject = (JSONObject) object;
  608. if (jsonObject.getString("parm").equals(firstspec)) {
  609. isexistParm = true;
  610. break;
  611. }
  612. }
  613. if (!isexistParm) {
  614. JSONObject jsonObject = new JSONObject();
  615. jsonObject.put("parm", firstspec);
  616. jsonObject.put("flag", false);
  617. specmap.add(jsonObject);
  618. }
  619. }
  620. for (String firstmaterial : firstmaterialList) {
  621. boolean isexistParm = false;
  622. for (Object object : materialmap) {
  623. JSONObject jsonObject = (JSONObject) object;
  624. if (jsonObject.getString("parm").equals(firstmaterial)) {
  625. isexistParm = true;
  626. break;
  627. }
  628. }
  629. if (!isexistParm) {
  630. JSONObject jsonObject = new JSONObject();
  631. jsonObject.put("parm", firstmaterial);
  632. jsonObject.put("flag", false);
  633. materialmap.add(jsonObject);
  634. }
  635. }
  636. for (String firstcheek : firstcheekList) {
  637. boolean isexistParm = false;
  638. for (Object object : cheekmap) {
  639. JSONObject jsonObject = (JSONObject) object;
  640. if (jsonObject.getString("parm").equals(firstcheek)) {
  641. isexistParm = true;
  642. break;
  643. }
  644. }
  645. if (!isexistParm) {
  646. JSONObject jsonObject = new JSONObject();
  647. jsonObject.put("parm", firstcheek);
  648. jsonObject.put("flag", false);
  649. cheekmap.add(jsonObject);
  650. }
  651. }
  652. factory.addParameter_SQL("where", " 1=1 " + colorwhere + specwhere + materialwhere + cheekwhere);
  653. } else if(listParmNotBlank.size()==1){
  654. String where = " 1=1 ";
  655. for (String value : listParmNotBlank) {
  656. if (value.equals("color")) {
  657. JSONObject jsonObject = new JSONObject();
  658. jsonObject.put("parm", content.getString("color"));
  659. jsonObject.put("flag", true);
  660. colormap.add(jsonObject);
  661. // for (String firstcolor : firstcolorList) {
  662. // JSONObject jsonObject1 =new JSONObject();
  663. // if (!firstcolor.equals(content.getString("color"))) {
  664. // jsonObject1.put("parm",firstcolor);
  665. // jsonObject1.put("flag", true);
  666. // colormap.add(jsonObject1);
  667. // }
  668. // }
  669. } else if (value.equals("spec")) {
  670. JSONObject jsonObject = new JSONObject();
  671. jsonObject.put("parm", content.getString("spec"));
  672. jsonObject.put("flag", true);
  673. specmap.add(jsonObject);
  674. // for (String firstspec : firstspecList) {
  675. // JSONObject jsonObject1 =new JSONObject();
  676. // if (!firstspec.equals(content.getString("spec"))) {
  677. // jsonObject1.put("parm",firstspec);
  678. // jsonObject1.put("flag", true);
  679. // specmap.add(jsonObject1);
  680. // }
  681. // }
  682. } else if (value.equals("material")) {
  683. JSONObject jsonObject = new JSONObject();
  684. jsonObject.put("parm", content.getString("material"));
  685. jsonObject.put("flag", true);
  686. materialmap.add(jsonObject);
  687. // for (String firstmaterial : firstmaterialList) {
  688. // JSONObject jsonObject1 =new JSONObject();
  689. // if (!firstmaterial.equals(content.getString("material"))) {
  690. // jsonObject1.put("parm",firstmaterial);
  691. // jsonObject1.put("flag", true);
  692. // materialmap.add(jsonObject1);
  693. // }
  694. // }
  695. } else if (value.equals("cheek")) {
  696. JSONObject jsonObject = new JSONObject();
  697. jsonObject.put("parm", content.getString("cheek"));
  698. jsonObject.put("flag", true);
  699. cheekmap.add(jsonObject);
  700. // for (String firstcheek : firstcheekList) {
  701. // JSONObject jsonObject1 =new JSONObject();
  702. // if (!firstcheek.equals(content.getString("cheek"))) {
  703. // jsonObject1.put("parm", firstcheek);
  704. // jsonObject1.put("flag", true);
  705. // cheekmap.add(jsonObject1);
  706. // }
  707. // }
  708. }
  709. where = where + " and " + value + "='" + content.getString(value) + "' ";
  710. }
  711. factory.addParameter_SQL("where", where);
  712. for (String value : listAll) {
  713. if (value.equals("color")) {
  714. rows = dbConnect.runSqlQuery(factory.getSQL());
  715. if (!rows.isEmpty()) {
  716. for (Row row : rows) {
  717. JSONObject jsonObject = new JSONObject();
  718. jsonObject.put("parm", row.getString("color"));
  719. jsonObject.put("flag", true);
  720. colormap.add(jsonObject);
  721. }
  722. }
  723. } else if (value.equals("spec")) {
  724. rows = dbConnect.runSqlQuery(factory.getSQL());
  725. if (!rows.isEmpty()) {
  726. for (Row row : rows) {
  727. JSONObject jsonObject = new JSONObject();
  728. jsonObject.put("parm", row.getString("spec"));
  729. jsonObject.put("flag", true);
  730. specmap.add(jsonObject);
  731. }
  732. }
  733. } else if (value.equals("material")) {
  734. rows = dbConnect.runSqlQuery(factory.getSQL());
  735. if (!rows.isEmpty()) {
  736. for (Row row : rows) {
  737. JSONObject jsonObject = new JSONObject();
  738. jsonObject.put("parm", row.getString("material"));
  739. jsonObject.put("flag", true);
  740. materialmap.add(jsonObject);
  741. }
  742. }
  743. } else if (value.equals("cheek")) {
  744. rows = dbConnect.runSqlQuery(factory.getSQL());
  745. if (!rows.isEmpty()) {
  746. for (Row row : rows) {
  747. JSONObject jsonObject = new JSONObject();
  748. jsonObject.put("parm", row.getString("cheek"));
  749. jsonObject.put("flag", true);
  750. cheekmap.add(jsonObject);
  751. }
  752. }
  753. }
  754. }
  755. List<String> list = new ArrayList<>(listParmNotBlank);
  756. for (String firstcolor : firstcolorList) {
  757. boolean isexistParm = false;
  758. for (Object object : colormap) {
  759. JSONObject jsonObject = (JSONObject) object;
  760. if (jsonObject.getString("parm").equals(firstcolor)) {
  761. isexistParm = true;
  762. break;
  763. }
  764. }
  765. if (!isexistParm) {
  766. if(list.get(0).equals("color")){
  767. JSONObject jsonObject = new JSONObject();
  768. jsonObject.put("parm", firstcolor);
  769. jsonObject.put("flag", true);
  770. colormap.add(jsonObject);
  771. }else{
  772. JSONObject jsonObject = new JSONObject();
  773. jsonObject.put("parm", firstcolor);
  774. jsonObject.put("flag", false);
  775. colormap.add(jsonObject);
  776. }
  777. }
  778. }
  779. for (String firstspec : firstspecList) {
  780. boolean isexistParm = false;
  781. for (Object object : specmap) {
  782. JSONObject jsonObject = (JSONObject) object;
  783. if (jsonObject.getString("parm").equals(firstspec)) {
  784. isexistParm = true;
  785. break;
  786. }
  787. }
  788. if (!isexistParm) {
  789. if(list.get(0).equals("spec")){
  790. JSONObject jsonObject = new JSONObject();
  791. jsonObject.put("parm", firstspec);
  792. jsonObject.put("flag", true);
  793. specmap.add(jsonObject);
  794. }else{
  795. JSONObject jsonObject = new JSONObject();
  796. jsonObject.put("parm", firstspec);
  797. jsonObject.put("flag", false);
  798. specmap.add(jsonObject);
  799. }
  800. }
  801. }
  802. for (String firstmaterial : firstmaterialList) {
  803. boolean isexistParm = false;
  804. for (Object object : materialmap) {
  805. JSONObject jsonObject = (JSONObject) object;
  806. if (jsonObject.getString("parm").equals(firstmaterial)) {
  807. isexistParm = true;
  808. break;
  809. }
  810. }
  811. if (!isexistParm) {
  812. if(list.get(0).equals("material")){
  813. JSONObject jsonObject = new JSONObject();
  814. jsonObject.put("parm", firstmaterial);
  815. jsonObject.put("flag", true);
  816. materialmap.add(jsonObject);
  817. }else{
  818. JSONObject jsonObject = new JSONObject();
  819. jsonObject.put("parm", firstmaterial);
  820. jsonObject.put("flag", false);
  821. materialmap.add(jsonObject);
  822. }
  823. }
  824. }
  825. for (String firstcheek : firstcheekList) {
  826. boolean isexistParm = false;
  827. for (Object object : cheekmap) {
  828. JSONObject jsonObject = (JSONObject) object;
  829. if (jsonObject.getString("parm").equals(firstcheek)) {
  830. isexistParm = true;
  831. break;
  832. }
  833. }
  834. if (!isexistParm) {
  835. if(list.get(0).equals("cheek")){
  836. JSONObject jsonObject = new JSONObject();
  837. jsonObject.put("parm", firstcheek);
  838. jsonObject.put("flag", true);
  839. cheekmap.add(jsonObject);
  840. }else{
  841. JSONObject jsonObject = new JSONObject();
  842. jsonObject.put("parm", firstcheek);
  843. jsonObject.put("flag", false);
  844. cheekmap.add(jsonObject);
  845. }
  846. }
  847. }
  848. }else {
  849. String where = " 1=1 ";
  850. for (String value : listParmNotBlank) {
  851. if (value.equals("color")) {
  852. JSONObject jsonObject = new JSONObject();
  853. jsonObject.put("parm", content.getString("color"));
  854. jsonObject.put("flag", true);
  855. colormap.add(jsonObject);
  856. // for (String firstcolor : firstcolorList) {
  857. // JSONObject jsonObject1 =new JSONObject();
  858. // if (!firstcolor.equals(content.getString("color"))) {
  859. // jsonObject1.put("parm",firstcolor);
  860. // jsonObject1.put("flag", true);
  861. // colormap.add(jsonObject1);
  862. // }
  863. // }
  864. } else if (value.equals("spec")) {
  865. JSONObject jsonObject = new JSONObject();
  866. jsonObject.put("parm", content.getString("spec"));
  867. jsonObject.put("flag", true);
  868. specmap.add(jsonObject);
  869. // for (String firstspec : firstspecList) {
  870. // JSONObject jsonObject1 =new JSONObject();
  871. // if (!firstspec.equals(content.getString("spec"))) {
  872. // jsonObject1.put("parm",firstspec);
  873. // jsonObject1.put("flag", true);
  874. // specmap.add(jsonObject1);
  875. // }
  876. // }
  877. } else if (value.equals("material")) {
  878. JSONObject jsonObject = new JSONObject();
  879. jsonObject.put("parm", content.getString("material"));
  880. jsonObject.put("flag", true);
  881. materialmap.add(jsonObject);
  882. // for (String firstmaterial : firstmaterialList) {
  883. // JSONObject jsonObject1 =new JSONObject();
  884. // if (!firstmaterial.equals(content.getString("material"))) {
  885. // jsonObject1.put("parm",firstmaterial);
  886. // jsonObject1.put("flag", true);
  887. // materialmap.add(jsonObject1);
  888. // }
  889. // }
  890. } else if (value.equals("cheek")) {
  891. JSONObject jsonObject = new JSONObject();
  892. jsonObject.put("parm", content.getString("cheek"));
  893. jsonObject.put("flag", true);
  894. cheekmap.add(jsonObject);
  895. // for (String firstcheek : firstcheekList) {
  896. // JSONObject jsonObject1 =new JSONObject();
  897. // if (!firstcheek.equals(content.getString("cheek"))) {
  898. // jsonObject1.put("parm", firstcheek);
  899. // jsonObject1.put("flag", true);
  900. // cheekmap.add(jsonObject1);
  901. // }
  902. // }
  903. }
  904. where = where + " and " + value + "='" + content.getString(value) + "' ";
  905. }
  906. factory.addParameter_SQL("where", where);
  907. for (String value : listAll) {
  908. if (value.equals("color")) {
  909. rows = dbConnect.runSqlQuery(factory.getSQL());
  910. if (!rows.isEmpty()) {
  911. for (Row row : rows) {
  912. JSONObject jsonObject = new JSONObject();
  913. jsonObject.put("parm", row.getString("color"));
  914. jsonObject.put("flag", true);
  915. colormap.add(jsonObject);
  916. }
  917. }
  918. } else if (value.equals("spec")) {
  919. rows = dbConnect.runSqlQuery(factory.getSQL());
  920. if (!rows.isEmpty()) {
  921. for (Row row : rows) {
  922. JSONObject jsonObject = new JSONObject();
  923. jsonObject.put("parm", row.getString("spec"));
  924. jsonObject.put("flag", true);
  925. specmap.add(jsonObject);
  926. }
  927. }
  928. } else if (value.equals("material")) {
  929. rows = dbConnect.runSqlQuery(factory.getSQL());
  930. if (!rows.isEmpty()) {
  931. for (Row row : rows) {
  932. JSONObject jsonObject = new JSONObject();
  933. jsonObject.put("parm", row.getString("material"));
  934. jsonObject.put("flag", true);
  935. materialmap.add(jsonObject);
  936. }
  937. }
  938. } else if (value.equals("cheek")) {
  939. rows = dbConnect.runSqlQuery(factory.getSQL());
  940. if (!rows.isEmpty()) {
  941. for (Row row : rows) {
  942. JSONObject jsonObject = new JSONObject();
  943. jsonObject.put("parm", row.getString("cheek"));
  944. jsonObject.put("flag", true);
  945. cheekmap.add(jsonObject);
  946. }
  947. }
  948. }
  949. }
  950. if(customschemeItems1RowsMap.containsKey("color")){
  951. where=" 1=1 ";
  952. for (String value : listParmNotBlank) {
  953. if(!value.equals("color")){
  954. where = where + " and " + value + "='" + content.getString(value) + "' ";
  955. }
  956. }
  957. factory.addParameter_SQL("where", where);
  958. rows = dbConnect.runSqlQuery(factory.getSQL());
  959. if (!rows.isEmpty()) {
  960. for (Row row : rows) {
  961. JSONObject jsonObject = new JSONObject();
  962. jsonObject.put("parm", row.getString("color"));
  963. jsonObject.put("flag", true);
  964. colormap.add(jsonObject);
  965. }
  966. }
  967. for (String firstcolor : firstcolorList) {
  968. boolean isexistParm = false;
  969. for (Object object : colormap) {
  970. JSONObject jsonObject = (JSONObject) object;
  971. if (jsonObject.getString("parm").equals(firstcolor)) {
  972. isexistParm = true;
  973. break;
  974. }
  975. }
  976. if (!isexistParm) {
  977. JSONObject jsonObject = new JSONObject();
  978. jsonObject.put("parm", firstcolor);
  979. jsonObject.put("flag", false);
  980. colormap.add(jsonObject);
  981. }
  982. }
  983. }else{
  984. for (String firstcolor : firstcolorList) {
  985. boolean isexistParm = false;
  986. for (Object object : colormap) {
  987. JSONObject jsonObject = (JSONObject) object;
  988. if (jsonObject.getString("parm").equals(firstcolor)) {
  989. isexistParm = true;
  990. break;
  991. }
  992. }
  993. if (!isexistParm) {
  994. JSONObject jsonObject = new JSONObject();
  995. jsonObject.put("parm", firstcolor);
  996. jsonObject.put("flag", false);
  997. colormap.add(jsonObject);
  998. }
  999. }
  1000. }
  1001. if(customschemeItems1RowsMap.containsKey("spec")){
  1002. where=" 1=1 ";
  1003. for (String value : listParmNotBlank) {
  1004. if(!value.equals("spec")){
  1005. where = where + " and " + value + "='" + content.getString(value) + "' ";
  1006. }
  1007. }
  1008. factory.addParameter_SQL("where", where);
  1009. rows = dbConnect.runSqlQuery(factory.getSQL());
  1010. if (!rows.isEmpty()) {
  1011. for (Row row : rows) {
  1012. JSONObject jsonObject = new JSONObject();
  1013. jsonObject.put("parm", row.getString("spec"));
  1014. jsonObject.put("flag", true);
  1015. colormap.add(jsonObject);
  1016. }
  1017. }
  1018. for (String firstspec : firstspecList) {
  1019. boolean isexistParm = false;
  1020. for (Object object : specmap) {
  1021. JSONObject jsonObject = (JSONObject) object;
  1022. if (jsonObject.getString("parm").equals(firstspec)) {
  1023. isexistParm = true;
  1024. break;
  1025. }
  1026. }
  1027. if (!isexistParm) {
  1028. JSONObject jsonObject = new JSONObject();
  1029. jsonObject.put("parm", firstspec);
  1030. jsonObject.put("flag", false);
  1031. specmap.add(jsonObject);
  1032. }
  1033. }
  1034. }else{
  1035. for (String firstspec : firstspecList) {
  1036. boolean isexistParm = false;
  1037. for (Object object : specmap) {
  1038. JSONObject jsonObject = (JSONObject) object;
  1039. if (jsonObject.getString("parm").equals(firstspec)) {
  1040. isexistParm = true;
  1041. break;
  1042. }
  1043. }
  1044. if (!isexistParm) {
  1045. JSONObject jsonObject = new JSONObject();
  1046. jsonObject.put("parm", firstspec);
  1047. jsonObject.put("flag", false);
  1048. specmap.add(jsonObject);
  1049. }
  1050. }
  1051. }
  1052. if(customschemeItems1RowsMap.containsKey("material")){
  1053. where=" 1=1 ";
  1054. for (String value : listParmNotBlank) {
  1055. if(!value.equals("material")){
  1056. where = where + " and " + value + "='" + content.getString(value) + "' ";
  1057. }
  1058. }
  1059. factory.addParameter_SQL("where", where);
  1060. rows = dbConnect.runSqlQuery(factory.getSQL());
  1061. if (!rows.isEmpty()) {
  1062. for (Row row : rows) {
  1063. JSONObject jsonObject = new JSONObject();
  1064. jsonObject.put("parm", row.getString("material"));
  1065. jsonObject.put("flag", true);
  1066. colormap.add(jsonObject);
  1067. }
  1068. }
  1069. for (String firstmaterial : firstmaterialList) {
  1070. boolean isexistParm = false;
  1071. for (Object object : materialmap) {
  1072. JSONObject jsonObject = (JSONObject) object;
  1073. if (jsonObject.getString("parm").equals(firstmaterial)) {
  1074. isexistParm = true;
  1075. break;
  1076. }
  1077. }
  1078. if (!isexistParm) {
  1079. JSONObject jsonObject = new JSONObject();
  1080. jsonObject.put("parm", firstmaterial);
  1081. jsonObject.put("flag", false);
  1082. materialmap.add(jsonObject);
  1083. }
  1084. }
  1085. }else{
  1086. for (String firstmaterial : firstmaterialList) {
  1087. boolean isexistParm = false;
  1088. for (Object object : materialmap) {
  1089. JSONObject jsonObject = (JSONObject) object;
  1090. if (jsonObject.getString("parm").equals(firstmaterial)) {
  1091. isexistParm = true;
  1092. break;
  1093. }
  1094. }
  1095. if (!isexistParm) {
  1096. JSONObject jsonObject = new JSONObject();
  1097. jsonObject.put("parm", firstmaterial);
  1098. jsonObject.put("flag", false);
  1099. materialmap.add(jsonObject);
  1100. }
  1101. }
  1102. }
  1103. if(customschemeItems1RowsMap.containsKey("cheek")){
  1104. where=" 1=1 ";
  1105. for (String value : listParmNotBlank) {
  1106. if(!value.equals("cheek")){
  1107. where = where + " and " + value + "='" + content.getString(value) + "' ";
  1108. }
  1109. }
  1110. factory.addParameter_SQL("where", where);
  1111. rows = dbConnect.runSqlQuery(factory.getSQL());
  1112. if (!rows.isEmpty()) {
  1113. for (Row row : rows) {
  1114. JSONObject jsonObject = new JSONObject();
  1115. jsonObject.put("parm", row.getString("cheek"));
  1116. jsonObject.put("flag", true);
  1117. colormap.add(jsonObject);
  1118. }
  1119. }
  1120. for (String firstcheek : firstcheekList) {
  1121. boolean isexistParm = false;
  1122. for (Object object : cheekmap) {
  1123. JSONObject jsonObject = (JSONObject) object;
  1124. if (jsonObject.getString("parm").equals(firstcheek)) {
  1125. isexistParm = true;
  1126. break;
  1127. }
  1128. }
  1129. if (!isexistParm) {
  1130. JSONObject jsonObject = new JSONObject();
  1131. jsonObject.put("parm", firstcheek);
  1132. jsonObject.put("flag", false);
  1133. cheekmap.add(jsonObject);
  1134. }
  1135. }
  1136. }else{
  1137. for (String firstcheek : firstcheekList) {
  1138. boolean isexistParm = false;
  1139. for (Object object : cheekmap) {
  1140. JSONObject jsonObject = (JSONObject) object;
  1141. if (jsonObject.getString("parm").equals(firstcheek)) {
  1142. isexistParm = true;
  1143. break;
  1144. }
  1145. }
  1146. if (!isexistParm) {
  1147. JSONObject jsonObject = new JSONObject();
  1148. jsonObject.put("parm", firstcheek);
  1149. jsonObject.put("flag", false);
  1150. cheekmap.add(jsonObject);
  1151. }
  1152. }
  1153. }
  1154. }
  1155. colormap = jsonArraySortByField(colormap.toJSONString(), "parm", "0");
  1156. specmap = jsonArraySortByField(specmap.toJSONString(), "parm", "0");
  1157. materialmap = jsonArraySortByField(materialmap.toJSONString(), "parm", "0");
  1158. cheekmap = jsonArraySortByField(cheekmap.toJSONString(), "parm", "0");
  1159. for (Object object : colormap) {
  1160. boolean flag = false;
  1161. parm parm = JSON.parseObject(((JSONObject) object).toJSONString(), parm.class);
  1162. for (parm parm1 : colorList) {
  1163. if (parm1.getParm().equals(parm.getParm())) {
  1164. flag = true;
  1165. break;
  1166. }
  1167. }
  1168. if (!flag) {
  1169. colorList.add(parm);
  1170. }
  1171. }
  1172. for (Object object : specmap) {
  1173. boolean flag = false;
  1174. parm parm = JSON.parseObject(((JSONObject) object).toJSONString(), parm.class);
  1175. for (parm parm1 : specList) {
  1176. if (parm1.getParm().equals(parm.getParm())) {
  1177. flag = true;
  1178. break;
  1179. }
  1180. }
  1181. if (!flag) {
  1182. specList.add(parm);
  1183. }
  1184. }
  1185. for (Object object : materialmap) {
  1186. boolean flag = false;
  1187. parm parm = JSON.parseObject(((JSONObject) object).toJSONString(), parm.class);
  1188. for (parm parm1 : materialList) {
  1189. if (parm1.getParm().equals(parm.getParm())) {
  1190. flag = true;
  1191. break;
  1192. }
  1193. }
  1194. if (!flag) {
  1195. materialList.add(parm);
  1196. }
  1197. }
  1198. for (Object object : cheekmap) {
  1199. boolean flag = false;
  1200. parm parm = JSON.parseObject(((JSONObject) object).toJSONString(), parm.class);
  1201. for (parm parm1 : cheekList) {
  1202. if (parm1.getParm().equals(parm.getParm())) {
  1203. flag = true;
  1204. break;
  1205. }
  1206. }
  1207. if (!flag) {
  1208. cheekList.add(parm);
  1209. }
  1210. }
  1211. // colorList.addAll(JSONObject.parseArray(colormap.toJSONString(), parm.class));
  1212. // specList.addAll(JSONObject.parseArray(specmap.toJSONString(), parm.class));
  1213. // materialList.addAll(JSONObject.parseArray(materialmap.toJSONString(), parm.class));
  1214. // cheekList.addAll(JSONObject.parseArray(cheekmap.toJSONString(), parm.class));
  1215. rows = dbConnect.runSqlQuery(factory.getSQL());
  1216. String itemno = "";
  1217. if (!rows.isEmpty()) {
  1218. itemno = rows.get(0).getString("itemno");
  1219. }
  1220. /**
  1221. * 查询商品明细
  1222. */
  1223. SQLFactory priceSqlFactory = new SQLFactory(this, "查询商品原价");
  1224. priceSqlFactory.addParameter("sa_itemgroupid", content.getString("sa_itemgroupid"));
  1225. priceSqlFactory.addParameter("siteid", siteid);
  1226. Rows siteParameterRows =dbConnect.runSqlQuery("select defaultlevelprice from sys_site_parameter where siteid='"+siteid+"'");
  1227. if(!siteParameterRows.isEmpty()){
  1228. if(StringUtils.isBlank(siteParameterRows.get(0).getString("defaultlevelprice"))){
  1229. priceSqlFactory.addParameter("pricegrade", "1");
  1230. }else{
  1231. priceSqlFactory.addParameter("pricegrade", siteParameterRows.get(0).getString("defaultlevelprice"));
  1232. }
  1233. }else{
  1234. priceSqlFactory.addParameter("pricegrade", "1");
  1235. }
  1236. Rows pricerows = dbConnect.runSqlQuery(priceSqlFactory);
  1237. RowsMap pricerowsMap = pricerows.toRowsMap("itemid");
  1238. SQLFactory sqlFactory = new SQLFactory(this, "查询商品详情", pageSize, pageNumber, pageSorting);
  1239. sqlFactory.addParameter_SQL("where", "t2.itemno='" + itemno + "' ");
  1240. sqlFactory.addParameter("itemno", itemno);
  1241. sqlFactory.addParameter("siteid", siteid);
  1242. sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
  1243. Rows itemrows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  1244. for (Row row : itemrows) {
  1245. row.put("customschemeItems",customschemeItems);
  1246. ItemPrice itemPrice = ItemPrice.getItemPrice(this, sys_enterpriseid, row.getLong("itemid"));
  1247. row.put("oldprice", itemPrice.getPrice());
  1248. if (sys_enterpriseid > 0 || (usertype == 21 || usertype == 22)) {
  1249. row.put("gradeprice", itemPrice.getContractprice());
  1250. } else {
  1251. if(pricerowsMap.containsKey(row.getString("itemid"))){
  1252. if(pricerowsMap.get(row.getString("itemid")).isNotEmpty()){
  1253. row.put("gradeprice", pricerowsMap.get(row.getString("itemid")).get(0).getBigDecimal("price"));
  1254. }else{
  1255. row.put("gradeprice",0);
  1256. }
  1257. }else {
  1258. row.put("gradeprice", 0);
  1259. }
  1260. }
  1261. //判断商品是否参与活动:当前经销商参与的有效的活动
  1262. if(listAll.size()==listParmNotBlank.size()){
  1263. SQLFactory activitysqlFactory = new SQLFactory(new promotion(new JSONObject()), "促销方案列表查询");
  1264. activitysqlFactory.addParameter("siteid", siteid);
  1265. activitysqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
  1266. activitysqlFactory.addParameter_SQL("where", "1=1");
  1267. Rows activityrows = dbConnect.runSqlQuery(activitysqlFactory);
  1268. SQLFactory sqlFactory1 = new SQLFactory(new promotion(new JSONObject()), "促销订单金额合计查询");
  1269. sqlFactory1.addParameter("siteid", siteid);
  1270. sqlFactory1.addParameter("sys_enterpriseid", sys_enterpriseid);
  1271. Rows sumAmountRows = dbConnect.runSqlQuery(sqlFactory1.getSQL());
  1272. RowsMap sumAmountRowsMap = sumAmountRows.toRowsMap("sa_promotionid");
  1273. SQLFactory sqlFactory2 = new SQLFactory(new promotion(new JSONObject()), "促销方案列表查询(触发的促销方案)");
  1274. sqlFactory2.addParameter("siteid", siteid);
  1275. sqlFactory2.addParameter("sys_enterpriseid", sys_enterpriseid);
  1276. Rows openPromotionsRows = dbConnect.runSqlQuery(sqlFactory2.getSQL());
  1277. RowsMap openPromotionsRowsMap = openPromotionsRows.toRowsMap("sa_promotionid");
  1278. ListIterator<Row> iterator = activityrows.listIterator();
  1279. while (iterator.hasNext()) {
  1280. Row activityrow = iterator.next();
  1281. if(activityrow.getLong("sa_openpromotionid")!=0){
  1282. if(sumAmountRowsMap.containsKey(activityrow.getString("sa_promotionid"))){
  1283. BigDecimal sumamount = sumAmountRowsMap.get(activityrow.getString("sa_promotionid")).get(0).getBigDecimal("sumamount");
  1284. if(sumamount.compareTo(activityrow.getBigDecimal("openamount"))>=0){
  1285. if(openPromotionsRowsMap.containsKey(activityrow.getString("sa_openpromotionid"))){
  1286. iterator.add(openPromotionsRowsMap.get(activityrow.getString("sa_openpromotionid")).get(0));
  1287. }
  1288. }
  1289. }
  1290. }
  1291. }
  1292. SQLFactory promotionsqlFactory = new SQLFactory(this, "查询商品所在有效活动", pageSize, pageNumber, pageSorting);
  1293. promotionsqlFactory.addParameter("itemno", itemno);
  1294. promotionsqlFactory.addParameter_in("sa_promotionids", activityrows.toArray("sa_promotionid"));
  1295. promotionsqlFactory.addParameter("siteid", siteid);
  1296. Rows promotionrows = dbConnect.runSqlQuery(promotionsqlFactory.getSQL());
  1297. row.put("canuseactivity",promotionrows);
  1298. }else{
  1299. row.put("canuseactivity",new Rows());
  1300. }
  1301. }
  1302. ArrayList<Long> ids = itemrows.toArrayList("itemid", new ArrayList<>());
  1303. //默认商品图片
  1304. Rows defaultImageRows = Item.getItemdefaultImage(this);
  1305. // 封面cover
  1306. RowsMap coverRowsMap = getAttachmentUrl("plm_item", ids, "cover");
  1307. // 附件
  1308. RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
  1309. Rows rowsitemclass = dbConnect.runSqlQuery(
  1310. " select t7.itemclassname,t6.itemid,t8.brandname from sa_itemsaleclass t6 inner JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='"
  1311. + siteid + "'");
  1312. RowsMap itemclassRowsMap = rowsitemclass.toRowsMap("itemid");
  1313. // 货品档案领域
  1314. Rows rowstradefield = dbConnect.runSqlQuery(
  1315. " select t6.itemid,t6.tradefield from plm_item_tradefield t6 where t6.siteid='" + siteid + "'");
  1316. RowsMap tradefieldRowsMap = rowstradefield.toRowsMap("itemid");
  1317. // 品牌
  1318. Rows rowsbrand = dbConnect.runSqlQuery(
  1319. " select distinct t8.sa_brandid,t6.itemid,t8.brandname from sa_itemsaleclass t6 inner JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='"
  1320. + siteid + "'");
  1321. RowsMap brandRowsMap = rowsbrand.toRowsMap("itemid");
  1322. for (Row row : itemrows) {
  1323. Rows coverRows = coverRowsMap.get(row.getString("itemid"));
  1324. if (coverRows.isEmpty()) {
  1325. row.put("cover", "");
  1326. } else {
  1327. row.put("cover", coverRows.get(0).getString("url"));
  1328. }
  1329. if ((attRowsMap.getOrDefault(row.getString("itemid"), new Rows())).isEmpty()) {
  1330. row.put("attinfos", defaultImageRows);
  1331. } else {
  1332. row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
  1333. }
  1334. row.put("itemclass", itemclassRowsMap.get(row.getString("itemid")));
  1335. row.put("tradefield", tradefieldRowsMap.get(row.getString("itemid")));
  1336. row.put("brand", brandRowsMap.get(row.getString("itemid")));
  1337. }
  1338. JSONObject oject = new JSONObject();
  1339. oject.put("customschemeItems", customschemeItems.toJsonArray());
  1340. if(customschemeItems.size()==1){
  1341. if(customschemeItems.get(0).getString("value").equals("color")){
  1342. RowsMap rowsMap = rowsall.toRowsMap("color");
  1343. for (parm parm : colorList) {
  1344. if(rowsMap.containsKey(parm.getParm())){
  1345. parm.setDelistingstatus(rowsMap.get(parm.getParm()).get(0).getString("delistingstatus"));
  1346. }
  1347. }
  1348. }
  1349. if(customschemeItems.get(0).getString("value").equals("spec")){
  1350. RowsMap rowsMap = rowsall.toRowsMap("spec");
  1351. for (parm parm : specList) {
  1352. if(rowsMap.containsKey(parm.getParm())) {
  1353. parm.setDelistingstatus(rowsMap.get(parm.getParm()).get(0).getString("delistingstatus"));
  1354. }
  1355. }
  1356. }
  1357. if(customschemeItems.get(0).getString("value").equals("material")){
  1358. RowsMap rowsMap = rowsall.toRowsMap("material");
  1359. for (parm parm : materialList) {
  1360. if(rowsMap.containsKey(parm.getParm())) {
  1361. parm.setDelistingstatus(rowsMap.get(parm.getParm()).get(0).getString("delistingstatus"));
  1362. }
  1363. }
  1364. }
  1365. if(customschemeItems.get(0).getString("value").equals("cheek")){
  1366. RowsMap rowsMap = rowsall.toRowsMap("cheek");
  1367. for (parm parm : cheekList) {
  1368. if(rowsMap.containsKey(parm.getParm())) {
  1369. parm.setDelistingstatus(rowsMap.get(parm.getParm()).get(0).getString("delistingstatus"));
  1370. }
  1371. }
  1372. }
  1373. }
  1374. oject.put("colorRows", colorList);
  1375. oject.put("specRows", specList);
  1376. oject.put("materialRows", materialList);
  1377. oject.put("cheekRows", cheekList);
  1378. oject.put("rows", rows);
  1379. oject.put("item", itemrows);
  1380. return getSucReturnObject().setData(oject).toString();
  1381. }
  1382. /**
  1383. * 按照JSONArray中的对象的某个字段进行排序(采用fastJson)
  1384. *
  1385. * @param jsonArrayStr json数组字符串
  1386. * @param sortkeyname 根据哪个字段进行排序
  1387. * @param order 倒序:0;非0顺序
  1388. * @return 排序后的jsonarray
  1389. */
  1390. public JSONArray jsonArraySortByField(String jsonArrayStr, String sortkeyname, String order) throws YosException {
  1391. JSONArray sortedJsonArray = new JSONArray();
  1392. try {
  1393. JSONArray jsonArray = JSON.parseArray(jsonArrayStr);
  1394. List<JSONObject> jsonList = new ArrayList<JSONObject>();
  1395. for (int i = 0; i < jsonArray.size(); i++) {
  1396. jsonList.add(jsonArray.getJSONObject(i));
  1397. }
  1398. Collections.sort(jsonList, new Comparator<JSONObject>() {
  1399. @Override
  1400. public int compare(JSONObject a, JSONObject b) {
  1401. String strA = new String();
  1402. String strB = new String();
  1403. String regEx = "[\n`~!@#$%^&*()+=|{}':;',\\-_\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]";
  1404. String aStr = a.getStringValue(sortkeyname);
  1405. strA = aStr.replaceAll(regEx, "");
  1406. String bStr = b.getStringValue(sortkeyname);
  1407. strB = bStr.replaceAll(regEx, "");
  1408. if ("0".equals(order)) {
  1409. return -strA.compareTo(strB);
  1410. } else {
  1411. return strA.compareTo(strB);
  1412. }
  1413. }
  1414. });
  1415. for (int i = 0; i < jsonArray.size(); i++) {
  1416. sortedJsonArray.add(jsonList.get(i));
  1417. }
  1418. } catch (Exception e) {
  1419. e.printStackTrace();
  1420. }
  1421. return sortedJsonArray;
  1422. }
  1423. }