Commit 66fa6b72a6251f38040f712e280e25e258232747
1 parent
d62183488b
Exists in
master
and in
6 other branches
数据同步
Showing 2 changed files with 27 additions and 35 deletions
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/MongoSyncService.java
View file @
66fa6b7
... | ... | @@ -3,12 +3,14 @@ |
3 | 3 | import com.lyms.platform.common.dao.operator.MongoCondition; |
4 | 4 | import com.lyms.platform.common.dao.operator.MongoOper; |
5 | 5 | import com.lyms.platform.common.dao.operator.MongoQuery; |
6 | +import com.lyms.platform.common.enums.YnEnums; | |
6 | 7 | import com.lyms.platform.common.pojo.UpdateMultiData; |
7 | 8 | import com.lyms.platform.common.utils.*; |
8 | 9 | import com.lyms.platform.pojo.*; |
9 | 10 | import com.mongodb.Mongo; |
10 | 11 | import com.mongodb.WriteResult; |
11 | 12 | import org.apache.commons.codec.binary.Base64; |
13 | +import org.apache.commons.collections.CollectionUtils; | |
12 | 14 | import org.apache.commons.lang.StringUtils; |
13 | 15 | import org.slf4j.Logger; |
14 | 16 | import org.slf4j.LoggerFactory; |
... | ... | @@ -110,6 +112,29 @@ |
110 | 112 | Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(obj)); |
111 | 113 | Assert.notNull(update, "execute update method must not null."); |
112 | 114 | WriteResult result = mongoTemplate.upsert(new MongoQuery(new MongoCondition("id", LymsEncodeUtil.aesDecrypt(id, mongo_crypto_key), MongoOper.IS)).convertToMongoQuery(), update, cla); |
115 | + | |
116 | + //解决衡水问题 | |
117 | + try { | |
118 | + | |
119 | + if ("com.lyms.platform.pojo.Patients".equals(cla.getName())) | |
120 | + { | |
121 | + Patients pat = (Patients)obj; | |
122 | + PersonModel pmodel = new PersonModel(); | |
123 | + pmodel.setId(pat.getPid()); | |
124 | + pmodel.setName(pat.getUsername()); | |
125 | + pmodel.setBirth(pat.getBirth()); | |
126 | + pmodel.setPhone(pat.getPhone()); | |
127 | + pmodel.setCardNo(pat.getCardNo()); | |
128 | + pmodel.setType(pat.getType()); | |
129 | + pmodel.setModified(pat.getModified()); | |
130 | + pmodel.setYn(YnEnums.YES.getId()); | |
131 | + pmodel.setCreated(pat.getCreated()); | |
132 | + mongoTemplate.save(pmodel); | |
133 | + } | |
134 | + }catch (Exception e) | |
135 | + { | |
136 | + System.out.println(e.toString()); | |
137 | + } | |
113 | 138 | return true; |
114 | 139 | } else if ("DELETE".equals(action)) { |
115 | 140 | Class cla = Class.forName(LymsEncodeUtil.aesDecrypt(className, mongo_crypto_key)); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
View file @
66fa6b7
... | ... | @@ -1569,41 +1569,8 @@ |
1569 | 1569 | |
1570 | 1570 | |
1571 | 1571 | public static void main(String[] a) throws Exception { |
1572 | - Mongo mongo = new Mongo("119.90.57.26", 10001); | |
1573 | - UserCredentials credentials = new UserCredentials("platform", "platform123"); | |
1574 | - MongoTemplate mongoTemplate = new MongoTemplate(mongo, "platform", credentials); | |
1575 | - PatientWeight pw = mongoTemplate.findById("123", PatientWeight.class); | |
1576 | - Map<String, String> s = new HashMap<>(); | |
1577 | - s.put("name", "1"); | |
1578 | - s.put("name2", "12"); | |
1579 | - pw.setDayWeights(s); | |
1580 | - String json = JSON.toJSONString(pw); | |
1581 | - String clazz = "com.lyms.platform.pojo.PatientWeight"; | |
1582 | - JSON.parseObject(json, Class.forName(clazz)); | |
1583 | - mongoTemplate.save(pw); | |
1584 | - | |
1585 | - /* try { | |
1586 | - List<String> list = FileUtils.readLines(new File("D:\\QHD.csv"), "gbk"); | |
1587 | - List<String> linenums = new ArrayList<>(); | |
1588 | - for (String line : list) { | |
1589 | - String ss[] = line.split(","); | |
1590 | - if (ss.length > 0 && ss[0].trim().length() > 0) { | |
1591 | - System.out.println(ss[0] + " " + ss[1]); | |
1592 | - } | |
1593 | - } | |
1594 | -// List<String> list1 = FileUtils.readLines(new File("D:\\temp\\qhd-jd.csv"), "utf-8"); | |
1595 | -// StringBuffer sb = new StringBuffer(); | |
1596 | -// for (String line:list1) { | |
1597 | -// String ss[] = line.split(","); | |
1598 | -// if (ss.length > 0 && ss[0].trim().length() > 0 && linenums.contains(ss[0].trim())) { | |
1599 | -// sb.append(line); | |
1600 | -// sb.append("\r\n"); | |
1601 | -// } | |
1602 | -// } | |
1603 | -// FileUtils.writeStringToFile(new File("d:\\temp\\qhdfy_lost_data.csv"), sb.toString()); | |
1604 | - } catch (Exception e) { | |
1605 | - e.printStackTrace(); | |
1606 | - }*/ | |
1572 | + Class clazz = Patients.class; | |
1573 | + System.out.println(clazz.getName()); | |
1607 | 1574 | } |
1608 | 1575 | |
1609 | 1576 | @RequestMapping("/poll") |