Showing
2 changed files
with
96 additions
and
86 deletions
xingyun-sc/src/main/java/com/lframework/xingyun/sc/controller/order/OrderChangeRecordController.java
| ... | ... | @@ -200,20 +200,12 @@ public class OrderChangeRecordController extends DefaultBaseController { |
| 200 | 200 | |
| 201 | 201 | // 过滤需要显示的变更前记录(DELETE 或 UPDATE 且有变化) |
| 202 | 202 | List<PurchaseOrderLine> beforeLines = beforeChangeSpecList.stream() |
| 203 | - .filter(line -> "DELETE".equals(line.getType()) || | |
| 204 | - ("UPDATE".equals(line.getType()) && | |
| 205 | - (line.getBrandChange() || line.getLengthChange() || line.getWidthChange() || | |
| 206 | - line.getThicknessChange() || line.getStatusChange() || | |
| 207 | - line.getQuantityChange() || line.getSalesPriceChange()))) | |
| 203 | + .filter(this::shouldPrintChangeLine) | |
| 208 | 204 | .collect(Collectors.toList()); |
| 209 | 205 | |
| 210 | 206 | // 过滤需要显示的变更后记录(ADD 或 UPDATE 且有变化) |
| 211 | 207 | List<PurchaseOrderLine> afterLines = afterChangeSpecList.stream() |
| 212 | - .filter(line -> "ADD".equals(line.getType()) || | |
| 213 | - ("UPDATE".equals(line.getType()) && | |
| 214 | - (line.getBrandChange() || line.getLengthChange() || line.getWidthChange() || | |
| 215 | - line.getThicknessChange() || line.getStatusChange() || | |
| 216 | - line.getQuantityChange() || line.getSalesPriceChange()))) | |
| 208 | + .filter(this::shouldPrintChangeLine) | |
| 217 | 209 | .collect(Collectors.toList()); |
| 218 | 210 | |
| 219 | 211 | // ========== 填充变更前区域(起始行:5)========== |
| ... | ... | @@ -227,44 +219,7 @@ public class OrderChangeRecordController extends DefaultBaseController { |
| 227 | 219 | PurchaseOrderLine line = i < beforeLines.size() ? beforeLines.get(i) : null; |
| 228 | 220 | int rowIdx = beforeStartRow + i; |
| 229 | 221 | if (line != null) { |
| 230 | - ExcelUtil.setCellValue(sheet, rowIdx, 0, line.getIndustry()); | |
| 231 | - ExcelUtil.setCellValue(sheet, rowIdx, 1, line.getQuality()); | |
| 232 | - ExcelUtil.setCellValue(sheet, rowIdx, 2, line.getBrand()); | |
| 233 | - List<LatexFormulaExcelExporterUtil.FormulaComponent> formulaComponentList = new ArrayList<>(3); | |
| 234 | - if (line.getThickness() != null) { | |
| 235 | - LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent(); | |
| 236 | - formulaComponent.setBase(line.getThickness()); | |
| 237 | - formulaComponent.setSup(line.getThicknessTolPos()); | |
| 238 | - formulaComponent.setSub(line.getThicknessTolNeg()); | |
| 239 | - formulaComponentList.add(formulaComponent); | |
| 240 | - } | |
| 241 | - | |
| 242 | - if (line.getWidth() != null) { | |
| 243 | - LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent(); | |
| 244 | - formulaComponent.setBase(line.getWidth()); | |
| 245 | - formulaComponent.setSup(line.getWidthTolPos()); | |
| 246 | - formulaComponent.setSub(line.getWidthTolNeg()); | |
| 247 | - formulaComponentList.add(formulaComponent); | |
| 248 | - } | |
| 249 | - | |
| 250 | - if (line.getLength() != null) { | |
| 251 | - LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent(); | |
| 252 | - formulaComponent.setBase(line.getLength()); | |
| 253 | - formulaComponent.setSup(line.getLengthTolPos()); | |
| 254 | - formulaComponent.setSub(line.getLengthTolNeg()); | |
| 255 | - formulaComponentList.add(formulaComponent); | |
| 256 | - } | |
| 257 | - | |
| 258 | - String latex = LatexFormulaExcelExporterUtil.convertToLatex(formulaComponentList); | |
| 259 | - if (StringUtils.isNotBlank(latex)) { | |
| 260 | - LatexFormulaExcelExporterUtil.insertLatexImageToCell(workbook, sheet, latex, rowIdx, 3, 1, 1); | |
| 261 | - } | |
| 262 | - ExcelUtil.setCellValue(sheet, rowIdx, 4, line.getStatus()); | |
| 263 | - ExcelUtil.setCellValue(sheet, rowIdx, 5, line.getQuantity()); | |
| 264 | - ExcelUtil.setCellValue(sheet, rowIdx, 6, line.getSalesPrice()); | |
| 265 | - ExcelUtil.setCellValue(sheet, rowIdx, 7, | |
| 266 | - line.getDeliveryDate() == null ? "" : line.getDeliveryDate().format(dateFormatter)); | |
| 267 | - ExcelUtil.setCellValue(sheet, rowIdx, 8, line.getAssessmentExceedsAgreement()); | |
| 222 | + fillChangePrintRow(workbook, sheet, rowIdx, line, dateFormatter); | |
| 268 | 223 | } else { |
| 269 | 224 | for (int col = 0; col <= 8; col++) { |
| 270 | 225 | ExcelUtil.setCellValue(sheet, rowIdx, col, ""); |
| ... | ... | @@ -282,44 +237,7 @@ public class OrderChangeRecordController extends DefaultBaseController { |
| 282 | 237 | PurchaseOrderLine line = i < afterLines.size() ? afterLines.get(i) : null; |
| 283 | 238 | int rowIdx = afterStartRow + i; |
| 284 | 239 | if (line != null) { |
| 285 | - ExcelUtil.setCellValue(sheet, rowIdx, 0, line.getIndustry()); | |
| 286 | - ExcelUtil.setCellValue(sheet, rowIdx, 1, line.getQuality()); | |
| 287 | - ExcelUtil.setCellValue(sheet, rowIdx, 2, line.getBrand()); | |
| 288 | - List<LatexFormulaExcelExporterUtil.FormulaComponent> formulaComponentList = new ArrayList<>(3); | |
| 289 | - if (line.getThickness() != null) { | |
| 290 | - LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent(); | |
| 291 | - formulaComponent.setBase(line.getThickness()); | |
| 292 | - formulaComponent.setSup(line.getThicknessTolPos()); | |
| 293 | - formulaComponent.setSub(line.getThicknessTolNeg()); | |
| 294 | - formulaComponentList.add(formulaComponent); | |
| 295 | - } | |
| 296 | - | |
| 297 | - if (line.getWidth() != null) { | |
| 298 | - LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent(); | |
| 299 | - formulaComponent.setBase(line.getWidth()); | |
| 300 | - formulaComponent.setSup(line.getWidthTolPos()); | |
| 301 | - formulaComponent.setSub(line.getWidthTolNeg()); | |
| 302 | - formulaComponentList.add(formulaComponent); | |
| 303 | - } | |
| 304 | - | |
| 305 | - if (line.getLength() != null) { | |
| 306 | - LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent(); | |
| 307 | - formulaComponent.setBase(line.getLength()); | |
| 308 | - formulaComponent.setSup(line.getLengthTolPos()); | |
| 309 | - formulaComponent.setSub(line.getLengthTolNeg()); | |
| 310 | - formulaComponentList.add(formulaComponent); | |
| 311 | - } | |
| 312 | - | |
| 313 | - String latex = LatexFormulaExcelExporterUtil.convertToLatex(formulaComponentList); | |
| 314 | - if (StringUtils.isNotBlank(latex)) { | |
| 315 | - LatexFormulaExcelExporterUtil.insertLatexImageToCell(workbook, sheet, latex, rowIdx, 3, 1, 1); | |
| 316 | - } | |
| 317 | - ExcelUtil.setCellValue(sheet, rowIdx, 4, line.getStatus()); | |
| 318 | - ExcelUtil.setCellValue(sheet, rowIdx, 5, line.getQuantity()); | |
| 319 | - ExcelUtil.setCellValue(sheet, rowIdx, 6, line.getSalesPrice()); | |
| 320 | - ExcelUtil.setCellValue(sheet, rowIdx, 7, | |
| 321 | - line.getDeliveryDate() == null ? "" : line.getDeliveryDate().format(dateFormatter)); | |
| 322 | - ExcelUtil.setCellValue(sheet, rowIdx, 8, line.getAssessmentExceedsAgreement()); | |
| 240 | + fillChangePrintRow(workbook, sheet, rowIdx, line, dateFormatter); | |
| 323 | 241 | } else { |
| 324 | 242 | for (int col = 0; col <= 8; col++) { |
| 325 | 243 | ExcelUtil.setCellValue(sheet, rowIdx, col, ""); |
| ... | ... | @@ -510,4 +428,96 @@ public class OrderChangeRecordController extends DefaultBaseController { |
| 510 | 428 | target.setAssessmentExceedsAgreementChange(!Objects.equals(before.getAssessmentExceedsAgreement(), after.getAssessmentExceedsAgreement())); |
| 511 | 429 | } |
| 512 | 430 | |
| 431 | + /** | |
| 432 | + * 判断当前记录是否需要在规格变更打印中展示。 | |
| 433 | + * | |
| 434 | + * @param line 订货单明细 | |
| 435 | + * @return true:需要打印;false:不需要打印 | |
| 436 | + */ | |
| 437 | + private boolean shouldPrintChangeLine(PurchaseOrderLine line) { | |
| 438 | + if (line == null) { | |
| 439 | + return false; | |
| 440 | + } | |
| 441 | + if ("DELETE".equals(line.getType()) || "ADD".equals(line.getType())) { | |
| 442 | + return true; | |
| 443 | + } | |
| 444 | + return "UPDATE".equals(line.getType()) && (line.getBrandChange() | |
| 445 | + || line.getLengthChange() | |
| 446 | + || line.getWidthChange() | |
| 447 | + || line.getThicknessChange() | |
| 448 | + || line.getStatusChange() | |
| 449 | + || line.getQuantityChange() | |
| 450 | + || line.getSalesPriceChange() | |
| 451 | + || line.getDeliveryDateChange() | |
| 452 | + || line.getAssessmentExceedsAgreementChange()); | |
| 453 | + } | |
| 454 | + | |
| 455 | + /** | |
| 456 | + * 填充规格变更单打印行数据,并按订货单一致的方式渲染规格。 | |
| 457 | + * | |
| 458 | + * @param workbook 工作簿 | |
| 459 | + * @param sheet 工作表 | |
| 460 | + * @param rowIdx 行号 | |
| 461 | + * @param line 订货单明细 | |
| 462 | + * @param dateFormatter 日期格式化器 | |
| 463 | + * @throws IOException 规格渲染异常 | |
| 464 | + */ | |
| 465 | + private void fillChangePrintRow(Workbook workbook, Sheet sheet, int rowIdx, PurchaseOrderLine line, | |
| 466 | + DateTimeFormatter dateFormatter) throws IOException { | |
| 467 | + ExcelUtil.setCellValue(sheet, rowIdx, 0, line.getIndustry()); | |
| 468 | + ExcelUtil.setCellValue(sheet, rowIdx, 1, line.getQuality()); | |
| 469 | + ExcelUtil.setCellValue(sheet, rowIdx, 2, line.getBrand()); | |
| 470 | + renderSpecForChangePrint(workbook, sheet, rowIdx, line); | |
| 471 | + ExcelUtil.setCellValue(sheet, rowIdx, 4, line.getStatus()); | |
| 472 | + ExcelUtil.setCellValue(sheet, rowIdx, 5, line.getQuantity()); | |
| 473 | + ExcelUtil.setCellValue(sheet, rowIdx, 6, line.getSalesPrice()); | |
| 474 | + ExcelUtil.setCellValue(sheet, rowIdx, 7, | |
| 475 | + line.getDeliveryDate() == null ? "" : line.getDeliveryDate().format(dateFormatter)); | |
| 476 | + ExcelUtil.setCellValue(sheet, rowIdx, 8, line.getAssessmentExceedsAgreement()); | |
| 477 | + } | |
| 478 | + | |
| 479 | + /** | |
| 480 | + * 按订货单打印规则渲染规格,避免规格图片过大并保持左对齐。 | |
| 481 | + * | |
| 482 | + * @param workbook 工作簿 | |
| 483 | + * @param sheet 工作表 | |
| 484 | + * @param rowIdx 行号 | |
| 485 | + * @param line 订货单明细 | |
| 486 | + * @throws IOException 规格渲染异常 | |
| 487 | + */ | |
| 488 | + private void renderSpecForChangePrint(Workbook workbook, Sheet sheet, int rowIdx, PurchaseOrderLine line) | |
| 489 | + throws IOException { | |
| 490 | + List<LatexFormulaExcelExporterUtil.FormulaComponent> formulaComponentList = new ArrayList<>(3); | |
| 491 | + if (line.getThickness() != null) { | |
| 492 | + LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent(); | |
| 493 | + formulaComponent.setBase(line.getThickness()); | |
| 494 | + formulaComponent.setSup(line.getThicknessTolPos()); | |
| 495 | + formulaComponent.setSub(line.getThicknessTolNeg()); | |
| 496 | + formulaComponentList.add(formulaComponent); | |
| 497 | + } | |
| 498 | + | |
| 499 | + if (line.getWidth() != null) { | |
| 500 | + LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent(); | |
| 501 | + formulaComponent.setBase(line.getWidth()); | |
| 502 | + formulaComponent.setSup(line.getWidthTolPos()); | |
| 503 | + formulaComponent.setSub(line.getWidthTolNeg()); | |
| 504 | + formulaComponentList.add(formulaComponent); | |
| 505 | + } | |
| 506 | + | |
| 507 | + if (line.getLength() != null) { | |
| 508 | + LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent(); | |
| 509 | + formulaComponent.setBase(line.getLength()); | |
| 510 | + formulaComponent.setSup(line.getLengthTolPos()); | |
| 511 | + formulaComponent.setSub(line.getLengthTolNeg()); | |
| 512 | + formulaComponentList.add(formulaComponent); | |
| 513 | + } | |
| 514 | + | |
| 515 | + String latex = LatexFormulaExcelExporterUtil.convertToContractSpecLatexSingleLineFixed3(formulaComponentList); | |
| 516 | + if (StringUtils.isNotBlank(latex)) { | |
| 517 | + LatexFormulaExcelExporterUtil.insertLatexImageToCellLeftAligned(workbook, sheet, latex, rowIdx, 3, 1, 1); | |
| 518 | + } else { | |
| 519 | + ExcelUtil.setCellValue(sheet, rowIdx, 3, ""); | |
| 520 | + } | |
| 521 | + } | |
| 522 | + | |
| 513 | 523 | } | ... | ... |
No preview for this file type