已添加1个文件
已修改51个文件
1357 ■■■■ 文件已修改
doc/20260313_坤泰化工.sql 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/approve/controller/ApproveProcessController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/approve/pojo/ApproveProcess.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/approve/service/impl/ApproveNodeServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/approve/service/impl/ApproveProcessServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/approve/vo/ApproveProcessVO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/common/enums/FileNameType.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/common/enums/RawMaterialCheckResult.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/common/enums/RawMaterialCheckType.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/common/enums/RawMaterialInspectState.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/controller/ConsumablesInRecordController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/controller/ConsumablesInventoryController.java 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/controller/ConsumablesOutRecordController.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/controller/ConsumablesUnInventoryController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/mapper/ConsumablesInventoryMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/mapper/ConsumablesUnInventoryMapper.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/pojo/ConsumablesInRecord.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/pojo/ConsumablesOutRecord.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/service/ConsumablesOutRecordService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/service/ConsumablesUnInventoryService.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/service/impl/ConsumablesInRecordServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/service/impl/ConsumablesInventoryServiceImpl.java 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/service/impl/ConsumablesOutRecordServiceImpl.java 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/consumables/service/impl/ConsumablesUnInventoryServiceImpl.java 82 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/device/dto/DeviceRepairDto.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/device/pojo/DeviceRepair.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/device/service/impl/DeviceRepairServiceImpl.java 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/inspectiontask/pojo/QualityInspectItem.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/other/service/TempFileService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/other/service/impl/TempFileServiceImpl.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java 69 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/quality/controller/RawMaterialController.java 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/quality/dto/RawMaterialDto.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/quality/dto/RawMaterialQualityInspectItemDto.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/quality/pojo/RawMaterial.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/quality/pojo/RawMaterialQualityInspectItem.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/quality/service/RawMaterialService.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/quality/service/impl/RawMaterialServiceImpl.java 337 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/pojo/StockOutRecord.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/word/WeighbridgeDocGenerator.java 244 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-kthg.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/consumables/ConsumablesInRecordMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/consumables/ConsumablesInventoryMapper.xml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/consumables/ConsumablesOutRecordMapper.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/consumables/ConsumablesUninventoryMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/quality/RawMaterialMapper.xml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/stock/StockInRecordMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/stock/StockInventoryMapper.xml 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/stock/StockOutRecordMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/static/report-template.docx 补丁 | 查看 | 原始文档 | blame | 历史
doc/20260313_À¤Ì©»¯¹¤.sql
@@ -25,3 +25,6 @@
    update_time             datetime null comment '更新时间',
    unique idx_raw_material_id_quality_inspect_item_id (raw_material_id, quality_inspect_item_id)
);
alter table approve_process
    add approve_record_id bigint not null default 0;
src/main/java/com/ruoyi/approve/controller/ApproveProcessController.java
@@ -192,4 +192,14 @@
        ExcelUtil<ApproveProcess> util = new ExcelUtil<ApproveProcess>(ApproveProcess.class);
        util.exportExcel(response, accountExpenses, "危险作业审批导出");
    }
    @ApiOperation(value = "原料审批导出")
    @PostMapping("/exportNine")
    public void exportNine(HttpServletResponse response) {
        List<ApproveProcess> accountExpenses = approveProcessService.list(new LambdaQueryWrapper<ApproveProcess>()
                .eq(ApproveProcess::getApproveDelete, 0)
                .eq(ApproveProcess::getApproveType, 9));
        ExcelUtil<ApproveProcess> util = new ExcelUtil<ApproveProcess>(ApproveProcess.class);
        util.exportExcel(response, accountExpenses, "原料审批导出");
    }
}
src/main/java/com/ruoyi/approve/pojo/ApproveProcess.java
@@ -127,10 +127,15 @@
    private Long tenantId;
    /**
     * å®¡æ‰¹ç±»åž‹ 1-公出管理 2-请假管理 3-出差管理 4-报销管理 5-采购审批 6-报价审批 7-发货审批 8-危险作业审批
     * å®¡æ‰¹ç±»åž‹ 1-公出管理 2-请假管理 3-出差管理 4-报销管理 5-采购审批 6-报价审批 7-发货审批 8-危险作业审批 9-原料审批
     */
    private Integer approveType;
    /**
     * å®¡æ‰¹å…³è”记录id
     */
    private Long approveRecordId;
    @TableField(exist = false)
    private String approveTypeName;
src/main/java/com/ruoyi/approve/service/impl/ApproveNodeServiceImpl.java
@@ -325,6 +325,8 @@
                return "发货审批";
            case 8:
                return "危险作业审批";
            case 9:
                return "原料审批";
        }
        return null;
    }
src/main/java/com/ruoyi/approve/service/impl/ApproveProcessServiceImpl.java
@@ -115,6 +115,9 @@
        approveProcess.setApproveStatus(0);
        approveProcess.setApproveDelete(0);
        approveProcess.setApproveType(approveProcessVO.getApproveType());
        if (approveProcessVO.getApproveRecordId() != null) {
            approveProcess.setApproveRecordId(approveProcessVO.getApproveRecordId());
        }
        approveProcess.setCreateTime(LocalDateTime.now());
        approveProcess.setTenantId(approveProcessVO.getApproveDeptId());
        approveProcess.setApproveUserIds(approveProcessVO.getApproveUserIds());
@@ -441,6 +444,8 @@
                return "发货审批";
            case 8:
                return "危险作业审批";
            case 9:
                return "原料审批";
        }
        return null;
    }
src/main/java/com/ruoyi/approve/vo/ApproveProcessVO.java
@@ -67,6 +67,10 @@
     * å®¡æ‰¹ç±»åž‹
     */
    private Integer approveType;
    /**
     * å®¡æ‰¹å…³è”记录id
     */
    private Long approveRecordId;
     /**
     * è®¾å¤‡æŠ¥ä¿®id
     */
src/main/java/com/ruoyi/common/enums/FileNameType.java
@@ -14,7 +14,8 @@
    SHIP(9),//发货台账
    INSPECTION_PRODUCTION_BEFORE(10),
    INSPECTION_PRODUCTION_AFTER(11),
    INSPECTION(12);//巡检 ç”Ÿäº§å‰
    INSPECTION(12),//巡检 ç”Ÿäº§å‰
    DeviceRepair(13);// è®¾å¤‡ç»´ä¿®
    private final int value;
