Procházet zdrojové kódy

查询套保计划返回单位名称

zou.yingbin před 4 roky
rodič
revize
fe18a6971c
4 změnil soubory, kde provedl 50 přidání a 17 odebrání
  1. 8 0
      docs/docs.go
  2. 8 0
      docs/swagger.json
  3. 6 0
      docs/swagger.yaml
  4. 28 17
      models/ermcpHedgePlan.go

+ 8 - 0
docs/docs.go

@@ -11041,6 +11041,10 @@ var doc = `{
                     "description": "现货品种名称",
                     "type": "string"
                 },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
                 "hedgeplanid": {
                     "description": "套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)",
                     "type": "string"
@@ -11073,6 +11077,10 @@ var doc = `{
                     "description": "商品型号",
                     "type": "string"
                 },
+                "unitid": {
+                    "description": "单位id",
+                    "type": "integer"
+                },
                 "updatetime": {
                     "description": "更新时间",
                     "type": "string"

+ 8 - 0
docs/swagger.json

@@ -11025,6 +11025,10 @@
                     "description": "现货品种名称",
                     "type": "string"
                 },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
                 "hedgeplanid": {
                     "description": "套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)",
                     "type": "string"
@@ -11057,6 +11061,10 @@
                     "description": "商品型号",
                     "type": "string"
                 },
+                "unitid": {
+                    "description": "单位id",
+                    "type": "integer"
+                },
                 "updatetime": {
                     "description": "更新时间",
                     "type": "string"

+ 6 - 0
docs/swagger.yaml

@@ -3313,6 +3313,9 @@ definitions:
       deliverygoodsname:
         description: 现货品种名称
         type: string
+      enumdicname:
+        description: 单位名称
+        type: string
       hedgeplanid:
         description: 套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)
         type: string
@@ -3337,6 +3340,9 @@ definitions:
       spotgoodsdesc:
         description: 商品型号
         type: string
+      unitid:
+        description: 单位id
+        type: integer
       updatetime:
         description: 更新时间
         type: string

+ 28 - 17
models/ermcpHedgePlan.go

@@ -10,28 +10,35 @@ import (
 	"fmt"
 	"mtp2_if/db"
 	"mtp2_if/logger"
+	"mtp2_if/mtpcache"
 )
 
 // ErmcpHedgePlan 套保计划表结构
 type ErmcpHedgePlan struct {
-	Areauserid        int64   `json:"areauserid"  xorm:"'Areauserid'"`               //用户ID
-	Hedgeplanid       string  `json:"hedgeplanid"  xorm:"'Hedgeplanid'"`             //套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)
-	Hedgeplanno       string  `json:"hedgeplanno"  xorm:"'Hedgeplanno'"`             //套保计划编号(名称)
-	Contracttype      int     `json:"contracttype"  xorm:"'Contracttype'"`           //计划类型 - 1:采购 -1:销售
-	Deliverygoodsid   int     `json:"deliverygoodsid"  xorm:"'Deliverygoodsid'"`     //现货品种ID
-	Deliverygoodsname string  `json:"deliverygoodsname"  xorm:"'Deliverygoodsname'"` //现货品种名称
-	Wrstandardid      int     `json:"wrstandardid"  xorm:"'Wrstandardid'"`           //现货商品ID
+	Areauserid        int64   `json:"areauserid"  xorm:"'Areauserid'"`               // 用户ID
+	Hedgeplanid       string  `json:"hedgeplanid"  xorm:"'Hedgeplanid'"`             // 套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)
+	Hedgeplanno       string  `json:"hedgeplanno"  xorm:"'Hedgeplanno'"`             // 套保计划编号(名称)
+	Contracttype      int     `json:"contracttype"  xorm:"'Contracttype'"`           // 计划类型 - 1:采购 -1:销售
+	Deliverygoodsid   int     `json:"deliverygoodsid"  xorm:"'Deliverygoodsid'"`     // 现货品种ID
+	Deliverygoodsname string  `json:"deliverygoodsname"  xorm:"'Deliverygoodsname'"` // 现货品种名称
+	Wrstandardid      int     `json:"wrstandardid"  xorm:"'Wrstandardid'"`           // 现货商品ID
 	Wrstandardname    string  `json:"wrstandardname"  xorm:"'Wrstandardname'"`       // 现货商品名称
-	Producttype       int     `json:"producttype"  xorm:"'Producttype'"`             //产品类型 - 1:标准仓单 2:等标 3:非标
-	Spotgoodsdesc     string  `json:"spotgoodsdesc"  xorm:"'Spotgoodsdesc'"`         //商品型号
-	Planqty           float64 `json:"planqty"  xorm:"'Planqty'"`                     //计划数量
-	Convertfactor     float64 `json:"convertfactor"  xorm:"'Convertfactor'"`         //标仓系数
-	Plantime          string  `json:"plantime"  xorm:"'Plantime'"`                   //计划时间
-	Hedgeplanstatus   int     `json:"hedgeplanstatus"  xorm:"'Hedgeplanstatus'"`     //套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
-	Remark            string  `json:"remark"  xorm:"'Remark'"`                       //备注
-	CREATETIME        string  `json:"createtime"  xorm:"'CREATETIME'"`               //创建时间
-	UPDATETIME        string  `json:"updatetime"  xorm:"'UPDATETIME'"`               //更新时间
-	AUDITTIME         string  `json:"audittime"  xorm:"'AUDITTIME'"`                 //审核时间
+	Producttype       int     `json:"producttype"  xorm:"'Producttype'"`             // 产品类型 - 1:标准仓单 2:等标 3:非标
+	Spotgoodsdesc     string  `json:"spotgoodsdesc"  xorm:"'Spotgoodsdesc'"`         // 商品型号
+	Planqty           float64 `json:"planqty"  xorm:"'Planqty'"`                     // 计划数量
+	Convertfactor     float64 `json:"convertfactor"  xorm:"'Convertfactor'"`         // 标仓系数
+	Plantime          string  `json:"plantime"  xorm:"'Plantime'"`                   // 计划时间
+	Hedgeplanstatus   int     `json:"hedgeplanstatus"  xorm:"'Hedgeplanstatus'"`     // 套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+	Remark            string  `json:"remark"  xorm:"'Remark'"`                       // 备注
+	CREATETIME        string  `json:"createtime"  xorm:"'CREATETIME'"`               // 创建时间
+	UPDATETIME        string  `json:"updatetime"  xorm:"'UPDATETIME'"`               // 更新时间
+	AUDITTIME         string  `json:"audittime"  xorm:"'AUDITTIME'"`                 // 审核时间
+	UNITID            int32   `json:"unitid"  xorm:"'UNITID'"`                       // 单位id
+	ENUMDICNAME       string  `json:"enumdicname"`                                   // 单位名称
+}
+
+func (r *ErmcpHedgePlan) calc() {
+	r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
 }
 
 func (r *ErmcpHedgePlan) buildSql(status string) string {
@@ -42,6 +49,7 @@ func (r *ErmcpHedgePlan) buildSql(status string) string {
 		"       t.g.Deliverygoodsname," +
 		"       t.Wrstandardid," +
 		"       w.Wrstandardname," +
+		"       w.unitid," +
 		"       t.Producttype," +
 		"       t.Spotgoodsdesc," +
 		"       t.Planqty," +
@@ -77,6 +85,9 @@ func (r *ErmcpHedgePlan) GetData(status string) ([]ErmcpHedgePlan, error) {
 		logger.GetLogger().Errorf("query hedgeplan:%v", err)
 		return sData, err
 	}
+	for i := range sData {
+		sData[i].calc()
+	}
 
 	return sData, nil
 }