Index: ssts-web/src/main/resources/spring/projects/gdszyy/timer.xml =================================================================== diff -u --- ssts-web/src/main/resources/spring/projects/gdszyy/timer.xml (revision 0) +++ ssts-web/src/main/resources/spring/projects/gdszyy/timer.xml (revision 26593) @@ -0,0 +1,35 @@ + + + + + + + + + + + + syncForeignTousseApplication + + + + + + + + + + 0 0/10 * * * ? + + + + + + + + + + + + + \ No newline at end of file Index: build.gradle =================================================================== diff -u -r26581 -r26593 --- build.gradle (.../build.gradle) (revision 26581) +++ build.gradle (.../build.gradle) (revision 26593) @@ -839,6 +839,7 @@ compile (project(":ssts-expensivegoods")) compile (project(":ssts-tousse")) compile (project(":ssts-userecord")) + compile (project(":ssts-recyclingapplication")) } } Index: ssts-datasync/src/main/java/com/forgon/disinfectsystem/datasynchronization/service/DataSynchronizationManager.java =================================================================== diff -u -r26566 -r26593 --- ssts-datasync/src/main/java/com/forgon/disinfectsystem/datasynchronization/service/DataSynchronizationManager.java (.../DataSynchronizationManager.java) (revision 26566) +++ ssts-datasync/src/main/java/com/forgon/disinfectsystem/datasynchronization/service/DataSynchronizationManager.java (.../DataSynchronizationManager.java) (revision 26593) @@ -102,6 +102,11 @@ /** * 同步住院病人信息及科室人员信息,项目启动时开始监听消息队列(北京垂杨柳医院) */ - void initializeRunOnceSyncData(); + public void initializeRunOnceSyncData(); + + /** + * 同步外来器械申请单 + */ + public void syncForeignTousseApplication(); } Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gdszyy/DatasyncConstant.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gdszyy/DatasyncConstant.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gdszyy/DatasyncConstant.java (revision 26593) @@ -0,0 +1,36 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.gdszyy; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * 广东省中医院接口相关常量 + * + */ +public class DatasyncConstant { + /** + * 外来器械申请单同步接口地址 + */ + public static String URL = "http://192.168.195.162:8092/services/Lis?wsdl"; + /** + * 外来器械申请单同步服务 + */ + public static String SYNCSERVICE = "getDeliveryInfoSync"; + /** + * 外来器械申请单同步成功后发送回复信息的服务名称 + */ + public static String RESPONCESERVICE = "updateDeliveryStateSync"; + /** + * 由于医院有4个院区,需要发送4个单位编码获取4个不同院区的外来器械申请单 + */ + public static String[] COMPCODES = {"100101"}; + /** + * 东软望海OES平台 院区编号和追溯系统科室编号的对应 + */ + public static Map DEPARTCODE = new LinkedHashMap(); + + static{ + // OES的院区编号-->追溯系统的科室编号 + DEPARTCODE.put("100101", "0010301902"); + } +} Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/service/DataSynchronizationManagerImpl.java =================================================================== diff -u -r26566 -r26593 --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/service/DataSynchronizationManagerImpl.java (.../DataSynchronizationManagerImpl.java) (revision 26566) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/service/DataSynchronizationManagerImpl.java (.../DataSynchronizationManagerImpl.java) (revision 26593) @@ -33,6 +33,7 @@ import com.forgon.disinfectsystem.common.CssdUtils; import com.forgon.disinfectsystem.datasynchronization.dao.FindPatientInfoByHospitalNumDao; import com.forgon.disinfectsystem.datasynchronization.dao.FindPatientInfoByTreatmentNumDao; +import com.forgon.disinfectsystem.datasynchronization.dao.SyncForeignTousseApplicationDao; import com.forgon.disinfectsystem.datasynchronization.dao.SyncOrgUnitAndUserDao; import com.forgon.disinfectsystem.datasynchronization.dao.SyncOrgUnitAndUserSource2Dao; import com.forgon.disinfectsystem.datasynchronization.dao.SyncSupplierDao; @@ -49,7 +50,6 @@ import com.forgon.disinfectsystem.inventorymanagement.dao.InventoryDao; import com.forgon.disinfectsystem.inventorymanagement.model.Inventory; import com.forgon.disinfectsystem.inventorymanagement.model.entity.InventoryTemporaryData; -import com.forgon.disinfectsystem.mq.dao.bjcylyy.MQHelper; import com.forgon.disinfectsystem.tousse.materialdefinition.service.MaterialDefinitionManager; import com.forgon.disinfectsystem.useRecord.service.gyey.PatientAdmissionInfoManager; import com.forgon.log.model.Log; @@ -65,7 +65,6 @@ import com.forgon.tools.GB2WB; import com.forgon.tools.db.DatabaseUtil; import com.forgon.tools.hibernate.ObjectDao; -import com.forgon.tools.util.ConfigUtils; import com.forgon.treenode.model.THTreeNode; import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -142,6 +141,16 @@ */ private JsonObject config; + /** + * 外来器械包申请单同步 + */ + private SyncForeignTousseApplicationDao syncForeignTousseApplicationDao; + + public void setSyncForeignTousseApplicationDao( + SyncForeignTousseApplicationDao syncForeignTousseApplicationDao) { + this.syncForeignTousseApplicationDao = syncForeignTousseApplicationDao; + } + public void setConfig(JsonObject config) { this.config = config; } @@ -1122,5 +1131,16 @@ } } } + + /** + * 同步外来器械申请单(广东省中医院) + */ + @Override + public void syncForeignTousseApplication() { + if (syncForeignTousseApplicationDao == null) { + return; + } + syncForeignTousseApplicationDao.syncForeignTousseApplication(); + } } Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gdszyy/SyncForeignTousseApplicationDaoImpl.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gdszyy/SyncForeignTousseApplicationDaoImpl.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gdszyy/SyncForeignTousseApplicationDaoImpl.java (revision 26593) @@ -0,0 +1,328 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.gdszyy; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.StringReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.List; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.Node; +import org.dom4j.XPath; +import org.dom4j.io.SAXReader; + +import com.forgon.disinfectsystem.datasynchronization.dao.SyncForeignTousseApplicationDao; +import com.forgon.disinfectsystem.entity.foreigntousseapplication.ForeignTousseApplication; +import com.forgon.disinfectsystem.foreigntousseapplication.service.ForeignTousseApplicationManager; +import com.forgon.tools.SpringBeanManger; + +public class SyncForeignTousseApplicationDaoImpl implements SyncForeignTousseApplicationDao{ + + private static Logger logger = Logger.getLogger(SyncForeignTousseApplicationDaoImpl.class); + + /** + * 根据部门编码,通过webService接口获取外来器械申请单(广东省中医院) + * @param url webService接口地址 + * @param service 服务名称 + * @param compCode 部门编码 + * @return 外来器械申请单xml字符串集合 + */ + @Override + public List getForeignTousseApplicationFromWebService(String urlStr, String service, String compCode){ + logger.debug("开始同步外来器械申请单,部门编码:【" + compCode + "】"); + if (null == urlStr) { + logger.debug("webService接口地址为空!"); + return null; + } + //外来器械申请单xml字符串集合 + ArrayList responces = new ArrayList(); + try { + URL url = new URL(urlStr); + //打开连接 + URLConnection conn; + conn = url.openConnection(); + //转换成HttpURL + HttpURLConnection httpConn = (HttpURLConnection) conn; + //打开输入输出的开关 + httpConn.setDoInput(true); + httpConn.setDoOutput(true); + //设置请求方式 + httpConn.setRequestMethod("POST"); + //设置请求的头信息 + httpConn.setRequestProperty("Content-type", "text/xml;charset=UTF-8"); + //拼接请求消息 + String data = "" + +"" + // 服务名称getDeliveryInfoSync + +"" + +"" + // 部门编码 + +""+ compCode +"" + +"" + +"" + +"" + +""; + logger.debug("请求信息:" + data); + //获得输出流 + OutputStream out = httpConn.getOutputStream(); + //发送数据 + out.write(data.getBytes()); + //判断请求成功 + if(httpConn.getResponseCode() == 200){ + //获得输入流 + InputStream in = httpConn.getInputStream(); + //使用输入流的缓冲区 + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + StringBuffer sb = new StringBuffer(); + String line = null; + //读取输入流 + while((line = reader.readLine()) != null){ + sb.append(line); + } + //创建sax的读取器 + SAXReader saxReader = new SAXReader(); + //创建文档对象 + Document doc; + doc = saxReader.read(new StringReader(sb.toString())); + //获得请求响应return元素 + List eles = doc.selectNodes("//return"); + for(Element ele : eles){ + // 包含请求失败的返回信息 + responces.add(ele.getText()); + logger.debug("响应信息:" + ele.getText()); + } + } + } catch (IOException e) { + logger.debug("连接webService接口【"+ urlStr + "】失败!"); + e.printStackTrace(); + } catch (DocumentException e) { + logger.debug("解析xml失败!"); + e.printStackTrace(); + } + return responces; + } + + /** + * 外来器械申请单同步成功后调用 + * @param url webService接口地址 + * @param service 服务名称 + * @param deliveryCode 申请单编号 + */ + @Override + public void returnSuccessMessage (String urlStr, String service, String deliveryCode) { + logger.debug("返回同步成功信息,申请单ID:【" + deliveryCode + "】"); + if (null == urlStr) { + logger.debug("webService接口地址为空!"); + return; + } + try { + URL url = new URL(urlStr); + //打开连接 + URLConnection conn; + conn = url.openConnection(); + //转换成HttpURL + HttpURLConnection httpConn = (HttpURLConnection) conn; + //打开输入输出的开关 + httpConn.setDoInput(true); + httpConn.setDoOutput(true); + //设置请求方式 + httpConn.setRequestMethod("POST"); + //设置请求的头信息 + httpConn.setRequestProperty("Content-type", "text/xml;charset=UTF-8"); + //拼接请求消息 + String data = "" + + "" + // 服务名称updateDeliveryStateSync + + "" + + "" + + " " + + "" + + deliveryCode + + "成功" + + "]]>" + + "" + + "" + + "" + + ""; + logger.debug("更新OES接收成功信息:" + data); + //获得输出流 + java.io.OutputStream out = httpConn.getOutputStream(); + //发送数据 + out.write(data.getBytes()); + } catch (IOException e) { + logger.debug("连接webService接口【"+ urlStr + "】失败!"); + e.printStackTrace(); + } + } + + /** + * 同步外来器械申请单 + */ + @Override + public void syncForeignTousseApplication() { + try { + // 分部门同步外来器械申请单 + for (String compCode : DatasyncConstant.COMPCODES) { + // 获取当前分院的外来器械申请单 + List applicationXMLList = getForeignTousseApplicationFromWebService(DatasyncConstant.URL, DatasyncConstant.SYNCSERVICE, compCode); + if (null != applicationXMLList && applicationXMLList.size() > 0) { + for (String applicationStr : applicationXMLList) { + try{ + Document document = DocumentHelper.parseText(applicationStr); + String businessSyncMsgXpath = "/xml/head/businessSyncMsg"; + String businessSyncMsg = processDataByXpath(document, businessSyncMsgXpath); // 判断是否查询成功 + if ("成功".equals(businessSyncMsg)) { + // 申请单列表 + String orderInfoXpath = "/xml/body/OrderInfo"; + XPath xpath1 = document.createXPath(orderInfoXpath); + List nodeList1 = xpath1.selectNodes(document, xpath1); // 申请单列表 + if (null != nodeList1 && nodeList1.size() > 0) { + // 一个单位有多张外来器械申请单 + for(int i = 1; i <= nodeList1.size(); i++) { + // 外来器械申请单信息 + ForeignTousseApplication foreignTousseApplication = new ForeignTousseApplication(); + // 申请单信息 + JSONObject applicationJSON = new JSONObject(); + // 器械包材料列表 + JSONArray materialArray = new JSONArray(); + applicationJSON.put("materials", materialArray); + String orderInfoDetailXpath = "/xml/body/OrderInfo["+ i +"]/OrderInfoDetail"; + XPath xpath2 = document.createXPath(orderInfoDetailXpath); + List nodeList2 = xpath2.selectNodes(document, xpath2); + if (null != nodeList2 && nodeList2.size() > 0) { + String supplierName = null; // 器械包供应商 + String name = null; //器械包名称 + // 一张申请单包含多种器械包及材料 + for (int j = 1; j <= nodeList2.size(); j++) { + String amountXpath = "/xml/body/OrderInfo["+ i +"]/OrderInfoDetail[" + j +"]/amount"; + String includeImplantXpath = "/xml/body/OrderInfo["+ i +"]/OrderInfoDetail[" + j +"]/isImplantation"; + String materialNameXpath = "/xml/body/OrderInfo["+ i +"]/OrderInfoDetail[" + j +"]/invName"; + String amount = processDataByXpath(document, amountXpath); // 材料数量 + String includeImplant = processDataByXpath(document, includeImplantXpath); // 是否是植入物 + String materialInstanceId = null; // + String materialName = processDataByXpath(document, materialNameXpath); // 材料名称 + String minDismantleAmount = "0"; // + int usedAmountOfIncludeImplant = 0; // + // 器械包材料明细 + JSONObject materialObj = new JSONObject(); + materialObj.put("amount", amount); + materialObj.put("includeImplant", includeImplant); + materialObj.put("materialInstanceId", materialInstanceId); + materialObj.put("materialName", materialName); + materialObj.put("minDismantleAmount", minDismantleAmount); + materialObj.put("usedAmountOfIncludeImplant", usedAmountOfIncludeImplant); + materialArray.add(materialObj); + String supplierNameXpath = "/xml/body/OrderInfo["+ i +"]/OrderInfoDetail[" + j +"]/venName"; + supplierName = processDataByXpath(document, supplierNameXpath); + String nameXpath = "/xml/body/OrderInfo["+ i +"]/OrderInfoDetail[" + j +"]/packageName"; + name = processDataByXpath(document, nameXpath); // 器械包名称 + } + applicationJSON.put("amount", 1); + applicationJSON.put("foreignToussePrintAmount", 1); + applicationJSON.put("oldSupplierName", supplierName); + applicationJSON.put("oldTousseName", name); + applicationJSON.put("packageSize", null); + applicationJSON.put("price", 0); + applicationJSON.put("splitNumber", 1); + applicationJSON.put("supplierName", supplierName); + applicationJSON.put("tousseDefinitionId", ""); + applicationJSON.put("tousseItemId", 0); + applicationJSON.put("tousseName", name); + applicationJSON.put("weight", ""); + } + // 处理科室名称及编码 + String handleDepartXpath = "/xml/body/OrderInfo["+ i +"]/deptName"; + String handleDepartCodingXpath = "/xml/body/OrderInfo["+ i +"]/deptCode"; + String handleDepart = processDataByXpath(document, handleDepartXpath); //处理科室名称 + String handleDepartCoding = processDataByXpath(document, handleDepartCodingXpath); // 处理科室编码 + // String specification = ""; + String invoicePlanIDXpath = "/xml/body/OrderInfo["+ i +"]/billCode"; + String invoicePlanID = processDataByXpath(document, invoicePlanIDXpath); //OES申请单ID + String operation = null; // 手术名称 + // String manufacturer = null; // 生成厂家 + foreignTousseApplication.setType(ForeignTousseApplication.TYPE_FOREIGNTOUSSEAPPLIACTION); + foreignTousseApplication.setSerialNumber(invoicePlanID); + foreignTousseApplication.setDepartCoding(DatasyncConstant.DEPARTCODE.get(compCode)); + foreignTousseApplication.setSurgery(operation); + foreignTousseApplication.setHandleDepart(handleDepart); + foreignTousseApplication.setHandleDepartCoding(handleDepartCoding); + // 保存外来器械申请单 + saveForeignTousseApplication(foreignTousseApplication, applicationJSON); + returnSuccessMessage(DatasyncConstant.URL, DatasyncConstant.RESPONCESERVICE, invoicePlanID); + } + } + } else { + logger.debug("单位编码为【" + compCode + "】的外来器械申请单查找失败!\n" + applicationStr); + } + } catch (DocumentException e) { + logger.debug("解析xml出错!\n" + applicationStr); + e.printStackTrace(); + } + } + // 拿到数据之后返回单号和成功给对方通知我们获取同步成功 + returnSuccessMessage(DatasyncConstant.URL, DatasyncConstant.RESPONCESERVICE, compCode); + } + } + } catch (Exception e) { + logger.debug("创建url地址出错!"); + e.printStackTrace(); + } + } + + /** + * 保存外来器械包申请单(三种操作类型:“新增”、“干预”、“确认归还\提前归还”). + * @return + */ + public void saveForeignTousseApplication(ForeignTousseApplication foreignTousseApplication, JSONObject foreignTousseInfo) { + //[{"tousseItemId":0,"tousseDefinitionId":218066,"oldTousseName":"笛形针","tousseName":"笛形针","oldSupplierName":"洁定","supplierName":"洁定","amount":1,"price":0,"packageSize":"大包","foreignToussePrintAmount":1,"splitNumber":1,"materials":[{"materialInstanceId":0,"materialName":"test1","amount":4,"includeImplant":"否","usedAmountOfIncludeImplant":0,"minDismantleAmount":0},{"materialInstanceId":0,"materialName":"test2","amount":0,"includeImplant":"是","usedAmountOfIncludeImplant":0,"minDismantleAmount":0}]}] + String actionType = ForeignTousseApplication.ACTION_TYPE_ADD; + try { + ForeignTousseApplicationManager foreignTousseApplicationManager = + ((ForeignTousseApplicationManager)SpringBeanManger.getBean("foreignTousseApplicationManager")); + if (foreignTousseApplicationManager != null) { + foreignTousseApplicationManager.saveOrUpdate(foreignTousseApplication, foreignTousseInfo.toString(), actionType); + } + } catch (Exception e) { + logger.error("外来器械申请单保存失败:" + e); + } + } + + /** + * 根据document和Xpath表达式解析数据 + * @param document + * @param xpathExp + * @return + */ + public static String processDataByXpath(Document document, String xpathExp) { + logger.debug("调用processDataByXpath方法解析数据..."); + if ((StringUtils.isNotBlank(xpathExp)) && (document != null)) { + XPath xpath = document.createXPath(xpathExp); + Node node = xpath.selectSingleNode(xpath); + if (null != node) { + return node.getText(); + } + } + return null; + } + + +} Index: ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java =================================================================== diff -u -r26453 -r26593 --- ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java (.../RecyclingRecordManagerImpl.java) (revision 26453) +++ ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java (.../RecyclingRecordManagerImpl.java) (revision 26593) @@ -43,6 +43,7 @@ import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; import com.forgon.disinfectsystem.basedatamanager.urgent.service.UrgentLevelManager; import com.forgon.disinfectsystem.common.CssdUtils; +import com.forgon.disinfectsystem.datasynchronization.dao.SyncForeignTousseApplicationDao; import com.forgon.disinfectsystem.entity.assestmanagement.DiposableGoodsInstance; import com.forgon.disinfectsystem.entity.basedatamanager.container.Container; import com.forgon.disinfectsystem.entity.basedatamanager.materialdefinition.MaterialDefinition; @@ -190,6 +191,12 @@ private UrgentLevelManager urgentLevelManager; + private SyncForeignTousseApplicationDao syncForeignTousseApplicationDao; + + public void setSyncForeignTousseApplicationDao( + SyncForeignTousseApplicationDao syncForeignTousseApplicationDao) { + this.syncForeignTousseApplicationDao = syncForeignTousseApplicationDao; + } public void setUrgentLevelManager(UrgentLevelManager urgentLevelManager) { this.urgentLevelManager = urgentLevelManager; } @@ -1666,6 +1673,16 @@ //都已经归还了,就删除 delete(record); } + // 广东省中医院外来器械包同步后,要求给平台返回申请单id及回收成功信息 + if (syncForeignTousseApplicationDao != null) { + if (InvoicePlan.TYPE_FOREIGNTOUSSEAPPLIACTION.equals(application.getType())){ + String URL = "http://192.168.195.162:8092/services/Lis?wsdl"; + String service = "updateDeliveryStateSync"; + String deliveryCode = application.getSerialNumber(); + syncForeignTousseApplicationDao.returnSuccessMessage(URL, service, deliveryCode); + logger.debug("外来器械包申请单回收完成,返回申请单id及回收成功信息,申请单ID:【" + deliveryCode + "】"); + } + } // throw new RuntimeException("测试"); } Index: ssts-web/src/main/resources/spring/projects/gdszyy/HIS.xml =================================================================== diff -u -r25243 -r26593 --- ssts-web/src/main/resources/spring/projects/gdszyy/HIS.xml (.../HIS.xml) (revision 25243) +++ ssts-web/src/main/resources/spring/projects/gdszyy/HIS.xml (.../HIS.xml) (revision 26593) @@ -116,4 +116,10 @@ + + + + + \ No newline at end of file Index: ssts-datasync/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/SyncForeignTousseApplicationDao.java =================================================================== diff -u --- ssts-datasync/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/SyncForeignTousseApplicationDao.java (revision 0) +++ ssts-datasync/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/SyncForeignTousseApplicationDao.java (revision 26593) @@ -0,0 +1,30 @@ +package com.forgon.disinfectsystem.datasynchronization.dao; + +import java.net.URL; +import java.util.List; + +public interface SyncForeignTousseApplicationDao { + + /** + * 根据部门编码,通过webService接口获取外来器械申请单(广东省中医院) + * @param url webService接口地址 + * @param service 服务名称 + * @param compCode 部门编码 + * @return 外来器械申请单xml字符串集合 + */ + public List getForeignTousseApplicationFromWebService(String urlStr, String service, String compCode); + + /** + * 同步外来器械申请单 + */ + public void syncForeignTousseApplication(); + + /** + * 外来器械申请单同步成功后调用 + * @param url webService接口地址 + * @param service 服务名称 + * @param deliveryCode 申请单编号 + */ + public void returnSuccessMessage (String urlStr, String service, String deliveryCode); + +}