浏览代码

fix 预约逻辑完成

Administrator 1 年之前
父节点
当前提交
10ca59e916

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

@@ -7,6 +7,7 @@ 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.IBomanNewsService;
 import com.ruoyi.system.service.IBomanReservatConfigTimeService;
 import com.ruoyi.system.service.IBomanReservatService;
 import org.apache.commons.lang3.ObjectUtils;
@@ -35,6 +36,9 @@ public class BomanCommonController extends BaseController {
     @Autowired
     private IBomanReservatService bomanReservatService;
 
+    @Autowired
+    private IBomanNewsService bomanNewsService;
+
     /**
      * H5时段信息 查询预约时段配置列表
      */
@@ -88,4 +92,13 @@ public class BomanCommonController extends BaseController {
         AjaxResult calendar = bomanReservatConfigTimeService.getCalendar(bomanReservatConfigTime.getReservatConfigDate());
         return calendar;
     }
+
+
+    /**
+     * 发布首页统计
+     */
+    @PostMapping("/indexStatisticsInFor")
+    public AjaxResult indexStatisticsInFor() {
+        return  bomanNewsService.indexStatisticsInFor();
+    }
 }

+ 10 - 10
ruoyi-system/src/main/java/com/ruoyi/system/domain/BomanNews.java

@@ -54,7 +54,7 @@ public class BomanNews extends BaseEntity
 
     /** 类型(1:普通,2:热门...) */
     @Excel(name = "类型(1:普通,2:热门...)")
-    private Integer type;
+    private String type;
 
     /** 是否允许评论(0:不允许,1:允许) */
     @Excel(name = "是否允许评论(0:不允许,1:允许)")
@@ -89,7 +89,15 @@ public class BomanNews extends BaseEntity
     @Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date releaseTime;
 
-    public void setNewsId(Long newsId) 
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public void setNewsId(Long newsId)
     {
         this.newsId = newsId;
     }
@@ -170,15 +178,7 @@ public class BomanNews extends BaseEntity
     {
         return description;
     }
-    public void setType(Integer type) 
-    {
-        this.type = type;
-    }
 
-    public Integer getType() 
-    {
-        return type;
-    }
     public void setAllowcomments(String allowcomments) 
     {
         this.allowcomments = allowcomments;

+ 12 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java

@@ -21,6 +21,10 @@ public class SysNotice extends BaseEntity
 
     /** 公告标题 */
     private String noticeTitle;
+    /**
+     * 封面
+     */
+    private String noticeImage;
 
     /** 公告类型(1通知 2公告) */
     private String noticeType;
@@ -54,6 +58,14 @@ public class SysNotice extends BaseEntity
         return noticeTitle;
     }
 
+    public String getNoticeImage() {
+        return noticeImage;
+    }
+
+    public void setNoticeImage(String noticeImage) {
+        this.noticeImage = noticeImage;
+    }
+
     public void setNoticeType(String noticeType)
     {
         this.noticeType = noticeType;

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

@@ -1,6 +1,8 @@
 package com.ruoyi.system.service;
 
 import java.util.List;
+
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.system.domain.BomanNews;
 
 /**
@@ -58,4 +60,9 @@ public interface IBomanNewsService
      * @return 结果
      */
     public int deleteBomanNewsByNewsId(Long newsId);
+
+    /**
+     * 发布首页统计
+     */
+    AjaxResult indexStatisticsInFor ();
 }

+ 75 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BomanNewsServiceImpl.java

@@ -1,7 +1,18 @@
 package com.ruoyi.system.service.impl;
 
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysDictData;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.system.service.ISysDictTypeService;
+import org.apache.commons.lang3.math.NumberUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.BomanNewsMapper;
@@ -20,6 +31,9 @@ public class BomanNewsServiceImpl implements IBomanNewsService
     @Autowired
     private BomanNewsMapper bomanNewsMapper;
 
