ReportService.java
3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.xkl.service;
import com.alibaba.fastjson.JSONObject;
import com.xkl.domain.AMPReport;
import com.xkl.domain.AMPReportDetail;
import com.xkl.domain.ReportData;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
/**
* Created by zhao yue on 2016/11/13.
*/
@Service
public class ReportService {
/*
1. 验证md5
3. 获取report
4. 获取detail
5. 评判detail
1. 验证member
2. 获取admin
*/
// 需要程喆增加 title,account字段,String,修改set字段为int,0男,1女。
public ReportData parseReport(String reportJson, String md5) {
ReportData reportData = new ReportData();
AMPReport ampReport = new AMPReport();
List<AMPReportDetail> detailList = new ArrayList<>();
/*
* 获取report基础信息
*/
try {
JSONObject rpJson = JSONObject.parseObject(reportJson);
ampReport.setReport(rpJson.getString("name"),
rpJson.getString("title"),/// "AMP快速无创身心健康评估报告",
rpJson.getTimestamp("report_date"),
new Timestamp(System.currentTimeMillis()),
rpJson.getString("account"),///
rpJson.getInteger("sex").intValue(),///
rpJson.getInteger("age").intValue(),
rpJson.getInteger("weight").intValue(),
rpJson.getInteger("pulse").intValue(),
rpJson.getInteger("respiratory_rate").intValue(),
rpJson.getInteger("atmospheric_pressure").intValue(),
rpJson.getFloat("LCA").floatValue(),
rpJson.getFloat("RCA").floatValue(),
rpJson.getFloat("LAC").floatValue(),
rpJson.getFloat("RAC").floatValue(),
rpJson.getFloat("ABD").floatValue(),
rpJson.getFloat("total").floatValue(),
rpJson.getInteger("stable").intValue(),
md5, rpJson.getString("basic_result"));
/*
* 获取detail信息
*/
JSONObject rpDetails = rpJson.getJSONObject("detail");
for (int item_id = 1; item_id <= 125; item_id++) {
String val = rpDetails.getString(String.valueOf(item_id));
if (val == null || val.equals("")) {
continue;
}
val = val.trim().replace(" ", "").replace("``", "").replace("`", ".");
float valFloat = Float.parseFloat(val);
AMPReportDetail detail = new AMPReportDetail();
detail.setItem_value(valFloat);
detail.setItem_id(item_id);
detailList.add(detail);
}
} catch (Exception e) {
return null;
}
reportData.setAmpReport(ampReport);
reportData.setRpDetailList(detailList);
return reportData;
}
}