no message
parent
6bea28259a
commit
2b4eed320e
|
|
@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.cpte.modules.agvTask.entity.AgvTask;
|
import org.cpte.modules.agvTask.entity.AgvTask;
|
||||||
import org.cpte.modules.agvTask.service.IAgvTaskService;
|
import org.cpte.modules.agvTask.service.IAgvTaskService;
|
||||||
|
import org.cpte.modules.dashboard.vo.OutAndInData;
|
||||||
import org.cpte.modules.inventory.mapper.InventoryMapper;
|
import org.cpte.modules.inventory.mapper.InventoryMapper;
|
||||||
import org.cpte.modules.receive.mapper.AsnDetailMapper;
|
import org.cpte.modules.receive.mapper.AsnDetailMapper;
|
||||||
import org.cpte.modules.receive.mapper.ReceiveRecordMapper;
|
import org.cpte.modules.receive.mapper.ReceiveRecordMapper;
|
||||||
|
|
@ -27,10 +28,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: AGV任务表
|
* @Description: AGV任务表
|
||||||
|
|
@ -42,7 +40,7 @@ import java.util.GregorianCalendar;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/dashboard")
|
@RequestMapping("/dashboard")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DashBoardController {
|
public class DashBoardController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private InventoryMapper inventoryMapper;
|
private InventoryMapper inventoryMapper;
|
||||||
|
|
@ -55,7 +53,6 @@ public class DashBoardController {
|
||||||
|
|
||||||
@GetMapping("/getChartCardList")
|
@GetMapping("/getChartCardList")
|
||||||
public Result<JSONArray> getChartCardList() {
|
public Result<JSONArray> getChartCardList() {
|
||||||
Result<JSONArray> result = new Result<JSONArray>();
|
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
|
||||||
Long invTotal = inventoryMapper.queryStockCount();
|
Long invTotal = inventoryMapper.queryStockCount();
|
||||||
|
|
@ -92,8 +89,14 @@ public class DashBoardController {
|
||||||
turnoverObj.put("total", roundedValue);
|
turnoverObj.put("total", roundedValue);
|
||||||
jsonArray.add(turnoverObj);
|
jsonArray.add(turnoverObj);
|
||||||
|
|
||||||
result.setResult(jsonArray);
|
return Result.OK(jsonArray);
|
||||||
return result;
|
}
|
||||||
|
|
||||||
|
@GetMapping("/queryOutAndInData")
|
||||||
|
public Result<List<OutAndInData>> queryOutAndInData() {
|
||||||
|
//本周出入库数据
|
||||||
|
List<OutAndInData> outAndInDataList = inventoryMapper.queryOutAndInData();
|
||||||
|
return Result.OK(outAndInDataList);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.cpte.modules.dashboard.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OutAndInData {
|
||||||
|
private String createTime;
|
||||||
|
private double qty;
|
||||||
|
private String type;
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.cpte.modules.dashboard.vo.OutAndInData;
|
||||||
import org.cpte.modules.inventory.entity.Inventory;
|
import org.cpte.modules.inventory.entity.Inventory;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
|
@ -104,4 +105,6 @@ public interface InventoryMapper extends BaseMapper<Inventory> {
|
||||||
|
|
||||||
@Select("select count(stock_id) from data_inventory")
|
@Select("select count(stock_id) from data_inventory")
|
||||||
Long queryStockCount();
|
Long queryStockCount();
|
||||||
|
|
||||||
|
List<OutAndInData> queryOutAndInData();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,4 +63,47 @@
|
||||||
#{stockId}
|
#{stockId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="queryOutAndInData" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
DATE_ADD(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY), INTERVAL n DAY) AS createTime,
|
||||||
|
t.type,
|
||||||
|
COALESCE(qty, 0) AS qty
|
||||||
|
FROM (
|
||||||
|
-- 生成0-6的数字序列(代表一周7天)
|
||||||
|
SELECT 0 AS n UNION SELECT 1 UNION SELECT 2 UNION SELECT 3
|
||||||
|
UNION SELECT 4 UNION SELECT 5 UNION SELECT 6
|
||||||
|
) AS days
|
||||||
|
CROSS JOIN (
|
||||||
|
-- 两种类型
|
||||||
|
SELECT '入库' AS type UNION SELECT '出库'
|
||||||
|
) AS t
|
||||||
|
LEFT JOIN (
|
||||||
|
-- 入库数据
|
||||||
|
SELECT
|
||||||
|
DATE(create_time) as createTime,
|
||||||
|
COUNT(stock_id) as qty,
|
||||||
|
'入库' as type
|
||||||
|
FROM data_receive_record
|
||||||
|
WHERE create_time >= DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY)
|
||||||
|
AND create_time < DATE_ADD(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY), INTERVAL 7 DAY)
|
||||||
|
GROUP BY DATE(create_time)
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
-- 出库数据
|
||||||
|
SELECT
|
||||||
|
DATE(create_time) as createTime,
|
||||||
|
COUNT(stock_id) as qty,
|
||||||
|
'出库' as type
|
||||||
|
FROM data_task
|
||||||
|
WHERE task_status in (4,5)
|
||||||
|
AND create_time >= DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY)
|
||||||
|
AND create_time < DATE_ADD(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY), INTERVAL 7 DAY)
|
||||||
|
AND pick_id > 0
|
||||||
|
GROUP BY DATE(create_time)
|
||||||
|
) AS data ON DATE_ADD(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY), INTERVAL n DAY) = data.createTime
|
||||||
|
AND t.type = data.type
|
||||||
|
ORDER BY createTime, type;
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue