注入 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();
	}
	
	
}

 

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