Commit e0d78f3d6b71a741661c3a1944f381e675c5f721

Authored by jiangjiazhi

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ResidentsArchiveFacade.java

Showing 9 changed files

platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java View file @ e0d78f3
... ... @@ -11,6 +11,7 @@
11 11 public class DateUtil {
12 12 private static Lock lock = new ReentrantLock();
13 13 public static SimpleDateFormat dd = new SimpleDateFormat("dd");
  14 + public static SimpleDateFormat yyyy = new SimpleDateFormat("yyyy");
14 15 public static SimpleDateFormat ymd = new SimpleDateFormat("yyyyMMdd");
15 16 public static SimpleDateFormat y_m_d = new SimpleDateFormat("yyyy-MM-dd");
16 17 public static SimpleDateFormat md = new SimpleDateFormat("MM-dd");
... ... @@ -196,6 +197,28 @@
196 197 }
197 198 }
198 199  
  200 + public static Date getYearDate(String s) {
  201 + if (s == null) {
  202 + return null;
  203 + }
  204 + try {
  205 + return yyyy.parse(s);
  206 + } catch (Exception e) {
  207 + return null;
  208 + }
  209 + }
  210 +
  211 + public static Date getNextYearDate(String s) {
  212 + if (s == null) {
  213 + return null;
  214 + }
  215 + try {
  216 + return DateUtil.addYear(yyyy.parse(s), 1);
  217 + } catch (Exception e) {
  218 + return null;
  219 + }
  220 + }
  221 +
199 222 public static String getymdhm(Date d) {
200 223 if (d == null) {
201 224 return null;
... ... @@ -949,7 +972,9 @@
949 972 public static void main(String[] arg) throws Exception {
950 973 Date start = parseYMD("2017-05-11");
951 974 Date end = parseYMD("2017-06-02");
952   - System.err.println(getMonthDesc(start, end));
  975 +
  976 + System.out.println(getMonth(start));
  977 + System.out.println(getMonth(end));
953 978 }
954 979  
955 980  
... ... @@ -966,6 +991,17 @@
966 991 int month = getMonth(start, end);
967 992 int day = getExcludeMonthDay(start, end);
968 993 return month + "月龄+" + day + "天";
  994 + }
  995 +
  996 + /**
  997 + * 获取传入日期的月份
  998 + * @param date
  999 + * @return
  1000 + */
  1001 + public static Integer getMonth(Date date) {
  1002 + Calendar calendar = Calendar.getInstance();
  1003 + calendar.setTime(date);
  1004 + return calendar.get(Calendar.MONTH) + 1;
969 1005 }
970 1006 }
platform-operate-api/src/main/java/com/lyms/hospitalapi/pojo/ReportModel.java View file @ e0d78f3
... ... @@ -32,6 +32,8 @@
32 32  
33 33 private List<Object> doctorInfo;
34 34  
  35 + private List<String> legend;
  36 +
35 37 /**
36 38 * 将 x 轴数据去重并把series数据合并
37 39 */
... ... @@ -150,6 +152,14 @@
150 152  
151 153 public void setSeries(List<Series> series) {
152 154 this.series = series;
  155 + }
  156 +
  157 + public List<String> getLegend() {
  158 + return legend;
  159 + }
  160 +
  161 + public void setLegend(List<String> legend) {
  162 + this.legend = legend;
153 163 }
154 164 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java View file @ e0d78f3
... ... @@ -273,5 +273,24 @@
273 273 return reportService.couponInit(CollectionUtils.createMap("userId", getUserId(request), "couponType", couponType));
274 274 }
275 275  
  276 +
  277 + /**
  278 + * 把产前检查/产妇分娩/出院小结/产后复查/产前筛查里面所有的pid找出来去重
  279 + * 根据省市区条件返回统计数据
  280 + * @param request
  281 + * @param year
  282 + * @param provinceId
  283 + * @param cityId
  284 + * @param areaId
  285 + * @return
  286 + */
  287 + @ResponseBody
  288 +// @TokenRequired
  289 + @RequestMapping(value = "/patient", method = RequestMethod.GET)
  290 + public BaseObjectResponse patient(HttpServletRequest request, String year, String provinceId, String cityId, String areaId) {
  291 +// return reportService.patient(getUserId(request), year);
  292 + return reportService.patient(2144, year, provinceId, cityId, areaId);
  293 + }
  294 +
