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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
package com.shlanbao.tzsc.pms.sys.datadict.controller;
 
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
 
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.DocFilemanage;
import com.shlanbao.tzsc.base.mapping.SysEqpCategory;
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.sys.datadict.beans.SysEqpCategoryBean;
import com.shlanbao.tzsc.pms.sys.datadict.service.SysEqpCategoryServiceI;
import com.shlanbao.tzsc.utils.tools.Mes2DASParams;
 
/**
 * 数据字典小类维护
 */
@Controller
@RequestMapping("/pms/sys/eqpcategory")
public class SysEqpCategoryController {
    protected Logger log = Logger.getLogger(this.getClass());
    @Autowired
    protected SysEqpCategoryServiceI mdEqpCategoryService;
    @RequestMapping("/gotoMdCategoryJsp")
    public String gotoMdCategory(String id,HttpServletRequest request){
        try {
            request.setAttribute("mdCategory", mdEqpCategoryService.getMdCategoryById(id));
        } catch (Exception e) {
            e.printStackTrace();
        } 
        return "/pms/sys/datadict/editCategory";
    }
    @RequestMapping("/addMdCategoryJsp")
    public String addMdCategory(){
        return "/pms/sys/datadict/addMdCategory";
    }
    
    @ResponseBody
    @RequestMapping("/addMdCategory")
    public Json addMdCategory(SysEqpCategory 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(SysEqpCategoryBean mdEqpCategoryBean){
        Json json = new Json();
        try {
            mdEqpCategoryService.updateCategory(mdEqpCategoryBean);
            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 {
            Map<String,String> map=Mes2DASParams.SysEqpCategoryMap();
            boolean falg=map.containsValue(id);
            if(!falg){
                mdEqpCategoryService.deleteMdCategory(id);
                json.setMsg("操作成功!");
                json.setSuccess(true);
            }else{
                json.setMsg("操作失败!该条目为关键数据。不可以删除!");
                json.setSuccess(false);
            }
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
 
    /**
     * 批量删除一级数据
     * @param ids
     * @return
     */
    @ResponseBody
    @RequestMapping("/batchDeleteMdCategory")
    public Json batchDeleteMdCategory(String ids){
        Json json = new Json();
        String[] split = ids.split(",");
        try {
            if(split.length>0){
                Map<String,String> map=Mes2DASParams.SysEqpCategoryMap();
                boolean falg = false;
                for (int i =0;i<split.length;i++){
                        if(map.containsValue(split[i])) falg = true;
                }
                if(!falg){
                    mdEqpCategoryService.batchDeleteMdCategory(ids);
                    json.setMsg("操作成功!");
                    json.setSuccess(true);
                }else{
                    json.setMsg("操作失败!该条目为关键数据。不可以删除!");
                    json.setSuccess(false);
                }
            }
 
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
    
    @ResponseBody
    @RequestMapping("/queryMdCategory")
    public DataGrid queryMdCategory(SysEqpCategory mdEqpCategory,PageParams pageParams){
        try {
            return mdEqpCategoryService.queryMdCategory(mdEqpCategory, pageParams);
        } catch (Exception e) {
            log.error("查询异常", e);
            e.printStackTrace();
        }
        return null;
    }
    
    /**
     * 查询,供combobox使用
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryMdEqpCategory")
    public List<SysEqpCategoryBean> queryMdEqpCategory(){
        try {
            return mdEqpCategoryService.queryMdCategory();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    
    
    
    @RequestMapping("/uploadJsp")
    public String goTofileUploadJsp(HttpServletRequest request){
        return "/pms/sys/datadict/fileUpload";
    }
    /**
     * 批量导入日润滑数据
     * @param request
     * @return
     */
    
    @RequestMapping("/DatadictinputExcel")
    public String DatadictinputExcel(HttpServletRequest request){
        return "/pms/sys/datadict/iframe_excel";
    }
    
    
    /**
     * 文件上传
     */
    @ResponseBody
    @RequestMapping("/updateFile")
    public Json fileUpdate(String id,HttpSession session,
             HttpServletRequest request,SysEqpCategoryBean fmBean) {
        Json json = new Json();
        try {
            DocFilemanage doc = mdEqpCategoryService.fileUpdate(id,session,request,fmBean);
            if(null!=doc){//回写
                mdEqpCategoryService.updateCategory(doc);
            }
            json.setMsg("文件上传成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error("文件上传异常", e);
            json.setMsg("文件上传失败!");
            json.setSuccess(false);
        }
        return json;
    }
    
    @RequestMapping("/lookMdCategoryJsp")
    public String lookMdCategoryJsp(String uploadUrl,HttpServletRequest request){
        try {
            SysEqpCategoryBean cate = new SysEqpCategoryBean();
            cate.setUploadUrl(uploadUrl);
            request.setAttribute("mdCategory", cate);
        } catch (Exception e) {
            e.printStackTrace();
        } 
        return "/pms/sys/datadict/lookMdCategory";
    }
    
}