gongchunyi
3 天以前 711a9201dfcb8fe8d445a6cf940bc7e4a9182e9d
feat: 首页-计划与生产趋势
已添加1个文件
已修改3个文件
122 ■■■■■ 文件已修改
src/main/java/com/ruoyi/home/controller/HomeController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/home/dto/PlanTrendsDto.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/home/service/HomeService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/home/controller/HomeController.java
@@ -1,17 +1,14 @@
package com.ruoyi.home.controller;
import com.ruoyi.approve.pojo.ApproveProcess;
import com.ruoyi.energy.vo.EnergyStatisticsVo;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.home.annotation.DefaultType;
import com.ruoyi.home.dto.*;
import com.ruoyi.home.service.HomeService;
import com.ruoyi.dto.MapDto;
import com.ruoyi.productionPlan.service.SalesDeliveryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@@ -421,5 +418,11 @@
        return AjaxResult.success(homeService.manage());
    }
    @GetMapping("/planTrends")
    @ApiOperation("首页-计划与生产趋势")
    public AjaxResult planTrends(@DefaultType Integer type) {
        List<PlanTrendsDto> list = homeService.planTrends(type);
        return AjaxResult.success(list);
    }
}
src/main/java/com/ruoyi/home/dto/PlanTrendsDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,33 @@
package com.ruoyi.home.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
 * <br>
 * è®¡åˆ’与生产趋势Dto
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/04/02
 */
@Data
@ApiModel(value = "PlanTrendsDto", description = "计划与生产趋势Dto")
public class PlanTrendsDto {
    @ApiModelProperty("日期")
    private String dateStr;
    @ApiModelProperty("计划量")
    private BigDecimal plannedVolume;
    @ApiModelProperty("下发量")
    private BigDecimal lowerVolume;
    @ApiModelProperty("完成量")
    private BigDecimal completionVolume;
}
src/main/java/com/ruoyi/home/service/HomeService.java
@@ -127,4 +127,6 @@
    List<MapDto> typeDistribution(productionStatisticsDto dto);
    Map<String,Long> manage();
    List<PlanTrendsDto> planTrends(Integer type);
}
src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -36,6 +36,8 @@
import com.ruoyi.productionPlan.enums.AddressRegionEnum;
import com.ruoyi.productionPlan.mapper.SalesDeliveryMapper;
import com.ruoyi.productionPlan.pojo.SalesDelivery;
import com.ruoyi.productionPlan.pojo.ProductionPlan;
import com.ruoyi.productionPlan.service.ProductionPlanService;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.domain.SysDictData;
import com.ruoyi.project.system.mapper.SysDeptMapper;
@@ -3621,4 +3623,80 @@
        map.put("materialInspection", materialInspection);
        return map;
    }
    @Autowired
    private ProductionPlanService productionPlanService;
    @Override
    public List<PlanTrendsDto> planTrends(Integer type) {
        LocalDate now = LocalDate.now();
        LocalDate startDate;
        DateTimeFormatter formatter;
        int points;
        if (type == null) type = 1;
        if (type == 1) { // æ—¥
            points = 1;
            startDate = now;
            formatter = DateTimeFormatter.ofPattern("MM-dd");
        } else if (type == 2) { // å‘¨
            startDate = now.with(DayOfWeek.MONDAY);
            points = (int) ChronoUnit.DAYS.between(startDate, now) + 1;
            formatter = DateTimeFormatter.ofPattern("MM-dd");
        } else { // æœˆ
            startDate = now.with(TemporalAdjusters.firstDayOfMonth());
            points = now.getDayOfMonth();
            formatter = DateTimeFormatter.ofPattern("MM-dd");
        }
        Map<String, PlanTrendsDto> resultMap = new LinkedHashMap<>();
        for (int i = 0; i < points; i++) {
            String label = startDate.plusDays(i).format(formatter);
            PlanTrendsDto dto = new PlanTrendsDto();
            dto.setDateStr(label);
            dto.setPlannedVolume(BigDecimal.ZERO);
            dto.setLowerVolume(BigDecimal.ZERO);
            dto.setCompletionVolume(BigDecimal.ZERO);
            resultMap.put(label, dto);
        }
        //  ç»Ÿè®¡è®¡åˆ’量
        List<ProductionPlan> plans = productionPlanService.list(Wrappers.<ProductionPlan>lambdaQuery()
                .ge(ProductionPlan::getStartDate, Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant())));
        for (ProductionPlan plan : plans) {
            if (plan.getStartDate() == null || plan.getVolume() == null) continue;
            LocalDate d = plan.getStartDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
            String label = d.format(formatter);
            if (resultMap.containsKey(label)) {
                PlanTrendsDto dto = resultMap.get(label);
                dto.setPlannedVolume(dto.getPlannedVolume().add(plan.getVolume()));
            }
        }
        //  ç»Ÿè®¡ä¸‹å‘量
        List<ProductOrder> orders = productOrderMapper.selectList(Wrappers.<ProductOrder>lambdaQuery()
                .ge(ProductOrder::getStartTime, startDate.atStartOfDay()));
        for (ProductOrder order : orders) {
            if (order.getStartTime() == null || order.getQuantity() == null) continue;
            LocalDate d = order.getStartTime().toLocalDate();
            String label = d.format(formatter);
            if (resultMap.containsKey(label)) {
                PlanTrendsDto dto = resultMap.get(label);
                dto.setLowerVolume(dto.getLowerVolume().add(order.getQuantity()));
            }
        }
        //  ç»Ÿè®¡å®Œæˆé‡
        List<ProductionProductOutput> outputs = productionProductOutputMapper.selectList(Wrappers.<ProductionProductOutput>lambdaQuery()
                .ge(ProductionProductOutput::getCreateTime, startDate.atStartOfDay()));
        for (ProductionProductOutput output : outputs) {
            if (output.getCreateTime() == null || output.getQuantity() == null) continue;
            LocalDate d = output.getCreateTime().toLocalDate();
            String label = d.format(formatter);
            if (resultMap.containsKey(label)) {
                PlanTrendsDto dto = resultMap.get(label);
                dto.setCompletionVolume(dto.getCompletionVolume().add(output.getQuantity()));
            }
        }
        return new ArrayList<>(resultMap.values());
    }
}