276 295 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/LisFacade.java View file @ e0d78f3
... ... @@ -548,7 +548,7 @@
548 548 query.setPage(page);
549 549 query.setLimit(limit);
550 550 query.setNeed("true");
551   - query.setSort(" PUBLISH_TIME DESC ");
  551 + query.setSort(" CHECK_TIME,ID DESC ");
552 552  
553 553 query.setPhones(phones);
554 554 query.setVcCardNos(vcCardNos);
555 555  
... ... @@ -556,8 +556,23 @@
556 556 query.setHospitalIds(hosptalIds);
557 557  
558 558 Map<String,String> hospitalNames = getHospitalNames(hosptalIds);
559   -
560 559 lises = lisService.queryLisDataByQuery(query);
  560 + // 排序
  561 + Collections.sort(lises, new Comparator() {
  562 + public int compare(Object a, Object b) {
  563 + if (((LisReportModel) a).getCheckTime() == null) {
  564 + return -1;
  565 + }
  566 + if (((LisReportModel) b).getCheckTime() == null) {
  567 + return -1;
  568 + }
  569 + if (((LisReportModel) a).getCheckTime().before(((LisReportModel) a).getCheckTime())) {
  570 + return 1;
  571 + }
  572 + return -1;
  573 + }
  574 + });
  575 +
