注入 bean 失敗 org.springframework.beans.factory.BeanCreationException 異常

啓動 Tomcat 服務器,報出如下錯誤 出現 org.springframework.beans.factory.BeanCreationException 異常

1

 

通過觀察上圖中被標記出來的異常信息,可以知道

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘XXX’

此異常,爲:注入 bean 失敗異常。

說白了,出現這個異常,就是找不到對應的 bean 啦!能夠導致 bean 注入失敗的原因包括以下幾種但不限於這幾種:

  1. 對應的 bean 沒有添加註解;
  2. 對應的 bean 添加註解錯誤,例如將 Spring 的@Service錯選成 dubbo 的;
  3. 選擇錯誤的自動注入方法等。

 

SSH架構下項目當中報這個是因爲我在Service層中添加的註解錯誤導致的,

正確註解爲

service層

--接口   (我在service接口中使用了 @WebService 標註了接口  這個才導致項目啓動報錯  )

/**
 * Service 接口
 *
 */
public interface SonghuodanServiceI extends CommonService{

}

 

--實現類

@Service("SonghuodanService")
@Transactional
public class BaseSonghuodanServiceImpl extends CommonServiceImpl implements SonghuodanServiceI {

}

 

在這裏就引出了一個知識點 @WebService  是什麼 , 有什麼樣的作用?

WebService簡介
Web Service技術, 能使得運行在不同機器上的不同應用無須藉助附加的、專門的第三方軟件或硬件, 就可相互交換數據或集成。依據Web Service規範實施的應用之間, 無論它們所使用的語言、 平臺或內部協議是什麼, 都可以相互交換數據。

簡單的說,WebService就是一種跨編程語言和跨操作系統平臺的遠程調用技術。所謂跨編程語言和跨操作平臺,就是說服務端程序採用java編寫,客戶端程序則可以採用其他編程語言編寫,反之亦然。跨操作系統平臺則是指服務端程序和客戶端程序可以在不同的操作系統上運行。 遠程調用,就是一臺計算機的應用可以調用其他計算機上的應用。例如:支付寶,支付寶並沒有銀行卡等數據,它只是去調用銀行提供的接口來獲得數據。還有天氣預報等,也是氣象局把自己的系統服務以webservice服務的形式暴露出來,讓第三方網站和程序可以調用這些服務功能。


Web服務的三個核心

一.Soap

  SOAP(Simple Object Access Protocol,簡單對象訪問協議)是一個基於xml的協議,用於在分步的應用程序都可以識別。另外,SOAP本身沒有定義任何程序語言,這使得SOAP能夠以消息的形式傳遞到各種遠程系統中。

  SOAP所使用的傳輸協議,可以是HTTP,SMTP,POP3,JMS。

  SOAP包括了4部分:

   01.“SOAP封裝(Envelope)”:

定義一個描述信息描述的內容是什麼,是誰發送的,誰應當處理他,以及如何處理他們的框架。

  02.“SOAP編碼規則”:

 用於表示應用程序需要使用的數據類型的實例。

  03.“SOAP RPC":

 表示遠程過程中調用和應答的協定。

  04.“SOPA綁定”:

  使用底層協議交換信息。

二.WSDL

  WSDL(Web Service Description Language,web服務描述語言)是一個XML文檔,他以一種和具體語言無關的抽象方式定義了給定web服務收發者的有關操作和消息。

 

三.UDDI

UDDI(Universal Description Discovery and Integration,統一描述發現和集成協議)是一個規範,定義了與web服務相關的信息的發佈,發現和管理。

 

參考文章鏈接:https://blog.csdn.net/c99463904/article/details/76018436

 

生產項目中也用到了@WebService 註解 主要是用於系統間的數據推送和接收,還有配合了 Apache CXF 一起使用的。

Apache  CXF 簡介

Apache CXF = Celtix + XFire,開始叫 Apache CeltiXfire,後來更名爲 Apache CXF 了,以下簡稱爲 CXF。CXF 繼承了 Celtix 和 XFire 兩大開源項目的精華,提供了對 JAX-WS 全面的支持,並且提供了多種 Binding 、DataBinding、Transport 以及各種 Format 的支持,並且可以根據實際項目的需要,採用代碼優先(Code First)或者 WSDL 優先(WSDL First)來輕鬆地實現 Web Services 的發佈和使用。Apache CXF已經是一個正式的Apache頂級項目。

 

 

關於框架

Apache CXF 是一個開源的 Services 框架,CXF 幫助您利用 Frontend 編程 API 來構建和開發 Services ,像 JAX-WS 。這些 Services 可以支持多種協議,比如:SOAP、XML/HTTP、RESTful HTTP 或者 CORBA ,並且可以在多種傳輸協議上運行,比如:HTTP、JMS 或者 JBI,CXF 大大簡化了 Services 的創建,同時它繼承了 XFire 傳統,一樣可以天然地和 Spring 進行無縫集成。

功能特性

CXF 包含了大量的功能特性,但是主要集中在以下幾個方面:

支持 Web Services 標準:CXF 支持多種 Web Services 標準,包含 SOAP、Basic Profile、WS-Addressing、WS-Policy、WS-ReliableMessaging 和 WS-Security。Frontends:CXF 支持多種“Frontend”編程模型,CXF 實現了JAX-WS API (遵循 JAX-WS 2.0 TCK 版本),它也包含一個“simple frontend”允許客戶端和 EndPoint 的創建,而不需要 Annotation 註解。CXF 既支持 WSDL優先開發,也支持從 Java 的代碼優先開發模式。容易使用: CXF 設計得更加直觀與容易使用。有大量簡單的 API 用來快速地構建代碼優先的 Services,各種 Maven 的插件也使集成更加容易,支持 JAX-WS API ,支持 Spring 2.0 更加簡化的 XML 配置方式,等等。支持二進制和遺留協議:CXF 的設計是一種可插撥的架構,既可以支持 XML ,也可以支持非 XML 的類型綁定,比如:JSON 和 CORBA。

項目目標

下面列出了來自 Apache CXF 官方網站的項目目標。

概要

高性能可擴展簡單且容易使用支持多種標準

支持 JAX-WSJAX-RS、JSR-181 和 SAAJ;支持 SOAP 1.1、1.2、WS-I BasicProfile、WS-Security、WS-Addressing、WS-RM 和 WS-Policy;支持 WSDL 1.1 、2.0;支持 MTOM;

多種傳輸方式、Bindings、Data Bindings 和 Format

Bindings:SOAP、REST/HTTP;Data Bndings:目前支持 JAXB 2.0、Aegis 兩種,默認是 JAXB 2.0。XMLBeans、Castor 和 JiBX 數據綁定方式將在 CXF 2.1 版本中得到支持;格式(Format):XML、JSON;傳輸方式:HTTP、Servlet、JMS 和 Jabber;可擴展的 API 允許爲 CXF 增加其它的 Bindings,以能夠支持其它的消息格式,比如:CSV 和固定記錄長度。

項目特點

編輯

靈活部署

