Authored by fangyeqing

ADD:add reportItemGraph interface

@@ -80,7 +80,7 @@ public class SignAspect { @@ -80,7 +80,7 @@ public class SignAspect {
80 } 80 }
81 81
82 String key = getKeyByType(type); 82 String key = getKeyByType(type);
83 - long t1= UtilTools.get10Second(); 83 + long t1= UtilTools.getNow10Second();
84 String sign1= SecurityTool.encode("MD5",str+t1+key); 84 String sign1= SecurityTool.encode("MD5",str+t1+key);
85 /** 85 /**
86 * 比较sign和过期时间 86 * 比较sign和过期时间
@@ -8,12 +8,14 @@ import com.xkl.authorization.annotation.CurrentUser; @@ -8,12 +8,14 @@ import com.xkl.authorization.annotation.CurrentUser;
8 import com.xkl.config.Constants; 8 import com.xkl.config.Constants;
9 import com.xkl.domain.*; 9 import com.xkl.domain.*;
10 import com.xkl.model.ReportDetailModel; 10 import com.xkl.model.ReportDetailModel;
  11 +import com.xkl.model.ReportItemGraphModel;
11 import com.xkl.model.ReportModel; 12 import com.xkl.model.ReportModel;
12 import com.xkl.model.ResultModel; 13 import com.xkl.model.ResultModel;
13 import com.xkl.repository.XklAmpReportDetailRespository; 14 import com.xkl.repository.XklAmpReportDetailRespository;
14 import com.xkl.repository.XklAmpReportHealthScoreRespository; 15 import com.xkl.repository.XklAmpReportHealthScoreRespository;
15 import com.xkl.repository.XklAmpReportRespository; 16 import com.xkl.repository.XklAmpReportRespository;
16 import com.xkl.service.IScoreService; 17 import com.xkl.service.IScoreService;
  18 +import com.xkl.tools.UtilTools;
17 import org.springframework.beans.factory.annotation.Autowired; 19 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.http.HttpStatus; 20 import org.springframework.http.HttpStatus;
19 import org.springframework.http.ResponseEntity; 21 import org.springframework.http.ResponseEntity;
@@ -134,5 +136,34 @@ public class ReportController { @@ -134,5 +136,34 @@ public class ReportController {
134 return new ResponseEntity<>(ResultModel.ok(result), HttpStatus.OK); 136 return new ResponseEntity<>(ResultModel.ok(result), HttpStatus.OK);
135 } 137 }
136 138
  139 + @RequestMapping(value="/itemGraph",method = RequestMethod.GET)
  140 + @Authorization
  141 + //@Sign
  142 + @ApiOperation(value = "指标曲线查询接口")
  143 + @ApiImplicitParams({
  144 + @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
  145 + })
  146 + public ResponseEntity<ResultModel> getReportItemGraph(HttpServletRequest request, @CurrentUser User user,@RequestParam int itemId,@RequestParam String stime,@RequestParam String etime,
  147 + @RequestParam String sign, @RequestParam long t, @RequestParam int type) {
  148 + long member_id=user.getMemberId();
  149 + List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberId(member_id);
  150 + List<ReportItemGraphModel> reportItemGraphModelList =new ArrayList<>();
  151 +
  152 + if(xklAmpReportEntity!=null && xklAmpReportEntity.size()>0){
  153 + for(XklAmpReportEntity report:xklAmpReportEntity){
  154 + long reportTime= UtilTools.getLongTime(report.getUptime());
  155 + long stimeLong= UtilTools.getLongTime(stime);
  156 + long etimeLong= UtilTools.getLongTime(etime);
  157 + long reportId= report.getId();
  158 + if(reportTime>=stimeLong&&reportTime<=etimeLong){//在时间范围内
  159 + XklAmpReportDetailEntity reportDetail = xklAmpReportDetailRespository.findByReportIdAndItemId(reportId,itemId);
  160 + ReportItemGraphModel reportItemGraphModel= new ReportItemGraphModel(reportTime,reportDetail.getItemValue());
  161 + reportItemGraphModelList.add(reportItemGraphModel);
  162 + }
  163 + }
  164 + }
  165 + return new ResponseEntity<>(ResultModel.ok(reportItemGraphModelList), HttpStatus.OK);
  166 + }
  167 +
137 168
138 } 169 }
  1 +package com.xkl.model;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Data;
  5 +
  6 +/**
  7 + * Created by win7 on 2016/12/13.
  8 + * 体检报告指标曲线返回结果
  9 + */
  10 +@Data
  11 +@AllArgsConstructor
  12 +public class ReportItemGraphModel {
  13 + public long time;
  14 + public double value;
  15 +}
