yzc 1 سال پیش
والد
کامیت
89ec5e3b5e

+ 6 - 0
hx-item/src/main/java/com/fjhx/item/entity/product/ProcessesBo.java

@@ -3,9 +3,15 @@ package com.fjhx.item.entity.product;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.math.BigDecimal;
+
 @Getter
 @Setter
 public class ProcessesBo {
+
+    private Long id;
     private String name;
     private String code;
+
+    private BigDecimal costPrice;
 }

+ 46 - 0
hx-sale/src/main/java/com/fjhx/sale/controller/quotation/QuotationEstimateController.java

@@ -0,0 +1,46 @@
+package com.fjhx.sale.controller.quotation;
+
+import com.fjhx.sale.entity.quotation.dto.QuotationEstimateDto;
+import com.fjhx.sale.entity.quotation.vo.QuotationEstimateVo;
+import com.fjhx.sale.service.quotation.QuotationEstimateService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+
+/**
+ * <p>
+ * 报价评估 前端控制器
+ * </p>
+ *
+ * @author
+ * @since 2024-02-04
+ */
+@RestController
+@RequestMapping("/quotationEstimate")
+public class QuotationEstimateController {
+
+    @Autowired
+    private QuotationEstimateService quotationEstimateService;
+
+    /**
+     * 报价评估明细
+     */
+    @PostMapping("/detail")
+    public List<QuotationEstimateVo> detail(@RequestBody QuotationEstimateDto dto) {
+        return quotationEstimateService.detail(dto);
+    }
+
+    /**
+     * 报价评估新增
+     */
+    @PostMapping("/addOrEdit")
+    public void addOrEdit(@RequestBody QuotationEstimateDto quotationEstimateDto) {
+        quotationEstimateService.addOrEdit(quotationEstimateDto);
+    }
+
+}

+ 24 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/quotation/dto/QuotationEstimateDto.java

@@ -0,0 +1,24 @@
+package com.fjhx.sale.entity.quotation.dto;
+
+import com.fjhx.sale.entity.quotation.po.QuotationEstimate;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * 报价评估新增编辑入参实体
+ *
+ * @author
+ * @since 2024-02-04
+ */
+@Getter
+@Setter
+public class QuotationEstimateDto extends QuotationEstimate {
+
+    /**
+     * 报价列表
+     */
+    List<QuotationEstimate> quotationEstimateList;
+
+}

+ 17 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/quotation/dto/QuotationEstimateSelectDto.java

@@ -0,0 +1,17 @@
+package com.fjhx.sale.entity.quotation.dto;
+
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 报价评估列表查询入参实体
+ *
+ * @author
+ * @since 2024-02-04
+ */
+@Getter
+@Setter
+public class QuotationEstimateSelectDto extends BaseSelectDto {
+
+}

+ 107 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/quotation/po/QuotationEstimate.java

@@ -0,0 +1,107 @@
+package com.fjhx.sale.entity.quotation.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BasePo;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 报价评估
+ * </p>
+ *
+ * @author
+ * @since 2024-02-04
+ */
+@Getter
+@Setter
+@TableName("quotation_estimate")
+public class QuotationEstimate extends BasePo {
+
+    /**
+     * 报价单id
+     */
+    private Long quotationId;
+
+    /**
+     * 报价单明细id
+     */
+    private Long quotationProductId;
+
+    /**
+     * 商品ID
+     */
+    private Long productId;
+    /**
+     * 物品ID
+     */
+    private Long materialId;
+
+    /**
+     * 类型 1原材料 2包材辅材 3工序
+     */
+    private Integer type;
+
+    /**
+     * 模具id
+     */
+    private Long moldId;
+
+    /**
+     * 数量
+     */
+    private BigDecimal quantity;
+
+    /**
+     * 单价
+     */
+    private BigDecimal price;
+
+    /**
+     * 工序id
+     */
+    private Long processesId;
+
+    /**
+     * 总数量
+     */
+    private Long totalQuantity;
+
+    /**
+     * 总价
+     */
+    private BigDecimal amount;
+
+    /**
+     * 物料长
+     */
+    private BigDecimal materialLength;
+
+    /**
+     * 物料宽
+     */
+    private BigDecimal materialWidth;
+
+    /**
+     * 物料高
+     */
+    private BigDecimal materialHeight;
+
+    /**
+     * 物料长
+     */
+    private BigDecimal moldLength;
+
+    /**
+     * 物料宽
+     */
+    private BigDecimal moldWidth;
+
+    /**
+     * 物料高
+     */
+    private BigDecimal moldHeight;
+
+}

+ 22 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/quotation/vo/QuotationEstimateVo.java

