package com.zbooksoft.gdmis.controller;
|
|
import com.ruili.wcp.web.model.AjaxResponse;
|
import com.ruili.wcp.web.model.ErrorInfo;
|
import com.zbooksoft.gdmis.common.BoxEnum;
|
import org.apache.shiro.authz.annotation.RequiresUser;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.dao.DataAccessException;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import java.util.List;
|
import java.util.Map;
|
|
import static com.zbooksoft.gdmis.common.ShelveOpForAndroid.shelveOperate;
|
|
|
/**
|
* @Description: 库房
|
* @Author: zhai
|
* @Date: 2024/8/28
|
**/
|
|
@Controller
|
@RequestMapping("/depot")
|
public class DepotController {
|
|
@Autowired
|
JdbcTemplate jdbcTemplate;
|
|
private static final Logger logger = LoggerFactory.getLogger(DepotController.class);
|
|
|
/**
|
* depot/openShelve
|
* 密集架开关
|
*
|
* @param id
|
* @param actionType
|
* @return
|
*/
|
@RequestMapping(value = "/openShelve")
|
@RequiresUser
|
@ResponseBody
|
public Object openShelve(Long id, String actionType) {
|
String sql = "SELECT * FROM BUS_DEPOT_MANAGEMENT WHERE ID = " + id;
|
Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(sql);
|
String ip = stringObjectMap.get("IP").toString();
|
int column = Integer.parseInt(stringObjectMap.get("COLUMN_NUMBER").toString());
|
shelveOperate(ip, 10086, column, actionType);
|
return new AjaxResponse(true);
|
}
|
|
/**
|
* depot/openShelve
|
* 密集架开关
|
*
|
* @param id
|
* @param actionType
|
* @return
|
*/
|
@RequestMapping(value = "/openShelveByUser")
|
@RequiresUser
|
@ResponseBody
|
public Object openShelveByUser(Long id) {
|
try {
|
String sqlWarehousing = " select * from BUS_WAREHOUSING where id =" + id;
|
|
List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sqlWarehousing);
|
if (mapList.size() > 0) {
|
Map<String, Object> stringObjectMap = mapList.get(0);
|
String locationNumber = stringObjectMap.get("LOCATION_NUMBER").toString();
|
String newCode = generateStorageLocationCode(locationNumber);
|
//取最后一位
|
String newActionType = newCode.substring(newCode.length() - 1);
|
String actionType = "4";
|
if (newActionType.equals("0")) {
|
actionType = "5";
|
}
|
String sql = "SELECT * FROM BUS_DEPOT_MANAGEMENT WHERE CODE = '" + newCode + "'";
|
Map<String, Object> stringObjectMaps = jdbcTemplate.queryForMap(sql);
|
String ip = stringObjectMaps.get("IP").toString();
|
int column = Integer.parseInt(stringObjectMap.get("COLUMN_NUMBER").toString());
|
shelveOperate(ip, 10086, column, actionType);
|
|
}
|
return new AjaxResponse(true);
|
} catch (Exception e) {
|
return new AjaxResponse(new ErrorInfo("开启失败"));
|
}
|
}
|
|
public static String generateStorageLocationCode(String location) {
|
// 示例输入: Z01-A01左-08列-02层
|
String[] parts = location.split("-");
|
|
String zoneStr = parts[0]; // Z01
|
String rackAndSide = parts[1]; // A01左
|
|
// 区域代码 (例如 Z01 -> 04)
|
String zoneCode = BoxEnum.getCodeByName(zoneStr);
|
|
// 架号中的字母与数字 (例如 A01 -> A=1, 01)
|
String rackLetter = rackAndSide.substring(0, 1); // A
|
String rackNumber = rackAndSide.substring(1, 3); // 01
|
String sideStr = rackAndSide.substring(3); // 左 or 右
|
|
// 获取字母对应的数字 (例如 A -> 1)
|
// 根据数字获取对应字母
|
String rackLetterNum = BoxEnum.RackLetter.getNumberByLetter(rackLetter); // 返回 "A"
|
|
|
// 方向代码 (左 -> 1, 右 -> 2)
|
String sideCode = "左".equals(sideStr) ? "1" : "0";
|
|
|
// 拼接最终结果
|
return zoneCode + rackLetterNum + rackNumber + sideCode;
|
}
|
}
|