...
|
...
|
@@ -9,14 +9,13 @@ import com.xkl.authorization.annotation.Sign; |
|
|
import com.xkl.config.Constants;
|
|
|
import com.xkl.config.ResultStatus;
|
|
|
import com.xkl.domain.*;
|
|
|
import com.xkl.model.ReportDetailModel;
|
|
|
import com.xkl.model.ReportItemGraphModel;
|
|
|
import com.xkl.model.ReportModel;
|
|
|
import com.xkl.model.ResultModel;
|
|
|
import com.xkl.model.*;
|
|
|
import com.xkl.repository.XklAmpReportDetailRespository;
|
|
|
import com.xkl.repository.XklAmpReportHealthScoreRespository;
|
|
|
import com.xkl.repository.XklAmpReportRespository;
|
|
|
import com.xkl.security.AntiXSS;
|
|
|
import com.xkl.service.IScoreService;
|
|
|
import com.xkl.tools.HtmlTools;
|
|
|
import com.xkl.tools.UtilTools;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
...
|
...
|
@@ -28,7 +27,6 @@ import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.*;
|
|
|
import java.util.function.DoubleToIntFunction;
|
|
|
|
|
|
/**
|
|
|
* Created by win7 on 2016/11/20.
|
...
|
...
|
@@ -46,9 +44,10 @@ public class ReportController { |
|
|
@Autowired
|
|
|
private IScoreService scoreService;
|
|
|
|
|
|
@RequestMapping(value="/list",method = RequestMethod.GET)
|
|
|
@AntiXSS
|
|
|
@Authorization
|
|
|
@Sign
|
|
|
@RequestMapping(value="/list",method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "体检报告列表查询接口")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
|
...
|
...
|
@@ -59,13 +58,14 @@ public class ReportController { |
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
|
|
|
|
|
|
long member_id=user.getMemberId();
|
|
|
List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberId(member_id);
|
|
|
List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberIdAndStatus(member_id,1);
|
|
|
return new ResponseEntity<>(ResultModel.ok(xklAmpReportEntity), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value="/detail",method = RequestMethod.GET)
|
|
|
@AntiXSS
|
|
|
@Authorization
|
|
|
@Sign
|
|
|
@RequestMapping(value="/detail",method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "体检报告详情查询接口")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
|
...
|
...
|
@@ -93,8 +93,11 @@ public class ReportController { |
|
|
XklAmpReportMetaItemsEntity metaItems=Constants.itemMetaMap.get(itemId);
|
|
|
if(metaItems!=null){
|
|
|
reportDetail.setTitle(metaItems.getTitle());
|
|
|
reportDetail.setNormal(metaItems.getStandardLowMale()+" - "+metaItems.getStandardHighMale());
|
|
|
reportDetail.setNormalNv(metaItems.getStandardLowFemale()+ " - "+metaItems.getStandardHighFemale());
|
|
|
if(report.getSex()==Constants.MALE){
|
|
|
reportDetail.setNormalRange(metaItems.getStandardLowMale()+" - "+metaItems.getStandardHighMale());
|
|
|
}else{
|
|
|
reportDetail.setNormalRange(metaItems.getStandardLowFemale()+ " - "+metaItems.getStandardHighFemale());
|
|
|
}
|
|
|
reportDetail.setType(metaItems.getType());
|
|
|
}
|
|
|
|
...
|
...
|
@@ -108,31 +111,37 @@ public class ReportController { |
|
|
return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
/*@RequestMapping(value="/score",method = RequestMethod.GET)
|
|
|
@Authorization
|
|
|
@AntiXSS
|
|
|
@Sign
|
|
|
@ApiOperation(value = "健康评分接口(测试service用,后续可以注释掉)")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
|
|
|
})
|
|
|
public ResponseEntity<ResultModel> getReportScore(HttpServletRequest request, @CurrentUser User user,@RequestParam long report_id,
|
|
|
@RequestMapping(value="/score",method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "健康评分接口")
|
|
|
public ResponseEntity<ResultModel> getReportScore(HttpServletRequest request,@RequestParam long report_id,
|
|
|
@RequestParam String sign, @RequestParam long t, @RequestParam int type) {
|
|
|
if(!(boolean)request.getAttribute("signAspect"))
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
|
|
|
double score = 0;
|
|
|
XklAmpReportEntity report=xklAmpReportRespository.findOne(report_id);
|
|
|
if(report != null ){
|
|
|
if(report.getScore()==0){//首次调用接口,score为0
|
|
|
//TODO:可以在上传时直接打分?
|
|
|
//单独测试需要删除xkl_amp_report_health_scroe表中数据
|
|
|
score = scoreService.getScore(report_id);
|
|
|
}else{
|
|
|
score = report.getScore();
|
|
|
}
|
|
|
}
|
|
|
return new ResponseEntity<>(ResultModel.ok(score), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
//单独测试需要删除xkl_amp_report_health_scroe表中数据
|
|
|
scoreService.getScore(report_id);
|
|
|
return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK);
|
|
|
}*/
|
|
|
|
|
|
@RequestMapping(value="/itemInfo",method = RequestMethod.GET)
|
|
|
@AntiXSS
|
|
|
@Authorization
|
|
|
@Sign
|
|
|
@RequestMapping(value="/itemInfo",method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "指标解释查询接口")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
|
|
|
})
|
|
|
public ResponseEntity<ResultModel> getReportItemInfo(HttpServletRequest request, @CurrentUser User user,@RequestParam int itemId,@RequestParam int status,
|
|
|
public ResponseEntity<ResultModel> getReportItemInfo(HttpServletRequest request, @CurrentUser User user,@RequestParam int itemId,@RequestParam int status,@RequestParam boolean isPureHtml,
|
|
|
@RequestParam String sign, @RequestParam long t, @RequestParam int type) {
|
|
|
if(!(boolean)request.getAttribute("signAspect"))
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
|
...
|
...
|
@@ -141,11 +150,11 @@ public class ReportController { |
|
|
String result="";
|
|
|
if(metaItems!= null){
|
|
|
//0, normal,1, lower,2, higher
|
|
|
if(status == 0){
|
|
|
if(status == Constants.NORMAL){
|
|
|
result = metaItems.getExplainNormal();
|
|
|
}else if(status == 1){
|
|
|
}else if(status == Constants.LOWER){
|
|
|
result = metaItems.getExplainLow();
|
|
|
}else if(status == 2){
|
|
|
}else if(status == Constants.HIGHER){
|
|
|
result = metaItems.getExplainHigh();
|
|
|
}else{
|
|
|
result = "没有此status相关信息";
|
...
|
...
|
@@ -153,13 +162,16 @@ public class ReportController { |
|
|
}else{
|
|
|
result = "没有此itemId相关信息";
|
|
|
}
|
|
|
|
|
|
if(isPureHtml){
|
|
|
result = HtmlTools.stripHtml(result);
|
|
|
}
|
|
|
return new ResponseEntity<>(ResultModel.ok(result), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value="/itemGraph",method = RequestMethod.GET)
|
|
|
@AntiXSS
|
|
|
@Authorization
|
|
|
@Sign
|
|
|
@RequestMapping(value="/itemGraph",method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "指标曲线查询接口")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
|
...
|
...
|
@@ -170,7 +182,7 @@ public class ReportController { |
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
|
|
|
|
|
|
long member_id=user.getMemberId();
|
|
|
List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberId(member_id);
|
|
|
List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberIdAndStatus(member_id,1);
|
|
|
List<ReportItemGraphModel> reportItemGraphModelList =new ArrayList<>();
|
|
|
|
|
|
if(xklAmpReportEntity!=null && xklAmpReportEntity.size()>0){
|
...
|
...
|
@@ -192,4 +204,47 @@ public class ReportController { |
|
|
}
|
|
|
|
|
|
|
|
|
@AntiXSS
|
|
|
@Authorization
|
|
|
@Sign
|
|
|
@RequestMapping(value="/compare",method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "微信端体检报告分年龄比较接口")
|
|
|
public ResponseEntity<ResultModel> openIdCompare(HttpServletRequest request, @CurrentUser User user,@RequestParam Long report_id,
|
|
|
@RequestParam String sign, @RequestParam long t, @RequestParam int type) {
|
|
|
if(!(boolean)request.getAttribute("signAspect"))
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
|
|
|
List<CompareModel> result = new ArrayList<>();
|
|
|
|
|
|
XklAmpReportEntity report=xklAmpReportRespository.findOne(report_id);
|
|
|
double score = 0;
|
|
|
if(report != null ) {
|
|
|
if (report.getScore() == 0) {//首次调用接口,score为0
|
|
|
score = scoreService.getScore(report_id);
|
|
|
} else {
|
|
|
score = report.getScore();
|
|
|
}
|
|
|
int age = report.getAge();
|
|
|
String ageId = String.valueOf((age - age % 5) / 5);
|
|
|
for (Map.Entry<Integer, XklAmpReportCategoryEntity> entry : Constants.weightedScoreMap.entrySet()) {
|
|
|
//List<XklAmpReportHealthScoreEntity> scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id);
|
|
|
int typeId = entry.getKey();
|
|
|
XklAmpReportCategoryEntity value = entry.getValue();
|
|
|
String key = ageId +"-"+ typeId;
|
|
|
double aveScore = Constants.aveScoreMap.get(key);
|
|
|
double typeScore = 0;
|
|
|
XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, typeId);
|
|
|
if (scoreEntity != null) {
|
|
|
typeScore = scoreEntity.getTypeHealthScore();
|
|
|
}else{
|
|
|
if(typeId==1){//第一项为测试项目
|
|
|
typeScore = score;
|
|
|
}
|
|
|
}
|
|
|
CompareModel cm = new CompareModel(typeId, value.getName(), typeScore, aveScore);
|
|
|
result.add(cm);
|
|
|
}
|
|
|
}
|
|
|
return new ResponseEntity<>(ResultModel.ok(result), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|