523096025 2 mēneši atpakaļ
vecāks
revīzija
05b1ccd54f

+ 108 - 11
ruoyi-admin/src/main/java/com/ruoyi/web/base/controller/ProductionShipmentNotificationController.java

@@ -3,18 +3,22 @@ package com.ruoyi.web.base.controller;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.framework.web.service.TokenService;
 import com.ruoyi.web.base.domain.ProductionShipmentNotification;
+import com.ruoyi.web.base.domain.param.ProductionRegularPlanParam;
 import com.ruoyi.web.base.domain.param.ProductionRegularPlanRequest;
+import com.ruoyi.web.base.domain.param.TreeNode;
 import com.ruoyi.web.base.service.IProductionShipmentNotificationService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.Map;
+import java.util.*;
 
 import static com.ruoyi.common.core.domain.AjaxResult.success;
+import static com.ruoyi.common.core.domain.AjaxResult.warn;
 import static com.ruoyi.common.utils.SecurityUtils.getUsername;
 
 @RestController
@@ -57,24 +61,117 @@ public class ProductionShipmentNotificationController {
 
     @ApiOperation("出货通知列表")
     @PostMapping("/list")
-    public AjaxResult listAll(HttpServletRequest request) {
-        return success(productionShipmentNotificationService.list(
-                new QueryWrapper<ProductionShipmentNotification>()
-                        .eq("org_id", tokenService.getLoginOrgId(request))
-        ));
+    public AjaxResult listAll(  @RequestBody ProductionRegularPlanRequest planRequest,HttpServletRequest request) {
+        String productionType = planRequest.getProductionType();
+        QueryWrapper<ProductionShipmentNotification> wrapper = new QueryWrapper<ProductionShipmentNotification>()
+                .eq("org_id", tokenService.getLoginOrgId(request));
+        if (StringUtils.isNotEmpty(productionType)){
+            wrapper.in("a.product_type", Arrays.asList(productionType.split(",")));
+        }
+        wrapper.eq(StringUtils.isNotEmpty(planRequest.getDeliveryDate()),"a.delivery_date",planRequest.getDeliveryDate());
+        List<ProductionShipmentNotification> list = productionShipmentNotificationService.list(wrapper);
+
+
+        return success();
     }
 
+    @ApiOperation("出货通知列表")
+    @PostMapping("/listTree")
+    public AjaxResult listTree(  @RequestBody ProductionRegularPlanRequest planRequest,HttpServletRequest request) {
+        String productionType = planRequest.getProductionType();
+        QueryWrapper<ProductionShipmentNotification> wrapper = new QueryWrapper<ProductionShipmentNotification>()
+                .eq("org_id", tokenService.getLoginOrgId(request));
+        if (StringUtils.isNotEmpty(productionType)){
+            wrapper.in("a.product_type", Arrays.asList(productionType.split(",")));
+        }
+        wrapper.eq(StringUtils.isNotEmpty(planRequest.getDeliveryDate()),"a.delivery_date",planRequest.getDeliveryDate());
+        List<ProductionRegularPlanParam> listTree = productionShipmentNotificationService.listTree(wrapper);
+
+
+        return success( buildTree(listTree));
+    }
+    public static void main(String[] args) {
+        // 测试数据
+        List<ProductionRegularPlanParam> dataList = new ArrayList<>();
+        dataList.add(new ProductionRegularPlanParam("客户A", "市场1", "线路X", "C1", "L1", "M1"));
+        dataList.add(new ProductionRegularPlanParam("客户B", "市场1", "线路X", "C2", "L1", "M1"));
+        dataList.add(new ProductionRegularPlanParam("客户C", "市场2", "线路Y", "C3", "L2", "M2"));
+
+        // 构建树
+        List<TreeNode> tree = buildTree(dataList);
+
+        // 打印树结构
+        for (TreeNode treeNode : tree) {
+            System.out.println(treeNode);
+        }
+    }
+        public static List<TreeNode> buildTree(List<ProductionRegularPlanParam> dataList) {
+            // 存储根节点(按lineNum分组)
+            Map<String, TreeNode> lineNodeMap = new HashMap<>();
+            // 存储市场节点(按marketNum分组)
+            Map<String, TreeNode> marketNodeMap = new HashMap<>();
+
+            // 第一步:构建所有节点并建立层级关系
+            for (ProductionRegularPlanParam data : dataList) {
+                // 创建或获取line节点
+                TreeNode lineNode = lineNodeMap.computeIfAbsent(data.getLineNum(),
+                        k -> new TreeNode(TreeNode.NodeType.LINE, data.getLineNum(), data.getLineName()));
+
+                // 创建或获取market节点
+                TreeNode marketNode = marketNodeMap.computeIfAbsent(data.getMarketNum(),
+                        k -> new TreeNode(TreeNode.NodeType.MARKET, data.getMarketNum(), data.getMarketName()));
+
+                // 确保market节点属于正确的line节点
+                if (!lineNode.getChildren().contains(marketNode)) {
+                    lineNode.addChild(marketNode);
+
+                }
+                // 创建customer节点并添加到market节点
+                TreeNode customerNode = new TreeNode(TreeNode.NodeType.CUSTOMER,
+                        data.getCustomerNum(), data.getCustomer());
+                marketNode.addChild(customerNode);
+            }
+
+            // 第二步:向上收集customerNum
+            for (TreeNode lineNode : lineNodeMap.values()) {
+                for (TreeNode marketNode : lineNode.getChildren()) {
+                    for (TreeNode customerNode : marketNode.getChildren()) {
+                        customerNode.addCustomerNum(customerNode.getNum());
+                        // 收集market节点的customerNum
+                        marketNode.getAllCustomerNums().add(customerNode.getNum());
+                    }
+
+                    // 收集line节点的customerNum
+                    lineNode.getAllCustomerNums().addAll(marketNode.getAllCustomerNums());
+                }
+            }
+
+            return new ArrayList<>(lineNodeMap.values());
+        }
+
+
     @ApiOperation("出货通知分页")
     @GetMapping("/page")
     public AjaxResult page(
             @RequestBody ProductionRegularPlanRequest planRequest,
             HttpServletRequest request
     ) {
-        return success(productionShipmentNotificationService.page(
-                new Page<ProductionShipmentNotification>(planRequest.getPageNum(), planRequest.getPageSize()),
-                new QueryWrapper<ProductionShipmentNotification>()
-                        .eq("org_id", tokenService.getLoginOrgId(request))
-        ));
+        String productionType = planRequest.getProductionType();
+        String customerNums = planRequest.getCustomerNums();
+        QueryWrapper<ProductionShipmentNotification> wrapper = new QueryWrapper<ProductionShipmentNotification>()
+                .eq("org_id", tokenService.getLoginOrgId(request));
+        if (StringUtils.isNotEmpty(productionType)){
+            wrapper.in("product_type", Arrays.asList(productionType.split(",")));
+        }
+        if (StringUtils.isNotEmpty(customerNums)){
+            wrapper.in("customer_number", Arrays.asList(customerNums.split(",")));
+        }
+
+        wrapper.eq(StringUtils.isNotEmpty(planRequest.getDeliveryDate()),"delivery_date",planRequest.getDeliveryDate());
+
+
+        productionShipmentNotificationService.page(new Page<>(planRequest.getPageNum(),planRequest.getPageSize()),wrapper);
+        return success();
     }
 
     @ApiOperation("出货通知详情")

+ 32 - 8
ruoyi-admin/src/main/java/com/ruoyi/web/base/controller/ProductionWhiteStripAllocationController.java

@@ -1,19 +1,16 @@
 package com.ruoyi.web.base.controller;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.framework.web.service.TokenService;
-import com.ruoyi.web.base.domain.BaseMaterial;
-import com.ruoyi.web.base.domain.ProductionRegular;
-import com.ruoyi.web.base.domain.ProductionSlaughter;
-import com.ruoyi.web.base.domain.ProductionWhiteStripAllocation;
+import com.ruoyi.web.base.domain.*;
 import com.ruoyi.web.base.domain.param.WiteStripAllRequest;
-import com.ruoyi.web.base.service.IBaseMaterialService;
-import com.ruoyi.web.base.service.IProductionRegularService;
-import com.ruoyi.web.base.service.IProductionSlaughterService;
-import com.ruoyi.web.base.service.IProductionWhiteStripAllocationService;
+import com.ruoyi.web.base.service.*;
+import com.ruoyi.web.sales.domain.SalesOrder;
+import com.ruoyi.web.sales.service.ISalesOrderService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.parameters.P;
@@ -36,7 +33,11 @@ public class ProductionWhiteStripAllocationController {
     @Autowired
     private IBaseMaterialService baseMaterialService;
     @Autowired
+    private IProductionShipmentNotificationService shipmentNotificationService;
+    @Autowired
     private TokenService tokenService;
+    @Autowired
+    private ISalesOrderService salesOrderService;
 
     @ApiOperation("白条分配添加")
     @PostMapping("/add")
@@ -155,10 +156,33 @@ public class ProductionWhiteStripAllocationController {
             productionWhiteStripAllocation.setId(Integer.parseInt(id));
             productionWhiteStripAllocation.setCompletionStatus(1);
             productionWhiteStripAllocationService.updateById(productionWhiteStripAllocation);
+            saveShipmentNotification(id);
         }
         return success();
     }
 
+    private void saveShipmentNotification(String id) {
+
+        ProductionShipmentNotification productionShipmentNotification = new ProductionShipmentNotification();
+        ProductionWhiteStripAllocation byId = productionWhiteStripAllocationService.getById(id);
+        SalesOrder salesOrder = salesOrderService.getById(byId.getSaleId());
+
+        BeanUtil.copyProperties(byId,productionShipmentNotification);
+        productionShipmentNotification.setAmount(salesOrder.getTotalAmount()) ;
+        productionShipmentNotification.setUnitPrice(salesOrder.getGoods().get(0).getUnitPrice()) ;
+        productionShipmentNotification.setReceivableCustomer(salesOrder.getReceivableCustomer()) ;
+        BaseMaterial material = baseMaterialService.getOne(new QueryWrapper<BaseMaterial>().eq("goods_num", byId.getMaterialCode()));
+        productionShipmentNotification.setProductType(material.getProductTypeName()) ;
+//        productionShipmentNotification.setTotalDeduction(salesOrder.getReceivableCustomer()) ;
+//        productionShipmentNotification.setCustomerChannel(salesOrder.getc()) ;
+        productionShipmentNotification.setWarehouse(material.getWarehouseName()) ;
+        productionShipmentNotification.setCustomerNumber(salesOrder.getCustomerNum()) ;
+        productionShipmentNotification.setSalesWeight(byId.getWeight()) ;
+//        productionShipmentNotification.setSalesDeductionPercentage(salesOrder.getReceivableCustomer()) ;
+
+        shipmentNotificationService.save(productionShipmentNotification);
+    }
+
     @ApiOperation("白条分配分页")
     @GetMapping("/page")
     public AjaxResult page(

+ 8 - 5
ruoyi-admin/src/main/java/com/ruoyi/web/base/domain/ProductionShipmentNotification.java

@@ -9,7 +9,9 @@ import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
+import java.util.Date;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.web.base.domain.base.Base;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -35,10 +37,11 @@ public class ProductionShipmentNotification  extends Base {
     private static final long serialVersionUID = 1L;
 
     @ApiModelProperty(value = "发货日期")
-    private LocalDate shipmentDate;
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date deliveryDate;
 
     @ApiModelProperty(value = "客户名称")
-    private String customerName;
+    private String customer;
 
     @ApiModelProperty(value = "物料名称")
     private String materialName;
@@ -47,13 +50,13 @@ public class ProductionShipmentNotification  extends Base {
     private String whiteStripNumber;
 
     @ApiModelProperty(value = "数量")
-    private Integer quantity;
+    private String baseNum;
 
     @ApiModelProperty(value = "单位")
     private String unit;
 
     @ApiModelProperty(value = "辅助数量")
-    private Integer auxiliaryQuantity;
+    private Integer assNum;
 
     @ApiModelProperty(value = "辅助单位")
     private String auxiliaryUnit;
@@ -89,7 +92,7 @@ public class ProductionShipmentNotification  extends Base {
     private String salesWeight;
 
     @ApiModelProperty(value = "销售扣水分%")
-    private BigDecimal salesDeductionPercentage;
+    private String salesDeductionPercentage;
 
 
 }

+ 9 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/base/domain/ProductionWhiteStripAllocation.java

@@ -74,8 +74,11 @@ public class ProductionWhiteStripAllocation  extends Base {
 
     @ApiModelProperty(value = "发货客户")
     private String deliveryCustomer;
+
+
     private String saleNum;
-    private int saleId;
+
+    private Integer saleId;
 
     @ApiModelProperty(value = "订单未分配片数")
     private Integer orderUnallocatedQuantity;
@@ -98,6 +101,11 @@ public class ProductionWhiteStripAllocation  extends Base {
     @ApiModelProperty(value = "物料编码")
     private String materialCode;
     private Integer regularId;
+    private String baseNum;
+    private String assNum;
+    private String warehouseNo;
+    private String peelWeight;
+
 
 
 

+ 24 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/base/domain/param/ProductionRegularPlanParam.java

@@ -0,0 +1,24 @@
+package com.ruoyi.web.base.domain.param;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+
+@Data
+public class ProductionRegularPlanParam  {
+    private String customer;
+    private String marketName;
+    private String lineName;
+    private String customerNum;
+    private String lineNum;
+    private String marketNum;
+
+    public ProductionRegularPlanParam(String customer, String marketName, String lineName, String customerNum, String lineNum, String marketNum) {
+        this.customer = customer;
+        this.marketName = marketName;
+        this.lineName = lineName;
+        this.customerNum = customerNum;
+        this.lineNum = lineNum;
+        this.marketNum = marketNum;
+    }
+}

+ 4 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/base/domain/param/ProductionRegularPlanRequest.java

@@ -3,6 +3,8 @@ package com.ruoyi.web.base.domain.param;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.Date;
+
 @EqualsAndHashCode(callSuper = true)
 @Data
 public class ProductionRegularPlanRequest extends  PageRequest{
@@ -19,10 +21,11 @@ public class ProductionRegularPlanRequest extends  PageRequest{
     private  String whiteNo;
 
 
-
     private  String   gradel;
     private  String   animalTag;
+    private  String   customerNums;
     private  String processingType;
+    private String deliveryDate;
     private  String startDate;
     private  String endDate;
     private  String productionType;

+ 49 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/base/domain/param/TreeNode.java

@@ -0,0 +1,49 @@
+package com.ruoyi.web.base.domain.param;
+
+import java.util.*;
+
+public class TreeNode {
+    public enum NodeType { LINE, MARKET, CUSTOMER }
+    
+    private final NodeType nodeType;
+    private final String num;
+    private final String name;
+    private final List<TreeNode> children = new ArrayList<>();
+    private final Set<String> allCustomerNums = new HashSet<>();
+
+    public TreeNode(NodeType nodeType, String num, String name) {
+        this.nodeType = nodeType;
+        this.num = num;
+        this.name = name;
+    }
+
+    public void addChild(TreeNode child) {
+        children.add(child);
+    }
+
+    // Getter方法
+    public NodeType getNodeType() { return nodeType; }
+    public String getNum() { return num; }
+    public String getName() { return name; }
+    public List<TreeNode> getChildren() { return children; }
+    public Set<String> getAllCustomerNums() { return allCustomerNums; }
+    
+    public void addCustomerNum(String num) {
+        allCustomerNums.add(num);
+    }
+    
+    public void addAllCustomerNums(Collection<String> nums) {
+        allCustomerNums.addAll(nums);
+    }
+
+    @Override
+    public String toString() {
+        return "TreeNode{" +
+                "nodeType=" + nodeType +
+                ", num='" + num + '\'' +
+                ", name='" + name + '\'' +
+                ", children=" + children +
+                ", allCustomerNums=" + allCustomerNums +
+                '}';
+    }
+}

+ 7 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/base/mapper/ProductionShipmentNotificationMapper.java

@@ -1,7 +1,13 @@
 package com.ruoyi.web.base.mapper;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.ruoyi.web.base.domain.ProductionShipmentNotification;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.web.base.domain.param.ProductionRegularPlanParam;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +19,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface ProductionShipmentNotificationMapper extends BaseMapper<ProductionShipmentNotification> {
 
+    List<ProductionRegularPlanParam> listTree(@Param(Constants.WRAPPER) QueryWrapper<ProductionShipmentNotification> wrapper);
 }

+ 5 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/base/service/IProductionShipmentNotificationService.java

@@ -1,7 +1,11 @@
 package com.ruoyi.web.base.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ruoyi.web.base.domain.ProductionShipmentNotification;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.web.base.domain.param.ProductionRegularPlanParam;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +17,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IProductionShipmentNotificationService extends IService<ProductionShipmentNotification> {
 
+    List<ProductionRegularPlanParam> listTree(QueryWrapper<ProductionShipmentNotification> wrapper);
 }

+ 12 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/base/service/impl/ProductionShipmentNotificationServiceImpl.java

@@ -1,11 +1,16 @@
 package com.ruoyi.web.base.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ruoyi.web.base.domain.ProductionShipmentNotification;
+import com.ruoyi.web.base.domain.param.ProductionRegularPlanParam;
 import com.ruoyi.web.base.mapper.ProductionShipmentNotificationMapper;
 import com.ruoyi.web.base.service.IProductionShipmentNotificationService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 出货通知单表,存储出货通知单的详细信息 服务实现类
@@ -17,4 +22,11 @@ import org.springframework.stereotype.Service;
 @Service
 public class ProductionShipmentNotificationServiceImpl extends ServiceImpl<ProductionShipmentNotificationMapper, ProductionShipmentNotification> implements IProductionShipmentNotificationService {
 
+    @Autowired
+    private ProductionShipmentNotificationMapper shipmentNotificationMapper;
+
+    @Override
+    public List<ProductionRegularPlanParam> listTree(QueryWrapper<ProductionShipmentNotification> wrapper) {
+        return shipmentNotificationMapper.listTree(wrapper);
+    }
 }

+ 11 - 0
ruoyi-admin/src/main/resources/mapper/ProductionShipmentNotificationMapper.xml

@@ -32,5 +32,16 @@
         <result column="update_time" property="updateTime" />
         <result column="org_id" property="orgId" />
     </resultMap>
+    <select id="listTree" resultType="com.ruoyi.web.base.domain.param.ProductionRegularPlanParam">
+
+
+        SELECT a.customer custtomer , a.customer_number    customerNum,
+         c.market_name  marketName , b.market_num marketNum ,b.line_num  lineNum ,
+         d.line_name   lineName FROM  `production_shipment_notification`  a
+        LEFT JOIN   `rel_customer_market` b ON  a.customer_number = b.customer_num
+        LEFT JOIN  `base_market`  c  ON  c.market_num = b.market_num
+         LEFT JOIN     `base_line`  d ON  d.line_num = b.line_num
+         ${ew.customSqlSegment}
+    </select>
 
 </mapper>