Authored by fangyeqing

fix some bug

@@ -50,6 +50,15 @@ public interface Constants { @@ -50,6 +50,15 @@ public interface Constants {
50 Set<Integer> testItemSet = new HashSet<>(); 50 Set<Integer> testItemSet = new HashSet<>();
51 Integer testItemType = 1; 51 Integer testItemType = 1;
52 /** 52 /**
  53 + * 报告详情特殊处理:item_id=91,114,115。这里在原始报告中为“----”,为了好计算得分,改成了-999-999999,需要改回去
  54 + */
  55 + Set<Integer> itemIdSpSet = new HashSet<Integer>(){{
  56 + add(91);
  57 + add(114);
  58 + add(115);
  59 + }};
  60 + String itemRangeSpString = "----";
  61 + /**
53 * 分年龄段平均得分 62 * 分年龄段平均得分
54 */ 63 */
55 64
@@ -125,6 +125,7 @@ public class DataShareController { @@ -125,6 +125,7 @@ public class DataShareController {
125 return new ResponseEntity<>(ResultModel.error(COMPANY_ERROR), HttpStatus.OK); 125 return new ResponseEntity<>(ResultModel.error(COMPANY_ERROR), HttpStatus.OK);
126 } 126 }
127 Map<Integer,ReportTypeModel> reportTypeMap = new HashMap<>(); 127 Map<Integer,ReportTypeModel> reportTypeMap = new HashMap<>();
  128 +
128 if (report != null) { 129 if (report != null) {
129 if (report.getScore() - 0 < Constants.SMALL_DOUBLE || report.getScore() == null) {//首次调用接口,score为0 130 if (report.getScore() - 0 < Constants.SMALL_DOUBLE || report.getScore() == null) {//首次调用接口,score为0
130 scoreService.getScore(report_id); 131 scoreService.getScore(report_id);
@@ -137,7 +138,7 @@ public class DataShareController { @@ -137,7 +138,7 @@ public class DataShareController {
137 if (metaItems != null) { 138 if (metaItems != null) {
138 int item_type = metaItems.getType(); 139 int item_type = metaItems.getType();
139 boolean testFlag = false;//是否是测试项目,测试项目要存两份 140 boolean testFlag = false;//是否是测试项目,测试项目要存两份
140 - if(Constants.testItemSet.contains(item_type)){ 141 + if(Constants.testItemSet.contains(itemId)){
141 testFlag = true; 142 testFlag = true;
142 } 143 }
143 144
@@ -146,45 +147,55 @@ public class DataShareController { @@ -146,45 +147,55 @@ public class DataShareController {
146 reportDetail.setItemValue(detail.getItemValue()); 147 reportDetail.setItemValue(detail.getItemValue());
147 reportDetail.setStatus(detail.getStatus()); 148 reportDetail.setStatus(detail.getStatus());
148 reportDetail.setTitle(metaItems.getTitle()); 149 reportDetail.setTitle(metaItems.getTitle());
149 - if (report.getSex() == Constants.MALE) { 150 + if(Constants.itemIdSpSet.contains(itemId)){//特殊项
  151 + reportDetail.setNormalRange(Constants.itemRangeSpString);
  152 + }else if (report.getSex() == Constants.MALE) {//男
150 reportDetail.setNormalRange(metaItems.getStandardLowMale() + " - " + metaItems.getStandardHighMale()); 153 reportDetail.setNormalRange(metaItems.getStandardLowMale() + " - " + metaItems.getStandardHighMale());
151 - } else { 154 + }else {//女
152 reportDetail.setNormalRange(metaItems.getStandardLowFemale() + " - " + metaItems.getStandardHighFemale()); 155 reportDetail.setNormalRange(metaItems.getStandardLowFemale() + " - " + metaItems.getStandardHighFemale());
153 } 156 }
154 - 157 + //正常的一份
155 if(!reportTypeMap.containsKey(item_type)){ 158 if(!reportTypeMap.containsKey(item_type)){
156 ReportTypeModel reportTypeModel = new ReportTypeModel(); 159 ReportTypeModel reportTypeModel = new ReportTypeModel();
157 -  
158 - if(testFlag){//测试项目没有打分  
159 - //reportTypeModel.setTypeHealthScore(0);  
160 - reportTypeModel.setType(Constants.testItemType);  
161 - }else{  
162 reportTypeModel.setType(item_type); 160 reportTypeModel.setType(item_type);
163 XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, item_type); 161 XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, item_type);
164 if (scoreEntity != null) { 162 if (scoreEntity != null) {
165 reportTypeModel.setTypeHealthScore(scoreEntity.getTypeHealthScore()); 163 reportTypeModel.setTypeHealthScore(scoreEntity.getTypeHealthScore());
166 } 164 }
167 - }  
168 List<ReportDetailModel> reportDetailModelList = new ArrayList<>(); 165 List<ReportDetailModel> reportDetailModelList = new ArrayList<>();
169 reportDetailModelList.add(reportDetail); 166 reportDetailModelList.add(reportDetail);
170 reportTypeModel.setReportDetailModelList(reportDetailModelList); 167 reportTypeModel.setReportDetailModelList(reportDetailModelList);
171 reportTypeMap.put(item_type,reportTypeModel); 168 reportTypeMap.put(item_type,reportTypeModel);
172 - if(testFlag){//同时也是测试项目  
173 - reportTypeMap.put(Constants.testItemType,reportTypeModel);  
174 - }  
175 }else{ 169 }else{
176 ReportTypeModel reportTypeModel = reportTypeMap.get(item_type); 170 ReportTypeModel reportTypeModel = reportTypeMap.get(item_type);
177 List<ReportDetailModel> reportDetailModelList = reportTypeModel.getReportDetailModelList(); 171 List<ReportDetailModel> reportDetailModelList = reportTypeModel.getReportDetailModelList();
178 reportDetailModelList.add(reportDetail); 172 reportDetailModelList.add(reportDetail);
179 reportTypeModel.setReportDetailModelList(reportDetailModelList); 173 reportTypeModel.setReportDetailModelList(reportDetailModelList);
180 reportTypeMap.put(item_type,reportTypeModel); 174 reportTypeMap.put(item_type,reportTypeModel);
181 - if(testFlag){//同时也是测试项目  
182 - reportTypeMap.put(Constants.testItemType,reportTypeModel); 175 + }
  176 + //测试项目另存一份
  177 + if(testFlag){
  178 + if(!reportTypeMap.containsKey(Constants.testItemType)){
  179 + //test项目一份
  180 + ReportTypeModel reportTypeModel_test = new ReportTypeModel();
  181 + reportTypeModel_test.setTypeHealthScore(0);//测试项目没有打分
  182 + reportTypeModel_test.setType(Constants.testItemType);
  183 + List<ReportDetailModel> reportDetailModelList_test = new ArrayList<>();
  184 + reportDetailModelList_test.add(reportDetail);
  185 + reportTypeModel_test.setReportDetailModelList(reportDetailModelList_test);
  186 + reportTypeMap.put(Constants.testItemType,reportTypeModel_test);
  187 + }else{
  188 + ReportTypeModel reportTypeModel_test = reportTypeMap.get(Constants.testItemType);
  189 + List<ReportDetailModel> reportDetailModelList_test = reportTypeModel_test.getReportDetailModelList();
  190 + reportDetailModelList_test.add(reportDetail);
  191 + reportTypeModel_test.setReportDetailModelList(reportDetailModelList_test);
  192 + reportTypeMap.put(Constants.testItemType,reportTypeModel_test);
183 } 193 }
184 } 194 }
185 } 195 }
186 } 196 }
187 } 197 }
  198 +
188 ReportModel reportModel = new ReportModel(report, reportTypeMap); 199 ReportModel reportModel = new ReportModel(report, reportTypeMap);
189 return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK); 200 return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK);
190 } 201 }
@@ -18,6 +18,7 @@ import com.xkl.security.AntiXSS; @@ -18,6 +18,7 @@ import com.xkl.security.AntiXSS;
18 import com.xkl.service.IScoreService; 18 import com.xkl.service.IScoreService;
19 import com.xkl.tools.HtmlTools; 19 import com.xkl.tools.HtmlTools;
20 import com.xkl.tools.UtilTools; 20 import com.xkl.tools.UtilTools;
  21 +import lombok.extern.apachecommons.CommonsLog;
