📄 productclass.java
字号:
resultMap.put("class_desc", class_desc);
return resultMap;
}
/***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
* @param cust_id
* @param up_id
* @param img
* @return
* @throws SaasApplicationException
*/
public String getJsonDataForTree(String class_type, String up_id, String img) throws SaasApplicationException {
String iconCls = img;
JSONArray jsonList = new JSONArray();
ArrayList rootList = getInfoByUpId(up_id, class_type);
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(id, class_type);
tree.setChildren(node.getChildren());
tree.setLeaf(node.isLeaf());
jsonList.add(tree);
}
}
return jsonList.toString();
}
// 取出下一级
public ArrayList getInfoByUpId(String up_pos_id, String class_type) throws SaasApplicationException {
ArrayList list = new ArrayList();
ProductclassExt classExt = new ProductclassExt();
classExt.setParam(":VCLASS_TYPE", class_type);
classExt.setParam(":VUP_CLASS_ID", up_pos_id);
list = classExt.selByList("SEL_CLASS_BY_UP");
return list;
}
/**
* @param cust_id
* @param up_id
* @return
* @throws SaasApplicationException
*/
public TreeNode isLeaf(String up_id, String class_type) throws SaasApplicationException {
ArrayList nextList = getInfoByUpId(up_id, class_type);
TreeNode node = new TreeNode();
if (nextList != null && nextList.size() > 0) {
node.setLeaf(false);
JSONArray children = getChildrenNodes(up_id, nextList, class_type);
node.setChildren(children);
}
return node;
}
/**
* @param cust_id
* @param root_id
* @param nextList
* @return 返回树的子节点
* @throws SaasApplicationException
*/
public JSONArray getChildrenNodes(String root_id, ArrayList nextList, String class_type) 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(id, class_type);
tree.setChildren(node.getChildren());
tree.setLeaf(node.isLeaf());
children.add(tree);
}
}
return children;
}
/**
* @param iStart
* @param limit
* @param class_id
* @return
*/
public int getProductClassCount(int iStart, int limit, String class_id) {
int size = 0;
if (iStart > 1) {
iStart = (iStart - 1) * limit;
}
else {
iStart = 0;
}
ProductclassExt productclassExt = new ProductclassExt();
productclassExt.setParam(":VCLASS_ID", class_id);
ArrayList list = productclassExt.selByList("SEL_BY_CLASSID_CT", iStart, limit);
if (list != null && list.size() > 0) {
HashMap map = (HashMap) list.get(0);
size = Integer.parseInt(map.get("ct").toString());
}
return size;
}
/**
* 检测是否有子分类
*/
public int checkChildren(String up_class_id) throws SaasApplicationException {
int hasChildern = 0;
ProductclassExt classExt = new ProductclassExt();
classExt.setParam(":VUP_CLASS_ID", up_class_id);
ArrayList list = classExt.selByList("SEL_BY_UP");
if (list != null && list.size() > 0) {
hasChildern = list.size();
}
return hasChildern;
}
/**
* 删除分类信息
*/
public void deleteClassInfo(Buffers inbuffer) {
log.LOG_INFO("进入deleteClassInfo方法...");
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
int iResult = -1;
String class_id = inbuffer.getString("CLASS_ID");
try {
iResult = deleteClassInfo(class_id);
}
catch (SaasApplicationException 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("退出deleteClassInfo方法...");
}
public int deleteClassInfo(String class_id) throws SaasApplicationException {
ProductclassExt productclassExt = new ProductclassExt();
productclassExt.setParam(":VCLASS_ID", class_id);
tradeQuery.executeBy(productclassExt.insBy("DELETE_BY_ID"));
return 0;
}
// 修改分类类型
public void updateByClassId(Buffers inbuffer) {
log.LOG_INFO("进入updateByClassId方法...");
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
int iResult = -1;
String classId = inbuffer.getString("CLASS_ID");
String class_name = inbuffer.getString("CLASS_NAME");
String class_desc = inbuffer.getString("CLASS_DESC");
try {
iResult = updateByClassId(classId, class_name, class_desc);
}
catch (SaasApplicationException 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("退出updateByClassId方法...");
}
public int updateByClassId(String classId, String class_name, String class_desc) throws SaasApplicationException {
ProductclassExt productclassExt = new ProductclassExt();
productclassExt.setParam(":VCLASS_ID", classId);
productclassExt.setParam(":VCLASS_NAME", class_name);
productclassExt.setParam(":VCLASS_DESC", class_desc);
tradeQuery.executeBy(productclassExt.insBy("UPDATE_CLASS_BY_ID"));
return 0;
}
public ArrayList genClassNameByClassId(String class_id) throws SaasApplicationException {
ProductclassExt productclassExt = new ProductclassExt();
ArrayList classList = new ArrayList();
productclassExt.setParam(":VCLASS_ID", class_id);
classList = productclassExt.selByList("SEL_NAME_BY_ID");
if (classList == null || !(classList.size() > 0)) {
classList = null;
}
return classList;
}
/**
* @param class_type
* @param class_level
* @return 通过分类类型和级别取出分类信息
* @throws SaasApplicationException
*/
public ArrayList getClassInfoByTypeLevel(String class_type, String class_level) throws SaasApplicationException {
ProductclassExt classExt = new ProductclassExt();
classExt.setParam(":VCLASS_TYPE", class_type);
classExt.setParam(":VCLASS_LEVEL", class_level);
ArrayList list = classExt.selByList("SEL_CLASS_BY_LEVEL");
return list;
}
/**
* @param class_type
* @param class_level
* @return 生成下拉列表
* @throws SaasApplicationException
*/
public String getSelectedByComm(String class_type, String class_level) throws SaasApplicationException {
String select = "";
ArrayList list = getClassInfoByTypeLevel(class_type, class_level);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
HashMap map = (HashMap) list.get(i);
String id = map.get("class_id").toString();
String text = map.get("class_name").toString();
select = select + "<option value=" + id + ">" + text + "</option>";
}
}
return select;
}
/**
* @param class_type
* @param up_id
* @return 通过上级取出下级
* @throws SaasApplicationException
*/
public ArrayList getClassInfoByUpClassId(String class_type, String up_id) throws SaasApplicationException {
ProductclassExt classExt = new ProductclassExt();
classExt.setParam(":VCLASS_TYPE", class_type);
classExt.setParam(":VUP_ClASS_ID", up_id);
ArrayList list = classExt.selByList("SEL_BY_CLASS_TYPE");
return list;
}
/**
* 取出分类信息
*/
public String getCalalogInfo(String info_type, String class_id, String linkUrl) throws SaasApplicationException {
log.LOG_INFO("进入getCalalogInfo方法...");
String calalog = "";
ArrayList list = getClassInfoByUpId(class_id, info_type);
if (list != null && list.size() > 0) {
HashMap map = (HashMap) list.get(0);
String up_id = "";
if (map.get("up_class_id") != null) {
up_id = map.get("up_class_id").toString();
}
calalog = getCalalogUrl(info_type, class_id, linkUrl) + calalog;
if (up_id == "000000000000000" || up_id.equals("000000000000000")) {
return calalog;
}
else {
calalog = getCalalogInfo(info_type, up_id, linkUrl) + calalog;
}
}
log.LOG_INFO(".............." + calalog);
return calalog;
}
public String getCalalogUrl(String info_type, String class_id, String linkUrl) throws SaasApplicationException {
log.LOG_INFO("进入getCalalogUrl方法...");
String calalog = "";
ArrayList list = getClassInfoByUpId(class_id, info_type);
if (list != null && list.size() > 0) {
HashMap map = (HashMap) list.get(0);
String class_name = "";
if (map.get("class_name") != null) {
class_name = map.get("class_name").toString();
}
if (map.get("class_id") != null) {
class_id = map.get("class_id").toString();
}
calalog = "<a href=" + linkUrl + class_id + ">" + class_name + "</a> <img src=/zone_b2b/images/lujian.gif border=0>" + calalog;
}
return calalog;
}
/**
* @param class_id
* @param class_type
* @return 取出分类信息
* @throws SaasApplicationException
*/
public ArrayList getClassInfoByUpId(String class_id, String class_type) throws SaasApplicationException {
log.LOG_INFO("进入getClassInfoByUpId方法...");
ProductclassExt classExt = new ProductclassExt();
classExt.setParam(":VClASS_ID", class_id);
classExt.setParam(":VCLASS_TYPE", class_type);
ArrayList list = classExt.selByList("SEL_CLASS_BY_LEAVE");
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -