Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发

CXF框架入门案例请看上面这篇文章
文章地址:https://blog.csdn.net/qq_44757034/article/details/111869428

一、物流BOS系统开发:服务端

1、需求与思路分析

我们需要开发《物流 BOS 系统》,并提供两个功能。

1)可以通过运单号查询该运单的运单详情
2)可以在线下单预约

最终由 ERP 系统调用这两个功能

2、数据库设计

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第1张图片
运单状态: 0:待发 1:在途 2:结束
数据库:mysql, 数据库名称:redsun

CREATE DATABASE redsun DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
use redsun;
CREATE TABLE `waybill` (
  `sn` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '运单号',
  `userid` bigint(20) DEFAULT NULL COMMENT '用户ID',
  `toaddress` varchar(100) DEFAULT NULL COMMENT '收货地址',
  `addressee` varchar(100) DEFAULT NULL COMMENT '收货人',
  `tele` varchar(100) DEFAULT NULL COMMENT '收件人电话',
  `info` varchar(2000) DEFAULT NULL COMMENT '运单详情',
  `state` varchar(1) DEFAULT NULL COMMENT '运单状态',
  PRIMARY KEY (`sn`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
CREATE TABLE `waybilldetail` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `sn` bigint(20) DEFAULT NULL COMMENT '运单号',
  `exedate` varchar(10) DEFAULT NULL COMMENT '执行日期',
  `exetime` varchar(10) DEFAULT NULL COMMENT '执行时间',
  `info` varchar(100) DEFAULT NULL COMMENT '执行信息',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

3、项目工程搭建

因为《物流 BOS 系统》会与《ERP》同时运行,所以需要将《物流 BOS 系统》的 pom.xml 中的 8080 端口改为9090

(1)创建父工程

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第2张图片
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第3张图片
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第4张图片

(2)创建子工程

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第5张图片
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第6张图片
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第7张图片

(3)创建其他子工程与步骤2相同

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第8张图片

(4)创建redsun_web的时候要注意

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第9张图片
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第10张图片

(4)在redsun_web工程当中展开src\main\webapp目录 建立WEB-INF文件夹,并创建web.xml到文件夹WEB-INF当中

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第11张图片
web.xml当中的内容
配置一些框架的内容


<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
	
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>
	listener>
	<context-param>
		<param-name>contextConfigLocationparam-name>
		<param-value>classpath*:applicationContext*.xmlparam-value>
	context-param>
		
	<filter>
   		<filter-name>openSessionInViewfilter-name>
   		<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilterfilter-class>
	filter>
	
	<filter-mapping>
		<filter-name>openSessionInViewfilter-name>
		<url-pattern>/*url-pattern>
	filter-mapping>
	
	<filter>
		<filter-name>struts2filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilterfilter-class>
	filter>

	<filter-mapping>
		<filter-name>struts2filter-name>
		<url-pattern>/admin/*url-pattern>
	filter-mapping>
	
	
	<filter>
		<filter-name>cxffilter-name>
		<filter-class>org.apache.cxf.transport.servlet.CXFServletfilter-class>
	filter>
	<filter-mapping>
		<filter-name>cxffilter-name>
		<url-pattern>/ws/*url-pattern>
	filter-mapping>
	
	<welcome-file-list>
		<welcome-file>login.htmlwelcome-file>
	welcome-file-list>
web-app>
(5)在redsun_parent当中pom.xml添加依赖
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0modelVersion>
	<groupId>com.itzhenggroupId>
	<artifactId>redsun_parentartifactId>
	<version>0.0.1-SNAPSHOTversion>
	<packaging>pompackaging>
	<properties>
		<hibernate.version>5.0.7.Finalhibernate.version>
		<spring.version>4.2.4.RELEASEspring.version>
		<struts.version>2.3.24struts.version>
		<slf4j.version>1.6.6slf4j.version>
		<log4j.version>1.2.12log4j.version>   
	properties>
	<dependencies>
		<dependency>
			<groupId>org.hibernategroupId>
			<artifactId>hibernate-coreartifactId>
			<version>${hibernate.version}version>
		dependency>
		<dependency>
			<groupId>org.springframeworkgroupId>
			<artifactId>spring-coreartifactId>
			<version>${spring.version}version>
		dependency>
		<dependency>
			<groupId>org.springframeworkgroupId>
			<artifactId>spring-beansartifactId>
			<version>${spring.version}version>
		dependency>
		<dependency>
			<groupId>org.springframeworkgroupId>
			<artifactId>spring-contextartifactId>
			<version>${spring.version}version>
		dependency>
		<dependency>
			<groupId>org.springframeworkgroupId>
			<artifactId>spring-ormartifactId>
			<version>${spring.version}version>
		dependency>
		<dependency>
			<groupId>org.springframeworkgroupId>
			<artifactId>spring-testartifactId>
			<version>${spring.version}version>
		dependency>
		<dependency>
			<groupId>org.springframeworkgroupId>
			<artifactId>spring-context-supportartifactId>
			<version>${spring.version}version>
		dependency> 
		<dependency>
			<groupId>org.springframeworkgroupId>
			<artifactId>spring-aopartifactId>
			<version>${spring.version}version>
		dependency>
		<dependency>
			<groupId>org.springframeworkgroupId>
			<artifactId>spring-webartifactId>
			<version>${spring.version}version>
		dependency>
		<dependency>
			<groupId>org.aspectjgroupId>
			<artifactId>aspectjweaverartifactId>
			<version>1.8.7version>
		dependency>
		<dependency>
			<groupId>org.apache.strutsgroupId>
			<artifactId>struts2-coreartifactId>
			<version>${struts.version}version>
			<exclusions>
				<exclusion>
					<groupId>javassistgroupId>
					<artifactId>javassistartifactId>
				exclusion>  		
			exclusions>
		dependency>
		<dependency>
			<groupId>org.apache.strutsgroupId>
			<artifactId>struts2-spring-pluginartifactId>
			<version>${struts.version}version>
		dependency>
		 
		<dependency>
			<groupId>log4jgroupId>
			<artifactId>log4jartifactId>
			<version>${log4j.version}version>
		dependency>
		<dependency>
			<groupId>org.slf4jgroupId>
			<artifactId>slf4j-apiartifactId>
			<version>${slf4j.version}version>
		dependency>
		<dependency>
			<groupId>org.slf4jgroupId>
			<artifactId>slf4j-log4j12artifactId>
			<version>${slf4j.version}version>
		dependency>
		
		<dependency>
			<groupId>jstlgroupId>
			<artifactId>jstlartifactId>
			<version>1.2version>
		dependency>
	 	
		<dependency>
			<groupId>com.oraclegroupId>
			<artifactId>ojdbc6artifactId>
			<version>11.2.0.3version>
		dependency>
		<dependency>
			<groupId>mysqlgroupId>
			<artifactId>mysql-connector-javaartifactId>
			<version>5.1.6version>
			<scope>runtimescope>
		dependency>
		<dependency>
			<groupId>com.alibabagroupId>
			<artifactId>fastjsonartifactId>
			<version>1.1.37version>
		dependency>
		<dependency>
			<groupId>junitgroupId>
			<artifactId>junitartifactId>
			<version>4.9version>
			<scope>testscope>
		dependency>
		<dependency>
			<groupId>javax.servletgroupId>
			<artifactId>servlet-apiartifactId>
			<version>2.5version>
			<scope>providedscope>
		dependency>
  
  		
  		<dependency>
	  		<groupId>org.apache.cxfgroupId>
	  		<artifactId>cxf-rt-frontend-jaxwsartifactId>
	  		<version>3.1.10version>
	  	dependency>
	  	<dependency>
	  		<groupId>org.apache.cxfgroupId>
	  		<artifactId>cxf-rt-transports-httpartifactId>
	  		<version>3.1.10version>
	  	dependency>
	dependencies>
    <build>  
	  <plugins>
	      <plugin>  
	          <groupId>org.apache.maven.pluginsgroupId>  
	          <artifactId>maven-compiler-pluginartifactId>  
	          <version>2.3.2version>  
	          <configuration>  
	              <source>1.7source>  
	              <target>1.7target>  
	          configuration>  
	      plugin>  
	      <plugin>
				<groupId>org.apache.tomcat.mavengroupId>
				<artifactId>tomcat7-maven-pluginartifactId>
				<configuration>
					
					<port>9090port>
					
					<path>/redsunpath>
				configuration>
	  	  plugin>
	  plugins>  
    build>
    <modules>
    	<module>redsun_entitymodule>
    	<module>redsun_daomodule>
    	<module>redsun_bizmodule>
    	<module>redsun_webmodule>
    modules>
project>
(6)添加其他子项目的依赖关系

1)在redsun_entity当中创建对应的实体类,以及对应的映射文件
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第12张图片
Waybill

package com.redsum.bos.entity;
/**
 * 实体类
 * @author Administrator *
 */
public class Waybill {
     	
	private Long sn;//运单号
	private Long userid;//用户ID
	private String toaddress;//收货地址
	private String addressee;//收货人
	private String tele;//收件人电话
	private String info;//运单详情
	private String state;//运单状态

	public Long getSn() {
     		
		return sn;
	}
	public void setSn(Long sn) {
     
		this.sn = sn;
	}
	public Long getUserid() {
     		
		return userid;
	}
	public void setUserid(Long userid) {
     
		this.userid = userid;
	}
	public String getToaddress() {
     		
		return toaddress;
	}
	public void setToaddress(String toaddress) {
     
		this.toaddress = toaddress;
	}
	public String getAddressee() {
     		
		return addressee;
	}
	public void setAddressee(String addressee) {
     
		this.addressee = addressee;
	}
	public String getTele() {
     		
		return tele;
	}
	public void setTele(String tele) {
     
		this.tele = tele;
	}
	public String getInfo() {
     		
		return info;
	}
	public void setInfo(String info) {
     
		this.info = info;
	}
	public String getState() {
     		
		return state;
	}
	public void setState(String state) {
     
		this.state = state;
	}
}

waybill.hbm.xml



<hibernate-mapping>
    <class name="com.redsum.bos.entity.Waybill" table="waybill" >
        <id name="sn" >
            <generator class="native">generator>
        id>
        <property name="userid" /> 
        <property name="toaddress" /> 
        <property name="addressee" /> 
        <property name="tele" /> 
        <property name="info" /> 
        <property name="state" /> 
    class>
hibernate-mapping>

Waybilldetail

package com.redsum.bos.entity;
/**
 * 实体类
 * @author Administrator *
 */
public class Waybilldetail {
     	
	private Long id;//ID
	private Long sn;//运单号
	private String exedate;//执行日期
	private String exetime;//执行时间
	private String info;//执行信息

	public Long getId() {
     		
		return id;
	}
	public void setId(Long id) {
     
		this.id = id;
	}
	public Long getSn() {
     		
		return sn;
	}
	public void setSn(Long sn) {
     
		this.sn = sn;
	}
	public String getExedate() {
     		
		return exedate;
	}
	public void setExedate(String exedate) {
     
		this.exedate = exedate;
	}
	public String getExetime() {
     		
		return exetime;
	}
	public void setExetime(String exetime) {
     
		this.exetime = exetime;
	}
	public String getInfo() {
     		
		return info;
	}
	public void setInfo(String info) {
     
		this.info = info;
	}
}

waybilldetail.hbm.xml



<hibernate-mapping>
    <class name="com.redsum.bos.entity.Waybilldetail" table="waybilldetail" >
        <id name="id" >
            <generator class="native">generator>
        id>
        <property name="sn" /> 
        <property name="exedate" /> 
        <property name="exetime" /> 
        <property name="info" /> 
    class>
hibernate-mapping>

2)redsun_dao当中创建创建接口和类,并添加依赖
先添加依赖dao依赖redsun_parent
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第13张图片
创建对应的接口和类
将spring配置文件中的applicationContext_datasource.xml和
applicationContext_dao.xml创建到erp_dao工程的src/main/resources下。
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第14张图片
IBaseDao

package com.redsum.bos.dao;
import java.util.List;
public interface IBaseDao<T> {
     
	/**
	 * 条件查询
	 * @param t1
	 * @return
	 */
	List<T> getList(T t1,T t2,Object param);
	/**
	 * 分页查询
	 * @param t1
	 * @param t2
	 * @param param
	 * @param firstResult
	 * @param maxResults
	 * @return
	 */
	List<T> getListByPage(T t1,T t2,Object param,int firstResult, int maxResults);
	/**
	 * 记录条件查询的总记录数
	 * @param t1
	 * @return
	 */
	long getCount(T t1,T t2,Object param);
	/**
	 * 新增
	 * @param t
	 */
	void add(T t);
	/**
	 * 删除
	 */
	void delete(Long uuid);
	/**
	 * 通过编号查询对象
	 * @param uuid
	 * @return
	 */
	T get(Long uuid);
	/**
	 * 更新
	 */
	void update(T t);
}

BaseDao

package com.redsum.bos.dao.impl;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Projections;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import com.redsum.bos.dao.IBaseDao;

/**
 * 通用数据访问层
 * @author Administrator
 *
 * @param 
 */
@SuppressWarnings("unchecked")
public class BaseDao<T> extends HibernateDaoSupport implements IBaseDao<T> {
     
	
	/** 泛型中的初阶类型 */
	private Class<T> entityClass;
	
	public BaseDao(){
     
		//获取对象对应的父类的类型
		Type baseDaoClass = this.getClass().getGenericSuperclass();
		//转成带参数,即泛型的类型
		ParameterizedType pType = (ParameterizedType)baseDaoClass;
		//获取参数泛型类型数组
		Type[] types = pType.getActualTypeArguments();
		//由于我们的BaseDao的泛型参数里只有一个类型T,因此数组的第一个元素就是类型T的实际上的类型
		entityClass = (Class<T>)types[0];
	}

	/**
	 * 条件查询
	 */
	public List<T> getList(T t1,T t2,Object param) {
     
		DetachedCriteria dc = getDetachedCriteria(t1,t2,param);
		return (List<T>) this.getHibernateTemplate().findByCriteria(dc);
	}
	
	/**
	 * 分页查询
	 * @param t1
	 * @param t2
	 * @param param
	 * @param firstResult
	 * @param maxResults
	 * @return
	 */
	public List<T> getListByPage(T t1,T t2,Object param,int firstResult, int maxResults) {
     
		DetachedCriteria dc = getDetachedCriteria(t1,t2,param);
		return (List<T>) this.getHibernateTemplate().findByCriteria(dc,firstResult, maxResults);
	}

	/**
	 * 记录条件查询的总记录数
	 * @param t1
	 * @return
	 */
	public long getCount(T t1,T t2,Object param) {
     
		DetachedCriteria dc = getDetachedCriteria(t1,t2,param);
		dc.setProjection(Projections.rowCount());
		List<Long> list = (List<Long>)getHibernateTemplate().findByCriteria(dc);
		return list.get(0);
	}
	
	/**
	 * 新增
	 * @param t
	 */
	public void add(T t){
     
		this.getHibernateTemplate().save(t);
	}
	
	/**
	 * 删除
	 */
	public void delete(Long uuid){
     
		//让对象进入持久化状态
		T t = this.getHibernateTemplate().get(entityClass, uuid);
		//删除持久化状态
		this.getHibernateTemplate().delete(t);
	}
	
	/**
	 * 通过编号查询对象
	 * @param uuid
	 * @return
	 */
	public T get(Long uuid){
     
		return getHibernateTemplate().get(entityClass, uuid);
	}
	
	/**
	 * 更新
	 */
	public void update(T t){
     
		this.getHibernateTemplate().update(t);
	}
	
	/**
	 * 由子类实现
	 * @param t1
	 * @return
	 */
	public DetachedCriteria getDetachedCriteria(T t1, T t2, Object param){
     
		
		return null;
	}
}

IWaybillDao

package com.redsum.bos.dao;

import com.redsum.bos.entity.Waybill;
/**
 * 数据访问接口
 * @author Administrator
 *
 */
public interface IWaybillDao extends IBaseDao<Waybill>{
     

}

WaybillDao

package com.redsum.bos.dao.impl;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import com.redsum.bos.dao.IWaybillDao;
import com.redsum.bos.entity.Waybill;

/**
 * 数据访问类
 * 
 * @author Administrator
 *
 */
public class WaybillDao extends BaseDao<Waybill> implements IWaybillDao {
     
	/**
	 * 构建查询条件
	 * 
	 * @param dep1
	 * @param dep2
	 * @param param
	 * @return
	 */
	public DetachedCriteria getDetachedCriteria(Waybill waybill1, Waybill waybill2, Object param) {
     
		DetachedCriteria dc = DetachedCriteria.forClass(Waybill.class);
		if (waybill1 != null) {
     
			if (null != waybill1.getToaddress() && waybill1.getToaddress().trim().length() > 0) {
     
				dc.add(Restrictions.like("toaddress", waybill1.getToaddress(), MatchMode.ANYWHERE));
			}
			if (null != waybill1.getAddressee() && waybill1.getAddressee().trim().length() > 0) {
     
				dc.add(Restrictions.like("addressee", waybill1.getAddressee(), MatchMode.ANYWHERE));
			}
			if (null != waybill1.getTele() && waybill1.getTele().trim().length() > 0) {
     
				dc.add(Restrictions.like("tele", waybill1.getTele(), MatchMode.ANYWHERE));
			}
			if (null != waybill1.getInfo() && waybill1.getInfo().trim().length() > 0) {
     
				dc.add(Restrictions.like("info", waybill1.getInfo(), MatchMode.ANYWHERE));
			}
			if (null != waybill1.getState() && waybill1.getState().trim().length() > 0) {
     
				dc.add(Restrictions.like("state", waybill1.getState(), MatchMode.ANYWHERE));
			}

		}
		return dc;
	}

}

IWaybilldetailDao

package com.redsum.bos.dao;

import com.redsum.bos.entity.Waybilldetail;
/**
 * 数据访问接口
 * @author Administrator
 *
 */
public interface IWaybilldetailDao extends IBaseDao<Waybilldetail>{
     

}

WaybilldetailDao

package com.redsum.bos.dao.impl;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import com.redsum.bos.dao.IWaybilldetailDao;
import com.redsum.bos.entity.Waybilldetail;
/**
 * 数据访问类
 * @author Administrator
 *
 */
public class WaybilldetailDao extends BaseDao<Waybilldetail> implements IWaybilldetailDao {
     

	/**
	 * 构建查询条件
	 * @param dep1
	 * @param dep2
	 * @param param
	 * @return
	 */
	public DetachedCriteria getDetachedCriteria(Waybilldetail waybilldetail1,Waybilldetail waybilldetail2,Object param){
     
		DetachedCriteria dc=DetachedCriteria.forClass(Waybilldetail.class);
		if(waybilldetail1!=null){
     
			if(null != waybilldetail1.getExedate() && waybilldetail1.getExedate().trim().length()>0){
     
				dc.add(Restrictions.like("exedate", waybilldetail1.getExedate(), MatchMode.ANYWHERE));
			}
			if(null != waybilldetail1.getExetime() && waybilldetail1.getExetime().trim().length()>0){
     
				dc.add(Restrictions.like("exetime", waybilldetail1.getExetime(), MatchMode.ANYWHERE));
			}
			if(null != waybilldetail1.getInfo() && waybilldetail1.getInfo().trim().length()>0){
     
				dc.add(Restrictions.like("info", waybilldetail1.getInfo(), MatchMode.ANYWHERE));
			}
			//根据运单号查询明细
			if(null != waybilldetail1.getSn()){
     
				dc.add(Restrictions.eq("sn", waybilldetail1.getSn()));
			}
		}
		return dc;
	}
}

applicationContext_dao.xml


<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context 
		http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/tx 
		http://www.springframework.org/schema/tx/spring-tx.xsd
		http://www.springframework.org/schema/aop 
		http://www.springframework.org/schema/aop/spring-aop.xsd
		">  
	
	<bean id="waybillDao" class="com.redsum.bos.dao.impl.WaybillDao">
		<property name="sessionFactory" ref="sessionFactory">property>
	bean>
	
	<bean id="waybilldetailDao" class="com.redsum.bos.dao.impl.WaybilldetailDao">
		<property name="sessionFactory" ref="sessionFactory">property>
	bean>
beans>

applicationContext_datasource.xml


<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context 
		http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/tx 
		http://www.springframework.org/schema/tx/spring-tx.xsd
		http://www.springframework.org/schema/aop 
		http://www.springframework.org/schema/aop/spring-aop.xsd
		">  
	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
		<property name="url" value="jdbc:mysql://127.0.0.1:3306/redsun?useUnicode=true&characterEncoding=UTF8"/>
		<property name="username" value="root"/>
		<property name="password" value="root"/>
	bean>
	<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"/>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialectprop>
				<prop key="hibernate.show_sql">trueprop>
				<prop key="hibernate.format_sql">falseprop>
			props>
		property>
		<property name="mappingLocations">
			<value>classpath:com/redsum/bos/entity/*.hbm.xmlvalue>
		property>
	bean>
beans>

3)redsun_biz当中创建创建接口和类,并添加依赖
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第15张图片
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第16张图片
IBaseBiz

package com.redsum.bos.biz;

import java.util.List;

/**
 * 通用业务逻辑接口
 * @author Administrator
 *
 * @param 
 */
public interface IBaseBiz<T> {
     
	/**
	 * 条件查询
	 * @param t1
	 * @return
	 */
	List<T> getList(T t1,T t2,Object param);
	/**
	 * 分页查询
	 * @param t1
	 * @param t2
	 * @param param
	 * @param firstResult
	 * @param maxResults
	 * @return
	 */
	List<T> getListByPage(T t1,T t2,Object param,int firstResult, int maxResults);
	/**
	 * 计算总记录数
	 * @param t1
	 * @param t2
	 * @param param
	 * @return
	 */
	public long getCount(T t1,T t2,Object param);
	/**
	 * 新增
	 * @param t
	 */
	void add(T t);
	/**
	 * 删除
	 */
	void delete(Long uuid);
	/**
	 * 通过编号查询对象
	 * @param uuid
	 * @return
	 */
	T get(Long uuid);
	/**
	 * 更新
	 */
	void update(T t);
}

BaseBiz

package com.redsum.bos.biz.impl;

import java.util.List;
import com.redsum.bos.biz.IBaseBiz;
import com.redsum.bos.dao.IBaseDao;
/**
 * 通用业务逻辑实现类
 * @author Administrator
 *
 * @param 
 */
public class BaseBiz<T> implements IBaseBiz<T> {
     

	/** 数据访问注入*/
	private IBaseDao<T> baseDao;

	public void setBaseDao(IBaseDao<T> baseDao) {
     
		this.baseDao = baseDao;
	}
	
	/**
	 * 条件查询
	 * @param t1
	 * @return
	 */
	public List<T> getList(T t1,T t2,Object param){
     
		return baseDao.getList(t1,t2,param);
	}
	
	/**
	 * 条件查询
	 * @param t1
	 * @return
	 */
	public List<T> getListByPage(T t1,T t2,Object param,int firstResult, int maxResults){
     
		return baseDao.getListByPage(t1,t2,param,firstResult, maxResults);
	}

	@Override
	public long getCount(T t1,T t2,Object param) {
     
		return baseDao.getCount(t1,t2,param);
	}

	@Override
	public void add(T t) {
     
		baseDao.add(t);
	}

	/**
	 * 删除
	 */
	public void delete(Long uuid){
     
		baseDao.delete(uuid);
	}
	
	/**
	 * 通过编号查询对象
	 * @param uuid
	 * @return
	 */
	public T get(Long uuid){
     
		return baseDao.get(uuid);
	}
	
	/**
	 * 更新
	 */
	public void update(T t){
     
		baseDao.update(t);
	}

}


IWaybillBiz

package com.redsum.bos.biz;
import com.redsum.bos.entity.Waybill;
/**
 * 业务逻辑层接口
 * @author Administrator
 *
 */
public interface IWaybillBiz extends IBaseBiz<Waybill>{
     

}


WaybillBiz

package com.redsum.bos.biz.impl;
import com.redsum.bos.biz.IWaybillBiz;
import com.redsum.bos.dao.IWaybillDao;
import com.redsum.bos.entity.Waybill;
/**
 * 业务逻辑类
 * @author Administrator
 *
 */
public class WaybillBiz extends BaseBiz<Waybill> implements IWaybillBiz {
     

	private IWaybillDao waybillDao;
	
	public void setWaybillDao(IWaybillDao waybillDao) {
     
		this.waybillDao = waybillDao;
		super.setBaseDao(this.waybillDao);
	}
	
}

IWaybilldetailBiz

package com.redsum.bos.biz;
import com.redsum.bos.entity.Waybilldetail;
/**
 * 业务逻辑层接口
 * @author Administrator
 *
 */
public interface IWaybilldetailBiz extends IBaseBiz<Waybilldetail>{
     

}


WaybilldetailBiz

package com.redsum.bos.biz.impl;
import com.redsum.bos.biz.IWaybilldetailBiz;
import com.redsum.bos.dao.IWaybilldetailDao;
import com.redsum.bos.entity.Waybilldetail;
/**
 * 业务逻辑类
 * @author Administrator
 *
 */
public class WaybilldetailBiz extends BaseBiz<Waybilldetail> implements IWaybilldetailBiz {
     

	private IWaybilldetailDao waybilldetailDao;
	
	public void setWaybilldetailDao(IWaybilldetailDao waybilldetailDao) {
     
		this.waybilldetailDao = waybilldetailDao;
		super.setBaseDao(this.waybilldetailDao);
	}
	
}

applicationContext_biz.xml


<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context 
		http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/tx 
		http://www.springframework.org/schema/tx/spring-tx.xsd
		http://www.springframework.org/schema/aop 
		http://www.springframework.org/schema/aop/spring-aop.xsd
		">   
	
	<bean id="waybillBiz" class="com.redsum.bos.biz.impl.WaybillBiz">
		<property name="waybillDao" ref="waybillDao">property>
	bean>
	
	<bean id="waybilldetailBiz" class="com.redsum.bos.biz.impl.WaybilldetailBiz">
		<property name="waybilldetailDao" ref="waybilldetailDao">property>
	bean>
beans>

applicationContext_tx.xml


<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context 
		http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/tx 
		http://www.springframework.org/schema/tx/spring-tx.xsd
		http://www.springframework.org/schema/aop 
		http://www.springframework.org/schema/aop/spring-aop.xsd
		">  
	<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory"/>
	bean>
	<tx:advice id="advice" transaction-manager="transactionManager">
	    <tx:attributes>	     
	      <tx:method name="do*" propagation="REQUIRED"/>
	      <tx:method name="add*" propagation="REQUIRED"/>
	      <tx:method name="update*" propagation="REQUIRED"/>
	      <tx:method name="save*" propagation="REQUIRED"/>
	      <tx:method name="delete*" propagation="REQUIRED"/>
	      <tx:method name="*" read-only="true"/>
	    tx:attributes>
	tx:advice>
	<aop:config>
		<aop:pointcut id="serviceMethod" expression="execution(* com.redsum.bos.biz.impl.*.*(..))"/>
		<aop:advisor pointcut-ref="serviceMethod" advice-ref="advice" />
	aop:config>
beans>

4)redsun_web当中创建创建接口和类,并添加依赖
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第17张图片
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第18张图片

