Commit 6fe6161eb91097970fd3e7f79f7eeaddbb98d078

Authored by liquanyu
1 parent 6c5fd3218f

update code

Showing 8 changed files with 397 additions and 27 deletions

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IMeasureInfoDao.java View file @ 6fe6161
  1 +package com.lyms.platform.biz.dal;
  2 +
  3 +import com.lyms.platform.common.dao.operator.MongoQuery;
  4 +import com.lyms.platform.pojo.MeasureInfoModel;
  5 +
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * Created by Administrator on 2018-01-10.
  10 + */
  11 +public interface IMeasureInfoDao {
  12 + List<MeasureInfoModel> queryMeasureInfoList(MongoQuery query);
  13 +
  14 + int queryMeasureInfoListCount(MongoQuery mongoQuery);
  15 +}
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/MeasureInfoDao.java View file @ 6fe6161
  1 +package com.lyms.platform.biz.dal.impl;
  2 +
  3 +import com.lyms.platform.biz.dal.IMeasureInfoDao;
  4 +import com.lyms.platform.common.dao.BaseMongoDAOImpl;
  5 +import com.lyms.platform.common.dao.operator.MongoQuery;
  6 +import com.lyms.platform.pojo.MeasureInfoModel;
  7 +import org.springframework.stereotype.Repository;
  8 +
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * Created by Administrator on 2018-01-10.
  13 + */
  14 +@Repository("measureInfoDao")
  15 +public class MeasureInfoDao extends BaseMongoDAOImpl<MeasureInfoModel> implements IMeasureInfoDao {
  16 + @Override
  17 + public List<MeasureInfoModel> queryMeasureInfoList(MongoQuery query) {
  18 + return find(query.convertToMongoQuery());
  19 + }
  20 +
  21 + @Override
  22 + public int queryMeasureInfoListCount(MongoQuery mongoQuery) {
  23 + return (int)count(mongoQuery.convertToMongoQuery());
  24 + }
  25 +}
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/MeasureInfoService.java View file @ 6fe6161
  1 +package com.lyms.platform.biz.service;
  2 +
  3 +import com.lyms.platform.biz.dal.IMatDeliverDao;
  4 +import com.lyms.platform.biz.dal.IMeasureInfoDao;
  5 +import com.lyms.platform.common.dao.operator.MongoQuery;
  6 +import com.lyms.platform.pojo.MeasureInfoModel;
  7 +import com.lyms.platform.query.MeasureInfoQuery;
  8 +import org.apache.commons.lang.StringUtils;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.data.domain.Sort;
  11 +import org.springframework.stereotype.Service;
  12 +
  13 +import java.util.List;
  14 +
  15 +/**
  16 + * Created by Administrator on 2018-01-10.
  17 + */
  18 +@Service
  19 +public class MeasureInfoService {
  20 +
  21 + @Autowired
  22 + private IMeasureInfoDao measureInfoDao;
  23 +
  24 + public List<MeasureInfoModel> queryMeasureInfoList(MeasureInfoQuery measureInfoQuery) {
  25 +
  26 + MongoQuery query = measureInfoQuery.convertToQuery();
  27 + if (StringUtils.isNotEmpty(measureInfoQuery.getNeed())) {
  28 + measureInfoQuery.mysqlBuild(measureInfoDao.queryMeasureInfoListCount(measureInfoQuery.convertToQuery()));
  29 + query.start(measureInfoQuery.getOffset()).end(measureInfoQuery.getLimit());
  30 + }
  31 + return measureInfoDao.queryMeasureInfoList(query.addOrder(Sort.Direction.DESC, "created"));
  32 + }
  33 +}
platform-dal/src/main/java/com/lyms/platform/pojo/MeasureInfoModel.java View file @ 6fe6161
... ... @@ -41,6 +41,17 @@
41 41 //ไฟฎๆ”นๆ—ถ้—ด
42 42 private Date modified;
43 43  
  44 + //ๅŒป้™ขid
  45 + private String hospitalId;
  46 +
  47 + public String getHospitalId() {
  48 + return hospitalId;
  49 + }
  50 +
  51 + public void setHospitalId(String hospitalId) {
  52 + this.hospitalId = hospitalId;
  53 + }
  54 +
