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
package com.shlanbao.tzsc.pms.equ.eqpMaintain.controller;
 
import java.util.Date;
import java.util.List;
 
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.google.gson.Gson;
import com.shlanbao.tzsc.base.mapping.EqmMaintain;
import com.shlanbao.tzsc.base.mapping.SysEqpCategory;
import com.shlanbao.tzsc.base.mapping.SysRole;
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.equ.eqpMaintain.bean.EqmMaintainBean;
import com.shlanbao.tzsc.pms.equ.eqpMaintain.service.EqMaintainServiceI;
import com.shlanbao.tzsc.pms.sys.datadict.service.SysEqpCategoryServiceI;
import com.shlanbao.tzsc.utils.tools.StringUtil;
/**
 * 设备维保计划控制层
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/pms/eqMaintain")
public class EqMaintainController {
    protected Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private SysEqpCategoryServiceI mdEqpCategoryService;
        
    @Autowired
    private EqMaintainServiceI eqMainService;
    
    
    
    /**
     * 设备保养计划新增
     * @param object
     * @return
     * @throws Exception
     */
    
    
    @RequestMapping("/goToAddMaintain")
    public String goToAddLubiPlan(String cateid,HttpServletRequest request)throws Exception{
        SysEqpCategory category = mdEqpCategoryService.getMdCategoryById(cateid);
        EqmMaintainBean bean = new  EqmMaintainBean();
        bean.setCategoryId(category.getId());
        bean.setCategoryName(category.getName());
        request.setAttribute("bean", bean);
        return "/pms/equ/maintain/addMaintain";
    }
        
    @ResponseBody
    @RequestMapping("/addMaintain")
    public Json addMaintain(EqmMaintain bean,String categoryId , HttpServletRequest request,HttpSession session)throws Exception{
            Json json = new Json();
            try {
                
                
                /*LoginBean loginBean = (LoginBean) session.getAttribute("loginInfo");
                if(loginBean!=null){
                    bean.setLastUpdateName(loginBean.getName());
                }*/
                SysEqpCategory scg=new SysEqpCategory();
                scg.setId(categoryId);
                bean.setSysEqpCategory(scg);
                eqMainService.addBean(bean);
                json.setMsg("操作成功!");
                json.setSuccess(true);
            } catch (Exception e) {
                e.printStackTrace();
                json.setMsg("操作失败!");
                json.setSuccess(false);
            }
            return json;
        }
    
    /**
     * 设备润滑计划修改
     * @param object
     * @return
     * @throws Exception
     */
    @RequestMapping("/goToEditMaintain")
    public String goToEditMaintain(String id,HttpServletRequest request)throws Exception{
        if(StringUtil.notNull(id)){
            EqmMaintainBean bean =eqMainService.getBeanByIds(id);
            request.setAttribute("bean", bean);
            return "/pms/equ/maintain/editMaintain";
        }else{
            return "";
        }
    }
    
 
    
    @ResponseBody
    @RequestMapping("/editMaintain")
    public Json editMaintain(EqmMaintainBean bean,HttpServletRequest request,HttpSession session)throws Exception{
        Json json = new Json();
        try {
            bean.setLastUpdateTime(new Date());
            eqMainService.updateBean(bean);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
    
    
    /**
     * 功能说明:查询角色
     *   添加保养基础数据时,选择的角色
     * @author zhouzhiqin
     * @date  2017年9月9日13:54:28
     * 
     * */
    @ResponseBody
    @RequestMapping("/getRoleAll")
    public String getRoleAll(HttpServletRequest request,HttpSession session)throws Exception{
        List<SysRole> list=eqMainService.getRoleAll();
        Gson gson=new Gson();
         String json = gson.toJson(list);
        //返回到前台
        return json;
    }
    
    
    
        
    /**设备保养查询 */
    @ResponseBody
    @RequestMapping("/queryMaintainById")
    public DataGrid queryMaintainById(SysEqpCategory mdTypeBean, PageParams pageParams) {
        try {
            DataGrid gd = eqMainService.queryMaintainById(mdTypeBean, pageParams);
            return gd;
        } catch (Exception e) {
            log.error("查询异常!!!", e);
        }
        return null;
    }    
    
    
    /**删除选中的设备保养明细 */
    @ResponseBody
    @RequestMapping("/deleteMaintain")
    public Json deleteMaintain(String id) {
        Json json = new Json();
        try {
            eqMainService.deleteMaintain(id);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error("删除数据异常。", e);
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
 
    /**
     * 批量删除选中的设备保养明细
     * @param ids
     * @return*/
    @ResponseBody
    @RequestMapping("/batchDeleteMaintain")
    public Json batchDeleteMaintain(String ids) {
        Json json = new Json();
        try {
            eqMainService.batchDeleteMaintain(ids);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error("删除数据异常。", e);
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
 
}