This commit is contained in:
猫猫guowen
2025-12-29 16:35:26 +08:00
parent bec185c139
commit dc8f2d329a
8 changed files with 379 additions and 284 deletions

View File

@@ -120,15 +120,13 @@ public class KpiController extends BaseController {
* 获取库存平面图
*
* @param warehouseId 仓库ID
* @param roadwayId 巷道ID
* @param thePlatoon 排
* @param theFloor 层
* @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));
@RequestParam("theFloor") String theFloor){
return success(kpiService.getChartData(warehouseId,theFloor));
}
/**
@@ -147,5 +145,15 @@ public class KpiController extends BaseController {
@RequestParam("thePlatoon") String thePlatoon){
return success(kpiService.getChartMag(warehouseId,theColumn,theFloor,thePlatoon));
}
/**
* 获取货位楼层数据
*
* @param warehouseId 仓库ID
* @return 货位楼层数据
*/
@GetMapping("/getFloors")
public AjaxResult getFloors(@RequestParam("warehouseId") String warehouseId){
return success(kpiService.getFloors(warehouseId));
}
}

View File

@@ -42,10 +42,12 @@ public interface KpiService {
Map<String, Object> getPlatoons(String warehouseId, String roadwayId);
Map<String,Object> getChartData(String warehouseId, String roadwayId, String thePlatoon);
Map<String,Object> getChartData(String warehouseId, String theFloor);
Map<String,Object> getChartMag(String warehouseId, String theColumn, String theFloor, String thePlatoon);
AjaxResult getInAnalysisByData(String warehouseId, String startTime, String endTime,String inOut);
Map<String, Object> getFloors(String warehouseId);
}

View File

