|  | @@ -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();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  }
 |