cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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");
        }
    }
}