package com.northglass.web.shelfmanager; import java.text.ParseException; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.northglass.constants.StateConstants.ShelfRankState; import com.northglass.entity.MachineDispose; import com.northglass.entity.MachineMessage; import com.northglass.entity.RawPackage; import com.northglass.entity.ShelfRack; import com.northglass.service.cutmanage.CutManageService; import com.northglass.service.shelfmanager.ShelfManagerService; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; /** * @author northglass * */ @Controller @RequestMapping(value="/shelfmanager") public class ShelfManagerController { @Autowired private ShelfManagerService shelfManagerService; //仓储任务显示 @RequestMapping(method=RequestMethod.GET, value="/shelftask") public String shelftask(Model model){ model.addAttribute("shelftasks", shelfManagerService.findShelfTask()); // model.addAttribute("shelftaskHtml", shelfManagerService.findShelfTaskHtml()); model.addAttribute("workingtask", shelfManagerService.findWorkingShelfTask()); model.addAttribute("status", shelfManagerService.getstatus()); /*model.addAttribute("lackGlassHtml", shelfManagerService.lackGlassHtml());*/ /* Map param1 = shelfManagerService.showMachineState(); model.addAttribute("allstatu", param1.get("allstatu")); model.addAttribute("info", param1.get("info"));*/ return "shelfmanager/shelftask"; } //料架管理 @RequestMapping(method=RequestMethod.GET,value="/rankmanager") public String rank(Model model) { model.addAttribute("working", ShelfRankState.IN_WORK); model.addAttribute("free", ShelfRankState.FREE); model.addAttribute("rawPackage", new RawPackage()); model.addAttribute("addrawPackage", new RawPackage()); model.addAttribute("shelfRankInfo", shelfManagerService.getShelfRankInfo()); model.addAttribute("shelfRankInfohmtl", shelfManagerService.getShelfRankInfohmtl()); model.addAttribute("action", "createAction"); model.addAttribute("addaction", "addcreateAction"); model.addAttribute("shelfRankNumberList", shelfManagerService.getFreeShelfRankNumberList()); model.addAttribute("shelfRankNumberList2", shelfManagerService.getFreeShelfRankNumberList2()); model.addAttribute("getColorList", shelfManagerService.getColorList()); /*model.addAttribute("getGlassCommerList", shelfManagerService.getGlassNameList()); model.addAttribute("optionHtml",shelfManagerService.getcolorHtml()); Map param1 = manageService.showMachineState(); model.addAttribute("allstatu", param1.get("allstatu")); model.addAttribute("info", param1.get("info"));*/ return "shelfmanager/rankmanager"; } //料架信息 @RequestMapping(method=RequestMethod.GET, value="/rawpackagelist") public String rawpackagelist(Model model,ShelfRack v,HttpServletRequest request, @RequestParam("start") Integer start,@RequestParam("length") Integer length, @RequestParam("glassThickness") String glassThickness,@RequestParam("glassId") String glassId) { Map map = new HashMap(); int count = 0; List list=null; if((glassThickness==null||glassThickness=="")&&(glassId==null||glassId=="")){ count = shelfManagerService.selectCount(); list=shelfManagerService.selectAll(start,length); }/*else if((glassThickness!=null&&glassThickness!="")&&(glassId==null||glassId=="")){ count = shelfManagerService.selectCount1(glassThickness); list=shelfManagerService.selectAll1(start,length,glassThickness); }else if((glassThickness==null||glassThickness=="")&&(glassId!=null&&glassId!="")){ // count = shelfManagerService.selectCount(); // list=shelfManagerService.selectAll(start,length); count = shelfManagerService.selectCount2(glassId); list=shelfManagerService.selectAll2(start,length,glassId); }else if((glassThickness!=null&&glassThickness!="")&&(glassId!=null&&glassId!="")){ count = shelfManagerService.selectCount3(glassThickness,glassId); list=shelfManagerService.selectAll3(start,length,glassThickness,glassId); }*/ for(ShelfRack ShelfRank:list){ if(ShelfRank.getRawPackage()!=null){ ShelfRank.setCount(ShelfRank.getRawPackage().getLeftPieces()); System.out.println(ShelfRank.getCount()); }else{ ShelfRank.setCount(0); } } map.put("recordsTotal", count); map.put("recordsFiltered", count); map.put("aaData", list); System.out.println(list); JsonConfig config = new JsonConfig(); config.setExcludes(new String[]{"rawPackage", "shelfTaskes"}); model.addAttribute("result", JSONObject.fromObject(map, config)); return "ajax/ajax"; } //删除上片任务 @RequestMapping(method=RequestMethod.GET, value="/deletetloadask") public String deletetloadask(Model model) { shelfManagerService.deletetloadask(); return "redirect:/shelfmanager/shelftask"; } //删除吊装任务 @RequestMapping(method=RequestMethod.GET, value="/deletetask") public String deletetask(Model model) { shelfManagerService.deletetask(); return "redirect:/shelfmanager/shelftask"; } //手动任务完成 @RequestMapping(method=RequestMethod.GET, value="/finishshelftask") public String finishshelftask(){ //shelfManagerService.finishWorkingShelfTask(); return "redirect:/shelfmanager/shelftask"; } //手动重新开始完成 @RequestMapping(method=RequestMethod.GET, value="/againshelftask") public String againshelftask(){ shelfManagerService.againshelftask(); return "redirect:/shelfmanager/shelftask"; } //删除料架信息 @RequestMapping(method=RequestMethod.POST, value="/rackdelete") @ResponseBody public boolean rackdelete(HttpServletRequest request, Model model) { shelfManagerService.rackdelete(Long.valueOf(request.getParameter("MachineId"))); return true; } @RequestMapping(method=RequestMethod.POST, value="/EnableDisablesReset") @ResponseBody public boolean enableDisablesReset(HttpServletRequest request, Model model) { shelfManagerService.enableDisablesReset(request.getParameter("type"),Long.valueOf(request.getParameter("MachineId"))); return true; } //添加料架信息 @RequestMapping(method = RequestMethod.POST, value = "/addshelfrack") @ResponseBody public boolean addshelfrack(HttpServletRequest request, Model model) { shelfManagerService.addshelfrack(request); return true; } //添加仓储任务信息 @RequestMapping(method = RequestMethod.POST, value = "/addshelftask") @ResponseBody public boolean addshelftask( Model model) { shelfManagerService.addshelftask(); return true; } //添加料架信息 @RequestMapping(method = RequestMethod.POST, value = "/addtask") @ResponseBody public boolean addtask(HttpServletRequest request, Model model) { shelfManagerService.addtask(request); return true; } //修改数量 @RequestMapping(method = RequestMethod.POST, value = "/updatecount") @ResponseBody public boolean updatecount(HttpServletRequest request, Model model) { shelfManagerService.updatecount(request); return true; } //修改批次号 @RequestMapping(method = RequestMethod.POST, value = "/updatepicihao") @ResponseBody public boolean updatepicihao(HttpServletRequest request, Model model) { shelfManagerService.updatepicihao(request); return true; } //入库 @RequestMapping(method = RequestMethod.POST, value = "/addshelfracks") @ResponseBody public boolean addshelfracks(HttpServletRequest request, Model model) { shelfManagerService.addshelfracks(request); return true; } //手动入库 @RequestMapping(method = RequestMethod.POST, value = "/addshelfracks2") @ResponseBody public boolean addshelfracks2(HttpServletRequest request, Model model) { shelfManagerService.addshelfracks2(request); return true; } //修改料架 @RequestMapping(method = RequestMethod.POST, value = "/updateshelfrank") @ResponseBody public boolean updateshelfrank(HttpServletRequest request, Model model) { shelfManagerService.updateshelfrank(request); return true; } //入库 @RequestMapping(method = RequestMethod.POST, value = "/addshelfracks1") @ResponseBody public boolean addshelfracks1(HttpServletRequest request, Model model) { shelfManagerService.addshelfracks1(request); return true; } //出库 @RequestMapping(method = RequestMethod.POST, value = "/deleteAll") @ResponseBody public boolean deleteAll(HttpServletRequest request, Model model) { shelfManagerService.exitSeparate(request.getParameter("rackid")); return true; } //fanpian @RequestMapping(method = RequestMethod.POST, value = "/fanpian") @ResponseBody public boolean fanpian(HttpServletRequest request, Model model) { shelfManagerService.fanpian(request.getParameter("rackid")); return true; } //进退库显示 @RequestMapping(method=RequestMethod.GET, value="/enterandexitrack") public String enterandexitrack(Model model,HttpServletRequest request){ model.addAttribute("rankList", shelfManagerService.getrankList()); return "shelfmanager/eAndExitrack"; } //手动添加上片位信息 @RequestMapping(method=RequestMethod.POST, value="/addAction") public String addAction(@Valid RawPackage rawPackage, HttpServletRequest request,@RequestParam(value="shelfRankNumber") String shelfRankNumber,@RequestParam("Ids") String Ids) { shelfManagerService.addAction(request, shelfRankNumber,Ids); return "redirect:/standalonemanage/intopage"; } //手动添加上片位信息 @RequestMapping(method=RequestMethod.POST, value="/modifyAction") public String modifyAction(HttpServletRequest request,@RequestParam(value="pieces") String pieces,@RequestParam("Ids") String Ids) { shelfManagerService.modifyAction(pieces,Ids); return "redirect:/standalonemanage/intopage"; } //单机退库 /*@RequestMapping(method=RequestMethod.GET, value="/exitload/{id}") public String exitload(Model model, @PathVariable("id") String id){ shelfManagerService.exitload(id); // model.addAttribute("loadMachineHtml", shelfManagerService.getLoadMachineRankHtml(1L)); // model.addAttribute("shelftasks", shelfManagerService.findShelfTask()); Map param1 = manageService.showMachineState(); model.addAttribute("allstatu", param1.get("allstatu")); model.addAttribute("info", param1.get("info")); if(id.equals("1")){ return "redirect:/standalonemanage/intopage"; }else { return "redirect:/standalonemanage/intopage2"; } }*/ //手动退库 @RequestMapping(method=RequestMethod.GET,value="/tuikuinfo/{loadMachineId}") public String tuikuinfo(Model model,@PathVariable("loadMachineId") String loadMachineId){ return shelfManagerService.tuikuinfo(loadMachineId); } //残片详情 @RequestMapping(method=RequestMethod.GET,value="/fragmentsrank") public String slicecagerank(Model model){ model.addAttribute("fragmentsRankInfohmtl", shelfManagerService.getfragmentsRankInfohmt()); //model.addAttribute("galsstaskInfohmtl", shelfManagerService.galsstaskInfohmtl()); return "shelfmanager/fragmentsrank"; } @RequestMapping(method=RequestMethod.POST, value="/fragmentsrankdelete") @ResponseBody public boolean fragmentsrankdelete(HttpServletRequest request, Model model) { shelfManagerService.fragmentsrankdelete(Long.valueOf(request.getParameter("rankid")),request.getParameter("type")); return true; } @RequestMapping(method=RequestMethod.POST, value="/updateshelftask") @ResponseBody public boolean updateshelftask(HttpServletRequest request, Model model) { shelfManagerService.updateshelftask(Long.valueOf(request.getParameter("taskid")),request.getParameter("type")); return true; } }