package com.slcf.controller; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; 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.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.slcf.pojo.UserBean; import com.slcf.pojo.WaitPakOutBean; import com.slcf.pojo.WorkDetailBean; import com.slcf.bean.WorkMastCondition; import com.slcf.bean.WorkDetailCondition; import com.slcf.pojo.WorkMastBean; import com.slcf.pojo.LocationBean; import com.slcf.pojo.SysLogBean; import com.slcf.service.WorkFileService; import com.slcf.util.AuthorityCode; import com.slcf.service.LocationService; import com.slcf.service.RoleService; import com.slcf.service.SysLogService; import com.slcf.service.WaitPakOutService; /** * 工作档管理控制器层 * @author admin * @date 2018年11月22日 */ @Controller @RequestMapping("/work") public class WorkFileController { @Resource WorkFileService workFileService; @Autowired SysLogService sysLogService; @Autowired RoleService roleService; @Resource WaitPakOutService waitPakOutService; @Resource LocationService locationService; @RequestMapping("/goWorkFile.action") public String goWorkFilePage(HttpServletRequest request){ try { String rid = request.getSession().getAttribute("ROLEID").toString(); String authCode = roleService.getAuthListByRoleMenu(Integer.parseInt(rid), AuthorityCode.WorkFileCode); request.getSession().setAttribute("AUTHCODE",authCode); // 插入日志 UserBean user = (UserBean) request.getSession().getAttribute("USER"); SysLogBean sysLog = new SysLogBean(); sysLog.setLogin_no(user.getUser_account()); sysLog.setMachine_ip(request.getRemoteAddr()); sysLog.setForm_no("goWorkFile.action"); sysLog.setTts_keyname("访问:工作主档"); sysLog.setModi_user(user.getUser_account()); sysLogService.insertSysLog(sysLog); }catch (Exception e) { System.out.println(e.getMessage()); } return "workFile"; } /** * 分页查询主档 * @param pageNumber * @param pageSize * @return */ @ResponseBody @RequestMapping("/workMastList.action") public Map queryWorkMastListByPages(WorkMastCondition workMastCon){ Mapmap=workFileService.queryWorkMastList(workMastCon); return map; } /** * 分页查询明细 * @param pageNumber * @param pageSize * @return */ @ResponseBody @RequestMapping("/workDetailList.action") public Map queryWorkDetailListByPages(WorkDetailCondition workDetailCon){ if(workDetailCon.getWrk_no()==null || "".equals(workDetailCon.getWrk_no())) { return null; // locationCon.setLoc_no("1"); } Mapmap=workFileService.queryWorkDetailList(workDetailCon); return map; } /** * 修改信息 * @param workStatus * @return */ @ResponseBody @RequestMapping("/upWorkDetl.action") public Integer upWorkDetl(WorkDetailBean workDetl,HttpServletRequest request){ int result = 0; try { UserBean user=(UserBean)request.getSession().getAttribute("USER"); // workMast.setModi_user(user.getUser_account()); result=workFileService.upWorkDetl(workDetl); WaitPakOutBean waitPakOutBean = new WaitPakOutBean(); waitPakOutBean.setLgnum(workDetl.getLgnum()); waitPakOutBean.setTanum(workDetl.getTbnum()); waitPakOutBean.setTapos(workDetl.getTbpos()); waitPakOutBean.setNista(workDetl.getNista()); waitPakOutBean.setIo_status("N"); waitPakOutBean.setMemo(""); result = waitPakOutService.upWaitPakOut(waitPakOutBean, 1); if(result>0) { // 插入日志 // UserBean user = (UserBean) request.getSession().getAttribute("USER"); SysLogBean sysLog = new SysLogBean(); sysLog.setLogin_no(user.getUser_account()); sysLog.setMachine_ip(request.getRemoteAddr()); sysLog.setForm_no("upWorkDetl.action"); sysLog.setTts_keyname("维护拣料数量:" + workDetl.getMatnr()); sysLog.setModi_user(user.getUser_account()); sysLogService.insertSysLog(sysLog); } }catch(Exception e) { System.out.println(e.getMessage()); } return result; } /** * 根据id查询信息 * @param id * @return */ @ResponseBody @RequestMapping("/queryWorkDetlById.action") // public WorkDetailBean queryWorkDetlById(@RequestParam("wrk_no")int wrk_no, // @RequestParam("matnr")String matnr){ public WorkDetailBean queryWorkDetlById(WorkDetailBean workDetl1){ WorkMastBean workMast = new WorkMastBean(); workMast = workFileService.queryWorkMastById(workDetl1.getWrk_no()); if(workMast==null || workMast.getIo_type()!=103) { return null; } WorkDetailBean workDetl = new WorkDetailBean(); try { workDetl = workFileService.queryWorkDetlById(workDetl1); }catch(Exception e) { System.out.println(e.getMessage()); return null; } return workDetl; } /** * 查询所有 * @return */ @ResponseBody @RequestMapping("/getWorkMast.action") public List getWorkMast(){ try { return workFileService.getWorkMastList(); }catch(Exception e) { System.out.println(e.getMessage()); return null; } } /** * 工作档资料转历史档 * @return */ @ResponseBody @RequestMapping("/movWorkToLog.action") public int movePakInToLog(@RequestParam("wrk_no")int wrk_no,HttpServletRequest request){ int result = 0; try { result=workFileService.moveToLog(wrk_no); if(result>0) { // 插入日志 UserBean user = (UserBean) request.getSession().getAttribute("USER"); SysLogBean sysLog = new SysLogBean(); sysLog.setLogin_no(user.getUser_account()); sysLog.setMachine_ip(request.getRemoteAddr()); sysLog.setForm_no("movWorkToLog.action"); sysLog.setTts_keyname("工作档资料转历史档:" + wrk_no); sysLog.setModi_user(user.getUser_account()); sysLogService.insertSysLog(sysLog); } }catch(Exception e) { System.out.println(e.getMessage()); } return result; } /** * 手工处理,完结/取消工作档 * @return */ @ResponseBody @RequestMapping("/opWork.action") public int opWork(@RequestParam("wrk_no")int wrk_no,@RequestParam("type")int type, HttpServletRequest request){ int result = 0; try { UserBean user = (UserBean) request.getSession().getAttribute("USER"); WorkMastBean workMast = new WorkMastBean(); workMast = workFileService.queryWorkMastById(wrk_no); int wrk_sts=0; if(workMast!=null) { int io_type = workMast.getIo_type(); if(type==1) {//完成 if(workMast.getWrk_sts()<4 || (workMast.getWrk_sts()>10 && workMast.getIo_type()==11)) { wrk_sts=4; }else if(workMast.getWrk_sts()>10) { wrk_sts=14; } workMast.setWrk_sts(wrk_sts); result=workFileService.upWorkMast(workMast); } else if(type==2) {//取消 String loc_no=""; String loc_sts=""; if(workMast.getWrk_sts()<4) { if(io_type!=11) { loc_no=workMast.getLoc_no(); loc_sts="O"; }else { loc_no=workMast.getSource_loc_no(); loc_sts="F"; String d_loc_no = workMast.getLoc_no(); LocationBean location = new LocationBean(); location.setLoc_no(d_loc_no); location.setLoc_sts("O"); location.setModi_user(user.getUser_account()); locationService.upLocation(location); } }else if(workMast.getWrk_sts()>10) { loc_no=workMast.getSource_loc_no(); if(io_type>101 && io_type!=110) { loc_sts="F"; }else if(io_type==110) { loc_sts="D"; }else if(io_type==11) { String d_loc_no = workMast.getLoc_no(); LocationBean location = new LocationBean(); location.setLoc_no(d_loc_no); location.setLoc_sts("O"); location.setModi_user(user.getUser_account()); locationService.upLocation(location); } } result=workFileService.deleteWorkFile(wrk_no,loc_no,loc_sts,type); } } // result=workFileService.moveToLog(wrk_no); if(result>0) { // 插入日志 // UserBean user = (UserBean) request.getSession().getAttribute("USER"); SysLogBean sysLog = new SysLogBean(); sysLog.setLogin_no(user.getUser_account()); sysLog.setMachine_ip(request.getRemoteAddr()); sysLog.setForm_no("opWork.action"); sysLog.setTts_keyname("工作档手工完结:" + wrk_no); sysLog.setModi_user(user.getUser_account()); sysLogService.insertSysLog(sysLog); } }catch(Exception e) { System.out.println(e.getMessage()); } return result; } /** * 调整优先级 * @param locstr * @param request * @return * @throws Exception */ @ResponseBody @RequestMapping("/addIopri.action") public Map addIopri(@RequestParam("pri")String pri, @RequestParam("wrk_nostr")String[] wrk_nostr,HttpServletRequest request) throws Exception{ Map map=new HashMap(); try { // UserBean user=(UserBean)request.getSession().getAttribute("USER"); if(wrk_nostr!=null) { for(String ids:wrk_nostr) { int wrk_no = Integer.parseInt(ids); WorkMastBean workMast = new WorkMastBean(); workMast = workFileService.queryWorkMastById(wrk_no); if(workMast!=null) { workMast.setIo_pri(workMast.getIo_pri() + Integer.parseInt(pri)); // workMast.setModi_time(modi_time); int result=workFileService.upWorkMast(workMast); if(result>0) { map.put("code", 0); map.put("msg", "调整成功"); }else { map.put("code", 1); map.put("msg", "调整失败"); continue; } } } } }catch(RuntimeException e) { System.out.println(e.getMessage()); } return map; } }