561 576 if (CollectionUtils.isNotEmpty(lises))
562 577 {
563 578 for(LisReportModel lisReportModel : lises)
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ResidentsArchiveFacade.java View file @ e0d78f3
... ... @@ -28,7 +28,6 @@
28 28 import com.lyms.platform.query.ResidentsArchiveQuery;
29 29 import org.apache.commons.collections.CollectionUtils;
30 30 import org.apache.commons.lang.StringUtils;
31   -import org.apache.commons.lang.math.*;
32 31 import org.springframework.beans.factory.annotation.Autowired;
33 32 import org.springframework.stereotype.Component;
34 33  
35 34  
36 35  
37 36  
38 37  
... ... @@ -487,33 +486,29 @@
487 486 result.setStreetRegisterId(model.getStreetRegisterId());
488 487 result.setAddressRegister(model.getAddressRegister());
489 488  
490   - result.setPastHistory(model.getPastHistory() == null ? null : JsonUtil.jkstr2Obj(model.getPastHistory(), Map.class));
  489 + result.setPastHistory(model.getPastHistory()==null ? null :JsonUtil.jkstr2Obj(model.getPastHistory(), Map.class));
491 490 result.setFamilyHistory(model.getFamilyHistory() == null ? null : JsonUtil.jkstr2Obj(model.getFamilyHistory(), Map.class));
492   - result.setPersonalHistory(model.getPersonalHistory() == null ? null : JsonUtil.jkstr2Obj(model.getPersonalHistory(), Map.class));
493   - result.setYwgmHistory(model.getYwgmHistory() == null ? null : JsonUtil.jkstr2Obj(model.getYwgmHistory(), Map.class));
494   - result.setPresentHistory(model.getPresentHistory() == null ? null : JsonUtil.jkstr2Obj(model.getPresentHistory(), Map.class));
  491 + result.setPersonalHistory(model.getPersonalHistory() == null ? null :JsonUtil.jkstr2Obj(model.getPersonalHistory(), Map.class));
  492 + result.setYwgmHistory(model.getYwgmHistory() == null ? null :JsonUtil.jkstr2Obj(model.getYwgmHistory(), Map.class));
  493 + result.setPresentHistory(model.getPresentHistory() == null ? null : JsonUtil.jkstr2Obj(model.getPresentHistory(),Map.class));
495 494  
496 495 result.setVcCardNo(model.getVcCardNo());
497   -
498   - Map<String,String> doctInfo = new HashMap<>();
499   - doctInfo.put("id", String.valueOf(model.getBuildDoctor()));
500   - doctInfo.put("name", String.valueOf(model.getBuildDoctor()));
501   - result.setBuildDoctor(doctInfo);
502   -
503   - if (StringUtils.isNotEmpty(model.getBuildDoctor())){
504   - if(org.apache.commons.lang.math.NumberUtils.isNumber(model.getBuildDoctor())){
505   - Users u = usersService.getUsers(Integer.valueOf(model.getBuildDoctor()));
506   - if(u!=null){
507   - doctInfo.put("id",String.valueOf(u.getId()));
508   - doctInfo.put("name",u.getName());
509   - result.setBuildDoctor(doctInfo);
510   - }
511   - }
512   - else{
513   - doctInfo.put("id","-1");
514   - doctInfo.put("name",model.getBuildDoctor());
  496 + if (StringUtils.isNotEmpty(model.getBuildDoctor()) && com.lyms.platform.common.utils.StringUtils.isNum(model.getBuildDoctor())){
  497 + Users u = usersService.getUsers(Integer.valueOf(model.getBuildDoctor()));
  498 + if(u!=null){
  499 + Map<String,String> doctInfo = new HashMap<>();
  500 + doctInfo.put("id",String.valueOf(u.getId()));
  501 + doctInfo.put("name",u.getName());
515 502 result.setBuildDoctor(doctInfo);
  503 + }else{
  504 + Map<String,String> doctInfo = new HashMap<>();
  505 + doctInfo.put("id",String.valueOf(u.getId()));
  506 + result.setBuildDoctor(doctInfo);
516 507 }
  508 + }else{
  509 + Map<String,String> doctInfo = new HashMap<>();
  510 + doctInfo.put("id",String.valueOf(model.getBuildDoctor()));
  511 + result.setBuildDoctor(doctInfo);
517 512 }
518 513  
519 514  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java View file @ e0d78f3
... ... @@ -74,5 +74,7 @@
74 74 BaseObjectResponse couponInfo(Map<String, Object> param);
75 75  
76 76 void exportCouponInfo(Map<String, Object> param, HttpServletResponse response);
  77 +
  78 + BaseObjectResponse patient(Integer userId, String s, String provinceId, String cityId, String year);
77 79 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ e0d78f3
... ... @@ -20,6 +20,9 @@
20 20 import org.springframework.beans.factory.annotation.Autowired;
21 21 import org.springframework.data.domain.Sort;
22 22 import org.springframework.data.mongodb.core.MongoTemplate;
  23 +import org.springframework.data.mongodb.core.aggregation.Aggregation;
  24 +import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
  25 +import org.springframework.data.mongodb.core.aggregation.AggregationResults;
23 26 import org.springframework.data.mongodb.core.query.Criteria;
24 27 import org.springframework.data.mongodb.core.query.Query;
25 28 import org.springframework.stereotype.Service;
... ... @@ -54,6 +57,9 @@
54 57 @Autowired
55 58 private AccessPermissionFacade accessPermissionFacade;
56 59  
  60 + @Autowired
  61 + private MongoUtil mongoUtil;
  62 +
57 63 private static final Map<String, String> colorMap = new HashMap<>();
58 64  
59 65 /**
... ... @@ -1054,6 +1060,127 @@
1054 1060 exportChildUsedInfo(couponInfos == null ? userSendInfos : couponInfos, response);
1055 1061 }
1056 1062  
  1063 + }
  1064 +
  1065 + @Override
  1066 + public BaseObjectResponse patient(Integer userId, String year, String provinceId, String cityId, String areaId) {
  1067 + String hospitalId = autoMatchFacade.getHospitalId(userId);
  1068 +
  1069 + Set<String> patientIds = new HashSet<>();
  1070 +
  1071 + Criteria criteria = Criteria.where("created").gte(DateUtil.getYearDate(year))
  1072 + .lt(DateUtil.getNextYearDate(year))
  1073 + .and("hospitalId").is(hospitalId);
  1074 +
  1075 + /** 产前检查: lyms_antexc(初诊),lyms_antex(复诊)设置pid */
  1076 + List<AntenatalExaminationModel> antenatalExaminationModels = mongoUtil.findField(AntenatalExaminationModel.class, criteria, "parentId");
  1077 + for (AntenatalExaminationModel antenatalExaminationModel : antenatalExaminationModels) {
  1078 + patientIds.add(antenatalExaminationModel.getParentId());
  1079 + }
  1080 + List<AntExChuModel> antExChuModels = mongoUtil.findField(AntExChuModel.class, criteria, "parentId");
  1081 + for (AntExChuModel antExChuModel : antExChuModels) {
  1082 + patientIds.add(antExChuModel.getParentId());
  1083 + }
  1084 +
  1085 + /** 产妇分娩: lyms_matdeliver */
  1086 + List<MaternalDeliverModel> deliverModels = mongoUtil.findField(MaternalDeliverModel.class, criteria, "parentId");
  1087 + for (MaternalDeliverModel deliverModel : deliverModels) {
  1088 + patientIds.add(deliverModel.getParentId());
  1089 + }
  1090 +
  1091 + /** 出院小结: lyms_discharge_abstract_mother 医院需要确定下 */
  1092 + Criteria disCriteria = Criteria.where("createDate").gte(DateUtil.getYearDate(year))
  1093 + .lt(DateUtil.getNextYearDate(year));
  1094 + List<DischargeAbstractMotherModel> dischargeAbstractMotherModels = mongoUtil.findField(DischargeAbstractMotherModel.class, disCriteria, "patientId");
  1095 + for (DischargeAbstractMotherModel dischargeAbstractMotherModel : dischargeAbstractMotherModels) {
  1096 + patientIds.add(dischargeAbstractMotherModel.getPatientId());
  1097 + }
  1098 +
  1099 + /** 产后复查: lyms_postreview */
  1100 + List<PostReviewModel> postReviewModels = mongoUtil.findField(PostReviewModel.class, criteria, "parentId");
  1101 + for (PostReviewModel postReviewModel : postReviewModels) {
  1102 + patientIds.add(postReviewModel.getParentId());
  1103 + }
  1104 +
  1105 + /** 产前筛查: lyms_sieve */
  1106 + List<SieveModel> sieveModels = mongoUtil.findField(SieveModel.class, criteria, "parentId");
  1107 + for (SieveModel sieveModel : sieveModels) {
  1108 + patientIds.add(sieveModel.getParentId());
  1109 + }
  1110 +
  1111 + if(StringUtils.isNotEmpty(provinceId)) {
  1112 + criteria.and("provinceId").in(CollectionUtils.asList(provinceId));
  1113 + }
  1114 +
  1115 + List<Patients> patients = mongoTemplate.find(Query.query(criteria), Patients.class);
  1116 +
  1117 + /* AggregationOperation match = Aggregation.match(
  1118 + Criteria.where("hospitalId").is(hospitalId)
  1119 +// .and("bookbuildingDate").gte(DateUtil.getYearDate(year)).lt(DateUtil.getNextYearDate(year))
  1120 + .and("id").in(patientIds));
  1121 + AggregationOperation provinceGroup = Aggregation.group("bookbuildingDate").count().as("provinceCount");
  1122 +// AggregationOperation cityGroup = Aggregation.group("cityId").count().as("cityCount");
  1123 +// AggregationOperation areaGroup = Aggregation.group("areaId").count().as("areaCount");
  1124 + Aggregation aggregation = Aggregation.newAggregation(match, provinceGroup);
  1125 + AggregationResults<HashMap> result = mongoTemplate.aggregate(aggregation, Patients.class, HashMap.class);
  1126 + List<HashMap> mappedResults = result.getMappedResults();
  1127 +
  1128 + for (HashMap mappedResult : mappedResults) {
  1129 + System.out.println(mappedResult);
  1130 + }
  1131 +*/
  1132 + ReportModel reportModel = new ReportModel();
  1133 + reportModel.setLegend(Arrays.asList("秦皇岛市", "辖区外"));
  1134 +
  1135 + reportModel.setxAxis(Arrays.asList("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"));
  1136 +
  1137 +
  1138 + List<Map<String, Object>> mapList = mongoUtil.getListByGroup(patients);
  1139 + List<Series> series = createPatientSeries(mapList);
  1140 + reportModel.setSeries(series);
  1141 + return RespBuilder.buildSuccess("patients", mapList, "report", reportModel);
  1142 + }
  1143 +
  1144 + private List<Series> createPatientSeries(List<Map<String, Object>> datas) {
  1145 + List<Series> series = new ArrayList<>();
  1146 +
  1147 + Series qhdSeries = new Series();
  1148 + qhdSeries.setName("秦皇岛市");
  1149 + qhdSeries.setType("bar");
  1150 + qhdSeries.setStack("总计");
  1151 + List<Object> qhdDatas = new ArrayList<>();
  1152 +
  1153 + Series otherSeries = new Series();
  1154 + otherSeries.setName("辖区外");
  1155 + otherSeries.setType("bar");
  1156 + otherSeries.setStack("总计");
  1157 + List<Object> otherDatas = new ArrayList<>();
  1158 + Map<String, Integer> temp = new HashMap<>();
  1159 + for(int i = 1; i < 13; i++) {
  1160 + temp.put(i + "", 0);
  1161 + }
  1162 +
  1163 + String provinceId = mongoUtil.findId("河北省");
  1164 + if(StringUtils.isNotEmpty(provinceId)) {}
  1165 + for (Map<String, Object> data : datas) {
  1166 + if(provinceId.equals(data.get("id"))) {
  1167 + for(int i = 1; i < 13; i++) {
  1168 + qhdDatas.add(data.get(i + ""));
  1169 + }
  1170 + qhdSeries.setData(qhdDatas);
  1171 + } else {
  1172 + for(int i = 1; i < 13; i++) {
  1173 + temp.put(i + "", temp.get(i + "") + Integer.parseInt(data.get(i + "") + ""));
  1174 + }
  1175 + }
  1176 + }
  1177 + List<Integer> integers = CollectionUtils.transValToList(temp);
  1178 + otherDatas.addAll(integers);
  1179 + otherSeries.setData(otherDatas);
  1180 +
  1181 + series.add(qhdSeries);
  1182 + series.add(otherSeries);
  1183 + return series;
1057 1184 }
1058 1185  
1059 1186 private void exportChildUsedInfo(List<Map<String, Object>> data, HttpServletResponse response) {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java View file @ e0d78f3
  1 +package com.lyms.platform.operate.web.utils;
  2 +
  3 +import com.lyms.platform.common.utils.DateUtil;
  4 +import com.lyms.platform.common.utils.StringUtils;
  5 +import com.lyms.platform.pojo.BasicConfig;
  6 +import com.lyms.platform.pojo.Patients;
  7 +import com.mongodb.BasicDBObject;
  8 +import com.mongodb.DBObject;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.data.mongodb.core.MongoTemplate;
  11 +import org.springframework.data.mongodb.core.query.BasicQuery;
  12 +import org.springframework.data.mongodb.core.query.Criteria;
  13 +import org.springframework.data.mongodb.core.query.Query;
  14 +import org.springframework.stereotype.Component;
  15 +
  16 +import java.util.*;
  17 +
  18 +/**
  19 + * @Author: litao
  20 + * @Date: 2017/6/13 0013
  21 + */
  22 +@Component
  23 +public class MongoUtil {
  24 + @Autowired
  25 + private MongoTemplate mongoTemplate;
  26 +
  27 + /**
  28 + * 查询mongo表中指定的字段
  29 + * @param clazz
  30 + * @param criteria
  31 + * @param fields
  32 + * @param <T>
  33 + * @return
  34 + */
  35 + public <T> List<T> findField(Class<T> clazz, Criteria criteria, String ... fields) {
  36 + DBObject dbObject = new BasicDBObject();
  37 + DBObject fieldObject = new BasicDBObject();
  38 + for (String field : fields) {
  39 + fieldObject.put(field, true);
  40 + }
  41 + Query query = new BasicQuery(dbObject, fieldObject);
  42 + query.addCriteria(criteria);
  43 + List<T> list = mongoTemplate.find(query, clazz);
  44 + return list;
  45 + }
  46 +
  47 + /**
  48 + * 按照月份、省市区统计总数
  49 + * 详见原型图建册人数统计
  50 + * @param patients
  51 + * @return
  52 + */
  53 + public List<Map<String, Object>> getListByGroup(List<Patients> patients) {
  54 + Map<String, Integer> codeMap = new HashMap<>(); /** key为 id_month */
  55 +
  56 + Map<String, Integer> otherCountMap = new HashMap<>();
  57 + Map<String, Integer> otherMonthMap = new HashMap<>();
  58 + for (int i = 1; i <= 12; i++) {
  59 + otherMonthMap.put(i + "", 0);
  60 + }
  61 +
  62 + Integer otherCount = 0;
  63 + /* for (Patients patient : patients) {
  64 + System.out.println("month:" + DateUtil.getMonth(patient.getBookbuildingDate()) + "\tprovinceId: " + patient.getProvinceId()
  65 + + "\tcityId: " + patient.getCityId() + "\tareaId:" + patient.getAreaId());
  66 + }*/
  67 + for (Patients patient : patients) {
  68 + Date bookbuildingDate = patient.getBookbuildingDate();
  69 + if(bookbuildingDate == null) {
  70 + bookbuildingDate = patient.getCreated();
  71 + }
  72 + if(bookbuildingDate != null) {
  73 + String provinceId = patient.getProvinceId();
  74 + String cityId = patient.getCityId();
  75 + String areaId = patient.getAreaId();
  76 + Integer month = DateUtil.getMonth(bookbuildingDate);
  77 +
  78 + if (StringUtils.isEmpty(provinceId) || StringUtils.isEmpty(cityId) || StringUtils.isEmpty(areaId)) {
  79 + otherMonthMap.put(month + "", otherMonthMap.get(month + "") + 1);
  80 + ++otherCount;
  81 + continue;
  82 + }
  83 +
  84 + if(codeMap.containsKey(provinceId + "_" + month)) {
  85 + codeMap.put(provinceId + "_" + month, codeMap.get(provinceId + "_" + month) + 1);
  86 + } else {
  87 + codeMap.put(provinceId + "_" + month, 1);
  88 + }
  89 + if(codeMap.containsKey(cityId + "_" + month)) {
  90 + codeMap.put(cityId + "_" + month, codeMap.get(cityId + "_" + month) + 1);
  91 + } else {
  92 + codeMap.put(cityId + "_" + month, 1);
  93 + }
  94 + if(codeMap.containsKey(areaId + "_" + month)) {
  95 + codeMap.put(areaId + "_" + month, codeMap.get(areaId + "_" + month) + 1);
  96 + } else {
  97 + codeMap.put(areaId + "_" + month, 1);
  98 + }
  99 + }
  100 + }
  101 +
  102 + List<Map<String, Map<Integer, Integer>>> datas = new ArrayList<>();
  103 + Set<Map.Entry<String, Integer>> entries = codeMap.entrySet();
  104 + for (Map.Entry<String, Integer> entry : entries) {
  105 + String key = entry.getKey();
  106 + String id = key.split("_")[0];
  107 + Integer month = Integer.parseInt(key.split("_")[1]);
  108 + Integer count = entry.getValue();
  109 +
  110 + boolean flag = true;
  111 + for (Map<String, Map<Integer, Integer>> data : datas) {
  112 + if(data.containsKey(id)) {
  113 + Map<Integer, Integer> map = data.get(id);
  114 + if(map.containsKey(month)) {
  115 + map.put(month, map.get(month) + count);
  116 + } else {
  117 + map.put(month, count);
  118 + }
  119 + flag = false;
  120 + }
  121 + }
  122 +
  123 + if(flag) {
  124 + Map<String, Map<Integer, Integer>> tempMap = new HashMap<>();
  125 + Map<Integer, Integer> map = new HashMap<>();
  126 + map.put(month, count);
  127 + tempMap.put(id, map);
  128 + datas.add(tempMap);
  129 + }
  130 + }
  131 +
  132 + System.out.println("===================================== codemap =================================");
  133 + Set<Map.Entry<String, Integer>> codeMapEntries = codeMap.entrySet();
  134 + for (Map.Entry<String, Integer> codeMapEntry : codeMapEntries) {
  135 + System.out.println(codeMapEntry.getKey() + " : " + codeMapEntry.getValue());
  136 + }
  137 + System.out.println("===================================== datas =================================");
  138 + for (Map<String, Map<Integer, Integer>> data : datas) {
  139 + Set<Map.Entry<String, Map<Integer, Integer>>> set = data.entrySet();
  140 + for (Map.Entry<String, Map<Integer, Integer>> mapEntry : set) {
  141 + System.out.println(mapEntry.getKey() + " : " + mapEntry.getValue());
  142 + }
  143 + }
  144 +
  145 + List<Map<String, Object>> restMap = new ArrayList<>();
  146 +
  147 + /** 设置没数据的月份为0 */
  148 + for (Map<String, Map<Integer, Integer>> data : datas) {
  149 + Integer count = 0;
  150 + Set<Map.Entry<String, Map<Integer, Integer>>> set = data.entrySet();
  151 + for (Map.Entry<String, Map<Integer, Integer>> entry : set) {
  152 + Map<Integer, Integer> map = entry.getValue();
  153 + Map<String, Object> tempMap = new HashMap<>();
  154 + for (int i = 1; i <= 12; i++) {
  155 + if(!map.containsKey(i)) {
  156 + map.put(i, 0);
  157 + tempMap.put(i + "", 0);
  158 + } else {
  159 + count += map.get(i);
  160 + tempMap.put(i + "", map.get(i));
  161 + }
  162 + }
  163 + map.put(0, count);
  164 + tempMap.put("count", count);
  165 + tempMap.put("id", entry.getKey());
  166 + tempMap.put("name", findName(entry.getKey()));
  167 + restMap.add(tempMap);
  168 + }
  169 + }
  170 +
  171 +
  172 + /** 处理 其他 数据 */
  173 + Map<String, Object> tempMap = new HashMap<>();
  174 + tempMap.put("count", otherCount);
  175 + tempMap.put("name", "其他");
  176 + tempMap.put("id", null);
  177 + for (int i = 1; i <= 12; i++) {
  178 + if(otherMonthMap.containsKey(i + "")) {
  179 + tempMap.put(i + "", otherMonthMap.get(i + ""));
  180 + } else {
  181 + tempMap.put(i + "", 0);
  182 + }
  183 + }
  184 + restMap.add(tempMap);
  185 +
  186 + /* for (Map<String, Map<Integer, Integer>> data : datas) {
  187 + System.out.println("data>>> " + data);
  188 + }
  189 + System.out.println("========================");
  190 + for (Map<String, Object> map : restMap) {
  191 + System.out.println("rest>> " + map);
  192 + }*/
  193 + return restMap;
  194 + }
  195 +
  196 + public String findName(Object id) {
  197 + if(id != null) {
  198 + BasicConfig basicConfig = mongoTemplate.findById(id, BasicConfig.class);
  199 + if(basicConfig != null) {
  200 + return basicConfig.getName();
  201 + }
  202 + }
  203 + return null;
  204 + }
  205 +
  206 + public String findId(String name) {
  207 + if(StringUtils.isNotEmpty(name)) {
  208 + BasicConfig basicConfig = mongoTemplate.findOne(Query.query(Criteria.where("name").is(name)), BasicConfig.class);
  209 + if(basicConfig != null) {
  210 + return basicConfig.getId();
  211 + }
  212 + }
  213 + return null;
  214 + }
  215 +
  216 +}
platform-reportData/src/main/java/com/lymsh/platform/reportdata/model/echarts/Series.java View file @ e0d78f3
... ... @@ -13,6 +13,7 @@
13 13 private Boolean roam;
14 14 private Label label;
15 15 private List<Object> data;
  16 + private String stack;
16 17  
17 18 public String getName() {
18 19 return name;
... ... @@ -60,6 +61,14 @@
60 61  
61 62 public void setData(List<Object> data) {
62 63 this.data = data;
  64 + }
  65 +
  66 + public String getStack() {
  67 + return stack;
  68 + }
  69 +
  70 + public void setStack(String stack) {
  71 + this.stack = stack;
63 72 }
64 73 }