BaseAction

package com.redsum.bos.action;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.alibaba.fastjson.JSON;

import com.redsum.bos.biz.IBaseBiz;

/**
 * 通用Action类
 * @author Administrator
 *
 * @param 
 */
public class BaseAction<T> {
     

	private IBaseBiz<T> baseBiz;
	
	public void setBaseBiz(IBaseBiz<T> baseBiz) {
     
		this.baseBiz = baseBiz;
	}
	
	//属性驱动:条件查询
	private T t1;
	private T t2;
	private Object param;
	public T getT2() {
     
		return t2;
	}
	public void setT2(T t2) {
     
		this.t2 = t2;
	}
	public Object getParam() {
     
		return param;
	}
	public void setParam(Object param) {
     
		this.param = param;
	}
	public T getT1() {
     
		return t1;
	}
	public void setT1(T t1) {
     
		this.t1 = t1;
	}
	
	private int page;//页码
	private int rows;//每页的记录数
	
	public int getPage() {
     
		return page;
	}
	public void setPage(int page) {
     
		this.page = page;
	}
	public int getRows() {
     
		return rows;
	}
	public void setRows(int rows) {
     
		this.rows = rows;
	}
	/**
	 * 条件查询
	 */
	public void list(){
     
		List<T> list = baseBiz.getList(t1,t2,param);
		//把部门列表转JSON字符串
		String listString = JSON.toJSONString(list);
		write(listString);
	}
	