輕量級容器:可在 Tomcat 或基於 Spring 的容器中部署 Services;集成 JBI:可以在如 ServiceMix, OpenESB or Petals 等等的 JBI 容器中將它部署爲一個服務引擎;集成 SCA:可以部署在如 Tuscany 之類的 SCA 容器中;集成 J2EE:可以在 J2EE 應用服務器中部署 Services,比如:Geronimo、JOnAS、JBoss、WebSphere Application Server 和 WebLogic Application Server,以及 Jetty 和 Tomcat;獨立的 Java 客戶端/服務器。

支持編程語言

全面支持 JAX-WS 2.0 客戶端/服務器編程模型;支持 JAX-WS 2.0 synchronous、asynchronous 和 one-way API's;支持 JAX-WS 2.0 Dynamic Invocation Interface (DII) API;支持 wrapped and non-wrapped 風格;支持 XML messaging API;支持 JavaScript 和 ECMAScript 4 XML (E4X) ,客戶端與服務端均支持;通過 Yoko 支持 CORBA;通過 Tuscany 支持 SCA;通過 ServiceMix 支持 JBI ;

代碼生成

Java to WSDL;WSDL to Java;XSD to WSDL;WSDL to XML;WSDL to SOAP;WSDL to Service;

CXF 框架支撐環境

CXF 框架是一種基於 Servlet 技術的 SOA 應用開發框架,要正常運行基於 CXF 應用框架開發的企業應用,除了 CXF 框架本身之外,還需要 JDK 和 Servlet 容器的支持。

 

一個系統數據傳輸的demo   (推送數據)

 

Service 層

--接口

import org.jeecgframework.core.common.service.CommonService;

import java.io.Serializable;

public interface SonghuodanServiceI extends CommonService{
 	/**
 	 * 提交發貨
 	 * @throws Exception 
 	 */
	public void delivery(String id) throws Exception ;
	
}

 

--實現類


import com.szerp.enums.BillTypeEnum;

import com.szerp.enums.SalesAccountsEnum;
import com.szerp.enums.basesonghuodanEnum;

import com.szerp.util.WebServiceUtil;
import com.szerp.wmsmateriel.entity.WmsMaterielEntity;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.jeecgframework.core.common.exception.BusinessException;
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import org.jeecgframework.core.constant.Globals;

import com.fr.third.com.lowagie.tools.SplitPdf;
import com.szerp.baseclient.entity.BaseClientEntity;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.io.Serializable;
import java.text.SimpleDateFormat;

import org.jeecgframework.core.util.ApplicationContextUtil;
import org.jeecgframework.core.util.ListUtils;
import org.jeecgframework.core.util.MyClassLoader;
import org.jeecgframework.core.util.ResourceUtil;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecgframework.web.cgform.enhance.CgformEnhanceJavaInter;
import org.jeecgframework.web.system.service.SystemService;
@Service("SonghuodanService")
@Transactional
public class SonghuodanServiceImpl extends CommonServiceImpl implements SonghuodanServiceI {

/**
 	 * 推送數據
 	 * @throws Exception 
 	 */
	@Override
	public void delivery(String id)  {
		//送貨單
		BaseSonghuodanEntity entity = getEntity(BaseSonghuodanEntity.class, id);
		//送貨單明細
		List<BaseSonghuodansublistEntity> details = systemService.findByProperty(BaseSonghuodansublistEntity.class, "songhuodanid", id);
		//銷售合同
		//SalesContractEntity contractEntity = systemService.findUniqueByProperty(SalesContractEntity.class, "contractCode", entity.getKehuCode());
		JSONObject json=new JSONObject();
		json.put("SourceOrder", entity.getSonghuodanhao());
		json.put("CustomerCode", entity.getKehuCode());
		json.put("address",entity.getPeisongaddr());
		json.put("orderType", "3");
		

		JSONArray array=new JSONArray();
		for(BaseSonghuodansublistEntity detail:details){
			JSONObject jd=new JSONObject();
			jd.put("skuCode", detail.getWuliaobianhao());
			jd.put("deliverQuantity", detail.getFahuoshuliang());
			jd.put("ActualDeliverQuantity", '0');
			
			array.add(jd);
		}
		json.put("Details", array);
		System.out.println("json==="+json.toString());
		//調用接口
		String result = WebServiceUtil.callInterface(systemService,"PickingService","InsertPicking",json.toString());	
		JSONObject resultJson=JSONObject.fromObject(result);
		String flag=resultJson.getString("state");//0:成功1:失敗
		if(flag!=null&&flag.equals("1")){
			entity.setSonghuodantype(basesonghuodanEnum.SUBMIT.getStatus());
			systemService.saveOrUpdate(entity);
		}else{
			throw new BusinessException(resultJson.getString("msg"));
		}
	}
	


}

 

WebServiceUtil.callInterface 類

package com.szerp.util;

import org.apache.commons.lang3.StringUtils;
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import org.jeecgframework.web.system.service.SystemService;

import com.szerp.cgformerpjiekou.entity.CgformErpjiekouEntity;
import com.szerp.util.JiekouWebservice;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class WebServiceUtil {
	
	/** 校驗後沒有問題 **/
	public static String NO_PROBLEM = "OK";
	
	/**
	 * @description 接口調用(已在接口表cgfrom_erpjiekou配置)
	 * @param systemService SystemService實例
	 * @param serviceName 服務名稱
	 * @param methodName 方法名稱
	 * @param params 傳參
	 * @return 所調用的接口返回結果(未根據serviceName和methodName在系統中查到接口配置時。返回null)
	 */
    public static String callInterface(SystemService systemService, String serviceName, String methodName, Object... params){
    	CgformErpjiekouEntity jiekouEntity = systemService.getOne(methodName, serviceName);
    	// serviceName、methodName輸入有誤或未配置
    	if (jiekouEntity == null) {
    		return null;
		}
    	// 操作編碼和ID未配置,爲null值時,在getCxfServiceESB方法中會報錯
    	if (null == jiekouEntity.getCaozuobianma()) {
    		jiekouEntity.setCaozuobianma("");
		}
    	if (null == jiekouEntity.getCaozuoid()) {
    		jiekouEntity.setCaozuoid("");;
    	}
    	String result = JiekouWebservice.JiekouDiaoYong(jiekouEntity, params);
    	return result;
    }
    
    /**
     * @description 接口調用(未配置到接口表,直接調用,主要用於測試)
     * @param webserviceUrl 服務完整地址
     * @param namespace 命名空間
     * @param methodName 方法名稱
     * @param params 傳參
     * @return 返回結果
     */
    public static String callInterface(String webserviceUrl, String namespace, String methodName, Object... params){
		try {
			Object[] res = CommonServiceImpl.getCxfServiceESB("", "", webserviceUrl, namespace, methodName, params);
			if(res != null && res.length > 0) {
				return JSONArray.fromObject(res).get(0).toString();
			}else{
				return "接口返回值爲空";
			}
		} catch (Exception e) {
			e.printStackTrace();
			return "接口調用報錯";
		} 
    }
    
    /**
     * @description 必要參數判空校驗
     * @param paramsJson 調用接口所傳參數
     * @param needVerifyParams 待校驗字段字符串數組
     * @return 校驗結果(待判斷字段全部存在且不爲空則返回“OK”,否則返回詳細信息,詳細信息可用於接口直接返回給調用者)
     */
    public static String paramsEmptyVerify(JSONObject paramsJson, String[] needVerifyParams) {
    	// 所有校驗字段全部存在且不爲空則返回“OK”
    	String result = NO_PROBLEM;
    	for (int i = 0; i < needVerifyParams.length; i++) {
    		if (!paramsJson.containsKey(needVerifyParams[i]) || StringUtils.isBlank(paramsJson.getString(needVerifyParams[i]))) {
    			result = "必要字段“" + needVerifyParams[i] + "”不存在或值爲空";
    			break;
    		}
		}
    	return result;
    }

    /**
     * @description 獲取非必要參數值,不存在或爲空則返回""
     * @param paramsJson 調用接口所傳參數
     * @param oneParamString 待獲取參數
     * @return 參數值
     */
    public static String getNotNecessaryValue(JSONObject paramsJson, String oneParamString) {
    	String result = "";
    	if (paramsJson.containsKey(oneParamString) && StringUtils.isNotBlank(paramsJson.getString(oneParamString))) {
    		result = paramsJson.getString(oneParamString);
		}
    	return result;
    }
}

