Authored by fangyeqing

ADD:add reportItemGraph interface

... ... @@ -80,7 +80,7 @@ public class SignAspect {
}
String key = getKeyByType(type);
long t1= UtilTools.get10Second();
long t1= UtilTools.getNow10Second();
String sign1= SecurityTool.encode("MD5",str+t1+key);
/**
* 比较sign和过期时间
... ...
... ... @@ -8,12 +8,14 @@ import com.xkl.authorization.annotation.CurrentUser;
import com.xkl.config.Constants;
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.repository.XklAmpReportDetailRespository;
import com.xkl.repository.XklAmpReportHealthScoreRespository;
import com.xkl.repository.XklAmpReportRespository;
import com.xkl.service.IScoreService;
import com.xkl.tools.UtilTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
... ... @@ -134,5 +136,34 @@ public class ReportController {
return new ResponseEntity<>(ResultModel.ok(result), HttpStatus.OK);
}
@RequestMapping(value="/itemGraph",method = RequestMethod.GET)
@Authorization
//@Sign
@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,
@RequestParam String sign, @RequestParam long t, @RequestParam int type) {
long member_id=user.getMemberId();
List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberId(member_id);
List<ReportItemGraphModel> reportItemGraphModelList =new ArrayList<>();
if(xklAmpReportEntity!=null && xklAmpReportEntity.size()>0){
for(XklAmpReportEntity report:xklAmpReportEntity){
long reportTime= UtilTools.getLongTime(report.getUptime());
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);
ReportItemGraphModel reportItemGraphModel= new ReportItemGraphModel(reportTime,reportDetail.getItemValue());
reportItemGraphModelList.add(reportItemGraphModel);
}
}
}
return new ResponseEntity<>(ResultModel.ok(reportItemGraphModelList), HttpStatus.OK);
}
}
... ...
package com.xkl.model;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* Created by win7 on 2016/12/13.
* 体检报告指标曲线返回结果
*/
@Data
@AllArgsConstructor
public class ReportItemGraphModel {
public long time;
public double value;
}
... ...
... ... @@ -9,6 +9,7 @@ import java.util.List;
/**
* Created by win7 on 2016/11/21.
* 体检报告详情返回结果
*/
@Data
@AllArgsConstructor
... ...
... ... @@ -11,7 +11,7 @@ import java.util.List;
*/
public interface XklAmpReportDetailRespository extends CrudRepository<XklAmpReportDetailEntity, Long> {
//item_id
public List<XklAmpReportDetailEntity> findByReportIdAndItemId(long report_id, long item_id);
public XklAmpReportDetailEntity findByReportIdAndItemId(long report_id, int item_id);
public List<XklAmpReportDetailEntity> findAllByReportId(long report_id);
}
... ...
... ... @@ -3,6 +3,7 @@ package com.xkl.tools;
import org.joda.time.DateTime;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
... ... @@ -52,7 +53,27 @@ public class UtilTools {
return a;
}
public static long get10Second(){
/**
* 由String转为long型时间,10位
* @param timestamp
* @return
*/
public static long getLongTime(String timestamp){
long time = 0;
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
time = format.parse(timestamp).getTime()/1000;
} catch (ParseException e) {
e.printStackTrace();
}
return time;
}
/**
* 获取当前时间long型,10位
* @return
*/
public static long getNow10Second(){
Calendar c = Calendar.getInstance();//可以对每个时间域单独修改
long a=c.getTimeInMillis()/1000;
return a;
... ... @@ -107,5 +128,9 @@ public class UtilTools {
return object.toString();
}
public static void main(String[] args) {
System.out.println(getLongTime("2016-10-11 22:22:22"));
}
}
\ No newline at end of file
... ...