@@ -317,6 +317,35 @@ public class KpiServiceImpl implements KpiService
}
@Override
public Map<String, Object> getFloors(String warehouseId) {
Map<String, Object> response = new HashMap<>();
// 查询指定仓库和巷道的排号信息
BasCargoSpace queryParams = new BasCargoSpace();
queryParams.setWarehouseId(warehouseId);
List<BasCargoSpace> list = basCargoSpaceMapper.selectBasCargoSpaceList(queryParams);
// 使用TreeSet去重并排序排号
Set<Long> platoonSet = new TreeSet<>();
for (BasCargoSpace space : list) {
if (space.getTheFloor() != null) {
platoonSet.add(space.getTheFloor());
}
}
// 转换为前端下拉框所需的格式
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> getRoadways(String warehouseId){
@@ -380,14 +409,11 @@ public class KpiServiceImpl implements KpiService
}
@Override
public Map<String,Object> getChartData(String warehouseId, String roadwayId, String thePlatoon) {
public Map<String,Object> getChartData(String warehouseId, String theFloor) {
// 查询指定仓库、巷道和排号的货位信息
BasCargoSpace queryParams = new BasCargoSpace();
queryParams.setWarehouseId(warehouseId);
queryParams.setRoadwayId(roadwayId);
if (thePlatoon != null) {
queryParams.setThePlatoon(Long.parseLong(thePlatoon));
}
queryParams.setTheFloor(Long.valueOf(theFloor));
List<BasCargoSpace> list = basCargoSpaceMapper.selectBasCargoSpaceList(queryParams);
// 用于存储不同状态的货位坐标
@@ -406,11 +432,11 @@ public class KpiServiceImpl implements KpiService
for (BasCargoSpace space : list) {
// 收集列和层信息
columnSet.add(space.getTheColumn());
floorSet.add(space.getTheFloor());
floorSet.add(space.getThePlatoon());
// 根据状态分类处理
if (space.getStatus() != null) {
String coordinate = "[" + space.getTheColumn() + "," + space.getTheFloor() + "," + space.getStatus() + "],";
String coordinate = "[" + space.getTheColumn() + "," + space.getThePlatoon() + "," + space.getStatus() + "],";
switch (Integer.parseInt(space.getStatus())) {
case 1: empty += coordinate; break;
case 2: full += coordinate; break;
@@ -425,15 +451,15 @@ public class KpiServiceImpl implements KpiService
// 构建列和层的标签
StringBuilder columnLabels = new StringBuilder();
for (Long col : columnSet) {
columnLabels.append("'").append(col).append(MessageUtils.message("kpi.spacePlan.column")).append("',");
columnLabels.append("'").append(col).append("列").append("',");
}
String column = "[" + columnLabels.toString() + "]";
String column = "[" + columnLabels + "]";
StringBuilder floorLabels = new StringBuilder();
for (Long floor : floorSet) {
floorLabels.append("'").append(floor).append(MessageUtils.message("kpi.spacePlan.floor")).append("',");
floorLabels.append("'").append(floor).append("排").append("',");
}
String floor = "[" + floorLabels.toString() + "]";
String floor = "[" + floorLabels + "]";
// 返回结果
Map<String, Object> map = new HashMap<>();
@@ -498,43 +524,86 @@ public class KpiServiceImpl implements KpiService
mydoJobParam.setCreateLeftTime(startTime);
mydoJobParam.setCreateRightTime(endTime);
mydoJobParam.setInOut(inOut);
List<DateTime> datesBetween = DateUtil.rangeToList(DateUtil.parseDate(startTime), DateUtil.parseDate(endTime), DateField.DAY_OF_MONTH);
List<MydoJob> list = mydoJobFinishMapper.selectMydoJobFinishListByMydoJob(mydoJobParam);
// 获取所有巷道ID(1和2)
List<String> roadwayIds = Arrays.asList("1", "2");
// 收集所有涉及的楼层
Set<Long> floorSet = new HashSet<>();
Map<String, BasCargoSpace> cargoSpaceCache = new HashMap<>();
// 遍历作业记录,收集涉及的货位ID并查询对应楼层
for (MydoJob job : list) {
if (job.getCargoSpaceId() != null) {
// 检查缓存中是否有该货位信息
if (!cargoSpaceCache.containsKey(job.getCargoSpaceId())) {
// 使用现有的查询方法查询货位信息
BasCargoSpace queryParam = new BasCargoSpace();
queryParam.setCargoSpaceId(job.getCargoSpaceId());
List<BasCargoSpace> cargoSpaces = basCargoSpaceMapper.selectBasCargoSpaceList(queryParam);
if (!cargoSpaces.isEmpty()) {
BasCargoSpace cargoSpace = cargoSpaces.get(0);
cargoSpaceCache.put(job.getCargoSpaceId(), cargoSpace);
if (cargoSpace.getTheFloor() != null) {
floorSet.add(cargoSpace.getTheFloor());
}
}
} else {
BasCargoSpace cachedSpace = cargoSpaceCache.get(job.getCargoSpaceId());
if (cachedSpace.getTheFloor() != null) {
floorSet.add(cachedSpace.getTheFloor());
}
}
}
}
// 将楼层排序
List<Long> floors = new ArrayList<>(floorSet);
Collections.sort(floors);
// 生成日期范围
List<DateTime> datesBetween = DateUtil.rangeToList(DateUtil.parseDate(startTime), DateUtil.parseDate(endTime), DateField.DAY_OF_MONTH);
List<String> xAxis = new ArrayList<>();
List<Map<String, Object>> series = new ArrayList<>();
// 为每个巷道创建一个系列
for (String roadwayId : roadwayIds) {
// 为每个楼层创建一个系列
for (Long floor : floors) {
Map<String, Object> seriesItem = new HashMap<>();
seriesItem.put("name", roadwayId + "号巷道");
seriesItem.put("name", floor + "层");
seriesItem.put("type", "line");
List<Long> data = new ArrayList<>();
seriesItem.put("data", data);
series.add(seriesItem);
}
// 按日期统计每个巷道的数量
// 按日期统计每个楼层的数量
for (DateTime dateTime : datesBetween) {
xAxis.add(DateUtil.format(dateTime, "yyyy-MM-dd"));
// 统计每个巷道在当天的数量
for (int i = 0; i < roadwayIds.size(); i++) {
String roadwayId = roadwayIds.get(i);
long count = list.stream()
.filter(mydoJob -> roadwayId.equals(mydoJob.getRoadwayId())
&& DateUtil.isIn(mydoJob.getCreateTime(), DateUtil.beginOfDay(dateTime), DateUtil.endOfDay(dateTime)))
.count();
// 统计每个楼层在当天的数量
for (int i = 0; i < floors.size(); i++) {
Long floor = floors.get(i);
long count = 0;
// 遍历作业记录,统计该楼层在当天的作业数量
for (MydoJob job : list) {
if (DateUtil.isIn(job.getCreateTime(), DateUtil.beginOfDay(dateTime), DateUtil.endOfDay(dateTime))) {
// 查找该作业对应的货位是否属于当前楼层
if (job.getCargoSpaceId() != null && cargoSpaceCache.containsKey(job.getCargoSpaceId())) {
BasCargoSpace space = cargoSpaceCache.get(job.getCargoSpaceId());
if (space.getTheFloor() != null && space.getTheFloor().equals(floor)) {
count++;
}
}
}
}
@SuppressWarnings("unchecked")
List<Long> data = (List<Long>) series.get(i).get("data");
data.add(count);
}
}
res.put("xAxis", xAxis);
res.put("series", series);
return AjaxResult.success(res);