Explorar o código

修改统计报表查询规则

txf %!s(int64=3) %!d(string=hai) anos
pai
achega
a0a03e5679

+ 7 - 9
src/main/java/com/steerinfo/dil/controller/StatisticalReportController.java

@@ -17,10 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @ author    :TXF
@@ -37,8 +34,9 @@ public class StatisticalReportController extends BaseRESTfulController {
     @Autowired
     ColumnDataUtil columnDataUtil;
 
-    private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+    private final SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
 
+    private final SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     @ApiOperation(value="查询辅料燃料统计报表")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"),
@@ -57,7 +55,7 @@ public class StatisticalReportController extends BaseRESTfulController {
                                                Integer orderType
     ){
         mapValue.put("orderTypee", orderType);
-        DataChange.queryDataByDate(startTime, endTime, mapValue, sdf);//根据时间段查询数据
+        DataChange.queryDataByDate(startTime, endTime, mapValue, sdfDate);//根据时间段查询数据
         List<Map<String, Object>> allReport =  statisticalReportService.getAllPurchaseFLRLReport(mapValue);
         PageHelper.startPage(pageNum, pageSize);
         //分页数据
@@ -88,7 +86,7 @@ public class StatisticalReportController extends BaseRESTfulController {
                 mapValue.put("carrierSsoId", carrierSsoId);
             }
         }
-        DataChange.queryDataByDate(startTime, endTime, mapValue, sdf);//根据时间段查询数据
+        DataChange.queryDataByTwoDate(startTime, endTime, mapValue, sdfDateTime);//根据时间段查询数据
         List<Map<String, Object>> allReport =  statisticalReportService.getAllSaleReportNum(mapValue);
         PageHelper.startPage(pageNum, pageSize);
         //分页数据
@@ -123,7 +121,7 @@ public class StatisticalReportController extends BaseRESTfulController {
                 mapValue.put("carrierSsoId", carrierSsoId);
             }
         }
-        DataChange.queryDataByDate(startTime, endTime, mapValue, sdf);//根据时间段查询数据
+        DataChange.queryDataByDate(startTime, endTime, mapValue, sdfDate);//根据时间段查询数据
             if (userId!=null){
                 mapValue.put("userId",userId);
             }
@@ -170,7 +168,7 @@ public class StatisticalReportController extends BaseRESTfulController {
                 mapValue.put("carrierSsoId", carrierSsoId);
             }
         }
-        DataChange.queryDataByDate(startTime, endTime, mapValue, sdf);//根据时间段查询数据
+        DataChange.queryDataByDate(startTime, endTime, mapValue, sdfDate);//根据时间段查询数据
         if (con!=null&&!con.equals("undefined")){
             mapValue.put("con","%"+con+"%");
         }

+ 22 - 1
src/main/java/com/steerinfo/dil/util/DataChange.java

@@ -167,7 +167,7 @@ public class DataChange {
     }
 
     /**
-     * 根据时间段查询数据
+     * 根据时间段查询数据 支持只选择单个时间
      * @Author TXF
      * @Date 2022/1/10 23:21
      * @param startTime
@@ -188,4 +188,25 @@ public class DataChange {
             map.put("oneDate", sdf.format(new Date()));
         }
     }
+
+    /**
+     * 只支持两个时间查询
+     * @Author TXF
+     * @Date 2022/1/15 9:08
+     * @param startTime
+     * @param endTime
+     * @param sdf
+     * @return
+     **/
+    public static void queryDataByTwoDate(String startTime, String endTime, Map<String, Object> map,SimpleDateFormat sdf){
+        if (startTime != null && !"null".equals(startTime) && endTime != null && !"null".equals(endTime)) {
+            map.put("startDate", sdf.format(new Date(Long.parseLong(startTime))));
+            map.put("endDate", sdf.format(new Date(Long.parseLong(endTime))));
+        }else {
+            //如果两者时间都为空,则查询当天数据
+            SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
+            String nowDate = sdfDate.format(new Date());
+            map.put("oneDate", nowDate + " 00:00:00");
+        }
+    }
 }

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

@@ -215,11 +215,11 @@
                               and RCA.CARRIER_SSO_ID = #{carrierSsoId}
                           </if>
                           <if test="oneDate != null">
-                              and to_char(TER.RESULT_ENTRY_GATE_TIME, 'YYYY-MM-DD') = #{oneDate}
+                              and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= TER.RESULT_ENTRY_GATE_TIME
                           </if>
                           <if test="startDate != null">
-                              and to_date(#{startDate}, 'yyyy-mm-dd') &lt;= TER.RESULT_ENTRY_GATE_TIME
-                              and to_date(#{endDate}, 'yyyy-mm-dd') >= TER.RESULT_ENTRY_GATE_TIME
+                              and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= TWR.RESULT_GROSS_WEIGHT_TIME
+                              and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= TWR.RESULT_GROSS_WEIGHT_TIME
                           </if>
              )
         <where>

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

@@ -1193,9 +1193,9 @@
         left join RMS_CAPACITY RC
         on RC.CAPACITY_ID = OO.CAPACITY_ID
         WHERE OO.ORDER_TYPE = #{orderTypee} and TER.RESULT_ENTRY_GATE_TIME IS NOT NULL
-            `<if test="userId">
+            <if test="userId">
                and ASO.INSERT_USERNAME=#{userId}
-            </if>`
+            </if>
             <if test="userIds">
                and ASO.UPDATE_USERNAME=#{userIds}
             </if>