Commit 42f8d9c5a54f0318343a000726f69de13dc98159
1 parent
37e011d55e
Exists in
master
and in
6 other branches
逗号改括号
Showing 5 changed files with 126 additions and 10 deletions
- platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ViewFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/ResolveUtils.java
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
View file @
42f8d9c
| ... | ... | @@ -53,6 +53,72 @@ |
| 53 | 53 | return days; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | + /** | |
| 57 | + * 获取传入日期 相加xx月后的第xx天 | |
| 58 | + * @param date | |
| 59 | + * @param addMonth 添加的月份数 当前月=0, 下月=1,上月=-1 | |
| 60 | + * @param day 第一天传1, 第二天传2,....... 最后一天传0 | |
| 61 | + * @return | |
| 62 | + */ | |
| 63 | + public static Date getMonthDay(Date date, Integer addMonth, Integer day) { | |
| 64 | + if(date != null && addMonth != null && day != null) { | |
| 65 | + Calendar calendar = Calendar.getInstance(); | |
| 66 | + calendar.setTime(date); | |
| 67 | + calendar.add(Calendar.MONTH, day == 0 ? addMonth + 1 : addMonth); | |
| 68 | + calendar.set(Calendar.DAY_OF_MONTH, day); | |
| 69 | + return getYmdDate(calendar.getTime()); | |
| 70 | + } | |
| 71 | + return null; | |
| 72 | + } | |
| 73 | + | |
| 74 | + /** | |
| 75 | + * 获取季度的时间 | |
| 76 | + * 和getMonthDay一样 | |
| 77 | + */ | |
| 78 | + public static Date getQuartDay(Date date, Integer addQuart, Integer day) { | |
| 79 | + Integer quart = getQuart(date); | |
| 80 | + if(quart != null && addQuart != null && day != null) { | |
| 81 | + Calendar calendar = Calendar.getInstance(); | |
| 82 | + calendar.setTime(date); | |
| 83 | + calendar.set(Calendar.MONTH, day == 0 ? (quart + addQuart) * 3 : (quart - 1 + addQuart) * 3); | |
| 84 | + calendar.set(Calendar.DAY_OF_MONTH, day); | |
| 85 | + return getYmdDate(calendar.getTime()); | |
| 86 | + } | |
| 87 | + return null; | |
| 88 | + } | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * 1月~3月 4~6 7~9 10~11 | |
| 92 | + * 获取当前时间属于哪个季度 | |
| 93 | + * @param date | |
| 94 | + * @return | |
| 95 | + */ | |
| 96 | + public static Integer getQuart(Date date) { | |
| 97 | + if(date != null) { | |
| 98 | + Integer month = getMonth(date); | |
| 99 | + if(month >= 1 && month <= 3) { | |
| 100 | + return 1; | |
| 101 | + } else if(month >= 4 && month <= 6) { | |
| 102 | + return 2; | |
| 103 | + } else if(month >= 7 && month <= 9) { | |
| 104 | + return 3; | |
| 105 | + } else if(month >= 10 && month <= 12) { | |
| 106 | + return 4; | |
| 107 | + } | |
| 108 | + } | |
| 109 | + return null; | |
| 110 | + } | |
| 111 | + | |
| 112 | + public static Date getYmdDate(Date date){ | |
| 113 | + try { | |
| 114 | + date.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(y_m_d.format(date)).getTime()); | |
| 115 | + } catch (Exception e) { | |
| 116 | + e.printStackTrace(); | |
| 117 | + } | |
| 118 | + return date; | |
| 119 | + } | |
| 120 | + | |
| 121 | + | |
| 56 | 122 | public static Integer minute2Index(Date date) { |
| 57 | 123 | |
| 58 | 124 | DateTime dt = new DateTime(date.getTime()); |
| 59 | 125 | |
| 60 | 126 | |
| ... | ... | @@ -1270,13 +1336,21 @@ |
| 1270 | 1336 | } |
| 1271 | 1337 | |
| 1272 | 1338 | public static void main(String[] args) { |
| 1273 | - List<Map<String, Date>> monthBetween = getRange(parseYMD("2017-1-11"), parseYMD("2017-3-11")); | |
| 1339 | + /* List<Map<String, Date>> monthBetween = getRange(parseYMD("2017-1-11"), parseYMD("2017-3-11")); | |
| 1274 | 1340 | for (Map<String, Date> map : monthBetween) { |
| 1275 | 1341 | System.out.print("cname>> " + getyyyy_mm(map.get("cname"))); |
| 1276 | 1342 | System.out.print(" start>> " + getyyyy_MM_dd(map.get("start"))); |
| 1277 | 1343 | System.out.println(" end>> " + getyyyy_MM_dd(map.get("end"))); |
| 1278 | - } | |
| 1344 | + }*/ | |
| 1279 | 1345 | |
| 1346 | + System.out.println("当月第一天: " + getMonthDay(new Date(), 0, 1).toLocaleString()); | |
| 1347 | + System.out.println("当月最后一天: " + getMonthDay(new Date(), 0, 0).toLocaleString()); | |
| 1348 | + System.out.println("上月第一天: " + getMonthDay(new Date(), -1, 1).toLocaleString()); | |
| 1349 | + System.out.println("上月最后一天: " + getMonthDay(new Date(), -1, 0).toLocaleString()); | |
| 1350 | + System.out.println("当前季度第一天: " + getQuartDay(new Date(), 0, 1).toLocaleString()); | |
| 1351 | + System.out.println("当前季度最后一天: " + getQuartDay(new Date(), 0, 0).toLocaleString()); | |
| 1352 | + System.out.println("上个季度第一天: " + getQuartDay(new Date(), -1, 1).toLocaleString()); | |
| 1353 | + System.out.println("上个季度最后一天: " + getQuartDay(new Date(), -1, 0).toLocaleString()); | |
| 1280 | 1354 | } |
| 1281 | 1355 | |
| 1282 | 1356 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
View file @
42f8d9c
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ViewFacade.java
View file @
42f8d9c
| ... | ... | @@ -237,6 +237,8 @@ |
| 237 | 237 | //建档孕周 |
| 238 | 238 | map.put("buildDueWeek", ResolveUtils.getPregnancyWeek(data, data.getBookbuildingDate())); |
| 239 | 239 | |
| 240 | + map.put("fuckLastMensWeek", ResolveUtils.getPregnancyWeek2(data, data.getBookbuildingDate())); | |
| 241 | + | |
| 240 | 242 | /** 优惠券编号 */ |
| 241 | 243 | map.put("couponCode", couponService.findByUsedId(id)); |
| 242 | 244 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
42f8d9c
| ... | ... | @@ -205,11 +205,12 @@ |
| 205 | 205 | Map<String, Object> lineMap = new HashMap<>(); |
| 206 | 206 | List<Map<String, Date>> range = DateUtil.getRange(startDate, endDate); |
| 207 | 207 | |
| 208 | + List<String> patientIds = new ArrayList<>(); | |
| 209 | + for (Patients patient : patients) { | |
| 210 | + patientIds.add(patient.getId()); | |
| 211 | + } | |
| 212 | + | |
| 208 | 213 | if(StringUtils.isNotEmpty(aredId)) { // 按照医院统计 |
| 209 | - List<String> patientIds = new ArrayList<>(); | |
| 210 | - for (Patients patient : patients) { | |
| 211 | - patientIds.add(patient.getId()); | |
| 212 | - } | |
| 213 | 214 | GroupOperation groupOperation = Aggregation.group("hospitalId").count().as("count"); |
| 214 | 215 | Aggregation agg = Aggregation.newAggregation(Patients.class, Aggregation.match(Criteria.where("id").in(patientIds)), groupOperation); |
| 215 | 216 | AggregationResults<Map> results = mongoTemplate.aggregate(agg, Patients.class, Map.class); |
| ... | ... | @@ -345,7 +346,6 @@ |
| 345 | 346 | } |
| 346 | 347 | tabList.add(tempList); |
| 347 | 348 | } |
| 348 | - System.out.println(tabList); | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | tabList.add(0, titleList); |
| ... | ... | @@ -365,7 +365,24 @@ |
| 365 | 365 | line.add(MathUtil.getProportion(num, count)); |
| 366 | 366 | } |
| 367 | 367 | } else if(statistType == 2) { |
| 368 | - | |
| 368 | + Date start = null; | |
| 369 | + Date end = null; | |
| 370 | + Date beforeStart = null; | |
| 371 | + Date beforeEnd = null; | |
| 372 | + switch (statistVal) { //1=月 2=季度 3=半年 4=年 | |
| 373 | + case 1: | |
| 374 | + start = DateUtil.getMonthDay(new Date(), 0, 1); | |
| 375 | + end = DateUtil.getMonthDay(new Date(), 0, 0); | |
| 376 | + beforeStart = DateUtil.getMonthDay(new Date(), -1, 1); | |
| 377 | + beforeEnd = DateUtil.getMonthDay(new Date(), -1, 0); | |
| 378 | + break; | |
| 379 | + case 2: | |
| 380 | + break; | |
| 381 | + case 3: | |
| 382 | + break; | |
| 383 | + case 4: | |
| 384 | + break; | |
| 385 | + } | |
| 369 | 386 | } |
| 370 | 387 | lineMap.put("data", line); |
| 371 | 388 | lineMap.put("type", "line"); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/ResolveUtils.java
View file @
42f8d9c
| ... | ... | @@ -11,7 +11,6 @@ |
| 11 | 11 | import org.apache.commons.collections.CollectionUtils; |
| 12 | 12 | import org.apache.commons.lang.StringUtils; |
| 13 | 13 | import org.apache.commons.lang.math.NumberUtils; |
| 14 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 15 | 14 | |
| 16 | 15 | import java.util.*; |
| 17 | 16 | |
| 18 | 17 | |
| ... | ... | @@ -372,12 +371,36 @@ |
| 372 | 371 | dueWeek = "已分娩"; |
| 373 | 372 | } else { |
| 374 | 373 | if (null != patients.getLastMenses()) { |
| 374 | + int days = 0; | |
| 375 | + if(patients.getFuckLastMens() != null) { | |
| 376 | + days = DateUtil.daysBetween(patients.getFuckLastMens(), date); | |
| 377 | + } else { | |
| 378 | + days = DateUtil.daysBetween(patients.getLastMenses(), date); | |
| 379 | + } | |
| 380 | + dueWeek = com.lyms.platform.common.utils.StringUtils.dueWeek(days); | |
| 381 | + } | |
| 382 | + } | |
| 383 | + return dueWeek; | |
| 384 | + } | |
| 385 | + | |
| 386 | + public static String getPregnancyWeek2(Patients patients,Date date){ | |
| 387 | + String dueWeek=""; | |
| 388 | + if (null != patients.getDueStatus() && patients.getDueStatus() != null && 1 == patients.getDueStatus()) { | |
| 389 | + dueWeek = "终止妊娠"; | |
| 390 | + } else if (patients.getType() != null && 3 == patients.getType()) { | |
| 391 | + dueWeek = "已分娩"; | |
| 392 | + } else { | |
| 393 | + if (null != patients.getLastMenses()) { | |
| 394 | + if(patients.getFuckLastMens() == null) { | |
| 395 | + return ""; | |
| 396 | + } | |
| 375 | 397 | int days = DateUtil.daysBetween(patients.getLastMenses(), date); |
| 376 | 398 | dueWeek = com.lyms.platform.common.utils.StringUtils.dueWeek(days); |
| 377 | 399 | } |
| 378 | 400 | } |
| 379 | 401 | return dueWeek; |
| 380 | 402 | } |
| 403 | + | |
| 381 | 404 | |
| 382 | 405 | |
| 383 | 406 |