📄 gbs_priceedithardwarepriceaction.java
字号:
}
//USPrice's check on number yes or no and lower then max digital.
if(!BaseCommonCheck.isEmpty(strUSPrice)){
if( !BaseCommonCheck.isFloat(strUSPrice) ){
messages.setMessage("USPrice",strUSPrice,"90000010",i+1);
}else if(new Double(strUSPrice).doubleValue() > MAXPRICEORRATE){
messages.setMessage("USPrice",strUSPrice,"90000037",i+1);
}else if(new Double(strUSPrice).doubleValue() < 0){
messages.setMessage("USPrice",strUSPrice,"90000015",i+1);
}
}
//EUROPrice's check on number yes or no and lower then max digital.
if(!BaseCommonCheck.isEmpty(strEUROPrice)){
if(!BaseCommonCheck.isEmpty(strEUROPrice) && !BaseCommonCheck.isFloat(strEUROPrice) ){
messages.setMessage("EUROPrice",strEUROPrice,"90000010",i+1);
}else if(new Double(strEUROPrice).doubleValue() > MAXPRICEORRATE){
messages.setMessage("EUROPrice",strEUROPrice,"90000037",i+1);
}else if(new Double(strEUROPrice).doubleValue() < 0){
messages.setMessage("EUROPrice",strEUROPrice,"90000015",i+1);
}
}
}
return messages;
}
/**
* newProductIdList_st
* @param GBS_HardwarePrice_stBean hardwarePrice_st
* @return GBS_ProductHardwarePriceList_stBean
*/
private GBS_ProductPrice_stBean newProductId_st(GBS_HardwarePrice_stBean hardwarePrice_st){
GBS_ProductPrice_stBean productIdList_st = new GBS_ProductPrice_stBean();
productIdList_st.setProductID(hardwarePrice_st.getProductID());
productIdList_st.setProductName(hardwarePrice_st.getProductName());
productIdList_st.setEUROPrice(hardwarePrice_st.getEUROPrice());
productIdList_st.setLocalPrice(hardwarePrice_st.getLocalPrice());
productIdList_st.setUSPrice(hardwarePrice_st.getUSPrice());
productIdList_st.setLocalCurrency(hardwarePrice_st.getLocalCurrency());
productIdList_st.setDataTime(hardwarePrice_st.getDateTime());
return productIdList_st;
}
/**
* newProductCategoryList_st
* @param GBS_HardwarePrice_stBean hardwarePrice_st
* @return GBS_ProductCategory_stBean
*/
private GBS_ProductCategory_stBean newProductCategory_st(GBS_HardwarePrice_stBean hardwarePrice_st){
GBS_ProductCategory_stBean productCategoryList_st =new GBS_ProductCategory_stBean();
return setProductCategory_st(hardwarePrice_st,productCategoryList_st);
}
/**
* setProductCategoryList_st
* @param GBS_HardwarePrice_stBean hardwarePrice_st
* @return GBS_ProductCategory_stBean
*/
private GBS_ProductCategory_stBean setProductCategory_st(GBS_HardwarePrice_stBean hardwarePrice_st,GBS_ProductCategory_stBean productCategoryList_st){
ArrayList dataList=productCategoryList_st.getDataList();
productCategoryList_st.setProductCategory(hardwarePrice_st.getProductCategory()==null || hardwarePrice_st.getProductCategory().equals("") ?" ":hardwarePrice_st.getProductCategory());
dataList.add(newProductId_st(hardwarePrice_st));
productCategoryList_st.setDataList(dataList);
return productCategoryList_st;
}
/**
* newKind_st
* @param GBS_HardwarePrice_stBean hardwarePrice_st
* @return GBS_Kind_stBean
*/
private GBS_Kind_stBean newKind_st(GBS_HardwarePrice_stBean hardwarePrice_st){
GBS_Kind_stBean kindCode_st = new GBS_Kind_stBean();
return setKind_st(hardwarePrice_st,kindCode_st);
}
/**
* setKind_st
* @param GBS_HardwarePrice_stBean hardwarePrice_st
* @return GBS_Kind_stBean
*/
private GBS_Kind_stBean setKind_st(GBS_HardwarePrice_stBean hardwarePrice_st,GBS_Kind_stBean kindCode_st){
ArrayList dataList = kindCode_st.getDataList();
//get kindCode
kindCode_st.setKindCode(hardwarePrice_st.getKind());
//get kindName
if(hardwarePrice_st.getKind().equals("P")){
kindCode_st.setKindName("Product");
}
if(hardwarePrice_st.getKind().equals("O")){
kindCode_st.setKindName("Option");
}
GBS_ProductCategory_stBean productCategoryList_st;
if(dataList.size()>0){
productCategoryList_st = (GBS_ProductCategory_stBean)dataList.get(dataList.size()-1);
}else{
productCategoryList_st = new GBS_ProductCategory_stBean();
}
if(productCategoryList_st.getProductCategory().equals(hardwarePrice_st.getProductCategory())){
productCategoryList_st=setProductCategory_st(hardwarePrice_st,productCategoryList_st);
if(dataList.size()>0){
dataList.set(dataList.size()-1,productCategoryList_st);
} else {
dataList.add(productCategoryList_st);
}
}else{
productCategoryList_st = newProductCategory_st(hardwarePrice_st);
dataList.add(productCategoryList_st);
}
kindCode_st.setDataList(dataList);
return kindCode_st;
}
/**
* returnAllData
* @param GBS_PriceEditHardwarePriceForm thisForm
* @return GBS_PriceEditHardwarePriceForm
*/
private GBS_PriceEditHardwarePriceForm returnAllData(GBS_PriceEditHardwarePriceForm thisForm,HttpServletRequest request)throws Exception{
String[] localPrice = thisForm.getLocalPrice();//尰抧扨壙
String[] USPrice = thisForm.getUSPrice();//US$扨壙
String[] EUROPrice = thisForm.getEUROPrice();//Euro扨壙
String[] productID = thisForm.getProductID();//惢昳ID
String[] productName =thisForm.getProductName();//惢昳
String[] kindCode =thisForm.getKindCode();//庬椶
String[] category =thisForm.getProductCategory();//惢昳暘椶
GBS_HardwarePrice_stBean hardwarePrice_st ;
ArrayList hardwarePrice_stList =new ArrayList();
GBS_PriceEditHardwareORCPCActionLogic logic = new GBS_PriceEditHardwareORCPCActionLogic(this.getDataSource(request));
thisForm= getCombox(thisForm,logic);
for(int j = 1;j < productID.length;j++ ){
if(localPrice[j].equals("")
&&localPrice[j].equals("0")
&&USPrice[j].equals("")
&&USPrice[j].equals("0")
&&EUROPrice[j].equals("")
&&EUROPrice[j].equals("0")){
}else{
hardwarePrice_st = new GBS_HardwarePrice_stBean();
hardwarePrice_st.setKind(kindCode[j]);//庬椶
hardwarePrice_st.setProductCategory(category[j]);//惢昳暘椶
hardwarePrice_st.setProductID(productID[j]);//惢昳ID
hardwarePrice_st.setProductName(productName[j]);//惢昳
hardwarePrice_st.setCountryCode(thisForm.getCountryCode());//崙僐乕僪
hardwarePrice_st.setLocalCurrencye(thisForm.getLocalCurrency());//尰抧捠壿
hardwarePrice_st.setLocalPrice(localPrice[j]);//尰抧扨壙
hardwarePrice_st.setUSPrice(USPrice[j]);//US$扨壙
hardwarePrice_st.setEUROPrice(EUROPrice[j]);//Euro扨壙
hardwarePrice_st.setRateUS(thisForm.getRateUS());//愝掕帪偺儗乕僩乮懳US)
hardwarePrice_st.setRateEuro(thisForm.getRateEURO());//愝掕帪偺儗乕僩乮懳EURO)
hardwarePrice_stList.add(hardwarePrice_st);
}
}
return toTree(thisForm,hardwarePrice_stList);
}
/**
* getCombox
* @param GBS_PriceEditHardwarePriceForm thisForm,GBS_PriceEditHardwareORCPCActionLogic logic
* @return GBS_PriceEditHardwarePriceForm
*/
private GBS_PriceEditHardwarePriceForm getCombox (GBS_PriceEditHardwarePriceForm thisForm ,GBS_PriceEditHardwareORCPCActionLogic logic)throws Exception{
//Country 弶婜壔
ReturnValue ret =logic.getCountryInfo();
ArrayList countryCodeList = new ArrayList();
ArrayList countryNameList = new ArrayList();
if ( ret.isError() ){
if ( ret.isBussinessError() ){
this.setMessage( ret.getMessageList() );
}
//getErrorCode ,getErrorMessage傪張棟
}else{
ArrayList countryList=(ArrayList)ret.getDataValue();
for(int i = 0;i < countryList.size();i++){
GBS_LittleCountry_stBean littleCountry= (GBS_LittleCountry_stBean)countryList.get(i);
countryCodeList.add(littleCountry.getCountryCode());
countryNameList.add(littleCountry.getCountryName());
}
}
//Local currency 弶婜壔
ret = logic.getAllLocalCurrencyInfo();
ArrayList currencyKeyList =new ArrayList();
ArrayList currencyNameList =new ArrayList();
if ( ret.isError() ){
if ( ret.isBussinessError() ){
this.setMessage( ret.getMessageList() );
}
//getErrorCode ,getErrorMessage傪張棟
}else{
ArrayList localCurrencyList=(ArrayList)ret.getDataValue();
for(int i = 0 ;i<localCurrencyList.size();i++){
GBS_MWideUse_stBean mWideUse_st = ( GBS_MWideUse_stBean)localCurrencyList.get(i);
currencyKeyList.add(mWideUse_st.getMainKey());
currencyNameList.add(mWideUse_st.getString1());
}
}
thisForm.setCountryValueList(countryCodeList);
thisForm.setCountryLableList(countryNameList);
thisForm.setLocalCurrencyKeyList(currencyKeyList);
thisForm.setLocalCurrencyNameList(currencyNameList);
return thisForm;
}
/**
* toTree
* @param GBS_PriceEditHardwarePriceForm thisForm,ArrayList hardwarePrice_stList
* @return GBS_PriceEditHardwarePriceForm
*/
private GBS_PriceEditHardwarePriceForm toTree(GBS_PriceEditHardwarePriceForm thisForm ,ArrayList hardwarePrice_stList){
ArrayList kindCode_stList = new ArrayList();
GBS_Kind_stBean kindCode_st = new GBS_Kind_stBean();
ArrayList KindCode_st_DataList = new ArrayList();
GBS_ProductCategory_stBean productCategoryList_st =new GBS_ProductCategory_stBean();
ArrayList productCategoryList_st_DataList = new ArrayList();
GBS_ProductPrice_stBean productIdList_st = new GBS_ProductPrice_stBean();
thisForm.setLocalCurrency("");
thisForm.setRateUS("");
thisForm.setRateEURO("");
if(hardwarePrice_stList.size() >0){
for(int i = 0;i < hardwarePrice_stList.size();i++){
GBS_HardwarePrice_stBean hardwarePrice_st = (GBS_HardwarePrice_stBean)hardwarePrice_stList.get(i);
//get LocalCurrency
if(hardwarePrice_st.getLocalCurrency()!=null && !hardwarePrice_st.getLocalCurrency().equals("")){
thisForm.setLocalCurrency(hardwarePrice_st.getLocalCurrency());
}
//get US's rate
if(hardwarePrice_st.getRateUS()!=null && !hardwarePrice_st.getRateUS().equals("")){
if(hardwarePrice_st.getRateUS().startsWith(".")){
thisForm.setRateUS("0" + hardwarePrice_st.getRateUS());
}else{
thisForm.setRateUS(hardwarePrice_st.getRateUS());
}
}
//get Euro's rate
if(hardwarePrice_st.getRateEuro()!=null && !hardwarePrice_st.getRateEuro().equals("")){
if(hardwarePrice_st.getRateEuro().startsWith(".")){
thisForm.setRateEURO("0" + hardwarePrice_st.getRateEuro());
}else{
thisForm.setRateEURO(hardwarePrice_st.getRateEuro());
}
}
//get data
if(hardwarePrice_st.getKind().equals(kindCode_st.getKindCode())){
kindCode_st=setKind_st(hardwarePrice_st,kindCode_st);
kindCode_stList.set(kindCode_stList.size()-1,kindCode_st);
}else{
kindCode_st = newKind_st(hardwarePrice_st);
kindCode_stList.add(kindCode_st);
}
}
}
thisForm.setDataList(kindCode_stList);
return thisForm;
}
/**
* remove all re in the in.
* @param String in,char re
* @return String
*/
private String remove(String in , char re){
String out="";
for(int i=0;i<in.length();i++){
char charst = in.charAt(i);
if (charst != re){
out+=charst;
}
}
if (out.indexOf(".")>=0) {
while (out.endsWith("0")) {
out = out.substring(0,out.lastIndexOf("0"));
}
if (out.endsWith(".")){
out = out.substring(0,out.lastIndexOf("."));
}
}
return out.trim();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -