package com.slcf.controller;
|
|
import java.util.HashMap;
|
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.WorkMastBean;
|
import com.slcf.bean.MatCodeCondition;
|
import com.slcf.pojo.LocationBean;
|
import com.slcf.pojo.MatCodeBean;
|
import com.slcf.pojo.StationBean;
|
import com.slcf.pojo.SysLogBean;
|
import com.slcf.service.WaitPakInService;
|
import com.slcf.service.WorkFileService;
|
import com.slcf.service.WorkNoService;
|
import com.slcf.util.AuthorityCode;
|
import com.slcf.util.CommonMethod;
|
import com.slcf.util.DateTimeUtil;
|
import com.slcf.service.CrnService;
|
import com.slcf.service.LocationService;
|
import com.slcf.service.MatCodeService;
|
import com.slcf.service.OperateService;
|
import com.slcf.service.RoleService;
|
import com.slcf.service.RowNoService;
|
import com.slcf.service.StaDescService;
|
import com.slcf.service.StationService;
|
import com.slcf.service.SysLogService;
|
|
/**
|
* 入库作业控制器层
|
* @author admin
|
* @date 2018年12月1日
|
*/
|
@Controller
|
@RequestMapping("/work")
|
public class PakStoreController {
|
|
@Resource
|
WaitPakInService waitPakInService;
|
@Autowired
|
SysLogService sysLogService;
|
@Autowired
|
MatCodeService matCodeService;
|
@Autowired
|
StaDescService staDescService;
|
@Autowired
|
StationService stationService;
|
@Autowired
|
WorkNoService workNoService;
|
@Autowired
|
WorkFileService workFileService;
|
@Autowired
|
RowNoService rowNoService;
|
@Autowired
|
LocationService locationService;
|
@Autowired
|
CrnService crnService;
|
@Autowired
|
OperateService operateService;
|
@Autowired
|
RoleService roleService;
|
|
@RequestMapping("/goPakStore.action")
|
public String goPakStorePage(HttpServletRequest request){
|
try {
|
String rid = request.getSession().getAttribute("ROLEID").toString();
|
String authCode = roleService.getAuthListByRoleMenu(Integer.parseInt(rid),
|
AuthorityCode.PakStoreCode);
|
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("goWaitPakIn.action");
|
sysLog.setTts_keyname("访问:全板入库");
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}catch (Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return "pakStore";
|
}
|
|
@RequestMapping("/goCombine.action")
|
public String goCombinPage(HttpServletRequest request){
|
try {
|
String rid = request.getSession().getAttribute("ROLEID").toString();
|
String authCode = roleService.getAuthListByRoleMenu(Integer.parseInt(rid),
|
AuthorityCode.CombineCode);
|
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("goCombin.action");
|
sysLog.setTts_keyname("访问:并板入库");
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}catch (Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return "combine";
|
}
|
|
@RequestMapping("/goRetrieve.action")
|
public String goRetrievePage(HttpServletRequest request){
|
try {
|
String rid = request.getSession().getAttribute("ROLEID").toString();
|
String authCode = roleService.getAuthListByRoleMenu(Integer.parseInt(rid),
|
AuthorityCode.RetrieveCode);
|
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("goRetrieve.action");
|
sysLog.setTts_keyname("访问:出库作业");
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}catch (Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return "retrieve";
|
}
|
|
/**
|
* 查询所有
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/getStaDesc.action")
|
public Map<String,Object> getStaDesc(@RequestParam("type")int type){
|
Map<String,Object> map=new HashMap<String, Object>();
|
try {
|
map.put("rows",staDescService.queryStaDescByTypeNo(type));
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return map;
|
}
|
|
/**
|
* 分页查询物料信息,如果没有从ERP中查询
|
* @param pageNumber
|
* @param pageSize
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/erpMatList.action")
|
public Map<String,Object> queryErpMatListByPages(MatCodeCondition matCodeCon){
|
Map<String,Object> map=matCodeService.queryMatCodeByNo(matCodeCon);
|
return map;
|
}
|
|
/**
|
* 组盘
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/pakPalletizing.action")
|
public Map<String,Object> pakPalletizing(@RequestParam("mat_no")String mat_no,
|
@RequestParam("barcode_no")String barcode,HttpServletRequest request) throws Exception{
|
Map<String,Object> map=new HashMap<String, Object>();
|
try {
|
MatCodeBean matCode = new MatCodeBean();
|
UserBean user=(UserBean)request.getSession().getAttribute("USER");
|
matCode.setMat_no(mat_no);
|
matCode.setModi_user(user.getUser_account());
|
matCode.setBarcode(barcode);
|
|
int result=0;
|
result=matCodeService.upMatBarcode(matCode);
|
if(result>0) {
|
map.put("code", 0);
|
map.put("msg", "组盘成功:" + matCode.getMat_no() + "-" + matCode.getBarcode());
|
|
// 插入日志
|
// 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("upMatCode.action");
|
sysLog.setTts_keyname("组托:" + matCode.getMat_no() + "-" + matCode.getBarcode());
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}
|
}catch(RuntimeException e) {
|
System.out.println(e.getMessage());
|
}
|
return map;
|
}
|
|
/**
|
* 入库启动
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/pakStoreIn.action")
|
public Map<String,Object> pakStoreIn(@RequestParam("ids")String[] ids,
|
@RequestParam("stn_no")int stn_no,HttpServletRequest request) throws Exception{
|
Map<String,Object> map=new HashMap<String, Object>();
|
try {
|
CommonMethod commonMethod = new CommonMethod(workFileService,workNoService,crnService,
|
stationService,locationService,rowNoService,staDescService);
|
|
int result=0;
|
UserBean user=(UserBean)request.getSession().getAttribute("USER");
|
WorkMastBean workMast = new WorkMastBean();
|
|
if(ids==null || ids.toString().equals("")) {
|
map.put("code", 1);
|
map.put("msg", "没有入库明细数据");
|
return map;
|
}
|
|
//判断站点是否正常
|
StationBean station = stationService.queryStationById(stn_no);
|
Map<String,Object> mapStation = commonMethod.checkStationStatus(station);
|
if((Integer)mapStation.get("code")==1) {
|
map.put("code", 1);
|
map.put("msg", mapStation.get("msg"));
|
return map;
|
}
|
|
int wrk_no = commonMethod.getNewWorkNo(workNoService.queryWorkNoById(0));
|
if(wrk_no<=0) {
|
map.put("code", 1);
|
map.put("msg", "生成工作号失败,请联系管理员");
|
return map;
|
}else {
|
WorkMastBean workFile = workFileService.queryWorkMastById(wrk_no);
|
if(workFile!=null) {
|
map.put("code", 1);
|
map.put("msg", "生成工作号" + wrk_no + "在工作档中已存在");
|
return map;
|
}
|
}
|
|
String loc_no = "";
|
loc_no = commonMethod.getLocNo(1,rowNoService.queryRowNoById(1), stn_no, station.getCtn_type());
|
if(loc_no.equals("")) {
|
map.put("code", 1);
|
map.put("msg", "查询可用库位失败,请检查堆垛机、设备状态");
|
return map;
|
}
|
int crn_no = Integer.parseInt(loc_no.substring(0,2));
|
crn_no = (crn_no+1) / 2;
|
int e_staNo = commonMethod.getIoStaNo(1,crn_no,stn_no);
|
if(e_staNo<=0) {
|
map.put("code", 1);
|
map.put("msg", "获取堆垛机站点失败");
|
return map;
|
}
|
String io_time = DateTimeUtil.getStringDateTime(19);
|
workMast.setWrk_no(wrk_no);
|
workMast.setIo_time(io_time);
|
workMast.setWrk_sts(1);
|
workMast.setIo_type(1);
|
workMast.setIo_pri(10);
|
workMast.setCrn_no(crn_no);
|
workMast.setSource_sta_no(stn_no);
|
workMast.setSta_no(e_staNo);
|
workMast.setLoc_no(loc_no);
|
workMast.setFull_plt("N");
|
workMast.setPicking("N");
|
workMast.setExit_mk("N");
|
workMast.setEmpty_mk("N");
|
workMast.setLink_mis("N");
|
workMast.setCtn_type(station.getCtn_type());
|
workMast.setModi_user(user.getUser_account());
|
|
map = operateService.insertPakStoreIn(workMast, ids, station, user);
|
|
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("pakStoreIn.action");
|
sysLog.setTts_keyname("启动入库:" + workMast.getWrk_no() + "-" + workMast.getLoc_no());
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}
|
}catch(RuntimeException e) {
|
System.out.println(e.getMessage());
|
}
|
return map;
|
}
|
|
/**
|
* 并板启动
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/pakCombine.action")
|
public Map<String,Object> pakCombine(@RequestParam("ids")String[] ids,@RequestParam("loc_no")String loc_no,
|
@RequestParam("stn_no")int stn_no,HttpServletRequest request) throws Exception{
|
Map<String,Object> map=new HashMap<String, Object>();
|
try {
|
CommonMethod commonMethod = new CommonMethod(workFileService,workNoService,crnService,
|
stationService,locationService,rowNoService,staDescService);
|
|
int result=0;
|
UserBean user=(UserBean)request.getSession().getAttribute("USER");
|
WorkMastBean workMast = new WorkMastBean();
|
|
// //判断站点是否正常
|
// StationBean station = stationService.queryStationById(stn_no);
|
// Map<String,Object> mapStation = commonMethod.checkStationStatus(station);
|
// if((Integer)mapStation.get("code")==1) {
|
// map.put("code", 1);
|
// map.put("msg", mapStation.get("msg"));
|
// return map;
|
// }
|
|
int wrk_no = commonMethod.getNewWorkNo(workNoService.queryWorkNoById(0));
|
if(wrk_no<=0) {
|
map.put("code", 1);
|
map.put("msg", "生成工作号失败,请联系管理员");
|
return map;
|
}else {
|
WorkMastBean workFile = workFileService.queryWorkMastById(wrk_no);
|
if(workFile!=null) {
|
map.put("code", 1);
|
map.put("msg", "生成工作号" + wrk_no + "在工作档中已存在");
|
return map;
|
}
|
}
|
|
int crn_no = Integer.parseInt(loc_no.substring(0,2));
|
crn_no = (crn_no+1) / 2;
|
int s_staNo = commonMethod.getIoStaNo(104,crn_no,stn_no);
|
if(s_staNo<=0) {
|
map.put("code", 1);
|
map.put("msg", "获取堆垛机站点失败");
|
return map;
|
}
|
String io_time = DateTimeUtil.getStringDateTime(19);
|
workMast.setWrk_no(wrk_no);
|
workMast.setIo_time(io_time);
|
workMast.setWrk_sts(11);
|
workMast.setIo_type(104);
|
workMast.setIo_pri(10);
|
workMast.setCrn_no(crn_no);
|
workMast.setSource_sta_no(s_staNo);
|
workMast.setSta_no(stn_no);
|
workMast.setSource_loc_no(loc_no);
|
workMast.setFull_plt("N");
|
workMast.setPicking("N");
|
workMast.setExit_mk("N");
|
workMast.setEmpty_mk("N");
|
workMast.setLink_mis("N");
|
workMast.setModi_user(user.getUser_account());
|
|
map = operateService.insertPakCombine(workMast, ids, user);
|
|
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("pakCombine.action");
|
sysLog.setTts_keyname("启动并板入库:" + workMast.getWrk_no() + "-" + workMast.getSource_loc_no());
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}
|
}catch(RuntimeException e) {
|
System.out.println(e.getMessage());
|
}
|
return map;
|
}
|
|
/**
|
* 出库启动
|
* @param ids
|
* @param locstr
|
* @param stn_no
|
* @param stn_no1
|
* @param request
|
* @return
|
* @throws Exception
|
*/
|
@ResponseBody
|
@RequestMapping("/pakRetrieve.action")
|
public Map<String,Object> pakRetrieve(@RequestParam("ids")String[] ids,@RequestParam("locstr")String[] locstr,
|
@RequestParam("stn_no")int stn_no,HttpServletRequest request) throws Exception{
|
Map<String,Object> map=new HashMap<String, Object>();
|
try {
|
CommonMethod commonMethod = new CommonMethod(workFileService,workNoService,crnService,
|
stationService,locationService,rowNoService,staDescService);
|
|
UserBean user=(UserBean)request.getSession().getAttribute("USER");
|
if(locstr!=null && ids!=null) {
|
for(String loc_no:locstr) {
|
LocationBean location = locationService.queryLocationById(loc_no);
|
if(location==null || !location.getLoc_sts().equals("F")){
|
continue;
|
}
|
map = operateService.insertPakRetrieve(loc_no, ids, stn_no, user, commonMethod);
|
}
|
}else {
|
map.put("code", 1);
|
map.put("msg", "没有选择出库库位");
|
return map;
|
}
|
|
if((Integer)map.get("code")==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("pakRetrieve.action");
|
sysLog.setTts_keyname("启动出库");
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}
|
}catch(RuntimeException e) {
|
System.out.println(e.getMessage());
|
}
|
return map;
|
}
|
|
}
|