Authored by fangyeqing

ADD:add reportdetail interface and itemInfo interface

package com.xkl.config;
import com.xkl.domain.XklAmpReportMetaItemsEntity;
import com.xkl.domain.XklAmpReportMetaScoreStandardEntity;
import java.util.HashMap;
... ... @@ -56,6 +57,8 @@ public interface Constants {
}
};
Map<Integer,XklAmpReportMetaItemsEntity> itemMetaMap = new HashMap<Integer, XklAmpReportMetaItemsEntity>();
public static final int MALE = 0;
public static final int FEMALE = 1;
... ...
package com.xkl.config;
import com.xkl.domain.XklAmpReportMetaItemsEntity;
import com.xkl.domain.XklAmpReportMetaScoreStandardEntity;
import com.xkl.repository.XklAmpReportMetaItemsRespository;
import com.xkl.repository.XklAmpReportMetaScoreStandardRespository;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -16,9 +18,11 @@ import java.util.Iterator;
*/
@Component
@CommonsLog
public class ScheduledTask {
public class ScheduledTask implements Constants{
@Autowired
private XklAmpReportMetaScoreStandardRespository scoreStandardRespository;
@Autowired
private XklAmpReportMetaItemsRespository metaItemsRespository;
@Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000)
public void getTableMap(){
... ... @@ -26,7 +30,17 @@ public class ScheduledTask {
Iterator<XklAmpReportMetaScoreStandardEntity> it=scoreStandardRespository.findAll().iterator();
while(it.hasNext()){
XklAmpReportMetaScoreStandardEntity scoreStandard=it.next();
Constants.scoreMap.put(scoreStandard.getItemId(),scoreStandard);
scoreMap.put(scoreStandard.getItemId(),scoreStandard);
}
}
@Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000)
public void getItemMetaMap(){
log.info("Load ItemMeta Table");
Iterator<XklAmpReportMetaItemsEntity> it = metaItemsRespository.findAll().iterator();
while(it.hasNext()){
XklAmpReportMetaItemsEntity reportMetaItems = it.next();
itemMetaMap.put(reportMetaItems.getItemId(),reportMetaItems);
}
}
}
... ...
... ... @@ -7,6 +7,8 @@ import com.xkl.authorization.annotation.Authorization;
import com.xkl.authorization.annotation.CurrentUser;
import com.xkl.config.Constants;
import com.xkl.domain.*;
import com.xkl.model.ReportDetailModel;
import com.xkl.model.ReportModel;
import com.xkl.model.ResultModel;
import com.xkl.repository.XklAmpReportDetailRespository;
import com.xkl.repository.XklAmpReportHealthScoreRespository;
... ... @@ -34,14 +36,14 @@ public class ReportController {
private XklAmpReportRespository xklAmpReportRespository;
@Autowired
private XklAmpReportDetailRespository xklAmpReportDetailRespository;
@Autowired
private XklAmpReportHealthScoreRespository xklAmpReportHealthScoreRespository;
@Autowired
private IScoreService scoreService;
@RequestMapping(value="/list",method = RequestMethod.GET)
//@Authorization
@Authorization
//@Sign
@ApiOperation(value = "体检报告列表查询接口")
@ApiImplicitParams({
... ... @@ -54,19 +56,83 @@ public class ReportController {
return new ResponseEntity<>(ResultModel.ok(xklAmpReportEntity), HttpStatus.OK);
}
@RequestMapping(value="/detail",method = RequestMethod.GET)
@Authorization
//@Sign
@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,
@RequestParam String sign, @RequestParam long t, @RequestParam int type) {
XklAmpReportEntity report=xklAmpReportRespository.findOne(report_id);
List<ReportDetailModel> reportDetailModelList = new ArrayList<>();
if(report != null ){
if(report.getScore()==0){//首次调用接口,score为0
//TODO:可以在上传时直接打分?
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());
XklAmpReportMetaItemsEntity metaItems=Constants.itemMetaMap.get(itemId);
reportDetail.setTitle(metaItems.getTitle());
reportDetail.setNormal(metaItems.getStandardLowMale()+" - "+metaItems.getStandardHighMale());
reportDetail.setNormalNv(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);
}
}
ReportModel reportModel = new ReportModel(report,reportDetailModelList);
return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK);
}
@RequestMapping(value="/score",method = RequestMethod.GET)
@Authorization
//@Sign
@ApiOperation(value = "健康评分接口")
@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,
@RequestParam String sign, @RequestParam long t, @RequestParam int type) {
//单独测试需要删除xkl_amp_report_health_scroe表中数据
scoreService.getScore(report_id);
return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK);
}
@RequestMapping(value="/itemInfo",method = RequestMethod.GET)
@Authorization
//@Sign
@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 String sign, @RequestParam long t, @RequestParam int type) {
XklAmpReportMetaItemsEntity metaItems = Constants.itemMetaMap.get(itemId);
String result="";
//0, normal,1, lower,2, higher
if(status == 0){
result = metaItems.getExplainNormal();
}else if(status == 1){
result = metaItems.getExplainLow();
}else if(status == 2){
result = metaItems.getExplainHigh();
}else{
result = "没有此status相关信息";
}
return new ResponseEntity<>(ResultModel.ok(result), HttpStatus.OK);
}
}
... ...
... ... @@ -22,7 +22,7 @@ public class ReportMetaItem {
// type
@Column(name = "type")
private String type;
private int type;
// title
@Column(name = "title")
... ... @@ -72,11 +72,11 @@ public class ReportMetaItem {
this.item_id = item_id;
}
public String getType() {
public int getType() {
return type;
}
public void setType(String type) {
public void setType(int type) {
this.type = type;
}
... ...
... ... @@ -12,170 +12,37 @@ import javax.persistence.*;
@Entity
@Table(name = "xkl_amp_report_meta_items", schema = "hanhe_test", catalog = "")
public class XklAmpReportMetaItemsEntity {
private int id;
private int itmeId;
private String type;
private String title;
private double standardLowMale;
private double standardHighMale;
private double standardLowFemale;
private double standardHighFemale;
private String explainLow;
private String explainHigh;
private String explainNormal;
@Id
@Column(name = "id")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
private int id;
@Basic
@Column(name = "itme_id")
public int getItmeId() {
return itmeId;
}
public void setItmeId(int itmeId) {
this.itmeId = itmeId;
}
@Column(name = "item_id")
private int itemId;
@Basic
@Column(name = "type")
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
private int type;
@Basic
@Column(name = "title")
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
private String title;
@Basic
@Column(name = "standard_low_male")
public double getStandardLowMale() {
return standardLowMale;
}
public void setStandardLowMale(double standardLowMale) {
this.standardLowMale = standardLowMale;
}
private double standardLowMale;
@Basic
@Column(name = "standard_high_male")
public double getStandardHighMale() {
return standardHighMale;
}
public void setStandardHighMale(double standardHighMale) {
this.standardHighMale = standardHighMale;
}
private double standardHighMale;
@Basic
@Column(name = "standard_low_female")
public double getStandardLowFemale() {
return standardLowFemale;
}
public void setStandardLowFemale(double standardLowFemale) {
this.standardLowFemale = standardLowFemale;
}
private double standardLowFemale;
@Basic
@Column(name = "standard_high_female")
public double getStandardHighFemale() {
return standardHighFemale;
}
public void setStandardHighFemale(double standardHighFemale) {
this.standardHighFemale = standardHighFemale;
}
private double standardHighFemale;
@Basic
@Column(name = "explain_low")
public String getExplainLow() {
return explainLow;
}
public void setExplainLow(String explainLow) {
this.explainLow = explainLow;
}
private String explainLow;
@Basic
@Column(name = "explain_high")
public String getExplainHigh() {
return explainHigh;
}
public void setExplainHigh(String explainHigh) {
this.explainHigh = explainHigh;
}
private String explainHigh;
@Basic
@Column(name = "explain_normal")
public String getExplainNormal() {
return explainNormal;
}
public void setExplainNormal(String explainNormal) {
this.explainNormal = explainNormal;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
XklAmpReportMetaItemsEntity that = (XklAmpReportMetaItemsEntity) o;
if (id != that.id) return false;
if (itmeId != that.itmeId) return false;
if (Double.compare(that.standardLowMale, standardLowMale) != 0) return false;
if (Double.compare(that.standardHighMale, standardHighMale) != 0) return false;
if (Double.compare(that.standardLowFemale, standardLowFemale) != 0) return false;
if (Double.compare(that.standardHighFemale, standardHighFemale) != 0) return false;
if (type != null ? !type.equals(that.type) : that.type != null) return false;
if (title != null ? !title.equals(that.title) : that.title != null) return false;
if (explainLow != null ? !explainLow.equals(that.explainLow) : that.explainLow != null) return false;
if (explainHigh != null ? !explainHigh.equals(that.explainHigh) : that.explainHigh != null) return false;
if (explainNormal != null ? !explainNormal.equals(that.explainNormal) : that.explainNormal != null)
return false;
return true;
}
@Override
public int hashCode() {
int result;
long temp;
result = id;
result = 31 * result + itmeId;
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (title != null ? title.hashCode() : 0);
temp = Double.doubleToLongBits(standardLowMale);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(standardHighMale);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(standardLowFemale);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(standardHighFemale);
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + (explainLow != null ? explainLow.hashCode() : 0);
result = 31 * result + (explainHigh != null ? explainHigh.hashCode() : 0);
result = 31 * result + (explainNormal != null ? explainNormal.hashCode() : 0);
return result;
}
private String explainNormal;
}
... ...
package com.xkl.model;
import lombok.Data;
/**
* Created by win7 on 2016/12/12.
*/
@Data
public class ReportDetailModel {
/**
* XklAmpReportDetailEntity
*/
private int itemId;//对应itemId
private double itemValue;
private int status;
/**
* XklAmpReportMetaItemsEntity
*/
private String title;
private String normalNv;
private String normal;
/**
* XklAmpReportHealthScoreEntity
*/
private int type;
private double typeHealthScore;
}
... ...
package com.xkl.model;
import com.xkl.domain.XklAmpReportDetailEntity;
import com.xkl.domain.XklAmpReportEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* Created by win7 on 2016/11/21.
*/
@Data
@AllArgsConstructor
public class ReportModel {
//
private XklAmpReportEntity Report;
private List<ReportDetailModel> ReportDetailList;
}
... ...
... ... @@ -11,7 +11,7 @@ import java.util.List;
*/
public interface XklAmpReportHealthScoreRespository extends CrudRepository<XklAmpReportHealthScoreEntity, Long> {
//item_id
public List<XklAmpReportHealthScoreEntity> findByReportIdAndType(long report_id,int type);
public XklAmpReportHealthScoreEntity findByReportIdAndType(long report_id,int type);
//public boolean existsByReportId(long report_id);
... ...
package com.xkl.repository;
import com.xkl.domain.XklAmpReportDetailEntity;
import com.xkl.domain.XklAmpReportMetaItemsEntity;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
/**
* Created by win7 on 2016/11/20.
*/
public interface XklAmpReportMetaItemsRespository extends CrudRepository<XklAmpReportMetaItemsEntity, Long> {
}
... ...
... ... @@ -31,6 +31,9 @@ public class ScoreServiceImpl implements IScoreService,Constants{
public void getScore(long report_id) {
Map<Integer,Double> typeScoreMap=new HashMap<>();//记录各大项打分的Map
/**
* report_detail表中获取每项体检的值,按大类存入typeScoreMap
*/
List<XklAmpReportDetailEntity> reportDetailList=xklAmpReportDetailRespository.findAllByReportId(report_id);
for(XklAmpReportDetailEntity detail:reportDetailList){
... ...
server.port=8090
#server.ssl.key-store = ${user.home}/.keystore
#server.ssl.key-store-password = xkl2016
#server.ssl.key-password = xkl2016
#MySQL
spring.datasource.url=jdbc:mysql://db.hanhezy.com:4096/hanhe_test?useUnicode=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=round&autoReconnect=true
spring.datasource.username=hanhe
spring.datasource.password=HANhetest2016
#Redis
spring.redis.host=127.0.0.1
#spring.redis.password=foobared
#spring.redis.host=r-m5e7cedd3124afd4.redis.rds.aliyuncs.com
#spring.redis.password=r-m5e7cedd3124afd4:XIkaiLURedis2016
spring.redis.port=6379