Your Name hace 3 años
padre
commit
29ac8f5f59

+ 1 - 5
src/main/java/com/steerinfo/dil/controller/StatisticalReportController.java

@@ -233,13 +233,9 @@ public class StatisticalReportController extends BaseRESTfulController {
                                                     Integer pageNum,
                                                     Integer pageSize,
                                                     String startTime,
-                                                    String endTime,
-                                                    String con
+                                                    String endTime
     ){
         DataChange.queryDataByDate(startTime, endTime, mapValue, sdfDate);//根据时间段查询数据
-        if (con!=null&&!con.equals("undefined")){
-            mapValue.put("con","%"+con+"%");
-        }
         List<Map<String, Object>> allReport =  statisticalReportService.getPurInwardReport(mapValue);
         PageHelper.startPage(pageNum, pageSize);
         //分页数据

+ 2 - 1
src/main/java/com/steerinfo/dil/mapper/StatisticalReportMapper.java

@@ -2,6 +2,7 @@ package com.steerinfo.dil.mapper;
 
 import org.apache.ibatis.annotations.Mapper;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -27,6 +28,6 @@ public interface StatisticalReportMapper {
     // 查询采购内转统计报表
     List<Map<String, Object>> getTotalResultList();
 
-    List<Map<String, Object>> getInwardReportResult(Map<String, Object> mapValue);
+    List<Map<String, Object>> getInwardReportResult(Map<String,Object> mapValue);
 
 }

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

@@ -5,8 +5,10 @@ import com.steerinfo.dil.service.IStatisticalReportService;
 import com.steerinfo.dil.util.DataChange;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestBody;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -119,20 +121,18 @@ public class StatisticalReportImpl implements IStatisticalReportService {
 
     //采购内转统计报表
     @Override
-    public List<Map<String, Object>> getPurInwardReport(Map<String, Object> mapValue) {
-        //查询出所有订单类型为10的采购内转订单总实绩id集合
-        List<Map<String,Object>> inwardReport=null;
-        List<Map<String,Object>> totalResultList = statisticalReportMapper.getTotalResultList();
-        for (Map<String,Object>maptotal:totalResultList
+    public List<Map<String, Object>> getPurInwardReport( Map<String, Object> mapValue) {
+        List<Map<String, Object>> inwardReportResult = statisticalReportMapper.getInwardReportResult(mapValue);
+        for (Map<String,Object>inwardReport:inwardReportResult
         ) {
-            //遍历总实绩,根据总实绩id获取所有采购内转统计报表
-            mapValue.put("totalId",maptotal.get("totalId"));
-            List<Map<String, Object>> inwardReportResult = statisticalReportMapper.getInwardReportResult(mapValue);
-            for (Map<String,Object> map1:inwardReportResult) {
-                calculateDifferenceTime(map1);
-                inwardReport.add(map1);
-            }
+
+            BigDecimal netWeightSecond = DataChange.dataToBigDecimal(inwardReport.get("netWeightSecond"));
+            BigDecimal netWeightFirst = DataChange.dataToBigDecimal(inwardReport.get("netWeightFirst"));
+            BigDecimal netTract = netWeightSecond.subtract(netWeightFirst).divide(new BigDecimal(1), 2, 4);
+            //第二次净重减第一次净重
+            inwardReport.put("newTract",netTract);
+            calculateDifferenceTime(inwardReport);
         }
-        return inwardReport;
+        return inwardReportResult;
     }
 }

+ 160 - 2
src/main/resources/com/steerinfo/dil/mapper/StatisticalReportMapper.xml

@@ -717,13 +717,171 @@
             order by "resultOutGateTime" desc, "resultEntryGateTime" desc
         </if>
     </select>
-    <select id="getTotalResultList" resultType="java.util.Map">
+    <select id="getTotalResultList" resultType="java.util.LinkedHashMap">
         SELECT DISTINCT
             TTR.RESULT_TOTAL_ID "totalId"
         FROM
             TMSTRUCK_TOTAL_RESULT TTR
-                LEFT JOIN OMSTRUCK_ORDER OO ON OO.ORDER_ID = TTR.ORDER_ID
+        LEFT JOIN OMSTRUCK_ORDER OO ON OO.ORDER_ID = TTR.ORDER_ID
         WHERE
             OO.ORDER_TYPE = 10
+        order by TTR.RESULT_TOTAL_ID desc
+    </select>
+    <select id="getInwardReportResult" resultType="java.util.LinkedHashMap">
+            select * from (select oo.order_id                   "orderId",
+           rm.material_name              "materialName",
+           apo.purchase_order_no         "purchaseNo",
+           rc.capacity_number            "capacityNo",
+           rs.supplier_name              "supplierName",
+           oo.order_number               "orderNumber",
+           rce.consignee_company_name    "consigneeName",
+           ttr.result_total_id           "totalResultId",
+           ter1.result_entry_mode        "entryModeFirst",
+           ter1.result_entry_gate_time   "entryGateTimeFirst",
+           rg1.gatepost_name             "entryGatepostNameFirst",
+           twr1.result_tare_weight       "tareWeightFirst",
+           twr1.result_tare_weight_time  "tareWeightTimeFirst",
+           rtc1.truck_calculate_number   "tareTruckCalculateFirst",
+           tlr.result_load_end_time      "loadTime",
+           rw.warehouse_name             "loadPoint",
+           twr2.result_gross_weight      "grossWeightFirst",
+           twr2.result_gross_weight_time "grossWeigtTimeFirst",
+           rtc2.truck_calculate_number   "grossTruckCalculateFirst",
+           twr2.result_net_weight        "netWeightFirst",
+           tlfr1.result_out_gate_time    "outGatepostTimeFirst",
+           tlfr1.result_out_mode         "outModeFirst",
+           rg2.gatepost_name             "gatepostNameFirst",
+           ter2.result_entry_mode        "entryModeSecond",
+           ter2.result_entry_gate_time   "resultEntryGateTime",
+           ter2.result_entry_gate_time   "entryGateTimeSecond",
+           rg3.gatepost_name             "entryGatepostNameSecond",
+           twr3.result_gross_weight      "grossWeightSecond",
+           twr3.result_gross_weight_time "grossWeigtTimeSecond",
+           rtc3.truck_calculate_number   "grossTruckCalculateSecond",
+           tur.result_end_time           "unloadTime",
+           rw2.warehouse_name            "unloadPoint",
+           twr4.result_tare_weight       "tareWeightSecond",
+           twr4.result_tare_weight_time  "tareWeightTimeSecond",
+           twr4.result_net_weight        "netWeightSecond",
+           rtc4.truck_calculate_number   "tareTruckCalculateSecond",
+           tlfr2.result_out_gate_time    "outGatepostTimeSecond",
+           tlfr2.result_out_gate_time    "resultOutGateTime",
+           tlfr2.result_out_mode         "outModeSecond",
+           rg4.gatepost_name             "gatepostNameSecond"
+      from omstruck_order oo
+      left join omstruck_order_material oom
+        on oom.order_id = oo.order_id
+      left join rms_material rm
+        on rm.material_id = oom.material_id
+      left join rms_capacity rc
+        on rc.capacity_id = oo.capacity_id
+      left join amstruck_inward_plan aip
+        on aip.plan_id = oo.order_plan_id
+      left join amstruck_requirement_plan arp
+        on arp.plan_id = aip.plan_id
+      left join amstruck_inward_requirement air
+        on air.requirement_id = arp.requirement_id
+      left join ams_purchase_order apo
+        on apo.purchase_order_id = air.purchase_order_id
+      left join rms_supplier rs
+        on rs.supplier_id = apo.supplier_unit_id
+      left join rms_consignee rce
+        on rce.consignee_id = apo.receive_unit_id
+      left join tmstruck_total_result ttr
+        on ttr.order_id = oo.order_id
+      left join tmstruck_enfactory_result ter1
+        on ter1.result_total_id = ttr.result_total_id
+      left join rms_gatepost rg1
+        on rg1.gatepost_id = ter1.gatepost_id
+      left join tmstruck_weight_result twr1
+        on twr1.result_total_id = ttr.result_total_id
+      left join rms_truck_calculate rtc1
+        on rtc1.truck_calculate_id = twr1.result_tare_place_id
+      left join tmstruck_load_result tlr
+        on tlr.result_total_id = ttr.result_total_id
+      left join rms_warehouse rw
+        on rw.warehouse_id = tlr.loading_id
+      left join tmstruck_weight_result twr2
+        on twr2.result_total_id = ttr.result_total_id
+      left join rms_truck_calculate rtc2
+        on rtc2.truck_calculate_id = twr2.result_gross_place_id
+      left join tmstruck_leave_factory_result tlfr1
+        on tlfr1.result_total_id = ttr.result_total_id
+      left join rms_gatepost rg2
+        on tlfr1.gatepost_id = rg2.gatepost_id
+      left join tmstruck_enfactory_result ter2
+        on ter2.result_total_id = ttr.result_total_id
+      left join rms_gatepost rg3
+        on rg3.gatepost_id = ter2.gatepost_id
+      left join tmstruck_weight_result twr3
+        on twr3.result_total_id = ttr.result_total_id
+      left join rms_truck_calculate rtc3
+        on rtc3.truck_calculate_id = twr3.result_gross_place_id
+      left join tmstruck_unload_result tur
+        on tur.result_total_id = ttr.result_total_id
+      left join rms_warehouse rw2
+        on rw2.warehouse_id = tur.result_unload_place_id
+      left join tmstruck_weight_result twr4
+        on twr4.result_total_id = ttr.result_total_id
+      left join rms_truck_calculate rtc4
+        on rtc4.truck_calculate_id = twr4.result_tare_place_id
+      left join tmstruck_leave_factory_result tlfr2
+        on tlfr2.result_total_id = ttr.result_total_id
+      left join rms_gatepost rg4
+        on tlfr2.gatepost_id = rg4.gatepost_id
+     where oo.order_type = 10
+       and ter1.segmen_sqe = 1
+       and twr1.tare_segment_sqe = 2
+       and tlr.segment_sqe = 3
+       and twr2.gross_segment_sqe = 4
+       and tlfr1.segment_sqe = 5
+       and ter2.segmen_sqe = 6
+       and twr3.gross_segment_sqe = 7
+       and tur.segment_sqe = 8
+       and twr4.tare_segment_sqe = 9
+       and tlfr2.segment_sqe = 10
+       and twr2.result_gross_weight_time is not null
+        <if test="oneDate != null">
+            and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= TWR4.RESULT_TARE_WEIGHT_TIME
+        </if>
+        <if test="startDate != null">
+            and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= TWR4.RESULT_TARE_WEIGHT_TIME
+            and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= TWR4.RESULT_TARE_WEIGHT_TIME
+        </if>
+    )
+        <where>
+            <if test="consigneeName != null">
+                and
+                <foreach collection="consigneeName" item="item" open="(" separator="or" close=")">
+                    "consigneeName" like '%${item}%'
+                </foreach>
+            </if>
+            <if test="supplierName != null">
+                and
+                <foreach collection="supplierName" item="item" open="(" separator="or" close=")">
+                    "supplierName" like '%${item}%'
+                </foreach>
+            </if>
+            <if test="materialName != null">
+                and
+                <foreach collection="materialName" item="item" open="(" separator="or" close=")">
+                    "materialName" like '%${item}%'
+                </foreach>
+            </if>
+            <if test="orderNumber != null">
+                <foreach collection="orderNumber" item="item" open="(" separator="or" close=")">
+                    "orderNumber" like '%${item}%'
+                </foreach>
+            </if>
+            <if test="capacityNo != null">
+                and
+                <foreach collection="capacityNo" item="item" open="(" separator="or" close=")">
+                    "capacityNo" like '%${item}%'
+                </foreach>
+            </if>
+        </where><include refid="orderBy"></include>
+        <if test="orderField == null">
+            order by "outGatepostTimeFirst" desc, "entryGateTimeFirst" desc
+        </if>
     </select>
 </mapper>

+ 13 - 0
src/main/test/tts.java

@@ -0,0 +1,13 @@
+import org.junit.Test;
+
+import java.math.BigDecimal;
+
+public class tts {
+    @Test
+    public void test(){
+        BigDecimal bigDecimal = new BigDecimal("10.001");
+        BigDecimal bigDecimal1 = new BigDecimal("7.288");
+        BigDecimal divide = bigDecimal.subtract(bigDecimal1).divide(new BigDecimal(1), 2, 4);
+        System.out.println(divide);
+    }
+}