7 天以前 9ae2624e0c36dabc10b2781998549e8e1eb8d7d8
src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -1019,7 +1019,7 @@
    public List<Map<String, Object>> productInOutAnalysis(Integer type) {
        String targetName;
        if (type == 1) {
            targetName = "原材料";
            targetName = "原料";
        } else if (type == 2) {
            targetName = "成品";
        } else if (type == 3) {
@@ -1332,8 +1332,11 @@
                int startMonth = ((currentMonth - 1) / 3) * 3 + 1;
                startDate = LocalDate.of(today.getYear(), startMonth, 1);
                break;
            default:
                startDate = today.with(DayOfWeek.MONDAY);
            case 4: // 年
                startDate = LocalDate.of(today.getYear(), 1, 1);
                break;
            default: // 默认查询今年数据
                startDate = LocalDate.of(today.getYear(), 1, 1);
                break;
        }
@@ -1345,15 +1348,16 @@
        String endStr = endDate.atStartOfDay()
                .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
//        List<Map<String, Object>> inputList = productionProductInputMapper.selectInputStats(startStr, endStr);
        List<Map<String, Object>> inputList = null;
        List<Map<String, Object>> inputList = productionProductInputMapper.selectInputStats(startStr, endStr);
//        List<Map<String, Object>> inputList = null;
        List<Map<String, Object>> outputList = productionProductOutputMapper.selectDailyOutputStats(startStr, endStr);
        Map<String, InputOutputAnalysisDto> dateMap = new HashMap<>();
        if (!CollectionUtils.isEmpty(inputList)) {
            for (Map<String, Object> map : inputList) {
                String date = (String) map.get("date");
                Object dateObj = map.get("statDate");
                String date = convertDateToString(dateObj);
                if (date == null)
                    continue;
                InputOutputAnalysisDto dto = dateMap.getOrDefault(date, new InputOutputAnalysisDto());
@@ -1366,7 +1370,8 @@
        if (!CollectionUtils.isEmpty(outputList)) {
            for (Map<String, Object> map : outputList) {
                String date = (String) map.get("date");
                Object dateObj = map.get("statDate");
                String date = convertDateToString(dateObj);
                if (date == null)
                    continue;
                InputOutputAnalysisDto dto = dateMap.getOrDefault(date, new InputOutputAnalysisDto());
@@ -2433,4 +2438,22 @@
    private BigDecimal defaultDecimal(BigDecimal value) {
        return value == null ? BigDecimal.ZERO : value;
    }
    private String convertDateToString(Object dateObj) {
        if (dateObj == null) {
            return null;
        }
        if (dateObj instanceof String) {
            return (String) dateObj;
        }
        if (dateObj instanceof java.sql.Date) {
            return ((java.sql.Date) dateObj).toLocalDate().toString();
        }
        if (dateObj instanceof java.util.Date) {
            return ((java.util.Date) dateObj).toInstant()
                    .atZone(ZoneId.systemDefault())
                    .toLocalDate().toString();
        }
        return dateObj.toString();
    }
}