gongchunyi
2026-04-28 e992aa74b2a75653f007ab12a83cfc28aee7d7a6
fix: 报工台账导出修改
已添加2个文件
已修改5个文件
221 ■■■■■ 文件已修改
src/main/java/com/ruoyi/production/controller/ProductionProductMainController.java 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductionProductMainDetailExportDto.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductionProductMainDto.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductionProductMainSummaryExportDto.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/ProductionProductMainService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductionProductMainMapper.xml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/controller/ProductionProductMainController.java
@@ -3,7 +3,9 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.production.dto.ProductionProductMainDetailExportDto;
import com.ruoyi.production.dto.ProductionProductMainDto;
import com.ruoyi.production.dto.ProductionProductMainSummaryExportDto;
import com.ruoyi.production.dto.ProductionReportDailySummaryDto;
import com.ruoyi.production.dto.ProductionReportStateDto;
import com.ruoyi.production.pojo.ProductionProductMain;
@@ -29,6 +31,7 @@
    /**
     * æŠ¥å·¥æŸ¥è¯¢
     *
     * @param page
     * @param productionProductMainDto
     * @return
@@ -64,6 +67,7 @@
    /**
     * æŠ¥å·¥æ–°å¢žæ›´æ–°
     *
     * @param productionProductMainDto
     * @return
     */
@@ -108,13 +112,35 @@
    /**
     * å¯¼å‡º
     * æŠ¥å·¥å°è´¦æ±‡æ€»å¯¼å‡º
     */
    @ApiOperation("报工台账汇总导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "workOrderIds", value = "工单ID列表, å¯ä¼ å¤šä¸ª", allowMultiple = true, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "workOrderNo", value = "工单编号(模糊)", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "workOrderStatus", value = "工单状态", dataType = "string", paramType = "query")
    })
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductionProductMainDto productionProductMainDto) {
        List<ProductionProductMainDto> list;
        list = productionProductMainService.listPageProductionProductMainDto(new Page<>(1, -1), productionProductMainDto).getRecords();
        ExcelUtil<ProductionProductMainDto> util = new ExcelUtil<ProductionProductMainDto>(ProductionProductMainDto.class);
        util.exportExcel(response, list, "生产报工数据");
        List<ProductionProductMainSummaryExportDto> list = productionProductMainService.listSummaryExportData(productionProductMainDto);
        ExcelUtil<ProductionProductMainSummaryExportDto> util = new ExcelUtil<>(ProductionProductMainSummaryExportDto.class);
        util.exportExcel(response, list, "生产报工汇总数据");
    }
    /**
     * æŠ¥å·¥æ˜Žç»†å¯¼å‡º
     */
    @ApiOperation("报工明细导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "workOrderIds", value = "工单ID列表, å¯ä¼ å¤šä¸ª", allowMultiple = true, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "workOrderId", value = "工单ID", dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始日期(按结束时间过滤, yyyy-MM-dd)", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束日期(按结束时间过滤, yyyy-MM-dd)", dataType = "string", paramType = "query")
    })
    @PostMapping("/exportDetail")
    public void exportDetail(HttpServletResponse response, ProductionProductMainDto productionProductMainDto) {
        List<ProductionProductMainDetailExportDto> list = productionProductMainService.listDetailExportData(productionProductMainDto);
        ExcelUtil<ProductionProductMainDetailExportDto> util = new ExcelUtil<>(ProductionProductMainDetailExportDto.class);
        util.exportExcel(response, list, "生产报工明细数据");
    }
}
src/main/java/com/ruoyi/production/dto/ProductionProductMainDetailExportDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,56 @@
package com.ruoyi.production.dto;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
public class ProductionProductMainDetailExportDto {
    @Excel(name = "产品编号", sort = 1)
    private String productNo;
    @Excel(name = "操作人员", sort = 2)
    private String nickName;
    @Excel(name = "工序", sort = 3)
    private String process;
    @Excel(name = "工单号", sort = 4)
    private String workOrderNo;
    @Excel(name = "销售合同号", sort = 5)
    private String salesContractNo;
    @Excel(name = "生产订单号", sort = 6)
    private String productOrderNpsNo;
    @Excel(name = "产品名称", sort = 7)
    private String productName;
    @Excel(name = "产品规格型号", sort = 8)
    private String productModelName;
    @Excel(name = "合格数量", sort = 9)
    private BigDecimal quantity;
    @Excel(name = "不合格数量", sort = 10)
    private BigDecimal scrapQty;
    @Excel(name = "单位", sort = 11)
    private String unit;
    @Excel(name = "工序标准工时(小时)", sort = 12)
    private BigDecimal processStandardHours;
    @Excel(name = "实际报工工时(小时)", sort = 13)
    private BigDecimal actualReportHours;
    @Excel(name = "每人每日工时(小时)", sort = 14)
    private BigDecimal dailyPersonHours;
    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 15)
    private LocalDateTime createTime;
}
src/main/java/com/ruoyi/production/dto/ProductionProductMainDto.java
@@ -12,6 +12,7 @@
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
@@ -63,6 +64,9 @@
    @ApiModelProperty(value = "结束日期(明细查询用)")
    private LocalDate endDate;
    @ApiModelProperty(value = "工单ID列表(明细导出用)")
    private List<Long> workOrderIds;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "日期(明细/汇总中使用)")
