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;
|
}
|
|
|
}
|