Authored by fangyeqing

fix some bug

... ... @@ -50,6 +50,15 @@ public interface Constants {
Set<Integer> testItemSet = new HashSet<>();
Integer testItemType = 1;
/**
* 报告详情特殊处理:item_id=91,114,115。这里在原始报告中为“----”,为了好计算得分,改成了-999-999999,需要改回去
*/
Set<Integer> itemIdSpSet = new HashSet<Integer>(){{
add(91);
add(114);
add(115);
}};
String itemRangeSpString = "----";
/**
* 分年龄段平均得分
*/
... ...
... ... @@ -125,6 +125,7 @@ public class DataShareController {
return new ResponseEntity<>(ResultModel.error(COMPANY_ERROR), HttpStatus.OK);
}
Map<Integer,ReportTypeModel> reportTypeMap = new HashMap<>();
if (report != null) {
if (report.getScore() - 0 < Constants.SMALL_DOUBLE || report.getScore() == null) {//首次调用接口,score为0
scoreService.getScore(report_id);
... ... @@ -137,7 +138,7 @@ public class DataShareController {
if (metaItems != null) {
int item_type = metaItems.getType();
boolean testFlag = false;//是否是测试项目,测试项目要存两份
if(Constants.testItemSet.contains(item_type)){
if(Constants.testItemSet.contains(itemId)){
testFlag = true;
}
... ... @@ -146,45 +147,55 @@ public class DataShareController {
reportDetail.setItemValue(detail.getItemValue());
reportDetail.setStatus(detail.getStatus());
reportDetail.setTitle(metaItems.getTitle());
if (report.getSex() == Constants.MALE) {
if(Constants.itemIdSpSet.contains(itemId)){//特殊项
reportDetail.setNormalRange(Constants.itemRangeSpString);
}else if (report.getSex() == Constants.MALE) {//男
reportDetail.setNormalRange(metaItems.getStandardLowMale() + " - " + metaItems.getStandardHighMale());
} else {
}else {//女
reportDetail.setNormalRange(metaItems.getStandardLowFemale() + " - " + metaItems.getStandardHighFemale());
}
//正常的一份
if(!reportTypeMap.containsKey(item_type)){
ReportTypeModel reportTypeModel = new ReportTypeModel();
if(testFlag){//测试项目没有打分
//reportTypeModel.setTypeHealthScore(0);
reportTypeModel.setType(Constants.testItemType);
}else{
reportTypeModel.setType(item_type);
XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, item_type);
if (scoreEntity != null) {
reportTypeModel.setTypeHealthScore(scoreEntity.getTypeHealthScore());
}
reportTypeModel.setType(item_type);
XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, item_type);
if (scoreEntity != null) {
reportTypeModel.setTypeHealthScore(scoreEntity.getTypeHealthScore());
}
List<ReportDetailModel> reportDetailModelList = new ArrayList<>();
reportDetailModelList.add(reportDetail);
reportTypeModel.setReportDetailModelList(reportDetailModelList);
reportTypeMap.put(item_type,reportTypeModel);
if(testFlag){//同时也是测试项目
reportTypeMap.put(Constants.testItemType,reportTypeModel);
}
}else{
ReportTypeModel reportTypeModel = reportTypeMap.get(item_type);
List<ReportDetailModel> reportDetailModelList = reportTypeModel.getReportDetailModelList();
reportDetailModelList.add(reportDetail);
reportTypeModel.setReportDetailModelList(reportDetailModelList);
reportTypeMap.put(item_type,reportTypeModel);
if(testFlag){//同时也是测试项目
reportTypeMap.put(Constants.testItemType,reportTypeModel);
}
//测试项目另存一份
if(testFlag){
if(!reportTypeMap.containsKey(Constants.testItemType)){
//test项目一份
ReportTypeModel reportTypeModel_test = new ReportTypeModel();
reportTypeModel_test.setTypeHealthScore(0);//测试项目没有打分
reportTypeModel_test.setType(Constants.testItemType);
List<ReportDetailModel> reportDetailModelList_test = new ArrayList<>();
reportDetailModelList_test.add(reportDetail);
reportTypeModel_test.setReportDetailModelList(reportDetailModelList_test);
reportTypeMap.put(Constants.testItemType,reportTypeModel_test);
}else{
ReportTypeModel reportTypeModel_test = reportTypeMap.get(Constants.testItemType);
List<ReportDetailModel> reportDetailModelList_test = reportTypeModel_test.getReportDetailModelList();
reportDetailModelList_test.add(reportDetail);
reportTypeModel_test.setReportDetailModelList(reportDetailModelList_test);
reportTypeMap.put(Constants.testItemType,reportTypeModel_test);
}
}
}
}
}
ReportModel reportModel = new ReportModel(report, reportTypeMap);
return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK);
}
... ...
... ... @@ -18,6 +18,7 @@ import com.xkl.security.AntiXSS;
import com.xkl.service.IScoreService;
import com.xkl.tools.HtmlTools;
import com.xkl.tools.UtilTools;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
... ... @@ -32,6 +33,7 @@ import java.util.*;
/**
* Created by win7 on 2016/11/20.
*/
@CommonsLog
@RestController
@RequestMapping("/report")
public class ReportController {
... ... @@ -92,7 +94,7 @@ public class ReportController {
if (metaItems != null) {
int item_type = metaItems.getType();
boolean testFlag = false;//是否是测试项目,测试项目要存两份
if(Constants.testItemSet.contains(item_type)){
if(Constants.testItemSet.contains(itemId)){
testFlag = true;
}
... ... @@ -101,40 +103,49 @@ public class ReportController {
reportDetail.setItemValue(detail.getItemValue());
reportDetail.setStatus(detail.getStatus());
reportDetail.setTitle(metaItems.getTitle());
if (report.getSex() == Constants.MALE) {
if(Constants.itemIdSpSet.contains(itemId)){//特殊项
reportDetail.setNormalRange(Constants.itemRangeSpString);
}else if (report.getSex() == Constants.MALE) {//男
reportDetail.setNormalRange(metaItems.getStandardLowMale() + " - " + metaItems.getStandardHighMale());
} else {
}else {//女
reportDetail.setNormalRange(metaItems.getStandardLowFemale() + " - " + metaItems.getStandardHighFemale());
}
//正常的一份
if(!reportTypeMap.containsKey(item_type)){
ReportTypeModel reportTypeModel = new ReportTypeModel();
if(testFlag){//测试项目没有打分
//reportTypeModel.setTypeHealthScore(0);
reportTypeModel.setType(Constants.testItemType);
}else{
reportTypeModel.setType(item_type);
XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, item_type);
if (scoreEntity != null) {
reportTypeModel.setTypeHealthScore(scoreEntity.getTypeHealthScore());
}
reportTypeModel.setType(item_type);
XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, item_type);
if (scoreEntity != null) {
reportTypeModel.setTypeHealthScore(scoreEntity.getTypeHealthScore());
}
List<ReportDetailModel> reportDetailModelList = new ArrayList<>();
reportDetailModelList.add(reportDetail);
reportTypeModel.setReportDetailModelList(reportDetailModelList);
reportTypeMap.put(item_type,reportTypeModel);
if(testFlag){//同时也是测试项目,需要再存一份到测试项目分类中
reportTypeMap.put(Constants.testItemType,reportTypeModel);
}
}else{
ReportTypeModel reportTypeModel = reportTypeMap.get(item_type);
List<ReportDetailModel> reportDetailModelList = reportTypeModel.getReportDetailModelList();
reportDetailModelList.add(reportDetail);
reportTypeModel.setReportDetailModelList(reportDetailModelList);
reportTypeMap.put(item_type,reportTypeModel);
if(testFlag){//同时也是测试项目
reportTypeMap.put(Constants.testItemType,reportTypeModel);
}
//测试项目另存一份
if(testFlag){
if(!reportTypeMap.containsKey(Constants.testItemType)){
//test项目一份
ReportTypeModel reportTypeModel_test = new ReportTypeModel();
reportTypeModel_test.setTypeHealthScore(0);//测试项目没有打分
reportTypeModel_test.setType(Constants.testItemType);
List<ReportDetailModel> reportDetailModelList_test = new ArrayList<>();
reportDetailModelList_test.add(reportDetail);
reportTypeModel_test.setReportDetailModelList(reportDetailModelList_test);
reportTypeMap.put(Constants.testItemType,reportTypeModel_test);
}else{
ReportTypeModel reportTypeModel_test = reportTypeMap.get(Constants.testItemType);
List<ReportDetailModel> reportDetailModelList_test = reportTypeModel_test.getReportDetailModelList();
reportDetailModelList_test.add(reportDetail);
reportTypeModel_test.setReportDetailModelList(reportDetailModelList_test);
reportTypeMap.put(Constants.testItemType,reportTypeModel_test);
}
}
}
... ...
... ... @@ -5,6 +5,9 @@ import java.util.Random;
/**
* Created by win7 on 2016/11/7.
* 首先将用户输入的原始密码进行md5加密;
* 将用户账号和加密盐(用户注册和修改时生成的随机字符串)进行sha1加密;
* 将sha1加密后的密文和原始密码加密后的密文一起进行md5加密,这样就得到了最终的加密密码
*/
public class SecurityTool {
private static final String ALGORITHM = "SHA1";
... ...
... ... @@ -29,6 +29,7 @@ public class ScoreServiceImpl implements IScoreService,Constants{
@Override
public double getScore(long report_id) {
log.info("打分开始report_id= "+report_id);
Map<Integer,Double> typeScoreMap=new HashMap<>();//记录各大项打分的Map
/**
... ...