Commit c096cab61aa4072c700e28d3f12912214aca9a85
1 parent
f6489a8461
Exists in
master
and in
6 other branches
写bug
Showing 2 changed files with 76 additions and 5 deletions
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
View file @
c096cab
| ... | ... | @@ -4,9 +4,7 @@ |
| 4 | 4 | |
| 5 | 5 | import java.text.ParseException; |
| 6 | 6 | import java.text.SimpleDateFormat; |
| 7 | -import java.util.Calendar; | |
| 8 | -import java.util.Date; | |
| 9 | -import java.util.GregorianCalendar; | |
| 7 | +import java.util.*; | |
| 10 | 8 | import java.util.concurrent.locks.Lock; |
| 11 | 9 | import java.util.concurrent.locks.ReentrantLock; |
| 12 | 10 | |
| ... | ... | @@ -16,6 +14,7 @@ |
| 16 | 14 | public static SimpleDateFormat yyyy = new SimpleDateFormat("yyyy"); |
| 17 | 15 | public static SimpleDateFormat ymd = new SimpleDateFormat("yyyyMMdd"); |
| 18 | 16 | public static SimpleDateFormat y_m_d = new SimpleDateFormat("yyyy-MM-dd"); |
| 17 | + public static SimpleDateFormat y_m = new SimpleDateFormat("yyyy年MM月"); | |
| 19 | 18 | |
| 20 | 19 | public static SimpleDateFormat y_m_d1= new SimpleDateFormat("yyyy年MM月dd日"); |
| 21 | 20 | public static SimpleDateFormat md = new SimpleDateFormat("MM-dd"); |
| ... | ... | @@ -340,6 +339,18 @@ |
| 340 | 339 | return null; |
| 341 | 340 | } |
| 342 | 341 | } |
| 342 | + | |
| 343 | + public static String getyyyy_mm(Date d) { | |
| 344 | + if (d == null) { | |
| 345 | + return null; | |
| 346 | + } | |
| 347 | + try { | |
| 348 | + return y_m.format(d); | |
| 349 | + } catch (Exception e) { | |
| 350 | + return null; | |
| 351 | + } | |
| 352 | + } | |
| 353 | + | |
| 343 | 354 | public static String getyyyy_MM_dd1(Date d) { |
| 344 | 355 | if (d == null) { |
| 345 | 356 | return null; |
| ... | ... | @@ -1203,6 +1214,55 @@ |
| 1203 | 1214 | Date time = c.getTime(); |
| 1204 | 1215 | formatYmd(time); |
| 1205 | 1216 | return time; |
| 1217 | + } | |
| 1218 | + | |
| 1219 | + public static List<Map<String, Object>> getRange(Date start, Date end) { | |
| 1220 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
| 1221 | + if(start != null && end != null) { | |
| 1222 | + List<Date> dates = getMonthBetween(start, end); | |
| 1223 | + for (int i = 0; i < dates.size(); i++) { | |
| 1224 | + Map<String, Object> temp = new HashMap<>(); | |
| 1225 | + temp.put("cname", getyyyy_mm(dates.get(i))); | |
| 1226 | + if(i == 0) { | |
| 1227 | + temp.put("condition", Arrays.asList(start, dates.get(i))); | |
| 1228 | + } else if(i == dates.size() - 1) { | |
| 1229 | + temp.put("condition", Arrays.asList(dates.get(dates.size() - 1), end)); | |
| 1230 | + } else { | |
| 1231 | + temp.put("condition", Arrays.asList(dates.get(i), dates.get(i + 1))); | |
| 1232 | + } | |
| 1233 | + restList.add(temp); | |
| 1234 | + } | |
| 1235 | + } | |
| 1236 | + return restList; | |
| 1237 | + } | |
| 1238 | + | |
| 1239 | + private static List<Date> getMonthBetween(Date start, Date end) { | |
| 1240 | + List<Date> result = new ArrayList<>(); | |
| 1241 | + Calendar min = Calendar.getInstance(); | |
| 1242 | + Calendar max = Calendar.getInstance(); | |
| 1243 | + min.setTime(start); | |
| 1244 | + min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1); | |
| 1245 | + max.setTime(end); | |
| 1246 | + max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2); | |
| 1247 | + | |
| 1248 | + Calendar curr = min; | |
| 1249 | + while (curr.before(max)) { | |
| 1250 | + result.add(curr.getTime()); | |
| 1251 | + curr.add(Calendar.MONTH, 1); | |
| 1252 | + } | |
| 1253 | + return result; | |
| 1254 | + } | |
| 1255 | + | |
| 1256 | + public static void main(String[] args) { | |
| 1257 | + List<Map<String, Object>> monthBetween = getRange(parseYMD("2017-1-11"), parseYMD("2017-3-11")); | |
| 1258 | + for (Map<String, Object> map : monthBetween) { | |
| 1259 | + System.out.println(map.get("cname")); | |
| 1260 | + List<Date> conditions = (List<Date>) map.get("condition"); | |
| 1261 | + for (Date condition : conditions) { | |
| 1262 | + System.out.println(condition.toLocaleString()); | |
| 1263 | + } | |
| 1264 | + } | |
| 1265 | + | |
| 1206 | 1266 | } |
| 1207 | 1267 | |
| 1208 | 1268 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
c096cab
| ... | ... | @@ -197,8 +197,10 @@ |
| 197 | 197 | List<String> xDatas = new ArrayList<>(); |
| 198 | 198 | List<Map<String, Object>> series = new ArrayList<>(); |
| 199 | 199 | List<String> legend = Arrays.asList("建档总数"); |
| 200 | - List<Object> bar = new ArrayList<>(); | |
| 200 | + List<Integer> bar = new ArrayList<>(); | |
| 201 | + List<Object> line = new ArrayList<>(); | |
| 201 | 202 | Map<String, Object> barMap = new HashMap<>(); |
| 203 | + Map<String, Object> lineMap = new HashMap<>(); | |
| 202 | 204 | |
| 203 | 205 | if(StringUtils.isNotEmpty(aredId)) { // 按照医院统计 |
| 204 | 206 | List<String> patientIds = new ArrayList<>(); |
| ... | ... | @@ -211,7 +213,7 @@ |
| 211 | 213 | List<Map> mappedResults = results.getMappedResults(); |
| 212 | 214 | for (Map mappedResult : mappedResults) { |
| 213 | 215 | xDatas.add(couponMapper.findHospitalNameById((String) mappedResult.get("_id"))); |
| 214 | - bar.add(mappedResult.get("count")); | |
| 216 | + bar.add((Integer) mappedResult.get("count")); | |
| 215 | 217 | } |
| 216 | 218 | } else { |
| 217 | 219 | Map<Integer, Integer> areaCountMap = new HashMap<>(); |
| ... | ... | @@ -243,6 +245,15 @@ |
| 243 | 245 | barMap.put("type", "bar"); |
| 244 | 246 | barMap.put("name", "建档总数"); |
| 245 | 247 | series.add(barMap); |
| 248 | + | |
| 249 | + for (Integer count : bar) { | |
| 250 | + | |
| 251 | + } | |
| 252 | + lineMap.put("data", line); | |
| 253 | + lineMap.put("type", "line"); | |
| 254 | + lineMap.put("name", "建档总数"); | |
| 255 | + series.add(lineMap); | |
| 256 | + | |
| 246 | 257 | |
| 247 | 258 | restMap.put("legend", legend); |
| 248 | 259 | restMap.put("series", series); |