|
|
@@ -69,9 +69,12 @@ public class UASCustDataService implements CustDataService {
|
|
|
// A,B,C格式的数据改为'A','B','C'格式
|
|
|
final String brandsWithFix = StringUtils.collectionToDelimitedString(Arrays.asList(brands.split(",")), ",", "'", "'");
|
|
|
int nowMonth = DateUtils.getYearmonth(new Date());
|
|
|
+ // 修改为按物料分组,防止物料本身的原厂型号或规格定义重复
|
|
|
return commonDao
|
|
|
- .query("select pr_brand as brand,nvl(pr_orispeccode,pr_spec) as org_item,pr_detail as item_desc,pr_spec as item_spec,pr_unit as item_unit,po_onhand as stock,(select pm_beginqty from v$productmonth where pr_code=pm_prodcode and pm_yearmonth=?) as beginStock from productonhand left join product on po_prodcode=pr_code where po_onhand > 0 and pr_brand in ("
|
|
|
- + brandsWithFix + ")", Stock.class, nowMonth);
|
|
|
+ .query("select brand,org_item,item_desc,item_spec,item_unit,sum(stock) as stock,sum(beginStock) as beginStock from (select pr_brand as brand,nvl(pr_orispeccode,pr_spec) as org_item,pr_detail as item_desc,pr_spec as item_spec,pr_unit as item_unit,po_onhand as stock,(select pm_beginqty from v$productmonth where pr_code=pm_prodcode and pm_yearmonth=?) as beginStock from productonhand left join product on po_prodcode=pr_code where po_onhand > 0 and pr_brand in ("
|
|
|
+ + brandsWithFix
|
|
|
+ + ")) group by brand,org_item,item_desc,item_spec,item_unit order by brand,org_item,item_desc,item_spec,item_unit",
|
|
|
+ Stock.class, nowMonth);
|
|
|
} finally {
|
|
|
SpObserver.putSp(currDs);
|
|
|
}
|
|
|
@@ -118,8 +121,9 @@ public class UASCustDataService implements CustDataService {
|
|
|
final String brandsWithFix = StringUtils.collectionToDelimitedString(Arrays.asList(brands.split(",")), ",", "'", "'");
|
|
|
// {@code startDate}所处期间
|
|
|
int month = DateUtils.getYearmonth(startDate);
|
|
|
+ // 修改为按物料分组求和,防止物料本身的原厂型号或规格定义重复
|
|
|
StringBuffer sql = new StringBuffer(
|
|
|
- "select case when nvl(pd_inqty,0)<>0 then null else cu_kind end as end_item_fld,pr_brand as brand,nvl(pr_orispeccode,pr_spec) as org_item,pr_detail as item_desc,pr_spec as item_spec,pr_unit as item_unit,to_char(pi_date,'yyyy-mm-dd') as \"DATE\",nvl(pd_inqty,0)+nvl(pd_outqty,0) as qty,case when nvl(pd_inqty,0)<>0 then 'in' else 'out' end as type,(select pm_beginqty from v$productmonth where pr_code=pm_prodcode and pm_yearmonth=?) as beginStock from prodinout left join prodiodetail on pi_id=pd_piid left join customer on pi_cardcode=cu_code left join product on pd_prodcode=pr_code where ");
|
|
|
+ "select case when nvl(pd_inqty,0)<>0 then null else cu_kind end as end_item_fld,pr_brand as brand,nvl(pr_orispeccode,pr_spec) as org_item,pr_detail as item_desc,pr_spec as item_spec,pr_unit as item_unit,to_char(pi_date,'yyyy-mm-dd') as \"DATE\",nvl(pd_inqty,0)+nvl(pd_outqty,0) as qty,case when nvl(pd_inqty,0)<>0 then 'in' else 'out' end as type,(select nvl(sum(pm_beginqty),0) from v$productmonth left join product p2 on p2.pr_code=pm_prodcode where p2.pr_spec=p1.pr_spec and p2.pr_detail=p1.pr_detail and p2.pr_brand=p1.pr_brand and nvl(p2.pr_orispeccode,' ')=nvl(p1.pr_orispeccode,' ') and nvl(p2.pr_unit,' ')=nvl(p1.pr_unit,' ') and pm_yearmonth=?) as beginStock from prodinout left join prodiodetail on pi_id=pd_piid left join customer on pi_cardcode=cu_code left join product p1 on pd_prodcode=p1.pr_code where ");
|
|
|
sql.append("pi_statuscode='POSTED' and pi_date >= to_date('").append(startDate).append("','yyyy-mm-dd')");
|
|
|
if (StringUtils.hasText(code))
|
|
|
sql.append(" and pr_orispeccode='").append(code).append("'");
|
|
|
@@ -127,10 +131,10 @@ public class UASCustDataService implements CustDataService {
|
|
|
sql.append(" order by pr_brand,pr_spec,pi_date,pd_pdno");
|
|
|
// 无io部分
|
|
|
StringBuffer noioSql = new StringBuffer(
|
|
|
- "select pr_brand as brand,nvl(pr_orispeccode,pr_spec) as code,pr_detail as title,pr_spec as spec,pr_unit as unit,pm_beginqty as beginStock from v$productmonth left join product on pm_prodcode=pr_code where pm_yearmonth=? and pm_beginqty > 0");
|
|
|
+ "select brand,code,title,spec,unit,sum(beginStock) as beginStock from (select pr_brand as brand,nvl(pr_orispeccode,pr_spec) as code,pr_detail as title,pr_spec as spec,pr_unit as unit,pm_beginqty as beginStock from v$productmonth left join product on pm_prodcode=pr_code where pm_yearmonth=? and pm_beginqty > 0");
|
|
|
noioSql.append(" and pr_brand in (").append(brandsWithFix).append(")");
|
|
|
- noioSql.append(" and not exists (select 1 from prodinout left join prodiodetail on pi_id=pd_piid where to_char(pi_date,'yyyymm')=pm_yearmonth and pi_statuscode='POSTED' and pd_prodcode=pm_prodcode)");
|
|
|
- noioSql.append(" order by pr_brand,pr_spec");
|
|
|
+ noioSql.append(" and not exists (select 1 from prodinout left join prodiodetail on pi_id=pd_piid where to_char(pi_date,'yyyymm')=pm_yearmonth and pi_statuscode='POSTED' and pd_prodcode=pm_prodcode))");
|
|
|
+ noioSql.append(" group by brand,code,title,spec,unit order by brand,code,title,spec,unit");
|
|
|
|
|
|
return TEMP_IO.reduce(commonDao.query(sql.toString(), TEMP_IO.class, month),
|
|
|
commonDao.query(noioSql.toString(), TEMP_DATA.class, month));
|