diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/IndexController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/IndexController.java index 6ac75c6..8ecfaf2 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/IndexController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/IndexController.java @@ -129,4 +129,19 @@ public class IndexController { return baseResponse; } + /** + * 首页科室占比统计 + * @param hid + * @return + */ + @GetMapping("getDepartStat") + public BaseResponse getDepartStat(Integer hid){ + BaseResponse baseResponse=new BaseResponse(); + Map param=new HashMap<>(); + param.put("hid",hid); + Map rs=indexService.getDepartStat(param); + 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 index 9b74c31..574e602 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/IndexMapper.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/IndexMapper.java @@ -1,5 +1,6 @@ package com.lyms.talkonlineweb.mapper; +import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.util.List; @@ -49,8 +50,8 @@ public interface IndexMapper { Map getSearchSum(); // 科室类别占比 - @Select("SELECT hd.`dname`,COUNT(1) cnt FROM lyms_tkrecord tk,lyms_doctor d,lyms_hdepart hd WHERE tk.`did`=d.`did` AND d.`dpid`=hd.`did` GROUP BY hd.`dname`") - List> getDepart(); + @Select("SELECT hd.`dname`,COUNT(1) cnt FROM lyms_tkrecord tk,lyms_doctor d,lyms_hdepart hd WHERE tk.`did`=d.`did` AND d.`dpid`=hd.`did` ${hSql} GROUP BY hd.`dname`") + List> getDepart(@Param("hSql") String hSql); @Select("SELECT DATE(s.`createdtime`) dt,COUNT(1) cnt FROM lyms_searchlogs s GROUP BY DATE(s.`createdtime`) ORDER BY cnt DESC LIMIT 7") List> getSearchByDay(); diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/IndexService.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/IndexService.java index 9ef6b11..6012e74 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/IndexService.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/IndexService.java @@ -4,4 +4,6 @@ import java.util.Map; public interface IndexService { Map getVsStat(); + + Map getDepartStat(Map param); } 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 index dae5775..4773bf2 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/IndexServiceImpl.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/IndexServiceImpl.java @@ -8,6 +8,7 @@ import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; @Service public class IndexServiceImpl implements IndexService { @@ -38,10 +39,24 @@ public class IndexServiceImpl implements IndexService { rs.put("serchSum",indexMapper.getSearchSum()); // 科室类别占比 - List> dLst=indexMapper.getDepart(); + List> dLst=indexMapper.getDepart(""); rs.put("depart",dLst); rs.put("departCnt",dLst.stream().mapToInt(m-> Math.toIntExact((long) m.get("cnt"))).sum()); return rs; } + + @Override + public Map getDepartStat(Map param) { + Map rs=new HashMap<>(); + String hSql=""; + if(Objects.nonNull(param.get("hid"))){ + hSql=" AND hd.`hid`= "+param.get("hid"); + } + // 科室类别占比 + List> dLst=indexMapper.getDepart(hSql); + rs.put("depart",dLst); + rs.put("departCnt",dLst.stream().mapToInt(m-> Math.toIntExact((long) m.get("cnt"))).sum()); + return rs; + } } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HXTask.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HXTask.java index a6600e5..4ab304c 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HXTask.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HXTask.java @@ -27,7 +27,7 @@ public class HXTask { @Autowired private LymsDictService lymsDictService; - @Scheduled(initialDelay=1000, fixedRate=5000) +// @Scheduled(initialDelay=1000, fixedRate=5000) public void checkDoctorStat(){ Map param=new HashMap<>(); diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java index b5ad32c..cc3d186 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java @@ -37,7 +37,7 @@ public class PushArticleTask { @Autowired private LymsDictService lymsDictService; - @Scheduled(initialDelay=1000, fixedRate=5000) +// @Scheduled(initialDelay=1000, fixedRate=5000) public void pushArtcle(){ Map param=new HashMap<>();