Ver código fonte

修改接口BUG

zhou.xiaoning 3 anos atrás
pai
commit
c7e1c6621f
4 arquivos alterados com 115 adições e 55 exclusões
  1. 22 6
      docs/docs.go
  2. 22 6
      docs/swagger.json
  3. 20 8
      docs/swagger.yaml
  4. 51 35
      models/ermcp8.go

+ 22 - 6
docs/docs.go

@@ -20981,6 +20981,10 @@ var doc = `{
                     "description": "期货套期量",
                     "type": "number"
                 },
+                "futureqtychange": {
+                    "description": "期货变动量 = FutureQty - OriFutureQty",
+                    "type": "number"
+                },
                 "goodsunitid": {
                     "description": "单位ID",
                     "type": "integer"
@@ -20993,6 +20997,10 @@ var doc = `{
                     "description": "套期期现比例 = 期货套期量/被套期现货敞口量",
                     "type": "number"
                 },
+                "hedgedtotalexposourechange": {
+                    "description": "被套期敞口变动量 = HedgedTotalExposure - OriHedgedTotalExposure",
+                    "type": "number"
+                },
                 "hedgedtotalexposure": {
                     "description": "套期敞口量 = 被套期现货敞口量+期货套期量",
                     "type": "number"
@@ -21001,6 +21009,10 @@ var doc = `{
                     "description": "套期计划量",
                     "type": "number"
                 },
+                "hedgeplanqtychange": {
+                    "description": "计划变动量 = HedgePlanQty - OriHedgePlanQty",
+                    "type": "number"
+                },
                 "hedgespotqty": {
                     "description": "被套期现货量",
                     "type": "number"
@@ -21053,6 +21065,10 @@ var doc = `{
                     "description": "现货总量",
                     "type": "number"
                 },
+                "spotqtychange": {
+                    "description": "现货变动量 = SpotQty - OriSpotQty",
+                    "type": "number"
+                },
                 "spratio": {
                     "description": "总期现比例 = 期货套期量/现货敞口量",
                     "type": "number"
@@ -21061,6 +21077,10 @@ var doc = `{
                     "description": "总敞口量 = 现货敞口量 + 期货套期量",
                     "type": "number"
                 },
+                "totalexposurechange": {
+                    "description": "总敞口变动量 = TotalExposure - OriTotalExposure",
+                    "type": "number"
+                },
                 "updatetime": {
                     "description": "更新时间  --DATE",
                     "type": "string"
@@ -26061,7 +26081,7 @@ var doc = `{
                 },
                 "hedgeditemid": {
                     "description": "被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "hedgeditemname": {
                     "description": "项目名称",
@@ -31385,7 +31405,7 @@ var doc = `{
                     "type": "number"
                 },
                 "createtime": {
-                    "description": "创建时间",
+                    "description": "[日期时间]创建时间",
                     "type": "string"
                 },
                 "creatorid": {
@@ -31476,10 +31496,6 @@ var doc = `{
                     "description": "[价格]成交价格",
                     "type": "number"
                 },
-                "tradetime": {
-                    "description": "日期时间",
-                    "type": "string"
-                },
                 "tradetradedate": {
                     "description": "成交交易日(yyyyMMdd)",
                     "type": "string"

+ 22 - 6
docs/swagger.json

@@ -20965,6 +20965,10 @@
                     "description": "期货套期量",
                     "type": "number"
                 },
+                "futureqtychange": {
+                    "description": "期货变动量 = FutureQty - OriFutureQty",
+                    "type": "number"
+                },
                 "goodsunitid": {
                     "description": "单位ID",
                     "type": "integer"
@@ -20977,6 +20981,10 @@
                     "description": "套期期现比例 = 期货套期量/被套期现货敞口量",
                     "type": "number"
                 },
+                "hedgedtotalexposourechange": {
+                    "description": "被套期敞口变动量 = HedgedTotalExposure - OriHedgedTotalExposure",
+                    "type": "number"
+                },
                 "hedgedtotalexposure": {
                     "description": "套期敞口量 = 被套期现货敞口量+期货套期量",
                     "type": "number"
@@ -20985,6 +20993,10 @@
                     "description": "套期计划量",
                     "type": "number"
                 },
+                "hedgeplanqtychange": {
+                    "description": "计划变动量 = HedgePlanQty - OriHedgePlanQty",
+                    "type": "number"
+                },
                 "hedgespotqty": {
                     "description": "被套期现货量",
                     "type": "number"
@@ -21037,6 +21049,10 @@
                     "description": "现货总量",
                     "type": "number"
                 },
+                "spotqtychange": {
+                    "description": "现货变动量 = SpotQty - OriSpotQty",
+                    "type": "number"
+                },
                 "spratio": {
                     "description": "总期现比例 = 期货套期量/现货敞口量",
                     "type": "number"
@@ -21045,6 +21061,10 @@
                     "description": "总敞口量 = 现货敞口量 + 期货套期量",
                     "type": "number"
                 },
+                "totalexposurechange": {
+                    "description": "总敞口变动量 = TotalExposure - OriTotalExposure",
+                    "type": "number"
+                },
                 "updatetime": {
                     "description": "更新时间  --DATE",
                     "type": "string"
@@ -26045,7 +26065,7 @@
                 },
                 "hedgeditemid": {
                     "description": "被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "hedgeditemname": {
                     "description": "项目名称",
@@ -31369,7 +31389,7 @@
                     "type": "number"
                 },
                 "createtime": {
-                    "description": "创建时间",
+                    "description": "[日期时间]创建时间",
                     "type": "string"
                 },
                 "creatorid": {
@@ -31460,10 +31480,6 @@
                     "description": "[价格]成交价格",
                     "type": "number"
                 },
-                "tradetime": {
-                    "description": "日期时间",
-                    "type": "string"
-                },
                 "tradetradedate": {
                     "description": "成交交易日(yyyyMMdd)",
                     "type": "string"

+ 20 - 8
docs/swagger.yaml

@@ -3980,6 +3980,9 @@ definitions:
       futureqty:
         description: 期货套期量
         type: number
+      futureqtychange:
+        description: 期货变动量 = FutureQty - OriFutureQty
+        type: number
       goodsunitid:
         description: 单位ID
         type: integer
@@ -3989,12 +3992,18 @@ definitions:
       hedgedspratio:
         description: 套期期现比例 = 期货套期量/被套期现货敞口量
         type: number
+      hedgedtotalexposourechange:
+        description: 被套期敞口变动量 = HedgedTotalExposure - OriHedgedTotalExposure
+        type: number
       hedgedtotalexposure:
         description: 套期敞口量 = 被套期现货敞口量+期货套期量
         type: number
       hedgeplanqty:
         description: 套期计划量
         type: number
+      hedgeplanqtychange:
+        description: 计划变动量 = HedgePlanQty - OriHedgePlanQty
+        type: number
       hedgespotqty:
         description: 被套期现货量
         type: number
@@ -4034,12 +4043,18 @@ definitions:
       spotqty:
         description: 现货总量
         type: number
+      spotqtychange:
+        description: 现货变动量 = SpotQty - OriSpotQty
+        type: number
       spratio:
         description: 总期现比例 = 期货套期量/现货敞口量
         type: number
       totalexposure:
         description: 总敞口量 = 现货敞口量 + 期货套期量
         type: number
+      totalexposurechange:
+        description: 总敞口变动量 = TotalExposure - OriTotalExposure
+        type: number
       updatetime:
         description: 更新时间  --DATE
         type: string
@@ -7760,7 +7775,7 @@ definitions:
         type: string
       hedgeditemid:
         description: 被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)
-        type: integer
+        type: string
       hedgeditemname:
         description: 项目名称
         type: string
@@ -11028,7 +11043,7 @@ definitions:
         type: integer
       convertratio:
         description: 品种系数
-        type: number   
+        type: number
       deliverygoodscode:
         description: 现货品种代码
         type: string
@@ -11046,7 +11061,7 @@ definitions:
         type: integer
       hedgeditemid:
         description: 被套期项目ID
-        type: string      
+        type: string
       hedgeditemnum:
         description: 项目编号
         type: string
@@ -11064,7 +11079,7 @@ definitions:
         type: integer
       wrstandardname:
         description: 现货品类名称
-        type: string             
+        type: string
     required:
     - areauserid
     - goodsid
@@ -11752,7 +11767,7 @@ definitions:
         description: 套期商品变化量 = RelatedLot * AgreeUnit * ConvertRatio
         type: number
       createtime:
-        description: 创建时间
+        description: '[日期时间]创建时间'
         type: string
       creatorid:
         description: 创建人ID
@@ -11821,9 +11836,6 @@ definitions:
       tradeprice:
         description: '[价格]成交价格'
         type: number
-      tradetime:
-        description: 日期时间
-        type: string
       tradetradedate:
         description: 成交交易日(yyyyMMdd)
         type: string

+ 51 - 35
models/ermcp8.go

@@ -749,10 +749,10 @@ func (r *Ermcppatradelinkdetail) buildSql() string {
 		t.RELATEDLOT,
 		(t.RelatedLot * t.TradePrice * t.AgreeUnit) AMOUNT,
 		to_char(t.TRADEID) TRADEID,
-		(u.ACCOUNTNAME || '/' || to_char(t.ACCOUNTID)) NAME
+		(u.ACCOUNTNAME || '/' || to_char(p.ACCOUNTID)) NAME
 	FROM ERMCP_PA_TradeLinkDetail t
 	LEFT JOIN ERMCP_PA_TradeLink p ON p.TradeID = t.TradeID AND p.BuyorSell = t.BuyorSell
-	LEFT JOIN TAACCOUNT ta ON ta.ACCOUNTID = t.ACCOUNTID
+	LEFT JOIN TAACCOUNT ta ON ta.ACCOUNTID = p.ACCOUNTID
 	LEFT JOIN USERACCOUNT u on u.userid = ta.relateduserid
 	WHERE t.HedgeFlag = 13 AND t.SpotContractID = %v
 	ORDER BY p.TradeTime
@@ -887,22 +887,22 @@ func (r *InternalUncorrelatedTradeDetail) GetDataEx() (interface{}, error) {
 
 // InternalEnableTradeDetail 内部成交单可关联项目
 type InternalEnableTradeDetail struct {
-	HEDGEDITEMNUM     string  `json:"hedgeditemnum"  xorm:"HEDGEDITEMNUM"`                                // 项目编号
-	Deliverygoodsid   int32   `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID"`                            // 现货品种ID(SEQ_DELIVERYGOODS)
-	Deliverygoodscode string  `json:"deliverygoodscode"  xorm:"DELIVERYGOODSCODE"`                        // 现货品种代码
-	Deliverygoodsname string  `json:"deliverygoodsname"  xorm:"DELIVERYGOODSNAME"`                        // 现货品种名称
-	Wrstandardid      int64   `json:"wrstandardid"  xorm:"WRSTANDARDID"`                                  // 现货品类ID(SEQ_WRSTANDARD)
-	Wrstandardcode    string  `json:"wrstandardcode"  xorm:"WRSTANDARDCODE"`                              // 现货品类代码
-	Wrstandardname    string  `json:"wrstandardname"  xorm:"WRSTANDARDNAME"`                              // 现货品类名称
-	UNEXESPOTQTY      float64 `json:"unexespotqty"  xorm:"UNEXESPOTQTY"`                                  // 未执行现货量
-	UNEXEHEDGEQTY     float64 `json:"unexehedgeqty"  xorm:"UNEXEHEDGEQTY"`                                // 未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)
-	FUTUREHEDGEQTY    float64 `json:"futurehedgeqty"  xorm:"FUTUREHEDGEQTY"`                              // [已关联数量]期货持仓套期量
-	HEDGEDITEMID      string  `json:"hedgeditemid"  xorm:"HEDGEDITEMID"`                              	  // 被套期项目ID
-	AGREEUNIT    	  float64 `json:"agreeunit"  xorm:"AGREEUNIT"`                              		  // 合约乘数
-	CONVERTRATIO   	  float64 `json:"convertratio"  xorm:"CONVERTRATIO"`                              	  // 品种系数
-
-	AREAUSERID        int64   `json:"areauserid"  xorm:"AREAUSERID" form:"areauserid" binding:"required"` // 企业ID
-	GOODSID int64 `form:"goodsid" binding:"required"` // 期货合约ID
+	HEDGEDITEMNUM     string  `json:"hedgeditemnum"  xorm:"HEDGEDITEMNUM"`         // 项目编号
+	Deliverygoodsid   int32   `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID"`     // 现货品种ID(SEQ_DELIVERYGOODS)
+	Deliverygoodscode string  `json:"deliverygoodscode"  xorm:"DELIVERYGOODSCODE"` // 现货品种代码
+	Deliverygoodsname string  `json:"deliverygoodsname"  xorm:"DELIVERYGOODSNAME"` // 现货品种名称
+	Wrstandardid      int64   `json:"wrstandardid"  xorm:"WRSTANDARDID"`           // 现货品类ID(SEQ_WRSTANDARD)
+	Wrstandardcode    string  `json:"wrstandardcode"  xorm:"WRSTANDARDCODE"`       // 现货品类代码
+	Wrstandardname    string  `json:"wrstandardname"  xorm:"WRSTANDARDNAME"`       // 现货品类名称
+	UNEXESPOTQTY      float64 `json:"unexespotqty"  xorm:"UNEXESPOTQTY"`           // 未执行现货量
+	UNEXEHEDGEQTY     float64 `json:"unexehedgeqty"  xorm:"UNEXEHEDGEQTY"`         // 未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)
+	FUTUREHEDGEQTY    float64 `json:"futurehedgeqty"  xorm:"FUTUREHEDGEQTY"`       // [已关联数量]期货持仓套期量
+	HEDGEDITEMID      string  `json:"hedgeditemid"  xorm:"HEDGEDITEMID"`           // 被套期项目ID
+	AGREEUNIT         float64 `json:"agreeunit"  xorm:"AGREEUNIT"`                 // 合约乘数
+	CONVERTRATIO      float64 `json:"convertratio"  xorm:"CONVERTRATIO"`           // 品种系数
+
+	AREAUSERID int64 `json:"areauserid"  xorm:"AREAUSERID" form:"areauserid" binding:"required"` // 企业ID
+	GOODSID    int64 `form:"goodsid" binding:"required"`                                         // 期货合约ID
 }
 
 func (r *InternalEnableTradeDetail) calc() {
@@ -922,7 +922,7 @@ func (r *InternalEnableTradeDetail) buildSql() string {
 		t.UNEXESPOTQTY,
 		t.UNEXEHEDGEQTY,
 		t.FUTUREHEDGEQTY,
-		to_char(T.HEDGEDITEMID,
+		to_char(T.HEDGEDITEMID) HEDGEDITEMID,
 		G.AGREEUNIT,
 		GC.CONVERTRATIO
 	FROM ERMCP2_HIMiddleGoods t
@@ -1277,7 +1277,7 @@ func (r *ErmcpSpotContractModelEx) buildSql(req QrySpotContractExReq) string {
 		str += " and uc.ACCOUNTNAME like '%%%s%%'"
 		str = fmt.Sprintf(str, req.CUSTOMERNAME)
 	}
-	if req.CONTRACTTYPE > 0 {
+	if req.CONTRACTTYPE != 0 {
 		str += " and t.CONTRACTTYPE = %v"
 		str = fmt.Sprintf(str, req.CONTRACTTYPE)
 	}
@@ -1300,7 +1300,7 @@ func (r *ErmcpSpotContractModelEx) GetData(req QrySpotContractExReq) ([]ErmcpSpo
 
 // Ermcp8EnableHedgeditem 可关联项目
 type Ermcp8EnableHedgeditem struct {
-	HEDGEDITEMID   string  `json:"hedgeditemid"  xorm:"HEDGEDITEMID"`     // 被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)
+	HEDGEDITEMID   string `json:"hedgeditemid"  xorm:"HEDGEDITEMID"`     // 被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)
 	HEDGEDITEMNUM  string `json:"hedgeditemnum"  xorm:"HEDGEDITEMNUM"`   // 项目编号
 	HEDGEDITEMNAME string `json:"hedgeditemname"  xorm:"HEDGEDITEMNAME"` // 项目名称
 	HEDGEDTYPE     int32  `json:"hedgedtype"  xorm:"HEDGEDTYPE"`         // 套期类型 - 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目
@@ -1572,8 +1572,14 @@ type Ermcp2AreaExposure struct {
 	OriHedgedSpotExposure  float64 `json:"orihedgedspotexposure"`  // 期初被套期现货敞口量
 	OriHedgedTotalExposure float64 `json:"orihedgedtotalexposure"` // 期初套期敞口量
 	UpdateTime             string  `json:"updatetime"`             // 更新时间  --DATE
-	MiddleGoodsName        string  `json:"middlegoodsname"`        //套保品种名称
-	GoodsUnitID            int     `json:"goodsunitid"`            //单位ID
+	MiddleGoodsName        string  `json:"middlegoodsname"`        // 套保品种名称
+	GoodsUnitID            int     `json:"goodsunitid"`            // 单位ID
+
+	TotalExposureChange        float64 `json:"totalexposurechange"`        // 总敞口变动量 = TotalExposure - OriTotalExposure
+	HedgedTotalExposoureChange float64 `json:"hedgedtotalexposourechange"` // 被套期敞口变动量 = HedgedTotalExposure - OriHedgedTotalExposure
+	SpotQtyChange              float64 `json:"spotqtychange"`              // 现货变动量 = SpotQty - OriSpotQty
+	HedgePlanQtyChange         float64 `json:"hedgeplanqtychange"`         // 计划变动量 = HedgePlanQty - OriHedgePlanQty
+	FutureQtyChange            float64 `json:"futureqtychange"`            // 期货变动量 = FutureQty - OriFutureQty
 
 	EnumdicName string `json:"enumdicname"` // 单位
 
@@ -1607,6 +1613,12 @@ func (r *Ermcp2AreaExposure) ParseFromProto(p *pb.Ermcp2AreaExposure) {
 	if p.GetGoodsUnitID() != 0 {
 		r.EnumdicName = mtpcache.GetEnumDicitemName(int32(p.GetGoodsUnitID()))
 	}
+
+	r.TotalExposureChange = r.TotalExposure - r.OriTotalExposure
+	r.HedgedTotalExposoureChange = r.HedgedTotalExposure - r.OriHedgedTotalExposure
+	r.SpotQtyChange = r.SpotQty - r.OriSpotQty
+	r.HedgePlanQtyChange = r.HedgePlanQty - r.OriHedgePlanQty
+	r.FutureQtyChange = r.FutureQty - r.OriFutureQty
 }
 
 // GetDataEx 从数据库中查询数据
@@ -1771,8 +1783,8 @@ type Ermcp2hedgeditemsDetail struct {
 	UNEXEQTY       float64 `json:"unexeqty"  xorm:"UNEXEQTY"`            // 未执行现货量 = 套期现货量 - 执行现货量
 	AccountName    string  `json:"accountname" xorm:"ACCOUNTNAME"`       // 套期主体
 
-	USERID        int64 `json:"-" form:"userid"`         // 用户ID
-	MIDDLEGOODSID int64 `json:"-"  form:"middlegoodsid"` // 套保品种ID
+	USERID        int64 `json:"-" form:"userid"`        // 用户ID
+	MIDDLEGOODSID int64 `json:"-" form:"middlegoodsid"` // 套保品种ID
 }
 
 func (r *Ermcp2hedgeditemsDetail) calc() {
@@ -1797,7 +1809,12 @@ func (r *Ermcp2hedgeditemsDetail) buildSql() string {
 		LEFT JOIN ERMCP2_HedgedItem h on h.HedgedItemID = t.HEDGEDITEMID
 		LEFT JOIN useraccount u ON u.userid = t.TRADEUSERID
 		WHERE t.SpotType IN (1,2) 
-			AND t.areauserid = %v AND mg.MiddleGoodsID = %v
+			AND t.areauserid = %v 
+			AND t.wrstandardid 
+				IN (SELECT 
+						wrc.wrstandardid 
+					FROM ERMS2_WRSConvertDetail wrc 
+					WHERE wrc.middlegoodsid = %v)
 	`
 	sqlId.FormatParam(r.USERID, r.MIDDLEGOODSID)
 
@@ -1842,18 +1859,17 @@ type Patradelinkdetail struct {
 	AREAUSERID     int64   `json:"areauserid"  xorm:"AREAUSERID"`                            // 所属机构
 	CREATORSRC     int32   `json:"creatorsrc"  xorm:"CREATORSRC"`                            // 创建人来源 - 1:管理端 2:终端 3:交易
 	CREATORID      int64   `json:"creatorid"  xorm:"CREATORID"`                              // 创建人ID
-	CREATETIME     string  `json:"createtime"  xorm:"CREATETIME"`                            // 创建时间
+	CREATETIME     string  `json:"createtime"  xorm:"CREATETIME"`                            // [日期时间]创建时间
 	LINKSTATUS     int32   `json:"linkstatus"  xorm:"LINKSTATUS"`                            // 关联状态 - 1:成功 2:失败 3:解绑
 	RETCODE        int32   `json:"retcode"  xorm:"RETCODE"`                                  // 返回码
 
-	TRADETIME          time.Time `json:"tradetime"  xorm:"TRADETIME"`                  // 日期时间
-	ORDERTYPE          int32     `json:"ordertype"  xorm:"ORDERTYPE"`                  // 单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单
-	OPTIONCODE         string    `json:"optioncode"  xorm:"OPTIONCODE"`                // [期货合约]期权代码 [期权]
-	AMOUNT             float64   `json:"amount"  xorm:"AMOUNT"`                        // 金额 = RelatedLot * TradePrice * AgreeUnit
-	NAME               string    `json:"name" xorm:"NAME"`                             // 账户名/子账户
-	GOODSCODE          string    `json:"goodscode"  xorm:"GOODSCODE"`                  // 商品代码(内部)
-	CONVERTRATIOCHANGE float64   `json:"convertratiochange" xorm:"CONVERTRATIOCHANGE"` // 套期商品变化量 = RelatedLot * AgreeUnit * ConvertRatio
-	AccountName        string    `json:"accountname" xorm:"ACCOUNTNAME"`               // 套期主体
+	ORDERTYPE          int32   `json:"ordertype"  xorm:"ORDERTYPE"`                  // 单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单
+	OPTIONCODE         string  `json:"optioncode"  xorm:"OPTIONCODE"`                // [期货合约]期权代码 [期权]
+	AMOUNT             float64 `json:"amount"  xorm:"AMOUNT"`                        // 金额 = RelatedLot * TradePrice * AgreeUnit
+	NAME               string  `json:"name" xorm:"NAME"`                             // 账户名/子账户
+	GOODSCODE          string  `json:"goodscode"  xorm:"GOODSCODE"`                  // 商品代码(内部)
+	CONVERTRATIOCHANGE float64 `json:"convertratiochange" xorm:"CONVERTRATIOCHANGE"` // 套期商品变化量 = RelatedLot * AgreeUnit * ConvertRatio
+	AccountName        string  `json:"accountname" xorm:"ACCOUNTNAME"`               // 套期主体
 
 	USERID int64 `json:"-" form:"userid"` // 用户ID
 }