	public void listByPage(){
     
		System.out.println("页码:" + page + " 记录数:" + rows);
		int firstResult = (page -1) * rows;
		List<T> list = baseBiz.getListByPage(t1,t2,param,firstResult, rows);
		long total = baseBiz.getCount(t1,t2,param);
		//{total: total, rows:[]}
		Map<String, Object> mapData = new HashMap<String, Object>();
		mapData.put("total", total);
		mapData.put("rows", list);
		//把部门列表转JSON字符串
		String listString = JSON.toJSONString(mapData);
		write(listString);
	}
	
	/**新增,修改*/
	private T t;
	public T getT() {
     
		return t;
	}
	public void setT(T t) {
     
		this.t = t;
	}
	/**
	 * 新增
	 * @param jsonString
	 */
	public void add(){
     
		//{"success":true,"message":""}
		//返回前端的JSON数据
		Map<String, Object> rtn = new HashMap<String, Object>();
		try {
     
			baseBiz.add(t);
			rtn.put("success",true);
			rtn.put("message","新增成功");
		} catch (Exception e) {
     
			e.printStackTrace();
			rtn.put("success",false);
			rtn.put("message","新增失败");
		}
		write(JSON.toJSONString(rtn));
	}
	
	private long id;
	public long getId() {
     
		return id;
	}
	public void setId(long id) {
     
		this.id = id;
	}
	/**
	 * 删除
	 * @param jsonString
	 */
	public void delete(){
     
		
		try {
     
			baseBiz.delete(id);
			ajaxReturn(true, "删除成功");
		} catch (Exception e) {
     
			e.printStackTrace();
			ajaxReturn(false, "删除失败");
		}
	}
	
