ソースを参照

错误 #94493 现货报表有重复记录

zou.yingbin 4 年 前
コミット
a9e7892489
1 ファイル変更25 行追加4 行削除
  1. 25 4
      models/ermcpReport.go

+ 25 - 4
models/ermcpReport.go

@@ -422,7 +422,15 @@ func (r *ErmcpReportDaySpot) Calc() {
 }
 
 func (r *ErmcpReportDaySpot) buildSql() string {
-	var sqlId utils.SQLVal = "select t.reckondate," +
+	var sqlId utils.SQLVal = "with tmp as" +
+		" (select t.userid," +
+		"         t.wrstandardid," +
+		"         t.reckondate," +
+		"         sum(t.todaybuyinqty) todaybuyinqty," +
+		"         sum(t.todayselloutqty) todayselloutqty" +
+		"    from Reckon_ERMCP_AreaStock t" +
+		"   group by t.userid, t.wrstandardid,t.reckondate)" +
+		"select t.reckondate," +
 		"       t.BUYPRICEDQTY," +
 		"       t.SELLPRICEDQTY," +
 		"       t.Oribuypricedqty," +
@@ -438,8 +446,10 @@ func (r *ErmcpReportDaySpot) buildSql() string {
 		"       s.todaybuyinqty      buyinqty," +
 		"       s.todayselloutqty    selloutqty" +
 		"  from RECKON_ERMCP_AREASPOT t" +
-		"  left join Reckon_ERMCP_AreaStock s" +
+		"  left join tmp s" +
 		"    on t.reckondate = s.reckondate" +
+		"   and t.areauserid = s.userid" +
+		"   and t.wrstandardid = s.wrstandardid" +
 		"  left join wrstandard w" +
 		"    on t.wrstandardid = w.wrstandardid" +
 		" where 1 = 1"
@@ -504,7 +514,16 @@ func (r *ErmcpReportMonSpot) Calc() {
 }
 
 func (r *ErmcpReportMonSpot) buildSql() string {
-	var sqlId utils.SQLVal = "select t.BUYPRICEDQTY," +
+	var sqlId utils.SQLVal = "with tmp as" +
+		" (select t.userid," +
+		"         t.wrstandardid," +
+		"         t.cycletime," +
+		"         t.cycletype," +
+		"         sum(t.todaybuyinqty) todaybuyinqty," +
+		"         sum(t.todayselloutqty) todayselloutqty" +
+		"    from Report_ERMCP_AreaStock t" +
+		"   group by t.userid, t.wrstandardid, t.cycletime, t.cycletype)" +
+		"select t.BUYPRICEDQTY," +
 		"       t.SELLPRICEDQTY," +
 		"       t.Oribuypricedqty," +
 		"       t.Orisellpricedqty," +
@@ -520,9 +539,11 @@ func (r *ErmcpReportMonSpot) buildSql() string {
 		"       s.todaybuyinqty      buyinqty," +
 		"       s.todayselloutqty    selloutqty" +
 		"  from Report_ERMCP_AreaSpot t" +
-		"  left join Report_ERMCP_AreaStock s" +
+		"  left join tmp s" +
 		"    on t.cycletime = s.cycletime" +
 		"   and t.cycletype = s.cycletype" +
+		"   and t.areauserid = s.userid" +
+		"   and t.wrstandardid = s.wrstandardid" +
 		"  left join wrstandard w" +
 		"    on t.wrstandardid = w.wrstandardid" +
 		" where t.cycletype = 1"