Ver código fonte

增加3接口和修改bug#94622 #94624

zou.yingbin 4 anos atrás
pai
commit
194bb64211

+ 154 - 0
controllers/ermcp3/qryErmcp3.go

@@ -9,7 +9,9 @@ package ermcp3
 import (
 	"github.com/gin-gonic/gin"
 	"mtp2_if/global/app"
+	"mtp2_if/global/e"
 	"mtp2_if/models"
+	"net/http"
 )
 
 // QueryDeliveryGoods
@@ -251,3 +253,155 @@ func QueryGoodsWrstandard(c *gin.Context) {
 		DELIVERYGOODSID: req.DELIVERYGOODSID}
 	appG.DoGetDataI(&m)
 }
+
+// QueryAreaStockApply
+// @Summary 查询库存申请(出入库记录|库存审核)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param deliverygoodsid query int false "现货商品ID"
+// @Param inouttype query string false "出入库类型(可多项,逗号隔开) 1:采购入库 2:销售出库 3:生产入库 4:生产出库"
+// @Param spotcontractid query int false "合同ID"
+// @Param wrstandardid query int false "品类ID"
+// @Param spotgoodsbrandid query int false "品牌ID"
+// @Param warehouseinfoid query int false "仓库ID"
+// @Param applystatus query string false "申请状态(可多项,逗号隔开)1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回"
+// @Success 200 {array} models.Ermcp3AreaStockApply
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QueryAreaStockApply [get]
+// @Tags 企业风险管理v3(app)
+func QueryAreaStockApply(c *gin.Context) {
+	a := app.NewGinUtils(c)
+	req := struct {
+		USERID           int64  `form:"userid" binding:"required"` // 用户
+		WRSTANDARDID     string `form:"wrstandardid"`              // 品类
+		SPOTGOODSBRANDID int32  `form:"spotgoodsbrandid"`          // 品牌
+		SPOTCONTRACTID   string `form:"spotcontractid"`            // 合同id
+		WAREHOUSEINFOID  string `form:"warehouseinfoid"`           // 仓库id
+		DELIVERYGOODSID  int32  `form:"deliverygoodsid"`           // 现货商品id
+		FilterStatus     string `form:"applystatus"`               // 申请状态
+		FilterType       string `form:"inouttype"`                 // 出入库类型
+	}{}
+	a.DoBindReq(&req)
+	m := models.Ermcp3AreaStockApply{
+		USERID:           req.USERID,
+		FilterType:       req.FilterType,
+		SPOTCONTRACTID:   req.SPOTCONTRACTID,
+		WRSTANDARDID:     req.WRSTANDARDID,
+		SPOTGOODSBRANDID: req.SPOTGOODSBRANDID,
+		DELIVERYGOODSID:  req.DELIVERYGOODSID,
+		WAREHOUSEINFOID:  req.WAREHOUSEINFOID,
+		FilterStatus:     req.FilterStatus,
+	}
+	a.DoGetDataI(&m)
+}
+
+// QueryAreaStockApplySum
+// @Summary 查询已登记出入库信息(入库登记/已入库信息 | 出库登记/已出库信息)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param spotcontractid query int false "合同ID"
+// @Success 200 {array} models.Ermcp3AreaStockApplySum
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QueryAreaStockApplySum [get]
+// @Tags 企业风险管理v3(app)
+func QueryAreaStockApplySum(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := struct {
+		SPOTCONTRACTID string `form:"spotcontractid"` // 合同id
+	}{}
+	a.DoBindReq(&req)
+	m := models.Ermcp3AreaStockApplySum{SPOTCONTRACTID: req.SPOTCONTRACTID}
+	a.DoGetDataI(&m)
+}
+
+// QueryAreaStockReport
+// @Summary 查询库存报表
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param querytype query int true "查询类型 1-日报表 2-月报表"
+// @Param querydate query string true "查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)"
+// @Param deliverygoodsid query int false "现货商品ID"
+// @Param wrstandardid query int false "品类ID"
+// @Param spotgoodsbrandid query int false "品牌ID"
+// @Param warehouseinfoid query int false "仓库ID"
+// @Success 200 {array} models.Ermcp3AreaStockReport
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QueryAreaStockReport [get]
+// @Tags 企业风险管理v3(app)
+func QueryAreaStockReport(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := struct {
+		USERID           int64  `form:"userid" binding:"required"` // 机构ID
+		WRSTANDARDID     string `form:"wrstandardid"`              // 品类ID
+		SPOTGOODSBRANDID int32  `form:"spotgoodsbrandid"`          // 现货品牌ID
+		WAREHOUSEINFOID  string `form:"warehouseinfoid"`           // 仓库ID
+		DELIVERYGOODSID  int32  `form:"deliverygoodsid"`           // 现货品种id
+
+		ReportType int32  `form:"querytype" binding:"required"` // 报表类型 1-日报表 2-月报表
+		ReportDate string `form:"querydate" binding:"required"` // 格式 日报表(YYYYMMDD) 月报表(YYYYMM)
+	}{}
+	a.DoBindReq(&req)
+	if QueryDate(req.ReportDate).IsNumberic(req.ReportType) {
+		m := models.Ermcp3AreaStockReport{USERID: req.USERID, WRSTANDARDID: req.WRSTANDARDID,
+			SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, DELIVERYGOODSID: req.DELIVERYGOODSID,
+			WAREHOUSEINFOID: req.WAREHOUSEINFOID, ReportDate: req.ReportDate, ReportType: req.ReportType}
+		a.DoGetDataI(&m)
+	} else {
+		a.Gin.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+	}
+}
+
+// QueryAreaStockReportDetail
+// @Summary 查询库存报表明细
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param querytype query int true "查询类型 1-日报表明细 2-月报表明细"
+// @Param detailtype query int true "明细类型 1:入库明细(采购入库+生产入库) 2:出库明细(销售出库+生产出库)"
+// @Param querydate query string true "查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)"
+// @Param deliverygoodsid query int false "现货商品ID"
+// @Param wrstandardid query int false "品类ID"
+// @Param spotgoodsbrandid query int false "品牌ID"
+// @Param warehouseinfoid query int false "仓库ID"
+// @Success 200 {array} models.Ermcp3AreaStockApply
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QueryAreaStockReportDetail [get]
+// @Tags 企业风险管理v3(app)
+func QueryAreaStockReportDetail(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := struct {
+		USERID           int64  `form:"userid" binding:"required"`     // 机构ID
+		DELIVERYGOODSID  int32  `form:"deliverygoodsid"`               // 现货品种id
+		WRSTANDARDID     string `form:"wrstandardid"`                  // 品类ID
+		SPOTGOODSBRANDID int32  `form:"spotgoodsbrandid"`              // 品牌id
+		WAREHOUSEINFOID  string `form:"warehouseinfoid"`               // 现货仓库ID
+		QUERYTYPE        int32  `form:"querytype" binding:"required"`  // 查询类型
+		QUERYDATE        string `form:"querydate" binding:"required"`  // 查询日期
+		DETAILTYPE       int32  `form:"detailtype" binding:"required"` // 明细类型
+	}{}
+	a.DoBindReq(&req)
+	if QueryDate(req.QUERYDATE).IsNumberic(req.QUERYTYPE) {
+		var beginDate, endDate string
+		if req.QUERYTYPE == 1 {
+			beginDate = req.QUERYDATE
+			endDate = beginDate
+		} else if req.QUERYTYPE == 2 {
+			beginDate = req.QUERYDATE + "01"
+			endDate = req.QUERYDATE + "31"
+		}
+		m := models.Ermcp3AreaStockApply{USERID: req.USERID, WRSTANDARDID: req.WRSTANDARDID,
+			SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, DELIVERYGOODSID: req.DELIVERYGOODSID,
+			WAREHOUSEINFOID: req.WAREHOUSEINFOID, BeginDate: beginDate, EndDate: endDate, APPLYSTATUS: 2}
+		// 出入库类型(可多项,逗号隔开) 1:采购入库 2:销售出库 3:生产入库 4:生产出库"
+		if req.DETAILTYPE == 1 {
+			m.FilterStatus = "1,3"
+		} else if req.DETAILTYPE == 2 {
+			m.FilterStatus = "2,4"
+		}
+		a.DoGetDataI(&m)
+	} else {
+		a.Gin.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+	}
+}

+ 2 - 2
controllers/ermcp3/qryErmcp3Report.go

@@ -97,7 +97,7 @@ func QryReportDayFinanceFp(c *gin.Context) {
 		TRADEDATE string `form:"tradedate" binding:"required"` // 交易日
 	}{}
 	a.DoBindReq(&req)
