货位分析、库存平面图

This commit is contained in:
猫猫guowen
2025-05-23 17:55:43 +08:00
parent 7a0f4606dc
commit 9559511e56
6 changed files with 607 additions and 9 deletions

View File

@@ -67,10 +67,65 @@ public class KpiController extends BaseController {
* 获取货位分析数据
*
* @param warehouseId 仓库ID
* @return 货位分析数据}
* @return 货位分析数据
*/
@GetMapping("/spaceAnalysis")
public AjaxResult getSpaceAnalysis(@RequestParam("warehouseId") String warehouseId) {
return success(kpiService.getSpaceAnalysis(warehouseId));
}
/**
* 获取货位巷道数据
*
* @param warehouseId 仓库ID
* @return 货位巷道数据
*/
@GetMapping("/getRoadways")
public AjaxResult getRoadways(@RequestParam("warehouseId") String warehouseId){
return success(kpiService.getRoadways(warehouseId));
}
/**
* 获取货位排数据
*
* @param warehouseId 仓库ID
* @param roadwayId 巷道ID
* @return 货位排数据
*/
@GetMapping("/getPlatoons")
public AjaxResult getPlatoons(@RequestParam("warehouseId") String warehouseId,
@RequestParam("roadwayId") String roadwayId){
return success(kpiService.getPlatoons(warehouseId,roadwayId));
}
/**
* 获取库存平面图
*
* @param warehouseId 仓库ID
* @param roadwayId 巷道ID
* @param thePlatoon 排
* @return 库存平面图数据
*/
@GetMapping("/getChartData")
public AjaxResult getChartData(@RequestParam("warehouseId") String warehouseId,
@RequestParam("roadwayId") String roadwayId,
@RequestParam("thePlatoon") String thePlatoon){
return success(kpiService.getChartData(warehouseId,roadwayId,thePlatoon));
}
/**
* 获取库存平面图信息
*
* @param warehouseId 仓库ID
* @param theColumn 列
* @param thePlatoon 排
* @param theFloor 层
* @return 库存平面图信息数据
*/
@GetMapping("/getChartMag")
public AjaxResult getChartMag(@RequestParam("warehouseId") String warehouseId,
@RequestParam("theColumn") String theColumn,
@RequestParam("theFloor") String theFloor,
@RequestParam("thePlatoon") String thePlatoon){
return success(kpiService.getChartMag(warehouseId,theColumn,theFloor,thePlatoon));
}
}

View File

@@ -33,4 +33,13 @@ public interface KpiService {
Map<String, Object> getSpaceAnalysis(String warehouseId);
Map<String, Object> getRoadways(String warehouseId);
Map<String, Object> getPlatoons(String warehouseId, String roadwayId);
Map<String,Object> getChartData(String warehouseId, String roadwayId, String thePlatoon);
Map<String,Object> getChartMag(String warehouseId, String theColumn, String theFloor, String thePlatoon);
}

View File

