From 80221523e999744f7538ce72783fdd94c72b9475 Mon Sep 17 00:00:00 2001 From: yangbo Date: Sun, 2 Feb 2020 01:01:40 +0800 Subject: [PATCH] =?UTF-8?q?[feature]=20=20mock=E5=9C=B0=E5=8C=BA=E8=AF=A6?= =?UTF-8?q?=E7=BB=86=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contract/dto2/PatientAreaInfoDaily.java | 16 -- .../dto2/PatientAreaInfoDailyDTO2.java | 60 +++++ .../service/NcovCommonDataService.java | 10 +- .../d420115/D420115DataController.java | 228 +++++++++++++++--- .../service/NcovCommonDataServiceImpl.java | 23 +- 5 files changed, 274 insertions(+), 63 deletions(-) delete mode 100644 src/main/java/com/gsafety/gemp/wuhanncov/contract/dto2/PatientAreaInfoDaily.java create mode 100644 src/main/java/com/gsafety/gemp/wuhanncov/contract/dto2/PatientAreaInfoDailyDTO2.java diff --git a/src/main/java/com/gsafety/gemp/wuhanncov/contract/dto2/PatientAreaInfoDaily.java b/src/main/java/com/gsafety/gemp/wuhanncov/contract/dto2/PatientAreaInfoDaily.java deleted file mode 100644 index 3020133..0000000 --- a/src/main/java/com/gsafety/gemp/wuhanncov/contract/dto2/PatientAreaInfoDaily.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * - */ -package com.gsafety.gemp.wuhanncov.contract.dto2; - -/** - * 该类用于...,用于实现...等能力。 - * - * @author yangbo - * - * @since 2020年2月1日 下午11:12:24 - * - */ -public class PatientAreaInfoDaily { - -} diff --git a/src/main/java/com/gsafety/gemp/wuhanncov/contract/dto2/PatientAreaInfoDailyDTO2.java b/src/main/java/com/gsafety/gemp/wuhanncov/contract/dto2/PatientAreaInfoDailyDTO2.java new file mode 100644 index 0000000..cece62f --- /dev/null +++ b/src/main/java/com/gsafety/gemp/wuhanncov/contract/dto2/PatientAreaInfoDailyDTO2.java @@ -0,0 +1,60 @@ +/** + * + */ +package com.gsafety.gemp.wuhanncov.contract.dto2; + +import java.util.Date; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 该类用于...,用于实现...等能力。 + * + * @author yangbo + * + * @since 2020年2月1日 下午11:12:24 + * + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class PatientAreaInfoDailyDTO2 { + + private String id; + + private String area; + + private String areaCode; + + private Date stasTime; + + private String stasDate; + + private String stasHour; + + private Integer patientNumber; + + private Integer debtNumber; + + private Integer deathNumber; + + private Integer severeNumber; + + private Integer curedNumber; + + private String dataSrc; + + private String createBy; + + private String upateBy; + + private Date createTime; + + private Date updateTime; + + private String postDate; +} diff --git a/src/main/java/com/gsafety/gemp/wuhanncov/contract/service/NcovCommonDataService.java b/src/main/java/com/gsafety/gemp/wuhanncov/contract/service/NcovCommonDataService.java index f7c9911..b8d837a 100644 --- a/src/main/java/com/gsafety/gemp/wuhanncov/contract/service/NcovCommonDataService.java +++ b/src/main/java/com/gsafety/gemp/wuhanncov/contract/service/NcovCommonDataService.java @@ -1,11 +1,11 @@ package com.gsafety.gemp.wuhanncov.contract.service; +import java.util.List; + import com.gsafety.gemp.wuhanncov.contract.dto.AreaHotDTO; import com.gsafety.gemp.wuhanncov.contract.dto.PatientAreaCountDailyDTO; import com.gsafety.gemp.wuhanncov.contract.dto.PatientAreaInfoDailyDTO; -import com.gsafety.gemp.wuhanncov.contract.dto2.PatientAreaInfoDaily; - -import java.util.List; +import com.gsafety.gemp.wuhanncov.contract.dto2.PatientAreaInfoDailyDTO2; /** * 该类用于疫情大屏数据服务,用于实现疫情通用数据查询等能力 @@ -33,13 +33,13 @@ public interface NcovCommonDataService { * * @author yangbo * - * @since 2020年2月1日 下午11:13:00 + * @since 2020年2月1日 下午11:57:27 * * @param areaId * @param days * @return */ - List getPatientAreaInfoHistory2(String areaId, Integer days); + List getPatientAreaInfoHistoryV2(String areaId, Integer days); /*** * 多个行政区病患状态对比接口,查询多个区域患者确诊数量历史数据 diff --git a/src/main/java/com/gsafety/gemp/wuhanncov/controller/d420115/D420115DataController.java b/src/main/java/com/gsafety/gemp/wuhanncov/controller/d420115/D420115DataController.java index e7714a7..b86fa7a 100644 --- a/src/main/java/com/gsafety/gemp/wuhanncov/controller/d420115/D420115DataController.java +++ b/src/main/java/com/gsafety/gemp/wuhanncov/controller/d420115/D420115DataController.java @@ -4,10 +4,14 @@ package com.gsafety.gemp.wuhanncov.controller.d420115; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import javax.annotation.Resource; +import org.joda.time.DateTime; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -15,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController; import com.fasterxml.jackson.annotation.JsonProperty; import com.gsafety.gemp.wuhanncov.contract.dto.ChinaCountStatisticsJSON; +import com.gsafety.gemp.wuhanncov.contract.dto2.PatientAreaInfoDailyDTO2; import com.gsafety.gemp.wuhanncov.contract.service.NcovCommonDataService; import com.gsafety.gemp.wuhanncov.contract.service.PatientAreaRuntimeService; @@ -39,6 +44,16 @@ import lombok.NoArgsConstructor; @RequestMapping("/ncov/d420115/") public class D420115DataController { + /** + * + */ + private static final DateTimeFormatter DTF_YMD = DateTimeFormat.forPattern("yyyyMMdd"); + + /** + * + */ + private static final DateTimeFormatter DTF_YMD2 = DateTimeFormat.forPattern("yyyy/MM/dd"); + @Resource private NcovCommonDataService ncovCommonDataService; @@ -62,44 +77,75 @@ public class D420115DataController { public List getPatientAreaDailyInfo( @ApiParam(value = "单个区域行政区划编码", example = "420115") @RequestParam("area_id") String areaId, @ApiParam(value = "需要展示最近多少天的历史数据(不包含当日)", example = "7") @RequestParam("days") Integer days) { + List records = ncovCommonDataService.getPatientAreaInfoHistoryV2(areaId, days); + List list = new ArrayList<>(); + records.forEach(temp -> { + list.addAll(toPatientAreaD420115Datav(temp)); + }); + + // list.add(new PatientAreaD420115Datav("2020/02/01", 1, "1")); + // list.add(new PatientAreaD420115Datav("2020/01/31", 1, "1")); + // list.add(new PatientAreaD420115Datav("2020/01/30", 1, "1")); + // list.add(new PatientAreaD420115Datav("2020/01/29", 1, "1")); + // list.add(new PatientAreaD420115Datav("2020/01/28", 1, "1")); + // list.add(new PatientAreaD420115Datav("2020/01/27", 1, "1")); + // list.add(new PatientAreaD420115Datav("2020/02/01", 1, "2")); + // list.add(new PatientAreaD420115Datav("2020/01/31", 1, "2")); + // list.add(new PatientAreaD420115Datav("2020/01/30", 1, "2")); + // list.add(new PatientAreaD420115Datav("2020/01/29", 1, "2")); + // list.add(new PatientAreaD420115Datav("2020/01/28", 1, "2")); + // list.add(new PatientAreaD420115Datav("2020/01/27", 1, "2")); + // list.add(new PatientAreaD420115Datav("2020/02/01", 1, "3")); + // list.add(new PatientAreaD420115Datav("2020/01/31", 1, "3")); + // list.add(new PatientAreaD420115Datav("2020/01/30", 1, "3")); + // list.add(new PatientAreaD420115Datav("2020/01/29", 1, "3")); + // list.add(new PatientAreaD420115Datav("2020/01/28", 1, "3")); + // list.add(new PatientAreaD420115Datav("2020/01/27", 1, "3")); + // list.add(new PatientAreaD420115Datav("2020/02/01", 1, "4")); + // list.add(new PatientAreaD420115Datav("2020/01/31", 1, "4")); + // list.add(new PatientAreaD420115Datav("2020/01/30", 1, "4")); + // list.add(new PatientAreaD420115Datav("2020/01/29", 1, "4")); + // list.add(new PatientAreaD420115Datav("2020/01/28", 1, "4")); + // list.add(new PatientAreaD420115Datav("2020/01/27", 1, "4")); + // list.add(new PatientAreaD420115Datav("2020/02/01", 1, "5")); + // list.add(new PatientAreaD420115Datav("2020/01/31", 1, "5")); + // list.add(new PatientAreaD420115Datav("2020/01/30", 1, "5")); + // list.add(new PatientAreaD420115Datav("2020/01/29", 1, "5")); + // list.add(new PatientAreaD420115Datav("2020/01/28", 1, "5")); + // list.add(new PatientAreaD420115Datav("2020/01/27", 1, "5")); + // list.add(new PatientAreaD420115Datav("2020/02/01", 1, "6")); + // list.add(new PatientAreaD420115Datav("2020/01/31", 1, "6")); + // list.add(new PatientAreaD420115Datav("2020/01/30", 1, "6")); + // list.add(new PatientAreaD420115Datav("2020/01/29", 1, "6")); + // list.add(new PatientAreaD420115Datav("2020/01/28", 1, "6")); + // list.add(new PatientAreaD420115Datav("2020/01/27", 1, "6")); + return list; + } - list.add(new PatientAreaD420115Datav("2020/02/01", 1, "1")); - list.add(new PatientAreaD420115Datav("2020/01/31", 1, "1")); - list.add(new PatientAreaD420115Datav("2020/01/30", 1, "1")); - list.add(new PatientAreaD420115Datav("2020/01/29", 1, "1")); - list.add(new PatientAreaD420115Datav("2020/01/28", 1, "1")); - list.add(new PatientAreaD420115Datav("2020/01/27", 1, "1")); - list.add(new PatientAreaD420115Datav("2020/02/01", 1, "2")); - list.add(new PatientAreaD420115Datav("2020/01/31", 1, "2")); - list.add(new PatientAreaD420115Datav("2020/01/30", 1, "2")); - list.add(new PatientAreaD420115Datav("2020/01/29", 1, "2")); - list.add(new PatientAreaD420115Datav("2020/01/28", 1, "2")); - list.add(new PatientAreaD420115Datav("2020/01/27", 1, "2")); - list.add(new PatientAreaD420115Datav("2020/02/01", 1, "3")); - list.add(new PatientAreaD420115Datav("2020/01/31", 1, "3")); - list.add(new PatientAreaD420115Datav("2020/01/30", 1, "3")); - list.add(new PatientAreaD420115Datav("2020/01/29", 1, "3")); - list.add(new PatientAreaD420115Datav("2020/01/28", 1, "3")); - list.add(new PatientAreaD420115Datav("2020/01/27", 1, "3")); - list.add(new PatientAreaD420115Datav("2020/02/01", 1, "4")); - list.add(new PatientAreaD420115Datav("2020/01/31", 1, "4")); - list.add(new PatientAreaD420115Datav("2020/01/30", 1, "4")); - list.add(new PatientAreaD420115Datav("2020/01/29", 1, "4")); - list.add(new PatientAreaD420115Datav("2020/01/28", 1, "4")); - list.add(new PatientAreaD420115Datav("2020/01/27", 1, "4")); - list.add(new PatientAreaD420115Datav("2020/02/01", 1, "5")); - list.add(new PatientAreaD420115Datav("2020/01/31", 1, "5")); - list.add(new PatientAreaD420115Datav("2020/01/30", 1, "5")); - list.add(new PatientAreaD420115Datav("2020/01/29", 1, "5")); - list.add(new PatientAreaD420115Datav("2020/01/28", 1, "5")); - list.add(new PatientAreaD420115Datav("2020/01/27", 1, "5")); - list.add(new PatientAreaD420115Datav("2020/02/01", 1, "6")); - list.add(new PatientAreaD420115Datav("2020/01/31", 1, "6")); - list.add(new PatientAreaD420115Datav("2020/01/30", 1, "6")); - list.add(new PatientAreaD420115Datav("2020/01/29", 1, "6")); - list.add(new PatientAreaD420115Datav("2020/01/28", 1, "6")); - list.add(new PatientAreaD420115Datav("2020/01/27", 1, "6")); + /** + * + * 该方法用于实现...的功能 + * + * @author yangbo + * + * @since 2020年2月2日 上午12:04:42 + * + * @param temp + * @return + */ + private Collection toPatientAreaD420115Datav(PatientAreaInfoDailyDTO2 record) { + List list = new ArrayList<>(); + + DateTime d = DateTime.parse(record.getStasDate(), DTF_YMD); + String date = d.toString(DTF_YMD2); + list.add(new PatientAreaD420115Datav(date, record.getPatientNumber(), + PatientAreaD420115DatavEnum.CONFIRM.scode)); + list.add(new PatientAreaD420115Datav(date, record.getDebtNumber(), PatientAreaD420115DatavEnum.DEBT.scode)); + list.add(new PatientAreaD420115Datav(date, record.getSevereNumber(), PatientAreaD420115DatavEnum.SEVERE.scode)); + list.add(new PatientAreaD420115Datav(date, record.getDeathNumber(), PatientAreaD420115DatavEnum.DANGER.scode)); + list.add(new PatientAreaD420115Datav(date, 0, PatientAreaD420115DatavEnum.DEATH.scode)); + list.add(new PatientAreaD420115Datav(date, record.getCuredNumber(), PatientAreaD420115DatavEnum.CURE.scode)); return list; } @@ -175,9 +221,12 @@ public class D420115DataController { */ @ApiOperation(value = "查询指定区域实时病患情况") @GetMapping("/runtime_patient_area") - public ChinaCountStatisticsJSON runtimePatientArea( + public PatientRuntimeD420115Datav runtimePatientArea( @RequestParam(name = "areaCode", required = true) String areaCode) { - return patientAreaRuntimeService.findByAreaCode(areaCode); + PatientRuntimeD420115Datav v = new PatientRuntimeD420115Datav(); + v.setAreaName("江夏区"); + v.setStasDate("1月31日0时-24时"); + return v; } @Data @@ -196,6 +245,30 @@ public class D420115DataController { } + /** + * + * 数据类型。1- 确诊,2-疑似,3-重症,4-危重,5-死亡,6-出院 + * + * @author yangbo + * + * @since 2020年2月2日 上午12:16:40 + * + */ + enum PatientAreaD420115DatavEnum { + CONFIRM("1"), DEBT("2"), SEVERE("3"), DANGER("4"), DEATH("5"), CURE("6"); + + private final String scode; + + private PatientAreaD420115DatavEnum(String scode) { + this.scode = scode; + } + + public String getScode() { + return scode; + } + + } + /** * * @author yangbo @@ -247,4 +320,83 @@ public class D420115DataController { private Integer probableCase; } + + /** + * + * 该类用于...,用于实现...等能力。 + * + * @author yangbo + * + * @since 2020年2月2日 上午12:43:35 + * + */ + @Data + @AllArgsConstructor + @NoArgsConstructor + class PatientRuntimeD420115Datav { + + @JsonProperty("stasDate") + @ApiModelProperty(value = "截止日期") + private String stasDate; + + @JsonProperty("name") + @ApiModelProperty(value = "地区") + private String areaName; + + @JsonProperty("confirm") + @ApiModelProperty(value = "确诊人数") + private Integer confirmCase = 0; + + @JsonProperty("probable") + @ApiModelProperty(value = "疑似人数") + private Integer probableCase = 0; + + @JsonProperty("cure") + @ApiModelProperty(value = "治愈人数") + private Integer cureCase = 0; + + @JsonProperty("dead") + @ApiModelProperty(value = "死亡人数") + private Integer deadCase = 0; + + @JsonProperty("severe") + @ApiModelProperty(value = "重症人数") + private Integer severeCase = 0; + + @JsonProperty("danger") + @ApiModelProperty(value = "危重症人数") + private Integer dangerCase = 0; + + @JsonProperty("new") + @ApiModelProperty(value = "新增人数") + private Integer newCase = 0; + + @JsonProperty("new_cure") + @ApiModelProperty(value = "新增治愈") + private Integer newCure = 0; + + @JsonProperty("new_dead") + @ApiModelProperty(value = "新增死亡") + private Integer newDead = 0; + + @JsonProperty("new_probable") + @ApiModelProperty(value = "新增疑似") + private Integer newProbable = 0; + + @JsonProperty("new_severe") + @ApiModelProperty(value = "新增疑似") + private Integer newSevere = 0; + + @JsonProperty("contact") + @ApiModelProperty(value = "密切接触者") + private Integer contact = 0; + + @JsonProperty("observe") + @ApiModelProperty(value = "观察中") + private Integer observe = 0; + + @JsonProperty("relieve") + @ApiModelProperty(value = "已解除") + private Integer relieve = 0; + } } diff --git a/src/main/java/com/gsafety/gemp/wuhanncov/service/NcovCommonDataServiceImpl.java b/src/main/java/com/gsafety/gemp/wuhanncov/service/NcovCommonDataServiceImpl.java index 4a69946..8ae7af8 100644 --- a/src/main/java/com/gsafety/gemp/wuhanncov/service/NcovCommonDataServiceImpl.java +++ b/src/main/java/com/gsafety/gemp/wuhanncov/service/NcovCommonDataServiceImpl.java @@ -3,7 +3,7 @@ package com.gsafety.gemp.wuhanncov.service; import com.gsafety.gemp.wuhanncov.contract.dto.AreaHotDTO; import com.gsafety.gemp.wuhanncov.contract.dto.PatientAreaCountDailyDTO; import com.gsafety.gemp.wuhanncov.contract.dto.PatientAreaInfoDailyDTO; -import com.gsafety.gemp.wuhanncov.contract.dto2.PatientAreaInfoDaily; +import com.gsafety.gemp.wuhanncov.contract.dto2.PatientAreaInfoDailyDTO2; import com.gsafety.gemp.wuhanncov.contract.service.NcovCommonDataService; import com.gsafety.gemp.wuhanncov.dao.ChinaCountStatisticsDao; import com.gsafety.gemp.wuhanncov.dao.LocationDimDao; @@ -15,6 +15,7 @@ import com.gsafety.gemp.wuhanncov.dao.po.PatientAreaRuntimePO; import com.gsafety.gemp.wuhanncov.dao.po.PatientAreaStatisticPO; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.DateUtils; +import org.springframework.beans.BeanUtils; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; @@ -238,9 +239,23 @@ public class NcovCommonDataServiceImpl implements NcovCommonDataService { } @Override - public List getPatientAreaInfoHistory2(String areaId, Integer days) { - // TODO Auto-generated method stub - return null; + public List getPatientAreaInfoHistoryV2(String areaId, Integer days) { + List resultList = new ArrayList<>(); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + Date now = new Date(); + String startDate = sdf.format(DateUtils.addDays(now, -2 - days)); + String endDate = sdf.format(now); + //获取指定区域和时间段的患者统计数据列表 + List poList = patientAreaStatisticDao + .findByAreaCodeAndStasDateGreaterThanAndStasDateLessThanOrderByStasTimeAsc(areaId, startDate, endDate); + poList.forEach(temp -> { + PatientAreaInfoDailyDTO2 record = PatientAreaInfoDailyDTO2.builder().build(); + BeanUtils.copyProperties(temp, record); + resultList.add(record); + }); + + return resultList; } } -- Gitee