Commit 18a3086255dc6e73a88b1b38ba0ad4f95c50613f

Authored by liquanyu
1 parent 8571949915

update code

Showing 4 changed files with 319 additions and 31 deletions

platform-dal/src/main/java/com/lyms/platform/pojo/MeasureInfoModel.java View file @ 18a3086
  1 +package com.lyms.platform.pojo;
  2 +
  3 +import org.springframework.data.mongodb.core.mapping.Document;
  4 +
  5 +import java.util.Date;
  6 +
  7 +/**
  8 + * Created by Administrator on 2018-01-09.
  9 + * 测量血糖和脉搏、身高和体重的值
  10 + */
  11 +@Document(collection = "lyms_measureInfo")
  12 +public class MeasureInfoModel {
  13 +
  14 + private Integer id;
  15 + //用户姓名
  16 + private String userName;
  17 + //证件类型
  18 + private String certType;
  19 + //证件号
  20 + private String certNo;
  21 + //性别
  22 + private Integer sex;
  23 + //就诊卡号
  24 + private String vcCardNo;
  25 + //血压/体重
  26 + private String valueOne;
  27 + //脉搏/身高
  28 + private String valueTwo;
  29 + //值类型: 1 身高、体重 2 血压和脉搏
  30 + private Integer valueType;
  31 + //记录时间
  32 + private Date recordTime;
  33 + //微信号
  34 + private String wxXode;
  35 + //记录总次数
  36 + private Integer recordCount;
  37 + //openId
  38 + private String openId;
  39 + //创建时间
  40 + private Date created;
  41 + //修改时间
  42 + private Date modified;
  43 +
  44 + public Integer getId() {
  45 + return id;
  46 + }
  47 +
  48 + public void setId(Integer id) {
  49 + this.id = id;
  50 + }
  51 +
  52 + public String getUserName() {
  53 + return userName;
  54 + }
  55 +
  56 + public void setUserName(String userName) {
  57 + this.userName = userName;
  58 + }
  59 +
  60 + public String getCertType() {
  61 + return certType;
  62 + }
  63 +
  64 + public void setCertType(String certType) {
  65 + this.certType = certType;
  66 + }
  67 +
  68 + public String getCertNo() {
  69 + return certNo;
  70 + }
  71 +
  72 + public void setCertNo(String certNo) {
  73 + this.certNo = certNo;
  74 + }
  75 +
  76 + public Integer getSex() {
  77 + return sex;
  78 + }
  79 +
  80 + public void setSex(Integer sex) {
  81 + this.sex = sex;
  82 + }
  83 +
  84 + public String getVcCardNo() {
  85 + return vcCardNo;
  86 + }
  87 +
  88 + public void setVcCardNo(String vcCardNo) {
  89 + this.vcCardNo = vcCardNo;
  90 + }
  91 +
  92 + public String getValueOne() {
  93 + return valueOne;
  94 + }
  95 +
  96 + public void setValueOne(String valueOne) {
  97 + this.valueOne = valueOne;
  98 + }
  99 +
  100 + public String getValueTwo() {
  101 + return valueTwo;
  102 + }
  103 +
  104 + public void setValueTwo(String valueTwo) {
  105 + this.valueTwo = valueTwo;
  106 + }
  107 +
  108 + public Integer getValueType() {
  109 + return valueType;
  110 + }
  111 +
  112 + public void setValueType(Integer valueType) {
  113 + this.valueType = valueType;
  114 + }
  115 +
  116 + public Date getRecordTime() {
  117 + return recordTime;
  118 + }
  119 +
  120 + public void setRecordTime(Date recordTime) {
  121 + this.recordTime = recordTime;
  122 + }
  123 +
  124 + public String getWxXode() {
  125 + return wxXode;
  126 + }
  127 +
  128 + public void setWxXode(String wxXode) {
  129 + this.wxXode = wxXode;
  130 + }
  131 +
  132 + public Integer getRecordCount() {
  133 + return recordCount;
  134 + }
  135 +
  136 + public void setRecordCount(Integer recordCount) {
  137 + this.recordCount = recordCount;
  138 + }
  139 +
  140 + public String getOpenId() {
  141 + return openId;
  142 + }
  143 +
  144 + public void setOpenId(String openId) {
  145 + this.openId = openId;
  146 + }
  147 +
  148 + public Date getCreated() {
  149 + return created;
  150 + }
  151 +
  152 + public void setCreated(Date created) {
  153 + this.created = created;
  154 + }
  155 +
  156 + public Date getModified() {
  157 + return modified;
  158 + }
  159 +
  160 + public void setModified(Date modified) {
  161 + this.modified = modified;
  162 + }
  163 +}
