【springmvc+mybatis项目实战】杰信商贸-16.新增从表货物信息

通过上几次我们已经将购销合同的所有业务完成了,接下来我们要完成的是在购销合同下的货物的业务

我们的购销合同相对于货物是一对多的,所以我们需要配置对象之间的关联关系。

首先先编写实体类ContractProduct.java:

package cn.hpu.jk.domain;

public class ContractProduct {
	private String id;

	//private Contract contract;//将复杂的关联变成单表操作
	private String contractId;//关联关系的表,都成为普通字段
	private String factoryId;

	private String factoryName;
	private String productNo;
	private String productImage;
	private String productDesc;//货物描述
	private Integer cnumber;//数量
	private Integer outNumber;//出货数量
	private String loadingRate;//装率
	private String boxNum;//箱数
	private String packingUnit;//包装单位
	private Double price;//单价
	private Double amount;//总价
	private Integer finished;//是否出货完毕
	private String exts;//附件
	private Integer orderNo;//排序号

	//get与set方法省略
}

我们将关系对象的形式变成了一张单表,变得简单了(比hibernate效率高),我们的关键是如何将他们关联起来而已。

我们然后来做一个映射,编写映射文件ContractProductMapper.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.hpu.jk.mapper.ContractProductMapper">
	<!-- 映射合同和合同下的货物信息一对多 -->
	<resultMap type="cn.hpu.jk.domain.ContractProduct" id="ContractProductRM">
		<id property="id" column="CONTRACT_PRODUCT_ID"/>
		<result property="contractId" column="CONTRACT_ID"/>
		<result property="factoryId" column="FACTORY_ID"/>
		<result property="factoryName" column="FACTORY_NAME"/>
		<result property="productNo" column="PRODUCT_NO"/>
		<result property="productImage" column="PRODUCT_IMAGE"/>
		<result property="productDesc" column="PRODUCT_DESC"/>
		<result property="cnumber" column="CNUMBER"/>
		<result property="outNumber" column="OUT_NUMBER"/>
		<result property="loadingRate" column="LOADING_RATE"/>
		<result property="boxNum" column="BOX_NUM"/>
		<result property="packingUnit" column="PACKING_UNIT"/>
		<result property="price" column="PRICE"/>
		<result property="amount" column="AMOUNT"/>
		<result property="finished" column="FINISHED"/>
		<result property="exts" column="EXTS"/>
		<result property="orderNo" column="ORDER_NO"/>
	</resultMap>

	 <!-- 查询 -->
	 <select id="find" parameterType="map" resultMap="ContractProductRM">
	 	select * from contract_product_c
	 	where 1=1
	 </select>

	 <!-- 查询一个 -->
	  <select id="get" parameterType="String" resultMap="ContractProductRM">
	 	select * from contract_product_c
	 	where contract_product_id=#{id}
	 </select>

	 <insert id="insert" parameterType="cn.hpu.jk.domain.ContractProduct">
	 	insert into contract_product_c
		(CONTRACT_PRODUCT_ID,CONTRACT_ID,FACTORY_ID,FACTORY_NAME,PRODUCT_NO,
			PRODUCT_IMAGE,PRODUCT_DESC,CNUMBER,OUT_NUMBER,LOADING_RATE,BOX_NUM,
			PACKING_UNIT,PRICE,AMOUNT,FINISHED,EXTS,ORDER_NO)
		values(
			#{id},
			#{contractId},
			#{factoryId},
			#{factoryName, jdbcType=VARCHAR},
			#{productNo, jdbcType=VARCHAR},
			#{productImage, jdbcType=VARCHAR},
			#{productDesc, jdbcType=VARCHAR},
			#{cnumber, jdbcType=INTEGER},
			#{outNumber, jdbcType=INTEGER},
			#{loadingRate, jdbcType=VARCHAR},
			#{boxNum, jdbcType=INTEGER},
			#{packingUnit, jdbcType=VARCHAR},
			#{price, jdbcType=DOUBLE},
			#{amount, jdbcType=DOUBLE},
			#{finished, jdbcType=INTEGER},
			#{exts, jdbcType=VARCHAR},
			#{orderNo, jdbcType=INTEGER}
		)
	 </insert>

	 <update id="update" parameterType="cn.hpu.jk.domain.ContractProduct">
	 	update contract_product_c
	 	<set>
	 		CONTRACT_ID=#{contractId},
			FACTORY_ID=#{factoryId},
			<if test="factoryName != null">FACTORY_NAME=#{factoryName},</if>
			<if test="productNo != null">PRODUCT_NO=#{productNo},</if>
			<if test="productImage != null">PRODUCT_IMAGE=#{productImage},</if>
			<if test="productDesc != null">PRODUCT_DESC=#{productDesc},</if>
			<if test="cnumber != null">CNUMBER=#{cnumber},</if>
			<if test="outNumber != null">OUT_NUMBER=#{outNumber},</if>
			<if test="loadingRate != null">LOADING_RATE=#{loadingRate},</if>
			<if test="boxNum != null">BOX_NUM=#{boxNum},</if>
			<if test="packingUnit != null">PACKING_UNIT=#{packingUnit},</if>
			<if test="price != null">PRICE=#{price},</if>
			<if test="amount != null">AMOUNT=#{amount},</if>
			<if test="finished != null">FINISHED=#{finished},</if>
			<if test="exts != null">EXTS=#{exts},</if>
			<if test="orderNo != null">ORDER_NO=#{orderNo},</if>
	 	</set>
	 	where contract_product_id=#{id}
	 </update>

	 <!-- 删除一条 -->
	<delete id="deleteById" parameterType="string">
		delete from contract_product_c
		where contract_product_id=#{id}
	</delete>

	<!-- 删除多条(一维字符串数组) -->
	<delete id="delete" parameterType="string">
		delete from contract_product_c
		where contract_product_id in
		<foreach collection="array" item="id" open="(" close=")" separator=",">
			#{id}
		</foreach>
	</delete>