src/main/java/com/ruoyi/common/enums/RawMaterialCheckResult.java
@@ -26,10 +26,10 @@
     */
    public static RawMaterialCheckResult fromValue(Integer value) {
        for (RawMaterialCheckResult type : values()) {
            if (type.getValue().equals(value)) {
            if (type.getCode().equals(value)) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的 RawMaterialCheckResult å€¼: " + value);
        return null;
    }
}
src/main/java/com/ruoyi/common/enums/RawMaterialCheckType.java
@@ -27,10 +27,10 @@
     */
    public static RawMaterialCheckType fromValue(Integer value) {
        for (RawMaterialCheckType type : values()) {
            if (type.getValue().equals(value)) {
            if (type.getCode().equals(value)) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的 RawMaterialCheckType å€¼: " + value);
        return null;
    }
}
src/main/java/com/ruoyi/common/enums/RawMaterialInspectState.java
@@ -26,10 +26,10 @@
     */
    public static RawMaterialInspectState fromValue(Integer value) {
        for (RawMaterialInspectState type : values()) {
            if (type.getValue().equals(value)) {
            if (type.getCode().equals(value)) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的 RawMaterialInspectState å€¼: " + value);
        return null;
    }
}
src/main/java/com/ruoyi/consumables/controller/ConsumablesInRecordController.java
@@ -26,8 +26,8 @@
    @GetMapping("/listPage")
    @Log(title = "生产入库-入库管理-列表", businessType = BusinessType.OTHER)
    @ApiOperation(value = "入库管理列表")
    public AjaxResult listPage(Page page, ConsumablesInRecordDto ConsumablesInRecordDto) {
        IPage<ConsumablesInRecordDto> result = consumablesInRecordService.listPage(page, ConsumablesInRecordDto);
    public AjaxResult listPage(Page page, ConsumablesInRecordDto consumablesInRecordDto) {
        IPage<ConsumablesInRecordDto> result = consumablesInRecordService.listPage(page, consumablesInRecordDto);
        return AjaxResult.success(result);
    }
@@ -44,8 +44,8 @@
    @PostMapping("/exportConsumablesInRecord")
    @ApiOperation("导出入库记录")
    public void exportConsumablesInRecord(HttpServletResponse response, ConsumablesInRecordDto ConsumablesInRecordDto) {
        consumablesInRecordService.exportConsumablesInRecord(response,ConsumablesInRecordDto);
    public void exportConsumablesInRecord(HttpServletResponse response, ConsumablesInRecordDto consumablesInRecordDto) {
        consumablesInRecordService.exportConsumablesInRecord(response,consumablesInRecordDto);
    }
}
src/main/java/com/ruoyi/consumables/controller/ConsumablesInventoryController.java
@@ -35,37 +35,37 @@
public class ConsumablesInventoryController {
    @Autowired
    private ConsumablesInventoryService ConsumablesInventoryService;
    private ConsumablesInventoryService consumablesInventoryService;
    @GetMapping("/pageConsumablesInventory")
    @ApiOperation("分页查询库存")
    public R pageConsumablesInventory(Page page, ConsumablesInventoryDto ConsumablesInventoryDto) {
        IPage<ConsumablesInventoryDto> ConsumablesInventoryDtoIPage = ConsumablesInventoryService.pageConsumablesInventory(page, ConsumablesInventoryDto);
    public R pageConsumablesInventory(Page page, ConsumablesInventoryDto consumablesInventoryDto) {
        IPage<ConsumablesInventoryDto> ConsumablesInventoryDtoIPage = consumablesInventoryService.pageConsumablesInventory(page, consumablesInventoryDto);
        return R.ok(ConsumablesInventoryDtoIPage);
    }
    @PostMapping("/addConsumablesInventory")
    @ApiOperation("新增库存")
    public R addConsumablesInventory(@RequestBody ConsumablesInventoryDto ConsumablesInventoryDto) {
        ConsumablesInventoryDto.setRecordType(String.valueOf(StockInQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode()));
        ConsumablesInventoryDto.setRecordId(0L);
        return R.ok(ConsumablesInventoryService.addConsumablesInventory(ConsumablesInventoryDto));
    public R addConsumablesInventory(@RequestBody ConsumablesInventoryDto consumablesInventoryDto) {
        consumablesInventoryDto.setRecordType(String.valueOf(StockInQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode()));
        consumablesInventoryDto.setRecordId(0L);
        return R.ok(consumablesInventoryService.addConsumablesInventory(consumablesInventoryDto));
    }
    @PostMapping("/subtractConsumablesInventory")
    @ApiOperation("扣减库存")
    public R subtractConsumablesInventory(@RequestBody ConsumablesInventoryDto ConsumablesInventoryDto) {
        ConsumablesInventoryDto.setRecordType(String.valueOf(StockOutQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_OUT.getCode()));
        ConsumablesInventoryDto.setRecordId(0L);
        return R.ok(ConsumablesInventoryService.subtractConsumablesInventory(ConsumablesInventoryDto));
    public R subtractConsumablesInventory(@RequestBody ConsumablesInventoryDto consumablesInventoryDto) {
        consumablesInventoryDto.setRecordType(String.valueOf(StockOutQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_OUT.getCode()));
        consumablesInventoryDto.setRecordId(0L);
        return R.ok(consumablesInventoryService.subtractConsumablesInventory(consumablesInventoryDto));
    }
    @PostMapping("importConsumablesInventory")
    @ApiOperation("导入库存")
    public R importConsumablesInventory(MultipartFile file) {
        return ConsumablesInventoryService.importConsumablesInventory(file);
        return consumablesInventoryService.importConsumablesInventory(file);
    }
    @Log(title = "下载库存导入模板", businessType = BusinessType.EXPORT)
@@ -78,31 +78,31 @@
    @PostMapping("/exportConsumablesInventory")
    @ApiOperation("导出库存")
    public void exportConsumablesInventory(HttpServletResponse response, ConsumablesInventoryDto ConsumablesInventoryDto) {
        ConsumablesInventoryService.exportConsumablesInventory(response, ConsumablesInventoryDto);
    public void exportConsumablesInventory(HttpServletResponse response, ConsumablesInventoryDto consumablesInventoryDto) {
        consumablesInventoryService.exportConsumablesInventory(response, consumablesInventoryDto);
    }
    @GetMapping("ConsumablesInventoryPage")
    @ApiOperation("库存报表查询")
    public R ConsumablesInventoryPage(Page page, ConsumablesInventoryDto consumablesInventoryDto) {
        return R.ok(ConsumablesInventoryService.consumablesInventoryPage(consumablesInventoryDto,page));
        return R.ok(consumablesInventoryService.consumablesInventoryPage(consumablesInventoryDto,page));
    }
    @GetMapping("ConsumablesInAndOutRecord")
    @ApiOperation("统计各个产品的入库和出库记录")
    public R ConsumablesInAndOutRecord(ConsumablesInventoryDto consumablesInventoryDto, Page page) {
        return R.ok(ConsumablesInventoryService.consumablesInAndOutRecord(consumablesInventoryDto,page));
        return R.ok(consumablesInventoryService.consumablesInAndOutRecord(consumablesInventoryDto,page));
    }
    @PostMapping("/frozenConsumables")
    @ApiOperation("冻结库存")
    public R frozenConsumables(@RequestBody ConsumablesInventoryDto ConsumablesInventoryDto) {
        return R.ok(ConsumablesInventoryService.frozenConsumables(ConsumablesInventoryDto));
    public R frozenConsumables(@RequestBody ConsumablesInventoryDto consumablesInventoryDto) {
        return R.ok(consumablesInventoryService.frozenConsumables(consumablesInventoryDto));
    }
    @PostMapping("/thawConsumables")
    @ApiOperation("解冻库存")
    public R thawConsumables(@RequestBody ConsumablesInventoryDto ConsumablesInventoryDto) {
        return R.ok(ConsumablesInventoryService.thawConsumables(ConsumablesInventoryDto));
    public R thawConsumables(@RequestBody ConsumablesInventoryDto consumablesInventoryDto) {
        return R.ok(consumablesInventoryService.thawConsumables(consumablesInventoryDto));
    }
}
src/main/java/com/ruoyi/consumables/controller/ConsumablesOutRecordController.java
@@ -34,21 +34,21 @@
    @GetMapping("/listPage")
    @Log(title = "生产出库-出库管理-列表", businessType = BusinessType.OTHER)
    @ApiOperation(value = "出库管理列表")
    public AjaxResult listPage(Page page, ConsumablesOutRecordDto ConsumablesOutRecordDto) {
        IPage<ConsumablesOutRecordDto> result = consumablesUnInventoryDto.listPage(page, ConsumablesOutRecordDto);
    public AjaxResult listPage(Page page, ConsumablesOutRecordDto consumablesOutRecordDto) {
        IPage<ConsumablesOutRecordDto> result = consumablesUnInventoryDto.listPage(page, consumablesOutRecordDto);
        return AjaxResult.success(result);
    }
    @PostMapping("")
    @Log(title = "出库管理-新增出库", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody ConsumablesOutRecordDto ConsumablesOutRecordDto) {
        return AjaxResult.success(consumablesUnInventoryDto.add(ConsumablesOutRecordDto));
    public AjaxResult add(@RequestBody ConsumablesOutRecordDto consumablesOutRecordDto) {
        return AjaxResult.success(consumablesUnInventoryDto.add(consumablesOutRecordDto));
    }
    @PutMapping("/{id}")
    @Log(title = "出库管理-更新出库", businessType = BusinessType.UPDATE)
    public AjaxResult update(@PathVariable("id") Long id, @RequestBody ConsumablesOutRecordDto ConsumablesOutRecordDto) {
        return AjaxResult.success(consumablesUnInventoryDto.update(id, ConsumablesOutRecordDto));
    public AjaxResult update(@PathVariable("id") Long id, @RequestBody ConsumablesOutRecordDto consumablesOutRecordDto) {
        return AjaxResult.success(consumablesUnInventoryDto.update(id, consumablesOutRecordDto));
    }
    @DeleteMapping("")
@@ -62,8 +62,8 @@
    @PostMapping("/exportConsumablesOutRecord")
    @ApiOperation("导出出库记录")
    public void exportConsumablesOutRecord(HttpServletResponse response, ConsumablesOutRecordDto ConsumablesOutRecordDto) {
        consumablesUnInventoryDto.exportConsumablesOutRecord(response,ConsumablesOutRecordDto);
    public void exportConsumablesOutRecord(HttpServletResponse response, ConsumablesOutRecordDto consumablesOutRecordDto) {
        consumablesUnInventoryDto.exportConsumablesOutRecord(response,consumablesOutRecordDto);
    }
}
src/main/java/com/ruoyi/consumables/controller/ConsumablesUnInventoryController.java
@@ -33,8 +33,8 @@
    @GetMapping("/pageConsumablesUnInventory")
    @ApiOperation("分页查询库存")
    public R pageConsumablesUnInventory(Page page, ConsumablesUnInventoryDto consumablesUnInventoryDto) {
        IPage<ConsumablesUnInventoryDto> ConsumablesUnInventoryDtoIPage = consumablesUnInventoryService.pageConsumablesUnInventory(page, consumablesUnInventoryDto);
        return R.ok(ConsumablesUnInventoryDtoIPage);
        IPage<ConsumablesUnInventoryDto> consumablesUnInventoryDtoIPage = consumablesUnInventoryService.pageConsumablesUnInventory(page, consumablesUnInventoryDto);
        return R.ok(consumablesUnInventoryDtoIPage);
    }
    @PostMapping("/addConsumablesUnInventory")
src/main/java/com/ruoyi/consumables/mapper/ConsumablesInventoryMapper.java
@@ -36,9 +36,9 @@
    List<ConsumablesInventoryExportData> listConsumablesInventoryExportData(@Param("ew") ConsumablesInventoryDto ConsumablesInventoryDto);
    IPage<ConsumablesInRecordDto> ConsumablesInventoryPage(@Param("ew") ConsumablesInventoryDto ConsumablesInventoryDto, Page page);
    IPage<ConsumablesInRecordDto> consumablesInventoryPage(@Param("ew") ConsumablesInventoryDto ConsumablesInventoryDto, Page page);
    IPage<ConsumablesInventoryDto> ConsumablesInAndOutRecord(@Param("ew") ConsumablesInventoryDto ConsumablesInventoryDto, Page page);
    IPage<ConsumablesInventoryDto> consumablesInAndOutRecord(@Param("ew") ConsumablesInventoryDto ConsumablesInventoryDto, Page page);
    BigDecimal selectTotal();
src/main/java/com/ruoyi/consumables/mapper/ConsumablesUnInventoryMapper.java
@@ -22,11 +22,11 @@
@Mapper
public interface ConsumablesUnInventoryMapper extends BaseMapper<ConsumablesUnInventory> {
    IPage<ConsumablesUnInventoryDto> pageConsumablesUnInventory(Page page, @Param("ew") ConsumablesUnInventoryDto ConsumablesUnInventoryDto);
    IPage<ConsumablesUnInventoryDto> pageConsumablesUnInventory(Page page, @Param("ew") ConsumablesUnInventoryDto consumablesUnInventoryDto);
    int updateSubtractConsumablesUnInventory(@Param("ew") ConsumablesUnInventoryDto ConsumablesUnInventoryDto);
    int updateSubtractConsumablesUnInventory(@Param("ew") ConsumablesUnInventoryDto consumablesUnInventoryDto);
    int updateAddConsumablesUnInventory(@Param("ew") ConsumablesUnInventoryDto ConsumablesUnInventoryDto);
    int updateAddConsumablesUnInventory(@Param("ew") ConsumablesUnInventoryDto consumablesUnInventoryDto);
    List<ConsumablesUnInventoryExportData> listConsumablesInventoryExportData(@Param("ew") ConsumablesUnInventoryDto ConsumablesUnInventoryDto);
    List<ConsumablesUnInventoryExportData> listConsumablesInventoryExportData(@Param("ew") ConsumablesUnInventoryDto consumablesUnInventoryDto);
}
src/main/java/com/ruoyi/consumables/pojo/ConsumablesInRecord.java
@@ -27,7 +27,7 @@
    private String inboundBatches;
    @ApiModelProperty(value = "入库数量")
    private BigDecimal consumablesInNum;
    private BigDecimal stockInNum;
    @ApiModelProperty(value = "记录类型  æžšä¸¾")
    private String recordType;
src/main/java/com/ruoyi/consumables/pojo/ConsumablesOutRecord.java
@@ -35,7 +35,7 @@
    private String outboundBatches;
    @ApiModelProperty("入库数量")
    private BigDecimal consumablesOutNum;
    private BigDecimal stockOutNum;
    @ApiModelProperty("入库来源id")
    private Long recordId;
@@ -94,4 +94,7 @@
    @ApiModelProperty("产品id")
    private Long productId;
    @ApiModelProperty("磅单文件路径")
    private String weighbridgeDocPath;
}
src/main/java/com/ruoyi/consumables/service/ConsumablesOutRecordService.java
@@ -18,13 +18,13 @@
 * @since 2026-01-21 05:27:04
 */
public interface ConsumablesOutRecordService extends IService<ConsumablesOutRecord> {
    IPage<ConsumablesOutRecordDto> listPage(Page page, ConsumablesOutRecordDto ConsumablesOutRecordDto);
    IPage<ConsumablesOutRecordDto> listPage(Page page, ConsumablesOutRecordDto consumablesOutRecordDto);
    int add(ConsumablesOutRecordDto ConsumablesOutRecordDto);
    int add(ConsumablesOutRecordDto consumablesOutRecordDto);
    int update(Long id, ConsumablesOutRecordDto ConsumablesOutRecordDto);
    int update(Long id, ConsumablesOutRecordDto consumablesOutRecordDto);
    int batchDelete(List<Long> ids);
    void exportConsumablesOutRecord(HttpServletResponse response, ConsumablesOutRecordDto ConsumablesOutRecordDto);
    void exportConsumablesOutRecord(HttpServletResponse response, ConsumablesOutRecordDto consumablesOutRecordDto);
}
src/main/java/com/ruoyi/consumables/service/ConsumablesUnInventoryService.java
@@ -19,15 +19,15 @@
 */
public interface ConsumablesUnInventoryService extends IService<ConsumablesUnInventory> {
    IPage<ConsumablesUnInventoryDto> pageConsumablesUnInventory(Page page, ConsumablesUnInventoryDto ConsumablesUnInventoryDto);
    IPage<ConsumablesUnInventoryDto> pageConsumablesUnInventory(Page page, ConsumablesUnInventoryDto consumablesUnInventoryDto);
    Integer addConsumablesUnInventory(ConsumablesUnInventoryDto ConsumablesUnInventoryDto);
    Integer addConsumablesUnInventory(ConsumablesUnInventoryDto consumablesUnInventoryDto);
    Integer subtractConsumablesUnInventory(ConsumablesUnInventoryDto ConsumablesUnInventoryDto);
    Integer subtractConsumablesUnInventory(ConsumablesUnInventoryDto consumablesUnInventoryDto);
    void exportConsumablesUnInventory(HttpServletResponse response, ConsumablesUnInventoryDto ConsumablesUnInventoryDto);
    void exportConsumablesUnInventory(HttpServletResponse response, ConsumablesUnInventoryDto consumablesUnInventoryDto);
    Boolean frozenConsumables(ConsumablesInventoryDto ConsumablesInventoryDto);
    Boolean frozenConsumables(ConsumablesInventoryDto consumablesInventoryDto);
    Boolean thawConsumables(ConsumablesInventoryDto ConsumablesInventoryDto);
    Boolean thawConsumables(ConsumablesInventoryDto consumablesInventoryDto);
}
src/main/java/com/ruoyi/consumables/service/impl/ConsumablesInRecordServiceImpl.java
@@ -79,7 +79,7 @@
                }else {
                    ConsumablesInventoryDto consumablesInRecordDto = new ConsumablesInventoryDto();
                    consumablesInRecordDto.setProductModelId(consumablesInventory.getProductModelId());
                    consumablesInRecordDto.setQualitity(consumablesInRecord.getConsumablesInNum());
                    consumablesInRecordDto.setQualitity(consumablesInRecord.getStockInNum());
                    consumablesInventoryMapper.updateSubtractConsumablesInventory(consumablesInRecordDto);
                }
            }else if (consumablesInRecord.getType().equals("1")) {
@@ -89,7 +89,7 @@
                }else {
                    ConsumablesUnInventoryDto consumablesUnInventoryDto = new ConsumablesUnInventoryDto();
                    consumablesUnInventoryDto.setProductModelId(consumablesUnInventory.getProductModelId());
                    consumablesUnInventoryDto.setQualitity(consumablesInRecord.getConsumablesInNum());
                    consumablesUnInventoryDto.setQualitity(consumablesInRecord.getStockInNum());
                    consumablesUnInventoryMapper.updateSubtractConsumablesUnInventory(consumablesUnInventoryDto);
                }
            }
src/main/java/com/ruoyi/consumables/service/impl/ConsumablesInventoryServiceImpl.java
@@ -19,8 +19,10 @@
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.stock.dto.StockInRecordDto;
import com.ruoyi.stock.word.WeighbridgeDocGenerator;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -43,14 +45,15 @@
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class ConsumablesInventoryServiceImpl extends ServiceImpl<ConsumablesInventoryMapper, ConsumablesInventory> implements ConsumablesInventoryService {
    private final ConsumablesInventoryMapper ConsumablesInventoryMapper;
    private final ConsumablesInRecordService ConsumablesInRecordService;
    private final ConsumablesOutRecordService ConsumablesOutRecordService;
    private final ConsumablesInventoryMapper consumablesInventoryMapper;
    private final ConsumablesInRecordService consumablesInRecordService;
    private final ConsumablesOutRecordService consumablesOutRecordService;
    private final SalesLedgerProductMapper salesLedgerProductMapper;
    private final WeighbridgeDocGenerator weighbridgeDocGenerator;
    @Override
    public IPage<ConsumablesInventoryDto> pageConsumablesInventory(Page page, ConsumablesInventoryDto ConsumablesInventoryDto) {
        return ConsumablesInventoryMapper.pageConsumablesInventory(page, ConsumablesInventoryDto);
    public IPage<ConsumablesInventoryDto> pageConsumablesInventory(Page page, ConsumablesInventoryDto consumablesInventoryDto) {
        return consumablesInventoryMapper.pageConsumablesInventory(page, consumablesInventoryDto);
    }
    //入库调用
@@ -61,7 +64,7 @@
        ConsumablesInRecordDto consumablesInRecordDto = new ConsumablesInRecordDto();
        consumablesInRecordDto.setRecordId(consumablesInventoryDto.getRecordId());
        consumablesInRecordDto.setRecordType(consumablesInventoryDto.getRecordType());
        consumablesInRecordDto.setConsumablesInNum(consumablesInventoryDto.getNetWeight());
        consumablesInRecordDto.setStockInNum(consumablesInventoryDto.getNetWeight());
        consumablesInRecordDto.setWeighingDate(consumablesInventoryDto.getWeighingDate());
        consumablesInRecordDto.setNetWeight(consumablesInventoryDto.getNetWeight());
        consumablesInRecordDto.setGrossWeight(consumablesInventoryDto.getGrossWeight());
@@ -71,10 +74,15 @@
        consumablesInRecordDto.setProductModelId(consumablesInventoryDto.getProductModelId());
        consumablesInRecordDto.setProductId(consumablesInventoryDto.getProductId());
        consumablesInRecordDto.setType("0");
        ConsumablesInRecordService.add(consumablesInRecordDto);
        //生成磅单
        StockInRecordDto stockInRecordDto = new StockInRecordDto();
        BeanUtils.copyProperties(consumablesInventoryDto, stockInRecordDto);
        String absoluteDocPath = weighbridgeDocGenerator.generateWeighbridgeDoc(stockInRecordDto);
        consumablesInRecordDto.setWeighbridgeDocPath(absoluteDocPath);
        consumablesInRecordService.add(consumablesInRecordDto);
        //再进行新增库存数量库存
        //先查询库存表中的产品是否存在,不存在新增,存在更新
        ConsumablesInventory oldConsumablesInventory = ConsumablesInventoryMapper.selectOne(new QueryWrapper<ConsumablesInventory>().lambda().eq(ConsumablesInventory::getProductModelId, consumablesInventoryDto.getProductModelId()));
        ConsumablesInventory oldConsumablesInventory = consumablesInventoryMapper.selectOne(new QueryWrapper<ConsumablesInventory>().lambda().eq(ConsumablesInventory::getProductModelId, consumablesInventoryDto.getProductModelId()));
        if (ObjectUtils.isEmpty(oldConsumablesInventory)) {
            ConsumablesInventory newConsumablesInventory = new ConsumablesInventory();
            newConsumablesInventory.setProductModelId(consumablesInventoryDto.getProductModelId());
@@ -83,10 +91,11 @@
            newConsumablesInventory.setRemark(consumablesInventoryDto.getRemark());
            newConsumablesInventory.setLockedQuantity(consumablesInventoryDto.getLockedQuantity());
            newConsumablesInventory.setWarnNum(consumablesInventoryDto.getWarnNum());
            ConsumablesInventoryMapper.insert(newConsumablesInventory);
            newConsumablesInventory.setProductId(consumablesInventoryDto.getProductId());
            consumablesInventoryMapper.insert(newConsumablesInventory);
        } else {
            consumablesInventoryDto.setQualitity(consumablesInventoryDto.getNetWeight());
            ConsumablesInventoryMapper.updateAddConsumablesInventory(consumablesInventoryDto);
            consumablesInventoryMapper.updateAddConsumablesInventory(consumablesInventoryDto);
        }
        return true;
    }
@@ -100,7 +109,7 @@
        consumablesOutRecordDto.setRecordId(consumablesInventoryDto.getRecordId());
        consumablesOutRecordDto.setRecordType(consumablesInventoryDto.getRecordType());
        consumablesOutRecordDto.setWeighingDate(consumablesInventoryDto.getWeighingDate());
        consumablesOutRecordDto.setConsumablesOutNum(consumablesInventoryDto.getNetWeight());
        consumablesOutRecordDto.setStockOutNum(consumablesInventoryDto.getNetWeight());
        consumablesOutRecordDto.setNetWeight(consumablesInventoryDto.getNetWeight());
        consumablesOutRecordDto.setGrossWeight(consumablesInventoryDto.getGrossWeight());
        consumablesOutRecordDto.setTareWeight(consumablesInventoryDto.getTareWeight());
@@ -109,8 +118,13 @@
        consumablesOutRecordDto.setLicensePlateNo(consumablesInventoryDto.getLicensePlateNo());
        consumablesOutRecordDto.setProductId(consumablesInventoryDto.getProductId());
        consumablesOutRecordDto.setType("0");
        ConsumablesOutRecordService.add(consumablesOutRecordDto);
        ConsumablesInventory oldConsumablesInventory = ConsumablesInventoryMapper.selectOne(new QueryWrapper<ConsumablesInventory>().lambda().eq(ConsumablesInventory::getProductModelId, consumablesInventoryDto.getProductModelId()));
        //生成磅单
        StockInRecordDto stockInRecordDto = new StockInRecordDto();
        BeanUtils.copyProperties(consumablesInventoryDto, stockInRecordDto);
        String absoluteDocPath = weighbridgeDocGenerator.generateWeighbridgeDoc(stockInRecordDto);
        consumablesOutRecordDto.setWeighbridgeDocPath(absoluteDocPath);
        consumablesOutRecordService.add(consumablesOutRecordDto);
        ConsumablesInventory oldConsumablesInventory = consumablesInventoryMapper.selectOne(new QueryWrapper<ConsumablesInventory>().lambda().eq(ConsumablesInventory::getProductModelId, consumablesInventoryDto.getProductModelId()));
        if (ObjectUtils.isEmpty(oldConsumablesInventory)) {
            throw new RuntimeException("产品库存不存在");
        }
@@ -122,7 +136,7 @@
            throw new RuntimeException("库存不足无法出库");
        }
        ConsumablesInventoryMapper.updateSubtractConsumablesInventory(consumablesInventoryDto);
        consumablesInventoryMapper.updateSubtractConsumablesInventory(consumablesInventoryDto);
        return true;
    }
@@ -143,18 +157,18 @@
                for (SalesLedgerProduct item : salesLedgerProducts) {
                    if (item.getProductCategory().equals(dto.getProductName()) &&
                            item.getSpecificationModel().equals(dto.getModel())) {
                        ConsumablesInventoryDto ConsumablesInventoryDto = new ConsumablesInventoryDto();
                        ConsumablesInventoryDto.setRecordId(0L);
                        ConsumablesInventoryDto.setRecordType(StockInQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode());
                        ConsumablesInventoryDto.setQualitity(dto.getQualitity());
                        ConsumablesInventoryDto.setRemark(dto.getRemark());
                        ConsumablesInventoryDto.setWarnNum(dto.getWarnNum());
                        ConsumablesInventoryDto consumablesInventoryDto = new ConsumablesInventoryDto();
                        consumablesInventoryDto.setRecordId(0L);
                        consumablesInventoryDto.setRecordType(StockInQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode());
                        consumablesInventoryDto.setQualitity(dto.getQualitity());
                        consumablesInventoryDto.setRemark(dto.getRemark());
                        consumablesInventoryDto.setWarnNum(dto.getWarnNum());
                        if (ObjectUtils.isNotEmpty(dto.getLockedQuantity()) && dto.getLockedQuantity().compareTo(dto.getQualitity()) > 0) {
                            throw new RuntimeException("冻结数量不能超过本次导入的库存数量");
                        }
                        ConsumablesInventoryDto.setLockedQuantity(dto.getLockedQuantity());
                        ConsumablesInventoryDto.setProductModelId(item.getProductModelId());
                        this.addConsumablesInventory(ConsumablesInventoryDto);
                        consumablesInventoryDto.setLockedQuantity(dto.getLockedQuantity());
                        consumablesInventoryDto.setProductModelId(item.getProductModelId());
                        this.addConsumablesInventory(consumablesInventoryDto);
                        matched = true;
                        break; // æ‰¾åˆ°åŒ¹é…é¡¹åŽè·³å‡ºå¾ªçޝ
                    }
@@ -184,44 +198,44 @@
    @Override
    public void exportConsumablesInventory(HttpServletResponse response, ConsumablesInventoryDto ConsumablesInventoryDto) {
    public void exportConsumablesInventory(HttpServletResponse response, ConsumablesInventoryDto consumablesInventoryDto) {
        List<ConsumablesInventoryExportData> list = ConsumablesInventoryMapper.listConsumablesInventoryExportData(ConsumablesInventoryDto);
        List<ConsumablesInventoryExportData> list = consumablesInventoryMapper.listConsumablesInventoryExportData(consumablesInventoryDto);
        ExcelUtil<ConsumablesInventoryExportData> util = new ExcelUtil<>(ConsumablesInventoryExportData.class);
        util.exportExcel(response, list, "库存信息");
    }
    @Override
    public IPage<ConsumablesInRecordDto> consumablesInventoryPage(ConsumablesInventoryDto consumablesInventoryDto, Page page) {
        return ConsumablesInventoryMapper.ConsumablesInventoryPage(consumablesInventoryDto, page);
        return consumablesInventoryMapper.consumablesInventoryPage(consumablesInventoryDto, page);
    }
    @Override
    public IPage<ConsumablesInventoryDto> consumablesInAndOutRecord(ConsumablesInventoryDto consumablesInventoryDto, Page page) {
        return ConsumablesInventoryMapper.ConsumablesInAndOutRecord(consumablesInventoryDto, page);
        return consumablesInventoryMapper.consumablesInAndOutRecord(consumablesInventoryDto, page);
    }
    @Override
    public Boolean frozenConsumables(ConsumablesInventoryDto ConsumablesInventoryDto) {
        ConsumablesInventory ConsumablesInventory = ConsumablesInventoryMapper.selectById(ConsumablesInventoryDto.getId());
        if (ConsumablesInventory.getQualitity().compareTo(ConsumablesInventoryDto.getLockedQuantity()) < 0) {
    public Boolean frozenConsumables(ConsumablesInventoryDto consumablesInventoryDto) {
        ConsumablesInventory consumablesInventory = consumablesInventoryMapper.selectById(consumablesInventoryDto.getId());
        if (consumablesInventory.getQualitity().compareTo(consumablesInventoryDto.getLockedQuantity()) < 0) {
            throw new RuntimeException("冻结数量不能超过库存数量");
        }
        if (ObjectUtils.isEmpty(ConsumablesInventory.getLockedQuantity())) {
            ConsumablesInventory.setLockedQuantity(ConsumablesInventoryDto.getLockedQuantity());
        if (ObjectUtils.isEmpty(consumablesInventory.getLockedQuantity())) {
            consumablesInventory.setLockedQuantity(consumablesInventoryDto.getLockedQuantity());
        } else {
            ConsumablesInventory.setLockedQuantity(ConsumablesInventory.getLockedQuantity().add(ConsumablesInventoryDto.getLockedQuantity()));
            consumablesInventory.setLockedQuantity(consumablesInventory.getLockedQuantity().add(consumablesInventoryDto.getLockedQuantity()));
        }
        return this.updateById(ConsumablesInventory);
        return this.updateById(consumablesInventory);
    }
    @Override
    public Boolean thawConsumables(ConsumablesInventoryDto ConsumablesInventoryDto) {
        ConsumablesInventory ConsumablesInventory = ConsumablesInventoryMapper.selectById(ConsumablesInventoryDto.getId());
        if (ConsumablesInventory.getLockedQuantity().compareTo(ConsumablesInventoryDto.getLockedQuantity()) < 0) {
    public Boolean thawConsumables(ConsumablesInventoryDto consumablesInventoryDto) {
        ConsumablesInventory consumablesInventory = consumablesInventoryMapper.selectById(consumablesInventoryDto.getId());
        if (consumablesInventory.getLockedQuantity().compareTo(consumablesInventoryDto.getLockedQuantity()) < 0) {
            throw new RuntimeException("解冻数量不能超过冻结数量");
        }
        ConsumablesInventory.setLockedQuantity(ConsumablesInventory.getLockedQuantity().subtract(ConsumablesInventoryDto.getLockedQuantity()));
        return this.updateById(ConsumablesInventory);
        consumablesInventory.setLockedQuantity(consumablesInventory.getLockedQuantity().subtract(consumablesInventoryDto.getLockedQuantity()));
        return this.updateById(consumablesInventory);
    }
}
src/main/java/com/ruoyi/consumables/service/impl/ConsumablesOutRecordServiceImpl.java
@@ -18,7 +18,6 @@
import com.ruoyi.consumables.mapper.ConsumablesInventoryMapper;
import com.ruoyi.consumables.mapper.ConsumablesOutRecordMapper;
import com.ruoyi.consumables.mapper.ConsumablesUnInventoryMapper;
import com.ruoyi.consumables.pojo.ConsumablesInRecord;
import com.ruoyi.consumables.pojo.ConsumablesInventory;
import com.ruoyi.consumables.pojo.ConsumablesOutRecord;
import com.ruoyi.consumables.pojo.ConsumablesUnInventory;
@@ -45,30 +44,28 @@
    private ConsumablesUnInventoryMapper consumablesUnInventoryMapper;
    @Override
    public IPage<ConsumablesOutRecordDto> listPage(Page page, ConsumablesOutRecordDto ConsumablesOutRecordDto) {
        return consumablesOutRecordMapper.listPage(page, ConsumablesOutRecordDto);
    public IPage<ConsumablesOutRecordDto> listPage(Page page, ConsumablesOutRecordDto consumablesOutRecordDto) {
        return consumablesOutRecordMapper.listPage(page, consumablesOutRecordDto);
    }
    @Override
    public int add(ConsumablesOutRecordDto ConsumablesOutRecordDto) {
    public int add(ConsumablesOutRecordDto consumablesOutRecordDto) {
        String no = OrderUtils.countTodayByCreateTime(consumablesOutRecordMapper, "CK");
        ConsumablesOutRecordDto.setOutboundBatches(no);
        ConsumablesInRecord ConsumablesInRecord = new ConsumablesInRecord();
        BeanUtils.copyProperties(ConsumablesOutRecordDto, ConsumablesInRecord);
        return consumablesOutRecordMapper.insert(ConsumablesOutRecordDto);
        consumablesOutRecordDto.setOutboundBatches(no);
        return consumablesOutRecordMapper.insert(consumablesOutRecordDto);
    }
    @Override
    public int update(Long id, ConsumablesOutRecordDto ConsumablesOutRecordDto) {
    public int update(Long id, ConsumablesOutRecordDto consumablesOutRecordDto) {
        // åˆ¤æ–­å¯¹è±¡æ˜¯å¦å­˜åœ¨
        ConsumablesOutRecord ConsumablesOutRecord = consumablesOutRecordMapper.selectById(id);
        if (ConsumablesOutRecord == null){
        ConsumablesOutRecord consumablesOutRecord = consumablesOutRecordMapper.selectById(id);
        if (consumablesOutRecord == null){
            throw new BaseException("该出库记录不存在,无法更新!!!");
        }
        String[] ignoreProperties = {"id", "outbound_batches"};//排除id属性
        BeanUtils.copyProperties(ConsumablesOutRecordDto, ConsumablesOutRecord, ignoreProperties);
        return consumablesOutRecordMapper.updateById(ConsumablesOutRecord);
        BeanUtils.copyProperties(consumablesOutRecordDto, consumablesOutRecord, ignoreProperties);
        return consumablesOutRecordMapper.updateById(consumablesOutRecord);
    }
    @Override
@@ -82,7 +79,7 @@
                }else {
                    ConsumablesInventoryDto consumablesInRecordDto = new ConsumablesInventoryDto();
                    consumablesInRecordDto.setProductModelId(consumablesInventory.getProductModelId());
                    consumablesInRecordDto.setQualitity(consumablesOutRecord.getConsumablesOutNum());
                    consumablesInRecordDto.setQualitity(consumablesOutRecord.getStockOutNum());
                    consumablesInventoryMapper.updateAddConsumablesInventory(consumablesInRecordDto);
                }
            }else if (consumablesOutRecord.getType().equals("1")) {
@@ -92,7 +89,7 @@
                }else {
                    ConsumablesUnInventoryDto consumablesUnInventoryDto = new ConsumablesUnInventoryDto();
                    consumablesUnInventoryDto.setProductModelId(consumablesUnInventory.getProductModelId());
                    consumablesUnInventoryDto.setQualitity(consumablesOutRecord.getConsumablesOutNum());
                    consumablesUnInventoryDto.setQualitity(consumablesOutRecord.getStockOutNum());
                    consumablesUnInventoryMapper.updateAddConsumablesUnInventory(consumablesUnInventoryDto);
                }
            }
@@ -101,8 +98,8 @@
    }
    @Override
    public void exportConsumablesOutRecord(HttpServletResponse response, ConsumablesOutRecordDto ConsumablesOutRecordDto) {
        List<ConsumablesOutRecordExportData> list = consumablesOutRecordMapper.listConsumablesOutRecordExportData(ConsumablesOutRecordDto);
    public void exportConsumablesOutRecord(HttpServletResponse response, ConsumablesOutRecordDto consumablesOutRecordDto) {
        List<ConsumablesOutRecordExportData> list = consumablesOutRecordMapper.listConsumablesOutRecordExportData(consumablesOutRecordDto);
        for (ConsumablesOutRecordExportData consumablesInRecordExportData : list) {
            if (consumablesInRecordExportData.getType().equals("0")) {
                consumablesInRecordExportData.setRecordType(EnumUtil.fromCode(StockOutQualifiedRecordTypeEnum.class, Integer.parseInt(consumablesInRecordExportData.getRecordType())).getValue());
src/main/java/com/ruoyi/consumables/service/impl/ConsumablesUnInventoryServiceImpl.java
@@ -35,91 +35,91 @@
@AllArgsConstructor
public class ConsumablesUnInventoryServiceImpl extends ServiceImpl<ConsumablesUnInventoryMapper, ConsumablesUnInventory> implements ConsumablesUnInventoryService {
    private ConsumablesUnInventoryMapper ConsumablesUnInventoryMapper;
    private ConsumablesUnInventoryMapper consumablesUnInventoryMapper;
    private ConsumablesOutRecordService ConsumablesOutRecordService;
    private ConsumablesInRecordService ConsumablesInRecordService;
    @Override
    public IPage<ConsumablesUnInventoryDto> pageConsumablesUnInventory(Page page, ConsumablesUnInventoryDto ConsumablesUnInventoryDto) {
        return ConsumablesUnInventoryMapper.pageConsumablesUnInventory(page, ConsumablesUnInventoryDto);
    public IPage<ConsumablesUnInventoryDto> pageConsumablesUnInventory(Page page, ConsumablesUnInventoryDto consumablesUnInventoryDto) {
        return consumablesUnInventoryMapper.pageConsumablesUnInventory(page, consumablesUnInventoryDto);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer addConsumablesUnInventory(ConsumablesUnInventoryDto ConsumablesUnInventoryDto) {
    public Integer addConsumablesUnInventory(ConsumablesUnInventoryDto consumablesUnInventoryDto) {
        //新增入库记录再添加库存
        ConsumablesInRecordDto ConsumablesInRecordDto = new ConsumablesInRecordDto();
        ConsumablesInRecordDto.setRecordId(ConsumablesUnInventoryDto.getRecordId());
        ConsumablesInRecordDto.setRecordType(ConsumablesUnInventoryDto.getRecordType());
        ConsumablesInRecordDto.setConsumablesInNum(ConsumablesUnInventoryDto.getQualitity());
        ConsumablesInRecordDto.setProductModelId(ConsumablesUnInventoryDto.getProductModelId());
        ConsumablesInRecordDto.setType("1");
        ConsumablesInRecordService.add(ConsumablesInRecordDto);
        ConsumablesInRecordDto consumablesInRecordDto = new ConsumablesInRecordDto();
        consumablesInRecordDto.setRecordId(consumablesUnInventoryDto.getRecordId());
        consumablesInRecordDto.setRecordType(consumablesUnInventoryDto.getRecordType());
        consumablesInRecordDto.setStockInNum(consumablesUnInventoryDto.getQualitity());
        consumablesInRecordDto.setProductModelId(consumablesUnInventoryDto.getProductModelId());
        consumablesInRecordDto.setType("1");
        ConsumablesInRecordService.add(consumablesInRecordDto);
        //再进行新增库存数量库存
        //先查询库存表中的产品是否存在,不存在新增,存在更新
        ConsumablesUnInventory oldConsumablesUnInventory = ConsumablesUnInventoryMapper.selectOne(new QueryWrapper<ConsumablesUnInventory>().lambda().eq(ConsumablesUnInventory::getProductModelId, ConsumablesUnInventoryDto.getProductModelId()));
        ConsumablesUnInventory oldConsumablesUnInventory = consumablesUnInventoryMapper.selectOne(new QueryWrapper<ConsumablesUnInventory>().lambda().eq(ConsumablesUnInventory::getProductModelId, consumablesUnInventoryDto.getProductModelId()));
        if (ObjectUtils.isEmpty(oldConsumablesUnInventory)) {
            ConsumablesUnInventory newConsumablesUnInventory = new ConsumablesUnInventory();
            newConsumablesUnInventory.setProductModelId(ConsumablesUnInventoryDto.getProductModelId());
            newConsumablesUnInventory.setQualitity(ConsumablesUnInventoryDto.getQualitity());
            newConsumablesUnInventory.setProductModelId(consumablesUnInventoryDto.getProductModelId());
            newConsumablesUnInventory.setQualitity(consumablesUnInventoryDto.getQualitity());
            newConsumablesUnInventory.setVersion(1);
            newConsumablesUnInventory.setRemark(ConsumablesUnInventoryDto.getRemark());
            ConsumablesUnInventoryMapper.insert(newConsumablesUnInventory);
            newConsumablesUnInventory.setRemark(consumablesUnInventoryDto.getRemark());
            consumablesUnInventoryMapper.insert(newConsumablesUnInventory);
        }else {
            ConsumablesUnInventoryMapper.updateAddConsumablesUnInventory(ConsumablesUnInventoryDto);
            consumablesUnInventoryMapper.updateAddConsumablesUnInventory(consumablesUnInventoryDto);
        }
        return 1;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer subtractConsumablesUnInventory(ConsumablesUnInventoryDto ConsumablesUnInventoryDto) {
    public Integer subtractConsumablesUnInventory(ConsumablesUnInventoryDto consumablesUnInventoryDto) {
        //  æ–°å¢žå‡ºåº“记录
        ConsumablesOutRecordDto ConsumablesOutRecordDto = new ConsumablesOutRecordDto();
        ConsumablesOutRecordDto.setRecordId(ConsumablesUnInventoryDto.getRecordId());
        ConsumablesOutRecordDto.setRecordType(ConsumablesUnInventoryDto.getRecordType());
        ConsumablesOutRecordDto.setConsumablesOutNum(ConsumablesUnInventoryDto.getQualitity());
        ConsumablesOutRecordDto.setProductModelId(ConsumablesUnInventoryDto.getProductModelId());
        ConsumablesOutRecordDto.setType("1");
        ConsumablesOutRecordService.add(ConsumablesOutRecordDto);
        ConsumablesUnInventory oldConsumablesInventory = ConsumablesUnInventoryMapper.selectOne(new QueryWrapper<ConsumablesUnInventory>().lambda().eq(ConsumablesUnInventory::getProductModelId, ConsumablesUnInventoryDto.getProductModelId()));
        ConsumablesOutRecordDto consumablesOutRecordDto = new ConsumablesOutRecordDto();
        consumablesOutRecordDto.setRecordId(consumablesUnInventoryDto.getRecordId());
        consumablesOutRecordDto.setRecordType(consumablesUnInventoryDto.getRecordType());
        consumablesOutRecordDto.setStockOutNum(consumablesUnInventoryDto.getQualitity());
        consumablesOutRecordDto.setProductModelId(consumablesUnInventoryDto.getProductModelId());
        consumablesOutRecordDto.setType("1");
        ConsumablesOutRecordService.add(consumablesOutRecordDto);
        ConsumablesUnInventory oldConsumablesInventory = consumablesUnInventoryMapper.selectOne(new QueryWrapper<ConsumablesUnInventory>().lambda().eq(ConsumablesUnInventory::getProductModelId, consumablesUnInventoryDto.getProductModelId()));
        if (ObjectUtils.isEmpty(oldConsumablesInventory)) {
            throw new RuntimeException("产品库存不存在");
        }else {
            ConsumablesUnInventoryMapper.updateSubtractConsumablesUnInventory(ConsumablesUnInventoryDto);
            consumablesUnInventoryMapper.updateSubtractConsumablesUnInventory(consumablesUnInventoryDto);
        }
        return 1;
    }
    @Override
    public void exportConsumablesUnInventory(HttpServletResponse response, ConsumablesUnInventoryDto ConsumablesUnInventoryDto) {
        List<ConsumablesUnInventoryExportData> list = ConsumablesUnInventoryMapper.listConsumablesInventoryExportData(ConsumablesUnInventoryDto);
    public void exportConsumablesUnInventory(HttpServletResponse response, ConsumablesUnInventoryDto consumablesUnInventoryDto) {
        List<ConsumablesUnInventoryExportData> list = consumablesUnInventoryMapper.listConsumablesInventoryExportData(consumablesUnInventoryDto);
        ExcelUtil<ConsumablesUnInventoryExportData> util = new ExcelUtil<>(ConsumablesUnInventoryExportData.class);
        util.exportExcel(response,list, "不合格库存信息");
    }
    @Override
    public Boolean frozenConsumables(ConsumablesInventoryDto ConsumablesInventoryDto) {
        ConsumablesUnInventory ConsumablesUnInventory = ConsumablesUnInventoryMapper.selectById(ConsumablesInventoryDto.getId());
        if (ConsumablesUnInventory.getQualitity().compareTo(ConsumablesInventoryDto.getLockedQuantity())<0) {
    public Boolean frozenConsumables(ConsumablesInventoryDto consumablesInventoryDto) {
        ConsumablesUnInventory consumablesUnInventory = consumablesUnInventoryMapper.selectById(consumablesInventoryDto.getId());
        if (consumablesUnInventory.getQualitity().compareTo(consumablesInventoryDto.getLockedQuantity())<0) {
            throw new RuntimeException("冻结数量不能超过库存数量");
        }
        if (ObjectUtils.isEmpty(ConsumablesUnInventory.getLockedQuantity())) {
            ConsumablesUnInventory.setLockedQuantity(ConsumablesInventoryDto.getLockedQuantity());
        if (ObjectUtils.isEmpty(consumablesUnInventory.getLockedQuantity())) {
            consumablesUnInventory.setLockedQuantity(consumablesInventoryDto.getLockedQuantity());
        }else {
            ConsumablesUnInventory.setLockedQuantity(ConsumablesUnInventory.getLockedQuantity().add(ConsumablesInventoryDto.getLockedQuantity()));
            consumablesUnInventory.setLockedQuantity(consumablesUnInventory.getLockedQuantity().add(consumablesInventoryDto.getLockedQuantity()));
        }
        return this.updateById(ConsumablesUnInventory);
        return this.updateById(consumablesUnInventory);
    }
    @Override
    public Boolean thawConsumables(ConsumablesInventoryDto ConsumablesInventoryDto) {
        ConsumablesUnInventory ConsumablesUnInventory = ConsumablesUnInventoryMapper.selectById(ConsumablesInventoryDto.getId());
        if (ConsumablesUnInventory.getLockedQuantity().compareTo(ConsumablesInventoryDto.getLockedQuantity())<0) {
    public Boolean thawConsumables(ConsumablesInventoryDto consumablesInventoryDto) {
        ConsumablesUnInventory consumablesUnInventory = consumablesUnInventoryMapper.selectById(consumablesInventoryDto.getId());
        if (consumablesUnInventory.getLockedQuantity().compareTo(consumablesInventoryDto.getLockedQuantity())<0) {
            throw new RuntimeException("解冻数量不能超过冻结数量");
        }
        ConsumablesUnInventory.setLockedQuantity(ConsumablesUnInventory.getLockedQuantity().subtract(ConsumablesInventoryDto.getLockedQuantity()));
        return this.updateById(ConsumablesUnInventory);
        consumablesUnInventory.setLockedQuantity(consumablesUnInventory.getLockedQuantity().subtract(consumablesInventoryDto.getLockedQuantity()));
        return this.updateById(consumablesUnInventory);
    }
}
src/main/java/com/ruoyi/device/dto/DeviceRepairDto.java
@@ -3,11 +3,13 @@
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.sales.pojo.CommonFile;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
@Data
public class DeviceRepairDto {
@@ -74,5 +76,7 @@
    private String sparePartsNames;
    private List<CommonFile> fileList;
}
src/main/java/com/ruoyi/device/pojo/DeviceRepair.java
@@ -4,12 +4,14 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.other.pojo.TempFile;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
@Data
@TableName("device_repair")
@@ -76,5 +78,6 @@
    @ApiModelProperty("领用备件ids")
    private String sparePartsIds;
    @ApiModelProperty("文件列表")
    private List<TempFile> fileList;
}
src/main/java/com/ruoyi/device/service/impl/DeviceRepairServiceImpl.java
@@ -1,11 +1,12 @@
package com.ruoyi.device.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
import com.github.xiaoymin.knife4j.core.util.StrUtil;
import com.google.common.collect.Lists;
import com.ruoyi.common.enums.FileNameType;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.device.dto.DeviceDefectRecordDto;
@@ -20,14 +21,15 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.measuringinstrumentledger.mapper.SparePartsMapper;
import com.ruoyi.measuringinstrumentledger.pojo.SpareParts;
import com.ruoyi.measuringinstrumentledger.service.SparePartsService;
import com.ruoyi.other.pojo.TempFile;
import com.ruoyi.other.service.TempFileService;
import com.ruoyi.sales.mapper.CommonFileMapper;
import com.ruoyi.sales.pojo.CommonFile;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
@@ -46,12 +48,20 @@
    private IDeviceLedgerService deviceLedgerService;
    @Autowired
    private SparePartsMapper sparePartsMapper;
    @Autowired
    private TempFileService tempFileService;
    @Autowired
    private CommonFileMapper commonFileMapper;
    @Override
    public IPage<DeviceRepairDto> queryPage(Page page, DeviceRepairDto deviceRepairDto) {
        IPage<DeviceRepairDto> deviceRepairDtoIPage = deviceRepairMapper.queryPage(page, deviceRepairDto);
        List<DeviceRepairDto> records = deviceRepairDtoIPage.getRecords();
        List<Long> recordIds = records.stream()
                .map(DeviceRepairDto::getId)
                .collect(Collectors.toList());
        if (!CollectionUtils.isEmpty(records)) {
            // 1. èŽ·å–æ‰€æœ‰å”¯ä¸€çš„å¤‡ä»¶ID
            Set<String> allIds = records.stream()
@@ -86,6 +96,12 @@
                    record.setSparePartsNames(names);
                });
            }
            // å¤„理文件
            List<CommonFile> commonFiles = commonFileMapper.selectList(new LambdaQueryWrapper<CommonFile>().in(CommonFile::getCommonId, recordIds)
                    .eq(CommonFile::getType, FileNameType.DeviceRepair.getValue()));
            Map<Long, List<CommonFile>> collect = commonFiles.stream()
                    .collect(Collectors.groupingBy(CommonFile::getCommonId));
            records.forEach(record -> record.setFileList(collect.get(record.getId())));
        }
        return deviceRepairDtoIPage;
@@ -94,6 +110,17 @@
    @Override
    public AjaxResult saveDeviceRepair(DeviceRepair deviceRepair) {
        DeviceLedger byId = deviceLedgerService.getById(deviceRepair.getDeviceLedgerId());
        if (CollectionUtils.isNotEmpty(deviceRepair.getFileList())) {
            List<String> fileIds = deviceRepair.getFileList().stream()
                    .map(TempFile::getTempId)
                    .collect(Collectors.toList());
            try {
                tempFileService.migrateTempFilesToFormal(deviceRepair.getId(), fileIds, FileNameType.DeviceRepair.getValue());
            } catch (Exception e) {
                log.error("设备维修文件迁移错误", e);
            }
        }
        deviceRepair.setDeviceName(byId.getDeviceName());
        deviceRepair.setDeviceModel(byId.getDeviceModel());
        boolean save = this.save(deviceRepair);
@@ -106,6 +133,16 @@
    @Override
    public AjaxResult updateDeviceRepair(DeviceRepair deviceRepair) {
        if (this.updateById(deviceRepair)) {
            if (CollectionUtils.isNotEmpty(deviceRepair.getFileList())) {
                List<String> fileIds = deviceRepair.getFileList().stream()
                        .map(TempFile::getTempId)
                        .collect(Collectors.toList());
                try {
                    tempFileService.migrateTempFilesToFormal(deviceRepair.getId(), fileIds, FileNameType.DeviceRepair.getValue());
                } catch (Exception e) {
                    log.error("设备维修文件迁移错误", e);
                }
            }
            Long id = deviceRepair.getId();
            //
            DeviceDefectRecordDto deviceDefectRecordDto = new DeviceDefectRecordDto();
src/main/java/com/ruoyi/inspectiontask/pojo/QualityInspectItem.java
@@ -1,10 +1,12 @@
package com.ruoyi.inspectiontask.pojo;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
 * è´¨é‡æ£€æµ‹é¡¹
@@ -59,12 +61,16 @@
     * 
     */
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * 
     */
    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
    /**
src/main/java/com/ruoyi/other/service/TempFileService.java
@@ -4,9 +4,12 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
public interface TempFileService {
    TempFile uploadFile(MultipartFile file,Integer type) throws IOException;
    String uploadByCommon(MultipartFile file, Integer type, Long id) throws IOException;
    void migrateTempFilesToFormal(Long businessId, List<String> tempFileIds, Integer fileType) throws IOException;
}
src/main/java/com/ruoyi/other/service/impl/TempFileServiceImpl.java
@@ -9,16 +9,13 @@
import com.ruoyi.sales.mapper.CommonFileMapper;
import com.ruoyi.sales.pojo.CommonFile;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.util.URLEncoder;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -98,6 +95,7 @@
     * @param fileType     æ–‡ä»¶ç±»åž‹(来自FileNameType)
     * @throws IOException æ–‡ä»¶æ“ä½œå¼‚常
     */
    @Override
    public void migrateTempFilesToFormal(Long businessId, List<String> tempFileIds, Integer fileType) throws IOException {
        if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(tempFileIds)) {
            return;
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -171,41 +171,40 @@
            /*新增质检*/
            List<ProductProcessRouteItem> productProcessRouteItems = productProcessRouteItemMapper.selectList(Wrappers.<ProductProcessRouteItem>lambdaQuery().eq(ProductProcessRouteItem::getProductRouteId, productProcessRouteItem.getProductRouteId()));
            if (productProcessRouteItem.getIsQuality()) {
                //对应的过程检或者出厂检
                int inspectType = 1;
                String process = productProcess.getName();//工序
                if (productProcessRouteItem.getDragSort() == productProcessRouteItems.size()) {
                    //最后一道工序生成出厂检
                    inspectType = 2;
                    process = null;
                }
                Product product = productMapper.selectById(productModel.getProductId());
                QualityInspect qualityInspect = new QualityInspect();
                qualityInspect.setProductId(product.getId());
                qualityInspect.setProductName(product.getProductName());
                qualityInspect.setModel(productModel.getModel());
                qualityInspect.setUnit(productModel.getUnit());
                qualityInspect.setQuantity(productQty);
                qualityInspect.setProcess(process);
                qualityInspect.setInspectState(0);
                qualityInspect.setInspectType(inspectType);
                qualityInspect.setProductMainId(productionProductMain.getId());
                qualityInspect.setProductModelId(productModel.getId());
                qualityInspectMapper.insert(qualityInspect);
                List<QualityTestStandard> qualityTestStandard = qualityTestStandardMapper.getQualityTestStandardByProductId(product.getId(), inspectType, process);
                if (qualityTestStandard.size() > 0) {
                    qualityInspect.setTestStandardId(qualityTestStandard.get(0).getId());
                    qualityInspectMapper.updateById(qualityInspect);
                    qualityTestStandardParamMapper.selectList(Wrappers.<QualityTestStandardParam>lambdaQuery()
                                    .eq(QualityTestStandardParam::getTestStandardId, qualityTestStandard.get(0).getId()))//默认获取最新的
                            .forEach(qualityTestStandardParam -> {
                                QualityInspectParam param = new QualityInspectParam();
                                BeanUtils.copyProperties(qualityTestStandardParam, param);
                                param.setId(null);
                                param.setInspectId(qualityInspect.getId());
                                qualityInspectParamMapper.insert(param);
                            });
                }
//                int inspectType = 1;
//                String process = productProcess.getName();//工序
//                if (productProcessRouteItem.getDragSort() == productProcessRouteItems.size()) {
//                    //最后一道工序生成出厂检
//                    inspectType = 2;
//                    process = null;
//                }
//                Product product = productMapper.selectById(productModel.getProductId());
//                QualityInspect qualityInspect = new QualityInspect();
//                qualityInspect.setProductId(product.getId());
//                qualityInspect.setProductName(product.getProductName());
//                qualityInspect.setModel(productModel.getModel());
//                qualityInspect.setUnit(productModel.getUnit());
//                qualityInspect.setQuantity(productQty);
//                qualityInspect.setProcess(process);
//                qualityInspect.setInspectState(0);
//                qualityInspect.setInspectType(inspectType);
//                qualityInspect.setProductMainId(productionProductMain.getId());
//                qualityInspect.setProductModelId(productModel.getId());
//                qualityInspectMapper.insert(qualityInspect);
//                List<QualityTestStandard> qualityTestStandard = qualityTestStandardMapper.getQualityTestStandardByProductId(product.getId(), inspectType, process);
//                if (qualityTestStandard.size() > 0) {
//                    qualityInspect.setTestStandardId(qualityTestStandard.get(0).getId());
//                    qualityInspectMapper.updateById(qualityInspect);
//                    qualityTestStandardParamMapper.selectList(Wrappers.<QualityTestStandardParam>lambdaQuery()
//                                    .eq(QualityTestStandardParam::getTestStandardId, qualityTestStandard.get(0).getId()))//默认获取最新的
//                            .forEach(qualityTestStandardParam -> {
//                                QualityInspectParam param = new QualityInspectParam();
//                                BeanUtils.copyProperties(qualityTestStandardParam, param);
//                                param.setId(null);
//                                param.setInspectId(qualityInspect.getId());
//                                qualityInspectParamMapper.insert(param);
//                            });
//                }
            }else {
                //直接入库
                stockUtils.addStock(productProcessRouteItem.getProductModelId(), productQty, StockInQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_IN.getCode(), productionProductMain.getId());
src/main/java/com/ruoyi/quality/controller/RawMaterialController.java
@@ -1,12 +1,20 @@
package com.ruoyi.quality.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.enums.RawMaterialInspectState;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.quality.dto.RawMaterialDto;
import com.ruoyi.quality.pojo.*;
import com.ruoyi.quality.service.IQualityInspectFileService;
import com.ruoyi.quality.service.RawMaterialQualityInspectItemService;
import com.ruoyi.quality.service.RawMaterialService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@@ -23,6 +31,12 @@
    @Resource
    private RawMaterialService rawMaterialService;
    @Resource
    private RawMaterialQualityInspectItemService rawMaterialQualityInspectItemService;
    @Resource
    private IQualityInspectFileService qualityInspectFileService;
    /**
     * åŽŸæ–™åˆ†é¡µæŸ¥è¯¢
     */
@@ -31,6 +45,13 @@
        return AjaxResult.success(rawMaterialService.listPage(page, rawMaterialDto));
    }
    /**
     * åŽŸæ–™è¯¦æƒ…
     */
    @GetMapping("/detail/{id}")
    public AjaxResult detail(@PathVariable Long id) {
        return AjaxResult.success(rawMaterialService.detail(id));
    }
    /**
     * åŽŸæ–™æ–°å¢ž
@@ -41,18 +62,72 @@
    }
    /**
     * æ£€æµ‹æäº¤
     * @param id åŽŸæ–™id
     * @return
     */
    @PatchMapping("/submit/{id}")
    public AjaxResult submit(@PathVariable Long id) {
        return AjaxResult.success(rawMaterialService.submit(id));
    }
    /**
     * ä¿®æ”¹æ£€éªŒäºº
     * @param rawMaterialDto åŽŸæ–™
     * @return
     */
    @PatchMapping("/updateCheckUserName")
    public AjaxResult updateCheckUserName(@RequestBody RawMaterialDto rawMaterialDto) {
        RawMaterial rawMaterial = new RawMaterial();
        rawMaterial.setId(rawMaterialDto.getId());
        rawMaterial.setCheckUserName(rawMaterialDto.getCheckUserName());
        return AjaxResult.success(rawMaterialService.updateById(rawMaterial));
    }
    /**
     * åŽŸæ–™æ›´æ–°
     */
    @PutMapping("")
    public AjaxResult update(@RequestBody RawMaterialDto rawMaterialDto) {
        return AjaxResult.success(rawMaterialService.updateById(rawMaterialDto));
        return AjaxResult.success(rawMaterialService.update(rawMaterialDto));
    }
    /**
     * åŽŸæ–™åˆ é™¤
     */
    @DeleteMapping("")
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult delete(@RequestBody List<Integer> ids) {
        return AjaxResult.success(rawMaterialService.removeByIds(ids));
        if(CollectionUtils.isEmpty(ids)){
            return AjaxResult.error("请选择至少一条数据");
        }
        //如果已经提交就不允许删除
        List<RawMaterial> rawMaterials = rawMaterialService.list(Wrappers.<RawMaterial>lambdaQuery()
                .in(RawMaterial::getId,ids)
                .eq(RawMaterial::getInspectState, RawMaterialInspectState.RawMaterialInspectStateSubmitted.getCode()));
        if(!CollectionUtils.isEmpty(rawMaterials)){
            throw new RuntimeException("已提交的数据不允许删除");
        }
        //删除检验参数
        rawMaterialQualityInspectItemService.remove(Wrappers.<RawMaterialQualityInspectItem>lambdaQuery()
                .in(RawMaterialQualityInspectItem::getRawMaterialId,ids));
        //删除检验附件
        qualityInspectFileService.remove(Wrappers.<QualityInspectFile>lambdaQuery()
                .in(QualityInspectFile::getInspectId,ids));
        //删除检验单
        return AjaxResult.success(rawMaterialService.removeBatchByIds(ids));
    }
    /**
     * å¯¼å‡ºåŽŸæ–™æ•°æ®
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, RawMaterialDto rawMaterialDto) {
        rawMaterialService.export(response, rawMaterialDto);
    }
    @PostMapping("/down")
    public void down(HttpServletResponse response,@RequestBody RawMaterialDto rawMaterialDto) {
        rawMaterialService.down(response, rawMaterialDto);
    }
}
src/main/java/com/ruoyi/quality/dto/RawMaterialDto.java
@@ -1,16 +1,13 @@
package com.ruoyi.quality.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.inspectiontask.pojo.QualityInspectItem;
import com.ruoyi.quality.pojo.RawMaterial;
import com.ruoyi.quality.pojo.RawMaterialQualityInspectItem;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;
/**
@@ -24,18 +21,14 @@
    /**
     * å¼€å§‹æ—¶é—´
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty("表单搜索时间范围:开始时间")
    private LocalDate entryDateStart;
    private String entryDateStart;
    /**
     * ç»“束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty("表单搜索时间范围:结束时间")
    private LocalDate entryDateEnd;
    private String entryDateEnd;
    @ApiModelProperty("检验类型 0入场检 1车间检 2出厂检")
    private String checkTypeText;
@@ -46,6 +39,23 @@
     @ApiModelProperty("类别(0:未提交;1:已提交)")
    private String inspectStateText;
     @ApiModelProperty("原料检测项列表ids")
     private List<Long> qualityInspectItemIds;
    @ApiModelProperty("原料检测项列表")
    private List<QualityInspectItem> qualityInspectItem;
    @ApiModelProperty("产品名称")
    @Excel(name = "产品名称")
    private String productName;
    @ApiModelProperty("规格型号")
    @Excel(name = "规格型号")
    private String model;
    @ApiModelProperty("产品id")
    private Long productId;
    @ApiModelProperty("单位")
    private String unit;
    @ApiModelProperty("检验日期")
    private String checkTimeText;
}
src/main/java/com/ruoyi/quality/dto/RawMaterialQualityInspectItemDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
package com.ruoyi.quality.dto;
import com.ruoyi.quality.pojo.RawMaterialQualityInspectItem;
import lombok.Data;
@Data
public class RawMaterialQualityInspectItemDto extends RawMaterialQualityInspectItem {
    /**
     * é¡¹ç›®åç§°
     */
    private String name;
    /**
     * å•位
     */
    private String unit;
    /**
     * æ ‡å‡†å€¼
     */
    private String standardValue;
    /**
     * å†…控值
     */
    private String internalControl;
}
src/main/java/com/ruoyi/quality/pojo/RawMaterial.java
@@ -3,8 +3,10 @@
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
@@ -12,6 +14,7 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
/**
 * <p>
@@ -35,25 +38,31 @@
    @ApiModelProperty("产品型号id")
    private Long productModelId;
    @ApiModelProperty("批次号")
    private String batchNo;
    @ApiModelProperty("检验类型 0入场检 1车间检 2出厂检")
    @ApiModelProperty("检验类型 0入厂检 1车间检 2出厂检")
    @Excel(name = "检验类型", readConverterExp = "0=入厂检,1=车间检,2=出厂检")
    private Integer checkType;
    @ApiModelProperty("批次号")
    @Excel(name = "批次号")
    private String batchNo;
    @ApiModelProperty("检验结果 0合格 1不合格")
    @Excel(name = "检验结果", readConverterExp = "0=合格,1=不合格")
    private Integer checkResult;
    @ApiModelProperty("类别(0:未提交;1:已提交)")
    @Excel(name = "提交状态", readConverterExp = "0=未提交,1=已提交")
    private Integer inspectState;
    @ApiModelProperty("检验员名称")
    @Excel(name = "检验员")
    private String checkUserName;
    @ApiModelProperty("检验日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "检测日期", width = 30, dateFormat = "yyyy-MM-dd")
    private LocalDate checkTime;
    private Date checkTime;
    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
src/main/java/com/ruoyi/quality/pojo/RawMaterialQualityInspectItem.java
@@ -1,16 +1,13 @@
package com.ruoyi.quality.pojo;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * <p>
@@ -37,6 +34,9 @@
    @ApiModelProperty("质量检验项id")
    private Long qualityInspectItemId;
    @ApiModelProperty("化验值")
    private String testValue;
    @ApiModelProperty("录入时间")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
@@ -44,4 +44,7 @@
    @ApiModelProperty("更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    @TableField(select = false, exist = false)
    private Integer index;
}
src/main/java/com/ruoyi/quality/service/RawMaterialService.java
@@ -2,10 +2,11 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.quality.dto.RawMaterialDto;
import com.ruoyi.quality.pojo.QualityInspectFile;
import com.ruoyi.quality.pojo.RawMaterial;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.quality.dto.RawMaterialDto;
import com.ruoyi.quality.pojo.RawMaterial;
import javax.servlet.http.HttpServletResponse;
/**
 * <p>
@@ -18,5 +19,15 @@
public interface RawMaterialService extends IService<RawMaterial> {
    IPage<RawMaterialDto> listPage(Page page, RawMaterialDto rawMaterialDto);
    RawMaterialDto detail(Long id);
    boolean submit(Long id);
    boolean add(RawMaterialDto rawMaterialDto);
    boolean update(RawMaterialDto rawMaterialDto);
    void export(HttpServletResponse response, RawMaterialDto rawMaterialDto);
    void down(HttpServletResponse response, RawMaterialDto rawMaterialDto);
}
src/main/java/com/ruoyi/quality/service/impl/RawMaterialServiceImpl.java
@@ -1,31 +1,55 @@
package com.ruoyi.quality.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.collaborativeApproval.dto.DutyPlanDTO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl;
import com.ruoyi.approve.vo.ApproveProcessVO;
import com.ruoyi.basic.mapper.ProductMapper;
import com.ruoyi.basic.mapper.ProductModelMapper;
import com.ruoyi.basic.pojo.Product;
import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.common.enums.RawMaterialCheckResult;
import com.ruoyi.common.enums.RawMaterialCheckType;
import com.ruoyi.common.enums.RawMaterialInspectState;
import com.ruoyi.production.mapper.ProductProcessRouteMapper;
import com.ruoyi.common.utils.HackLoopTableRenderPolicy;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.inspectiontask.mapper.QualityInspectItemMapper;
import com.ruoyi.inspectiontask.pojo.QualityInspectItem;
import com.ruoyi.quality.dto.RawMaterialDto;
import com.ruoyi.quality.mapper.RawMaterialQualityInspectItemMapper;
import com.ruoyi.quality.pojo.RawMaterial;
import com.ruoyi.quality.dto.RawMaterialQualityInspectItemDto;
import com.ruoyi.quality.mapper.QualityUnqualifiedMapper;
import com.ruoyi.quality.mapper.RawMaterialMapper;
import com.ruoyi.quality.pojo.RawMaterialQualityInspectItem;
import com.ruoyi.quality.pojo.*;
import com.ruoyi.quality.service.RawMaterialQualityInspectItemService;
import com.ruoyi.quality.service.RawMaterialService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
import static com.ruoyi.home.service.impl.HomeServiceImpl.formatDate;
/**
 * <p>
 *  æœåŠ¡å®žçŽ°ç±»
 * æœåŠ¡å®žçŽ°ç±»
 * </p>
 *
 * @author èŠ¯å¯¼è½¯ä»¶ï¼ˆæ±Ÿè‹ï¼‰æœ‰é™å…¬å¸
@@ -38,33 +62,304 @@
    private RawMaterialQualityInspectItemService rawMaterialQualityInspectItemService;
    private QualityInspectItemMapper qualityInspectItemMapper;
    private ProductModelMapper productModelMapper;
    private ProductMapper productMapper;
    private QualityUnqualifiedMapper qualityUnqualifiedMapper;
    @Autowired
    private  ApproveProcessServiceImpl approveProcessService;
    @Override
    public IPage<RawMaterialDto> listPage(Page page, RawMaterialDto rawMaterialDto) {
        IPage<RawMaterialDto> rawMaterials = rawMaterialMapper.listPage(page, rawMaterialDto);
        for (RawMaterialDto rawMaterial : rawMaterials.getRecords()) {
            rawMaterial.setCheckTypeText(RawMaterialCheckType.fromValue(rawMaterial.getCheckType()).getValue());
            rawMaterial.setCheckResultText(RawMaterialCheckResult.fromValue(rawMaterial.getCheckResult()).getValue());
            rawMaterial.setInspectStateText(RawMaterialInspectState.fromValue(rawMaterial.getInspectState()).getValue());
        IPage<RawMaterialDto> pageRes = rawMaterialMapper.listPage(page, rawMaterialDto);
        List<RawMaterialDto> rawMaterials = pageRes.getRecords();
        Map<Long, ProductModel> productModelMap = new HashMap<>();
        Map<Long, Product> productMap = new HashMap<>();
        if (CollectionUtils.isNotEmpty(rawMaterials)) {
            List<Long> productModelIds = rawMaterials.stream().map(RawMaterialDto::getProductModelId).collect(Collectors.toList());
            List<ProductModel> productModels = productModelMapper.selectList(new LambdaQueryWrapper<ProductModel>()
                    .in(ProductModel::getId, productModelIds));
            productModelMap = productModels.stream().collect(Collectors.toMap(ProductModel::getId, productModel -> productModel));
            List<Long> productIds = productModels.stream().map(ProductModel::getProductId).collect(Collectors.toList());
            List<Product> products = productMapper.selectList(new LambdaQueryWrapper<Product>()
                    .in(Product::getId, productIds));
            productMap = products.stream().collect(Collectors.toMap(Product::getId, product -> product));
        }
        return rawMaterials;
        for (RawMaterialDto rawMaterial : pageRes.getRecords()) {
            rawMaterial.setCheckTypeText(RawMaterialCheckType.fromValue(rawMaterial.getCheckType()) == null ? "" : RawMaterialCheckType.fromValue(rawMaterial.getCheckType()).getValue());
            rawMaterial.setCheckResultText(RawMaterialCheckResult.fromValue(rawMaterial.getCheckResult()) == null ? "" : RawMaterialCheckResult.fromValue(rawMaterial.getCheckResult()).getValue());
            rawMaterial.setInspectStateText(RawMaterialInspectState.fromValue(rawMaterial.getInspectState()) == null ? "" : RawMaterialInspectState.fromValue(rawMaterial.getInspectState()).getValue());
            rawMaterial.setProductName(productMap.get(productModelMap.get(rawMaterial.getProductModelId()).getProductId()).getProductName());
            rawMaterial.setModel(productModelMap.get(rawMaterial.getProductModelId()).getModel());
            rawMaterial.setProductId(productModelMap.get(rawMaterial.getProductModelId()).getProductId());
        }
        return pageRes;
    }
    @Override
    public RawMaterialDto detail(Long id) {
        RawMaterial rawMaterial = rawMaterialMapper.selectById(id);
        RawMaterialDto rawMaterialDto = new RawMaterialDto();
        if (rawMaterial == null) {
            return rawMaterialDto;
        }
        BeanUtils.copyBeanProp(rawMaterialDto, rawMaterial);
        // èŽ·å–æ£€æµ‹é¡¹å…³è”å…³ç³»
        List<RawMaterialQualityInspectItem> rawQualityList = rawMaterialQualityInspectItemService.list(new LambdaQueryWrapper<RawMaterialQualityInspectItem>()
                .eq(RawMaterialQualityInspectItem::getRawMaterialId, id));
        Map<Long, RawMaterialQualityInspectItem> map = rawQualityList.stream().collect(Collectors.toMap(RawMaterialQualityInspectItem::getQualityInspectItemId, qualityInspectItem -> qualityInspectItem));
        // èŽ·å–æ£€éªŒé¡¹ç›®
        List<QualityInspectItem> qualityInspectItems = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(rawQualityList)) {
            List<Long> qualityInspectItemIds = rawQualityList.stream().map(RawMaterialQualityInspectItem::getQualityInspectItemId).collect(Collectors.toList());
            qualityInspectItems = qualityInspectItemMapper.selectList(new LambdaQueryWrapper<QualityInspectItem>()
                    .in(QualityInspectItem::getId, qualityInspectItemIds));
        }
        // æ›¿æ¢åŒ–验值
        qualityInspectItems.forEach(qualityInspectItem -> {
            qualityInspectItem.setTestValue(map.get(qualityInspectItem.getId()).getTestValue());
        });
        rawMaterialDto.setQualityInspectItem(qualityInspectItems);
        // æŸ¥è¯¢äº§å“id
        ProductModel productModel = productModelMapper.selectById(rawMaterialDto.getProductModelId());
        Product product = productMapper.selectById(productModel.getProductId());
        rawMaterialDto.setProductId(productModel.getProductId());
        rawMaterialDto.setProductName(product.getProductName());
        rawMaterialDto.setModel(productModel.getModel());
        rawMaterialDto.setUnit(productModel.getUnit());
        rawMaterialDto.setCheckResultText(RawMaterialCheckResult.fromValue(rawMaterial.getCheckResult()) == null ? "" : RawMaterialCheckResult.fromValue(rawMaterial.getCheckResult()).getValue());
        rawMaterialDto.setCheckTypeText(RawMaterialCheckType.fromValue(rawMaterial.getCheckType()) == null ? "" : RawMaterialCheckType.fromValue(rawMaterial.getCheckType()).getValue());
        return rawMaterialDto;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean submit(Long id) {
        RawMaterial rawMaterial = rawMaterialMapper.selectById(id);
        if (rawMaterial.getCheckResult() == null) {
            throw new RuntimeException("请先判断是否合格");
        }
        // ä¸åˆæ ¼ï¼šç”Ÿæˆä¸åˆæ ¼è®°å½•
        if (rawMaterial.getCheckResult().equals(RawMaterialCheckResult.RawMaterialCheckResultUnqualified.getCode())) {
            QualityUnqualified qualityUnqualified = new QualityUnqualified();
            qualityUnqualified.setInspectId(rawMaterial.getId());//检验id
            qualityUnqualified.setInspectType(rawMaterial.getCheckType());//检验类型
            qualityUnqualified.setInspectState(0);//待处理
            qualityUnqualified.setCheckName(rawMaterial.getCheckUserName());//检验员名称
            qualityUnqualified.setCheckTime(rawMaterial.getCheckTime());//检验日期
            ProductModel productModel = productModelMapper.selectById(rawMaterial.getProductModelId());
            Product product = productMapper.selectById(productModel.getProductId());
            qualityUnqualified.setProductId(productModel.getProductId());//产品id
            qualityUnqualified.setProductName(product.getProductName());//产品名称
            qualityUnqualified.setModel(productModel.getModel());//规格型号
            qualityUnqualified.setUnit(productModel.getUnit());//单位
            List<RawMaterialQualityInspectItem> inspectParams = rawMaterialQualityInspectItemService.list(Wrappers.<RawMaterialQualityInspectItem>lambdaQuery().eq(RawMaterialQualityInspectItem::getRawMaterialId, rawMaterial.getId()));
            // èŽ·å–å…³è”çš„QualityInspectItem项目名
            String text = inspectParams.stream().map(item -> {
                QualityInspectItem qualityInspectItem = qualityInspectItemMapper.selectById(item.getQualityInspectItemId());
                return qualityInspectItem != null ? qualityInspectItem.getName() : "";
            }).collect(Collectors.joining(","));
            qualityUnqualified.setDefectivePhenomena(text + "这些项目中存在不合格");//不合格现象
            qualityUnqualifiedMapper.insert(qualityUnqualified);
        } else {
            //合格: äº§ç”ŸåŽŸæ–™å®¡æ ¸è®°å½•
            LoginUser loginUser = SecurityUtils.getLoginUser();
            ApproveProcessVO approveProcessVO = new ApproveProcessVO();
            approveProcessVO.setApproveType(9);
            approveProcessVO.setApproveRecordId(rawMaterial.getId());
            approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
            approveProcessVO.setApproveReason( "原料审核批号:"+rawMaterial.getBatchNo());
            Long adminUserId = 1L; // todo å‡è®¾ç¬¬ä¸€ä¸ªç®¡ç†å‘˜çš„ID为1
            approveProcessVO.setApproveUserIds(String.valueOf(adminUserId));
            approveProcessVO.setApproveUser(loginUser.getUserId());
            approveProcessVO.setApproveTime(LocalDate.now().toString());
            try {
                approveProcessService.addApprove(approveProcessVO);
            }catch (Exception e){
                log.error("RawMaterialServiceImpl error:{}", e);
                throw new RuntimeException("审批失败");
            }
        }
        rawMaterial.setInspectState(RawMaterialInspectState.RawMaterialInspectStateSubmitted.getCode());
        return rawMaterialMapper.updateById(rawMaterial) > 0;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean add(RawMaterialDto rawMaterialDto) {
        rawMaterialDto.setInspectState(RawMaterialInspectState.RawMaterialInspectStateUnsubmitted.getCode());
        // æ–°å¢žåŽŸæ–™
        int i = rawMaterialMapper.insert(rawMaterialDto);
        // æ–°å¢žæ£€æµ‹é¡¹å…³è”关系
        if (rawMaterialDto.getQualityInspectItemIds() != null && !rawMaterialDto.getQualityInspectItemIds().isEmpty()) {
            List<RawMaterialQualityInspectItem> rawMaterialQualityInspectItems = rawMaterialDto.getQualityInspectItemIds().stream()
                    .map(id -> {
        if (CollectionUtils.isNotEmpty(rawMaterialDto.getQualityInspectItem())) {
            List<RawMaterialQualityInspectItem> rawMaterialQualityInspectItems = rawMaterialDto.getQualityInspectItem().stream()
                    .map(qualityInspectItem -> {
                        RawMaterialQualityInspectItem item = new RawMaterialQualityInspectItem();
                        item.setRawMaterialId(rawMaterialDto.getId());
                        item.setQualityInspectItemId(id);
                        item.setQualityInspectItemId(qualityInspectItem.getId());
                        item.setTestValue(qualityInspectItem.getTestValue());
                        return item;
                    })
                    .collect(Collectors.toList());
            rawMaterialQualityInspectItemService.saveBatch(rawMaterialQualityInspectItems);
        }
        // æ–°å¢žåŽŸæ–™
        return rawMaterialMapper.insert(rawMaterialDto) > 0;
        return i > 0;
    }
}
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean update(RawMaterialDto rawMaterialDto) {
        // æ›´æ–°åŽŸæ–™
        if (rawMaterialMapper.updateById(rawMaterialDto) <= 0) {
            return false;
        }
        Long rawMaterialId = rawMaterialDto.getId();
        List<QualityInspectItem> newQualityInspectItems = rawMaterialDto.getQualityInspectItem();
        // èŽ·å–çŽ°æœ‰æ£€éªŒé¡¹å…³è”è®°å½•
        List<RawMaterialQualityInspectItem> existingItems = rawMaterialQualityInspectItemService.list(
                new LambdaQueryWrapper<RawMaterialQualityInspectItem>()
                        .eq(RawMaterialQualityInspectItem::getRawMaterialId, rawMaterialId)
        );
        // åˆ é™¤ä¸å­˜åœ¨çš„关联记录
        if (CollectionUtils.isEmpty(newQualityInspectItems)) {
            // å¦‚果没有检验项,删除所有现有关联记录
            if (CollectionUtils.isNotEmpty(existingItems)) {
                List<Long> existingIds = existingItems.stream()
                        .map(RawMaterialQualityInspectItem::getId)
                        .collect(Collectors.toList());
                rawMaterialQualityInspectItemService.removeByIds(existingIds);
            }
            return true;
        }
        // èŽ·å–æ–°æ£€éªŒé¡¹çš„ID集合和测试值映射
        Set<Long> newItemIds = newQualityInspectItems.stream()
                .map(QualityInspectItem::getId)
                .collect(Collectors.toSet());
        Map<Long, String> testValueMap = newQualityInspectItems.stream()
                .collect(Collectors.toMap(QualityInspectItem::getId, QualityInspectItem::getTestValue));
        // åˆ é™¤ä¸å­˜åœ¨çš„关联记录
        List<Long> toDelete = existingItems.stream()
                .filter(item -> !newItemIds.contains(item.getQualityInspectItemId()))
                .map(RawMaterialQualityInspectItem::getId)
                .collect(Collectors.toList());
        if (CollectionUtils.isNotEmpty(toDelete)) {
            rawMaterialQualityInspectItemService.removeByIds(toDelete);
        }
        // å¤„理更新数据
        List<RawMaterialQualityInspectItem> toUpdate = existingItems.stream()
                .filter(item -> newItemIds.contains(item.getQualityInspectItemId()))
                .peek(item -> item.setTestValue(testValueMap.get(item.getQualityInspectItemId())))
                .collect(Collectors.toList());
        if (CollectionUtils.isNotEmpty(toUpdate)) {
            rawMaterialQualityInspectItemService.updateBatchById(toUpdate);
        }
        // å¤„理新增数据
        Set<Long> existingItemIds = existingItems.stream()
                .map(RawMaterialQualityInspectItem::getQualityInspectItemId)
                .collect(Collectors.toSet());
        List<RawMaterialQualityInspectItem> toCreate = newQualityInspectItems.stream()
                .filter(item -> !existingItemIds.contains(item.getId()))
                .map(item -> {
                    RawMaterialQualityInspectItem newItem = new RawMaterialQualityInspectItem();
                    newItem.setRawMaterialId(rawMaterialId);
                    newItem.setQualityInspectItemId(item.getId());
                    newItem.setTestValue(item.getTestValue());
                    return newItem;
                })
                .collect(Collectors.toList());
        if (CollectionUtils.isNotEmpty(toCreate)) {
            rawMaterialQualityInspectItemService.saveBatch(toCreate);
        }
        return true;
    }
    @Override
    public void export(HttpServletResponse response, RawMaterialDto rawMaterialDto) {
        List<RawMaterialDto> rawMaterials = rawMaterialMapper.listPage(new Page<>(1, Integer.MAX_VALUE), rawMaterialDto).getRecords();
        ExcelUtil<RawMaterialDto> util = new ExcelUtil<RawMaterialDto>(RawMaterialDto.class);
        util.exportExcel(response, rawMaterials, "原料检验导出");
    }
    @Override
    public void down(HttpServletResponse response, RawMaterialDto rawMaterialDto) {
        RawMaterial rawMaterial = rawMaterialMapper.selectById(rawMaterialDto.getId());
        // èŽ·å–äº§å“åž‹å·ä¿¡æ¯
        ProductModel productModel = productModelMapper.selectById(rawMaterial.getProductModelId());
        Product product = productMapper.selectById(productModel.getProductId());
        RawMaterialDto inspect = new RawMaterialDto();
        BeanUtils.copyProperties(rawMaterial, inspect);
        inspect.setModel(productModel.getModel());
        inspect.setProductName(product.getProductName());
        inspect.setCheckTypeText(RawMaterialCheckType.fromValue(rawMaterial.getCheckType()) == null ? "" : RawMaterialCheckType.fromValue(rawMaterial.getCheckType()).getValue());
        inspect.setCheckResultText(RawMaterialCheckResult.fromValue(rawMaterial.getCheckResult()) == null ? "" : RawMaterialCheckResult.fromValue(rawMaterial.getCheckResult()).getValue());
        inspect.setCheckTimeText(formatDate(rawMaterial.getCheckTime()));
        List<RawMaterialQualityInspectItem> paramList = rawMaterialQualityInspectItemService.list(
                new LambdaQueryWrapper<RawMaterialQualityInspectItem>()
                        .eq(RawMaterialQualityInspectItem::getRawMaterialId, rawMaterialDto.getId())
        );
        List<RawMaterialQualityInspectItemDto> inspectItems = new ArrayList<>();
        int index = 1;
        for (RawMaterialQualityInspectItem item : paramList) {
            RawMaterialQualityInspectItemDto dto = new RawMaterialQualityInspectItemDto();
            BeanUtils.copyProperties(item, dto);
            QualityInspectItem qualityInspectItem = qualityInspectItemMapper.selectById(item.getQualityInspectItemId());
            dto.setName(qualityInspectItem.getName());
            dto.setUnit(qualityInspectItem.getUnit());
            dto.setStandardValue(qualityInspectItem.getStandardValue());
            dto.setInternalControl(qualityInspectItem.getInternalControl());
            dto.setIndex(index);
            inspectItems.add(dto);
            index++;
        }
        InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx");
        Configure configure = Configure.builder()
                .bind("paramList", new HackLoopTableRenderPolicy())
                .build();
        XWPFTemplate template = XWPFTemplate.compile(inputStream, configure).render(
                new HashMap<String, Object>() {{
                    put("inspect", inspect);
                    put("paramList", inspectItems);
                }});
        try {
            response.setContentType("application/msword");
            String fileName = URLEncoder.encode(
                    "检验报告", "UTF-8");
            response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
            response.setHeader("Content-disposition",
                    "attachment;filename=" + fileName + ".docx");
            OutputStream os = response.getOutputStream();
            template.write(os);
            os.flush();
            os.close();
            inputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("导出失败");
        }
    }
}
src/main/java/com/ruoyi/stock/pojo/StockOutRecord.java
@@ -94,4 +94,7 @@
    @ApiModelProperty("产品id")
    private Long productId;
    @ApiModelProperty("磅单文件路径")
    private String weighbridgeDocPath;
}
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -21,6 +21,7 @@
import com.ruoyi.stock.service.StockOutRecordService;
import com.ruoyi.stock.word.WeighbridgeDocGenerator;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -71,6 +72,7 @@
        stockInRecordDto.setWeighingOperator(stockInventoryDto.getWeighingOperator());
        stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
        stockInRecordDto.setProductId(stockInventoryDto.getProductId());
        stockInRecordDto.setRemark(stockInventoryDto.getRemark());
        stockInRecordDto.setType("0");
        //生成磅单
        String absoluteDocPath = weighbridgeDocGenerator.generateWeighbridgeDoc(stockInRecordDto);
@@ -87,6 +89,7 @@
            newStockInventory.setRemark(stockInventoryDto.getRemark());
            newStockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity());
            newStockInventory.setWarnNum(stockInventoryDto.getWarnNum());
            newStockInventory.setProductId(stockInventoryDto.getProductId());
            stockInventoryMapper.insert(newStockInventory);
        } else {
            stockInventoryDto.setQualitity(stockInventoryDto.getNetWeight());
@@ -103,7 +106,7 @@
        StockOutRecordDto stockOutRecordDto = new StockOutRecordDto();
        stockOutRecordDto.setRecordId(stockInventoryDto.getRecordId());
        stockOutRecordDto.setRecordType(stockInventoryDto.getRecordType());
        stockInventoryDto.setWeighingDate(stockInventoryDto.getWeighingDate());
        stockOutRecordDto.setWeighingDate(stockInventoryDto.getWeighingDate());
        stockOutRecordDto.setStockOutNum(stockInventoryDto.getNetWeight());
        stockOutRecordDto.setNetWeight(stockInventoryDto.getNetWeight());
        stockOutRecordDto.setGrossWeight(stockInventoryDto.getGrossWeight());
@@ -112,7 +115,13 @@
        stockOutRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
        stockOutRecordDto.setLicensePlateNo(stockInventoryDto.getLicensePlateNo());
        stockOutRecordDto.setProductId(stockInventoryDto.getProductId());
        stockOutRecordDto.setRemark(stockInventoryDto.getRemark());
        stockOutRecordDto.setType("0");
        //生成磅单
        StockInRecordDto stockInRecordDto = new StockInRecordDto();
        BeanUtils.copyProperties(stockOutRecordDto, stockInRecordDto);
        String absoluteDocPath = weighbridgeDocGenerator.generateWeighbridgeDoc(stockInRecordDto);
        stockOutRecordDto.setWeighbridgeDocPath(absoluteDocPath);
        stockOutRecordService.add(stockOutRecordDto);
        StockInventory oldStockInventory = stockInventoryMapper.selectOne(new QueryWrapper<StockInventory>().lambda().eq(StockInventory::getProductModelId, stockInventoryDto.getProductModelId()));
        if (ObjectUtils.isEmpty(oldStockInventory)) {
src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java
@@ -4,8 +4,8 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum;
import com.ruoyi.common.enums.StockInUnQualifiedRecordTypeEnum;
import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.EnumUtil;
import com.ruoyi.common.utils.OrderUtils;
@@ -18,7 +18,6 @@
import com.ruoyi.stock.mapper.StockInventoryMapper;
import com.ruoyi.stock.mapper.StockOutRecordMapper;
import com.ruoyi.stock.mapper.StockUninventoryMapper;
import com.ruoyi.stock.pojo.StockInRecord;
import com.ruoyi.stock.pojo.StockInventory;
import com.ruoyi.stock.pojo.StockOutRecord;
import com.ruoyi.stock.pojo.StockUninventory;
@@ -53,8 +52,6 @@
    public int add(StockOutRecordDto stockOutRecordDto) {
        String no = OrderUtils.countTodayByCreateTime(stockOutRecordMapper, "CK");
        stockOutRecordDto.setOutboundBatches(no);
        StockInRecord stockInRecord = new StockInRecord();
        BeanUtils.copyProperties(stockOutRecordDto, stockInRecord);
        return stockOutRecordMapper.insert(stockOutRecordDto);
    }
src/main/java/com/ruoyi/stock/word/WeighbridgeDocGenerator.java
@@ -5,6 +5,7 @@
import com.ruoyi.stock.dto.StockInRecordDto;
import org.apache.poi.xwpf.usermodel.*;
import org.apache.poi.xwpf.usermodel.XWPFTable.XWPFBorderType;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@@ -13,6 +14,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -61,7 +63,7 @@
            document.write(out);
            out.flush();
            // è¿”回绝对路径(用于数据库存储)
            // è¿”回绝对路径
            return absolutePath;
        } catch (Exception e) {
@@ -84,9 +86,22 @@
    /**
     * æž„建文档内容
     * @param document Word文档对象
     * @param dto å…¥åº“记录DTO
     */
    private void buildDocumentContent(XWPFDocument document, StockInRecordDto dto) {
        // 1. æ·»åŠ æ ‡é¢˜ "磅码单" - ä½¿ç”¨é»‘体
        // è®¾ç½®çº¸å¼ å¤§å°ä¸ºA5横向
        CTSectPr sectPr = document.getDocument().getBody().isSetSectPr()
                ? document.getDocument().getBody().getSectPr()
                : document.getDocument().getBody().addNewSectPr();
        CTPageSz pageSize = sectPr.isSetPgSz() ? sectPr.getPgSz() : sectPr.addNewPgSz();
        pageSize.setW(BigInteger.valueOf(11906));  // A5横向宽度 210mm
        pageSize.setH(BigInteger.valueOf(8392));   // A5横向高度 148mm
        pageSize.setOrient(STPageOrientation.LANDSCAPE);
        // æ ‡é¢˜ "磅码单"
        XWPFParagraph titlePara = document.createParagraph();
        titlePara.setAlignment(ParagraphAlignment.CENTER);
        titlePara.setSpacingAfter(200);
@@ -97,22 +112,71 @@
        titleRun.setFontSize(28);
        titleRun.setFontFamily("黑体");
        // 2. ç©ºä¸€è¡Œ
        document.createParagraph();
        // å®šä¹‰ç»Ÿä¸€çš„页面宽度值(所有表格使用相同的总宽度)
        int pageWidth = 9000; // ç»Ÿä¸€çš„页面宽度值
        // 3. å¤´éƒ¨ä¿¡æ¯ï¼ˆå¹´æœˆæ—¥å’Œè®¡é‡å•位合并在一行)- ä½¿ç”¨å®‹ä½“
        XWPFParagraph headerPara = document.createParagraph();
        headerPara.setSpacingAfter(200);
        XWPFRun headerRun = headerPara.createRun();
        // åˆ›å»ºä¸€è¡Œä¸¤åˆ—表格来放置日期和计量单位
        XWPFTable headerTable = document.createTable(1, 2);
        headerTable.setWidth("100%");
        // æ ¼å¼åŒ–日期为 yyyy-MM-dd
        // è®¾ç½®è¡¨æ ¼æ— è¾¹æ¡†
        headerTable.setInsideHBorder(XWPFBorderType.NONE, 0, 0, "000000");
        headerTable.setInsideVBorder(XWPFBorderType.NONE, 0, 0, "000000");
        headerTable.setTopBorder(XWPFBorderType.NONE, 0, 0, "000000");
        headerTable.setBottomBorder(XWPFBorderType.NONE, 0, 0, "000000");
        headerTable.setLeftBorder(XWPFBorderType.NONE, 0, 0, "000000");
        headerTable.setRightBorder(XWPFBorderType.NONE, 0, 0, "000000");
        // è®¾ç½®è¡¨å¤´è¡¨æ ¼åˆ—宽:日期列50%,计量单位列50%
        CTTbl headerTbl = headerTable.getCTTbl();
        CTTblGrid headerTblGrid = headerTbl.addNewTblGrid();
        // ä½¿ç”¨ç»Ÿä¸€çš„页面宽度
        int headerColWidth = pageWidth / 2; // 4500
        CTTblGridCol col1 = headerTblGrid.addNewGridCol();
        col1.setW(BigInteger.valueOf(headerColWidth));
        CTTblGridCol col2 = headerTblGrid.addNewGridCol();
        col2.setW(BigInteger.valueOf(headerColWidth));
        // è®¾ç½®è¡Œé«˜
        headerTable.getRow(0).setHeight(300);
        // ä¸ºè¡¨å¤´è¡¨æ ¼çš„æ¯ä¸ªå•元格设置宽度
        for (int colIndex = 0; colIndex < 2; colIndex++) {
            XWPFTableCell cell = headerTable.getRow(0).getCell(colIndex);
            CTTcPr tcPr = cell.getCTTc().addNewTcPr();
            CTTblWidth cellWidth = tcPr.addNewTcW();
            cellWidth.setType(STTblWidth.DXA);
            cellWidth.setW(BigInteger.valueOf(headerColWidth));
        }
        // å·¦ä¾§å•元格:日期(左对齐)
        XWPFTableCell dateCell = headerTable.getRow(0).getCell(0);
        dateCell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
        // æ¸…除单元格中可能存在的默认段落
        for (int i = dateCell.getParagraphs().size() - 1; i > 0; i--) {
            dateCell.removeParagraph(i);
        }
        XWPFParagraph datePara = dateCell.getParagraphs().get(0);
        datePara.setAlignment(ParagraphAlignment.LEFT);
        // æ¸…除段落中可能存在的默认Run
        for (int i = datePara.getRuns().size() - 1; i > 0; i--) {
            datePara.removeRun(i);
        }
        XWPFRun dateRun = datePara.createRun();
        // æ ¼å¼åŒ–日期
        String weighDate = "";
        if (dto.getWeighingDate() != null) {
            try {
                // å‡è®¾ weighingDate æ˜¯ LocalDateTime ç±»åž‹
                weighDate = dto.getWeighingDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
            } catch (Exception e) {
                // å¦‚果是字符串类型,尝试转换
                weighDate = dto.getWeighingDate().toString();
                if (weighDate.length() > 10) {
                    weighDate = weighDate.substring(0, 10);
@@ -120,17 +184,37 @@
            }
        }
        headerRun.setText("年月日:" + weighDate + "    è®¡é‡å•位:(吨)");
        headerRun.setFontSize(12);
        headerRun.setFontFamily("宋体");
        dateRun.setText("日 æœŸï¼š" + weighDate);
        dateRun.setFontSize(12);
        dateRun.setFontFamily("宋体");
        // 4. åˆ›å»ºä¸»è¡¨æ ¼ - 4行6列(表头1行+数据1行+合计1行+空行1行)
        XWPFTable table = document.createTable(4, 6);
        // è®¡é‡å•位(右对齐)
        XWPFTableCell unitCell = headerTable.getRow(0).getCell(1);
        unitCell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
        for (int i = unitCell.getParagraphs().size() - 1; i > 0; i--) {
            unitCell.removeParagraph(i);
        }
        XWPFParagraph unitPara = unitCell.getParagraphs().get(0);
        unitPara.setAlignment(ParagraphAlignment.RIGHT);
        for (int i = unitPara.getRuns().size() - 1; i > 0; i--) {
            unitPara.removeRun(i);
        }
        XWPFRun unitRun = unitPara.createRun();
        unitRun.setText("计量单位:(吨)");
        unitRun.setFontSize(12);
        unitRun.setFontFamily("宋体");
        // åˆ›å»ºä¸»è¡¨æ ¼ - 3行6列
        XWPFTable table = document.createTable(3, 6);
        // è®¾ç½®è¡¨æ ¼å®½åº¦
        table.setWidth("100%");
        // è®¾ç½®è¡¨æ ¼è¾¹æ¡†åŠ ç²—ï¼ˆè¾¹æ¡†å®½åº¦è®¾ä¸º2)
        // è®¾ç½®è¡¨æ ¼è¾¹æ¡†åŠ ç²—
        table.setInsideHBorder(XWPFBorderType.SINGLE, 2, 0, "000000");
        table.setInsideVBorder(XWPFBorderType.SINGLE, 2, 0, "000000");
        table.setTopBorder(XWPFBorderType.SINGLE, 2, 0, "000000");
@@ -142,7 +226,47 @@
        table.getRow(0).setHeight(400);
        table.getRow(1).setHeight(400);
        table.getRow(2).setHeight(400);
        table.getRow(3).setHeight(400);
        // è®¾ç½®ä¸»è¡¨æ ¼åˆ—宽网格 - ä½¿ç”¨ç›¸åŒçš„æ€»å®½åº¦ pageWidth
        CTTbl mainTbl = table.getCTTbl();
        CTTblGrid mainTblGrid = mainTbl.addNewTblGrid();
        // åˆ—宽比例
        int[] colWidths = {
                (int)(pageWidth * 0.20),
                (int)(pageWidth * 0.24),
                (int)(pageWidth * 0.14),
                (int)(pageWidth * 0.14),
                (int)(pageWidth * 0.14),
                (int)(pageWidth * 0.14)
        };
        // ç¡®ä¿æ€»å’Œç­‰äºŽpageWidth
        int sum = 0;
        for (int width : colWidths) {
            sum += width;
        }
        // å¦‚果有误差,调整最后一列
        if (sum != pageWidth) {
            colWidths[5] += (pageWidth - sum);
        }
        for (int width : colWidths) {
            CTTblGridCol col = mainTblGrid.addNewGridCol();
            col.setW(BigInteger.valueOf(width));
        }
        // ä¸ºæ¯ä¸€è¡Œçš„æ¯ä¸ªå•元格设置具体的宽度
        for (int rowIndex = 0; rowIndex < 3; rowIndex++) {
            XWPFTableRow row = table.getRow(rowIndex);
            for (int colIndex = 0; colIndex < 6; colIndex++) {
                XWPFTableCell cell = row.getCell(colIndex);
                CTTcPr tcPr = cell.getCTTc().addNewTcPr();
                CTTblWidth cellWidth = tcPr.addNewTcW();
                cellWidth.setType(STTblWidth.DXA);
                cellWidth.setW(BigInteger.valueOf(colWidths[colIndex]));
            }
        }
        // è®¾ç½®è¡¨å¤´ - ä½¿ç”¨é»‘体加粗
        String[] headers = {"车号", "品名", "毛重", "皮重", "净重", "备注"};
@@ -152,8 +276,18 @@
            cell.setText(headers[i]);
            cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            // æ¸…除可能存在的多余段落
            while (cell.getParagraphs().size() > 1) {
                cell.removeParagraph(1);
            }
            XWPFParagraph cellPara = cell.getParagraphs().get(0);
            cellPara.setAlignment(ParagraphAlignment.CENTER);
            while (cellPara.getRuns().size() > 1) {
                cellPara.removeRun(1);
            }
            XWPFRun cellRun = cellPara.getRuns().get(0);
            cellRun.setBold(true);
            cellRun.setFontSize(12);
@@ -180,8 +314,17 @@
            cell.setText(data[i]);
            cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            while (cell.getParagraphs().size() > 1) {
                cell.removeParagraph(1);
            }
            XWPFParagraph cellPara = cell.getParagraphs().get(0);
            cellPara.setAlignment(ParagraphAlignment.CENTER);
            while (cellPara.getRuns().size() > 1) {
                cellPara.removeRun(1);
            }
            XWPFRun cellRun = cellPara.getRuns().get(0);
            cellRun.setFontSize(12);
            cellRun.setFontFamily("宋体");
@@ -194,43 +337,68 @@
        XWPFTableCell totalLabelCell = totalRow.getCell(0);
        totalLabelCell.setText("合计(大写)");
        totalLabelCell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
        // æ¸…除可能存在的多余段落
        while (totalLabelCell.getParagraphs().size() > 1) {
            totalLabelCell.removeParagraph(1);
        }
        XWPFParagraph totalLabelPara = totalLabelCell.getParagraphs().get(0);
        totalLabelPara.setAlignment(ParagraphAlignment.CENTER);
        // æ¸…除可能存在的多余Run
        while (totalLabelPara.getRuns().size() > 1) {
            totalLabelPara.removeRun(1);
        }
        XWPFRun totalLabelRun = totalLabelPara.getRuns().get(0);
        totalLabelRun.setBold(true);
        totalLabelRun.setFontSize(12);
        totalLabelRun.setFontFamily("宋体");
        totalLabelRun.setFontFamily("黑体");
        XWPFTableCell contentCell = totalRow.getCell(1);
        // å°†å‡€é‡è½¬æ¢ä¸ºå¤§å†™
        String netWeightChinese = ChineseNumberUtil.numberToChinese(
                dto.getNetWeight() != null ? dto.getNetWeight() : BigDecimal.ZERO
        );
        contentCell.setText(netWeightChinese + "吨");
        contentCell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
        XWPFParagraph contentPara = contentCell.getParagraphs().get(0);
        contentPara.setAlignment(ParagraphAlignment.LEFT);
        XWPFRun contentRun = contentPara.getRuns().get(0);
        contentRun.setFontSize(12);
        contentRun.setFontFamily("宋体");
        // åˆå¹¶ç¬¬3-6列到第2列
        for (int i = 2; i < 6; i++) {
            XWPFTableCell cell = totalRow.getCell(i);
            // è®¾ç½®è¿™äº›å•元格为合并状态(继承自第2列)
            cell.getCTTc().addNewTcPr().addNewHMerge().setVal(org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge.CONTINUE);
        XWPFTableCell startCell = totalRow.getCell(1);
        startCell.setText(netWeightChinese + "吨");
        startCell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
        while (startCell.getParagraphs().size() > 1) {
            startCell.removeParagraph(1);
        }
        // 6. åˆ›å»ºè¿‡ç£…员行(单独一行,左对齐)
        XWPFParagraph startPara = startCell.getParagraphs().get(0);
        startPara.setAlignment(ParagraphAlignment.CENTER);
        while (startPara.getRuns().size() > 1) {
            startPara.removeRun(1);
        }
        XWPFRun startRun = startPara.getRuns().get(0);
        startRun.setFontSize(12);
        startRun.setFontFamily("宋体");
        // æ ‡è®°ç¬¬2列为合并起始
        startCell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.RESTART);
        // ç¬¬3-6列合并
        for (int i = 2; i < 6; i++) {
            XWPFTableCell cell = totalRow.getCell(i);
            cell.setText("");
            cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.CONTINUE);
        }
        // åˆ›å»ºè¿‡ç£…员行(单独一行,左对齐)
        XWPFParagraph operatorPara = document.createParagraph();
        operatorPara.setSpacingAfter(100);
        operatorPara.setAlignment(ParagraphAlignment.LEFT);
        XWPFRun operatorRun = operatorPara.createRun();
        String operator = dto.getWeighingOperator() != null ? dto.getWeighingOperator() : "";
        operatorRun.setText("过磅员:" + operator);
        operatorRun.setFontSize(8);
        operatorRun.setFontSize(12);
        operatorRun.setFontFamily("宋体");
    }
    /**
@@ -242,10 +410,10 @@
        String month = String.format("%02d", now.getMonthValue());
        String day = String.format("%02d", now.getDayOfMonth());
        // æ–‡ä»¶åæ ¼å¼ï¼šç£…单_车牌号_年月日时分秒.docx
        // æ–‡ä»¶åæ ¼å¼ï¼šç£…单_车牌号_年月日.docx
        String fileName = String.format("磅单_%s_%s.docx",
                dto.getLicensePlateNo() != null ? dto.getLicensePlateNo() : "未知车牌",
                now.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
                now.format(DateTimeFormatter.ofPattern("yyyyMMdd")));
        return uploadDir + File.separator + year + File.separator + month + File.separator + day + File.separator + fileName;
    }
src/main/resources/application-kthg.yml
@@ -75,7 +75,7 @@
      # ä¸»åº“数据源
      master:
        #        url: jdbc:mysql://localhost:3306/product-inventory-management-new?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
        url: jdbc:mysql://1.15.17.182:9999/product-inventory-management-kthg?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
        url: jdbc:mysql://172.17.0.1:3306/product-inventory-management-kthg?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
        username: root
        password: xd@123456..
      # ä»Žåº“数据源
@@ -256,4 +256,4 @@
#  temp-dir: D:/ruoyi/temp/uploads   # ä¸´æ—¶ç›®å½•
#  upload-dir: D:/ruoyi/prod/uploads # æ­£å¼ç›®å½•
  temp-dir: /javaWork/product-inventory-management/file/temp/uploads
  upload-dir: /javaWork/product-inventory-management/file/prod/uploads
  upload-dir: /javaWork/product-inventory-management/file/prod/uploads
src/main/resources/mapper/consumables/ConsumablesInRecordMapper.xml
@@ -8,6 +8,7 @@
        p.product_name as product_name,
        pm.model,
        pm.unit,
        sir.weighbridge_doc_path,
        u.nick_name as createBy
        FROM consumables_in_record as sir
        LEFT JOIN product_model as pm on sir.product_model_id = pm.id
src/main/resources/mapper/consumables/ConsumablesInventoryMapper.xml
@@ -14,8 +14,11 @@
        <result column="warn_num" property="warnNum"/>
    </resultMap>
    <update id="updateAddConsumablesInventory">
        update Consumables_inventory
        update consumables_inventory
        <set>
            <if test="ew.productId != null">
                product_id = #{ew.productId},
            </if>
            <if test="ew.qualitity != null">
                qualitity = qualitity + #{ew.qualitity},
            </if>
@@ -37,7 +40,7 @@
        where product_model_id = #{ew.productModelId}
    </update>
    <update id="updateSubtractConsumablesInventory">
        update Consumables_inventory
        update consumables_inventory
        <set>
            <if test="ew.netWeight != null">
                qualitity = qualitity - #{ew.netWeight},
@@ -71,9 +74,9 @@
        pm.unit,
        p.product_name,
        p1.product_name as parent_name,
        p1.id as parent_id
        from Consumables_inventory si
        p1.id as parent_id,
        si.product_id as productId
        from consumables_inventory si
        left join product_model pm on si.product_model_id = pm.id
        left join product p on pm.product_id = p.id
        left join product p1 on p.parent_id = p1.id
@@ -114,7 +117,7 @@
        coalesce(si.locked_quantity, 0) as locked_quantity,
        si.remark,
        si.update_time
        from Consumables_inventory si
        from consumables_inventory si
        left join product_model pm on si.product_model_id = pm.id
        left join product p on pm.product_id = p.id
        where 1 = 1
@@ -123,10 +126,10 @@
        </if>
    </select>
    <select id="ConsumablesInventoryPage" resultType="com.ruoyi.consumables.dto.ConsumablesInRecordDto">
    <select id="consumablesInventoryPage" resultType="com.ruoyi.consumables.dto.ConsumablesInRecordDto">
        select
        sir.*,
        si.qualitity as current_Consumables,
        si.qualitity as current_consumables,
        pm.model,
        pm.unit,
        p.product_name,
@@ -137,7 +140,7 @@
        from Consumables_in_record sir
        left join Consumables_inventory si
        left join consumables_inventory si
        on sir.product_model_id = si.product_model_id
        left join product_model pm
@@ -183,12 +186,12 @@
        </where>
    </select>
    <select id="ConsumablesInAndOutRecord" resultType="com.ruoyi.consumables.dto.ConsumablesInventoryDto">
    <select id="consumablesInAndOutRecord" resultType="com.ruoyi.consumables.dto.ConsumablesInventoryDto">
        SELECT
        pm.model,
        pm.unit,
        p.product_name,
        MAX(current_inventory) as current_Consumables,
        MAX(current_inventory) as current_consumables,
        SUM(CASE WHEN record_type = 'in' THEN amount ELSE 0 END) as total_Consumables_in,
        SUM(CASE WHEN record_type = 'out' THEN amount ELSE 0 END) as total_Consumables_out
        FROM (
@@ -197,7 +200,7 @@
        SUM(qualitity) as current_inventory,
        0 as amount,
        '' as record_type
        FROM Consumables_inventory
        FROM consumables_inventory
        GROUP BY product_model_id
        UNION ALL
src/main/resources/mapper/consumables/ConsumablesOutRecordMapper.xml
@@ -6,7 +6,7 @@
    <resultMap id="BaseResultMap" type="com.ruoyi.consumables.pojo.ConsumablesOutRecord">
        <id column="id" property="id" />
        <result column="outbound_batches" property="outboundBatches" />
        <result column="Consumables_out_num" property="consumablesOutNum" />
        <result column="stock_out_num" property="stockOutNum" />
        <result column="record_id" property="recordId" />
        <result column="record_type" property="recordType" />
        <result column="product_model_id" property="productModelId" />
@@ -24,8 +24,9 @@
        p.product_name as productName,
        pm.model,
        pm.unit,
        sor.weighbridge_doc_path,
        u.nick_name as createBy
        FROM Consumables_out_record as sor
        FROM consumables_out_record as sor
        LEFT JOIN product_model as pm on sor.product_model_id = pm.id
        LEFT JOIN product as p on pm.product_id = p.id
        LEFT JOIN sys_user as u on sor.create_user = u.user_id
@@ -52,7 +53,7 @@
        pm.model,
        pm.unit,
        u.nick_name as createBy
        FROM Consumables_out_record as sor
        FROM consumables_out_record as sor
        LEFT JOIN product_model as pm on sor.product_model_id = pm.id
        LEFT JOIN product as p on pm.product_id = p.id
        LEFT JOIN sys_user as u on sor.create_user = u.user_id
src/main/resources/mapper/consumables/ConsumablesUninventoryMapper.xml
@@ -43,7 +43,7 @@
        </set>
        where product_model_id = #{ew.productModelId}
    </update>
    <select id="pageConsumablesUninventory" resultType="com.ruoyi.consumables.dto.ConsumablesUnInventoryDto">
    <select id="pageConsumablesUnInventory" resultType="com.ruoyi.consumables.dto.ConsumablesUnInventoryDto">
        select su.id,
        su.qualitity,
        COALESCE(su.locked_quantity, 0) as locked_quantity,
src/main/resources/mapper/quality/RawMaterialMapper.xml
@@ -27,11 +27,17 @@
        <if test="params.checkType != null ">
            AND rm.check_type = #{params.checkType}
        </if>
        <if test="params.batchNo != null and params.batchNo != ''">
            and rm.batch_no like concat('%', #{params.batchNo}, '%')
        </if>
        <if test="params.inspectState != null ">
            AND rm.inspect_state = #{params.inspectState}
        </if>
        <if test="params.entryDateStart != null and params.entryDateStart != '' ">
            AND rm.check_time &gt;= DATE_FORMAT(#{params.entryDateStart},'%Y-%m-%d')
            AND rm.check_time &gt;= #{params.entryDateStart}
        </if>
        <if test="params.entryDateEnd != null and params.entryDateEnd != '' ">
            AND rm.check_time &lt;= DATE_FORMAT(#{params.entryDateEnd},'%Y-%m-%d')
            AND rm.check_time &lt;= #{params.entryDateEnd}
        </if>
        ORDER BY rm.check_time DESC
    </select>
src/main/resources/mapper/stock/StockInRecordMapper.xml
@@ -8,6 +8,7 @@
        p.product_name as product_name,
        pm.model,
        pm.unit,
        sir.weighbridge_doc_path,
        u.nick_name as createBy
        FROM stock_in_record as sir
        LEFT JOIN product_model as pm on sir.product_model_id = pm.id
src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -16,6 +16,9 @@
    <update id="updateAddStockInventory">
        update stock_inventory
        <set>
            <if test="ew.productId != null">
                product_id = #{ew.productId},
            </if>
            <if test="ew.qualitity != null">
                qualitity = qualitity + #{ew.qualitity},
            </if>
@@ -71,8 +74,8 @@
        pm.unit,
        p.product_name,
        p1.product_name as parent_name,
        p1.id as parent_id
        p1.id as parent_id,
        si.product_id as productId
        from stock_inventory si
        left join product_model pm on si.product_model_id = pm.id
        left join product p on pm.product_id = p.id
src/main/resources/mapper/stock/StockOutRecordMapper.xml
@@ -24,6 +24,7 @@
        p.product_name as productName,
        pm.model,
        pm.unit,
        sor.weighbridge_doc_path,
        u.nick_name as createBy
        FROM stock_out_record as sor
        LEFT JOIN product_model as pm on sor.product_model_id = pm.id
src/main/resources/static/report-template.docx
Binary files differ