Showing
7 changed files
with
111 additions
and
31 deletions
@@ -6,7 +6,9 @@ import com.xkl.domain.XklAmpReportMetaScoreStandardEntity; | @@ -6,7 +6,9 @@ import com.xkl.domain.XklAmpReportMetaScoreStandardEntity; | ||
6 | import com.xkl.model.CityModel; | 6 | import com.xkl.model.CityModel; |
7 | 7 | ||
8 | import java.util.HashMap; | 8 | import java.util.HashMap; |
9 | +import java.util.HashSet; | ||
9 | import java.util.Map; | 10 | import java.util.Map; |
11 | +import java.util.Set; | ||
10 | 12 | ||
11 | /** | 13 | /** |
12 | * 常量 | 14 | * 常量 |
@@ -42,8 +44,11 @@ public interface Constants { | @@ -42,8 +44,11 @@ public interface Constants { | ||
42 | * 大项综合加权标准 | 44 | * 大项综合加权标准 |
43 | */ | 45 | */ |
44 | Map<Integer, XklAmpReportCategoryEntity> weightedScoreMap = new HashMap<>(); | 46 | Map<Integer, XklAmpReportCategoryEntity> weightedScoreMap = new HashMap<>(); |
45 | - | 47 | + //不包含测试项目 |
46 | Map<Integer, XklAmpReportMetaItemsEntity> itemMetaMap = new HashMap<Integer, XklAmpReportMetaItemsEntity>(); | 48 | Map<Integer, XklAmpReportMetaItemsEntity> itemMetaMap = new HashMap<Integer, XklAmpReportMetaItemsEntity>(); |
49 | + //测试项目type=1 | ||
50 | + Set<Integer> testItemSet = new HashSet<>(); | ||
51 | + Integer testItemType = 1; | ||
47 | /** | 52 | /** |
48 | * 分年龄段平均得分 | 53 | * 分年龄段平均得分 |
49 | */ | 54 | */ |
@@ -55,7 +55,11 @@ public class ScheduledTask implements Constants{ | @@ -55,7 +55,11 @@ public class ScheduledTask implements Constants{ | ||
55 | Iterator<XklAmpReportMetaItemsEntity> it = metaItemsRespository.findAll().iterator(); | 55 | Iterator<XklAmpReportMetaItemsEntity> it = metaItemsRespository.findAll().iterator(); |
56 | while(it.hasNext()){ | 56 | while(it.hasNext()){ |
57 | XklAmpReportMetaItemsEntity reportMetaItems = it.next(); | 57 | XklAmpReportMetaItemsEntity reportMetaItems = it.next(); |
58 | - itemMetaMap.put(reportMetaItems.getItemId(),reportMetaItems); | 58 | + if(reportMetaItems.getType()!=1) {//测试项目除外 |
59 | + itemMetaMap.put(reportMetaItems.getItemId(), reportMetaItems); | ||
60 | + }else{ | ||
61 | + testItemSet.add(reportMetaItems.getItemId()); | ||
62 | + } | ||
59 | } | 63 | } |
60 | } | 64 | } |
61 | 65 |
@@ -7,6 +7,7 @@ import com.xkl.config.Constants; | @@ -7,6 +7,7 @@ import com.xkl.config.Constants; | ||
7 | import com.xkl.domain.*; | 7 | import com.xkl.domain.*; |
8 | import com.xkl.model.ReportDetailModel; | 8 | import com.xkl.model.ReportDetailModel; |
9 | import com.xkl.model.ReportModel; | 9 | import com.xkl.model.ReportModel; |
10 | +import com.xkl.model.ReportTypeModel; | ||
10 | import com.xkl.model.ResultModel; | 11 | import com.xkl.model.ResultModel; |
11 | import com.xkl.repository.*; | 12 | import com.xkl.repository.*; |
12 | import com.xkl.security.AntiXSS; | 13 | import com.xkl.security.AntiXSS; |
@@ -21,7 +22,9 @@ import org.springframework.web.bind.annotation.RestController; | @@ -21,7 +22,9 @@ import org.springframework.web.bind.annotation.RestController; | ||
21 | 22 | ||
22 | import javax.servlet.http.HttpServletRequest; | 23 | import javax.servlet.http.HttpServletRequest; |
23 | import java.util.ArrayList; | 24 | import java.util.ArrayList; |
25 | +import java.util.HashMap; | ||
24 | import java.util.List; | 26 | import java.util.List; |
27 | +import java.util.Map; | ||
25 | 28 | ||
26 | import static com.xkl.config.ResultStatus.*; | 29 | import static com.xkl.config.ResultStatus.*; |
27 | 30 | ||
@@ -121,38 +124,68 @@ public class DataShareController { | @@ -121,38 +124,68 @@ public class DataShareController { | ||
121 | }else{ | 124 | }else{ |
122 | return new ResponseEntity<>(ResultModel.error(COMPANY_ERROR), HttpStatus.OK); | 125 | return new ResponseEntity<>(ResultModel.error(COMPANY_ERROR), HttpStatus.OK); |
123 | } | 126 | } |
124 | - | ||
125 | - List<ReportDetailModel> reportDetailModelList = new ArrayList<>(); | 127 | + Map<Integer,ReportTypeModel> reportTypeMap = new HashMap<>(); |
126 | if (report != null) { | 128 | if (report != null) { |
127 | if (report.getScore() - 0 < Constants.SMALL_DOUBLE || report.getScore() == null) {//首次调用接口,score为0 | 129 | if (report.getScore() - 0 < Constants.SMALL_DOUBLE || report.getScore() == null) {//首次调用接口,score为0 |
128 | scoreService.getScore(report_id); | 130 | scoreService.getScore(report_id); |
129 | } | 131 | } |
130 | List<XklAmpReportDetailEntity> reportDetailEntityList = xklAmpReportDetailRespository.findAllByReportId(report_id); | 132 | List<XklAmpReportDetailEntity> reportDetailEntityList = xklAmpReportDetailRespository.findAllByReportId(report_id); |
131 | for (XklAmpReportDetailEntity detail : reportDetailEntityList) { | 133 | for (XklAmpReportDetailEntity detail : reportDetailEntityList) { |
134 | + | ||
132 | int itemId = detail.getItemId(); | 135 | int itemId = detail.getItemId(); |
136 | + XklAmpReportMetaItemsEntity metaItems = Constants.itemMetaMap.get(itemId); | ||
137 | + if (metaItems != null) { | ||
138 | + int item_type = metaItems.getType(); | ||
139 | + boolean testFlag = false;//是否是测试项目,测试项目要存两份 | ||
140 | + if(Constants.testItemSet.contains(item_type)){ | ||
141 | + testFlag = true; | ||
142 | + } | ||
143 | + | ||
133 | ReportDetailModel reportDetail = new ReportDetailModel(); | 144 | ReportDetailModel reportDetail = new ReportDetailModel(); |
134 | reportDetail.setItemId(itemId); | 145 | reportDetail.setItemId(itemId); |
135 | reportDetail.setItemValue(detail.getItemValue()); | 146 | reportDetail.setItemValue(detail.getItemValue()); |
136 | reportDetail.setStatus(detail.getStatus()); | 147 | reportDetail.setStatus(detail.getStatus()); |
137 | - | ||
138 | - XklAmpReportMetaItemsEntity metaItems = Constants.itemMetaMap.get(itemId); | ||
139 | - if (metaItems != null) { | ||
140 | reportDetail.setTitle(metaItems.getTitle()); | 148 | reportDetail.setTitle(metaItems.getTitle()); |
141 | if (report.getSex() == Constants.MALE) { | 149 | if (report.getSex() == Constants.MALE) { |
142 | reportDetail.setNormalRange(metaItems.getStandardLowMale() + " - " + metaItems.getStandardHighMale()); | 150 | reportDetail.setNormalRange(metaItems.getStandardLowMale() + " - " + metaItems.getStandardHighMale()); |
143 | } else { | 151 | } else { |
144 | reportDetail.setNormalRange(metaItems.getStandardLowFemale() + " - " + metaItems.getStandardHighFemale()); | 152 | reportDetail.setNormalRange(metaItems.getStandardLowFemale() + " - " + metaItems.getStandardHighFemale()); |
145 | } | 153 | } |
146 | - reportDetail.setType(metaItems.getType()); | ||
147 | - } | ||
148 | 154 | ||
149 | - XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, metaItems.getType()); | ||
150 | - if (scoreEntity != null) | ||
151 | - reportDetail.setTypeHealthScore(scoreEntity.getTypeHealthScore()); | 155 | + if(!reportTypeMap.containsKey(item_type)){ |
156 | + ReportTypeModel reportTypeModel = new ReportTypeModel(); | ||
157 | + | ||
158 | + if(testFlag){//测试项目没有打分 | ||
159 | + //reportTypeModel.setTypeHealthScore(0); | ||
160 | + reportTypeModel.setType(Constants.testItemType); | ||
161 | + }else{ | ||
162 | + reportTypeModel.setType(item_type); | ||
163 | + XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, item_type); | ||
164 | + if (scoreEntity != null) { | ||
165 | + reportTypeModel.setTypeHealthScore(scoreEntity.getTypeHealthScore()); | ||
166 | + } | ||
167 | + } | ||
168 | + List<ReportDetailModel> reportDetailModelList = new ArrayList<>(); | ||
152 | reportDetailModelList.add(reportDetail); | 169 | reportDetailModelList.add(reportDetail); |
170 | + reportTypeModel.setReportDetailModelList(reportDetailModelList); | ||
171 | + reportTypeMap.put(item_type,reportTypeModel); | ||
172 | + if(testFlag){//同时也是测试项目 | ||
173 | + reportTypeMap.put(Constants.testItemType,reportTypeModel); | ||
174 | + } | ||
175 | + }else{ | ||
176 | + ReportTypeModel reportTypeModel = reportTypeMap.get(item_type); | ||
177 | + List<ReportDetailModel> reportDetailModelList = reportTypeModel.getReportDetailModelList(); | ||
178 | + reportDetailModelList.add(reportDetail); | ||
179 | + reportTypeModel.setReportDetailModelList(reportDetailModelList); | ||
180 | + reportTypeMap.put(item_type,reportTypeModel); | ||
181 | + if(testFlag){//同时也是测试项目 | ||
182 | + reportTypeMap.put(Constants.testItemType,reportTypeModel); | ||
183 | + } | ||
184 | + } | ||
185 | + } | ||
153 | } | 186 | } |
154 | } | 187 | } |
155 | - ReportModel reportModel = new ReportModel(report, reportDetailModelList); | 188 | + ReportModel reportModel = new ReportModel(report, reportTypeMap); |
156 | return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK); | 189 | return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK); |
157 | } | 190 | } |
158 | 191 |
@@ -79,37 +79,68 @@ public class ReportController { | @@ -79,37 +79,68 @@ public class ReportController { | ||
79 | return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); | 79 | return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); |
80 | 80 | ||
81 | XklAmpReportEntity report = xklAmpReportRespository.findOne(report_id); | 81 | XklAmpReportEntity report = xklAmpReportRespository.findOne(report_id); |
82 | - List<ReportDetailModel> reportDetailModelList = new ArrayList<>(); | 82 | + Map<Integer,ReportTypeModel> reportTypeMap = new HashMap<>(); |
83 | if (report != null) { | 83 | if (report != null) { |
84 | if (report.getScore() - 0 < Constants.SMALL_DOUBLE || report.getScore() == null) {//首次调用接口,score为0 | 84 | if (report.getScore() - 0 < Constants.SMALL_DOUBLE || report.getScore() == null) {//首次调用接口,score为0 |
85 | scoreService.getScore(report_id); | 85 | scoreService.getScore(report_id); |
86 | } | 86 | } |
87 | List<XklAmpReportDetailEntity> reportDetailEntityList = xklAmpReportDetailRespository.findAllByReportId(report_id); | 87 | List<XklAmpReportDetailEntity> reportDetailEntityList = xklAmpReportDetailRespository.findAllByReportId(report_id); |
88 | for (XklAmpReportDetailEntity detail : reportDetailEntityList) { | 88 | for (XklAmpReportDetailEntity detail : reportDetailEntityList) { |
89 | + | ||
89 | int itemId = detail.getItemId(); | 90 | int itemId = detail.getItemId(); |
91 | + XklAmpReportMetaItemsEntity metaItems = Constants.itemMetaMap.get(itemId); | ||
92 | + if (metaItems != null) { | ||
93 | + int item_type = metaItems.getType(); | ||
94 | + boolean testFlag = false;//是否是测试项目,测试项目要存两份 | ||
95 | + if(Constants.testItemSet.contains(item_type)){ | ||
96 | + testFlag = true; | ||
97 | + } | ||
98 | + | ||
90 | ReportDetailModel reportDetail = new ReportDetailModel(); | 99 | ReportDetailModel reportDetail = new ReportDetailModel(); |
91 | reportDetail.setItemId(itemId); | 100 | reportDetail.setItemId(itemId); |
92 | reportDetail.setItemValue(detail.getItemValue()); | 101 | reportDetail.setItemValue(detail.getItemValue()); |
93 | reportDetail.setStatus(detail.getStatus()); | 102 | reportDetail.setStatus(detail.getStatus()); |
94 | - | ||
95 | - XklAmpReportMetaItemsEntity metaItems = Constants.itemMetaMap.get(itemId); | ||
96 | - if (metaItems != null) { | ||
97 | reportDetail.setTitle(metaItems.getTitle()); | 103 | reportDetail.setTitle(metaItems.getTitle()); |
98 | if (report.getSex() == Constants.MALE) { | 104 | if (report.getSex() == Constants.MALE) { |
99 | reportDetail.setNormalRange(metaItems.getStandardLowMale() + " - " + metaItems.getStandardHighMale()); | 105 | reportDetail.setNormalRange(metaItems.getStandardLowMale() + " - " + metaItems.getStandardHighMale()); |
100 | } else { | 106 | } else { |
101 | reportDetail.setNormalRange(metaItems.getStandardLowFemale() + " - " + metaItems.getStandardHighFemale()); | 107 | reportDetail.setNormalRange(metaItems.getStandardLowFemale() + " - " + metaItems.getStandardHighFemale()); |
102 | } | 108 | } |
103 | - reportDetail.setType(metaItems.getType()); | ||
104 | - } | ||
105 | 109 | ||
106 | - XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, metaItems.getType()); | ||
107 | - if (scoreEntity != null) | ||
108 | - reportDetail.setTypeHealthScore(scoreEntity.getTypeHealthScore()); | 110 | + if(!reportTypeMap.containsKey(item_type)){ |
111 | + ReportTypeModel reportTypeModel = new ReportTypeModel(); | ||
112 | + | ||
113 | + if(testFlag){//测试项目没有打分 | ||
114 | + //reportTypeModel.setTypeHealthScore(0); | ||
115 | + reportTypeModel.setType(Constants.testItemType); | ||
116 | + }else{ | ||
117 | + reportTypeModel.setType(item_type); | ||
118 | + XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, item_type); | ||
119 | + if (scoreEntity != null) { | ||
120 | + reportTypeModel.setTypeHealthScore(scoreEntity.getTypeHealthScore()); | ||
121 | + } | ||
122 | + } | ||
123 | + List<ReportDetailModel> reportDetailModelList = new ArrayList<>(); | ||
109 | reportDetailModelList.add(reportDetail); | 124 | reportDetailModelList.add(reportDetail); |
125 | + reportTypeModel.setReportDetailModelList(reportDetailModelList); | ||
126 | + reportTypeMap.put(item_type,reportTypeModel); | ||
127 | + if(testFlag){//同时也是测试项目,需要再存一份到测试项目分类中 | ||
128 | + reportTypeMap.put(Constants.testItemType,reportTypeModel); | ||
129 | + } | ||
130 | + }else{ | ||
131 | + ReportTypeModel reportTypeModel = reportTypeMap.get(item_type); | ||
132 | + List<ReportDetailModel> reportDetailModelList = reportTypeModel.getReportDetailModelList(); | ||
133 | + reportDetailModelList.add(reportDetail); | ||
134 | + reportTypeModel.setReportDetailModelList(reportDetailModelList); | ||
135 | + reportTypeMap.put(item_type,reportTypeModel); | ||
136 | + if(testFlag){//同时也是测试项目 | ||
137 | + reportTypeMap.put(Constants.testItemType,reportTypeModel); | ||
138 | + } | ||
139 | + } | ||
140 | + } | ||
110 | } | 141 | } |
111 | } | 142 | } |
112 | - ReportModel reportModel = new ReportModel(report, reportDetailModelList); | 143 | + ReportModel reportModel = new ReportModel(report, reportTypeMap); |
113 | return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK); | 144 | return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK); |
114 | } | 145 | } |
115 | 146 |
@@ -18,9 +18,4 @@ public class ReportDetailModel { | @@ -18,9 +18,4 @@ public class ReportDetailModel { | ||
18 | */ | 18 | */ |
19 | private String title; | 19 | private String title; |
20 | private String normalRange; | 20 | private String normalRange; |
21 | - /** | ||
22 | - * XklAmpReportHealthScoreEntity | ||
23 | - */ | ||
24 | - private int type; | ||
25 | - private double typeHealthScore; | ||
26 | } | 21 | } |
@@ -6,6 +6,7 @@ import lombok.AllArgsConstructor; | @@ -6,6 +6,7 @@ import lombok.AllArgsConstructor; | ||
6 | import lombok.Data; | 6 | import lombok.Data; |
7 | 7 | ||
8 | import java.util.List; | 8 | import java.util.List; |
9 | +import java.util.Map; | ||
9 | 10 | ||
10 | /** | 11 | /** |
11 | * Created by win7 on 2016/11/21. | 12 | * Created by win7 on 2016/11/21. |
@@ -14,9 +15,8 @@ import java.util.List; | @@ -14,9 +15,8 @@ import java.util.List; | ||
14 | @Data | 15 | @Data |
15 | @AllArgsConstructor | 16 | @AllArgsConstructor |
16 | public class ReportModel { | 17 | public class ReportModel { |
17 | - // | ||
18 | - private XklAmpReportEntity Report; | ||
19 | 18 | ||
20 | - private List<ReportDetailModel> ReportDetailList; | 19 | + private XklAmpReportEntity report; |
21 | 20 | ||
21 | + private Map<Integer,ReportTypeModel> reportTypeMap; | ||
22 | } | 22 | } |
1 | package com.xkl.model; | 1 | package com.xkl.model; |
2 | 2 | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
3 | /** | 7 | /** |
4 | * Created by win7 on 2017/3/19. | 8 | * Created by win7 on 2017/3/19. |
5 | */ | 9 | */ |
10 | +@Data | ||
6 | public class ReportTypeModel { | 11 | public class ReportTypeModel { |
12 | + /** | ||
13 | + * XklAmpReportHealthScoreEntity | ||
14 | + */ | ||
15 | + private int type; | ||
16 | + private double typeHealthScore; | ||
17 | + | ||
18 | + private List<ReportDetailModel> reportDetailModelList; | ||
7 | } | 19 | } |
-
Please register or login to post a comment