cgform_erpjiekou 接口類實體

package com.szerp.cgformerpjiekou.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.jeecgframework.poi.excel.annotation.Excel;


@Entity
@Table(name = "cgform_erpjiekou", schema = "")
@SuppressWarnings("serial")
public class CgformErpjiekouEntity implements java.io.Serializable {
    /** ID */
    private java.lang.String id;
    /** 接口名稱 */
    @Excel(name = "接口名稱")
    private java.lang.String jiekoumingcheng;
    /** 接口方法 */
    @Excel(name = "接口方法")
    private java.lang.String jiekoufangfa;
    /** 操作編碼 */
    @Excel(name = "操作編碼")
    private java.lang.String caozuobianma;
    /** 操作ID */
    @Excel(name = "操作ID")
    private java.lang.String caozuoid;
    /** 備註 */
    @Excel(name = "備註")
    private java.lang.String beizhu;
    /** 接口ID */
    @Excel(name = "接口ID")
    private java.lang.String jiekouid;
    /** 創建人名稱 */
    @Excel(name = "創建人名稱")
    private java.lang.String createName;
    /** 創建時間 */
    @Excel(name = "創建時間", format = "yyyy-MM-dd")
    private java.util.Date createDate;
    /** 工作空間WORKSPACE */
    @Excel(name = "工作空間")
    private java.lang.String workspace;
    /** 項目名稱 */
    @Excel(name = "項目名稱")
    private java.lang.String project;
    /** ESB接口 */
    @Excel(name = "ESB接口")
    private java.lang.String esbjiekou;

    @Column(name = "ESBJIEKOU", nullable = true, length = 200)
    public java.lang.String getEsbjiekou() {
        return esbjiekou;
    }

    public void setEsbjiekou(java.lang.String esbjiekou) {
        this.esbjiekou = esbjiekou;
    }

    @Column(name = "PROJECT", nullable = true, length = 200)
    public java.lang.String getProject() {
        return project;
    }

    public void setProject(java.lang.String project) {
        this.project = project;
    }

    @Column(name = "ISSTATE", nullable = true, length = 200)
    public java.lang.String getIsstate() {
        return isstate;
    }

    public void setIsstate(java.lang.String isstate) {
        this.isstate = isstate;
    }

    @Column(name = "JKTYPE", nullable = true, length = 200)
    public java.lang.String getJktype() {
        return jktype;
    }

    public void setJktype(java.lang.String jktype) {
        this.jktype = jktype;
    }

    /** 啓用狀態 */
    @Excel(name = "啓用狀態")
    private java.lang.String isstate;
    /** 接口類型 0:ESB 1:項目 */
    @Excel(name = "接口類型 0:ESB 1:項目")
    private java.lang.String jktype;

    @Column(name = "workspace", nullable = true, length = 200)
    public java.lang.String getWorkspace() {
        return workspace;
    }

    public void setWorkspace(java.lang.String workspace) {
        this.workspace = workspace;
    }

    /**
     * 方法: 取得java.lang.String
     * 
     * @return: java.lang.String ID
     */
    @Id
    @GeneratedValue(generator = "paymentableGenerator")
    @GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
    @Column(name = "ID", nullable = false, length = 36)
    public java.lang.String getId() {
        return this.id;
    }

    /**
     * 方法: 設置java.lang.String
     * 
     * @param: java.lang.String
     *             ID
     */
    public void setId(java.lang.String id) {
        this.id = id;
    }

    /**
     * 方法: 取得java.lang.String
     * 
     * @return: java.lang.String 接口名稱
     */
    @Column(name = "JIEKOUMINGCHENG", nullable = true, length = 200)
    public java.lang.String getJiekoumingcheng() {
        return this.jiekoumingcheng;
    }

    /**
     * 方法: 設置java.lang.String
     * 
     * @param: java.lang.String
     *             接口名稱
     */
    public void setJiekoumingcheng(java.lang.String jiekoumingcheng) {
        this.jiekoumingcheng = jiekoumingcheng;
    }

    /**
     * 方法: 取得java.lang.String
     * 
     * @return: java.lang.String 接口方法
     */
    @Column(name = "JIEKOUFANGFA", nullable = true, length = 200)
    public java.lang.String getJiekoufangfa() {
        return this.jiekoufangfa;
    }

    /**
     * 方法: 設置java.lang.String
     * 
     * @param: java.lang.String
     *             接口方法
     */
    public void setJiekoufangfa(java.lang.String jiekoufangfa) {
        this.jiekoufangfa = jiekoufangfa;
    }

    /**
     * 方法: 取得java.lang.String
     * 
     * @return: java.lang.String 操作編碼
     */
    @Column(name = "CAOZUOBIANMA", nullable = true, length = 200)
    public java.lang.String getCaozuobianma() {
        return this.caozuobianma;
    }

    /**
     * 方法: 設置java.lang.String
     * 
     * @param: java.lang.String
     *             操作編碼
     */
    public void setCaozuobianma(java.lang.String caozuobianma) {
        this.caozuobianma = caozuobianma;
    }

    /**
     * 方法: 取得java.lang.String
     * 
     * @return: java.lang.String 操作ID
     */
    @Column(name = "CAOZUOID", nullable = true, length = 200)
    public java.lang.String getCaozuoid() {
        return this.caozuoid;
    }

    /**
     * 方法: 設置java.lang.String
     * 
     * @param: java.lang.String
     *             操作ID
     */
    public void setCaozuoid(java.lang.String caozuoid) {
        this.caozuoid = caozuoid;
    }

    /**
     * 方法: 取得java.lang.String
     * 
     * @return: java.lang.String 備註
     */
    @Column(name = "BEIZHU", nullable = true, length = 2000)
    public java.lang.String getBeizhu() {
        return this.beizhu;
    }

    /**
     * 方法: 設置java.lang.String
     * 
     * @param: java.lang.String
     *             備註
     */
    public void setBeizhu(java.lang.String beizhu) {
        this.beizhu = beizhu;
    }

    /**
     * 方法: 取得java.lang.String
     * 
     * @return: java.lang.String 接口ID
     */
    @Column(name = "JIEKOUID", nullable = true, length = 200)
    public java.lang.String getJiekouid() {
        return this.jiekouid;
    }