@@ -0,0 +1,22 @@
+package com.fjhx.sale.entity.quotation.vo;
+
+import com.fjhx.sale.entity.quotation.po.QuotationEstimate;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 报价评估列表查询返回值实体
+ *
+ * @author
+ * @since 2024-02-04
+ */
+@Getter
+@Setter
+public class QuotationEstimateVo extends QuotationEstimate {
+
+    private String code;
+    private String name;
+
+    private String materialColor;
+
+}

+ 17 - 0
hx-sale/src/main/java/com/fjhx/sale/mapper/quotation/QuotationEstimateMapper.java

@@ -0,0 +1,17 @@
+package com.fjhx.sale.mapper.quotation;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fjhx.sale.entity.quotation.po.QuotationEstimate;
+
+
+/**
+ * <p>
+ * 报价评估 Mapper 接口
+ * </p>
+ *
+ * @author
+ * @since 2024-02-04
+ */
+public interface QuotationEstimateMapper extends BaseMapper<QuotationEstimate> {
+
+}

+ 31 - 0
hx-sale/src/main/java/com/fjhx/sale/service/quotation/QuotationEstimateService.java

@@ -0,0 +1,31 @@
+package com.fjhx.sale.service.quotation;
+
+import com.fjhx.sale.entity.quotation.dto.QuotationEstimateDto;
+import com.fjhx.sale.entity.quotation.po.QuotationEstimate;
+import com.fjhx.sale.entity.quotation.vo.QuotationEstimateVo;
+import com.ruoyi.common.core.service.BaseService;
+
+import java.util.List;
+
+
+/**
+ * <p>
+ * 报价评估 服务类
+ * </p>
+ *
+ * @author
+ * @since 2024-02-04
+ */
+public interface QuotationEstimateService extends BaseService<QuotationEstimate> {
+
+    /**
+     * 报价评估明细
+     */
+    List<QuotationEstimateVo> detail(QuotationEstimateDto dto);
+
+    /**
+     * 报价评估新增
+     */
+    void addOrEdit(QuotationEstimateDto quotationEstimateDto);
+
+}

+ 139 - 0
hx-sale/src/main/java/com/fjhx/sale/service/quotation/impl/QuotationEstimateServiceImpl.java

