Commit 05468d841087885d64f3c1c257bb4cc8df751fe1

Authored by jiangjiazhi

Merge remote-tracking branch 'origin/master'

Showing 3 changed files

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/JdbcUtil.java View file @ 05468d8
... ... @@ -29,6 +29,158 @@
29 29 * Created by Administrator on 2016/9/29.
30 30 */
31 31 public class JdbcUtil {
  32 +
  33 + private static List<Map<String,String>> employees = new ArrayList<>();
  34 + private static List<Map<String,String>> oracleHosps = new ArrayList<>();
  35 + private static List<Map<String,String>> users = new ArrayList<>();
  36 + private static List<Map<String,String>> mysqlHosps = new ArrayList<>();
  37 + private static List<Map<String,String>> datacontents = new ArrayList<>();
  38 + private static List<Map<String,String>> basicConfigs = new ArrayList<>();
  39 +
  40 +
  41 +
  42 + public static void initData()
  43 + {
  44 + List<Map<String,Object>> listEmp = getListDataBySql("select e.e_name,e.e_id from mommy_employee e");
  45 + for(Map<String,Object> map : listEmp)
  46 + {
  47 + Map<String,String> emap = new HashMap<>();
  48 + emap.put("id",getString(map.get("E_ID")));
  49 + emap.put("name",getString(map.get("E_NAME")));
  50 + employees.add(emap);
  51 + }
  52 +
  53 + System.out.println("employees------"+employees.size());
  54 +
  55 +
  56 + List<Map<String,Object>> datacontentsList = getListDataBySql("select dc_name,dc_id from plat_datacontent ");
  57 + for(Map<String,Object> map : datacontentsList)
  58 + {
  59 + Map<String,String> data = new HashMap<>();
  60 + data.put("id",getString(map.get("DC_ID")));
  61 + data.put("name",getString(map.get("DC_NAME")));
  62 + datacontents.add(data);
  63 + }
  64 +
  65 + System.out.println("datacontents------"+datacontents.size());
  66 + List<Map<String,Object>> orcleHospsList = getListDataBySql("select h_name,h_id from plat_hospital h");
  67 + for(Map<String,Object> map : orcleHospsList)
  68 + {
  69 + Map<String,String> data = new HashMap<>();
  70 + data.put("id",getString(map.get("H_ID")));
  71 + data.put("name",getString(map.get("H_NAME")));
  72 + oracleHosps.add(data);
  73 + }
  74 +
  75 + System.out.println("oracleHosps------"+oracleHosps.size());
  76 +
  77 + List<Map<String,Object>> usersList = getMysqlListDataBySql("select id,name from users");
  78 + for(Map<String,Object> map : usersList)
  79 + {
  80 + Map<String,String> data = new HashMap<>();
  81 + data.put("id",getString(map.get("ID")));
  82 + data.put("name",getString(map.get("NAME")));
  83 + users.add(data);
  84 + }
  85 + System.out.println("users------"+users.size());
  86 +
  87 + List<Map<String,Object>> mysqlHospsList = getMysqlListDataBySql("select id,name from organization");
  88 + for(Map<String,Object> map : mysqlHospsList)
  89 + {
  90 + Map<String,String> data = new HashMap<>();
  91 + data.put("id",getString(map.get("ID")));
  92 + data.put("name",getString(map.get("NAME")));
  93 + mysqlHosps.add(data);
  94 + }
  95 +
  96 + System.out.println("mysqlHosps------"+mysqlHosps.size());
  97 + List<Map<String,Object>> oracleBasicList = getListDataBySql("select id,name,parentId from lyms_basicconfig ");
  98 + for(Map<String,Object> map : oracleBasicList)
  99 + {
  100 + Map<String,String> data = new HashMap<>();
  101 + data.put("id",getString(map.get("ID")));
  102 + data.put("name",getString(map.get("NAME")));
  103 + data.put("parentId",getString(map.get("PARENTID")));
  104 + basicConfigs.add(data);
  105 + }
  106 +
  107 + System.out.println("basicConfigs------"+basicConfigs.size());
  108 +
  109 + }
  110 +
  111 +
  112 + public static String getDataContentByById(String id)
  113 + {
  114 + for (Map<String,String> map : datacontents)
  115 + {
  116 + if (StringUtils.isNotEmpty(map.get("id")) && map.get("id").equals(map.get(id)))
  117 + {
  118 + return map.get("name");
  119 + }
  120 + }
  121 + return null;
  122 + }
  123 +
  124 +
  125 + public static String getPatHosptalById(String id)
  126 + {
  127 + for (Map<String,String> map : oracleHosps)
  128 + {
  129 + if (StringUtils.isNotEmpty(map.get("id")) && map.get("id").equals(map.get(id)))
  130 + {
  131 + return map.get("name");
  132 + }
  133 + }
  134 + return null;
  135 + }
  136 +
  137 +
  138 + public static String getOrgIdByName(String name)
  139 + {
  140 + for (Map<String,String> map : oracleHosps)
  141 + {
  142 + if (StringUtils.isNotEmpty(map.get("name")) && map.get("name").equals(map.get(name)))
  143 + {
  144 + return map.get("id");
  145 + }
  146 + }
  147 + return null;
  148 + }
  149 + public static String getEmpNameById(String id)
  150 + {
  151 + for (Map<String,String> map : oracleHosps)
  152 + {
  153 + if (StringUtils.isNotEmpty(map.get("id")) && map.get("id").equals(map.get(id)))
  154 + {
  155 + return map.get("name");
  156 + }
  157 + }
  158 + return null;
  159 + }
  160 +
  161 +
  162 + public static String getUserIdByName(String name)
  163 + {
  164 + for (Map<String,String> map : oracleHosps)
  165 + {
  166 + if (StringUtils.isNotEmpty(map.get("name")) && map.get("name").equals(map.get(name)))
  167 + {
  168 + return map.get("id");
  169 + }
  170 + }
  171 + return null;
  172 + } public static String getBasicConfigByNameAndParentId(String name,String parentId)
  173 + {
  174 + for (Map<String,String> map : basicConfigs)
  175 + {
  176 + if (StringUtils.isNotEmpty(map.get("parentId")) && StringUtils.isNotEmpty(map.get("name")) && map.get("name").equals(map.get(name)) && map.get("parentId").equals(parentId))
  177 + {
  178 + return map.get("id");
  179 + }
  180 + }
  181 + return null;
  182 + }
  183 +
32 184 public static Connection getOracleConnection() {
33 185 Connection con = null;
34 186 try {
... ... @@ -113,6 +265,41 @@
113 265 return list;
114 266 }
115 267  
  268 +
  269 + public static List<Map<String,Object>> getMysqlListDataBySql(String sql)
  270 + {
  271 + Connection conn = getMysqlConnection();
  272 + PreparedStatement pst = null;
  273 + ResultSet rs = null;
  274 + List<Map<String,Object>> list = new ArrayList<>();
  275 + try {
  276 + pst = conn.prepareStatement(sql);
  277 + rs = pst.executeQuery();
  278 + int count = rs.getMetaData().getColumnCount();
  279 + while (rs.next()) {
  280 + Map<String,Object> maps = new HashMap<>();
  281 + for (int i = 1; i <= count; i++) {
  282 + String columnName = rs.getMetaData().getColumnName(i);
  283 + Object obj = rs.getObject(columnName);
  284 + if (obj != null) {
  285 + maps.put(columnName, obj);
  286 + }
  287 + else
  288 + {
  289 + maps.put(columnName,null);
  290 + }
  291 + }
  292 + list.add(maps);
  293 + }
  294 + }catch (Exception e)
  295 + {
  296 + e.printStackTrace();
  297 + } finally {
  298 + freeConnection(conn,pst,rs);
  299 + }
  300 + return list;
  301 + }
  302 +
116 303 public static Object getOralceSingleObjBySql(String sql)
117 304 {
118 305 Connection conn = getOracleConnection();
119 306  
120 307  
121 308  
122 309  
... ... @@ -176,30 +363,27 @@
176 363 }
177 364  
178 365  
179   - public static void syncPatientData(String hospitalId)
  366 + public static void syncPatientData(String hospitalId,MongoTemplate mongoTemplate,int start,int end)
180 367 {
181 368  
182   - int num = 1;
183   -
184   - while (true) {
185   - List<Map<String, Object>> list = getListDataBySql(" SELECT * FROM ( SELECT A.*, ROWNUM RN FROM " +
186   - "(select replace(mp.P_NO,'-','') as PID,mp.*,p_birthday,p_name,floor((trunc(sysdate) - trunc(mp.P_LASTMENSTRUALPERIOD)+1) /7) as weeks from MOMMY_PATIENT mp left join Plat_Patient pp" +
187   - " on mp.p_platpatientid=pp.p_id where mp.p_hospitalid = '" + hospitalId + "') A WHERE ROWNUM < "+(num+20)+" and weeks < 42) WHERE RN >= "+num+" ");
188   - num=num+20;
189   - MongoTemplate mongoTemplate = getMongoTemplate();
190   -
  369 + String sql = " SELECT * FROM ( SELECT A.*, ROWNUM RN FROM " +
  370 + "(select replace(mp.P_NO,'-','') as PID,mp.*,p_birthday,p_name,floor((trunc(sysdate) - trunc(mp.P_LASTMENSTRUALPERIOD)+1) /7) as weeks from MOMMY_PATIENT mp left join Plat_Patient pp" +
  371 + " on mp.p_platpatientid=pp.p_id where mp.p_hospitalid = '" + hospitalId + "' order by mp.p_lastmenstrualperiod desc ) A WHERE ROWNUM <= "+end+" ) WHERE RN >= "+start;
  372 + List<Map<String, Object>> list = getListDataBySql(sql);
  373 + System.out.println(list.size()+"---------------------------------");
  374 + System.out.println(sql);
191 375 for (Map<String, Object> map : list) {
  376 + try {
  377 +
192 378 Patients patients = new Patients();
193 379 PersonModel person = new PersonModel();
194   -
195   -
196 380 int type = 1;
197 381 Integer weeks = getInteger(map.get("WEEKS"));
198 382 List<Map<String, Object>> chanList = null;
199 383 if (StringUtils.isNotEmpty(getString(map.get("P_ID")))) {
200 384 chanList = getListDataBySql("select * from MOMMY_PREGDELIVERYRECORD p where p.pdr_patientid = '" + getString(map.get("p_id")) + "' order by p.PDR_CHILDBIRTHDAY desc ");
201 385 }
202   - if (weeks >= 42 || CollectionUtils.isNotEmpty(chanList)) {
  386 + if (weeks != null && weeks >= 42 || CollectionUtils.isNotEmpty(chanList)) {
203 387 Date fmDate = null;
204 388 if (CollectionUtils.isNotEmpty(chanList)) {
205 389 fmDate = getDate(chanList.get(0).get("PDR_CHILDBIRTHDAY"));
... ... @@ -210,6 +394,10 @@
210 394  
211 395 type = 3;
212 396 }
  397 + if (map.get("P_LASTMENSTRUALPERIOD")== null || "".equals(map.get("P_LASTMENSTRUALPERIOD")))
  398 + {
  399 + continue;
  400 + }
213 401  
214 402 patients.setDueDate(DateUtil.addDay(getDate(map.get("P_LASTMENSTRUALPERIOD")), 42 * 7));
215 403 person.setCreated(new Date());
... ... @@ -237,7 +425,8 @@
237 425  
238 426 if (StringUtils.isNotEmpty(getString(map.get("P_CARDNO")))) {
239 427 String cardType = getString(map.get("P_CARDTYPE")); //่ฏไปถ็ฑปๅž‹
240   - String cardTypeName = getString(getOralceSingleObjBySql("select dc_name from plat_datacontent where dc_id='" + cardType + "'"));
  428 + String cardTypeName = getDataContentByById(cardType);
  429 + //String cardTypeName = getString(getOralceSingleObjBySql("select dc_name from plat_datacontent where dc_id='" + cardType + "'"));
241 430 if (cardTypeName != null && !"".equals(cardTypeName)) {
242 431 String id = getMongoBasicConfig(cardTypeName, SystemConfig.CERTE_TYPE_ID);
243 432 patients.setPcerteTypeId(id);
... ... @@ -312,8 +501,10 @@
312 501 }
313 502  
314 503 if (buildHospitalId != null && !"".equals(buildHospitalId)) {
315   - String hname = getString(getOralceSingleObjBySql("select h_name from plat_hospital h where h.h_isvalid=1 and h_id = '" + buildHospitalId + "'"));
316   - String id = getString(getMysqlSingleObjBySql("select id from organization where name = '" + hname + "'"));
  504 + //String hname = getString(getOralceSingleObjBySql("select h_name from plat_hospital h where h.h_isvalid=1 and h_id = '" + buildHospitalId + "'"));
  505 + String hname = getPatHosptalById(buildHospitalId);
  506 + // String id = getString(getMysqlSingleObjBySql("select id from organization where name = '" + hname + "'"));
  507 + String id = getOrgIdByName(hname);
317 508 patients.setHospitalId(id);
318 509 }
319 510  
... ... @@ -321,8 +512,10 @@
321 512  
322 513 String doctorId = getString(map.get("P_FILINGOPER"));
323 514 if (doctorId != null && !"".equals(doctorId)) {
324   - String hname = getString(getOralceSingleObjBySql("select e.e_name from mommy_employee e where e.e_id = '" + doctorId + "'"));
325   - String id = getString(getMysqlSingleObjBySql("select id from users where name = '" + hname + "'"));
  515 + //String hname = getString(getOralceSingleObjBySql("select e.e_name from mommy_employee e where e.e_id = '" + doctorId + "'"));
  516 + String userName = getEmpNameById(doctorId);
  517 + //String id = getString(getMysqlSingleObjBySql("select id from users where name = '" + hname + "'"));
  518 + String id = getUserIdByName(userName);
326 519 patients.setBookbuildingDoctor(id); //ๅปบๆกฃๅŒป็”Ÿ(ๅˆ›ๅปบ่€…)
327 520 }
328 521  
... ... @@ -443,12 +636,17 @@
443 636 patients.setHprofessionTypeId(id);
444 637 }
445 638  
446   - String P_HUSBANDCARDTYPE = getString(map.get("P_HUSBANDCARDTYPE")); //ไธˆๅคซ่ฏไปถ็ฑปๅž‹
447   - String hcardTypeName = getString(getOralceSingleObjBySql("select dc_name from plat_datacontent where dc_id='" + P_HUSBANDCARDTYPE + "'"));
448   - if (hcardTypeName != null && !"".equals(hcardTypeName)) {
449   - String id = getMongoBasicConfig(hcardTypeName, SystemConfig.CERTE_TYPE_ID);
450   - patients.setHcertificateTypeId(id);
451   - }
  639 + String P_HUSBANDCARDTYPE = getString(map.get("P_HUSBANDCARDTYPE")); //ไธˆๅคซ่ฏไปถ็ฑป
  640 + if (StringUtils.isNotEmpty(P_HUSBANDCARDTYPE))
  641 + {
  642 + String hcardTypeName = getDataContentByById(P_HUSBANDCARDTYPE);
  643 + if (hcardTypeName != null && !"".equals(hcardTypeName)) {
  644 + String id = getMongoBasicConfig(hcardTypeName, SystemConfig.CERTE_TYPE_ID);
  645 + patients.setHcertificateTypeId(id);
  646 + }
  647 + }
  648 + //String hcardTypeName = getString(getOralceSingleObjBySql("select dc_name from plat_datacontent where dc_id='" + P_HUSBANDCARDTYPE + "'"));
  649 +
452 650 patients.setHcertificateNum(getString(map.get("P_HUSBANDCARDNO"))); //่ฏไปถๅท็ 
453 651  
454 652  
455 653  
... ... @@ -511,8 +709,12 @@
511 709 mongoTemplate.save(patients);
512 710 syncChuZhen(person.getId(), patients.getId(), mongoTemplate);
513 711 syncFuzhen(person.getId(), patients.getId(), mongoTemplate);
  712 + } catch (Exception e)
  713 + {
  714 + ExceptionUtils.catchException(e,map+"ๅญ•ๅฆ‡ๅผ‚ๅธธ");
  715 + continue;
  716 + }
514 717 }
515   - }
516 718 }
517 719  
518 720 private static void syncChuZhen(String pid,String parentId, MongoTemplate mongoTemplate)
... ... @@ -582,8 +784,10 @@
582 784 String doctorId = getString(map.get("FE_DOCTOR"));
583 785 if (doctorId != null && !"".equals(doctorId))
584 786 {
585   - String dname = getString(getOralceSingleObjBySql("select e.e_name from mommy_employee e where e.e_id = '" + doctorId + "'"));
586   - String id = getString(getMysqlSingleObjBySql("select id from users where name = '" + dname + "'"));
  787 + //String dname = getString(getOralceSingleObjBySql("select e.e_name from mommy_employee e where e.e_id = '" + doctorId + "'"));
  788 + String dname = getEmpNameById(doctorId);
  789 + String id = getUserIdByName(dname);
  790 + // String id = getString(getMysqlSingleObjBySql("select id from users where name = '" + dname + "'"));
587 791 chuModel.setProdDoctor(id);//ไบงๆฃ€ๅŒป็”Ÿ
588 792 }
589 793  
... ... @@ -615,8 +819,10 @@
615 819 String hid = getString(map.get("FE_HOSPITALID"));
616 820 if (hid != null && !"".equals(hid))
617 821 {
618   - String hname = getString(getOralceSingleObjBySql("select h_name from plat_hospital h where h.h_isvalid=1 and h_id = '" + hid + "'"));
619   - String id = getString(getMysqlSingleObjBySql("select id from organization where name = '" + hname + "'"));
  822 + // String hname = getString(getOralceSingleObjBySql("select h_name from plat_hospital h where h.h_isvalid=1 and h_id = '" + hid + "'"));
  823 + String hname = getPatHosptalById(hid);
  824 +// String id = getString(getMysqlSingleObjBySql("select id from organization where name = '" + hname + "'"));
  825 + String id = getOrgIdByName(hname);
620 826 chuModel.setHospitalId(id);
621 827 }
622 828 if (map.get("FE_LBLOODPRESSURE") != null)
... ... @@ -819,7 +1025,8 @@
819 1025 String checkDoctorName = getString(map.get("CHECKDOCTOR"));
820 1026 if (checkDoctorName != null && !"".equals(checkDoctorName))
821 1027 {
822   - String id = getString(getMysqlSingleObjBySql("select id from users where name = '" + checkDoctorName + "'"));
  1028 + String id = getUserIdByName(checkDoctorName);
  1029 + // String id = getString(getMysqlSingleObjBySql("select id from users where name = '" + checkDoctorName + "'"));
823 1030 antxModel.setCheckDoctor(id);
824 1031 }
825 1032  
... ... @@ -832,8 +1039,10 @@
832 1039 String hid = getString(map.get("HOSPITALID"));
833 1040 if (hid != null && !"".equals(hid))
834 1041 {
835   - String hname = getString(getOralceSingleObjBySql("select h_name from plat_hospital h where h.h_isvalid=1 and h_id = '" + hid + "'"));
836   - String id = getString(getMysqlSingleObjBySql("select id from organization where name = '" + hname + "'"));
  1042 +// String hname = getString(getOralceSingleObjBySql("select h_name from plat_hospital h where h.h_isvalid=1 and h_id = '" + hid + "'"));
  1043 + String hname = getPatHosptalById(hid);
  1044 +// String id = getString(getMysqlSingleObjBySql("select id from organization where name = '" + hname + "'"));
  1045 + String id = getOrgIdByName(hname);
837 1046 antxModel.setHospitalId(id);
838 1047 }
839 1048 antxModel.setcDueWeek(getString(map.get("CDUEWEEK")));
840 1049  
841 1050  
842 1051  
843 1052  
... ... @@ -896,24 +1105,23 @@
896 1105 return dat1a;
897 1106 }
898 1107  
899   - public static void syncBabyData(String hospitalId) {
  1108 + public static void syncBabyData(String hospitalId,MongoTemplate mongoTemplate) {
900 1109  
901 1110 int num = 1;
902 1111  
903 1112 while (true)
904 1113 {
905   -
906   -
907   -
908 1114 List<Map<String, Object>> list = getListDataBySql(" SELECT * FROM ( SELECT A.*, ROWNUM RN FROM " +
909 1115 " (select replace(m.PI_ID,'-','') as ID,m.* from MOMMY_PATIENTINFO m where m.pi_bookbuildinghospitalid='"+hospitalId+"') " +
910 1116 " A WHERE ROWNUM < "+(num+20)+" ) WHERE RN >= "+num+" ");
  1117 + if (list == null || list.size() == 0)
  1118 + {
  1119 + break;
  1120 + }
911 1121  
912 1122 num = num+20;
913   - MongoTemplate mongoTemplate = getMongoTemplate();
914   -
915 1123 for (Map<String, Object> map : list) {
916   -
  1124 + try {
917 1125 PersonModel personModel = new PersonModel();
918 1126 personModel.setPhone(getString(map.get("PI_MOTHERPHONE")));
919 1127 personModel.setName(getString(map.get("PI_NAME")));
920 1128  
... ... @@ -1090,12 +1298,27 @@
1090 1298 String dueWeek = getString(map.get("PI_GESTATIONALWEEKS"));
1091 1299 if (dueWeek != null && !"".equals(dueWeek))
1092 1300 {
1093   - String sp = "\\u002B";
1094   - model.setDueWeek(Integer.parseInt(dueWeek.split(sp)[0]));
  1301 +
  1302 + if (dueWeek.contains(".") && dueWeek.split("\\u002E").length > 0)
  1303 + {
  1304 + model.setDueWeek(Integer.parseInt(dueWeek.split("\\u002E")[0]));
  1305 + }
  1306 + else
  1307 + {
  1308 + String sp = "\\u002B";
  1309 + String str = dueWeek.split(sp)[0];
  1310 + model.setDueWeek(Integer.parseInt(str));
  1311 + }
  1312 +
1095 1313 }
1096 1314  
1097 1315 mongoTemplate.save(model);
1098 1316 syncBabyCheck(model.getId(),mongoTemplate);
  1317 + } catch (Exception e)
  1318 + {
  1319 + ExceptionUtils.catchException(e,map+"ๅ„ฟ็ซฅๅผ‚ๅธธ");
  1320 + continue;
  1321 + }
1099 1322 }
1100 1323 }
1101 1324 }
1102 1325  
1103 1326  
... ... @@ -1326,15 +1549,18 @@
1326 1549  
1327 1550 public static String getMongoBasicConfig(String name,String parentId)
1328 1551 {
1329   - return getString(getOralceSingleObjBySql("select id from lyms_basicconfig where name='" + name + "' and parentId='" + parentId + "'"));
  1552 + //return getString(getOralceSingleObjBySql("select id from lyms_basicconfig where name='" + name + "' and parentId='" + parentId + "'"));
  1553 + return getBasicConfigByNameAndParentId(name,parentId);
1330 1554 }
1331 1555  
1332 1556 public static String getOracleBasicConfig(String id)
1333 1557 {
1334   - return getString(getOralceSingleObjBySql("select dc_name from plat_datacontent where dc_id='" + id + "'"));
  1558 +// return getString(getOralceSingleObjBySql("select dc_name from plat_datacontent where dc_id='" + id + "'"));
  1559 + return getDataContentByById(id);
1335 1560 }
1336 1561  
1337 1562  
  1563 +
1338 1564 public static String getString(Object obj)
1339 1565 {
1340 1566 return obj == null ? null : String.valueOf(obj);
1341 1567  
1342 1568  
... ... @@ -1398,12 +1624,51 @@
1398 1624 }
1399 1625 }
1400 1626  
1401   - public static void syncData(String hid)
  1627 + public void syncDataBaby(String hid,MongoTemplate mongoTemplate)
1402 1628 {
1403   - syncBabyData(hid);
1404   - syncPatientData(hid);
  1629 + try {
  1630 + syncBabyData(hid, mongoTemplate);
  1631 + }catch (Exception e)
  1632 + {
  1633 + ExceptionUtils.catchException(e,"ๅ„ฟ็ซฅๅŒๆญฅๅ‡บ้”™ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚");
  1634 + }
  1635 +
1405 1636 }
1406 1637  
  1638 + public static void syncDataPat1(String hid,MongoTemplate mongoTemplate)
  1639 + {
  1640 + try {
  1641 + syncPatientData(hid, mongoTemplate, 1, 30000);
  1642 + }
  1643 + catch (Exception e)
  1644 + {
  1645 + ExceptionUtils.catchException(e,"ๅญ•ๅฆ‡ๅŒๆญฅๅ‡บ้”™1ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚");
  1646 + }
  1647 +
  1648 + }
  1649 + public static void syncDataPat2(String hid,MongoTemplate mongoTemplate)
  1650 + {
  1651 + try {
  1652 + syncPatientData(hid,mongoTemplate,30001,8000);
  1653 + }
  1654 + catch (Exception e)
  1655 + {
  1656 + ExceptionUtils.catchException(e,"ๅญ•ๅฆ‡ๅŒๆญฅๅ‡บ้”™2ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚");
  1657 + }
  1658 +
  1659 + }
  1660 + public static void syncDataPat3(String hid,MongoTemplate mongoTemplate)
  1661 + {
  1662 + try {
  1663 + syncPatientData(hid,mongoTemplate,8001,100000);
  1664 + }
  1665 + catch (Exception e)
  1666 + {
  1667 + ExceptionUtils.catchException(e,"ๅญ•ๅฆ‡ๅŒๆญฅๅ‡บ้”™3ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚ใ€‚");
  1668 + }
  1669 +
  1670 + }
  1671 +
1407 1672 public static void main(String[] args)
1408 1673 {
1409 1674 // MongoTemplate template = getMongoTemplate();
... ... @@ -1415,8 +1680,11 @@
1415 1680 // System.out.print(list);
1416 1681 // DBCollection conn = template.getCollection("lyms_patient_test");
1417 1682 // conn.up
1418   - syncBabyData("62");
1419   - syncPatientData("62");
  1683 +// syncBabyData("62");
  1684 +// syncPatientData("62");
  1685 +// initData();
  1686 +// syncPatientData("62", getMongoTemplate(), 1,2000);
  1687 +
1420 1688 }
1421 1689 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java View file @ 05468d8
1 1 package com.lyms.platform.operate.web.controller;
2 2  
3   -import com.lyms.platform.operate.web.utils.JdbcUtil;
  3 +import com.lyms.platform.biz.JdbcUtil;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +import org.springframework.data.mongodb.core.MongoTemplate;
4 6 import org.springframework.stereotype.Controller;
5 7 import org.springframework.web.bind.annotation.RequestMapping;
6 8 import org.springframework.web.bind.annotation.RequestMethod;
... ... @@ -19,6 +21,9 @@
19 21 @Controller
20 22 public class TestController {
21 23  
  24 +
  25 + @Autowired
  26 + private MongoTemplate mongoTemplate;
22 27 /**
23 28 * ่Žทๅ–็ง‘ๅฎค
24 29 */
... ... @@ -91,10 +96,45 @@
91 96  
92 97  
93 98 @RequestMapping(value = "/syncData", method = RequestMethod.GET)
94   - public void syncData( @RequestParam(required = true) String hid) {
95   - System.out.print("ๅŒๆญฅๅผ€ๅง‹>>>>>>>>>>>>>>>>>>>>>>>>>");
96   - com.lyms.platform.biz.JdbcUtil.syncData(hid);
97   - System.out.print("ๅŒๆญฅ็ป“ๆŸ>>>>>>>>>>>>>>>>>>>>>>>>>");
  99 + @ResponseBody
  100 + public String syncData(@RequestParam(required = true) final String hid) {
  101 + final MongoTemplate template = mongoTemplate;
  102 +// new Thread(new Runnable() {
  103 +// @Override
  104 +// public void run() {
  105 +// System.out.print("ๅŒๆญฅๅผ€ๅง‹ๅ„ฟ็ซฅ>>>>>>>>>>>>>>>>>>>>>>>>>");
  106 +// new com.lyms.platform.biz.JdbcUtil().syncDataBaby(hid, template);
  107 +// System.out.print("ๅŒๆญฅ็ป“ๆŸๅ„ฟ็ซฅ>>>>>>>>>>>>>>>>>>>>>>>>>");
  108 +// }
  109 +// }).start();
  110 + JdbcUtil.initData();
  111 + System.out.println("initData------");
  112 +
  113 + new Thread(new Runnable() {
  114 + @Override
  115 + public void run() {
  116 + System.out.println("ๅŒๆญฅๅผ€ๅง‹ๅญ•ๅฆ‡1>>>>>>>>>>>>>>>>>>>>>>>>>");
  117 + JdbcUtil.syncDataPat1(hid, template);
  118 + System.out.println("ๅŒๆญฅ็ป“ๆŸๅญ•ๅฆ‡1>>>>>>>>>>>>>>>>>>>>>>>>>");
  119 + }
  120 + }).start();
  121 + new Thread(new Runnable() {
  122 + @Override
  123 + public void run() {
  124 + System.out.println("ๅŒๆญฅๅผ€ๅง‹ๅญ•ๅฆ‡2>>>>>>>>>>>>>>>>>>>>>>>>>");
  125 + JdbcUtil.syncDataPat2(hid, template);
  126 + System.out.println("ๅŒๆญฅ็ป“ๆŸๅญ•ๅฆ‡2>>>>>>>>>>>>>>>>>>>>>>>>>");
  127 + }
  128 + }).start();
  129 + new Thread(new Runnable() {
  130 + @Override
  131 + public void run() {
  132 + System.out.println("ๅŒๆญฅๅผ€ๅง‹ๅญ•ๅฆ‡3>>>>>>>>>>>>>>>>>>>>>>>>>");
  133 + JdbcUtil.syncDataPat3(hid, template);
  134 + System.out.println("ๅŒๆญฅ็ป“ๆŸๅญ•ๅฆ‡3>>>>>>>>>>>>>>>>>>>>>>>>>");
  135 + }
  136 + }).start();
  137 + return "starting...........";
98 138 }
99 139 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java View file @ 05468d8
... ... @@ -114,7 +114,7 @@
114 114 if (yunRequest.getPregnantCertificateNum() != null)
115 115 {
116 116 patientsQuery.setCardNo(yunRequest.getPregnantCertificateNum());
117   - //ๅˆคๆ–ญ่ฏฅ่บซไปฝ่ฏๅท็ ๆ˜ฏๅฆๆœ‰ๅญ•ๅฆ‡ๅปบๆกฃ ๅœจ่ฏฅๅŒป้™ข
  117 + //ๅˆคๆ–ญ่ฏฅ่บซไปฝ่ฏๅท็ ๆ˜ฏๅฆๆœ‰ๅญ•ๅฆ‡ๅปบๆกฃ ๅœจ่ฏฅๅŒป้™ข
118 118 List<Patients> patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery);
119 119 if (CollectionUtils.isNotEmpty(patients))
120 120 {
... ... @@ -159,7 +159,7 @@
159 159 Date date = null;
160 160 if (yunRequest.getLastMenstrualPeriod() != null)
161 161 {
162   - date = DateUtil.addWeek(DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod()),42);
  162 + date = DateUtil.addWeek(DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod()),42);
163 163 Date currentDate = DateUtil.formatDate(new Date());
164 164 if (date.getTime() <= currentDate.getTime())
165 165 {
... ... @@ -238,7 +238,7 @@
238 238  
239 239 if (type == ServiceObjEnums.YUNOBJ.getId())
240 240 {
241   - //็”Ÿๆˆๅปบๆกฃ็Ÿญไฟก
  241 + //็”Ÿๆˆๅปบๆกฃ็Ÿญไฟก
242 242 createBuildSms(p);
243 243 }
244 244  
... ... @@ -246,7 +246,7 @@
246 246 br.setErrormsg("ๆˆๅŠŸ");
247 247 br.setData(p.getId());
248 248 return br;
249   -
  249 +
250 250 }
251 251  
252 252 /**
... ... @@ -311,7 +311,7 @@
311 311 sendList.add(temp);
312 312 }
313 313 }
314   - else if (temp.getServiceType() == ServiceTypeEnums.ALL_SERVICE.getId() && temp.getServiceStatus() == ServiceStatusEnums.ALL.getId())
  314 + else if (temp.getServiceType() == ServiceTypeEnums.ALL_SERVICE.getId() && temp.getServiceStatus() == ServiceStatusEnums.ALL.getId())
315 315 {
316 316 sendList.add(temp);
317 317 }
... ... @@ -320,7 +320,7 @@
320 320 if (CollectionUtils.isNotEmpty(sendList))
321 321 {
322 322  
323   - //็Ÿญไฟกๅ‰็ผ€
  323 + //็Ÿญไฟกๅ‰็ผ€
324 324 String messagePrefix = smsConfigFacade.getSmsPrefix(configModel, patient.getBookbuildingDoctor());
325 325 for (SmsTemplateModel templateModel : sendList)
326 326 {
... ... @@ -477,7 +477,7 @@
477 477 personService.updatePerson(pmodel, yunRequest.getPid());
478 478 }
479 479 patient.setId(id);
480   - //ๅŠ ๅ…ฅไบง็ญ›
  480 + //ๅŠ ๅ…ฅไบง็ญ›
481 481 patientsService.validata(patient);
482 482  
483 483  
... ... @@ -525,7 +525,7 @@
525 525 if (!StringUtils.isEmpty(bookbuildingQueryRequest.getCardNo()))
526 526 {
527 527 patientsQuery.setCardNo(bookbuildingQueryRequest.getCardNo());
528   - patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery,"bookbuildingDate", Sort.Direction.DESC);
  528 + patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery,"bookbuildingDate", Sort.Direction.DESC);
529 529 }
530 530 //ๅฆๅˆ™็”จๅฐฑ่ฏŠๅกๅท ๆŸฅ่ฏขๅˆฐ่ฟ™ไธชๅญ•ๅฆ‡็š„่บซไปฝ่ฏๅท็  ๅ†็”จ่บซไปฝ่ฏๅท็ ๆŸฅ่ฏข่ฏฅๅญ•ๅฆ‡็š„ๆ‰€ๆœ‰ๅปบๆกฃ ๅŒ…ๆ‹ฌไบงๅฆ‡่ฎฐๅฝ•
531 531 else if (!StringUtils.isEmpty(bookbuildingQueryRequest.getVcCardNo()))
... ... @@ -944,7 +944,7 @@
944 944 AntExChuQuery antExChuQuery = new AntExChuQuery();
945 945 antExChuQuery.setParentId(id);
946 946 antExChuQuery.setYn(YnEnums.YES.getId());
947   - //่Žทๅ–ๅˆ่ฏŠ่ฎฐๅฝ•
  947 + //่Žทๅ–ๅˆ่ฏŠ่ฎฐๅฝ•
948 948 List<AntExChuModel> antExChulist = antenatalExaminationService.queryAntExChu(antExChuQuery);
949 949 String hospital = autoMatchFacade.getHospitalId(userId);
950 950 Patients patients = yunBookbuildingService.findOneById(id);
... ... @@ -1056,20 +1056,20 @@
1056 1056 }
1057 1057  
1058 1058 public BaseListResponse queryChanJianReport(Integer userId, String exDateStart,
1059   - String exDateEnd,
1060   - String name,
1061   - Integer weekStarts,
1062   - Integer weekEnds,
1063   - String hbsag,
1064   - String hbeag,
1065   - String hbeab,
1066   - String hbcab,
1067   - String syphilis,
1068   - String hiv,
1069   - String hcv,
1070   - String doctorNo,
1071   - Integer page,
1072   - Integer limit) {
  1059 + String exDateEnd,
  1060 + String name,
  1061 + Integer weekStarts,
  1062 + Integer weekEnds,
  1063 + String hbsag,
  1064 + String hbeag,
  1065 + String hbeab,
  1066 + String hbcab,
  1067 + String syphilis,
  1068 + String hiv,
  1069 + String hcv,
  1070 + String doctorNo,
  1071 + Integer page,
  1072 + Integer limit) {
1073 1073  
1074 1074 String hospitalId = autoMatchFacade.getHospitalId(userId);
1075 1075  
1076 1076  
1077 1077  
1078 1078  
1079 1079  
1080 1080  
1081 1081  
1082 1082  
1083 1083  
1084 1084  
1085 1085  
... ... @@ -1123,82 +1123,82 @@
1123 1123 " INNER JOIN ODS_F_GRAVIDA_RECORD B ON A.RECORD_ID=B.RECORD_ID \n" +
1124 1124 " INNER JOIN ODS_D_HOSPITAL C ON A.HOSPITAL_NO=C.HOSPITAL_NO AND C.VER_NO=2 \n" +
1125 1125 " WHERE C.YCY_STSTEM_ID= '"+hospitalId +"'";
1126   - if (StringUtils.isNotEmpty(exDateStart))
1127   - {
1128   - sql += " AND A.EXAMINE_DATE>= to_date('"+exDateStart+"','yyyy-MM-dd')";
1129   - countSql += " AND A.EXAMINE_DATE>= to_date('"+exDateStart+"','yyyy-MM-dd')";
1130   - }
1131   - if (StringUtils.isNotEmpty(exDateEnd))
1132   - {
1133   - sql += " AND A.EXAMINE_DATE <= to_date('"+exDateEnd+"','yyyy-MM-dd')";
1134   - countSql += " AND A.EXAMINE_DATE <= to_date('"+exDateEnd+"','yyyy-MM-dd')";
1135   - }
  1126 + if (StringUtils.isNotEmpty(exDateStart))
  1127 + {
  1128 + sql += " AND A.EXAMINE_DATE>= to_date('"+exDateStart+"','yyyy-MM-dd')";
  1129 + countSql += " AND A.EXAMINE_DATE>= to_date('"+exDateStart+"','yyyy-MM-dd')";
  1130 + }
  1131 + if (StringUtils.isNotEmpty(exDateEnd))
  1132 + {
  1133 + sql += " AND A.EXAMINE_DATE <= to_date('"+exDateEnd+"','yyyy-MM-dd')";
  1134 + countSql += " AND A.EXAMINE_DATE <= to_date('"+exDateEnd+"','yyyy-MM-dd')";
  1135 + }
1136 1136  
1137   - if (StringUtils.isNotEmpty(name))
1138   - {
1139   - sql += " AND A.NAME LIKE '%"+name+"%'";
1140   - countSql += " AND A.NAME LIKE '%"+name+"%'";
1141   - }
  1137 + if (StringUtils.isNotEmpty(name))
  1138 + {
  1139 + sql += " AND A.NAME LIKE '%"+name+"%'";
  1140 + countSql += " AND A.NAME LIKE '%"+name+"%'";
  1141 + }
1142 1142  
1143   - if (weekStarts != null)
1144   - {
1145   - sql += " AND A.NOW_WEEKS>= "+weekStarts;
1146   - countSql += " AND A.NOW_WEEKS>= "+weekStarts;
1147   - }
  1143 + if (weekStarts != null)
  1144 + {
  1145 + sql += " AND A.NOW_WEEKS>= "+weekStarts;
  1146 + countSql += " AND A.NOW_WEEKS>= "+weekStarts;
  1147 + }
1148 1148  
1149   - if (weekEnds != null)
1150   - {
1151   - sql += " AND A.NOW_WEEKS <= "+weekEnds;
1152   - countSql += " AND A.NOW_WEEKS <= "+weekEnds;
1153   - }
  1149 + if (weekEnds != null)
  1150 + {
  1151 + sql += " AND A.NOW_WEEKS <= "+weekEnds;
  1152 + countSql += " AND A.NOW_WEEKS <= "+weekEnds;
  1153 + }
1154 1154  
1155   - if (StringUtils.isNotEmpty(hbsag))
1156   - {
1157   - sql += " AND A.HBSAG = "+hbsag;
1158   - countSql += " AND A.HBSAG = "+hbsag;
1159   - }
  1155 + if (StringUtils.isNotEmpty(hbsag))
  1156 + {
  1157 + sql += " AND A.HBSAG = "+hbsag;
  1158 + countSql += " AND A.HBSAG = "+hbsag;
  1159 + }
1160 1160  
1161   - if (StringUtils.isNotEmpty(hbeag))
1162   - {
1163   - sql += " AND A.HBEAG = "+hbeag;
1164   - countSql += " AND A.HBEAG = "+hbeag;
1165   - }
  1161 + if (StringUtils.isNotEmpty(hbeag))
  1162 + {
  1163 + sql += " AND A.HBEAG = "+hbeag;
  1164 + countSql += " AND A.HBEAG = "+hbeag;
  1165 + }
1166 1166  
1167   - if (StringUtils.isNotEmpty(hbeab))
1168   - {
1169   - sql += " AND A.HBEAB = "+hbeab;
1170   - countSql += " AND A.HBEAB = "+hbeab;
1171   - }
  1167 + if (StringUtils.isNotEmpty(hbeab))
  1168 + {
  1169 + sql += " AND A.HBEAB = "+hbeab;
  1170 + countSql += " AND A.HBEAB = "+hbeab;
  1171 + }
1172 1172  
1173   - if (StringUtils.isNotEmpty(hbcab))
1174   - {
1175   - sql += " AND A.HBCAB = "+hbcab;
1176   - countSql += " AND A.HBCAB = "+hbcab;
1177   - }
1178   - if (StringUtils.isNotEmpty(syphilis))
1179   - {
1180   - sql += " AND A.SYPHILIS = "+syphilis;
1181   - countSql += " AND A.SYPHILIS = "+syphilis;
1182   - }
  1173 + if (StringUtils.isNotEmpty(hbcab))
  1174 + {
  1175 + sql += " AND A.HBCAB = "+hbcab;
  1176 + countSql += " AND A.HBCAB = "+hbcab;
  1177 + }
  1178 + if (StringUtils.isNotEmpty(syphilis))
  1179 + {
  1180 + sql += " AND A.SYPHILIS = "+syphilis;
  1181 + countSql += " AND A.SYPHILIS = "+syphilis;
  1182 + }
1183 1183  
1184   - if (StringUtils.isNotEmpty(hiv))
1185   - {
1186   - sql += " AND A.HIV = "+hiv;
1187   - countSql += " AND A.HIV = "+hiv;
1188   - }
  1184 + if (StringUtils.isNotEmpty(hiv))
  1185 + {
  1186 + sql += " AND A.HIV = "+hiv;
  1187 + countSql += " AND A.HIV = "+hiv;
  1188 + }
1189 1189  
1190   - if (StringUtils.isNotEmpty(hcv))
1191   - {
1192   - sql += " AND A.HCV = "+hcv;
1193   - countSql += " AND A.HCV = "+hcv;
1194   - }
1195   - if (StringUtils.isNotEmpty(doctorNo))
1196   - {
1197   - sql += " AND A.DOCTOR_NO = "+doctorNo;
1198   - countSql += " AND A.DOCTOR_NO = "+doctorNo;
1199   - }
  1190 + if (StringUtils.isNotEmpty(hcv))
  1191 + {
  1192 + sql += " AND A.HCV = "+hcv;
  1193 + countSql += " AND A.HCV = "+hcv;
  1194 + }
  1195 + if (StringUtils.isNotEmpty(doctorNo))
  1196 + {
  1197 + sql += " AND A.DOCTOR_NO = "+doctorNo;
  1198 + countSql += " AND A.DOCTOR_NO = "+doctorNo;
  1199 + }
1200 1200  
1201   - sql+=" order by A.EXAMINE_DATE DESC,A.Name ASC,A.EXAMINE_ID DESC ) A WHERE ROWNUM <= "+end+" ) WHERE RN >= "+start;
  1201 + sql+=" order by A.EXAMINE_DATE DESC,A.Name ASC,A.EXAMINE_ID DESC ) A WHERE ROWNUM <= "+end+" ) WHERE RN >= "+start;
1202 1202  
1203 1203 logger.info(sql);
1204 1204 List<Map<String,Object>> list = JdbcUtil.getListDataBySql(sql);