Эх сурвалжийг харах

智慧安防随机数范围修改

ZhangManMan 2 жил өмнө
parent
commit
0ad8783533

+ 39 - 0
src/main/java/com/sky/ioc/mapper/CuisineMapper.java

@@ -1,4 +1,43 @@
 package com.sky.ioc.mapper;
 
+import com.sky.ioc.entity.params.IocParam;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+@Mapper
 public interface CuisineMapper {
+
+    @Select("<script> " +
+            "SELECT count(DISTINCT user_id) FROM cuisine_order  where 1=1 " +
+            "<if test='iocParam!=null and iocParam.deptId != null '>" +
+            " and department_id=#{iocParam.deptId} " +
+            "</if>"+
+            "<if test='iocParam!=null and iocParam.timeRange != null '>" +
+            " and order_time BETWEEN #{iocParam.timeRange.startDate} AND #{iocParam.timeRange.endDate} " +
+            "</if>" +
+            "</script>")
+    Integer getTotalPersonByCompanyIdAndDeptId(@Param("iocParam") IocParam iocParam);
+
+    @Select("<script>" +
+            "SELECT sum(order_price) FROM cuisine_order where 1=1 " +
+            "<if test='iocParam!=null and iocParam.deptId != null '>" +
+            " and department_id=#{iocParam.deptId} " +
+            "</if>"+
+            "<if test='iocParam!=null and iocParam.timeRange != null '>" +
+            " and order_time BETWEEN #{iocParam.timeRange.startDate} AND #{iocParam.timeRange.endDate} " +
+            "</if>"+
+            "</script>")
+    Double getTotalPriceByCompanyIdAndDeptId(@Param("iocParam") IocParam iocParam);
+
+    @Select("<script>" +
+            "SELECT count(1) FROM cuisine_order where 1=1 " +
+            "<if test='iocParam!=null and iocParam.deptId != null '>" +
+            " and department_id=#{iocParam.deptId} " +
+            "</if>"+
+            "<if test='iocParam!=null and iocParam.timeRange != null '>" +
+            " and order_time BETWEEN #{iocParam.timeRange.startDate} AND #{iocParam.timeRange.endDate} " +
+            "</if>"+
+            "</script>")
+    Integer getTotalOrderByCompanyIdAndDeptId(@Param("iocParam") IocParam iocParam);
 }

+ 2 - 8
src/main/java/com/sky/ioc/service/personnel/impl/PersonnelServiceImpl.java

@@ -79,14 +79,8 @@ public class PersonnelServiceImpl implements PersonnelService {
         ThreadLocalRandom random = ThreadLocalRandom.current();
         int enterCount = random.nextInt(1000, 3000);
         int orderCount = random.nextInt(50, 300);
-        int inCount = random.nextInt(1000, 3000);
-        while (inCount>enterCount){
-            inCount = random.nextInt(1000, 3000);
-        }
-        int arrivedCount = random.nextInt(50, 300);
-        while (arrivedCount>orderCount){
-            arrivedCount = random.nextInt(1000, 3000);
-        }
+        int inCount = random.nextInt(0, enterCount);
+        int arrivedCount = random.nextInt(0, orderCount);
         DecimalFormat decimalFormat = new DecimalFormat("#.0");
         float compare = (float) Math.random();
         compare = Float.parseFloat(decimalFormat.format(compare));