diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/JdbcUtil.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/JdbcUtil.java index fc6202b..b287908 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/JdbcUtil.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/JdbcUtil.java @@ -226,6 +226,21 @@ public class JdbcUtil { return con; } + + public static Connection getQhdMysqlConnection() { + Connection con = null; + try { + Class.forName("com.mysql.jdbc.Driver"); + String url = "jdbc:mysql://127.0.0.1:3306/platform_dev?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8"; + String userName = "root"; + String pwd = ""; + con = DriverManager.getConnection(url, userName, pwd); + } catch (Exception e) { + e.printStackTrace(); + } + return con; + } + public static void freeConnection(Connection connection, PreparedStatement ps, ResultSet rs) { try { if (rs != null) { @@ -306,6 +321,9 @@ public class JdbcUtil { return list; } + + + public static Object getOralceSingleObjBySql(String sql) { Connection conn = getOracleConnection(); PreparedStatement pst = null; @@ -352,6 +370,27 @@ public class JdbcUtil { } return null; } + public static Object getQhdMysqlSingleObjBySql(String sql,Connection conn ) { + PreparedStatement pst = null; + ResultSet rs = null; + try { + pst = conn.prepareStatement(sql); + rs = pst.executeQuery(); + int count = rs.getMetaData().getColumnCount(); + for (int i = 1; i <= count; i++) { + String columnName = rs.getMetaData().getColumnName(i); + while (rs.next()) { + return rs.getObject(columnName); + } + + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + freeConnection(conn, pst, rs); + } + return null; + } public static MongoTemplate getMongoTemplate() { ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext_biz_patient1.xml"); diff --git a/platform-job-index/src/main/java/com/lyms/platform/job/index/service/SyncDataService.java b/platform-job-index/src/main/java/com/lyms/platform/job/index/service/SyncDataService.java index e92f8e9..5cc64b7 100644 --- a/platform-job-index/src/main/java/com/lyms/platform/job/index/service/SyncDataService.java +++ b/platform-job-index/src/main/java/com/lyms/platform/job/index/service/SyncDataService.java @@ -935,7 +935,7 @@ public class SyncDataService { model.setmLevelId(id); } - String zhuchanOrg = DataUtil.getString(map.get("PI_BIRTHASPHYXIA")); + String zhuchanOrg = DataUtil.getString(map.get("PI_HOSPITALNAME")); if (zhuchanOrg != null && !"".equals(zhuchanOrg)) { String id = DataUtil.getString(JDBCUtil.getMysqlSingleObjBySql("select id from organization where name = '" + zhuchanOrg + "'")); model.setDeliverOrg(id); @@ -1235,6 +1235,14 @@ public class SyncDataService { public static void main(String[] args) { +// List> list = JDBCUtil.getOracleListDataBySql(" select replace(m.PI_ID,'-','') as ID,m.* from MOMMY_PATIENTINFO m where m.pi_bookbuildinghospitalid='62' " ); +// for (Map map : list) +// { +// String zhuchanOrg = DataUtil.getString(map.get("PI_HOSPITALNAME")); +// String id = DataUtil.getString(map.get("ID")); +// System.out.println(id + " " + zhuchanOrg); +// } + } diff --git a/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/FmItem.java b/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/FmItem.java index a45c631..7eeddd9 100644 --- a/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/FmItem.java +++ b/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/FmItem.java @@ -43,7 +43,7 @@ public class FmItem { private String jsz;//接生者 public String getSyxh() { - return syxh; + return trim(syxh); } public void setSyxh(String syxh) { @@ -51,7 +51,7 @@ public class FmItem { } public String getYexh() { - return yexh; + return trim(yexh); } public void setYexh(String yexh) { @@ -59,7 +59,7 @@ public class FmItem { } public String getJlrq() { - return jlrq; + return trim(jlrq); } public void setJlrq(String jlrq) { @@ -67,7 +67,7 @@ public class FmItem { } public String getSsrq() { - return ssrq; + return trim(ssrq); } public void setSsrq(String ssrq) { @@ -75,7 +75,7 @@ public class FmItem { } public String getSsj() { - return ssj; + return trim(ssj); } public void setSsj(String ssj) { @@ -83,7 +83,7 @@ public class FmItem { } public String getYexb() { - return yexb; + return trim(yexb); } public void setYexb(String yexb) { @@ -91,7 +91,7 @@ public class FmItem { } public String getRc() { - return rc; + return trim(rc); } public void setRc(String rc) { @@ -99,7 +99,7 @@ public class FmItem { } public String getJts() { - return jts; + return trim(jts); } public void setJts(String jts) { @@ -107,7 +107,7 @@ public class FmItem { } public String getDjt() { - return djt; + return trim(djt); } public void setDjt(String djt) { @@ -115,7 +115,7 @@ public class FmItem { } public String getCjc() { - return cjc; + return trim(cjc); } public void setCjc(String cjc) { @@ -123,7 +123,7 @@ public class FmItem { } public String getZx() { - return zx; + return trim(zx); } public void setZx(String zx) { @@ -131,7 +131,7 @@ public class FmItem { } public String getTz() { - return tz; + return trim(tz); } public void setTz(String tz) { @@ -139,7 +139,7 @@ public class FmItem { } public String getSc() { - return sc; + return trim(sc); } public void setSc(String sc) { @@ -147,7 +147,7 @@ public class FmItem { } public String getSh() { - return sh; + return trim(sh); } public void setSh(String sh) { @@ -155,7 +155,7 @@ public class FmItem { } public String getJx() { - return jx; + return trim(jx); } public void setJx(String jx) { @@ -163,7 +163,7 @@ public class FmItem { } public String getYfz() { - return yfz; + return trim(yfz); } public void setYfz(String yfz) { @@ -171,7 +171,7 @@ public class FmItem { } public String getWfz() { - return wfz; + return trim(wfz); } public void setWfz(String wfz) { @@ -179,7 +179,7 @@ public class FmItem { } public String getSfz() { - return sfz; + return trim(sfz); } public void setSfz(String sfz) { @@ -187,7 +187,7 @@ public class FmItem { } public String getPfz() { - return pfz; + return trim(pfz); } public void setPfz(String pfz) { @@ -195,7 +195,7 @@ public class FmItem { } public String getCcqk() { - return ccqk; + return trim(ccqk); } public void setCcqk(String ccqk) { @@ -203,7 +203,7 @@ public class FmItem { } public String getFmfs() { - return fmfs; + return trim(fmfs); } public void setFmfs(String fmfs) { @@ -211,7 +211,7 @@ public class FmItem { } public String getTpmcfs() { - return tpmcfs; + return trim(tpmcfs); } public void setTpmcfs(String tpmcfs) { @@ -219,7 +219,7 @@ public class FmItem { } public String getYeqk() { - return yeqk; + return trim(yeqk); } public void setYeqk(String yeqk) { @@ -227,7 +227,7 @@ public class FmItem { } public String getSw() { - return sw; + return trim(sw); } public void setSw(String sw) { @@ -235,7 +235,7 @@ public class FmItem { } public String getSffq() { - return sffq; + return trim(sffq); } public void setSffq(String sffq) { @@ -243,7 +243,7 @@ public class FmItem { } public String getFqyy() { - return fqyy; + return trim(fqyy); } public void setFqyy(String fqyy) { @@ -251,7 +251,7 @@ public class FmItem { } public String getHyqk() { - return hyqk; + return trim(hyqk); } public void setHyqk(String hyqk) { @@ -267,7 +267,7 @@ public class FmItem { } public String getYc() { - return yc; + return trim(yc); } public void setYc(String yc) { @@ -275,7 +275,7 @@ public class FmItem { } public String getSfgw() { - return sfgw; + return trim(sfgw); } public void setSfgw(String sfgw) { @@ -283,7 +283,7 @@ public class FmItem { } public String getMctpslxl() { - return mctpslxl; + return trim(mctpslxl); } public void setMctpslxl(String mctpslxl) { @@ -291,7 +291,7 @@ public class FmItem { } public String getChexxsxl() { - return chexxsxl; + return trim(chexxsxl); } public void setChexxsxl(String chexxsxl) { @@ -299,7 +299,7 @@ public class FmItem { } public String getQjqk() { - return qjqk; + return trim(qjqk); } public void setQjqk(String qjqk) { @@ -307,7 +307,7 @@ public class FmItem { } public String getSrks() { - return srks; + return trim(srks); } public void setSrks(String srks) { @@ -315,13 +315,22 @@ public class FmItem { } public String getJsz() { - return jsz; + return trim(jsz); } public void setJsz(String jsz) { this.jsz = jsz; } + public String trim(String str) + { + if (str != null) + { + return str.trim(); + } + return ""; + } + @Override public String toString() { return "FmItem{" + diff --git a/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdfyFmService.java b/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdfyFmService.java index ef97311..bbec843 100644 --- a/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdfyFmService.java +++ b/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdfyFmService.java @@ -45,9 +45,9 @@ public class QhdfyFmService { private UsersService usersService; public void fmTimerWork() { - SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date end = new Date(); - Date start = new Date(end.getTime()-1000*60*60*24*6); + Date start = new Date(end.getTime()-1000*60*60); String startStr = fmt.format(start); String endStr = fmt.format(end); System.out.println("start="+startStr+"end="+endStr); @@ -98,329 +98,304 @@ public class QhdfyFmService { QueryRunner queryRunner = new QueryRunner(); SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHH:mm:ss"); SimpleDateFormat fmt1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - try {//select count(*) from JHMK_FMJL where CONVERT(varchar(16),SSRQ, 20) > CONVERT(varchar(16),'20170110', 20) - List list = queryRunner.query(conn, "select "+cloumns+" from JHMK_FMJL where " + - " CONVERT(varchar(50),SSRQ, 20) > CONVERT(varchar(50),'"+start+"', 20) and CONVERT(varchar(50),SSRQ, 20) <= CONVERT(varchar(50),'"+end+"', 20)" + - " and SYXH not in (select SYXH from JHMK_FMJL where JSZ is not null and SC is not null and TZ is not null and YFZ is not null and SH is not null and (SFFZRSTDT = ' 是 ' or SFSTDT = ' 是 '))", new BeanListHandler(FmItem.class)); + try { + String sql ="select "+cloumns+" from JHMK_FMJL where " + + " CONVERT(DATETIME,left(SSRQ,8)+' '+RIGHT(SSRQ,8),20) > CONVERT(DATETIME,'"+start+"', 120) and CONVERT(DATETIME,left(SSRQ,8)+' '+RIGHT(SSRQ,8),20) <= CONVERT(DATETIME,'"+end+"', 120)" + + " and SYXH not in (select SYXH from JHMK_FMJL where JSZ is not null and SC is not null and TZ is not null and YFZ is not null and SH is not null" + + " and (SFFZRSTDT = ' 是 ' or SFSTDT = ' 是 '))"; + List list = queryRunner.query(conn, sql, new BeanListHandler(FmItem.class)); + ExceptionUtils.catchException("size=" + list.size()); + if (CollectionUtils.isNotEmpty(list)) { + for (FmItem item : list) { + try { + String dueDateStr = item.getSsrq(); + if (!StringUtils.isNotEmpty(dueDateStr)) { + continue; + } + Date dueDate = fmt.parse(dueDateStr); + FmPatInfo patInfo = getFmPatInfoById(item.getSyxh()); + if (patInfo != null && com.lyms.platform.common.utils.StringUtils.isNotEmpty(patInfo.getLXDH())) { + PatientsQuery query = new PatientsQuery(); + query.setYn(YnEnums.YES.getId()); + query.setType(1); //孕妇 + query.setDueStatus(0); //未终止妊娠 + query.setPhone(patInfo.getLXDH()); + List patientses = patientsService.queryPatient(query); + if (CollectionUtils.isNotEmpty(patientses)) { + Patients patient = patientses.get(0); + UsersQuery usersQuery = new UsersQuery(); + usersQuery.setName(item.getJsz()); + usersQuery.setYn(YnEnums.YES.getId()); + List users = usersService.queryUsers(usersQuery); + if (!CollectionUtils.isNotEmpty(users)) { + usersQuery.setName("产房"); + users = usersService.queryUsers(usersQuery); + } - ExceptionUtils.catchException("size="+list.size()); + if (CollectionUtils.isNotEmpty(users) && users.get(0).getId() != null) { + MatDeliverAddRequest deliverAddRequest = new MatDeliverAddRequest(); - if (CollectionUtils.isNotEmpty(list)) { - for (FmItem item : list) - { - FmPatInfo patInfo = getFmPatInfoById(item.getSyxh()); - System.out.println("patinfo="+patInfo); - System.out.println("item="+item); - } - } + if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(item.getSsrq())) { + continue; + } + + deliverAddRequest.setDueDate(DateUtil.getyyyy_MM_dd(dueDate)); + deliverAddRequest.setParentId(patient.getId()); + deliverAddRequest.setPid(patient.getPid()); + if (StringUtils.isNotEmpty(item.getRc())) { + String week = ""; + if (item.getRc().split("\\u002B").length > 1) { + week = item.getRc().split("\\u002B")[0] + "周"; + week += item.getRc().split("\\u002B")[1] + "天"; + } else { + week = item.getRc() + "周"; + week += item.getJts() + "天"; + } + deliverAddRequest.setDueWeek(week); + } + + deliverAddRequest.setTireNumber(1);//TODO 胎数 + deliverAddRequest.setPlacenta("1");//TODO 胎盘 + + if ("完好".equals(item.getHyqk())) { + deliverAddRequest.setPerinealCondition("full"); + } else if ("会阴切开".equals(item.getHyqk())) { + deliverAddRequest.setPerinealCondition("split"); + } + + if ("一度裂伤".equals(item.getHyqk())) { + deliverAddRequest.setSiLielevel(1); + } else if ("二度裂伤".equals(item.getHyqk())) { + deliverAddRequest.setSiLielevel(2); + } else if ("三度裂伤".equals(item.getHyqk())) { + deliverAddRequest.setSiLielevel(3); + } + + if (StringUtils.isNotEmpty(item.getChexxsxl())) { + deliverAddRequest.settHloseBloodL(Double.parseDouble(item.getChexxsxl())); + } + //胎盘信息 + List extPlacentas = new ArrayList<>(); + MaternalDeliverModel.ExtPlacenta extPlacenta = new MaternalDeliverModel.ExtPlacenta(); + extPlacenta.setMcType(FmTypeEnums.getIdByName(item.getFmfs())); //分娩方式 + String tpmcType = ""; + if ("手术产".equals(item.getTpmcfs())) { + tpmcType = TpmcTypeEnums.O2.getId(); + } else if ("自然产出".equals(item.getTpmcfs())) { + tpmcType = TpmcTypeEnums.O.getId(); + } + extPlacenta.setTpmcType(tpmcType); + extPlacentas.add(extPlacenta); -// if (CollectionUtils.isNotEmpty(list)) { -// for(FmItem item : list) -// { -// String dueDateStr = item.getSsrq(); -// if (!StringUtils.isNotEmpty(dueDateStr)) -// { -// continue; -// } -// Date dueDate = fmt.parse(dueDateStr); -// FmPatInfo patInfo = getFmPatInfoById(item.getSyxh()); -// if (patInfo != null && com.lyms.platform.common.utils.StringUtils.isNotEmpty(patInfo.getLXDH())) -// { -// PatientsQuery query = new PatientsQuery(); -// query.setYn(YnEnums.YES.getId()); -// query.setType(1); //孕妇 -// query.setDueStatus(0); //未终止妊娠 -// query.setPhone(patInfo.getLXDH()); -// List patientses = patientsService.queryPatient(query); -// if (CollectionUtils.isNotEmpty(patientses)) -// { -// Patients patient = patientses.get(0); -// -// UsersQuery usersQuery = new UsersQuery(); -// usersQuery.setName(item.getJsz()); -// usersQuery.setYn(YnEnums.YES.getId()); -// List users = usersService.queryUsers(usersQuery); -// if (!CollectionUtils.isNotEmpty(users)) -// { -// usersQuery.setName("产房"); -// users = usersService.queryUsers(usersQuery); -// } -// -// if (CollectionUtils.isNotEmpty(users) && users.get(0).getId() != null) -// { -// MatDeliverAddRequest deliverAddRequest = new MatDeliverAddRequest(); -// -// if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(item.getSsrq())) -// { -// continue; -// } -// -// deliverAddRequest.setDueDate(DateUtil.getyyyy_MM_dd(dueDate)); -// deliverAddRequest.setParentId(patient.getId()); -// deliverAddRequest.setPid(patient.getPid()); -// if (StringUtils.isNotEmpty(item.getRc())) -// { -// String week = ""; -// if (item.getRc().split("\\u002B").length > 1) -// { -// week = item.getRc().split("\\u002B")[0]+"周"; -// week+= item.getRc().split("\\u002B")[1]+"天"; -// } -// else -// { -// week = item.getRc()+"周"; -// week+=item.getJts()+"天"; -// } -// deliverAddRequest.setDueWeek(week); -// } -// -// deliverAddRequest.setTireNumber(1);//TODO 胎数 -// deliverAddRequest.setPlacenta("1");//TODO 胎盘 -// -// if ("完好".equals(item.getHyqk())) -// { -// deliverAddRequest.setPerinealCondition("full"); -// } -// else if ("会阴切开".equals(item.getHyqk())) -// { -// deliverAddRequest.setPerinealCondition("split"); -// } -// -// if ("一度裂伤".equals(item.getHyqk())) -// { -// deliverAddRequest.setSiLielevel(1); -// } -// else if ("二度裂伤".equals(item.getHyqk())) -// { -// deliverAddRequest.setSiLielevel(2); -// } -// else if ("三度裂伤".equals(item.getHyqk())) -// { -// deliverAddRequest.setSiLielevel(3); -// } -// -// if (StringUtils.isNotEmpty(item.getChexxsxl())) -// { -// deliverAddRequest.settHloseBloodL(Double.parseDouble(item.getChexxsxl())); -// } -// -// //胎盘信息 -// List extPlacentas = new ArrayList<>(); -// MaternalDeliverModel.ExtPlacenta extPlacenta = new MaternalDeliverModel.ExtPlacenta(); -// extPlacenta.setMcType(FmTypeEnums.getIdByName(item.getFmfs())); //分娩方式 -// String tpmcType = ""; -// if ("手术产".equals(item.getTpmcfs())) -// { -// tpmcType = TpmcTypeEnums.O2.getId(); -// } -// else if ("自然产出".equals(item.getTpmcfs())) -// { -// tpmcType = TpmcTypeEnums.O.getId(); -// } -// extPlacenta.setTpmcType(tpmcType); -// extPlacentas.add(extPlacenta); -// -// //儿童 -// List babies = new ArrayList<>(); -// MaternalDeliverModel.Baby baby = new MaternalDeliverModel.Baby(); -// Map as = new HashMap<>(); -// as.put("pf1", item.getYfz()); -// as.put("pf5", item.getWfz()); -// as.put("pf10", item.getSfz()); -// baby.setApgarScore(JsonUtil.obj2JsonString(as)); -// baby.setBabyGender("男".equals(item.getYexb()) ? "1" : "0"); -// baby.setBabyHeight(item.getSc());//新生儿生长 -// baby.setBabyWeight(item.getTz());//新生儿重量 -// baby.setDeformity("无".equals(item.getJx()) ? 0 : 1); //畸形 0非畸形 1畸形 -// baby.setAsphyxiaM(item.getZx()); //窒息分钟 -// baby.setPregnancyOut(RenShenJieJuEnums.getIdByName(item.getCcqk())); // 妊娠结局 -// baby.setBabyHealthy(item.getYeqk()); //新生儿疾病 -// baby.setDueTime(fmt1.format(dueDate));//分娩时间 -// babies.add(baby); -// matDeliverFacade.addOrUpdateMatDeliver(deliverAddRequest, users.get(0).getId()); -// } -// -// } -// } -// } -// } + //儿童 + List babies = new ArrayList<>(); + MaternalDeliverModel.Baby baby = new MaternalDeliverModel.Baby(); + Map as = new HashMap<>(); + as.put("pf1", item.getYfz()); + as.put("pf5", item.getWfz()); + as.put("pf10", item.getSfz()); + baby.setApgarScore(JsonUtil.obj2JsonString(as)); + baby.setBabyGender(" 男 ".equals(item.getYexb()) ? "1" : "0"); + baby.setBabyHeight(item.getSc());//新生儿生长 + baby.setBabyWeight(item.getTz());//新生儿重量 + baby.setDeformity("无".equals(item.getJx()) ? 0 : 1); //畸形 0非畸形 1畸形 + baby.setAsphyxiaM(item.getZx()); //窒息分钟 + baby.setPregnancyOut(RenShenJieJuEnums.getIdByName(item.getCcqk())); // 妊娠结局 + baby.setBabyHealthy(item.getYeqk()); //新生儿疾病 + baby.setDueTime(fmt1.format(dueDate));//分娩时间 + babies.add(baby); + deliverAddRequest.setFmHospital("216"); //设置为秦皇岛分娩医院 + + matDeliverFacade.addOrUpdateMatDeliver(deliverAddRequest, users.get(0).getId()); + } + + } + } + + } catch (Exception e) + { + ExceptionUtils.catchException(e, "数据异常"); + continue; + } + } + } List duoTaiList = queryRunner.query(conn, "select * from JHMK_FMJL where JSZ is not null and SC is not null and TZ is not null and YFZ is not null " + " and SH is not null and (SFFZRSTDT = ' 是 ' or SFSTDT = ' 是 ') and " + - " CONVERT(varchar(50),SSRQ, 20) > CONVERT(varchar(50),'"+start+"', 20) and CONVERT(varchar(50),SSRQ, 20) <= CONVERT(varchar(50),'"+end+"', 20)", new BeanListHandler(FmItem.class)); -// if (CollectionUtils.isNotEmpty(duoTaiList)) { -// Map> maps = new HashMap<>(); -// for(FmItem item : duoTaiList) -// { -// if (maps.containsKey(item.getSyxh())) -// { -// maps.get(item.getSyxh()).add(item); -// } -// else -// { -// List items = new ArrayList(); -// items.add(item); -// maps.put(item.getSyxh(),items); -// } -// -// } -// if (maps.size() > 0) -// { -// for(String key : maps.keySet()) -// { -// List items = maps.get(key); -// FmItem item = items.get(0); -// -// String dueDateStr = item.getSsrq(); -// if (!StringUtils.isNotEmpty(dueDateStr)) -// { -// continue; -// } -// Date dueDate = fmt.parse(dueDateStr); -// FmPatInfo patInfo = getFmPatInfoById(item.getSyxh()); -// if (patInfo != null && com.lyms.platform.common.utils.StringUtils.isNotEmpty(patInfo.getLXDH())) -// { -// PatientsQuery query = new PatientsQuery(); -// query.setYn(YnEnums.YES.getId()); -// query.setType(1); //孕妇 -// query.setDueStatus(0); //未终止妊娠 -// query.setPhone(patInfo.getLXDH()); -// List patientses = patientsService.queryPatient(query); -// if (CollectionUtils.isNotEmpty(patientses)) -// { -// Patients patient = patientses.get(0); -// -// UsersQuery usersQuery = new UsersQuery(); -// usersQuery.setName(item.getJsz()); -// usersQuery.setYn(YnEnums.YES.getId()); -// List users = usersService.queryUsers(usersQuery); -// if (!CollectionUtils.isNotEmpty(users)) -// { -// usersQuery.setName("产房"); -// users = usersService.queryUsers(usersQuery); -// } -// -// if (CollectionUtils.isNotEmpty(users) && users.get(0).getId() != null) -// { -// MatDeliverAddRequest deliverAddRequest = new MatDeliverAddRequest(); -// -// if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(item.getSsrq())) -// { -// continue; -// } -// -// deliverAddRequest.setDueDate(DateUtil.getyyyy_MM_dd(dueDate)); -// deliverAddRequest.setParentId(patient.getId()); -// deliverAddRequest.setPid(patient.getPid()); -// if (StringUtils.isNotEmpty(item.getRc())) -// { -// String week = ""; -// if (item.getRc().split("\\u002B").length > 1) -// { -// week = item.getRc().split("\\u002B")[0]+"周"; -// week+= item.getRc().split("\\u002B")[1]+"天"; -// } -// else -// { -// week = item.getRc()+"周"; -// week+=item.getJts()+"天"; -// } -// deliverAddRequest.setDueWeek(week); -// } -// -// deliverAddRequest.setTireNumber(items.size());//TODO 胎数 -// deliverAddRequest.setPlacenta(items.size()+"");//TODO 胎盘 -// -// if ("完好".equals(item.getHyqk())) -// { -// deliverAddRequest.setPerinealCondition("full"); -// } -// else if ("会阴切开".equals(item.getHyqk())) -// { -// deliverAddRequest.setPerinealCondition("split"); -// } -// -// if ("一度裂伤".equals(item.getHyqk())) -// { -// deliverAddRequest.setSiLielevel(1); -// } -// else if ("二度裂伤".equals(item.getHyqk())) -// { -// deliverAddRequest.setSiLielevel(2); -// } -// else if ("三度裂伤".equals(item.getHyqk())) -// { -// deliverAddRequest.setSiLielevel(3); -// } -// -// if (StringUtils.isNotEmpty(item.getChexxsxl())) -// { -// deliverAddRequest.settHloseBloodL(Double.parseDouble(item.getChexxsxl())); -// } -// -// //胎盘信息 -// List extPlacentas = new ArrayList<>(); -// //儿童 -// List babies = new ArrayList<>(); -// -// for (FmItem item1 : items) -// { -// -// String dueDateStr1 = item1.getSsrq(); -// if (!StringUtils.isNotEmpty(dueDateStr1)) -// { -// continue; -// } -// Date dueDate1 = fmt.parse(dueDateStr1); -// -// MaternalDeliverModel.ExtPlacenta extPlacenta = new MaternalDeliverModel.ExtPlacenta(); -// extPlacenta.setMcType(FmTypeEnums.getIdByName(item1.getFmfs())); //分娩方式 -// String tpmcType = ""; -// if ("手术产".equals(item1.getTpmcfs())) -// { -// tpmcType = TpmcTypeEnums.O2.getId(); -// } -// else if ("自然产出".equals(item1.getTpmcfs())) -// { -// tpmcType = TpmcTypeEnums.O.getId(); -// } -// extPlacenta.setTpmcType(tpmcType); -// extPlacentas.add(extPlacenta); -// -// MaternalDeliverModel.Baby baby = new MaternalDeliverModel.Baby(); -// Map as = new HashMap<>(); -// as.put("pf1",item1.getYfz()); -// as.put("pf5",item1.getWfz()); -// as.put("pf10", item1.getSfz()); -// baby.setApgarScore(JsonUtil.obj2JsonString(as)); -// baby.setBabyGender("男".equals(item1.getYexb()) ? "1" : "0"); -// baby.setBabyHeight(item1.getSc());//新生儿生长 -// baby.setBabyWeight(item1.getTz());//新生儿重量 -// baby.setDeformity("无".equals(item1.getJx()) ? 0 : 1); //畸形 0非畸形 1畸形 -// baby.setAsphyxiaM(item1.getZx()); //窒息分钟 -// baby.setPregnancyOut(RenShenJieJuEnums.getIdByName(item1.getCcqk())); // 妊娠结局 -// baby.setBabyHealthy(item1.getYeqk()); //新生儿疾病 -// baby.setDueTime(fmt1.format(dueDate1));//分娩时间 -// babies.add(baby); -// -// } -// matDeliverFacade.addOrUpdateMatDeliver(deliverAddRequest, users.get(0).getId()); -// } -// -// } -// } -// } -// } -// } + " CONVERT(DATETIME,left(SSRQ,8)+' '+RIGHT(SSRQ,8),20) > CONVERT(DATETIME,'"+start+"', 120) and CONVERT(DATETIME,left(SSRQ,8)+' '+RIGHT(SSRQ,8),20) <= CONVERT(DATETIME,'"+end+"', 120)", new BeanListHandler(FmItem.class)); + if (CollectionUtils.isNotEmpty(duoTaiList)) { + Map> maps = new HashMap<>(); + for(FmItem item : duoTaiList) + { + if (maps.containsKey(item.getSyxh())) + { + maps.get(item.getSyxh()).add(item); + } + else + { + List items = new ArrayList(); + items.add(item); + maps.put(item.getSyxh(),items); + } + + } + if (maps.size() > 0) + { + for(String key : maps.keySet()) + { + List items = maps.get(key); + FmItem item = items.get(0); + + String dueDateStr = item.getSsrq(); + if (!StringUtils.isNotEmpty(dueDateStr)) + { + continue; + } + Date dueDate = fmt.parse(dueDateStr); + FmPatInfo patInfo = getFmPatInfoById(item.getSyxh()); + if (patInfo != null && com.lyms.platform.common.utils.StringUtils.isNotEmpty(patInfo.getLXDH())) + { + PatientsQuery query = new PatientsQuery(); + query.setYn(YnEnums.YES.getId()); + query.setType(1); //孕妇 + query.setDueStatus(0); //未终止妊娠 + query.setPhone(patInfo.getLXDH()); + List patientses = patientsService.queryPatient(query); + if (CollectionUtils.isNotEmpty(patientses)) + { + Patients patient = patientses.get(0); + + UsersQuery usersQuery = new UsersQuery(); + usersQuery.setName(item.getJsz()); + usersQuery.setYn(YnEnums.YES.getId()); + List users = usersService.queryUsers(usersQuery); + if (!CollectionUtils.isNotEmpty(users)) + { + usersQuery.setName("产房"); + users = usersService.queryUsers(usersQuery); + } + + if (CollectionUtils.isNotEmpty(users) && users.get(0).getId() != null) + { + MatDeliverAddRequest deliverAddRequest = new MatDeliverAddRequest(); + + if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(item.getSsrq())) + { + continue; + } + + deliverAddRequest.setDueDate(DateUtil.getyyyy_MM_dd(dueDate)); + deliverAddRequest.setParentId(patient.getId()); + deliverAddRequest.setPid(patient.getPid()); + if (StringUtils.isNotEmpty(item.getRc())) + { + String week = ""; + if (item.getRc().split("\\u002B").length > 1) + { + week = item.getRc().split("\\u002B")[0]+"周"; + week+= item.getRc().split("\\u002B")[1]+"天"; + } + else + { + week = item.getRc()+"周"; + week+=item.getJts()+"天"; + } + deliverAddRequest.setDueWeek(week); + } + + deliverAddRequest.setTireNumber(items.size());//TODO 胎数 + deliverAddRequest.setPlacenta(items.size()+"");//TODO 胎盘 + + if ("完好".equals(item.getHyqk())) + { + deliverAddRequest.setPerinealCondition("full"); + } + else if ("会阴切开".equals(item.getHyqk())) + { + deliverAddRequest.setPerinealCondition("split"); + } + + if ("一度裂伤".equals(item.getHyqk())) + { + deliverAddRequest.setSiLielevel(1); + } + else if ("二度裂伤".equals(item.getHyqk())) + { + deliverAddRequest.setSiLielevel(2); + } + else if ("三度裂伤".equals(item.getHyqk())) + { + deliverAddRequest.setSiLielevel(3); + } + + if (StringUtils.isNotEmpty(item.getChexxsxl())) + { + deliverAddRequest.settHloseBloodL(Double.parseDouble(item.getChexxsxl())); + } + + //胎盘信息 + List extPlacentas = new ArrayList<>(); + //儿童 + List babies = new ArrayList<>(); + + for (FmItem item1 : items) + { + + String dueDateStr1 = item1.getSsrq(); + if (!StringUtils.isNotEmpty(dueDateStr1)) + { + continue; + } + Date dueDate1 = fmt.parse(dueDateStr1); + + MaternalDeliverModel.ExtPlacenta extPlacenta = new MaternalDeliverModel.ExtPlacenta(); + extPlacenta.setMcType(FmTypeEnums.getIdByName(item1.getFmfs())); //分娩方式 + String tpmcType = ""; + if ("手术产".equals(item1.getTpmcfs())) + { + tpmcType = TpmcTypeEnums.O2.getId(); + } + else if ("自然产出".equals(item1.getTpmcfs())) + { + tpmcType = TpmcTypeEnums.O.getId(); + } + extPlacenta.setTpmcType(tpmcType); + extPlacentas.add(extPlacenta); + + MaternalDeliverModel.Baby baby = new MaternalDeliverModel.Baby(); + Map as = new HashMap<>(); + as.put("pf1",item1.getYfz()); + as.put("pf5",item1.getWfz()); + as.put("pf10", item1.getSfz()); + baby.setApgarScore(JsonUtil.obj2JsonString(as)); + baby.setBabyGender("男".equals(item1.getYexb()) ? "1" : "0"); + baby.setBabyHeight(item1.getSc());//新生儿生长 + baby.setBabyWeight(item1.getTz());//新生儿重量 + baby.setDeformity("无".equals(item1.getJx()) ? 0 : 1); //畸形 0非畸形 1畸形 + baby.setAsphyxiaM(item1.getZx()); //窒息分钟 + baby.setPregnancyOut(RenShenJieJuEnums.getIdByName(item1.getCcqk())); // 妊娠结局 + baby.setBabyHealthy(item1.getYeqk()); //新生儿疾病 + baby.setDueTime(fmt1.format(dueDate1));//分娩时间 + babies.add(baby); + + } + deliverAddRequest.setFmHospital("216"); + matDeliverFacade.addOrUpdateMatDeliver(deliverAddRequest, users.get(0).getId()); + } + + } + } + } + } + } DbUtils.closeQuietly(conn); } catch (SQLException e) { ExceptionUtils.catchException(e, "sql执行异常"); e.printStackTrace(); -// } catch (ParseException e) { -// ExceptionUtils.catchException(e,"分娩日期解析错误"); -// e.printStackTrace(); -// } + } catch (ParseException e) { + ExceptionUtils.catchException(e,"分娩日期解析错误"); + e.printStackTrace(); }finally { DbUtils.closeQuietly(conn); } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java index 509cec8..543af4e 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java @@ -1,10 +1,12 @@ package com.lyms.platform.operate.web.controller; import com.lyms.hospitalapi.qhdfy.QhdfyHisService; +import com.lyms.platform.biz.JdbcUtil; import com.lyms.platform.biz.service.*; import com.lyms.platform.common.enums.YnEnums; import com.lyms.platform.common.utils.CompressEncodeingUtil; import com.lyms.platform.common.utils.DateUtil; +import com.lyms.platform.common.utils.ExceptionUtils; import com.lyms.platform.common.utils.JsonUtil; import com.lyms.platform.operate.web.facade.AntenatalExaminationFacade; import com.lyms.platform.operate.web.facade.BabyCheckFacade; @@ -30,6 +32,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import java.io.File; +import java.io.IOException; import java.util.*; /** @@ -944,26 +947,60 @@ public class TestController { return "updateBabyFmHospital finish"; } - public static void main(String[] a) { + @RequestMapping(value = "/updateBabyFmHid", method = RequestMethod.GET) + @ResponseBody + public String updateBabyFmHid(@RequestParam(required = true) String hid) { + List list = null; try { - List list = FileUtils.readLines(new File("D:\\temp\\qhdfy_lost1.csv")); - List linenums = new ArrayList<>(); + list = FileUtils.readLines(new File("D:\\QHD.csv"), "gbk"); for (String line:list) { String ss[] = line.split(","); - if (ss.length > 0 && ss[0].trim().length() > 0) { - linenums.add(ss[0].trim()); + if (ss.length > 1 && ss[0].trim().length() > 0) { + if (ss[0] != null) + { + String id = ss[0].replace("-",""); + String name = ss[1]; + String oid = (String)JdbcUtil.getQhdMysqlSingleObjBySql("select id from organization where name = '" + name + "'",JdbcUtil.getQhdMysqlConnection()); + BabyModelQuery babyModelQuery = new BabyModelQuery(); + babyModelQuery.setYn(YnEnums.YES.getId()); + babyModelQuery.setId(id); + + List models = babyBookbuildingService.queryBabyBuildByCond(babyModelQuery); + if (CollectionUtils.isNotEmpty(models) && com.lyms.platform.common.utils.StringUtils.isNotEmpty(oid)) { + BabyModel model = models.get(0); + model.setDeliverOrg(oid); + babyBookbuildingService.updateBabyBuild(model, model.getId()); + } + } } } - List list1 = FileUtils.readLines(new File("D:\\temp\\qhd-jd.csv"), "utf-8"); - StringBuffer sb = new StringBuffer(); - for (String line:list1) { + } catch (IOException e) { + ExceptionUtils.catchException(e,"跟新异常"); + e.printStackTrace(); + } + return "updateBabyFmHid finish"; + } + + public static void main(String[] a) { + try { + List list = FileUtils.readLines(new File("D:\\QHD.csv"), "gbk"); + List linenums = new ArrayList<>(); + for (String line:list) { String ss[] = line.split(","); - if (ss.length > 0 && ss[0].trim().length() > 0 && linenums.contains(ss[0].trim())) { - sb.append(line); - sb.append("\r\n"); + if (ss.length > 0 && ss[0].trim().length() > 0) { + System.out.println(ss[0]+" "+ ss[1]); } } - FileUtils.writeStringToFile(new File("d:\\temp\\qhdfy_lost_data.csv"), sb.toString()); +// List list1 = FileUtils.readLines(new File("D:\\temp\\qhd-jd.csv"), "utf-8"); +// StringBuffer sb = new StringBuffer(); +// for (String line:list1) { +// String ss[] = line.split(","); +// if (ss.length > 0 && ss[0].trim().length() > 0 && linenums.contains(ss[0].trim())) { +// sb.append(line); +// sb.append("\r\n"); +// } +// } +// FileUtils.writeStringToFile(new File("d:\\temp\\qhdfy_lost_data.csv"), sb.toString()); } catch (Exception e) { e.printStackTrace(); }