yuansh 3 ماه پیش
والد
کامیت
9401195570
39فایلهای تغییر یافته به همراه629 افزوده شده و 183 حذف شده
  1. 3 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysDepartMapper.java
  2. 6 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysDepartMapper.xml
  3. 4 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysDepartService.java
  4. 4 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java
  5. 5 0
      pom.xml
  6. 3 3
      srm-module-code/src/main/java/org/jeecg/modules/baseCode/entity/BaseShipArchive.java
  7. 1 1
      srm-module-code/src/main/java/org/jeecg/modules/purCode/controller/PurDeliveryNoteController.java
  8. 158 71
      srm-module-code/src/main/java/org/jeecg/modules/purCode/controller/PurInquiryFormController.java
  9. 3 0
      srm-module-code/src/main/java/org/jeecg/modules/purCode/entity/PurDeliveryNoteArrival.java
  10. 18 4
      srm-module-code/src/main/java/org/jeecg/modules/purCode/entity/PurInquiryForm.java
  11. 3 0
      srm-module-code/src/main/java/org/jeecg/modules/purCode/entity/PurInquiryFormProduct.java
  12. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/purCode/entity/PurOrder.java
  13. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/purCode/entity/PurOrderHis.java
  14. 1 0
      srm-module-code/src/main/java/org/jeecg/modules/purCode/mapper/xml/PurDeliveryNoteArrivalMapper.xml
  15. 1 0
      srm-module-code/src/main/java/org/jeecg/modules/purCode/mapper/xml/PurOrderProductMapper.xml
  16. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/purCode/vo/PurOrderAlert.java
  17. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/purCode/vo/PurOrderHisPage.java
  18. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/purCode/vo/PurOrderPage.java
  19. 21 1
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleInquiryFormController.java
  20. 146 92
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleQuotationController.java
  21. 4 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/entity/SaleDelivery.java
  22. 3 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/entity/SaleOrder.java
  23. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/entity/SaleOrderHis.java
  24. 28 4
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/entity/SaleQuotation.java
  25. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/entity/SaleQuotationHis.java
  26. 33 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/util/EasyExcelUtil.java
  27. 3 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/vo/SaleDeliveryAlert.java
  28. 4 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/vo/SaleDeliveryPage.java
  29. 1 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/vo/SaleInquiryFormAlert.java
  30. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/vo/SaleOrderAlert.java
  31. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/vo/SaleOrderHisPage.java
  32. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/vo/SaleOrderPage.java
  33. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/vo/SaleQuotationAlert.java
  34. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/vo/SaleQuotationHisPage.java
  35. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/vo/SaleQuotationPage.java
  36. 7 0
      srm-module-code/src/main/java/org/jeecg/modules/storeCode/entity/StorePurchaseIn.java
  37. 131 5
      srm-module-code/src/main/java/org/jeecg/modules/storeCode/service/impl/StorePurchaseInServiceImpl.java
  38. 6 0
      srm-module-code/src/main/java/org/jeecg/modules/storeCode/vo/StorePurchaseInAlert.java
  39. 6 0
      srm-module-code/src/main/java/org/jeecg/modules/storeCode/vo/StorePurchaseInPage.java

+ 3 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysDepartMapper.java

