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);
}
}