-	m := models.ErmcpReportOPLog{USERID: req.USERID, TRADEDATE: req.TRADEDATE, LogTypeFilter: "11, 12"}
+	m := models.Ermcp3ReportOPLog{USERID: req.USERID, TRADEDATE: req.TRADEDATE, LogTypeFilter: "11, 12"}
 	a.DoGetDataI(&m)
 }
 
@@ -146,7 +146,7 @@ func QryReportMonthSpot(c *gin.Context) {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param userid query int true "用户ID"
-// @Param wrstandardid query int true "现货商品id"
+// @Param deliverygoodsid query int true "现货商品id"
 // @Param cycletime query string true "周期时间:月(格式:yyyyMM)"
 // @Success 200 {array} models.Ermcp3ReportDaySpot
 // @Failure 500 {object} app.Response

+ 663 - 76
docs/docs.go

@@ -4368,7 +4368,7 @@ var doc = `{
                     {
                         "type": "integer",
                         "description": "现货商品id",
-                        "name": "wrstandardid",
+                        "name": "deliverygoodsid",
                         "in": "query",
                         "required": true
                     },
@@ -4399,7 +4399,7 @@ var doc = `{
                 }
             }
         },
-        "/Ermcp3/QueryDGFactoryItem": {
+        "/Ermcp3/QueryAreaStockApply": {
             "get": {
                 "security": [
                     {
@@ -4412,36 +4412,55 @@ var doc = `{
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询品种要素定义项",
+                "summary": "查询库存申请(出入库记录|库存审核)",
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "所属机构ID",
-                        "name": "areauserid",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品ID",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "出入库类型(可多项,逗号隔开) 1:采购入库 2:销售出库 3:生产入库 4:生产出库",
+                        "name": "inouttype",
                         "in": "query"
                     },
                     {
                         "type": "integer",
-                        "description": "选择项ID(SEQ_DGFACTORYITEM)",
-                        "name": "dgfactoryitemid",
+                        "description": "合同ID",
+                        "name": "spotcontractid",
                         "in": "query"
                     },
                     {
                         "type": "integer",
-                        "description": "现货品种ID",
-                        "name": "deliverygoodsid",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
                         "in": "query"
                     },
                     {
                         "type": "integer",
-                        "description": "要素项类型",
-                        "name": "dgfactoryitemtypeid",
+                        "description": "品牌ID",
+                        "name": "spotgoodsbrandid",
                         "in": "query"
                     },
                     {
                         "type": "integer",
-                        "description": "顺序",
-                        "name": "orderindex",
+                        "description": "仓库ID",
+                        "name": "warehouseinfoid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "申请状态(可多项,逗号隔开)1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回",
+                        "name": "applystatus",
                         "in": "query"
                     }
                 ],
@@ -4451,7 +4470,7 @@ var doc = `{
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.ErmcpDGFactoryItem"
+                                "$ref": "#/definitions/models.Ermcp3AreaStockApply"
                             }
                         }
                     },
@@ -4464,7 +4483,7 @@ var doc = `{
                 }
             }
         },
-        "/Ermcp3/QueryDeliveryGoods": {
+        "/Ermcp3/QueryAreaStockApplySum": {
             "get": {
                 "security": [
                     {
@@ -4477,19 +4496,12 @@ var doc = `{
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询现货商品",
+                "summary": "查询已登记出入库信息(入库登记/已入库信息 | 出库登记/已出库信息)",
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "所属机构id",
-                        "name": "areauserid",
-                        "in": "query",
-                        "required": true
-                    },
-                    {
-                        "type": "integer",
-                        "description": "排除已配置的现货商品 1-排除",
-                        "name": "excludecfg",
+                        "description": "合同ID",
+                        "name": "spotcontractid",
                         "in": "query"
                     }
                 ],
@@ -4499,7 +4511,7 @@ var doc = `{
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.ErmcpDeliveryGoods"
+                                "$ref": "#/definitions/models.Ermcp3AreaStockApplySum"
                             }
                         }
                     },
@@ -4512,7 +4524,7 @@ var doc = `{
                 }
             }
         },