21 import org.springframework.beans.factory.annotation.Autowired; 22 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.http.HttpStatus; 23 import org.springframework.http.HttpStatus;
23 import org.springframework.http.ResponseEntity; 24 import org.springframework.http.ResponseEntity;
@@ -32,6 +33,7 @@ import java.util.*; @@ -32,6 +33,7 @@ import java.util.*;
32 /** 33 /**
33 * Created by win7 on 2016/11/20. 34 * Created by win7 on 2016/11/20.
34 */ 35 */
  36 +@CommonsLog
35 @RestController 37 @RestController
36 @RequestMapping("/report") 38 @RequestMapping("/report")
37 public class ReportController { 39 public class ReportController {
@@ -92,7 +94,7 @@ public class ReportController { @@ -92,7 +94,7 @@ public class ReportController {
92 if (metaItems != null) { 94 if (metaItems != null) {
93 int item_type = metaItems.getType(); 95 int item_type = metaItems.getType();
94 boolean testFlag = false;//是否是测试项目,测试项目要存两份 96 boolean testFlag = false;//是否是测试项目,测试项目要存两份
95 - if(Constants.testItemSet.contains(item_type)){ 97 + if(Constants.testItemSet.contains(itemId)){
96 testFlag = true; 98 testFlag = true;
97 } 99 }
98 100
@@ -101,40 +103,49 @@ public class ReportController { @@ -101,40 +103,49 @@ public class ReportController {
101 reportDetail.setItemValue(detail.getItemValue()); 103 reportDetail.setItemValue(detail.getItemValue());
102 reportDetail.setStatus(detail.getStatus()); 104 reportDetail.setStatus(detail.getStatus());
103 reportDetail.setTitle(metaItems.getTitle()); 105 reportDetail.setTitle(metaItems.getTitle());
104 - if (report.getSex() == Constants.MALE) { 106 + if(Constants.itemIdSpSet.contains(itemId)){//特殊项
  107 + reportDetail.setNormalRange(Constants.itemRangeSpString);
  108 + }else if (report.getSex() == Constants.MALE) {//男
105 reportDetail.setNormalRange(metaItems.getStandardLowMale() + " - " + metaItems.getStandardHighMale()); 109 reportDetail.setNormalRange(metaItems.getStandardLowMale() + " - " + metaItems.getStandardHighMale());
106 - } else { 110 + }else {//女
107 reportDetail.setNormalRange(metaItems.getStandardLowFemale() + " - " + metaItems.getStandardHighFemale()); 111 reportDetail.setNormalRange(metaItems.getStandardLowFemale() + " - " + metaItems.getStandardHighFemale());
108 } 112 }
109 - 113 + //正常的一份
110 if(!reportTypeMap.containsKey(item_type)){ 114 if(!reportTypeMap.containsKey(item_type)){
111 ReportTypeModel reportTypeModel = new ReportTypeModel(); 115 ReportTypeModel reportTypeModel = new ReportTypeModel();
112 -  
113 - if(testFlag){//测试项目没有打分  
114 - //reportTypeModel.setTypeHealthScore(0);  
115 - reportTypeModel.setType(Constants.testItemType);  
116 - }else{  
117 reportTypeModel.setType(item_type); 116 reportTypeModel.setType(item_type);
118 XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, item_type); 117 XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, item_type);
119 if (scoreEntity != null) { 118 if (scoreEntity != null) {
120 reportTypeModel.setTypeHealthScore(scoreEntity.getTypeHealthScore()); 119 reportTypeModel.setTypeHealthScore(scoreEntity.getTypeHealthScore());
121 } 120 }
122 - }  
123 List<ReportDetailModel> reportDetailModelList = new ArrayList<>(); 121 List<ReportDetailModel> reportDetailModelList = new ArrayList<>();
124 reportDetailModelList.add(reportDetail); 122 reportDetailModelList.add(reportDetail);
125 reportTypeModel.setReportDetailModelList(reportDetailModelList); 123 reportTypeModel.setReportDetailModelList(reportDetailModelList);
126 reportTypeMap.put(item_type,reportTypeModel); 124 reportTypeMap.put(item_type,reportTypeModel);
127 - if(testFlag){//同时也是测试项目,需要再存一份到测试项目分类中  
128 - reportTypeMap.put(Constants.testItemType,reportTypeModel);  
129 - }  
130 }else{ 125 }else{
131 ReportTypeModel reportTypeModel = reportTypeMap.get(item_type); 126 ReportTypeModel reportTypeModel = reportTypeMap.get(item_type);
132 List<ReportDetailModel> reportDetailModelList = reportTypeModel.getReportDetailModelList(); 127 List<ReportDetailModel> reportDetailModelList = reportTypeModel.getReportDetailModelList();
133 reportDetailModelList.add(reportDetail); 128 reportDetailModelList.add(reportDetail);
134 reportTypeModel.setReportDetailModelList(reportDetailModelList); 129 reportTypeModel.setReportDetailModelList(reportDetailModelList);
135 reportTypeMap.put(item_type,reportTypeModel); 130 reportTypeMap.put(item_type,reportTypeModel);
136 - if(testFlag){//同时也是测试项目  
137 - reportTypeMap.put(Constants.testItemType,reportTypeModel); 131 + }
  132 + //测试项目另存一份
  133 + if(testFlag){
  134 + if(!reportTypeMap.containsKey(Constants.testItemType)){
  135 + //test项目一份
  136 + ReportTypeModel reportTypeModel_test = new ReportTypeModel();
  137 + reportTypeModel_test.setTypeHealthScore(0);//测试项目没有打分
  138 + reportTypeModel_test.setType(Constants.testItemType);
  139 + List<ReportDetailModel> reportDetailModelList_test = new ArrayList<>();
  140 + reportDetailModelList_test.add(reportDetail);
  141 + reportTypeModel_test.setReportDetailModelList(reportDetailModelList_test);
  142 + reportTypeMap.put(Constants.testItemType,reportTypeModel_test);
  143 + }else{
  144 + ReportTypeModel reportTypeModel_test = reportTypeMap.get(Constants.testItemType);
  145 + List<ReportDetailModel> reportDetailModelList_test = reportTypeModel_test.getReportDetailModelList();
  146 + reportDetailModelList_test.add(reportDetail);
  147 + reportTypeModel_test.setReportDetailModelList(reportDetailModelList_test);
  148 + reportTypeMap.put(Constants.testItemType,reportTypeModel_test);
138 } 149 }
139 } 150 }
140 } 151 }
@@ -5,6 +5,9 @@ import java.util.Random; @@ -5,6 +5,9 @@ import java.util.Random;
5 5
6 /** 6 /**
7 * Created by win7 on 2016/11/7. 7 * Created by win7 on 2016/11/7.
  8 + * 首先将用户输入的原始密码进行md5加密;
  9 + * 将用户账号和加密盐(用户注册和修改时生成的随机字符串)进行sha1加密;
  10 + * 将sha1加密后的密文和原始密码加密后的密文一起进行md5加密,这样就得到了最终的加密密码
8 */ 11 */
9 public class SecurityTool { 12 public class SecurityTool {
10 private static final String ALGORITHM = "SHA1"; 13 private static final String ALGORITHM = "SHA1";
@@ -29,6 +29,7 @@ public class ScoreServiceImpl implements IScoreService,Constants{ @@ -29,6 +29,7 @@ public class ScoreServiceImpl implements IScoreService,Constants{
29 29
30 @Override 30 @Override
31 public double getScore(long report_id) { 31 public double getScore(long report_id) {
  32 + log.info("打分开始report_id= "+report_id);
32 Map<Integer,Double> typeScoreMap=new HashMap<>();//记录各大项打分的Map 33 Map<Integer,Double> typeScoreMap=new HashMap<>();//记录各大项打分的Map
33 34
34 /** 35 /**