?? addproductinfo.java
字號:
package com.saas.biz.addproductMgr;
import java.util.ArrayList;
import java.util.HashMap;
import net.sf.json.JSONArray;
import com.saas.biz.JavaScriptObject.TreeNode;
import com.saas.biz.JavaScriptObject.TreeObject;
import com.saas.biz.commen.commMethodMgr;
import com.saas.biz.dao.addproductDAO.AddProductDAO;
import com.saas.biz.dao.addproductDAO.AddProductExt;
import com.saas.biz.dao.relationccDAO.RelationCcExt;
import com.saas.sys.buffer.Buffers;
import com.saas.sys.dbm.Dbtable;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.sys.log.Logger;
public class AddProductInfo {
Logger log;
Buffers inBuffer;
Buffers outBuffer;
Dbtable tradeQuery;
ArrayList queryResult = new ArrayList();
public AddProductInfo() {
log = new Logger(this);
tradeQuery = new Dbtable();
outBuffer = new Buffers();
}
public void setOutBuffer(Buffers outBuffer) {
this.outBuffer = outBuffer;
}
public Buffers getOutBuffer() {
return this.outBuffer;
}
public void setTradeQuery(Dbtable tradeQuery) {
this.tradeQuery = tradeQuery;
}
public Dbtable getTradeQuery() {
return this.tradeQuery;
}
public ArrayList getQueryResult() {
return this.queryResult;
}
public void setQueryResult(ArrayList queryResult) {
this.queryResult = queryResult;
}
// 添加產(chǎn)品
public void addProductInfo(Buffers inbuffer) {
log.LOG_INFO("進入addProductInfo方法...");
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
int iResult = -1;
String cust_id = inbuffer.getString("SESSION_CUST_ID");
String class_id = inbuffer.getString("CLASS_ID");
String class_name = inbuffer.getString("CLASS_NAME");
String up_class_id = inbuffer.getString("UP_CLASS_ID");
String class_level = inbuffer.getString("CLASS_LEVEL");
String class_type = inbuffer.getString("CLASS_TYPE");
String class_desc = inbuffer.getString("CLASS_DESC");
String enable_tag = inbuffer.getString("ENABLE_TAG");
String remark = inbuffer.getString("REMARK");
try {
AddProductDAO addproductdao = new AddProductDAO();
addproductdao.setCust_id(cust_id);
addproductdao.setClass_id(class_id);
addproductdao.setClass_name(class_name);
addproductdao.setUp_class_id(up_class_id);
addproductdao.setClass_level(class_level);
addproductdao.setClass_type(class_type);
addproductdao.setClass_desc(class_desc);
addproductdao.setEnable_tag(enable_tag);
addproductdao.setRemark(remark);
iResult = addProductInfo(addproductdao);
} catch (Exception e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "業(yè)務(wù)處理失敗!");
} else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "業(yè)務(wù)處理成功!");
}
log.LOG_INFO("退出addProductInfo方法...");
}
public int addProductInfo(AddProductDAO areaDao)
throws SaasApplicationException {
AddProductExt areaExt = new AddProductExt();
// log.LOG_INFO("開始執(zhí)行SQL:===:");
areaExt.setParam(":VCUST_ID", areaDao.getCust_id());
areaExt.setParam(":VCLASS_ID", areaDao.getClass_id());
areaExt.setParam(":VCLASS_NAME", areaDao.getClass_name());
areaExt.setParam(":VUP_CLASS_ID", areaDao.getUp_class_id());
areaExt.setParam(":VCLASS_LEVEL", areaDao.getClass_level());
areaExt.setParam(":VCLASS_TYPE", areaDao.getClass_type());
areaExt.setParam(":VCLASS_DESC", areaDao.getClass_desc());
areaExt.setParam(":VENABLE_TAG", areaDao.getEnable_tag());
areaExt.setParam(":VREMARK", areaDao.getRemark());
// log.LOG_INFO("開始執(zhí)行SQL:===:" + areaExt.insBy("INS_BY_ALL"));
tradeQuery.executeBy(areaExt.insBy("INS_BY_ALL"));
return 0;
}
// 修改產(chǎn)品資料
public void modifyproductInfo(Buffers inbuffer) {
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
log.LOG_INFO("進入modifyproductInfo方法...");
int iResult = -1;
String cust_id = inbuffer.getString("SESSION_CUST_ID");
String class_id = inbuffer.getString("class_id");
String class_name = inbuffer.getString("class_name");
String class_desc = inbuffer.getString("class_desc");
String enable_tag = inbuffer.getString("enable_tag");
String remark = inbuffer.getString("remark");
try {
AddProductDAO productDao = new AddProductDAO();
productDao.setCust_id(cust_id);
productDao.setClass_id(class_id);
productDao.setClass_name(class_name);
productDao.setClass_desc(class_desc);
productDao.setEnable_tag(enable_tag);
productDao.setRemark(remark);
iResult = modifyproductInfo(productDao);
} catch (Exception e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "業(yè)務(wù)處理失敗!");
} else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "業(yè)務(wù)處理成功!");
}
log.LOG_INFO("退出modifyproductInfo方法...");
}
public int modifyproductInfo(AddProductDAO productDao)
throws SaasApplicationException {
AddProductExt productExt = new AddProductExt();
productExt.setParam(":VCUST_ID", productDao.getCust_id());
productExt.setParam(":VCLASS_ID", productDao.getClass_id());
productExt.setParam(":VCLASS_NAME", productDao.getClass_name());
productExt.setParam(":VCLASS_DESC", productDao.getClass_desc());
productExt.setParam(":VENABLE_TAG", productDao.getEnable_tag());
productExt.setParam(":VREMARK", productDao.getRemark());
tradeQuery.executeBy(productExt.insBy("UP_PRODUCT_BY_ALL"));
return 0;
}
public String getJsonDataForTree(String cust_id, String up_id, String img)
throws SaasApplicationException {
String iconCls = img;
JSONArray jsonList = new JSONArray();
ArrayList rootList = getproductByUpId(cust_id, up_id);
if (rootList != null && rootList.size() > 0) {
for (int i = 0; i < rootList.size(); i++) {
HashMap map = (HashMap) rootList.get(i);
TreeObject tree = new TreeObject();
String text = map.get("class_name").toString();
String id = map.get("class_id").toString();
tree.setIconCls(iconCls);
tree.setId(id);
tree.setText(text);
TreeNode node = isLeaf(cust_id, id);
tree.setChildren(node.getChildren());
tree.setLeaf(node.isLeaf());
jsonList.add(tree);
}
}
return jsonList.toString();
}
// 刪除片區(qū)資料
public void deleteProductInfo(Buffers inbuffer) {
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
log.LOG_INFO("進入deleteProductInfo方法...");
int iResult = -1;
String cust_id = inbuffer.getString("SESSION_CUST_ID");
String class_id = inbuffer.getString("CLASS_ID");
try {
AddProductDAO productDao = new AddProductDAO();
productDao.setCust_id(cust_id);
productDao.setClass_id(class_id);
iResult = deleteProductInfo(productDao);
}
catch (Exception e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "業(yè)務(wù)處理失敗!");
}
else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "業(yè)務(wù)處理成功!");
}
log.LOG_INFO("退出deleteProductInfo方法...");
}
public int deleteProductInfo(AddProductDAO productDao) throws SaasApplicationException {
AddProductExt productExt = new AddProductExt();
productExt.setParam(":VCUST_ID", productDao.getCust_id());
productExt.setParam(":VCLASS_ID", productDao.getClass_id());
tradeQuery.executeBy(productExt.insBy("DEL_PRODUCT_BY_ID"));
return 0;
}
public JSONArray getChildrenNodes(String cust_id, String root_id,
ArrayList nextList) throws SaasApplicationException {
JSONArray children = new JSONArray();
if (nextList != null && nextList.size() > 0) {
for (int i = 0; i < nextList.size(); i++) {
HashMap map = (HashMap) nextList.get(i);
TreeObject tree = new TreeObject();
String text = map.get("class_name").toString();
String id = map.get("class_id").toString();
tree.setId(id);
tree.setText(text);
TreeNode node = isLeaf(cust_id, id);
tree.setChildren(node.getChildren());
tree.setLeaf(node.isLeaf());
children.add(tree);
}
}
return children;
}
public TreeNode isLeaf(String cust_id, String up_id)
throws SaasApplicationException {
ArrayList nextList = getproductByUpId(cust_id, up_id);
TreeNode node = new TreeNode();
if (nextList != null && nextList.size() > 0) {
node.setLeaf(false);
JSONArray children = getChildrenNodes(cust_id, up_id, nextList);
node.setChildren(children);
}
return node;
}
public int checkChildren(String cust_id, String class_id)
throws SaasApplicationException {
int child = 0;
ArrayList list = getproductByUpId(cust_id, class_id);
if (list != null && list.size() > 0) {
child = list.size();
}
return child;
}
// 取出下一級
public ArrayList getproductByUpId(String cust_id, String up_class_id)
throws SaasApplicationException {
ArrayList relationList = new ArrayList();
AddProductExt relaExt = new AddProductExt();
relaExt.setParam(":VCUST_ID", cust_id);
relaExt.setParam(":VUP_CLASS_ID", up_class_id);
relationList = relaExt.selByList("SEL_BY_UP_ID");
return relationList;
}
public HashMap getproductById(String cust_id, String class_id)
throws SaasApplicationException {
HashMap map = new HashMap();
ArrayList relationList = new ArrayList();
AddProductExt relaExt = new AddProductExt();
relaExt.setParam(":VCUST_ID", cust_id);
relaExt.setParam(":VCLASS_ID", class_id);
relationList = relaExt.selByList("SEL_BY_ID");
map = (HashMap) relationList.get(0);
return map;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -