332 lines
13 KiB
Java
332 lines
13 KiB
Java
|
|
package com.sipai.controller.command;
|
||
|
|
|
||
|
|
import com.github.pagehelper.PageHelper;
|
||
|
|
import com.github.pagehelper.PageInfo;
|
||
|
|
import com.sipai.entity.command.EmergencyConfigure;
|
||
|
|
import com.sipai.entity.command.EmergencyConfigureInfo;
|
||
|
|
import com.sipai.entity.command.EmergencyConfigureWorkOrder;
|
||
|
|
import com.sipai.entity.user.User;
|
||
|
|
import com.sipai.service.command.EmergencyConfigureInfoService;
|
||
|
|
import com.sipai.service.command.EmergencyConfigureService;
|
||
|
|
import com.sipai.service.command.EmergencyConfigureWorkOrderService;
|
||
|
|
import com.sipai.tools.CommUtil;
|
||
|
|
import net.sf.json.JSONArray;
|
||
|
|
import net.sf.json.JSONObject;
|
||
|
|
import org.springframework.stereotype.Controller;
|
||
|
|
import org.springframework.ui.Model;
|
||
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
||
|
|
import org.springframework.web.servlet.ModelAndView;
|
||
|
|
|
||
|
|
import javax.annotation.Resource;
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
import java.io.BufferedReader;
|
||
|
|
import java.io.IOException;
|
||
|
|
import java.io.InputStreamReader;
|
||
|
|
import java.io.UnsupportedEncodingException;
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
|
||
|
|
@Controller
|
||
|
|
@RequestMapping("/command/emergencyConfigure")
|
||
|
|
public class EmergencyConfigureInfoController {
|
||
|
|
@Resource
|
||
|
|
private EmergencyConfigureInfoService emergencyConfigureInfoService;
|
||
|
|
@Resource
|
||
|
|
private EmergencyConfigureService emergencyConfigureService;
|
||
|
|
@Resource
|
||
|
|
private EmergencyConfigureWorkOrderService emergencyConfigureWorkOrderService;
|
||
|
|
|
||
|
|
@RequestMapping("/getFuncJson.do")
|
||
|
|
public String getFuncJson(HttpServletRequest request,Model model,
|
||
|
|
@RequestParam(value = "id") String id,
|
||
|
|
@RequestParam(value = "page") Integer page,
|
||
|
|
@RequestParam(value = "rows") Integer rows,
|
||
|
|
@RequestParam(value = "sort", required = false) String sort,
|
||
|
|
@RequestParam(value = "order", required = false) String order){
|
||
|
|
PageHelper.startPage(page, rows);
|
||
|
|
List<EmergencyConfigureInfo> list = this.emergencyConfigureInfoService.selectcountByWhere("where m.pid='"+id+"' order by m.ord");
|
||
|
|
PageInfo<EmergencyConfigureInfo> pInfo = new PageInfo<EmergencyConfigureInfo>(list);
|
||
|
|
JSONArray jsonArray = JSONArray.fromObject(list);
|
||
|
|
if(list.size()==0){
|
||
|
|
List<EmergencyConfigureInfo> list1 = this.emergencyConfigureInfoService.selectListByWhere("where pid='"+id+"' order by ord");
|
||
|
|
jsonArray = JSONArray.fromObject(list1);
|
||
|
|
}
|
||
|
|
List<EmergencyConfigureWorkOrder> list2 = this.emergencyConfigureWorkOrderService.selectListByWhere("where nodeid='"+id+"'");
|
||
|
|
|
||
|
|
String result = "{\"total\":"+pInfo.getTotal()+",\"rows\":"+jsonArray+",\"size\":"+list2.size()+"}";
|
||
|
|
model.addAttribute("result", result);
|
||
|
|
return "result";
|
||
|
|
// String result="{\"total\":"+list.size()+",\"rows\":"+json+",\"size\":"+list2.size()+"}";
|
||
|
|
// model.addAttribute("result", result);
|
||
|
|
//
|
||
|
|
// return "result";
|
||
|
|
}
|
||
|
|
@RequestMapping("/getInfoJson.do")
|
||
|
|
public ModelAndView getInfoJson(HttpServletRequest request,Model model,
|
||
|
|
@RequestParam(value = "id") String id){
|
||
|
|
List<EmergencyConfigureInfo> list1 = this.emergencyConfigureInfoService.selectListByWhere("where pid='"+id+"' order by ord");
|
||
|
|
JSONArray jsonArray = JSONArray.fromObject(list1);
|
||
|
|
model.addAttribute("result", jsonArray);
|
||
|
|
return new ModelAndView("result");
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 北控版本
|
||
|
|
* @param request
|
||
|
|
* @param model
|
||
|
|
* @param pid
|
||
|
|
* @param unitId
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@RequestMapping("/showFuncAdd.do")
|
||
|
|
public ModelAndView doFuncAdd(HttpServletRequest request,Model model,
|
||
|
|
@RequestParam(value="pid") String pid,
|
||
|
|
@RequestParam(value="unitId") String unitId){
|
||
|
|
if(pid!=null && !pid.equals("")){
|
||
|
|
//检查是否有步骤
|
||
|
|
List<EmergencyConfigure> list = emergencyConfigureService.selectListByWhere("where pid='"+pid+"' and type = '"+EmergencyConfigure.Type_Step+"' ");
|
||
|
|
if(list!=null && list.size()>0){
|
||
|
|
int result = 2;
|
||
|
|
model.addAttribute("result", result);
|
||
|
|
return new ModelAndView("result");
|
||
|
|
}
|
||
|
|
//System.out.println("pid:::"+pid);
|
||
|
|
/*model.addAttribute("_pname",emergencyConfigureInfo.getName());*/
|
||
|
|
}
|
||
|
|
model.addAttribute("id",request.getParameter("id"));
|
||
|
|
model.addAttribute("pid",pid);
|
||
|
|
model.addAttribute("bizid",unitId);
|
||
|
|
return new ModelAndView("command/menuFuncAdd");
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 流程图版本
|
||
|
|
* @param request
|
||
|
|
* @param model
|
||
|
|
* @param emergencyConfigureId
|
||
|
|
* @param unitId
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@RequestMapping("/showLogicFlowAdd.do")
|
||
|
|
public ModelAndView showLogicFlowAdd(HttpServletRequest request,Model model,
|
||
|
|
@RequestParam(value="emergencyConfigureId") String emergencyConfigureId,
|
||
|
|
@RequestParam(value="unitId") String unitId){
|
||
|
|
model.addAttribute("emergencyConfigureId",emergencyConfigureId);
|
||
|
|
model.addAttribute("bizid",unitId);
|
||
|
|
return new ModelAndView("command/emergencyConfigureLogicFlowAdd");
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 南市版本
|
||
|
|
* @param request
|
||
|
|
* @param model
|
||
|
|
* @param pid
|
||
|
|
* @param unitId
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@RequestMapping("/showFuncAdd4NS.do")
|
||
|
|
public String showFuncAdd4NS(HttpServletRequest request,Model model,
|
||
|
|
@RequestParam(value="pid") String pid,
|
||
|
|
@RequestParam(value="unitId") String unitId){
|
||
|
|
if(pid!=null && !pid.equals("")){
|
||
|
|
model.addAttribute("pid",pid);
|
||
|
|
}
|
||
|
|
model.addAttribute("bizid",unitId);
|
||
|
|
return "command/menuFuncAdd4NS";
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("/showFuncEdit.do")
|
||
|
|
public String doFuncEdit(HttpServletRequest request,Model model,
|
||
|
|
@RequestParam(value="pid") String pid,
|
||
|
|
@RequestParam(value="id") String id,
|
||
|
|
@RequestParam(value="unitId") String unitId){
|
||
|
|
EmergencyConfigureInfo emergencyConfigureInfo= emergencyConfigureInfoService.getMenuById(id);
|
||
|
|
model.addAttribute("emergencyConfigureInfo",emergencyConfigureInfo );
|
||
|
|
if(pid!=null && !pid.equals("")){
|
||
|
|
model.addAttribute("pid",pid);
|
||
|
|
}
|
||
|
|
model.addAttribute("bizid",unitId);
|
||
|
|
//return "command/menuFuncEdit";
|
||
|
|
return "command/emergencyConfigureInfoEdit";
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("/showFuncEdit4NS.do")
|
||
|
|
public String doFuncEdit4NS(HttpServletRequest request,Model model,
|
||
|
|
@RequestParam(value="pid") String pid,
|
||
|
|
@RequestParam(value="id") String id,
|
||
|
|
@RequestParam(value="unitId") String unitId){
|
||
|
|
EmergencyConfigureInfo emergencyConfigureInfo= emergencyConfigureInfoService.getMenuById(id);
|
||
|
|
model.addAttribute("emergencyConfigureInfo",emergencyConfigureInfo );
|
||
|
|
if(pid!=null && !pid.equals("")){
|
||
|
|
model.addAttribute("pid",pid);
|
||
|
|
}
|
||
|
|
model.addAttribute("bizid",unitId);
|
||
|
|
return "command/emergencyConfigureInfoEdit4NS";
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("/editMemoFun.do")
|
||
|
|
public String editMemoFun(HttpServletRequest request,Model model,
|
||
|
|
@RequestParam(value="pid") String pid,
|
||
|
|
@RequestParam(value="id") String id,
|
||
|
|
@RequestParam(value="unitId") String unitId){
|
||
|
|
EmergencyConfigureInfo emergencyConfigureInfo= emergencyConfigureInfoService.getMenuById(id);
|
||
|
|
model.addAttribute("emergencyConfigureInfo",emergencyConfigureInfo );
|
||
|
|
if(pid!=null && !pid.equals("")){
|
||
|
|
model.addAttribute("pid",pid);
|
||
|
|
}
|
||
|
|
model.addAttribute("bizid",unitId);
|
||
|
|
//return "command/menuFuncEdit";
|
||
|
|
return "command/emergencyConfigureInfoEdit4Memo";
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("/saveFunc.do")
|
||
|
|
public String dosaveFunc(HttpServletRequest request,Model model,
|
||
|
|
@ModelAttribute("emergencyConfigureInfo") EmergencyConfigureInfo emergencyConfigureInfo){
|
||
|
|
if(emergencyConfigureInfo.getId()==null || emergencyConfigureInfo.getId().isEmpty()){
|
||
|
|
emergencyConfigureInfo.setId(CommUtil.getUUID());
|
||
|
|
}
|
||
|
|
int result = this.emergencyConfigureInfoService.saveMenu(emergencyConfigureInfo);
|
||
|
|
model.addAttribute("result", "{\"res\":\""+result+"\",\"id\":\""+emergencyConfigureInfo.getId()+"\"}");
|
||
|
|
return "result";
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("/updateFunc.do")
|
||
|
|
public String doupdateFunc(HttpServletRequest request,Model model,
|
||
|
|
@ModelAttribute EmergencyConfigureInfo emergencyConfigureInfo){
|
||
|
|
int result = this.emergencyConfigureInfoService.updateMenu(emergencyConfigureInfo);
|
||
|
|
model.addAttribute("result", "{\"res\":\""+result+"\",\"id\":\""+emergencyConfigureInfo.getId()+"\"}");
|
||
|
|
return "result";
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("/deleteMenu.do")
|
||
|
|
public String dodel(HttpServletRequest request,Model model,
|
||
|
|
@RequestParam(value="id") String id){
|
||
|
|
|
||
|
|
String msg = "";
|
||
|
|
int result = 0;
|
||
|
|
//System.out.println("del_id:::"+id);
|
||
|
|
List<EmergencyConfigureInfo> mlist = this.emergencyConfigureInfoService.selectListByWhere(" where id = '"+id+"'");
|
||
|
|
if(mlist!=null && mlist.size()>0){
|
||
|
|
result = this.emergencyConfigureInfoService.deleteMenuById(id);
|
||
|
|
}else{
|
||
|
|
msg="删除失败";
|
||
|
|
}
|
||
|
|
model.addAttribute("result","{\"res\":\""+result+"\",\"msg\":\""+msg+"\"}");
|
||
|
|
|
||
|
|
return "result";
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("/doprocess3.do")
|
||
|
|
public String doprocess3(HttpServletRequest request,Model model,
|
||
|
|
@RequestParam(value="id") String id,
|
||
|
|
@RequestParam(value="category") String category){
|
||
|
|
|
||
|
|
|
||
|
|
EmergencyConfigure emergencyConfigure = emergencyConfigureService.getMenuById(id);
|
||
|
|
model.addAttribute("titleName",emergencyConfigure.getName());
|
||
|
|
|
||
|
|
/*
|
||
|
|
* 三级菜单
|
||
|
|
*/
|
||
|
|
if(category!=null && category.equals("3")){
|
||
|
|
List<EmergencyConfigureInfo> mlist = this.emergencyConfigureInfoService.selectListByWhere(" where pid = '"+emergencyConfigure.getId()+"'");
|
||
|
|
JSONArray jsonArray=new JSONArray();//矩形框json
|
||
|
|
int y=0;
|
||
|
|
if (mlist!=null && mlist.size()>0) {
|
||
|
|
for (int i = 0; i < mlist.size(); i++) {
|
||
|
|
JSONObject jsonObject=new JSONObject();
|
||
|
|
if(mlist.get(i).getRoles()!=null){
|
||
|
|
jsonObject.put("roleName", mlist.get(i).getRoles().toString());
|
||
|
|
}
|
||
|
|
if(mlist.get(i).getPersonliablename() !=null){
|
||
|
|
jsonObject.put("person", mlist.get(i).getPersonliablename().toString());
|
||
|
|
}
|
||
|
|
y=y+100;
|
||
|
|
jsonObject.put("person_y", y);//责任人Y轴
|
||
|
|
if(mlist.get(i).getContents() != null){//处理事项
|
||
|
|
int clength = mlist.get(i).getContents().toString().length();
|
||
|
|
if(clength>10){
|
||
|
|
jsonObject.put("content", mlist.get(i).getContents().toString().substring(0, 10));
|
||
|
|
}else{
|
||
|
|
jsonObject.put("content", mlist.get(i).getContents().toString());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if(mlist.get(i).getContentsdetail() != null){//操作内容
|
||
|
|
int clength=mlist.get(i).getContentsdetail().toString().length();
|
||
|
|
if(clength>10){
|
||
|
|
jsonObject.put("contentDetailTitle", mlist.get(i).getContentsdetail().toString().substring(0, 10));
|
||
|
|
}else {
|
||
|
|
jsonObject.put("contentDetailTitle", mlist.get(i).getContentsdetail().toString());
|
||
|
|
}
|
||
|
|
jsonObject.put("contentDetail", mlist.get(i).getContentsdetail().toString());//详细内容
|
||
|
|
}
|
||
|
|
y=y+100;
|
||
|
|
jsonObject.put("status_y", y);//是否完成Y轴
|
||
|
|
jsonArray.add(jsonObject);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
request.setAttribute("end_y", y+100);
|
||
|
|
request.setAttribute("jsonArray", jsonArray);//矩形框json
|
||
|
|
//System.out.println("jsonArray:::"+jsonArray);
|
||
|
|
|
||
|
|
return "command/processEmergencyConfigure";
|
||
|
|
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
@RequestMapping("/dosortnew.do")
|
||
|
|
public String dosortnew(HttpServletRequest request,Model model){
|
||
|
|
//接收json数据
|
||
|
|
BufferedReader streamReader = null;
|
||
|
|
StringBuilder responseStrBuilder = new StringBuilder();
|
||
|
|
String inputStr;
|
||
|
|
try {
|
||
|
|
streamReader = new BufferedReader( new
|
||
|
|
InputStreamReader(request.getInputStream(), "UTF-8"));
|
||
|
|
while ((inputStr = streamReader.readLine()) != null)
|
||
|
|
responseStrBuilder.append(inputStr);
|
||
|
|
} catch (UnsupportedEncodingException e) {
|
||
|
|
// TODO Auto-generated catch block
|
||
|
|
System.out.println(e.toString());
|
||
|
|
e.printStackTrace();
|
||
|
|
throw new RuntimeException(e);
|
||
|
|
} catch (IOException e) {
|
||
|
|
// TODO Auto-generated catch block
|
||
|
|
e.printStackTrace();
|
||
|
|
System.out.println(e.toString());
|
||
|
|
throw new RuntimeException(e);
|
||
|
|
}
|
||
|
|
//转化成json对象
|
||
|
|
com.alibaba.fastjson.JSONObject json=com.alibaba.fastjson.JSONObject.parseObject(responseStrBuilder.toString());
|
||
|
|
String jsondata = json.getString("jsondata");
|
||
|
|
// System.out.println("jsondata:::"+jsondata);
|
||
|
|
String ds = jsondata;
|
||
|
|
JSONArray jsonArray=JSONArray.fromObject(ds);
|
||
|
|
JSONObject jsonOne;
|
||
|
|
int result=0;
|
||
|
|
for(int i=0;i<jsonArray.size();i++){
|
||
|
|
jsonOne = jsonArray.getJSONObject(i);
|
||
|
|
EmergencyConfigureInfo d= this.emergencyConfigureInfoService.getMenuById((String) jsonOne.get("id"));
|
||
|
|
d.setOrd(i);
|
||
|
|
result = this.emergencyConfigureInfoService.updateMenu(d);
|
||
|
|
}
|
||
|
|
model.addAttribute("result",result);
|
||
|
|
return String.valueOf(result);
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("/saveEditor.do")
|
||
|
|
public String saveEditor(HttpServletRequest request,Model model){
|
||
|
|
User cu=(User)request.getSession().getAttribute("cu");
|
||
|
|
String descripe = request.getParameter("editorText");
|
||
|
|
EmergencyConfigureInfo modeltype = new EmergencyConfigureInfo();
|
||
|
|
modeltype.setId(request.getParameter("modelid"));
|
||
|
|
modeltype.setMemo(descripe);
|
||
|
|
int res = this.emergencyConfigureInfoService.updateMenu(modeltype);
|
||
|
|
model.addAttribute("result", res);
|
||
|
|
return "result";
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|