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.bean.LocationCondition;
|
import com.slcf.bean.LocationEntity;
|
import com.slcf.pojo.LocationBean;
|
import com.slcf.pojo.SysLogBean;
|
import com.slcf.service.LocationService;
|
import com.slcf.service.RoleService;
|
import com.slcf.service.SysLogService;
|
import com.slcf.util.AuthorityCode;
|
|
/**
|
* 库位管理控制器层
|
* @author admin
|
* @date 2018年11月7日
|
*/
|
@Controller
|
@RequestMapping("/basic")
|
public class LocationController {
|
|
@Resource
|
LocationService locationService;
|
@Autowired
|
SysLogService sysLogService;
|
@Autowired
|
RoleService roleService;
|
|
@RequestMapping("/goLocation.action")
|
public String goLocationPage(HttpServletRequest request){
|
try {
|
String rid = request.getSession().getAttribute("ROLEID").toString();
|
String authCode = roleService.getAuthListByRoleMenu(Integer.parseInt(rid),
|
AuthorityCode.LocationCode);
|
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("goLocation.action");
|
sysLog.setTts_keyname("访问:库位管理");
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}catch (Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return "location";
|
}
|
|
/**
|
* 添加
|
* @param LocationEntity
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/addLocation.action")
|
public Integer insertLocation(LocationEntity location,HttpServletRequest request){
|
int result=0;
|
try {
|
UserBean user=(UserBean)request.getSession().getAttribute("USER");
|
int srow = location.getS_row();
|
int erow = location.getE_row();
|
int sbay = location.getS_bay();
|
int ebay = location.getE_bay();
|
int slev = location.getS_lev();
|
int elev = location.getE_lev();
|
int whs_type = location.getWhs_type();
|
|
for(int i=srow; i<=erow; i++) {
|
for(int j=sbay; j<=ebay; j++) {
|
for(int k=slev; k<=elev; k++) {
|
String loc_no = String.format("%02d", i) + String.format("%03d", j) + String.format("%02d", k);
|
int crn_no = (i+1)/2;
|
LocationBean loc = new LocationBean();
|
loc.setLoc_no(loc_no);
|
loc.setLoc_sts("O");
|
loc.setModi_user(user.getUser_account());
|
loc.setRow1(i);
|
loc.setBay1(j);
|
loc.setLev1(k);
|
loc.setCrn_no(crn_no);
|
loc.setWhs_type(whs_type);
|
loc.setLoc_type(whs_type); //库位类型
|
locationService.insertLocation(loc);
|
result++;
|
}
|
}
|
}
|
// System.out.println(i+"++++++++++++");
|
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("addLocation.action");
|
sysLog.setTts_keyname("初始化库位:排" + srow + "-" + erow + ",列" + sbay + "-" + ebay + ",层" + slev + "-" + elev);
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
result=0;
|
}
|
return result;
|
}
|
|
/**
|
* 分页查询所有
|
* @param pageNumber
|
* @param pageSize
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/locationList.action")
|
public Map<String,Object> queryLocationListByPages(LocationCondition locationCon){
|
Map<String,Object>map=locationService.queryLocationList(locationCon);
|
return map;
|
}
|
// @ResponseBody
|
// @RequestMapping("/locationList.action")
|
// public Map<String,Object> queryLocationListByPages(
|
// @RequestParam(value="pageNumber",defaultValue="1",required=false)int pageNumber,
|
// @RequestParam("pageSize")int pageSize){
|
// Map<String,Object>map=new HashMap<String, Object>();
|
// try {
|
// int count=locationService.queryLocationCount();
|
// List<LocationBean>dlist=locationService.queryLocationList((pageNumber-1)*pageSize, pageSize);
|
// map.put("total", count);
|
// map.put("rows", dlist);
|
// }catch(Exception e) {
|
// System.out.println(e.getMessage());
|
// }
|
// return map;
|
// }
|
|
/**
|
* 根据id查询信息
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/queryLocationById.action")
|
public LocationBean queryLocationById(@RequestParam("did")String id){
|
try {
|
return locationService.queryLocationById(id);
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
return null;
|
}
|
}
|
|
/**
|
* 验证工作代号是否唯一
|
* @param did
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/checkLocation.action")
|
public Map<String,Object> checkLocation(@RequestParam("did")String id){
|
Map<String,Object> map=new HashMap<String, Object>();
|
// boolean flag=userService.validUserAccount(account, uid);
|
try {
|
LocationBean Location = locationService.queryLocationById(id);
|
if(Location==null){
|
map.put("msg", "代号可用");
|
}else{
|
map.put("msg", "代号不可用");
|
}
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return map;
|
}
|
|
/**
|
* 修改信息
|
* @param LocationEntity
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/upLocation.action")
|
public Integer upLocation(LocationBean location,HttpServletRequest request){
|
int result = 0;
|
try {
|
UserBean user=(UserBean)request.getSession().getAttribute("USER");
|
location.setModi_user(user.getUser_account());
|
|
result=locationService.upLocation(location);
|
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("upLocation.action");
|
sysLog.setTts_keyname("修改库位:" + location.getLoc_no());
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return result;
|
}
|
|
/**
|
* 删除信息
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/delLocation.action")
|
public int delLocation(@RequestParam("did")String id,HttpServletRequest request){
|
int result = 0;
|
try {
|
result=locationService.delLocation(id);
|
|
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("delLocation.action");
|
sysLog.setTts_keyname("删除库位,ID:" + id);
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return result;
|
}
|
|
/**
|
* 查询所有
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/getLocation.action")
|
public List<LocationBean> getLocation(){
|
try {
|
return locationService.getLocationList();
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
return null;
|
}
|
}
|
|
/**
|
* 重置库位表
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/resetLocation.action")
|
public int resetLocation(HttpServletRequest request){
|
int result = 0;
|
try {
|
result=locationService.resetLocation();
|
|
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("resetLocation.action");
|
sysLog.setTts_keyname("重置库位表");
|
sysLog.setModi_user(user.getUser_account());
|
sysLogService.insertSysLog(sysLog);
|
}
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return result;
|
}
|
|
@ResponseBody
|
@RequestMapping("/getRow.action")
|
public Map<String,Object> getRow(){
|
Map<String,Object> map=new HashMap<String, Object>();
|
try {
|
map.put("rows",locationService.getRowList());
|
}catch(Exception e) {
|
System.out.println(e.getMessage());
|
}
|
return map;
|
}
|
}
|