Browse Source

单据导出调整

fenghaifu 1 tháng trước cách đây
mục cha
commit
79ec898e93

+ 1 - 1
srm-module-code/src/main/java/org/jeecg/modules/purCode/controller/PurInquiryFormController.java

@@ -820,7 +820,7 @@ public class PurInquiryFormController {
                 productList.forEach(p->noteList.add(p.getNotes()));
 
                 ExcelExportUtils.excelInsertRowNotes(getOutputStream(purInquiryForm.getBillCode()+".xlsx", response),
-                        tempFilePath, 16, noteList, 2, 4);
+                        tempFilePath, 14, noteList, 1, 4);
 
 
             } catch (Exception ex) {

+ 19 - 2
srm-module-code/src/main/java/org/jeecg/modules/purCode/controller/PurOrderController.java

@@ -847,14 +847,29 @@ public class PurOrderController {
      */
     @GetMapping(value = "/exportBillXls")
     public void exportBillXls(String id, HttpServletRequest request, HttpServletResponse response) throws IOException {
-        BaseTemplates templates = baseTemplatesService.getByTemplateType("采购订单");
+        BaseTemplates templatesN = baseTemplatesService.getByTemplateType("采购订单无折上折");
+        BaseTemplates templatesZ = baseTemplatesService.getByTemplateType("采购订单有折上折");
+
         PurOrder purOrder = purOrderService.getById(id);
         LambdaQueryWrapper<PurOrderProduct> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(PurOrderProduct::getHeadId, id);
         List<PurOrderProduct> productList = purOrderProductService.list(queryWrapper);
+        BaseTemplates templates = null;
+        if (purOrder.getDiscountHead() == null || purOrder.getDiscountHead().doubleValue()==0) {
+            templates = templatesN;
+        } else {
+            templates = templatesZ;
+        }
+
         if (templates != null) {
 
             try {
+                // 折上折
+                if (oConvertUtils.isNotEmpty(purOrder.getDiscountHead())) {
+                    purOrder.setDiscountHeadText((100-purOrder.getDiscountHead().doubleValue()) + "%");
+                    BigDecimal discountAmount = purOrder.getTotalAmount().subtract(purOrder.getDiscountAmount());
+                    purOrder.setDiscountHeadMoney(discountAmount.setScale(2));
+                }
 
                 String productionClass = purOrder.getProductionClass();
                 if (StringUtils.isNotBlank(productionClass)) {
@@ -873,6 +888,8 @@ public class PurOrderController {
                         purOrder.setContacts(classEnt.getContacts());
                         purOrder.setPhone(classEnt.getPhone());
                         purOrder.setEmail(classEnt.getEmail());
+                        purOrder.setPurchaseRegisterAddress(classEnt.getRegisterAddress());
+                        purOrder.setPurchaseOfficeAddress(classEnt.getAddress());
                     }
                 }
                 // 制单人信息
@@ -936,7 +953,7 @@ public class PurOrderController {
                 productList.forEach(p->noteList.add(p.getNotes()));
 
                 ExcelExportUtils.excelInsertRowNotes(getOutputStream(purOrder.getBillCode()+".xlsx", response),
-                        tempFilePath, 15, noteList, 1, 3);
+                        tempFilePath, 19, noteList, 1, 4);
 
             } catch (Exception ex) {
                 ex.printStackTrace();

+ 8 - 0
srm-module-code/src/main/java/org/jeecg/modules/purCode/entity/PurOrder.java

@@ -235,6 +235,10 @@ public class PurOrder implements Serializable {
     @TableField(exist = false)
     private String purchaseEmail;
     @TableField(exist = false)
+    private String purchaseRegisterAddress;
+    @TableField(exist = false)
+    private String purchaseOfficeAddress;
+    @TableField(exist = false)
     private String contacts;
     @TableField(exist = false)
     private String phone;
@@ -251,4 +255,8 @@ public class PurOrder implements Serializable {
     private String paymentTermsText;
     @TableField(exist = false)
     private String currencyText;
+    @TableField(exist = false)
+    private String discountHeadText;
+    @TableField(exist = false)
+    private BigDecimal discountHeadMoney;
 }

+ 35 - 29
srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleDeliveryController.java

@@ -763,13 +763,6 @@ public class SaleDeliveryController {
                 int rowNum = 1;
                 BigDecimal deliverMoney = BigDecimal.ZERO;
                 for (SaleDeliveryDetails o : deliveryDetailsList) {
-                    BigDecimal amount = o.getMoney() == null ? BigDecimal.ZERO : o.getMoney();
-                    deliverMoney = deliverMoney.add(amount);
-                    o.setRowNumber(rowNum++);
-                    if (o.getDeliveryTime() != null) {
-                        o.setDeliverDateText(DateUtils.date2Str(o.getDeliveryTime(), DateUtils.date_sdf.get()));
-                    }
-
                     BaseProductArchive findProduct = productArchiveList.stream().filter(e -> e.getId().equals(o.getProductId())).findFirst().orElse(null);
                     if (findProduct != null) {
                         o.setUnit(findProduct.getMeasurementUnit());
@@ -780,6 +773,15 @@ public class SaleDeliveryController {
                             }
                         }
                     }
+
+                    BigDecimal amount = o.getMoney() == null ? BigDecimal.ZERO : o.getMoney();
+                    deliverMoney = deliverMoney.add(amount);
+                    o.setRowNumber(rowNum++);
+                    if (o.getDeliveryTime() != null) {
+                        o.setDeliverDateText(DateUtils.date2Str(o.getDeliveryTime(), DateUtils.date_sdf.get()));
+                    }
+
+
                     SaleOrderProduct saleOrderProduct = saleOrderProductList.stream().filter(e -> e.getId().equals(o.getSourceId())).findFirst().orElse(null);
                     if (saleOrderProduct != null) {
                         if (oConvertUtils.isNotEmpty(saleOrderProduct.getDiscount()) && saleOrderProduct.getDiscount().intValue() != 0) {
@@ -811,7 +813,7 @@ public class SaleDeliveryController {
                 if (saleDelivery.getProject() != null) {
                     BaseProjectArchive projectArchive = baseProjectArchiveService.getById(saleDelivery.getProject());
                     if (projectArchive != null) {
-                        saleDelivery.setContactsNo(projectArchive.getName());
+                        saleDelivery.setProjectCode(projectArchive.getCode());
                     }
 
                 }
@@ -870,19 +872,17 @@ public class SaleDeliveryController {
                         saleDelivery.setEmail(classEnt.getEmail());
                     }
                 }
-                // 获取计产品档案
-                List<BaseProductArchive> productArchiveList = new ArrayList<>();
-                if (oConvertUtils.listIsNotEmpty(deliveryDetailsList)) {
-                    LambdaQueryWrapper<BaseProductArchive> productWrapper = new LambdaQueryWrapper<>();
-                    productWrapper.in(BaseProductArchive::getId, deliveryDetailsList.stream().map(SaleDeliveryDetails::getProductId).collect(Collectors.toList()));
-                    productArchiveList = baseProductArchiveService.list(productWrapper);
-                }
+                // 获取产品档案
+                LambdaQueryWrapper<BaseProductArchive> productWrapper = new LambdaQueryWrapper<>();
+                productWrapper.in(BaseProductArchive::getId, deliveryDetailsList.stream().map(SaleDeliveryDetails::getProductId).collect(Collectors.toList()));
+                List<BaseProductArchive> productArchiveList = baseProductArchiveService.list(productWrapper);
+
                 // 获取销售订单行
                 List<SaleOrderProduct> saleOrderProductList = new ArrayList<>();
                 if (oConvertUtils.listIsNotEmpty(deliveryDetailsList)) {
-                    LambdaQueryWrapper<SaleOrderProduct> productWrapper = new LambdaQueryWrapper<>();
-                    productWrapper.in(SaleOrderProduct::getId, deliveryDetailsList.stream().map(SaleDeliveryDetails::getSourceId).collect(Collectors.toList()));
-                    saleOrderProductList = saleOrderProductService.list(productWrapper);
+                    LambdaQueryWrapper<SaleOrderProduct> saleOrderProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                    saleOrderProductLambdaQueryWrapper.in(SaleOrderProduct::getId, deliveryDetailsList.stream().map(SaleDeliveryDetails::getSourceId).collect(Collectors.toList()));
+                    saleOrderProductList = saleOrderProductService.list(saleOrderProductLambdaQueryWrapper);
                 }
                 // 获取销售订单
                 if (oConvertUtils.isNotEmpty(saleDelivery.getSourceCode())) {
@@ -902,19 +902,17 @@ public class SaleDeliveryController {
                 saleDelivery.setPaymentTermsText(paymentTermsText);
                 List<DictModel> unitDictList = sysDictService.queryDictItemsByCode("measurement_unit");
 
+                // 过滤虚拟产品
+                deliveryDetailsList = deliveryDetailsList.stream().filter(e -> {
+                    return productArchiveList.stream().filter(p->p.getId().equals(e.getProductId()) && p.getVirtualProduct()==0).count()>0;
+                }).collect(Collectors.toList());
                 // 产品设置
                 int rowNum = 1;
                 BigDecimal deliverMoney = BigDecimal.ZERO;
                 for (SaleDeliveryDetails o : deliveryDetailsList) {
-                    BigDecimal amount = o.getMoney() == null ? BigDecimal.ZERO : o.getMoney();
-                    deliverMoney = deliverMoney.add(amount);
-                    o.setRowNumber(rowNum++);
-                    if (o.getDeliveryTime() != null) {
-                        o.setDeliverDateText(DateUtils.date2Str(o.getDeliveryTime(), DateUtils.date_sdf.get()));
-                    }
-
                     BaseProductArchive findProduct = productArchiveList.stream().filter(e -> e.getId().equals(o.getProductId())).findFirst().orElse(null);
                     if (findProduct != null) {
+
                         o.setUnit(findProduct.getMeasurementUnit());
                         if (findProduct.getMeasurementUnit() != null) {
                             DictModel findDict = unitDictList.stream().filter(d -> d.getValue().equals(findProduct.getMeasurementUnit())).findFirst().orElse(null);
@@ -923,6 +921,14 @@ public class SaleDeliveryController {
                             }
                         }
                     }
+
+                    BigDecimal amount = o.getMoney() == null ? BigDecimal.ZERO : o.getMoney();
+                    deliverMoney = deliverMoney.add(amount);
+                    o.setRowNumber(rowNum++);
+                    if (o.getDeliveryTime() != null) {
+                        o.setDeliverDateText(DateUtils.date2Str(o.getDeliveryTime(), DateUtils.date_sdf.get()));
+                    }
+
                     SaleOrderProduct saleOrderProduct = saleOrderProductList.stream().filter(e -> e.getId().equals(o.getSourceId())).findFirst().orElse(null);
                     if (saleOrderProduct != null) {
                         if (oConvertUtils.isNotEmpty(saleOrderProduct.getDiscount()) && saleOrderProduct.getDiscount().intValue() != 0) {
@@ -954,7 +960,7 @@ public class SaleDeliveryController {
                 if (saleDelivery.getProject() != null) {
                     BaseProjectArchive projectArchive = baseProjectArchiveService.getById(saleDelivery.getProject());
                     if (projectArchive != null) {
-                        saleDelivery.setContactsNo(projectArchive.getName());
+                        saleDelivery.setProjectCode(projectArchive.getCode());
                     }
 
                 }
@@ -993,12 +999,12 @@ public class SaleDeliveryController {
                 List<String> noteList = new ArrayList<>();
                 deliveryDetailsList.forEach(p -> noteList.add(p.getNotes()));
 
-                int startIndex = 18;
+                int startIndex = 17;
                 if ("随货发票".equals(templateName)) {
-                    startIndex = 19;
+                    startIndex = 18;
                 }
                 ExcelExportUtils.excelInsertRowNotes(getOutputStream(saleDelivery.getBillCode() + ".xlsx", response),
-                        tempFilePath, startIndex, noteList, 2, 4);
+                        tempFilePath, startIndex, noteList, 1, 4);
 
 
             } catch (Exception ex) {

+ 1 - 1
srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleInvoiceController.java

@@ -887,7 +887,7 @@ public class SaleInvoiceController {
                 productList.forEach(p->noteList.add(p.getNotes()));
 
                 ExcelExportUtils.excelInsertRowNotes(getOutputStream(saleInvoice.getInvoiceCode()+".xlsx", response),
-                        tempFilePath, 18, noteList, 1, 7);
+                        tempFilePath, 19, noteList, 1, 4);
 
 
 

+ 1 - 1
srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleOrderController.java

@@ -1095,7 +1095,7 @@ public class SaleOrderController {
                 productList.forEach(p -> noteList.add(p.getNotes()));
 
                 ExcelExportUtils.excelInsertRowNotes(getOutputStream(saleOrder.getBillCode() + ".xlsx", response),
-                        tempFilePath, 17, noteList, 1, 3);
+                        tempFilePath, 19, noteList, 1, 4);
 
 
             } catch (Exception ex) {

+ 34 - 2
srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleQuotationController.java

@@ -573,12 +573,44 @@ public class SaleQuotationController {
     @RequestMapping(value = "/exportXls")
     public void exportXls(HttpServletResponse response, SaleQuotation saleQuotation1) throws Exception {
 //        saleQuotation1.setId("1874732508546240513");
-        BaseTemplates templates = baseTemplatesService.getByTemplateType("销售报价单");
+
         SaleQuotation saleQuotation = saleQuotationService.getById(saleQuotation1.getId());
         List<SaleQuotationProduct> productList = saleQuotationProductService.selectByMainId(saleQuotation.getId());
+        boolean hasDiscount = false;
+        for (SaleQuotationProduct product : productList) {
+            double d = product.getDiscount()== null ? 0: product.getDiscount().doubleValue();
+            if (d != 0){
+                hasDiscount = true;
+                break;
+            }
+        }
+        BaseTemplates templates = null;
+        if (hasDiscount) {
+            templates = baseTemplatesService.getByTemplateType("销售报价单有折扣");
+        }else{
+            templates = baseTemplatesService.getByTemplateType("销售报价单无折扣");
+        }
         List<SaleQuotationShip> saleQuotationShipList = saleQuotationShipService.selectByMainId(saleQuotation.getId());
         if (templates != null) {
             try {
+                // 表头交期文字:天和周表示,10天以下用天,10天以上用周表示,不满一周的进位
+                int days = oConvertUtils.getInt(saleQuotation.getDeliveryDayHead(), 0);
+                if (days > 0){
+                    if (days>10){
+                        days = days / 7 + (days%7==0?0:1);
+                        if (days == 1){
+                            saleQuotation.setDeliveryDayHeadText(days + " week");
+                        }else{
+                            saleQuotation.setDeliveryDayHeadText(days + " weeks");
+                        }
+                    }else{
+                        if (days == 1){
+                            saleQuotation.setDeliveryDayHeadText(days + " day");
+                        }else{
+                            saleQuotation.setDeliveryDayHeadText(days + " days");
+                        }
+                    }
+                }
 
                 String productionClass = saleQuotation.getProductionClass();
                 if (StringUtils.isNotBlank(productionClass)) {
@@ -685,7 +717,7 @@ public class SaleQuotationController {
                 productList.forEach(p->noteList.add(p.getNotes()));
 
                 ExcelExportUtils.excelInsertRowNotes(getOutputStream(saleQuotation.getBillCode()+".xlsx", response),
-                        tempFilePath, 21, noteList, 1, 3);
+                        tempFilePath, 22, noteList, 1, 4);
 
             } catch (Exception ex) {
                 ex.printStackTrace();

+ 1 - 1
srm-module-code/src/main/java/org/jeecg/modules/saleCode/entity/SaleDelivery.java

@@ -213,7 +213,7 @@ public class SaleDelivery implements Serializable {
     private String salesEmail;
 
     @TableField(exist = false)
-    private String contactsNo;
+    private String projectCode;
     @TableField(exist = false)
     private String contacts;
     @TableField(exist = false)

+ 2 - 0
srm-module-code/src/main/java/org/jeecg/modules/saleCode/entity/SaleQuotation.java

@@ -239,4 +239,6 @@ public class SaleQuotation implements Serializable {
     private String currencyText;
     @TableField(exist = false)
     private String quotationPeriodText;
+    @TableField(exist = false)
+    private String deliveryDayHeadText;
 }