@ -31,7 +31,6 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet ;
import org.apache.poi.xssf.usermodel.XSSFSheet ;
import org.apache.poi.xssf.usermodel.XSSFWorkbook ;
import org.apache.poi.xssf.usermodel.XSSFWorkbook ;
import org.apache.shiro.SecurityUtils ;
import org.apache.shiro.SecurityUtils ;
import org.springframework.beans.BeanUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.core.io.ClassPathResource ;
import org.springframework.core.io.ClassPathResource ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
@ -92,14 +91,12 @@ public class CoDelServiceImpl implements CoDelService {
@Override
@Override
@Transactional
@Transactional
public void saveEcssCoDelNotifyByExcel ( MultipartFile file , EcssCoDelNotifyHeaderData inData ) {
public Map < String , List < String > > saveEcssCoDelNotifyByExcel ( MultipartFile file , EcssCoDelNotifyHeaderData inData ) {
SysUserEntity currentUser = ( SysUserEntity ) SecurityUtils . getSubject ( ) . getPrincipal ( ) ;
SysUserEntity currentUser = ( SysUserEntity ) SecurityUtils . getSubject ( ) . getPrincipal ( ) ;
String site = coDelMapper . getSiteByBu ( inData . getBuNo ( ) ) ;
String site = coDelMapper . getSiteByBu ( inData . getBuNo ( ) ) ;
List < EcssCoDelNotifyData > excelList = new ArrayList < > ( ) ;
List < EcssCoDelNotifyData > excelList = new ArrayList < > ( ) ;
try {
/ / 转流
InputStream is = file . getInputStream ( ) ;
/ / 读取工作簿
try ( InputStream is = file . getInputStream ( ) ) {
XSSFWorkbook workbook = new XSSFWorkbook ( is ) ;
XSSFWorkbook workbook = new XSSFWorkbook ( is ) ;
importNotifyExcel ( inData , workbook , site , currentUser , excelList ) ;
importNotifyExcel ( inData , workbook , site , currentUser , excelList ) ;
} catch ( NullPointerException e ) {
} catch ( NullPointerException e ) {
@ -108,19 +105,32 @@ public class CoDelServiceImpl implements CoDelService {
throw new RuntimeException ( "导入失败:" + e . getMessage ( ) ) ;
throw new RuntimeException ( "导入失败:" + e . getMessage ( ) ) ;
}
}
/ / 使用 groupingBy 进行分组
/ / 成功和失败列表
List < String > successList = new ArrayList < > ( ) ;
List < String > failList = new ArrayList < > ( ) ;
/ / 使用 groupingBy 分组
Map < String , List < EcssCoDelNotifyData > > groupedByReadyDateAndCmcInvoice = excelList . stream ( )
Map < String , List < EcssCoDelNotifyData > > groupedByReadyDateAndCmcInvoice = excelList . stream ( )
. collect ( Collectors . groupingBy ( data - > data . getReadyDate ( ) + "-" + data . getCmcInvoice ( ) ) ) ;
. collect ( Collectors . groupingBy ( data - > data . getReadyDate ( ) + "-" + data . getCmcInvoice ( ) ) ) ;
/ / 每个分组创建一个销售发货单
/ / 每个分组创建一个销售发货单
groupedByReadyDateAndCmcInvoice . forEach ( ( key , list ) - > {
groupedByReadyDateAndCmcInvoice . forEach ( ( key , list ) - > {
String cmcInvoice = list . get ( 0 ) . getCmcInvoice ( ) ;
String transNo ;
String transNo ;
/ / 测试下有没有发票号已经录入并且转化了
List < EcssCoDelNotifyHeaderData > checkIfHasHeader = coDelMapper . checkIfHasHeader ( list . get ( 0 ) . getCmcInvoice ( ) ) ;
if ( checkIfHasHeader . size ( ) = = 0 ) {
/ / 检查是否已经存在
List < EcssCoDelNotifyHeaderData > checkIfHasHeader = coDelMapper . checkIfHasHeader ( cmcInvoice ) ;
if ( ! checkIfHasHeader . isEmpty ( ) ) {
failList . add ( "发票号:" + cmcInvoice + " 已经生成发货通知单" ) ;
return ; / / 跳过当前分组 , 继续下一个
}
try {
/ / 新建头
EcssCoDelNotifyHeader headerList = new EcssCoDelNotifyHeader ( ) ;
EcssCoDelNotifyHeader headerList = new EcssCoDelNotifyHeader ( ) ;
coDelMapper . updateTransNo ( list . get ( 0 ) . getSite ( ) , "EC" ) ;
coDelMapper . updateTransNo ( list . get ( 0 ) . getSite ( ) , "EC" ) ;
transNo = coDelMapper . getTransNo ( list . get ( 0 ) . getSite ( ) , "EC" ) ;
transNo = coDelMapper . getTransNo ( list . get ( 0 ) . getSite ( ) , "EC" ) ;
headerList . setDelNo ( transNo ) ;
headerList . setDelNo ( transNo ) ;
headerList . setSite ( list . get ( 0 ) . getSite ( ) ) ;
headerList . setSite ( list . get ( 0 ) . getSite ( ) ) ;
headerList . setBuNo ( list . get ( 0 ) . getBuNo ( ) ) ;
headerList . setBuNo ( list . get ( 0 ) . getBuNo ( ) ) ;
@ -134,25 +144,32 @@ public class CoDelServiceImpl implements CoDelService {
headerList . setOverseasShipper ( inData . getOverseasShipper ( ) ) ;
headerList . setOverseasShipper ( inData . getOverseasShipper ( ) ) ;
headerList . setOverseasAddress ( inData . getOverseasAddress ( ) ) ;
headerList . setOverseasAddress ( inData . getOverseasAddress ( ) ) ;
headerList . setCnative ( inData . getCnative ( ) ) ;
headerList . setCnative ( inData . getCnative ( ) ) ;
headerList . setCmcInvoice ( list . get ( 0 ) . getC mcInvoice( ) ) ;
headerList . setCmcInvoice ( c mcInvoice) ;
headerList . setCreateBy ( inData . getUsername ( ) ) ;
headerList . setCreateBy ( inData . getUsername ( ) ) ;
coDelMapper . saveEcssCoDelNotifyHeader ( headerList ) ;
coDelMapper . saveEcssCoDelNotifyHeader ( headerList ) ;
} else {
/ / if ( "Y" . equals ( checkIfHasHeader . get ( 0 ) . getErpFlag ( ) ) ) {
throw new RuntimeException ( "发票号:" + list . get ( 0 ) . getCmcInvoice ( ) + "已经生成了发货通知单,请先删除!" ) ;
/ / }
}
/ / 明细
for ( int i = 0 ; i < list . size ( ) ; i + + ) {
list . get ( i ) . setDelNo ( transNo ) ;
list . get ( i ) . setItemNo ( i + 1 ) ;
}
coDelMapper . batchSaveEcssCoDelNotifyDetail ( list ) ;
for ( int i = 0 ; i < list . size ( ) ; i + + ) {
list . get ( i ) . setDelNo ( transNo ) ;
list . get ( i ) . setItemNo ( i + 1 ) ;
/ / 加入成功列表
successList . add ( "发票号:" + cmcInvoice + " 导入成功" ) ;
} catch ( Exception e ) {
failList . add ( "发票号:" + cmcInvoice + " 导入失败,原因:" + e . getMessage ( ) ) ;
}
}
coDelMapper . batchSaveEcssCoDelNotifyDetail ( list ) ;
} ) ;
} ) ;
/ / 返回结果
Map < String , List < String > > resultMap = new HashMap < > ( ) ;
resultMap . put ( "success" , successList ) ;
resultMap . put ( "fail" , failList ) ;
return resultMap ;
}
}
private void importNotifyExcel ( EcssCoDelNotifyHeaderData inData , XSSFWorkbook workbook , String site ,
private void importNotifyExcel ( EcssCoDelNotifyHeaderData inData , XSSFWorkbook workbook , String site ,
SysUserEntity currentUser , List < EcssCoDelNotifyData > excelList ) {
SysUserEntity currentUser , List < EcssCoDelNotifyData > excelList ) {
for ( int s = 0 ; s < workbook . getNumberOfSheets ( ) ; s + + ) {
for ( int s = 0 ; s < workbook . getNumberOfSheets ( ) ; s + + ) {
@ -294,9 +311,6 @@ public class CoDelServiceImpl implements CoDelService {
@Override
@Override
public void deleteEcssDelHeader ( EcssCoDelNotifyHeaderData data ) {
public void deleteEcssDelHeader ( EcssCoDelNotifyHeaderData data ) {
List < EcssCoDelNotifyDetailData > checkEcssCoDelNotifyDetail = coDelMapper . searchEcssCoDelNotifyDetail ( data ) ;
List < EcssCoDelNotifyDetailData > checkEcssCoDelNotifyDetail = coDelMapper . searchEcssCoDelNotifyDetail ( data ) ;
/ * if ( checkEcssCoDelNotifyDetail . size ( ) > 0 ) {
throw new RuntimeException ( "该发货通知单下有明细无法删除!" ) ;
} * /
coDelMapper . deleteEcssDelHeader ( data ) ;
coDelMapper . deleteEcssDelHeader ( data ) ;
for ( EcssCoDelNotifyDetailData detailData : checkEcssCoDelNotifyDetail ) {
for ( EcssCoDelNotifyDetailData detailData : checkEcssCoDelNotifyDetail ) {
coDelMapper . deleteEcssDelDetail ( detailData ) ;
coDelMapper . deleteEcssDelDetail ( detailData ) ;
@ -419,9 +433,6 @@ public class CoDelServiceImpl implements CoDelService {
if ( checkHeader . isEmpty ( ) ) {
if ( checkHeader . isEmpty ( ) ) {
throw new RuntimeException ( "不存在该发货通知单请刷新界面" ) ;
throw new RuntimeException ( "不存在该发货通知单请刷新界面" ) ;
}
}
/ * if ( ! "已计划" . equals ( checkHeader . get ( 0 ) . getNotifyStatus ( ) ) ) {
throw new RuntimeException ( "发货通知单状态不为已计划,无法修改。" ) ;
} * /
SysUserEntity currentUser = ( SysUserEntity ) SecurityUtils . getSubject ( ) . getPrincipal ( ) ;
SysUserEntity currentUser = ( SysUserEntity ) SecurityUtils . getSubject ( ) . getPrincipal ( ) ;
List < PartData > parts = coDelMapper . getPartNo ( data . getSite ( ) , data . getPn ( ) , currentUser . getUsername ( ) , data . getBuNo ( ) ) ;
List < PartData > parts = coDelMapper . getPartNo ( data . getSite ( ) , data . getPn ( ) , currentUser . getUsername ( ) , data . getBuNo ( ) ) ;
if ( parts . isEmpty ( ) ) {
if ( parts . isEmpty ( ) ) {
@ -485,9 +496,6 @@ public class CoDelServiceImpl implements CoDelService {
if ( checkHeader . isEmpty ( ) ) {
if ( checkHeader . isEmpty ( ) ) {
throw new RuntimeException ( "不存在该发货通知单请刷新界面" ) ;
throw new RuntimeException ( "不存在该发货通知单请刷新界面" ) ;
}
}
/ * if ( ! "已计划" . equals ( checkHeader . get ( 0 ) . getNotifyStatus ( ) ) ) {
throw new RuntimeException ( "发货通知单状态不为已计划,无法删除。" ) ;
} * /
data . setQty ( BigDecimal . ZERO ) ;
data . setQty ( BigDecimal . ZERO ) ;
data . setModifyFlag ( true ) ;
data . setModifyFlag ( true ) ;
data . setStatus ( "取消发货" ) ;
data . setStatus ( "取消发货" ) ;
@ -622,9 +630,6 @@ public class CoDelServiceImpl implements CoDelService {
if ( checkHeader . isEmpty ( ) ) {
if ( checkHeader . isEmpty ( ) ) {
throw new RuntimeException ( "不存在该发货通知单请刷新界面" ) ;
throw new RuntimeException ( "不存在该发货通知单请刷新界面" ) ;
}
}
/ * if ( ! "仓库已确认" . equals ( checkHeader . get ( 0 ) . getNotifyStatus ( ) ) ) {
throw new RuntimeException ( "发货通知单状态不为仓库已确认,请刷新页面。" ) ;
} * /
coDelMapper . updateEcssDel ( data ) ;
coDelMapper . updateEcssDel ( data ) ;
}
}
@ -788,11 +793,6 @@ public class CoDelServiceImpl implements CoDelService {
}
}
}
}
@Override
public List < EcssCoDelPalletData > searchCoDelPalletData ( EcssCoDelNotifyHeaderData inData ) {
return coDelMapper . searchCoDelPalletData ( inData ) ;
}
@Override
@Override
public List < Map > selectBoxList ( EcssCoDelNotifyHeaderData inData ) {
public List < Map > selectBoxList ( EcssCoDelNotifyHeaderData inData ) {
return coDelMapper . selectBoxList ( inData ) ;
return coDelMapper . selectBoxList ( inData ) ;
@ -832,9 +832,6 @@ public class CoDelServiceImpl implements CoDelService {
EcssCoDelPalletData excelData = new EcssCoDelPalletData ( ) ;
EcssCoDelPalletData excelData = new EcssCoDelPalletData ( ) ;
/ / 获得该行
/ / 获得该行
XSSFRow row = sheet . getRow ( j ) ;
XSSFRow row = sheet . getRow ( j ) ;
/ * if ( ( inData . getWalMartOrderFlag ( ) = = null | | inData . getWalMartOrderFlag ( ) . equals ( "N" ) ) & & row . getCell ( 0 ) = = null ) {
throw new RuntimeException ( "第" + j + "行的序号不能为空!" ) ;
} * /
if ( row . getCell ( 1 ) ! = null & & ! inData . getCmcInvoice ( ) . equals ( row . getCell ( 1 ) . getStringCellValue ( ) ) ) {
if ( row . getCell ( 1 ) ! = null & & ! inData . getCmcInvoice ( ) . equals ( row . getCell ( 1 ) . getStringCellValue ( ) ) ) {
throw new RuntimeException ( "第" + j + "行的发票号与发货通知单的发票号不一致!" ) ;
throw new RuntimeException ( "第" + j + "行的发票号与发货通知单的发票号不一致!" ) ;
}
}
@ -844,12 +841,10 @@ public class CoDelServiceImpl implements CoDelService {
if ( row . getCell ( 7 ) = = null ) {
if ( row . getCell ( 7 ) = = null ) {
throw new RuntimeException ( "第" + j + "行的数量不能为空!" ) ;
throw new RuntimeException ( "第" + j + "行的数量不能为空!" ) ;
}
}
/ / excelData . setSeqNo ( ( inData . getWalMartOrderFlag ( ) ! = null & & inData . getWalMartOrderFlag ( ) . equals ( "Y" ) ) ? j : getIntegerCellValue ( row , 0 ) ) ;
/ / 为对象赋值
/ / 为对象赋值
excelData . setSite ( inData . getSite ( ) ) ; / / site
excelData . setSite ( inData . getSite ( ) ) ; / / site
excelData . setBuNo ( inData . getBuNo ( ) ) ; / / bu
excelData . setBuNo ( inData . getBuNo ( ) ) ; / / bu
excelData . setDelNo ( inData . getDelNo ( ) ) ;
excelData . setDelNo ( inData . getDelNo ( ) ) ;
/ / excelData . setPalletRemark ( getStringCellValue ( row , 2 ) ) ;
excelData . setPoNo ( getStringCellValue ( row , 5 ) ) ;
excelData . setPoNo ( getStringCellValue ( row , 5 ) ) ;
excelData . setPn ( getStringCellValue ( row , 6 ) ) ;
excelData . setPn ( getStringCellValue ( row , 6 ) ) ;
List < PartData > parts = coDelMapper . getPartNo ( excelData . getSite ( ) , excelData . getPn ( ) , currentUser . getUsername ( ) , inData . getBuNo ( ) ) ;
List < PartData > parts = coDelMapper . getPartNo ( excelData . getSite ( ) , excelData . getPn ( ) , currentUser . getUsername ( ) , inData . getBuNo ( ) ) ;
@ -860,11 +855,6 @@ public class CoDelServiceImpl implements CoDelService {
excelData . setQty ( getNumericCellValueOrDefault ( row , 7 ) ) ;
excelData . setQty ( getNumericCellValueOrDefault ( row , 7 ) ) ;
excelData . setBoxQty ( getNumericCellValueOrDefault ( row , 2 ) ) ;
excelData . setBoxQty ( getNumericCellValueOrDefault ( row , 2 ) ) ;
excelData . setRolls ( getNumericCellValueOrDefault ( row , 8 ) ) ;
excelData . setRolls ( getNumericCellValueOrDefault ( row , 8 ) ) ;
/ / excelData . setPalletQty ( getIntegerCellValue ( row , 8 ) ) ;
/ / excelData . setLength ( getNumericCellValueOrDefault ( row , 9 ) ) ;
/ / excelData . setWidth ( getNumericCellValueOrDefault ( row , 10 ) ) ;
/ / excelData . setHeight ( getNumericCellValueOrDefault ( row , 11 ) ) ;
/ / excelData . setVolume ( getNumericCellValueOrDefault ( row , 12 ) ) ;
excelData . setGrossWeight ( getNumericCellValueOrDefault ( row , 3 ) ) ;
excelData . setGrossWeight ( getNumericCellValueOrDefault ( row , 3 ) ) ;
excelData . setNetWeight ( getNumericCellValueOrDefault ( row , 4 ) ) ;
excelData . setNetWeight ( getNumericCellValueOrDefault ( row , 4 ) ) ;
if ( excelData . getBoxQty ( ) = = null & & excelData . getGrossWeight ( ) = = null & & excelData . getNetWeight ( ) = = null ) {
if ( excelData . getBoxQty ( ) = = null & & excelData . getGrossWeight ( ) = = null & & excelData . getNetWeight ( ) = = null ) {
@ -903,98 +893,11 @@ public class CoDelServiceImpl implements CoDelService {
palletListMap2 . put ( itemData . getGroupSeqNo ( ) , palletDataList ) ;
palletListMap2 . put ( itemData . getGroupSeqNo ( ) , palletDataList ) ;
}
}
}
}
/ * if ( inData . getWalMartOrderFlag ( ) ! = null & & inData . getWalMartOrderFlag ( ) . equals ( "Y" ) ) {
for ( EcssCoDelPalletData itemData : excelList ) {
if ( palletListMap . containsKey ( itemData . getSeqNo ( ) ) ) {
palletListMap . get ( itemData . getSeqNo ( ) ) . add ( itemData ) ;
} else {
List < EcssCoDelPalletData > palletDataList = new ArrayList < > ( ) ;
palletDataList . add ( itemData ) ;
palletListMap . put ( itemData . getSeqNo ( ) , palletDataList ) ;
}
}
} else {
* / / * if ( excelList . get ( 0 ) . getPalletQty ( ) = = null | | excelList . get ( 0 ) . getPalletQty ( ) = = 0 ) {
throw new RuntimeException ( "导入失败:第一行的托数不能为0!" ) ;
} * / / *
for ( EcssCoDelPalletData itemData : excelList ) {
if ( palletListMap2 . containsKey ( itemData . getGroupSeqNo ( ) ) ) {
palletListMap2 . get ( itemData . getGroupSeqNo ( ) ) . add ( itemData ) ;
} else {
List < EcssCoDelPalletData > palletDataList = new ArrayList < > ( ) ;
palletDataList . add ( itemData ) ;
palletListMap2 . put ( itemData . getGroupSeqNo ( ) , palletDataList ) ;
}
}
} * /
EcssWalMartOrder task = new EcssWalMartOrder ( ) ;
EcssWalMartOrder task = new EcssWalMartOrder ( ) ;
List < EcssCoDelPalletHeaderData > headerList = new ArrayList < > ( ) ;
List < EcssCoDelPalletHeaderData > headerList = new ArrayList < > ( ) ;
List < EcssCoDelBoxListData > boxList = new ArrayList < > ( ) ;
List < EcssCoDelBoxListData > boxList = new ArrayList < > ( ) ;
List < EcssCoDelPalletDetailData > detailList = new ArrayList < > ( ) ;
List < EcssCoDelPalletDetailData > detailList = new ArrayList < > ( ) ;
int seqNo = 0 ;
int seqNo = 0 ;
/ / palletListMap里每一个key生成一个EcssCoDelPalletHeaderData , 每一个value生成一组EcssCoDelPalletDetailData
/ * for ( Map . Entry < Integer , List < EcssCoDelPalletData > > entry : palletListMap . entrySet ( ) ) {
seqNo + + ;
EcssCoDelPalletHeaderData headerData = new EcssCoDelPalletHeaderData ( ) ;
headerData . setSite ( inData . getSite ( ) ) ;
headerData . setBuNo ( inData . getBuNo ( ) ) ;
headerData . setDelNo ( inData . getDelNo ( ) ) ;
headerData . setSeqNo ( seqNo ) ;
headerData . setPalletNo ( inData . getDelNo ( ) + "-" + String . format ( "%03d" , seqNo ) ) ;
headerData . setPalletQty ( entry . getValue ( ) . get ( 0 ) . getPalletQty ( ) ) ;
headerData . setPalletRemark ( entry . getValue ( ) . get ( 0 ) . getPalletRemark ( ) ) ;
headerData . setLength ( entry . getValue ( ) . get ( 0 ) . getLength ( ) ) ;
headerData . setWidth ( entry . getValue ( ) . get ( 0 ) . getWidth ( ) ) ;
headerData . setHeight ( entry . getValue ( ) . get ( 0 ) . getHeight ( ) ) ;
headerData . setVolume ( entry . getValue ( ) . get ( 0 ) . getVolume ( ) ) ;
headerData . setCreateBy ( currentUser . getUsername ( ) ) ;
int i = 0 ;
BigDecimal totalGrossWeight = new BigDecimal ( 0 ) ;
BigDecimal boxQty = new BigDecimal ( 0 ) ;
for ( EcssCoDelPalletData thisData : entry . getValue ( ) ) {
EcssCoDelPalletDetailData detailData = new EcssCoDelPalletDetailData ( ) ;
detailData . setSite ( thisData . getSite ( ) ) ;
detailData . setBuNo ( thisData . getBuNo ( ) ) ;
detailData . setDelNo ( thisData . getDelNo ( ) ) ;
detailData . setSeqNo ( seqNo ) ;
detailData . setItemNo ( i + 1 ) ;
i + + ;
detailData . setPartNo ( thisData . getPartNo ( ) ) ;
detailData . setPn ( thisData . getPn ( ) ) ;
detailData . setQty ( thisData . getQty ( ) ) ;
task . setSku ( detailData . getPn ( ) ) ;
task . setQty ( detailData . getQty ( ) ) ;
List < EcssWalMartOrder > orderDataList = sqlSession . selectList ( "ecssMapper" + "." + "searchWalMartOrderList" , task ) ;
totalGrossWeight = totalGrossWeight . add ( orderDataList . isEmpty ( ) ? new BigDecimal ( 0 ) : orderDataList . get ( 0 ) . getGrossWeight ( ) ) ;
detailData . setPoNo ( thisData . getPoNo ( ) ) ;
if ( thisData . getBoxQty ( ) ! = null & & thisData . getBoxQty ( ) . intValue ( ) > 0 ) {
detailData . setBoxQty ( thisData . getBoxQty ( ) ) ;
} else {
String partNo = thisData . getPartNo ( ) ;
/ / 关务物料属性
List < PartSubPropertiesValueData > propertiesValues = coDelMapper . getPropertiesListByTypeAndCodeNo (
inData . getSite ( ) , "ECSSPART" , "BG001" , inData . getBuNo ( ) , partNo ) ;
/ / 每一个物料加属性对应一个属性 , 用来下面遍历发货通知单明细时获取具体属性值
Map < String , List < PartSubPropertiesValueData > > partNoAndItemNoMap = propertiesValues . stream ( )
. collect ( Collectors . groupingBy ( PartSubPropertiesValue : : getPropertiesItemNo ) ) ;
PartSubPropertiesValueData propertiesRollQty = partNoAndItemNoMap . get ( "ROLLQTY" ) = = null ? null : partNoAndItemNoMap . get ( "ROLLQTY" ) . get ( 0 ) ; / / 每卷数量
PartSubPropertiesValueData propertiesBoxRolls = partNoAndItemNoMap . get ( "BOXROLLS" ) = = null ? null : partNoAndItemNoMap . get ( "BOXROLLS" ) . get ( 0 ) ; / / 每箱卷数
if ( propertiesRollQty = = null | | propertiesBoxRolls = = null ) {
throw new RuntimeException ( "请先维护物料[" + detailData . getPn ( ) + "]的每卷数量和每箱卷数!" ) ;
}
detailData . setBoxQty ( detailData . getQty ( ) . divide (
BigDecimal . valueOf ( ( ( double ) propertiesRollQty . getNumValue ( ) . intValue ( ) * propertiesBoxRolls . getNumValue ( ) . intValue ( ) ) ) , 2 , BigDecimal . ROUND_HALF_UP ) ) ;
}
detailData . setRolls ( thisData . getRolls ( ) ) ;
detailData . setCreateBy ( currentUser . getUsername ( ) ) ;
detailList . add ( detailData ) ;
boxQty = boxQty . add ( detailData . getBoxQty ( ) ! = null ? detailData . getBoxQty ( ) : new BigDecimal ( 0 ) ) ;
}
BigDecimal netWeight = totalGrossWeight . intValue ( ) > 0 ? totalGrossWeight . subtract ( boxQty . divide ( BigDecimal . valueOf ( 2 ) , 2 , RoundingMode . HALF_UP ) ) : new BigDecimal ( 0 ) ;
headerData . setGrossWeight ( totalGrossWeight ) ;
headerData . setNetWeight ( netWeight ) ;
headerList . add ( headerData ) ;
} * /
for ( Map . Entry < Integer , List < EcssCoDelPalletData > > entry : palletListMap2 . entrySet ( ) ) {
for ( Map . Entry < Integer , List < EcssCoDelPalletData > > entry : palletListMap2 . entrySet ( ) ) {
seqNo + + ;
seqNo + + ;
EcssCoDelBoxListData boxListData = new EcssCoDelBoxListData ( ) ;
EcssCoDelBoxListData boxListData = new EcssCoDelBoxListData ( ) ;
@ -1026,9 +929,6 @@ public class CoDelServiceImpl implements CoDelService {
detailList . add ( detailData ) ;
detailList . add ( detailData ) ;
}
}
}
}
/ * for ( EcssCoDelPalletHeaderData ecssCoDelPalletHeaderData : headerList ) {
coDelMapper . saveCodelPalletHeader ( ecssCoDelPalletHeaderData ) ;
} * /
for ( EcssCoDelBoxListData boxData : boxList ) {
for ( EcssCoDelBoxListData boxData : boxList ) {
coDelMapper . saveCodelBoxList ( boxData ) ;
coDelMapper . saveCodelBoxList ( boxData ) ;
}
}
@ -2262,7 +2162,6 @@ public class CoDelServiceImpl implements CoDelService {
list . add ( detailData ) ;
list . add ( detailData ) ;
palletListMap . put ( detailData . getPartNo ( ) , list ) ;
palletListMap . put ( detailData . getPartNo ( ) , list ) ;
}
}
/ / totalQty = totalQty + detailData . getQty ( ) . intValue ( ) ;
}
}
int seqNo = 1 ;
int seqNo = 1 ;
StringBuilder partNos = new StringBuilder ( ) ;
StringBuilder partNos = new StringBuilder ( ) ;
@ -2294,36 +2193,6 @@ public class CoDelServiceImpl implements CoDelService {
PartSubPropertiesValueData propertiesRollQty = partNoAndItemNoMap . get ( "ROLLQTY" ) . get ( 0 ) ; / / 每卷数量
PartSubPropertiesValueData propertiesRollQty = partNoAndItemNoMap . get ( "ROLLQTY" ) . get ( 0 ) ; / / 每卷数量
PartSubPropertiesValueData propertiesBoxRolls = partNoAndItemNoMap . get ( "BOXROLLS" ) . get ( 0 ) ; / / 每箱卷数
PartSubPropertiesValueData propertiesBoxRolls = partNoAndItemNoMap . get ( "BOXROLLS" ) . get ( 0 ) ; / / 每箱卷数
PartSubPropertiesValueData propertiesBoxWeight = partNoAndItemNoMap . get ( "BOXWEIGHT" ) . get ( 0 ) ; / / 箱重量
PartSubPropertiesValueData propertiesBoxWeight = partNoAndItemNoMap . get ( "BOXWEIGHT" ) . get ( 0 ) ; / / 箱重量
/ * EcssCoDelPalletHeaderData headerData = new EcssCoDelPalletHeaderData ( ) ;
BeanUtils . copyProperties ( inData , headerData ) ;
headerData . setSeqNo ( seqNo + seq ) ;
seq + + ;
headerData . setPalletNo ( inData . getDelNo ( ) + "-" + String . format ( "%03d" , headerData . getSeqNo ( ) ) ) ;
headerData . setCreateBy ( currentUser . getUsername ( ) ) ;
headerData . setCreateDate ( new Date ( ) ) ;
headerData . setUpdateBy ( currentUser . getUsername ( ) ) ;
headerData . setUpdateDate ( new Date ( ) ) ;
headerData . setAddFlag ( 0 ) ;
headerData . setLength ( palletData . getLength ( ) ) ;
headerData . setWidth ( palletData . getWidth ( ) ) ;
headerData . setHeight ( inData . getHeight ( ) ) ;
int totalQty = 0 ;
for ( EcssCoDelNotifyDetailData detailData : palletListMap . get ( partNo ) ) {
totalQty = totalQty + detailData . getQty ( ) . intValue ( ) ;
}
/ / 每托层数 * 箱高 + 底座高
headerData . setVolume ( headerData . getLength ( ) . multiply ( headerData . getWidth ( ) ) . multiply ( headerData . getHeight ( ) ) ) ;
BigDecimal boxWeight = BigDecimal . valueOf ( propertiesBoxWeight . getNumValue ( ) ) ; / / 箱的重量
/ / Total Qty / 每箱EA
BigDecimal noCartons = BigDecimal . valueOf ( totalQty / ( ( double ) propertiesRollQty . getNumValue ( ) . intValue ( ) * propertiesBoxRolls . getNumValue ( ) . intValue ( ) ) ) ;
/ / 箱重量 : 物料维护里取
BigDecimal grossWeight = noCartons . multiply ( boxWeight ) ;
/ / Net Weight = Gross Weight - No of Cartons / 2
BigDecimal netWeight = grossWeight . subtract ( noCartons . divide ( BigDecimal . valueOf ( 2 ) ) ) ;
/ / 如果是沃尔玛订单可以根据料号和发货数量直接取维护好的净重 、 毛重
headerData . setGrossWeight ( grossWeight ) ;
headerData . setNetWeight ( netWeight ) ;
coDelMapper . saveCodelPalletHeader ( headerData ) ; * /
int totalQty = 0 ;
int totalQty = 0 ;
for ( EcssCoDelNotifyDetailData detailData : palletListMap . get ( partNo ) ) {
for ( EcssCoDelNotifyDetailData detailData : palletListMap . get ( partNo ) ) {
totalQty = totalQty + detailData . getQty ( ) . intValue ( ) ;
totalQty = totalQty + detailData . getQty ( ) . intValue ( ) ;
@ -2463,10 +2332,6 @@ public class CoDelServiceImpl implements CoDelService {
}
}
}
}
/ / 处理栈板记录
/ * palletHeaderSave ( inData . getSite ( ) , inData . getBuNo ( ) , inData . getDelNo ( ) ,
inData . getPalletRecords ( ) , currentUser ) ; * /
/ / 将发货通知单modifyFlag变更为false
notifyHeader . setModifyFlag ( false ) ;
notifyHeader . setModifyFlag ( false ) ;
coDelMapper . updateEcssDelHeaderForModify ( notifyHeader ) ;
coDelMapper . updateEcssDelHeaderForModify ( notifyHeader ) ;
coDelMapper . updateEcssDelDetailForModify ( notifyHeader ) ;
coDelMapper . updateEcssDelDetailForModify ( notifyHeader ) ;