Browse Source

详情列自适应

master
han\hanst 4 weeks ago
parent
commit
5fef42d4b5
  1. 71
      src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelServiceImpl.java

71
src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelServiceImpl.java

@ -1487,7 +1487,10 @@ public class CoDelExcelServiceImpl implements CoDelExcelService {
if (row == null) { if (row == null) {
continue; continue;
} }
// 验证发票号是否为空空过滤列F索引5
if (row.getCell(5) == null ) {
continue;
}
// 验证发票号是否匹配列F索引5 // 验证发票号是否匹配列F索引5
if (row.getCell(5) != null && !inData.getCmcInvoice().equals(getStringCellValue(row, 5))) { if (row.getCell(5) != null && !inData.getCmcInvoice().equals(getStringCellValue(row, 5))) {
continue; continue;
@ -2605,9 +2608,21 @@ public class CoDelExcelServiceImpl implements CoDelExcelService {
String hsCodeDesc = data.getHsCodeDesc()!=null&& data.getHsCodeDesc()? String hsCodeDesc = data.getHsCodeDesc()!=null&& data.getHsCodeDesc()?
("\n"+(data.getHsCodeDescTypeInvoice()!=null&& data.getHsCodeDescTypeInvoice().equals("N") ("\n"+(data.getHsCodeDescTypeInvoice()!=null&& data.getHsCodeDescTypeInvoice().equals("N")
?eorder.get("hsCodeDescEn") :eorder.get("hsCodeDesc"))):""; ?eorder.get("hsCodeDescEn") :eorder.get("hsCodeDesc"))):"";
eorder.put("designation", eorder.get("part_description") + "\n" + "PO:" + eorder.get("customerPO")
// 构建designation内容
String designationContent = eorder.get("part_description") + "\n" + "PO:" + eorder.get("customerPO")
+ (data.getSo()!=null && data.getSo()?" SO:"+eorder.get("so"):"") + (data.getSo()!=null && data.getSo()?" SO:"+eorder.get("so"):"")
+ (data.getHsCodeFlag()!=null && data.getHsCodeFlag()?"\nHS Code:" + eorder.get("hsCode"):"")+hsCodeDesc+ lossratio);
+ (data.getHsCodeFlag()!=null && data.getHsCodeFlag()?"\nHS Code:" + eorder.get("hsCode"):"")+hsCodeDesc+ lossratio;
eorder.put("designation", designationContent);
// 计算designation内容的行数动态设置行高
int lineCount = calculateLineCount(designationContent);
// 基础行高16点 + 每额外行增加15点可根据实际字体大小调整
int rowHeight = 16 + (lineCount - 1) * 15;
// 设置当前行的行高ndList的当前索引
template.setRowHeight(i, i, rowHeight);
eorder.put("totalPrice", ((BigDecimal)eorder.get("ttl_amount")).setScale(2, RoundingMode.HALF_UP)); eorder.put("totalPrice", ((BigDecimal)eorder.get("ttl_amount")).setScale(2, RoundingMode.HALF_UP));
allPrice = allPrice.add( ((BigDecimal)eorder.get("ttl_amount"))); allPrice = allPrice.add( ((BigDecimal)eorder.get("ttl_amount")));
if (data.getShowWeight()!=null && data.getShowWeight()) { if (data.getShowWeight()!=null && data.getShowWeight()) {
@ -2770,10 +2785,22 @@ public class CoDelExcelServiceImpl implements CoDelExcelService {
if (notifyHeader.getBoxSizeFlag()!=null && notifyHeader.getBoxSizeFlag().equals("Y")) { if (notifyHeader.getBoxSizeFlag()!=null && notifyHeader.getBoxSizeFlag().equals("Y")) {
boxSize = list.get(m).get("remark") != null ? list.get(m).get("remark").toString() : ""; boxSize = list.get(m).get("remark") != null ? list.get(m).get("remark").toString() : "";
} }
eorder.put("artNo", eorder.get("part_description") + "\n" + "PO:" + eorder.get("po_no")
// 构建artNo内容
String artNoContent = eorder.get("part_description") + "\n" + "PO:" + eorder.get("po_no")
+ (data.getSo()!=null && data.getSo()? " SO:"+eorder.get("so"):"") + lossratio + (data.getSo()!=null && data.getSo()? " SO:"+eorder.get("so"):"") + lossratio
+ (data.getUpc()!=null && data.getUpc()?"\n" + "UPC:"+ eorder.get("upc"):"") + (data.getUpc()!=null && data.getUpc()?"\n" + "UPC:"+ eorder.get("upc"):"")
+ (data.getHsCodeFlag()!=null && data.getHsCodeFlag()?"\nHS Code:" + eorder.get("hsCode"):"")+ hsCodeDesc+(boxSize!=null?" "+boxSize:""));
+ (data.getHsCodeFlag()!=null && data.getHsCodeFlag()?"\nHS Code:" + eorder.get("hsCode"):"")+ hsCodeDesc+(boxSize!=null?" "+boxSize:"");
eorder.put("artNo", artNoContent);
// 计算artNo内容的行数动态设置行高
int lineCount = calculateLineCount(artNoContent);
// 基础行高16点 + 每额外行增加15点可根据实际字体大小调整
int rowHeight = 16 + (lineCount - 1) * 15;
// 设置当前行的行高exportList的当前索引
template.setRowHeight(exportList.size(), exportList.size(), rowHeight);
exportList.add(eorder); exportList.add(eorder);
} }
// 如果当前箱子对应多个物料合箱添加合并单元格区域 // 如果当前箱子对应多个物料合箱添加合并单元格区域
@ -3086,13 +3113,23 @@ public class CoDelExcelServiceImpl implements CoDelExcelService {
boxSize = list.get(m).get("remark") != null ? list.get(m).get("remark").toString() : ""; boxSize = list.get(m).get("remark") != null ? list.get(m).get("remark").toString() : "";
} }
eorder.put("artNo", eorder.get("part_description") + "\n" + "PO:" + eorder.get("po_no")
// 构建artNo内容
String artNoContent = eorder.get("part_description") + "\n" + "PO:" + eorder.get("po_no")
+ (data.getSo() != null && data.getSo() ? " SO:" + eorder.get("so") : "") + (data.getSo() != null && data.getSo() ? " SO:" + eorder.get("so") : "")
+ lossratio + lossratio
+ (data.getUpc() != null && data.getUpc() ? "\n" + "UPC:" + eorder.get("upc") : "") + (data.getUpc() != null && data.getUpc() ? "\n" + "UPC:" + eorder.get("upc") : "")
+ (data.getHsCodeFlag() != null && data.getHsCodeFlag() ? + (data.getHsCodeFlag() != null && data.getHsCodeFlag() ?
"\nHS Code:" + eorder.get("hsCode") : "") + hsCodeDesc+ "\nHS Code:" + eorder.get("hsCode") : "") + hsCodeDesc+
(boxSize != null ? " " + boxSize : ""));
(boxSize != null ? " " + boxSize : "");
eorder.put("artNo", artNoContent);
// 计算artNo内容的行数动态设置行高
int lineCount = calculateLineCount(artNoContent);
// 基础行高16点 + 每额外行增加15点可根据实际字体大小调整
int rowHeight = 16 + (lineCount - 1) * 15;
// 设置当前行的行高exportList的当前索引
template.setRowHeight(exportList.size(), exportList.size(), rowHeight);
exportList.add(eorder); exportList.add(eorder);
} }
@ -4862,4 +4899,24 @@ public class CoDelExcelServiceImpl implements CoDelExcelService {
template.addListVarAll(dataList); template.addListVarAll(dataList);
} }
/**
* 计算文本内容的行数根据换行符
*
* @param content 文本内容
* @return 行数
*/
private int calculateLineCount(String content) {
if (content == null || content.isEmpty()) {
return 1;
}
// 计算换行符数量 + 1 = 行数
int lineCount = 1;
for (int i = 0; i < content.length(); i++) {
if (content.charAt(i) == '\n') {
lineCount++;
}
}
return lineCount;
}
} }
Loading…
Cancel
Save