|
@@ -54,15 +54,14 @@ import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.imageio.IIOException;
|
|
|
import javax.imageio.ImageIO;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
-import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URL;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.BiConsumer;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -356,90 +355,9 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
saveOrEditCustomInfo(productInfoDto);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public void edit(ProductInfoDto productInfoDto) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
productInfoDto.setCode(null);
|
|
|
|
|
@@ -469,9 +387,6 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
productInfoDto.setCompanyId(SecurityUtils.getCompanyId());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
this.updateById(productInfoDto);
|
|
|
ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId());
|
|
|
ObsFileUtil.editFile(productInfoDto.getProdFileList(), productInfoDto.getId(), 2);
|
|
@@ -509,36 +424,6 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public void delete(Long id) {
|
|
@@ -578,7 +463,6 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public synchronized void editAvailableQuantity(List<AvailableStockBo> inOutList, Long businessId, ProductAvailableRecordType businessType, Long companyId) {
|
|
|
-
|
|
|
if (ObjectUtil.isEmpty(inOutList)) {
|
|
|
return;
|
|
|
}
|
|
@@ -1102,9 +986,35 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
return baseMapper.getProductAnalysisPage(page, wrapper);
|
|
|
}
|
|
|
|
|
|
+ private <T> void setExcelImg(List<T> list, SFunction<T, String> getIdFun, BiConsumer<T, WriteCellData> setBic) {
|
|
|
+ for (T t : list) {
|
|
|
+ try {
|
|
|
+ String fileUrl = getIdFun.apply(t);
|
|
|
+
|
|
|
+ int lastIndex = fileUrl.lastIndexOf(".");
|
|
|
+ String suffix = fileUrl.substring(lastIndex + 1, fileUrl.length());
|
|
|
|
|
|
- private List<ProductExcelExportBo> excelExportComm(ProductInfoSelectDto dto) {
|
|
|
+ BufferedImage image = ImageIO.read(new URL(fileUrl));
|
|
|
+ if (ObjectUtil.isNotEmpty(image)) {
|
|
|
+
|
|
|
+ Double imgWidth = Double.valueOf(image.getWidth());
|
|
|
+ Double imgHeight = Double.valueOf(image.getHeight());
|
|
|
+
|
|
|
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
+ ImageIO.write(image, suffix, baos);
|
|
|
+ WriteCellData<Void> voidWriteCellData = ExcelImgUtils.imageCells(baos.toByteArray(), imgWidth, imgHeight, 10.0 * 5.8, 50.0);
|
|
|
+ setBic.accept(t, voidWriteCellData);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn(String.format("Excel导出图片处理异常:(%s) %s", e.getClass().getSimpleName(), e.getMessage()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void excelExport(HttpServletResponse httpServletResponse, ProductInfoSelectDto dto) {
|
|
|
IWrapper<ProductInfo> wrapper = getPageWrapper(dto);
|
|
|
+ wrapper.eq("pi", ProductInfo::getDefinition, 1);
|
|
|
List<ProductInfoVo> productInfoList = baseMapper.getList(wrapper);
|
|
|
List<Long> pIds = productInfoList.stream().map(ProductInfo::getId).collect(Collectors.toList());
|
|
|
|
|
@@ -1132,30 +1042,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
|
|
|
List<FileInfoVo> fileInfoVoList = fileMap.get(productInfo.getId());
|
|
|
if (ObjectUtil.isNotEmpty(fileInfoVoList)) {
|
|
|
- try {
|
|
|
- String fileUrl = fileInfoVoList.get(0).getFileUrl();
|
|
|
-
|
|
|
-
|
|
|
- int lastIndex = fileUrl.lastIndexOf(".");
|
|
|
- String suffix = fileUrl.substring(lastIndex + 1, fileUrl.length());
|
|
|
-
|
|
|
- BufferedImage image = ImageIO.read(new URL(fileUrl));
|
|
|
- if (ObjectUtil.isNotEmpty(image)) {
|
|
|
-
|
|
|
- Double imgWidth = Double.valueOf(image.getWidth());
|
|
|
- Double imgHeight = Double.valueOf(image.getHeight());
|
|
|
-
|
|
|
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
- ImageIO.write(image, suffix, baos);
|
|
|
- WriteCellData<Void> voidWriteCellData = ExcelImgUtils.imageCells(baos.toByteArray(), imgWidth, imgHeight, 10.0 * 5.8, 50.0);
|
|
|
- bo.setProductImg(voidWriteCellData);
|
|
|
- }
|
|
|
- } catch (IIOException iioe) {
|
|
|
- log.error(iioe.getMessage());
|
|
|
- } catch (IOException e) {
|
|
|
- log.error("导出失败" + e.getMessage(), e);
|
|
|
- throw new ServiceException("导出失败" + e.getMessage());
|
|
|
- }
|
|
|
+ String fileUrl = fileInfoVoList.get(0).getFileUrl();
|
|
|
+ bo.setProductImgPath(fileUrl);
|
|
|
}
|
|
|
|
|
|
bo.setProductCode(productInfo.getCustomCode());
|
|
@@ -1187,44 +1075,58 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
|
|
|
productExcelExportBoList.add(bo);
|
|
|
}
|
|
|
- return productExcelExportBoList;
|
|
|
- }
|
|
|
|
|
|
- private <V> void setExcelImg(List<V> list, SFunction<V, String> getIdFun, SFunction<V, WriteCellData> setFun) {
|
|
|
- for (V v : list) {
|
|
|
- try {
|
|
|
- String fileUrl = getIdFun.apply(v);
|
|
|
-
|
|
|
- int lastIndex = fileUrl.lastIndexOf(".");
|
|
|
- String suffix = fileUrl.substring(lastIndex + 1, fileUrl.length());
|
|
|
+
|
|
|
+ setExcelImg(productExcelExportBoList, ProductExcelExportBo::getProductImgPath, ProductExcelExportBo::setProductImg);
|
|
|
|
|
|
- BufferedImage image = ImageIO.read(new URL(fileUrl));
|
|
|
- if (ObjectUtil.isNotEmpty(image)) {
|
|
|
-
|
|
|
- Double imgWidth = Double.valueOf(image.getWidth());
|
|
|
- Double imgHeight = Double.valueOf(image.getHeight());
|
|
|
-
|
|
|
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
- ImageIO.write(image, suffix, baos);
|
|
|
- WriteCellData<Void> voidWriteCellData = ExcelImgUtils.imageCells(baos.toByteArray(), imgWidth, imgHeight, 10.0 * 5.8, 50.0);
|
|
|
- setFun.apply(v).setData(voidWriteCellData);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.warn(String.format("Excel导出图片处理异常:(%s) %s", e.getClass().getSimpleName(), e.getMessage()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public void excelExport(HttpServletResponse httpServletResponse, ProductInfoSelectDto dto) {
|
|
|
- List<ProductExcelExportBo> productExcelExportBoList = excelExportComm(dto);
|
|
|
ExcelUtil.export(httpServletResponse, productExcelExportBoList, ProductExcelExportBo.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void materialExcelExport(HttpServletResponse httpServletResponse, ProductInfoSelectDto dto) {
|
|
|
- List<ProductExcelExportBo> productExcelExportBoList = excelExportComm(dto);
|
|
|
- List<MaterialExcelExportBo> materialExcelExportBos = BeanUtil.copyToList(productExcelExportBoList, MaterialExcelExportBo.class);
|
|
|
+ IWrapper<ProductInfo> wrapper = getPageWrapper(dto);
|
|
|
+ wrapper.eq("pi", ProductInfo::getDefinition, 2);
|
|
|
+ List<ProductInfoVo> productInfoList = baseMapper.getList(wrapper);
|
|
|
+ setPageInfo(productInfoList);
|
|
|
+
|
|
|
+
|
|
|
+ List<Long> pIds = productInfoList.stream().map(ProductInfo::getId).collect(Collectors.toList());
|
|
|
+ Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(pIds, 0);
|
|
|
+
|
|
|
+ Map<String, Map<String, String>> allDictKVMap = DictUtils.getAllDictKVMap();
|
|
|
+
|
|
|
+ List<MaterialExcelExportBo> materialExcelExportBos = new ArrayList<>();
|
|
|
+ for (ProductInfoVo productInfo : productInfoList) {
|
|
|
+ MaterialExcelExportBo bo = BeanUtil.copyProperties(productInfo, MaterialExcelExportBo.class);
|
|
|
+
|
|
|
+
|
|
|
+ List<FileInfoVo> fileInfoVoList = fileMap.get(productInfo.getId());
|
|
|
+ if (ObjectUtil.isNotEmpty(fileInfoVoList)) {
|
|
|
+ String fileUrl = fileInfoVoList.get(0).getFileUrl();
|
|
|
+ bo.setProductImgPath(fileUrl);
|
|
|
+ }
|
|
|
+
|
|
|
+ bo.setFrontalTexture(allDictKVMap.get("front_lines").get(productInfo.getFrontalTexture()));
|
|
|
+ bo.setReverseTexture(allDictKVMap.get("back_lines").get(productInfo.getReverseTexture()));
|
|
|
+ bo.setColorLayer(allDictKVMap.get("color_layer").get(productInfo.getColorLayer()));
|
|
|
+
|
|
|
+
|
|
|
+ BigDecimal length = productInfo.getLength();
|
|
|
+ BigDecimal width = productInfo.getWidth();
|
|
|
+ BigDecimal height = productInfo.getHeight();
|
|
|
+ bo.setProductSize(String.format("%s * %s * %s",
|
|
|
+ ObjectUtil.isEmpty(length) ? BigDecimal.ZERO : length,
|
|
|
+ ObjectUtil.isEmpty(width) ? BigDecimal.ZERO : width,
|
|
|
+ ObjectUtil.isEmpty(height) ? BigDecimal.ZERO : height)
|
|
|
+ );
|
|
|
+
|
|
|
+ materialExcelExportBos.add(bo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ setExcelImg(materialExcelExportBos, MaterialExcelExportBo::getProductImgPath, MaterialExcelExportBo::setProductImg);
|
|
|
+
|
|
|
ExcelUtil.export(httpServletResponse, materialExcelExportBos, MaterialExcelExportBo.class);
|
|
|
}
|
|
|
|