gongchunyi
2026-04-30 78b637613099f0e2e04e98c5f33c24f8e6c78c7a
src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -12,7 +12,6 @@
import com.ruoyi.approve.pojo.ApproveProcess;
import com.ruoyi.basic.mapper.CustomerMapper;
import com.ruoyi.basic.mapper.ProductMapper;
import com.ruoyi.basic.mapper.ProductModelMapper;
import com.ruoyi.basic.mapper.SupplierManageMapper;
import com.ruoyi.basic.pojo.Customer;
import com.ruoyi.basic.pojo.Product;
@@ -20,6 +19,7 @@
import com.ruoyi.collaborativeApproval.mapper.NoticeMapper;
import com.ruoyi.collaborativeApproval.pojo.Notice;
import com.ruoyi.common.enums.ApproveTypeEnum;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.device.mapper.DeviceRepairMapper;
@@ -28,9 +28,6 @@
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.home.dto.*;
import com.ruoyi.home.service.HomeService;
import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper;
import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage;
import com.ruoyi.procurementrecord.utils.StockUtils;
import com.ruoyi.production.dto.ProductOrderDto;
import com.ruoyi.production.dto.ProductWorkOrderDto;
import com.ruoyi.production.mapper.ProductOrderMapper;
@@ -39,7 +36,6 @@
import com.ruoyi.production.mapper.ProductionProductInputMapper;
import com.ruoyi.production.mapper.ProductionProductOutputMapper;
import com.ruoyi.production.mapper.SalesLedgerProductionAccountingMapper;
import com.ruoyi.production.pojo.ProductProcess;
import com.ruoyi.production.pojo.ProductWorkOrder;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.mapper.SysDeptMapper;
@@ -145,7 +141,7 @@
    @Autowired
    private ProductProcessMapper productProcessMapper;
    @Autowired
    private AccountExpenseMapper accountExpenseMapper;
@@ -584,8 +580,8 @@
    public ProductionTurnoverDto workInProcessTurnover() {
        ProductionTurnoverDto productionTurnoverDto = new ProductionTurnoverDto();
        ProductWorkOrderDto workOrder = new ProductWorkOrderDto();
        workOrder.setPlanStartTime(LocalDate.now().minusMonths(1));
        workOrder.setPlanEndTime(LocalDate.now());
        workOrder.setPlanStartTime(LocalDateTime.now());
        workOrder.setPlanEndTime(LocalDateTime.now());
        List<ProductWorkOrderDto> productWorkOrders = productWorkOrderMapper
                .pageProductWorkOrder(new Page<>(1, -1), workOrder).getRecords();
        long sum = productWorkOrders.stream()
@@ -1589,30 +1585,31 @@
    @Override
    public List<MapDto> processOutputAnalysis(Integer type) {
        LocalDate today = LocalDate.now();
        LocalDate startDate;
        LocalDate endDate = today;
        // 获取当前时间点
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime startDateTime;
        LocalDateTime endDateTime = now.with(LocalTime.MAX);
        switch (type) {
            case 1: // 周
                startDate = today.with(DayOfWeek.MONDAY);
                startDateTime = now.with(DayOfWeek.MONDAY).with(LocalTime.MIN);
                break;
            case 2: // 月
                startDate = today.withDayOfMonth(1);
                startDateTime = now.withDayOfMonth(1).with(LocalTime.MIN);
                break;
            case 3: // 季度
                int currentMonth = today.getMonthValue();
                int currentMonth = now.getMonthValue();
                int startMonth = ((currentMonth - 1) / 3) * 3 + 1;
                startDate = LocalDate.of(today.getYear(), startMonth, 1);
                startDateTime = LocalDateTime.of(now.getYear(), startMonth, 1, 0, 0, 0);
                break;
            default:
                startDate = today.with(DayOfWeek.MONDAY);
                startDateTime = now.with(DayOfWeek.MONDAY).with(LocalTime.MIN);
                break;
        }
        ProductWorkOrderDto queryDto = new ProductWorkOrderDto();
        queryDto.setPlanStartTime(startDate);
        queryDto.setPlanEndTime(endDate);
        queryDto.setPlanStartTime(startDateTime);
        queryDto.setPlanEndTime(endDateTime);
        List<ProductWorkOrderDto> list = productWorkOrderMapper.pageProductWorkOrder(new Page<>(1, -1), queryDto)
                .getRecords();
@@ -1632,7 +1629,7 @@
        BigDecimal total = processOutputMap.values().stream()
                .reduce(BigDecimal.ZERO, BigDecimal::add);
        if (BigDecimal.ZERO.compareTo(total) == 0) {
        if (total.compareTo(BigDecimal.ZERO) == 0) {
            return new ArrayList<>();
        }
@@ -2480,8 +2477,7 @@
    }
    @Override
    public List<processDataProductionStatisticsDto> processDataProductionStatistics(Integer type,
                                                                                    List<Long> processIds) {
    public List<ProcessDataProductionStatisticsDto> processDataProductionStatistics(Integer type, List<Long> processTypes) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        Long userId = SecurityUtils.isAdmin(loginUser.getUserId()) ? null : loginUser.getUserId();
@@ -2510,6 +2506,24 @@
        LocalDateTime startDateTime = startDate.atStartOfDay();
        LocalDateTime endDateTime = endDate.atTime(LocalTime.MAX);
        return productProcessMapper.calculateProductionStatistics(startDateTime, endDateTime, userId, processIds);
        List<ProcessDataProductionStatisticsDto> result = productProcessMapper.calculateProductionStatistics(startDateTime, endDateTime, userId, processTypes);
        if (!ObjectUtils.isEmpty(result)) {
            result.forEach(dto -> {
                if (dto == null) {
                    return;
                }
                Integer processType = dto.getProcessType();
                String dictLabel = null;
                if (processType != null) {
                    dictLabel = DictUtils.getDictLabel("product_process_type", String.valueOf(processType));
                }
                if (StringUtils.isEmpty(dictLabel)) {
                    dictLabel = "其他";
                }
                dto.setProcessName(dictLabel);
            });
        }
        return result;
    }
}