Przeglądaj źródła

服务工单节点详情逻辑优化

hu 9 miesięcy temu
rodzic
commit
996b45d4d3

+ 19 - 10
src/custom/restcontroller/webmanage/sale/workorder/workorder.java

@@ -497,17 +497,26 @@ public class workorder extends Controller {
             row.put("team", workorderteamRows);
 
             /** 工单节点物料查询 **/
-            Rows oldworkorderitemRows = dbConnect.runSqlQuery(
-                    "select t1.*,t2.itemno,t2.model,t2.itemname,t2.spec from sa_workorder_node_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.sa_workorder_nodeid="
-                            + sa_workorder_nodeid + " and t1.sa_workorderid=" + sa_workorderid + " and ifnull(t1.isnew,0)=0 and t1.siteid='"
-                            + siteid + "'");
-            row.put("oldtitems", oldworkorderitemRows);
-
-            Rows newworkorderitemRows = dbConnect.runSqlQuery(
-                    "select t1.*,t2.itemno,t2.model,t2.itemname,t2.spec from sa_workorder_node_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.sa_workorder_nodeid="
-                            + sa_workorder_nodeid + " and t1.sa_workorderid=" + sa_workorderid + " and ifnull(t1.isnew,0)=1 and t1.siteid='"
+            Rows workorderitemRows = dbConnect.runSqlQuery(
+                    "select t1.*,t2.itemno,t2.model,t2.itemname,t2.spec,t7.bomfullname,ifnull(t1.isnew,0) isnew from sa_workorder_node_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid" +
+                            "LEFT JOIN sa_itemsalebom t6 on t1.itemid=t6.itemid and t6.siteid = t1.siteid " +
+                            "LEFT JOIN plm_bom t7 on t7.plm_bomid=t6.plm_bomid and t6.siteid = t7.siteid where t1.sa_workorder_nodeid="
+                            + sa_workorder_nodeid + " and t1.sa_workorderid=" + sa_workorderid + " and t1.siteid='"
                             + siteid + "'");
-            row.put("newtitems", newworkorderitemRows);
+            // 默认商品图片
+            Rows defaultImageRows = beans.Item.Item.getItemdefaultImage(this);
+            // 附件
+            ArrayList<Long> itemids = workorderitemRows.toArrayList("itemid", new ArrayList<>());
+            RowsMap itemattRowsMap = getAttachmentUrl("plm_item", itemids);
+            for (Row itemRow : workorderitemRows) {
+                if (itemattRowsMap.getOrDefault(itemRow.getString("itemid"), new Rows()).isNotEmpty()) {
+                    itemRow.put("attinfos", itemattRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
+                } else {
+                    itemRow.put("attinfos", defaultImageRows);
+                }
+            }
+            row.put("oldtitems", workorderitemRows.toRowsMap("isnew").get("0"));
+            row.put("newtitems", workorderitemRows.toRowsMap("isnew").get("1"));
 
 //			 /** 节点关联培训物料查询 **/
 //			  Rows traintitem = dbConnect.runSqlQuery("select * from sa_workorder_node_items where sa_workorder_nodeid="+sa_workorder_nodeid+" and sa_workorderid="