...
|
...
|
@@ -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();
|
|
|
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());
|
|
|
|
|
|
XklAmpReportMetaItemsEntity metaItems = Constants.itemMetaMap.get(itemId);
|
|
|
if (metaItems != null) {
|
|
|
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());
|
|
|
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);
|
|
|
}
|
|
|
|
...
|
...
|
|