|
...
|
...
|
@@ -5,9 +5,13 @@ import com.lframework.starter.web.core.annotations.security.HasPermission; |
|
5
|
5
|
import com.lframework.starter.web.core.controller.DefaultBaseController;
|
|
6
|
6
|
import com.lframework.starter.web.core.utils.JsonUtil;
|
|
7
|
7
|
import com.lframework.xingyun.sc.bo.order.change.OrderChangeRecordBo;
|
|
|
8
|
+import com.lframework.xingyun.sc.entity.ContractDistributorStandard;
|
|
8
|
9
|
import com.lframework.xingyun.sc.entity.OrderInfoChangeRecord;
|
|
|
10
|
+import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
|
|
9
|
11
|
import com.lframework.xingyun.sc.entity.PurchaseOrderLine;
|
|
10
|
12
|
import com.lframework.xingyun.sc.enums.OrderSpecChangeStatus;
|
|
|
13
|
+import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService;
|
|
|
14
|
+import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
|
|
11
|
15
|
import com.lframework.xingyun.sc.utils.ExcelUtil;
|
|
12
|
16
|
import com.lframework.xingyun.sc.utils.LatexFormulaExcelExporterUtil;
|
|
13
|
17
|
import com.lframework.xingyun.sc.utils.ResponseUtil;
|
|
...
|
...
|
@@ -60,6 +64,10 @@ public class OrderChangeRecordController extends DefaultBaseController { |
|
60
|
64
|
|
|
61
|
65
|
@Resource
|
|
62
|
66
|
private OrderChangeRecordService orderChangeRecordService;
|
|
|
67
|
+ @Resource
|
|
|
68
|
+ private PurchaseOrderInfoService purchaseOrderInfoService;
|
|
|
69
|
+ @Resource
|
|
|
70
|
+ private ContractDistributorStandardService contractDistributorStandardService;
|
|
63
|
71
|
|
|
64
|
72
|
/**
|
|
65
|
73
|
* 查询列表
|
|
...
|
...
|
@@ -90,6 +98,16 @@ public class OrderChangeRecordController extends DefaultBaseController { |
|
90
|
98
|
throw new DefaultClientException("订货单变更记录不存在!");
|
|
91
|
99
|
}
|
|
92
|
100
|
OrderChangeRecordBo result = new OrderChangeRecordBo(data);
|
|
|
101
|
+ PurchaseOrderInfo purchaseOrderInfo = purchaseOrderInfoService.findById(result.getOrderId());
|
|
|
102
|
+ if (purchaseOrderInfo != null) {
|
|
|
103
|
+ String contractId = purchaseOrderInfo.getContractId();
|
|
|
104
|
+ if (StringUtils.isNotEmpty(contractId)) {
|
|
|
105
|
+ ContractDistributorStandard contractDistributorStandard = contractDistributorStandardService.findById(contractId);
|
|
|
106
|
+ if (contractDistributorStandard != null) {
|
|
|
107
|
+ result.setContractType(contractDistributorStandard.getType());
|
|
|
108
|
+ }
|
|
|
109
|
+ }
|
|
|
110
|
+ }
|
|
93
|
111
|
|
|
94
|
112
|
return InvokeResultBuilder.success(result);
|
|
95
|
113
|
}
|
|
...
|
...
|
@@ -182,20 +200,12 @@ public class OrderChangeRecordController extends DefaultBaseController { |
|
182
|
200
|
|
|
183
|
201
|
// 过滤需要显示的变更前记录(DELETE 或 UPDATE 且有变化)
|
|
184
|
202
|
List<PurchaseOrderLine> beforeLines = beforeChangeSpecList.stream()
|
|
185
|
|
- .filter(line -> "DELETE".equals(line.getType()) ||
|
|
186
|
|
- ("UPDATE".equals(line.getType()) &&
|
|
187
|
|
- (line.getBrandChange() || line.getLengthChange() || line.getWidthChange() ||
|
|
188
|
|
- line.getThicknessChange() || line.getStatusChange() ||
|
|
189
|
|
- line.getQuantityChange() || line.getSalesPriceChange())))
|
|
|
203
|
+ .filter(this::shouldPrintChangeLine)
|
|
190
|
204
|
.collect(Collectors.toList());
|
|
191
|
205
|
|
|
192
|
206
|
// 过滤需要显示的变更后记录(ADD 或 UPDATE 且有变化)
|
|
193
|
207
|
List<PurchaseOrderLine> afterLines = afterChangeSpecList.stream()
|
|
194
|
|
- .filter(line -> "ADD".equals(line.getType()) ||
|
|
195
|
|
- ("UPDATE".equals(line.getType()) &&
|
|
196
|
|
- (line.getBrandChange() || line.getLengthChange() || line.getWidthChange() ||
|
|
197
|
|
- line.getThicknessChange() || line.getStatusChange() ||
|
|
198
|
|
- line.getQuantityChange() || line.getSalesPriceChange())))
|
|
|
208
|
+ .filter(this::shouldPrintChangeLine)
|
|
199
|
209
|
.collect(Collectors.toList());
|
|
200
|
210
|
|
|
201
|
211
|
// ========== 填充变更前区域(起始行:5)==========
|
|
...
|
...
|
@@ -209,44 +219,7 @@ public class OrderChangeRecordController extends DefaultBaseController { |
|
209
|
219
|
PurchaseOrderLine line = i < beforeLines.size() ? beforeLines.get(i) : null;
|
|
210
|
220
|
int rowIdx = beforeStartRow + i;
|
|
211
|
221
|
if (line != null) {
|
|
212
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 0, line.getIndustry());
|
|
213
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 1, line.getQuality());
|
|
214
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 2, line.getBrand());
|
|
215
|
|
- List<LatexFormulaExcelExporterUtil.FormulaComponent> formulaComponentList = new ArrayList<>(3);
|
|
216
|
|
- if (line.getThickness() != null) {
|
|
217
|
|
- LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent();
|
|
218
|
|
- formulaComponent.setBase(line.getThickness());
|
|
219
|
|
- formulaComponent.setSup(line.getThicknessTolPos());
|
|
220
|
|
- formulaComponent.setSub(line.getThicknessTolNeg());
|
|
221
|
|
- formulaComponentList.add(formulaComponent);
|
|
222
|
|
- }
|
|
223
|
|
-
|
|
224
|
|
- if (line.getWidth() != null) {
|
|
225
|
|
- LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent();
|
|
226
|
|
- formulaComponent.setBase(line.getWidth());
|
|
227
|
|
- formulaComponent.setSup(line.getWidthTolPos());
|
|
228
|
|
- formulaComponent.setSub(line.getWidthTolNeg());
|
|
229
|
|
- formulaComponentList.add(formulaComponent);
|
|
230
|
|
- }
|
|
231
|
|
-
|
|
232
|
|
- if (line.getLength() != null) {
|
|
233
|
|
- LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent();
|
|
234
|
|
- formulaComponent.setBase(line.getLength());
|
|
235
|
|
- formulaComponent.setSup(line.getLengthTolPos());
|
|
236
|
|
- formulaComponent.setSub(line.getLengthTolNeg());
|
|
237
|
|
- formulaComponentList.add(formulaComponent);
|
|
238
|
|
- }
|
|
239
|
|
-
|
|
240
|
|
- String latex = LatexFormulaExcelExporterUtil.convertToLatex(formulaComponentList);
|
|
241
|
|
- if (StringUtils.isNotBlank(latex)) {
|
|
242
|
|
- LatexFormulaExcelExporterUtil.insertLatexImageToCell(workbook, sheet, latex, rowIdx, 3, 1, 1);
|
|
243
|
|
- }
|
|
244
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 4, line.getStatus());
|
|
245
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 5, line.getQuantity());
|
|
246
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 6, line.getSalesPrice());
|
|
247
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 7,
|
|
248
|
|
- line.getDeliveryDate() == null ? "" : line.getDeliveryDate().format(dateFormatter));
|
|
249
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 8, line.getAssessmentExceedsAgreement());
|
|
|
222
|
+ fillChangePrintRow(workbook, sheet, rowIdx, line, dateFormatter);
|
|
250
|
223
|
} else {
|
|
251
|
224
|
for (int col = 0; col <= 8; col++) {
|
|
252
|
225
|
ExcelUtil.setCellValue(sheet, rowIdx, col, "");
|
|
...
|
...
|
@@ -264,44 +237,7 @@ public class OrderChangeRecordController extends DefaultBaseController { |
|
264
|
237
|
PurchaseOrderLine line = i < afterLines.size() ? afterLines.get(i) : null;
|
|
265
|
238
|
int rowIdx = afterStartRow + i;
|
|
266
|
239
|
if (line != null) {
|
|
267
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 0, line.getIndustry());
|
|
268
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 1, line.getQuality());
|
|
269
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 2, line.getBrand());
|
|
270
|
|
- List<LatexFormulaExcelExporterUtil.FormulaComponent> formulaComponentList = new ArrayList<>(3);
|
|
271
|
|
- if (line.getThickness() != null) {
|
|
272
|
|
- LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent();
|
|
273
|
|
- formulaComponent.setBase(line.getThickness());
|
|
274
|
|
- formulaComponent.setSup(line.getThicknessTolPos());
|
|
275
|
|
- formulaComponent.setSub(line.getThicknessTolNeg());
|
|
276
|
|
- formulaComponentList.add(formulaComponent);
|
|
277
|
|
- }
|
|
278
|
|
-
|
|
279
|
|
- if (line.getWidth() != null) {
|
|
280
|
|
- LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent();
|
|
281
|
|
- formulaComponent.setBase(line.getWidth());
|
|
282
|
|
- formulaComponent.setSup(line.getWidthTolPos());
|
|
283
|
|
- formulaComponent.setSub(line.getWidthTolNeg());
|
|
284
|
|
- formulaComponentList.add(formulaComponent);
|
|
285
|
|
- }
|
|
286
|
|
-
|
|
287
|
|
- if (line.getLength() != null) {
|
|
288
|
|
- LatexFormulaExcelExporterUtil.FormulaComponent formulaComponent = new LatexFormulaExcelExporterUtil.FormulaComponent();
|
|
289
|
|
- formulaComponent.setBase(line.getLength());
|
|
290
|
|
- formulaComponent.setSup(line.getLengthTolPos());
|
|
291
|
|
- formulaComponent.setSub(line.getLengthTolNeg());
|
|
292
|
|
- formulaComponentList.add(formulaComponent);
|
|
293
|
|
- }
|
|
294
|
|
-
|
|
295
|
|
- String latex = LatexFormulaExcelExporterUtil.convertToLatex(formulaComponentList);
|
|
296
|
|
- if (StringUtils.isNotBlank(latex)) {
|
|
297
|
|
- LatexFormulaExcelExporterUtil.insertLatexImageToCell(workbook, sheet, latex, rowIdx, 3, 1, 1);
|
|
298
|
|
- }
|
|
299
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 4, line.getStatus());
|
|
300
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 5, line.getQuantity());
|
|
301
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 6, line.getSalesPrice());
|
|
302
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 7,
|
|
303
|
|
- line.getDeliveryDate() == null ? "" : line.getDeliveryDate().format(dateFormatter));
|
|
304
|
|
- ExcelUtil.setCellValue(sheet, rowIdx, 8, line.getAssessmentExceedsAgreement());
|
|
|
240
|
+ fillChangePrintRow(workbook, sheet, rowIdx, line, dateFormatter);
|
|
305
|
241
|
} else {
|
|
306
|
242
|
for (int col = 0; col <= 8; col++) {
|
|
307
|
243
|
ExcelUtil.setCellValue(sheet, rowIdx, col, "");
|
|
...
|
...
|
@@ -492,4 +428,96 @@ public class OrderChangeRecordController extends DefaultBaseController { |
|
492
|
428
|
target.setAssessmentExceedsAgreementChange(!Objects.equals(before.getAssessmentExceedsAgreement(), after.getAssessmentExceedsAgreement()));
|
|
493
|
429
|
}
|
|
494
|
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
|
+
|
|
495
|
523
|
} |
...
|
...
|
|