src/main/java/com/ruoyi/production/dto/ProductionProductMainSummaryExportDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,49 @@
package com.ruoyi.production.dto;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ProductionProductMainSummaryExportDto {
    @Excel(name = "工序", sort = 1)
    private String process;
    @Excel(name = "工单号", sort = 2)
    private String workOrderNo;
    @Excel(name = "销售合同号", sort = 3)
    private String salesContractNo;
    @Excel(name = "生产订单号", sort = 4)
    private String productOrderNpsNo;
    @Excel(name = "产品名称", sort = 5)
    private String productName;
    @Excel(name = "产品规格型号", sort = 6)
    private String productModelName;
    @Excel(name = "单位", sort = 7)
    private String unit;
    @Excel(name = "总工时", sort = 8)
    private BigDecimal projectTotalHours;
    @Excel(name = "工序标准工时(小时)", sort = 9)
    private BigDecimal processStandardHours;
    @Excel(name = "实际报工工时(小时)", sort = 10)
    private BigDecimal actualReportHours;
    @Excel(name = "每人每日工时(小时)", sort = 11)
    private BigDecimal dailyPersonHours;
    @Excel(name = "产出总数量", sort = 12)
    private BigDecimal outputTotalQuantity;
    @Excel(name = "报废总数量", sort = 13)
    private BigDecimal scrapTotalQuantity;
}
src/main/java/com/ruoyi/production/service/ProductionProductMainService.java
@@ -3,7 +3,9 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.production.dto.ProductionProductMainDetailExportDto;
import com.ruoyi.production.dto.ProductionProductMainDto;
import com.ruoyi.production.dto.ProductionProductMainSummaryExportDto;
import com.ruoyi.production.dto.ProductionReportDailySummaryDto;
import com.ruoyi.production.dto.ProductionReportStateDto;
import com.ruoyi.production.pojo.ProductionProductMain;
@@ -18,6 +20,10 @@
    IPage<ProductionProductMainDto> listPageProductionProductMainDetailDto(Page<ProductionProductMainDto> page, ProductionProductMainDto productionProductMainDto);
    List<ProductionProductMainSummaryExportDto> listSummaryExportData(ProductionProductMainDto productionProductMainDto);
    List<ProductionProductMainDetailExportDto> listDetailExportData(ProductionProductMainDto productionProductMainDto);
    Boolean addProductMain(ProductionProductMainDto productionProductMainDto);
    /**
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -18,7 +18,9 @@
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.procurementrecord.utils.StockUtils;
import com.ruoyi.production.dto.ProductionProductMainDetailExportDto;
import com.ruoyi.production.dto.ProductionProductMainDto;
import com.ruoyi.production.dto.ProductionProductMainSummaryExportDto;
import com.ruoyi.production.dto.ProductionReportDailySummaryDto;
import com.ruoyi.production.dto.ProductionReportStateDto;
import com.ruoyi.production.enums.ProductProcessEnum;
@@ -103,6 +105,58 @@
        return result;
    }
    @Override
    public List<ProductionProductMainSummaryExportDto> listSummaryExportData(ProductionProductMainDto productionProductMainDto) {
        return listPageProductionProductMainDto(new Page<>(1, -1), productionProductMainDto)
                .getRecords()
                .stream()
                .map(item -> {
                    ProductionProductMainSummaryExportDto exportDto = new ProductionProductMainSummaryExportDto();
                    exportDto.setProcess(item.getProcess());
                    exportDto.setWorkOrderNo(item.getWorkOrderNo());
                    exportDto.setSalesContractNo(item.getSalesContractNo());
                    exportDto.setProductOrderNpsNo(item.getProductOrderNpsNo());
                    exportDto.setProductName(item.getProductName());
                    exportDto.setProductModelName(item.getProductModelName());
                    exportDto.setUnit(item.getUnit());
                    exportDto.setProjectTotalHours(item.getProjectTotalHours());
                    exportDto.setProcessStandardHours(item.getProcessStandardHours());
                    exportDto.setActualReportHours(item.getActualReportHours());
                    exportDto.setDailyPersonHours(item.getDailyPersonHours());
                    exportDto.setOutputTotalQuantity(item.getOutputTotalQuantity());
                    exportDto.setScrapTotalQuantity(item.getScrapTotalQuantity());
                    return exportDto;
                })
                .collect(Collectors.toList());
    }
    @Override
    public List<ProductionProductMainDetailExportDto> listDetailExportData(ProductionProductMainDto productionProductMainDto) {
        return listPageProductionProductMainDetailDto(new Page<>(1, -1), productionProductMainDto)
                .getRecords()
                .stream()
                .map(item -> {
                    ProductionProductMainDetailExportDto exportDto = new ProductionProductMainDetailExportDto();
                    exportDto.setProductNo(item.getProductNo());
                    exportDto.setNickName(item.getNickName());
                    exportDto.setProcess(item.getProcess());
                    exportDto.setWorkOrderNo(item.getWorkOrderNo());
                    exportDto.setSalesContractNo(item.getSalesContractNo());
                    exportDto.setProductOrderNpsNo(item.getProductOrderNpsNo());
                    exportDto.setProductName(item.getProductName());
                    exportDto.setProductModelName(item.getProductModelName());
                    exportDto.setQuantity(item.getQuantity());
                    exportDto.setScrapQty(item.getScrapQty());
                    exportDto.setUnit(item.getUnit());
                    exportDto.setProcessStandardHours(item.getProcessStandardHours());
                    exportDto.setActualReportHours(item.getActualReportHours());
                    exportDto.setDailyPersonHours(item.getDailyPersonHours());
                    exportDto.setCreateTime(item.getCreateTime());
                    return exportDto;
                })
                .collect(Collectors.toList());
    }
    private void fillHourDefaults(List<ProductionProductMainDto> records) {
        if (records == null || records.isEmpty()) {
            return;
src/main/resources/mapper/production/ProductionProductMainMapper.xml
@@ -71,6 +71,14 @@
        left join sales_ledger sl on sl.id = po.sales_ledger_id
        left join sys_user u on u.user_id = ppm.user_id
        <where>
            and ppm.status = 1
            and ifnull(ppo.quantity, 0) > 0
            <if test="c.workOrderIds != null and c.workOrderIds.size() > 0">
                and ppm.work_order_id in
                <foreach collection="c.workOrderIds" item="workOrderId" open="(" separator="," close=")">
                    #{workOrderId}
                </foreach>
            </if>
            <if test="c.nickName != null and c.nickName != ''">
                and u.nick_name like concat('%',#{c.nickName},'%')
            </if>
@@ -139,6 +147,14 @@
        left join sales_ledger sl on sl.id = po.sales_ledger_id
        left join sys_user u on u.user_id = ppm.user_id
        <where>
            and ppm.status = 1
            and ifnull(ppo.quantity, 0) > 0
            <if test="c.workOrderIds != null and c.workOrderIds.size() > 0">
                and ppm.work_order_id in
                <foreach collection="c.workOrderIds" item="workOrderId" open="(" separator="," close=")">
                    #{workOrderId}
                </foreach>
            </if>
            <if test="c.workOrderId != null">
                and ppm.work_order_id = #{c.workOrderId}
            </if>