Bladeren bron

增加接口:查已登记出入库信息

zou.yingbin 4 jaren geleden
bovenliggende
commit
a773d48aee
6 gewijzigde bestanden met toevoegingen van 283 en 17 verwijderingen
  1. 31 6
      controllers/ermcp/qryAreaStock.go
  2. 79 2
      docs/docs.go
  3. 79 2
      docs/swagger.json
  4. 53 2
      docs/swagger.yaml
  5. 40 5
      models/ermcpAreaStock.go
  6. 1 0
      routers/router.go

+ 31 - 6
controllers/ermcp/qryAreaStock.go

@@ -48,14 +48,39 @@ func QueryAreaStockApply(c *gin.Context) {
 	req := QryAreaStockApplyReq{}
 	a.DoBindReq(&req)
 	m := models.ErmcpAreaStockApply{
-		USERID: req.USERID,
-		FilterType: req.INOUTTYPE,
-		SPOTCONTRACTID: req.SPOTCONTRACTID,
-		WRSTANDARDID: req.WRSTANDARDID,
+		USERID:           req.USERID,
+		FilterType:       req.INOUTTYPE,
+		SPOTCONTRACTID:   req.SPOTCONTRACTID,
+		WRSTANDARDID:     req.WRSTANDARDID,
 		SPOTGOODSBRANDID: req.SPOTGOODSBRANDID,
 		SPOTGOODSMODELID: req.SPOTGOODSMODELID,
-		WAREHOUSEINFOID: req.WAREHOUSEINFOID,
-		FilterStatus: req.APPLYSTATUS,
+		WAREHOUSEINFOID:  req.WAREHOUSEINFOID,
+		FilterStatus:     req.APPLYSTATUS,
 	}
 	a.DoGetDataEx(&m)
 }
+
+// QueryAreaStockApplySum 出入库汇总请求
+type QueryAreaStockApplySumReq struct {
+	SPOTCONTRACTID string `form:"spotcontractid"` // 合同ID
+}
+
+// QueryAreaStockApplySumRsp 出入库汇总响应
+type QueryAreaStockApplySumRsp models.ErmcpAreaStockApplySum
+
+// QueryAreaStockApplySum
+// @Summary 查询已登记出入库信息(入库登记/已入库信息 | 出库登记/已出库信息)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param spotcontractid query int false "合同ID"
+// @Success 200 {array} QueryAreaStockApplySumRsp
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryAreaStockApplySum [get]
+// @Tags 企业风险管理(app)
+func QueryAreaStockApplySum(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QueryAreaStockApplySumReq{}
+	a.DoBindReq(&req)
+	m := models.ErmcpAreaStockApplySum{SPOTCONTRACTID: req.SPOTCONTRACTID}
+	a.DoGetDataEx(&m)
+}

+ 79 - 2
docs/docs.go

