Authored by fangyeqing

Merge branch 'reportStructure' into 'master'

Report structure

报告层级变为3层

See merge request !31
... ... @@ -6,7 +6,9 @@ import com.xkl.domain.XklAmpReportMetaScoreStandardEntity;
import com.xkl.model.CityModel;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* 常量
... ... @@ -42,8 +44,11 @@ public interface Constants {
* 大项综合加权标准
*/
Map<Integer, XklAmpReportCategoryEntity> weightedScoreMap = new HashMap<>();
//不包含测试项目
Map<Integer, XklAmpReportMetaItemsEntity> itemMetaMap = new HashMap<Integer, XklAmpReportMetaItemsEntity>();
//测试项目type=1
Set<Integer> testItemSet = new HashSet<>();
Integer testItemType = 1;
/**
* 分年龄段平均得分
*/
... ...
... ... @@ -55,7 +55,11 @@ public class ScheduledTask implements Constants{
Iterator<XklAmpReportMetaItemsEntity> it = metaItemsRespository.findAll().iterator();
while(it.hasNext()){
XklAmpReportMetaItemsEntity reportMetaItems = it.next();
itemMetaMap.put(reportMetaItems.getItemId(),reportMetaItems);
if(reportMetaItems.getType()!=1) {//测试项目除外
itemMetaMap.put(reportMetaItems.getItemId(), reportMetaItems);
}else{
testItemSet.add(reportMetaItems.getItemId());
}
}
}
... ...
... ... @@ -7,6 +7,7 @@ import com.xkl.config.Constants;
import com.xkl.domain.*;
import com.xkl.model.ReportDetailModel;
import com.xkl.model.ReportModel;
import com.xkl.model.ReportTypeModel;
import com.xkl.model.ResultModel;
import com.xkl.repository.*;
import com.xkl.security.AntiXSS;
... ... @@ -21,7 +22,9 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.xkl.config.ResultStatus.*;
... ... @@ -121,38 +124,68 @@ public class DataShareController {
}else{
return new ResponseEntity<>(ResultModel.error(COMPANY_ERROR), HttpStatus.OK);
}
List<ReportDetailModel> reportDetailModelList = new ArrayList<>();
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);
}
List<XklAmpReportDetailEntity> reportDetailEntityList = xklAmpReportDetailRespository.findAllByReportId(report_id);
for (XklAmpReportDetailEntity detail : reportDetailEntityList) {
int itemId = detail.getItemId();
ReportDetailModel reportDetail = new ReportDetailModel();
reportDetail.setItemId(itemId);
reportDetail.setItemValue(detail.getItemValue());
reportDetail.setStatus(detail.getStatus());
int itemId = detail.getItemId();
XklAmpReportMetaItemsEntity metaItems = Constants.itemMetaMap.get(itemId);
if (metaItems != null) {
int item_type = metaItems.getType();
boolean testFlag = false;//是否是测试项目,测试项目要存两份
if(Constants.testItemSet.contains(item_type)){
testFlag = true;
}
ReportDetailModel reportDetail = new ReportDetailModel();
reportDetail.setItemId(itemId);
reportDetail.setItemValue(detail.getItemValue());
reportDetail.setStatus(detail.getStatus());
reportDetail.setTitle(metaItems.getTitle());
if (report.getSex() == Constants.MALE) {
reportDetail.setNormalRange(metaItems.getStandardLowMale() + " - " + metaItems.getStandardHighMale());
} else {
reportDetail.setNormalRange(metaItems.getStandardLowFemale() + " - " + metaItems.getStandardHighFemale());
}
reportDetail.setType(metaItems.getType());
}
XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, metaItems.getType());
if (scoreEntity != null)
reportDetail.setTypeHealthScore(scoreEntity.getTypeHealthScore());
reportDetailModelList.add(reportDetail);
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());
}
}
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);
}
}
}
}
}
ReportModel reportModel = new ReportModel(report, reportDetailModelList);
ReportModel reportModel = new ReportModel(report, reportTypeMap);
return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK);
}
... ...
... ... @@ -79,37 +79,68 @@ public class ReportController {
return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
XklAmpReportEntity report = xklAmpReportRespository.findOne(report_id);
List<ReportDetailModel> reportDetailModelList = new ArrayList<>();
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);
}
List<XklAmpReportDetailEntity> reportDetailEntityList = xklAmpReportDetailRespository.findAllByReportId(report_id);
for (XklAmpReportDetailEntity detail : reportDetailEntityList) {
int itemId = detail.getItemId();
ReportDetailModel reportDetail = new ReportDetailModel();
reportDetail.setItemId(itemId);
reportDetail.setItemValue(detail.getItemValue());
reportDetail.setStatus(detail.getStatus());
int itemId = detail.getItemId();
XklAmpReportMetaItemsEntity metaItems = Constants.itemMetaMap.get(itemId);
if (metaItems != null) {
int item_type = metaItems.getType();
boolean testFlag = false;//是否是测试项目,测试项目要存两份
if(Constants.testItemSet.contains(item_type)){
testFlag = true;
}
ReportDetailModel reportDetail = new ReportDetailModel();
reportDetail.setItemId(itemId);
reportDetail.setItemValue(detail.getItemValue());
reportDetail.setStatus(detail.getStatus());
reportDetail.setTitle(metaItems.getTitle());
if (report.getSex() == Constants.MALE) {
reportDetail.setNormalRange(metaItems.getStandardLowMale() + " - " + metaItems.getStandardHighMale());
} else {
reportDetail.setNormalRange(metaItems.getStandardLowFemale() + " - " + metaItems.getStandardHighFemale());
}
reportDetail.setType(metaItems.getType());
}
XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, metaItems.getType());
if (scoreEntity != null)
reportDetail.setTypeHealthScore(scoreEntity.getTypeHealthScore());
reportDetailModelList.add(reportDetail);
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());
}
}
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);
}
}
}
}
}
ReportModel reportModel = new ReportModel(report, reportDetailModelList);
ReportModel reportModel = new ReportModel(report, reportTypeMap);
return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK);
}
... ...
... ... @@ -18,9 +18,4 @@ public class ReportDetailModel {
*/
private String title;
private String normalRange;
/**
* XklAmpReportHealthScoreEntity
*/
private int type;
private double typeHealthScore;
}
... ...
... ... @@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* Created by win7 on 2016/11/21.
... ... @@ -14,9 +15,8 @@ import java.util.List;
@Data
@AllArgsConstructor
public class ReportModel {
//
private XklAmpReportEntity Report;
private List<ReportDetailModel> ReportDetailList;
private XklAmpReportEntity report;
private Map<Integer,ReportTypeModel> reportTypeMap;
}
... ...
package com.xkl.model;
import lombok.Data;
import java.util.List;
/**
* Created by win7 on 2017/3/19.
*/
@Data
public class ReportTypeModel {
/**
* XklAmpReportHealthScoreEntity
*/
private int type;
private double typeHealthScore;
private List<ReportDetailModel> reportDetailModelList;
}
... ...