diff --git a/src/main/java/com/org/system/service/SysUserService.java b/src/main/java/com/org/system/service/SysUserService.java index 6764a60..576c4ab 100644 --- a/src/main/java/com/org/system/service/SysUserService.java +++ b/src/main/java/com/org/system/service/SysUserService.java @@ -91,7 +91,7 @@ public class SysUserService extends ServiceImpl { int countByAccount = this.count(queryWrapper); //大于等于1个则表示重复 if (countByAccount >= 1) { - throw new CustomException("用户名:" + sysUser.getUserName() + "已存在"); + throw new CustomException("身份证号:" + sysUser.getUserName() + "已存在"); } } diff --git a/src/main/java/com/org/web/data/controller/DataController.java b/src/main/java/com/org/web/data/controller/DataController.java index ca66061..36de72f 100644 --- a/src/main/java/com/org/web/data/controller/DataController.java +++ b/src/main/java/com/org/web/data/controller/DataController.java @@ -20,7 +20,7 @@ public class DataController extends BaseController { @PostMapping("/statistics") @PreAuthorize("@ss.hasPermi('data:statistics')") - public AjaxResult add() { + public AjaxResult statistics() { return AjaxResult.success(dataService.queryDataStatistics()); } diff --git a/src/main/java/com/org/web/data/domain/DataStatistics.java b/src/main/java/com/org/web/data/domain/DataStatistics.java index 5d559c2..00eaa6b 100644 --- a/src/main/java/com/org/web/data/domain/DataStatistics.java +++ b/src/main/java/com/org/web/data/domain/DataStatistics.java @@ -3,6 +3,7 @@ package com.org.web.data.domain; import lombok.Data; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -12,17 +13,33 @@ import java.util.List; @Data public class DataStatistics { - List villageCountList = new ArrayList<>(); - - List ifHelpPoorList = new ArrayList<>(); - List sexList = new ArrayList<>(); - List nursingLevelList = new ArrayList<>(); - List ageList = new ArrayList<>(); - List inHospitalList = new ArrayList<>(); + List nursingLevelList = new ArrayList<>(); + List ifHelpPoorList = new ArrayList<>(); + + + int ljrzCount = 0; + int jnrzCount = 0; + int byxzCount = 0; + int mqzyCount = 0; + int wcjyCount = 0; + int jnjyCount = 0; + + BigDecimal jzgyRate = BigDecimal.ZERO; + BigDecimal fsgyRate = BigDecimal.ZERO; + + // 在院人数村籍榜 + List villageRankList = new ArrayList<>(); + + // 入住情况 + List roomTypeList = new ArrayList<>(); List roomCountList = new ArrayList<>(); + + // 各村供养情况 + List villageCountList = new ArrayList<>(); + } diff --git a/src/main/java/com/org/web/data/domain/DataStatisticsItem.java b/src/main/java/com/org/web/data/domain/DataStatisticsItem.java index 6a49864..4a48e56 100644 --- a/src/main/java/com/org/web/data/domain/DataStatisticsItem.java +++ b/src/main/java/com/org/web/data/domain/DataStatisticsItem.java @@ -13,15 +13,20 @@ public class DataStatisticsItem { /** * 子项名称 */ - private String itemName; - - /** - * 子项值 - */ - private int itemValue; + private String name; /** * 子项备注 可存放数据字典的value值 */ - private String itemRemark; + private Integer id; + + /** + * 子项值 + */ + private int value; + + /** + * 子项值2 + */ + private int value2; } diff --git a/src/main/java/com/org/web/data/mapper/DataMapper.java b/src/main/java/com/org/web/data/mapper/DataMapper.java index 8d42e76..eb2d212 100644 --- a/src/main/java/com/org/web/data/mapper/DataMapper.java +++ b/src/main/java/com/org/web/data/mapper/DataMapper.java @@ -6,80 +6,80 @@ import com.org.web.person.domain.BcPersonSupport; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; +import java.math.BigDecimal; import java.util.List; @Mapper public interface DataMapper extends BaseMapper { - // 各村供养人数 - @Select("select c.name as item_name, c.value as item_remark, " + - " (select count(1) " + - " from bc_person_support a " + - " where a.is_delete = 0 " + - " and a.type = 1 " + - " and IFNULL(a.village, '') != '' " + - " and a.village = c.value) as item_value " + - " from sys_data_dictionary_item c " + - " where c.is_delete = 0 " + - " and c.dictionary_code = '0040' ") - List listVillageCount(); - // 是否精准扶贫 @Select("SELECT " + - " '是' AS item_name, " + - " 1 as item_remark, " + - " SUM(CASE WHEN if_help_poor = 1 THEN 1 ELSE 0 END) AS item_value " + - "FROM bc_person_support " + - "UNION " + - "SELECT " + - " '否' AS item_name, " + - " 0 as item_remark, " + - " SUM(CASE WHEN if_help_poor = 0 THEN 1 ELSE 0 END) AS item_value " + + " '是' AS name, " + + " 1 as id, " + + " SUM(CASE WHEN if_help_poor = 1 THEN 1 ELSE 0 END) AS value " + "FROM bc_person_support " + "where is_delete = 0 " + - "and type = 1 ") + "and type = 1 " + + "and support_type = 1 " + + + "UNION " + + + "SELECT " + + " '否' AS name, " + + " 0 as id, " + + " SUM(CASE WHEN if_help_poor = 0 THEN 1 ELSE 0 END) AS value " + + "FROM bc_person_support " + + "where is_delete = 0 " + + "and type = 1 " + + "and support_type = 1 ") List listIfHelpPoor(); // 性别 @Select("SELECT " + - " '男' AS item_name, " + - " 1 as item_remark, " + - " SUM(CASE WHEN sex = 1 THEN 1 ELSE 0 END) AS item_value " + - "FROM bc_person_support " + - "UNION " + - "SELECT " + - " '女' AS item_name, " + - " 0 as item_remark, " + - " SUM(CASE WHEN sex = 0 THEN 1 ELSE 0 END) AS item_value " + + " '男' AS name, " + + " 1 as id, " + + " SUM(CASE WHEN sex = 1 THEN 1 ELSE 0 END) AS value " + "FROM bc_person_support " + "where is_delete = 0 " + - "and type = 1 ") + "and type = 1 " + + "and support_type = 1 " + + "UNION " + + "SELECT " + + " '女' AS name, " + + " 0 as id, " + + " SUM(CASE WHEN sex = 0 THEN 1 ELSE 0 END) AS value " + + "FROM bc_person_support " + + "where is_delete = 0 " + + "and type = 1 " + + "and support_type = 1 ") List listSex(); // 护理等级 - @Select("select c.name as item_name, c.value as item_remark, " + + @Select("select c.name as name, c.value as id, " + " (select count(1) " + " from bc_person_support a " + " where a.is_delete = 0 " + " and a.type = 1 " + - " and IFNULL(a.village, '') != '' " + - " and a.village = c.value) as item_value " + + " and a.support_type = 1 " + + " and IFNULL(a.nursing_level, '') != '' " + + " and a.nursing_level = c.value) as value " + " from sys_data_dictionary_item c " + " where c.is_delete = 0 " + - " and c.dictionary_code = '0040' ") + " and c.dictionary_code = '0021' " + + " order by c.value ") List listNursingLevel(); // 年龄区间 @Select("SELECT " + - " age_ranges.age_group as item_name, " + - " COALESCE(COUNT(age_table.id_card_no), 0) AS item_value " + + " age_ranges.age_group as name, id, " + + " COALESCE(COUNT(age_table.id_card_no), 0) AS value " + "FROM ( " + - " SELECT '50岁以下' AS age_group, 0 AS min_age, 49 AS max_age " + - " UNION SELECT '50-59岁', 50, 59 " + - " UNION SELECT '60-69岁', 60, 69 " + - " UNION SELECT '70-79岁', 70, 79 " + - " UNION SELECT '80-89岁', 80, 89 " + - " UNION SELECT '90岁以上', 90, 999 " + + " SELECT '50岁以下' AS age_group, 0 AS min_age, 49 AS max_age, 1 AS id " + + " UNION SELECT '50-59岁', 50, 59, 2 " + + " UNION SELECT '60-69岁', 60, 69, 3 " + + " UNION SELECT '70-79岁', 70, 79, 4 " + + " UNION SELECT '80-89岁', 80, 89, 5 " + + " UNION SELECT '90岁以上', 90, 999, 6 " + ") AS age_ranges " + "LEFT JOIN ( " + " SELECT " + @@ -88,43 +88,189 @@ public interface DataMapper extends BaseMapper { " FROM bc_person_support " + " where is_delete = 0 " + " and type = 1 " + + " and support_type = 1 " + ") AS age_table ON age_table.age BETWEEN age_ranges.min_age AND age_ranges.max_age " + - "GROUP BY age_ranges.age_group ") + "GROUP BY age_ranges.age_group, id ") List listAgeCount(); - // 是否在园 + // 是否在院 @Select("SELECT " + - " '是' AS item_name, " + - " 1 as item_remark, " + - " SUM(CASE WHEN is_in_hospital = 1 THEN 1 ELSE 0 END) AS item_value " + - "FROM bc_person_support " + - "UNION " + - "SELECT " + - " '否' AS item_name, " + - " 0 as item_remark, " + - " SUM(CASE WHEN is_in_hospital = 0 THEN 1 ELSE 0 END) AS item_value " + + " '是' AS name, " + + " 1 as id, " + + " SUM(CASE WHEN is_in_hospital = 1 THEN 1 ELSE 0 END) AS value " + "FROM bc_person_support " + "where is_delete = 0 " + - "and type = 1 ") + "and type = 1 " + + "and support_type = 1 " + + + "UNION " + + "SELECT " + + " '否' AS name, " + + " 0 as id, " + + " SUM(CASE WHEN is_in_hospital = 0 THEN 1 ELSE 0 END) AS value " + + "FROM bc_person_support " + + "where is_delete = 0 " + + "and type = 1 " + + "and support_type = 1 ") List listInHospital(); + + /** ----------------------------------------- center ------------------------------ */ + // 在院人数村籍榜 + @Select("select c.name as name, c.value as id, " + + " (select count(1) " + + " from bc_person_support a " + + " where a.is_delete = 0 " + + " and a.type = 1 " + + " and a.support_type = 1 " + + " and IFNULL(a.village, '') != '' " + + " and a.village = c.value) as value " + + " from sys_data_dictionary_item c " + + " where c.is_delete = 0 " + + " and c.dictionary_code = '0040' " + + " order by value desc ") + List listVillageRank(); + + // 累计入住数 + @Select("select count(1) " + + "from bc_hospital_record " + + "where is_delete = 0") + int getLjrzCount(); + + // 今年入住数 + @Select("select count(1) " + + "from bc_hospital_record " + + "where is_delete = 0 " + + "and year(check_in_time) = year(curdate()) ") + int getJnrzCount(); + + // 本月新增数 + @Select("select count(1) " + + "from bc_hospital_record " + + "where is_delete = 0 " + + "and year(check_in_time) = year(curdate()) " + + "and month(check_in_time) = month(curdate()) ") + int getByxzCount(); + + // 目前在院数 + @Select("select count(1) " + + "from bc_person_support " + + "where is_delete = 0 " + + " and type = 1 " + + " and support_type = 1 " + + " and is_in_hospital = 1") + int getMqzyCount(); + + // 外出就医数 + @Select("select count(1) " + + "from bc_person_support " + + "where is_delete = 0 " + + " and type = 1 " + + " and support_type = 1 " + + " and is_in_hospital = 0") + int getWcjyCount(); + + // 今年减员数 + @Select("select count(1) " + + "from bc_hospital_record " + + "where is_delete = 0 " + + " and year(check_out_time) = year(curdate())") + int getJnjyCount(); + + // 集中供养率 + @Select("select ROUND((select count(1) " + + " from bc_person_support a " + + " where a.is_delete = 0 " + + " and a.type = 1 " + + " and a.support_type = 1) / " + + " (select count(1) " + + " from bc_person_support a " + + " where a.is_delete = 0 " + + " and a.type = 1) * 100)") + BigDecimal getJzgyl(); + + // 分散供养率 + @Select("select ROUND((select count(1) " + + " from bc_person_support a " + + " where a.is_delete = 0 " + + " and a.type = 1 " + + " and a.support_type = 2) / " + + " (select count(1) " + + " from bc_person_support a " + + " where a.is_delete = 0 " + + " and a.type = 1) * 100)") + BigDecimal getFsgyl(); + /** ----------------------------------------- center ------------------------------ */ + + + /** ----------------------------------------- 入住情况统计 ------------------------------ */ + + @Select("select c.name as name, " + + " c.value as id, " + + " (select count(1) " + + " from bc_room a " + + " where a.is_delete = 0 " + + " and a.room_type = c.value) as value " + + "from sys_data_dictionary_item c " + + "where c.is_delete = 0 " + + " and c.dictionary_code = '0010' " + + "order by c.value") + List listRoomType(); + + // 房源入住情况 - @Select("SELECT " + - " '总房源' AS item_name, " + - " 0 as item_remark, " + - " count(1) AS item_value " + - "FROM bc_room a " + - "left join bc_room_bed b on a.id = b.room_id " + - "where a.is_delete = 0 " + - "and b.is_delete = 0 " + - "and a.room_type = 1 " + - "UNION " + - "select '入住房源' AS item_name, " + - " 1 as item_remark, " + - " count(1) AS item_value " + - "from bc_hospital_record a " + - "where a.is_delete = 0 " + - "and check_out_time is null") + @Select("select '房间' as name, " + + " (select count(1) " + + " from bc_room " + + " where is_delete = 0 " + + " and room_type = 1) as value, " + + " (select count(distinct a.id) " + + " from bc_room a " + + " left join bc_hospital_record b on a.id = b.room_id " + + " where a.is_delete = 0 " + + " and b.is_delete = 0 " + + " and b.check_out_time is null) as value2 " + + + "union " + + + "select '床位' as name, " + + " (select count(1) " + + " from bc_room_bed a " + + " left join bc_room b on a.room_id = b.id " + + " where a.is_delete = 0 " + + " and b.is_delete = 0 " + + " and b.room_type = 1) as value, " + + " (select count(1) " + + " from bc_room_bed a " + + " left join bc_hospital_record b on a.id = b.bed_id " + + " where a.is_delete = 0 " + + " and b.is_delete = 0 " + + " and b.check_out_time is null) as value2") List listRoomCount(); + + /** ----------------------------------------- 入住情况统计 ------------------------------ */ + + + // 各村供养人数 + @Select("select c.name as name, c.value as id, " + + " (select count(1) " + + " from bc_person_support a " + + " where a.is_delete = 0 " + + " and a.type = 1 " + + " and IFNULL(a.village, '') != '' " + + " and a.village = c.value) as value, " + + " (select count(1) " + + " from bc_person_support a " + + " where a.is_delete = 0 " + + " and a.type = 1 " + + " and a.support_type = 1 " + + " and IFNULL(a.village, '') != '' " + + " and a.village = c.value) as value2 " + + " from sys_data_dictionary_item c " + + " where c.is_delete = 0 " + + " and c.dictionary_code = '0040' " + + " order by c.value ") + List listVillageCount(); + } diff --git a/src/main/java/com/org/web/data/service/DataService.java b/src/main/java/com/org/web/data/service/DataService.java index 4d7e3a9..dca6a7c 100644 --- a/src/main/java/com/org/web/data/service/DataService.java +++ b/src/main/java/com/org/web/data/service/DataService.java @@ -9,6 +9,7 @@ import com.org.web.person.domain.BcPersonSupport; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.List; @Service @@ -19,28 +20,50 @@ public class DataService extends ServiceImpl { * 列表 */ public DataStatistics queryDataStatistics() { - List villageCountList = baseMapper.listVillageCount(); - - List ifHelpPoorList = baseMapper.listIfHelpPoor(); List sexList = baseMapper.listSex(); - - List nursingLevelList = baseMapper.listNursingLevel(); - List ageList = baseMapper.listAgeCount(); + List nursingLevelList = baseMapper.listNursingLevel(); + List ifHelpPoorList = baseMapper.listIfHelpPoor(); - List inHospitalList = baseMapper.listInHospital(); + int ljrzCount = baseMapper.getLjrzCount(); + int jnrzCount = baseMapper.getJnrzCount(); + int byxzCount = baseMapper.getByxzCount(); + int mqzyCount = baseMapper.getMqzyCount(); + int wcjyCount = baseMapper.getWcjyCount(); + int jnjyCount = baseMapper.getJnjyCount(); + + BigDecimal jzgyl = baseMapper.getJzgyl(); + BigDecimal fsgyl = baseMapper.getFsgyl(); + + List villageRankList = baseMapper.listVillageRank(); List roomCountList = baseMapper.listRoomCount(); + List roomTypeList = baseMapper.listRoomType(); + + List villageCountList = baseMapper.listVillageCount(); DataStatistics dataStatistics = new DataStatistics(); - dataStatistics.setVillageCountList(villageCountList); - dataStatistics.setIfHelpPoorList(ifHelpPoorList); dataStatistics.setSexList(sexList); - dataStatistics.setNursingLevelList(nursingLevelList); dataStatistics.setAgeList(ageList); - dataStatistics.setInHospitalList(inHospitalList); + dataStatistics.setNursingLevelList(nursingLevelList); + dataStatistics.setIfHelpPoorList(ifHelpPoorList); + + dataStatistics.setVillageRankList(villageRankList); + dataStatistics.setLjrzCount(ljrzCount); + dataStatistics.setJnrzCount(jnrzCount); + dataStatistics.setByxzCount(byxzCount); + dataStatistics.setMqzyCount(mqzyCount); + dataStatistics.setWcjyCount(wcjyCount); + dataStatistics.setJnjyCount(jnjyCount); + dataStatistics.setJzgyRate(jzgyl); + dataStatistics.setFsgyRate(fsgyl); + + dataStatistics.setRoomCountList(roomCountList); + dataStatistics.setRoomTypeList(roomTypeList); + + dataStatistics.setVillageCountList(villageCountList); return dataStatistics; } diff --git a/src/main/java/com/org/web/hospital/domain/BcHospitalRecord.java b/src/main/java/com/org/web/hospital/domain/BcHospitalRecord.java index ba985cb..bf64ec6 100644 --- a/src/main/java/com/org/web/hospital/domain/BcHospitalRecord.java +++ b/src/main/java/com/org/web/hospital/domain/BcHospitalRecord.java @@ -1,9 +1,11 @@ package com.org.web.hospital.domain; +import cn.hutool.core.date.DatePattern; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import com.org.system.entity.BaseEntity; import lombok.Data; import lombok.experimental.Accessors; @@ -41,11 +43,13 @@ public class BcHospitalRecord extends BaseEntity { /** * 入住时间 */ + @JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN, timezone = "GMT+8") private Date checkInTime; /** * 退房时间 */ + @JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN, timezone = "GMT+8") private Date checkOutTime; /** diff --git a/src/main/java/com/org/web/hospital/mapper/BcHospitalRecordMapper.java b/src/main/java/com/org/web/hospital/mapper/BcHospitalRecordMapper.java index 060ef13..156ee7d 100644 --- a/src/main/java/com/org/web/hospital/mapper/BcHospitalRecordMapper.java +++ b/src/main/java/com/org/web/hospital/mapper/BcHospitalRecordMapper.java @@ -5,6 +5,7 @@ import com.org.web.hospital.domain.BcHospitalRecord; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; import java.util.List; @@ -75,4 +76,9 @@ public interface BcHospitalRecordMapper extends BaseMapper { "and check_out_time is null "+ "" ) BcHospitalRecord getLastRecordByPersonId(@Param("personId") Long personId, @Param("bedId") Long bedId); + + @Update("update bc_hospital_record set is_delete = 1, delete_by = #{deleteBy}, delete_time = now() " + + "where is_delete = 0 " + + "and person_id = #{personId} ") + void deleteByPersonId(@Param("personId") Long personId, @Param("deleteBy") Long deleteBy); } diff --git a/src/main/java/com/org/web/hospital/service/BcHospitalRecordService.java b/src/main/java/com/org/web/hospital/service/BcHospitalRecordService.java index cc49f85..273ee10 100644 --- a/src/main/java/com/org/web/hospital/service/BcHospitalRecordService.java +++ b/src/main/java/com/org/web/hospital/service/BcHospitalRecordService.java @@ -47,7 +47,9 @@ public class BcHospitalRecordService extends ServiceImpl list = bcRoomService.getBaseMapper().queryList(new BcRoom()); + List list = bcRoomService.getBaseMapper().queryList(room); return AjaxResult.success(list); }