From f047fe37d7e48f9e8b2337c0610cec924a9005bc Mon Sep 17 00:00:00 2001 From: changpengfei Date: Sat, 11 Sep 2021 15:29:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E9=A6=96=E9=A1=B5=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../talkonlineweb/controller/IndexController.java | 32 ++++++++++++++ .../com/lyms/talkonlineweb/mapper/IndexMapper.java | 50 ++++++++++++++++++++++ .../lyms/talkonlineweb/service/IndexService.java | 7 +++ .../service/impl/IndexServiceImpl.java | 39 +++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/IndexController.java create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/IndexMapper.java create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/IndexService.java create mode 100644 talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/IndexServiceImpl.java diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/IndexController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/IndexController.java new file mode 100644 index 0000000..d83b8c6 --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/IndexController.java @@ -0,0 +1,32 @@ +package com.lyms.talkonlineweb.controller; + +import com.lyms.talkonlineweb.result.BaseResponse; +import com.lyms.talkonlineweb.service.IndexService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@RestController +@RequestMapping("index") +public class IndexController { + + @Autowired + private IndexService indexService; + + /** + * 访问统计 + * @return + */ + @GetMapping("getVsStat") + public BaseResponse getVsStat(){ + BaseResponse baseResponse=new BaseResponse(); + + Map rs=indexService.getVsStat(); + baseResponse.setObject(rs); + return baseResponse; + } + +} diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/IndexMapper.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/IndexMapper.java new file mode 100644 index 0000000..120517b --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/IndexMapper.java @@ -0,0 +1,50 @@ +package com.lyms.talkonlineweb.mapper; + +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; + +/** + * 首页统计使用 + */ +public interface IndexMapper { + + //今日访问人数 + @Select("SELECT COUNT(*) cnt FROM lyms_logs l WHERE DATE(l.`log_date`)=DATE(NOW())") + public Map getCurDayVs(); + + //得到最近1个月的访问量 + @Select("SELECT DATE(l.`log_date`) dt, COUNT(*) cnt FROM lyms_logs l WHERE l.`log_date`>DATE_SUB(now(),INTERVAL 1 MONTH) GROUP BY DATE(l.`log_date`)") + public List> getLastMonthVs(); + +// 总访问人数 + @Select("SELECT COUNT(*) cnt FROM lyms_logs l") + public Map getSumVsCnt(); + +// 今日问诊量 + @Select("select count(1) cnt from lyms_tkrecord tk where date(tk.createdtime)=date(NOW()) ") + public Map getCurDaysTk(); + + @Select("SELECT DATE(tk.createdtime) dt,COUNT(1) cnt FROM lyms_tkrecord tk WHERE tk.createdtime > DATE_SUB(NOW(),INTERVAL 1 MONTH) GROUP BY DATE(tk.createdtime)") + public List> getLastMonthTk(); + + @Select("select count(1) cnt from lyms_tkrecord tk ") + public Map getSumTkCnt(); + + // 今日完成问诊量 + @Select("select count(1) cnt from lyms_tkrecord tk where stat=1 and date(tk.createdtime)=date(NOW()) ") + public Map getCurDaysTkFs(); + + @Select("SELECT DATE(tk.createdtime) dt,COUNT(1) cnt FROM lyms_tkrecord tk WHERE stat=1 and tk.createdtime > DATE_SUB(NOW(),INTERVAL 1 MONTH) GROUP BY DATE(tk.createdtime)") + public List> getLastMonthTkFs(); + + @Select("select count(1) cnt from lyms_tkrecord tk where stat=1 ") + public Map getSumTkCntFs(); + + @Select("SELECT searchtxt,COUNT(1) cnt FROM lyms_searchlogs s GROUP BY searchtxt ORDER BY cnt DESC ") + List> getSearch(); + + @Select("SELECT COUNT(1) cnt FROM lyms_searchlogs s ") + Map getSearchSum(); +} diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/IndexService.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/IndexService.java new file mode 100644 index 0000000..9ef6b11 --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/IndexService.java @@ -0,0 +1,7 @@ +package com.lyms.talkonlineweb.service; + +import java.util.Map; + +public interface IndexService { + Map getVsStat(); +} diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/IndexServiceImpl.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/IndexServiceImpl.java new file mode 100644 index 0000000..5b86746 --- /dev/null +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/IndexServiceImpl.java @@ -0,0 +1,39 @@ +package com.lyms.talkonlineweb.service.impl; + +import com.lyms.talkonlineweb.mapper.IndexMapper; +import com.lyms.talkonlineweb.service.IndexService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.Map; + +@Service +public class IndexServiceImpl implements IndexService { + @Autowired + private IndexMapper indexMapper; + + @Override + public Map getVsStat() { + Map rs=new HashMap<>(); +// 访问统计 + rs.put("curVsDay",indexMapper.getCurDayVs()); + rs.put("lastVsCnt",indexMapper.getLastMonthVs()); + rs.put("sumVsCnt",indexMapper.getSumVsCnt()); + +// 问诊统计 + rs.put("curDayTkcnt",indexMapper.getCurDaysTk()); + rs.put("lastTkCnt",indexMapper.getLastMonthTk()); + rs.put("sumTkCnt",indexMapper.getSumTkCnt()); + +// 完成问诊统计 + rs.put("curDayTkcntFs",indexMapper.getCurDaysTkFs()); + rs.put("lastTkCntFs",indexMapper.getLastMonthTkFs()); + rs.put("sumTkCntFs",indexMapper.getSumTkCntFs()); + +// 热门搜索 + rs.put("serch",indexMapper.getSearch()); + rs.put("serchSum",indexMapper.getSearchSum()); + return rs; + } +} -- 1.8.3.1