diff --git a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/dashboard/controller/DashBoardController.java b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/dashboard/controller/DashBoardController.java new file mode 100644 index 0000000..990270e --- /dev/null +++ b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/dashboard/controller/DashBoardController.java @@ -0,0 +1,93 @@ +package org.cpte.modules.dashboard.controller; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.cpte.modules.agvTask.entity.AgvTask; +import org.cpte.modules.agvTask.service.IAgvTaskService; +import org.cpte.modules.inventory.mapper.InventoryMapper; +import org.cpte.modules.receive.mapper.AsnDetailMapper; +import org.cpte.modules.receive.mapper.ReceiveRecordMapper; +import org.cpte.modules.shipping.mapper.TaskMapper; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.common.system.base.controller.JeecgController; +import org.jeecg.common.system.query.QueryGenerator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.ModelAndView; + +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +/** + * @Description: AGV任务表 + * @author: cpte + * @Date: 2025-11-06 + * @Version: V1.0 + */ +@Tag(name = "首页") +@RestController +@RequestMapping("/dashboard") +@Slf4j +public class DashBoardController { + + @Autowired + private InventoryMapper inventoryMapper; + + @Autowired + private ReceiveRecordMapper receiveRecordMapper; + + @Autowired + private TaskMapper taskMapper; + + @GetMapping("/getChartCardList") + public Result getChartCardList() { + Result result = new Result(); + JSONArray jsonArray = new JSONArray(); + + Long invTotal = inventoryMapper.queryStockCount(); + JSONObject invObj = new JSONObject(true); + invObj.put("title", "总库存数量/托"); + invObj.put("icon", "visit-count|svg"); + invObj.put("total", invTotal); + jsonArray.add(invObj); + + Long inTotal = receiveRecordMapper.queryStockCount(); + JSONObject inObj = new JSONObject(true); + inObj.put("title", "日均入库量/托"); + inObj.put("icon", "total-sales|svg"); + inObj.put("total", inTotal); + inObj.put("color", "blue"); + jsonArray.add(inObj); + + Long outTotal = taskMapper.queryStockCount(); + JSONObject outObj = new JSONObject(true); + outObj.put("title", "日均出库量/托"); + outObj.put("icon", "download-count|svg"); + outObj.put("total", outTotal); + outObj.put("color", "orange"); + jsonArray.add(outObj); + + double turnoverTotal = outTotal / (double) invTotal; + JSONObject turnoverObj = new JSONObject(true); + turnoverObj.put("title", "库存周转率(次/天)"); + turnoverObj.put("icon", "transaction|svg"); + turnoverObj.put("total", turnoverTotal); + jsonArray.add(turnoverObj); + + result.setResult(jsonArray); + return result; + } + +} diff --git a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/dashboard/test.java b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/dashboard/test.java new file mode 100644 index 0000000..34fa26f --- /dev/null +++ b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/dashboard/test.java @@ -0,0 +1,4 @@ +package org.cpte.modules.dashboard; + +public class test { +} diff --git a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/inventory/mapper/InventoryMapper.java b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/inventory/mapper/InventoryMapper.java index 42f3f0a..e4e3bc7 100644 --- a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/inventory/mapper/InventoryMapper.java +++ b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/inventory/mapper/InventoryMapper.java @@ -102,4 +102,6 @@ public interface InventoryMapper extends BaseMapper { "${ew.customSqlSegment}") IPage selectInventoryWithItemKey(Page page, @Param("inventory") Inventory inventory, @Param("ew") Wrapper wrapper); + @Select("select count(stock_id) from data_inventory") + Long queryStockCount(); } diff --git a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/receive/mapper/ReceiveRecordMapper.java b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/receive/mapper/ReceiveRecordMapper.java index 96a91cf..4b93b13 100644 --- a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/receive/mapper/ReceiveRecordMapper.java +++ b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/receive/mapper/ReceiveRecordMapper.java @@ -10,11 +10,9 @@ import java.util.List; public interface ReceiveRecordMapper extends BaseMapper { /** - * 根据任务号查询入库单 - * - * @param asnId 入库ID - * @return List + * 当天入库托数 */ - @Select("select * from data_receive_record where asn_id = #{asnId} ") - List queryByAsnId(@Param("asnId") Long asnId); + @Select("SELECT COUNT(stock_id) FROM data_receive_record WHERE create_time >= CURDATE() AND create_time < CURDATE() + INTERVAL 1 DAY") + Long queryStockCount(); + } diff --git a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/shipping/mapper/TaskMapper.java b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/shipping/mapper/TaskMapper.java index f35e088..a581348 100644 --- a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/shipping/mapper/TaskMapper.java +++ b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/shipping/mapper/TaskMapper.java @@ -41,4 +41,10 @@ public interface TaskMapper extends BaseMapper { */ @Select("SELECT * FROM data_task WHERE agv_task_id is null and to_point_id is null") List queryUnallocatedTask(); + + /** + * 当天出库托数 + */ + @Select("SELECT COUNT(stock_id) FROM data_task WHERE task_status in (4,5) AND create_time >= CURDATE() AND create_time < CURDATE() + INTERVAL 1 DAY AND pick_id>0") + Long queryStockCount(); }