Commit 2c95b36f7f44248f9a53743446dbb3fa528582a8
1 parent
365429f6df
Exists in
master
and in
6 other branches
update
Showing 11 changed files with 296 additions and 268 deletions
- platform-common/src/main/java/com/lyms/platform/common/utils/StringUtils.java
- platform-dal/src/main/java/com/lyms/platform/pojo/BoneModel.java
- platform-transfer/src/main/java/com/lyms/platform/comm/ApplicationProperties.java
- platform-transfer/src/main/java/com/lyms/platform/worker/BoneTransferWorker.java
- platform-transfer/src/main/java/com/lyms/platform/worker/BoneWorker.java
- platform-transfer/src/main/java/com/lyms/platform/worker/ITransfer.java
- platform-transfer/src/main/java/com/lyms/platform/worker/MicroelementTransferWorker.java
- platform-transfer/src/main/java/com/lyms/platform/worker/MicroelementWorker.java
- platform-transfer/src/main/java/com/lyms/platform/worker/TransferAbstract.java
- platform-transfer/src/main/java/com/lyms/platform/worker/TransferWorker.java
- platform-transfer/src/main/resources/application.yml
platform-common/src/main/java/com/lyms/platform/common/utils/StringUtils.java
View file @
2c95b36
1 | 1 | package com.lyms.platform.common.utils; |
2 | 2 | |
3 | +import java.math.BigDecimal; | |
4 | +import java.text.DecimalFormat; | |
3 | 5 | import java.util.*; |
4 | 6 | import java.util.regex.Matcher; |
5 | 7 | import java.util.regex.Pattern; |
... | ... | @@ -265,6 +267,10 @@ |
265 | 267 | return String.valueOf(str); |
266 | 268 | } |
267 | 269 | |
270 | + public static double formatDouble2(double retainTwoDecimal) { | |
271 | + BigDecimal bg = new BigDecimal(retainTwoDecimal); | |
272 | + return bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |
273 | + } | |
268 | 274 | |
269 | 275 | /** |
270 | 276 | * 替换短信中的表达式 |
platform-dal/src/main/java/com/lyms/platform/pojo/BoneModel.java
View file @
2c95b36
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | |
3 | 3 | import com.lyms.platform.beans.SerialIdEnum; |
4 | 4 | import com.lyms.platform.common.result.BaseModel; |
5 | +import com.lyms.platform.common.utils.StringUtils; | |
5 | 6 | import org.springframework.data.mongodb.core.mapping.Document; |
6 | 7 | |
7 | 8 | import java.util.Date; |
... | ... | @@ -151,7 +152,8 @@ |
151 | 152 | } |
152 | 153 | |
153 | 154 | public void setSos(Double sos) { |
154 | - this.sos = sos; | |
155 | + | |
156 | + this.sos = StringUtils.formatDouble2(sos); | |
155 | 157 | } |
156 | 158 | |
157 | 159 | public Double getTvalue() { |
... | ... | @@ -159,7 +161,8 @@ |
159 | 161 | } |
160 | 162 | |
161 | 163 | public void setTvalue(Double tvalue) { |
162 | - this.tvalue = tvalue; | |
164 | + | |
165 | + this.tvalue = StringUtils.formatDouble2(tvalue); | |
163 | 166 | } |
164 | 167 | |
165 | 168 | public Double getZvalue() { |
... | ... | @@ -167,7 +170,7 @@ |
167 | 170 | } |
168 | 171 | |
169 | 172 | public void setZvalue(Double zvalue) { |
170 | - this.zvalue = zvalue; | |
173 | + this.zvalue = StringUtils.formatDouble2(zvalue); | |
171 | 174 | } |
172 | 175 | |
173 | 176 | public Double getBqi() { |
... | ... | @@ -175,7 +178,7 @@ |
175 | 178 | } |
176 | 179 | |
177 | 180 | public void setBqi(Double bqi) { |
178 | - this.bqi = bqi; | |
181 | + this.bqi = StringUtils.formatDouble2(bqi); | |
179 | 182 | } |
180 | 183 | |
181 | 184 | public Double getRrf() { |
... | ... | @@ -183,7 +186,7 @@ |
183 | 186 | } |
184 | 187 | |
185 | 188 | public void setRrf(Double rrf) { |
186 | - this.rrf = rrf; | |
189 | + this.rrf = StringUtils.formatDouble2(rrf); | |
187 | 190 | } |
188 | 191 | |
189 | 192 | public Double getEoa() { |
... | ... | @@ -191,7 +194,7 @@ |
191 | 194 | } |
192 | 195 | |
193 | 196 | public void setEoa(Double eoa) { |
194 | - this.eoa = eoa; | |
197 | + this.eoa = StringUtils.formatDouble2(eoa); | |
195 | 198 | } |
196 | 199 | |
197 | 200 | public Double getAdultPercent() { |
... | ... | @@ -199,7 +202,7 @@ |
199 | 202 | } |
200 | 203 | |
201 | 204 | public void setAdultPercent(Double adultPercent) { |
202 | - this.adultPercent = adultPercent; | |
205 | + this.adultPercent = StringUtils.formatDouble2(adultPercent); | |
203 | 206 | } |
204 | 207 | |
205 | 208 | public Double getAgePercent() { |
... | ... | @@ -207,7 +210,7 @@ |
207 | 210 | } |
208 | 211 | |
209 | 212 | public void setAgePercent(Double agePercent) { |
210 | - this.agePercent = agePercent; | |
213 | + this.agePercent = StringUtils.formatDouble2(agePercent); | |
211 | 214 | } |
212 | 215 | |
213 | 216 | public Double getAge() { |
... | ... | @@ -215,7 +218,7 @@ |
215 | 218 | } |
216 | 219 | |
217 | 220 | public void setAge(Double age) { |
218 | - this.age = age; | |
221 | + this.age = StringUtils.formatDouble2(age); | |
219 | 222 | } |
220 | 223 | |
221 | 224 | public Integer getType() { |
platform-transfer/src/main/java/com/lyms/platform/comm/ApplicationProperties.java
View file @
2c95b36
... | ... | @@ -10,25 +10,16 @@ |
10 | 10 | @ConfigurationProperties(prefix = "param") |
11 | 11 | public class ApplicationProperties { |
12 | 12 | |
13 | - private String microelementPath; | |
14 | - private String bonePath; | |
13 | + private String dataPath; | |
15 | 14 | private Integer type; |
16 | 15 | private String url; |
17 | 16 | |
18 | - public String getMicroelementPath() { | |
19 | - return microelementPath; | |
17 | + public String getDataPath() { | |
18 | + return dataPath; | |
20 | 19 | } |
21 | 20 | |
22 | - public void setMicroelementPath(String microelementPath) { | |
23 | - this.microelementPath = microelementPath; | |
24 | - } | |
25 | - | |
26 | - public String getBonePath() { | |
27 | - return bonePath; | |
28 | - } | |
29 | - | |
30 | - public void setBonePath(String bonePath) { | |
31 | - this.bonePath = bonePath; | |
21 | + public void setDataPath(String dataPath) { | |
22 | + this.dataPath = dataPath; | |
32 | 23 | } |
33 | 24 | |
34 | 25 | public Integer getType() { |
platform-transfer/src/main/java/com/lyms/platform/worker/BoneTransferWorker.java
View file @
2c95b36
1 | +package com.lyms.platform.worker; | |
2 | + | |
3 | +import com.lyms.platform.comm.ApplicationProperties; | |
4 | +import com.lyms.platform.conn.BoneConnectionFactory; | |
5 | +import com.lyms.platform.conn.inf.ConnectionFactoryMethod; | |
6 | +import com.lyms.platform.conn.inf.IConnection; | |
7 | +import org.apache.commons.httpclient.util.DateUtil; | |
8 | +import org.springframework.beans.factory.annotation.Autowired; | |
9 | +import org.springframework.stereotype.Component; | |
10 | + | |
11 | +import java.sql.Connection; | |
12 | +import java.sql.ResultSet; | |
13 | +import java.sql.SQLException; | |
14 | +import java.sql.Statement; | |
15 | +import java.util.Date; | |
16 | +import java.util.HashMap; | |
17 | +import java.util.Map; | |
18 | + | |
19 | +/** | |
20 | + * 骨密度 | |
21 | + */ | |
22 | +@Component | |
23 | +public class BoneTransferWorker extends TransferAbstract implements ITransfer{ | |
24 | + | |
25 | + @Autowired | |
26 | + private ApplicationProperties properties; | |
27 | + | |
28 | + @Override | |
29 | + public void doTransfer() { | |
30 | + System.out.println("getBoneRecords start"); | |
31 | + Connection conn = null; | |
32 | + Statement sta = null; | |
33 | + ResultSet rst = null; | |
34 | + ConnectionFactoryMethod factoryMethod = new BoneConnectionFactory(); | |
35 | + IConnection iConnection = factoryMethod.createConnection(properties.getDataPath()); | |
36 | + try { | |
37 | + | |
38 | + conn = iConnection.getConnection(); | |
39 | + sta = conn.createStatement(); | |
40 | + rst = sta.executeQuery("select PatientID,ZScore,TScore,dbSos,dbBqi,dbRrf,dbEoa,YoungAdult,ageMatched,dbAge,PartDisplayName from PatientInfo where status is null and DayTimeOfSave > #"+ DateUtil.formatDate(new Date(),"yyyy-MM-dd")+"#"); | |
41 | + while (rst.next()) { | |
42 | + Map map = new HashMap(); | |
43 | + | |
44 | + String PatientID = rst.getString("PatientID"); //身份证后八位 | |
45 | + //String position = rst.getString(""); | |
46 | + map.put("cardNo",PatientID); | |
47 | + | |
48 | + String PartDisplayName = rst.getString("PartDisplayName"); | |
49 | + map.put("position",PartDisplayName); | |
50 | + | |
51 | + String ZScore = rst.getString("ZScore"); | |
52 | + String TScore = rst.getString("TScore"); | |
53 | + String dbSos = rst.getString("dbSos"); | |
54 | + | |
55 | + String bqi = rst.getString("dbBqi"); | |
56 | + String rrf = rst.getString("dbRrf"); | |
57 | + String eoa = rst.getString("dbEoa"); | |
58 | + | |
59 | + String adultPercent = rst.getString("YoungAdult"); | |
60 | + String agePercent = rst.getString("ageMatched"); | |
61 | + String age = rst.getString("dbAge"); | |
62 | + | |
63 | + map.put("zvalue",ZScore); | |
64 | + map.put("tvalue",TScore); | |
65 | + map.put("sos",dbSos); | |
66 | + | |
67 | + map.put("bqi",bqi); | |
68 | + map.put("rrf",rrf); | |
69 | + map.put("eoa",eoa); | |
70 | + | |
71 | + map.put("adultPercent",adultPercent); | |
72 | + map.put("agePercent",agePercent); | |
73 | + map.put("age",age); | |
74 | + map.put("type",1); // | |
75 | + | |
76 | + if (map.size() > 0 && PatientID != null) | |
77 | + { | |
78 | + String response = send(map, properties.getUrl() + "/saveBone"); | |
79 | + if (response.contains("0")) | |
80 | + { | |
81 | + sta.executeUpdate("update PatientInfo set status='1' where PatientID='"+PatientID+"'"); | |
82 | + conn.commit(); | |
83 | + } | |
84 | + } | |
85 | + } | |
86 | + } catch (Exception e) { | |
87 | + try { | |
88 | + conn.rollback(); | |
89 | + } catch (SQLException e1) { | |
90 | + e1.printStackTrace(); | |
91 | + } | |
92 | + } | |
93 | + finally { | |
94 | + iConnection.close(conn, sta,rst); | |
95 | + } | |
96 | + } | |
97 | +} |
platform-transfer/src/main/java/com/lyms/platform/worker/BoneWorker.java
View file @
2c95b36
1 | -package com.lyms.platform.worker; | |
2 | - | |
3 | -import com.lyms.platform.comm.ApplicationProperties; | |
4 | -import com.lyms.platform.comm.HttpClientUtil; | |
5 | -import com.lyms.platform.comm.JsonUtil; | |
6 | -import com.lyms.platform.conn.BoneConnectionFactory; | |
7 | -import com.lyms.platform.conn.inf.ConnectionFactoryMethod; | |
8 | -import com.lyms.platform.conn.inf.IConnection; | |
9 | -import org.apache.commons.httpclient.util.DateUtil; | |
10 | -import org.springframework.beans.factory.annotation.Autowired; | |
11 | -import org.springframework.scheduling.annotation.Scheduled; | |
12 | -import org.springframework.stereotype.Component; | |
13 | - | |
14 | -import java.sql.Connection; | |
15 | -import java.sql.ResultSet; | |
16 | -import java.sql.SQLException; | |
17 | -import java.sql.Statement; | |
18 | -import java.util.Date; | |
19 | -import java.util.HashMap; | |
20 | -import java.util.Map; | |
21 | - | |
22 | -/** | |
23 | - * 骨密度 | |
24 | - */ | |
25 | -@Component | |
26 | -public class BoneWorker { | |
27 | - | |
28 | - @Autowired | |
29 | - private ApplicationProperties properties; | |
30 | - | |
31 | - @Scheduled(cron = "0 0/1 * * * ?") | |
32 | - public void getBoneRecords() | |
33 | - { | |
34 | - System.out.println("getBoneRecords start"); | |
35 | - Connection conn = null; | |
36 | - Statement sta = null; | |
37 | - ResultSet rst = null; | |
38 | - ConnectionFactoryMethod factoryMethod = new BoneConnectionFactory(); | |
39 | - IConnection iConnection = factoryMethod.createConnection(properties.getBonePath()); | |
40 | - try { | |
41 | - | |
42 | - conn = iConnection.getConnection(); | |
43 | - sta = conn.createStatement(); | |
44 | - rst = sta.executeQuery("select PatientID,ZScore,TScore,dbSos,dbBqi,dbRrf,dbEoa,YoungAdult,ageMatched,dbAge,PartDisplayName from PatientInfo where status is null and DayTimeOfSave > #"+ DateUtil.formatDate(new Date(),"yyyy-MM-dd")+"#"); | |
45 | - while (rst.next()) { | |
46 | - Map map = new HashMap(); | |
47 | - | |
48 | - String PatientID = rst.getString("PatientID"); //身份证后八位 | |
49 | - //String position = rst.getString(""); | |
50 | - map.put("cardNo",PatientID); | |
51 | - | |
52 | - String PartDisplayName = rst.getString("PartDisplayName"); | |
53 | - map.put("position",PartDisplayName); | |
54 | - | |
55 | - String ZScore = rst.getString("ZScore"); | |
56 | - String TScore = rst.getString("TScore"); | |
57 | - String dbSos = rst.getString("dbSos"); | |
58 | - | |
59 | - String bqi = rst.getString("dbBqi"); | |
60 | - String rrf = rst.getString("dbRrf"); | |
61 | - String eoa = rst.getString("dbEoa"); | |
62 | - | |
63 | - String adultPercent = rst.getString("YoungAdult"); | |
64 | - String agePercent = rst.getString("ageMatched"); | |
65 | - String age = rst.getString("dbAge"); | |
66 | - | |
67 | - map.put("zvalue",ZScore); | |
68 | - map.put("tvalue",TScore); | |
69 | - map.put("sos",dbSos); | |
70 | - | |
71 | - map.put("bqi",bqi); | |
72 | - map.put("rrf",rrf); | |
73 | - map.put("eoa",eoa); | |
74 | - | |
75 | - map.put("adultPercent",adultPercent); | |
76 | - map.put("agePercent",agePercent); | |
77 | - map.put("age",age); | |
78 | - map.put("type",1); // | |
79 | - | |
80 | - if (map.size() > 0 && PatientID != null) | |
81 | - { | |
82 | - String response = autoTransfer(map); | |
83 | - if (response.contains("0")) | |
84 | - { | |
85 | - sta.executeUpdate("update PatientInfo set status='1' where PatientID='"+PatientID+"'"); | |
86 | - conn.commit(); | |
87 | - } | |
88 | - } | |
89 | - } | |
90 | - } catch (Exception e) { | |
91 | - try { | |
92 | - conn.rollback(); | |
93 | - } catch (SQLException e1) { | |
94 | - e1.printStackTrace(); | |
95 | - } | |
96 | - } | |
97 | - finally { | |
98 | - iConnection.close(conn, sta,rst); | |
99 | - } | |
100 | - } | |
101 | - | |
102 | - public String autoTransfer(Map<String,Object> data) | |
103 | - { | |
104 | - if (data != null && data.size() > 0) | |
105 | - { | |
106 | - String json = JsonUtil.obj2Str(data); | |
107 | - System.out.println(json); | |
108 | - String result = HttpClientUtil.doPostSSL(properties.getUrl() + "/saveBone", json); | |
109 | - System.out.println("http result= "+result); | |
110 | - return result; | |
111 | - } | |
112 | - return ""; | |
113 | - } | |
114 | -} |
platform-transfer/src/main/java/com/lyms/platform/worker/ITransfer.java
View file @
2c95b36
platform-transfer/src/main/java/com/lyms/platform/worker/MicroelementTransferWorker.java
View file @
2c95b36
1 | +package com.lyms.platform.worker; | |
2 | + | |
3 | +import com.lyms.platform.comm.ApplicationProperties; | |
4 | +import com.lyms.platform.comm.StringUtils; | |
5 | +import com.lyms.platform.conn.*; | |
6 | +import com.lyms.platform.conn.inf.ConnectionFactoryMethod; | |
7 | +import com.lyms.platform.conn.inf.IConnection; | |
8 | +import org.springframework.beans.factory.annotation.Autowired; | |
9 | +import org.springframework.stereotype.Component; | |
10 | + | |
11 | +import java.sql.Connection; | |
12 | +import java.sql.ResultSet; | |
13 | +import java.sql.SQLException; | |
14 | +import java.sql.Statement; | |
15 | +import java.util.ArrayList; | |
16 | +import java.util.HashMap; | |
17 | +import java.util.List; | |
18 | +import java.util.Map; | |
19 | +@Component | |
20 | +public class MicroelementTransferWorker extends TransferAbstract implements ITransfer{ | |
21 | + | |
22 | + @Autowired | |
23 | + private ApplicationProperties properties; | |
24 | + | |
25 | + public void doTransfer() | |
26 | + { | |
27 | + System.out.println("getMicroelementRecords start"); | |
28 | + Connection conn = null; | |
29 | + Statement sta = null; | |
30 | + ResultSet rst = null; | |
31 | + | |
32 | + ConnectionFactoryMethod factoryMethod = new MicroelementConnectionFactory(); | |
33 | + IConnection iConnection = factoryMethod.createConnection(properties.getDataPath()); | |
34 | + try { | |
35 | + conn = iConnection.getConnection(); | |
36 | + sta = conn.createStatement(); | |
37 | + rst = sta.executeQuery("select * from BaseInfo where status is null "); | |
38 | + while (rst.next()){ | |
39 | + Map<String,Object> data = new HashMap(); | |
40 | + String numberCode = rst.getString("编号"); | |
41 | + String autoId = rst.getString("AUTOID"); | |
42 | + data.put("numberCode",numberCode); | |
43 | + data.put("type",properties.getType()); | |
44 | + data.put("autoId",autoId); | |
45 | + getMicroelementRecords(data); | |
46 | + } | |
47 | + } | |
48 | + catch (SQLException e) { | |
49 | + } | |
50 | + finally { | |
51 | + iConnection.close(conn, sta,rst); | |
52 | + } | |
53 | + } | |
54 | + | |
55 | + | |
56 | + private void getMicroelementRecords(Map<String,Object> data) | |
57 | + { | |
58 | + Connection conn = null; | |
59 | + Statement sta = null; | |
60 | + ResultSet rst = null; | |
61 | + ConnectionFactoryMethod factoryMethod = new MicroelementConnectionFactory(); | |
62 | + IConnection iConnection = factoryMethod.createConnection(properties.getDataPath()); | |
63 | + try { | |
64 | + conn = iConnection.getConnection(); | |
65 | + String autoId = data.get("autoId").toString(); | |
66 | + sta = conn.createStatement(); | |
67 | + rst = sta.executeQuery("select * from ItemsInfo where BaseAutoId = "+autoId); | |
68 | + | |
69 | + List<Map> microelements = new ArrayList(); | |
70 | + while (rst.next()) { | |
71 | + Map map = new HashMap(); | |
72 | + String eleName = rst.getString("元素名称"); | |
73 | + String value = rst.getString("测量值"); | |
74 | + String result = StringUtils.checkNum(value); | |
75 | + map.put("result",result); | |
76 | + map.put("unit",value.contains("mmol") ? "mmol/l" : (value.contains("umol") ? "umol/l" : "ug/l")); | |
77 | + map.put("eleName",eleName); | |
78 | + map.put("refValue","");//TODO | |
79 | + microelements.add(map); | |
80 | + } | |
81 | + data.put("microelements", microelements); | |
82 | + data.remove("autoId"); | |
83 | + if (microelements.size() > 0) | |
84 | + { | |
85 | + String response = send(data, properties.getUrl() + "/saveMicroelement"); | |
86 | + if (response.contains("0")) | |
87 | + { | |
88 | + sta.executeUpdate("update BaseInfo set status='1' where AUTOID="+autoId); | |
89 | + conn.commit(); | |
90 | + } | |
91 | + } | |
92 | + } | |
93 | + catch (Exception e) | |
94 | + { | |
95 | + try { | |
96 | + conn.rollback(); | |
97 | + } catch (SQLException e1) { | |
98 | + e1.printStackTrace(); | |
99 | + } | |
100 | + } | |
101 | + finally { | |
102 | + iConnection.close(conn, sta,rst); | |
103 | + } | |
104 | + } | |
105 | + | |
106 | +} |
platform-transfer/src/main/java/com/lyms/platform/worker/MicroelementWorker.java
View file @
2c95b36
1 | -package com.lyms.platform.worker; | |
2 | - | |
3 | -import com.lyms.platform.comm.ApplicationProperties; | |
4 | -import com.lyms.platform.comm.HttpClientUtil; | |
5 | -import com.lyms.platform.comm.JsonUtil; | |
6 | -import com.lyms.platform.comm.StringUtils; | |
7 | -import com.lyms.platform.conn.*; | |
8 | -import com.lyms.platform.conn.inf.ConnectionFactoryMethod; | |
9 | -import com.lyms.platform.conn.inf.IConnection; | |
10 | -import org.springframework.beans.factory.annotation.Autowired; | |
11 | -import org.springframework.context.annotation.Configuration; | |
12 | -import org.springframework.scheduling.annotation.EnableScheduling; | |
13 | -import org.springframework.scheduling.annotation.Scheduled; | |
14 | -import org.springframework.stereotype.Component; | |
15 | - | |
16 | -import java.sql.Connection; | |
17 | -import java.sql.ResultSet; | |
18 | -import java.sql.SQLException; | |
19 | -import java.sql.Statement; | |
20 | -import java.util.ArrayList; | |
21 | -import java.util.HashMap; | |
22 | -import java.util.List; | |
23 | -import java.util.Map; | |
24 | -@Configuration | |
25 | -@EnableScheduling | |
26 | -@Component | |
27 | -public class MicroelementWorker { | |
28 | - | |
29 | - @Autowired | |
30 | - private ApplicationProperties properties; | |
31 | - | |
32 | - @Scheduled(cron = "0 0/1 * * * ?") | |
33 | - public void getMicroelementRecords() | |
34 | - { | |
35 | - System.out.println("getMicroelementRecords start"); | |
36 | - Connection conn = null; | |
37 | - Statement sta = null; | |
38 | - ResultSet rst = null; | |
39 | - | |
40 | - ConnectionFactoryMethod factoryMethod = new MicroelementConnectionFactory(); | |
41 | - IConnection iConnection = factoryMethod.createConnection(properties.getMicroelementPath()); | |
42 | - try { | |
43 | - conn = iConnection.getConnection(); | |
44 | - sta = conn.createStatement(); | |
45 | - rst = sta.executeQuery("select * from BaseInfo where status is null "); | |
46 | - while (rst.next()){ | |
47 | - Map<String,Object> data = new HashMap(); | |
48 | - String numberCode = rst.getString("编号"); | |
49 | - String autoId = rst.getString("AUTOID"); | |
50 | - data.put("numberCode",numberCode); | |
51 | - data.put("type",properties.getType()); | |
52 | - data.put("autoId",autoId); | |
53 | - getMicroelementRecords(data); | |
54 | - } | |
55 | - } | |
56 | - catch (SQLException e) { | |
57 | - } | |
58 | - finally { | |
59 | - iConnection.close(conn, sta,rst); | |
60 | - } | |
61 | - } | |
62 | - | |
63 | - | |
64 | - public void getMicroelementRecords(Map<String,Object> data) | |
65 | - { | |
66 | - Connection conn = null; | |
67 | - Statement sta = null; | |
68 | - ResultSet rst = null; | |
69 | - ConnectionFactoryMethod factoryMethod = new MicroelementConnectionFactory(); | |
70 | - IConnection iConnection = factoryMethod.createConnection(properties.getMicroelementPath()); | |
71 | - try { | |
72 | - conn = iConnection.getConnection(); | |
73 | - String autoId = data.get("autoId").toString(); | |
74 | - sta = conn.createStatement(); | |
75 | - rst = sta.executeQuery("select * from ItemsInfo where BaseAutoId = "+autoId); | |
76 | - | |
77 | - List<Map> microelements = new ArrayList(); | |
78 | - while (rst.next()) { | |
79 | - Map map = new HashMap(); | |
80 | - String eleName = rst.getString("元素名称"); | |
81 | - String value = rst.getString("测量值"); | |
82 | - String result = StringUtils.checkNum(value); | |
83 | - map.put("result",result); | |
84 | - map.put("unit",value.contains("mmol") ? "mmol/l" : (value.contains("umol") ? "umol/l" : "ug/l")); | |
85 | - map.put("eleName",eleName); | |
86 | - map.put("refValue","");//TODO | |
87 | - microelements.add(map); | |
88 | - } | |
89 | - data.put("microelements", microelements); | |
90 | - data.remove("autoId"); | |
91 | - if (microelements.size() > 0) | |
92 | - { | |
93 | - String response = autoTransfer(data); | |
94 | - if (response.contains("0")) | |
95 | - { | |
96 | - sta.executeUpdate("update BaseInfo set status='1' where AUTOID="+autoId); | |
97 | - conn.commit(); | |
98 | - } | |
99 | - } | |
100 | - } | |
101 | - catch (Exception e) | |
102 | - { | |
103 | - try { | |
104 | - conn.rollback(); | |
105 | - } catch (SQLException e1) { | |
106 | - e1.printStackTrace(); | |
107 | - } | |
108 | - } | |
109 | - finally { | |
110 | - iConnection.close(conn, sta,rst); | |
111 | - } | |
112 | - } | |
113 | - | |
114 | - public String autoTransfer(Map<String,Object> data) | |
115 | - { | |
116 | - if (data != null && data.size() > 0) | |
117 | - { | |
118 | - String json = JsonUtil.obj2Str(data); | |
119 | - System.out.println(json); | |
120 | - String result = HttpClientUtil.doPostSSL(properties.getUrl() + "/saveMicroelement", json); | |
121 | - System.out.println("http result= "+result); | |
122 | - return result; | |
123 | - } | |
124 | - return ""; | |
125 | - } | |
126 | - | |
127 | -} |
platform-transfer/src/main/java/com/lyms/platform/worker/TransferAbstract.java
View file @
2c95b36
1 | +package com.lyms.platform.worker; | |
2 | + | |
3 | +import com.lyms.platform.comm.HttpClientUtil; | |
4 | +import com.lyms.platform.comm.JsonUtil; | |
5 | + | |
6 | +import java.util.Map; | |
7 | + | |
8 | +/** | |
9 | + * Created by Administrator on 2020-03-23. | |
10 | + */ | |
11 | +public abstract class TransferAbstract implements ITransfer { | |
12 | + | |
13 | + public abstract void doTransfer(); | |
14 | + | |
15 | + @Override | |
16 | + public String send(Map<String,Object> data,String path) { | |
17 | + if (data != null && data.size() > 0) | |
18 | + { | |
19 | + String json = JsonUtil.obj2Str(data); | |
20 | + System.out.println(json); | |
21 | + String result = HttpClientUtil.doPostSSL(path, json); | |
22 | + System.out.println("http result= "+result); | |
23 | + return result; | |
24 | + } | |
25 | + return ""; | |
26 | + } | |
27 | +} |
platform-transfer/src/main/java/com/lyms/platform/worker/TransferWorker.java
View file @
2c95b36
1 | +package com.lyms.platform.worker; | |
2 | + | |
3 | +import org.springframework.beans.factory.annotation.Autowired; | |
4 | +import org.springframework.scheduling.annotation.EnableScheduling; | |
5 | +import org.springframework.scheduling.annotation.Scheduled; | |
6 | +import org.springframework.stereotype.Component; | |
7 | + | |
8 | +/** | |
9 | + * Created by Administrator on 2020-03-23. | |
10 | + */ | |
11 | +@Component | |
12 | +@EnableScheduling | |
13 | +public class TransferWorker extends TransferAbstract implements ITransfer { | |
14 | + | |
15 | + @Autowired | |
16 | + private BoneTransferWorker boneTransferWorker; | |
17 | + | |
18 | + @Autowired | |
19 | + private MicroelementTransferWorker microelementTransferWorker; | |
20 | + | |
21 | + @Override | |
22 | + @Scheduled(cron = "0 0/1 * * * ?") | |
23 | + public void doTransfer() { | |
24 | + boneTransferWorker.doTransfer(); | |
25 | + } | |
26 | + | |
27 | + | |
28 | +} |
platform-transfer/src/main/resources/application.yml
View file @
2c95b36
... | ... | @@ -3,10 +3,8 @@ |
3 | 3 | |
4 | 4 | |
5 | 5 | param: |
6 | - #微量元素access路径 | |
7 | - microelement-path: D://tc.mdb | |
8 | - #骨密度access数据库路径 | |
9 | - bone-path: D://EK-8800181001-net_Plus//System//Patient.mdb | |
6 | + #access数据库路径 | |
7 | + data-path: D://EK-8800181001-net_Plus//System//Patient.mdb | |
10 | 8 | #区域url地址 |
11 | 9 | url: https://dev-rp-api.healthbaby.com.cn |
12 | 10 | type: 0 # 0孕妇 1儿童 |