|
|
@@ -94,7 +94,8 @@ func (r *ErmcpRealExposureModel) GetData() ([]ErmcpRealExposureModel, error) {
|
|
|
if len(ret) > 0 {
|
|
|
var data pb.ErmcpAreaExposure
|
|
|
if err := proto.Unmarshal([]byte(ret), &data); err == nil {
|
|
|
- var m ErmcpRealExposureModel
|
|
|
+ var m = ErmcpRealExposureModel{MiddleGoodsName: sGoods[i].MIDDLEGOODSNAME,
|
|
|
+ MiddleGoodsCode: sGoods[i].MIDDLEGOODSCODE, MiddleGoodsHedgeRatio: sGoods[i].NEEDHEDGERATIO}
|
|
|
m.ParseFromProto(&data)
|
|
|
sData = append(sData, m)
|
|
|
}
|
|
|
@@ -264,6 +265,7 @@ type ErmcpAreaSpotDetailModel struct {
|
|
|
Strtime string `json:"strtime" xorm:"'strtime'"` // 时间
|
|
|
Enumdicname string `json:"enumdicname"` // 现货商品单位名称
|
|
|
Recordname string `json:"recordname"` // 类型名称
|
|
|
+ CREATETIME string `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
|
|
|
Unitid int32 `json:"-" xorm:"'UNITID'"` // 单位ID
|
|
|
UserId int `json:"-"` // 所属用户ID
|
|
|
WrstandardId int32 `json:"-"` // 现货商品ID
|
|
|
@@ -279,7 +281,7 @@ func (r *ErmcpAreaSpotDetailModel) buildSql() string {
|
|
|
" w.wrstandardcode," +
|
|
|
" t.planqty qty," +
|
|
|
" w.unitid," +
|
|
|
- " to_char(t.createtime, 'yyyy-mm-dd hh:mi:ss') strtime" +
|
|
|
+ " to_char(t.createtime, 'yyyy-mm-dd hh:mi:ss') createtime" +
|
|
|
" from ermcp_hedgeplan t" +
|
|
|
" left join wrstandard w" +
|
|
|
" on t.wrstandardid = w.wrstandardid" +
|
|
|
@@ -294,7 +296,7 @@ func (r *ErmcpAreaSpotDetailModel) buildSql() string {
|
|
|
" w.wrstandardcode," +
|
|
|
" t.qty," +
|
|
|
" w.unitid," +
|
|
|
- " to_char(t.createtime, 'yyyy-mm-dd hh:mi:ss') strtime" +
|
|
|
+ " to_char(t.createtime, 'yyyy-mm-dd hh:mi:ss') createtime" +
|
|
|
" from ermcp_spotcontract t" +
|
|
|
" left join wrstandard w" +
|
|
|
" on t.wrstandardid = w.wrstandardid" +
|
|
|
@@ -317,6 +319,10 @@ func (r *ErmcpAreaSpotDetailModel) Calc() {
|
|
|
contractTypeName = "采购"
|
|
|
} else {
|
|
|
contractTypeName = "销售"
|
|
|
+ if r.Qty > 0 {
|
|
|
+ // 销售的数量转为负数
|
|
|
+ r.Qty = r.Qty * -1
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
r.Recordname = contractTypeName + logTypeName
|
|
|
@@ -569,6 +575,8 @@ type ErmcpExposurePostion struct {
|
|
|
CurQty int64 `json:"curqty" xorm:"'CurQty'"` // 当前持仓
|
|
|
DiffQty int64 `json:"diffqty" xorm:"'DiffQty'"` // 持仓变动量=当前持仓-昨日持仓
|
|
|
DiffHedgeQty float64 `json:"diffhedgeqty" xorm:"'DiffHedgeQty'"` // 套保品种变动量=持仓变动量*期货合约单位*期货品种系数
|
|
|
+ AGREEUNIT string `json:"agreeunit"` // 合约单位
|
|
|
+ CONVERTRATIO float64 `json:"convertratio"` // 期货品种系数(折算系数)
|
|
|
}
|
|
|
|
|
|
// 子账户相关计算(不一定用得到,现在说都是查母账号的)
|
|
|
@@ -583,6 +591,10 @@ func (r *ErmcpExposurePostion) ParseFromPos(val *ErmcpTradeGoods, data *ErmcpTra
|
|
|
r.CurQty = data.BUYCURPOSITIONQTY - data.SELLCURPOSITIONQTY
|
|
|
r.DiffQty = r.CurQty - r.YdQty
|
|
|
r.DiffHedgeQty = float64(r.DiffQty) * float64(val.AGREEUNIT) * val.CONVERTRATIO
|
|
|
+ r.CONVERTRATIO = val.CONVERTRATIO
|
|
|
+ if strName := mtpcache.GetEnumDicitemName(val.GOODSUNITID); len(strName) > 0{
|
|
|
+ r.AGREEUNIT = fmt.Sprintf("%v%v/手", val.AGREEUNIT, strName)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 母账户相关计算
|
|
|
@@ -597,6 +609,10 @@ func (r *ErmcpExposurePostion) ParseFromHedgePos(val *ErmcpTradeGoods, data *Erm
|
|
|
r.CurQty = int64(data.CURBUYPOSITION - data.CURSELLPOSITION)
|
|
|
r.DiffQty = r.CurQty - r.YdQty
|
|
|
r.DiffHedgeQty = float64(r.DiffQty) * float64(val.AGREEUNIT) * val.CONVERTRATIO
|
|
|
+ r.CONVERTRATIO = val.CONVERTRATIO
|
|
|
+ if strName := mtpcache.GetEnumDicitemName(val.GOODSUNITID); len(strName) > 0{
|
|
|
+ r.AGREEUNIT = fmt.Sprintf("%v%v/手", val.AGREEUNIT, strName)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 获取敞口明细期货头寸
|
|
|
@@ -640,7 +656,7 @@ type ErmcpHedgePositionDetail struct {
|
|
|
}
|
|
|
|
|
|
func (r *ErmcpHedgePositionDetail) Calc() {
|
|
|
- if r.BUYORSELL == 1 && r.TRADEQTY > 0{
|
|
|
+ if r.BUYORSELL == 1 && r.TRADEQTY > 0 {
|
|
|
r.TRADEQTY = r.TRADEQTY * -1
|
|
|
}
|
|
|
}
|
|
|
@@ -690,4 +706,4 @@ func (r *ErmcpHedgePositionDetail) GetDataEx() (interface{}, error) {
|
|
|
sData[i].Calc()
|
|
|
}
|
|
|
return sData, err
|
|
|
-}
|
|
|
+}
|