	/**
	 * 通过编辑查询对象
	 */
	public void get(){
     
		T t = baseBiz.get(id);
		String jsonString = JSON.toJSONString(t);
		System.out.println("转换前:" + jsonString);
		//{"name":"管理员组","tele":"000011","uuid":1}
		String jsonStringAfter = mapData(jsonString, "t");
		System.out.println("转换后:" + jsonStringAfter);
		write(jsonStringAfter);
	}
	
	/**
	 * 修改
	 */
	public void update(){
     
		try {
     
			baseBiz.update(t);
			ajaxReturn(true, "修改成功");
		} catch (Exception e) {
     
			e.printStackTrace();
			ajaxReturn(false, "修改失败");
		}
	}
	
	/**
	 * //{"name":"管理员组","tele":"000011","uuid":1} 
	 * @param jsonString JSON数据字符串
	 * @param prefix 要加上的前缀
	 * @return  {"t.name":"管理员组","t.tele":"000011","t.uuid":1} 
	 */
	public String mapData(String jsonString, String prefix){
     
		Map<String, Object> map = JSON.parseObject(jsonString);
		
		//存储key加上前缀后的值
		Map<String, Object> dataMap = new HashMap<String, Object>();
		//给每key值加上前缀
		for(String key : map.keySet()){
     
			dataMap.put(prefix + "." + key, map.get(key));
		}
		return JSON.toJSONString(dataMap);
	}
	
