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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
package com.shlanbao.tzsc.pms.sys.datadict.controller;
 
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
 
import com.shlanbao.tzsc.base.mapping.EqmLubricant;
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.init.BaseParams;
import com.shlanbao.tzsc.pms.cos.spare.controller.InputFilesController;
import com.shlanbao.tzsc.pms.equ.lubricate.beans.EqmLubricantBean;
import com.shlanbao.tzsc.pms.equ.lubricate.service.EqmLubricantServiceI;
import com.shlanbao.tzsc.pms.md.fixCode.beans.FixCodeBean;
import com.shlanbao.tzsc.pms.sys.datadict.beans.SysEqpTypeBean;
import com.shlanbao.tzsc.pms.sys.datadict.service.SysEqpCategoryServiceI;
import com.shlanbao.tzsc.pms.sys.datadict.service.SysEqpTypeServiceI;
import com.shlanbao.tzsc.utils.tools.SystemConstant;
 
/**
 * 数据字典维护
 */
@Controller
@RequestMapping("/pms/sys/eqptype")
public class SysEqpTypeController {
    protected Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private SysEqpTypeServiceI mdEqpTypeService;
    @Autowired
    private SysEqpCategoryServiceI mdEqpCategoryService;
    @Autowired
    public EqmLubricantServiceI eqmLubricantServiceI;
    
    
    /**
     * [功能说明]:数据字典,润滑,点检,轮保添加页基础数据加载
     * @author wanchanghuang
     * @createTime 2016年6月8日10:33:46
     * @param upcode- md_fix_code表CODE
     * */
    @ResponseBody
    @RequestMapping("/queryMdFixCodeByCode")
    public Map<String, String> queryMdFixCodeByCode(HttpServletRequest request,String code){
        List<FixCodeBean> listcb=BaseParams.getListMdFixCode();
        Map<String, String> map=null;
        if(listcb!=null && listcb.size()>0){
            map=new HashMap<String, String>();
            for(FixCodeBean f:listcb){
                if(code.equals(f.getUpcode())){
                    map.put(f.getCode(), f.getName());
                }
            }
        }
        return map;
    }
    
