|
|
@ -287,6 +287,7 @@ public class PurchaseOrderController extends BaseController |
|
|
|
if("submit".equals(instanceType)){ |
|
|
|
// 使用状态-是
|
|
|
|
purchaseOrderVo.setUseStatus("1"); |
|
|
|
purchaseOrderService.addPurchaseOrderPayable(purchaseOrderVo); |
|
|
|
} |
|
|
|
// 作废
|
|
|
|
else if("cancel".equals(instanceType)){ |
|
|
@ -351,83 +352,83 @@ public class PurchaseOrderController extends BaseController |
|
|
|
return "操作成功!"; |
|
|
|
} |
|
|
|
|
|
|
|
@RequiresPermissions("purchase:purchaseOrder:export") |
|
|
|
@Log(title = "采购订单", businessType = BusinessType.EXPORT) |
|
|
|
@RequestMapping("/exportSelected/{purchaseOrderId}") |
|
|
|
@ResponseBody |
|
|
|
public void exportSelected(@PathVariable("purchaseOrderId") Long purchaseOrderId, HttpServletResponse response) throws IOException { |
|
|
|
// @RequiresPermissions("purchase:purchaseOrder:export")
|
|
|
|
// @Log(title = "采购订单", businessType = BusinessType.EXPORT)
|
|
|
|
// @RequestMapping("/exportSelected/{purchaseOrderId}")
|
|
|
|
// @ResponseBody
|
|
|
|
// public void exportSelected(@PathVariable("purchaseOrderId") Long purchaseOrderId, HttpServletResponse response) throws IOException {
|
|
|
|
////
|
|
|
|
//
|
|
|
|
|
|
|
|
System.out.println(purchaseOrderId); |
|
|
|
PurchaseOrder purchaseOrder = purchaseOrderService.selectPurchaseOrderById(purchaseOrderId); |
|
|
|
PurchaseOrderDto purchaseOrderDto = new PurchaseOrderDto(); |
|
|
|
BeanUtils.copyProperties(purchaseOrder,purchaseOrderDto); |
|
|
|
|
|
|
|
PurchaseMaterial purchaseMaterial = new PurchaseMaterial(); |
|
|
|
purchaseMaterial.setPurchaseOrderNumber(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
purchaseMaterial.setSupplierCode(purchaseOrder.getSupplierCode()); |
|
|
|
purchaseMaterial.setSupplierName(purchaseOrder.getSupplierName()); |
|
|
|
|
|
|
|
// 创建列合并工具类对象
|
|
|
|
// ExcelFillCellMergePrevColUtils mergePrevColUtils = new ExcelFillCellMergePrevColUtils();
|
|
|
|
List<PurchaseMaterial> purchaseMaterialList = purchaseMaterialService.selectPurchaseMaterialList(purchaseMaterial); |
|
|
|
List<PurchaseMaterialDto> purchaseMaterialDtoList = new ArrayList<>(); |
|
|
|
double total = 0.00; |
|
|
|
int number = 0; |
|
|
|
try { |
|
|
|
Iterator values= purchaseMaterialList.iterator(); |
|
|
|
while(values.hasNext()) { |
|
|
|
Object source = values.next(); |
|
|
|
PurchaseMaterialDto target = PurchaseMaterialDto.class.newInstance(); |
|
|
|
BeanUtils.copyProperties(source, target); |
|
|
|
// mergePrevColUtils.add(number+8,1,1);
|
|
|
|
// mergePrevColUtils.add(number+8,10,1);
|
|
|
|
target.setNumber(++number); |
|
|
|
purchaseMaterialDtoList.add(target); |
|
|
|
total = total + Double.parseDouble(target.getAmountMoney()); |
|
|
|
} |
|
|
|
}catch (Exception e) { |
|
|
|
log.error(">>>>>>异常<<<<<<", e); |
|
|
|
} |
|
|
|
System.out.println(purchaseMaterialDtoList); |
|
|
|
|
|
|
|
Map<Integer, Integer> colMap = new HashMap<>(); |
|
|
|
colMap.put(2, 3); |
|
|
|
colMap.put(11, 12); |
|
|
|
// response.setCharacterEncoding("utf-8");
|
|
|
|
// String fileName = URLEncoder.encode("采购订单", "UTF-8").replaceAll("\\+", "%20");
|
|
|
|
// response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
|
|
|
String templateFileName = "C:\\exportTemplates\\exportPurchaseOrder.xlsx"; |
|
|
|
try (ExcelWriter excelWriter = EasyExcel |
|
|
|
.write(response.getOutputStream(), PurchaseMaterialDto.class) |
|
|
|
.withTemplate(templateFileName) |
|
|
|
// .registerWriteHandler(mergePrevColUtils)
|
|
|
|
//样式注册
|
|
|
|
// .registerWriteHandler(horizontalCellStyleStrategyBuilder())
|
|
|
|
// .registerWriteHandler(new CustomRowWriteHandler(1))
|
|
|
|
// .registerWriteHandler(new CustomRowWriteHandler(10))
|
|
|
|
.registerWriteHandler(new CustomRowWriteCellHandler(colMap)) |
|
|
|
.build()) { |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); |
|
|
|
excelWriter.fill(purchaseMaterialDtoList, fillConfig, writeSheet); |
|
|
|
Map<String, Object> map = MapUtils.newHashMap(); |
|
|
|
// map.put("date", DateTimeFormatter.ofPattern("yyyy/MM/dd").format(LocalDateTime.now()));
|
|
|
|
map.put("supplierName", purchaseOrderDto.getSupplierName()); |
|
|
|
map.put("contactNumber", purchaseOrderDto.getContactNumber()); |
|
|
|
map.put("customerFax", purchaseOrderDto.getCustomerFax()); |
|
|
|
map.put("customerContact", purchaseOrderDto.getCustomerContact()); |
|
|
|
map.put("purchaseOrderNumber", purchaseOrderDto.getPurchaseOrderNumber()); |
|
|
|
map.put("paymentTerms", purchaseOrderDto.getPaymentTerms()); |
|
|
|
map.put("taxRate", purchaseOrderDto.getTaxRate()); |
|
|
|
map.put("approveName", purchaseOrderDto.getApproveName()); |
|
|
|
map.put("auditName", purchaseOrderDto.getAuditName()); |
|
|
|
map.put("purchaseCommander", purchaseOrderDto.getPurchaseCommander()); |
|
|
|
map.put("total", total); |
|
|
|
excelWriter.fill(map, writeSheet); |
|
|
|
// excelWriter.close();
|
|
|
|
} |
|
|
|
} |
|
|
|
// System.out.println(purchaseOrderId);
|
|
|
|
// PurchaseOrder purchaseOrder = purchaseOrderService.selectPurchaseOrderById(purchaseOrderId);
|
|
|
|
// PurchaseOrderDto purchaseOrderDto = new PurchaseOrderDto();
|
|
|
|
// BeanUtils.copyProperties(purchaseOrder,purchaseOrderDto);
|
|
|
|
//
|
|
|
|
// PurchaseMaterial purchaseMaterial = new PurchaseMaterial();
|
|
|
|
// purchaseMaterial.setPurchaseOrderNumber(purchaseOrder.getPurchaseOrderCode());
|
|
|
|
// purchaseMaterial.setSupplierCode(purchaseOrder.getSupplierCode());
|
|
|
|
// purchaseMaterial.setSupplierName(purchaseOrder.getSupplierName());
|
|
|
|
//
|
|
|
|
// // 创建列合并工具类对象
|
|
|
|
//// ExcelFillCellMergePrevColUtils mergePrevColUtils = new ExcelFillCellMergePrevColUtils();
|
|
|
|
// List<PurchaseMaterial> purchaseMaterialList = purchaseMaterialService.selectPurchaseMaterialList(purchaseMaterial);
|
|
|
|
// List<PurchaseMaterialDto> purchaseMaterialDtoList = new ArrayList<>();
|
|
|
|
// double total = 0.00;
|
|
|
|
// int number = 0;
|
|
|
|
// try {
|
|
|
|
// Iterator values= purchaseMaterialList.iterator();
|
|
|
|
// while(values.hasNext()) {
|
|
|
|
// Object source = values.next();
|
|
|
|
// PurchaseMaterialDto target = PurchaseMaterialDto.class.newInstance();
|
|
|
|
// BeanUtils.copyProperties(source, target);
|
|
|
|
//// mergePrevColUtils.add(number+8,1,1);
|
|
|
|
//// mergePrevColUtils.add(number+8,10,1);
|
|
|
|
// target.setNumber(++number);
|
|
|
|
// purchaseMaterialDtoList.add(target);
|
|
|
|
// total = total + Double.parseDouble(target.getAmountMoney());
|
|
|
|
// }
|
|
|
|
// }catch (Exception e) {
|
|
|
|
// log.error(">>>>>>异常<<<<<<", e);
|
|
|
|
// }
|
|
|
|
// System.out.println(purchaseMaterialDtoList);
|
|
|
|
//
|
|
|
|
// Map<Integer, Integer> colMap = new HashMap<>();
|
|
|
|
// colMap.put(2, 3);
|
|
|
|
// colMap.put(11, 12);
|
|
|
|
//// response.setCharacterEncoding("utf-8");
|
|
|
|
//// String fileName = URLEncoder.encode("采购订单", "UTF-8").replaceAll("\\+", "%20");
|
|
|
|
//// response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
|
|
|
// String templateFileName = "C:\\exportTemplates\\exportPurchaseOrder.xlsx";
|
|
|
|
// try (ExcelWriter excelWriter = EasyExcel
|
|
|
|
// .write(response.getOutputStream(), PurchaseMaterialDto.class)
|
|
|
|
// .withTemplate(templateFileName)
|
|
|
|
//// .registerWriteHandler(mergePrevColUtils)
|
|
|
|
// //样式注册
|
|
|
|
//// .registerWriteHandler(horizontalCellStyleStrategyBuilder())
|
|
|
|
//// .registerWriteHandler(new CustomRowWriteHandler(1))
|
|
|
|
//// .registerWriteHandler(new CustomRowWriteHandler(10))
|
|
|
|
// .registerWriteHandler(new CustomRowWriteCellHandler(colMap))
|
|
|
|
// .build()) {
|
|
|
|
// WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
|
|
|
// FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
|
|
|
|
// excelWriter.fill(purchaseMaterialDtoList, fillConfig, writeSheet);
|
|
|
|
// Map<String, Object> map = MapUtils.newHashMap();
|
|
|
|
//// map.put("date", DateTimeFormatter.ofPattern("yyyy/MM/dd").format(LocalDateTime.now()));
|
|
|
|
// map.put("supplierName", purchaseOrderDto.getSupplierName());
|
|
|
|
// map.put("contactNumber", purchaseOrderDto.getContactNumber());
|
|
|
|
// map.put("customerFax", purchaseOrderDto.getCustomerFax());
|
|
|
|
// map.put("customerContact", purchaseOrderDto.getCustomerContact());
|
|
|
|
// map.put("purchaseOrderNumber", purchaseOrderDto.getPurchaseOrderNumber());
|
|
|
|
// map.put("paymentTerms", purchaseOrderDto.getPaymentTerms());
|
|
|
|
// map.put("taxRate", purchaseOrderDto.getTaxRate());
|
|
|
|
// map.put("approveName", purchaseOrderDto.getApproveName());
|
|
|
|
// map.put("auditName", purchaseOrderDto.getAuditName());
|
|
|
|
// map.put("purchaseCommander", purchaseOrderDto.getPurchaseCommander());
|
|
|
|
// map.put("total", total);
|
|
|
|
// excelWriter.fill(map, writeSheet);
|
|
|
|
//// excelWriter.close();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
public HorizontalCellStyleStrategy horizontalCellStyleStrategyBuilder() { |
|
|
|
WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
|
|
|