    /**
     * 方法: 設置java.lang.String
     * 
     * @param: java.lang.String
     *             接口ID
     */
    public void setJiekouid(java.lang.String jiekouid) {
        this.jiekouid = jiekouid;
    }

    /**
     * 方法: 取得java.lang.String
     * 
     * @return: java.lang.String 創建人名稱
     */
    @Column(name = "CREATE_NAME", nullable = true, length = 200)
    public java.lang.String getCreateName() {
        return this.createName;
    }

    /**
     * 方法: 設置java.lang.String
     * 
     * @param: java.lang.String
     *             創建人名稱
     */
    public void setCreateName(java.lang.String createName) {
        this.createName = createName;
    }

    /**
     * 方法: 取得java.util.Date
     * 
     * @return: java.util.Date 創建時間
     */
    @Column(name = "CREATE_DATE", nullable = true)
    public java.util.Date getCreateDate() {
        return this.createDate;
    }

    /**
     * 方法: 設置java.util.Date
     * 
     * @param: java.util.Date
     *             創建時間
     */
    public void setCreateDate(java.util.Date createDate) {
        this.createDate = createDate;
    }
}

 

   	ID	JIEKOUMINGCHENG	JIEKOUFANGFA	CAOZUOBIANMA	CAOZUOID	BEIZHU	JIEKOUID	CREATE_NAME	CREATE_DATE	WORKSPACE	PROJECT	ISSTATE	JKTYPE	ESBJIEKOU
	402881ee67304a4c016730595f4f0017	http://ip:端口/PickingService.asmx?wsdl	InsertPicking	cmf.esb.wms	cmf.esb.wms.picking.PickingService	123	PickingService	123		http://tempuri.org/PickingService	2	0	0	http://ip:端口/cmf.esb.wms.picking?wsdl

 

JiekouWebservice.JiekouDiaoYong 類

 

package com.szerp.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.jeecgframework.core.common.service.impl.CommonServiceImpl;

import com.szerp.cgformerpjiekou.entity.CgformErpjiekouEntity;

public class JiekouWebservice {

    public static String JiekouDiaoYong(CgformErpjiekouEntity cgentity, java.lang.Object... params) {
        // 接口調用
        /*
         * String path=ConfigUtil.getWebServiceURLPrefix();
         * path+="/"+cgentity.getJiekoumingcheng();
         */
        String path = "";
        /*
         * if(cgentity.getJktype()!=null){ if(cgentity.getJktype().equals("0")){
         * path=cgentity.getJiekoumingcheng(); }else if(cgentity.equals("1")){
         * path=cgentity.getEsbjiekou(); } }
         */
        if (cgentity.getJktype() != null && !cgentity.equals("")) {
            if (Integer.parseInt(cgentity.getJktype()) == 0) {
                path = cgentity.getJiekoumingcheng();
            } else if (Integer.parseInt(cgentity.getJktype()) == 1) {
                path = cgentity.getEsbjiekou();
            }
        }

        try {
            if (path != null && !path.equals("")) {
                Object[] res = CommonServiceImpl.getCxfServiceESB(cgentity.getCaozuobianma(), cgentity.getCaozuoid(),
                        path, cgentity.getWorkspace(), cgentity.getJiekoufangfa(), params);
                if (res != null && res.length > 0) {
                    return res[0].toString();
                } else {
                    return "接口返回值爲空";
                }
            } else {
                return "接口請求路徑爲空";
            }
        } catch (Exception e) {
            return "接口調用報錯";
        }

    }

    public static Date getAddTime(Date time, int num) {
        // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd
        // HH:mm:ss");
        Date currdate = time;
        try {
            Calendar ca = Calendar.getInstance();
            ca.setTime(currdate);
            ca.add(Calendar.DATE, num);// num爲增加的天數,可以改變的
            currdate = ca.getTime();
        } catch (Exception e) {
            System.err.println("時間添加出錯");
            e.printStackTrace();
        }
        return currdate;
    }
}

 

CommonServiceImpl.getCxfServiceESB 類

