Parcourir la source

Merge branch 'master' of https://git.steerinfo.com/DAL-DAZHOU/DAL-DAZHOU-AMS-API

luobang il y a 1 an
Parent
commit
88fb492733

+ 42 - 0
src/main/resources/com/steerinfo/dil/mapper/AmsSaleOrderMapper.xml

@@ -4722,6 +4722,12 @@
                         TPAR.RESULT_ID                                          "approveId",
                         TPAR.UPDATE_USERNAME                                    "sendStationOptionName",
                         ASO.UPDATE_USERNAME                                     "consigneeOptionName",
+                        SW."sumWeight" "sumWeight",
+                        (case
+                        WHEN  RM.MATERIAL_NAME LIKE '%螺纹钢%'
+                        THEN 1
+                        ELSE 0
+                        end) AS "weight",
                         (CASE
                             WHEN ASO.DELETED IN (1,2)
                             THEN '关闭'
@@ -4754,6 +4760,41 @@
                         ON RISWINOF.INWARD_WAREHOUSE_CODE = ASM.TRANSFER_IN_OF_WAREHOUSE
                         LEFT JOIN TMSTRUCK_WEIGHT_RESULT TWR
                         ON TWR.SALE_MATERIAL_ID = ASM.SALE_MATERIAL_ID
+                        LEFT JOIN (
+                              SELECT "saleNo",
+                              SUM("weight") "sumWeight"
+                              FROM
+                              (
+                              SELECT ASO.SALE_NUMBER "saleNo",
+                              ASM.SALE_MATERIAL_ID "saleMaterialId",
+                              (case
+                              WHEN  RM.MATERIAL_NAME LIKE '%螺纹钢%'
+                              THEN 1
+                              ELSE 0
+                              end) AS "weight"
+                              FROM AMS_SALE_ORDER ASO
+                              LEFT JOIN AMS_SALE_MATERIAL ASM
+                              ON ASM.SALE_ORDER_ID = ASO.SALE_ORDER_ID
+                              LEFT JOIN RMS_MATERIAL RM
+                              ON RM.MATERIAL_ID = ASM.MATERIAL_ID
+                              WHERE
+                              ASO.SALE_TYPE = 4
+                              and asm.DELETED is null
+                              and asm.SALE_ORDER_ID != -1
+                              and aso.SALE_ORDER_STATUS = 4
+                              <if test="oneDate != null">
+                                and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = ASO.INSERT_TIME
+                              </if>
+                              <if test="startDate != null">
+                                and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;=  ASO.INSERT_TIME
+                                and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >=  ASO.INSERT_TIME
+                              </if>
+                              <if test="remark != null">
+                                and ASO.SALE_REMARK||RM.MATERIAL_NAME LIKE #{remark}
+                              </if>
+                              )
+                              GROUP BY "saleNo"
+                        ) SW ON SW."saleNo" = ASO.SALE_NUMBER
                       WHERE ASO.SALE_TYPE = 4
                         and asm.DELETED is null
                         and asm.SALE_ORDER_ID != -1
@@ -4787,6 +4828,7 @@
                         and RAS1.ARRIVAL_NAME  LIKE '%${sendStation}%'
                       </if>
        )
+      ORDER BY "sumWeight" DESC,"saleNo","weight" DESC
     </select>
   <select id="selectSaleAreaId" resultType="java.math.BigDecimal" parameterType="decimal">
         SELECT RC.AREA_ID AS "areaId"