	/**
	 * 返回前端操作结果
	 * @param success
	 * @param message
	 */
	public void ajaxReturn(boolean success, String message){
     
		//返回前端的JSON数据
		Map<String, Object> rtn = new HashMap<String, Object>();
		rtn.put("success",success);
		rtn.put("message",message);
		write(JSON.toJSONString(rtn));
	}
	
	/**
	 * 输出字符串到前端
	 * @param jsonString
	 */
	public void write(String jsonString){
     
		try {
     
			//响应对象
			HttpServletResponse response = ServletActionContext.getResponse();
			//设置编码
			response.setContentType("text/html;charset=utf-8"); 
			//输出给页面
			response.getWriter().write(jsonString);
		} catch (IOException e) {
     
			e.printStackTrace();
		}
	}
}

WaybillAction

package com.redsum.bos.action;
import com.redsum.bos.biz.IWaybillBiz;
import com.redsum.bos.entity.Waybill;

/**
 * Action 
 * @author Administrator
 *
 */
public class WaybillAction extends BaseAction<Waybill> {
     

	private IWaybillBiz waybillBiz;

	public void setWaybillBiz(IWaybillBiz waybillBiz) {
     
		this.waybillBiz = waybillBiz;
		super.setBaseBiz(this.waybillBiz);
	}

}

