|
|
@@ -205,15 +205,34 @@ func (r *ErmcpAreaStockApplySum) buildSql() string {
|
|
|
" from (SELECT t.INOUTTYPE," +
|
|
|
" t.SPOTGOODSMODELID," +
|
|
|
" t.SPOTGOODSBRANDID," +
|
|
|
+ " t.SPOTCONTRACTID," +
|
|
|
" sum(t.QTY) TOTALQTY" +
|
|
|
" FROM ERMCP_AREAINOUTSTOCKAPPLY t" +
|
|
|
- " WHERE t.applystatus= 2 and t.inouttype = %v and t.spotcontractid = %v" +
|
|
|
- " group by t.inouttype, t.spotgoodsbrandid, t.spotgoodsmodelid) a" +
|
|
|
+ " WHERE t.applystatus= 2 and t.spotcontractid = %v" +
|
|
|
+ " group by t.inouttype, t.spotgoodsbrandid, t.spotgoodsmodelid, t.spotcontractid) a" +
|
|
|
" left join spotgoodsbrand gb" +
|
|
|
" on a.spotgoodsbrandid = gb.brandid" +
|
|
|
" left join spotgoodsmodel gm" +
|
|
|
" on a.spotgoodsmodelid = gm.modelid"
|
|
|
- sqlId = fmt.Sprintf(sqlId, r.INOUTTYPE, r.SPOTCONTRACTID)
|
|
|
+ sqlId = fmt.Sprintf(sqlId, r.SPOTCONTRACTID)
|
|
|
+
|
|
|
+ // 不关联合同id
|
|
|
+ sqlId2 := "select a.*, gb.brandname, gm.modelname" +
|
|
|
+ " from (SELECT t.INOUTTYPE," +
|
|
|
+ " t.SPOTGOODSMODELID," +
|
|
|
+ " t.SPOTGOODSBRANDID," +
|
|
|
+ " t.SPOTCONTRACTID," +
|
|
|
+ " sum(t.QTY) TOTALQTY" +
|
|
|
+ " FROM ERMCP_AREAINOUTSTOCKAPPLY t" +
|
|
|
+ " WHERE t.applystatus= 2" +
|
|
|
+ " group by t.inouttype, t.spotgoodsbrandid, t.spotgoodsmodelid, t.SPOTCONTRACTID) a" +
|
|
|
+ " left join spotgoodsbrand gb" +
|
|
|
+ " on a.spotgoodsbrandid = gb.brandid" +
|
|
|
+ " left join spotgoodsmodel gm" +
|
|
|
+ " on a.spotgoodsmodelid = gm.modelid"
|
|
|
+ if len(r.SPOTCONTRACTID) == 0 {
|
|
|
+ return sqlId2
|
|
|
+ }
|
|
|
return sqlId
|
|
|
}
|
|
|
|