zhuguifei
2026-03-10 58402bd5e762361363a0f7d7907153c77dbb819f
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
137
138
package com.shlanbao.tzsc.pms.md.eqpcategory.controller;
 
import java.util.List;
 
import javax.servlet.http.HttpServletRequest;
 
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.shlanbao.tzsc.base.mapping.MdEqpCategory;
import com.shlanbao.tzsc.base.model.DataGrid;
import com.shlanbao.tzsc.base.model.Json;
import com.shlanbao.tzsc.base.model.PageParams;
import com.shlanbao.tzsc.pms.md.eqpcategory.beans.MdEqpCategoryBean;
import com.shlanbao.tzsc.pms.md.eqpcategory.service.MdEqpCategoryServiceI;
 
 
/**
 * 设备类型维护
 * @author liuligong 
 * @Time 2014/11/17 9:49
 */
@Controller
@RequestMapping("/pms/md/eqpcategory")
public class MdEqpCategoryController {
    protected Logger log = Logger.getLogger(this.getClass());
    
    @Autowired
    protected MdEqpCategoryServiceI mdEqpCategoryService;
    
    @RequestMapping("/gotoMdCategoryJsp")
    public String gotoMdCategory(String id,HttpServletRequest request){
        try {
            request.setAttribute("mdCategory", mdEqpCategoryService.getMdCategoryById(id));
        } catch (Exception e) {
            e.printStackTrace();
        } 
        return "/pms/md/eqpcategory/editCategory";
    }
    @RequestMapping("/addMdCategoryJsp")
    public String addMdCategory(){
        return "/pms/md/eqpcategory/addMdCategory";
    }
    
    @ResponseBody
    @RequestMapping("/addMdCategory")
    public Json addMdCategory(MdEqpCategory mdEqpCategory){
        Json json = new Json();
        try {
            mdEqpCategoryService.addMdCategory(mdEqpCategory);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
    @ResponseBody
    @RequestMapping("/updatecategory")
    public Json updateCategory(MdEqpCategory mdEqpCategory){
        Json json = new Json();
        try {
            mdEqpCategoryService.updateCategory(mdEqpCategory);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
    
    @ResponseBody
    @RequestMapping("/deleteMdCategory")
    public Json deleteMdCategory(String id){
        Json json = new Json();
        try {
            mdEqpCategoryService.deleteMdCategory(id);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
    @ResponseBody
    @RequestMapping("/batchDeleteCategory")
    public Json batchDeleteCategory(String ids){
        Json json = new Json();
        try {
            mdEqpCategoryService.batchDeleteCategory(ids);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
    
    @ResponseBody
    @RequestMapping("/queryMdCategory")
    public DataGrid queryMdCategory(MdEqpCategory mdEqpCategory,PageParams pageParams){
        try {
            DataGrid gd = mdEqpCategoryService.queryMdCategory(mdEqpCategory, pageParams);
            return gd;
        } catch (Exception e) {
            log.error("查询设备类型失败", e);
            e.printStackTrace();
        }
        return null;
    }
    
    /**
     * 查询设备类型列表,供combobox使用
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryMdEqpCategory")
    public List<MdEqpCategoryBean> queryMdEqpCategory(){
        try {
            return mdEqpCategoryService.queryMdCategory();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}