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