?? gbs_pricehardwarepricelistactionlogic.java
字號:
package LOGIC;
import java.util.ArrayList;
import javax.sql.DataSource;
import ACTION.GBS_PriceHardwarePriceListForm;
import COMMON.MessageList;
import COMMON.ReturnValue;
import COMMON.SystemConstants;
import DB.GBS_MCountry_DB;
import DB.GBS_TProductPrice_DB;
import DataBean.GBS_HardwarePrice_stBean;
import DataBean.GBS_Kind_stBean;
import DataBean.GBS_LittleCountry_stBean;
import DataBean.GBS_LittleHardwarePrice_stBean;
import DataBean.GBS_ProductHardwarePriceList_stBean;
/**
* public class GBS_PriceHardwarePriceListActionLogic implements SystemConstants
* created on 07-30-2004
* @author wxf
* @version 1.0
*/
public class GBS_PriceHardwarePriceListActionLogic implements SystemConstants {
private DataSource datasource = null;
private ArrayList littleCountry_stList;
/**
* trans datasource to db
* @param datasource
*/
public GBS_PriceHardwarePriceListActionLogic(DataSource datasource) {
this.datasource = datasource;
}
/**
* getAllHardwarePriceInfo
* @param String productCategoryCode
* @param String countryCode
* @return all CPCPrice inforamtion
* @throws Exception
*/
public ReturnValue getAllHardwarePriceInfo( String productCategoryCode,
String countryCode,
int plusHour) throws Exception {
ReturnValue returnValue = new ReturnValue();
MessageList messageList = new MessageList();
returnValue.setMessageList( messageList );
GBS_PriceHardwarePriceListForm priceHardwarePriceListForm =new GBS_PriceHardwarePriceListForm();
GBS_MCountry_DB countryDB = new GBS_MCountry_DB(datasource);
GBS_TProductPrice_DB tProductPriceDB= new GBS_TProductPrice_DB(datasource);
ReturnValue ret = countryDB.seletCountryName(countryCode);
this.littleCountry_stList=(ArrayList)ret.getDataValue();
//get all hardware price inforamtion
ret=tProductPriceDB.selectHardwarePricelist(productCategoryCode,countryCode,plusHour);
if ( ret.isError() ){
if ( ret.isBussinessError() ){
returnValue.setMessageList( ret.getMessageList() );
}
//getErrorCode ,getErrorMessage傪張棟
returnValue.setErrorCode( ret.getErrorCode() );
returnValue.setErrorMessage( ret.getErrorMessage() );
}
ArrayList hardwarePrice_stlist =(ArrayList)ret.getDataValue();
ArrayList dataList=new ArrayList();
GBS_Kind_stBean kind_st = new GBS_Kind_stBean();
ArrayList productIdList = new ArrayList();
GBS_ProductHardwarePriceList_stBean productId_st=new GBS_ProductHardwarePriceList_stBean();
ArrayList priceList=new ArrayList();
GBS_LittleHardwarePrice_stBean price_st =new GBS_LittleHardwarePrice_stBean();
productId_st.setDataList(this.littleCountry_stList);
productIdList.add(productId_st);
kind_st.setDataList(productIdList);
dataList.add(kind_st);
//hardware price data from list cheng into tree.
for(int i=0;i<hardwarePrice_stlist.size();i++){
GBS_HardwarePrice_stBean hardwarePrice_st = (GBS_HardwarePrice_stBean)hardwarePrice_stlist.get(i);
if(kind_st.getKindCode().equals(hardwarePrice_st.getKind())){
productId_st=(GBS_ProductHardwarePriceList_stBean)kind_st.getDataList().get(kind_st.getDataList().size()-1);
if(productId_st.getProductID().equals(hardwarePrice_st.getProductID())){
priceList = productId_st.getDataList();
for(int j = 0; j < littleCountry_stList.size() ;j++ ){
GBS_LittleCountry_stBean littleCountry_st = (GBS_LittleCountry_stBean)littleCountry_stList.get(j);
if(littleCountry_st.getCountryCode().equals(hardwarePrice_st.getCountryCode())){
priceList.set(j,newPrice_st(hardwarePrice_st));
}
}
}else{
productIdList=kind_st.getDataList();
productIdList.add(newProductId_st(hardwarePrice_st));
kind_st.setDataList(productIdList);
}
}else{
kind_st =newKind_st(hardwarePrice_st);
dataList.add(kind_st);
}
}
productId_st=new GBS_ProductHardwarePriceList_stBean();
productId_st.setProductName(" ");
productId_st.setDataList(this.littleCountry_stList);
productIdList = new ArrayList();
productIdList.add(productId_st);
kind_st = new GBS_Kind_stBean();
kind_st.setKindName(" ");
kind_st.setDataList(productIdList);
dataList.set(0,kind_st);
priceHardwarePriceListForm.setDataList(dataList);
priceHardwarePriceListForm.setLittleCountrylist(this.littleCountry_stList);
returnValue.setDataValue( priceHardwarePriceListForm );
return returnValue;
}
/**
* newPrice_st
* @param GBS_HardwarePrice_stBean hardwarePrice_st
* @return GBS_LittleHardwarePrice_stBean
* @throws Exception
*/
private GBS_LittleHardwarePrice_stBean newPrice_st(GBS_HardwarePrice_stBean hardwarePrice_st){
GBS_LittleHardwarePrice_stBean price_st =new GBS_LittleHardwarePrice_stBean();
for(int j = 0; j < littleCountry_stList.size() ;j++ ){
GBS_LittleCountry_stBean littleCountry_st = (GBS_LittleCountry_stBean)littleCountry_stList.get(j);
if(littleCountry_st.getCountryCode().equals(hardwarePrice_st.getCountryCode())){
if(littleCountry_st.getDateTime().compareTo(hardwarePrice_st.getDateTime()) < 0){
littleCountry_st.setDateTime(hardwarePrice_st.getDateTime());
littleCountry_st.setDate(hardwarePrice_st.getDate());
littleCountry_st.setRowSize(2);
littleCountry_stList.set(j,littleCountry_st);
}
}
}
price_st.setLocalCurrency(hardwarePrice_st.getLocalCurrency());
price_st.setLocalCurrencyeKey(hardwarePrice_st.getLocalCurrencyKey());
price_st.setLocalPrice(hardwarePrice_st.getLocalPrice());
price_st.setEUROPrice(hardwarePrice_st.getEUROPrice());
price_st.setUSPrice(hardwarePrice_st.getUSPrice());
price_st.setRowSize(3);
return price_st;
}
/**
* newProductId_st
* @param GBS_HardwarePrice_stBean hardwarePrice_st
* @return GBS_ProductHardwarePriceList_stBean
* @throws Exception
*/
private GBS_ProductHardwarePriceList_stBean newProductId_st(
GBS_HardwarePrice_stBean hardwarePrice_st){
GBS_ProductHardwarePriceList_stBean productId_st=new GBS_ProductHardwarePriceList_stBean();
productId_st.setProductID(hardwarePrice_st.getProductID());
productId_st.setProductName(hardwarePrice_st.getProductName());
ArrayList dataList=new ArrayList();
for(int i = 0; i < littleCountry_stList.size();i++){
GBS_LittleCountry_stBean littleCountry_st = (GBS_LittleCountry_stBean)littleCountry_stList.get(i);
GBS_LittleHardwarePrice_stBean price_st;
if(littleCountry_st.getCountryCode().equals(hardwarePrice_st.getCountryCode())){
price_st = newPrice_st(hardwarePrice_st);
}else{
price_st =new GBS_LittleHardwarePrice_stBean();
}
dataList.add(price_st);
}
productId_st.setDataList(dataList);
productId_st.setRowSize(3);
return productId_st;
}
/**
* newKind_st
* @param GBS_HardwarePrice_stBean hardwarePrice_st
* @return GBS_Kind_stBean
* @throws Exception
*/
private GBS_Kind_stBean newKind_st(
GBS_HardwarePrice_stBean hardwarePrice_st){
GBS_Kind_stBean kind_st = new GBS_Kind_stBean();
kind_st.setKindCode(hardwarePrice_st.getKind());
if(hardwarePrice_st.getKind().equals("P")){
kind_st.setKindName("Product");
}
if(hardwarePrice_st.getKind().equals("O")){
kind_st.setKindName("Option");
}
ArrayList dataList =new ArrayList();
dataList.add(newProductId_st(hardwarePrice_st));
kind_st.setDataList(dataList);
return kind_st;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -