luobang před 2 roky
rodič
revize
9a6d15afa6

+ 16 - 0
src/main/java/com/steerinfo/dil/controller/StatisticalReportController.java

@@ -1494,4 +1494,20 @@ public class StatisticalReportController extends BaseRESTfulController {
         }
         return success(report);
     }
+
+    @PostMapping("steelTransportReport")
+    @ApiOperation(value="销售钢材报表每日运输情况查询")
+    public RESTfulResult steelTransportReport(@RequestBody(required = false) Map<String,Object> map,
+                                              String startTime,
+                                              String endTime){
+        DataChange.queryDataByDateTimeYestDay(startTime, endTime, map, sdfDateTime);//根据时间段查询数据
+        List<Map<String, Object>> report = statisticalReportService.steelTransportReport(map);
+        return success(report);
+    }
+
+    @ApiOperation("同步saleMaterialId至tmstruck和oom中")
+    @PostMapping("testTb")
+    public RESTfulResult testTb() {
+        return success(statisticalReportService.testTb());
+    }
 }

+ 8 - 0
src/main/java/com/steerinfo/dil/mapper/StatisticalReportMapper.java

@@ -113,4 +113,12 @@ public interface StatisticalReportMapper {
 
     List<Map<String, Object>> getSaleSteelReportForFinance(Map<String, Object> map);
 
+    List<Map<String, Object>> steelTransportReport(Map<String, Object> map);
+
+    List<Map<String, Object>> getNoSaleterialIdWeight();
+
+    List<BigDecimal> getSaleMaterialIds(BigDecimal orderId, BigDecimal materialId);
+
+    int updateTw(BigDecimal weightTaskId, BigDecimal dataToBigDecimal);
+
 }

+ 2 - 0
src/main/java/com/steerinfo/dil/service/IStatisticalReportService.java

@@ -103,5 +103,7 @@ public interface IStatisticalReportService {
     List<String> getSaleAreaRemark(String saler);
 
     List<Map<String, Object>> getSaleSteelReportForFinance(Map<String, Object> map);
+
+    List<Map<String, Object>> steelTransportReport(Map<String, Object> map);
 }
 

+ 33 - 0
src/main/java/com/steerinfo/dil/service/impl/StatisticalReportImpl.java

@@ -1,9 +1,11 @@
 package com.steerinfo.dil.service.impl;
 
+import com.google.gson.JsonObject;
 import com.steerinfo.dil.mapper.StatisticalReportMapper;
 import com.steerinfo.dil.service.IStatisticalReportService;
 import com.steerinfo.dil.util.DataChange;
 import com.steerinfo.dil.util.PageListAdd;
+import com.steerinfo.framework.controller.RESTfulResult;
 import oracle.sql.DATE;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -506,4 +508,35 @@ public class StatisticalReportImpl implements IStatisticalReportService {
         List<Map<String, Object>> saleSteelReport = statisticalReportMapper.getSaleSteelReportForFinance(map);
         return saleSteelReport;
     }
+
+    @Override
+    public List<Map<String, Object>> steelTransportReport(Map<String, Object> map) {
+        List<Map<String, Object>> saleSteelReport = statisticalReportMapper.steelTransportReport(map);
+
+        return saleSteelReport;
+    }
+
+    public int testTb() {
+        //首先查询已经完成的销售钢材有净重的没有saleMaterialId的数据
+        List<Map<String,Object>> mapList = statisticalReportMapper.getNoSaleterialIdWeight();
+        for (Map<String,Object> map :mapList) {
+            BigDecimal orderId = DataChange.dataToBigDecimal(map.get("orderId"));
+            BigDecimal weightTaskId = DataChange.dataToBigDecimal(map.get("weightTaskId"));
+            BigDecimal materialId = DataChange.dataToBigDecimal(map.get("materialId"));
+            //根据运输订单号和物资id去查询saleMaterialId的数量,若数量为1则更新,否则记录下来不更新
+            List<BigDecimal> saleMaterialIds = statisticalReportMapper.getSaleMaterialIds(orderId,materialId);
+            if(saleMaterialIds.size() > 1) {
+                System.out.println("该车有问题:" + map.toString());
+                continue;
+            }else if(saleMaterialIds.size() ==1 && saleMaterialIds.get(0) != null){
+                //否则更新计量实绩表
+                System.out.println("该车正常更新:"+ map.toString());
+                statisticalReportMapper.updateTw(weightTaskId,DataChange.dataToBigDecimal(saleMaterialIds.get(0)));
+            }else{
+                System.out.println("查不到数据"+ map.toString());
+            }
+
+        }
+        return 0;
+    }
 }

+ 39 - 10
src/main/resources/com/steerinfo/dil/mapper/StatisticalReportMapper.xml

