package com.shlanbao.tzsc.pms.qm.self.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import com.shlanbao.tzsc.base.mapping.QmOutward;
import com.shlanbao.tzsc.utils.tools.LogAnno;
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.alibaba.fastjson.JSON;
import com.shlanbao.tzsc.base.controller.BaseController;
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.base.model.SessionInfo;
import com.shlanbao.tzsc.pms.qm.self.beans.QmAppearanceDataBean;
import com.shlanbao.tzsc.pms.qm.self.beans.QmOutWandBean;
import com.shlanbao.tzsc.pms.qm.self.beans.QmSelfCheckStripBean;
import com.shlanbao.tzsc.pms.qm.self.service.QmOutWandService;
import com.shlanbao.tzsc.pms.qm.self.service.QmSelfCheckStripService;
import com.shlanbao.tzsc.utils.tools.StringUtil;
import com.shlanbao.tzsc.utils.tools.WebContextUtil;
/**
* 外观质量检验记录控制器
*
@author luther.zhang
* @create 2015-01-05
*/
@Controller
@RequestMapping("/pms/selfCheckStrip")
public class QmSelfCheckStripController extends BaseController{
@Autowired
private QmSelfCheckStripService service;
@Autowired
private QmOutWandService qmWardService;
/** 查询*/
@ResponseBody
@RequestMapping("/getList")
public DataGrid getList(QmSelfCheckStripBean bean,PageParams pageParams){
try {
DataGrid grid = service.queryList(bean,pageParams);
return grid;
} catch (Exception e) {
log.error(message, e);
}
return null;
}
/**
* 查询外观检测记录
* @param bean
* @param pageParams
* @return
*/
@ResponseBody
@RequestMapping("/getOutWandList")
public DataGrid getOutWandList(HttpSession session, QmOutWandBean bean,PageParams pageParams){
try {
/**
* sts: 0 质检员数据
* sts:1 班长数据
* sts:2 已反馈MES数据
*
* 班长可以看到所有用户数据
* 质检员只能看到自己数据
* */
SessionInfo loginBean = (SessionInfo) session.getAttribute("sessionInfo");
if(StringUtil.notEmpty(bean.getSts())){ // sts 不为空 表示外观巡检查询
if("0".equals(bean.getSts()) && !"1".equals(loginBean.getUser().getId())){
//通过登录用户ID过滤
if(loginBean!=null){
bean.setUid(loginBean.getUser().getId());
DataGrid grid = qmWardService.queryList(bean,pageParams);
return grid;
}
}else{
bean.setSts(null);
//无需过滤
DataGrid grid = qmWardService.queryList(bean,pageParams);
return grid;
}
}else{
//表示查询外观自检查询
DataGrid grid = qmWardService.queryList(bean,pageParams);
return grid;
}
} catch (Exception e) {
log.error(message, e);
}
return null;
}
/**
* 删除自检数据
* @author sunzhen
*
*/
@ResponseBody
@RequestMapping("/deleteOutWand")
public Json deleteOutWand(String id,HttpServletRequest request){
Json json=new Json();
try {
String result = qmWardService.deleteOutWand(id,request);
json.setSuccess(true);
json.setMsg(result);
} catch (Exception e) {
json.setMsg(message);
}
return json;
}
/**
* 批量删除自检数据
* @author sunzhen
*
*/
@ResponseBody
@RequestMapping("/beatchDeleteOutWand")
public Json beatchDeleteOutWand(String id,HttpServletRequest request){
Json json=new Json();
try {
String result = qmWardService.beatchDeleteOutWand(id,request);
json.setSuccess(true);
json.setMsg(result);
} catch (Exception e) {
json.setMsg(message);
}
return json;
}
/**
* 外观巡检 修改状态
*
* 反馈班长:修改状态1
* 班长回退:修改状态0
* @param ids
* @param sts
* @return
*/
@ResponseBody
@RequestMapping("/updateQmOutWardByIds")
public Json updateQmOutWardByIds(String ids,String sts){
Json json=new Json();
try {
qmWardService.updateQmOutWardByIds(ids,sts);
json.setSuccess(true);
json.setMsg("反馈成功!");
} catch (Exception e) {
json.setMsg("反馈失败!!!");
}
return json;
}
/**
* 查询详细
* @param id
* @return
*/
@ResponseBody
@RequestMapping("/getOutWandDelList")
public List getOutWandList(String id){
try {
return qmWardService.queryDel(id);
} catch (Exception e) {
log.error(message, e);
}
return null;
}
/**
* 反馈物理外观缺陷
* @param id
* @return
* shisihai
*/
@ResponseBody
@RequestMapping("/sendMsg")
public Json outWardResult(String id,String param){
Json json=new Json();
try {
qmWardService.sendMsg(id,param);
json.setSuccess(true);
json.setMsg("反馈MES成功!");
} catch (Exception e) {
json.setMsg(message);
}
return json;
}
/**
* 跳转外观质量数据添加界面
*
* Rengj
*/
@RequestMapping("/goToAddQualityDateJsp")
public String goToAddFixUserJsp(String temp){
if("bz".equals(temp)){
return "/pms/quality/self/qualityDateBzAdd";
}else if("jy".equals(temp)){
return "/pms/quality/self/qualityDateJyAdd";
}else if("xz".equals(temp)){
return "/pms/quality/self/qualityDateXzAdd";
}else{
return "/pms/quality/self/qualityDateCxAdd";
}
}
/**
* 根据机台及时间查询工单信息
* Rengj
*/
@ResponseBody
@RequestMapping("/queryOrderNumber")
public String queryOrderNumber(String eqp,HttpServletRequest request){
try {
//Json json=new Json();
List list;
SessionInfo info = (SessionInfo) WebContextUtil.getSessionValue(request.getSession(), WebContextUtil.SESSION_INFO);//用户信息
if(info!=null){
list = qmWardService.queryOrderNumber(eqp,info,request);
return JSON.toJSONString(list);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 跳转缺陷类型添加界面
*
* Rengj
*/
@RequestMapping("/bzDefectItems")
public String bzDefectItems(){
return "/pms/quality/self/bzDefectItems";
}
/**
* 跳转缺陷类型添加界面
*
* Rengj
*/
@RequestMapping("/xzDefectItems")
public String xzDefectItems(){
return "/pms/quality/self/xzDefectItems";
}
/**
* 跳转缺陷类型添加界面
*
* Rengj
*/
@RequestMapping("/jyDefectItems")
public String jyDefectItems(){
return "/pms/quality/self/jyDefectItems";
}
/**
* 跳转缺陷类型添加界面
*
* Rengj
*/
@RequestMapping("/cxDefectItems")
public String cxDefectItems(){
return "/pms/quality/self/cxDefectItems";
}
/**
* 保存缺陷
*
* Rengj
*/
@ResponseBody
@RequestMapping("/saveOutWandDes")
public Json saveOutWandDes(QmAppearanceDataBean bean, HttpServletRequest request){
Json json=new Json();
try {
qmWardService.saveOutWandDes(bean,request);
json.setSuccess(true);
json.setMsg("保存成功");
} catch (Exception e) {
log.error(message, e);
}
return json;
}
/**
* 查询缺陷
* Rengj
*/
@ResponseBody
@RequestMapping("/getOutWandDesList")
public DataGrid getOutWandDesList(QmOutWandBean bean, HttpServletRequest request,PageParams pageParams){
try {
return qmWardService.queryOutWandDes(bean, request, pageParams);
} catch (Exception e) {
log.error(message, e);
}
return null;
}
/**
* 跳转更改缺陷检测时间界面
*
* Rengj
*/
@RequestMapping("/goToEditCheckTime")
public String goToEditCheckTime(String ids,HttpServletRequest request){
request.getSession().setAttribute("selfIds", ids);
return "/pms/quality/self/checkTimeEdit";
}
/**
* 跳转编辑
* @param id
* @param request
* @return
*/
@RequestMapping("/goToEdit")
public String goToEdit(String id,HttpServletRequest request){
QmOutWandBean qmOutward = qmWardService.queryById(id);
request.setAttribute("qmOutward", qmOutward);
return "/pms/quality/self/patrolCheckEdit";
}
/**
* 编辑
* @return
*/
@ResponseBody
@RequestMapping("/edit")
public Json edit(QmOutWandBean qmOutWandBean,HttpServletRequest request){
String result ="";
Json json = new Json();
try {
result = qmWardService.edit(qmOutWandBean);
json.setSuccess(true);
json.setMsg(result);
} catch (Exception e) {
log.error("外观缺陷过品管巡检", e);
json.setMsg(result);
}
return json;
}
/**
* 保存修改检测时间
* @author Rengj
* @return
*/
@ResponseBody
@RequestMapping("/addCheckTime")
public Json addCheckTime(String stim,String etim,HttpServletRequest request){
String result ="";
Json json = new Json();
try {
String ids= String.valueOf(request.getSession().getAttribute("selfIds"));
result = qmWardService.updateCheckTimes(stim, ids);
json.setSuccess(true);
json.setMsg(result);
request.getSession().removeAttribute("selfIds");
} catch (Exception e) {
log.error("修改运行时间", e);
json.setMsg(result);
}
return json;
}
}