入库出库分析
This commit is contained in:
@@ -53,7 +53,7 @@ public class KpiServiceImpl implements KpiService
|
||||
Map<String, Integer> roadwayCount = new HashMap<>();
|
||||
|
||||
for (MydoJob job : list) {
|
||||
// 检查入库作业标识是否小于10
|
||||
// 检查入库作业标识是否小于20
|
||||
if (job.getInOrOut() == null || Integer.parseInt(job.getInOrOut()) >= 20) {
|
||||
continue;
|
||||
}
|
||||
@@ -520,7 +520,7 @@ public class KpiServiceImpl implements KpiService
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getInAnalysisByData(String warehouseId, String startTime, String endTime,String inOut) {
|
||||
public AjaxResult getInAnalysisByData(String warehouseId, String startTime, String endTime, String inOut) {
|
||||
Map<String,Object> res = new HashMap<>();
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setWarehouseId(warehouseId);
|
||||
@@ -528,36 +528,79 @@ 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");
|
||||
@@ -571,4 +614,6 @@ public class KpiServiceImpl implements KpiService
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user