Authored by zhaoyue

Fix little bug

... ... @@ -2,5 +2,5 @@ git add --all src/*
git add push.sh
git add pom.xml
git commit -m "Fix little bug"
git push origin zhaoyue-dev
git push origin master
git status
... ...
... ... @@ -53,5 +53,7 @@ public interface Constants {
public static final int STATUS_OK = 1;
public static final boolean STATUS_OK2 = true;
public static final double SMALL_DOUBLE = 0.001;
}
... ...
... ... @@ -49,18 +49,18 @@ public class ReportController {
@AntiXSS
@Authorization
@Sign
@RequestMapping(value="/list",method = RequestMethod.GET)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(value = "体检报告列表查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
})
public ResponseEntity<ResultModel> getReportList(HttpServletRequest request, @CurrentUser User user,
@RequestParam String sign, @RequestParam long t, @RequestParam int type) {
if(!(boolean)request.getAttribute("signAspect"))
if (!(boolean) request.getAttribute("signAspect"))
return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
long member_id=user.getMemberId();
List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberIdAndStatus(member_id,1);
long member_id = user.getMemberId();
List<XklAmpReportEntity> xklAmpReportEntity = xklAmpReportRespository.findByMemberIdAndStatus(member_id, 1);
return new ResponseEntity<>(ResultModel.ok(xklAmpReportEntity), HttpStatus.OK);
}
... ... @@ -68,69 +68,68 @@ public class ReportController {
@AntiXSS
@Authorization
@Sign
@RequestMapping(value="/detail",method = RequestMethod.GET)
@RequestMapping(value = "/detail", method = RequestMethod.GET)
@ApiOperation(value = "体检报告详情查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
})
public ResponseEntity<ResultModel> getReportDetail(HttpServletRequest request, @CurrentUser User user,@RequestParam long report_id,
public ResponseEntity<ResultModel> getReportDetail(HttpServletRequest request, @CurrentUser User user, @RequestParam long report_id,
@RequestParam String sign, @RequestParam long t, @RequestParam int type) {
if(!(boolean)request.getAttribute("signAspect"))
if (!(boolean) request.getAttribute("signAspect"))
return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
XklAmpReportEntity report=xklAmpReportRespository.findOne(report_id);
XklAmpReportEntity report = xklAmpReportRespository.findOne(report_id);
List<ReportDetailModel> reportDetailModelList = new ArrayList<>();
if(report != null ){
if(report.getScore()==0){//首次调用接口,score为0
//TODO:可以在上传时直接打分?
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();
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());
XklAmpReportMetaItemsEntity metaItems=Constants.itemMetaMap.get(itemId);
if(metaItems!=null){
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());
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)
XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, metaItems.getType());
if (scoreEntity != null)
reportDetail.setTypeHealthScore(scoreEntity.getTypeHealthScore());
reportDetailModelList.add(reportDetail);
}
}
ReportModel reportModel = new ReportModel(report,reportDetailModelList);
ReportModel reportModel = new ReportModel(report, reportDetailModelList);
return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK);
}
@LogAnnotation
@AntiXSS
@Sign
@RequestMapping(value="/score",method = RequestMethod.GET)
@RequestMapping(value = "/score", method = RequestMethod.GET)
@ApiOperation(value = "健康评分接口")
public ResponseEntity<ResultModel> getReportScore(HttpServletRequest request,@RequestParam long report_id,
public ResponseEntity<ResultModel> getReportScore(HttpServletRequest request, @RequestParam long report_id,
@RequestParam String sign, @RequestParam long t, @RequestParam int type) {
if(!(boolean)request.getAttribute("signAspect"))
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 || report.getScore() == null) {//首次调用接口,score为0
XklAmpReportEntity report = xklAmpReportRespository.findOne(report_id);
if (report != null) {
if (report.getScore() - 0 < Constants.SMALL_DOUBLE || report.getScore() == null) {//首次调用接口,score为0
//TODO:可以在上传时直接打分?
//单独测试需要删除xkl_amp_report_health_scroe表中数据
score = scoreService.getScore(report_id);
}else{
} else {
score = report.getScore();
}
}
... ... @@ -141,33 +140,33 @@ public class ReportController {
@AntiXSS
@Authorization
@Sign
@RequestMapping(value="/itemInfo",method = RequestMethod.GET)
@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,@RequestParam boolean isPureHtml,
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"))
if (!(boolean) request.getAttribute("signAspect"))
return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
XklAmpReportMetaItemsEntity metaItems = Constants.itemMetaMap.get(itemId);
String result="";
if(metaItems!= null){
String result = "";
if (metaItems != null) {
//0, normal,1, lower,2, higher
if(status == Constants.NORMAL){
if (status == Constants.NORMAL) {
result = metaItems.getExplainNormal();
}else if(status == Constants.LOWER){
} else if (status == Constants.LOWER) {
result = metaItems.getExplainLow();
}else if(status == Constants.HIGHER){
} else if (status == Constants.HIGHER) {
result = metaItems.getExplainHigh();
}else{
} else {
result = "没有此status相关信息";
}
}else{
} else {
result = "没有此itemId相关信息";
}
if(isPureHtml){
if (isPureHtml) {
result = HtmlTools.stripHtml(result);
}
return new ResponseEntity<>(ResultModel.ok(result), HttpStatus.OK);
... ... @@ -177,30 +176,30 @@ public class ReportController {
@AntiXSS
@Authorization
@Sign
@RequestMapping(value="/itemGraph",method = RequestMethod.GET)
@RequestMapping(value = "/itemGraph", method = RequestMethod.GET)
@ApiOperation(value = "指标曲线查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
})
public ResponseEntity<ResultModel> getReportItemGraph(HttpServletRequest request, @CurrentUser User user,@RequestParam int itemId,@RequestParam String stime,@RequestParam String etime,
public ResponseEntity<ResultModel> getReportItemGraph(HttpServletRequest request, @CurrentUser User user, @RequestParam int itemId, @RequestParam String stime, @RequestParam String etime,
@RequestParam String sign, @RequestParam long t, @RequestParam int type) {
if(!(boolean)request.getAttribute("signAspect"))
if (!(boolean) request.getAttribute("signAspect"))
return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
long member_id=user.getMemberId();
List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberIdAndStatus(member_id,1);
List<ReportItemGraphModel> reportItemGraphModelList =new ArrayList<>();
if(xklAmpReportEntity!=null && xklAmpReportEntity.size()>0){
for(XklAmpReportEntity report:xklAmpReportEntity){
long reportTime= report.getUptime().getTime();
long stimeLong= UtilTools.getLongTime(stime);
long etimeLong= UtilTools.getLongTime(etime);
long reportId= report.getId();
if(reportTime>=stimeLong&&reportTime<=etimeLong){//在时间范围内
XklAmpReportDetailEntity reportDetail = xklAmpReportDetailRespository.findByReportIdAndItemId(reportId,itemId);
if(reportDetail!=null){
ReportItemGraphModel reportItemGraphModel= new ReportItemGraphModel(reportTime,reportDetail.getItemValue());
long member_id = user.getMemberId();
List<XklAmpReportEntity> xklAmpReportEntity = xklAmpReportRespository.findByMemberIdAndStatus(member_id, 1);
List<ReportItemGraphModel> reportItemGraphModelList = new ArrayList<>();
if (xklAmpReportEntity != null && xklAmpReportEntity.size() > 0) {
for (XklAmpReportEntity report : xklAmpReportEntity) {
long reportTime = report.getUptime().getTime();
long stimeLong = UtilTools.getLongTime(stime);
long etimeLong = UtilTools.getLongTime(etime);
long reportId = report.getId();
if (reportTime >= stimeLong && reportTime <= etimeLong) {//在时间范围内
XklAmpReportDetailEntity reportDetail = xklAmpReportDetailRespository.findByReportIdAndItemId(reportId, itemId);
if (reportDetail != null) {
ReportItemGraphModel reportItemGraphModel = new ReportItemGraphModel(reportTime, reportDetail.getItemValue());
reportItemGraphModelList.add(reportItemGraphModel);
}
}
... ... @@ -213,18 +212,18 @@ public class ReportController {
@AntiXSS
@Authorization
@Sign
@RequestMapping(value="/compare",method = RequestMethod.POST)
@RequestMapping(value = "/compare", method = RequestMethod.POST)
@ApiOperation(value = "微信端体检报告分年龄比较接口")
public ResponseEntity<ResultModel> openIdCompare(HttpServletRequest request, @CurrentUser User user,@RequestParam Long report_id,
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"))
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);
XklAmpReportEntity report = xklAmpReportRespository.findOne(report_id);
double score = 0;
if(report != null ) {
if (report.getScore() == 0) {//首次调用接口,score为0
if (report != null) {
if (report.getScore() - 0 < Constants.SMALL_DOUBLE || report.getScore() == null) {//首次调用接口,score为0
score = scoreService.getScore(report_id);
} else {
score = report.getScore();
... ... @@ -235,14 +234,14 @@ public class ReportController {
//List<XklAmpReportHealthScoreEntity> scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id);
int typeId = entry.getKey();
XklAmpReportCategoryEntity value = entry.getValue();
String key = ageId +"-"+ typeId;
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){//第一项为测试项目
} else {
if (typeId == 1) {//第一项为测试项目
typeScore = score;
}
}
... ...
... ... @@ -120,7 +120,7 @@ public class XklAmpReportEntity {
Timestamp uptime, String account_str, Byte sex, Byte age,
int weight, int pulse, int breath_rate, Double atmos_pressure,
Double LCA, Double RCA, Double LAC, Double RAC, Double ABD, Double temp_sum,
int stable, String md5, String machine_num, String conclusion) {
int stable, String md5, String machine_num, String conclusion, String t0, String t1, String t2, String t3, String t4) {
this.name = name;
this.title = title;
this.checkTime = check_time;
... ... @@ -143,6 +143,11 @@ public class XklAmpReportEntity {
this.machineNum = machine_num;
this.conclusion = conclusion;
this.status = 1; //默认为有效。
this.t0 = t0;
this.t1 = t1;
this.t2 = t2;
this.t3 = t3;
this.t4 = t4;
}
public void setId(long id) {
... ...
... ... @@ -38,6 +38,9 @@ public class ReportService implements IReportService {
@Autowired
private UserRepository userRepository;
@Autowired
private IScoreService scoreService;
// 存储报告相关md5,防止重复上传已存在报告,防止重复上传错误报告。
private RedisTemplate<String, String> redis;
... ... @@ -157,7 +160,7 @@ public class ReportService implements IReportService {
sex = rpJson.getInteger("sex").intValue();
ampReport.setReport(rpJson.getString("name"),
rpJson.getString("title"),/// "AMP快速无创身心健康评估报告",
Timestamp.valueOf(rpJson.getString("report_date")),
new Timestamp(rpJson.getLong("report_date")),
new Timestamp(System.currentTimeMillis()),
rpJson.getString("account"),///
rpJson.getInteger("sex").byteValue(),///
... ... @@ -173,7 +176,14 @@ public class ReportService implements IReportService {
rpJson.getDouble("ABD").doubleValue(),
rpJson.getDouble("total").doubleValue(),
rpJson.getInteger("stable").intValue(),
md5, rpJson.getString("machine_num"), rpJson.getString("basic_result"));
md5, rpJson.getString("machine_num"),
rpJson.getString("basic_result"),
rpJson.getString("T0"),
rpJson.getString("T1"),
rpJson.getString("T2"),
rpJson.getString("T3"),
rpJson.getString("T4")
);
/*
* 3. 获取detail信息,id,float类型
*/
... ... @@ -222,6 +232,7 @@ public class ReportService implements IReportService {
}
reportDetailRepository.save(report.getRpDetailList());
reportResultRepository.save(report.getBasicResList());
scoreService.getScore(ampReport.getId());
return ampReport.getId();
}
... ...