</mapper>

之后我们写Dao层:
ContractProductDao.java:

package cn.hpu.jk.dao;

import cn.hpu.jk.domain.Contract;

public interface ContractProductDao extends BaseDao<ContractProduct>{
	//我们这里可以直接使用继承的BaseDao的增删改查方法
	//创建一系列其它Dao的原因是因为其它Dao有可能需要拓展

}

ContractProductDaoImpl.java:

package cn.hpu.jk.dao.impl;

import org.springframework.stereotype.Repository;

import cn.hpu.jk.dao.ContractProductDao;
import cn.hpu.jk.domain.ContractProduct;

@Repository //为了包扫描的时候这个Dao被扫描到
public class ContractProductDaoImpl extends BaseDaoImpl<ContractProduct> implements ContractProductDao{

	public ContractProductDaoImpl(){
		//设置命名空间
		super.setNs("cn.hpu.jk.mapper.ContractProductMapper");
	}

}

然后是Service层
ContractProductService.java:

package cn.hpu.jk.service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import cn.hpu.jk.domain.Contract;
import cn.hpu.jk.domain.ContractProduct;
import cn.hpu.jk.pagination.Page;

public interface ContractProductService {
	public List<ContractProduct> findPage(Page page);	//分页查询
	public List<ContractProduct> find(Map paraMap);		//带条件查询,条件可以为null,既没有条件;返回list对象集合
	public ContractProduct get(Serializable id);				//只查询一个,常用于修改
	public void insert(ContractProduct contractProduct);		//插入,用实体作为参数
	public void update(ContractProduct contractProduct);		//修改,用实体作为参数
	public void deleteById(Serializable id);	//按id删除,删除一条;支持整数型和字符串类型ID
	public void delete(Serializable[] ids);	//批量删除;支持整数型和字符串类型ID
}

ContractProductServiceImpl.java:

package cn.hpu.jk.service.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.hpu.jk.dao.ContractProductDao;
import cn.hpu.jk.domain.ContractProduct;
import cn.hpu.jk.pagination.Page;
import cn.hpu.jk.service.ContractProductService;

