|
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
@@ -22,6 +23,7 @@ import com.fjhx.common.utils.excel.util.ExcelUtil;
|
|
|
import com.fjhx.file.entity.FileInfoVo;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.item.entity.product.ProcessesBo;
|
|
|
+import com.fjhx.item.entity.product.bo.MaterialExcelExportBo;
|
|
|
import com.fjhx.item.entity.product.bo.ProductAnalysisBo;
|
|
|
import com.fjhx.item.entity.product.bo.ProductExcelExportBo;
|
|
|
import com.fjhx.item.entity.product.dto.ProductCustomInfoDto;
|
|
@@ -590,6 +592,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
|
|
|
//获取产品安全库存
|
|
|
ProductInfo materialInfo = materialMap.get(materialId);
|
|
|
+ Assert.notEmpty(materialInfo, "查询不到物料信息!");
|
|
|
BigDecimal stockThreshold = materialInfo.getStockThreshold();
|
|
|
|
|
|
//获取可用库存
|
|
@@ -1099,8 +1102,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
return baseMapper.getProductAnalysisPage(page, wrapper);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void excelExport(HttpServletResponse httpServletResponse, ProductInfoSelectDto dto) {
|
|
|
+
|
|
|
+ private List<ProductExcelExportBo> excelExportComm(ProductInfoSelectDto dto) {
|
|
|
IWrapper<ProductInfo> wrapper = getPageWrapper(dto);
|
|
|
List<ProductInfoVo> productInfoList = baseMapper.getList(wrapper);
|
|
|
List<Long> pIds = productInfoList.stream().map(ProductInfo::getId).collect(Collectors.toList());
|
|
@@ -1184,11 +1187,48 @@ 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());
|
|
|
+
|
|
|
+ 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);
|
|
|
+ ExcelUtil.export(httpServletResponse, materialExcelExportBos, MaterialExcelExportBo.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public Page<ProductInfoVo> getProductByMaterialId(ProductInfoSelectDto dto) {
|
|
|
IWrapper<Object> wrapper = IWrapper.getWrapper();
|
|
|
wrapper.eq("pbd.material_id", dto.getMaterialId());
|