WaybilldetailAction

package com.redsum.bos.action;
import com.redsum.bos.biz.IWaybilldetailBiz;
import com.redsum.bos.entity.Waybilldetail;

/**
 * Action 
 * @author Administrator
 *
 */
public class WaybilldetailAction extends BaseAction<Waybilldetail> {
     

	private IWaybilldetailBiz waybilldetailBiz;

	public void setWaybilldetailBiz(IWaybilldetailBiz waybilldetailBiz) {
     
		this.waybilldetailBiz = waybilldetailBiz;
		super.setBaseBiz(this.waybilldetailBiz);
	}

}

(7)测试运行

http://localhost:9090/redsun/admin/waybill.html
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第19张图片
http://localhost:9090/redsun/admin/waybilldetail.html
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第20张图片

4、系统开发

(1)修改WaybilldetailDao

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第21张图片

			//根据运单号查询明细
			if(null != waybilldetail1.getSn()) {
     
				dc.add(Restrictions.eq("sn", waybilldetail1.getSn()));
			}
(2)创建包结构以及对应的类

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第22张图片
IWaybillWS

package com.redsum.bos.ws;

import java.util.List;

import javax.jws.WebService;

import com.redsum.bos.entity.Waybilldetail;

/*
 * 运单服务接口
 */
