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
package com.shlanbao.tzsc.pms.md.eqptype.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.mapping.MdEqpType;
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.service.MdEqpCategoryServiceI;
import com.shlanbao.tzsc.pms.md.eqptype.beans.MdEqpTypeBean;
import com.shlanbao.tzsc.pms.md.eqptype.service.MdEqpTypeServiceI;
import com.shlanbao.tzsc.utils.tools.SystemConstant;
 
 
/**
 * 设备类型与型号维护
 * @author liuligong 
 * @Time 2014/11/17 9:49
 */
@Controller
@RequestMapping("/pms/md/eqptype")
public class MdEqpTypeController {
    protected Logger log = Logger.getLogger(this.getClass());
        
        @Autowired
    private MdEqpTypeServiceI mdEqpTypeService;
        @Autowired
        private MdEqpCategoryServiceI mdEqpCategoryService;
    @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/md/eqptype/addMdType";
    }
    @RequestMapping("/AddMdTypeJsp")
    public String goToMdType(String cateid,HttpServletRequest request) throws Exception{
        MdEqpCategory category= mdEqpCategoryService.getMdCategoryById(cateid);
        MdEqpTypeBean eqpTypeBean=new MdEqpTypeBean();
        eqpTypeBean.setCategoryId(category.getId());
        eqpTypeBean.setCategoryName(category.getName());
        request.setAttribute("mdEqpTypeBean",eqpTypeBean);
        return "/pms/md/eqptype/addMdType";
    }
    // 设备类型新增
    @ResponseBody
    @RequestMapping("/addMdType")
    public Json addMdType(MdEqpTypeBean 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(MdEqpTypeBean 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<MdEqpTypeBean> queryMdEqpType(){
        try {
            return mdEqpTypeService.queryMdType(null);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    @ResponseBody
    @RequestMapping("/queryMdEqpTypeByCid")
    public List<MdEqpTypeBean> queryMdEqpTypeByCid(String id,HttpServletRequest request){
        try {
            return mdEqpTypeService.queryMdType(id);
        } 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;
    }
 
    /**
     * 批量删除
     * @param ids
     * @return
     */
    @ResponseBody
    @RequestMapping("/batchDeleteMdType")
    public Json batchDeleteMdType(String ids){
        Json json = new Json();
        try {
            mdEqpTypeService.batchDeleteMdType(ids);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error("删除设备型号异常。", e);
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
 
    //获取卷烟机、包装机和成型机的机型
    @ResponseBody
    @RequestMapping("/queryMdEqpTypeByCategory")
    public List<MdEqpTypeBean> 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;
    }
}