    /**
     * 将FixCodeBean主数据字典下的数据转化成下拉
     * @param request
     * @param code
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryMdFixCodeBeanByCode")
    public List<FixCodeBean> queryMdFixCodeBeanByCode(HttpServletRequest request,String code){
        List<FixCodeBean> listcb=BaseParams.getListMdFixCode();
        List<FixCodeBean> beans=new ArrayList<>();
        if(listcb!=null && listcb.size()>0){
            FixCodeBean bean=new FixCodeBean();
            bean.setName("请选择");
            bean.setCode("");
            beans.add(bean);
            for(FixCodeBean f:listcb){
                if(code.equals(f.getUpcode())){
                    beans.add(f);
                }
            }
        }
        return beans;
    }
    
    /**
     * 将FixCodeBean主数据字典转化成下拉
     * @param request
     * @param code
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryMdFixCodeUpCodeBean")
    public List<FixCodeBean> queryMdFixCodeUpCodeBean(){
        List<FixCodeBean> listcb=BaseParams.getListMdFixCode();
        List<FixCodeBean> beans=new ArrayList<>();
        if(listcb!=null && listcb.size()>0){
            FixCodeBean bean=new FixCodeBean();
            /*bean.setName("全部");
            bean.setCode("");*/
            beans.add(bean);
            for(FixCodeBean f:listcb){
                if(f.getUpcode()!=null && f.getUpcode().equals("0")){
                    beans.add(f);
                }
            }
        }
        return beans;
    }
    
 
    @RequestMapping("/goToMdTypeJsp")
    public String goToMdType(HttpServletRequest request, String id) {
        if (null != id) {
            try {
                request.setAttribute("mdEqpTypeBean",
                        mdEqpTypeService.getTypeById(id));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return "/pms/sys/datadict/addMdType";
    }
 
    @RequestMapping("/AddMdTypeJsp")
    public String goToMdType(String cateid, HttpServletRequest request)
            throws Exception {
        SysEqpCategory category = mdEqpCategoryService
                .getMdCategoryById(cateid);
        SysEqpTypeBean eqpTypeBean = new SysEqpTypeBean();
        eqpTypeBean.setCategoryId(category.getId());
        eqpTypeBean.setCategoryName(category.getName());
        request.setAttribute("mdEqpTypeBean", eqpTypeBean);
        return "/pms/sys/datadict/addMdType";
    }
 
    // 设备类型新增
    @ResponseBody
    @RequestMapping("/addMdType")
    public Json addMdType(SysEqpTypeBean mdEqpTypeBean) {
        Json json = new Json();
        try {
            mdEqpTypeService.addMdType(mdEqpTypeBean);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
    @ResponseBody
    @RequestMapping("/queryMdType")
    public DataGrid queryMdType(SysEqpTypeBean mdTypeBean, PageParams pageParams) {
        try {
            DataGrid gd = mdEqpTypeService.queryMdType(mdTypeBean, pageParams);
            return gd;
        } catch (Exception e) {
            log.error("查询异常。", e);
        }
        return null;
    }
 
    @ResponseBody
    @RequestMapping("/queryMdEqpType")
    public List<SysEqpTypeBean> queryMdEqpType() {
        try {
            return mdEqpTypeService.queryMdType();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    @ResponseBody
    @RequestMapping("/deleteMdType")
    public Json deleteMdType(String id) {
        Json json = new Json();
        try {
            mdEqpTypeService.deleteMdType(id);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error("删除数据异常。", e);
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
    // 获取卷烟机、包装机和成型机的机型
    @ResponseBody
    @RequestMapping("/queryMdEqpTypeByCategory")
    public List<SysEqpTypeBean> queryMdEqpTypeByCategory() {
        try {
            String[] categorys = new String[3];
            categorys[0] = SystemConstant.CATEGORY_JY_ID;
            categorys[1] = SystemConstant.CATEGORY_BZ_ID;
            categorys[2] = SystemConstant.CATEGORY_CX_ID;
            return mdEqpTypeService.queryMdEqpTypeByCategory(categorys);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    @RequestMapping("/gotoHotspotJsp")
    public String gotoHotspot(SysEqpTypeBean bean, HttpServletRequest request) {
        try {
            // 需要查询 不然有乱码
            SysEqpTypeBean queryBean = mdEqpTypeService.getTypeById(bean
                    .getTwoRowId());
            queryBean.setUploadUrl(bean.getUploadUrl());// 图片地址
            queryBean.setTwoRowId(bean.getTwoRowId());// 子节点 主键ID
            queryBean.setContextPath(bean.getContextPath());// 项目路径
            queryBean.setContextDes(queryBean.getSetImagePoint());// 内容
            request.setAttribute("mdEqpTypeBean", queryBean);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/pms/sys/datadict/imagesHotspot/hotspot";
    }
 
    /**
     * 图片设置
     * 
     * @param id
     *            主键ID
     * @param result
     *            设置的内容
     * @param session
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping("/setUpImage")
    public Json setUpImage(String id, String result, String filePath,
            HttpSession session, HttpServletRequest request) {
        Json json = new Json();
        try {
            // setImagePoint
            mdEqpTypeService.addSetUpImages(id, result, filePath);
            json.setMsg("设置成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error("设置异常", e);
            json.setMsg("设置失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
    /**
     * 【功能说明】:数据字典批量导入功能- 添加解析excel
     * 
     * @time 2015年8月2日14:50:16
     * @param id
     * @param request
     * @return path -页面路径
     * 
     * */
    @RequestMapping("/inputExeclAndReadWrite")
    @ResponseBody
    public Json inputExeclAndReadWrite(
            @RequestParam(value = "importFile", required = false) MultipartFile file,
            HttpServletRequest request, String type, SysEqpTypeBean etb) {
        Json json = new Json();
        try {
            String path = request.getSession().getServletContext()
                    .getRealPath("upload");
            String fileName = file.getOriginalFilename();
            File targetFile = new File(path, fileName);
            if (!targetFile.exists()) {
                targetFile.mkdirs();
            }
            file.transferTo(targetFile);
            String url = path + "/" + fileName;
            
            String bm=null;
            try {
                bm = fileName.substring((fileName.lastIndexOf(".") + 1),
                        fileName.length());
            } catch (Exception e) {
                json.setMsg("文件后缀错误!导入失败");
                json.setSuccess(false);
                return json;
            }
            List<SysEqpTypeBean> list = null;
            InputFilesController fl = new InputFilesController();
            if ("xls".equals(bm)) {
                list = fl.readXls2003_2(url, type);
            } else if ("xlsx".equals(bm)) {
                list = fl.readXlsx2007_2(url, type);
            }
            if (list != null && list.size() > 0) {
                mdEqpTypeService.inputExeclAndReadWrite(list, etb);
                json.setMsg("导入成功!");
                json.setSuccess(true);
            }
        } catch (Exception e) {
            json.setMsg("导入失败!");
            json.setSuccess(false);
            e.printStackTrace();
        }
        return json;
    }
    
    
    
    /**##############################设备润滑#############################################################*/
    
    
    /**设备润滑查询 */
    @ResponseBody
    @RequestMapping("/queryEqmLubricationById")
    public DataGrid queryEqmLubricationById(SysEqpCategory mdTypeBean, PageParams pageParams) {
        try {
            DataGrid gd = eqmLubricantServiceI.queryEqmLubricationById(mdTypeBean, pageParams);
            return gd;
        } catch (Exception e) {
            log.error("查询异常!!!", e);
        }
        return null;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}