package cn.ksource.web.controller.business.pages.xtpz.sjzd;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
|
import org.apache.commons.lang.StringUtils;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.servlet.ModelAndView;
|
|
import cn.ksource.beans.CONFIG_DATA_DICTIONARY_AREA;
|
import cn.ksource.beans.CONFIG_DICTIONARY_INDUSTRY;
|
import cn.ksource.core.util.ConvertUtil;
|
import cn.ksource.core.util.JsonUtil;
|
import cn.ksource.core.util.StringUtil;
|
import cn.ksource.core.web.SysInfo;
|
import cn.ksource.core.web.TreeNode;
|
import cn.ksource.core.web.WebUtil;
|
import cn.ksource.web.controller.business.pages.xtpz.sjzd.industry.IndustryFacade;
|
|
@Controller
|
@RequestMapping("/business/pages/xtgl/xtpz/sjzd/industry/")
|
public class IndustryController {
|
|
@Resource(name="industryFacade")
|
private IndustryFacade industryFacade;
|
|
@RequestMapping("industryTree.html")
|
public void addressTree(HttpServletRequest request,HttpServletResponse response){
|
String id = request.getParameter("id");
|
TreeNode root = industryFacade.getIndustryTree(id);
|
if (StringUtils.isBlank(id)) {
|
WebUtil.write(response, root.toJson());
|
} else {
|
WebUtil.write(response, root.getChildrenNodesForJson());
|
}
|
}
|
|
@RequestMapping("industryList.html")
|
public ModelAndView onaddressListLoad(HttpServletRequest request,HttpServletResponse response){
|
return new ModelAndView("/business/pages/xtgl/xtpz/sjzd/industry/industryList");
|
}
|
|
@RequestMapping("industryListJson.html")
|
public void onaddressListJson(HttpServletRequest request,HttpServletResponse response){
|
Map industry = new HashMap();
|
industry = industryFacade.getIndustryListForPagination(request);
|
String json = JsonUtil.map2Json(industry);
|
WebUtil.write(response,json);
|
}
|
|
@RequestMapping("addIndustry.html")
|
public ModelAndView addAddress(HttpServletRequest request,HttpServletResponse response){
|
String id = request.getParameter("id");
|
Map info = new HashMap();
|
if (StringUtils.isNotBlank(id)) {
|
info = industryFacade.getIndustryById(id);
|
}
|
String up_id = request.getParameter("up_id");
|
String sn = request.getParameter("sn");
|
if (StringUtils.isNotBlank(up_id) && !up_id.toString().equals("0")) {
|
Map upMap = industryFacade.getIndustryById(up_id);
|
info.put("level", ConvertUtil.obj2Integer(upMap.get("level")) + 1);
|
info.put("up_id", up_id);
|
info.put("sn",sn);
|
}
|
return new ModelAndView("/business/pages/xtgl/xtpz/sjzd/industry/addIndustry","info",info);
|
}
|
|
@RequestMapping("addIndustrySubmit.html")
|
public ModelAndView onAddAddressSubmit(CONFIG_DICTIONARY_INDUSTRY industry,HttpServletRequest request,HttpServletResponse response){
|
String industry_name = request.getParameter("industry_name");
|
Integer sn = Integer.parseInt(request.getParameter("sn"));
|
if (industry.getLevel()==null ||industry.getLevel() ==0 ) {
|
industry.setLevel(1);
|
industry.setUp_id(null);
|
}else{
|
String up_id = request.getParameter("up_id");
|
Integer level = Integer.parseInt(request.getParameter("level"));
|
industry.setLevel(level);
|
industry.setUp_id(StringUtils.isBlank(up_id) ? null : up_id);
|
}
|
industry.setIndustry_name(industry_name);
|
industry.setSn(sn);
|
industry.setStatus(1);
|
industryFacade.saveIndustry(industry);
|
return WebUtil.goSysInfoPage(request,"操作成功!",
|
"window.top.closeDialog(0);" +
|
"window.top.getDomID().contentWindow.reloadTree('industryTree');" +
|
"window.top.getDomID().contentWindow.reloadDataGrid('industryList',{})",
|
SysInfo.Success);
|
}
|
|
|
@RequestMapping("disable.html")
|
public void onDisableStatusSubmit(CONFIG_DICTIONARY_INDUSTRY industry,HttpServletRequest request,HttpServletResponse response){
|
String id = request.getParameter("id");
|
String result = new String();
|
try{
|
industryFacade.updateIndustryStatus(id,2);
|
result = "1";//result = "1",地址禁用成功
|
}catch (Exception e) {
|
e.printStackTrace();
|
result = "2";//result = "2",地址禁用失败
|
}
|
WebUtil.write(response, result);
|
}
|
|
@RequestMapping("able.html")
|
public void onAbleStatusSubmit(CONFIG_DICTIONARY_INDUSTRY industry,HttpServletRequest request,HttpServletResponse response){
|
String id = request.getParameter("id");
|
String result = new String();
|
try{
|
industryFacade.updateIndustryStatus(id,1);
|
result = "1";//result = "1",地址禁用成功
|
}catch (Exception e) {
|
e.printStackTrace();
|
result = "2";//result = "2",地址禁用失败
|
}
|
WebUtil.write(response, result);
|
}
|
|
@RequestMapping("del.html")
|
public void ondel(HttpServletRequest request,HttpServletResponse response){
|
String id = request.getParameter("id");
|
if(industryFacade.getIndustryList(id)==null||industryFacade.getIndustryList(id).isEmpty()){
|
industryFacade.delIndustry(id);
|
}else{
|
WebUtil.write(response, "1");
|
}
|
}
|
}
|