Selaa lähdekoodia

Merge branch 'dev'

zou.yingbin 4 vuotta sitten
vanhempi
commit
f306563b94
9 muutettua tiedostoa jossa 1068 lisäystä ja 44 poistoa
  1. 59 0
      controllers/ermcp3/qryErmcp3.go
  2. 259 8
      docs/docs.go
  3. 259 8
      docs/swagger.json
  4. 179 7
      docs/swagger.yaml
  5. 270 0
      models/ermcp3.go
  6. 21 21
      models/ermcpAccMgr.go
  7. 3 0
      models/ermcpWrstandard.go
  8. 9 0
      routers/router.go
  9. 9 0
      utils/sqlUtils.go

+ 59 - 0
controllers/ermcp3/qryErmcp3.go

@@ -0,0 +1,59 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/4/15 10:35
+* @Modify  : 2021/4/15 10:35
+ */
+
+package ermcp3
+
+import (
+	"github.com/gin-gonic/gin"
+	"mtp2_if/global/app"
+	"mtp2_if/models"
+)
+
+// QueryDeliveryGoods
+// @Summary 查询现货商品
+// @Produce json
+// @Security ApiKeyAuth
+// @Param areauserid query int true "所属机构id"
+// @Param excludecfg query int false "排除已配置的现货商品 1-排除"
+// @Success 200 {array} models.ErmcpDeliveryGoods
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QueryDeliveryGoods [get]
+// @Tags 企业风险管理v3(app)
+func QueryDeliveryGoods(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := struct {
+		AreaUserId int64 `form:"areauserid" binding:"required"` // 所属机构id
+		ExcludeCfg int32 `form:"excludecfg"`                    // 排除已配置的商品
+	}{}
+	a.DoBindReq(&req)
+	m := models.ErmcpDeliveryGoods{AREAUSERID: req.AreaUserId, ExcludeCfg: req.ExcludeCfg}
+	a.DoGetDataI(&m)
+}
+
+// QueryDeliveryGoodsDetail
+// @Summary 查询现货商品详情
+// @Produce json
+// @Security ApiKeyAuth
+// @Param areauserid query int true "所属机构id"
+// @Param deliverygoodsid query int false "现货商品id"
+// @Param qrytradegoods query int false "是否查询关联交易商品 1-查询"
+// @Success 200 {array} models.ErmcpDeliveryGoodsDetail
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QueryDeliveryGoodsDetail [get]
+// @Tags 企业风险管理v3(app)
+func QueryDeliveryGoodsDetail(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := struct {
+		AreaUserId      int64 `form:"areauserid" binding:"required"` // 所属机构id
+		DeliveryGoodsId int32 `form:"deliverygoodsid"`               // 排除已配置的商品
+		QryTradeGoods   int32 `form:"qrytradegoods"`                 // 查询关联交易商品
+	}{}
+	a.DoBindReq(&req)
+	m := models.ErmcpDeliveryGoodsDetail{
+		Data:          models.ErmcpDeliveryGoods{AREAUSERID: req.AreaUserId, DELIVERYGOODSID: req.DeliveryGoodsId},
+		QryTradeGoods: req.QryTradeGoods}
+	a.DoGetDataI(&m)
+}

+ 259 - 8
docs/docs.go

