Showing
10 changed files
with
291 additions
and
15 deletions
@@ -13,7 +13,8 @@ public enum ResultStatus { | @@ -13,7 +13,8 @@ public enum ResultStatus { | ||
13 | USER_LOGOUT(101,"修改密码成功,退出登录"), | 13 | USER_LOGOUT(101,"修改密码成功,退出登录"), |
14 | 14 | ||
15 | // 111开头的都是与amp报告上传软件相关的 | 15 | // 111开头的都是与amp报告上传软件相关的 |
16 | - AMP_KEY_ERROR(-11100, "AMP密钥不匹配"); | 16 | + AMP_KEY_ERROR(-11100, "AMP密钥不匹配"), |
17 | + REPORT_FORMAT_ERROR(-11140,"报告格式错误"); | ||
17 | 18 | ||
18 | /** | 19 | /** |
19 | * 返回码 | 20 | * 返回码 |
1 | +package com.xkl.controller.uploadsoft; | ||
2 | + | ||
3 | +import com.wordnik.swagger.annotations.ApiImplicitParam; | ||
4 | +import com.wordnik.swagger.annotations.ApiImplicitParams; | ||
5 | +import com.wordnik.swagger.annotations.ApiOperation; | ||
6 | +import com.xkl.authorization.annotation.Authorization; | ||
7 | +import com.xkl.authorization.annotation.CurrentAdmin; | ||
8 | +import com.xkl.domain.Admin; | ||
9 | +import com.xkl.model.ResultModel; | ||
10 | +import com.xkl.repository.UpSoftVersionRepository; | ||
11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
12 | +import org.springframework.http.HttpStatus; | ||
13 | +import org.springframework.http.ResponseEntity; | ||
14 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
15 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
16 | +import org.springframework.web.bind.annotation.RequestParam; | ||
17 | +import org.springframework.web.bind.annotation.RestController; | ||
18 | +import com.alibaba.fastjson.*; | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +/** | ||
22 | + * 上传报告及删除报告接口。 | ||
23 | + */ | ||
24 | +@RestController | ||
25 | +@RequestMapping("/report") | ||
26 | +public class ReportController { | ||
27 | + | ||
28 | + @Autowired | ||
29 | + private UpSoftVersionRepository upSoftVersionRepository; | ||
30 | + | ||
31 | + @RequestMapping(method = RequestMethod.POST) | ||
32 | + @Authorization | ||
33 | + @ApiOperation(value = "上传报告") | ||
34 | + @ApiImplicitParams({ | ||
35 | + @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), | ||
36 | + }) | ||
37 | + public ResponseEntity<ResultModel> save(@CurrentAdmin Admin admin, @RequestParam String json_report) { | ||
38 | + | ||
39 | + return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK); | ||
40 | + } | ||
41 | + | ||
42 | + @RequestMapping(method = RequestMethod.DELETE) | ||
43 | + @Authorization | ||
44 | + @ApiOperation(value = "删除报告") | ||
45 | + @ApiImplicitParams({ | ||
46 | + @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), | ||
47 | + }) | ||
48 | + public ResponseEntity<ResultModel> delete(@CurrentAdmin Admin admin, @RequestParam int report_id) { | ||
49 | + | ||
50 | + return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK); | ||
51 | + } | ||
52 | + | ||
53 | +} |
@@ -54,7 +54,7 @@ public class AMPReport { | @@ -54,7 +54,7 @@ public class AMPReport { | ||
54 | private int breath_rate; | 54 | private int breath_rate; |
55 | // 大气压力 | 55 | // 大气压力 |
56 | @Column(name = "atmos_pressure") | 56 | @Column(name = "atmos_pressure") |
57 | - private int atmos_pressure; | 57 | + private float atmos_pressure; |
58 | 58 | ||
59 | @Column(name = "LCA") | 59 | @Column(name = "LCA") |
60 | private float LCA; | 60 | private float LCA; |
@@ -113,6 +113,33 @@ public class AMPReport { | @@ -113,6 +113,33 @@ public class AMPReport { | ||
113 | @Column(name = "status") | 113 | @Column(name = "status") |
114 | private int status; | 114 | private int status; |
115 | 115 | ||
116 | + public void setReport(String name, String title, Timestamp check_time, | ||
117 | + Timestamp uptime, String account_str, int sex, int age, | ||
118 | + int weight, int pulse, int breath_rate, float atmos_pressure, | ||
119 | + float LCA, float RCA, float LAC, float RAC, float ABD, float temp_sum, | ||
120 | + int stable, String md5, String conclusion) { | ||
121 | + this.name = name; | ||
122 | + this.title = title; | ||
123 | + this.check_time = check_time; | ||
124 | + this.uptime = uptime; | ||
125 | + this.account_str = account_str; | ||
126 | + this.sex = sex; | ||
127 | + this.age = age; | ||
128 | + this.weight = weight; | ||
129 | + this.pulse = pulse; | ||
130 | + this.breath_rate = breath_rate; | ||
131 | + this.atmos_pressure = atmos_pressure; | ||
132 | + this.LCA = LCA; | ||
133 | + this.RCA = RCA; | ||
134 | + this.LAC = LAC; | ||
135 | + this.RAC = RAC; | ||
136 | + this.ABD = ABD; | ||
137 | + this.temp_sum = temp_sum; | ||
138 | + this.stable = stable; | ||
139 | + this.md5 = md5; | ||
140 | + this.conclusion = conclusion; | ||
141 | + } | ||
142 | + | ||
116 | public int getId() { | 143 | public int getId() { |
117 | return id; | 144 | return id; |
118 | } | 145 | } |
@@ -209,11 +236,11 @@ public class AMPReport { | @@ -209,11 +236,11 @@ public class AMPReport { | ||
209 | this.breath_rate = breath_rate; | 236 | this.breath_rate = breath_rate; |
210 | } | 237 | } |
211 | 238 | ||
212 | - public int getAtmos_pressure() { | 239 | + public float getAtmos_pressure() { |
213 | return atmos_pressure; | 240 | return atmos_pressure; |
214 | } | 241 | } |
215 | 242 | ||
216 | - public void setAtmos_pressure(int atmos_pressure) { | 243 | + public void setAtmos_pressure(float atmos_pressure) { |
217 | this.atmos_pressure = atmos_pressure; | 244 | this.atmos_pressure = atmos_pressure; |
218 | } | 245 | } |
219 | 246 |
1 | +package com.xkl.domain; | ||
2 | + | ||
3 | +import javax.persistence.Column; | ||
4 | +import javax.persistence.Entity; | ||
5 | +import javax.persistence.Id; | ||
6 | +import javax.persistence.Table; | ||
7 | + | ||
8 | +/** | ||
9 | + * 用户数据的domain类 | ||
10 | + */ | ||
11 | +@Entity | ||
12 | +@Table(name = "xkl_amp_report_detail") | ||
13 | +public class AMPReportDetail { | ||
14 | + | ||
15 | + //自增id | ||
16 | + @Id | ||
17 | + @Column(name = "id") | ||
18 | + private long id; | ||
19 | + | ||
20 | + // 报告id | ||
21 | + @Column(name = "report_id") | ||
22 | + private int report_id; | ||
23 | + | ||
24 | + // 指标id | ||
25 | + @Column(name = "item_id") | ||
26 | + private int item_id; | ||
27 | + | ||
28 | + // 指标值 | ||
29 | + @Column(name = "item_value") | ||
30 | + private float item_value; | ||
31 | + | ||
32 | + | ||
33 | + // 0, normal; 1, lower; 2, higher. | ||
34 | + @Column(name = "status") | ||
35 | + private int status; | ||
36 | + | ||
37 | + public long getId() { | ||
38 | + return id; | ||
39 | + } | ||
40 | + | ||
41 | + public void setId(long id) { | ||
42 | + this.id = id; | ||
43 | + } | ||
44 | + | ||
45 | + public int getReport_id() { | ||
46 | + return report_id; | ||
47 | + } | ||
48 | + | ||
49 | + public void setReport_id(int report_id) { | ||
50 | + this.report_id = report_id; | ||
51 | + } | ||
52 | + | ||
53 | + public int getItem_id() { | ||
54 | + return item_id; | ||
55 | + } | ||
56 | + | ||
57 | + public void setItem_id(int item_id) { | ||
58 | + this.item_id = item_id; | ||
59 | + } | ||
60 | + | ||
61 | + public float getItem_value() { | ||
62 | + return item_value; | ||
63 | + } | ||
64 | + | ||
65 | + public void setItem_value(float item_value) { | ||
66 | + this.item_value = item_value; | ||
67 | + } | ||
68 | + | ||
69 | + public int getStatus() { | ||
70 | + return status; | ||
71 | + } | ||
72 | + | ||
73 | + public void setStatus(int status) { | ||
74 | + this.status = status; | ||
75 | + } | ||
76 | +} |
src/main/java/com/xkl/domain/ReportData.java
0 → 100644
1 | +package com.xkl.domain; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | +import com.xkl.config.ResultStatus; | ||
5 | + | ||
6 | +/** | ||
7 | + * 用于报告处理的中间数据类。 | ||
8 | + * Created by zhao yue on 2016/11/13. | ||
9 | + */ | ||
10 | +public class ReportData { | ||
11 | + private AMPReport ampReport; | ||
12 | + private List<AMPReportDetail> rpDetailList; | ||
13 | +// ResultStatus resStatus; | ||
14 | + | ||
15 | +// public ReportData(ResultStatus resStatus) { | ||
16 | +// this.resStatus = resStatus; | ||
17 | +// } | ||
18 | + | ||
19 | + public AMPReport getAmpReport() { | ||
20 | + return ampReport; | ||
21 | + } | ||
22 | + | ||
23 | + public void setAmpReport(AMPReport ampReport) { | ||
24 | + this.ampReport = ampReport; | ||
25 | + } | ||
26 | + | ||
27 | + public List<AMPReportDetail> getRpDetailList() { | ||
28 | + return rpDetailList; | ||
29 | + } | ||
30 | + | ||
31 | + public void setRpDetailList(List<AMPReportDetail> rpDetailList) { | ||
32 | + this.rpDetailList = rpDetailList; | ||
33 | + } | ||
34 | + | ||
35 | +// public ResultStatus getResStatus() { | ||
36 | +// return resStatus; | ||
37 | +// } | ||
38 | +// | ||
39 | +// public void setResStatus(ResultStatus resStatus) { | ||
40 | +// this.resStatus = resStatus; | ||
41 | +// } | ||
42 | +} |
1 | +package com.xkl.service; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
4 | +import com.xkl.domain.AMPReport; | ||
5 | +import com.xkl.domain.AMPReportDetail; | ||
6 | +import com.xkl.domain.ReportData; | ||
7 | +import org.springframework.stereotype.Service; | ||
8 | + | ||
9 | +import java.sql.Timestamp; | ||
10 | +import java.util.ArrayList; | ||
11 | +import java.util.List; | ||
12 | + | ||
13 | +/** | ||
14 | + * Created by zhao yue on 2016/11/13. | ||
15 | + */ | ||
16 | +@Service | ||
17 | +public class ReportService { | ||
18 | + /* | ||
19 | + 1. 验证md5 | ||
20 | + 3. 获取report | ||
21 | + 4. 获取detail | ||
22 | + 5. 评判detail | ||
23 | + 1. 验证member | ||
24 | + 2. 获取admin | ||
25 | + */ | ||
26 | + // 需要程喆增加 title,account字段,String,修改set字段为int,0男,1女。 | ||
27 | + public ReportData parseReport(String reportJson, String md5) { | ||
28 | + ReportData reportData = new ReportData(); | ||
29 | + AMPReport ampReport = new AMPReport(); | ||
30 | + List<AMPReportDetail> detailList = new ArrayList<>(); | ||
31 | + /* | ||
32 | + * 获取report基础信息 | ||
33 | + */ | ||
34 | + try { | ||
35 | + JSONObject rpJson = JSONObject.parseObject(reportJson); | ||
36 | + ampReport.setReport(rpJson.getString("name"), | ||
37 | + rpJson.getString("title"),/// "AMP快速无创身心健康评估报告", | ||
38 | + rpJson.getTimestamp("report_date"), | ||
39 | + new Timestamp(System.currentTimeMillis()), | ||
40 | + rpJson.getString("account"),/// | ||
41 | + rpJson.getInteger("sex").intValue(),/// | ||
42 | + rpJson.getInteger("age").intValue(), | ||
43 | + rpJson.getInteger("weight").intValue(), | ||
44 | + rpJson.getInteger("pulse").intValue(), | ||
45 | + rpJson.getInteger("respiratory_rate").intValue(), | ||
46 | + rpJson.getInteger("atmospheric_pressure").intValue(), | ||
47 | + rpJson.getFloat("LCA").floatValue(), | ||
48 | + rpJson.getFloat("RCA").floatValue(), | ||
49 | + rpJson.getFloat("LAC").floatValue(), | ||
50 | + rpJson.getFloat("RAC").floatValue(), | ||
51 | + rpJson.getFloat("ABD").floatValue(), | ||
52 | + rpJson.getFloat("total").floatValue(), | ||
53 | + rpJson.getInteger("stable").intValue(), | ||
54 | + md5, rpJson.getString("basic_result")); | ||
55 | + /* | ||
56 | + * 获取detail信息 | ||
57 | + */ | ||
58 | + JSONObject rpDetails = rpJson.getJSONObject("detail"); | ||
59 | + for (int item_id = 1; item_id <= 125; item_id++) { | ||
60 | + String val = rpDetails.getString(String.valueOf(item_id)); | ||
61 | + if (val == null || val.equals("")) { | ||
62 | + continue; | ||
63 | + } | ||
64 | + val = val.trim().replace(" ", "").replace("``", "").replace("`", "."); | ||
65 | + float valFloat = Float.parseFloat(val); | ||
66 | + AMPReportDetail detail = new AMPReportDetail(); | ||
67 | + detail.setItem_value(valFloat); | ||
68 | + detail.setItem_id(item_id); | ||
69 | + detailList.add(detail); | ||
70 | + } | ||
71 | + } catch (Exception e) { | ||
72 | + return null; | ||
73 | + } | ||
74 | + reportData.setAmpReport(ampReport); | ||
75 | + reportData.setRpDetailList(detailList); | ||
76 | + return reportData; | ||
77 | + } | ||
78 | +} |
@@ -5,13 +5,14 @@ server.port=8090 | @@ -5,13 +5,14 @@ server.port=8090 | ||
5 | #server.ssl.key-password = xkl2016 | 5 | #server.ssl.key-password = xkl2016 |
6 | 6 | ||
7 | #MySQL | 7 | #MySQL |
8 | -spring.datasource.url=jdbc:mysql://localhost:3306/hanhe_test?useUnicode=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=round&autoReconnect=true | ||
9 | -spring.datasource.username=root | ||
10 | -spring.datasource.password=fyqmysql | 8 | +spring.datasource.url=jdbc:mysql://db.hanhezy.com:4096/hanhe_test?useUnicode=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=round&autoReconnect=true |
9 | +spring.datasource.username=hanhe | ||
10 | +spring.datasource.password=HANhetest2016 | ||
11 | + | ||
11 | 12 | ||
12 | #Redis | 13 | #Redis |
13 | spring.redis.host=127.0.0.1 | 14 | spring.redis.host=127.0.0.1 |
14 | -spring.redis.password=foobared | 15 | +#spring.redis.password=foobared |
15 | #spring.redis.host=r-m5e7cedd3124afd4.redis.rds.aliyuncs.com | 16 | #spring.redis.host=r-m5e7cedd3124afd4.redis.rds.aliyuncs.com |
16 | #spring.redis.password=r-m5e7cedd3124afd4:XIkaiLURedis2016 | 17 | #spring.redis.password=r-m5e7cedd3124afd4:XIkaiLURedis2016 |
17 | 18 |
@@ -5,14 +5,13 @@ server.port=8090 | @@ -5,14 +5,13 @@ server.port=8090 | ||
5 | #server.ssl.key-password = xkl2016 | 5 | #server.ssl.key-password = xkl2016 |
6 | 6 | ||
7 | #MySQL | 7 | #MySQL |
8 | -spring.datasource.url=jdbc:mysql://db.hanhezy.com:4096/hanhe_test?useUnicode=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=round&autoReconnect=true | ||
9 | -spring.datasource.username=hanhe | ||
10 | -spring.datasource.password=HANhetest2016 | ||
11 | - | 8 | +spring.datasource.url=jdbc:mysql://localhost:3306/hanhe_test?useUnicode=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=round&autoReconnect=true |
9 | +spring.datasource.username=root | ||
10 | +spring.datasource.password=fyqmysql | ||
12 | 11 | ||
13 | #Redis | 12 | #Redis |
14 | spring.redis.host=127.0.0.1 | 13 | spring.redis.host=127.0.0.1 |
15 | -#spring.redis.password=foobared | 14 | +spring.redis.password=foobared |
16 | #spring.redis.host=r-m5e7cedd3124afd4.redis.rds.aliyuncs.com | 15 | #spring.redis.host=r-m5e7cedd3124afd4.redis.rds.aliyuncs.com |
17 | #spring.redis.password=r-m5e7cedd3124afd4:XIkaiLURedis2016 | 16 | #spring.redis.password=r-m5e7cedd3124afd4:XIkaiLURedis2016 |
18 | 17 |
-
Please register or login to post a comment