@@ -9,7 +9,8 @@
             </if>
         </if>
     </sql>
-<!--查询采购统计报表-->
+
+    <!--查询采购统计报表-->
     <select id="getFuPurchaseFLRLReport" parameterType="map" resultType="java.util.Map">
         select *
         from (select
@@ -1960,8 +1961,6 @@
                         END)
                      "carrierName",
                     OO.ORDER_NUMBER "orderNo",
-                    ACTP.PRICE_VALUE AS "priceValue",
-                    BDO.DETAILS_AMOUNT AS "detailsAmount",
                     (CASE WHEN RRA_HISTORY.ADDRESS_PROVINCE is not null
                     THEN '新地址:' || RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT ||
                     RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS
@@ -2114,12 +2113,6 @@
                     LEFT JOIN TMSTRUCK_WEIGHT_RESULT TWR
                               ON
                     TWR.SALE_MATERIAL_ID = ASM.SALE_MATERIAL_ID
-                    and twr.SALE_MATERIAL_ID is not null
-                    OR ( TWR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID AND TWR.MATERIAL_ID = RM.MATERIAL_ID and twr.sale_material_id is null )
-                    LEFT JOIN BMSTRUCK_DETAILS_ORDER BDO
-                              ON BDO.WEIGHT_TASK_RESULT_ID = TWR.WEIGHT_TASK_RESULT_ID
-                    LEFT JOIN AMS_CONTRACT_TRANSPORT_PRICE actp
-                              ON actp.PRICE_ID = bdo.PRICE_ID
                     LEFT JOIN TMSTRUCK_LEAVE_FACTORY_RESULT TLFR
                               ON TLFR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
                     LEFT JOIN TMSTRUCK_ARRIVAL_RESULT TAR
@@ -2507,7 +2500,6 @@
         LEFT JOIN TMSTRUCK_WEIGHT_RESULT TWR
         ON TWR.SALE_MATERIAL_ID = ASM.SALE_MATERIAL_ID
         and twr.SALE_MATERIAL_ID is not null
-        OR ( TWR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID AND TWR.MATERIAL_ID = RM.MATERIAL_ID and twr.sale_material_id is null )
         LEFT JOIN BMSTRUCK_DETAILS_ORDER BDO
         ON BDO.WEIGHT_TASK_RESULT_ID = TWR.WEIGHT_TASK_RESULT_ID
         LEFT JOIN AMS_CONTRACT_TRANSPORT_PRICE actp
@@ -3880,5 +3872,42 @@
         order by ASO.SALE_ORDER_ID DESC, ASOM.SALE_ORDER_MATERIAL_ID DESC,OO.ORDER_ID  DESC
         )
     </select>
+    <select id="steelTransportReport" resultType="java.util.Map">
 
+    </select>
+    <select id="getNoSaleterialIdWeight" resultType="java.util.Map">
+        SELECT DISTINCT OO.ORDER_ID "orderId",
+               TWR.WEIGHT_TASK_RESULT_ID "weightTaskId",
+               TWR.MATERIAL_ID "materialId",
+               OO.ORDER_NUMBER "orderNumber",
+               OO.ORDER_RECEIVE_REFUSE_TIME "receiveTime",
+               RC.CAPACITY_NUMBER "capacityNo"
+               FROM OMSTRUCK_ORDER OO
+        LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR
+        ON TTR.ORDER_ID = OO.ORDER_ID
+        LEFT JOIN TMSTRUCK_WEIGHT_RESULT TWR
+        ON TWR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
+        LEFT JOIN RMS_CAPACITY RC
+        ON RC.CAPACITY_ID = OO.CAPACITY_ID
+        WHERE TWR.SALE_MATERIAL_ID IS NULL
+        AND TWR.RESULT_NET_WEIGHT IS NOT NULL
+        AND OO.ORDER_STATUS = 2
+        AND OO.ORDER_TYPE = 1
+    </select>
+    <select id="getSaleMaterialIds" resultType="java.math.BigDecimal">
+        SELECT ASM.SALE_MATERIAL_ID FROM OMSTRUCK_ORDER OO
+        LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
+        ON ASOM.SALE_ORDER_MATERIAL_ID = OO.ORDER_PLAN_ID
+        LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
+        ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
+        LEFT JOIN AMS_SALE_MATERIAL ASM
+        ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
+        WHERE ASM.MATERIAL_ID = #{materialId}
+        and  OO.ORDER_ID = #{orderId}
+    </select>
+    <update id="updateTw">
+        UPDATE TMSTRUCK_WEIGHT_RESULT TWR
+        SET TWR.SALE_MATERIAL_ID = #{dataToBigDecimal}
+        WHERE TWR.WEIGHT_TASK_RESULT_ID = #{weightTaskId}
+    </update>
 </mapper>