فهرست منبع

客户访问数据接口获取数据方法更新

hejq 7 سال پیش
والد
کامیت
c1dd77eb22
1فایلهای تغییر یافته به همراه14 افزوده شده و 22 حذف شده
  1. 14 22
      src/main/java/com/uas/platform/b2b/openapi/service/impl/UASCustDataService.java

+ 14 - 22
src/main/java/com/uas/platform/b2b/openapi/service/impl/UASCustDataService.java

@@ -1,28 +1,20 @@
 package com.uas.platform.b2b.openapi.service.impl;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
-
 import com.uas.platform.b2b.core.util.DateUtils;
 import com.uas.platform.b2b.dao.CommonDao;
 import com.uas.platform.b2b.data.support.DS;
 import com.uas.platform.b2b.data.support.DSUtils;
 import com.uas.platform.b2b.data.support.SpObserver;
-import com.uas.platform.b2b.openapi.model.Forecast;
-import com.uas.platform.b2b.openapi.model.IO;
-import com.uas.platform.b2b.openapi.model.Sale;
-import com.uas.platform.b2b.openapi.model.Stock;
-import com.uas.platform.b2b.openapi.model.TEMP_DATA;
-import com.uas.platform.b2b.openapi.model.TEMP_FORECAST;
-import com.uas.platform.b2b.openapi.model.TEMP_IO;
-import com.uas.platform.b2b.openapi.model.TEMP_SALE;
+import com.uas.platform.b2b.openapi.model.*;
 import com.uas.platform.b2b.openapi.service.CustDataService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
 
 /**
  * 使用UAS系统的客户的数据
@@ -71,7 +63,7 @@ public class UASCustDataService implements CustDataService {
 				int nowMonth = DateUtils.getYearmonth(new Date());
 				// 修改为按物料分组,防止物料本身的原厂型号或规格定义重复
 				return commonDao
-						.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,ifnull(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 ("
+						.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,coalesce(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);
@@ -94,7 +86,7 @@ public class UASCustDataService implements CustDataService {
 				// A,B,C格式的数据改为'A','B','C'格式
 				final String brandsWithFix = StringUtils.collectionToDelimitedString(Arrays.asList(brands.split(",")), ",", "'", "'");
 				StringBuffer sql = new StringBuffer(
-						"select pr_brand as brand,ifnull(pr_orispeccode,pr_spec) as org_item,pr_detail as item_desc,pr_spec as item_spec,pr_unit as item_unit,to_char(sa_date,'yyyy-mm-dd') as \"DATE\",sd_qty as qty from sale left join saledetail on sa_id=sd_said left join product on sd_prodcode=pr_code where ");
+						"select pr_brand as brand,coalesce(pr_orispeccode,pr_spec) as org_item,pr_detail as item_desc,pr_spec as item_spec,pr_unit as item_unit,to_char(sa_date,'yyyy-mm-dd') as \"DATE\",sd_qty as qty from sale left join saledetail on sa_id=sd_said left join product on sd_prodcode=pr_code where ");
 				sql.append("sa_statuscode='AUDITED' and sa_date >= to_date('").append(startDate).append("','yyyy-mm-dd')");
 				if (StringUtils.hasText(code)) {
                     sql.append(" and pr_orispeccode='").append(code).append("'");
@@ -124,7 +116,7 @@ public class UASCustDataService implements CustDataService {
 				int month = DateUtils.getYearmonth(startDate);
 				// 修改为按物料分组求和,防止物料本身的原厂型号或规格定义重复
 				StringBuffer sql = new StringBuffer(
-						"select case when ifnull(pd_inqty,0)<>0 then null else cu_kind end as end_item_fld,pr_brand as brand,ifnull(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\",ifnull(pd_inqty,0)+ifnull(pd_outqty,0) as qty,case when ifnull(pd_inqty,0)<>0 then 'in' else 'out' end as type,pd_ordercode as po,to_char((case when pi_class in ('出货单','销售退货单') then (select sa_date from sale where sa_code=pd_ordercode) when pi_class in ('采购验收单','采购验退单') then (select pu_date from purchase where pu_code=pd_ordercode) end),'yyyy-mm-dd') as po_date,(select ifnull(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 ifnull(p2.pr_orispeccode,' ')=ifnull(p1.pr_orispeccode,' ') and ifnull(p2.pr_unit,' ')=ifnull(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 ");
+						"select case when coalesce(pd_inqty,0)<>0 then null else cu_kind end as end_item_fld,pr_brand as brand,coalesce(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\",coalesce(pd_inqty,0)+coalesce(pd_outqty,0) as qty,case when coalesce(pd_inqty,0)<>0 then 'in' else 'out' end as type,pd_ordercode as po,to_char((case when pi_class in ('出货单','销售退货单') then (select sa_date from sale where sa_code=pd_ordercode) when pi_class in ('采购验收单','采购验退单') then (select pu_date from purchase where pu_code=pd_ordercode) end),'yyyy-mm-dd') as po_date,(select coalesce(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 coalesce(p2.pr_orispeccode,' ')=coalesce(p1.pr_orispeccode,' ') and coalesce(p2.pr_unit,' ')=coalesce(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("'");
@@ -133,7 +125,7 @@ public class UASCustDataService implements CustDataService {
 				sql.append(" order by pr_brand,pr_spec,pi_date,pd_pdno");
 				// 无io部分
 				StringBuffer noioSql = new StringBuffer(
-						"select brand,code,title,spec,unit,sum(beginStock) as beginStock from (select pr_brand as brand,ifnull(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,coalesce(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(" group by brand,code,title,spec,unit order by brand,code,title,spec,unit");
@@ -159,7 +151,7 @@ public class UASCustDataService implements CustDataService {
 				// A,B,C格式的数据改为'A','B','C'格式
 				final String brandsWithFix = StringUtils.collectionToDelimitedString(Arrays.asList(brands.split(",")), ",", "'", "'");
 				StringBuffer sql = new StringBuffer(
-						"select pr_brand as brand,ifnull(pr_orispeccode,pr_spec) as org_item,pr_detail as item_desc,pr_spec as item_spec,pr_unit as item_unit,to_char(sf_date,'yyyy-mm-dd') as \"DATE\",sd_qty as qty,to_char(sd_needdate,'yyyy-mm-dd') as needDate,to_char(sd_enddate,'yyyy-mm-dd') as endDate from saleforecast left join saleforecastdetail on sf_id=sd_sfid left join customer on sd_custcode=cu_code left join product on sd_prodcode=pr_code where ");
+						"select pr_brand as brand,coalesce(pr_orispeccode,pr_spec) as org_item,pr_detail as item_desc,pr_spec as item_spec,pr_unit as item_unit,to_char(sf_date,'yyyy-mm-dd') as \"DATE\",sd_qty as qty,to_char(sd_needdate,'yyyy-mm-dd') as needDate,to_char(sd_enddate,'yyyy-mm-dd') as endDate from saleforecast left join saleforecastdetail on sf_id=sd_sfid left join customer on sd_custcode=cu_code left join product on sd_prodcode=pr_code where ");
 				sql.append("sf_statuscode='AUDITED' and sf_date >= to_date('").append(startDate).append("','yyyy-mm-dd')");
 				if (StringUtils.hasText(code)) {
                     sql.append(" and pr_orispeccode='").append(code).append("'");