/*     */ package org.jeecgframework.core.common.service.impl;
/*     */ 
/*     */ import com.szerp.cgformerpjiekou.entity.CgformErpjiekouEntity;
/*     */ import com.szerp.util.LMD5Util;
/*     */ import java.io.FileInputStream;
/*     */ import java.io.PrintStream;
/*     */ import java.io.Serializable;
/*     */ import java.text.DecimalFormat;
/*     */ import java.util.Arrays;
/*     */ import java.util.Collection;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Properties;
/*     */ import javax.annotation.Resource;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import javax.xml.namespace.QName;
/*     */ import org.apache.cxf.endpoint.Client;
/*     */ import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
/*     */ import org.apache.cxf.message.Message;
/*     */ import org.hibernate.Query;
/*     */ import org.hibernate.SQLQuery;
/*     */ import org.hibernate.Session;
/*     */ import org.hibernate.criterion.DetachedCriteria;
/*     */ import org.hibernate.transform.Transformers;
/*     */ import org.jeecgframework.core.common.dao.ICommonDao;
/*     */ import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
/*     */ import org.jeecgframework.core.common.hibernate.qbc.HqlQuery;
/*     */ import org.jeecgframework.core.common.hibernate.qbc.PageList;
/*     */ import org.jeecgframework.core.common.model.common.DBTable;
/*     */ import org.jeecgframework.core.common.model.common.UploadFile;
/*     */ import org.jeecgframework.core.common.model.json.ComboTree;
/*     */ import org.jeecgframework.core.common.model.json.DataGridReturn;
/*     */ import org.jeecgframework.core.common.model.json.ImportFile;
/*     */ import org.jeecgframework.core.common.model.json.TreeGrid;
/*     */ import org.jeecgframework.core.common.service.CommonService;
/*     */ import org.jeecgframework.core.util.PropertiesUtil;
/*     */ import org.jeecgframework.tag.vo.datatable.DataTableReturn;
/*     */ import org.jeecgframework.tag.vo.easyui.Autocomplete;
/*     */ import org.jeecgframework.tag.vo.easyui.ComboTreeModel;
/*     */ import org.jeecgframework.tag.vo.easyui.TreeGridModel;
/*     */ import org.jeecgframework.web.system.pojo.base.TSDepart;
/*     */ import org.springframework.stereotype.Service;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ 
/*     */ @Service("commonService")
/*     */ @Transactional
/*     */ public class CommonServiceImpl
/*     */   implements CommonService
/*     */ {
/*  50 */   public ICommonDao commonDao = null;
/*  51 */   private static JaxWsDynamicClientFactory clientfactory = null;
/*  52 */   private static String wsuname = "";
/*  53 */   private static String md5pass = "";
/*  54 */   private static String wsclientconfigfile = "";
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public List<DBTable> getAllDbTableName()
/*     */   {
/*  62 */     return commonDao.getAllDbTableName();
/*     */   }
/*     */   
/*     */   public Integer getAllDbTableSize() {
/*  66 */     return commonDao.getAllDbTableSize();
/*     */   }
/*     */   
/*     */   @Resource
/*     */   public void setCommonDao(ICommonDao commonDao) {
/*  71 */     this.commonDao = commonDao;
/*     */   }
/*     */   
/*     */   public <T> Serializable save(T entity)
/*     */   {
/*  76 */     return commonDao.save(entity);
/*     */   }
/*     */   
/*     */   public <T> void saveOrUpdate(T entity)
/*     */   {
/*  81 */     commonDao.saveOrUpdate(entity);
/*     */   }
/*     */   
/*     */ 
/*     */   public <T> void delete(T entity)
/*     */   {
/*  87 */     commonDao.delete(entity);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> void deleteAllEntitie(Collection<T> entities)
/*     */   {
/*  98 */     commonDao.deleteAllEntitie(entities);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public <T> T get(Class<T> class1, Serializable id)
/*     */   {
/* 105 */     return (T)commonDao.get(class1, id);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> List<T> getList(Class clas)
/*     */   {
/* 117 */     return commonDao.loadAll(clas);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public <T> T getEntity(Class entityName, Serializable id)
/*     */   {
/* 124 */     return (T)commonDao.getEntity(entityName, id);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> T findUniqueByProperty(Class<T> entityClass, String propertyName, Object value)
/*     */   {
/* 138 */     return (T)commonDao.findUniqueByProperty(entityClass, propertyName, value);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> List<T> findByProperty(Class<T> entityClass, String propertyName, Object value)
/*     */   {
/* 147 */     return commonDao.findByProperty(entityClass, propertyName, value);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> List<T> loadAll(Class<T> entityClass)
/*     */   {
/* 158 */     return commonDao.loadAll(entityClass);
/*     */   }
/*     */   
/*     */   public <T> T singleResult(String hql) {
/* 162 */     return (T)commonDao.singleResult(hql);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> void deleteEntityById(Class entityName, Serializable id)
/*     */   {
/* 172 */     commonDao.deleteEntityById(entityName, id);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> void updateEntitie(T pojo)
/*     */   {
/* 182 */     commonDao.updateEntitie(pojo);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> List<T> findByQueryString(String hql)
/*     */   {
/* 194 */     return commonDao.findByQueryString(hql);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public int updateBySqlString(String sql)
/*     */   {
/* 204 */     return commonDao.updateBySqlString(sql);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> List<T> findListbySql(String query)
/*     */   {
/* 215 */     return commonDao.findListbySql(query);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> List<T> findByPropertyisOrder(Class<T> entityClass, String propertyName, Object value, boolean isAsc)
/*     */   {
/* 227 */     return commonDao.findByPropertyisOrder(entityClass, propertyName, 
/* 228 */       value, isAsc);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public PageList getPageList(CriteriaQuery cq, boolean isOffset)
/*     */   {
/* 240 */     return commonDao.getPageList(cq, isOffset);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public DataTableReturn getDataTableReturn(CriteriaQuery cq, boolean isOffset)
/*     */   {
/* 252 */     return commonDao.getDataTableReturn(cq, isOffset);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public DataGridReturn getDataGridReturn(CriteriaQuery cq, boolean isOffset)
/*     */   {
/* 264 */     return commonDao.getDataGridReturn(cq, isOffset);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public PageList getPageList(HqlQuery hqlQuery, boolean needParameter)
/*     */   {
/* 277 */     return commonDao.getPageList(hqlQuery, needParameter);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public PageList getPageListBySql(HqlQuery hqlQuery, boolean isToEntity)
/*     */   {
/* 290 */     return commonDao.getPageListBySql(hqlQuery, isToEntity);
/*     */   }
/*     */   
/*     */ 
/*     */   public Session getSession()
/*     */   {
/* 296 */     return commonDao.getSession();
/*     */   }
/*     */   
/*     */   public List findByExample(String entityName, Object exampleEntity)
/*     */   {
/* 301 */     return commonDao.findByExample(entityName, exampleEntity);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> List<T> getListByCriteriaQuery(CriteriaQuery cq, Boolean ispage)
/*     */   {
/* 313 */     return commonDao.getListByCriteriaQuery(cq, ispage);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> T uploadFile(UploadFile uploadFile)
/*     */   {
/* 322 */     return (T)commonDao.uploadFile(uploadFile);
/*     */   }
/*     */   
/*     */ 
/*     */   public HttpServletResponse viewOrDownloadFile(UploadFile uploadFile)
/*     */   {
/* 328 */     return commonDao.viewOrDownloadFile(uploadFile);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public HttpServletResponse createXml(ImportFile importFile)
/*     */   {
/* 339 */     return commonDao.createXml(importFile);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public void parserXml(String fileName)
/*     */   {
/* 349 */     commonDao.parserXml(fileName);
/*     */   }
/*     */   
/*     */   public List<ComboTree> comTree(List<TSDepart> all, ComboTree comboTree) {
/* 353 */     return commonDao.comTree(all, comboTree);
/*     */   }
/*     */   
/*     */   public List<ComboTree> ComboTree(List all, ComboTreeModel comboTreeModel, List in, boolean recursive) {
/* 357 */     return commonDao.ComboTree(all, comboTreeModel, in, recursive);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public List<TreeGrid> treegrid(List all, TreeGridModel treeGridModel)
/*     */   {
/* 364 */     return commonDao.treegrid(all, treeGridModel);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> List<T> getAutoList(Autocomplete autocomplete)
/*     */   {
/* 374 */     StringBuffer sb = new StringBuffer("");
/* 375 */     String searchFiel = autocomplete.getSearchField().replace(" ", "").replace("\t", "");
/* 376 */     if (autocomplete.getSearchType().intValue() == 0) {
/* 377 */       sb.append(searchFiel + " like '" + autocomplete.getTrem() + "%' ");
/* 378 */     } else if (autocomplete.getSearchType().intValue() == 1) {
/* 379 */       sb.append(searchFiel + " like '%" + autocomplete.getTrem() + "' ");
/* 380 */     } else if (autocomplete.getSearchType().intValue() == 2) {
/* 381 */       sb.append(searchFiel + " like '%" + autocomplete.getTrem() + "%' ");
/* 382 */     } else if (autocomplete.getSearchType().intValue() == 3) { String[] arrayOfString1;
/* 383 */       int j = (arrayOfString1 = autocomplete.getTrem().split(",")).length; for (int i = 0; i < j; i++) { String searchValue = arrayOfString1[i];
/* 384 */         sb.append(searchFiel + " like '%" + searchValue + "%' ");
/*     */       }
/* 386 */     } else if (autocomplete.getSearchType().intValue() == 4) {
/* 387 */       String[] s0 = searchFiel.split(",");
/* 388 */       String[] v0 = autocomplete.getTrem().split(",");
/* 389 */       for (int i = 0; i < s0.length; i++) {
/* 390 */         s0[i] = s0[i].trim();
/* 391 */         if ((s0[i].length() > 0) && (i <= v0.length - 1)) {
/* 392 */           v0[i] = v0[i].trim();
/* 393 */           if (sb.length() < 6) {
/* 394 */             sb.append(s0[i] + " like '" + v0[i] + "%' ");
/*     */           } else {
/* 396 */             sb.append("  or " + s0[i] + " like '" + v0[i] + "%' ");
/*     */           }
/*     */         }
/*     */       }
/* 400 */     } else if (autocomplete.getSearchType().intValue() == 5) {
/* 401 */       String[] s0 = searchFiel.split(",");
/* 402 */       String[] v0 = autocomplete.getTrem().split(",");
/* 403 */       for (int i = 0; i < s0.length; i++) {
/* 404 */         s0[i] = s0[i].trim();
/* 405 */         if ((s0[i].length() > 0) && (i <= v0.length - 1)) {
/* 406 */           v0[i] = v0[i].trim();
/* 407 */           if (sb.length() < 6) {
/* 408 */             sb.append(s0[i] + " like '%" + v0[i] + "' ");
/*     */           } else {
/* 410 */             sb.append("  or " + s0[i] + " like '%" + v0[i] + "' ");
/*     */           }
/*     */         }
/*     */       }
/* 414 */     } else if (autocomplete.getSearchType().intValue() == 6) {
/* 415 */       String[] s0 = searchFiel.split(",");
/* 416 */       String[] v0 = autocomplete.getTrem().split(",");
/* 417 */       for (int i = 0; i < s0.length; i++) {
/* 418 */         s0[i] = s0[i].trim();
/* 419 */         if ((s0[i].length() > 0) && (i <= v0.length - 1)) {
/* 420 */           v0[i] = v0[i].trim();
/* 421 */           if (sb.length() < 6) {
/* 422 */             sb.append(s0[i] + " like '%" + v0[i] + "%' ");
/*     */           } else {
/* 424 */             sb.append(" or " + s0[i] + " like '%" + v0[i] + "%' ");
/*     */           }
/*     */         }
/*     */       }
/*     */     } else {
/* 429 */       sb.append(searchFiel + " like '" + autocomplete.getTrem() + "%' ");
/*     */     }
/* 431 */     String config = autocomplete.getSearchConfig();
/* 432 */     if ((config != null) && (config.length() > 4)) {
/* 433 */       sb.append(" and (" + config + ")");
/*     */     }
/* 435 */     String hql = "from " + autocomplete.getEntityName() + " where 2>1 and (" + sb.toString() + ")";
/* 436 */     return commonDao.getSession().createQuery(hql).setFirstResult(autocomplete.getCurPage().intValue() - 1).setMaxResults(autocomplete.getMaxRows().intValue()).list();
/*     */   }
/*     */   
/*     */   public Integer executeSql(String sql, List<Object> param) {
/* 440 */     return commonDao.executeSql(sql, param);
/*     */   }
/*     */   
/*     */   public Integer executeSql(String sql, Object... param) {
/* 444 */     return commonDao.executeSql(sql, param);
/*     */   }
/*     */   
/*     */   public Integer executeSql(String sql, java.util.Map<String, Object> param)
/*     */   {
/* 449 */     return commonDao.executeSql(sql, param);
/*     */   }
/*     */   
/*     */   public int[] executeBatchUpdate(String[] sqls) {
/* 453 */     return commonDao.executeBatchUpdate(sqls);
/*     */   }
/*     */   
/*     */   public Object executeSqlReturnKey(String sql, java.util.Map<String, Object> param) {
/* 457 */     return commonDao.executeSqlReturnKey(sql, param);
/*     */   }
/*     */   
/*     */   public List<java.util.Map<String, Object>> findForJdbc(String sql, int page, int rows) {
/* 461 */     return commonDao.findForJdbc(sql, page, rows);
/*     */   }
/*     */   
/*     */   public List<java.util.Map<String, Object>> findForJdbc(String sql, Object... objs)
/*     */   {
/* 466 */     return commonDao.findForJdbc(sql, objs);
/*     */   }
/*     */   
/*     */ 
/*     */   public List<java.util.Map<String, Object>> findForJdbcParam(String sql, int page, int rows, Object... objs)
/*     */   {
/* 472 */     return commonDao.findForJdbcParam(sql, page, rows, objs);
/*     */   }
/*     */   
/*     */ 
/*     */   public <T> List<T> findObjForJdbc(String sql, int page, int rows, Class<T> clazz)
/*     */   {
/* 478 */     return commonDao.findObjForJdbc(sql, page, rows, clazz);
/*     */   }
/*     */   
/*     */   public java.util.Map<String, Object> findOneForJdbc(String sql, Object... objs)
/*     */   {
/* 483 */     return commonDao.findOneForJdbc(sql, objs);
/*     */   }
/*     */   
/*     */   public Long getCountForJdbc(String sql)
/*     */   {
/* 488 */     return commonDao.getCountForJdbc(sql);
/*     */   }
/*     */   
/* 491 */   public Long getCountForJdbcParam(String sql, Object[] objs) { return commonDao.getCountForJdbcParam(sql, objs); }
/*     */   
/*     */ 
/*     */   public <T> void batchSave(List<T> entitys)
/*     */   {
/* 496 */     commonDao.batchSave(entitys);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public <T> List<T> findHql(String hql, Object... param)
/*     */   {
/* 507 */     return commonDao.findHql(hql, param);
/*     */   }
/*     */   
/*     */   public <T> List<T> pageList(DetachedCriteria dc, int firstResult, int maxResult)
/*     */   {
/* 512 */     return commonDao.pageList(dc, firstResult, maxResult);
/*     */   }
/*     */   
/*     */   public <T> List<T> findByDetached(DetachedCriteria dc) {
/* 516 */     return commonDao.findByDetached(dc);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public <T> List<T> executeProcedure(String procedureSql, Object... params)
/*     */   {
/* 523 */     return commonDao.executeProcedure(procedureSql, params);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public int executeProcedureNoResult(String procedureSql, Object... params)
/*     */   {
/* 530 */     return commonDao.executeProcedureNoResult(procedureSql, params);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean isViewAllData(String userid)
/*     */   {
/* 539 */     return commonDao.isViewAllData(userid);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String[] getAllOwnedDepartId(String userid)
/*     */   {
/* 548 */     return commonDao.getAllOwnedDepartId(userid);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public List<org.hibernate.mapping.Map> executeOMHDaoJdbcSql(String sql)
/*     */   {
/* 559 */     String select0 = sql.toLowerCase().split(" from")[0].split("select ")[1];
/*     */     
/* 561 */     SQLQuery query = getSession().createSQLQuery(sql);
/* 562 */     String[] select1 = select0.split(",");
/* 563 */     for (int i = 0; i < select1.length; i++) {
/* 564 */       String field0 = select1[i].trim();
/* 565 */       if (field0.length() >= 1)
/*     */       {
/*     */ 
/* 568 */         if (field0.indexOf(" as ") > -1) {
/* 569 */           field0 = field0.split(" as ")[1];
/*     */         }
/* 571 */         if (field0.indexOf(".") > -1) {
/* 572 */           field0 = field0.split(".")[1];
/*     */         }
/* 574 */         field0 = field0.trim();
/* 575 */         if (field0.length() >= 1)
/*     */         {
/*     */ 
/* 578 */           query = query.addScalar(field0); }
/*     */       } }
/* 580 */     List<org.hibernate.mapping.Map> list = query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
/* 581 */     return list;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getCurrentDanjuhao(String piaoname, int yearmonthday)
/*     */   {
/* 589 */     String a0Where = "";
/* 590 */     String geshi = "''";
/*     */     
/* 592 */     piaoname = piaoname.replace("'", "").replace(" ", "").replace("null", "");
/* 593 */     if (yearmonthday == 0) {
/* 594 */       a0Where = " where t.piaoname='" + piaoname + "'";
/* 595 */     } else if (3 == yearmonthday) {
/* 596 */       a0Where = " where t.piaoname='" + piaoname + "' and to_char(t.piaodate, 'dd-mm-yyyy')=to_char(sysdate, 'dd-mm-yyyy')";
/* 597 */       geshi = "to_char(sysdate,'yyMMdd')";
/* 598 */     } else if (2 == yearmonthday) {
/* 599 */       a0Where = " where t.piaoname='" + piaoname + "' and to_char(t.piaodate, 'mm-yyyy')=to_char(sysdate, 'mm-yyyy')";
/* 600 */       geshi = "to_char(sysdate,'yyMM')";
/* 601 */     } else if (1 == yearmonthday) {
/* 602 */       a0Where = " where t.piaoname='" + piaoname + "' and to_char(t.piaodate, 'yyyy')=to_char(sysdate, 'yyyy')";
/* 603 */       geshi = "to_char(sysdate,'yy')";
/*     */     } else {
/* 605 */       a0Where = " where t.piaoname='" + piaoname + "'";
/*     */     }
/*     */     try {
/* 608 */       synchronized (this) {
/* 609 */         String aSql = "select ''||t.piaohao as piaohao,replace(t.piaoqianzhui||" + geshi + "||to_char(t.piaohao+1,t.piaogeshi),' ','') as showpiaohao from l_current_piaohao t " + a0Where;
/* 610 */         List<java.util.Map<String, Object>> lst0 = findForJdbc(aSql, new Object[0]);
/*     */         
/* 612 */         String showpiaohao = "";
/* 613 */         String piaohao; if ((lst0 != null) && (lst0.size() > 0) && (lst0.get(0) != null)) {
/* 614 */           HashMap aRow = (HashMap)lst0.get(0);
/* 615 */           String piaohao = ("0" + aRow.get("piaohao")).toLowerCase().replace("null", "");
/* 616 */           showpiaohao = aRow.get("showpiaohao") == null ? "" : aRow.get("showpiaohao").toString();
/*     */         } else {
/* 618 */           piaohao = "0";
/*     */         }
/*     */         
/* 621 */         Long along = Long.valueOf(Long.parseLong(piaohao) + 1L);
/* 622 */         if (along.longValue() < 2L) {
/* 623 */           String changdu = "";
/* 624 */           String aSql2 = "select ''||t.piaohao as piaohao,replace(t.piaoqianzhui||" + geshi + ",' ','') as showpiaohao,t.piaogeshi from l_current_piaohao t where t.piaoname = '" + piaoname + "'";
/* 625 */           List<java.util.Map<String, Object>> lst1 = findForJdbc(aSql2, new Object[0]);
/* 626 */           if ((lst1 != null) && (lst1.size() > 0) && (lst1.get(0) != null)) {
/* 627 */             HashMap aRow = (HashMap)lst1.get(0);
/* 628 */             showpiaohao = aRow.get("showpiaohao") == null ? "" : aRow.get("showpiaohao").toString();
/* 629 */             changdu = aRow.get("piaogeshi") == null ? "" : aRow.get("piaogeshi").toString();
/* 630 */             DecimalFormat df = new DecimalFormat(changdu);
/* 631 */             showpiaohao = showpiaohao + df.format(along);
/*     */           }
/*     */         }
/* 634 */         aSql = "update l_current_piaohao t set t.piaohao=" + along + ",t.piaodate=sysdate where t.piaoname='" + piaoname + "'";
/* 635 */         executeSql(aSql, new Object[0]);
/* 636 */         return showpiaohao;
/*     */       }
/*     */       
/* 639 */       return "0";
/*     */     } catch (Exception e) {}
/*     */   }
/*     */   
/*     */   private static void setWSUserPassword() {
/*     */     try {
/* 645 */       if (md5pass.length() < 16) {
/* 646 */         Properties prop = new Properties();
/* 647 */         FileInputStream fis = new FileInputStream(wsclientconfigfile);
/* 648 */         prop.load(fis);
/* 649 */         wsuname = prop.getProperty("webservice.url.username");
/* 650 */         String wspassd = prop.getProperty("webservice.url.password");
/* 651 */         md5pass = LMD5Util.parseStrToMd5L32(wsuname + "!" + wspassd + "@" + wsuname);
/*     */       }
/*     */     } catch (Exception e) {
/* 654 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */   
/*     */   public static void SetWSUserPassword(String username, String password) {
/* 659 */     wsuname = username;
/* 660 */     md5pass = LMD5Util.parseStrToMd5L32(wsuname + "!" + password + "@" + wsuname);
/*     */   }
/*     */   
/*     */   private static JaxWsDynamicClientFactory getJaxWsDynamicClientFactory() {
/* 664 */     if (clientfactory == null) {
/* 665 */       clientfactory = JaxWsDynamicClientFactory.newInstance();
/*     */     }
/* 667 */     if (md5pass.length() < 16) {
/* 668 */       PropertiesUtil util = new PropertiesUtil("sysConfig.properties");
/* 669 */       wsuname = util.readProperty("webservice.url.username");
/* 670 */       String wspassd = util.readProperty("webservice.url.password");
/* 671 */       if (("null".equals(wspassd.toLowerCase())) || ("".equals(wspassd)) || ("null".equals(wsuname.toLowerCase())) || ("".equals(wsuname))) {
/* 672 */         setWSUserPassword();
/*     */       } else {
/* 674 */         md5pass = LMD5Util.parseStrToMd5L32(wsuname + "!" + wspassd + "@" + wsuname);
/*     */       }
/*     */     }
/* 677 */     return clientfactory;
/*     */   }
/*     */   
/*     */   public static Object[] getCxfService(String url, String spacename, String methodname, Object... params) {
/*     */     try {
/* 682 */       if (url.toLowerCase().indexOf("?wsdl") < 6) {
/* 683 */         url = url + "?wsdl";
/*     */       }
/* 685 */       JaxWsDynamicClientFactory clientfactory = getJaxWsDynamicClientFactory();
/* 686 */       Client client = clientfactory.createClient(url);
/* 687 */       QName qname = new QName(spacename, methodname);
/* 688 */       java.util.Map<String, List<String>> headers = new HashMap();
/* 689 */       headers.put("username", Arrays.asList(new String[] { wsuname }));
/* 690 */       headers.put("password", Arrays.asList(new String[] { md5pass }));
/* 691 */       return client.invoke(qname, params);
/*     */     }
/*     */     catch (Exception e) {
/* 694 */       e.printStackTrace(); }
/* 695 */     return tmp156_153;
/*     */   }
/*     */   
/*     */   public static Object[] getCxfServiceESB(String clientid, String operationcode, String url, String spacename, String methodname, Object... params)
/*     */   {
/*     */     try
/*     */     {
/* 702 */       if (url.toLowerCase().indexOf("?wsdl") < 6) {
/* 703 */         url = url + "?wsdl";
/*     */       }
/* 705 */       JaxWsDynamicClientFactory clientfactory = getJaxWsDynamicClientFactory();
/* 706 */       Client client = clientfactory.createClient(url);
/* 707 */       QName qname = new QName(spacename, methodname);
/* 708 */       java.util.Map<String, List<String>> headers = new HashMap();
/* 709 */       headers.put("username", Arrays.asList(new String[] { wsuname }));
/* 710 */       headers.put("password", Arrays.asList(new String[] { md5pass }));
/* 711 */       headers.put("ClientId", Arrays.asList(new String[] { clientid }));
/* 712 */       headers.put("OperationCode", Arrays.asList(new String[] { operationcode }));
/* 713 */       client.getRequestContext().put(Message.PROTOCOL_HEADERS, headers);
/* 714 */       return client.invoke(qname, params);
/*     */     }
/*     */     catch (Exception e) {
/* 717 */       e.printStackTrace(); }
/* 718 */     return tmp220_217;
/*     */   }
/*     */   
/*     */   public void SetWSClientConfigFile()
/*     */   {
/*     */     try {
/* 724 */       if (wsclientconfigfile.length() < 6) {
/* 725 */         String aSql2 = "select t.string_value from l_erp_config t where t.cfg_name='erp_wsclient_configfile'";
/* 726 */         List<java.util.Map<String, Object>> lst1 = findForJdbc(aSql2, new Object[0]);
/* 727 */         java.util.Map map = (java.util.Map)lst1.get(0);
/* 728 */         wsclientconfigfile = map.get("string_value");
/*     */       }
/*     */     } catch (Exception e) {
/* 731 */       System.out.println("SetWSClientConfigFile() error:\r\n");
/* 732 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */   
/*     */   public CgformErpjiekouEntity getOne(String jiekoufangfa, String jiekouAddress)
/*     */   {
/* 738 */     String sql = "select id from CGFORM_erpjiekou where JIEKOUID='" + jiekouAddress + "' and JIEKOUFANGFA='" + 
/* 739 */       jiekoufangfa + "'";
/* 740 */     List<String> list = findListbySql(sql);
/* 741 */     if ((list != null) && (list.size() > 0)) {
/* 742 */       String id = (String)list.get(0);
/* 743 */       return (CgformErpjiekouEntity)get(CgformErpjiekouEntity.class, id);
/*     */     }
/* 745 */     return null;
/*     */   }
/*     */ }

/* Location:           D:\workspace\cmferp\WebContent\WEB-INF\classes
 * Qualified Name:     org.jeecgframework.core.common.service.impl.CommonServiceImpl
 * Java Class Version: 7 (51.0)
 * JD-Core Version:    0.7.1
 */

 

配置文件 填寫 對方系統的登陸賬號密碼

sysConfig.properties

webservice.url.username=123456
webservice.url.password=123456

 

一個系統數據傳輸的demo   (接收數據)

配置文件 cxf-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
	xsi:schemaLocation=" http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd 
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
	


	<!-- 銷售送貨單 -->
	<jaxws:endpoint id="SonghuodanWService"
		implementor="com.szerp.basesonghuodan.service.impl.SonghuodanWServiceImpl"
		address="SonghuodanWService" />	





</beans>

 

Service 層

--接口

import javax.jws.WebService;

@WebService
public interface SonghuodanWServiceI{
	/**
	 * 倉庫已經裝車出庫,這邊送貨單修改狀態和數量
	 * 送貨單號 songhuodanhao
	 * 物料編碼 wuliaobianhao 
	 * 裝車數量 zhuangcheshuliang
	 */
	public String updateDelivery(String paramJson) throws Exception ;
	
}

--實現類



import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.cxf.interceptor.InInterceptors;
import org.apache.cxf.interceptor.OutInterceptors;
import org.jeecgframework.web.system.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;



import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@InInterceptors(interceptors = "org.jeecgframework.core.interceptors.CxfWSServerInInterceptor")
@OutInterceptors(interceptors = "org.jeecgframework.core.interceptors.CxfWSServerOutInterceptor")
public class SonghuodanWServiceImpl implements SonghuodanWServiceI{	
	@Autowired
	private BaseSonghuodanDao baseSonghuodanDao;
	@Autowired
    private SystemService systemService; 
	
	
	/**
	 * 倉庫已經裝車出庫,這邊送貨單修改狀態和數量
	 * 送貨單號 songhuodanhao
	 * 物料編碼 wuliaobianhao 
	 * 裝車數量 zhuangcheshuliang
	 */
	public String updateDelivery(String paramJson)  {
		JSONObject result = new JSONObject();
		JSONObject results = JSONObject.fromObject(paramJson);
		SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH-mm-ss");
		//送貨單號
		String  songhuodanhao = results.getString("songhuodanhao");
		/**出庫編號*/
		String  chukubianhao = results.getString("OrderNum");
		
		JSONArray detailArr =results.getJSONArray("Details");
		//送貨單主表
		BaseSonghuodanEntity entity = systemService.findUniqueByProperty(BaseSonghuodanEntity.class,"songhuodanhao",songhuodanhao);

		if(songhuodanhao == null){
			result.put("status", "0");
			result.put("message", "送貨單不能爲空!");
		}
		for (int j = 0; j < detailArr.size(); j++) {
			JSONObject detailJson = detailArr.getJSONObject(j);
			//送貨單子表物料編碼
			String wuliaobianhao = detailJson.getString("wuliaobianhao");
			//送貨單子表裝車數量
			String zhuangcheshuliang = detailJson.getString("zhuangcheshuliang");
			if(wuliaobianhao==null && zhuangcheshuliang==null){
				result.put("status", "0");
				result.put("message", "物料編碼和裝車數量不能爲空!");
		    	return results.toString();
			}
			BaseSonghuodansublistEntity  sublistEntity = baseSonghuodanDao.findBaseSonghuodansublistEntity(entity.getId(),wuliaobianhao);
			if(sublistEntity==null){
				result.put("status", "0");
				result.put("message", "根據:"+wuliaobianhao+"物料編碼未查找到送貨單明細!");
		    	return results.toString();
			}
			/**實發數量*/
			sublistEntity.setShihuoshuliang(Double.parseDouble(zhuangcheshuliang) );
			/**裝車數量*/
			sublistEntity.setZhuangcheshuliang(Double.parseDouble(zhuangcheshuliang));
			/**簽收數量*/
			sublistEntity.setQianshoushuliang(Double.parseDouble(zhuangcheshuliang));
			/**送貨時間*/
			sublistEntity.setSonghuoshijian(sdf.format(new Date()));
			/**出庫編號*/
			sublistEntity.setChukubianhao(chukubianhao);
			systemService.updateEntitie(sublistEntity);
		}
		
		/**已發貨*/
		entity.setSonghuodantype(basesonghuodanEnum.DELIVERY.getStatus());
		/**送貨時間*/
		entity.setSonghuoshijian(new Date());
		
		systemService.updateEntitie(entity);
		
		result.put("status", "1");
		result.put("message", "更新送貨單成功!");
		
		
		return result.toString();
	}
	
	
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章