|
|
@@ -1017,25 +1017,28 @@ func (r *Ermcp3SellBuyContract) GetDataEx() (interface{}, error) {
|
|
|
|
|
|
// Ermcp3ExposureDetail 敞口现货明细
|
|
|
type Ermcp3ExposureDetail struct {
|
|
|
- Createtime string `json:"createtime" xorm:"'createtime'"` // 时间
|
|
|
- Areauserid int64 `json:"areauserid" xorm:"'areauserid'"` // 机构ID
|
|
|
- Logtype int32 `json:"logtype" xorm:"'logtype'"` // 类型 - 1:套保计划 2:现货合同
|
|
|
- Contracttype int32 `json:"contracttype" xorm:"'contracttype'"` // 现货合同类型 - 1:采购 -1:销售
|
|
|
- Qty float64 `json:"qty" xorm:"'qty'"` // 数量
|
|
|
- RelateNo string `json:"relateNo" xorm:"'relateNo'"` // 现货合同/套保计划编号
|
|
|
- Middlegoodsname string `json:"middlegoodsname" xorm:"'middlegoodsname'"` // 套保商品名称
|
|
|
- Middlegoodscode string `json:"middlegoodscode" xorm:"'middlegoodscode'"` // 套保商品代码
|
|
|
- MiddlegoodsId int32 `json:"middlegoodsId" xorm:"'middlegoodsId'"` // 套保商品id
|
|
|
- Unitid int32 `json:"-" xorm:"'unitid'"` // 现货商品单位ID
|
|
|
- Enumdicname string `json:"enumdicname" xorm:"'enumdicname'"` // 现货商品单位名称
|
|
|
- ChangeQty float64 `json:"changeQty" xorm:"'changeQty'"` // 套保变动量
|
|
|
- Convertfactor float64 `json:"convertfactor" xorm:"'convertfactor'"` // 标仓系数
|
|
|
- Convertratio float64 `json:"convertratio" xorm:"'convertratio'"` // 套保系数
|
|
|
- DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种id
|
|
|
- DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
|
|
|
- DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
|
|
|
- MGUNITID int32 `json:"mgunitid" xorm:"'MGUNITID'"` // 套保品种单位id
|
|
|
- MGUNITIDNAME string `json:"mgunitidname"` // 套保品种单位名称
|
|
|
+ Createtime string `json:"createtime" xorm:"'createtime'"` // 时间
|
|
|
+ Areauserid int64 `json:"areauserid" xorm:"'areauserid'"` // 机构ID
|
|
|
+ Logtype int32 `json:"logtype" xorm:"'logtype'"` // 类型 - 1:套保计划 2:现货合同
|
|
|
+ Contracttype int32 `json:"contracttype" xorm:"'contracttype'"` // 现货合同类型 - 1:采购 -1:销售
|
|
|
+ Qty float64 `json:"qty" xorm:"'qty'"` // 数量
|
|
|
+ RelateNo string `json:"relateNo" xorm:"'relateNo'"` // 现货合同/套保计划编号
|
|
|
+ Middlegoodsname string `json:"middlegoodsname" xorm:"'middlegoodsname'"` // 套保商品名称
|
|
|
+ Middlegoodscode string `json:"middlegoodscode" xorm:"'middlegoodscode'"` // 套保商品代码
|
|
|
+ MiddlegoodsId int32 `json:"middlegoodsId" xorm:"'middlegoodsId'"` // 套保商品id
|
|
|
+ ChangeQty float64 `json:"changeQty" xorm:"'changeQty'"` // 套保变动量
|
|
|
+ Convertfactor float64 `json:"convertfactor" xorm:"'convertfactor'"` // 标仓系数
|
|
|
+ Convertratio float64 `json:"convertratio" xorm:"'convertratio'"` // 套保系数
|
|
|
+ DELIVERYGOODSID int32 `json:"-" xorm:"'DELIVERYGOODSID'"` // 现货品种id
|
|
|
+ DELIVERYGOODSCODE string `json:"-" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
|
|
|
+ DELIVERYGOODSNAME string `json:"-" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
|
|
|
+ MGUNITID int32 `json:"mgunitid" xorm:"'MGUNITID'"` // 套保品种单位id
|
|
|
+ MGUNITIDNAME string `json:"mgunitidname"` // 套保品种单位名称
|
|
|
+ WRSTANDARDID int32 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 现货商品ID(SEQ_WRSTANDARD)
|
|
|
+ WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 现货商品代码
|
|
|
+ WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 现货商品名称
|
|
|
+ UNITID int32 `json:"unitid" xorm:"'UNITID'"` // 现货商品单位id
|
|
|
+ ENUMDICNAME string `json:"enumdicname" xorm:"'enumdicname'"` // 现货商品单位名称
|
|
|
}
|
|
|
|
|
|
func (r *Ermcp3ExposureDetail) calc() {
|
|
|
@@ -1051,56 +1054,43 @@ func (r *Ermcp3ExposureDetail) calc() {
|
|
|
r.Qty *= -1
|
|
|
}
|
|
|
|
|
|
- if r.Convertratio > 0 && r.Convertfactor > 0 {
|
|
|
- r.Qty = r.Qty / r.Convertfactor / r.Convertratio
|
|
|
- }
|
|
|
r.MGUNITIDNAME = mtpcache.GetEnumDicitemName(r.MGUNITID)
|
|
|
}
|
|
|
|
|
|
func (r *Ermcp3ExposureDetail) buildSql() string {
|
|
|
- var sqlId utils.SQLVal = "with tmp as" +
|
|
|
- " (select 2 as LogType," +
|
|
|
- " s.spotcontractid as relatedid," +
|
|
|
- " s.contractno as relateNo," +
|
|
|
- " s.qty" +
|
|
|
- " from ermcp_spotcontract s" +
|
|
|
- " union all" +
|
|
|
- " select 1," +
|
|
|
- " t.hedgeplanid as relateid," +
|
|
|
- " t.hedgeplanno as relateNo," +
|
|
|
- " t.planqty as qty" +
|
|
|
- " from ermcp_hedgeplan t)" +
|
|
|
- "select to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
|
|
|
- " t.middlegoodsid," +
|
|
|
- " t.areauserid," +
|
|
|
- " t.logtype," +
|
|
|
- " t.contracttype," +
|
|
|
- " t.qty," +
|
|
|
- " t.convertfactor," +
|
|
|
- " t.convertratio," +
|
|
|
- " t.qty changeQty," +
|
|
|
- " tmp.relateNo," +
|
|
|
- " m.middlegoodsname," +
|
|
|
- " m.middlegoodscode," +
|
|
|
- " m.goodsunitid mgunitid," +
|
|
|
- " g.deliverygoodsid," +
|
|
|
- " g.deliverygoodscode," +
|
|
|
- " g.deliverygoodsname," +
|
|
|
- " g.goodsunitid unitid," +
|
|
|
- " e.enumdicname" +
|
|
|
- " from ermcp_spotexposurelog t" +
|
|
|
- " left join erms_middlegoods m" +
|
|
|
- " on t.middlegoodsid = m.middlegoodsid" +
|
|
|
- " left join deliverygoods g" +
|
|
|
- " on t.deliverygoodsid = g.deliverygoodsid" +
|
|
|
- " left join enumdicitem e" +
|
|
|
- " on g.goodsunitid = e.enumitemname" +
|
|
|
- " and e.enumdiccode = 'goodsunit'" +
|
|
|
- " left join tmp" +
|
|
|
- " on t.logtype = tmp.LogType" +
|
|
|
- " and t.relatedid = tmp.relatedid" +
|
|
|
- " where 1=1 and t.tradedate=to_char(sysdate, 'yyyymmdd')"
|
|
|
- sqlId.And("t.areauserid", r.Areauserid)
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+select to_char(t.updatetime, 'yyyy-mm-dd hh24:mi:ss') createtime,
|
|
|
+ s.userid as areauserid,
|
|
|
+ 2 as LogType,
|
|
|
+ s.contracttype,
|
|
|
+ t.todaypricedqty qty,
|
|
|
+ to_char(s.spotcontractid) as relateid,
|
|
|
+ s.contractno as relateNo,
|
|
|
+ t.todaypricedqty * c.convertratio * (1 / (1 + nvl(w.vatrate, 0))) as changeQty,
|
|
|
+ m.middlegoodsid,
|
|
|
+ m.middlegoodsname,
|
|
|
+ m.middlegoodscode,
|
|
|
+ m.goodsunitid mgunitid,
|
|
|
+ w.wrstandardid,
|
|
|
+ w.wrstandardcode,
|
|
|
+ w.wrstandardname,
|
|
|
+ w.unitid,
|
|
|
+ e.enumdicname
|
|
|
+ from ERMCP_SCMiddleGoods t
|
|
|
+ inner join ermcp_spotcontract s
|
|
|
+ on t.spotcontractid = s.spotcontractid
|
|
|
+ left join erms_middlegoods m
|
|
|
+ on t.middlegoodsid = m.middlegoodsid
|
|
|
+ left join erms2_wrsconvertdetail c
|
|
|
+ on t.middlegoodsid = c.middlegoodsid
|
|
|
+ and t.wrstandardid = c.wrstandardid
|
|
|
+ left join wrstandard w
|
|
|
+ on t.wrstandardid = w.wrstandardid
|
|
|
+ left join enumdicitem e
|
|
|
+ on w.unitid = e.enumitemname
|
|
|
+ and e.enumdiccode = 'goodsunit'
|
|
|
+`
|
|
|
+ sqlId.And("s.userid", r.Areauserid)
|
|
|
sqlId.And("t.middlegoodsid", r.MiddlegoodsId)
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
@@ -1121,24 +1111,25 @@ func (r *Ermcp3ExposureDetail) GetDataEx() (interface{}, error) {
|
|
|
|
|
|
// Ermcp3AreaSpot 敞口现货头寸
|
|
|
type Ermcp3AreaSpot struct {
|
|
|
- AREAUSERID int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
|
|
|
- ORIBUYPLANQTY float64 `json:"-" xorm:"'ORIBUYPLANQTY'"` // 期初采购计划数量
|
|
|
- ORIBUYPRICEDQTY float64 `json:"-" xorm:"'ORIBUYPRICEDQTY'"` // 期初采购合同已定价数量
|
|
|
- ORISELLPLANQTY float64 `json:"-" xorm:"'ORISELLPLANQTY'"` // 期初销售计划数量
|
|
|
- ORISELLPRICEDQTY float64 `json:"-" xorm:"'ORISELLPRICEDQTY'"` // 期初销售合同已定价数量
|
|
|
- BUYPLANQTY float64 `json:"-" xorm:"'BUYPLANQTY'"` // 采购计划数量
|
|
|
- BUYPRICEDQTY float64 `json:"-" xorm:"'BUYPRICEDQTY'"` // 采购合同已定价数量
|
|
|
- SELLPLANQTY float64 `json:"-" xorm:"'SELLPLANQTY'"` // 销售计划数量
|
|
|
- SELLPRICEDQTY float64 `json:"-" xorm:"'SELLPRICEDQTY'"` // 销售合同已定价数量
|
|
|
- TOTALSPOTQTY float64 `json:"totalspotqty" xorm:"'TOTALSPOTQTY'"` // 当前数量(现货头寸总量) = (销售计划数量 - 销售已定价数量) - (采购计划数量 - 采购已定价数量)
|
|
|
- OriToalSpotQty float64 `json:"oritoalspotqty" xorm:"'OriToalSpotQty'"` // 昨日数量
|
|
|
- IncreaseQty float64 `json:"increaseqty" xorm:"'IncreaseQty'"` // 增加数量=销售计划数量+采购已定价数量
|
|
|
- DecreaseQty float64 `json:"decreaseqty" xorm:"'DecreaseQty'"` // 减少数量=-(销售已定价数量+采购计划数量)
|
|
|
- UPDATETIME string `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
|
|
|
- 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
|
|
|
+ AREAUSERID int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
|
|
|
+ ORIBUYPLANQTY float64 `json:"-" xorm:"'ORIBUYPLANQTY'"` // 期初采购计划数量
|
|
|
+ ORIBUYPRICEDQTY float64 `json:"-" xorm:"'ORIBUYPRICEDQTY'"` // 期初采购合同已定价数量
|
|
|
+ ORISELLPLANQTY float64 `json:"-" xorm:"'ORISELLPLANQTY'"` // 期初销售计划数量
|
|
|
+ ORISELLPRICEDQTY float64 `json:"-" xorm:"'ORISELLPRICEDQTY'"` // 期初销售合同已定价数量
|
|
|
+ BUYPLANQTY float64 `json:"-" xorm:"'BUYPLANQTY'"` // 采购计划数量
|
|
|
+ BUYPRICEDQTY float64 `json:"-" xorm:"'BUYPRICEDQTY'"` // 采购合同已定价数量
|
|
|
+ SELLPLANQTY float64 `json:"-" xorm:"'SELLPLANQTY'"` // 销售计划数量
|
|
|
+ SELLPRICEDQTY float64 `json:"-" xorm:"'SELLPRICEDQTY'"` // 销售合同已定价数量
|
|
|
+ TOTALSPOTQTY float64 `json:"totalspotqty" xorm:"'TOTALSPOTQTY'"` // 当前数量(现货头寸总量) = (销售计划数量 - 销售已定价数量) - (采购计划数量 - 采购已定价数量)
|
|
|
+ OriToalSpotQty float64 `json:"oritoalspotqty" xorm:"'OriToalSpotQty'"` // 昨日数量
|
|
|
+ IncreaseQty float64 `json:"increaseqty" xorm:"'IncreaseQty'"` // 增加数量=销售计划数量+采购已定价数量
|
|
|
+ DecreaseQty float64 `json:"decreaseqty" xorm:"'DecreaseQty'"` // 减少数量=-(销售已定价数量+采购计划数量)
|
|
|
+ UPDATETIME string `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
|
|
|
+ CONVERTRATIO float64 `json:"convertratio" xorm:"'CONVERTRATIO'"` // 套保系数
|
|
|
+ WRSTANDARDID int32 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 现货商品ID(SEQ_WRSTANDARD)
|
|
|
+ WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 现货商品代码
|
|
|
+ WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 现货商品名称
|
|
|
+ UNITID int32 `json:"unitid" xorm:"'UNITID'"` // 现货商品单位id
|
|
|
|
|
|
ENUMDICNAME string `json:"enumdicname"` // 单位名称
|
|
|
}
|
|
|
@@ -1157,29 +1148,34 @@ func (r *Ermcp3AreaSpot) calc() {
|
|
|
r.IncreaseQty = r.SELLPLANQTY - r.ORISELLPLANQTY + r.BUYPRICEDQTY - r.ORIBUYPRICEDQTY
|
|
|
r.DecreaseQty = (r.SELLPRICEDQTY - r.ORISELLPRICEDQTY + r.BUYPLANQTY - r.ORIBUYPLANQTY) * -1
|
|
|
r.OriToalSpotQty = (r.ORISELLPLANQTY - r.ORISELLPRICEDQTY) - (r.ORIBUYPLANQTY - r.ORIBUYPRICEDQTY)
|
|
|
- r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODSUNITID)
|
|
|
+ r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
|
|
|
}
|
|
|
|
|
|
func (r *Ermcp3AreaSpot) buildSql() string {
|
|
|
- var sqlId utils.SQLVal = "select t.AREAUSERID," +
|
|
|
- " t.ORIBUYPLANQTY," +
|
|
|
- " t.ORIBUYPRICEDQTY," +
|
|
|
- " t.ORISELLPLANQTY," +
|
|
|
- " t.ORISELLPRICEDQTY," +
|
|
|
- " t.BUYPLANQTY," +
|
|
|
- " t.BUYPRICEDQTY," +
|
|
|
- " t.SELLPLANQTY," +
|
|
|
- " t.SELLPRICEDQTY," +
|
|
|
- " t.TOTALSPOTQTY," +
|
|
|
- " g.deliverygoodsid," +
|
|
|
- " g.deliverygoodscode," +
|
|
|
- " g.deliverygoodsname," +
|
|
|
- " g.goodsunitid," +
|
|
|
- " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME" +
|
|
|
- " from ermcp_areaspot t" +
|
|
|
- " left join deliverygoods g" +
|
|
|
- " on t.deliverygoodsid = g.deliverygoodsid" +
|
|
|
- " where 1 = 1"
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+select t.AREAUSERID,
|
|
|
+ t.ORIBUYPLANQTY,
|
|
|
+ t.ORIBUYPRICEDQTY,
|
|
|
+ t.ORISELLPLANQTY,
|
|
|
+ t.ORISELLPRICEDQTY,
|
|
|
+ t.BUYPLANQTY,
|
|
|
+ t.BUYPRICEDQTY,
|
|
|
+ t.SELLPLANQTY,
|
|
|
+ t.SELLPRICEDQTY,
|
|
|
+ t.hedgeqty,
|
|
|
+ t.arbitrageqty,
|
|
|
+ t.hedgeqty + t.arbitrageqty TOTALSPOTQTY,
|
|
|
+ t.convertratio,
|
|
|
+ w.wrstandardid,
|
|
|
+ w.wrstandardcode,
|
|
|
+ w.wrstandardname,
|
|
|
+ w.unitid,
|
|
|
+ to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME
|
|
|
+ from ermcp_areamiddlesum t
|
|
|
+ left join wrstandard w
|
|
|
+ on t.wrstandardid = w.wrstandardid
|
|
|
+ where 1 = 1
|
|
|
+`
|
|
|
sqlId.And("t.areauserid", r.AREAUSERID)
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
@@ -1198,22 +1194,22 @@ func (r *Ermcp3AreaSpot) GetDataEx() (interface{}, error) {
|
|
|
return sData, nil
|
|
|
}
|
|
|
|
|
|
-// Ermcp3AreaSpotDetail 敞口现货头寸明细
|
|
|
+// Ermcp3AreaSpotDetail 敞口->现货头寸->现货明细
|
|
|
type Ermcp3AreaSpotDetail struct {
|
|
|
- Relatedid string `json:"relatedid" xorm:"'relatedid'"` // 套保计划ID/现货合同ID
|
|
|
- Relatedno string `json:"relatedno" xorm:"'relatedno'"` // 编号
|
|
|
- LogType int32 `json:"logtype" xorm:"'logType'"` // 记录类型 1-套保 2-现货合同
|
|
|
- Contracttype int32 `json:"contracttype" xorm:"'contracttype'"` // 合同类型 1-采购 -1-销售
|
|
|
- Qty float64 `json:"qty" xorm:"'qty'"` // 数量
|
|
|
- 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 int64 `json:"-"` // 所属用户ID
|
|
|
- DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种id
|
|
|
- DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
|
|
|
- DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
|
|
|
+ Relatedid string `json:"relatedid" xorm:"'relatedid'"` // 套保计划ID/现货合同ID
|
|
|
+ Relatedno string `json:"relatedno" xorm:"'relatedno'"` // 编号
|
|
|
+ LogType int32 `json:"logtype" xorm:"'logType'"` // 记录类型 1-套保 2-现货合同
|
|
|
+ Contracttype int32 `json:"contracttype" xorm:"'contracttype'"` // 合同类型 1-采购 -1-销售
|
|
|
+ Qty float64 `json:"qty" xorm:"'qty'"` // 数量
|
|
|
+ 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 int64 `json:"-"` // 所属用户ID
|
|
|
+ WRSTANDARDID int32 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 现货商品ID(SEQ_WRSTANDARD)
|
|
|
+ WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 现货商品代码
|
|
|
+ WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 现货商品名称
|
|
|
}
|
|
|
|
|
|
func (r *Ermcp3AreaSpotDetail) calc() {
|
|
|
@@ -1249,42 +1245,48 @@ func (r *Ermcp3AreaSpotDetail) calc() {
|
|
|
}
|
|
|
|
|
|
func (r *Ermcp3AreaSpotDetail) buildSql() string {
|
|
|
- var sqlId utils.SQLVal = "with tmp as" +
|
|
|
- " (select to_char(t.hedgeplanid) relatedid," +
|
|
|
- " t.hedgeplanno relatedno," +
|
|
|
- " 1 as logType," +
|
|
|
- " t.contracttype" +
|
|
|
- " from ermcp_hedgeplan t" +
|
|
|
- " where %v in(t.areauserid, t.tradeuserid)" +
|
|
|
- " and t.deliverygoodsid = %v" +
|
|
|
- " union all" +
|
|
|
- " select to_char(t.spotcontractid)," +
|
|
|
- " t.contractno," +
|
|
|
- " 2 as logType," +
|
|
|
- " t.contracttype" +
|
|
|
- " from ermcp_spotcontract t" +
|
|
|
- " where %v in(t.userid, t.tradeuserid)" +
|
|
|
- " and t.deliverygoodsid = %v)" +
|
|
|
- "select t.relatedid," +
|
|
|
- " tmp.relatedno," +
|
|
|
- " t.LogType," +
|
|
|
- " tmp.contracttype," +
|
|
|
- " t.RealQty qty," +
|
|
|
- " to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
|
|
|
- " g.deliverygoodsid," +
|
|
|
- " g.deliverygoodsname," +
|
|
|
- " g.deliverygoodscode," +
|
|
|
- " g.goodsunitid unitid" +
|
|
|
- " from ermcp_spotlog t" +
|
|
|
- " inner join tmp" +
|
|
|
- " on t.LogType = tmp.logType" +
|
|
|
- " and t.relatedid = tmp.relatedid" +
|
|
|
- " and t.areauserid = %v" +
|
|
|
- " and t.deliverygoodsid = %v" +
|
|
|
- " left join deliverygoods g" +
|
|
|
- " on t.deliverygoodsid = g.deliverygoodsid" +
|
|
|
- " where t.tradedate = to_char(sysdate, 'yyyymmdd')"
|
|
|
- sqlId.FormatParam(r.UserId, r.DELIVERYGOODSID, r.UserId, r.DELIVERYGOODSID, r.UserId, r.DELIVERYGOODSID)
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+select *
|
|
|
+ from (select to_char(t.hedgeplanid) as relatedid,
|
|
|
+ t.hedgeplanno relatedno,
|
|
|
+ 1 as LogType,
|
|
|
+ t.contracttype,
|
|
|
+ t.planqty qty,
|
|
|
+ to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') createtime,
|
|
|
+ w.wrstandardid,
|
|
|
+ w.wrstandardcode,
|
|
|
+ w.wrstandardname,
|
|
|
+ w.unitid,
|
|
|
+ t.areauserid as userid
|
|
|
+ from ermcp_hedgeplan t
|
|
|
+ inner join wrstandard w
|
|
|
+ on t.wrstandardid = w.wrstandardid
|
|
|
+ where t.hedgeplanstatus in (2, 3, 5)
|
|
|
+ and t.tradedate = to_char(sysdate, 'yyyymmdd')
|
|
|
+ and t.areauserid = %v
|
|
|
+ and t.wrstandardid = %v
|
|
|
+ union all
|
|
|
+ select to_char(t.spotcontractid) as relatedid,
|
|
|
+ t.contractno relatedno,
|
|
|
+ 2 as LogType,
|
|
|
+ t.contracttype,
|
|
|
+ t.qty,
|
|
|
+ to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') createtime,
|
|
|
+ w.wrstandardid,
|
|
|
+ w.wrstandardcode,
|
|
|
+ w.wrstandardname,
|
|
|
+ w.unitid,
|
|
|
+ t.userid
|
|
|
+ from ermcp_spotcontract t
|
|
|
+ inner join wrstandard w
|
|
|
+ on t.wrstandardid = w.wrstandardid
|
|
|
+ where t.userid = %v
|
|
|
+ and t.wrstandardid = %v
|
|
|
+ and t.contractstatus in (2, 3, 5)
|
|
|
+ and t.tradedate = to_char(sysdate, 'yyyymmdd')) a
|
|
|
+ order by a.createtime desc
|
|
|
+`
|
|
|
+ sqlId.FormatParam(r.UserId, r.WRSTANDARDID, r.UserId, r.WRSTANDARDID)
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
|