📄 setarealist.java
字号:
package com.saas.biz.setareaMgr;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;
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.setareaDAO.SetAreaDAO;
import com.saas.biz.dao.setareaDAO.SetAreaExt;
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 SetAreaList {
Logger log;
Buffers inBuffer;
Buffers outBuffer;
Dbtable tradeQuery;
commMethodMgr commen;
ArrayList queryResult = new ArrayList();
public SetAreaList() {
log = new Logger(this);
tradeQuery = new Dbtable();
commen = new commMethodMgr();
}
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;
}
// 片区设置
public void setAreaInfo(Buffers inbuffer) {
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
log.LOG_INFO("进入setAreaInfo方法...");
int iResult = -1;
String cust_id = inbuffer.getString("SESSION_CUST_ID");
String channels_type = inbuffer.getString("CHANNELS_TYPE");
String channels_id = inbuffer.getString("CHANNELS_ID");
String area_code = inbuffer.getString("AREA_CODE");
String area_name = inbuffer.getString("AREA_NAME");
String Exc_tag = inbuffer.getString("EXC_TAG");
String oper_user_id = inbuffer.getString("OPER_USER_ID");
String in_date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
String remark2 = inbuffer.getString("REMARK2");
try {
SetAreaDAO areaDao = new SetAreaDAO();
areaDao.setCust_id(cust_id);
areaDao.setChannels_type(channels_type);
areaDao.setChannels_id(channels_id);
areaDao.setArea_code(area_code);
areaDao.setArea_name(area_name);
areaDao.setExc_tag(Exc_tag);
areaDao.setOper_user_id(oper_user_id);
areaDao.setIn_date(in_date);
areaDao.setRemark2(remark2);
iResult = setAreaInfo(areaDao);
}
catch (Exception e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "新增片区业务处理失败!");
}
else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "新增片区业务处理成功!");
}
log.LOG_INFO("退出setAreaInfo方法...");
}
public int setAreaInfo(SetAreaDAO areaDao) throws SaasApplicationException {
SetAreaExt areaExt = new SetAreaExt();
areaExt.setParam(":VCUST_ID", areaDao.getCust_id());
areaExt.setParam(":VCHANNELS_TYPE", areaDao.getChannels_type());
areaExt.setParam(":VCHANNELS_ID", areaDao.getChannels_id());
areaExt.setParam(":VAREA_CODE", areaDao.getArea_code());
areaExt.setParam(":VAREA_NAME", areaDao.getArea_name());
areaExt.setParam(":VEXC_TAG", areaDao.getExc_tag());
areaExt.setParam(":VOPER_USER_ID", areaDao.getOper_user_id());
areaExt.setParam(":VIN_DATE", areaDao.getIn_date());
areaExt.setParam(":VREMARK2", areaDao.getRemark2());
tradeQuery.executeBy(areaExt.insBy("SET_AREA_INFO"));
return 0;
}
// 删除片区
public void delArea(Buffers inbuffer) {
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
log.LOG_INFO("进入delArea方法...");
int iResult = -1;
String cust_id = inbuffer.getString("SESSION_CUST_ID");
String channels_type = inbuffer.getString("CHANNELS_TYPE");
String channels_id = inbuffer.getString("CHANNELS_ID");
String area_code = inbuffer.getString("AREA_CODE");
String area_name = inbuffer.getString("AREA_NAME");
String Exc_tag = inbuffer.getString("EXC_TAG");
String oper_user_id = inbuffer.getString("OPER_USER_ID");
String in_date = inbuffer.getString("IN_DATE");
String remark2 = inbuffer.getString("REMARK2");
try {
SetAreaDAO areaDao = new SetAreaDAO();
areaDao.setCust_id(cust_id);
areaDao.setChannels_type(channels_type);
areaDao.setChannels_id(channels_id);
areaDao.setArea_code(area_code);
areaDao.setArea_name(area_name);
areaDao.setExc_tag(Exc_tag);
areaDao.setOper_user_id(oper_user_id);
areaDao.setIn_date(in_date);
areaDao.setRemark2(remark2);
iResult = delArea(areaDao);
}
catch (Exception e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "删除片区业务处理失败!");
}
else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "删除片区业务处理成功!");
}
log.LOG_INFO("退出delArea方法...");
}
public int delArea(SetAreaDAO areaDao) throws SaasApplicationException {
SetAreaExt areaExt = new SetAreaExt();
areaExt.setParam(":VCUST_ID", areaDao.getCust_id());
areaExt.setParam(":VCHANNELS_TYPE", areaDao.getChannels_type());
areaExt.setParam(":VCHANNELS_ID", areaDao.getChannels_id());
areaExt.setParam(":VAREA_CODE", areaDao.getArea_code());
areaExt.setParam(":VAREA_NAME", areaDao.getArea_name());
areaExt.setParam(":VEXC_TAG", areaDao.getExc_tag());
areaExt.setParam(":VOPER_USER_ID", areaDao.getOper_user_id());
areaExt.setParam(":VIN_DATE", areaDao.getIn_date());
areaExt.setParam(":VREMARK2", areaDao.getRemark2());
tradeQuery.executeBy(areaExt.insBy("DEL_BY_AREA"));
return 0;
}
/**
* @param inbuffer
*/
public void delAreaAll(Buffers inbuffer) {
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
log.LOG_INFO("进入delArea方法...");
int iResult = -1;
String cust_id = inbuffer.getString("SESSION_CUST_ID");
String channels_type = inbuffer.getString("CHANNELS_TYPE");
String channels_id = inbuffer.getString("CHANNELS_ID");
String oper_user_id = inbuffer.getString("OPER_USER_ID");
try {
SetAreaDAO areaDao = new SetAreaDAO();
areaDao.setChannels_id(channels_id);
areaDao.setCust_id(cust_id);
areaDao.setChannels_type(channels_type);
areaDao.setOper_user_id(oper_user_id);
iResult = delAreaAll(areaDao);
}
catch (Exception e) {
log.LOG_INFO(e.getMessage());
}
if (iResult != 0) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "删除片区业务处理失败!");
}
else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "删除片区业务处理成功!");
}
log.LOG_INFO("退出delArea方法...");
}
public int delAreaAll(SetAreaDAO areaDao) throws SaasApplicationException {
String area_codes = areaDao.getOper_user_id();
StringTokenizer st = new StringTokenizer(area_codes, "|");
while (st.hasMoreTokens()) {
String code = st.nextToken();
SetAreaExt areaExt = new SetAreaExt();
areaExt.setParam(":VCUST_ID", areaDao.getCust_id());
areaExt.setParam(":VCHANNELS_TYPE", areaDao.getChannels_type());
areaExt.setParam(":VCHANNELS_ID", areaDao.getChannels_id());
areaExt.setParam(":VAREA_CODE", code);
tradeQuery.executeBy(areaExt.insBy("DEL_BY_ALL"));
}
return 0;
}
// 取出下一级
public ArrayList getInfoByUpId(String cust_id, String up_channels_id) throws SaasApplicationException {
ArrayList relationList = new ArrayList();
SetAreaExt areaExt = new SetAreaExt();
areaExt.setParam(":VCUST_ID", cust_id);
areaExt.setParam(":VUP_CHANNELS_ID", up_channels_id);
relationList = areaExt.selByList("SEL_BY_UP_ID");
return relationList;
}
// 取出自己
public ArrayList getInfoById(String cust_id, String channels_id) throws SaasApplicationException {
ArrayList relationList = new ArrayList();
SetAreaExt relaExt = new SetAreaExt();
relaExt.setParam(":VCUST_ID", cust_id);
relaExt.setParam(":VCHANNELS_ID", channels_id);
relationList = relaExt.selByList("SEL_BY_ID");
return relationList;
}
public HashMap getAreaById(String cust_id, String channels_id) throws SaasApplicationException {
HashMap map = new HashMap();
ArrayList relationList = new ArrayList();
SetAreaExt relaExt = new SetAreaExt();
relaExt.setParam(":VCUST_ID", cust_id);
relaExt.setParam(":VCHANNELS_ID", channels_id);
relationList = relaExt.selByList("SEL_BY_ID");
map = (HashMap) relationList.get(0);
return map;
}
public String getJsonDataForTree(String cust_id, String up_id, String img) throws SaasApplicationException {
String iconCls = img;
JSONArray jsonList = new JSONArray();
ArrayList rootList = getInfoByUpId(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("channels_name").toString();
String id = map.get("channels_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();
}
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("channels_name").toString();
String id = map.get("channels_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 = getInfoByUpId(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;
}
// @return 判断是否有子节点
public int checkChildren(String cust_id, String chana_id) throws SaasApplicationException {
int child = 0;
ArrayList list = getInfoByUpId(cust_id, chana_id);
if (list != null && list.size() > 0) {
child = list.size();
}
return child;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -