luobang 3 роки тому
батько
коміт
8ab2c16ef6

+ 7 - 1
src/main/java/com/steerinfo/dil/controller/BmstruckDetailsOrderController.java

@@ -5,6 +5,7 @@ import com.steerinfo.dil.feign.ESFeign;
 import com.steerinfo.dil.service.impl.BmstruckDetailsOrderServiceImpl;
 import com.steerinfo.dil.util.BaseRESTfulController;
 import com.steerinfo.dil.util.ColumnDataUtil;
+import com.steerinfo.dil.util.DataChange;
 import com.steerinfo.dil.util.PageListAdd;
 import com.steerinfo.framework.controller.RESTfulResult;
 import io.swagger.annotations.ApiImplicitParam;
@@ -15,6 +16,7 @@ import org.springframework.beans.factory.annotation.Required;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -36,6 +38,7 @@ public class BmstruckDetailsOrderController extends BaseRESTfulController {
     @Autowired
     ESFeign esFeign;
 
+    private final SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     /**
      * 展示汽运详单信息
      *
@@ -128,7 +131,9 @@ public class BmstruckDetailsOrderController extends BaseRESTfulController {
                                                      String carrierSsoId,
                                                      Integer detailStatus,
                                                      Integer orderType,
-                                                     String userId){
+                                                     String userId,
+                                                     String startTime,
+                                                     String endTime){
         if (carrierSsoId != null && carrierSsoId.equals("undefined")) {
             carrierSsoId = null;
         }
@@ -139,6 +144,7 @@ public class BmstruckDetailsOrderController extends BaseRESTfulController {
         if(userId != null){
             mapValue.put("userId","%"+ userId +"%");
         }
+        DataChange.queryDataByDateTime(startTime, endTime, mapValue, sdfDateTime);//根据时间段查询数据
         mapValue.put("detailStatus",detailStatus);
         List<Map<String, Object>> truckDetailList = bmstruckDetailsOrderService.getInwardWeightDetailsOrder(mapValue,orderType);
         PageHelper.startPage(pageNum, pageSize);

+ 33 - 12
src/main/java/com/steerinfo/dil/util/DataChange.java

@@ -7,6 +7,7 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Pattern;
 
 /**
  * @ author    :TXF
@@ -17,24 +18,45 @@ public class DataChange {
 
 
     /**
-     * 解析前端传来的日期字符串
+     * 时间转换类
+     * 处理了三种类型 yyyy-MM-dd HH:mm:ss  yyyy/MM/dd HH:mm:ss  时间戳类型(带毫秒数时间戳13位)
      * @param vueDate
      * @return
      */
     public static Date dataToDate(Object vueDate){
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        Date parseDate = null;
-        if (vueDate != null){
+        if(vueDate instanceof Date){
+            return (Date) vueDate;
+        } else {
             try {
-                String date = (String) vueDate;
-                parseDate = sdf.parse(date);
-            } catch (ParseException e) {
-                e.printStackTrace();
+                String str = String.valueOf(vueDate);
+                if(judgeNumber(str) && str.length() == 13){
+                    return new Date(Long.parseLong(str));
+                }else if(str.contains("-")){
+                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                    return sdf.parse(str);
+                }else if(str.contains("/")){
+                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+                    return sdf.parse(str);
+                }
+            }catch (Exception e){
+                System.out.println("时间解析错误!返回null");
+                return null;
             }
         }
-        return parseDate;
+        return null;
+    }
+
+    /**
+     * 判断是否纯数字(不带小数点)仅供上面方法使用
+     * @param str
+     * @return
+     */
+    public static boolean judgeNumber(String str){
+        Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
+        return pattern.matcher(str).matches();
     }
 
+
     /**
      * 数据转换成BigDecimal
      * @param data
@@ -106,19 +128,18 @@ public class DataChange {
      * @param key
      */
     public static void dataTo2Number(List<Map<String, Object>> list, String ...key){
+        DecimalFormat df =  new DecimalFormat("0.00");
         //遍历List
         for (Map<String, Object> map : list) {
             for (String s : key) {
                 //修改数据为带两位小数
                 try {
-                    BigDecimal oldDate = (BigDecimal) map.get(s);
-                    DecimalFormat df =  new DecimalFormat("0.00");
+                    BigDecimal oldDate = dataToBigDecimal(map.get(s));
                     String resultDeduction = df.format(oldDate.doubleValue());
                     map.put(s, resultDeduction);
                 } catch (Exception e) {
                     System.out.println("原料扣减量数据有误");
                 }
-
             }
         }
     }

+ 21 - 0
src/main/resources/com/steerinfo/dil/mapper/BmstruckDetailsOrderMapper.xml

@@ -1274,6 +1274,13 @@
                 <if test="userId != null" >
                     AND  AIR.INSERT_USERNAME LIKE #{userId}
                 </if>
+                <if test="oneDate != null">
+                      and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= bdo.INSERT_TIME
+                </if>
+                <if test="startDate != null">
+                      and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= bdo.INSERT_TIME
+                      and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= bdo.INSERT_TIME
+                </if>
             )
         <where>
             <if test="capacityNumber!= null">
@@ -1402,6 +1409,13 @@
                         AND bdo.WETHER_TO_STATEMENT = #{detailStatus}
                         <if test="userId != null" >
                             AND AIR.INSERT_USERNAME LIKE #{userId}
+                        </if>
+                        <if test="oneDate != null">
+                            and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= bdo.INSERT_TIME
+                        </if>
+                        <if test="startDate != null">
+                            and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= bdo.INSERT_TIME
+                            and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= bdo.INSERT_TIME
                         </if>)
         <where>
             <if test="capacityNo!= null">
@@ -1482,6 +1496,13 @@
                 AND bdo.WETHER_TO_STATEMENT = #{detailStatus}
                 <if test="userId != null" >
                     AND AIR.INSERT_USERNAME LIKE #{userId}
+                </if>
+                <if test="oneDate != null">
+                    and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= bdo.INSERT_TIME
+                </if>
+                <if test="startDate != null">
+                    and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= bdo.INSERT_TIME
+                    and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= bdo.INSERT_TIME
                 </if>)
         <where>
             <if test="capacityNo!= null">