标签:mybatis oracle plsql developer powerdesigner spring mvc
我们上一篇完成了购销合同、货物以及附件的级联删除,这次我们需要做的业务就是----要求直接显示合同下的货物数和附件数select count(*) from contract_product_c where contract_id='928eb2ae-23ba-46e0-9ad0-054354f66af8'
获取合同下的货物下的附件数:
select count(*) from ext_cproduct_c where contract_product_id in (select contract_product_id from contract_product_c where contract_id='928eb2ae-23ba-46e0-9ad0-054354f66af8')
<span style="white-space:pre"> </span><tr> <td class="tableHeader">货物数/附件数</td> </tr> <tr> <td>${o.cpnum }/${o.extnum }</td> </tr>
效果如图
select (select count(*) from contract_product_c where contract_id=c.contract_id)as cpnum, (select count(*) from ext_cproduct_c where contract_product_id in( select contract_product_id from contract_product_c where contract_id=c.contract_id))as extnum, c.* from contract_c c
<mapper namespace="cn.hpu.jk.mapper.ContractMapper"> <resultMap type="cn.hpu.jk.domain.Contract" id="contractRM"> <id property="id" column="CONTRACT_ID"/> <result property="offeror" column="OFFEROR"/> <result property="contractNo" column="CONTRACT_NO"/> <result property="signingDate" column="SIGNING_DATE"/> <result property="inputBy" column="INPUT_BY"/> <result property="checkBy" column="CHECK_BY"/> <result property="inspector" column="INSPECTOR"/> <result property="totalAmount" column="TOTAL_AMOUNT"/> <result property="importNum" column="IMPORT_NUM"/> <result property="crequest" column="CREQUEST"/> <result property="customName" column="CUSTOM_NAME"/> <result property="deliveryPeriod" column="DELIVERY_PERIOD"/> <result property="shipTime" column="SHIP_TIME"/> <result property="tradeTerms" column="TRADE_TERMS"/> <result property="remark" column="REMARK"/> <result property="printStyle" column="PRINT_STYLE"/> <result property="oldState" column="OLD_STATE"/> <result property="state" column="STATE"/> <result property="outState" column="OUT_STATE"/> <result property="createBy" column="CREATE_BY"/> <result property="creatDept" column="CREATE_DEPT"/> <result property="creatTime" column="CREATE_TIME"/> </resultMap> <!-- 查询多个 --> <select id="find" parameterType="map" resultMap="contractRM"> select * from contract_c where 1=1 </select>
</pre><pre name="code" class="html"><mapper namespace="cn.hpu.jk.mapper.ContractMapper"> <resultMap type="cn.hpu.jk.domain.Contract" id="contractRM"> <id property="id" column="CONTRACT_ID"/> <result property="offeror" column="OFFEROR"/> <!-- 虚拟字段 --> <result property="contractNo" column="CONTRACT_NO"/> <result property="cpnum" column="CPNUM"/> <result property="extnum" column="EXTNUM"/> <result property="signingDate" column="SIGNING_DATE"/> <result property="inputBy" column="INPUT_BY"/> <result property="checkBy" column="CHECK_BY"/> <result property="inspector" column="INSPECTOR"/> <result property="totalAmount" column="TOTAL_AMOUNT"/> <result property="importNum" column="IMPORT_NUM"/> <result property="crequest" column="CREQUEST"/> <result property="customName" column="CUSTOM_NAME"/> <result property="deliveryPeriod" column="DELIVERY_PERIOD"/> <result property="shipTime" column="SHIP_TIME"/> <result property="tradeTerms" column="TRADE_TERMS"/> <result property="remark" column="REMARK"/> <result property="printStyle" column="PRINT_STYLE"/> <result property="oldState" column="OLD_STATE"/> <result property="state" column="STATE"/> <result property="outState" column="OUT_STATE"/> <result property="createBy" column="CREATE_BY"/> <result property="creatDept" column="CREATE_DEPT"/> <result property="creatTime" column="CREATE_TIME"/> </resultMap> <!-- 查询多个 --> <select id="find" parameterType="map" resultMap="contractRM"> select (select count(*) from contract_product_c where contract_id=c.contract_id)as cpnum, (select count(*) from ext_cproduct_c where contract_product_id in( select contract_product_id from contract_product_c where contract_id=c.contract_id))as extnum, c.* from contract_c c </select> <mapper>我们这里改完,接下来修改我们的实体:
package cn.hpu.jk.domain; import java.util.Date; public class Contract { private String id; private String offeror;//收购方 private String contractNo;//合同编号 private String cpnum; private String extnum; private java.util.Date signingDate;//签单日期 private String inputBy;//制单人 private String checkBy;//审单人 private String inspector;//验货员 private Double totalAmount;//总金额 private Integer importNum;//重要程度 private String crequest;//要求 private String customName; private java.util.Date deliveryPeriod;//交货期限 private java.util.Date shipTime;//船期 private String tradeTerms;//贸易条款 private String remark;//说明 private String printStyle;//打印版式 private Integer oldState;//归档前状态 private Integer state;//状态 private Integer outState;//走货状态 private String createBy; private String creatDept; private java.util.Date creatTime; //...get和set方法省略 }
<%@ page language="java" pageEncoding="UTF-8"%> <%@ include file="../../baselist.jsp"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <form name="icform" method="post"> <div id="menubar"> <div id="middleMenubar"> <div id="innerMenubar"> <div id="navMenubar"> <ul> <li id="view"><a href="#" onclick="formSubmit('toview.action','_self');this.blur();">查看</a></li> <li id="new"><a href="#" onclick="formSubmit('tocreate.action','_self');this.blur();">添加</a></li> <li id="update"><a href="#" onclick="formSubmit('toupdate.action','_self');this.blur();">修改</a></li> <li id="delete"><a href="#" onclick="formSubmit('delete.action','_self');this.blur();">删除</a></li> <li id="new"><a href="#" onclick="formSubmit('submit.action','_self');this.blur();">上报</a></li> <li id="new"><a href="#" onclick="formSubmit('cancel.action','_self');this.blur();">取消</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 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> <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.customName}</td> <td><a href="toview.action?id=${o.id}">${o.contractNo}</a></td> <td>${o.cpnum }/${o.extnum }</td> <td>${o.inputBy}</td> <td>${o.checkBy}</td> <td>${o.inspector}</td> <td><fmt:formatDate value="${o.signingDate}" pattern="yyyy-MM-dd"/></td> <td><fmt:formatDate value="${o.deliveryPeriod}" pattern="yyyy-MM-dd"/></td> <td><fmt:formatDate value="${o.shipTime}" pattern="yyyy-MM-dd"/></td> <td>${o.totalAmount}</td> <td> <c:if test="${o.state==1}"><font color="green">已上报</font></c:if> <c:if test="${o.state==0}">草稿</a></c:if> </td> <td><a href="${ctx}/cargo/contractproduct/tocreate.action?contractId=${o.id}" title="新增货物信息">[货物]</a><td> </tr> </c:forEach> </tbody> </table> </div> </div> </form> </body> </html>
我们的货物和附件数显示功能成功!
转载请注明出处:http://blog.csdn.net/acmman/article/details/48627483
版权声明:本文为博主原创文章,未经博主允许不得转载。
【springmvc+mybatis项目实战】杰信商贸-20.合同货物数和附件数
标签:mybatis oracle plsql developer powerdesigner spring mvc
原文地址:http://blog.csdn.net/acmman/article/details/48627483