Commit 745906869d4fc32d64e4086a755df7cc5ae6b662

Authored by liquanyu
1 parent 0948c36eb1

update

Showing 2 changed files with 75 additions and 84 deletions

platform-transfer/src/main/java/com/lyms/platform/worker/BoneTransferWorker.java View file @ 7459068
... ... @@ -2,12 +2,12 @@
2 2  
3 3 import com.lyms.platform.comm.ApplicationProperties;
4 4 import com.lyms.platform.comm.StringUtils;
  5 +import com.lyms.platform.conn.BoneConnectionFactory;
  6 +import com.lyms.platform.conn.inf.ConnectionFactoryMethod;
5 7 import com.lyms.platform.conn.inf.IConnection;
6   -import org.apache.commons.httpclient.util.DateUtil;
7 8 import org.slf4j.Logger;
8 9 import org.slf4j.LoggerFactory;
9 10 import org.springframework.beans.factory.annotation.Autowired;
10   -import org.springframework.context.annotation.Scope;
11 11 import org.springframework.stereotype.Component;
12 12  
13 13 import java.sql.*;
14 14  
15 15  
16 16  
17 17  
18 18  
19 19  
20 20  
21 21  
22 22  
23 23  
24 24  
25 25  
26 26  
27 27  
28 28  
29 29  
30 30  
31 31  
... ... @@ -19,99 +19,96 @@
19 19 * 骨密度
20 20 */
21 21 @Component
22   -@Scope("singleton")
23 22 public class BoneTransferWorker extends TransferAbstract implements ITransfer{
24 23 private static final Logger logger = LoggerFactory.getLogger(BoneTransferWorker.class);
25 24 @Autowired
26 25 private ApplicationProperties properties;
27 26  
28   -
29   -
30   - public Connection getConnection()
31   - {
32   - Connection conn = null;
33   - try {
34   - Class.forName("com.hxtt.sql.access.AccessDriver");
35   - String url = "jdbc:Access:///"+properties.getDataPath();
36   - conn = DriverManager.getConnection(url, "", "");
37   - } catch (Exception e) {
38   - logger.error("getConnection error.",e);
39   - }
40   - return conn;
41   - }
42   -
43   -
44 27 @Override
45 28 public void doTransfer() {
46   - while (true)
47   - {
  29 +
48 30 logger.info("getBoneRecords start");
49 31 Connection conn = null;
50 32 Statement sta = null;
51 33 ResultSet rst = null;
52   - IConnection iConnection = null;
  34 + ConnectionFactoryMethod factoryMethod = new BoneConnectionFactory();
  35 + IConnection iConnection = factoryMethod.createConnection(properties.getDataPath());
53 36 try {
54   - conn = getConnection();
  37 + conn = iConnection.getConnection();
55 38 sta = conn.createStatement();
56   - String sql = "select PatientID,ZScore,TScore,dbSos,dbBqi,dbRrf,dbEoa,YoungAdult,ageMatched,dbAge,PartDisplayName,PatientName from PatientInfo where status is null and DayTimeOfSave > "+ DateUtil.formatDate(new Date(),"yyyy-MM-dd");
  39 + String sql = "select PatientID,ZScore,TScore,dbSos,dbBqi,dbRrf,dbEoa,YoungAdult,ageMatched,dbAge,PartDisplayName,PatientName from PatientInfo where status is null ";
57 40 rst = sta.executeQuery(sql);
58   - if (!rst.isClosed())
59   - {
60   - while (rst.next()) {
61   - Map map = new HashMap();
62   - String PatientID = rst.getString("PatientID"); //身份证后八位
63   - map.put("cardNo",PatientID);
  41 + while (rst.next()) {
  42 + Map map = new HashMap();
  43 + String PatientID = rst.getString("PatientID"); //身份证后八位
  44 + map.put("cardNo",PatientID);
64 45  
65   - String PartDisplayName = rst.getString("PartDisplayName");
66   - map.put("position",PartDisplayName);
  46 + String PartDisplayName = rst.getString("PartDisplayName");
  47 + map.put("position",PartDisplayName);
67 48  
68   - String PatientName = rst.getString("PatientName"); //孕妇姓名
69   - map.put("username",PatientName);
  49 + String PatientName = rst.getString("PatientName"); //孕妇姓名
  50 + map.put("username",PatientName);
70 51  
71   - String ZScore = rst.getString("ZScore");
72   - String TScore = rst.getString("TScore");
73   - String dbSos = rst.getString("dbSos");
  52 + String ZScore = rst.getString("ZScore");
  53 + String TScore = rst.getString("TScore");
  54 + String dbSos = rst.getString("dbSos");
74 55  
75   - String bqi = rst.getString("dbBqi");
76   - String rrf = rst.getString("dbRrf");
77   - String eoa = rst.getString("dbEoa");
  56 + String bqi = rst.getString("dbBqi");
  57 + String rrf = rst.getString("dbRrf");
  58 + String eoa = rst.getString("dbEoa");
78 59  
79   - String adultPercent = rst.getString("YoungAdult");
80   - String agePercent = rst.getString("ageMatched");
81   - String age = rst.getString("dbAge");
  60 + String adultPercent = rst.getString("YoungAdult");
  61 + String agePercent = rst.getString("ageMatched");
  62 + String age = rst.getString("dbAge");
82 63  
83   - map.put("zvalue",ZScore);
84   - map.put("tvalue",TScore);
85   - map.put("sos",dbSos);
  64 + map.put("zvalue",ZScore);
  65 + map.put("tvalue",TScore);
  66 + map.put("sos",dbSos);
86 67  
87   - map.put("bqi",bqi);
88   - map.put("rrf",rrf);
89   - map.put("eoa",eoa);
  68 + map.put("bqi",bqi);
  69 + map.put("rrf",rrf);
  70 + map.put("eoa",eoa);
90 71  
91   - map.put("adultPercent",adultPercent);
92   - map.put("agePercent",agePercent);
93   - map.put("age",age);
94   - map.put("type",properties.getType()); //
95   - map.put("hospitalId",properties.getHospitalId()); //
  72 + map.put("adultPercent",adultPercent);
  73 + map.put("agePercent",agePercent);
  74 + map.put("age",age);
  75 + map.put("type",properties.getType()); //
  76 + map.put("hospitalId",properties.getHospitalId()); //
  77 + exeUpdate( map, PatientID);
96 78  
97   - if (map.size() > 0 && StringUtils.isNotEmpty(PatientID))
98   - {
99   - String response = send(map, properties.getUrl() + "/saveBone");
100   - if (response.contains("0"))
101   - {
102   - sta.executeUpdate("update PatientInfo set status='1' where PatientID='" + PatientID + "'");
103   - conn.commit();
104   - }
105   - }
106   - }
107   - Thread.sleep(30000);
108 79 }
  80 + Thread.sleep(5000);
109 81 } catch (Exception e) {
110   - logger.error("getBoneRecords Exception. ",e);
  82 + logger.error("getBoneRecords Exception. ",e);
111 83 }
112 84 finally {
113 85 iConnection.close(conn, sta,rst);
114 86 }
  87 + }
  88 +
  89 +
  90 + public void exeUpdate(Map map,String PatientID)
  91 + {
  92 + Connection conn = null;
  93 + Statement sta = null;
  94 + ConnectionFactoryMethod factoryMethod = new BoneConnectionFactory();
  95 + IConnection iConnection = factoryMethod.createConnection(properties.getDataPath());
  96 + try {
  97 + conn = iConnection.getConnection();
  98 + sta = conn.createStatement();
  99 + if (map.size() > 0 && StringUtils.isNotEmpty(PatientID)) {
  100 + String response = send(map, properties.getUrl() + "/saveBone");
  101 + if (response.contains("0")) {
  102 + sta.executeUpdate("update PatientInfo set status='1' where PatientID='" + PatientID + "'");
  103 + }
  104 + }
  105 + }
  106 + catch (Exception e)
  107 + {
  108 + logger.error("exeUpdate Exception. ",e);
  109 + }
  110 + finally {
  111 + iConnection.close(conn, sta,null);
115 112 }
116 113 }
117 114 }
platform-transfer/src/main/java/com/lyms/platform/worker/TransferWorker.java View file @ 7459068
1 1 package com.lyms.platform.worker;
2 2  
3   -import org.springframework.beans.factory.InitializingBean;
4 3 import org.springframework.beans.factory.annotation.Autowired;
5   -import org.springframework.scheduling.annotation.EnableScheduling;
6 4 import org.springframework.scheduling.annotation.Scheduled;
7 5 import org.springframework.stereotype.Component;
8 6  
9 7  
10 8  
11 9  
... ... @@ -10,20 +8,16 @@
10 8 * Created by Administrator on 2020-03-23.
11 9 */
12 10 @Component
13   -public class TransferWorker extends TransferAbstract implements ITransfer,InitializingBean {
  11 +public class TransferWorker extends TransferAbstract implements ITransfer {
14 12  
15 13 @Autowired
16 14 private BoneTransferWorker boneTransferWorker;
17 15  
18 16 @Override
19   -// @Scheduled(cron = "0 0/1 * * * ?",fixedDelay = 10000)
  17 + @Scheduled(cron = "0 0/1 * * * ?")
20 18 public void doTransfer() {
21   -
22   - }
23   -
24   - @Override
25   - public void afterPropertiesSet() throws Exception {
26 19 boneTransferWorker.doTransfer();
27 20 }
  21 +
28 22 }