@@ -4017,6 +4017,108 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp3/QueryDeliveryGoods": {
+            "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-排除",
+                        "name": "excludecfg",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpDeliveryGoods"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp3/QueryDeliveryGoodsDetail": {
+            "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"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "是否查询关联交易商品 1-查询",
+                        "name": "qrytradegoods",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpDeliveryGoodsDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms2/QueryArbitrageStrategy": {
             "get": {
                 "security": [
@@ -12228,7 +12330,7 @@ var doc = `{
                     "type": "integer"
                 },
                 "wrlist": {
-                    "description": "现货商品表",
+                    "description": "现货商品表",
                     "type": "array",
                     "items": {
                         "$ref": "#/definitions/models.ErmcpBizGroupSpotGoods"
@@ -12251,21 +12353,21 @@ var doc = `{
                     "description": "业务类型 1-套保 2-套利",
                     "type": "integer"
                 },
-                "unitid": {
-                    "description": "现货商品单位id",
-                    "type": "integer"
-                },
-                "wrstandardcode": {
+                "deliverygoodscode": {
                     "description": "现货商品代码",
                     "type": "string"
                 },
-                "wrstandardid": {
+                "deliverygoodsid": {
                     "description": "现货商品id",
                     "type": "integer"
                 },
-                "wrstandardname": {
+                "deliverygoodsname": {
                     "description": "现货商品名称",
                     "type": "string"
+                },
+                "unitid": {
+                    "description": "现货商品单位id",
+                    "type": "integer"
                 }
             }
         },
@@ -12294,6 +12396,126 @@ var doc = `{
                 }
             }
         },
+        "models.ErmcpBrand": {
+            "type": "object",
+            "properties": {
+                "brandid": {
+                    "description": "品牌id",
+                    "type": "integer"
+                },
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpDeliveryGoods": {
+            "type": "object",
+            "properties": {
+                "agreeunit": {
+                    "description": "合约单位[散货时默认为1, 整装时默认为标准数量]",
+                    "type": "integer"
+                },
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "auditflag": {
+                    "description": "交割是否需要审核 - 0:不需要 1:需要审核   默认为0",
+                    "type": "integer"
+                },
+                "categoryid": {
+                    "description": "类别ID(SEQ_WRCATEGORY)",
+                    "type": "integer"
+                },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID(SEQ_DELIVERYGOODS)",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "deliverygoodstype": {
+                    "description": "现货品种类型: 1-整装不拆分 2-散装记录明细 3:整装拆分 4:散装不记录明细",
+                    "type": "integer"
+                },
+                "dgstatus": {
+                    "description": "品种状态 - 作废 - 0:未激活 1:正常",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "现货品种单位名称",
+                    "type": "string"
+                },
+                "goodsunitid": {
+                    "description": "现货品种单位ID",
+                    "type": "integer"
+                },
+                "isvalid": {
+                    "description": "是否有效 - 0:无效 1:有效",
+                    "type": "integer"
+                },
+                "qtydecimalplace": {
+                    "description": "成交量小数位",
+                    "type": "integer"
+                },
+                "standardqty": {
+                    "description": "标准数量(库位数量) [标准品特有]",
+                    "type": "integer"
+                },
+                "standardqtyrange": {
+                    "description": "标准数量偏差范围 [标准品特有]",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpDeliveryGoodsDetail": {
+            "type": "object",
+            "properties": {
+                "data": {
+                    "description": "现货商品基本信息(交割品种)",
+                    "type": "object",
+                    "$ref": "#/definitions/models.ErmcpDeliveryGoods"
+                },
+                "gblist": {
+                    "description": "品牌列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpBrand"
+                    }
+                },
+                "gmlist": {
+                    "description": "品类列表(仓单标准)",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpWrstandard"
+                    }
+                },
+                "goodslist": {
+                    "description": "关联交易商品列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpRelatedGoods"
+                    }
+                },
+                "wrslist": {
+                    "description": "套保信息列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.WRSConverTDetail"
+                    }
+                }
+            }
+        },
         "models.ErmcpExposureDetailModel": {
             "type": "object",
             "properties": {
@@ -12931,6 +13153,14 @@ var doc = `{
                     "description": "创建时间",
                     "type": "string"
                 },
+                "logincode": {
+                    "description": "登录代码",
+                    "type": "string"
+                },
+                "loginid": {
+                    "description": "登录id(LOGINID)",
+                    "type": "integer"
+                },
                 "loginstatus": {
                     "description": "登录账户状态 - 1:正常 2:冻结 3:无效",
                     "type": "integer"
@@ -13559,6 +13789,27 @@ var doc = `{
                 }
             }
         },
+        "models.ErmcpRelatedGoods": {
+            "type": "object",
+            "properties": {
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                },
+                "goodscode": {
+                    "description": "商品代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品id",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.ErmcpReportAreaSpotPL": {
             "type": "object",
             "properties": {

+ 259 - 8
docs/swagger.json

@@ -4001,6 +4001,108 @@
                 }
             }
         },
+        "/Ermcp3/QueryDeliveryGoods": {
+            "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-排除",
+                        "name": "excludecfg",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpDeliveryGoods"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp3/QueryDeliveryGoodsDetail": {
+            "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"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "是否查询关联交易商品 1-查询",
+                        "name": "qrytradegoods",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpDeliveryGoodsDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms2/QueryArbitrageStrategy": {
             "get": {
                 "security": [
@@ -12212,7 +12314,7 @@
                     "type": "integer"
                 },
                 "wrlist": {
-                    "description": "现货商品表",
+                    "description": "现货商品表",
                     "type": "array",
                     "items": {
                         "$ref": "#/definitions/models.ErmcpBizGroupSpotGoods"
@@ -12235,21 +12337,21 @@
                     "description": "业务类型 1-套保 2-套利",
                     "type": "integer"
                 },
-                "unitid": {
-                    "description": "现货商品单位id",
-                    "type": "integer"
-                },
-                "wrstandardcode": {
+                "deliverygoodscode": {
                     "description": "现货商品代码",
                     "type": "string"
                 },
-                "wrstandardid": {
+                "deliverygoodsid": {
                     "description": "现货商品id",
                     "type": "integer"
                 },
-                "wrstandardname": {
+                "deliverygoodsname": {
                     "description": "现货商品名称",
                     "type": "string"
+                },
+                "unitid": {
+                    "description": "现货商品单位id",
+                    "type": "integer"
                 }
             }
         },
@@ -12278,6 +12380,126 @@
                 }
             }
         },
+        "models.ErmcpBrand": {
+            "type": "object",
+            "properties": {
+                "brandid": {
+                    "description": "品牌id",
+                    "type": "integer"
+                },
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpDeliveryGoods": {
+            "type": "object",
+            "properties": {
+                "agreeunit": {
+                    "description": "合约单位[散货时默认为1, 整装时默认为标准数量]",
+                    "type": "integer"
+                },
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "auditflag": {
+                    "description": "交割是否需要审核 - 0:不需要 1:需要审核   默认为0",
+                    "type": "integer"
+                },
+                "categoryid": {
+                    "description": "类别ID(SEQ_WRCATEGORY)",
+                    "type": "integer"
+                },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID(SEQ_DELIVERYGOODS)",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "deliverygoodstype": {
+                    "description": "现货品种类型: 1-整装不拆分 2-散装记录明细 3:整装拆分 4:散装不记录明细",
+                    "type": "integer"
+                },
+                "dgstatus": {
+                    "description": "品种状态 - 作废 - 0:未激活 1:正常",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "现货品种单位名称",
+                    "type": "string"
+                },
+                "goodsunitid": {
+                    "description": "现货品种单位ID",
+                    "type": "integer"
+                },
+                "isvalid": {
+                    "description": "是否有效 - 0:无效 1:有效",
+                    "type": "integer"
+                },
+                "qtydecimalplace": {
+                    "description": "成交量小数位",
+                    "type": "integer"
+                },
+                "standardqty": {
+                    "description": "标准数量(库位数量) [标准品特有]",
+                    "type": "integer"
+                },
+                "standardqtyrange": {
+                    "description": "标准数量偏差范围 [标准品特有]",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpDeliveryGoodsDetail": {
+            "type": "object",
+            "properties": {
+                "data": {
+                    "description": "现货商品基本信息(交割品种)",
+                    "type": "object",
+                    "$ref": "#/definitions/models.ErmcpDeliveryGoods"
+                },
+                "gblist": {
+                    "description": "品牌列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpBrand"
+                    }
+                },
+                "gmlist": {
+                    "description": "品类列表(仓单标准)",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpWrstandard"
+                    }
+                },
+                "goodslist": {
+                    "description": "关联交易商品列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpRelatedGoods"
+                    }
+                },
+                "wrslist": {
+                    "description": "套保信息列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.WRSConverTDetail"
+                    }
+                }
+            }
+        },
         "models.ErmcpExposureDetailModel": {
             "type": "object",
             "properties": {
@@ -12915,6 +13137,14 @@
                     "description": "创建时间",
                     "type": "string"
                 },
+                "logincode": {
+                    "description": "登录代码",
+                    "type": "string"
+                },
+                "loginid": {
+                    "description": "登录id(LOGINID)",
+                    "type": "integer"
+                },
                 "loginstatus": {
                     "description": "登录账户状态 - 1:正常 2:冻结 3:无效",
                     "type": "integer"
@@ -13543,6 +13773,27 @@
                 }
             }
         },
+        "models.ErmcpRelatedGoods": {
+            "type": "object",
+            "properties": {
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                },
+                "goodscode": {
+                    "description": "商品代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品id",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.ErmcpReportAreaSpotPL": {
             "type": "object",
             "properties": {

+ 179 - 7
docs/swagger.yaml

@@ -3383,7 +3383,7 @@ definitions:
         description: 业务类型 1-套保 2-套利
         type: integer
       wrlist:
-        description: 现货商品表
+        description: 现货商品表
         items:
           $ref: '#/definitions/models.ErmcpBizGroupSpotGoods'
         type: array
@@ -3399,18 +3399,18 @@ definitions:
       biztype:
         description: 业务类型 1-套保 2-套利
         type: integer
-      unitid:
-        description: 现货商品单位id
-        type: integer
-      wrstandardcode:
+      deliverygoodscode:
         description: 现货商品代码
         type: string
-      wrstandardid:
+      deliverygoodsid:
         description: 现货商品id
         type: integer
-      wrstandardname:
+      deliverygoodsname:
         description: 现货商品名称
         type: string
+      unitid:
+        description: 现货商品单位id
+        type: integer
     type: object
   models.ErmcpBizGroupTaAccount:
     properties:
@@ -3430,6 +3430,93 @@ definitions:
         description: 是否主账号 1-是 0-否
         type: integer
     type: object
+  models.ErmcpBrand:
+    properties:
+      brandid:
+        description: 品牌id
+        type: integer
+      brandname:
+        description: 品牌名称
+        type: string
+      deliverygoodsid:
+        description: 品种ID
+        type: integer
+    type: object
+  models.ErmcpDeliveryGoods:
+    properties:
+      agreeunit:
+        description: 合约单位[散货时默认为1, 整装时默认为标准数量]
+        type: integer
+      areauserid:
+        description: 所属机构
+        type: integer
+      auditflag:
+        description: 交割是否需要审核 - 0:不需要 1:需要审核   默认为0
+        type: integer
+      categoryid:
+        description: 类别ID(SEQ_WRCATEGORY)
+        type: integer
+      deliverygoodscode:
+        description: 现货品种代码
+        type: string
+      deliverygoodsid:
+        description: 现货品种ID(SEQ_DELIVERYGOODS)
+        type: integer
+      deliverygoodsname:
+        description: 现货品种名称
+        type: string
+      deliverygoodstype:
+        description: '现货品种类型: 1-整装不拆分 2-散装记录明细 3:整装拆分 4:散装不记录明细'
+        type: integer
+      dgstatus:
+        description: 品种状态 - 作废 - 0:未激活 1:正常
+        type: integer
+      enumdicname:
+        description: 现货品种单位名称
+        type: string
+      goodsunitid:
+        description: 现货品种单位ID
+        type: integer
+      isvalid:
+        description: 是否有效 - 0:无效 1:有效
+        type: integer
+      qtydecimalplace:
+        description: 成交量小数位
+        type: integer
+      standardqty:
+        description: 标准数量(库位数量) [标准品特有]
+        type: integer
+      standardqtyrange:
+        description: 标准数量偏差范围 [标准品特有]
+        type: integer
+    type: object
+  models.ErmcpDeliveryGoodsDetail:
+    properties:
+      data:
+        $ref: '#/definitions/models.ErmcpDeliveryGoods'
+        description: 现货商品基本信息(交割品种)
+        type: object
+      gblist:
+        description: 品牌列表
+        items:
+          $ref: '#/definitions/models.ErmcpBrand'
+        type: array
+      gmlist:
+        description: 品类列表(仓单标准)
+        items:
+          $ref: '#/definitions/models.ErmcpWrstandard'
+        type: array
+      goodslist:
+        description: 关联交易商品列表
+        items:
+          $ref: '#/definitions/models.ErmcpRelatedGoods'
+        type: array
+      wrslist:
+        description: 套保信息列表
+        items:
+          $ref: '#/definitions/models.WRSConverTDetail'
+        type: array
+    type: object
   models.ErmcpExposureDetailModel:
     properties:
       areauserid:
@@ -3899,6 +3986,12 @@ definitions:
       createtime:
         description: 创建时间
         type: string
+      logincode:
+        description: 登录代码
+        type: string
+      loginid:
+        description: 登录id(LOGINID)
+        type: integer
       loginstatus:
         description: 登录账户状态 - 1:正常 2:冻结 3:无效
         type: integer
@@ -4363,6 +4456,21 @@ definitions:
         description: 期初现货数量=(期初销售计划数量-期初销售合同已定价数量)-(期初采购计划数量-期初采购合同已定价数量)
         type: number
     type: object
+  models.ErmcpRelatedGoods:
+    properties:
+      deliverygoodsid:
+        description: 品种ID
+        type: integer
+      goodscode:
+        description: 商品代码
+        type: string
+      goodsid:
+        description: 商品id
+        type: integer
+      goodsname:
+        description: 商品名称
+        type: string
+    type: object
   models.ErmcpReportAreaSpotPL:
     properties:
       actualpl:
@@ -13084,6 +13192,70 @@ paths:
       summary: 查询现货商品详情(菜单:现货品种/现货品种详情)
       tags:
       - 企业风险管理(app)
+  /Ermcp3/QueryDeliveryGoods:
+    get:
+      parameters:
+      - description: 所属机构id
+        in: query
+        name: areauserid
+        required: true
+        type: integer
+      - description: 排除已配置的现货商品 1-排除
+        in: query
+        name: excludecfg
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.ErmcpDeliveryGoods'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询现货商品
+      tags:
+      - 企业风险管理v3(app)
+  /Ermcp3/QueryDeliveryGoodsDetail:
+    get:
+      parameters:
+      - description: 所属机构id
+        in: query
+        name: areauserid
+        required: true
+        type: integer
+      - description: 现货商品id
+        in: query
+        name: deliverygoodsid
+        type: integer
+      - description: 是否查询关联交易商品 1-查询
+        in: query
+        name: qrytradegoods
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.ErmcpDeliveryGoodsDetail'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询现货商品详情
+      tags:
+      - 企业风险管理v3(app)
   /Erms2/QueryArbitrageStrategy:
     get:
       parameters:

+ 270 - 0
models/ermcp3.go

@@ -0,0 +1,270 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/4/14 11:11
+* @Modify  : 2021/4/14 11:11
+ */
+
+package models
+
+import (
+	"mtp2_if/db"
+	"mtp2_if/mtpcache"
+	"mtp2_if/utils"
+)
+
+// ErmcpDeliveryGoods 现货品种(交割品种)
+type ErmcpDeliveryGoods struct {
+	DELIVERYGOODSID   int32  `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`     // 现货品种ID(SEQ_DELIVERYGOODS)
+	DELIVERYGOODSCODE string `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
+	DELIVERYGOODSNAME string `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
+	GOODSUNITID       int32  `json:"goodsunitid"  xorm:"'GOODSUNITID'"`             // 现货品种单位ID
+	DELIVERYGOODSTYPE int32  `json:"deliverygoodstype"  xorm:"'DELIVERYGOODSTYPE'"` // 现货品种类型: 1-整装不拆分 2-散装记录明细 3:整装拆分 4:散装不记录明细
+	STANDARDQTY       int32  `json:"standardqty"  xorm:"'STANDARDQTY'"`             // 标准数量(库位数量) [标准品特有]
+	STANDARDQTYRANGE  int32  `json:"standardqtyrange"  xorm:"'STANDARDQTYRANGE'"`   // 标准数量偏差范围 [标准品特有]
+	AUDITFLAG         int32  `json:"auditflag"  xorm:"'AUDITFLAG'"`                 // 交割是否需要审核 - 0:不需要 1:需要审核   默认为0
+	ISVALID           int32  `json:"isvalid"  xorm:"'ISVALID'"`                     // 是否有效 - 0:无效 1:有效
+	AGREEUNIT         int32  `json:"agreeunit"  xorm:"'AGREEUNIT'"`                 // 合约单位[散货时默认为1, 整装时默认为标准数量]
+	QTYDECIMALPLACE   int32  `json:"qtydecimalplace"  xorm:"'QTYDECIMALPLACE'"`     // 成交量小数位
+	CATEGORYID        int32  `json:"categoryid"  xorm:"'CATEGORYID'"`               // 类别ID(SEQ_WRCATEGORY)
+	DGSTATUS          int32  `json:"dgstatus"  xorm:"'DGSTATUS'"`                   // 品种状态 - 作废 - 0:未激活 1:正常
+	AREAUSERID        int64  `json:"areauserid"  xorm:"'AREAUSERID'"`               // 所属机构
+
+	EnumdicName string `json:"enumdicname"` // 现货品种单位名称
+	ExcludeCfg  int32  `json:"-"`           // 排除已配置项 1-排除
+}
+
+func (r *ErmcpDeliveryGoods) calc() {
+	r.EnumdicName = mtpcache.GetEnumDicitemName(r.GOODSUNITID)
+}
+
+func (r *ErmcpDeliveryGoods) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT t.DELIVERYGOODSID," +
+		"       t.DELIVERYGOODSCODE," +
+		"       t.DELIVERYGOODSNAME," +
+		"       t.GOODSUNITID," +
+		"       t.DELIVERYGOODSTYPE," +
+		"       t.STANDARDQTY," +
+		"       t.STANDARDQTYRANGE," +
+		"       t.AUDITFLAG," +
+		"       t.ISVALID," +
+		"       t.ISSPLIT," +
+		"       t.AGREEUNIT," +
+		"       t.QTYDECIMALPLACE," +
+		"       t.CATEGORYID," +
+		"       t.DGSTATUS," +
+		"       t.AREAUSERID" +
+		"  FROM DELIVERYGOODS t" +
+		" WHERE 1 = 1"
+	sqlId.AndEx("t.AREAUSERID", r.AREAUSERID, r.AREAUSERID > 0)
+	sqlId.AndEx("t.DELIVERYGOODSID", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
+	if r.ExcludeCfg == 1 {
+		sqlId.Join(" and t.deliverygoodsid not in(select distinct deliverygoodsid from ermcp_bizgroupspotgoods)")
+	}
+	return sqlId.String()
+}
+
+// GetDataEx 获取现货商品(交割商品)
+func (r *ErmcpDeliveryGoods) GetDataEx() (interface{}, error) {
+	return r.GetData()
+}
+
+// GetData
+func (r *ErmcpDeliveryGoods) GetData() ([]ErmcpDeliveryGoods, error) {
+	sData := make([]ErmcpDeliveryGoods, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}
+
+// ErmcpDGFactoryItem 品种选择项定义表
+type ErmcpDGFactoryItem struct {
+	DGFACTORYITEMID     int64  // 选择项ID(SEQ_DGFACTORYITEM)
+	DELIVERYGOODSID     int32  // 品种ID
+	DGFACTORYITEMTYPEID int64  // 要素项类型
+	DGFACTORYITEMVALUE  string // 要素项值(类型为仓库时填写仓库名称)
+	WAREHOUSEID         int64  // 仓库ID(类型为仓库时填写)
+	ISVALID             int32  // 是否有效 - 0:无效 1:有效
+	ORDERINDEX          int32  // 顺序
+}
+
+func (r *ErmcpDGFactoryItem) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT DGFACTORYITEMID," +
+		"       t.DELIVERYGOODSID," +
+		"       to_char(t.DGFACTORYITEMTYPEID) DGFACTORYITEMTYPEID," +
+		"       t.DGFACTORYITEMVALUE," +
+		"       to_char(t.WAREHOUSEID) WAREHOUSEID," +
+		"       t.ISVALID," +
+		"       t.ORDERINDEX" +
+		"  FROM DGFACTORYITEM t" +
+		" WHERE ISVALID = 1"
+	sqlId.AndEx("t.DGFACTORYITEMID", r.DGFACTORYITEMID, r.DGFACTORYITEMID > 0)
+	sqlId.AndEx("t.DELIVERYGOODSID", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
+	sqlId.AndEx("t.DGFACTORYITEMTYPEID", r.DGFACTORYITEMTYPEID, r.DGFACTORYITEMTYPEID > 0)
+	sqlId.AndEx("t.ORDERINDEX", r.ORDERINDEX, r.ORDERINDEX > 0)
+
+	return sqlId.String()
+}
+
+// GetDataEx 获取品种选择项定义
+func (r *ErmcpDGFactoryItem) GetDataEx() (interface{}, error) {
+	return r.GetData()
+}
+
+// GetData
+func (r *ErmcpDGFactoryItem) GetData() (interface{}, error) {
+	sData := make([]ErmcpDGFactoryItem, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	return sData, err
+}
+
+// ErmcpBrand 品牌(从品种选择项定义表中查)
+type ErmcpBrand struct {
+	BRANDID         int64  `json:"brandid"`         // 品牌id
+	BRANDNAME       string `json:"brandname"`       // 品牌名称
+	DELIVERYGOODSID int32  `json:"deliverygoodsid"` // 品种ID
+}
+
+// 获取品牌数据
+func (r *ErmcpBrand) GetData() ([]ErmcpBrand, error) {
+	m := ErmcpDGFactoryItem{
+		DELIVERYGOODSID:     r.DELIVERYGOODSID,
+		DGFACTORYITEMTYPEID: 2,
+		ORDERINDEX:          1,
+	}
+	sData := make([]ErmcpBrand, 0)
+	if d, err := m.GetDataEx(); err == nil {
+		if dgLst, ok := d.([]ErmcpDGFactoryItem); ok {
+			for _, val := range dgLst {
+				sData = append(sData, ErmcpBrand{BRANDID: val.DGFACTORYITEMID,
+					BRANDNAME: val.DGFACTORYITEMVALUE, DELIVERYGOODSID: val.DELIVERYGOODSID})
+			}
+		}
+	}
+	return sData, nil
+}
+
+// ErmcpRelatedGoods 现货品种的关联交易商品
+type ErmcpRelatedGoods struct {
+	GoodsId         int    `json:"goodsid"  xorm:"'GoodsId'"`                 // 商品id
+	GoodsCode       string `json:"goodscode"  xorm:"'GoodsCode'"`             // 商品代码
+	GoodsName       string `json:"goodsname"  xorm:"'GoodsName'"`             // 商品名称
+	DELIVERYGOODSID int32  `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"` // 品种ID
+
+	AREAUSERID int64 `json:"-"` // 所属机构
+}
+
+func (r *ErmcpRelatedGoods) buildSql() string {
+	var sqlId utils.SQLVal = "select distinct t.deliverygoodsid, g.goodsid, g.goodscode, g.goodsname" +
+		"  from deliverygoods t" +
+		" inner join ERMS2_WRSConvertDetail w" +
+		"    on t.deliverygoodsid = w.deliverygoodsid" +
+		" inner join erms_middlegoods m" +
+		"    on w.middlegoodsid = m.middlegoodsid" +
+		" inner join ERMCP_GGConvertConfig gc" +
+		"    on m.goodsgroupid = gc.destgoodsgroupid" +
+		" inner join goods g" +
+		"    on gc.srcgoodsgroupid = g.goodsgroupid" +
+		" where 1 = 1"
+	sqlId.AndEx("t.AREAUSERID", r.AREAUSERID, r.AREAUSERID > 0)
+	sqlId.AndEx("t.DELIVERYGOODSID", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
+	return sqlId.String()
+}
+
+// GetDataEx 获取现货关联交易商品
+func (r *ErmcpRelatedGoods) GetDataEx() (interface{}, error) {
+	return r.GetData()
+}
+
+// GetData 获取现货关联交易商品
+func (r *ErmcpRelatedGoods) GetData() ([]ErmcpRelatedGoods, error) {
+	sData := make([]ErmcpRelatedGoods, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	return sData, err
+}
+
+// ErmcpDeliveryGoodsDetail 现货商品详情
+type ErmcpDeliveryGoodsDetail struct {
+	Data      ErmcpDeliveryGoods  `json:"data"`      // 现货商品基本信息(交割品种)
+	GmList    []ErmcpWrstandard   `json:"gmlist"`    // 品类列表(仓单标准)
+	GbList    []ErmcpBrand        `json:"gblist"`    // 品牌列表
+	WrsList   []WRSConverTDetail  `json:"wrslist"`   // 套保信息列表
+	GoodsList []ErmcpRelatedGoods `json:"goodslist"` // 关联交易商品列表
+
+	QryTradeGoods int32 `json:"-"` // 是否查询关联交易商品 1-查询
+}
+
+func (r *ErmcpDeliveryGoodsDetail) addGmList(lst []ErmcpWrstandard) {
+	for i := range lst {
+		if lst[i].DELIVERYGOODSID == r.Data.DELIVERYGOODSID {
+			r.GmList = append(r.GmList, lst[i])
+		}
+	}
+}
+
+func (r *ErmcpDeliveryGoodsDetail) addGbList(lst []ErmcpBrand) {
+	for i := range lst {
+		if lst[i].DELIVERYGOODSID == r.Data.DELIVERYGOODSID {
+			r.GbList = append(r.GbList, lst[i])
+		}
+	}
+}
+
+func (r *ErmcpDeliveryGoodsDetail) addWrsList(lst []WRSConverTDetail) {
+	for i := range lst {
+		if lst[i].DELIVERYGOODSID == r.Data.DELIVERYGOODSID {
+			r.WrsList = append(r.WrsList, lst[i])
+		}
+	}
+}
+
+func (r *ErmcpDeliveryGoodsDetail) addGoodsList(lst []ErmcpRelatedGoods) {
+	for i := range lst {
+		if lst[i].DELIVERYGOODSID == r.Data.DELIVERYGOODSID {
+			r.GoodsList = append(r.GoodsList, lst[i])
+		}
+	}
+}
+
+// GetDataEx
+func (r *ErmcpDeliveryGoodsDetail) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpDeliveryGoodsDetail, 0)
+	m := ErmcpDeliveryGoods{AREAUSERID: r.Data.AREAUSERID, DELIVERYGOODSID: r.Data.DELIVERYGOODSID}
+	data, err := m.GetData()
+	if err != nil {
+		return sData, err
+	}
+	if data == nil || len(data) == 0 {
+		return sData, nil
+	}
+	// 基本信息
+	for i := range data {
+		val := ErmcpDeliveryGoodsDetail{Data: data[i],
+			GmList: make([]ErmcpWrstandard, 0), GbList: make([]ErmcpBrand, 0),
+			WrsList: make([]WRSConverTDetail, 0), GoodsList: make([]ErmcpRelatedGoods, 0),
+		}
+		sData = append(sData, val)
+	}
+	//品类
+	gm := ErmcpWrstandard{AREAUSERID: int(r.Data.AREAUSERID), DELIVERYGOODSID: r.Data.DELIVERYGOODSID, ISVALID: 1}
+	gb := ErmcpBrand{DELIVERYGOODSID: r.Data.DELIVERYGOODSID}
+	WrsC := WRSConverTDetail{DELIVERYGOODSID: r.Data.DELIVERYGOODSID}
+	gmLst, _ := gm.GetData()
+	gbLst, _ := gb.GetData()
+	wrsLst, _ := WrsC.GetData()
+	var goodLst []ErmcpRelatedGoods
+	if r.QryTradeGoods == 1 {
+		goodsM := ErmcpRelatedGoods{AREAUSERID: r.Data.AREAUSERID, DELIVERYGOODSID: r.Data.DELIVERYGOODSID}
+		goodLst, _ = goodsM.GetData()
+	}
+
+	for i := range sData {
+		sData[i].addGmList(gmLst)
+		sData[i].addGbList(gbLst)
+		sData[i].addWrsList(wrsLst)
+		sData[i].addGoodsList(goodLst)
+	}
+
+	return sData, nil
+}

+ 21 - 21
models/ermcpAccMgr.go

@@ -36,6 +36,8 @@ type ErmcpLoginUser struct {
 	CLIENTROLEID int32  `json:"clientroleid"  xorm:"'CLIENTROLEID'"` // 角色id(usertype=2)
 	ROLENAME     string `json:"rolename"  xorm:"'ROLENAME'"`         // 角色名称
 	ROLESTATUS   int32  `json:"rolestatus"  xorm:"'ROLESTATUS'"`     // 角色状态 1-启用 2-停用
+	LOGINCODE    string `json:"logincode"  xorm:"'LOGINCODE'"`       // 登录代码
+	LOGINID      int64  `json:"loginid"  xorm:"'LOGINID'"`           // 登录id(LOGINID)
 }
 
 func (r *ErmcpLoginUser) calc() {
@@ -56,7 +58,7 @@ func (r *ErmcpLoginUser) buildSql() string {
 		"       l.logincode," +
 		"       l.loginid," +
 		"       l.clientroleid," +
-		"       'name(22,23,24)' rolename," +
+		"       '企业成员' rolename," +
 		"       l.loginstatus" +
 		"  from useraccount t" +
 		"  left join loginaccount l" +
@@ -414,13 +416,13 @@ func (r *ErmcpRoleMenu) GetDataEx() (interface{}, error) {
 
 // ErmcpBizGroupSpotGoods 业务类型分组商品表
 type ErmcpBizGroupSpotGoods struct {
-	BIZTYPE        int32  `json:"biztype"  xorm:"'BIZTYPE'"`               // 业务类型 1-套保 2-套利
-	BIZGROUPID     int64  `json:"bizgroupid"  xorm:"'BIZGROUPID'"`         // 分组id
-	WRSTANDARDID   int32  `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`     // 现货商品id
-	WRSTANDARDCODE string `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"` // 现货商品代码
-	WRSTANDARDNAME string `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"` // 现货商品名称
-	UNITID         int32  `json:"unitid"  xorm:"'UNITID'"`                 // 现货商品单位id
-	AREAUSERID     int64  `json:"areauserid"  xorm:"'AREAUSERID'"`         // 所属机构id
+	BIZTYPE           int32  `json:"biztype"  xorm:"'BIZTYPE'"`                     // 业务类型 1-套保 2-套利
+	BIZGROUPID        int64  `json:"bizgroupid"  xorm:"'BIZGROUPID'"`               // 分组id
+	DELIVERYGOODSID   int32  `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`     // 现货商品id
+	DELIVERYGOODSCODE string `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"` // 现货商品代码
+	DELIVERYGOODSNAME string `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 现货商品名称
+	GOODSUNITID       int32  `json:"unitid"  xorm:"'UNITID'"`                       // 现货商品单位id
+	AREAUSERID        int64  `json:"areauserid"  xorm:"'AREAUSERID'"`               // 所属机构id
 }
 
 func (r *ErmcpBizGroupSpotGoods) calc() {
@@ -429,18 +431,16 @@ func (r *ErmcpBizGroupSpotGoods) calc() {
 func (r *ErmcpBizGroupSpotGoods) buildSql() string {
 	var sqlId utils.SQLVal = "select t.biztype," +
 		"       t.bizgroupid," +
-		"       t.wrstandardid," +
-		"       w.wrstandardcode," +
-		"       w.wrstandardname," +
-		"       w.unitid," +
-		"       w.areauserid" +
-		"  from ermcp_bizgroupspotgoods t" +
-		"  left join wrstandard w" +
-		"    on t.wrstandardid = w.wrstandardid" +
-		" where 1 = 1"
-	if r.AREAUSERID > 0 {
-		sqlId.And("w.AREAUSERID", r.AREAUSERID)
-	}
+		"       t.deliverygoodsid," +
+		"       g.deliverygoodsname," +
+		"       g.deliverygoodscode," +
+		"       g.goodsunitid," +
+		"       g.areauserid" +
+		"  from ERMCP_BizGroupSpotGoods t" +
+		"  left join deliverygoods g" +
+		"    on t.deliverygoodsid = g.deliverygoodsid" +
+		"  where 1=1"
+	sqlId.AndEx("g.areauserid", r.AREAUSERID, r.AREAUSERID > 0)
 	return sqlId.String()
 }
 
@@ -498,7 +498,7 @@ type ErmcpBizGroupEx struct {
 	BIZGROUPID int64 `json:"bizgroupid"  xorm:"'BIZGROUPID'"` // 业务分组id
 
 	AccList []ErmcpBizGroupTaAccount `json:"acclist"` // 账号列表
-	WrList  []ErmcpBizGroupSpotGoods `json:"wrlist"`  // 现货商品表
+	WrList  []ErmcpBizGroupSpotGoods `json:"wrlist"`  // 现货商品表
 
 	AREAUSERID int64 `json:"-"` // 所属机构
 }

+ 3 - 0
models/ermcpWrstandard.go

@@ -197,6 +197,9 @@ func (r *WRSConverTDetail) buildSql() string {
 	if r.WRSTANDARDID > 0 {
 		sqlId = sqlId + fmt.Sprintf(" and t.wrstandardid=%v", r.WRSTANDARDID)
 	}
+	if r.DELIVERYGOODSID > 0 {
+		sqlId += fmt.Sprintf(" and t.DELIVERYGOODSID=%v", r.DELIVERYGOODSID)
+	}
 	return sqlId
 }
 

+ 9 - 0
routers/router.go

@@ -7,6 +7,7 @@ import (
 	"mtp2_if/controllers/cptrade"
 	"mtp2_if/controllers/delivery"
 	"mtp2_if/controllers/ermcp"
+	"mtp2_if/controllers/ermcp3"
 	"mtp2_if/controllers/erms2"
 	"mtp2_if/controllers/erms3"
 	"mtp2_if/controllers/hsby"
@@ -407,6 +408,14 @@ func InitRouter() *gin.Engine {
 		ermcpR.GET("/GetErmcpRoleFuncMenuLists", ermcp.GetErmcpRoleFuncMenuLists)
 	}
 
+	// ***************************** 企业风险管理v3(app)***************************
+	ermcp3R := apiR.Group("Ermcp3")
+	ermcp3R.Use(token.Auth())
+	{
+		ermcp3R.GET("/QueryDeliveryGoods", ermcp3.QueryDeliveryGoods)
+		ermcp3R.GET("/QueryDeliveryGoodsDetail", ermcp3.QueryDeliveryGoodsDetail)
+	}
+
 	return r
 }
 

+ 9 - 0
utils/sqlUtils.go

@@ -27,6 +27,15 @@ func (r *SQLVal) And(fieldName string, val interface{}) {
 	*r = *r + SQLVal(fmt.Sprintf(" and %v = %v", fieldName, val))
 }
 
+// And 增加and 条件, bAdd参数省了在外层写if语句
+// 例如:  sqlId.AndEx("t.areauserid", r.areauserid, r.areauserid > 0)
+// 如果没有bAdd参数,外层就得写if r.areauserid > 0 {...}
+func (r *SQLVal) AndEx(fieldName string, val interface{}, bAdd bool) {
+	if bAdd {
+		*r = *r + SQLVal(fmt.Sprintf(" and %v = %v", fieldName, val))
+	}
+}
+
 // Bigger 大于
 func (r *SQLVal) Bigger(fieldName string, val interface{}) {
 	*r = *r + SQLVal(fmt.Sprintf(" and %v > %v", fieldName, val))