@WebService
public interface IWaybillWS {
     

	/*
	 * 查询运单详情
	 */
	List<Waybilldetail> waybilldetailList(Long sn);
	
	/*
	 * 在线预约下单
	 */
	Long addWaybill(Long id,String toAddress,String addressee,String tele,String info);
}

WaybillWS

package com.redsum.bos.ws.impl;
import java.util.List;
import com.redsum.bos.biz.IWaybillBiz;
import com.redsum.bos.biz.IWaybilldetailBiz;
import com.redsum.bos.entity.Waybill;
import com.redsum.bos.entity.Waybilldetail;
import com.redsum.bos.ws.IWaybillWS;
public class WaybillWS implements IWaybillWS {
     
	private IWaybillBiz waybillBiz;
	private IWaybilldetailBiz waybilldetailBiz;
	public void setWaybillBiz(IWaybillBiz waybillBiz) {
     
		this.waybillBiz = waybillBiz;
	}
	public void setWaybilldetailBiz(IWaybilldetailBiz waybilldetailBiz) {
     
		this.waybilldetailBiz = waybilldetailBiz;
	}
	/*
	 * 查询运单详情
	 */
	@Override
	public List<Waybilldetail> waybilldetailList(Long sn) {
     
		// 构建查询条件
		Waybilldetail waybilldetail = new Waybilldetail();
		waybilldetail.setSn(sn);
		return waybilldetailBiz.getList(waybilldetail, null, null);
	}
	/*
	 * 
	 */
	@Override
	public Long addWaybill(Long id, String toAddress, String addressee, String tele, String info) {
     
		Waybill waybill = new Waybill();
		waybill.setToaddress(toAddress);
		waybill.setInfo(info);
		waybill.setState("0");
		waybill.setTele(tele);
		waybill.setUserid(id);
		waybill.setAddressee(addressee);
		waybillBiz.add(waybill);
		return waybill.getSn();
	}
}
(3)创建applicationContext_cxf.xml配置文件

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第23张图片


<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">
	
	<bean id="waybillWs" class="com.redsum.bos.ws.impl.WaybillWS">
		<property name="waybillBiz" ref="waybillBiz">property>
		<property name="waybilldetailBiz" ref="waybilldetailBiz">property>
	bean>
	
	<jaxws:server address="/waybill">
		<jaxws:serviceBean>
			<ref bean="waybillWs"/>
		jaxws:serviceBean>
	jaxws:server>
beans>
(4)发布服务

http://localhost:9090/redsun/ws/waybill?wsdl
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第24张图片
http://localhost:9090/redsun/ws/waybill?wsdl=IWaybillWS.wsdl
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第25张图片

