소스 검색

问题处理

yzc 1 년 전
부모
커밋
f9700c4b6a

+ 8 - 0
hx-item/src/main/java/com/fjhx/item/controller/product/ProductInfoController.java

@@ -145,6 +145,14 @@ public class ProductInfoController {
         productInfoService.excelExport(httpServletResponse, dto);
     }
 
+    /**
+     * 导出Excel物料
+     */
+    @PostMapping("/materialExcelExport")
+    public void materialExcelExport(HttpServletResponse httpServletResponse, @RequestBody ProductInfoSelectDto dto) {
+        productInfoService.materialExcelExport(httpServletResponse, dto);
+    }
+
     @PostMapping("/getProductByMaterialId")
     public Page<ProductInfoVo> getProductByMaterialId(@RequestBody ProductInfoSelectDto dto) {
         return productInfoService.getProductByMaterialId(dto);

+ 67 - 0
hx-item/src/main/java/com/fjhx/item/entity/product/bo/MaterialExcelExportBo.java

@@ -0,0 +1,67 @@
+package com.fjhx.item.entity.product.bo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.metadata.data.WriteCellData;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+@Getter
+@Setter
+@ContentRowHeight(50)
+public class MaterialExcelExportBo {
+    @ColumnWidth(10)
+    @ExcelProperty("物料图片")
+    private WriteCellData<Void> productImg;
+    @ColumnWidth(15)
+    @ExcelProperty("物料分类")
+    private String productClassifyNames;
+    @ColumnWidth(15)
+    @ExcelProperty("物料名称")
+    private String productName;
+    @ColumnWidth(15)
+    @ExcelProperty("物料编号")
+    private String productCode;
+    @ColumnWidth(15)
+    @ExcelProperty("关联原材料")
+    private String rawMaterialName;
+    @ColumnWidth(15)
+    @ExcelProperty("材质")
+    private String material;
+    @ColumnWidth(15)
+    @ExcelProperty("规格型号")
+    private String spec;
+    @ColumnWidth(15)
+    @ExcelProperty("正面纹路")
+    private String frontalTexture;
+    @ColumnWidth(15)
+    @ExcelProperty("反面纹路")
+    private String reverseTexture;
+    @ColumnWidth(15)
+    @ExcelProperty("单位")
+    private String unit;
+    @ColumnWidth(15)
+    @ExcelProperty("色层")
+    private String colorLayer;
+    @ColumnWidth(15)
+    @ExcelProperty("颜色")
+    private String productColor;
+    @ColumnWidth(15)
+    @ExcelProperty("安全库存")
+    private String stockThreshold;
+    @ColumnWidth(15)
+    @ExcelProperty("成本价")
+    private String costPrice;
+    @ColumnWidth(15)
+    @ExcelProperty("销售价")
+    private BigDecimal price;
+    @ColumnWidth(15)
+    @ExcelProperty("产品尺寸")
+    private String productSize;
+    @ColumnWidth(15)
+    @ExcelProperty("净重")
+    private BigDecimal netWeight;
+}

+ 2 - 0
hx-item/src/main/java/com/fjhx/item/service/product/ProductInfoService.java

@@ -125,6 +125,8 @@ public interface ProductInfoService extends BaseService<ProductInfo> {
      */
     void excelExport(HttpServletResponse httpServletResponse, ProductInfoSelectDto dto);
 
+    void materialExcelExport(HttpServletResponse httpServletResponse, ProductInfoSelectDto dto);
+
     Page<ProductInfoVo> getProductByMaterialId(ProductInfoSelectDto dto);
 
     List<ProcessesBo> getProcessesByTechnologyId(Long technologyId);

+ 42 - 2
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductInfoServiceImpl.java

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

+ 5 - 5
hx-purchase/src/main/resources/mapper/subscribe/SubscribeDetailMapper.xml

@@ -16,17 +16,17 @@
                       null                     AS prodTag,
                       NULL                     AS prodRemark,
                       t2.is_in_stock,
-                      null                     as prodNeedCount
+                      t1.count                 AS prodNeedCount
                FROM subscribe_detail t1
                         LEFT JOIN subscribe t2 ON t1.subscribe_id = t2.id
                    AND t1.data_type = 0
                WHERE t1.data_type = 0)
               UNION ALL
               (SELECT t1.*,
-                      t2.`code`                               AS subscribeCode,
-                      null                                    AS subscribeContent,
-                      t1.create_time                          AS subcribeTime,
-                      null                                    AS subcribeName,
+                      t2.`code`                                                      AS subscribeCode,
+                      null                                                           AS subscribeContent,
+                      t1.create_time                                                 AS subcribeTime,
+                      null                                                           AS subcribeName,
                       t2.id                                   AS subcribeId,
                       null                                    AS requiredArrivalTime,
                       null                                    AS putWarehouseId,

+ 8 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/purchase/po/EhsdPurchaseProduct.java

@@ -100,5 +100,13 @@ public class EhsdPurchaseProduct extends BasePo {
      */
     private Long contractId;
 
+    /**
+     * 单价含税
+     */
     private BigDecimal priceIncludingTax;
+    /**
+     * 小计含税
+     */
+    private BigDecimal amountIncludingTax;
+
 }

+ 4 - 1
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -1532,7 +1532,10 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         List<AvailableStockBo> inOutBoList = new ArrayList<>();
 
         //获取产品BOM列表
-        List<ContractProductBomVo> contractProductBomList = contractProductBomMapper.getContractProductBomQuantitySum(IWrapper.getWrapper().eq("cpb.contract_id", businessId));
+        List<ContractProductBomVo> contractProductBomList = contractProductBomMapper.getContractProductBomQuantitySum(IWrapper.getWrapper()
+                .eq("cpb.contract_id", businessId)
+                .ne("cpb.type", 3)
+        );
         for (ContractProductBom contractProductBom : contractProductBomList) {
             Long materialId = contractProductBom.getMaterialId();
             //获取待采购量

+ 1 - 0
hx-sale/src/main/resources/mapper/purchase/EhsdPurchaseProductMapper.xml

@@ -130,6 +130,7 @@
                epp.contract_id,
                epp.subscribe_detail_id,
                epp.old_purchase_product_id,
+               epp.price_including_tax,
                IFNULL(t1.receiptQuantity, 0) AS arrivalQuantity,
                IFNULL(t1.receiptStatus, 0)   AS receiptStatus,
                ep.sell_corporation_id