@Service
public class ContractProductServiceImpl implements ContractProductService{

	@Resource
	ContractProductDao contractProductDao;

	@Override
	public void delete(Serializable[] ids) {
		contractProductDao.delete(ids);
	}

	@Override
	public void deleteById(Serializable id) {
		contractProductDao.deleteById(id);
	}

	@Override
	public List<ContractProduct> find(Map paraMap) {
		return contractProductDao.find(paraMap);
	}

	@Override
	public List<ContractProduct> findPage(Page page) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ContractProduct get(Serializable id) {
		return contractProductDao.get(id);
	}

	@Override
	public void insert(ContractProduct contractProduct) {
		//设置UUID
		contractProduct.setId(UUID.randomUUID().toString());
		contractProductDao.insert(contractProduct);
	}

	@Override
	public void update(ContractProduct contractProduct) {

		contractProductDao.update(contractProduct);
	}

}

然后在beans-service.xml增加contractProductService的注入

<?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:mvc="http://www.springframework.org/schema/mvc"
	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-3.0.xsd
			http://www.springframework.org/schema/mvc
			http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
			http://www.springframework.org/schema/context
			http://www.springframework.org/schema/context/spring-context-3.0.xsd
			http://www.springframework.org/schema/aop
			http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
			http://www.springframework.org/schema/tx
			http://www.springframework.org/schema/tx/spring-tx-3.0.xsd ">

		<!-- 加载service-->
		<bean name="factoryService" class="cn.hpu.jk.service.impl.FactoryServiceImpl"/>
		<bean name="contractService" class="cn.hpu.jk.service.impl.ContractServiceImpl"/>
		<bean name="contractProductService" class="cn.hpu.jk.service.impl.ContractProductServiceImpl"/>

</beans>

之后我们来编写Controller层,我们先写一个新增方法

package cn.hpu.jk.controller.cargo.contract;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.hpu.jk.controller.BaseController;
import cn.hpu.jk.domain.ContractProduct;
import cn.hpu.jk.service.ContractProductService;

@Controller
public class ContractProductController extends BaseController{

	@Autowired
	ContractProductService contractProductService; 

	//转向新增页面
	@RequestMapping("/cargo/contractproduct/tocreate.action")
	public String tocreate(String contractId,Model model){
		//传递购销合同Id
		model.addAttribute("contractId", contractId);
		return "/cargo/contract/jContractProductCreate.jsp";//货物的新增页面
	}

	//新增
	@RequestMapping("/cargo/contractproduct/insert.action")
	public String insert(ContractProduct contractProduct,Model model){
		contractProductService.insert(contractProduct);

		model.addAttribu("contractId", contractProduct.getContractId());

		return "redirect:/cargo/contractproduct/tocreate.action";
	}
}

回顾一下我们的货物表

由于我们后面要对生产厂家(Factory)带条件查询,所以我们将生产厂家的Mapper配置文件的find方法修改一下:

<!-- 查询 -->
<select id="find" parameterType="map" resultMap="factoryRM">
	select * from factory_c
	where 1=1
	<if test="state != null"> and STATE=#{state}</if>
</select>

即保证了单独跳向生产厂家页面的时候取所有,又保证带state参数跳向生产厂家列表的时候按条件取数据。

同时我们还要在生产厂家的Service加一些处理代码

在FactoryService中添加

public List<Factory> getFactoryList(); //获取生产厂家列表

在FactoryServiceImpl中添加

@Override
public List<Factory> getFactoryList() {

	Map<String,Object> paraMap=new HashMap<String,Object>();
	paraMap.put("state", 1);//1启用,代表只查询启用的生产厂家

	return factoryDao.find(paraMap);
}

这里我们修改一下刚刚我们写的货物的Controller层(准备生产厂家的下拉列表)

package cn.hpu.jk.controller.cargo.contract;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.hpu.jk.controller.BaseController;
import cn.hpu.jk.domain.ContractProduct;
import cn.hpu.jk.domain.Factory;
import cn.hpu.jk.service.ContractProductService;
import cn.hpu.jk.service.FactoryService;