platform-dal/src/main/java/com/lyms/platform/query/MeasureInfoQuery.java View file @ 18a3086
  1 +package com.lyms.platform.query;
  2 +
  3 +
  4 +import com.lyms.platform.common.base.IConvertToNativeQuery;
  5 +import com.lyms.platform.common.dao.BaseQuery;
  6 +import com.lyms.platform.common.dao.operator.MongoCondition;
  7 +import com.lyms.platform.common.dao.operator.MongoOper;
  8 +import com.lyms.platform.common.dao.operator.MongoQuery;
  9 +import org.springframework.data.mongodb.core.query.Criteria;
  10 +
  11 +import java.util.Date;
  12 +
  13 +/**
  14 + * Created by Administrator on 2018-01-09.
  15 + * 测量血糖和脉搏、身高和体重的值
  16 + */
  17 +public class MeasureInfoQuery extends BaseQuery implements IConvertToNativeQuery {
  18 +
  19 + private Integer id;
  20 + //用户姓名
  21 + private String userName;
  22 + //证件类型
  23 + private String certType;
  24 + //证件号
  25 + private String certNo;
  26 + //性别
  27 + private Integer sex;
  28 + //就诊卡号
  29 + private String vcCardNo;
  30 + //血压/体重
  31 + private String valueOne;
  32 +
  33 + //手机号码
  34 + private String phone;
  35 +
  36 + //脉搏/身高
  37 + private String valueTwo;
  38 + //值类型: 1 身高、体重 2 血压和脉搏
  39 + private Integer valueType;
  40 + //记录时间
  41 + private Date recordTimeStart;
  42 + private Date recordTimeEnd;
  43 + //微信号
  44 + private String wxCode;
  45 + //记录总次数
  46 + private Integer recordCount;
  47 + //openId
  48 + private String openId;
  49 + //创建时间
  50 + private Date created;
  51 + //修改时间
  52 + private Date modified;
  53 +
  54 + @Override
  55 + public MongoQuery convertToQuery() {
  56 + MongoCondition condition = MongoCondition.newInstance();
  57 + if (null != id) {
  58 + condition = condition.and("id", id, MongoOper.IS);
  59 + }
  60 +
  61 + if (null != userName) {
  62 + condition = condition.and("userName", userName, MongoOper.IS);
  63 + }
  64 +
  65 + if (null != certType) {
  66 + condition = condition.and("certType", certType, MongoOper.IS);
  67 + }
  68 +
  69 + if (null != certNo) {
  70 + condition = condition.and("certNo", certNo, MongoOper.IS);
  71 + }
  72 +
  73 +
  74 + if (null != sex) {
  75 + condition = condition.and("sex", sex, MongoOper.IS);
  76 + }
  77 +
  78 +
  79 + if (null != vcCardNo) {
  80 + condition = condition.and("vcCardNo", vcCardNo, MongoOper.IS);
  81 + }
  82 +
  83 + if (null != valueType) {
  84 + condition = condition.and("valueType", valueType, MongoOper.IS);
  85 + }
  86 +
  87 +
  88 + if (null != wxCode) {
  89 + condition = condition.and("wxCode", wxCode, MongoOper.IS);
  90 + }
  91 +
  92 + if (null != phone) {
  93 + condition = condition.and("phone", phone, MongoOper.IS);
  94 + }
  95 +
  96 +
  97 +
  98 + Criteria c1 = null;
  99 + if (null != recordTimeStart) {
  100 + if (null != c1) {
  101 + c1 = c1.and("recordTime").gte(recordTimeStart);
  102 + } else {
  103 + c1 = Criteria.where("recordTime").gte(recordTimeStart);
  104 + }
  105 + }
  106 + if (null != recordTimeEnd) {
  107 + if (c1 != null) {
  108 + c1 = c1.lte(recordTimeEnd);
  109 + } else {
  110 + c1 = Criteria.where("recordTime").lte(recordTimeEnd);
  111 + }
  112 + }
  113 +
  114 + if (null != c1) {
  115 + condition = condition.andCondition(new MongoCondition(c1));
  116 + }
  117 + return condition.toMongoQuery();
  118 + }
  119 +
  120 +
  121 +
  122 + public Integer getId() {
  123 + return id;
  124 + }
  125 +
  126 + public void setId(Integer id) {
  127 + this.id = id;
  128 + }
  129 +
  130 +
  131 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java View file @ 18a3086
... ... @@ -138,35 +138,21 @@
138 138 {
139 139 List<SyncDataModel> list = JsonUtil.toList(json, SyncDataModel.class);
140 140 System.out.println(DateUtil.getyyyy_MM_dd_hms(new Date())+url+" ; syncdata size = "+ list.size());
141   - int batchSize = 200;
142   - int end = 0;
143   - for (int i = 0; i < list.size(); i += batchSize) {
144   - end = (end + batchSize);
145   - if (end > list.size()) {
146   - end = list.size();
147   - }
148   - final List<SyncDataModel> tempList = list.subList(i, end);
149   - commonThreadPool.execute(new Runnable() {
150   - @Override
151   - public void run() {
152   - if (CollectionUtils.isNotEmpty(tempList))
153   - {
154   - StringBuffer ids = new StringBuffer();
155   - for (SyncDataModel model : tempList) {
156   - boolean boo = mongoSyncService.syncData(model.getAction(), model.getDataId(), model.getClassName(), model.getJsonData());
157   - if (boo) {
158   - ids.append(model.getId());
159   - ids.append(",");
160   - }
161   - }
162   - if (ids.length() > 0) {
163   - Map<String,String> params = new HashMap<String, String>();
164   - params.put("ids", ids.toString());
165   - excePost("https://" + url + "/updateSyncData", params);
166   - }
167   - }
  141 + if (CollectionUtils.isNotEmpty(list))
  142 + {
  143 + StringBuffer ids = new StringBuffer();
  144 + for (SyncDataModel model : list) {
  145 + boolean boo = mongoSyncService.syncData(model.getAction(), model.getDataId(), model.getClassName(), model.getJsonData());
  146 + if (boo) {
  147 + ids.append(model.getId());
  148 + ids.append(",");
168 149 }
169   - });
  150 + }
  151 + if (ids.length() > 0) {
  152 + Map<String,String> params = new HashMap<String, String>();
  153 + params.put("ids", ids.toString());
  154 + excePost("https://" + url + "/updateSyncData", params);
  155 + }
170 156 }
171 157 }
172 158 }catch(Exception ex){
... ... @@ -176,7 +162,7 @@
176 162 }
177 163  
178 164  
179   - private synchronized String excePost(String url,Map<String,String> param)
  165 + private String excePost(String url,Map<String,String> param)
180 166 {
181 167 String json = HttpClientUtil.doPost(url, param, "utf-8");
182 168 return json;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/HttpClientUtil.java View file @ 18a3086
... ... @@ -59,6 +59,7 @@
59 59 HttpClient httpClient = null;
60 60 HttpPost httpPost = null;
61 61 String result = null;
  62 + HttpResponse response = null;
62 63 try{
63 64 httpClient = new SSLClient();
64 65  
... ... @@ -75,7 +76,7 @@
75 76 UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list,charset);
76 77 httpPost.setEntity(entity);
77 78 }
78   - HttpResponse response = httpClient.execute(httpPost);
  79 + response = httpClient.execute(httpPost);
79 80 if(response != null){
80 81 HttpEntity resEntity = response.getEntity();
81 82 if(resEntity != null){
82 83  
... ... @@ -87,9 +88,16 @@
87 88 return null;
88 89 }
89 90 finally {
  91 + if (response != null) {
  92 + try {
  93 + EntityUtils.consume(response.getEntity());
  94 + } catch (IOException e) {
  95 + e.printStackTrace();
  96 + }
  97 + }
90 98 if (httpPost != null)
91 99 {
92   - httpPost.reset();
  100 + httpPost.releaseConnection();
93 101 }
94 102  
95 103 }