diff --git a/src/main/java/com/dev/swms/server/service/receiving/ASNManager.java b/src/main/java/com/dev/swms/server/service/receiving/ASNManager.java index 1ca921c..7c72ac1 100644 --- a/src/main/java/com/dev/swms/server/service/receiving/ASNManager.java +++ b/src/main/java/com/dev/swms/server/service/receiving/ASNManager.java @@ -265,4 +265,7 @@ public interface ASNManager extends BaseManager{ //芝华仕 @Transactional void importCHEERSASN(File file); + + //入库明细导入 + void asnDetailImport(long asnId,File file); } diff --git a/src/main/java/com/dev/swms/server/service/receiving/pojo/DefaultASNManager.java b/src/main/java/com/dev/swms/server/service/receiving/pojo/DefaultASNManager.java index 2c0a8bf..192d290 100644 --- a/src/main/java/com/dev/swms/server/service/receiving/pojo/DefaultASNManager.java +++ b/src/main/java/com/dev/swms/server/service/receiving/pojo/DefaultASNManager.java @@ -22,6 +22,8 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.springframework.transaction.annotation.Transactional; + import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException; @@ -3581,6 +3583,162 @@ public class DefaultASNManager extends DefaultBaseManager implements e.printStackTrace(); } } + + @Override + @Transactional + public void asnDetailImport(long asnId, File file) { + if(asnId<=0){ + throw new BusinessException("请选中一条入库单据!"); + } + Workbook workbook; + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + ASN asn=commonDao.load(ASN.class, asnId); + StringBuffer locBuffer=new StringBuffer();//不存在的库位 + StringBuffer itemBuffer=new StringBuffer();//不存在的物料 + StringBuffer zlztBuffer=new StringBuffer();//不存在的质量状态 + Map locMap=new HashMap(); + Map itemMap=new HashMap(); + Map packageUnitMap=new HashMap(); + Map zlztMap=new HashMap(); + workbook = Workbook.getWorkbook(file); + Sheet sheet = workbook.getSheet(0);// 得到excel第一页的内容 + for (int i = 1; i Items = commonDao.findByQuery(" from Item l where l.code=:code and l.disabled=0 and l.company.id="+asn.getCompany().getId()+" ", + new String[] { "code"},new Object[] {itemCode}); + if(Items.isEmpty()){ + itemBuffer.append((i+1)+"行"+itemCode+";"); + }else{ + itemMap.put(itemCode, Items.get(0)); + + //单位 + List PackageUnits = commonDao.findByQuery(" from PackageUnit pu where pu.item.id=:id ", + new String[] { "id"},new Object[] {Items.get(0).getId()}); + if(PackageUnits.size()>0){ + packageUnitMap.put(Items.get(0), PackageUnits.get(0)); + } + + } + + + //质量状态 + List CommonCodes = commonDao.findByQuery(" from CommonCode commonCode where commonCode.code=:code and commonCode.codeType='质量状态' ", + new String[] { "code"},new Object[] {zlzt}); + if(CommonCodes.isEmpty()){ + zlztBuffer.append((i+1)+"行"+zlzt+";"); + }else{ + zlztMap.put(zlzt, CommonCodes.get(0)); + } + + //库位 + List Locations = commonDao.findByQuery(" from Location l where l.code=:code and l.warehouse.id="+WarehouseHolder.getWarehouse().getId()+" ", + new String[] { "code"},new Object[] {loc_Code}); + if(Locations.isEmpty()){ + locBuffer.append((i+1)+"行"+loc_Code+";"); + }else{ + locMap.put(loc_Code, Locations.get(0)); + } + + } + + if(itemBuffer!=null&&!itemBuffer.toString().equals("")){ + throw new BusinessException(itemBuffer.toString()+"货品不存在!"); + } + + if(zlztBuffer!=null&&!zlztBuffer.toString().equals("")){ + throw new BusinessException(zlztBuffer.toString()+"质量状态不存在!"); + } + + if(locBuffer!=null&&!locBuffer.toString().equals("")){ + throw new BusinessException(locBuffer.toString()+"库位不存在!"); + } + + for (int i = 1; i ASNDetails = commonDao.findByQuery(" from ASNDetail ad where ad.asn.id=:asnId and ad.item.id=:itemId and ad.dock.id=:dockId ", + new String[] { "asnId","itemId","dockId"},new Object[] {asnId,item.getId(),dock.getId()}); + if(ASNDetails.size()>0){ + ASNDetail asnDetail=ASNDetails.get(0); + asnDetail.setExpectedQuantity(Double.parseDouble(quantity)); + asnDetail.setExpectedQtyOfMasterUnit(Double.parseDouble(quantity)); + asnDetail.setQualityStatus(zlzt); + if(asnDetail.getLotInfo()!=null){ + asnDetail.getLotInfo().setPropLC1(tsbz); + } + commonDao.store(asnDetail); + }else{ + ASNDetail asnDetail=EntityFactory.getEntity(ASNDetail.class); + asnDetail.setAsn(asn); + asnDetail.setItem(item); + asnDetail.setExpectedQuantity(Double.parseDouble(quantity)); + asnDetail.setExpectedQtyOfMasterUnit(Double.parseDouble(quantity)); + asnDetail.setQualityStatus(zlzt); + LotInfo lotInfo=new LotInfo(); + if(StringUtils.isEmpty(tsbz)){ + lotInfo.setPropLC1(null); + }else{ + lotInfo.setPropLC1(tsbz); + } + Date currentDate = new Date(); + String propC1 = sdf.format(currentDate); + lotInfo.setPropC1(propC1);//到货日期 + Date propD1=returnDate(propC1); + lotInfo.setPropD1(propD1); + asnDetail.setLotInfo(lotInfo); + asnDetail.setDock(dock); + Integer lineNo=getlineNo(asn); + if(lineNo==0){ + asnDetail.setLineNo(1); + }else{ + asnDetail.setLineNo(lineNo+1); + } + asnDetail.setPackageUnit(packageUnit); + commonDao.store(asnDetail); + + } + System.out.println("新增"+(i+1)+"条"); + } + + //刷新订单 + Refresh(asn.getId()); + + } catch (BiffException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } diff --git a/src/webapp/WEB-INF/classes/config/origen/receiving/editAsnDetailImportPage.xml b/src/webapp/WEB-INF/classes/config/origen/receiving/editAsnDetailImportPage.xml new file mode 100644 index 0000000..c3621d5 --- /dev/null +++ b/src/webapp/WEB-INF/classes/config/origen/receiving/editAsnDetailImportPage.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/webapp/WEB-INF/classes/config/origen/receiving/editXingkanASNPage.xml b/src/webapp/WEB-INF/classes/config/origen/receiving/editXingkanASNPage.xml index 5a50ef5..dafd0a5 100644 --- a/src/webapp/WEB-INF/classes/config/origen/receiving/editXingkanASNPage.xml +++ b/src/webapp/WEB-INF/classes/config/origen/receiving/editXingkanASNPage.xml @@ -107,6 +107,8 @@ + + diff --git a/target/hrbwms/WEB-INF/classes/config/origen/receiving/editXingkanASNPage.xml b/target/hrbwms/WEB-INF/classes/config/origen/receiving/editXingkanASNPage.xml deleted file mode 100644 index 5a50ef5..0000000 --- a/target/hrbwms/WEB-INF/classes/config/origen/receiving/editXingkanASNPage.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${asnDetail.receivedQuantity} ]]> - - - ${asnDetail.receivedQuantity} ]]> - - - - - - - - - - - - - - -