| | |
| | | public List<Map<String, Object>> productInOutAnalysis(Integer type) { |
| | | String targetName; |
| | | if (type == 1) { |
| | | targetName = "原材料"; |
| | | targetName = "原料"; |
| | | } else if (type == 2) { |
| | | targetName = "成品"; |
| | | } else if (type == 3) { |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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()); |
| | |
| | | |
| | | 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()); |
| | |
| | | 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(); |
| | | } |
| | | } |