|
|
@@ -473,7 +473,7 @@ type Ermcp3ExpourseReport struct {
|
|
|
ARBITRAGEQTY float64 `json:"arbitrageqty" xorm:"'ARBITRAGEQTY'"` // 套利量
|
|
|
NEEDHEDGEQTY float64 `json:"needhedgeqty" xorm:"'NEEDHEDGEQTY'"` // 应套保量
|
|
|
NEEDARBITRAGEQTY float64 `json:"needarbitrageqty" xorm:"'NEEDARBITRAGEQTY'"` // 应套利量
|
|
|
- MIDDLEGOODSNAME string `json:"middlegoodsnam" xorm:"'MIDDLEGOODSNAME'"` // 套保商品名称
|
|
|
+ MIDDLEGOODSNAME string `json:"middlegoodsname" xorm:"'MIDDLEGOODSNAME'"` // 套保商品名称
|
|
|
MIDDLEGOODSCODE string `json:"middlgoodscode" xorm:"'MIDDLEGOODSCODE'"` // 套保商品代码
|
|
|
UNITID int32 `json:"unitid" xorm:"'UNITID'"` // 单位id
|
|
|
MGNEEDHEDGERATIO float64 `json:"mgneedhedgeratio" xorm:"'MGNEEDHEDGERATIO'"` // 套保比例(套保品的)
|
|
|
@@ -663,6 +663,9 @@ type Ermcp3ExposureContractDetail struct {
|
|
|
TRADEDATE string `json:"tradedate" xorm:"'tradedate'"` // 交易日
|
|
|
NEEDHEDGERATIO float64 `json:"needhedgeratio" xorm:"'NEEDHEDGERATIO'"` // 应套保比例
|
|
|
NEEDARBITRAGERATIO float64 `json:"needarbitrageratio" xorm:"'NEEDARBITRAGERATIO'"` // 应套利比例
|
|
|
+ BRANDNAME string `json:"brandname" xorm:"'BRANDNAME'"` // 品牌名称
|
|
|
+ DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货商品代码
|
|
|
+ DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货商品名称
|
|
|
|
|
|
EnumdicName string `json:"enumdicname"` // 单位名称
|
|
|
BUYUSERNAME string `json:"buyusername"` // 采购方名称
|
|
|
@@ -703,7 +706,9 @@ func (r *Ermcp3ExposureContractDetail) buildSql() string {
|
|
|
" mg.needhedgeratio," +
|
|
|
" mg.needarbitrageratio," +
|
|
|
" dg.dgfactoryitemid brandid," +
|
|
|
- " dg.dgfactoryitemvalue brandName" +
|
|
|
+ " dg.dgfactoryitemvalue brandName," +
|
|
|
+ " g.deliverygoodscode," +
|
|
|
+ " g.deliverygoodsname" +
|
|
|
" from erms2_wrsconvertdetail t" +
|
|
|
" inner join ermcp_spotcontract s" +
|
|
|
" on t.deliverygoodsid = s.deliverygoodsid" +
|
|
|
@@ -711,8 +716,11 @@ func (r *Ermcp3ExposureContractDetail) buildSql() string {
|
|
|
" on t.middlegoodsid = mg.middlegoodsid" +
|
|
|
" left join wrstandard w" +
|
|
|
" on s.wrstandardid = w.wrstandardid" +
|
|
|
- " left join dgfactoryitem dg on s.spotgoodsbrandid=dg.dgfactoryitemid" +
|
|
|
- " where t.wrstandardid = 0 and s.contractstatus in(2,3)"
|
|
|
+ " left join dgfactoryitem dg" +
|
|
|
+ " on s.spotgoodsbrandid = dg.dgfactoryitemid" +
|
|
|
+ " left join deliverygoods g on s.deliverygoodsid=g.deliverygoodsid" +
|
|
|
+ " where t.wrstandardid = 0" +
|
|
|
+ " and s.contractstatus in (2, 3)"
|
|
|
sqlId.And("s.audittradedate", r.TRADEDATE)
|
|
|
sqlId.And("t.middlegoodsid", r.MIDDLEGOODSID)
|
|
|
sqlId.Join(fmt.Sprintf(" and %v in(s.userid, s.tradeuserid)", r.USERID))
|
|
|
@@ -737,7 +745,6 @@ type Ermcp3ExposureHedgeplanDetail struct {
|
|
|
USERID int64 `json:"userid" xorm:"'USERID'"` // 机构id
|
|
|
HEDGEPLANID string `json:"hedgeplanid" xorm:"'HEDGEPLANID'"` // 套保计划id
|
|
|
HEDGEPLANNO string `json:"hedgeplanno" xorm:"'HEDGEPLANNO'"` // 套保计划编号
|
|
|
- CONTRACTTYPE int32 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 现货合同类型 - 1:采购 -1:销售
|
|
|
BIZTYPE int32 `json:"biztype" xorm:"'BIZTYPE'"` // 业务类型 1-套保 2-套利
|
|
|
QTY float64 `json:"qty" xorm:"'QTY'"` // 合同量
|
|
|
PRICEDQTY float64 `json:"pricedqty" xorm:"'PRICEDQTY'"` // 已定价量
|
|
|
@@ -751,6 +758,8 @@ type Ermcp3ExposureHedgeplanDetail struct {
|
|
|
TRADEDATE string `json:"tradedate" xorm:"'tradedate'"` // 交易日(登记日)
|
|
|
NEEDHEDGERATIO float64 `json:"needhedgeratio" xorm:"'NEEDHEDGERATIO'"` // 应套保比例
|
|
|
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:已撤回
|
|
|
|
|
|
EnumdicName string `json:"enumdicname"` // 单位名称(品类)
|
|
|
MGUNITIDNAME string `json:"mgunitidname"` // 单位名称(套保商品)
|
|
|
@@ -779,6 +788,7 @@ func (r *Ermcp3ExposureHedgeplanDetail) buildSql() string {
|
|
|
" s.planqty qty," +
|
|
|
" s.wrstandardid," +
|
|
|
" s.audittradedate tradedate," +
|
|
|
+ " s.hedgeplanstatus," +
|
|
|
" w.wrstandardname," +
|
|
|
" w.wrstandardcode," +
|
|
|
" w.unitid," +
|
|
|
@@ -1034,6 +1044,10 @@ type Ermcp3FinanceReport struct {
|
|
|
BUYUNINVOICEDAMOUNT float64 `json:"buyuninvoicedamount" xorm:"BUYUNINVOICEDAMOUNT"` // 采购应收票额(应收票额)
|
|
|
SELLPREPAIDAMOUNT float64 `json:"sellprepaidamount" xorm:"SELLPREPAIDAMOUNT"` // 销售预收款额(预收货款额)
|
|
|
SELLUNPAIDAMOUNT float64 `json:"sellunpaidamount" xorm:"SELLUNPAIDAMOUNT"` // 销售应收款额(应收货款额)
|
|
|
+ WRFACTORTYPEID int64 `json:"wrfactortypeid" xorm:"WRFACTORTYPEID"` // 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
|
|
|
+ DELIVERYGOODSID int64 `json:"deliverygoodsid" xorm:"DELIVERYGOODSID"` // 现货品种ID
|
|
|
+ WRSTANDARDID int64 `json:"wrstandardid" xorm:"WRSTANDARDID"` // 现货商品ID
|
|
|
+ SPOTGOODSBRANDID int32 `json:"spotgoodsbrandid" xorm:"SPOTGOODSBRANDID"` // 现货品牌ID
|
|
|
|
|
|
CURRENCYNAME string `json:"currencyname"` // 币种名称
|
|
|
QueryType int32 `json:"-"` // 查询类型 1-日报表 2-周期报表 3-日报表(范围,[开始日期,结束日期])
|
|
|
@@ -1048,11 +1062,13 @@ func (r *Ermcp3FinanceReport) calc() {
|
|
|
func (r *Ermcp3FinanceReport) buildSql() string {
|
|
|
if r.QueryType == 1 || r.QueryType == 3 {
|
|
|
return r.buildSqlDay()
|
|
|
+ } else if r.QueryType == 4 {
|
|
|
+ return r.buildSqlDayDetail()
|
|
|
}
|
|
|
return r.buildSqlCycle()
|
|
|
}
|
|
|
|
|
|
-// 日报表查询语句
|
|
|
+// buildSqlDay 财务日报表查询语句
|
|
|
func (r *Ermcp3FinanceReport) buildSqlDay() string {
|
|
|
var sqlId utils.SQLVal = "SELECT t.SELLPREINVOICEDAMOUNT," +
|
|
|
" t.SELLUNINVOICEDAMOUNT," +
|
|
|
@@ -1086,7 +1102,42 @@ func (r *Ermcp3FinanceReport) buildSqlDay() string {
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
|
|
|
-// 周期报表查询语句
|
|
|
+// buildSqlDayDetail 财务日报表明细查询语句
|
|
|
+func (r *Ermcp3FinanceReport) buildSqlDayDetail() string {
|
|
|
+ var sqlId utils.SQLVal = "SELECT t.RECKONDATE," +
|
|
|
+ " t.AREAUSERID," +
|
|
|
+ " t.CURRENCYID," +
|
|
|
+ " t.BIZTYPE," +
|
|
|
+ " t.WRFACTORTYPEID," +
|
|
|
+ " t.DELIVERYGOODSID," +
|
|
|
+ " t.WRSTANDARDID," +
|
|
|
+ " t.SPOTGOODSBRANDID," +
|
|
|
+ " t.BUYTODAYSETTLEAMOUNT," +
|
|
|
+ " t.BUYTODAYREFUNDAMOUNT," +
|
|
|
+ " t.BUYPREPAIDAMOUNT," +
|
|
|
+ " t.BUYUNPAIDAMOUNT," +
|
|
|
+ " t.BUYTODAYINVOICEAMOUNT," +
|
|
|
+ " t.BUYPREINVOICEDAMOUNT," +
|
|
|
+ " t.BUYUNINVOICEDAMOUNT," +
|
|
|
+ " t.SELLTODAYSETTLEAMOUNT," +
|
|
|
+ " t.SELLTODAYREFUNDAMOUNT," +
|
|
|
+ " t.SELLPREPAIDAMOUNT," +
|
|
|
+ " t.SELLUNPAIDAMOUNT," +
|
|
|
+ " t.SELLTODAYINVOICEAMOUNT," +
|
|
|
+ " t.SELLPREINVOICEDAMOUNT," +
|
|
|
+ " t.SELLUNINVOICEDAMOUNT," +
|
|
|
+ " t.TODAYRECEIVESUM," +
|
|
|
+ " t.TODAYPAYSUM," +
|
|
|
+ " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME" +
|
|
|
+ " FROM RECKON_ERMCP_AFINANCESUB t" +
|
|
|
+ " WHERE 1 = 1"
|
|
|
+ sqlId.And("t.AREAUSERID", r.AREAUSERID)
|
|
|
+ sqlId.And("t.RECKONDATE", r.RECKONDATE)
|
|
|
+ sqlId.And("t.CURRENCYID", r.CURRENCYID)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+// buildSqlCycle 财务周期报表查询语句
|
|
|
func (r *Ermcp3FinanceReport) buildSqlCycle() string {
|
|
|
var sqlId utils.SQLVal = "SELECT t.SELLPREINVOICEDAMOUNT," +
|
|
|
" t.SELLUNINVOICEDAMOUNT," +
|
|
|
@@ -1323,35 +1374,38 @@ func (r *Ermcp3ArealSumPL) calc() {
|
|
|
func (r *Ermcp3ArealSumPL) buildSql() string {
|
|
|
if r.QueryType == 1 || r.QueryType == 3 {
|
|
|
return r.buildSqlDay()
|
|
|
+ } else if r.QueryType == 4 {
|
|
|
+ return r.buildSqlDayDetail()
|
|
|
}
|
|
|
return r.buildSqlCycle()
|
|
|
}
|
|
|
|
|
|
+// buildSqlDay 损益汇总日报表(需要汇总维度)
|
|
|
func (r *Ermcp3ArealSumPL) buildSqlDay() string {
|
|
|
var sqlId utils.SQLVal = "SELECT t.RECKONDATE," +
|
|
|
" t.AREAUSERID," +
|
|
|
- " t.MIDDLEGOODSID," +
|
|
|
" t.CURRENCYID," +
|
|
|
- " t.SPOTACTUALPL," +
|
|
|
- " t.SPOTFLOATPL," +
|
|
|
- " t.FUTUREACTUALPL," +
|
|
|
- " t.FUTUREFLOATPL," +
|
|
|
- " t.SUMACTUALPL," +
|
|
|
- " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME" +
|
|
|
+ " sum(t.SPOTACTUALPL) SPOTACTUALPL," +
|
|
|
+ " sum(t.SPOTFLOATPL) SPOTFLOATPL," +
|
|
|
+ " sum(t.FUTUREACTUALPL) FUTUREACTUALPL," +
|
|
|
+ " sum(t.FUTUREFLOATPL) FUTUREFLOATPL," +
|
|
|
+ " sum(t.SUMACTUALPL) SUMACTUALPL," +
|
|
|
+ " sum(t.SUMPL) SUMPL" +
|
|
|
" FROM RECKON_ERMCP_AREASUMPL t" +
|
|
|
" WHERE 1 = 1"
|
|
|
+ sqlId.And("t.AREAUSERID", r.AREAUSERID)
|
|
|
if r.QueryType == 1 {
|
|
|
sqlId.And("t.RECKONDATE", r.RECKONDATE)
|
|
|
} else if r.QueryType == 3 {
|
|
|
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")
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
|
|
|
-func (r *Ermcp3ArealSumPL) buildSqlCycle() string {
|
|
|
- var sqlId utils.SQLVal = "SELECT t.AREAUSERID," +
|
|
|
- " t.CYCLETIME," +
|
|
|
- " t.CYCLETYPE," +
|
|
|
+func (r *Ermcp3ArealSumPL) buildSqlDayDetail() string {
|
|
|
+ var sqlId utils.SQLVal = "SELECT t.RECKONDATE," +
|
|
|
+ " t.AREAUSERID," +
|
|
|
" t.MIDDLEGOODSID," +
|
|
|
" t.CURRENCYID," +
|
|
|
" t.SPOTACTUALPL," +
|
|
|
@@ -1359,11 +1413,33 @@ func (r *Ermcp3ArealSumPL) buildSqlCycle() string {
|
|
|
" t.FUTUREACTUALPL," +
|
|
|
" t.FUTUREFLOATPL," +
|
|
|
" t.SUMACTUALPL," +
|
|
|
+ " t.SUMPL," +
|
|
|
" to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME" +
|
|
|
+ " FROM RECKON_ERMCP_AREASUMPL t" +
|
|
|
+ " WHERE 1 = 1"
|
|
|
+ sqlId.And("t.AREAUSERID", r.AREAUSERID)
|
|
|
+ sqlId.And("t.RECKONDATE", r.RECKONDATE)
|
|
|
+ sqlId.And("t.CURRENCYID", r.CURRENCYID)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+func (r *Ermcp3ArealSumPL) buildSqlCycle() string {
|
|
|
+ var sqlId utils.SQLVal = "SELECT t.AREAUSERID," +
|
|
|
+ " t.CYCLETIME," +
|
|
|
+ " t.CYCLETYPE," +
|
|
|
+ " t.CURRENCYID," +
|
|
|
+ " sum(t.SPOTACTUALPL) SPOTACTUALPL," +
|
|
|
+ " sum(t.SPOTFLOATPL) SPOTFLOATPL," +
|
|
|
+ " sum(t.FUTUREACTUALPL) FUTUREACTUALPL," +
|
|
|
+ " sum(t.FUTUREFLOATPL) FUTUREFLOATPL," +
|
|
|
+ " sum(t.SUMACTUALPL) SUMACTUALPL," +
|
|
|
+ " sum(t.SUMPL) SUMPL" +
|
|
|
" FROM REPORT_ERMCP_AREASUMPL t" +
|
|
|
" WHERE 1 = 1"
|
|
|
+ sqlId.And("t.AREAUSERID", r.AREAUSERID)
|
|
|
sqlId.And("t.cycletype", r.CYCLETYPE)
|
|
|
sqlId.And("t.cycletime", r.CYCLETIME)
|
|
|
+ sqlId.Join(" GROUP BY t.AREAUSERID, t.CURRENCYID, t.CYCLETIME, t.CYCLETYPE")
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
|