Index: ssts-web/src/main/webapp/disinfectsystem/config/sznsrmyy/spring/webservice-cxf.xml =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/config/sznsrmyy/spring/webservice-cxf.xml (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/config/sznsrmyy/spring/webservice-cxf.xml (revision 30231) @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + \ No newline at end of file Index: ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/foreignTousse/service/ForeignTousseWebServiceExImpl.java =================================================================== diff -u --- ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/foreignTousse/service/ForeignTousseWebServiceExImpl.java (revision 0) +++ ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/foreignTousse/service/ForeignTousseWebServiceExImpl.java (revision 30231) @@ -0,0 +1,343 @@ +package com.forgon.disinfectsystem.webservice.foreignTousse.service; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.List; + +import javax.jws.WebService; + +import jxl.common.Logger; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import net.sf.json.xml.XMLSerializer; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Node; +import org.dom4j.XPath; +import org.springframework.beans.factory.annotation.Autowired; + +import com.forgon.directory.acegi.tools.AcegiHelper; +import com.forgon.disinfectsystem.basedatamanager.supplier.service.SupplierManager; +import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; +import com.forgon.disinfectsystem.datasynchronization.model.PatientInfoVO; +import com.forgon.disinfectsystem.datasynchronization.service.DataSynchronizationManager; +import com.forgon.disinfectsystem.entity.basedatamanager.supplier.Supplier; +import com.forgon.disinfectsystem.entity.basedatamanager.supplyroomconfig.SupplyRoomConfig; +import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseDefinition; +import com.forgon.disinfectsystem.entity.foreigntousseapplication.ForeignTousseApplication; +import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan; +import com.forgon.disinfectsystem.foreigntousseapplication.service.ForeignTousseApplicationManager; +import com.forgon.disinfectsystem.tousse.toussedefinition.service.TousseDefinitionManager; +import com.forgon.log.model.Log; +import com.forgon.log.service.LogManager; +import com.forgon.tools.GB2Alpha; +import com.forgon.tools.GB2WB; +import com.forgon.tools.hibernate.ObjectDao; +import com.forgon.tools.util.ConfigUtils; +import com.forgon.tools.util.ForgonDateUtils; + +@WebService(endpointInterface = "com.forgon.disinfectsystem.webservice.foreignTousse.service.ForeignTousseWebServiceEx", serviceName = "foreignTousseWebServiceEx") +public class ForeignTousseWebServiceExImpl extends ForeignTousseWebServiceImpl implements ForeignTousseWebServiceEx { + + private Logger logger = Logger.getLogger(this.getClass()); + @Autowired + private LogManager appLogManager; + @Autowired + private ObjectDao objectDao; + @Autowired + private SupplyRoomConfigManager supplyRoomConfigManager; + @Autowired + private DataSynchronizationManager dataSynchronizationManager; + @Autowired + private SupplierManager supplierManager; + @Autowired + private ForeignTousseApplicationManager foreignTousseApplicationManager; + @Autowired + private TousseDefinitionManager tousseDefinitionManager; + + //单号前缀 + final static String SERIALNUMBER_PREFIX = "SYNC_"; + + @Override + public String submitForeignTousseApplication(String param) { + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,参数param=" + param); + logger.debug("调用外来器械包接口的submitForeignTousseApplication方法,参数param=" + param); + JSONObject returnJSONObject = new JSONObject(); + returnJSONObject.put("result", "0"); + returnJSONObject.put("message", ""); + XMLSerializer xmlSerializer = new XMLSerializer(); + xmlSerializer.setRootName("return"); + //保留元素类型标识,默认true + xmlSerializer.setTypeHintsEnabled(false); + if(StringUtils.isBlank(param)){ + returnJSONObject.put("message","请求信息为空!"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return xmlSerializer.write(returnJSONObject); + } + + Document document; + try { + document = DocumentHelper.parseText(param); + if(document != null){ + String serialNumXpath = "/param/SERIALNUMBER"; + String hospitalNumXpath = "/param/HOSPITAL_NUMBER"; + String applicantXpath = "/param/APPLICANT"; + String departCodeXpath = "/param/DEPART_CODE"; + + String departXpath = "/param/DEPART_NAME"; + String settlementDepartCodeXpath = "/param/SETTLEMENT_DEPART_CODE"; + String settlementDepartNameXpath = "/param/SETTLEMENT_DEPART_NAME"; + String appTimeXpath = "/param/APPLICATION_TIME"; + + String serialNumber = processDataByXpath(document, serialNumXpath); + serialNumber = SERIALNUMBER_PREFIX + serialNumber; + String hospitalNumber = processDataByXpath(document, hospitalNumXpath); + String applicant = processDataByXpath(document, applicantXpath); + String departCode = processDataByXpath(document, departCodeXpath); + + String departName = processDataByXpath(document, departXpath); + String settlementDepartCode = processDataByXpath(document, settlementDepartCodeXpath); + String settlementDepartName = processDataByXpath(document, settlementDepartNameXpath); + String applicationTime = processDataByXpath(document, appTimeXpath); + + String itemXpath = "/param/items/item"; + XPath xpath = document.createXPath(itemXpath); + @SuppressWarnings("unchecked") + List nodeList = xpath.selectNodes(document, xpath); + + // true:显示原始的包定义;false或者没有配置:显示最近一次申请的包定义 + boolean isShowForeignTousseAncestorDefinitionForApply = + ConfigUtils.getSystemSetConfigByNameBool("isShowForeignTousseAncestorDefinitionForApply"); + + SupplyRoomConfig supplyRoomConfig = supplyRoomConfigManager.getSystemParamsObj(); + JSONArray jsonArray = new JSONArray(); + if(CollectionUtils.isNotEmpty(nodeList)){ + for (int i=1; i<=nodeList.size(); i++) { + itemXpath = "/param/items/item[" + i + "]"; + String supplierNameXPath = itemXpath + "/SUPPLIER_NAME"; + String tousseNameXPath = itemXpath + "/TOUSSENAME"; + String materialJsonStrXPath = itemXpath + "/MATERIAL_LIST"; + + String supplierName = processDataByXpath(document, supplierNameXPath); + String tousseName = processDataByXpath(document, tousseNameXPath); + String materialJsonStr = processDataByXpath(document, materialJsonStrXPath); + // 材料 + JSONArray materialArr = JSONArray.fromObject(materialJsonStr); + + if(StringUtils.isBlank(tousseName)){ + returnJSONObject.put("message","TOUSSENAME不能为空!"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return xmlSerializer.write(returnJSONObject); + } + + if(StringUtils.isBlank(materialJsonStr)){ + returnJSONObject.put("message","MATERIAL_LIST不能为空!"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return xmlSerializer.write(returnJSONObject); + } + + if(materialArr != null && materialArr.size() > 0){ + for (Object object : materialArr) { + JSONObject json = (JSONObject)object; + String materialName = json.optString("materialName"); + String amount = json.optString("amount"); + if(StringUtils.isBlank(materialName)){ + returnJSONObject.put("message","materialName不能为空!"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return xmlSerializer.write(returnJSONObject); + } + if(StringUtils.isBlank(amount)){ + returnJSONObject.put("message","amount不能为空!"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return xmlSerializer.write(returnJSONObject); + } + } + } + + String hql = String.format("select po from %s po where po.tousseType = '%s' and po.name = '%s' and po.supplierName = '%s' and (po.isDisable is null or po.isDisable ='%s')", + TousseDefinition.class.getSimpleName(), TousseDefinition.PACKAGE_TYPE_FOREIGN, + tousseName, supplierName==null?"":supplierName, TousseDefinition.STR_NO); + if(isShowForeignTousseAncestorDefinitionForApply){ + hql += " and po.forDisplay = 1 "; + } + hql += " order by po.id desc "; + List tousseList = objectDao.findByHql(hql); + TousseDefinition tousseDefinition = new TousseDefinition(); + if(CollectionUtils.isNotEmpty(tousseList)){ + tousseDefinition = tousseList.get(0); + } + JSONObject foreignTousseInfoJsonObject = new JSONObject(); + foreignTousseInfoJsonObject.put("amount", 1); + foreignTousseInfoJsonObject.put("tousseName", tousseName); + foreignTousseInfoJsonObject.put("supplierName", supplierName); + foreignTousseInfoJsonObject.put("price", + tousseDefinition.getPrice() == null || tousseDefinition.getPrice() == 0 ? supplyRoomConfig.getForeignToussePrice() : tousseDefinition.getPrice()); + foreignTousseInfoJsonObject.put("materials", materialArr); + jsonArray.add(foreignTousseInfoJsonObject); + } + }else{ + returnJSONObject.put("message", "未找到item节点!"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return xmlSerializer.write(returnJSONObject); + } + + //供应商联系人、供应商联系电话 + String supplierContactUser = null, supplierContactPhone = null; + //查询第一个外来器械包的供应商作为外来器械申请单的联系人与联系电话 + if(jsonArray != null && jsonArray.size() > 0){ + JSONObject firstSupplierJsonObject = jsonArray.optJSONObject(0); + String supplierName = firstSupplierJsonObject.optString("supplierName"); + //根据供应商名称及厂商类型查询供应商 + if(StringUtils.isNotBlank(supplierName)){ + Supplier supplier = supplierManager.getFirst(" companyName = '"+ supplierName +"' and rentTousse = '"+ Supplier.SUPPLIER_TYPE_RENTTOUSSE +"'"); + if(supplier != null){ + supplierContactUser = supplier.getContact(); + supplierContactPhone = supplier.getCellPhone(); + } + } + } + String foreignTousseInfo = jsonArray.toString(); + //住院号 + if(StringUtils.isBlank(hospitalNumber)){ + returnJSONObject.put("message","HOSPITAL_NUMBER节点不能为空"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return xmlSerializer.write(returnJSONObject); + } + if(StringUtils.isBlank(applicant)){ + returnJSONObject.put("message","APPLICANT节点不能为空"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return xmlSerializer.write(returnJSONObject); + } + if(StringUtils.isBlank(departName)){ + returnJSONObject.put("message","DEPART_NAME节点不能为空"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return xmlSerializer.write(returnJSONObject); + } + if(StringUtils.isBlank(departCode)){ + returnJSONObject.put("message","DEPART_CODE节点不能为空"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return xmlSerializer.write(returnJSONObject); + } + ForeignTousseApplication orginalForeignTousseApplication = foreignTousseApplicationManager.getFirst("serialNumber='"+ serialNumber +"'"); + //调用外来器械申请单业务方法 + ForeignTousseApplication foreignTousseApplication = null; + //如果根据单号能找到外来器械申请单,那就进行干预修改的操作 + if(orginalForeignTousseApplication == null){ + foreignTousseApplication = new ForeignTousseApplication(); + foreignTousseApplication.setType(InvoicePlan.TYPE_FOREIGNTOUSSEAPPLIACTION); + foreignTousseApplication.setSerialNumber(serialNumber); + foreignTousseApplication.setApplicant(applicant); + foreignTousseApplication.setDepart(departName); + foreignTousseApplication.setDepartCoding(departCode); + foreignTousseApplication.setSettleAccountsDepart(settlementDepartName); + if(StringUtils.isBlank(foreignTousseApplication.getSettleAccountsDepart())){ + foreignTousseApplication.setSettleAccountsDepart(foreignTousseApplication.getDepart()); + } + foreignTousseApplication.setSettleAccountsDepartCoding(settlementDepartCode); + if(StringUtils.isBlank(foreignTousseApplication.getSettleAccountsDepartCoding())){ + foreignTousseApplication.setSettleAccountsDepartCoding(foreignTousseApplication.getSettleAccountsDepartCoding()); + } + foreignTousseApplication.setApplicationTime(ForgonDateUtils.safelyParseDate(applicationTime)); + PatientInfoVO[] patientInfoVOs = dataSynchronizationManager.findPatientInfoByHospitalNum(hospitalNumber); + if(patientInfoVOs != null && patientInfoVOs.length > 0){ + foreignTousseApplication.setHospitalNumber(hospitalNumber); + foreignTousseApplication.setPatient(patientInfoVOs[0].getPatientName()); + foreignTousseApplication.setPatientAge(patientInfoVOs[0].getPatientAge()); + foreignTousseApplication.setPatientArea(patientInfoVOs[0].getPatientArea()); + foreignTousseApplication.setPatientSex(patientInfoVOs[0].getPatientSex()); + foreignTousseApplication.setDoctor(patientInfoVOs[0].getDoctorName()); + foreignTousseApplication.setOperationRoom(patientInfoVOs[0].getOpRoomId()); + foreignTousseApplication.setAscriptionDepartment(patientInfoVOs[0].getAscriptionDepartment()); + if(StringUtils.isNotBlank(patientInfoVOs[0].getOperationTime())){ + foreignTousseApplication.setOperationTime(ForgonDateUtils.safelyParseDate(patientInfoVOs[0].getOperationTime())); + } + foreignTousseApplication.setRoomNumber(patientInfoVOs[0].getRoomNumber()); + foreignTousseApplication.setSurgery(patientInfoVOs[0].getOperation()); + } + foreignTousseApplication.setPackageStatus(InvoicePlan.RECYCLINGSTATUS_AWAITRECEIVE); + foreignTousseApplication.setOrderByFiled(InvoicePlan.DELIVER_AWAITDELIVER); + // 设置五笔码和拼音码 + foreignTousseApplication.setSpelling(GB2Alpha.string2Alpha(departName)); + foreignTousseApplication.setWbCode(GB2WB.getWBCode(departName)); + //设置外来器械申请单的供应商联系人与联系电话 + foreignTousseApplication.setSupplierContactName(supplierContactUser); + foreignTousseApplication.setSupplierPhoneNumber(supplierContactPhone); + foreignTousseApplicationManager.saveOrUpdate(foreignTousseApplication, foreignTousseInfo, ForeignTousseApplication.ACTION_TYPE_ADD); + }else{ + if(!StringUtils.equals(orginalForeignTousseApplication.getApplicant(), applicant)){ + orginalForeignTousseApplication.setApplicant(applicant); + } + if(!StringUtils.equals(orginalForeignTousseApplication.getDepart(), departName)){ + orginalForeignTousseApplication.setDepart(departName); + } + if(!StringUtils.equals(orginalForeignTousseApplication.getDepartCoding(), departCode)){ + orginalForeignTousseApplication.setDepartCoding(departCode); + } + if(StringUtils.isBlank(settlementDepartName)){ + orginalForeignTousseApplication.setSettleAccountsDepart(departName); + }else if(!StringUtils.equals(orginalForeignTousseApplication.getSettleAccountsDepart(), settlementDepartName)){ + orginalForeignTousseApplication.setSettleAccountsDepart(settlementDepartName); + } + if(StringUtils.isBlank(settlementDepartCode)){ + orginalForeignTousseApplication.setSettleAccountsDepartCoding(departCode); + }else if(!StringUtils.equals(orginalForeignTousseApplication.getSettleAccountsDepartCoding(), settlementDepartCode)){ + orginalForeignTousseApplication.setSettleAccountsDepartCoding(settlementDepartCode); + } + orginalForeignTousseApplication.setApplicationTime(ForgonDateUtils.safelyParseDate(applicationTime)); + if(!StringUtils.equals(orginalForeignTousseApplication.getHospitalNumber(), hospitalNumber)){ + orginalForeignTousseApplication.setHospitalNumber(hospitalNumber); + PatientInfoVO[] patientInfoVOs = dataSynchronizationManager.findPatientInfoByHospitalNum(hospitalNumber); + if(patientInfoVOs != null && patientInfoVOs.length > 0){ + orginalForeignTousseApplication.setHospitalNumber(hospitalNumber); + orginalForeignTousseApplication.setPatient(patientInfoVOs[0].getPatientName()); + orginalForeignTousseApplication.setPatientAge(patientInfoVOs[0].getPatientAge()); + orginalForeignTousseApplication.setPatientArea(patientInfoVOs[0].getPatientArea()); + orginalForeignTousseApplication.setPatientSex(patientInfoVOs[0].getPatientSex()); + orginalForeignTousseApplication.setDoctor(patientInfoVOs[0].getDoctorName()); + orginalForeignTousseApplication.setOperationRoom(patientInfoVOs[0].getOpRoomId()); + orginalForeignTousseApplication.setAscriptionDepartment(patientInfoVOs[0].getAscriptionDepartment()); + if(StringUtils.isNotBlank(patientInfoVOs[0].getOperationTime())){ + orginalForeignTousseApplication.setOperationTime(ForgonDateUtils.safelyParseDate(patientInfoVOs[0].getOperationTime())); + } + orginalForeignTousseApplication.setRoomNumber(patientInfoVOs[0].getRoomNumber()); + orginalForeignTousseApplication.setSurgery(patientInfoVOs[0].getOperation()); + } + } + //设置外来器械申请单的供应商联系人与联系电话 + orginalForeignTousseApplication.setSupplierContactName(supplierContactUser); + orginalForeignTousseApplication.setSupplierPhoneNumber(supplierContactPhone); + objectDao.saveOrUpdate(orginalForeignTousseApplication); + } + returnJSONObject.put("result" , "1"); + + } + } catch (DocumentException e) { + e.printStackTrace(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + e.printStackTrace(new PrintStream(baos)); + String exception = baos.toString(); + returnJSONObject.put("message", exception); + logger.info("调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return xmlSerializer.write(returnJSONObject); + } + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return xmlSerializer.write(returnJSONObject); + } + + private String processDataByXpath(Document document, String xpathExp) { + if ((StringUtils.isNotBlank(xpathExp)) && (document != null)) { + XPath xpath = document.createXPath(xpathExp); + Node node = xpath.selectSingleNode(document); + if (node != null) { + return node.getStringValue(); + } + } + return null; + } + + +} Index: ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/foreignTousse/service/ForeignTousseWebServiceEx.java =================================================================== diff -u --- ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/foreignTousse/service/ForeignTousseWebServiceEx.java (revision 0) +++ ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/foreignTousse/service/ForeignTousseWebServiceEx.java (revision 30231) @@ -0,0 +1,116 @@ +package com.forgon.disinfectsystem.webservice.foreignTousse.service; + +import javax.jws.WebMethod; +import javax.jws.WebService; + +/** + * 外来器械webservice接口 + * @author zhouPeiMian + * @since 2021-01-12 + */ +@WebService +public interface ForeignTousseWebServiceEx { + + /** + * 查询外来器械包的信息(含供应商名称、联系人、外来器械包信息等) + * @return xml格式的字符串文本,格式为: + * + 1 //1表示成功,0为不成功 + //消息 + ...... //具体的数据内容 + + */ + @WebMethod(action="findForeignTousseInfo") + public String findForeignTousseInfo(); + + /** + * 获取所有供应商 + * @return + */ + @WebMethod(action="findAllSupplier") + public String findAllSupplier(); + + /** + * 根据厂商查询外来器械包的信息(含供应商名称、联系人、外来器械包信息等)(供应商名称为空则返回所有供应商的外来器械包) + * @return xml格式的字符串文本,格式为: + * + 1 //1表示成功,0为不成功 + //消息 + ...... //具体的数据内容 + + */ + @WebMethod(action="findForeignTousseInfoBySupplierName") + public String findForeignTousseInfoBySupplierName(String supplierName); + + /** + * 查询外来器械包的信息(含供应商名称、联系人、外来器械包信息等) + * @param param 外来器械申请单的参数,格式为: + + + + + + + + + + + + + + + + + + + + + + + + + + * @return xml格式的字符串文本,格式为: + * + 1 //1表示成功,0为不成功 + //消息 + + */ + @WebMethod(action="submitForeignTousseApplication") + public String submitForeignTousseApplication(String param); + +} Index: ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/spring/webservice-cxf.xml =================================================================== diff -u -r28956 -r30231 --- ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/spring/webservice-cxf.xml (.../webservice-cxf.xml) (revision 28956) +++ ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/spring/webservice-cxf.xml (.../webservice-cxf.xml) (revision 30231) @@ -17,4 +17,13 @@ address="/inventoryStockWebService" implementor="#inventoryStockWebService" /> + + + + + + + \ No newline at end of file