44 55 public Integer getId() {
45 56 return id;
46 57 }
platform-dal/src/main/java/com/lyms/platform/query/MeasureInfoQuery.java View file @ 6fe6161
... ... @@ -33,6 +33,9 @@
33 33 //ๆ‰‹ๆœบๅท็ 
34 34 private String phone;
35 35  
  36 + //ๅนด้พ„
  37 + private Integer age;
  38 +
36 39 //่„‰ๆ/่บซ้ซ˜
37 40 private String valueTwo;
38 41 //ๅ€ผ็ฑปๅž‹๏ผš 1 ่บซ้ซ˜ใ€ไฝ“้‡ 2 ่ก€ๅŽ‹ๅ’Œ่„‰ๆ
... ... @@ -51,6 +54,9 @@
51 54 //ไฟฎๆ”นๆ—ถ้—ด
52 55 private Date modified;
53 56  
  57 + private String queryNo;
  58 + private String hospitalId;
  59 +
54 60 @Override
55 61 public MongoQuery convertToQuery() {
56 62 MongoCondition condition = MongoCondition.newInstance();
... ... @@ -74,6 +80,9 @@
74 80 if (null != sex) {
75 81 condition = condition.and("sex", sex, MongoOper.IS);
76 82 }
  83 + if (null != hospitalId) {
  84 + condition = condition.and("hospitalId", hospitalId, MongoOper.IS);
  85 + }
77 86  
78 87  
79 88 if (null != vcCardNo) {
80 89  
... ... @@ -92,10 +101,23 @@
92 101 if (null != phone) {
93 102 condition = condition.and("phone", phone, MongoOper.IS);
94 103 }
95   -
96   -
97   -
  104 + if (null != age) {
  105 + condition = condition.and("age", age, MongoOper.IS);
  106 + }
98 107 Criteria c1 = null;
  108 + if (null != queryNo) {
  109 + MongoCondition c = MongoCondition.newInstance();
  110 + MongoCondition con1 = MongoCondition.newInstance("phone", queryNo, MongoOper.IS);
  111 + MongoCondition con2 = MongoCondition.newInstance("username", "^" + queryNo, MongoOper.LIKE);
  112 + MongoCondition con3 = MongoCondition.newInstance("certNo", certNo, MongoOper.IS);
  113 + MongoCondition con4 = MongoCondition.newInstance("vcCardNo", queryNo, MongoOper.IS);
  114 + if(c1!=null) {
  115 + c1 = c1.andOperator(c.orCondition(new MongoCondition[]{con1, con2, con3, con4}).getCriteria());
  116 + }else {
  117 + c1 = c.orCondition(new MongoCondition[]{con1, con2, con3, con4}).getCriteria();
  118 + }
  119 + }
  120 +
99 121 if (null != recordTimeStart) {
100 122 if (null != c1) {
101 123 c1 = c1.and("recordTime").gte(recordTimeStart);
102 124  
... ... @@ -117,7 +139,157 @@
117 139 return condition.toMongoQuery();
118 140 }
119 141  
  142 + public String getHospitalId() {
  143 + return hospitalId;
  144 + }
120 145  
  146 + public void setHospitalId(String hospitalId) {
  147 + this.hospitalId = hospitalId;
  148 + }
  149 +
  150 + public Integer getAge() {
  151 + return age;
  152 + }
  153 +
  154 + public void setAge(Integer age) {
  155 + this.age = age;
  156 + }
  157 +
  158 + public String getUserName() {
  159 + return userName;
  160 + }
  161 +
  162 + public void setUserName(String userName) {
  163 + this.userName = userName;
  164 + }
  165 +
  166 + public String getCertType() {
  167 + return certType;
  168 + }
  169 +
  170 + public void setCertType(String certType) {
  171 + this.certType = certType;
  172 + }
  173 +
  174 + public String getCertNo() {
  175 + return certNo;
  176 + }
  177 +
  178 + public void setCertNo(String certNo) {
  179 + this.certNo = certNo;
  180 + }
  181 +
  182 + public Integer getSex() {
  183 + return sex;
  184 + }
  185 +
  186 + public void setSex(Integer sex) {
  187 + this.sex = sex;
  188 + }
  189 +
  190 + public String getVcCardNo() {
  191 + return vcCardNo;
  192 + }
  193 +
  194 + public void setVcCardNo(String vcCardNo) {
  195 + this.vcCardNo = vcCardNo;
  196 + }
  197 +
  198 + public String getValueOne() {
  199 + return valueOne;
  200 + }
  201 +
  202 + public void setValueOne(String valueOne) {
  203 + this.valueOne = valueOne;
  204 + }
  205 +
  206 + public String getPhone() {
  207 + return phone;
  208 + }
  209 +
  210 + public void setPhone(String phone) {
  211 + this.phone = phone;
  212 + }
  213 +
  214 + public String getValueTwo() {
  215 + return valueTwo;
  216 + }
  217 +
  218 + public void setValueTwo(String valueTwo) {
  219 + this.valueTwo = valueTwo;
  220 + }
  221 +
  222 + public Integer getValueType() {
  223 + return valueType;
  224 + }
  225 +
  226 + public void setValueType(Integer valueType) {
  227 + this.valueType = valueType;
  228 + }
  229 +
  230 + public Date getRecordTimeStart() {
  231 + return recordTimeStart;
  232 + }
  233 +
  234 + public void setRecordTimeStart(Date recordTimeStart) {
  235 + this.recordTimeStart = recordTimeStart;
  236 + }
  237 +
  238 + public Date getRecordTimeEnd() {
  239 + return recordTimeEnd;
  240 + }
  241 +
  242 + public void setRecordTimeEnd(Date recordTimeEnd) {
  243 + this.recordTimeEnd = recordTimeEnd;
  244 + }
  245 +
  246 + public String getWxCode() {
  247 + return wxCode;
  248 + }
  249 +
  250 + public void setWxCode(String wxCode) {
  251 + this.wxCode = wxCode;
  252 + }
  253 +
  254 + public Integer getRecordCount() {
  255 + return recordCount;
  256 + }
  257 +
  258 + public void setRecordCount(Integer recordCount) {
  259 + this.recordCount = recordCount;
  260 + }
  261 +
  262 + public String getOpenId() {
  263 + return openId;
  264 + }
  265 +
  266 + public void setOpenId(String openId) {
  267 + this.openId = openId;
  268 + }
  269 +
  270 + public Date getCreated() {
  271 + return created;
  272 + }
  273 +
  274 + public void setCreated(Date created) {
  275 + this.created = created;
  276 + }
  277 +
  278 + public Date getModified() {
  279 + return modified;
  280 + }
  281 +
  282 + public void setModified(Date modified) {
  283 + this.modified = modified;
  284 + }
  285 +
  286 + public String getQueryNo() {
  287 + return queryNo;
  288 + }
  289 +
  290 + public void setQueryNo(String queryNo) {
  291 + this.queryNo = queryNo;
  292 + }
121 293  
122 294 public Integer getId() {
123 295 return id;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MeasureInfoController.java View file @ 6fe6161
  1 +package com.lyms.platform.operate.web.controller;
  2 +
  3 +import com.lyms.platform.common.annotation.TokenRequired;
  4 +import com.lyms.platform.common.base.BaseController;
  5 +import com.lyms.platform.common.result.BaseListResponse;
  6 +import com.lyms.platform.operate.web.facade.MeasureInfoFacade;
  7 +import com.lyms.platform.operate.web.request.SmsTemplateRequest;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Controller;
  10 +import org.springframework.web.bind.annotation.RequestMapping;
  11 +import org.springframework.web.bind.annotation.RequestMethod;
  12 +import org.springframework.web.bind.annotation.RequestParam;
  13 +import org.springframework.web.bind.annotation.ResponseBody;
  14 +
  15 +/**
  16 + * ๆต‹้‡่ก€็ณ–ๅ’Œ่„‰ๆใ€่บซ้ซ˜ๅ’Œไฝ“้‡็š„ๅ€ผ
  17 + *
  18 + * Created by Administrator on 2018-01-10.
  19 + */
  20 +@Controller
  21 +public class MeasureInfoController extends BaseController {
  22 +
  23 + @Autowired
  24 + private MeasureInfoFacade measureInfoFacade;
  25 + /**
  26 + * ่ก€็ณ–ๅ’Œ่„‰ๆ ่บซ้ซ˜ๅ’Œไฝ“้‡็š„ๅ€ผๅˆ—่กจ
  27 + * valueType ๅ€ผ็ฑปๅž‹๏ผš 1 ่บซ้ซ˜ใ€ไฝ“้‡ 2 ่ก€ๅŽ‹ๅ’Œ่„‰ๆ
  28 + * @return
  29 + */
  30 + @RequestMapping(method = RequestMethod.GET, value = "/queryMeasureInfoList")
  31 + @ResponseBody
  32 + @TokenRequired
  33 + public BaseListResponse querySmsTemps(@RequestParam(value = "queryNo", required = false) String queryNo,
  34 + @RequestParam("page") Integer page,
  35 + @RequestParam("limit") Integer limit,
  36 + @RequestParam("valueType") Integer valueType,
  37 + @RequestParam(value = "certNo", required = false) String certNo,
  38 + @RequestParam(value = "recordTime", required = false) String recordTime,
  39 + @RequestParam(value = "age", required = false) Integer age
  40 + ) {
  41 + return measureInfoFacade.queryMeasureInfoList(queryNo,valueType,certNo,recordTime,age,page,limit);
  42 + }
  43 +
  44 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MeasureInfoFacade.java View file @ 6fe6161
  1 +package com.lyms.platform.operate.web.facade;
  2 +
  3 +import com.lyms.platform.biz.service.MatDeliverService;
  4 +import com.lyms.platform.biz.service.MeasureInfoService;
  5 +import com.lyms.platform.common.constants.ErrorCodeConstants;
  6 +import com.lyms.platform.common.result.BaseListResponse;
  7 +import com.lyms.platform.common.utils.DateUtil;
  8 +import com.lyms.platform.pojo.MeasureInfoModel;
  9 +import com.lyms.platform.query.MeasureInfoQuery;
  10 +import org.apache.commons.lang.StringUtils;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +import java.util.List;
  15 +
  16 +/**
  17 + * Created by Administrator on 2018-01-10.
  18 + */
  19 +@Component
  20 +public class MeasureInfoFacade {
  21 + @Autowired
  22 + private MeasureInfoService measureInfoService;
  23 +
  24 +
  25 + public BaseListResponse queryMeasureInfoList(String queryNo,
  26 + Integer valueType, String certNo,
  27 + String recordTime, Integer age,
  28 + Integer page, Integer limit) {
  29 +
  30 + MeasureInfoQuery query = new MeasureInfoQuery();
  31 + query.setQueryNo(queryNo);
  32 + query.setValueType(valueType);
  33 + query.setLimit(limit);
  34 + query.setPage(page);
  35 + query.setAge(age);
  36 + query.setCertNo(certNo);
  37 + if (StringUtils.isNotEmpty(recordTime)) {
  38 + String[] dates = recordTime.split(" - ");
  39 + query.setRecordTimeStart(DateUtil.parseYMD(dates[0]));
  40 + if (dates.length == 2) {
  41 + query.setRecordTimeEnd(DateUtil.parseYMDHMS(dates[1] + " 23:59:59"));
  42 + }
  43 + }
  44 + List<MeasureInfoModel> list = measureInfoService.queryMeasureInfoList(query);
  45 + BaseListResponse objectResponse = new BaseListResponse();
  46 + objectResponse.setData(list);
  47 + objectResponse.setPageInfo(query.getPageInfo());
  48 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  49 + objectResponse.setErrormsg("ๆˆๅŠŸ");
  50 + return objectResponse;
  51 + }
  52 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java View file @ 6fe6161
... ... @@ -100,7 +100,6 @@
100 100 @Qualifier("commonThreadPool")
101 101 private ThreadPoolTaskExecutor commonThreadPool;
102 102  
103   - private Executor pool = Executors.newFixedThreadPool(5);
104 103  
105 104 /**
106 105 * ่ฏฅๆ–นๆณ•ๆ˜ฏๅŒบๅŸŸๆˆ–่€…ๅ•ไฝ“ๅŒป้™ข้ƒจ็ฝฒ็š„ๆŠŠๆ•ฐๆฎๅฎšๆ—ถๅพ€ๆŸไธช็ŽฏๅขƒไธŠไผ 
107 106  
108 107  
... ... @@ -131,33 +130,52 @@
131 130 {
132 131 for (final String url : urls.keySet())
133 132 {
134   - try{
135   - System.out.println(DateUtil.getyyyy_MM_dd_hms(new Date()) +" ; request url = " + url);
136   - String json = excePost("https://" + url + "/findSyncData", new HashMap<String, String>());
137   - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(json))
138   - {
139   - List<SyncDataModel> list = JsonUtil.toList(json, SyncDataModel.class);
140   - System.out.println(DateUtil.getyyyy_MM_dd_hms(new Date())+url+" ; syncdata size = "+ list.size());
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(",");
  133 + commonThreadPool.execute(new Runnable() {
  134 + @Override
  135 + public void run() {
  136 + try{
  137 + System.out.println(DateUtil.getyyyy_MM_dd_hms(new Date()) +" ; request url = " + url);
  138 + String json = HttpClientUtil.doPost("https://"+url+"/findSyncData", new HashMap<String, String>(), "utf-8");
  139 + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(json))
  140 + {
  141 + List<SyncDataModel> list = JsonUtil.toList(json, SyncDataModel.class);
  142 + System.out.println(DateUtil.getyyyy_MM_dd_hms(new Date())+url+" ; syncdata size = "+ list.size());
  143 + int batchSize = 200;
  144 + int end = 0;
  145 + for (int i = 0; i < list.size(); i += batchSize) {
  146 + end = (end + batchSize);
  147 + if (end > list.size()) {
  148 + end = list.size();
  149 + }
  150 + final List<SyncDataModel> tempList = list.subList(i, end);
  151 + commonThreadPool.execute(new Runnable() {
  152 + @Override
  153 + public void run() {
  154 + if (CollectionUtils.isNotEmpty(tempList))
  155 + {
  156 + StringBuffer ids = new StringBuffer();
  157 + for (SyncDataModel model : tempList) {
  158 + boolean boo = mongoSyncService.syncData(model.getAction(), model.getDataId(), model.getClassName(), model.getJsonData());
  159 + if (boo) {
  160 + ids.append(model.getId());
  161 + ids.append(",");
  162 + }
  163 + }
  164 + if (ids.length() > 0) {
  165 + Map<String,String> params = new HashMap<String, String>();
  166 + params.put("ids", ids.toString());
  167 + HttpClientUtil.doPost("https://" + url + "/updateSyncData", params, "utf-8");
  168 + }
  169 + }
  170 + }
  171 + });
149 172 }
150 173 }
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   - }
  174 + }catch(Exception ex){
  175 + ExceptionUtils.catchException(ex, url+": syncData Error.");
156 176 }
157 177 }
158   - }catch(Exception ex){
159   - ExceptionUtils.catchException(ex, url+": syncData Error.");
160   - }
  178 + });
161 179 }
162 180 }
163 181