@Controller
public class ContractProductController extends BaseController{

	@Autowired
	ContractProductService contractProductService;
	@Autowired
	FactoryService factoryService;

	//转向新增页面
	@RequestMapping("/cargo/contractproduct/tocreate.action")
	public String tocreate(String contractId,Model model){
		//传递购销合同Id
		model.addAttribute("contractId", contractId);

		//准备生产厂家的下拉列表
		List<Factory> factoryList=factoryService.getFactoryList();
		model.addAttribute("factoryList",factoryList);

		return "/cargo/contract/jContractProductCreate.jsp";//货物的新增页面
	}

	//新增
	@RequestMapping("/cargo/contractproduct/insert.action")
	public String insert(ContractProduct contractProduct,Model model){
		contractProductService.insert(contractProduct);

		model.addAttribu("contractId", contractProduct.getContractId());

		return "redirect:/cargo/contractproduct/tocreate.action";
	}
}

为了能看到新增的货物,我们在编辑页面添加货物的列表
因为我们是按照选择的生产厂家去看的货物列表,所以我们要修改我们的ContractProductMapper.xml中的find语句块:

 <!-- 查询某个合同下的货物信息 -->
 <select id="find" parameterType="map" resultMap="ContractProductRM">
 	select * from contract_product_c
 	where 1=1
 	<if test="contractId != null"> and contractId=#{CONTRACT_ID}</if>
 </select>

我们在修改Controller来在转向货物编辑页面时带着相应合同的货物列表过去:

//转向新增页面
@RequestMapping("/cargo/contractproduct/tocreate.action")
public String tocreate(String contractId,Model model){
	//传递购销合同Id
	model.addAttribute("contractId", contractId);

	//准备生产厂家的下拉列表
	List<Factory> factoryList=factoryService.getFactoryList();
	model.addAttribute("factoryList",factoryList);

	//某个合同下的货物
	Map paraMap=new HashMap();
	paraMap.put("contractId", contractId);
	List<ContractProduct> dataList=contractProductService.find(paraMap);
	model.addAttribute("dataList", dataList);

	return "/cargo/contract/jContractProductCreate.jsp";//货物的新增页面
}

下面是最终的编辑新增页面jContractProductCreate.jsp:

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../../base.jsp"%>
<%@ include file="../../baselist.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>添加货物信息</title>
    <script type="text/javascript">
    	//设置冗余的生产厂家名称
    	function setFactoryName(val){
    		var ele=document.getElementById("factoryName");
    		ele.value=val;
    	}
    </script>
</head>
<body>
<form method="post">
<div id="menubar">
<div id="middleMenubar">
<div id="innerMenubar">
    <div id="navMenubar">
<ul>
<li id="save"><a href="#" onclick="formSubmit('insert.action','_self');">确定</a></li>
<li id="back"><a href="list.action">返回</a></li>
</ul>
    </div>
</div>
</div>
</div>

<div class="textbox" id="centerTextbox">

    <div class="textbox-header">
    <div class="textbox-inner-header">
    <div class="textbox-title">
		添加货物信息
    </div>
    </div>
    </div>
