소스 검색

增加接口:查询机构库存

zou.yingbin 4 년 전
부모
커밋
b5b201fe51
6개의 변경된 파일483개의 추가작업 그리고 0개의 파일을 삭제
  1. 22 0
      controllers/ermcp/qryAreaStock.go
  2. 139 0
      docs/docs.go
  3. 139 0
      docs/swagger.json
  4. 98 0
      docs/swagger.yaml
  5. 84 0
      models/ermcpAreaStock.go
  6. 1 0
      routers/router.go

+ 22 - 0
controllers/ermcp/qryAreaStock.go

@@ -84,3 +84,25 @@ func QueryAreaStockApplySum(c *gin.Context) {
 	m := models.ErmcpAreaStockApplySum{SPOTCONTRACTID: req.SPOTCONTRACTID}
 	a.DoGetDataEx(&m)
 }
+
+// QueryAreaStockReq 查询库存量请求
+type QueryAreaStockReq struct {
+	USERID int64 `form:"userid" binding:"required"` // 用户id
+}
+
+// QueryAreaStock
+// @Summary 查询机构库存(库存管理/当前库存)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Success 200 {array} models.ErmcpAreaStock
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryAreaStock [get]
+// @Tags 企业风险管理(app)
+func QueryAreaStock(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QueryAreaStockReq{}
+	a.DoBindReq(&req)
+	m := models.ErmcpAreaStock{USERID: req.USERID}
+	a.DoGetDataEx(&m)
+}

+ 139 - 0
docs/docs.go

