excele导入实现

import jxl.Sheet;
import jxl.Workbook;

/**
  * SAP导入--asn导入
  * */
 public void importASN(File file,long asnId) {
  if (file == null) {
   throw new BusinessException("file.not.fount");
        }
  //默认为标准收获单
  BillType billtype = (BillType)this.commonDao.findByQueryUniqueResult("FROM BillType bt where bt.code=:code",
    new String[]{"code"},new Object[]{"PO001"});
  
  Sheet sheet = null;
  try {
   Workbook wb = Workbook.getWorkbook(new FileInputStream(file));
   sheet = wb.getSheet("ZCONTR");
  } catch (Exception e1) {
   e1.printStackTrace();
  } 
  int rowNum = sheet.getRows();
  for (int rowIndex = 1; rowIndex < rowNum; rowIndex++) {
   String handingUnit  = sheet.getCell(0,rowIndex).getContents();  //唯一,重复导入标志 ASN.handingUnit
   if(StringUtils.isEmpty(handingUnit)){
    if(rowIndex == 1){
     throw new BusinessException("excel.is.emp");
    }
    return;
   }
   Date orderDate  = strToDate(sheet.getCell(1,rowIndex).getContents());    //订单日期 ASN.orderDate
   String itemCode  = sheet.getCell(2,rowIndex).getContents();     //货品编号 ASNDetial.Item.code
   
   String batchNo  = sheet.getCell(6,rowIndex).getContents();  //批次属性的组成部分2 生产批号
   
   String vesselVoyageNo = sheet.getCell(21,rowIndex).getContents();//船名航次  ASN.vesselVoyageNo
     
   Item item = judgeImport(handingUnit,itemCode);
   
   //创建asn
   ASN asn = createImportAsn(billtype,orderDate,estimateDate,carrierName,
     portOfDischage,item.getCompany(),vesselVoyageNo,handingUnit,deliveryNo);

   //创建asn明细
   createImportAsnDetail(asn, item, grade, batchNo, expectedQtyOfMasterUnit,
     containerNo, containerSize, sealNo);
  }
 }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值