Administrator 1 年之前
父節點
當前提交
5cec1f6a4d

+ 12 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/BomanCommonController.java

@@ -5,8 +5,10 @@ import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.system.domain.BomanReservat;
 import com.ruoyi.system.domain.BomanReservatConfigTime;
 import com.ruoyi.system.service.IBomanReservatConfigTimeService;
+import com.ruoyi.system.service.IBomanReservatService;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.math.NumberUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +32,8 @@ public class BomanCommonController extends BaseController {
     @Autowired
     private RedisCache redisCache;
 
+    @Autowired
+    private IBomanReservatService bomanReservatService;
 
     /**
      * H5时段信息 查询预约时段配置列表
@@ -57,4 +61,12 @@ public class BomanCommonController extends BaseController {
         }
         return getDataTable(list);
     }
+
+    /**
+     * 预约首页统计
+     */
+    @PostMapping("/indexStatistics")
+    public AjaxResult indexStatistics(BomanReservat bomanReservat) {
+        return  bomanReservatService.indexStatistics(bomanReservat);
+    }
 }

+ 12 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -43,6 +43,18 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return new Date();
     }
 
+    /**
+     * 得到加减某个值的日期 yyyy-MM-dd
+     *
+     * @return
+     */
+    public static String getDateByDays(long days) {
+        //days为-1就是昨天日期,为1就是明天日期
+
+        LocalDate localDate = LocalDate.now().plusDays(days);
+        return localDate.toString();
+    }
+
     /**
      * 获取当前日期, 默认格式为yyyy-MM-dd
      * 

+ 21 - 11
ruoyi-system/src/main/java/com/ruoyi/system/domain/BomanReservat.java

@@ -45,9 +45,7 @@ public class BomanReservat extends BaseEntity
     private String visitRemark;
 
     /** 预约日期 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "预约日期", width = 30, dateFormat = "yyyy-MM-dd")
-    private Date visitDate;
+    private String visitDate;
 
     /** 预约时间 */
     @Excel(name = "预约时间")
@@ -87,12 +85,24 @@ public class BomanReservat extends BaseEntity
 
     /** 接人人员手机号 */
     private String receptionPhone;
+    /**
+     * 查询时间类型 1:今天 2:昨天 3:近7天 4:近三十天
+     */
+    private String dataType;
 
     /** 创建部门 */
     @Excel(name = "创建部门")
     private Long createDept;
 
-    public void setReservatId(Long reservatId) 
+    public String getDataType() {
+        return dataType;
+    }
+
+    public void setDataType(String dataType) {
+        this.dataType = dataType;
+    }
+
+    public void setReservatId(Long reservatId)
     {
         this.reservatId = reservatId;
     }
@@ -155,16 +165,16 @@ public class BomanReservat extends BaseEntity
     {
         return visitRemark;
     }
-    public void setVisitDate(Date visitDate) 
-    {
-        this.visitDate = visitDate;
-    }
 
-    public Date getVisitDate() 
-    {
+    public String getVisitDate() {
         return visitDate;
     }
-    public void setVisitTime(String visitTime) 
+
+    public void setVisitDate(String visitDate) {
+        this.visitDate = visitDate;
+    }
+
+    public void setVisitTime(String visitTime)
     {
         this.visitTime = visitTime;
     }

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IBomanReservatService.java

@@ -62,4 +62,11 @@ public interface IBomanReservatService
     public int deleteBomanReservatByReservatId(Long reservatId);
 
     AjaxResult examine(BomanReservat bomanReservat);
+
+    /**
+     * 预约首页统计
+     * @param
+     * @return
+     */
+    AjaxResult  indexStatistics (BomanReservat bomanReservat);
 }

+ 35 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BomanReservatServiceImpl.java

@@ -1,6 +1,8 @@
 package com.ruoyi.system.service.impl;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
@@ -44,6 +46,13 @@ public class BomanReservatServiceImpl implements IBomanReservatService
     @Override
     public List<BomanReservat> selectBomanReservatList(BomanReservat bomanReservat)
     {
+        String dataType = bomanReservat.getDataType();
+        if ("1".equals(dataType)){
+            bomanReservat.setVisitDate(DateUtils.getDate());
+        }
+        if ("2".equals(dataType)){
+            bomanReservat.setVisitDate(DateUtils.getDateByDays(-1));
+        }
         return bomanReservatMapper.selectBomanReservatList(bomanReservat);
     }
 
@@ -111,4 +120,30 @@ public class BomanReservatServiceImpl implements IBomanReservatService
         int i = bomanReservatMapper.updateBomanReservat(bomanReservat);
         return i > 0 ? AjaxResult.success() : AjaxResult.error();
     }
+
+    /**
+     * 预约首页统计
+     * @param
+     * @return
+     */
+    @Override
+    public AjaxResult indexStatistics(BomanReservat bomanReservat) {
+        Map<String,Object> map = new HashMap<>(4);
+        map.put("canGuan",0);
+        map.put("yuYue",0);
+        map.put("todayYuYue",0);
+        map.put("todayCanGuan",0);
+        List<BomanReservat> bomanReservats = bomanReservatMapper.selectBomanReservatList(bomanReservat);
+        if (bomanReservats != null && bomanReservats.size() > 0){
+            //来访数
+            long canGuan = bomanReservats.stream().filter(s -> "2".equals(s.getVisitStatus())).count();
+            long todayYuYue = bomanReservats.stream().filter(s -> DateUtils.getDate().equals(s.getVisitDate())).count();
+            long todayCanGuan = bomanReservats.stream().filter(s -> DateUtils.getDate().equals(s.getVisitDate())).filter(s -> "2".equals(s.getVisitStatus())).count();
+            map.put("canGuan",canGuan);
+            map.put("yuYue",bomanReservats.size());
+            map.put("todayYuYue",todayYuYue);
+            map.put("todayCanGuan",todayCanGuan);
+        }
+        return AjaxResult.success(map);
+    }
 }

+ 2 - 0
ruoyi-system/src/main/resources/mapper/system/BomanReservatMapper.xml

@@ -56,6 +56,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="receptionName != null "> and reception_name = #{receptionName}</if>
             <if test="receptionPhone != null "> and reception_phone = #{receptionPhone}</if>
             <if test="createDept != null "> and create_dept = #{createDept}</if>
+            <if test="dataType != null and dataType == '3'"> and  visit_date &gt;= DATE_SUB(NOW(), INTERVAL 7 DAY)</if>
+            <if test="dataType != null and dataType == '4'"> and visit_date &gt;= DATE_SUB(NOW(), INTERVAL 30 DAY))</if>
         </where>
     </select>