@@ -1323,6 +1323,48 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp/QueryAreaStock": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询机构库存(库存管理/当前库存)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpAreaStock"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/QueryAreaStockApply": {
             "get": {
                 "security": [
@@ -10695,6 +10737,103 @@ var doc = `{
                 }
             }
         },
+        "models.ErmcpAreaStock": {
+            "type": "object",
+            "properties": {
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "curstock": {
+                    "description": "期末库存量(今日量)",
+                    "type": "number"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "modelname": {
+                    "description": "型号名称",
+                    "type": "string"
+                },
+                "oristock": {
+                    "description": "期初库存量(昨日量)",
+                    "type": "number"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID",
+                    "type": "integer"
+                },
+                "spotgoodsmodelid": {
+                    "description": "现货型号ID",
+                    "type": "integer"
+                },
+                "todaybuyinqty": {
+                    "description": "今日采购入库量",
+                    "type": "number"
+                },
+                "todayproduceinqty": {
+                    "description": "今日生产入库量",
+                    "type": "number"
+                },
+                "todayproduceoutqty": {
+                    "description": "今日生产出库量",
+                    "type": "number"
+                },
+                "todayselloutqty": {
+                    "description": "今日销售出库量",
+                    "type": "number"
+                },
+                "unitid": {
+                    "description": "单位id",
+                    "type": "integer"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "机构ID",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "机构名称",
+                    "type": "string"
+                },
+                "warehousecode": {
+                    "description": "仓库代码",
+                    "type": "string"
+                },
+                "warehouseinfoid": {
+                    "description": "仓库ID",
+                    "type": "string"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "warehousetype": {
+                    "description": "仓库类型 - 1 厂库  2 自有库  3 合作库",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "string"
+                },
+                "wrstandardname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.ErmcpAreaStockApply": {
             "type": "object",
             "properties": {

+ 139 - 0
docs/swagger.json

@@ -1307,6 +1307,48 @@
                 }
             }
         },
+        "/Ermcp/QueryAreaStock": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询机构库存(库存管理/当前库存)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpAreaStock"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/QueryAreaStockApply": {
             "get": {
                 "security": [
@@ -10679,6 +10721,103 @@
                 }
             }
         },
+        "models.ErmcpAreaStock": {
+            "type": "object",
+            "properties": {
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "curstock": {
+                    "description": "期末库存量(今日量)",
+                    "type": "number"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "modelname": {
+                    "description": "型号名称",
+                    "type": "string"
+                },
+                "oristock": {
+                    "description": "期初库存量(昨日量)",
+                    "type": "number"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID",
+                    "type": "integer"
+                },
+                "spotgoodsmodelid": {
+                    "description": "现货型号ID",
+                    "type": "integer"
+                },
+                "todaybuyinqty": {
+                    "description": "今日采购入库量",
+                    "type": "number"
+                },
+                "todayproduceinqty": {
+                    "description": "今日生产入库量",
+                    "type": "number"
+                },
+                "todayproduceoutqty": {
+                    "description": "今日生产出库量",
+                    "type": "number"
+                },
+                "todayselloutqty": {
+                    "description": "今日销售出库量",
+                    "type": "number"
+                },
+                "unitid": {
+                    "description": "单位id",
+                    "type": "integer"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "机构ID",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "机构名称",
+                    "type": "string"
+                },
+                "warehousecode": {
+                    "description": "仓库代码",
+                    "type": "string"
+                },
+                "warehouseinfoid": {
+                    "description": "仓库ID",
+                    "type": "string"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "warehousetype": {
+                    "description": "仓库类型 - 1 厂库  2 自有库  3 合作库",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "string"
+                },
+                "wrstandardname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.ErmcpAreaStockApply": {
             "type": "object",
             "properties": {

+ 98 - 0
docs/swagger.yaml

@@ -3022,6 +3022,78 @@ definitions:
         description: 现货商品名称
         type: string
     type: object
+  models.ErmcpAreaStock:
+    properties:
+      brandname:
+        description: 品牌名称
+        type: string
+      curstock:
+        description: 期末库存量(今日量)
+        type: number
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      enumdicname:
+        description: 单位名称
+        type: string
+      modelname:
+        description: 型号名称
+        type: string
+      oristock:
+        description: 期初库存量(昨日量)
+        type: number
+      spotgoodsbrandid:
+        description: 现货品牌ID
+        type: integer
+      spotgoodsmodelid:
+        description: 现货型号ID
+        type: integer
+      todaybuyinqty:
+        description: 今日采购入库量
+        type: number
+      todayproduceinqty:
+        description: 今日生产入库量
+        type: number
+      todayproduceoutqty:
+        description: 今日生产出库量
+        type: number
+      todayselloutqty:
+        description: 今日销售出库量
+        type: number
+      unitid:
+        description: 单位id
+        type: integer
+      updatetime:
+        description: 更新时间
+        type: string
+      userid:
+        description: 机构ID
+        type: integer
+      username:
+        description: 机构名称
+        type: string
+      warehousecode:
+        description: 仓库代码
+        type: string
+      warehouseinfoid:
+        description: 仓库ID
+        type: string
+      warehousename:
+        description: 仓库名称
+        type: string
+      warehousetype:
+        description: 仓库类型 - 1 厂库  2 自有库  3 合作库
+        type: integer
+      wrstandardcode:
+        description: 现货商品代码
+        type: string
+      wrstandardid:
+        description: 现货商品ID
+        type: string
+      wrstandardname:
+        description: 现货商品名称
+        type: string
+    type: object
   models.ErmcpAreaStockApply:
     properties:
       applyid:
@@ -10207,6 +10279,32 @@ paths:
       summary: 查询现货月报表详情(菜单:报表查询/现货月报表/现货月报表详情)
       tags:
       - 企业风险管理(app)
+  /Ermcp/QueryAreaStock:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.ErmcpAreaStock'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询机构库存(库存管理/当前库存)
+      tags:
+      - 企业风险管理(app)
   /Ermcp/QueryAreaStockApply:
     get:
       parameters:

+ 84 - 0
models/ermcpAreaStock.go

@@ -157,6 +157,9 @@ func (r *ErmcpAreaStockApply) buildSql() string {
 	if len(r.FilterStatus) > 0 {
 		sqlId.Join(fmt.Sprintf(" and t.APPLYSTATUS in(%v)", r.FilterStatus))
 	}
+
+	// 排序
+	sqlId.Join(" order by t.APPLYTIME desc")
 	return sqlId.String()
 }
 
@@ -206,3 +209,84 @@ func (r *ErmcpAreaStockApplySum) GetDataEx() (interface{}, error) {
 	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
 	return sData, err
 }
+
+// ErmcpAreaStock 机构库存表
+type ErmcpAreaStock struct {
+	TODAYBUYINQTY      float64 `json:"todaybuyinqty"  xorm:"'TODAYBUYINQTY'"`           // 今日采购入库量
+	TODAYPRODUCEINQTY  float64 `json:"todayproduceinqty"  xorm:"'TODAYPRODUCEINQTY'"`   // 今日生产入库量
+	TODAYSELLOUTQTY    float64 `json:"todayselloutqty"  xorm:"'TODAYSELLOUTQTY'"`       // 今日销售出库量
+	TODAYPRODUCEOUTQTY float64 `json:"todayproduceoutqty"  xorm:"'TODAYPRODUCEOUTQTY'"` // 今日生产出库量
+	UPDATETIME         string  `json:"updatetime"  xorm:"'UPDATETIME'"`                 // 更新时间
+	USERID             int64   `json:"userid"  xorm:"'USERID'"`                         // 机构ID
+	WRSTANDARDID       string  `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`             // 现货商品ID
+	SPOTGOODSMODELID   int32   `json:"spotgoodsmodelid"  xorm:"'SPOTGOODSMODELID'"`     // 现货型号ID
+	SPOTGOODSBRANDID   int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"`     // 现货品牌ID
+	WAREHOUSEINFOID    string  `json:"warehouseinfoid"  xorm:"'WAREHOUSEINFOID'"`       // 仓库ID
+	DELIVERYGOODSID    int64   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`       // 现货品种ID
+	ORISTOCK           float64 `json:"oristock"  xorm:"'ORISTOCK'"`                     // 期初库存量(昨日量)
+	CURSTOCK           float64 `json:"curstock"  xorm:"'CURSTOCK'"`                     // 期末库存量(今日量)
+	WRSTANDARDNAME     string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`         // 现货商品名称
+	WRSTANDARDCODE     string  `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`         // 现货商品代码
+	UNITID             int32   `json:"unitid"  xorm:"'UNITID'"`                         // 单位id
+	BRANDNAME          string  `json:"brandname"  xorm:"'BRANDNAME'"`                   // 品牌名称
+	MODELNAME          string  `json:"modelname"  xorm:"'MODELNAME'"`                   // 型号名称
+	WAREHOUSENAME      string  `json:"warehousename"  xorm:"'WAREHOUSENAME'"`           // 仓库名称
+	WAREHOUSECODE      string  `json:"warehousecode"  xorm:"'WAREHOUSECODE'"`           // 仓库代码
+	WAREHOUSETYPE      int32   `json:"warehousetype"  xorm:"'WAREHOUSETYPE'"`           // 仓库类型 - 1 厂库  2 自有库  3 合作库
+	USERNAME           string  `json:"username"`                                        // 机构名称
+	ENUMDICNAME        string  `json:"enumdicname"`                                     // 单位名称
+}
+
+func (r *ErmcpAreaStock) calc() {
+	r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
+	r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
+}
+
+func (r *ErmcpAreaStock) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT t.TODAYBUYINQTY," +
+		"       t.TODAYPRODUCEINQTY," +
+		"       t.TODAYSELLOUTQTY," +
+		"       t.TODAYPRODUCEOUTQTY," +
+		"       to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
+		"       t.USERID," +
+		"       t.WRSTANDARDID," +
+		"       t.SPOTGOODSMODELID," +
+		"       t.SPOTGOODSBRANDID," +
+		"       t.WAREHOUSEINFOID," +
+		"       t.DELIVERYGOODSID," +
+		"       t.ORISTOCK," +
+		"       t.CURSTOCK," +
+		"       w.wrstandardname," +
+		"       w.wrstandardcode," +
+		"       w.unitid," +
+		"       gb.brandname," +
+		"       gm.modelname," +
+		"       h.warehousename," +
+		"       h.warehousecode," +
+		"       h.warehousetype" +
+		"  FROM ERMCP_AREASTOCK t" +
+		"  LEFT JOIN WRSTANDARD w" +
+		"    on t.wrstandardid = w.wrstandardid" +
+		"  LEFT JOIN SPOTGOODSBRAND gb" +
+		"    on t.spotgoodsbrandid = gb.brandid" +
+		"  LEFT JOIN SPOTGOODSMODEL gm" +
+		"    on t.spotgoodsmodelid = gm.modelid" +
+		"  LEFT JOIN WAREHOUSEINFO h" +
+		"    on t.warehouseinfoid = h.autoid" +
+		" WHERE 1 = 1"
+	sqlId.And("t.USERID", r.USERID)
+	sqlId.Join(" order by t.WRSTANDARDID, t.UPDATETIME desc")
+	return sqlId.String()
+}
+
+// GetDataEx 获取机构库存信息
+func (r *ErmcpAreaStock) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpAreaStock, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	if err == nil {
+		for i := range sData {
+			sData[i].calc()
+		}
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

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