<div>

    <div>
		<table class="commonTable" cellspacing="1">
			<input type="hidden" name="contractId" value="${contractId}"/>
		        <tr>
		        	<td class="columnTitle_mustbe">厂家名称:</td>
		            <td class="tableContent">
		            <select name="factoryId" onchange="setFactoryName(this.options[this.selectedIndex].text);">
		            	<option value="">--请选择--</option>
		            	<c:forEach items="${factoryList}" var="f">
						<option value="${f.id}">${f.factoryName }</option>
						</c:forEach>
						<input type="hidden" id="factoryName" name="factoryName" value=""/>
					</select>
                    </td>
		            <td class="columnTitle_mustbe">货号:</td>
		            <td class="tableContent"><input type="text" name="productNo" /></td>
		        </tr>

		        <tr>
		        	<td class="columnTitle_mustbe">货物照片:</td>
		            <td class="tableContent"><input type="text" name="productImage" /></td>

		        </tr>

		        <tr>
		        	<td class="columnTitle_mustbe">数量</td>
		            <td class="tableContent"><input type="text" name="cnumber" /></td>
		         	<td class="columnTitle_mustbe">装率:</td>
		            <td class="tableContent"><input type="text" name="loadingRate" /></td>
		        </tr>

		         <tr>
		         	<td class="columnTitle_mustbe">箱数:</td>
		            <td class="tableContent"><input type="text" name="boxNum" /></td>
		         	<td class="columnTitle_mustbe">单价:</td>
		            <td class="tableContent"><input type="text" name="price" /></td>
		        </tr>

		         <tr>
		         	<td class="columnTitle_mustbe">包装单位:</td>
		            <td class="tableContent"><input type="text" name="packingUnit" /></td>
		            <td class="columnTitle_mustbe">排序号:</td>
		            <td class="tableContent"><input type="text" name="orderNo" /></td>
		        </tr>

		        <tr>
		            <td class="columnTitle_mustbe">货物描述:</td>
		            <td class="tableContent"><textarea  name="productDesc" style="height:200px;width: 400px"></textarea></td>
		        </tr>
			</table>
	</div>
</div>

<div class="textbox" id="centerTextbox">
  <div class="textbox-header">
  <div class="textbox-inner-header">
  <div class="textbox-title">
  	货物列表
  </div>
  </div>
  </div>

<div>
<div class="eXtremeTable" >
<table id="ec_table" class="tableRegion" width="98%" >
	<thead>
	<tr>
		<td class="tableHeader"><input type="checkbox" name="selid" onclick="checkAll('id',this)"></td>
		<td class="tableHeader">序号</td>
		<td class="tableHeader">厂家名称</td>
		<td class="tableHeader">货号</td>
		<td class="tableHeader">数量</td>
		<td class="tableHeader">包装单位</td>
		<td class="tableHeader">装率</td>
		<td class="tableHeader">箱数</td>
		<td class="tableHeader">单价</td>
		<td class="tableHeader">总金额</td>
	</tr>
	</thead>
	<tbody class="tableBody" >

	<c:forEach items="${dataList}" var="o" varStatus="status">
	<tr class="odd" onmouseover="this.className='highlight'" onmouseout="this.className='odd'" >
		<td><input type="checkbox" name="id" value="${o.id}"/></td>
		<td>${status.index+1}</td>
		<td>${o.factoryName}</td>
		<td>${o.productNo}</td>
		<td>${o.cnumber}</td>
		<td>${o.packingUnit}</td>
		<td>${o.loadingRate }</td>
		<td>${o.boxNum }</td>
		<td>${o.price }</td>
		<td>${o.amount}</td>
	</tr>
	</c:forEach>

	</tbody>
</table>
</div>

</div>

</form>
</body>
</html>

新增货物搞定了,但是我们需要一个入口来新增货物。我们在购销合同的列表中新加一列“操作”选项,然后通过这一列可以添加货物。

<tr>
<td class="tableHeader">操作</td>
</tr>
<tr>
<td><a href="${ctx}/cargo/contractproduct/tocreate.action?contractId=${o.id}" title="新增货物信息">[货物]</a><td></tr>

效果:

之后我们为第一个购销合同添加两个货物:

我们添加成功之后在编辑框下可以看到相应的货物信息:

我们的“总金额”是计算出来的而不是填写出来的,所以我们要在必要的地方添加计算的代码。我们这里在ContractProductServiceImpl中的insert与update方法来计算总金额:

@Override
public void insert(ContractProduct contractProduct) {
	//设置UUID
	contractProduct.setId(UUID.randomUUID().toString());

	//自动计算总金额=数量*单价  ...修改,删除;同步合同金额
	if(UtilFuns.isNotEmpty(contractProduct.getCnumber())
				&&UtilFuns.isNotEmpty(contractProduct.getCnumber())){
		contractProduct.setAmount(contractProduct.getCnumber()*contractProduct.getPrice());
		}

	contractProductDao.insert(contractProduct);
}

