大屏
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package com.ruoyi.api.statistics.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.api.statistics.service.IJobStatisticsService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 作业统计 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/statistics")
|
||||
public class JobStatisticsController {
|
||||
|
||||
@Autowired
|
||||
private IJobStatisticsService jobStatisticsService;
|
||||
|
||||
/**
|
||||
* 获取当日入库和出库数量统计,以及货位状态统计
|
||||
*/
|
||||
@GetMapping("/daily")
|
||||
public AjaxResult getDailyStatistics() {
|
||||
Map<String, Object> result = jobStatisticsService.getDailyStatistics();
|
||||
Map<String, Object> statusCount = jobStatisticsService.getCargoSpaceStatusCount();
|
||||
|
||||
// 将状态统计转换为饼图所需的格式
|
||||
List<Map<String, Object>> pieData = new ArrayList<>();
|
||||
Map<String, String> statusMap = new HashMap<>();
|
||||
statusMap.put("1", "空货位");
|
||||
statusMap.put("2", "满货位");
|
||||
statusMap.put("3", "入库分配");
|
||||
statusMap.put("4", "出库分配");
|
||||
statusMap.put("5", "入库需盘点");
|
||||
statusMap.put("6", "出库需盘点");
|
||||
|
||||
for (Map.Entry<String, String> entry : statusMap.entrySet()) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("name", entry.getValue());
|
||||
item.put("value", statusCount.getOrDefault(entry.getKey(), 0));
|
||||
pieData.add(item);
|
||||
}
|
||||
|
||||
result.put("pie", pieData);
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.ruoyi.api.statistics.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 作业统计 Mapper 接口
|
||||
*/
|
||||
public interface JobStatisticsMapper {
|
||||
|
||||
/**
|
||||
* 查询当日入库数量(inOrOut < 20)
|
||||
*
|
||||
* @param createTime 创建日期
|
||||
* @return 入库数量
|
||||
*/
|
||||
public int selectDailyInCount(@Param("createTime") String createTime);
|
||||
|
||||
/**
|
||||
* 查询当日出库数量(inOrOut >= 20)
|
||||
*
|
||||
* @param createTime 创建日期
|
||||
* @return 出库数量
|
||||
*/
|
||||
public int selectDailyOutCount(@Param("createTime") String createTime);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ruoyi.api.statistics.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 作业统计 Service 接口
|
||||
*/
|
||||
public interface IJobStatisticsService {
|
||||
|
||||
/**
|
||||
* 获取当日入库和出库数量统计
|
||||
*
|
||||
* @return 统计结果
|
||||
*/
|
||||
public Map<String, Object> getDailyStatistics();
|
||||
|
||||
/**
|
||||
* 获取货位状态统计
|
||||
*
|
||||
* @return 状态统计结果,key为状态值,value为数量
|
||||
*/
|
||||
public Map<String, Object> getCargoSpaceStatusCount();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.ruoyi.api.statistics.service.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.api.statistics.service.IJobStatisticsService;
|
||||
import com.ruoyi.api.statistics.mapper.JobStatisticsMapper;
|
||||
import com.ruoyi.bas.cargoSpace.mapper.BasCargoSpaceMapper;
|
||||
|
||||
/**
|
||||
* 作业统计 Service 实现
|
||||
*/
|
||||
@Service
|
||||
public class JobStatisticsServiceImpl implements IJobStatisticsService {
|
||||
|
||||
@Autowired
|
||||
private JobStatisticsMapper jobStatisticsMapper;
|
||||
|
||||
@Autowired
|
||||
private BasCargoSpaceMapper basCargoSpaceMapper;
|
||||
|
||||
/**
|
||||
* 获取当日入库和出库数量统计
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getDailyStatistics() {
|
||||
// 获取当前日期
|
||||
String today = DateUtils.getDate();
|
||||
|
||||
// 查询当日入库数量
|
||||
int inCount = jobStatisticsMapper.selectDailyInCount(today);
|
||||
|
||||
// 查询当日出库数量
|
||||
int outCount = jobStatisticsMapper.selectDailyOutCount(today);
|
||||
|
||||
// 返回统计结果
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("drrk", String.valueOf(inCount));
|
||||
result.put("drck", String.valueOf(outCount));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取货位状态统计
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getCargoSpaceStatusCount() {
|
||||
List<Map<String, Object>> statusCounts = basCargoSpaceMapper.selectStatusCount();
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
// 将查询结果转换为所需格式
|
||||
for (Map<String, Object> count : statusCounts) {
|
||||
String status = String.valueOf(count.get("status"));
|
||||
Object countValue = count.get("count");
|
||||
result.put(status, countValue);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.bas.cargoSpace.domain.BasCargoSpace;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 库存信息Mapper接口
|
||||
@@ -61,5 +62,10 @@ public interface BasCargoSpaceMapper extends BaseMapper<BasCargoSpace>
|
||||
*/
|
||||
public int deleteBasCargoSpaceByCargoSpaceIds(String[] cargoSpaceIds);
|
||||
|
||||
|
||||
/**
|
||||
* 查询不同状态的货位数量统计
|
||||
*
|
||||
* @return 状态统计结果列表
|
||||
*/
|
||||
public List<Map<String, Object>> selectStatusCount();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user