-        "/Ermcp3/QueryDeliveryGoodsDetail": {
+        "/Ermcp3/QueryAreaStockReport": {
             "get": {
                 "security": [
                     {
@@ -4525,25 +4537,51 @@ var doc = `{
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询现货商品详情",
+                "summary": "查询库存报表",
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "所属机构id",
-                        "name": "areauserid",
+                        "description": "用户ID",
+                        "name": "userid",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "integer",
-                        "description": "现货商品id",
+                        "description": "查询类型 1-日报表 2-月报表",
+                        "name": "querytype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)",
+                        "name": "querydate",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品ID",
                         "name": "deliverygoodsid",
                         "in": "query"
                     },
                     {
                         "type": "integer",
-                        "description": "是否查询关联交易商品 1-查询",
-                        "name": "qrytradegoods",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品牌ID",
+                        "name": "spotgoodsbrandid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "仓库ID",
+                        "name": "warehouseinfoid",
                         "in": "query"
                     }
                 ],
@@ -4553,7 +4591,7 @@ var doc = `{
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.ErmcpDeliveryGoodsDetail"
+                                "$ref": "#/definitions/models.Ermcp3AreaStockReport"
                             }
                         }
                     },
@@ -4566,7 +4604,7 @@ var doc = `{
                 }
             }
         },
-        "/Ermcp3/QueryExposureDetail": {
+        "/Ermcp3/QueryAreaStockReportDetail": {
             "get": {
                 "security": [
                     {
@@ -4579,21 +4617,59 @@ var doc = `{
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询敞口现货明细",
+                "summary": "查询库存报表明细",
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "所属机构ID",
-                        "name": "areaUserId",
+                        "description": "用户ID",
+                        "name": "userid",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "integer",
-                        "description": "套保商品",
-                        "name": "middleGoodsId",
+                        "description": "查询类型 1-日报表明细 2-月报表明细",
+                        "name": "querytype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "明细类型 1:入库明细(采购入库+生产入库) 2:出库明细(销售出库+生产出库)",
+                        "name": "detailtype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)",
+                        "name": "querydate",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品ID",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品牌ID",
+                        "name": "spotgoodsbrandid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "仓库ID",
+                        "name": "warehouseinfoid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4602,7 +4678,7 @@ var doc = `{
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3ExposureDetail"
+                                "$ref": "#/definitions/models.Ermcp3AreaStockApply"
                             }
                         }
                     },
@@ -4615,7 +4691,7 @@ var doc = `{
                 }
             }
         },
-        "/Ermcp3/QueryExposureSpot": {
+        "/Ermcp3/QueryDGFactoryItem": {
             "get": {
                 "security": [
                     {
@@ -4628,14 +4704,37 @@ var doc = `{
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询敞口现货头寸(敞口/现货头寸)",
+                "summary": "查询品种要素定义项",
                 "parameters": [
                     {
                         "type": "integer",
                         "description": "所属机构ID",
-                        "name": "areaUserId",
-                        "in": "query",
-                        "required": true
+                        "name": "areauserid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "选择项ID(SEQ_DGFACTORYITEM)",
+                        "name": "dgfactoryitemid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品种ID",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "要素项类型",
+                        "name": "dgfactoryitemtypeid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "顺序",
+                        "name": "orderindex",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4644,7 +4743,7 @@ var doc = `{
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3AreaSpot"
+                                "$ref": "#/definitions/models.ErmcpDGFactoryItem"
                             }
                         }
                     },
@@ -4657,7 +4756,7 @@ var doc = `{
                 }
             }
         },
-        "/Ermcp3/QueryExposureSpotDetail": {
+        "/Ermcp3/QueryDeliveryGoods": {
             "get": {
                 "security": [
                     {
@@ -4670,21 +4769,20 @@ var doc = `{
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询敞口现货头寸明细(敞口/现货头寸/现货明细)",
+                "summary": "查询现货商品",
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "所属机构ID",
+                        "description": "所属机构id",
                         "name": "areauserid",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "integer",
-                        "description": "现货品种ID",
-                        "name": "deliverygoodsid",
-                        "in": "query",
-                        "required": true
+                        "description": "排除已配置的现货商品 1-排除",
+                        "name": "excludecfg",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4693,7 +4791,7 @@ var doc = `{
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3AreaSpotDetail"
+                                "$ref": "#/definitions/models.ErmcpDeliveryGoods"
                             }
                         }
                     },
@@ -4706,7 +4804,7 @@ var doc = `{
                 }
             }
         },
-        "/Ermcp3/QueryGoodsWrstandard": {
+        "/Ermcp3/QueryDeliveryGoodsDetail": {
             "get": {
                 "security": [
                     {
@@ -4719,11 +4817,11 @@ var doc = `{
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询商品品类",
+                "summary": "查询现货商品详情",
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "所属机构ID",
+                        "description": "所属机构id",
                         "name": "areauserid",
                         "in": "query",
                         "required": true
@@ -4733,6 +4831,12 @@ var doc = `{
                         "description": "现货商品id",
                         "name": "deliverygoodsid",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "是否查询关联交易商品 1-查询",
+                        "name": "qrytradegoods",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4741,7 +4845,7 @@ var doc = `{
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3Wrstandard"
+                                "$ref": "#/definitions/models.ErmcpDeliveryGoodsDetail"
                             }
                         }
                     },
@@ -4754,7 +4858,7 @@ var doc = `{
                 }
             }
         },
-        "/Ermcp3/QueryGoodsbrand": {
+        "/Ermcp3/QueryExposureDetail": {
             "get": {
                 "security": [
                     {
@@ -4767,12 +4871,19 @@ var doc = `{
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询商品品牌",
+                "summary": "查询敞口现货明细",
                 "parameters": [
                     {
                         "type": "integer",
                         "description": "所属机构ID",
-                        "name": "areauserid",
+                        "name": "areaUserId",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套保商品",
+                        "name": "middleGoodsId",
                         "in": "query",
                         "required": true
                     }
@@ -4783,7 +4894,7 @@ var doc = `{
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3Brand"
+                                "$ref": "#/definitions/models.Ermcp3ExposureDetail"
                             }
                         }
                     },
@@ -4796,7 +4907,7 @@ var doc = `{
                 }
             }
         },
-        "/Ermcp3/QuerySpotContract": {
+        "/Ermcp3/QueryExposureSpot": {
             "get": {
                 "security": [
                     {
@@ -4809,25 +4920,206 @@ var doc = `{
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询现货合同",
+                "summary": "查询敞口现货头寸(敞口/现货头寸)",
                 "parameters": [
                     {
                         "type": "integer",
                         "description": "所属机构ID",
-                        "name": "areauserid",
-                        "in": "query",
-                        "required": true
-                    },
-                    {
-                        "type": "integer",
-                        "description": "查询类型 1-全部 2-待点价 3-履约结算 4-已完成",
-                        "name": "querytype",
+                        "name": "areaUserId",
                         "in": "query",
                         "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3AreaSpot"
+                            }
+                        }
                     },
-                    {
-                        "type": "integer",
-                        "description": "用户ID",
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp3/QueryExposureSpotDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询敞口现货头寸明细(敞口/现货头寸/现货明细)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品种ID",
+                        "name": "deliverygoodsid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3AreaSpotDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp3/QueryGoodsWrstandard": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询商品品类",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品id",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3Wrstandard"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp3/QueryGoodsbrand": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询商品品牌",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3Brand"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp3/QuerySpotContract": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询现货合同",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "查询类型 1-全部 2-待点价 3-履约结算 4-已完成",
+                        "name": "querytype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
                         "name": "userid",
                         "in": "query"
                     },
@@ -12796,6 +13088,301 @@ var doc = `{
                 }
             }
         },
+        "models.Ermcp3AreaStockApply": {
+            "type": "object",
+            "properties": {
+                "applyid": {
+                    "description": "申请人",
+                    "type": "integer"
+                },
+                "applyname": {
+                    "description": "申请人名称",
+                    "type": "string"
+                },
+                "applyremark": {
+                    "description": "申请备注",
+                    "type": "string"
+                },
+                "applysrc": {
+                    "description": "申请来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "applystatus": {
+                    "description": "申请状态 - 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回",
+                    "type": "integer"
+                },
+                "applytime": {
+                    "description": "申请时间",
+                    "type": "string"
+                },
+                "auditid": {
+                    "description": "审核人",
+                    "type": "integer"
+                },
+                "auditname": {
+                    "description": "审核人名称",
+                    "type": "string"
+                },
+                "auditremark": {
+                    "description": "审核备注",
+                    "type": "string"
+                },
+                "auditsrc": {
+                    "description": "审核来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "audittime": {
+                    "description": "审核时间",
+                    "type": "string"
+                },
+                "audittradedate": {
+                    "description": "审核交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "buyuserid": {
+                    "description": "采购方userid",
+                    "type": "integer"
+                },
+                "buyusername": {
+                    "description": "采购方名称",
+                    "type": "string"
+                },
+                "contractno": {
+                    "description": "合同编号",
+                    "type": "string"
+                },
+                "contractqty": {
+                    "description": "合同量",
+                    "type": "number"
+                },
+                "contracttype": {
+                    "description": "现货合同类型 - 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种id",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "现货商品单位名称",
+                    "type": "string"
+                },
+                "inoutapplyid": {
+                    "description": "申请ID(607+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "inouttype": {
+                    "description": "出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库",
+                    "type": "integer"
+                },
+                "pricetype": {
+                    "description": "定价类型 - 1:一口价 2:点价 3:暂定价",
+                    "type": "integer"
+                },
+                "qty": {
+                    "description": "数量",
+                    "type": "number"
+                },
+                "selluserid": {
+                    "description": "销售方userid",
+                    "type": "integer"
+                },
+                "sellusername": {
+                    "description": "销售方名称",
+                    "type": "string"
+                },
+                "spotcontractid": {
+                    "description": "关联现货合同ID",
+                    "type": "string"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID",
+                    "type": "integer"
+                },
+                "unitid": {
+                    "description": "单位id",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "机构ID",
+                    "type": "integer"
+                },
+                "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.Ermcp3AreaStockApplySum": {
+            "type": "object",
+            "properties": {
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "inouttype": {
+                    "description": "出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库",
+                    "type": "integer"
+                },
+                "spotcontractid": {
+                    "description": "关联现货合同ID",
+                    "type": "string"
+                },
+                "spotgoodsbrandid": {
+                    "description": "品牌id",
+                    "type": "integer"
+                },
+                "totalqty": {
+                    "description": "总数量",
+                    "type": "number"
+                },
+                "wrstandardid": {
+                    "description": "品类id",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.Ermcp3AreaStockReport": {
+            "type": "object",
+            "properties": {
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "curstock": {
+                    "description": "期末库存量",
+                    "type": "number"
+                },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种id",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "goodsunitid": {
+                    "description": "现货单位id",
+                    "type": "integer"
+                },
+                "oristock": {
+                    "description": "期初库存量",
+                    "type": "number"
+                },
+                "spotgoodsbrandid": {
+                    "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.Ermcp3Brand": {
             "type": "object",
             "properties": {

+ 663 - 76
docs/swagger.json

@@ -4352,7 +4352,7 @@
                     {
                         "type": "integer",
                         "description": "现货商品id",
-                        "name": "wrstandardid",
+                        "name": "deliverygoodsid",
                         "in": "query",
                         "required": true
                     },
@@ -4383,7 +4383,7 @@
                 }
             }
         },
-        "/Ermcp3/QueryDGFactoryItem": {
+        "/Ermcp3/QueryAreaStockApply": {
             "get": {
                 "security": [
                     {
@@ -4396,36 +4396,55 @@
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询品种要素定义项",
+                "summary": "查询库存申请(出入库记录|库存审核)",
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "所属机构ID",
-                        "name": "areauserid",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品ID",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "出入库类型(可多项,逗号隔开) 1:采购入库 2:销售出库 3:生产入库 4:生产出库",
+                        "name": "inouttype",
                         "in": "query"
                     },
                     {
                         "type": "integer",
-                        "description": "选择项ID(SEQ_DGFACTORYITEM)",
-                        "name": "dgfactoryitemid",
+                        "description": "合同ID",
+                        "name": "spotcontractid",
                         "in": "query"
                     },
                     {
                         "type": "integer",
-                        "description": "现货品种ID",
-                        "name": "deliverygoodsid",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
                         "in": "query"
                     },
                     {
                         "type": "integer",
-                        "description": "要素项类型",
-                        "name": "dgfactoryitemtypeid",
+                        "description": "品牌ID",
+                        "name": "spotgoodsbrandid",
                         "in": "query"
                     },
                     {
                         "type": "integer",
-                        "description": "顺序",
-                        "name": "orderindex",
+                        "description": "仓库ID",
+                        "name": "warehouseinfoid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "申请状态(可多项,逗号隔开)1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回",
+                        "name": "applystatus",
                         "in": "query"
                     }
                 ],
@@ -4435,7 +4454,7 @@
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.ErmcpDGFactoryItem"
+                                "$ref": "#/definitions/models.Ermcp3AreaStockApply"
                             }
                         }
                     },
@@ -4448,7 +4467,7 @@
                 }
             }
         },
-        "/Ermcp3/QueryDeliveryGoods": {
+        "/Ermcp3/QueryAreaStockApplySum": {
             "get": {
                 "security": [
                     {
@@ -4461,19 +4480,12 @@
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询现货商品",
+                "summary": "查询已登记出入库信息(入库登记/已入库信息 | 出库登记/已出库信息)",
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "所属机构id",
-                        "name": "areauserid",
-                        "in": "query",
-                        "required": true
-                    },
-                    {
-                        "type": "integer",
-                        "description": "排除已配置的现货商品 1-排除",
-                        "name": "excludecfg",
+                        "description": "合同ID",
+                        "name": "spotcontractid",
                         "in": "query"
                     }
                 ],
@@ -4483,7 +4495,7 @@
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.ErmcpDeliveryGoods"
+                                "$ref": "#/definitions/models.Ermcp3AreaStockApplySum"
                             }
                         }
                     },
@@ -4496,7 +4508,7 @@
                 }
             }
         },
-        "/Ermcp3/QueryDeliveryGoodsDetail": {
+        "/Ermcp3/QueryAreaStockReport": {
             "get": {
                 "security": [
                     {
@@ -4509,25 +4521,51 @@
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询现货商品详情",
+                "summary": "查询库存报表",
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "所属机构id",
-                        "name": "areauserid",
+                        "description": "用户ID",
+                        "name": "userid",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "integer",
-                        "description": "现货商品id",
+                        "description": "查询类型 1-日报表 2-月报表",
+                        "name": "querytype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)",
+                        "name": "querydate",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品ID",
                         "name": "deliverygoodsid",
                         "in": "query"
                     },
                     {
                         "type": "integer",
-                        "description": "是否查询关联交易商品 1-查询",
-                        "name": "qrytradegoods",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品牌ID",
+                        "name": "spotgoodsbrandid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "仓库ID",
+                        "name": "warehouseinfoid",
                         "in": "query"
                     }
                 ],
@@ -4537,7 +4575,7 @@
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.ErmcpDeliveryGoodsDetail"
+                                "$ref": "#/definitions/models.Ermcp3AreaStockReport"
                             }
                         }
                     },
@@ -4550,7 +4588,7 @@
                 }
             }
         },
-        "/Ermcp3/QueryExposureDetail": {
+        "/Ermcp3/QueryAreaStockReportDetail": {
             "get": {
                 "security": [
                     {
@@ -4563,21 +4601,59 @@
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询敞口现货明细",
+                "summary": "查询库存报表明细",
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "所属机构ID",
-                        "name": "areaUserId",
+                        "description": "用户ID",
+                        "name": "userid",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "integer",
-                        "description": "套保商品",
-                        "name": "middleGoodsId",
+                        "description": "查询类型 1-日报表明细 2-月报表明细",
+                        "name": "querytype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "明细类型 1:入库明细(采购入库+生产入库) 2:出库明细(销售出库+生产出库)",
+                        "name": "detailtype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)",
+                        "name": "querydate",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品ID",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品牌ID",
+                        "name": "spotgoodsbrandid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "仓库ID",
+                        "name": "warehouseinfoid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4586,7 +4662,7 @@
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3ExposureDetail"
+                                "$ref": "#/definitions/models.Ermcp3AreaStockApply"
                             }
                         }
                     },
@@ -4599,7 +4675,7 @@
                 }
             }
         },
-        "/Ermcp3/QueryExposureSpot": {
+        "/Ermcp3/QueryDGFactoryItem": {
             "get": {
                 "security": [
                     {
@@ -4612,14 +4688,37 @@
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询敞口现货头寸(敞口/现货头寸)",
+                "summary": "查询品种要素定义项",
                 "parameters": [
                     {
                         "type": "integer",
                         "description": "所属机构ID",
-                        "name": "areaUserId",
-                        "in": "query",
-                        "required": true
+                        "name": "areauserid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "选择项ID(SEQ_DGFACTORYITEM)",
+                        "name": "dgfactoryitemid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品种ID",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "要素项类型",
+                        "name": "dgfactoryitemtypeid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "顺序",
+                        "name": "orderindex",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4628,7 +4727,7 @@
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3AreaSpot"
+                                "$ref": "#/definitions/models.ErmcpDGFactoryItem"
                             }
                         }
                     },
@@ -4641,7 +4740,7 @@
                 }
             }
         },
-        "/Ermcp3/QueryExposureSpotDetail": {
+        "/Ermcp3/QueryDeliveryGoods": {
             "get": {
                 "security": [
                     {
@@ -4654,21 +4753,20 @@
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询敞口现货头寸明细(敞口/现货头寸/现货明细)",
+                "summary": "查询现货商品",
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "所属机构ID",
+                        "description": "所属机构id",
                         "name": "areauserid",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "integer",
-                        "description": "现货品种ID",
-                        "name": "deliverygoodsid",
-                        "in": "query",
-                        "required": true
+                        "description": "排除已配置的现货商品 1-排除",
+                        "name": "excludecfg",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4677,7 +4775,7 @@
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3AreaSpotDetail"
+                                "$ref": "#/definitions/models.ErmcpDeliveryGoods"
                             }
                         }
                     },
@@ -4690,7 +4788,7 @@
                 }
             }
         },
-        "/Ermcp3/QueryGoodsWrstandard": {
+        "/Ermcp3/QueryDeliveryGoodsDetail": {
             "get": {
                 "security": [
                     {
@@ -4703,11 +4801,11 @@
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询商品品类",
+                "summary": "查询现货商品详情",
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "所属机构ID",
+                        "description": "所属机构id",
                         "name": "areauserid",
                         "in": "query",
                         "required": true
@@ -4717,6 +4815,12 @@
                         "description": "现货商品id",
                         "name": "deliverygoodsid",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "是否查询关联交易商品 1-查询",
+                        "name": "qrytradegoods",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4725,7 +4829,7 @@
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3Wrstandard"
+                                "$ref": "#/definitions/models.ErmcpDeliveryGoodsDetail"
                             }
                         }
                     },
@@ -4738,7 +4842,7 @@
                 }
             }
         },
-        "/Ermcp3/QueryGoodsbrand": {
+        "/Ermcp3/QueryExposureDetail": {
             "get": {
                 "security": [
                     {
@@ -4751,12 +4855,19 @@
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询商品品牌",
+                "summary": "查询敞口现货明细",
                 "parameters": [
                     {
                         "type": "integer",
                         "description": "所属机构ID",
-                        "name": "areauserid",
+                        "name": "areaUserId",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套保商品",
+                        "name": "middleGoodsId",
                         "in": "query",
                         "required": true
                     }
@@ -4767,7 +4878,7 @@
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3Brand"
+                                "$ref": "#/definitions/models.Ermcp3ExposureDetail"
                             }
                         }
                     },
@@ -4780,7 +4891,7 @@
                 }
             }
         },
-        "/Ermcp3/QuerySpotContract": {
+        "/Ermcp3/QueryExposureSpot": {
             "get": {
                 "security": [
                     {
@@ -4793,25 +4904,206 @@
                 "tags": [
                     "企业风险管理v3(app)"
                 ],
-                "summary": "查询现货合同",
+                "summary": "查询敞口现货头寸(敞口/现货头寸)",
                 "parameters": [
                     {
                         "type": "integer",
                         "description": "所属机构ID",
-                        "name": "areauserid",
-                        "in": "query",
-                        "required": true
-                    },
-                    {
-                        "type": "integer",
-                        "description": "查询类型 1-全部 2-待点价 3-履约结算 4-已完成",
-                        "name": "querytype",
+                        "name": "areaUserId",
                         "in": "query",
                         "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3AreaSpot"
+                            }
+                        }
                     },
-                    {
-                        "type": "integer",
-                        "description": "用户ID",
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp3/QueryExposureSpotDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询敞口现货头寸明细(敞口/现货头寸/现货明细)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品种ID",
+                        "name": "deliverygoodsid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3AreaSpotDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp3/QueryGoodsWrstandard": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询商品品类",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品id",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3Wrstandard"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp3/QueryGoodsbrand": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询商品品牌",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3Brand"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp3/QuerySpotContract": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询现货合同",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "查询类型 1-全部 2-待点价 3-履约结算 4-已完成",
+                        "name": "querytype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
                         "name": "userid",
                         "in": "query"
                     },
@@ -12780,6 +13072,301 @@
                 }
             }
         },
+        "models.Ermcp3AreaStockApply": {
+            "type": "object",
+            "properties": {
+                "applyid": {
+                    "description": "申请人",
+                    "type": "integer"
+                },
+                "applyname": {
+                    "description": "申请人名称",
+                    "type": "string"
+                },
+                "applyremark": {
+                    "description": "申请备注",
+                    "type": "string"
+                },
+                "applysrc": {
+                    "description": "申请来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "applystatus": {
+                    "description": "申请状态 - 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回",
+                    "type": "integer"
+                },
+                "applytime": {
+                    "description": "申请时间",
+                    "type": "string"
+                },
+                "auditid": {
+                    "description": "审核人",
+                    "type": "integer"
+                },
+                "auditname": {
+                    "description": "审核人名称",
+                    "type": "string"
+                },
+                "auditremark": {
+                    "description": "审核备注",
+                    "type": "string"
+                },
+                "auditsrc": {
+                    "description": "审核来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "audittime": {
+                    "description": "审核时间",
+                    "type": "string"
+                },
+                "audittradedate": {
+                    "description": "审核交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "buyuserid": {
+                    "description": "采购方userid",
+                    "type": "integer"
+                },
+                "buyusername": {
+                    "description": "采购方名称",
+                    "type": "string"
+                },
+                "contractno": {
+                    "description": "合同编号",
+                    "type": "string"
+                },
+                "contractqty": {
+                    "description": "合同量",
+                    "type": "number"
+                },
+                "contracttype": {
+                    "description": "现货合同类型 - 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种id",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "现货商品单位名称",
+                    "type": "string"
+                },
+                "inoutapplyid": {
+                    "description": "申请ID(607+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "inouttype": {
+                    "description": "出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库",
+                    "type": "integer"
+                },
+                "pricetype": {
+                    "description": "定价类型 - 1:一口价 2:点价 3:暂定价",
+                    "type": "integer"
+                },
+                "qty": {
+                    "description": "数量",
+                    "type": "number"
+                },
+                "selluserid": {
+                    "description": "销售方userid",
+                    "type": "integer"
+                },
+                "sellusername": {
+                    "description": "销售方名称",
+                    "type": "string"
+                },
+                "spotcontractid": {
+                    "description": "关联现货合同ID",
+                    "type": "string"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID",
+                    "type": "integer"
+                },
+                "unitid": {
+                    "description": "单位id",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "机构ID",
+                    "type": "integer"
+                },
+                "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.Ermcp3AreaStockApplySum": {
+            "type": "object",
+            "properties": {
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "inouttype": {
+                    "description": "出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库",
+                    "type": "integer"
+                },
+                "spotcontractid": {
+                    "description": "关联现货合同ID",
+                    "type": "string"
+                },
+                "spotgoodsbrandid": {
+                    "description": "品牌id",
+                    "type": "integer"
+                },
+                "totalqty": {
+                    "description": "总数量",
+                    "type": "number"
+                },
+                "wrstandardid": {
+                    "description": "品类id",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.Ermcp3AreaStockReport": {
+            "type": "object",
+            "properties": {
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "curstock": {
+                    "description": "期末库存量",
+                    "type": "number"
+                },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种id",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "goodsunitid": {
+                    "description": "现货单位id",
+                    "type": "integer"
+                },
+                "oristock": {
+                    "description": "期初库存量",
+                    "type": "number"
+                },
+                "spotgoodsbrandid": {
+                    "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.Ermcp3Brand": {
             "type": "object",
             "properties": {

+ 408 - 1
docs/swagger.yaml

@@ -3141,6 +3141,225 @@ definitions:
         description: 时间
         type: string
     type: object
+  models.Ermcp3AreaStockApply:
+    properties:
+      applyid:
+        description: 申请人
+        type: integer
+      applyname:
+        description: 申请人名称
+        type: string
+      applyremark:
+        description: 申请备注
+        type: string
+      applysrc:
+        description: 申请来源 - 1:管理端 2:终端
+        type: integer
+      applystatus:
+        description: 申请状态 - 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回
+        type: integer
+      applytime:
+        description: 申请时间
+        type: string
+      auditid:
+        description: 审核人
+        type: integer
+      auditname:
+        description: 审核人名称
+        type: string
+      auditremark:
+        description: 审核备注
+        type: string
+      auditsrc:
+        description: 审核来源 - 1:管理端 2:终端
+        type: integer
+      audittime:
+        description: 审核时间
+        type: string
+      audittradedate:
+        description: 审核交易日(yyyyMMdd)
+        type: string
+      brandname:
+        description: 品牌名称
+        type: string
+      buyuserid:
+        description: 采购方userid
+        type: integer
+      buyusername:
+        description: 采购方名称
+        type: string
+      contractno:
+        description: 合同编号
+        type: string
+      contractqty:
+        description: 合同量
+        type: number
+      contracttype:
+        description: 现货合同类型 - 1:采购 -1:销售
+        type: integer
+      deliverygoodscode:
+        description: 现货品种代码
+        type: string
+      deliverygoodsid:
+        description: 现货品种id
+        type: integer
+      deliverygoodsname:
+        description: 现货品种名称
+        type: string
+      enumdicname:
+        description: 现货商品单位名称
+        type: string
+      inoutapplyid:
+        description: 申请ID(607+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+      inouttype:
+        description: 出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库
+        type: integer
+      pricetype:
+        description: 定价类型 - 1:一口价 2:点价 3:暂定价
+        type: integer
+      qty:
+        description: 数量
+        type: number
+      selluserid:
+        description: 销售方userid
+        type: integer
+      sellusername:
+        description: 销售方名称
+        type: string
+      spotcontractid:
+        description: 关联现货合同ID
+        type: string
+      spotgoodsbrandid:
+        description: 现货品牌ID
+        type: integer
+      unitid:
+        description: 单位id
+        type: integer
+      userid:
+        description: 机构ID
+        type: integer
+      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.Ermcp3AreaStockApplySum:
+    properties:
+      brandname:
+        description: 品牌名称
+        type: string
+      inouttype:
+        description: 出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库
+        type: integer
+      spotcontractid:
+        description: 关联现货合同ID
+        type: string
+      spotgoodsbrandid:
+        description: 品牌id
+        type: integer
+      totalqty:
+        description: 总数量
+        type: number
+      wrstandardid:
+        description: 品类id
+        type: integer
+      wrstandardname:
+        description: 品类名称
+        type: string
+    type: object
+  models.Ermcp3AreaStockReport:
+    properties:
+      brandname:
+        description: 品牌名称
+        type: string
+      curstock:
+        description: 期末库存量
+        type: number
+      deliverygoodscode:
+        description: 现货品种代码
+        type: string
+      deliverygoodsid:
+        description: 现货品种id
+        type: integer
+      deliverygoodsname:
+        description: 现货品种名称
+        type: string
+      enumdicname:
+        description: 单位名称
+        type: string
+      goodsunitid:
+        description: 现货单位id
+        type: integer
+      oristock:
+        description: 期初库存量
+        type: number
+      spotgoodsbrandid:
+        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.Ermcp3Brand:
     properties:
       areauserid:
@@ -14222,7 +14441,7 @@ paths:
         type: integer
       - description: 现货商品id
         in: query
-        name: wrstandardid
+        name: deliverygoodsid
         required: true
         type: integer
       - description: 周期时间:月(格式:yyyyMM)
@@ -14248,6 +14467,194 @@ paths:
       summary: 查询现货月报表详情(菜单:报表查询/现货月报表/现货月报表详情)
       tags:
       - 企业风险管理v3(app)
+  /Ermcp3/QueryAreaStockApply:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 现货商品ID
+        in: query
+        name: deliverygoodsid
+        type: integer
+      - description: 出入库类型(可多项,逗号隔开) 1:采购入库 2:销售出库 3:生产入库 4:生产出库
+        in: query
+        name: inouttype
+        type: string
+      - description: 合同ID
+        in: query
+        name: spotcontractid
+        type: integer
+      - description: 品类ID
+        in: query
+        name: wrstandardid
+        type: integer
+      - description: 品牌ID
+        in: query
+        name: spotgoodsbrandid
+        type: integer
+      - description: 仓库ID
+        in: query
+        name: warehouseinfoid
+        type: integer
+      - description: 申请状态(可多项,逗号隔开)1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回
+        in: query
+        name: applystatus
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp3AreaStockApply'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询库存申请(出入库记录|库存审核)
+      tags:
+      - 企业风险管理v3(app)
+  /Ermcp3/QueryAreaStockApplySum:
+    get:
+      parameters:
+      - description: 合同ID
+        in: query
+        name: spotcontractid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp3AreaStockApplySum'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询已登记出入库信息(入库登记/已入库信息 | 出库登记/已出库信息)
+      tags:
+      - 企业风险管理v3(app)
+  /Ermcp3/QueryAreaStockReport:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 查询类型 1-日报表 2-月报表
+        in: query
+        name: querytype
+        required: true
+        type: integer
+      - description: 查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)
+        in: query
+        name: querydate
+        required: true
+        type: string
+      - description: 现货商品ID
+        in: query
+        name: deliverygoodsid
+        type: integer
+      - description: 品类ID
+        in: query
+        name: wrstandardid
+        type: integer
+      - description: 品牌ID
+        in: query
+        name: spotgoodsbrandid
+        type: integer
+      - description: 仓库ID
+        in: query
+        name: warehouseinfoid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp3AreaStockReport'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询库存报表
+      tags:
+      - 企业风险管理v3(app)
+  /Ermcp3/QueryAreaStockReportDetail:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 查询类型 1-日报表明细 2-月报表明细
+        in: query
+        name: querytype
+        required: true
+        type: integer
+      - description: 明细类型 1:入库明细(采购入库+生产入库) 2:出库明细(销售出库+生产出库)
+        in: query
+        name: detailtype
+        required: true
+        type: integer
+      - description: 查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)
+        in: query
+        name: querydate
+        required: true
+        type: string
+      - description: 现货商品ID
+        in: query
+        name: deliverygoodsid
+        type: integer
+      - description: 品类ID
+        in: query
+        name: wrstandardid
+        type: integer
+      - description: 品牌ID
+        in: query
+        name: spotgoodsbrandid
+        type: integer
+      - description: 仓库ID
+        in: query
+        name: warehouseinfoid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp3AreaStockApply'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询库存报表明细
+      tags:
+      - 企业风险管理v3(app)
   /Ermcp3/QueryDGFactoryItem:
     get:
       parameters:

+ 431 - 0
models/ermcp3.go

@@ -960,3 +960,434 @@ func (r *Ermcp3Wrstandard) GetDataEx() (interface{}, error) {
 	}
 	return sData, nil
 }
+
+// Ermcp3AreaStockApply 出入库申请
+type Ermcp3AreaStockApply struct {
+	INOUTAPPLYID      string  `json:"inoutapplyid"  xorm:"'INOUTAPPLYID'"`           // 申请ID(607+Unix秒时间戳(10位)+xxxxxx)
+	USERID            int64   `json:"userid"  xorm:"'USERID'"`                       // 机构ID
+	INOUTTYPE         int32   `json:"inouttype"  xorm:"'INOUTTYPE'"`                 // 出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库
+	WRSTANDARDID      string  `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`           // 品类ID
+	SPOTGOODSBRANDID  int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"`   // 现货品牌ID
+	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:已撤回
+	APPLYSRC          int32   `json:"applysrc"  xorm:"'APPLYSRC'"`                   // 申请来源 - 1:管理端 2:终端
+	APPLYID           int64   `json:"applyid"  xorm:"'APPLYID'"`                     // 申请人
+	APPLYREMARK       string  `json:"applyremark"  xorm:"'APPLYREMARK'"`             // 申请备注
+	APPLYTIME         string  `json:"applytime"  xorm:"'APPLYTIME'"`                 // 申请时间
+	AUDITSRC          int32   `json:"auditsrc"  xorm:"'AUDITSRC'"`                   // 审核来源 - 1:管理端 2:终端
+	AUDITID           int64   `json:"auditid"  xorm:"'AUDITID'"`                     // 审核人
+	AUDITTIME         string  `json:"audittime"  xorm:"'AUDITTIME'"`                 // 审核时间
+	AUDITREMARK       string  `json:"auditremark"  xorm:"'AUDITREMARK'"`             // 审核备注
+	AUDITTRADEDATE    string  `json:"audittradedate"  xorm:"'AUDITTRADEDATE'"`       // 审核交易日(yyyyMMdd)
+	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'"`                 // 品牌名称
+	WAREHOUSENAME     string  `json:"warehousename"  xorm:"'WAREHOUSENAME'"`         // 仓库名称
+	WAREHOUSECODE     string  `json:"warehousecode"  xorm:"'WAREHOUSECODE'"`         // 仓库代码
+	WAREHOUSETYPE     int32   `json:"warehousetype"  xorm:"'WAREHOUSETYPE'"`         // 仓库类型 - 1 厂库  2 自有库  3 合作库
+	CONTRACTNO        string  `json:"contractno"  xorm:"'CONTRACTNO'"`               // 合同编号
+	CONTRACTTYPE      int32   `json:"contracttype"  xorm:"'CONTRACTTYPE'"`           // 现货合同类型 - 1:采购 -1:销售
+	BUYUSERID         int64   `json:"buyuserid"  xorm:"'BUYUSERID'"`                 // 采购方userid
+	SELLUSERID        int64   `json:"selluserid"  xorm:"'SELLUSERID'"`               // 销售方userid
+	PRICETYPE         int32   `json:"pricetype"  xorm:"'PRICETYPE'"`                 // 定价类型 - 1:一口价 2:点价 3:暂定价
+	CONTRACTQTY       float64 `json:"contractqty"  xorm:"'CONTRACTQTY'"`             // 合同量
+	BUYUSERNAME       string  `json:"buyusername"`                                   // 采购方名称
+	SELLUSERNAME      string  `json:"sellusername"`                                  // 销售方名称
+	APPLYNAME         string  `json:"applyname"`                                     // 申请人名称
+	AUDITNAME         string  `json:"auditname"`                                     // 审核人名称
+	ENUMDICNAME       string  `json:"enumdicname"`                                   // 现货商品单位名称
+	DELIVERYGOODSID   int32   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`     // 现货品种id
+	DELIVERYGOODSCODE string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
+	DELIVERYGOODSNAME string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
+
+	FilterStatus string `json:"-"` // 查询条件, 申请状态, 逗号隔开
+	FilterType   string `json:"-"` // 查询条件, 出入库类型, 逗号隔开
+	BeginDate    string `json:"-"` // 开始日期
+	EndDate      string `json:"-"` // 结束日期
+}
+
+func (r *Ermcp3AreaStockApply) calc() {
+	// 采购方名称
+	r.BUYUSERNAME = mtpcache.GetUserNameByUserId(r.BUYUSERID)
+	// 销售方名称
+	r.SELLUSERNAME = mtpcache.GetUserNameByUserId(r.SELLUSERID)
+	// 申请人名称
+	if r.APPLYSRC == 1 {
+		r.APPLYNAME = mtpcache.GetSystemmangerLoginCode(r.APPLYID)
+	} else {
+		r.APPLYNAME = mtpcache.GetLoginCodeByLoginId(r.APPLYID)
+	}
+	// 审核人名称
+	if r.AUDITSRC == 1 {
+		r.AUDITNAME = mtpcache.GetSystemmangerLoginCode(r.AUDITID)
+	} else {
+		r.AUDITNAME = mtpcache.GetLoginCodeByLoginId(r.AUDITID)
+	}
+	// 单位名称
+	r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
+}
+
+func (r *Ermcp3AreaStockApply) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT to_char(t.INOUTAPPLYID) INOUTAPPLYID," +
+		"       t.USERID," +
+		"       t.INOUTTYPE," +
+		"       t.WRSTANDARDID," +
+		"       t.SPOTGOODSBRANDID," +
+		"       t.DELIVERYGOODSID," +
+		"       to_char(t.SPOTCONTRACTID) SPOTCONTRACTID," +
+		"       to_char(t.WAREHOUSEINFOID) WAREHOUSEINFOID," +
+		"       t.QTY," +
+		"       t.APPLYSTATUS," +
+		"       t.APPLYSRC," +
+		"       t.APPLYID," +
+		"       t.APPLYREMARK," +
+		"       to_char(t.APPLYTIME, 'yyyy-mm-dd hh24:mi:ss') APPLYTIME," +
+		"       t.AUDITSRC," +
+		"       t.AUDITID," +
+		"       to_char(t.AUDITTIME, 'yyyy-mm-dd hh24:mi:ss') AUDITTIME," +
+		"       t.AUDITREMARK," +
+		"       t.AUDITTRADEDATE," +
+		"       w.wrstandardname," +
+		"       w.wrstandardcode," +
+		"       g.goodsunitid unitid," +
+		"       gb.dgfactoryitemvalue brandname," +
+		"       h.warehousename," +
+		"       h.warehousecode," +
+		"       h.warehousetype," +
+		"       s.contractno," +
+		"       s.contracttype," +
+		"       s.buyuserid," +
+		"       s.selluserid," +
+		"       s.pricetype," +
+		"       s.qty CONTRACTQTY," +
+		"       g.deliverygoodscode," +
+		"       g.deliverygoodsname" +
+		"  FROM ERMCP_AREAINOUTSTOCKAPPLY t" +
+		"  left join wrstandard w" +
+		"    on t.wrstandardid = w.wrstandardid" +
+		"  left join dgfactoryitem gb" +
+		"    on t.spotgoodsbrandid = gb.dgfactoryitemid" +
+		"  left join deliverygoods g" +
+		"    on t.deliverygoodsid = g.deliverygoodsid" +
+		"  left join warehouseinfo h" +
+		"    on t.warehouseinfoid = h.autoid" +
+		"  left join ermcp_spotcontract s" +
+		"    on t.spotcontractid = s.spotcontractid" +
+		" WHERE 1 = 1"
+	// 用户id(必要条件)
+	sqlId.And("t.USERID", r.USERID)
+	// 合同id
+	if len(r.SPOTCONTRACTID) > 0 {
+		sqlId.And("t.SPOTCONTRACTID", r.SPOTCONTRACTID)
+	}
+	// 现货品种id
+	if r.DELIVERYGOODSID > 0 {
+		sqlId.And("t.DELIVERYGOODSID", r.DELIVERYGOODSID)
+	}
+	// 品类id
+	if len(r.WRSTANDARDID) > 0 {
+		sqlId.And("t.WRSTANDARDID", r.WRSTANDARDID)
+	}
+	// 品牌id
+	if r.SPOTGOODSBRANDID > 0 {
+		sqlId.And("t.SPOTGOODSBRANDID", r.SPOTGOODSBRANDID)
+	}
+	// 仓库id
+	if len(r.WAREHOUSEINFOID) > 0 {
+		sqlId.And("t.WAREHOUSEINFOID", r.WAREHOUSEINFOID)
+	}
+	// 日期范围
+	if len(r.BeginDate) > 0 {
+		if r.BeginDate == r.EndDate {
+			sqlId.And("t.audittradedate", r.BeginDate)
+		} else if r.EndDate > r.BeginDate {
+			sqlId.BiggerOrEq("t.audittradedate", r.BeginDate)
+			sqlId.LessOrEq("t.audittradedate", r.EndDate)
+		}
+	}
+	// 出入库类型
+	if len(r.FilterType) > 0 {
+		if len(r.FilterType) == 1 {
+			sqlId.And("t.INOUTTYPE", r.FilterType)
+		} else {
+			sqlId.Join(fmt.Sprintf(" and t.INOUTTYPE in(%v)", r.FilterType))
+		}
+	}
+	// 出入库状态
+	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()
+}
+
+// GetDataEx 查询库存申请(记录)
+func (r *Ermcp3AreaStockApply) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3AreaStockApply, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	if err == nil {
+		for i := range sData {
+			sData[i].calc()
+		}
+	}
+	return sData, err
+}
+
+// Ermcp3AreaStockApplySum 合同出入库数量汇总
+type Ermcp3AreaStockApplySum struct {
+	INOUTTYPE        int32   `json:"inouttype"  xorm:"'INOUTTYPE'"`               // 出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库
+	WRSTANDARDID     int32   `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`         // 品类id
+	SPOTGOODSBRANDID int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"` // 品牌id
+	BRANDNAME        string  `json:"brandname"  xorm:"'BRANDNAME'"`               // 品牌名称
+	WRSTANDARDNAME   string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`     // 品类名称
+	TOTALQTY         float64 `json:"totalqty"  xorm:"'TOTALQTY'"`                 // 总数量
+	SPOTCONTRACTID   string  `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'"`     // 关联现货合同ID
+}
+
+func (r *Ermcp3AreaStockApplySum) buildSql() string {
+	sqlId := "select a.*, gb.dgfactoryitemvalue brandname, w.wrstandardname" +
+		"  from (SELECT t.INOUTTYPE," +
+		"               t.wrstandardid," +
+		"               t.SPOTGOODSBRANDID," +
+		"               t.SPOTCONTRACTID," +
+		"               sum(t.QTY) TOTALQTY" +
+		"          FROM ERMCP_AREAINOUTSTOCKAPPLY t" +
+		"         WHERE t.applystatus = 2" +
+		"           and t.spotcontractid = %v" +
+		"         group by t.inouttype," +
+		"                  t.spotgoodsbrandid," +
+		"                  t.wrstandardid," +
+		"                  t.spotcontractid) a" +
+		"  left join dgfactoryitem gb" +
+		"    on a.spotgoodsbrandid = gb.dgfactoryitemid" +
+		"  left join wrstandard w" +
+		"    on a.wrstandardid = w.wrstandardid"
+	sqlId = fmt.Sprintf(sqlId, r.SPOTCONTRACTID)
+
+	// 不关联合同id
+	sqlId2 := "select a.*, gb.dgfactoryitemvalue brandname, w.wrstandardname" +
+		"  from (SELECT t.INOUTTYPE," +
+		"               t.wrstandardid," +
+		"               t.SPOTGOODSBRANDID," +
+		"               t.SPOTCONTRACTID," +
+		"               sum(t.QTY) TOTALQTY" +
+		"          FROM ERMCP_AREAINOUTSTOCKAPPLY t" +
+		"         WHERE t.applystatus = 2" +
+		"         group by t.inouttype," +
+		"                  t.spotgoodsbrandid," +
+		"                  t.wrstandardid," +
+		"                  t.spotcontractid) a" +
+		"  left join dgfactoryitem gb" +
+		"    on a.spotgoodsbrandid = gb.dgfactoryitemid" +
+		"  left join wrstandard w" +
+		"    on a.wrstandardid = w.wrstandardid"
+	if len(r.SPOTCONTRACTID) == 0 {
+		return sqlId2
+	}
+	return sqlId
+}
+
+// GetDataEx 获取合同出入库汇总信息
+func (r *Ermcp3AreaStockApplySum) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3AreaStockApplySum, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	return sData, err
+}
+
+// Ermcp3AreaStock 机构库存表
+type Ermcp3AreaStock 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
+	SPOTGOODSBRANDID   int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"`     // 现货品牌ID
+	WAREHOUSEINFOID    string  `json:"warehouseinfoid"  xorm:"'WAREHOUSEINFOID'"`       // 仓库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'"`                   // 品牌名称
+	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"`                                     // 单位名称
+	DELIVERYGOODSID    int32   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`       // 现货品种id
+	DELIVERYGOODSCODE  string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`   // 现货品种代码
+	DELIVERYGOODSNAME  string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`   // 现货品种名称
+	GOODSUNITID        int32   `json:"goodsunitid"  xorm:"'GOODSUNITID'"`               // 现货商品单位id
+}
+
+func (r *Ermcp3AreaStock) calc() {
+	r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
+	r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
+}
+
+func (r *Ermcp3AreaStock) 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.SPOTGOODSBRANDID," +
+		"       t.WAREHOUSEINFOID," +
+		"       t.DELIVERYGOODSID," +
+		"       t.ORISTOCK," +
+		"       t.CURSTOCK," +
+		"       w.wrstandardname," +
+		"       w.wrstandardcode," +
+		"       w.unitid," +
+		"       gb.dgfactoryitemvalue brandname," +
+		"       h.warehousename," +
+		"       h.warehousecode," +
+		"       h.warehousetype," +
+		"       g.deliverygoodsid," +
+		"       g.deliverygoodscode," +
+		"       g.deliverygoodsname," +
+		"       g.goodsunitid" +
+		"  FROM ERMCP_AREASTOCK t" +
+		"  LEFT JOIN WRSTANDARD w" +
+		"    on t.wrstandardid = w.wrstandardid" +
+		"  LEFT JOIN dgfactoryitem gb" +
+		"    on t.spotgoodsbrandid = gb.dgfactoryitemvalue" +
+		"  LEFT JOIN deliverygoods g" +
+		"    on t.deliverygoodsid = g.deliverygoodsid" +
+		"  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 *Ermcp3AreaStock) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3AreaStock, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	if err == nil {
+		for i := range sData {
+			sData[i].calc()
+		}
+	}
+	return sData, err
+}
+
+// Ermcp3AreaStockReport 库存报表
+type Ermcp3AreaStockReport struct {
+	USERID             int64   `json:"userid"  xorm:"'USERID'"`                         // 机构ID
+	WRSTANDARDID       string  `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`             // 品类ID
+	SPOTGOODSBRANDID   int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"`     // 现货品牌ID
+	WAREHOUSEINFOID    string  `json:"warehouseinfoid"  xorm:"'WAREHOUSEINFOID'"`       // 仓库ID
+	ORISTOCK           float64 `json:"oristock"  xorm:"'ORISTOCK'"`                     // 期初库存量
+	CURSTOCK           float64 `json:"curstock"  xorm:"'CURSTOCK'"`                     // 期末库存量
+	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'"`                 // 更新时间
+	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'"`                   // 品牌名称
+	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"`                                     // 单位名称
+	DELIVERYGOODSID    int32   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`       // 现货品种id
+	DELIVERYGOODSCODE  string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`   // 现货品种代码
+	DELIVERYGOODSNAME  string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`   // 现货品种名称
+	GOODSUNITID        int32   `json:"goodsunitid"  xorm:"'GOODSUNITID'"`               // 现货单位id
+
+	ReportType int32  `json:"-"` // 报表类型 1-日报表 2-月报表
+	ReportDate string `json:"-"` // 格式 日报表(YYYYMMDD) 月报表(YYYYMM)
+}
+
+func (r *Ermcp3AreaStockReport) calc() {
+	r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
+	r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
+}
+
+func (r *Ermcp3AreaStockReport) 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.SPOTGOODSBRANDID," +
+		"       t.WAREHOUSEINFOID," +
+		"       t.ORISTOCK," +
+		"       t.CURSTOCK," +
+		"       w.wrstandardname," +
+		"       w.wrstandardcode," +
+		"       w.unitid," +
+		"       gb.dgfactoryitemvalue brandname," +
+		"       h.warehousename," +
+		"       h.warehousecode," +
+		"       h.warehousetype," +
+		"       g.deliverygoodsid," +
+		"       g.deliverygoodscode," +
+		"       g.deliverygoodsname," +
+		"       g.goodsunitid" +
+		"  FROM %v t" +
+		"  LEFT JOIN WRSTANDARD w" +
+		"    on t.wrstandardid = w.wrstandardid" +
+		"  LEFT JOIN dgfactoryitem gb" +
+		"    on t.spotgoodsbrandid = gb.dgfactoryitemid" +
+		"  LEFT JOIN deliverygoods g" +
+		"    on t.deliverygoodsid = g.deliverygoodsid" +
+		"  LEFT JOIN WAREHOUSEINFO h" +
+		"    on t.warehouseinfoid = h.autoid" +
+		" WHERE 1 = 1"
+
+	sqlId.And("t.USERID", r.USERID)
+	if r.ReportType == 1 {
+		// 日报表
+		sqlId.FormatParam("RECKON_ERMCP_AREASTOCK")
+		sqlId.And("t.reckondate", r.ReportDate)
+	} else {
+		// 月报表
+		sqlId.FormatParam("REPORT_ERMCP_AREASTOCK")
+		sqlId.And("t.cycletype", 1)
+		sqlId.And("t.cycletime", r.ReportDate)
+	}
+	// 现货商品id
+	sqlId.AndEx("t.DELIVERYGOODSID", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
+	// 品类id
+	if len(r.WRSTANDARDID) > 0 {
+		sqlId.And("t.WRSTANDARDID", r.WRSTANDARDID)
+	}
+	// 品牌id
+	if r.SPOTGOODSBRANDID > 0 {
+		sqlId.And("t.SPOTGOODSBRANDID", r.SPOTGOODSBRANDID)
+	}
+	// 仓库id
+	if len(r.WAREHOUSEINFOID) > 0 {
+		sqlId.And("t.WAREHOUSEINFOID", r.WAREHOUSEINFOID)
+	}
+	return sqlId.String()
+}
+
+// GetDataEx 查询库存报表
+func (r *Ermcp3AreaStockReport) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpAreaStockReport, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	if err == nil {
+		for i := range sData {
+			sData[i].calc()
+		}
+	}
+	return sData, err
+}

+ 43 - 28
models/ermcpAccMgr.go

@@ -107,38 +107,48 @@ func (r *ErmcpLoginUser) hasRoletype(nType int32) bool {
 
 // GetDataEx 查询登录用户
 func (r *ErmcpLoginUser) GetDataEx() (interface{}, error) {
+	sDataEx := make([]ErmcpLoginUserEx, 0)
+	// 查询角色
+	m := ErmcpRole{AREAUSERID: r.USERID}
+	roles, _ := m.GetData()
+	if len(roles) == 0 {
+		return sDataEx, nil
+	}
+	// 初始化角色列表
+	for _, val := range roles {
+		sDataEx = append(sDataEx, ErmcpLoginUserEx{
+			ROLENAME: val.ROLENAME,
+			RoleId:   val.AUTOID,
+			UserList: make([]ErmcpLoginUser, 0),
+			USERTYPE: func(roldId int32) int32 {
+				if roldId == 22 || roldId == 23 || roldId == 24 {
+					return 7
+				}
+				return 2
+			}(val.AUTOID),
+		})
+	}
+	// 查询用户
 	sData := make([]ErmcpLoginUser, 0)
 	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
-	sDataEx := make([]ErmcpLoginUserEx, 0)
-	// 初始化固定三种企业成员角色
-	sDataEx = append(sDataEx, ErmcpLoginUserEx{ROLENAME: "业务员", USERTYPE: 7, RoleId: 22, UserList: make([]ErmcpLoginUser, 0)})
-	sDataEx = append(sDataEx, ErmcpLoginUserEx{ROLENAME: "跟单员", USERTYPE: 7, RoleId: 23, UserList: make([]ErmcpLoginUser, 0)})
-	sDataEx = append(sDataEx, ErmcpLoginUserEx{ROLENAME: "交易员", USERTYPE: 7, RoleId: 24, UserList: make([]ErmcpLoginUser, 0)})
 	for _, v := range sData {
-		if v.USERTYPE == 7 {
-			if len(sDataEx) >= 3 {
-				if v.hasRoletype(22) {
-					sDataEx[0].UserList = append(sDataEx[0].UserList, v)
-				} else if v.hasRoletype(23) {
-					sDataEx[1].UserList = append(sDataEx[1].UserList, v)
-				} else if v.hasRoletype(24) {
-					sDataEx[2].UserList = append(sDataEx[2].UserList, v)
+		for i := range sDataEx {
+			if v.USERTYPE == 2 {
+				// 企业管理角色直接使用CLIENTROLEID判断
+				if sDataEx[i].RoleId == v.CLIENTROLEID {
+					sDataEx[i].UserList = append(sDataEx[i].UserList, v)
 				}
-			}
-		} else if v.USERTYPE == 2 {
-			var bAdd bool = false
-			for i := range sDataEx {
-				if sDataEx[i].USERTYPE == 2 && sDataEx[i].RoleId == v.CLIENTROLEID {
+			} else {
+				// 企业成员usertype=7需根据roletype判断
+				if sDataEx[i].RoleId == 22 && v.hasRoletype(22) {
+					sDataEx[i].UserList = append(sDataEx[i].UserList, v)
+				}
+				if sDataEx[i].RoleId == 23 && v.hasRoletype(23) {
+
+				}
+				if sDataEx[i].RoleId == 24 && v.hasRoletype(24) {
 					sDataEx[i].UserList = append(sDataEx[i].UserList, v)
-					bAdd = true
-					break
 				}
-			}
-			// 不存在的新类别
-			if !bAdd {
-				val := ErmcpLoginUserEx{ROLENAME: v.ROLENAME, USERTYPE: 2, RoleId: v.CLIENTROLEID, UserList: make([]ErmcpLoginUser, 0)}
-				val.UserList = append(val.UserList, v)
-				sDataEx = append(sDataEx, val)
 			}
 		}
 	}
@@ -303,8 +313,8 @@ func (r *ErmcpRole) buildSql() string {
 	return sqlId.String()
 }
 
-// GetDataEx 查询角色
-func (r *ErmcpRole) GetDataEx() (interface{}, error) {
+// GetData
+func (r *ErmcpRole) GetData() ([]ErmcpRole, error) {
 	sData := make([]ErmcpRole, 0)
 	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
 	for i := range sData {
@@ -322,6 +332,11 @@ func (r *ErmcpRole) GetDataEx() (interface{}, error) {
 	return sDataEx, err
 }
 
+// GetDataEx 查询角色
+func (r *ErmcpRole) GetDataEx() (interface{}, error) {
+	return r.GetData()
+}
+
 // ErmcpRoleMenuEx 角色菜单(分层级)
 type ErmcpRoleMenuEx struct {
 	Menu    ErmcpRoleMenu   // 父级菜单

+ 4 - 0
routers/router.go

@@ -421,6 +421,10 @@ func InitRouter() *gin.Engine {
 		ermcp3R.GET("/QueryDGFactoryItem", ermcp3.QueryDGFactoryItem)
 		ermcp3R.GET("/QueryGoodsbrand", ermcp3.QueryGoodsbrand)
 		ermcp3R.GET("/QueryGoodsWrstandard", ermcp3.QueryGoodsWrstandard)
+		ermcp3R.GET("/QueryAreaStockApply", ermcp3.QueryAreaStockApply)
+		ermcp3R.GET("/QueryAreaStockApplySum", ermcp3.QueryAreaStockApplySum)
+		ermcp3R.GET("/QueryAreaStockReport", ermcp3.QueryAreaStockReport)
+		ermcp3R.GET("/QueryAreaStockReportDetail", ermcp3.QueryAreaStockReportDetail)
 	}
 
 	return r