二、ERP整合物流Bos系统客户端

1、在erp_partent的基础上创建子工程

(1)创建erp_client工程

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第26张图片
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第27张图片
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第28张图片

(2)erp_biz给工程添加依赖

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第29张图片

(3)生成客户端代码

a、查看工程的位置

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第30张图片
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第31张图片

b、在cmd当中执行如下代码
cd D:\ITZHENGWORKSPACE\erp_partent\erp_client\src\main\java
D:
wsimport -s . http://localhost:9090/redsun/ws/waybill?wsdl

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第32张图片

c、更新项目自动生成代码成功

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第33张图片

d、配置对应的坐标在erp_partent对应的pom.xml当中

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第34张图片

<!-- Web Service CXF-->
  		<dependency>
	  		<groupId>org.apache.cxf</groupId>
	  		<artifactId>cxf-rt-frontend-jaxws</artifactId>
	  		<version>3.1.10</version>
	  	</dependency>
	  	<dependency>
	  		<groupId>org.apache.cxf</groupId>
	  		<artifactId>cxf-rt-transports-http</artifactId>
	  		<version>3.1.10</version>
	  	</dependency>
e、配置客户端的配置文件(在erp_client)当中的resources

resources\applicationContext_cxf.xml
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第35张图片


<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">
	
	<jaxws:client id="waybillClient" address="http://localhost:9090/redsun/ws/waybill?wsdl" 
	 serviceClass="com.redsum.bos.ws.impl.IWaybillWS" >
	jaxws:client>
beans>

2、通过运单号查询运单详情

(1)在IOrdersBiz当中创建waybilldatailList方法

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第36张图片

/*
	 * 根据运单号查询运单分析
	 */
	List<Waybilldetail> waybilldatailList(Long sn);

(2)在OrdersBiz当中注入IWaybillWS

a、修改OrdersBiz

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第37张图片

b、修改applicationContext_biz.xml

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第38张图片

<property name="waybillWs" ref="waybillClient">property>

(3)在OrdersBiz当中创建waybilldatailList方法通过运单号查询运单详情

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第39张图片

/*
	 * 通过运单号查询运单详情
	 */
	@Override
	public List<Waybilldetail> waybilldatailList(Long sn) {
     
		return waybillWs.waybilldetailList(sn);
	}

3、通过运单号查询运单详情

(1)修改OrderdetailBiz,注入对应的接口

a、编写对应的类并设置set方法

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第40张图片

	private IWaybillWS waybillWs;
	private ISupplierDao supplierDao;
	public void setWaybillWs(IWaybillWS waybillWs) {
     
		this.waybillWs = waybillWs;
	}
	public void setSupplierDao(ISupplierDao supplierDao) {
     
		this.supplierDao = supplierDao;
	}
b、设置对应的配置文件applicationContext_biz.xml

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第41张图片

<property name="supplierDao" ref="supplierDao">property>
<property name="waybillWs" ref="waybillClient">property>

(2)修改OrderdetailBiz当中的doOutStore方法

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第42张图片

			 //客户
			Supplier supplier = supplierDao.get(orders.getSupplieruuid());
			//在线预约下单,获取运单号
			Long waybillsn = waybillWs.addWaybill(1l, supplier.getAddress(), supplier.getContact(), supplier.getTele(), "--");
			
			//更新运单号
			orders.setWaybillsn(waybillsn);

4、ERP系统当中显示物理系统的信息

(1)OrdersAction当中

在这里插入图片描述

// 根据运单号查询运单详情
	public void waybilldetailList() {
     
		List<Waybilldetail> waybilldatailList = ordersBiz.waybilldatailList(waybillSn);
		write(JSON.toJSONString(waybilldatailList));
	}

(2)修改orders.html

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第43张图片

(3)修改orders.js

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第44张图片
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第45张图片

(4)访问:http://localhost:8080/erp/orders.html?oper=orders&type=2

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第46张图片

(5)添加按钮弹出运单详情

a、修改orders.html

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第47张图片

<div id="waybillDlg" style="padding:2px;" class="easyui-dialog" data-options="
		title:'运单详情',width:500,height:300,modal:true,closed:true
	" >
	<table id="waybillgrid">table>
div>
b、修改orders.js

Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第48张图片

// 订单已经出库
			if (rowData.state * 1 == 1) {
     
				// 添加详情的按钮
				var options = $('#ordersDlg').dialog('options');
				var toolbar = options.toolbar;
				toolbar.push({
     
					text : '运单详情',
					iconCls : 'icon-search',
					handler : function() {
     
						$('#waybillDlg').dialog('open');
						$('#waybillgrid').datagrid({
     
							url:'orders_waybilldetailList?waybillsn=' + $('#waybillsn').html(),
							columns:[[
								{
     field:'exedate',title:'执行日期',width:100},
								{
     field:'exetime',title:'执行时间',width:100},
								{
     field:'info',title:'执行日期',width:100}
							]],
							rownumbers:true
						});
					}
				});
				//重新渲染工具栏
				$('#ordersDlg').dialog({
     
					toolbar : toolbar
				});
e、访问

http://localhost:8080/erp/orders.html?oper=orders&type=2
Java全栈开发---Java ERP系统开发:商业ERP(十三)CXF框架,物流BOS系统开发_第49张图片

你可能感兴趣的:(全栈开发项目源代码,数据库,spring,java,vue,mysql)