@@ -25,7 +25,9 @@ import java.util.List;
  * @Since:   2019-01-22
  */
 public interface SysDepartMapper extends BaseMapper<SysDepart> {
-	
+
+	public SysDepart queryDeptByCode(@Param("orgCode") String orgCode);
+
 	/**
 	 * 根据用户ID查询部门集合
      * @param userId 用户id

+ 6 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysDepartMapper.xml

@@ -62,7 +62,12 @@
     <select id="queryCompByOrgCode" resultType="org.jeecg.modules.system.entity.SysDepart">
 		select * from sys_depart where del_flag = '0' and org_category='1' and org_code= #{orgCode,jdbcType=VARCHAR}
 	</select>
-    
+
+    <!-- 根据Cod查询公司信息 -->
+    <select id="queryDeptByCode" resultType="org.jeecg.modules.system.entity.SysDepart">
+		select * from sys_depart where del_flag = '0' and org_code= #{orgCode,jdbcType=VARCHAR}
+	</select>
+
     <!--通过父级id和租户id查询部门-->
     <select id="queryBookDepTreeSync" resultType="org.jeecg.modules.system.entity.SysDepart">
         SELECT * FROM sys_depart

+ 4 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysDepartService.java

@@ -10,6 +10,7 @@ import org.jeecg.modules.system.model.DepartIdModel;
 import org.jeecg.modules.system.model.SysDepartTreeModel;
 import org.jeecg.modules.system.vo.SysDepartExportVo;
 import org.jeecg.modules.system.vo.lowapp.ExportDepartVo;
+import org.springframework.data.repository.query.Param;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
@@ -168,6 +169,9 @@ public interface ISysDepartService extends IService<SysDepart>{
      * @return
      */
     SysDepart queryCompByOrgCode(String orgCode);
+
+
+    public SysDepart queryDeptByCode(String orgCode);
     /**
      * 获取下级部门
      * @param pid

+ 4 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java

@@ -694,6 +694,10 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
 		}
 	}
 
+	@Override
+	public SysDepart queryDeptByCode(String orgCode){
+		return this.baseMapper.queryDeptByCode(orgCode);
+	}
 	@Override
 	public SysDepart queryCompByOrgCode(String orgCode) {
 		int length = YouBianCodeUtil.ZHANWEI_LENGTH;

+ 5 - 0
pom.xml

@@ -119,6 +119,11 @@
 	</repositories>
 
 	<dependencies>
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>easyexcel</artifactId>
+			<version>2.2.6</version>
+		</dependency>
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-test</artifactId>

+ 3 - 3
srm-module-code/src/main/java/org/jeecg/modules/baseCode/entity/BaseShipArchive.java

@@ -90,9 +90,9 @@ public class BaseShipArchive implements Serializable {
 //    @Dict(dictTable = "cusp_customer_profile", dicCode = "id", dicText = "name")
     private String relateCustomer;
 	/**造船日期*/
-	@Excel(name = "造船日期(ship date)", width = 20, format = "yyyy-MM-dd")
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
-    @DateTimeFormat(pattern="yyyy-MM-dd")
+	@Excel(name = "造船日期(ship date)", width = 20, format = "yyyy-MM")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM")
+    @DateTimeFormat(pattern="yyyy-MM")
     @ApiModelProperty(value = "造船日期")
     private Date shipDate;
 	/**备注*/

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

@@ -110,7 +110,7 @@ public class PurDeliveryNoteController {
 	  */
 	 @ApiOperation(value = "到货单弹框明细", notes = "到货单弹框明细")
 	 @GetMapping(value = "/purDeliveryNoteArrivalAlert")
-	 @PermissionData(pageComponent="purchase/arrivedGoods/ArriveGoodsList")
+//	 @PermissionData(pageComponent="purchase/arrivedGoods/ArriveGoodsList")
 	 public Result<IPage<PurDeliveryNoteAlert>> purDeliveryNoteArrivalAlert(PurDeliveryNoteAlert saleInquiryForm,
 																   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
 																   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,

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

@@ -1,10 +1,12 @@
 package org.jeecg.modules.purCode.controller;
 
+import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -14,16 +16,23 @@ import javax.servlet.http.HttpServletResponse;
 import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.enums.WriteDirectionEnum;
+import com.alibaba.excel.support.ExcelTypeEnum;
 import com.alibaba.excel.write.metadata.WriteSheet;
 import com.alibaba.excel.write.metadata.fill.FillConfig;
+import com.alibaba.excel.write.metadata.fill.FillWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.aspect.annotation.PermissionData;
 import org.jeecg.modules.baseCode.entity.BaseExchangeRate;
+import org.jeecg.modules.baseCode.entity.BaseProductClass;
 import org.jeecg.modules.baseCode.entity.BaseTemplates;
 import org.jeecg.modules.baseCode.service.IBaseExchangeRateService;
+import org.jeecg.modules.baseCode.service.IBaseProductClassService;
 import org.jeecg.modules.baseCode.service.IBaseTemplatesService;
 import org.jeecg.modules.baseCode.service.ISerialPatternService;
+import org.jeecg.modules.cuspCode.entity.CuspSupplierProfile;
+import org.jeecg.modules.cuspCode.service.ICuspSupplierProfileService;
 import org.jeecg.modules.purCode.service.IPurPurchaseQuotationProductService;
 import org.jeecg.modules.purCode.vo.SupplierQuotationDetails;
 import org.jeecg.modules.saleCode.vo.SaleInquiryFormAlert;
@@ -92,6 +101,10 @@ public class PurInquiryFormController {
     private IBaseTemplatesService baseTemplatesService;
     @Autowired
     private ISysUserService sysUserService;
+    @Autowired
+    private IBaseProductClassService baseProductClassService;
+    @Autowired
+    private ICuspSupplierProfileService cuspSupplierProfileService;
 
     @Value(value = "${jeecg.path.upload}")
     private String uploadpath;
@@ -108,7 +121,7 @@ public class PurInquiryFormController {
     //@AutoLog(value = "采购询价单-分页列表查询")
     @ApiOperation(value = "采购询价单-分页列表查询", notes = "采购询价单-分页列表查询")
     @GetMapping(value = "/list")
-    @PermissionData(pageComponent="purchase/purchaseInquiryForm/purchaseInquiryFormList")
+    @PermissionData(pageComponent = "purchase/purchaseInquiryForm/purchaseInquiryFormList")
     public Result<IPage<PurInquiryForm>> queryPageList(PurInquiryForm purInquiryForm,
                                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@@ -130,7 +143,7 @@ public class PurInquiryFormController {
      */
     @ApiOperation(value = "采购询价单-弹框分页列表查询", notes = "采购询价单-弹框分页列表查询")
     @GetMapping(value = "/alertPurInquiryList")
-    @PermissionData(pageComponent="purchase/purchaseInquiryForm/purchaseInquiryFormList")
+    @PermissionData(pageComponent = "purchase/purchaseInquiryForm/purchaseInquiryFormList")
     public Result<IPage<SaleInquiryFormAlert>> alertPurInquiryList(SaleInquiryFormAlert saleInquiryForm,
                                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@@ -229,7 +242,7 @@ public class PurInquiryFormController {
      * 报价选定,通过项目查询船明细
      */
     @GetMapping(value = "/getPurInquiryFormByProject")
-    public PurInquiryFormPage getShipByProject(@RequestParam(name = "projectId", required = true) String projectId,HttpServletRequest req) {
+    public PurInquiryFormPage getShipByProject(@RequestParam(name = "projectId", required = true) String projectId, HttpServletRequest req) {
 
         //采购询价单
         QueryWrapper<PurInquiryForm> queryWrapper = new QueryWrapper();
@@ -249,14 +262,14 @@ public class PurInquiryFormController {
             String headCodes = "";
 
             for (PurInquiryForm o : list) {
-            	String code = o.getBillCode();
-            	if(StringUtils.isBlank(headCodes)){
-					headCodes = code;
-				}else{
-					headCodes = headCodes+","+code;
-				}
-
-			}
+                String code = o.getBillCode();
+                if (StringUtils.isBlank(headCodes)) {
+                    headCodes = code;
+                } else {
+                    headCodes = headCodes + "," + code;
+                }
+
+            }
             for (PurInquiryForm o : list) {
 
                 List<PurInquiryFormProduct> productList = purInquiryFormProductService.selectByMainId(o.getId());
@@ -276,17 +289,17 @@ public class PurInquiryFormController {
 
             List<PurInquiryFormShip> purInquiryFormShipList = purInquiryFormShipService.selectByMainId(list.get(0).getId());
 //
-			SupplierQuotationDetails saleInquiryForm = new SupplierQuotationDetails();
-			saleInquiryForm.setQuotationProject(projectId);
-			saleInquiryForm.setStatus(0);
+            SupplierQuotationDetails saleInquiryForm = new SupplierQuotationDetails();
+            saleInquiryForm.setQuotationProject(projectId);
+            saleInquiryForm.setStatus(0);
 //
-			QueryWrapper<SupplierQuotationDetails> querySupplierQuotationDetails = QueryGenerator.initQueryWrapper(saleInquiryForm, req.getParameterMap());
-			Page<SupplierQuotationDetails> page2 = new Page<SupplierQuotationDetails>(-1, -1);
+            QueryWrapper<SupplierQuotationDetails> querySupplierQuotationDetails = QueryGenerator.initQueryWrapper(saleInquiryForm, req.getParameterMap());
+            Page<SupplierQuotationDetails> page2 = new Page<SupplierQuotationDetails>(-1, -1);
 
-			IPage<SupplierQuotationDetails> pageList = purPurchaseInquiryProductService.supplierQuotationDetails(page2, querySupplierQuotationDetails);
+            IPage<SupplierQuotationDetails> pageList = purPurchaseInquiryProductService.supplierQuotationDetails(page2, querySupplierQuotationDetails);
 
 
-            Map<String,BigDecimal> mapRate = new HashMap<>();
+            Map<String, BigDecimal> mapRate = new HashMap<>();
 
             for (SupplierQuotationDetails o : pageList.getRecords()) {
 
@@ -299,9 +312,9 @@ public class PurInquiryFormController {
 
                 if (StringUtils.isNotBlank(currency)) {
 
-                    if(mapRate.containsKey(currency)){
+                    if (mapRate.containsKey(currency)) {
                         rate = mapRate.get(currency);
-                    }else{
+                    } else {
                         rate = this.getRateByUsd(billDate, currency);
                         mapRate.put(currency, rate);
                     }
@@ -319,49 +332,49 @@ public class PurInquiryFormController {
 
             }
 
-            for(PurInquiryFormProduct a:purInquiryFormProductList){
+            for (PurInquiryFormProduct a : purInquiryFormProductList) {
 
-				String productId = a.getProductId();
+                String productId = a.getProductId();
                 BigDecimal taxPriceUsd = a.getTaxPriceUsd();
 
-				for(SupplierQuotationDetails o:pageList.getRecords()){
+                for (SupplierQuotationDetails o : pageList.getRecords()) {
 
-					String productIdo = o.getProductId();
-					if(productId.equals(productIdo)){
+                    String productIdo = o.getProductId();
+                    if (productId.equals(productIdo)) {
 
-					    BigDecimal getTaxPriceUsd = o.getTaxPriceUsd();
-					    if(taxPriceUsd !=null && taxPriceUsd.compareTo(getTaxPriceUsd) < 0){
-					        continue;
+                        BigDecimal getTaxPriceUsd = o.getTaxPriceUsd();
+                        if (taxPriceUsd != null && taxPriceUsd.compareTo(getTaxPriceUsd) < 0) {
+                            continue;
                         }
 
-						a.setSelectionSupplier(o.getQuotationSuppiler());
-						if(StringUtils.isNotBlank(o.getPaymentTerms())){
+                        a.setSelectionSupplier(o.getQuotationSuppiler());
+                        if (StringUtils.isNotBlank(o.getPaymentTerms())) {
 
                             a.setPaymentTerm(o.getPaymentTerms());
                         }
-						if(o.getQuotationValidity() != null){
+                        if (o.getQuotationValidity() != null) {
 
                             a.setQuotationValidity(o.getQuotationValidity());
                         }
-						a.setDelivery(o.getDelivery());
+                        a.setDelivery(o.getDelivery());
 //						a.setDeliveryTime(o.getHeadDeliveryTime());
-						a.setTaxPrice(o.getTaxPrice() == null ? BigDecimal.ZERO:o.getTaxPrice());
-						BigDecimal bd = BigDecimal.valueOf(a.getQuantity());
-						a.setTaxAmount(o.getTaxPrice() == null ? BigDecimal.ZERO:o.getTaxPrice().multiply(bd));
-						a.setSourceCode(o.getBillCode());
-						a.setSourceId(a.getId());
-						a.setSourceId2(o.getId());
-						a.setCurrency(o.getCurrency());
-						a.setDeliveryDayChild(o.getDeliveryDayChild());
-
-						a.setTaxPriceUsd(o.getTaxPriceUsd());
-						a.setTaxAmountUsd(o.getTaxAmountUsd());
-						a.setExchangeRateUsd(o.getExchangeRateUsd());
-					}
-
-				}
-
-			}
+                        a.setTaxPrice(o.getTaxPrice() == null ? BigDecimal.ZERO : o.getTaxPrice());
+                        BigDecimal bd = BigDecimal.valueOf(a.getQuantity());
+                        a.setTaxAmount(o.getTaxPrice() == null ? BigDecimal.ZERO : o.getTaxPrice().multiply(bd));
+                        a.setSourceCode(o.getBillCode());
+                        a.setSourceId(a.getId());
+                        a.setSourceId2(o.getId());
+                        a.setCurrency(o.getCurrency());
+                        a.setDeliveryDayChild(o.getDeliveryDayChild());
+
+                        a.setTaxPriceUsd(o.getTaxPriceUsd());
+                        a.setTaxAmountUsd(o.getTaxAmountUsd());
+                        a.setExchangeRateUsd(o.getExchangeRateUsd());
+                    }
+
+                }
+
+            }
 //
 
             page.setPurInquiryFormProductList(purInquiryFormProductList);
@@ -676,20 +689,36 @@ public class PurInquiryFormController {
         return Result.OK("文件导入失败!");
     }
 
+    /**
+     * 这是ExcelUtil.getOutputStream
+     * 这里就是将文件下载交给了浏览器
+     *
+     * @param
+     * @return
+     */
+    public OutputStream getOutputStream(String fileName, HttpServletResponse response) throws Exception {
+        // 这里文件名如果涉及中文一定要使用URL编码,否则会乱码
+        String exportFileName = URLEncoder.encode(fileName + ExcelTypeEnum.XLSX.getValue(), StandardCharsets.UTF_8.toString());
+        response.setContentType("application/force-download");
+        response.setHeader("Content-Disposition", "attachment;filename=" + exportFileName);
+        return response.getOutputStream();
+    }
+
+
     /**
      * 导出供应商询价单
+     *
      * @param request
      * @return
      */
-    @GetMapping(value = "/exportInquiryXls")
-    public void exportInquiryXls(String id, HttpServletRequest request, HttpServletResponse response) {
-
+    @GetMapping(value = "/exportXls")
+    public void exportInquiryXls(String id, HttpServletRequest request, HttpServletResponse response) throws IOException {
         BaseTemplates templates = baseTemplatesService.getByTemplateType("采购询价");
         PurInquiryForm purInquiryForm = purInquiryFormService.getById(id);
         LambdaQueryWrapper<PurInquiryFormProduct> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(PurInquiryFormProduct::getHeadId, id);
         List<PurInquiryFormProduct> productList = purInquiryFormProductService.list(queryWrapper);
-        if (templates != null){
+        if (templates != null) {
             response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
             response.setCharacterEncoding("utf-8");
             try {
@@ -698,25 +727,40 @@ public class PurInquiryFormController {
 
                 String filePath = uploadpath + templates.getTemplateFile();
 
-                try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(filePath).build()) {
-                    WriteSheet writeSheet = EasyExcel.writerSheet().build();
-                    // 这里注意 入参用了forceNewRow 代表在写入list的时候不管list下面有没有空行 都会创建一行,然后下面的数据往后移动。默认 是false,会直接使用下一行,如果没有则创建。
-                    // forceNewRow 如果设置了true,有个缺点 就是他会把所有的数据都放到内存了,所以慎用
-                    // 简单的说 如果你的模板有list,且list不是最后一行,下面还有数据需要填充 就必须设置 forceNewRow=true 但是这个就会把所有数据放到内存 会很耗内存
-                    // 如果数据量大 list不是最后一行 参照下一个
-                    FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
-                    excelWriter.fill(productList, fillConfig, writeSheet);
-                    Map<String, Object> map = BeanUtil.beanToMap(purInquiryForm);
-                    // 制单人信息
-                    SysUser sysUser = sysUserService.getUserByName(purInquiryForm.getCreateBy());
-                    map.put("purchaseman", sysUser.getRealname());
-                    map.put("purchasePhone", sysUser.getPhone());
-                    map.put("purchaseEmail", sysUser.getEmail());
-
-                    excelWriter.fill(map, writeSheet);
-                }
+                //填写合同单号和模板, getOutputStream浏览器下载方法写在下方
+                ExcelWriter excelWriter = EasyExcel.write(this.getOutputStream(fileName, response)).withTemplate(filePath).build();
+                WriteSheet writeSheet = EasyExcel.writerSheet(0, "sheet1").build();
+                String productionClass = purInquiryForm.getProductionClass();
+                if (StringUtils.isNotBlank(productionClass)) {
 
-            }catch (Exception ex){
+                    BaseProductClass classEnt = baseProductClassService.getById(productionClass);
+                    if (classEnt != null) {
+                        purInquiryForm.setProductionClass(classEnt.getName());
+                    }
+                }
+                String getInquirySuppiler = purInquiryForm.getInquirySuppiler();
+                if (StringUtils.isNotBlank(getInquirySuppiler)) {
+
+                    CuspSupplierProfile classEnt = cuspSupplierProfileService.getById(getInquirySuppiler);
+                    if (classEnt != null) {
+                        purInquiryForm.setInquirySuppiler(classEnt.getName());
+                        purInquiryForm.setContacts(classEnt.getContacts());
+                        purInquiryForm.setPhone(classEnt.getPhone());
+                        purInquiryForm.setEmail(classEnt.getEmail());
+                    }
+                }
+                // 制单人信息
+                SysUser sysUser = sysUserService.getUserByName(purInquiryForm.getCreateBy());
+                purInquiryForm.setPurchaseman(sysUser.getRealname());
+                purInquiryForm.setPurchasePhone(sysUser.getPhone());
+                purInquiryForm.setPurchaseEmail(sysUser.getEmail());
+                // 组合填充时,因为多组填充的数据量不确定,需要在多组填充完之后另起一行
+                FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.VERTICAL).forceNewRow(Boolean.TRUE).build();
+                excelWriter.fill(new FillWrapper(productList), fillConfig, writeSheet);
+                excelWriter.fill(purInquiryForm, writeSheet);
+                excelWriter.finish();
+
+            } catch (Exception ex) {
                 ex.printStackTrace();
             }
 
@@ -724,5 +768,48 @@ public class PurInquiryFormController {
 
 
     }
+//    public void exportInquiryXls(String id, HttpServletRequest request, HttpServletResponse response) throws IOException {
+//        exportOrder(response,"1874709655918645249");
+//        id = "1874709655918645249";
+//        BaseTemplates templates = baseTemplatesService.getByTemplateType("采购询价");
+//        PurInquiryForm purInquiryForm = purInquiryFormService.getById(id);
+//        LambdaQueryWrapper<PurInquiryFormProduct> queryWrapper = new LambdaQueryWrapper<>();
+//        queryWrapper.eq(PurInquiryFormProduct::getHeadId, id);
+//        List<PurInquiryFormProduct> productList = purInquiryFormProductService.list(queryWrapper);
+//        if (templates != null){
+//            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+//            response.setCharacterEncoding("utf-8");
+//            try {
+//                String fileName = URLEncoder.encode("采购询价单" + purInquiryForm.getBillCode(), "UTF-8").replaceAll("\\+", "%20");
+//                response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
+//
+//                String filePath = uploadpath + templates.getTemplateFile();
+//
+//                try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(filePath).build()) {
+//                    WriteSheet writeSheet = EasyExcel.writerSheet().build();
+//                    // 这里注意 入参用了forceNewRow 代表在写入list的时候不管list下面有没有空行 都会创建一行,然后下面的数据往后移动。默认 是false,会直接使用下一行,如果没有则创建。
+//                    // forceNewRow 如果设置了true,有个缺点 就是他会把所有的数据都放到内存了,所以慎用
+//                    // 简单的说 如果你的模板有list,且list不是最后一行,下面还有数据需要填充 就必须设置 forceNewRow=true 但是这个就会把所有数据放到内存 会很耗内存
+//                    // 如果数据量大 list不是最后一行 参照下一个
+//                    FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
+//                    excelWriter.fill(productList, fillConfig, writeSheet);
+//                    Map<String, Object> map = BeanUtil.beanToMap(purInquiryForm);
+//                    // 制单人信息
+//                    SysUser sysUser = sysUserService.getUserByName(purInquiryForm.getCreateBy());
+//                    map.put("purchaseman", sysUser.getRealname());
+//                    map.put("purchasePhone", sysUser.getPhone());
+//                    map.put("purchaseEmail", sysUser.getEmail());
+//
+//                    excelWriter.fill(map, writeSheet);
+//                }
+//
+//            }catch (Exception ex){
+//                ex.printStackTrace();
+//            }
+//
+//        }
+//
+//
+//    }
 
 }

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

@@ -142,6 +142,9 @@ public class PurDeliveryNoteArrival implements Serializable {
 	@Excel(name = "已到货金额(arrival money)", width = 15)
     @ApiModelProperty(value = "已到货金额(arrival money)")
     private java.math.BigDecimal arrivalMoney;
+
+	//采购入库单已参照数量
+    private java.math.BigDecimal inQuantity;
 	/**数量(quantity)*/
 	@Excel(name = "数量(quantity)", width = 15)
     @ApiModelProperty(value = "数量(quantity)")

+ 18 - 4
srm-module-code/src/main/java/org/jeecg/modules/purCode/entity/PurInquiryForm.java

@@ -2,11 +2,10 @@ package org.jeecg.modules.purCode.entity;
 
 import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
 import java.util.Date;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableLogic;
+
+import com.baomidou.mybatisplus.annotation.*;
 import org.jeecg.common.constant.ProvinceCityArea;
 import org.jeecg.common.util.SpringContextUtils;
 import lombok.Data;
@@ -169,4 +168,19 @@ public class PurInquiryForm implements Serializable {
     private String sourceCode;
     //来源销售询价单文件
     private String saleAttachs;
+
+
+    //导出字段使用
+    @TableField(exist = false)
+    private String purchaseman;
+    @TableField(exist = false)
+    private String purchasePhone;
+    @TableField(exist = false)
+    private String purchaseEmail;
+    @TableField(exist = false)
+    private String contacts;
+    @TableField(exist = false)
+    private String phone;
+    @TableField(exist = false)
+    private String email;
 }

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

@@ -174,4 +174,7 @@ public class PurInquiryFormProduct implements Serializable {
     @TableField(exist = false)
     private java.math.BigDecimal exchangeRateUsd;
 
+    @TableField(exist = false)
+    private Integer rowNumber;
+
 }

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

@@ -47,6 +47,8 @@ public class PurOrder implements Serializable {
     private String sysOrgCode;
     //组织  上海/香港
     private String organize;
+    //协议条款
+    private String agreementTerms;
 
 	/**创建时间*/
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

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

@@ -51,6 +51,8 @@ public class PurOrderHis implements Serializable {
     private String sysOrgCode;
     //组织  上海/香港
     private String organize;
+    //协议条款
+    private String agreementTerms;
 
 	/**创建时间*/
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

+ 1 - 0
srm-module-code/src/main/java/org/jeecg/modules/purCode/mapper/xml/PurDeliveryNoteArrivalMapper.xml

@@ -48,6 +48,7 @@
 
               where a.del_flag = 0
                 and a.submit = 1
+                and b.quantity > IFNULL(b.in_quantity,0)
                 and a.close = 0
                 and b.del_flag = 0
                 and IFNULL(c.virtual_product,0) = 0

+ 1 - 0
srm-module-code/src/main/java/org/jeecg/modules/purCode/mapper/xml/PurOrderProductMapper.xml

@@ -48,6 +48,7 @@
 
 		where a.del_flag = 0
 		  and a.status = 1
+		  and a.submit = 1
 		  and b.del_flag = 0
 			) a
 			${ew.customSqlSegment}

+ 2 - 0
srm-module-code/src/main/java/org/jeecg/modules/purCode/vo/PurOrderAlert.java

@@ -35,6 +35,8 @@ public class PurOrderAlert implements Serializable {
     private String sysOrgCode;
     //组织  上海/香港
     private String organize;
+    //协议条款
+    private String agreementTerms;
 
 	/**创建时间*/
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

+ 2 - 0
srm-module-code/src/main/java/org/jeecg/modules/purCode/vo/PurOrderHisPage.java

@@ -50,6 +50,8 @@ public class PurOrderHisPage {
     private String sysOrgCode;
 	//组织  上海/香港
 	private String organize;
+	//协议条款
+	private String agreementTerms;
 
 	/**创建时间*/
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

+ 2 - 0
srm-module-code/src/main/java/org/jeecg/modules/purCode/vo/PurOrderPage.java

@@ -38,6 +38,8 @@ public class PurOrderPage {
     private String sysOrgCode;
 	//组织  上海/香港
 	private String organize;
+	//协议条款
+	private String agreementTerms;
 
 	/**确认人*/
 	@ApiModelProperty(value = "确认人")

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

@@ -19,6 +19,8 @@ import org.jeecg.modules.saleCode.entity.SaleInquiryForm;
 import org.jeecg.modules.saleCode.entity.SaleOrder;
 import org.jeecg.modules.saleCode.vo.SaleInquiryFormAlert;
 import org.jeecg.modules.saleCode.vo.SaleInquiryFormPage;
+import org.jeecg.modules.system.entity.SysDepart;
+import org.jeecg.modules.system.service.ISysDepartService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -71,6 +73,8 @@ public class SaleInquiryFormController {
     private ISerialPatternService serialPatternService;
     @Autowired
     private IPurInquiryFormService purInquiryFormService;
+    @Autowired
+    private ISysDepartService sysDepartService;
 
     /**
      * 分页列表查询
@@ -106,13 +110,29 @@ public class SaleInquiryFormController {
      */
     @ApiOperation(value = "销售询价单-弹框分页列表查询", notes = "销售询价单-弹框分页列表查询")
     @GetMapping(value = "/alertSaleInquiryList")
-    @PermissionData(pageComponent="saleCode/saleInquiryForm/SaleInquiryFormList")
+//    @PermissionData(pageComponent="saleCode/saleInquiryForm/SaleInquiryFormList")
     public Result<IPage<SaleInquiryFormAlert>> alertSaleInquiryList(SaleInquiryFormAlert saleInquiryForm,
                                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                     HttpServletRequest req) {
+
+
+
+        LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
+        if(!sysUser.getUsername().equals("admin")){
+
+            String orgCode = sysUser.getOrgCode();
+            if(StringUtils.isNotBlank(orgCode)){
+                SysDepart dept = sysDepartService.queryDeptByCode(orgCode);
+                if(dept != null){
+                    saleInquiryForm.setInquiryTeam(dept.getId());
+                }
+            }
+        }
+
         QueryWrapper<SaleInquiryFormAlert> queryWrapper = QueryGenerator.initQueryWrapper(saleInquiryForm, req.getParameterMap());
         Page<SaleInquiryFormAlert> page = new Page<SaleInquiryFormAlert>(pageNo, pageSize);
+
         IPage<SaleInquiryFormAlert> pageList = saleInquiryFormService.alertSaleInquiryList(page, queryWrapper);
         return Result.OK(pageList);
     }

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

@@ -1,30 +1,42 @@
 package org.jeecg.modules.saleCode.controller;
 
-import java.io.IOException;
+import java.io.*;
+import java.math.BigDecimal;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.enums.WriteDirectionEnum;
+import com.alibaba.excel.support.ExcelTypeEnum;
 import com.alibaba.excel.write.metadata.WriteSheet;
 import com.alibaba.excel.write.metadata.fill.FillConfig;
+import com.alibaba.excel.write.metadata.fill.FillWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.aspect.annotation.PermissionData;
+import org.jeecg.modules.baseCode.entity.BaseProductClass;
 import org.jeecg.modules.baseCode.entity.BaseShipArchive;
 import org.jeecg.modules.baseCode.entity.BaseTemplates;
+import org.jeecg.modules.baseCode.service.IBaseProductClassService;
 import org.jeecg.modules.baseCode.service.IBaseShipArchiveService;
 import org.jeecg.modules.baseCode.service.IBaseTemplatesService;
 import org.jeecg.modules.baseCode.service.ISerialPatternService;
+import org.jeecg.modules.cuspCode.entity.CuspCustomerProfile;
+import org.jeecg.modules.cuspCode.entity.CuspSupplierProfile;
+import org.jeecg.modules.cuspCode.service.ICuspCustomerProfileService;
+import org.jeecg.modules.cuspCode.service.ICuspSupplierProfileService;
 import org.jeecg.modules.purCode.entity.PurInquiryForm;
 import org.jeecg.modules.purCode.entity.PurInquiryFormProduct;
 import org.jeecg.modules.saleCode.entity.*;
 import org.jeecg.modules.saleCode.service.*;
+import org.jeecg.modules.saleCode.util.EasyExcelUtil;
 import org.jeecg.modules.saleCode.vo.SaleQuotationAlert;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.service.ISysUserService;
@@ -43,6 +55,7 @@ import org.jeecg.modules.saleCode.vo.SaleQuotationPage;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.multipart.MultipartFile;
@@ -87,6 +100,10 @@ public class SaleQuotationController {
     @Autowired
     private ISysUserService sysUserService;
     @Autowired
+    private IBaseProductClassService baseProductClassService;
+    @Autowired
+    private ICuspCustomerProfileService cuspCustomerProfileService;
+    @Autowired
     private IBaseShipArchiveService baseShipArchiveService;
 
     @Value(value = "${jeecg.path.upload}")
@@ -103,7 +120,7 @@ public class SaleQuotationController {
     //@AutoLog(value = "销售报价单-分页列表查询")
     @ApiOperation(value = "销售报价单-分页列表查询", notes = "销售报价单-分页列表查询")
     @GetMapping(value = "/list")
-    @PermissionData(pageComponent="saleCode/quotation/quotation")
+    @PermissionData(pageComponent = "saleCode/quotation/quotation")
     public Result<IPage<SaleQuotation>> queryPageList(SaleQuotation saleQuotation,
                                                       @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                       @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@@ -116,6 +133,7 @@ public class SaleQuotationController {
 
     /**
      * 销售报价单弹框明细
+     *
      * @param saleInquiryForm
      * @param pageNo
      * @param pageSize
@@ -124,17 +142,18 @@ public class SaleQuotationController {
      */
     @ApiOperation(value = "销售报价单弹框明细", notes = "销售报价单弹框明细")
     @GetMapping(value = "/saleQuotationDetailsAlert")
-    @PermissionData(pageComponent="saleCode/quotation/quotation")
+    @PermissionData(pageComponent = "saleCode/quotation/quotation")
     public Result<IPage<SaleQuotationAlert>> saleQuotationDetailsAlert(SaleQuotationAlert saleInquiryForm,
-                                                                 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                                 HttpServletRequest req) {
+                                                                       @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                       @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                       HttpServletRequest req) {
 
         QueryWrapper<SaleQuotationAlert> queryWrapper = QueryGenerator.initQueryWrapper(saleInquiryForm, req.getParameterMap());
-        Page<SaleQuotationAlert> page = new Page<SaleQuotationAlert>(pageNo,pageSize);
+        Page<SaleQuotationAlert> page = new Page<SaleQuotationAlert>(pageNo, pageSize);
         IPage<SaleQuotationAlert> pageList = saleQuotationProductService.saleQuotationDetailsAlert(page, queryWrapper);
         return Result.OK(pageList);
     }
+
     /**
      * 添加
      *
@@ -223,10 +242,10 @@ public class SaleQuotationController {
         int newV = Integer.valueOf(version) + 1;
 
         List<SaleQuotationShipHis> saleQuotationShipHisList = new ArrayList<>();
-        if(saleQuotationPage.getSaleQuotationShipList() != null && saleQuotationPage.getSaleQuotationShipList().size() > 0){
+        if (saleQuotationPage.getSaleQuotationShipList() != null && saleQuotationPage.getSaleQuotationShipList().size() > 0) {
             for (SaleQuotationShip o : saleQuotationPage.getSaleQuotationShipList()) {
                 SaleQuotationShipHis his = new SaleQuotationShipHis();
-                BeanUtils.copyProperties(o,his);
+                BeanUtils.copyProperties(o, his);
                 his.setId(null);
                 his.setHisId(o.getId());
                 saleQuotationShipHisList.add(his);
@@ -235,11 +254,11 @@ public class SaleQuotationController {
         }
 
         List<SaleQuotationProductHis> saleQuotationProductList = new ArrayList<>();
-        if(saleQuotationPage.getSaleQuotationProductList() != null && saleQuotationPage.getSaleQuotationProductList().size() > 0){
+        if (saleQuotationPage.getSaleQuotationProductList() != null && saleQuotationPage.getSaleQuotationProductList().size() > 0) {
 
             for (SaleQuotationProduct o : saleQuotationPage.getSaleQuotationProductList()) {
                 SaleQuotationProductHis his = new SaleQuotationProductHis();
-                BeanUtils.copyProperties(o,his);
+                BeanUtils.copyProperties(o, his);
                 his.setId(null);
                 his.setHisId(o.getId());
                 saleQuotationProductList.add(his);
@@ -248,7 +267,7 @@ public class SaleQuotationController {
         }
 
         SaleQuotationHis saleQuotationHis = new SaleQuotationHis();
-        BeanUtils.copyProperties(saleQuotationPage,saleQuotationHis);
+        BeanUtils.copyProperties(saleQuotationPage, saleQuotationHis);
         saleQuotationHis.setId(null);
         saleQuotationHis.setHisId(saleQuotationPage.getId());
         saleQuotationHis.setVersion(version);
@@ -351,7 +370,7 @@ public class SaleQuotationController {
 
         SaleQuotation ent = new SaleQuotation();
         ent.setStatus(1);
-        LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         ent.setConfirmBy(sysUser.getUsername());
         ent.setConfirmTime(new Date());
         saleQuotationService.update(ent, queryWrapper);
@@ -400,10 +419,10 @@ public class SaleQuotationController {
             querySaleContract.eq("del_flag", "0");
 
             List<SaleContract> listSaleQuotation = saleContractService.list(querySaleContract);
-            if(listSaleQuotation.size() > 0){
+            if (listSaleQuotation.size() > 0) {
                 List<String> codeList = listSaleQuotation.stream().map(SaleContract::getBillCode).collect(Collectors.toList());
                 String codes = StringUtils.join(codeList.toArray(), ",");
-                sb.append("单号" + code).append("已被销售合同使用,请勿取消提交"+codes+";");
+                sb.append("单号" + code).append("已被销售合同使用,请勿取消提交" + codes + ";");
                 continue;
             }
 
@@ -412,10 +431,10 @@ public class SaleQuotationController {
             querySaleOrder.eq("del_flag", "0");
 
             List<SaleOrder> listSaleOrder = saleOrderService.list(querySaleOrder);
-            if(listSaleOrder.size() > 0){
+            if (listSaleOrder.size() > 0) {
                 List<String> codeList = listSaleOrder.stream().map(SaleOrder::getBillCode).collect(Collectors.toList());
                 String codes = StringUtils.join(codeList.toArray(), ",");
-                sb.append("单号" + code).append("已被销售订单使用,请勿取消提交"+codes+";");
+                sb.append("单号" + code).append("已被销售订单使用,请勿取消提交" + codes + ";");
                 continue;
             }
 
@@ -480,6 +499,113 @@ public class SaleQuotationController {
         return Result.OK(saleQuotationProductList);
     }
 
+    /**
+     * 这是ExcelUtil.getOutputStream
+     * 这里就是将文件下载交给了浏览器
+     *
+     * @param
+     * @return
+     */
+    public OutputStream getOutputStream(String fileName, HttpServletResponse response) throws Exception {
+        // 这里文件名如果涉及中文一定要使用URL编码,否则会乱码
+        String exportFileName = URLEncoder.encode(fileName + ExcelTypeEnum.XLSX.getValue(), StandardCharsets.UTF_8.toString());
+        response.setContentType("application/force-download");
+        response.setHeader("Content-Disposition", "attachment;filename=" + exportFileName);
+        return response.getOutputStream();
+    }
+
+    /**
+     * 导出excel
+     *
+     */
+    @RequiresPermissions("saleCode:sale_quotation:exportXls")
+    @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());
+        LambdaQueryWrapper<PurInquiryFormProduct> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(PurInquiryFormProduct::getHeadId, saleQuotation.getId());
+        List<SaleQuotationProduct> productList = saleQuotationProductService.selectByMainId(saleQuotation.getId());
+        List<SaleQuotationShip> saleQuotationShipList = saleQuotationShipService.selectByMainId(saleQuotation.getId());
+        if (templates != null) {
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+            response.setCharacterEncoding("utf-8");
+            try {
+                String fileName = URLEncoder.encode("销售报价单" + saleQuotation.getBillCode(), "UTF-8").replaceAll("\\+", "%20");
+                response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
+
+                String filePath = uploadpath + templates.getTemplateFile();
+
+                //填写合同单号和模板, getOutputStream浏览器下载方法写在下方
+                ExcelWriter excelWriter = EasyExcel.write(this.getOutputStream(fileName, response)).withTemplate(filePath).build();
+                WriteSheet writeSheet = EasyExcel.writerSheet(0, "sheet1").build();
+                String productionClass = saleQuotation.getProductionClass();
+                if (StringUtils.isNotBlank(productionClass)) {
+
+                    BaseProductClass classEnt = baseProductClassService.getById(productionClass);
+                    if (classEnt != null) {
+                        saleQuotation.setProductionClass(classEnt.getName());
+                    }
+                }
+                String getQuotationCustomer = saleQuotation.getQuotationCustomer();
+                if (StringUtils.isNotBlank(getQuotationCustomer)) {
+
+                    CuspCustomerProfile classEnt = cuspCustomerProfileService.getById(getQuotationCustomer);
+                    if (classEnt != null) {
+
+                        saleQuotation.setContacts(classEnt.getContacts());
+                        saleQuotation.setPhone(classEnt.getPhone());
+                        saleQuotation.setEmail(classEnt.getEmail());
+                    }
+                }
+                BigDecimal orderMoney = BigDecimal.ZERO;
+                for(SaleQuotationProduct o:productList){
+                    BigDecimal amount = o.getTaxAmount() == null ? BigDecimal.ZERO: o.getTaxAmount();
+                    orderMoney = orderMoney.add(amount);
+                }
+                saleQuotation.setOrderMoney(orderMoney);
+
+                String shipname = "";
+                String imo = "";
+
+                if(oConvertUtils.listIsNotEmpty(saleQuotationShipList)){
+
+                    shipname = saleQuotationShipList.stream().map(SaleQuotationShip::getShipName).distinct().collect(Collectors.joining());
+
+                    LambdaQueryWrapper<BaseShipArchive> shipArchiveLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                    shipArchiveLambdaQueryWrapper.in(BaseShipArchive::getId,saleQuotationShipList.stream().map(SaleQuotationShip::getShipId).collect(Collectors.joining()));
+                    List<BaseShipArchive> baseShipArchiveList = baseShipArchiveService.list(shipArchiveLambdaQueryWrapper);
+
+                    if(oConvertUtils.listIsNotEmpty(baseShipArchiveList)){
+                        imo = baseShipArchiveList.stream().map(BaseShipArchive::getImo).distinct().collect(Collectors.joining());
+                    }
+                }
+                saleQuotation.setShipName(shipname);
+                saleQuotation.setImo(imo);
+                saleQuotation.setContactsNo(saleQuotation.getQuotationProjectName());
+                if(productList.size() > 0){
+
+                    saleQuotation.setQualityGrade(productList.get(0).getQualityGrade());
+                }
+                // 制单人信息
+                SysUser sysUser = sysUserService.getUserByName(saleQuotation.getCreateBy());
+                saleQuotation.setSalesPhone(sysUser.getPhone());
+                saleQuotation.setSalesEmail(sysUser.getEmail());
+                // 组合填充时,因为多组填充的数据量不确定,需要在多组填充完之后另起一行
+                FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.VERTICAL).forceNewRow(Boolean.TRUE).build();
+                excelWriter.fill(new FillWrapper(productList), fillConfig, writeSheet);
+                excelWriter.fill(saleQuotation, writeSheet);
+                excelWriter.finish();
+
+            } catch (Exception ex) {
+                ex.printStackTrace();
+            }
+
+        }
+    }
+
+
     /**
      * 导出excel
      *
@@ -487,8 +613,8 @@ public class SaleQuotationController {
      * @param saleQuotation
      */
     @RequiresPermissions("saleCode:sale_quotation:exportXls")
-    @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(HttpServletRequest request, SaleQuotation saleQuotation) {
+    @RequestMapping(value = "/exportXls11111")
+    public ModelAndView exportXls1111(HttpServletRequest request, SaleQuotation saleQuotation) {
         // Step.1 组装查询条件查询数据
         QueryWrapper<SaleQuotation> queryWrapper = QueryGenerator.initQueryWrapper(saleQuotation, request.getParameterMap());
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
@@ -564,76 +690,4 @@ public class SaleQuotationController {
         return Result.OK("文件导入失败!");
     }
 
-    /**
-     * 导出销售报价单
-     * @param request
-     * @return
-     */
-    @GetMapping(value = "/exportQuotationXls")
-    public void exportQuotationXls(String id, HttpServletRequest request, HttpServletResponse response) {
-
-        BaseTemplates templates = baseTemplatesService.getByTemplateType("销售报价单");
-        SaleQuotation saleQuotation = saleQuotationService.getById(id);
-        LambdaQueryWrapper<SaleQuotationProduct> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(SaleQuotationProduct::getHeadId, id);
-        List<SaleQuotationProduct> productList = saleQuotationProductService.list(queryWrapper);
-
-        LambdaQueryWrapper<SaleQuotationShip> shipQueryWrapper = new LambdaQueryWrapper<>();
-        shipQueryWrapper.eq(SaleQuotationShip::getHeadId, id);
-        List<SaleQuotationShip> shipList = saleQuotationShipService.list(shipQueryWrapper);
-
-        List<BaseShipArchive> baseShipArchiveList = new ArrayList<>();
-        if (oConvertUtils.listIsNotEmpty(shipList)){
-            LambdaQueryWrapper<BaseShipArchive> shipArchiveLambdaQueryWrapper = new LambdaQueryWrapper<>();
-            shipArchiveLambdaQueryWrapper.in(BaseShipArchive::getId,shipList.stream().map(SaleQuotationShip::getShipId).collect(Collectors.toList()));
-            baseShipArchiveList = baseShipArchiveService.list(shipArchiveLambdaQueryWrapper);
-        }
-
-        if (templates != null){
-            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
-            response.setCharacterEncoding("utf-8");
-            try {
-                String fileName = URLEncoder.encode("销售报价单" + saleQuotation.getBillCode(), "UTF-8").replaceAll("\\+", "%20");
-                response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
-
-                String filePath = uploadpath + templates.getTemplateFile();
-
-                try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(filePath).build()) {
-                    WriteSheet writeSheet = EasyExcel.writerSheet().build();
-                    // 这里注意 入参用了forceNewRow 代表在写入list的时候不管list下面有没有空行 都会创建一行,然后下面的数据往后移动。默认 是false,会直接使用下一行,如果没有则创建。
-                    // forceNewRow 如果设置了true,有个缺点 就是他会把所有的数据都放到内存了,所以慎用
-                    // 简单的说 如果你的模板有list,且list不是最后一行,下面还有数据需要填充 就必须设置 forceNewRow=true 但是这个就会把所有数据放到内存 会很耗内存
-                    // 如果数据量大 list不是最后一行 参照下一个
-                    FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
-                    excelWriter.fill(productList, fillConfig, writeSheet);
-                    Map<String, Object> map = BeanUtil.beanToMap(saleQuotation);
-                    // 制单人信息
-                    SysUser sysUser = sysUserService.getUserByName(saleQuotation.getCreateBy());
-                    map.put("salesman", sysUser.getRealname());
-                    map.put("salesPhone", sysUser.getPhone());
-                    map.put("salesEmail", sysUser.getEmail());
-                    String shipname = "";
-                    String imo = "";
-                    if (oConvertUtils.listIsNotEmpty(shipList)){
-                        shipname = shipList.stream().map(SaleQuotationShip::getShipName).distinct().collect(Collectors.joining(","));
-
-                    }
-                    if (oConvertUtils.listIsNotEmpty(baseShipArchiveList)){
-                        imo = baseShipArchiveList.stream().map(BaseShipArchive::getImo).distinct().collect(Collectors.joining(","));
-                    }
-                    map.put("shipName", shipname);
-                    map.put("imo", imo);
-
-                    excelWriter.fill(map, writeSheet);
-                }
-
-            }catch (Exception ex){
-                ex.printStackTrace();
-            }
-
-        }
-
-
-    }
-
 }

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

@@ -196,4 +196,8 @@ public class SaleDelivery implements Serializable {
     private String otherFee;
     //是否已被运费参照
     private String carriageUsed;
+
+    @Excel(name = "包装详情(packingDetails)", width = 15)
+    @ApiModelProperty(value = "包装详情(packingDetails)")
+    private String packingDetails;
 }

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

@@ -241,6 +241,9 @@ public class SaleOrder implements Serializable {
     private String sourceCode;
     private String sourceCode2;
 
+    //协议条款
+    private String agreementTerms;
+
 
 //	/订单金额(order money)
     private java.math.BigDecimal orderMoney;

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

@@ -241,6 +241,8 @@ public class SaleOrderHis implements Serializable {
     private String version;
     private String sourceCode;
     private String sourceCode2;
+    //协议条款
+    private String agreementTerms;
     //	/订单金额(order money)
     private java.math.BigDecimal orderMoney;
     //    发货金额(delivery money)

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

@@ -4,10 +4,8 @@ import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.util.Date;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableLogic;
+
+import com.baomidou.mybatisplus.annotation.*;
 import org.jeecg.common.constant.ProvinceCityArea;
 import org.jeecg.common.util.SpringContextUtils;
 import lombok.Data;
@@ -46,6 +44,8 @@ public class SaleQuotation implements Serializable {
     @ApiModelProperty(value = "创建人")
     private String createBy;
     private String sysOrgCode;
+    //协议条款
+    private String agreementTerms;
 
 	/**创建时间*/
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@@ -196,4 +196,28 @@ public class SaleQuotation implements Serializable {
     private BigDecimal exchangeRate;
     @ApiModelProperty(value = "交期")
     private String deliveryDayHead;
+
+
+    //导出字段使用
+    @TableField(exist = false)
+    private String salesPhone;
+    @TableField(exist = false)
+    private String salesEmail;
+
+    @TableField(exist = false)
+    private String contactsNo;
+    @TableField(exist = false)
+    private String contacts;
+    @TableField(exist = false)
+    private String phone;
+    @TableField(exist = false)
+    private String email;
+    @TableField(exist = false)
+    private String shipName;
+    @TableField(exist = false)
+    private String imo;
+    @TableField(exist = false)
+    private String qualityGrade;
+    @TableField(exist = false)
+    private BigDecimal orderMoney;
 }

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

@@ -50,6 +50,8 @@ public class SaleQuotationHis implements Serializable {
     @ApiModelProperty(value = "创建人")
     private String createBy;
     private String sysOrgCode;
+    //协议条款
+    private String agreementTerms;
 
 	/**创建时间*/
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

+ 33 - 0
srm-module-code/src/main/java/org/jeecg/modules/saleCode/util/EasyExcelUtil.java

@@ -0,0 +1,33 @@
+package org.jeecg.modules.saleCode.util;
+
+import io.micrometer.core.instrument.util.StringUtils;
+import org.jeecg.common.util.DateUtils;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+public class EasyExcelUtil {
+
+
+    /**
+     * 初始化响应体
+     * @param response 请求头
+     * @param fileName 导出名称
+     */
+    public static void initResponse(HttpServletResponse response, String fileName) {
+        // 最终文件名:文件名_(截止yyyy-MM-dd)  --> 这块地方得根据你们自己项目做更改了
+        String finalFileName = fileName + DateUtils.formatTime();
+        // 设置content—type 响应类型
+        response.setContentType("application/vnd.ms-excel");
+        response.setCharacterEncoding("utf-8");
+        try {
+            // 这里URLEncoder.encode可以防止中文乱码
+            finalFileName = URLEncoder.encode(finalFileName, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        response.setHeader("Content-disposition", "attachment;filename=" + finalFileName + ".xlsx");
+    }
+
+}

+ 3 - 0
srm-module-code/src/main/java/org/jeecg/modules/saleCode/vo/SaleDeliveryAlert.java

@@ -279,4 +279,7 @@ public class SaleDeliveryAlert implements Serializable {
     private String otherFee;
     //是否已被运费参照
     private String carriageUsed;
+    @Excel(name = "包装详情(packingDetails)", width = 15)
+    @ApiModelProperty(value = "包装详情(packingDetails)")
+    private String packingDetails;
 }

+ 4 - 0
srm-module-code/src/main/java/org/jeecg/modules/saleCode/vo/SaleDeliveryPage.java

@@ -190,6 +190,10 @@ public class SaleDeliveryPage {
 	private String otherFee;
 	//是否已被运费参照
 	private String carriageUsed;
+	@Excel(name = "包装详情(packingDetails)", width = 15)
+	@ApiModelProperty(value = "包装详情(packingDetails)")
+	private String packingDetails;
+
 	@ExcelCollection(name="发货通知单 - 船明细")
 	@ApiModelProperty(value = "发货通知单 - 船明细")
 	private List<SaleDeliveryShip> saleDeliveryShipList;

+ 1 - 0
srm-module-code/src/main/java/org/jeecg/modules/saleCode/vo/SaleInquiryFormAlert.java

@@ -127,6 +127,7 @@ public class SaleInquiryFormAlert {
 	@ApiModelProperty(value = "采购询价组(procurement inquiry team)")
 	@Dict(dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
     private String inquiryTeam;
+
 	private String inquiryTeamName;
 	/**交期(delivery time)*/
 	@Excel(name = "主表交期(delivery time)", width = 20, format = "yyyy-MM-dd")

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

@@ -35,6 +35,8 @@ public class SaleOrderAlert implements Serializable {
     private String sysOrgCode;
     //组织  上海/香港
     private String organize;
+    //协议条款
+    private String agreementTerms;
 
 	/**创建时间*/
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

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

@@ -48,6 +48,8 @@ public class SaleOrderHisPage {
     private String sysOrgCode;
 	//组织  上海/香港
 	private String organize;
+	//协议条款
+	private String agreementTerms;
 
 	/**创建时间*/
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

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

@@ -44,6 +44,8 @@ public class SaleOrderPage {
     private String sysOrgCode;
 	//组织  上海/香港
 	private String organize;
+	//协议条款
+	private String agreementTerms;
 
 	/**创建时间*/
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

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

@@ -33,6 +33,8 @@ public class SaleQuotationAlert {
 	@ApiModelProperty(value = "创建人")
     private String createBy;
     private String sysOrgCode;
+	//协议条款
+	private String agreementTerms;
 
 	/**创建时间*/
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

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

@@ -47,6 +47,8 @@ public class SaleQuotationHisPage {
 	@ApiModelProperty(value = "创建人")
     private String createBy;
     private String sysOrgCode;
+	//协议条款
+	private String agreementTerms;
 
 	/**创建时间*/
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

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

@@ -35,6 +35,8 @@ public class SaleQuotationPage {
 	@ApiModelProperty(value = "创建人")
     private String createBy;
     private String sysOrgCode;
+	//协议条款
+	private String agreementTerms;
 
 	/**确认人*/
 	@ApiModelProperty(value = "确认人")

+ 7 - 0
srm-module-code/src/main/java/org/jeecg/modules/storeCode/entity/StorePurchaseIn.java

@@ -141,4 +141,11 @@ public class StorePurchaseIn implements Serializable {
     @ApiModelProperty(value = "1已处理 0未处理")
     @Dict(dicCode = "yes_or_no")
     private String hasDeal;
+
+    @Excel(name = "包装尺寸(Dimension)", width = 15)
+    private String dimension;
+    @Excel(name = "重量(Weight)", width = 15)
+    private String weight;
+    @Excel(name = "包装(Method)", width = 15)
+    private String method;
 }

+ 131 - 5
srm-module-code/src/main/java/org/jeecg/modules/storeCode/service/impl/StorePurchaseInServiceImpl.java

@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.exception.JeecgBootException;
+import org.jeecg.modules.purCode.entity.PurDeliveryNoteArrival;
+import org.jeecg.modules.purCode.mapper.PurDeliveryNoteArrivalMapper;
+import org.jeecg.modules.purCode.service.IPurDeliveryNoteArrivalService;
 import org.jeecg.modules.storeCode.entity.*;
 import org.jeecg.modules.storeCode.mapper.StorePurchaseInShipMapper;
 import org.jeecg.modules.storeCode.mapper.StorePurchaseInDetailsMapper;
@@ -39,9 +42,12 @@ public class StorePurchaseInServiceImpl extends ServiceImpl<StorePurchaseInMappe
     private StorePurchaseInShipMapper storePurchaseInShipMapper;
     @Autowired
     private StorePurchaseInDetailsMapper storePurchaseInDetailsMapper;
-
     @Autowired
     private IStoreOnhandService storeOnhandService;
+    @Autowired
+    private PurDeliveryNoteArrivalMapper purDeliveryNoteArrivalMapper;
+    @Autowired
+    private IPurDeliveryNoteArrivalService purDeliveryNoteArrivalService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -86,10 +92,34 @@ public class StorePurchaseInServiceImpl extends ServiceImpl<StorePurchaseInMappe
                 entity.setId(null);
                 entity.setHeadId(storePurchaseIn.getId());
                 storePurchaseInDetailsMapper.insert(entity);
+
+                String sourceId = entity.getSourceId();
+                if (StringUtils.isNotBlank(sourceId)) {
+
+                    BigDecimal stockInQuantity = entity.getStockInQuantity() == null ? BigDecimal.ZERO : entity.getStockInQuantity();//入库数量
+
+                    PurDeliveryNoteArrival arrival = purDeliveryNoteArrivalMapper.selectById(sourceId);
+                    if (arrival != null) {
+                        BigDecimal arrivalQuantity = arrival.getInQuantity() == null ? BigDecimal.ZERO : arrival.getInQuantity();//到货数量
+
+                        arrivalQuantity = arrivalQuantity.add(stockInQuantity);
+                        arrival.setInQuantity(arrivalQuantity);
+                        purDeliveryNoteArrivalMapper.updateById(arrival);
+                    }
+                }
+
             }
         }
     }
 
+    public static void main(String[] args) {
+
+        BigDecimal arrivalQuantity = new BigDecimal("-1");
+
+        System.out.println(arrivalQuantity.compareTo(BigDecimal.ZERO));
+    }
+
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void updateMain(StorePurchaseIn storePurchaseIn, List<StorePurchaseInShip> storePurchaseInShipList, List<StorePurchaseInDetails> storePurchaseInDetailsList) {
@@ -119,6 +149,32 @@ public class StorePurchaseInServiceImpl extends ServiceImpl<StorePurchaseInMappe
         storePurchaseIn.setHasDeal("0");
 //        }
 
+        List<StorePurchaseInDetails> list = storePurchaseInDetailsMapper.selectByMainId(storePurchaseIn.getId());
+        for(StorePurchaseInDetails entity:list){
+
+            String sourceId = entity.getSourceId();
+            if(StringUtils.isNotBlank(sourceId)){
+
+                BigDecimal stockInQuantity = entity.getStockInQuantity() == null ? BigDecimal.ZERO : entity.getStockInQuantity();//入库数量
+
+                PurDeliveryNoteArrival arrival =  purDeliveryNoteArrivalService.getById(sourceId);
+                if(arrival != null){
+                    BigDecimal arrivalQuantity = arrival.getInQuantity() == null ? BigDecimal.ZERO : arrival.getInQuantity();//到货数量
+
+                    arrivalQuantity = arrivalQuantity.subtract(stockInQuantity);
+
+                    if(arrivalQuantity.compareTo(BigDecimal.ZERO) < 1){
+                        arrival.setInQuantity(BigDecimal.ZERO);
+                    }else{
+
+                        arrival.setInQuantity(arrivalQuantity);
+                    }
+                    purDeliveryNoteArrivalService.updateById(arrival);
+                }
+            }
+
+        }
+
         storePurchaseInMapper.updateById(storePurchaseIn);
 
         //1.先删除子表数据
@@ -140,6 +196,23 @@ public class StorePurchaseInServiceImpl extends ServiceImpl<StorePurchaseInMappe
                 entity.setId(null);
                 entity.setHeadId(storePurchaseIn.getId());
                 storePurchaseInDetailsMapper.insert(entity);
+
+
+                String sourceId = entity.getSourceId();
+                if(StringUtils.isNotBlank(sourceId)){
+
+                    BigDecimal stockInQuantity = entity.getStockInQuantity() == null ? BigDecimal.ZERO : entity.getStockInQuantity();//入库数量
+
+                    PurDeliveryNoteArrival arrival =  purDeliveryNoteArrivalService.getById(sourceId);
+                    if(arrival != null){
+                        BigDecimal arrivalQuantity = arrival.getInQuantity() == null ? BigDecimal.ZERO : arrival.getInQuantity();//到货数量
+
+                        arrivalQuantity = arrivalQuantity.add(stockInQuantity);
+                        arrival.setInQuantity(arrivalQuantity);
+                        purDeliveryNoteArrivalService.updateById(arrival);
+                    }
+                }
+
             }
         }
     }
@@ -147,15 +220,68 @@ public class StorePurchaseInServiceImpl extends ServiceImpl<StorePurchaseInMappe
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void delMain(String id) {
+
+        List<StorePurchaseInDetails> list = storePurchaseInDetailsMapper.selectByMainId(id);
+        for(StorePurchaseInDetails entity:list){
+
+            String sourceId = entity.getSourceId();
+            if(StringUtils.isNotBlank(sourceId)){
+
+                BigDecimal stockInQuantity = entity.getStockInQuantity() == null ? BigDecimal.ZERO : entity.getStockInQuantity();//入库数量
+
+                PurDeliveryNoteArrival arrival =  purDeliveryNoteArrivalMapper.selectById(sourceId);
+                if(arrival != null){
+                    BigDecimal arrivalQuantity = arrival.getInQuantity() == null ? BigDecimal.ZERO : arrival.getInQuantity();//到货数量
+
+                    arrivalQuantity = arrivalQuantity.subtract(stockInQuantity);
+                    if(arrivalQuantity.compareTo(BigDecimal.ZERO) < 1){
+                        arrival.setInQuantity(BigDecimal.ZERO);
+                    }else{
+
+                        arrival.setInQuantity(arrivalQuantity);
+                    }
+                    purDeliveryNoteArrivalMapper.updateById(arrival);
+                }
+            }
+
+        }
+
         storePurchaseInShipMapper.deleteByMainId(id);
         storePurchaseInDetailsMapper.deleteByMainId(id);
         storePurchaseInMapper.deleteById(id);
+
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void delBatchMain(Collection<? extends Serializable> idList) {
         for (Serializable id : idList) {
+
+            List<StorePurchaseInDetails> list = storePurchaseInDetailsMapper.selectByMainId(id.toString());
+            for(StorePurchaseInDetails entity:list){
+
+                String sourceId = entity.getSourceId();
+                if(StringUtils.isNotBlank(sourceId)){
+
+                    BigDecimal stockInQuantity = entity.getStockInQuantity() == null ? BigDecimal.ZERO : entity.getStockInQuantity();//入库数量
+
+                    PurDeliveryNoteArrival arrival =  purDeliveryNoteArrivalMapper.selectById(sourceId);
+                    if(arrival != null){
+                        BigDecimal arrivalQuantity = arrival.getInQuantity() == null ? BigDecimal.ZERO : arrival.getInQuantity();//到货数量
+
+                        arrivalQuantity = arrivalQuantity.subtract(stockInQuantity);
+                        if(arrivalQuantity.compareTo(BigDecimal.ZERO) < 1){
+                            arrival.setInQuantity(BigDecimal.ZERO);
+                        }else{
+
+                            arrival.setInQuantity(arrivalQuantity);
+                        }
+                        purDeliveryNoteArrivalMapper.updateById(arrival);
+                    }
+                }
+
+            }
+
             storePurchaseInShipMapper.deleteByMainId(id.toString());
             storePurchaseInDetailsMapper.deleteByMainId(id.toString());
             storePurchaseInMapper.deleteById(id);
@@ -254,7 +380,7 @@ public class StorePurchaseInServiceImpl extends ServiceImpl<StorePurchaseInMappe
 
 //                return Result.error(result);
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             throw new JeecgBootException(e.getMessage());
 
 //            return Result.error(e.getMessage());
@@ -283,8 +409,8 @@ public class StorePurchaseInServiceImpl extends ServiceImpl<StorePurchaseInMappe
 
                     BigDecimal stockInQuantity = ent.getStockInQuantity();
 
-                    if(stockInQuantity == null || stockInQuantity.equals(BigDecimal.ZERO)){
-                        throw new JeecgBootException(o.getBillCode()+ "产品:" + ent.getProductCode() + "入库数量不能为空或为0!");
+                    if (stockInQuantity == null || stockInQuantity.equals(BigDecimal.ZERO)) {
+                        throw new JeecgBootException(o.getBillCode() + "产品:" + ent.getProductCode() + "入库数量不能为空或为0!");
                     }
 
                     StoreOnhand storeOnhand = new StoreOnhand();
@@ -386,7 +512,7 @@ public class StorePurchaseInServiceImpl extends ServiceImpl<StorePurchaseInMappe
 
 //                return Result.error(result);
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             throw new JeecgBootException(e.getMessage());
 
 //            return Result.error(e.getMessage());

+ 6 - 0
srm-module-code/src/main/java/org/jeecg/modules/storeCode/vo/StorePurchaseInAlert.java

@@ -138,6 +138,12 @@ public class StorePurchaseInAlert implements Serializable {
     @Dict(dicCode = "yes_or_no")
     private String hasDeal;
 
+    @Excel(name = "包装尺寸(Dimension)", width = 15)
+    private String dimension;
+    @Excel(name = "重量(Weight)", width = 15)
+    private String weight;
+    @Excel(name = "包装(Method)", width = 15)
+    private String method;
 
     /**到货日期(arrival date)*/
     @Excel(name = "到货日期(arrival date)", width = 15, format = "yyyy-MM-dd")

+ 6 - 0
srm-module-code/src/main/java/org/jeecg/modules/storeCode/vo/StorePurchaseInPage.java

@@ -134,6 +134,12 @@ public class StorePurchaseInPage {
 	@ApiModelProperty(value = "1已处理 0未处理")
 	private String hasDeal;
 
+	@Excel(name = "包装尺寸(Dimension)", width = 15)
+	private String dimension;
+	@Excel(name = "重量(Weight)", width = 15)
+	private String weight;
+	@Excel(name = "包装(Method)", width = 15)
+	private String method;
 	@ExcelCollection(name="入库单(采购/异常)子表- 船明细")
 	@ApiModelProperty(value = "入库单(采购/异常)子表- 船明细")
 	private List<StorePurchaseInShip> storePurchaseInShipList;