package com.shlanbao.tzsc.pms.equ.overhaul.controller;
|
|
import java.io.File;
|
import java.io.UnsupportedEncodingException;
|
import java.text.DecimalFormat;
|
import java.text.SimpleDateFormat;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpSession;
|
|
import com.alibaba.fastjson.JSON;
|
import com.shlanbao.tzsc.base.mapping.EqpSparePartsBean;
|
import com.shlanbao.tzsc.base.mapping.SysMaintenanceStaff;
|
import com.shlanbao.tzsc.data.runtime.netty.NettyServer;
|
import com.shlanbao.tzsc.init.BaseParams;
|
import com.shlanbao.tzsc.pms.equ.sbglplan.beans.EquipmentsBean;
|
import com.shlanbao.tzsc.pms.md.shift.beans.ShiftBean;
|
import com.shlanbao.tzsc.pms.md.team.beans.TeamBean;
|
import org.jboss.netty.channel.Channel;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.MediaType;
|
import org.springframework.http.ResponseEntity;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.util.LinkedMultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import com.shlanbao.tzsc.base.controller.BaseController;
|
import com.shlanbao.tzsc.base.mapping.EqmMaintain;
|
import com.shlanbao.tzsc.base.mapping.EqpRequestRecord;
|
import com.shlanbao.tzsc.base.model.Combobox;
|
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.Tree;
|
import com.shlanbao.tzsc.pms.cos.spare.controller.InputFilesController;
|
import com.shlanbao.tzsc.pms.equ.overhaul.beans.EqmMaintainBean;
|
import com.shlanbao.tzsc.pms.equ.overhaul.service.EqmMaintainServiceI;
|
import com.shlanbao.tzsc.pms.md.FilterCount.SchFilterCountBean;
|
import com.shlanbao.tzsc.pms.sys.datadict.beans.SysEqpTypeBean;
|
import com.shlanbao.tzsc.utils.params.SysEqpTypeBase;
|
import com.shlanbao.tzsc.utils.tools.StringUtil;
|
|
/**
|
* 设备检修项目维护控制器 包括添加,编辑,删除,查询设备项目维护
|
* @author liuligong
|
*
|
*/
|
@Controller
|
@RequestMapping("/pms/overhaul")
|
public class EqmMaintainController extends BaseController{
|
@Autowired
|
protected EqmMaintainServiceI eqmMaintainService;
|
protected SysEqpTypeBase sysEqpTypeBase;
|
|
@RequestMapping("/gotoMaintain")
|
public String gotoMaintain()throws Exception{
|
return "/pms/equ/overhaul/maintain";
|
}
|
|
@RequestMapping("/gotoMaintainAdd")
|
public String gotoMaintainAdd()throws Exception{
|
return "/pms/equ/overhaul/maintainAdd";
|
}
|
|
@ResponseBody
|
@RequestMapping("/addMaintain")
|
public Json addMaintain(EqmMaintainBean eqmMaintain)throws Exception{
|
Json json = new Json();
|
try {
|
eqmMaintainService.addEqmMaintain(eqmMaintain);
|
json.setMsg("操作成功!");
|
json.setSuccess(true);
|
} catch (Exception e) {
|
e.printStackTrace();
|
json.setMsg("操作失败!");
|
json.setSuccess(false);
|
}
|
return json;
|
}
|
|
@ResponseBody
|
@RequestMapping("/deleteMaintain")
|
public Json deleteMaintain(String id)throws Exception{
|
Json json = new Json();
|
try {
|
eqmMaintainService.deleteEqmMaintainById(id);
|
json.setMsg("操作成功!");
|
json.setSuccess(true);
|
} catch (Exception e) {
|
e.printStackTrace();
|
json.setMsg("操作失败!");
|
json.setSuccess(false);
|
}
|
return json;
|
}
|
|
@RequestMapping("/gotoMaintainEdit")
|
public String gotoMaintainEdit(String id,HttpServletRequest request)throws Exception{
|
request.setAttribute("bean", eqmMaintainService.getEqmMaintainById(id));
|
return "/pms/equ/overhaul/maintainEdit";
|
}
|
@RequestMapping("/gotoMaintainEditSlove")
|
public String gotoMaintainEditSlove(String id,HttpServletRequest request)throws Exception{
|
request.setAttribute("bean", eqmMaintainService.getEqmMaintainById(id));
|
return "/pms/equ/overhaul/maintainEditSolve";
|
}
|
@ResponseBody
|
@RequestMapping("/editMaintain")
|
public Json editMaintain(EqmMaintainBean eqmMaintain)throws Exception{
|
Json json = new Json();
|
try {
|
eqmMaintainService.editEqmMaintain(eqmMaintain);
|
json.setMsg("操作成功!");
|
json.setSuccess(true);
|
} catch (Exception e) {
|
e.printStackTrace();
|
json.setMsg("操作失败!");
|
json.setSuccess(false);
|
}
|
return json;
|
}
|
@ResponseBody
|
@RequestMapping("/queryMaintain")
|
public DataGrid queryMaintain(EqmMaintainBean eqmMaintain,PageParams pageParams)throws Exception{
|
try {
|
DataGrid gd = eqmMaintainService.queryEqmMaintain(eqmMaintain, pageParams);
|
return gd;
|
} catch (Exception e) {
|
log.error("查询设备检修项目数据异常。", e);
|
}
|
return null;
|
}
|
/**
|
* 导入excel
|
* @param file
|
* @param request
|
* @return
|
*/
|
@RequestMapping("/inputExeclAndReadWrite")
|
@ResponseBody
|
public Json inputExeclAndReadWrite(@RequestParam(value = "importFile", required = false)
|
MultipartFile file,HttpServletRequest request) {
|
Json json = new Json();
|
try {
|
String path = request.getSession().getServletContext().getRealPath("upload");
|
String fileName = file.getOriginalFilename();
|
File targetFile = new File(path, fileName);
|
if (!targetFile.exists()) {
|
targetFile.mkdirs();
|
}
|
file.transferTo(targetFile);
|
String url = path + "/" + fileName;
|
String bm=fileName.substring( (fileName.lastIndexOf(".")+1) ,fileName.length());
|
List<EqmMaintainBean> list =null;
|
InputFilesController fl=new InputFilesController();
|
if("xls".equals(bm)){
|
list=fl.readXls2003_3(url);
|
}else if("xlsx".equals(bm)){
|
list=fl.readXlsx2007_3(url);
|
}
|
if(list!=null&&list.size()>0){
|
eqmMaintainService.inputExeclAndReadWrite(list);
|
json.setMsg("导入成功!");
|
json.setSuccess(true);
|
}
|
} catch (Exception e) {
|
json.setMsg("导入失败!");
|
json.setSuccess(false);
|
e.printStackTrace();
|
}
|
return json;
|
}
|
/**
|
* 更新备件的数量信息
|
*
|
*/
|
@RequestMapping("/updateSpareParts")
|
@ResponseBody
|
public void updateSpareParts(String all_id,String use_n,String all_num){
|
eqmMaintainService.updateSpareParts(all_id, use_n,all_num);
|
}
|
|
//润滑部位下拉框
|
@RequestMapping("/combobox")
|
@ResponseBody
|
public List<Combobox> combobox(String equipmentId){
|
Map<String, String> retMap;
|
Object o[] = code(equipmentId);
|
String code=o[0].toString();
|
String name=o[1].toString();
|
try {
|
retMap = sysEqpTypeBase.getDJBoxRoleAlls(code,name);
|
List<Combobox> combox = new ArrayList<Combobox>();
|
for (Map.Entry<String, String> entry : retMap.entrySet()) {
|
Combobox box = new Combobox();
|
box.setId(entry.getValue());
|
box.setName(entry.getKey());
|
System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
|
combox.add(box);
|
}
|
return combox;
|
//String jsonf=JSONArray.fromObject(retMap).toString();
|
} catch (UnsupportedEncodingException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
//根据设备ID查询code和设备NAME
|
@RequestMapping("/code")
|
@ResponseBody
|
public Object[] code(String equipmentId){
|
return eqmMaintainService.loadToRhBuWeiCode(equipmentId);
|
}
|
|
/**
|
* @param stim
|
* @param etim
|
* @param pageParams
|
* @return
|
* @throws Exception
|
* 查询设备维修呼叫记录
|
*/
|
@ResponseBody
|
@RequestMapping("/queryRepairCallInfo")
|
public DataGrid queryRepairCallInfo(String stim,String etim,PageParams pageParams)throws Exception{
|
try {
|
DataGrid gd = eqmMaintainService.queryRepairCallInfo(stim,etim, pageParams);
|
return gd;
|
} catch (Exception e) {
|
e.printStackTrace();
|
log.error("查询设备维修呼叫记录异常。", e);
|
}
|
return null;
|
}
|
/**
|
* 查询维修呼叫中备品备件更换记录
|
* @return
|
* @throws Exception
|
*/
|
@ResponseBody
|
@RequestMapping("/queryRepairChangeSparepartInfo")
|
public DataGrid queryRepairChangeSparepartInfo(String id)throws Exception{
|
try {
|
DataGrid gd = eqmMaintainService.queryRepairChangeSparepartInfo(id);
|
return gd;
|
} catch (Exception e) {
|
log.error("查询设备维修呼叫记录异常。", e);
|
}
|
return null;
|
}
|
|
/**
|
* 维修记录反馈
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/dasSendEquipmentWorkOrderResult")
|
public Json sendMsg(String id){
|
Json json=new Json();
|
try {
|
RestTemplate client = new RestTemplate();
|
String url = "http://"+ BaseParams.LOCALADRESS+":8080/GF_LBDWS/wct/eqpMainCall/sendRepairRecordMsg.json";
|
HttpHeaders headers = new HttpHeaders();
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
MultiValueMap<String,String> map = new LinkedMultiValueMap<>();
|
map.add("id",id);
|
map.add("sts","1");
|
HttpEntity<MultiValueMap<String,String>> request = new HttpEntity<>(map,headers);
|
ResponseEntity<Json> res = client.postForEntity(url,request,Json.class);
|
|
Json resJson = res.getBody();
|
if (!resJson.isSuccess()){
|
throw new RuntimeException(resJson.getMsg());
|
}
|
json.setSuccess(true);
|
json.setMsg("反馈成功!");
|
} catch (Exception e) {
|
json.setMsg("反馈失败!");
|
}
|
return json;
|
}
|
|
/**
|
* 受理维修请求
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/acceptRequest")
|
public Json acceptRequest(String id){
|
return eqmMaintainService.acceptRequest(id);
|
}
|
/**
|
* 结束维修请求
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/finishRequest")
|
public Json finishRequest(String id){
|
return eqmMaintainService.finishRequest(id);
|
}
|
|
/**
|
* 初始化故障数
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/loadTroubleTree")
|
public List<Tree> loadTroubleTree(String id){
|
return eqmMaintainService.loadTroubleTree(id);
|
}
|
|
/**
|
* 添加故障信息
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/addTroubleInfo")
|
public Json addTroubleInfo(String id,String mesId,String nodeId){
|
return eqmMaintainService.addTroubleInfo(id,mesId,nodeId);
|
}
|
|
|
/**
|
* 添加故障数接点
|
* @param id
|
* @param text
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/addTroubleTreeNode")
|
public Json addTroubleTreeNode(String id,String text){
|
return eqmMaintainService.addTroubleTreeNode(id,text);
|
}
|
|
/**
|
* 编辑当前故障树节点
|
* @param id
|
* @param text
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/editTroubleTreeNode")
|
public Json editTroubleTreeNode(String id,String text){
|
return eqmMaintainService.editTroubleTreeNode(id,text);
|
}
|
|
/**
|
* 删除节点
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/deleteTroubleTreeNode")
|
public Json deleteTroubleTreeNode(String id){
|
return eqmMaintainService.deleteTroubleTreeNode(id);
|
}
|
|
/**
|
* 跳转到故障树编辑页面
|
*/
|
@RequestMapping("/goToEditTroubleTreeNodeJSP")
|
public String goToEditTroubleTreeNodeJSP(String id,HttpServletRequest request){
|
String txt=eqmMaintainService.goToEditTroubleTreeNodeJSP(id);
|
request.setAttribute("text", txt);
|
return "/pms/equ/trouble/addTroubleTreeNode";
|
}
|
|
/**
|
* 查询备品备件
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/chooseSparePart")
|
public DataGrid chooseSparePart(String desc,PageParams pageParam){
|
return eqmMaintainService.chooseSparePart(desc,pageParam);
|
}
|
|
@ResponseBody
|
@RequestMapping("/saveChooseSparePart")
|
public Json saveChooseSparePart(String callId,String id,String num){
|
return eqmMaintainService.saveChooseSparePart(callId,id,StringUtil.convert2Float(num));
|
}
|
|
@RequestMapping("/goToEditJsp")
|
public String goToEditJsp(HttpServletRequest request,String id){
|
try {
|
EqpRequestRecord record = eqmMaintainService.getCallInfoById(id);
|
request.setAttribute("callInfo",record);
|
} catch (Exception e) {
|
log.error("获取ID:"+id+"的数据失败", e);
|
}
|
return "/pms/equ/trouble/edit";
|
}
|
@ResponseBody
|
@RequestMapping("/editCallInfo")
|
public Json editCallInfo(EqpRequestRecord requestRecord){
|
Json json=new Json();
|
try {
|
eqmMaintainService.editCallInfo(requestRecord);
|
json.setMsg("编辑成功!");
|
json.setSuccess(true);
|
} catch (Exception e) {
|
log.error(message, e);
|
json.setMsg("编辑失败!");
|
}
|
return json;
|
}
|
@ResponseBody
|
@RequestMapping("/addSparePart")
|
public Json addSparePart(EqpSparePartsBean sparePartsBean){
|
Json json=new Json();
|
try {
|
eqmMaintainService.addSparePart(sparePartsBean);
|
json.setMsg("添加成功!");
|
json.setSuccess(true);
|
} catch (Exception e) {
|
log.error(message, e);
|
json.setMsg("添加失败!");
|
}
|
return json;
|
}
|
|
|
@ResponseBody
|
@RequestMapping("/editCallInfos")
|
public Json editCallInfos(EqpRequestRecord requestRecord){
|
//System.out.println(requestRecords);
|
Json json=new Json();
|
try {
|
//for(EqpRequestRecord requestRecord : requestRecords){
|
eqmMaintainService.editCallInfo(requestRecord);
|
//}
|
|
json.setMsg("编辑成功!");
|
json.setSuccess(true);
|
} catch (Exception e) {
|
log.error(message, e);
|
json.setMsg("编辑失败!");
|
}
|
return json;
|
}
|
|
@RequestMapping("/goToAddRepairCall")
|
public String goToAddRepairCall(){
|
return "/pms/equ/overhaul/addRepairCall";
|
}
|
|
/**
|
* 获得所有班次
|
*/
|
@ResponseBody
|
@RequestMapping("/getAllShifts")
|
public List<ShiftBean> getAllShifts(){
|
try {
|
return eqmMaintainService.getAllShifts();
|
} catch (Exception e) {
|
log.error("查询所有班次异常", e);
|
}
|
return null;
|
}
|
|
/**
|
* 获得所有班组
|
*/
|
@ResponseBody
|
@RequestMapping("/getAllTeams")
|
public List<TeamBean> getAllTeams(){
|
try {
|
return eqmMaintainService.getAllTeams();
|
} catch (Exception e) {
|
log.error("查询所有班组异常", e);
|
}
|
return null;
|
}
|
|
/**
|
* 获得所有设备
|
*/
|
@ResponseBody
|
@RequestMapping("/getAllEqus")
|
public List<EquipmentsBean> getAllEqus(){
|
try {
|
return eqmMaintainService.getAllEqus();
|
} catch (Exception e) {
|
log.error("查询所有设备异常", e);
|
}
|
return null;
|
}
|
|
/**
|
* 获得所有维修工
|
*/
|
@ResponseBody
|
@RequestMapping("/getAllStaff")
|
public /*List<SysMaintenanceStaff>*/ Json getAllStaff(@RequestParam("eqpName") String eqpName){
|
Json json = new Json();
|
try {
|
List<SysMaintenanceStaff> allStaff = eqmMaintainService.getAllStaff(eqpName);
|
json.setSuccess(true);
|
json.setObj(allStaff);
|
} catch (Exception e) {
|
log.error("查询所有维修工异常", e);
|
json.setMsg(e.getMessage());
|
}
|
return json;
|
}
|
|
/**
|
* @Description: 获得该故障详细类型的所有故障描述(故障描述按照出现次数倒叙排列)
|
* @Param: [faultTypeDetail 故障详细类型]
|
* @return: java.lang.String
|
* @Author: sunzhen
|
* @Date: 2019/10/29
|
*/
|
@ResponseBody
|
@RequestMapping("/getDescription")
|
public String getDescription(@RequestParam("faultTypeDetail") String faultTypeDetail){
|
try {
|
String descriptions = eqmMaintainService.getDescription(faultTypeDetail);
|
return descriptions;
|
} catch (Exception e) {
|
log.error("故障描述获取异常", e);
|
}
|
return null;
|
}
|
|
/**
|
* 新增维修呼叫记录
|
* @author sunzhen
|
* @create 2019年9月26日上午9:19:48
|
* @param eqpRequestRecord
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/addRepairCall")
|
public Json addRepairCall(EqpRequestRecord eqpRequestRecord){
|
Json json = new Json();
|
try {
|
eqmMaintainService.addRepairCall(eqpRequestRecord);
|
json.setSuccess(true);
|
json.setMsg("操作成功!");
|
/* //利用netty远程调用wct系统的维修呼叫推送(写在控制层是防止hibernate保存在缓存,wct那边查询不到该条记录)
|
NettyServer nettyServer=NettyServer.getInstance();
|
Channel nettyChannel = nettyServer.getNettyChannel();
|
Map<String, String> map = new HashMap<>();
|
map.put("pushMaintenanceCall",eqpRequestRecord.getId());
|
String str = JSON.toJSONString(map);
|
if(null==nettyChannel){
|
json.setMsg("推送异常,Netty的连接为空");
|
}else{
|
nettyChannel.write(str);
|
}*/
|
RestTemplate client = new RestTemplate();
|
String url = "http://"+ BaseParams.LOCALADRESS+":8080/GF_LBDWS/wct/eqpMainCall/pushMaintenanceCall.json";
|
HttpHeaders headers = new HttpHeaders();
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
MultiValueMap<String,String> map = new LinkedMultiValueMap<>();
|
map.add("id",eqpRequestRecord.getId());
|
HttpEntity<MultiValueMap<String,String>> request = new HttpEntity<>(map,headers);
|
ResponseEntity<Json> res = client.postForEntity(url,request,Json.class);
|
|
Json resJson = res.getBody();
|
if (!json.isSuccess()){
|
throw new RuntimeException(resJson.getMsg());
|
}
|
|
} catch (Exception e) {
|
log.error("新增维修呼叫记录失败", e);
|
json.setMsg(e.getMessage());
|
}
|
return json;
|
}
|
|
/**
|
* 删除维修呼叫记录
|
* @author sunzhen
|
* @create 2019年9月26日上午21:58:48
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/deleteRepairCall")
|
public Json deleteRepairCall(String id){
|
Json json = new Json();
|
try {
|
eqmMaintainService.deleteRepairCall(id);
|
json.setSuccess(true);
|
json.setMsg("操作成功!");
|
/* //利用netty远程调用wct系统的维修呼叫推送
|
NettyServer nettyServer=NettyServer.getInstance();
|
Channel nettyChannel = nettyServer.getNettyChannel();
|
Map<String, String> map = new HashMap<>();
|
map.put("refresh","refresh");
|
String str = JSON.toJSONString(map);
|
if(null==nettyChannel){
|
json.setMsg("推送异常,Netty的连接为空");
|
}else{
|
nettyChannel.write(str);
|
}*/
|
|
RestTemplate client = new RestTemplate();
|
String url = "http://"+ BaseParams.LOCALADRESS+":8080/GF_LBDWS/wct/eqpMainCall/refreshMaintenanceCall.json";
|
HttpHeaders headers = new HttpHeaders();
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
MultiValueMap<String,String> map = new LinkedMultiValueMap<>();
|
HttpEntity<MultiValueMap<String,String>> request = new HttpEntity<>(map,headers);
|
ResponseEntity<Json> res = client.postForEntity(url,request,Json.class);
|
|
Json resJson = res.getBody();
|
if (!json.isSuccess()){
|
throw new RuntimeException(resJson.getMsg());
|
}
|
} catch (Exception e) {
|
log.error("删除维修呼叫记录失败", e);
|
json.setMsg("删除维修呼叫记录失败");
|
}
|
return json;
|
}
|
|
/**
|
* 批量删除维修呼叫记录
|
* @author sunzhen
|
* @create 2019年9月26日上午21:58:48
|
* @param ids
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/beatchDeleteRepairCall")
|
public Json beatchDeleteRepairCall(String ids){
|
Json json = new Json();
|
try {
|
eqmMaintainService.beatchDeleteRepairCall(ids);
|
json.setSuccess(true);
|
json.setMsg("操作成功!");
|
/*//利用netty远程调用wct系统的维修呼叫推送
|
NettyServer nettyServer=NettyServer.getInstance();
|
Channel nettyChannel = nettyServer.getNettyChannel();
|
Map<String, String> map = new HashMap<>();
|
map.put("refresh","refresh");
|
String str = JSON.toJSONString(map);
|
if(null==nettyChannel){
|
json.setMsg("推送异常,Netty的连接为空");
|
}else{
|
nettyChannel.write(str);
|
}*/
|
RestTemplate client = new RestTemplate();
|
String url = "http://"+ BaseParams.LOCALADRESS+":8080/GF_LBDWS/wct/eqpMainCall/refreshMaintenanceCall.json";
|
HttpHeaders headers = new HttpHeaders();
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
MultiValueMap<String,String> map = new LinkedMultiValueMap<>();
|
HttpEntity<MultiValueMap<String,String>> request = new HttpEntity<>(map,headers);
|
ResponseEntity<Json> res = client.postForEntity(url,request,Json.class);
|
|
Json resJson = res.getBody();
|
if (!resJson.isSuccess()){
|
throw new RuntimeException(resJson.getMsg());
|
}
|
} catch (Exception e) {
|
log.error("批量删除维修呼叫记录失败", e);
|
json.setMsg(e.getMessage());
|
}
|
return json;
|
}
|
|
}
|