@@ -9,6 +9,7 @@ import java.util.List; @@ -9,6 +9,7 @@ import java.util.List;
9 9
10 /** 10 /**
11 * Created by win7 on 2016/11/21. 11 * Created by win7 on 2016/11/21.
  12 + * 体检报告详情返回结果
12 */ 13 */
13 @Data 14 @Data
14 @AllArgsConstructor 15 @AllArgsConstructor
@@ -11,7 +11,7 @@ import java.util.List; @@ -11,7 +11,7 @@ import java.util.List;
11 */ 11 */
12 public interface XklAmpReportDetailRespository extends CrudRepository<XklAmpReportDetailEntity, Long> { 12 public interface XklAmpReportDetailRespository extends CrudRepository<XklAmpReportDetailEntity, Long> {
13 //item_id 13 //item_id
14 - public List<XklAmpReportDetailEntity> findByReportIdAndItemId(long report_id, long item_id); 14 + public XklAmpReportDetailEntity findByReportIdAndItemId(long report_id, int item_id);
15 15
16 public List<XklAmpReportDetailEntity> findAllByReportId(long report_id); 16 public List<XklAmpReportDetailEntity> findAllByReportId(long report_id);
17 } 17 }
@@ -3,6 +3,7 @@ package com.xkl.tools; @@ -3,6 +3,7 @@ package com.xkl.tools;
3 import org.joda.time.DateTime; 3 import org.joda.time.DateTime;
4 4
5 import java.sql.Timestamp; 5 import java.sql.Timestamp;
  6 +import java.text.ParseException;
6 import java.text.SimpleDateFormat; 7 import java.text.SimpleDateFormat;
7 import java.util.Calendar; 8 import java.util.Calendar;
8 import java.util.Date; 9 import java.util.Date;
@@ -52,7 +53,27 @@ public class UtilTools { @@ -52,7 +53,27 @@ public class UtilTools {
52 return a; 53 return a;
53 } 54 }
54 55
55 - public static long get10Second(){ 56 + /**
  57 + * 由String转为long型时间,10位
  58 + * @param timestamp
  59 + * @return
  60 + */
  61 + public static long getLongTime(String timestamp){
  62 + long time = 0;
  63 + try {
  64 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
  65 + time = format.parse(timestamp).getTime()/1000;
  66 + } catch (ParseException e) {
  67 + e.printStackTrace();
  68 + }
  69 + return time;
  70 + }
  71 +
  72 + /**
  73 + * 获取当前时间long型,10位
  74 + * @return
  75 + */
  76 + public static long getNow10Second(){
56 Calendar c = Calendar.getInstance();//可以对每个时间域单独修改 77 Calendar c = Calendar.getInstance();//可以对每个时间域单独修改
57 long a=c.getTimeInMillis()/1000; 78 long a=c.getTimeInMillis()/1000;
58 return a; 79 return a;
@@ -107,5 +128,9 @@ public class UtilTools { @@ -107,5 +128,9 @@ public class UtilTools {
107 return object.toString(); 128 return object.toString();
108 } 129 }
109 130
  131 + public static void main(String[] args) {
  132 + System.out.println(getLongTime("2016-10-11 22:22:22"));
  133 + }
  134 +
110 135
111 } 136 }