yzc 10 сар өмнө
parent
commit
5dd8dd34f2

+ 0 - 166
hx-wms/src/main/java/com/fjhx/wms/a-json/ContractMrpInfoApi.json

@@ -1,166 +0,0 @@
-{
-  "openapi": "3.0.1",
-  "tags": [
-    {
-      "name": "合同物料MRP信息"
-    }
-  ],
-  "paths": {
-    "/contractMrpInfo/page": {
-      "post": {
-        "summary": "分页",
-        "tags": [
-          "合同物料MRP信息"
-        ],
-        "requestBody": {
-          "content": {
-            "application/json": {
-              "schema": {
-                "type": "object",
-                "required": [
-                  "pageNum",
-                  "pageSize"
-                ],
-                "title": null,
-                "properties": {
-                  "pageNum": {
-                    "type": "integer",
-                    "required": null,
-                    "title": "页数",
-                    "properties": null,
-                    "items": null
-                  },
-                  "pageSize": {
-                    "type": "integer",
-                    "required": null,
-                    "title": "每页大小",
-                    "properties": null,
-                    "items": null
-                  }
-                },
-                "items": null
-              }
-            }
-          }
-        },
-        "responses": {
-          "200": {
-            "description": "成功",
-            "content": {
-              "application/json": {
-                "schema": {
-                  "type": "object",
-                  "required": [
-                    "code",
-                    "success",
-                    "msg",
-                    "data"
-                  ],
-                  "title": null,
-                  "properties": {
-                    "code": {
-                      "type": "Integer",
-                      "required": null,
-                      "title": null,
-                      "properties": null,
-                      "items": null
-                    },
-                    "success": {
-                      "type": "boolean",
-                      "required": null,
-                      "title": null,
-                      "properties": null,
-                      "items": null
-                    },
-                    "msg": {
-                      "type": "string",
-                      "required": null,
-                      "title": null,
-                      "properties": null,
-                      "items": null
-                    },
-                    "data": {
-                      "type": "object",
-                      "required": [
-                        "rows",
-                        "total"
-                      ],
-                      "title": null,
-                      "properties": {
-                        "records": {
-                          "type": "array",
-                          "required": null,
-                          "title": "分页数据",
-                          "properties": null,
-                          "items": {
-                            "type": "object",
-                            "required": null,
-                            "title": null,
-                            "properties": {
-                              "id": {
-                                "type": "integer",
-                                "required": null,
-                                "title": "",
-                                "properties": null,
-                                "items": null
-                              },
-                              "contractId": {
-                                "type": "integer",
-                                "required": null,
-                                "title": "合同id",
-                                "properties": null,
-                                "items": null
-                              },
-                              "materialId": {
-                                "type": "integer",
-                                "required": null,
-                                "title": "物料id",
-                                "properties": null,
-                                "items": null
-                              },
-                              "stockQuantity": {
-                                "type": "number",
-                                "required": null,
-                                "title": "库存数量",
-                                "properties": null,
-                                "items": null
-                              },
-                              "createTime": {
-                                "type": "string",
-                                "required": null,
-                                "title": "创建时间",
-                                "properties": null,
-                                "items": null
-                              },
-                              "updateTime": {
-                                "type": "string",
-                                "required": null,
-                                "title": "修改时间",
-                                "properties": null,
-                                "items": null
-                              }
-                            },
-                            "items": null
-                          }
-                        },
-                        "total": {
-                          "type": "integer",
-                          "required": null,
-                          "title": "总条数",
-                          "properties": null,
-                          "items": null
-                        }
-                      },
-                      "items": null
-                    }
-                  },
-                  "items": null
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}

+ 2 - 0
hx-wms/src/main/java/com/fjhx/wms/entity/contract/dto/ContractMrpInfoSelectDto.java

@@ -14,4 +14,6 @@ import lombok.Setter;
 @Setter
 public class ContractMrpInfoSelectDto extends BaseSelectDto {
 
+    private Long contractId;
+
 }

+ 37 - 0
hx-wms/src/main/java/com/fjhx/wms/entity/contract/vo/ContractMrpInfoVo.java

@@ -4,6 +4,8 @@ import com.fjhx.wms.entity.contract.po.ContractMrpInfo;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.math.BigDecimal;
+
 /**
  * 合同物料MRP信息列表查询返回值实体
  *
@@ -14,4 +16,39 @@ import lombok.Setter;
 @Setter
 public class ContractMrpInfoVo extends ContractMrpInfo {
 
+    /**
+     * 订单号
+     */
+    private String orderCode;
+
+    private String productCode;
+    private String productName;
+    private String productLength;
+    private String productWidth;
+    private String productHeight;
+    private String productColor;
+
+    /**
+     * 订单量
+     */
+    private BigDecimal orderQuantity;
+
+    /**
+     * 需求量
+     */
+    private BigDecimal demandQuantity;
+    /**
+     * 领料数量
+     */
+    private BigDecimal prodOutQuantity;
+    /**
+     * 在途数量
+     */
+    private BigDecimal transitQuantity;
+
+    /**
+     * 欠量
+     */
+    private BigDecimal lackQuantity;
+
 }

+ 6 - 0
hx-wms/src/main/java/com/fjhx/wms/service/contract/impl/ContractMrpInfoServiceImpl.java

@@ -8,6 +8,7 @@ import com.fjhx.wms.entity.contract.vo.ContractMrpInfoVo;
 import com.fjhx.wms.mapper.contract.ContractMrpInfoMapper;
 import com.fjhx.wms.service.contract.ContractMrpInfoService;
 import com.ruoyi.common.utils.wrapper.IWrapper;
+import com.ruoyi.common.utils.wrapper.SqlField;
 import org.springframework.stereotype.Service;
 
 
@@ -25,6 +26,11 @@ public class ContractMrpInfoServiceImpl extends ServiceImpl<ContractMrpInfoMappe
     @Override
     public Page<ContractMrpInfoVo> getPage(ContractMrpInfoSelectDto dto) {
         IWrapper<ContractMrpInfo> wrapper = getWrapper();
+
+        wrapper.eq("cmi", ContractMrpInfo::getContractId, dto.getContractId());
+
+        wrapper.keyword(dto.getKeyword(), new SqlField("pi.name"), new SqlField("pi.custom_code"));
+
         wrapper.orderByDesc("cmi", ContractMrpInfo::getId);
         Page<ContractMrpInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         return page;

+ 51 - 7
hx-wms/src/main/resources/mapper/contract/ContractMrpInfoMapper.xml

@@ -2,15 +2,59 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fjhx.wms.mapper.contract.ContractMrpInfoMapper">
     <select id="getPage" resultType="com.fjhx.wms.entity.contract.vo.ContractMrpInfoVo">
-        select cmi.id,
-               cmi.contract_id,
+        SELECT cmi.contract_id,
+               c.`code`                           AS orderCode,
                cmi.material_id,
+               cpb1.quantity                      AS order_quantity,
+               sd.count                           AS demand_quantity,
                cmi.stock_quantity,
-               cmi.create_user,
-               cmi.create_time,
-               cmi.update_user,
-               cmi.update_time
-        from contract_mrp_info cmi
+               IFNULL(swd1.receipt_quantity, 0)   AS prod_out_quantity,
+               IFNULL(epp1.transit_quantity, 0)   AS transit_quantity,
+               (sd.count - cmi.stock_quantity - IFNULL(swd1.receipt_quantity, 0) -
+                IFNULL(epp1.transit_quantity, 0)) AS lack_quantity,
+               pi.custom_code                     AS product_code,
+               pi.name                            AS product_name,
+               pi.length                          AS product_length,
+               pi.width                           AS product_width,
+               pi.height                          AS product_height,
+               pi.color                           AS product_color
+        FROM contract_mrp_info cmi
+                 JOIN contract c ON cmi.contract_id = c.id
+                 LEFT JOIN product_info pi ON cmi.material_id = pi.id
+                 JOIN (SELECT cpb.contract_id,
+                              cpb.material_id,
+                              sum(cpb.quantity) AS quantity
+                       FROM contract_product_bom cpb
+                       WHERE cpb.type != 3
+                       GROUP BY
+                           cpb.contract_id,
+                           cpb.material_id) cpb1 ON cpb1.contract_id = cmi.contract_id
+            AND cpb1.material_id = cmi.material_id
+                 LEFT JOIN subscribe_detail sd ON sd.contract_id = cmi.contract_id
+            AND sd.product_id = cmi.material_id
+                 LEFT JOIN (SELECT sw.contract_id,
+                                   swd.product_id,
+                                   sum(swd.quantity)         AS quantity,
+                                   sum(swd.receipt_quantity) AS receipt_quantity
+                            FROM stock_wait_details swd
+                                     JOIN stock_wait sw ON swd.stock_wait_id = sw.id
+                            WHERE sw.business_type = 9
+                            GROUP BY sw.contract_id,
+                                     swd.product_id) swd1 ON swd1.contract_id = cmi.contract_id
+            AND swd1.product_id = cmi.material_id
+                 LEFT JOIN (SELECT epp.contract_id,
+                                   epp.product_id,
+                                   sum(
+                                           epp.quantity - IFNULL(swd.receipt_quantity, 0)) AS transit_quantity
+                            FROM ehsd_purchase_product epp
+                                     JOIN ehsd_purchase ep ON epp.purchase_id = ep.id
+                                     LEFT JOIN stock_wait_details swd ON swd.purchase_detail_id = epp.id
+                                     LEFT JOIN stock_wait sw ON swd.stock_wait_id = sw.id
+                                AND sw.business_type = 104
+                            WHERE ep.`status` IN (30, 60)
+                            GROUP BY epp.contract_id,
+                                     epp.product_id) epp1 ON epp1.contract_id = cmi.contract_id
+            AND epp1.product_id = cmi.material_id
             ${ew.customSqlSegment}
     </select>