前面分析过购销合同的Excel报表需要四张表,这篇讲的是合同货物表。
这个合同货物表是合同表
项目结构:
前面带红色框框的就是这个需要的domain->Dao层->Service层->到控制层。
具体代码如下:
domain就是数据库中对应的CONTRACT_PRODUCT_C这张表。
如下:
所以domain包中的po类就是:
package cn.itcast.jk.domain; //合同货物 public class ContractProduct { private String id;// 主键 private String contractid;// 外键,在这里就是普通的键; private String factoryid; private String factoryname;//厂家名称 private String productno;//货号 private String productimage;//货物照片 private String productdesc;//货物描述 private String cnumber;//数量 private String outnumber;//实际出货数量 private String loadingrate;//装率 private String boxnum;//箱数 private String packingunit;//包装单位 private String price;//单价 private String amount;//总金额 private String finished;//是否出货完毕 private String exts;//附件 private String orderno;//排序号 public String getId() { return id; } public void setId(String id) { this.id = id; } public String getContractid() { return contractid; } public void setContractid(String contractid) { this.contractid = contractid; } public String getFactoryid() { return factoryid; } public void setFactoryid(String factoryid) { this.factoryid = factoryid; } public String getFactoryname() { return factoryname; } public void setFactoryname(String factoryname) { this.factoryname = factoryname; } public String getProductno() { return productno; } public void setProductno(String productno) { this.productno = productno; } public String getProductimage() { return productimage; } public void setProductimage(String productimage) { this.productimage = productimage; } public String getProductdesc() { return productdesc; } public void setProductdesc(String productdesc) { this.productdesc = productdesc; } public String getCnumber() { return cnumber; } public void setCnumber(String cnumber) { this.cnumber = cnumber; } public String getOutnumber() { return outnumber; } public void setOutnumber(String outnumber) { this.outnumber = outnumber; } public String getLoadingrate() { return loadingrate; } public void setLoadingrate(String loadingrate) { this.loadingrate = loadingrate; } public String getBoxnum() { return boxnum; } public void setBoxnum(String boxnum) { this.boxnum = boxnum; } public String getPackingunit() { return packingunit; } public void setPackingunit(String packingunit) { this.packingunit = packingunit; } public String getPrice() { return price; } public void setPrice(String price) { this.price = price; } public String getAmount() { return amount; } public void setAmount(String amount) { this.amount = amount; } public String getFinished() { return finished; } public void setFinished(String finished) { this.finished = finished; } public String getExts() { return exts; } public void setExts(String exts) { this.exts = exts; } public String getOrderno() { return orderno; } public void setOrderno(String orderno) { this.orderno = orderno; } }
Dao层的代码:
就是BaseDaoImpl.java 的代码:
package cn.itcast.jk.dao.impl; import java.io.Serializable; import java.util.List; import java.util.Map; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.support.SqlSessionDaoSupport; import org.springframework.beans.factory.annotation.Autowired; import cn.itcast.jk.dao.BaseDao; import cn.itcast.jk.pagination.Page; public abstract class BaseDaoImpl<T> extends SqlSessionDaoSupport implements BaseDao<T>{ @Autowired //mybatis-spring 1.0无需此方法;mybatis-spring1.2必须注入。 public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory){ super.setSqlSessionFactory(sqlSessionFactory); } private String ns; //命名空间 public String getNs() { return ns; } public void setNs(String ns) { this.ns = ns; } public List<T> findPage(Page page){ List<T> oList = this.getSqlSession().selectList(ns + ".findPage", page); return oList; } public List<T> find(Map map) { List<T> oList = this.getSqlSession().selectList(ns + ".find", map); return oList; } public T get(Serializable id) { return this.getSqlSession().selectOne(ns + ".get", id); } public void insert(T entity) { this.getSqlSession().insert(ns + ".insert", entity); } public void update(T entity) { this.getSqlSession().update(ns + ".update", entity); } public void deleteById(Serializable id) { this.getSqlSession().delete(ns + ".deleteById", id); } public void delete(Serializable[] ids) { this.getSqlSession().delete(ns + ".delete", ids); } }
Service层:
package cn.itcast.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.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import cn.itcast.jk.dao.ContractProductDao; import cn.itcast.jk.domain.Contract; import cn.itcast.jk.domain.ContractProduct; import cn.itcast.jk.pagination.Page; import cn.itcast.jk.service.ContractProductService; @Service public class ContractProductServiceImpl implements ContractProductService{ @Resource ContractProductDao contractProductDao; @Override public List<ContractProduct> findPage(Page page) { return contractProductDao.findPage(page); } @Override public List<ContractProduct> find(Map paraMap) { return contractProductDao.find(paraMap); } @Override public ContractProduct get(Serializable id) { return contractProductDao.get(id); } @Override public void insert(ContractProduct contractproduct) { contractproduct.setId(UUID.randomUUID().toString()); contractProductDao.insert(contractproduct); } @Override public void update(ContractProduct contractproduct) { contractProductDao.update(contractproduct); } @Override public void deleteById(Serializable id) { contractProductDao.deleteById(id); } @Override public void delete(Serializable[] ids) { contractProductDao.delete(ids); } }
时间: 2024-11-04 23:59:12