@@ -1407,6 +1407,47 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp/QueryAreaStockApplySum": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询已登记出入库信息(入库登记/已入库信息 | 出库登记/已出库信息)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "合同ID",
+                        "name": "spotcontractid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/ermcp.QueryAreaStockApplySumRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/QueryAvaildGoodsGroup": {
             "get": {
                 "security": [
@@ -2808,7 +2849,7 @@ var doc = `{
                         "required": true
                     },
                     {
-                        "type": "integer",
+                        "type": "string",
                         "description": "仓库状态(可多项,逗号隔开) 1:正常 2:注销 3:待审核 4:审核拒绝",
                         "name": "status",
                         "in": "query"
@@ -8428,6 +8469,9 @@ var doc = `{
         "ermcp.QryWrStandardRsp": {
             "$ref": "#/definitions/models.ErmcpWrstandard"
         },
+        "ermcp.QueryAreaStockApplySumRsp": {
+            "$ref": "#/definitions/models.ErmcpAreaStockApplySum"
+        },
         "ermcp.QueryErmcpTradePositionRsp": {
             "type": "object",
             "properties": {
@@ -10763,7 +10807,7 @@ var doc = `{
                     "type": "string"
                 },
                 "spotcontractid": {
-                    "description": "关联现货合同ID [1:采购入库 2:销售出库 ]",
+                    "description": "关联现货合同ID",
                     "type": "string"
                 },
                 "spotgoodsbrandid": {
@@ -10812,6 +10856,39 @@ var doc = `{
                 }
             }
         },
+        "models.ErmcpAreaStockApplySum": {
+            "type": "object",
+            "properties": {
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "inouttype": {
+                    "description": "出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库",
+                    "type": "integer"
+                },
+                "modelname": {
+                    "description": "型号名称",
+                    "type": "string"
+                },
+                "spotcontractid": {
+                    "description": "关联现货合同ID",
+                    "type": "string"
+                },
+                "spotgoodsbrandid": {
+                    "description": "品牌id",
+                    "type": "integer"
+                },
+                "spotgoodsmodelid": {
+                    "description": "型号id",
+                    "type": "integer"
+                },
+                "totalqty": {
+                    "description": "总数量",
+                    "type": "number"
+                }
+            }
+        },
         "models.ErmcpAvalidGoodsGroupModel": {
             "type": "object",
             "properties": {

+ 79 - 2
docs/swagger.json

@@ -1391,6 +1391,47 @@
                 }
             }
         },
+        "/Ermcp/QueryAreaStockApplySum": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询已登记出入库信息(入库登记/已入库信息 | 出库登记/已出库信息)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "合同ID",
+                        "name": "spotcontractid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/ermcp.QueryAreaStockApplySumRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/QueryAvaildGoodsGroup": {
             "get": {
                 "security": [
@@ -2792,7 +2833,7 @@
                         "required": true
                     },
                     {
-                        "type": "integer",
+                        "type": "string",
                         "description": "仓库状态(可多项,逗号隔开) 1:正常 2:注销 3:待审核 4:审核拒绝",
                         "name": "status",
                         "in": "query"
@@ -8412,6 +8453,9 @@
         "ermcp.QryWrStandardRsp": {
             "$ref": "#/definitions/models.ErmcpWrstandard"
         },
+        "ermcp.QueryAreaStockApplySumRsp": {
+            "$ref": "#/definitions/models.ErmcpAreaStockApplySum"
+        },
         "ermcp.QueryErmcpTradePositionRsp": {
             "type": "object",
             "properties": {
@@ -10747,7 +10791,7 @@
                     "type": "string"
                 },
                 "spotcontractid": {
-                    "description": "关联现货合同ID [1:采购入库 2:销售出库 ]",
+                    "description": "关联现货合同ID",
                     "type": "string"
                 },
                 "spotgoodsbrandid": {
@@ -10796,6 +10840,39 @@
                 }
             }
         },
+        "models.ErmcpAreaStockApplySum": {
+            "type": "object",
+            "properties": {
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "inouttype": {
+                    "description": "出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库",
+                    "type": "integer"
+                },
+                "modelname": {
+                    "description": "型号名称",
+                    "type": "string"
+                },
+                "spotcontractid": {
+                    "description": "关联现货合同ID",
+                    "type": "string"
+                },
+                "spotgoodsbrandid": {
+                    "description": "品牌id",
+                    "type": "integer"
+                },
+                "spotgoodsmodelid": {
+                    "description": "型号id",
+                    "type": "integer"
+                },
+                "totalqty": {
+                    "description": "总数量",
+                    "type": "number"
+                }
+            }
+        },
         "models.ErmcpAvalidGoodsGroupModel": {
             "type": "object",
             "properties": {

+ 53 - 2
docs/swagger.yaml

@@ -1369,6 +1369,8 @@ definitions:
     $ref: '#/definitions/models.ErmcpWrstandDetail'
   ermcp.QryWrStandardRsp:
     $ref: '#/definitions/models.ErmcpWrstandard'
+  ermcp.QueryAreaStockApplySumRsp:
+    $ref: '#/definitions/models.ErmcpAreaStockApplySum'
   ermcp.QueryErmcpTradePositionRsp:
     properties:
       agreeunit:
@@ -3104,7 +3106,7 @@ definitions:
         description: 销售方名称
         type: string
       spotcontractid:
-        description: 关联现货合同ID [1:采购入库 2:销售出库 ]
+        description: 关联现货合同ID
         type: string
       spotgoodsbrandid:
         description: 现货品牌ID
@@ -3140,6 +3142,30 @@ definitions:
         description: 现货商品名称
         type: string
     type: object
+  models.ErmcpAreaStockApplySum:
+    properties:
+      brandname:
+        description: 品牌名称
+        type: string
+      inouttype:
+        description: 出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库
+        type: integer
+      modelname:
+        description: 型号名称
+        type: string
+      spotcontractid:
+        description: 关联现货合同ID
+        type: string
+      spotgoodsbrandid:
+        description: 品牌id
+        type: integer
+      spotgoodsmodelid:
+        description: 型号id
+        type: integer
+      totalqty:
+        description: 总数量
+        type: number
+    type: object
   models.ErmcpAvalidGoodsGroupModel:
     properties:
       goodsgroupid:
@@ -10235,6 +10261,31 @@ paths:
       summary: 查询库存申请(出入库记录|库存审核)
       tags:
       - 企业风险管理(app)
+  /Ermcp/QueryAreaStockApplySum:
+    get:
+      parameters:
+      - description: 合同ID
+        in: query
+        name: spotcontractid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/ermcp.QueryAreaStockApplySumRsp'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询已登记出入库信息(入库登记/已入库信息 | 出库登记/已出库信息)
+      tags:
+      - 企业风险管理(app)
   /Ermcp/QueryAvaildGoodsGroup:
     get:
       parameters:
@@ -11111,7 +11162,7 @@ paths:
       - description: 仓库状态(可多项,逗号隔开) 1:正常 2:注销 3:待审核 4:审核拒绝
         in: query
         name: status
-        type: integer
+        type: string
       produces:
       - application/json
       responses:

+ 40 - 5
models/ermcpAreaStock.go

@@ -22,7 +22,7 @@ type ErmcpAreaStockApply struct {
 	SPOTGOODSMODELID int32   `json:"spotgoodsmodelid"  xorm:"'SPOTGOODSMODELID'"` // 现货型号ID
 	SPOTGOODSBRANDID int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"` // 现货品牌ID
 	DELIVERYGOODSID  int64   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`   // 现货品种ID
-	SPOTCONTRACTID   string  `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'"`     // 关联现货合同ID [1:采购入库 2:销售出库 ]
+	SPOTCONTRACTID   string  `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'"`     // 关联现货合同ID
 	WAREHOUSEINFOID  string  `json:"warehouseinfoid"  xorm:"'WAREHOUSEINFOID'"`   // 现货仓库ID
 	QTY              float64 `json:"qty"  xorm:"'QTY'"`                           // 数量
 	APPLYSTATUS      int32   `json:"applystatus"  xorm:"'APPLYSTATUS'"`           // 申请状态 - 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回
@@ -56,7 +56,7 @@ type ErmcpAreaStockApply struct {
 	ENUMDICNAME      string  `json:"enumdicname"`                                 // 现货商品单位名称
 
 	FilterStatus string `json:"-"` // 查询条件, 申请状态, 逗号隔开
-	FilterType string `json:"-"` // 查询条件, 出入库类型, 逗号隔开
+	FilterType   string `json:"-"` // 查询条件, 出入库类型, 逗号隔开
 }
 
 func (r *ErmcpAreaStockApply) calc() {
@@ -67,13 +67,13 @@ func (r *ErmcpAreaStockApply) calc() {
 	// 申请人名称
 	if r.APPLYSRC == 1 {
 		r.APPLYNAME = mtpcache.GetSystemmangerLoginCode(r.APPLYID)
-	}else {
+	} else {
 		r.APPLYNAME = mtpcache.GetLoginCodeByLoginId(r.APPLYID)
 	}
 	// 审核人名称
 	if r.AUDITSRC == 1 {
 		r.AUDITNAME = mtpcache.GetSystemmangerLoginCode(r.AUDITID)
-	}else {
+	} else {
 		r.AUDITNAME = mtpcache.GetLoginCodeByLoginId(r.AUDITID)
 	}
 	// 单位名称
@@ -170,4 +170,39 @@ func (r *ErmcpAreaStockApply) GetDataEx() (interface{}, error) {
 		}
 	}
 	return sData, err
-}
+}
+
+// ErmcpAreaStockApplySum 合同出入库数量汇总
+type ErmcpAreaStockApplySum struct {
+	INOUTTYPE        int32   `json:"inouttype"  xorm:"'INOUTTYPE'"`               // 出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库
+	SPOTGOODSMODELID int32   `json:"spotgoodsmodelid"  xorm:"'SPOTGOODSMODELID'"` // 型号id
+	SPOTGOODSBRANDID int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"` // 品牌id
+	BRANDNAME        string  `json:"brandname"  xorm:"'BRANDNAME'"`               // 品牌名称
+	MODELNAME        string  `json:"modelname"  xorm:"'MODELNAME'"`               // 型号名称
+	TOTALQTY         float64 `json:"totalqty"  xorm:"'TOTALQTY'"`                 // 总数量
+	SPOTCONTRACTID   string  `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'"`     // 关联现货合同ID
+}
+
+func (r *ErmcpAreaStockApplySum) buildSql() string {
+	sqlId := "select a.*, gb.brandname, gm.modelname" +
+		"  from (SELECT t.INOUTTYPE," +
+		"               t.SPOTGOODSMODELID," +
+		"               t.SPOTGOODSBRANDID," +
+		"               sum(t.QTY) TOTALQTY" +
+		"          FROM ERMCP_AREAINOUTSTOCKAPPLY t" +
+		"         WHERE t.applystatus= 2 and t.inouttype = %v and t.spotcontractid = %v" +
+		"         group by t.inouttype, t.spotgoodsbrandid, t.spotgoodsmodelid) a" +
+		"  left join spotgoodsbrand gb" +
+		"    on a.spotgoodsbrandid = gb.brandid" +
+		"  left join spotgoodsmodel gm" +
+		"    on a.spotgoodsmodelid = gm.modelid"
+	sqlId = fmt.Sprintf(sqlId, r.INOUTTYPE, r.SPOTCONTRACTID)
+	return sqlId
+}
+
+// GetDataEx 获取合同出入库汇总信息
+func (r *ErmcpAreaStockApplySum) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpAreaStockApplySum, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -363,6 +363,7 @@ func InitRouter() *gin.Engine {
 		ermcpR.GET("/QueryPendingAuditInfo", ermcp.QueryPendingAuditInfo)
 		ermcpR.GET("/QueryWarehouseInfo", ermcp.QueryWarehouseInfo)
 		ermcpR.GET("/QueryAreaStockApply", ermcp.QueryAreaStockApply)
+		ermcpR.GET("/QueryAreaStockApplySum", ermcp.QueryAreaStockApplySum)
 
 		// 期货相关
 		// 查询企业风管期货商品信息