Browse Source

发票明细

master
han\hanst 4 days ago
parent
commit
5b89ea382e
  1. 58
      src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java
  2. 2
      src/main/resources/mapper/ecss/EcssCommonMapper.xml
  3. BIN
      src/main/resources/templates/YB/declaration-invoice2-template.xlsx

58
src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java

@ -1484,35 +1484,10 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
List<Map> ndList = sqlSession.selectList("ecssMapper.searchEcssCoDelNotifyDetailList", notifyHeader); List<Map> ndList = sqlSession.selectList("ecssMapper.searchEcssCoDelNotifyDetailList", notifyHeader);
for (int i = 0; i < ndList.size(); i++) { for (int i = 0; i < ndList.size(); i++) {
Map eorder = ndList.get(i); Map eorder = ndList.get(i);
String partNo = (String) eorder.get("part_no");
Integer itemNo = eorder.get("item_no") != null ? (Integer) eorder.get("item_no") : null;
eorder.put("row_num", i + 1); eorder.put("row_num", i + 1);
EcssCoDelNotifyDetailData nodifyData = notifyDetailMap.get(partNo);
// 根据item_no获取该明细行对应的装箱重量
String lossratio = "";
if (nodifyData!=null && nodifyData.getLossratio()!=null && !StringUtils.isBlank(nodifyData.getLossratio())) {
// 关务物料属性
List<PartSubPropertiesValueData> propertiesValues = coDelMapper.getPropertiesListByTypeAndCodeNo(
notifyHeader.getSite(), "ECSSPART","BG001", notifyHeader.getBuNo(), partNo);
// 每一个物料加属性对应一个属性用来下面遍历发货通知单明细时获取具体属性值
Map<String, List<PartSubPropertiesValueData>> partNoAndItemNoMap = propertiesValues.stream()
.collect(Collectors.groupingBy(PartSubPropertiesValue::getPropertiesItemNo));
BigDecimal qty = ((BigDecimal)eorder.get("qty")).setScale(6, RoundingMode.HALF_UP);
BigDecimal fscW = fscWeight(partNoAndItemNoMap,partNo, qty, nodifyData.getLossratio());
lossratio = (fscW.compareTo(BigDecimal.ZERO)>0?"\n"+"FSC Mix Credit SGSHK-COC-321321":"")+
"\n" + (nodifyData.getEhundred()!=null && StringUtils.isNotEmpty(nodifyData.getEhundred())
?"E100-"+nodifyData.getEhundred()+ " ":"")
+ (fscW.compareTo(BigDecimal.ZERO)>0?"重量:"+ fscW :"");
}
String hsCodeDesc = data.getHsCodeDesc()!=null&& data.getHsCodeDesc()?
("\n"+(data.getHsCodeDescTypeInvoice()!=null&& data.getHsCodeDescTypeInvoice().equals("N")
?eorder.get("hsCodeDescEn") :eorder.get("hsCodeDesc"))):"";
// 构建designation内容 // 构建designation内容
String designationContent = eorder.get("part_description") + "\n" + "PO:" + eorder.get("customerPO")
+ (data.getSo()!=null && data.getSo()?" SO:"+eorder.get("so"):"")
+ (data.getHsCodeFlag()!=null && data.getHsCodeFlag()?"\nHS Code:" + eorder.get("hsCode"):"")+hsCodeDesc+ lossratio;
String designationContent = eorder.get("pn")+" " + eorder.get("part_description") + "\n"
+ " PO#" + eorder.get("customerPO")+" HS CODE#" + eorder.get("hsCode");
eorder.put("designation", designationContent); eorder.put("designation", designationContent);
// 计算designation内容的行数动态设置行高 // 计算designation内容的行数动态设置行高
@ -1576,11 +1551,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
for (EcssCoDelNotifyDetailData nData:notifyDetailList){ for (EcssCoDelNotifyDetailData nData:notifyDetailList){
coDelMapper.updateEcssCoDelNotifyDetail(nData); coDelMapper.updateEcssCoDelNotifyDetail(nData);
} }
} else {
notifyDetailList = coDelMapper.getNotifyPartDetail2(data);
} }
Map<String, EcssCoDelNotifyDetailData> notifyDetailMap = notifyDetailList.stream().collect(
Collectors.toMap(EcssCoDelNotifyDetailData::getPartNo,e->e));
template.setCellStyle(true); template.setCellStyle(true);
template.setRangeStyle(true); template.setRangeStyle(true);
template.setMoveSeal(true); template.setMoveSeal(true);
@ -1621,7 +1592,6 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
BigDecimal totalCartons = BigDecimal.valueOf(0.0); BigDecimal totalCartons = BigDecimal.valueOf(0.0);
BigDecimal grossWeight = BigDecimal.valueOf(0.0); BigDecimal grossWeight = BigDecimal.valueOf(0.0);
BigDecimal netWeight = BigDecimal.valueOf(0.0); BigDecimal netWeight = BigDecimal.valueOf(0.0);
BigDecimal rolls = BigDecimal.valueOf(0.0);
BigDecimal totalQty = BigDecimal.valueOf(0.0); BigDecimal totalQty = BigDecimal.valueOf(0.0);
// 托盘序号 -> 托盘数用于托盘数列展示 // 托盘序号 -> 托盘数用于托盘数列展示
Map<String, Integer> palletQtyMap = palletHeaderDataList.stream() Map<String, Integer> palletQtyMap = palletHeaderDataList.stream()
@ -1656,18 +1626,13 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
if (!Objects.equals(palletSeqNo, previousPalletSeqNo)) { if (!Objects.equals(palletSeqNo, previousPalletSeqNo)) {
palletStartIndex = boxStartIndex; palletStartIndex = boxStartIndex;
} }
// 获取box的rolls
BigDecimal boxRolls = list.get(m).get("rolls") != null ?
((BigDecimal) list.get(m).get("rolls")).setScale(0, RoundingMode.HALF_UP) : BigDecimal.ZERO;
// 获取box的volume // 获取box的volume
BigDecimal volume = list.get(m).get("volume") != null ? BigDecimal volume = list.get(m).get("volume") != null ?
((BigDecimal) list.get(m).get("volume")).setScale(6, RoundingMode.HALF_UP) : BigDecimal.ZERO; ((BigDecimal) list.get(m).get("volume")).setScale(6, RoundingMode.HALF_UP) : BigDecimal.ZERO;
for (int i = 0; i < checkList.size(); i++) { for (int i = 0; i < checkList.size(); i++) {
Map eorder = checkList.get(i); Map eorder = checkList.get(i);
String partNo = (String) eorder.get("part_no");
BigDecimal qty = ((BigDecimal)eorder.get("qty")).setScale(6, RoundingMode.HALF_UP); BigDecimal qty = ((BigDecimal)eorder.get("qty")).setScale(6, RoundingMode.HALF_UP);
totalQty = totalQty.add(qty); totalQty = totalQty.add(qty);
BigDecimal noCartons = list.get(m).get("box_qty")!=null?(BigDecimal) list.get(m).get("box_qty"):BigDecimal.ZERO;
eorder.put("total_qty", ((BigDecimal)eorder.get("qty")).setScale(6, RoundingMode.HALF_UP)); eorder.put("total_qty", ((BigDecimal)eorder.get("qty")).setScale(6, RoundingMode.HALF_UP));
// 合箱时第一行显示数值用于合并单元格居中显示 // 合箱时第一行显示数值用于合并单元格居中显示
boolean isFirstRow = (i == 0); boolean isFirstRow = (i == 0);
@ -1686,12 +1651,6 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
eorder.put("gross_weight", isFirstRow ? ((BigDecimal) list.get(m).get("gross_weight")).setScale(2, RoundingMode.HALF_UP) : ""); eorder.put("gross_weight", isFirstRow ? ((BigDecimal) list.get(m).get("gross_weight")).setScale(2, RoundingMode.HALF_UP) : "");
eorder.put("net_weight", ((BigDecimal) list.get(m).get("net_weight")).setScale(2, RoundingMode.HALF_UP)); eorder.put("net_weight", ((BigDecimal) list.get(m).get("net_weight")).setScale(2, RoundingMode.HALF_UP));
// rolls处理如果明细的rolls全部为空或0则取box的rolls合箱时合并居中显示
// 使用box的rolls合箱时只在第一行显示用于合并单元格居中
if (isFirstRow) {
rolls = rolls.add(boxRolls);
}
// 构建artNo内容 // 构建artNo内容
String artNoContent = eorder.get("pn")+" " + eorder.get("part_description") + "\n" String artNoContent = eorder.get("pn")+" " + eorder.get("part_description") + "\n"
+ " PO#" + eorder.get("po_no")+" HS CODE#" + eorder.get("hsCode"); + " PO#" + eorder.get("po_no")+" HS CODE#" + eorder.get("hsCode");
@ -1751,7 +1710,6 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
template.addVar("total_netweight", netWeight.setScale(2, RoundingMode.HALF_UP)); template.addVar("total_netweight", netWeight.setScale(2, RoundingMode.HALF_UP));
template.addVar("total_box", totalCartons.setScale(0, RoundingMode.HALF_UP)); template.addVar("total_box", totalCartons.setScale(0, RoundingMode.HALF_UP));
template.addVar("goods_total_qty", totalQty); template.addVar("goods_total_qty", totalQty);
template.addVar("total_rolls", rolls.setScale(0, RoundingMode.HALF_UP));
// 下面是可选的或者手动维护的 // 下面是可选的或者手动维护的
// RFID需要的 // RFID需要的
if (notifyHeader.getBuNo().equals("01-Label") || notifyHeader.getBuNo().equals("03-RFID")) { if (notifyHeader.getBuNo().equals("01-Label") || notifyHeader.getBuNo().equals("03-RFID")) {
@ -1774,10 +1732,6 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
if (data.getMaterial()!=null && data.getMaterial()) { if (data.getMaterial()!=null && data.getMaterial()) {
template.addVar("RFIDBase", "RFID Base Material"); template.addVar("RFIDBase", "RFID Base Material");
template.addVar("HSCode", "& H.S.Code:"+stringInput(data.getHsCode())); template.addVar("HSCode", "& H.S.Code:"+stringInput(data.getHsCode()));
/* template.addVar("volume", !palletHeaderData.isPresent()?"":palletHeaderData.map(ecssCoDelPalletHeaderData ->
ecssCoDelPalletHeaderData.getLength().setScale(2, RoundingMode.HALF_UP)
+ "*" + ecssCoDelPalletHeaderData.getWidth().setScale(2, RoundingMode.HALF_UP) + "*"
+ ecssCoDelPalletHeaderData.getHeight().setScale(2, RoundingMode.HALF_UP) + "m").orElse(""));*/
} }
// 欧洲地区需要 // 欧洲地区需要
if (data.getPackaging()!=null && data.getPackaging()) { if (data.getPackaging()!=null && data.getPackaging()) {
@ -1863,7 +1817,6 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
BigDecimal totalCartons = BigDecimal.valueOf(0.0); BigDecimal totalCartons = BigDecimal.valueOf(0.0);
BigDecimal grossWeight = BigDecimal.valueOf(0.0); BigDecimal grossWeight = BigDecimal.valueOf(0.0);
BigDecimal netWeight = BigDecimal.valueOf(0.0); BigDecimal netWeight = BigDecimal.valueOf(0.0);
BigDecimal rolls = BigDecimal.valueOf(0.0);
BigDecimal totalQty = BigDecimal.valueOf(0.0); BigDecimal totalQty = BigDecimal.valueOf(0.0);
// 托盘序号 -> 托盘数用于托盘数列展示 // 托盘序号 -> 托盘数用于托盘数列展示
Map<String, Integer> palletQtyMap = palletHeaderDataList.stream() Map<String, Integer> palletQtyMap = palletHeaderDataList.stream()
@ -1936,12 +1889,6 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
eorder.put("gross_weight", isFirstRow ? ((BigDecimal) list.get(m).get("gross_weight")).setScale(2, RoundingMode.HALF_UP) : ""); eorder.put("gross_weight", isFirstRow ? ((BigDecimal) list.get(m).get("gross_weight")).setScale(2, RoundingMode.HALF_UP) : "");
eorder.put("net_weight", isFirstRow ? ((BigDecimal) list.get(m).get("net_weight")).setScale(2, RoundingMode.HALF_UP) : ""); eorder.put("net_weight", isFirstRow ? ((BigDecimal) list.get(m).get("net_weight")).setScale(2, RoundingMode.HALF_UP) : "");
// rolls处理如果明细的rolls全部为空或0则取box的rolls合箱时合并居中显示
// 使用box的rolls合箱时只在第一行显示用于合并单元格居中
if (isFirstRow) {
rolls = rolls.add(boxRolls);
}
// 构建artNo内容 // 构建artNo内容
String artNoContent = eorder.get("pn")+" " + eorder.get("part_description") + "\n" String artNoContent = eorder.get("pn")+" " + eorder.get("part_description") + "\n"
+ " PO#" + eorder.get("po_no")+" HS CODE#" + eorder.get("hsCode"); + " PO#" + eorder.get("po_no")+" HS CODE#" + eorder.get("hsCode");
@ -2004,7 +1951,6 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
template.addVar("total_netweight", netWeight.setScale(2, RoundingMode.HALF_UP)); template.addVar("total_netweight", netWeight.setScale(2, RoundingMode.HALF_UP));
template.addVar("total_box", totalCartons.setScale(0, RoundingMode.HALF_UP)); template.addVar("total_box", totalCartons.setScale(0, RoundingMode.HALF_UP));
template.addVar("goods_total_qty", totalQty); template.addVar("goods_total_qty", totalQty);
template.addVar("total_rolls", rolls.setScale(0, RoundingMode.HALF_UP));
// 下面是可选的或者手动维护的 // 下面是可选的或者手动维护的
// RFID需要的 // RFID需要的
if (notifyHeader.getBuNo().equals("01-Label") || notifyHeader.getBuNo().equals("03-RFID")) { if (notifyHeader.getBuNo().equals("01-Label") || notifyHeader.getBuNo().equals("03-RFID")) {

2
src/main/resources/mapper/ecss/EcssCommonMapper.xml

@ -137,7 +137,7 @@
CASE WHEN a.modifyFlag = 1 THEN '是' ELSE '否' END AS modifyFlag CASE WHEN a.modifyFlag = 1 THEN '是' ELSE '否' END AS modifyFlag
from ecss_CoDelNotifydetail a from ecss_CoDelNotifydetail a
left join part b on a.site=b.site and a.part_no=b.part_no left join part b on a.site=b.site and a.part_no=b.part_no
left join ecss_hsCode h on b.hsCode=h.HsCode and a.site=h.site and b.hsCodeDesc=h.hsCodeDesc
left join ecss_hsCode h on b.hsCode=h.HsCode and a.site=h.site and b.hsCodeDesc=h.hsCodeDesc and h.brand=b.brand
<where> <where>
And a.site = #{site} And a.site = #{site}
AND a.delNo = #{delNo} AND a.delNo = #{delNo}

BIN
src/main/resources/templates/YB/declaration-invoice2-template.xlsx

Loading…
Cancel
Save