|
|
@@ -570,7 +570,7 @@ func (r *Ermcp3ExpourseReport) buildSqlDay() string {
|
|
|
sqlId.AndEx("t.AREAUSERID", r.AREAUSERID, r.AREAUSERID > 0)
|
|
|
if r.QueryType == 1 {
|
|
|
sqlId.And("t.RECKONDATE", r.RECKONDATE)
|
|
|
- } else if r.QueryType == 3 {
|
|
|
+ } else if r.QueryType == 2 {
|
|
|
sqlId.Join(fmt.Sprintf(" and t.RECKONDATE >= '%v' and t.RECKONDATE <= '%v' ", r.BeginDate, r.EndDate))
|
|
|
}
|
|
|
return sqlId.String()
|
|
|
@@ -645,7 +645,7 @@ func (r *Ermcp3ExpourseReport) GetDataEx() (interface{}, error) {
|
|
|
// Ermcp3ExposureContractDetail 敞口合同明细
|
|
|
type Ermcp3ExposureContractDetail struct {
|
|
|
MIDDLEGOODSID int32 `json:"middlegoodsid" xorm:"'MIDDLEGOODSID'"` // 套保品种id
|
|
|
- DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` //现货商品id
|
|
|
+ DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货商品id
|
|
|
CONVERTRATIO float64 `json:"convertratio" xorm:"'CONVERTRATIO'"` // 折算系数(套保品种)
|
|
|
USERID int64 `json:"userid" xorm:"'USERID'"` // 机构id
|
|
|
SPOTCONTRACTID string `json:"spotcontractid" xorm:"'SPOTCONTRACTID'"` // 合同id
|
|
|
@@ -749,12 +749,12 @@ func (r *Ermcp3ExposureContractDetail) GetDataEx() (interface{}, error) {
|
|
|
// Ermcp3ExposureHedgeplanDetail 敞口套保计划明细
|
|
|
type Ermcp3ExposureHedgeplanDetail struct {
|
|
|
MIDDLEGOODSID int32 `json:"middlegoodsid" xorm:"'MIDDLEGOODSID'"` // 套保品种id
|
|
|
- DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` //现货商品id
|
|
|
+ DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货商品id
|
|
|
CONVERTRATIO float64 `json:"convertratio" xorm:"'CONVERTRATIO'"` // 折算系数(套保品种)
|
|
|
USERID int64 `json:"userid" xorm:"'USERID'"` // 机构id
|
|
|
HEDGEPLANID string `json:"hedgeplanid" xorm:"'HEDGEPLANID'"` // 套保计划id
|
|
|
HEDGEPLANNO string `json:"hedgeplanno" xorm:"'HEDGEPLANNO'"` // 套保计划编号
|
|
|
- BIZTYPE int32 `json:"biztype" xorm:"'BIZTYPE'"` // 业务类型 1-套保 2-套利
|
|
|
+ BIZTYPE int32 `json:"biztype" xorm:"'BIZTYPE'"` // 业务类型(期现用途,业务类型就是期现用途) 1-套保 2-套利
|
|
|
QTY float64 `json:"qty" xorm:"'QTY'"` // 合同量
|
|
|
PRICEDQTY float64 `json:"pricedqty" xorm:"'PRICEDQTY'"` // 已定价量
|
|
|
WRSTANDARDID int32 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 品类id
|
|
|
@@ -769,9 +769,13 @@ type Ermcp3ExposureHedgeplanDetail struct {
|
|
|
NEEDARBITRAGERATIO float64 `json:"needarbitrageratio" xorm:"'NEEDARBITRAGERATIO'"` // 应套利比例
|
|
|
CONTRACTTYPE int32 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 计划类型 - 1:采购 -1:销售
|
|
|
HEDGEPLANSTATUS int32 `json:"hedgeplanstatus" xorm:"'HEDGEPLANSTATUS'"` // 套保计划状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
|
|
|
+ DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货商品代码
|
|
|
+ DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货商吕名称
|
|
|
+ DGUNITID int32 `json:"dgunitid" xorm:"'DGUNITID'"` // 现货商品单位id
|
|
|
|
|
|
EnumdicName string `json:"enumdicname"` // 单位名称(品类)
|
|
|
MGUNITIDNAME string `json:"mgunitidname"` // 单位名称(套保商品)
|
|
|
+ DGUNITIDNAME string `json:"dgunitidname"` // 单位名称(现货商品)
|
|
|
CurQty float64 `json:"-"` // 今定价量
|
|
|
DiffQty float64 `json:"diffqty"` // 套保品种今变动量
|
|
|
ChangQty float64 `json:"changqty"` // 应套保总量变化量
|
|
|
@@ -783,6 +787,7 @@ type Ermcp3ExposureHedgeplanDetail struct {
|
|
|
func (r *Ermcp3ExposureHedgeplanDetail) calc() {
|
|
|
r.EnumdicName = mtpcache.GetEnumDicitemName(r.UNITID)
|
|
|
r.MGUNITIDNAME = mtpcache.GetEnumDicitemName(r.GOODSUNITID)
|
|
|
+ r.DGUNITIDNAME = mtpcache.GetEnumDicitemName(r.DGUNITID)
|
|
|
r.CurQty = r.QTY
|
|
|
r.DiffQty = r.QTY * r.CONVERTRATIO
|
|
|
r.ChangQty = r.QTY * r.NEEDHEDGERATIO * r.CONVERTRATIO
|
|
|
@@ -804,6 +809,9 @@ func (r *Ermcp3ExposureHedgeplanDetail) buildSql() string {
|
|
|
" w.wrstandardname," +
|
|
|
" w.wrstandardcode," +
|
|
|
" w.unitid," +
|
|
|
+ " g.deliverygoodscode," +
|
|
|
+ " g.deliverygoodsname," +
|
|
|
+ " g.goodsunitid," +
|
|
|
" mg.middlegoodsname," +
|
|
|
" mg.middlegoodscode," +
|
|
|
" mg.goodsunitid," +
|
|
|
@@ -816,7 +824,9 @@ func (r *Ermcp3ExposureHedgeplanDetail) buildSql() string {
|
|
|
" on t.middlegoodsid = mg.middlegoodsid" +
|
|
|
" left join wrstandard w" +
|
|
|
" on s.wrstandardid = w.wrstandardid" +
|
|
|
- " where t.wrstandardid = 0 and s.hedgeplanstatus in(2,3)"
|
|
|
+ " left join deliverygoods g on s.deliverygoodsid=g.deliverygoodsid" +
|
|
|
+ " where t.wrstandardid = 0" +
|
|
|
+ " and s.hedgeplanstatus in (2, 3)"
|
|
|
sqlId.AndEx("s.audittradedate", r.TRADEDATE, len(r.TRADEDATE) > 0)
|
|
|
if len(r.BeginDate) > 0 && len(r.EndDate) > 0 {
|
|
|
sqlId.Join(fmt.Sprintf(" and s.audittradedate >= '%v' and s.audittradedate <= '%v'", r.BeginDate, r.EndDate))
|
|
|
@@ -968,7 +978,7 @@ func (r *Ermcp3AreaSpotPLReport) buildSqlDay() string {
|
|
|
sqlParam.And("t.AREAUSERID", r.AREAUSERID)
|
|
|
if r.QueryType == 1 {
|
|
|
sqlParam.And("t.RECKONDATE", r.RECKONDATE)
|
|
|
- } else if r.QueryType == 3 {
|
|
|
+ } else if r.QueryType == 2 {
|
|
|
sqlParam.Join(fmt.Sprintf(" and t.RECKONDATE >= '%v' and t.RECKONDATE <= '%v' ", r.BeginDate, r.EndDate))
|
|
|
}
|
|
|
sqlId.FormatParam(sqlParam.String())
|
|
|
@@ -1194,7 +1204,7 @@ func (r *Ermcp3FinanceReport) buildSqlDay() string {
|
|
|
sqlId.And("t.AREAUSERID", r.AREAUSERID)
|
|
|
if r.QueryType == 1 {
|
|
|
sqlId.And("t.RECKONDATE", r.RECKONDATE)
|
|
|
- } else if r.QueryType == 3 {
|
|
|
+ } else if r.QueryType == 2 {
|
|
|
sqlId.Join(fmt.Sprintf(" and t.RECKONDATE >= '%v' and t.RECKONDATE <= '%v' ", r.BeginDate, r.EndDate))
|
|
|
}
|
|
|
return sqlId.String()
|
|
|
@@ -1662,20 +1672,24 @@ func (r *Ermcp3AreaStockReportEx) buildSqlReportSum(fields []string) string {
|
|
|
|
|
|
// Ermcp3ArealSumPL 损益汇总表
|
|
|
type Ermcp3ArealSumPL struct {
|
|
|
- RECKONDATE string `json:"reckondate" xorm:"RECKONDATE"` // 日照时期(yyyyMMdd)
|
|
|
- CYCLETIME string `json:"cycletime" xorm:"'CYCLETIME'"` // 周期时间 月(YYYYMM) 季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】
|
|
|
- CYCLETYPE int32 `json:"cycletype" xorm:"'CYCLETYPE'"` // 周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】
|
|
|
- AREAUSERID int64 `json:"areauserid" xorm:"AREAUSERID"` // 所属机构\交易用户ID
|
|
|
- MIDDLEGOODSID int64 `json:"middlegoodsid" xorm:"MIDDLEGOODSID"` // 套保品种ID(SEQ_ERMS_MIDDLEGOODS)
|
|
|
- CURRENCYID int32 `json:"currencyid" xorm:"CURRENCYID"` // 结算币种ID
|
|
|
- SPOTACTUALPL float64 `json:"spotactualpl" xorm:"SPOTACTUALPL"` // 现货损益
|
|
|
- SPOTFLOATPL float64 `json:"spotfloatpl" xorm:"SPOTFLOATPL"` // 现货浮动损益
|
|
|
- FUTUREACTUALPL float64 `json:"futureactualpl" xorm:"FUTUREACTUALPL"` // 期货损益
|
|
|
- FUTUREFLOATPL float64 `json:"futurefloatpl" xorm:"FUTUREFLOATPL"` // 期货浮动损益
|
|
|
- SUMACTUALPL float64 `json:"sumactualpl" xorm:"SUMACTUALPL"` // 实际损益 = (ActualPL + FutureActualPL)
|
|
|
- SUMPL float64 `json:"sumpl" xorm:"'SUMPL'"` // 汇总损益
|
|
|
- UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间
|
|
|
-
|
|
|
+ RECKONDATE string `json:"reckondate" xorm:"RECKONDATE"` // 日照时期(yyyyMMdd)
|
|
|
+ CYCLETIME string `json:"cycletime" xorm:"'CYCLETIME'"` // 周期时间 月(YYYYMM) 季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】
|
|
|
+ CYCLETYPE int32 `json:"cycletype" xorm:"'CYCLETYPE'"` // 周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】
|
|
|
+ AREAUSERID int64 `json:"areauserid" xorm:"AREAUSERID"` // 所属机构\交易用户ID
|
|
|
+ MIDDLEGOODSID int64 `json:"middlegoodsid" xorm:"MIDDLEGOODSID"` // 套保品种ID(SEQ_ERMS_MIDDLEGOODS)
|
|
|
+ CURRENCYID int32 `json:"currencyid" xorm:"CURRENCYID"` // 结算币种ID
|
|
|
+ SPOTACTUALPL float64 `json:"spotactualpl" xorm:"SPOTACTUALPL"` // 现货损益
|
|
|
+ SPOTFLOATPL float64 `json:"spotfloatpl" xorm:"SPOTFLOATPL"` // 现货浮动损益
|
|
|
+ FUTUREACTUALPL float64 `json:"futureactualpl" xorm:"FUTUREACTUALPL"` // 期货损益
|
|
|
+ FUTUREFLOATPL float64 `json:"futurefloatpl" xorm:"FUTUREFLOATPL"` // 期货浮动损益
|
|
|
+ SUMACTUALPL float64 `json:"sumactualpl" xorm:"SUMACTUALPL"` // 实际损益 = (ActualPL + FutureActualPL)
|
|
|
+ SUMPL float64 `json:"sumpl" xorm:"'SUMPL'"` // 汇总损益
|
|
|
+ UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间
|
|
|
+ MIDDLEGOODSNAME string `json:"middlegoodsname" xorm:"'MIDDLEGOODSNAME'"` // 套保品种名称
|
|
|
+ MIDDLEGOODSCODE string `json:"middlegoodscode" xorm:"'MIDDLEGOODSCODE'"` // 套保品种代码
|
|
|
+ GOODSUNITID int32 `json:"goodsunitid" xorm:"'GOODSUNITID'"` // 套保品种单位id
|
|
|
+
|
|
|
+ ENUMDICNAME string `json:"enumdicname"` // 单位名称(套保品种)
|
|
|
CURRENCYNAME string `json:"currencyname"` // 币种名称
|
|
|
QueryType int32 `json:"-"` // 查询类型 1-报表 2-报表明细
|
|
|
BeginDate string `json:"begindate"` // 开始交易日
|
|
|
@@ -1684,6 +1698,7 @@ type Ermcp3ArealSumPL struct {
|
|
|
|
|
|
func (r *Ermcp3ArealSumPL) calc() {
|
|
|
r.CURRENCYNAME = mtpcache.GetCurrencyName(r.CURRENCYID)
|
|
|
+ r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODSUNITID)
|
|
|
}
|
|
|
|
|
|
func (r *Ermcp3ArealSumPL) buildSql() string {
|
|
|
@@ -1714,7 +1729,7 @@ func (r *Ermcp3ArealSumPL) buildSqlDay() string {
|
|
|
sqlId.And("t.AREAUSERID", r.AREAUSERID)
|
|
|
if r.QueryType == 1 {
|
|
|
sqlId.And("t.RECKONDATE", r.RECKONDATE)
|
|
|
- } else if r.QueryType == 3 {
|
|
|
+ } else if r.QueryType == 2 {
|
|
|
sqlId.Join(fmt.Sprintf(" and t.RECKONDATE >= '%v' and t.RECKONDATE <= '%v' ", r.BeginDate, r.EndDate))
|
|
|
}
|
|
|
sqlId.Join(" GROUP BY t.RECKONDATE, t.AREAUSERID, t.CURRENCYID")
|
|
|
@@ -1732,8 +1747,12 @@ func (r *Ermcp3ArealSumPL) buildSqlDayDetail() string {
|
|
|
" t.FUTUREFLOATPL," +
|
|
|
" t.SUMACTUALPL," +
|
|
|
" t.SUMPL," +
|
|
|
- " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME" +
|
|
|
+ " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
|
|
|
+ " g.middlegoodsname," +
|
|
|
+ " g.middlegoodscode," +
|
|
|
+ " g.goodsunitid" +
|
|
|
" FROM RECKON_ERMCP_AREASUMPL t" +
|
|
|
+ " LEFT JOIN ERMS_MIDDLEGOODS g on t.middlegoodsid=g.middlegoodsid" +
|
|
|
" WHERE 1 = 1"
|
|
|
sqlId.And("t.AREAUSERID", r.AREAUSERID)
|
|
|
sqlId.AndEx("t.RECKONDATE", r.RECKONDATE, len(r.RECKONDATE) > 0)
|