@Override
public void update(ContractProduct contractProduct) {

	//自动计算总金额=数量*单价  ...修改,删除;同步合同金额
	if(UtilFuns.isNotEmpty(contractProduct.getCnumber())
			&&UtilFuns.isNotEmpty(contractProduct.getCnumber())){
	contractProduct.setAmount(contractProduct.getCnumber()*contractProduct.getPrice());
	}

	contractProductDao.update(contractProduct);
}

其中,UtilFuns是我们在cn.hpu.jk.Util包下放入的工具类UtilFuns.java,它是关于所有(对象、字符串、列表)判断是否为空的类,其中isNotEmpty方法如下:

public static boolean isNotEmpty(String str){
    try{
      if(str==null || str.equals("null") || str.equals("")){
    	  return false;
      }
      return true;
    }catch(Exception e){
      return true;
    }
  }

  public static boolean isNotEmpty(Object obj){
    try{
      if(obj==null || obj.toString().equals("null") || obj.toString().equals("")){
    	  return false;
      }
      return true;
    }catch(Exception e){
      return true;
    }
  }

接下来我们测试,我们来填写一下货物信息
(解释一下“装率”:我们的货物是玻璃器皿,玻璃器皿不能直接放在集装箱里,我们需要先把玻璃器皿放入纸盒子里,一个纸盒子能装多少个玻璃杯,那多少个就成为装率。例如,客户定300个玻璃杯,装到一个盒子能容纳3个玻璃杯,需要100个盒子,那么装率就是1/3。“箱数”=数量/装率的分母=300/3=100,若是有不足3个的就加一个箱子)

可以看到,我们的总金额被计算出来了:

至此,我们完成了随购销合同的货物的主要业务功能

转载请注明出处:http://blog.csdn.net/acmman/article/details/48521559

时间: 2024-09-13 06:41:10

【springmvc+mybatis项目实战】杰信商贸-16.新增从表货物信息的相关文章

【springmvc+mybatis项目实战】杰信商贸-1.项目背景

1.项目背景 杰信项目物流行业的项目, 杰信商贸是国际物流行业一家专门从事进出口玻璃器皿贸易的公司.公司总部位于十一个朝代的帝王之都西安,业务遍及欧美.随着公司不断发展壮大,旧的信息系统已无法满足公司的快速发展需求,妨碍公司成长,在此背景下,公司领导决定研发<杰信商贸综合管理平台>. <杰信商贸综合管理平台>分三期完成.一期完成仓储管理(包括:采购单.仓库.货物.条形码.入库.出库.退货.盘点.库存.库存上限报警.统计查询)和展会管理(包括:展会管理.出单管理),形成货物统一数字化

【springmvc+mybatis项目实战】杰信商贸-13.购销合同列表

我们接下来开始编写购销合同的列表业务 首先我们现往我们的FACTORY_C和基础表中倒入一些数据方便我们测试 导入数据的SQL文件:jk.sql (点击下载) 然后我们看到数据已经插入 启动服务器查看我们的数据已经插入 接下来我们开始做购销合同的业务.首先我们的数据库表已经建立(CONTRACT_C),我们首先创建购销合同的实体类Contract.java: package cn.hpu.jk.domain; import java.util.Date; public class Contrac

【springmvc+mybatis项目实战】杰信商贸-31.出口报运业务-购销合同查询与上报