+    @Autowired
+    private ISysDictTypeService dictTypeService;
+
     /**
      * 查询boman_news
      * 
@@ -93,4 +107,65 @@ public class BomanNewsServiceImpl implements IBomanNewsService
     {
         return bomanNewsMapper.deleteBomanNewsByNewsId(newsId);
     }
+
+    /**
+     * 发布首页统计
+     */
+    @Override
+    public AjaxResult indexStatisticsInFor() {
+        Map<String,Object> map = new HashMap<>();
+        map.put("year",0);
+        map.put("yearMonth",0);
+        //查询字典值
+        List<SysDictData> dictDataList = dictTypeService.selectDictDataByType("wenzl");
+        if (dictDataList != null && dictDataList.size() > 0){
+            for (SysDictData sysDictData : dictDataList) {
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("this",0);
+                jsonObject.put("last",0);
+                jsonObject.put("status",0);
+                map.put(sysDictData.getDictValue(),jsonObject);
+            }
+        }
+        //查询本月发布的文章数据
+        BomanNews bomanNews = new BomanNews();
+        bomanNews.setReleaseTime(DateUtils.getNowDate());
+        //本月数据
+        List<BomanNews> bomanNewsList = bomanNewsMapper.selectBomanNewsList(bomanNews);
+        //查询上月数据
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar c = Calendar.getInstance();
+        c.add(Calendar.MONTH, -1); //得到前一个月
+        bomanNews.setReleaseTime(DateUtils.parseDate(format.format(c.getTime())));
+        List<BomanNews> bomanNewsListLast = bomanNewsMapper.selectBomanNewsList(bomanNews);
+        if (bomanNewsList != null && bomanNewsList.size() > 0){
+            map.put("yearMonth",bomanNewsList.size());
+            //进行数据比对
+            Map<String, List<BomanNews>> collect = bomanNewsList.stream().collect(Collectors.groupingBy(BomanNews::getType));
+            if (collect != null && collect.size() > 0){
+                for (String key : collect.keySet()) {
+                    JSONObject jsonObject = (JSONObject)map.get(key);
+                    jsonObject.put("this",collect.get(key).size());
+                }
+            }
+            if (bomanNewsListLast != null && bomanNewsListLast.size() > 0){
+                //计算上月数据
+                Map<String, List<BomanNews>> collectLast = bomanNewsListLast.stream().collect(Collectors.groupingBy(BomanNews::getType));
+                if (collect != null && collect.size() > 0){
+                    for (String key : collect.keySet()) {
+                        //本月数据
+                        JSONObject jsonObject = (JSONObject)map.get(key);
+                        int num = (int)jsonObject.get("this");
+                        //上月数据
+                        int numLast = collectLast.get(key).size();
+                        //计算 x=y=0 x<y=-1 x>y=1
+                        int compare = NumberUtils.compare(num, numLast);
+                        jsonObject.put("last",num-numLast);
+                        jsonObject.put("status",compare);
+                    }
+                }
+            }
+        }
+        return AjaxResult.success(map);
+    }
 }

+ 1 - 1
ruoyi-system/src/main/resources/mapper/system/BomanNewsMapper.xml

@@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="readnumber != null "> and readnumber = #{readnumber}</if>
             <if test="top != null "> and top = #{top}</if>
             <if test="orders != null "> and orders = #{orders}</if>
-            <if test="releaseTime != null "> and release_time = #{releaseTime}</if>
+            <if test="releaseTime != null "> and DATE_FORMAT(release_time,'%Y%m') = DATE_FORMAT(#{releaseTime},'%Y%m');</if>
         </where>
     </select>
     

+ 5 - 1
ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml

@@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="noticeId"       column="notice_id"       />
         <result property="noticeTitle"    column="notice_title"    />
         <result property="noticeType"     column="notice_type"     />
+        <result property="noticeImage"     column="notice_image"     />
         <result property="noticeContent"  column="notice_content"  />
         <result property="status"         column="status"          />
         <result property="createBy"       column="create_by"       />
@@ -18,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
     
     <sql id="selectNoticeVo">
-        select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark 
+        select notice_id, notice_title,notice_image, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark
 		from sys_notice
     </sql>
     
@@ -46,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         insert into sys_notice (
 			<if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
 			<if test="noticeType != null and noticeType != '' ">notice_type, </if>
+			<if test="noticeImage != null and noticeImage != '' ">notice_image, </if>
 			<if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
 			<if test="status != null and status != '' ">status, </if>
 			<if test="remark != null and remark != ''">remark,</if>
@@ -54,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  		)values(
 			<if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle}, </if>
 			<if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
+			<if test="noticeImage != null and noticeImage != ''">#{noticeImage}, </if>
 			<if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
 			<if test="status != null and status != ''">#{status}, </if>
 			<if test="remark != null and remark != ''">#{remark},</if>
@@ -67,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <set>
             <if test="noticeTitle != null and noticeTitle != ''">notice_title = #{noticeTitle}, </if>
             <if test="noticeType != null and noticeType != ''">notice_type = #{noticeType}, </if>
+            <if test="noticeImage != null and noticeImage != ''">notice_image = #{noticeImage}, </if>
             <if test="noticeContent != null">notice_content = #{noticeContent}, </if>
             <if test="status != null and status != ''">status = #{status}, </if>
             <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>