zhuguifei
2026-03-10 2c1fd10c6fbabb8e9f0e9f07fe66fb36c008e883
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
package com.shlanbao.tzsc.pms.equ.lubricate.controller;
 
import java.util.Date;
import java.util.List;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
 
import com.shlanbao.tzsc.pms.sys.user.beans.LoginBean;
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.EqmLubricant;
import com.shlanbao.tzsc.base.mapping.EqpLubricantRecord;
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.lubricate.beans.EqmLubricantBean;
import com.shlanbao.tzsc.pms.equ.lubricate.service.EqmLubricantServiceI;
import com.shlanbao.tzsc.pms.sys.datadict.service.SysEqpCategoryServiceI;
import com.shlanbao.tzsc.utils.tools.StringUtil;
/**
 * 
* @ClassName: EqmLubricantController 
* @Description: 设备润滑周期设置
* @author luo
* @date 2015年7月8日 下午3:58:32 
*
 */
@Controller
@RequestMapping("/pms/lubrCycle")
public class EqmLubricantController {
 
    protected Logger log = Logger.getLogger(this.getClass());
    
    @Autowired
    private SysEqpCategoryServiceI mdEqpCategoryService;
    @Autowired
    public EqmLubricantServiceI eqmLubricantServiceI;
    
    /**
     * 设备润滑计划新增
     * @param cateid
     * @return
     * @throws Exception
     */
    
    
    @RequestMapping("/goToAddLubiCycle")
    public String goToAddLubiPlan(String cateid,HttpServletRequest request)throws Exception{
        SysEqpCategory category = mdEqpCategoryService.getMdCategoryById(cateid);
        EqmLubricantBean bean = new  EqmLubricantBean();
        bean.setCategoryId(category.getId());
        bean.setCategoryName(category.getName());
        request.setAttribute("bean", bean);
        return "/pms/equ/lubriplan/addLubriCycle";
        
    
    }
    
            
    
    @ResponseBody
    @RequestMapping("/addLubrCycle")
    public Json addLubrCycle(EqmLubricant 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());
            eqmLubricantServiceI.addBean(bean);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
    
    
    
    /**
     * 设备润滑计划修改
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping("/goToEditLubiCycle")
    public String goToEditLubiCycle(String id,HttpServletRequest request)throws Exception{
        if(StringUtil.notNull(id)){
            EqmLubricantBean bean=eqmLubricantServiceI.getBeanByIds(id);            
            request.setAttribute("bean", bean);
            return "/pms/equ/lubriplan/editLubriCycle";
        }else{
            return "";
        }
    }
    
 
    
    @ResponseBody
    @RequestMapping("/editLubrCycle")
    public Json editLubrplan(EqmLubricantBean bean,HttpServletRequest request,HttpSession session)throws Exception{
        Json json = new Json();
        try {
            LoginBean loginBean = (LoginBean) session.getAttribute("loginInfo");
            if(loginBean!=null){
                bean.setLastUpdateName(loginBean.getName());
            }
            bean.setLastUpdateTime(new Date());
            eqmLubricantServiceI.updateBean(bean);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
    
    
    @ResponseBody
    @RequestMapping("/queryLubrCycle")
    public DataGrid queryLubrCycle(EqmLubricantBean bean,PageParams pageParams){
        return eqmLubricantServiceI.searchBean(bean,pageParams);
    }
    
    
    /**
     * 功能说明:查询角色
     *   添加润滑基础数据时,选择的角色
     * @author wanchanghuang
     * @date  2017年8月28日14:31:21
     * 
     * */
    @ResponseBody
    @RequestMapping("/getRoleAll")
    public String getRoleAll(HttpServletRequest request,HttpSession session)throws Exception{
        List<SysRole> list=eqmLubricantServiceI.getRoleAll();
        Gson gson=new Gson();
         String json = gson.toJson(list);
        //返回到前台
        return json;
    }
    
    
    @ResponseBody
    @RequestMapping("/deleteLubrCycle")
    public Json deleteLubrCycle(String id) {
        Json json = new Json();
        try {
            eqmLubricantServiceI.deleteLubrCycle(id);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error("删除数据异常。", e);
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
    /**
     * 批量删除
     * @param ids
     * @return
     */
    @ResponseBody
    @RequestMapping("/batchDeleteLubrCycle")
    public Json batchDeleteLubrCycle(String ids) {
        Json json = new Json();
        try {
            eqmLubricantServiceI.batchDeleteLubrCycle(ids);
            json.setMsg("操作成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error("删除数据异常。", e);
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
 
 
    @ResponseBody
    @RequestMapping("/queryLubricantRec")
    public DataGrid queryFixRec(EqpLubricantRecord eqmFixRecBean,PageParams pageParams){
        try {
            DataGrid gd = eqmLubricantServiceI.queryLubricantRec(eqmFixRecBean, pageParams);
            return gd;
        } catch (Exception e) {
            log.error("查询油品消耗记录失败!", e);
        }
        return null;
    }
    
    
}