@@ -0,0 +1,139 @@
+package com.fjhx.sale.service.quotation.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.common.utils.Assert;
+import com.fjhx.item.entity.product.ProcessesBo;
+import com.fjhx.item.entity.product.po.ProductInfo;
+import com.fjhx.item.service.product.ProductInfoService;
+import com.fjhx.sale.entity.quotation.dto.QuotationEstimateDto;
+import com.fjhx.sale.entity.quotation.po.QuotationEstimate;
+import com.fjhx.sale.entity.quotation.po.QuotationProduct;
+import com.fjhx.sale.entity.quotation.po.QuotationProductBom;
+import com.fjhx.sale.entity.quotation.vo.QuotationEstimateVo;
+import com.fjhx.sale.mapper.quotation.QuotationEstimateMapper;
+import com.fjhx.sale.service.quotation.QuotationEstimateService;
+import com.fjhx.sale.service.quotation.QuotationProductBomService;
+import com.fjhx.sale.service.quotation.QuotationProductService;
+import com.ruoyi.common.core.domain.BasePo;
+import com.ruoyi.common.utils.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * <p>
+ * 报价评估 服务实现类
+ * </p>
+ *
+ * @author
+ * @since 2024-02-04
+ */
+@Service
+public class QuotationEstimateServiceImpl extends ServiceImpl<QuotationEstimateMapper, QuotationEstimate> implements QuotationEstimateService {
+
+    @Autowired
+    private QuotationProductBomService quotationProductBomService;
+    @Autowired
+    private QuotationProductService quotationProductService;
+    @Autowired
+    private ProductInfoService productInfoService;
+
+    @Override
+    public List<QuotationEstimateVo> detail(QuotationEstimateDto dto) {
+        Long quotationProductId = dto.getQuotationProductId();
+        Assert.notEmpty(quotationProductId, "报价明细id不能为空!");
+
+        QuotationProduct quotationProduct = quotationProductService.getById(quotationProductId);
+        Assert.notEmpty(quotationProduct, "查询不到报价明细信息!");
+
+        //查询现有报价信息
+        List<QuotationEstimate> quotationEstimateList = list(q -> q.eq(QuotationEstimate::getQuotationProductId, quotationProductId));
+        List<QuotationEstimateVo> quotationEstimateVos = BeanUtil.copyToList(quotationEstimateList, QuotationEstimateVo.class);
+
+        //没有现有数据回填报价明细信息
+        if (ObjectUtil.isEmpty(quotationEstimateVos)) {
+            quotationEstimateVos = new ArrayList<>();
+            List<QuotationProductBom> list1 = quotationProductBomService.list(q -> q.eq(QuotationProductBom::getQuotationProductId, quotationProductId));
+
+            //获取产品BOM
+            for (QuotationProductBom quotationProductBom : list1) {
+                QuotationEstimateVo quotationEstimate = new QuotationEstimateVo();
+                quotationEstimate.setQuotationProductId(quotationProductBom.getQuotationProductId());
+                quotationEstimate.setProductId(quotationProductBom.getProductId());
+                quotationEstimate.setMaterialId(quotationProductBom.getMaterialId());
+                quotationEstimate.setType(quotationProductBom.getType());
+
+                //原材料不赋值数量
+                if (ObjectUtil.notEqual(quotationProductBom.getType(), 1)) {
+                    quotationEstimate.setQuantity(quotationProductBom.getQuantity());
+                }
+
+                quotationEstimateVos.add(quotationEstimate);
+            }
+
+            //赋值物料信息
+            productInfoService.attributeAssign(quotationEstimateVos, QuotationEstimateVo::getMaterialId, (detail, product) -> {
+                detail.setMaterialLength(product.getLength());
+                detail.setMaterialWidth(product.getWidth());
+                detail.setMaterialHeight(product.getHeight());
+                detail.setName(product.getName());
+                detail.setCode(product.getCode());
+                detail.setMaterialColor(product.getColor());
+            });
+
+            //获取工序
+            ProductInfo productInfo = productInfoService.getById(quotationProduct.getProductId());
+            Assert.notEmpty(productInfo, "查询不到工艺信息!");
+            List<ProcessesBo> processesList = productInfoService.getProcessesByTechnologyId(productInfo.getTechnologyId());
+            for (ProcessesBo processesBo : processesList) {
+                QuotationEstimateVo quotationEstimate = new QuotationEstimateVo();
+                quotationEstimate.setProcessesId(processesBo.getId());
+                quotationEstimate.setCode(processesBo.getCode());
+                quotationEstimate.setName(processesBo.getName());
+                quotationEstimate.setPrice(processesBo.getCostPrice());
+                quotationEstimate.setQuantity(BigDecimal.valueOf(1));
+                quotationEstimate.setType(3);
+
+                quotationEstimateVos.add(quotationEstimate);
+            }
+        }
+
+
+        return quotationEstimateVos;
+    }
+
+    @Override
+    public void addOrEdit(QuotationEstimateDto quotationEstimateDto) {
+        Long quotationProductId = quotationEstimateDto.getQuotationProductId();
+        Assert.notEmpty(quotationProductId, "报价明细id不能为空!");
+
+        QuotationProduct quotationProduct = quotationProductService.getById(quotationProductId);
+        Assert.notEmpty(quotationProduct, "查询不到报价明细信息!");
+
+        List<QuotationEstimate> quotationEstimateList = quotationEstimateDto.getQuotationEstimateList();
+
+        //计算产品单价
+        BigDecimal amount = quotationEstimateList.stream().map(QuotationEstimate::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+        BigDecimal divide = amount.divide(quotationProduct.getQuantity(), 4, RoundingMode.HALF_UP);
+        quotationProductService.update(q -> q
+                .eq(QuotationProduct::getId, quotationProductId)
+                .set(QuotationProduct::getPrice, divide)
+                .set(BasePo::getUpdateTime, new Date())
+                .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+        );
+
+        for (QuotationEstimate quotationEstimate : quotationEstimateList) {
+            quotationEstimate.setQuotationProductId(quotationProductId);
+        }
+        this.saveOrUpdateBatch(quotationEstimateList);
+    }
+
+}

+ 7 - 3
hx-sale/src/main/java/com/fjhx/sale/service/sale/impl/SaleQuotationServiceImpl.java

@@ -116,15 +116,19 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
         IWrapper<SaleQuotation> wrapper = IWrapper.getWrapper();
 
         //权限过滤:报价评估自己看自己
+        Long companyId = SecurityUtils.getCompanyId();
         if (Objects.equals(dto.getIsEstimate(), 1)) {
-            wrapper.eq("sq", SaleQuotation::getOfCompanyId, SecurityUtils.getCompanyId());
+            //根据报价公司过滤
+            wrapper.eq("sq", SaleQuotation::getCompanyId, companyId);
             wrapper.ne("sq", SaleQuotation::getStatus, FlowStatusEnum1.DRAFT.getKey());
+        } else {
+            //报价单根据 归属公司过滤
+            wrapper.eq(SaleQuotation::getOfCompanyId, companyId);
         }
 
         //报价状态
         wrapper.eq(SaleQuotation::getQuotationStatus, dto.getQuotationStatus());
-        //报价公司
-        wrapper.eq(SaleQuotation::getCompanyId, dto.getCompanyId());
+
         //报价单类型
         wrapper.eq(SaleQuotation::getType, dto.getType());
 

+ 4 - 0
hx-sale/src/main/resources/mapper/quotation/QuotationEstimateMapper.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.sale.mapper.quotation.QuotationEstimateMapper">
+</mapper>