我们上一篇完成了出口报运增删查修的mapper+Dao+Service+Controller,而且在Controller中添加和获取出口报运的列表的方法,然后成功获取了出口报运的列表: 然后我们这次要添加出口报运的"新增"方法,但是这个"新增"和以往的新增方法不同,这个要与之前的购销合同关联在一起. 我们出口报运的"新增"是这样的: 用户要选择多个合同,然后进行报运.(体现出业务关联) 报运新增时,报运专责只能看到已上报的购销合同. (操作出口报

【springmvc+mybatis项目实战】杰信商贸-19.级联删除

我们从写项目开始到现在,一共完成了生产厂家.购销合同.货物(购销合同下的).附件(货物下的)这四大块的大部分业务. 我们的生产厂家.购销合同.货物(购销合同下的).附件(货物下的)这四大块的关系我们来回顾一下: 我们先不管生产厂家(因为它可以和后三个关联关系最弱). 购销合同与货物是一对多的关系,而货物与附件又是一对多的关系.那么购销合同与附件是两层一对多的关系.这里我们要注意,在两层一对多结构中,子表数据不设置外键关联时,就称为僵尸数据. 因为我们的购销合同.货物.附件表虽然都存储有关联关系的

【springmvc+mybatis项目实战】杰信商贸-11.购销合同业务

生产厂家我们做完了,接下来我们要做一个更加复杂的业务,就是"货运管理" 首先我们先了解一下业务,什么是"货运管理"? "货运管理"是国际物流的概念,往常我们货物送到国内没有那么多事情,但是货物发往国外就多了很多手续,依靠小物流公司我们是很不可能的,需要行业的大背景的支撑.下面我们来看看它是怎么做的 a)业务:购销合同 当我们的客户通过展会.其它渠道跟杰信公司联系上以后,他们看上杰信的货物样品,他们会跟杰信签订一个购买合同(样式要求,货物数量),客

【springmvc+mybatis项目实战】杰信商贸-15.细粒度的权限控制+业务上报取消

上一篇总结我们完成了购销合同的增删改查业务,这一篇我们首先完成权限控制以及业务的上报取消的设置功能. 先说我们的权限控制 1.细粒度的权限控制 a)日常权限框架: 基于角色权限,用户.角色.权限(URL.主菜单.左侧菜单.按钮) b)数据权限: 纵向的数据权限过滤:对数据进行过滤 1)本人(专责):登录后只能看到自己的信息Where条件 create_by = #{当前登录者id} 2)部门(集团公司):登录后登录人是经理级别A.只能看本部门Where条件 create_dept=#{当前登录者

【springmvc+mybatis项目实战】杰信商贸-23.重点知识回顾

1.重点知识回顾 购销合同查看,采用类似hibernate方式,都以对象关联方式. (1)PO为了利用MyBatis性能,在创建时,没有采用关联对象关联,而是将对象关键字段,也就是外键,利用这个普通属性,来记录值,表数据间关联关系存在,但对象关联关系不存在.代码也就变得简单.在货物新增时,只要从主对象中携带过来,主表ID即可. (2)VO为了方便对象关联时取数据.在列表循环货物信息时,要去查询当前货物下的附件时,如果采用上面的方式,只能再次查询.但是我们以对象关联方式,可以直接获取到当前货物下的

【springmvc+mybatis项目实战】杰信商贸-30.出口报运增删查修mapper+Dao+Service+Controller

我们接下来做我们项目的下一个环节,就是出口报运的业务,首先我们来看看两个设计方式 a)大型项目设计方式 传统设计方式,基于对象关联,数据量小时,系统无碍:当数据随着系统的使用,线性增长,系统变的越来越慢,到达一定数据量时,性能急剧下降. b)新的设计方式:打断设计 在表中增加一个字段,这个字段用来存储关联表的主键集合:在报运业务中要查询合同下的货物信息.直接通过这个关联字段,利用in子查询直接去查询货物表,这样查询效率提高很多.而且数据量越大,查询效率越高.这种方式,业务关联层级越多,这种设计方

【springmvc+mybatis项目实战】杰信商贸-34.业务出口报运WebService1

我们要为出口报运做一个WebService,来提供跨系统的信息查询功能. 我们使用的技术是 -------Apache CXF WebService 作用:两个异构系统,需要共享数据. 需求:我们要给客户提供合同追踪.在出口报运中增加一个WebService,用户可以通过它的系统来访问这个服务,展现出口报运单,主要可以浏览用户的订单状态(走到哪个流程).查看出口报运单 开发步骤:将现有的Service改造成WebService 1)将CXF整合到项目中,加入jar包.依赖jar.我们系统才 CX