|
|
@@ -114,8 +114,9 @@ type ErmcpReportOPLog struct {
|
|
|
func (r *ErmcpReportOPLog) Calc() {
|
|
|
r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
|
|
|
r.APPLYNAME = mtpcache.GetUserNameByUserId(r.APPLYID)
|
|
|
- sDes := []string{"点价价格", "点价数量", "结算量", "其它费用", "追加保证金", "溢短金额", "调整金额", "付款金额", "收款金额", "退款金额",
|
|
|
- "收票金额", "开票金额", "提交审核(合同)", "审核通过(合同)", "审核拒绝(合同)", "合同撤回", "提交审核(计划)",
|
|
|
+ // 数据库注释与返回值映身关系: 结算量->确定量, 收款->收款金额, 退款->退款金额, 付款->付款金额, 收票->收票金额, 开票->开票金额
|
|
|
+ sDes := []string{"点价价格", "点价数量", "确定量", "其它费用", "追加保证金", "溢短金额", "调整金额", "付款", "收款", "退款",
|
|
|
+ "收票", "开票", "提交审核(合同)", "审核通过(合同)", "审核拒绝(合同)", "合同撤回", "提交审核(计划)",
|
|
|
"审核通过(计划)", "审核拒绝(计划)", "计划撤回", "正常完结(合同)", "异常终止(合同)", "退还保证金"}
|
|
|
if r.OPERATELOGTYPE >= 1 && r.OPERATELOGTYPE <= 23 {
|
|
|
r.OPTYPENAME = sDes[r.OPERATELOGTYPE-1]
|
|
|
@@ -173,6 +174,9 @@ func (r *ErmcpReportOPLog) buildSql() string {
|
|
|
sqlId = utils.SQLVal(fmt.Sprintf(sqlId.String(), r.USERID, r.USERID, r.USERID))
|
|
|
// 筛选条件
|
|
|
sqlId.And("t.TRADEDATE", r.TRADEDATE)
|
|
|
+ if r.WRSTANDARDID > 0 {
|
|
|
+ sqlId.And("t.WRSTANDARDID", r.WRSTANDARDID)
|
|
|
+ }
|
|
|
if r.LogTypeFilter != "" {
|
|
|
sqlId.Join(fmt.Sprintf(" and t.OPERATELOGTYPE in(%v)", r.LogTypeFilter))
|
|
|
}
|
|
|
@@ -348,3 +352,140 @@ func (r *ErmcpReportDayExposure) GetDataEx() (interface{}, error) {
|
|
|
}
|
|
|
return sData, err
|
|
|
}
|
|
|
+
|
|
|
+// 现货日报表
|
|
|
+type ErmcpReportDaySpot struct {
|
|
|
+ BUYPRICEDQTY float64 `json:"-" xorm:"'BUYPRICEDQTY'"` // 期末采购定价量
|
|
|
+ SELLPRICEDQTY float64 `json:"-" xorm:"'SELLPRICEDQTY'"` // 期末销售定价量
|
|
|
+ ORIBUYPRICEDQTY float64 `json:"-" xorm:"'ORIBUYPRICEDQTY'"` // 期初采购定价量
|
|
|
+ ORISELLPRICEDQTY float64 `json:"-" xorm:"'ORISELLPRICEDQTY'"` // 期初销售定价量
|
|
|
+ TODAYBUYRECKONQTY float64 `json:"todaybuyreckonqty" xorm:"'TODAYBUYRECKONQTY'"` // 采购确定量
|
|
|
+ TODAYSELLRECKONQTY float64 `json:"todaysellreckonqty" xorm:"'TODAYSELLRECKONQTY'"` // 销售确定量
|
|
|
+ RECKONDATE string `json:"reckondate" xorm:"'RECKONDATE'"` // 日照时期(yyyyMMdd)
|
|
|
+ WRSTANDARDID int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 现货商品ID
|
|
|
+ AREAUSERID int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构T
|
|
|
+ WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 现货商品名称
|
|
|
+ WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 现货商品代码
|
|
|
+ UNITID int32 `json:"-" xorm:"'UNITID'"` // 现货商品单位id
|
|
|
+
|
|
|
+ ENUMDICNAME string `json:"enumdicname"` // 现货商品单位名称
|
|
|
+ TOTALBUYPRICEDQTY float64 `json:"totalbuypricedqty"` // 采购定价量 = 期末 - 期初
|
|
|
+ TOTALSELLPRICEDQTY float64 `json:"totalsellpricedqty"` // 销售定价量 = 期末 - 期初
|
|
|
+ BeginDate string `json:"-"` // 开始日期
|
|
|
+ EndDate string `json:"-"` // 结束日期
|
|
|
+}
|
|
|
+
|
|
|
+// 数据处理
|
|
|
+func (r *ErmcpReportDaySpot) Calc() {
|
|
|
+ r.TOTALBUYPRICEDQTY = r.BUYPRICEDQTY - r.ORIBUYPRICEDQTY
|
|
|
+ r.TOTALSELLPRICEDQTY = r.SELLPRICEDQTY - r.ORISELLPRICEDQTY
|
|
|
+ r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
|
|
|
+}
|
|
|
+
|
|
|
+func (r *ErmcpReportDaySpot) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = "select t.BUYPRICEDQTY," +
|
|
|
+ " t.SELLPRICEDQTY," +
|
|
|
+ " t.Oribuypricedqty," +
|
|
|
+ " t.Orisellpricedqty," +
|
|
|
+ " t.TODAYBUYRECKONQTY," +
|
|
|
+ " t.TODAYSELLRECKONQTY," +
|
|
|
+ " t.RECKONDATE," +
|
|
|
+ " t.WRSTANDARDID," +
|
|
|
+ " t.AREAUSERID," +
|
|
|
+ " w.wrstandardname," +
|
|
|
+ " w.wrstandardcode," +
|
|
|
+ " w.unitid" +
|
|
|
+ " from RECKON_ERMCP_AREASPOT t" +
|
|
|
+ " left join wrstandard w" +
|
|
|
+ " on t.wrstandardid = w.wrstandardid" +
|
|
|
+ " where 1 = 1"
|
|
|
+ sqlId.And("t.AREAUSERID", r.AREAUSERID)
|
|
|
+ if r.WRSTANDARDID > 0 {
|
|
|
+ sqlId.And("t.WRSTANDARDID", r.WRSTANDARDID)
|
|
|
+ }
|
|
|
+ if r.RECKONDATE != "" {
|
|
|
+ sqlId.And("t.RECKONDATE", r.RECKONDATE)
|
|
|
+ } else if r.BeginDate != "" && r.BeginDate == r.EndDate {
|
|
|
+ sqlId.And("t.RECKONDATE", r.BeginDate)
|
|
|
+ } else {
|
|
|
+ if r.BeginDate != "" {
|
|
|
+ sqlId.BiggerOrEq("t.RECKONDATE", r.BeginDate)
|
|
|
+ }
|
|
|
+ if r.EndDate != "" {
|
|
|
+ sqlId.LessOrEq("t.RECKONDATE", r.EndDate)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sqlId.Join(" order by t.RECKONDATE")
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+// 获取现货日报表
|
|
|
+func (r *ErmcpReportDaySpot) GetDataEx() (interface{}, error) {
|
|
|
+ sData := make([]ErmcpReportDaySpot, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].Calc()
|
|
|
+ }
|
|
|
+ return sData, err
|
|
|
+}
|
|
|
+
|
|
|
+// 现货月报表
|
|
|
+type ErmcpReportMonSpot struct {
|
|
|
+ CYCLETYPE int32 `json:"cycletype" xorm:"'cycletype'"` // 周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】
|
|
|
+ CYCLETIME string `json:"cycletime" xorm:"'cycletime'"` // 周期时间 月(YYYYMM) 季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】
|
|
|
+ BUYPRICEDQTY float64 `json:"-" xorm:"'BUYPRICEDQTY'"` // 期末采购定价量
|
|
|
+ SELLPRICEDQTY float64 `json:"-" xorm:"'SELLPRICEDQTY'"` // 期末销售定价量
|
|
|
+ ORIBUYPRICEDQTY float64 `json:"-" xorm:"'ORIBUYPRICEDQTY'"` // 期初采购定价量
|
|
|
+ ORISELLPRICEDQTY float64 `json:"-" xorm:"'ORISELLPRICEDQTY'"` // 期初销售定价量
|
|
|
+ TODAYBUYRECKONQTY float64 `json:"todaybuyreckonqty" xorm:"'TODAYBUYRECKONQTY'"` // 采购确定量
|
|
|
+ TODAYSELLRECKONQTY float64 `json:"todaysellreckonqty" xorm:"'TODAYSELLRECKONQTY'"` // 销售确定量
|
|
|
+ WRSTANDARDID int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 现货商品ID
|
|
|
+ AREAUSERID int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构T
|
|
|
+ WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 现货商品名称
|
|
|
+ WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 现货商品代码
|
|
|
+ UNITID int32 `json:"-" xorm:"'UNITID'"` // 现货商品单位id
|
|
|
+
|
|
|
+ ENUMDICNAME string `json:"enumdicname"` // 现货商品单位名称
|
|
|
+ TOTALBUYPRICEDQTY float64 `json:"totalbuypricedqty"` // 采购定价量 = 期末 - 期初
|
|
|
+ TOTALSELLPRICEDQTY float64 `json:"totalsellpricedqty"` // 销售定价量 = 期末 - 期初
|
|
|
+}
|
|
|
+
|
|
|
+// 数据处理
|
|
|
+func (r *ErmcpReportMonSpot) Calc() {
|
|
|
+ r.TOTALBUYPRICEDQTY = r.BUYPRICEDQTY - r.ORIBUYPRICEDQTY
|
|
|
+ r.TOTALSELLPRICEDQTY = r.SELLPRICEDQTY - r.ORISELLPRICEDQTY
|
|
|
+ r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
|
|
|
+}
|
|
|
+
|
|
|
+func (r *ErmcpReportMonSpot) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = "select t.BUYPRICEDQTY," +
|
|
|
+ " t.SELLPRICEDQTY," +
|
|
|
+ " t.Oribuypricedqty," +
|
|
|
+ " t.Orisellpricedqty," +
|
|
|
+ " t.TODAYBUYRECKONQTY," +
|
|
|
+ " t.TODAYSELLRECKONQTY," +
|
|
|
+ " t.cycletype," +
|
|
|
+ " t.cycletime," +
|
|
|
+ " t.WRSTANDARDID," +
|
|
|
+ " t.AREAUSERID," +
|
|
|
+ " w.wrstandardname," +
|
|
|
+ " w.wrstandardcode," +
|
|
|
+ " w.unitid" +
|
|
|
+ " from Report_ERMCP_AreaSpot t" +
|
|
|
+ " left join wrstandard w" +
|
|
|
+ " on t.wrstandardid = w.wrstandardid" +
|
|
|
+ " where t.cycletype = 1"
|
|
|
+ sqlId.And("t.AREAUSERID", r.AREAUSERID)
|
|
|
+ sqlId.And("t.cycletime", r.CYCLETIME)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+// 获取现货月报表
|
|
|
+func (r *ErmcpReportMonSpot) GetDataEx() (interface{}, error) {
|
|
|
+ sData := make([]ErmcpReportMonSpot, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].Calc()
|
|
|
+ }
|
|
|
+ return sData, err
|
|
|
+}
|