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
package com.shlanbao.tzsc.pms.equ.eqpInspection.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.EqmInspection;
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.eqpInspection.bean.EqmInspectionBean;
import com.shlanbao.tzsc.pms.equ.eqpInspection.service.EqmInspectionServiceI;
import com.shlanbao.tzsc.pms.sys.datadict.service.SysEqpCategoryServiceI;
import com.shlanbao.tzsc.utils.tools.StringUtil;
/**
 * 设备计划控制层
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/pms/eqmInspection")
public class EqmInspectionController {
    protected Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private SysEqpCategoryServiceI mdEqpCategoryService;
        
    @Autowired
    //private EqMaintainServiceI eqMainService;
    
    private EqmInspectionServiceI eqInsService;
    
    /**
     * 设备保养计划新增
     * @param object
     * @return
     * @throws Exception
     */
    
    
    @RequestMapping("/goToAddInspection")
    public String goToAddInspection(String cateid,HttpServletRequest request)throws Exception{
        SysEqpCategory category = mdEqpCategoryService.getMdCategoryById(cateid);
        EqmInspectionBean bean =new EqmInspectionBean();
        bean.setCategoryId(category.getId());
        bean.setCategoryName(category.getName());
        request.setAttribute("bean", bean);
        return "/pms/equ/inspection/addInspection";
    }
        
    @ResponseBody
    @RequestMapping("/addInspection")
    public Json addInspection(EqmInspection 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);
                bean.setCreateTime(new Date());
                bean.setLastUpdateTime(new Date());
                eqInsService.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("/goToEditInspection")
    public String goToEditInspection(String id,HttpServletRequest request)throws Exception{
        if(StringUtil.notNull(id)){
            EqmInspectionBean bean =eqInsService.getBeanByIds(id);
            request.setAttribute("bean", bean);
            return "/pms/equ/inspection/editInspection";
        }else{
            return "";
        }
    }
    
 
    
    @ResponseBody
    @RequestMapping("/editInspection")
    public Json editInspection(EqmInspectionBean bean,HttpServletRequest request,HttpSession session)throws Exception{
        Json json = new Json();
        try {
            bean.setLastUpdateTime(new Date());
            eqInsService.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=eqInsService.getRoleAll();
        Gson gson=new Gson();
         String json = gson.toJson(list);
        //返回到前台
        return json;
    }
    
    
    
        
    /**设备保养查询 */
    @ResponseBody
    @RequestMapping("/queryInspectionById")
    public DataGrid queryInspectionById(SysEqpCategory mdTypeBean, PageParams pageParams) {
        try {
            DataGrid gd = eqInsService.queryInspectionById(mdTypeBean, pageParams);
            return gd;
        } catch (Exception e) {
            log.error("查询异常!!!", e);
        }
        return null;
    }    
    
    
    /**删除选中的设备保养明细 */
    @ResponseBody
    @RequestMapping("/deleteInspection")
    public Json deleteInspection(String id) {
        Json json = new Json();
        try {
            eqInsService.deleteInspection(id);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error("删除数据异常。", e);
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
    /**
     * 批量删除点击数据字典二级数据
     * @param ids
     * @return
     */
    @ResponseBody
    @RequestMapping("/batchDeleteInspection")
    public Json batchDeleteInspection(String ids) {
        Json json = new Json();
        try {
            eqInsService.batchDeleteInspection(ids);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error("删除数据异常。", e);
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
        
    
    }