@@ -14,6 +14,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import com.ruoyi.kpi.service.KpiService;
@@ -220,7 +221,7 @@ public class KpiServiceImpl implements KpiService
}
/**
* 获取巷道均匀分析数据
* 获取货位分析数据
*
* @param warehouseId 仓库ID
* @return 货位分析
@@ -232,6 +233,13 @@ public class KpiServiceImpl implements KpiService
basCargoSpace.setWarehouseId(warehouseId);
List<BasCargoSpace> list = basCargoSpaceMapper.selectBasCargoSpaceList(basCargoSpace);
// 如果查询结果为空,返回空数据
if (list == null || list.isEmpty()) {
Map<String, Object> response = new HashMap<>();
response.put("data", new ArrayList<>());
return response;
}
// 按巷道和状态分类统计
Map<String, Map<String, Integer>> roadwayStats = new HashMap<>();
Set<String> roadwayIds = new HashSet<>();
@@ -277,5 +285,170 @@ public class KpiServiceImpl implements KpiService
return response;
}
@Override
public Map<String, Object> getRoadways(String warehouseId){
Map<String, Object> response = new HashMap<>();
// 查询指定仓库的巷道信息
BasCargoSpace queryParams = new BasCargoSpace();
queryParams.setWarehouseId(warehouseId);
List<BasCargoSpace> list = basCargoSpaceMapper.selectBasCargoSpaceList(queryParams);
// 使用Set去重并排序巷道ID
Set<String> roadwaySet = new TreeSet<>();
for (BasCargoSpace space : list) {
if (space.getRoadwayId() != null) {
roadwaySet.add(space.getRoadwayId());
}
}
// 转换为前端下拉框所需的格式
List<Map<String, String>> roadways = new ArrayList<>();
for (String roadwayId : roadwaySet) {
Map<String, String> roadway = new HashMap<>();
roadway.put("value", roadwayId);
roadway.put("label", "巷道" + roadwayId);
roadways.add(roadway);
}
response.put("data", roadways);
return response;
}
@Override
public Map<String,Object> getPlatoons(String warehouseId, String roadwayId){
Map<String, Object> response = new HashMap<>();
// 查询指定仓库和巷道的排号信息
BasCargoSpace queryParams = new BasCargoSpace();
queryParams.setWarehouseId(warehouseId);
queryParams.setRoadwayId(roadwayId);
List<BasCargoSpace> list = basCargoSpaceMapper.selectBasCargoSpaceList(queryParams);
// 使用TreeSet去重并排序排号
Set<Long> platoonSet = new TreeSet<>();
for (BasCargoSpace space : list) {
if (space.getThePlatoon() != null) {
platoonSet.add(space.getThePlatoon());
}
}
// 转换为前端下拉框所需的格式
List<Map<String, String>> platoons = new ArrayList<>();
for (Long platoon : platoonSet) {
Map<String, String> platoonMap = new HashMap<>();
platoonMap.put("value", platoon.toString());
platoonMap.put("label", platoon + "排");
platoons.add(platoonMap);
}
response.put("data", platoons);
return response;
}
@Override
public Map<String,Object> getChartData(String warehouseId, String roadwayId, String thePlatoon) {
// 查询指定仓库、巷道和排号的货位信息
BasCargoSpace queryParams = new BasCargoSpace();
queryParams.setWarehouseId(warehouseId);
queryParams.setRoadwayId(roadwayId);
if (thePlatoon != null) {
queryParams.setThePlatoon(Long.parseLong(thePlatoon));
}
List<BasCargoSpace> list = basCargoSpaceMapper.selectBasCargoSpaceList(queryParams);
// 用于存储不同状态的货位坐标
String empty = "";
String full = "";
String inAllot = "";
String outAllot = "";
String inCheck = "";
String outCheck = "";
// 用于存储列和层的集合
Set<Long> columnSet = new TreeSet<>();
Set<Long> floorSet = new TreeSet<>();
// 处理每个货位的状态
for (BasCargoSpace space : list) {
// 收集列和层信息
columnSet.add(space.getTheColumn());
floorSet.add(space.getTheFloor());
// 根据状态分类处理
if (space.getStatus() != null) {
String coordinate = "[" + space.getTheColumn() + "," + space.getTheFloor() + "," + space.getStatus() + "],";
switch (Integer.parseInt(space.getStatus())) {
case 1: empty += coordinate; break;
case 2: full += coordinate; break;
case 3: inAllot += coordinate; break;
case 4: outAllot += coordinate; break;
case 5: inCheck += coordinate; break;
case 6: outCheck += coordinate; break;
}
}
}
// 构建列和层的标签
StringBuilder columnLabels = new StringBuilder();
for (Long col : columnSet) {
columnLabels.append("'").append(col).append("列',");
}
String column = "[" + columnLabels.toString() + "]";
StringBuilder floorLabels = new StringBuilder();
for (Long floor : floorSet) {
floorLabels.append("'").append(floor).append("层',");
}
String floor = "[" + floorLabels.toString() + "]";
// 返回结果
Map<String, Object> map = new HashMap<>();
map.put("empty", "[" + empty + "]");
map.put("full", "[" + full + "]");
map.put("inAllot", "[" + inAllot + "]");
map.put("outAllot", "[" + outAllot + "]");
map.put("inCheck", "[" + inCheck + "]");
map.put("outCheck", "[" + outCheck + "]");
map.put("floor", floor);
map.put("column", column);
return map;
}
@Override
public Map<String,Object> getChartMag(String warehouseId,String theColumn,String theFloor,String thePlatoon){
Map<String, Object> response = new HashMap<>();
// 查询指定货位信息
BasCargoSpace queryParams = new BasCargoSpace();
queryParams.setWarehouseId(warehouseId);
queryParams.setTheColumn(Long.parseLong(theColumn));
queryParams.setTheFloor(Long.parseLong(theFloor));
queryParams.setThePlatoon(Long.parseLong(thePlatoon));
List<BasCargoSpace> list = basCargoSpaceMapper.selectBasCargoSpaceList(queryParams);
if (!list.isEmpty()) {
BasCargoSpace space = list.get(0);
StringBuilder info = new StringBuilder();
// 拼接货位信息
info.append("货位名称:").append(space.getCargoSpaceName()).append("<br>");
info.append("货位类型:").append(space.getTheTypeName()).append("<br>");
info.append("是否锁定:").append("Y".equals(space.getLocked()) ? "是" : "否").append("<br>");
info.append("托盘条码:").append(space.getTrayCode() != null ? space.getTrayCode() : "无").append("<br>");
info.append("货位高度:").append(space.getCargoHight() != null ? space.getCargoHight() : "无").append("<br>");
info.append("是否双伸:").append("Y".equals(space.getIssDouble()) ? "是" : "否").append("<br>");
response.put("msg", info.toString());
} else {
response.put("msg", "未找到货位信息");
}
return response;
}
}