|
@@ -14,8 +14,11 @@ import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.common.entity.InOutBo;
|
|
|
import com.fjhx.common.enums.InOutType;
|
|
|
import com.fjhx.common.service.file.FtpFileService;
|
|
|
+import com.fjhx.common.service.file.impl.FtpFileServiceImpl;
|
|
|
+import com.fjhx.file.entity.FileInfoVo;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.item.entity.product.bo.ProductAnalysisBo;
|
|
|
+import com.fjhx.item.entity.product.bo.ProductExcelExportBo;
|
|
|
import com.fjhx.item.entity.product.dto.ProductInfoDto;
|
|
|
import com.fjhx.item.entity.product.dto.ProductInfoSelectDto;
|
|
|
import com.fjhx.item.entity.product.po.ProductAvailableRecord;
|
|
@@ -30,9 +33,11 @@ import com.fjhx.item.service.product.ProductClassifyService;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.item.service.product.ProductStockInfoService;
|
|
|
import com.fjhx.item.util.CodeEnum;
|
|
|
+import com.fjhx.item.util.excel.util.ExcelUtil;
|
|
|
import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
|
|
|
import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
|
|
|
import com.fjhx.tenant.service.dict.DictTenantDataService;
|
|
|
+import com.fjhx.tenant.utils.DictUtils;
|
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
import com.ruoyi.common.core.domain.BasePo;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
@@ -46,8 +51,11 @@ import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.File;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.net.MalformedURLException;
|
|
|
+import java.net.URL;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -750,4 +758,77 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
return baseMapper.getProductAnalysisPage(page, wrapper);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void excelExport(HttpServletResponse httpServletResponse, ProductInfoSelectDto dto) {
|
|
|
+ IWrapper<ProductInfo> wrapper = IWrapper.getWrapper();
|
|
|
+
|
|
|
+ Long companyId = SecurityUtils.getCompanyId();
|
|
|
+ if (!Objects.equals(companyId, 100L)) {
|
|
|
+ dto.setCompanyId(companyId);
|
|
|
+ }
|
|
|
+ wrapper.and(q1 -> q1.
|
|
|
+ and(q -> q.eq(ProductInfo::getDefinition, 1).eq(ProductInfo::getCompanyId, dto.getCompanyId()))
|
|
|
+ .or().eq(ProductInfo::getDefinition, 2)
|
|
|
+ );
|
|
|
+
|
|
|
+ List<ProductInfo> productInfoList = this.list(wrapper);
|
|
|
+
|
|
|
+ List<Long> pIds = productInfoList.stream().map(ProductInfo::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(pIds);
|
|
|
+
|
|
|
+ List<ProductExcelExportBo> productExcelExportBoList = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<String, String> frontLinesMap = DictUtils.getDictMap("front_lines");
|
|
|
+ Map<String, String> backLinesMap = DictUtils.getDictMap("back_lines");
|
|
|
+
|
|
|
+ for (ProductInfo productInfo : productInfoList) {
|
|
|
+
|
|
|
+ BigDecimal length = productInfo.getLength();
|
|
|
+ BigDecimal width = productInfo.getWidth();
|
|
|
+ BigDecimal height = productInfo.getHeight();
|
|
|
+ length = ObjectUtil.isEmpty(length) ? BigDecimal.ZERO : length;
|
|
|
+ width = ObjectUtil.isEmpty(width) ? BigDecimal.ZERO : width;
|
|
|
+ height = ObjectUtil.isEmpty(height) ? BigDecimal.ZERO : height;
|
|
|
+
|
|
|
+
|
|
|
+ String fileUrl = "";
|
|
|
+ List<FileInfoVo> fileInfoVoList = fileMap.get(productInfo.getId());
|
|
|
+ if (ObjectUtil.isNotEmpty(fileInfoVoList)) {
|
|
|
+ fileUrl = fileInfoVoList.get(0).getFileUrl();
|
|
|
+ }
|
|
|
+
|
|
|
+ ProductExcelExportBo bo = new ProductExcelExportBo();
|
|
|
+ try {
|
|
|
+ bo.setProductImg(new URL(fileUrl));
|
|
|
+ } catch (MalformedURLException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ bo.setProductCode(productInfo.getCustomCode());
|
|
|
+ bo.setProductName(productInfo.getName());
|
|
|
+ bo.setProductSize(String.format("%s * %s * %s", length, width, height));
|
|
|
+ bo.setProductColor(productInfo.getColor());
|
|
|
+
|
|
|
+
|
|
|
+ bo.setFrontalTexture(frontLinesMap.getOrDefault(productInfo.getFrontalTexture(), productInfo.getFrontalTexture()));
|
|
|
+ bo.setReverseTexture(backLinesMap.getOrDefault(productInfo.getReverseTexture(), productInfo.getReverseTexture()));
|
|
|
+
|
|
|
+
|
|
|
+ List<String> prodImgList = ftpFileService.getFileList(productInfo.getProdImgPath());
|
|
|
+ if (ObjectUtil.isNotEmpty(prodImgList)) {
|
|
|
+ bo.setProdImgPath(FtpFileServiceImpl.fileServiceUrl + prodImgList.get(0));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> prodFileList = ftpFileService.getFileList(productInfo.getProdFilePath());
|
|
|
+ if (ObjectUtil.isNotEmpty(prodFileList)) {
|
|
|
+ bo.setProdFilePath(FtpFileServiceImpl.fileServiceUrl + prodFileList.get(0));
|
|
|
+ }
|
|
|
+
|
|
|
+ productExcelExportBoList.add(bo);
|
|
|
+ }
|
|
|
+
|
|
|
+ ExcelUtil.export(httpServletResponse, productExcelExportBoList, ProductExcelExportBo.class);
|
|
|
+ }
|
|
|
+
|
|
|
}
|