|
|
@@ -12,14 +12,20 @@ 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_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.service.CustDataService;
|
|
|
|
|
|
/**
|
|
|
* 使用UAS系统的客户的数据
|
|
|
*
|
|
|
* @author yingp
|
|
|
- *
|
|
|
+ *
|
|
|
*/
|
|
|
@Service
|
|
|
public class UASCustDataService implements CustDataService {
|
|
|
@@ -58,9 +64,10 @@ public class UASCustDataService implements CustDataService {
|
|
|
// 切换到客户账套
|
|
|
SpObserver.putSp(ds.getId());
|
|
|
// A,B,C格式的数据改为'A','B','C'格式
|
|
|
- final String brandsWithFix = StringUtils.collectionToDelimitedString(Arrays.asList(brands.split(",")), ",", "'", "'");
|
|
|
+ final String brandsWithFix = StringUtils.collectionToDelimitedString(Arrays.asList(brands.split(",")),
|
|
|
+ ",", "'", "'");
|
|
|
return commonDao
|
|
|
- .query("select pr_brand as brand,pr_orispeccode as code,pr_detail as title,pr_spec as spec,po_onhand as stock,pr_unit unit from productonhand left join product on po_prodcode=pr_code where po_onhand > 0 and pr_brand in ("
|
|
|
+ .query("select pr_brand as brand,pr_orispeccode as code,pr_detail as title,pr_spec as spec,po_onhand as stock,pr_unit as unit from productonhand left join product on po_prodcode=pr_code where po_onhand > 0 and pr_brand in ("
|
|
|
+ brandsWithFix + ")", Stock.class);
|
|
|
} finally {
|
|
|
SpObserver.putSp(currDs);
|
|
|
@@ -69,4 +76,88 @@ public class UASCustDataService implements CustDataService {
|
|
|
return new ArrayList<Stock>();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Sale> findSales(long custId, String brands, String code, String startDate) {
|
|
|
+ DS ds = getDSFromManage(custId);
|
|
|
+ // 先校验是否可以连接
|
|
|
+ if (ds != null && DSUtils.isConnectable(commonDao.getJdbcTemplate(), ds)) {
|
|
|
+ String currDs = SpObserver.getSp();
|
|
|
+ try {
|
|
|
+ // 切换到客户账套
|
|
|
+ SpObserver.putSp(ds.getId());
|
|
|
+ // A,B,C格式的数据改为'A','B','C'格式
|
|
|
+ final String brandsWithFix = StringUtils.collectionToDelimitedString(Arrays.asList(brands.split(",")),
|
|
|
+ ",", "'", "'");
|
|
|
+ StringBuffer sql = new StringBuffer(
|
|
|
+ "select pr_brand as brand,pr_orispeccode as code,pr_detail as title,pr_spec as spec,pr_unit as unit,sa_date as date,sa_custname as trader,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("'");
|
|
|
+ sql.append(" and pr_brand in (").append(brandsWithFix).append(")");
|
|
|
+ sql.append(" order by pr_brand,pr_orispeccode,sa_date,sd_detno");
|
|
|
+ return TEMP_SALE.reduce(commonDao.query(sql.toString(), TEMP_SALE.class));
|
|
|
+ } finally {
|
|
|
+ SpObserver.putSp(currDs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ArrayList<Sale>();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IO> findIOs(long custId, String brands, String code, String startDate) {
|
|
|
+ DS ds = getDSFromManage(custId);
|
|
|
+ // 先校验是否可以连接
|
|
|
+ if (ds != null && DSUtils.isConnectable(commonDao.getJdbcTemplate(), ds)) {
|
|
|
+ String currDs = SpObserver.getSp();
|
|
|
+ try {
|
|
|
+ // 切换到客户账套
|
|
|
+ SpObserver.putSp(ds.getId());
|
|
|
+ // A,B,C格式的数据改为'A','B','C'格式
|
|
|
+ final String brandsWithFix = StringUtils.collectionToDelimitedString(Arrays.asList(brands.split(",")),
|
|
|
+ ",", "'", "'");
|
|
|
+ StringBuffer sql = new StringBuffer(
|
|
|
+ "select pr_brand as brand,pr_orispeccode as code,pr_detail as title,pr_spec as spec,pr_unit as unit,pi_date as date,pi_title as trader,nvl(pd_inqty,0)+nvl(pd_outqty,0) as qty,case when nvl(pd_inqty,0)<>0 then 'in' else 'out' end as type from prodinout left join prodiodetail on pi_id=pd_piid left join product on pd_prodcode=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("'");
|
|
|
+ sql.append(" and pr_brand in (").append(brandsWithFix).append(")");
|
|
|
+ sql.append(" order by pr_brand,pr_orispeccode,pi_date,pd_pdno");
|
|
|
+ return TEMP_IO.reduce(commonDao.query(sql.toString(), TEMP_IO.class));
|
|
|
+ } finally {
|
|
|
+ SpObserver.putSp(currDs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ArrayList<IO>();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Forecast> findForecasts(long custId, String brands, String code, String startDate) {
|
|
|
+ DS ds = getDSFromManage(custId);
|
|
|
+ // 先校验是否可以连接
|
|
|
+ if (ds != null && DSUtils.isConnectable(commonDao.getJdbcTemplate(), ds)) {
|
|
|
+ String currDs = SpObserver.getSp();
|
|
|
+ try {
|
|
|
+ // 切换到客户账套
|
|
|
+ SpObserver.putSp(ds.getId());
|
|
|
+ // A,B,C格式的数据改为'A','B','C'格式
|
|
|
+ final String brandsWithFix = StringUtils.collectionToDelimitedString(Arrays.asList(brands.split(",")),
|
|
|
+ ",", "'", "'");
|
|
|
+ StringBuffer sql = new StringBuffer(
|
|
|
+ "select pr_brand as brand,pr_orispeccode as code,pr_detail as title,pr_spec as spec,pr_unit as unit,sf_date as date,cu_name as trader,sf_qty as qty,sd_needdate as needDate,sd_enddate 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("'");
|
|
|
+ sql.append(" and pr_brand in (").append(brandsWithFix).append(")");
|
|
|
+ sql.append(" order by pr_brand,pr_orispeccode,sf_date,sd_detno");
|
|
|
+ return TEMP_FORECAST.reduce(commonDao.query(sql.toString(), TEMP_FORECAST.class));
|
|
|
+ } finally {
|
|
|
+ SpObserver.putSp(currDs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ArrayList<Forecast>();
|
|
|
+ }
|
|
|
+
|
|
|
}
|