chenhj
2 天以前 9dcd90dc8e329900e6058ac0a3aa44a9e7e04599
库存明细,以及库存数量更新方法,库存节点存储
已修改7个文件
已添加23个文件
945 ■■■■■ 文件已修改
main-business/src/main/java/com/ruoyi/business/constant/InventoryRecordConstant.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/controller/InputInventoryRecordController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/controller/InventorySummaryController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/controller/OutputInventoryRecordController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/entity/InputInventoryRecord.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/entity/InventorySummary.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/entity/OutputInventoryRecord.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/mapper/InputInventoryRecordMapper.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/mapper/InventorySummaryMapper.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/mapper/OfficialInventoryMapper.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/mapper/OutputInventoryRecordMapper.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/mapper/PendingInventoryMapper.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/InputInventoryRecordService.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/InventorySummaryService.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/OutputInventoryRecordService.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/impl/InputInventoryRecordServiceImpl.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/impl/InventorySummaryServiceImpl.java 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/impl/OutputInventoryRecordServiceImpl.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/task/InventorySummaryTask.java 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/resources/db/migration/postgresql/V20250614110410__create_table_input_inventory_record.sql 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/resources/db/migration/postgresql/V20250614111500__create_table_output_inventory_record.sql 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/resources/db/migration/postgresql/V20250614111811__create_table_inventory_summary.sql 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/resources/mapper/InputInventoryRecordMapper.xml 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/resources/mapper/InventorySummaryMapper.xml 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/resources/mapper/OfficialInventoryMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/resources/mapper/OutputInventoryRecordMapper.xml 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/resources/mapper/PendingInventoryMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/PlusCodeGenerator.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/constant/InventoryRecordConstant.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.ruoyi.business.constant;
public class InventoryRecordConstant {
    // å¾…入库
    public static String PENDING_INVENTORY = "PENDING_INVENTORY";
    // æ­£å¼åº“
    public static String OFFICIAL_INVENTORY = "OFFICIAL_INVENTORY";
}
main-business/src/main/java/com/ruoyi/business/controller/InputInventoryRecordController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package com.ruoyi.business.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import lombok.AllArgsConstructor;
    import org.springframework.web.bind.annotation.RestController;
/**
* <p>
    * å…¥åº“记录表 å‰ç«¯æŽ§åˆ¶å™¨
    * </p>
*
* @author chenhj
* @since 2025-06-14
*/
@RestController
@AllArgsConstructor
@RequestMapping("/business/inputInventoryRecord")
        public class InputInventoryRecordController {
    }
main-business/src/main/java/com/ruoyi/business/controller/InventorySummaryController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package com.ruoyi.business.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import lombok.AllArgsConstructor;
    import org.springframework.web.bind.annotation.RestController;
/**
* <p>
    * åº“存汇总表 å‰ç«¯æŽ§åˆ¶å™¨
    * </p>
*
* @author chenhj
* @since 2025-06-14
*/
@RestController
@AllArgsConstructor
@RequestMapping("/business/inventorySummary")
        public class InventorySummaryController {
    }
main-business/src/main/java/com/ruoyi/business/controller/OutputInventoryRecordController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package com.ruoyi.business.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import lombok.AllArgsConstructor;
    import org.springframework.web.bind.annotation.RestController;
/**
* <p>
    * å‡ºåº“记录表 å‰ç«¯æŽ§åˆ¶å™¨
    * </p>
*
* @author chenhj
* @since 2025-06-14
*/
@RestController
@AllArgsConstructor
@RequestMapping("/business/outputInventoryRecord")
        public class OutputInventoryRecordController {
    }
main-business/src/main/java/com/ruoyi/business/entity/InputInventoryRecord.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,56 @@
package com.ruoyi.business.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
 * å…¥åº“记录表 å®žä½“ç±»
 *
 * @author chenhj
 * @date 2025-06-14
 */
@Data
@TableName("input_inventory_record")
public class InputInventoryRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ä¸»é”®ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * åº“id
     */
    @TableField(value = "inventory_id")
    private Long inventoryId;
    /**
     * åº“类型
     */
    @TableField(value = "inventory_type")
    private String inventoryType;
    /**
     * è®°å½•数量
     */
    @TableField(value = "quantity")
    private BigDecimal quantity;
    /** é€»è¾‘删除字段 */
    @TableLogic
    private Integer deleted;
    /** åˆ›å»ºè€… */
    @TableField(fill = FieldFill.INSERT)
    private String createBy;
    /** åˆ›å»ºæ—¶é—´ */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    private LocalDateTime createTime;
}
main-business/src/main/java/com/ruoyi/business/entity/InventorySummary.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,73 @@
package com.ruoyi.business.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
 * åº“存汇总表 å®žä½“ç±»
 *
 * @author chenhj
 * @date 2025-06-14
 */
@Data
@TableName("inventory_summary")
public class InventorySummary implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ä¸»é”®ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * åº“id
     */
    @TableField(value = "inventory_id")
    private Long inventoryId;
    /**
     * åº“类型
     */
    @TableField(value = "inventory_type")
    private String inventoryType;
    /**
     * åº“存数量
     */
    @TableField(value = "inventory_quantity")
    private BigDecimal inventoryQuantity;
    /**
     * å…¥åº“中止明细记录id
     */
    @TableField(value = "input_end_record_id")
    private Long inputEndRecordId;
    /**
     * å‡ºåº“中止明细记录id
     */
    @TableField(value = "output_end_record_id")
    private Long outputEndRecordId;
    /**
     * é€»è¾‘删除字段
     */
    @TableLogic
    private Integer deleted;
    /**
     * åˆ›å»ºæ—¶é—´
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    private LocalDateTime createTime;
    /**
     * æ›´æ–°æ—¶é—´
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
}
main-business/src/main/java/com/ruoyi/business/entity/OutputInventoryRecord.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,56 @@
package com.ruoyi.business.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
 * å‡ºåº“记录表 å®žä½“ç±»
 *
 * @author chenhj
 * @date 2025-06-14
 */
@Data
@TableName("output_inventory_record")
public class OutputInventoryRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ä¸»é”®ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * åº“id
     */
    @TableField(value = "inventory_id")
    private Long inventoryId;
    /**
     * åº“类型
     */
    @TableField(value = "inventory_type")
    private String inventoryType;
    /**
     * è®°å½•数量
     */
    @TableField(value = "quantity")
    private BigDecimal quantity;
    /** é€»è¾‘删除字段 */
    @TableLogic
    private Integer deleted;
    /** åˆ›å»ºè€… */
    @TableField(fill = FieldFill.INSERT)
    private String createBy;
    /** åˆ›å»ºæ—¶é—´ */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    private LocalDateTime createTime;
}
main-business/src/main/java/com/ruoyi/business/mapper/InputInventoryRecordMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
package com.ruoyi.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.business.entity.InputInventoryRecord;
import org.apache.ibatis.annotations.Mapper;
/**
 * <p>
 * å…¥åº“记录表 Mapper æŽ¥å£
 * </p>
 *
 * @author chenhj
 * @since 2025-06-14
 */
@Mapper
public interface InputInventoryRecordMapper extends BaseMapper<InputInventoryRecord> {
}
main-business/src/main/java/com/ruoyi/business/mapper/InventorySummaryMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
package com.ruoyi.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.business.entity.InventorySummary;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
 * <p>
 * åº“存汇总表 Mapper æŽ¥å£
 * </p>
 *
 * @author chenhj
 * @since 2025-06-14
 */
@Mapper
public interface InventorySummaryMapper extends BaseMapper<InventorySummary> {
    InventorySummary getInventorySummaryForUpdateById(@Param("id") Long id);
    InventorySummary getInventorySummaryForUpdateByInventoryIdAndType(@Param("inventoryId") Long inventoryId, @Param("type") String type);
}
main-business/src/main/java/com/ruoyi/business/mapper/OfficialInventoryMapper.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.business.entity.OfficialInventory;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
 * <p>
@@ -14,5 +15,6 @@
 */
@Mapper
public interface OfficialInventoryMapper extends BaseMapper<OfficialInventory> {
    // èŽ·å–æ­£å¼åº“è®°å½•
    OfficialInventory getOfficialInventoryForUpdateById(@Param("id") Long id);
}
main-business/src/main/java/com/ruoyi/business/mapper/OutputInventoryRecordMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
package com.ruoyi.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.business.entity.OutputInventoryRecord;
import org.apache.ibatis.annotations.Mapper;
/**
 * <p>
 * å‡ºåº“记录表 Mapper æŽ¥å£
 * </p>
 *
 * @author chenhj
 * @since 2025-06-14
 */
@Mapper
public interface OutputInventoryRecordMapper extends BaseMapper<OutputInventoryRecord> {
}
main-business/src/main/java/com/ruoyi/business/mapper/PendingInventoryMapper.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.business.entity.PendingInventory;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
 * <p>
@@ -14,5 +15,6 @@
 */
@Mapper
public interface PendingInventoryMapper extends BaseMapper<PendingInventory> {
    // èŽ·å–å¾…å…¥åº“è®°å½•
    PendingInventory  getPendingInventoryForUpdateById(@Param("id") Long id);
}
main-business/src/main/java/com/ruoyi/business/service/InputInventoryRecordService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
package com.ruoyi.business.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.business.dto.OfficialInventoryDto;
import com.ruoyi.business.dto.PendingInventoryDto;
import com.ruoyi.business.entity.InputInventoryRecord;
import java.math.BigDecimal;
/**
 * <p>
 * å…¥åº“记录表 æœåŠ¡ç±»
 * </p>
 *
 * @author chenhj
 * @since 2025-06-14
 */
public interface InputInventoryRecordService extends IService<InputInventoryRecord> {
    // æ·»åŠ å…¥åº“è®°å½•
    int insertInputInventoryRecord(PendingInventoryDto pendingInventoryDto, OfficialInventoryDto officialInventoryDto, BigDecimal quantity);
}
main-business/src/main/java/com/ruoyi/business/service/InventorySummaryService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,24 @@
package com.ruoyi.business.service;
import com.ruoyi.business.dto.OfficialInventoryDto;
import com.ruoyi.business.dto.PendingInventoryDto;
import com.ruoyi.business.entity.InventorySummary;
import com.baomidou.mybatisplus.extension.service.IService;
/**
 * <p>
 * åº“存汇总表 æœåŠ¡ç±»
 * </p>
 *
 * @author chenhj
 * @since 2025-06-14
 */
public interface InventorySummaryService extends IService<InventorySummary> {
    /**
     * æ›´æ–°åº“å­˜
     * @param pendingInventoryDto å¾…处理库存
     * @param officialInventoryDto æ­£å¼åº“å­˜
     */
    int updateInventory(PendingInventoryDto pendingInventoryDto, OfficialInventoryDto officialInventoryDto);
}
main-business/src/main/java/com/ruoyi/business/service/OutputInventoryRecordService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
package com.ruoyi.business.service;
import com.ruoyi.business.dto.OfficialInventoryDto;
import com.ruoyi.business.dto.PendingInventoryDto;
import com.ruoyi.business.entity.OutputInventoryRecord;
import com.baomidou.mybatisplus.extension.service.IService;
import java.math.BigDecimal;
/**
 * <p>
 * å‡ºåº“记录表 æœåŠ¡ç±»
 * </p>
 *
 * @author chenhj
 * @since 2025-06-14
 */
public interface OutputInventoryRecordService extends IService<OutputInventoryRecord> {
    // æ·»åŠ å‡ºåº“è®°å½•
    int insertOutputInventoryRecord(PendingInventoryDto pendingInventoryDto, OfficialInventoryDto officialInventoryDto, BigDecimal quantity);
}
main-business/src/main/java/com/ruoyi/business/service/impl/InputInventoryRecordServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,56 @@
package com.ruoyi.business.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.business.dto.OfficialInventoryDto;
import com.ruoyi.business.dto.PendingInventoryDto;
import com.ruoyi.business.entity.InputInventoryRecord;
import com.ruoyi.business.mapper.InputInventoryRecordMapper;
import com.ruoyi.business.service.InputInventoryRecordService;
import com.ruoyi.business.service.InventorySummaryService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import static com.ruoyi.business.constant.InventoryRecordConstant.OFFICIAL_INVENTORY;
import static com.ruoyi.business.constant.InventoryRecordConstant.PENDING_INVENTORY;
/**
 * <p>
 * å…¥åº“记录表 æœåŠ¡å®žçŽ°ç±»
 * </p>
 *
 * @author chenhj
 * @since 2025-06-14
 */
@Service
@RequiredArgsConstructor
public class InputInventoryRecordServiceImpl extends ServiceImpl<InputInventoryRecordMapper, InputInventoryRecord> implements InputInventoryRecordService {
    @Autowired
    private InputInventoryRecordMapper inputInventoryRecordMapper;
    @Autowired
    private InventorySummaryService inventorySummaryService;
    @Override
    public int insertInputInventoryRecord(PendingInventoryDto pendingInventoryDto, OfficialInventoryDto officialInventoryDto, BigDecimal quantity) {
        if ((pendingInventoryDto != null && officialInventoryDto != null) || (pendingInventoryDto == null && officialInventoryDto == null)) {
            throw new RuntimeException("库存记录异常");
        }
        InputInventoryRecord inputInventoryRecord = new InputInventoryRecord();
        if (officialInventoryDto != null) {
            inputInventoryRecord.setInventoryType(OFFICIAL_INVENTORY);
            inputInventoryRecord.setId(officialInventoryDto.getId());
        } else {
            inputInventoryRecord.setInventoryType(PENDING_INVENTORY);
            inputInventoryRecord.setId(pendingInventoryDto.getId());
        }
        inputInventoryRecord.setQuantity(quantity);
        inputInventoryRecordMapper.insert(inputInventoryRecord);
        // æ›´æ–°åº“å­˜
        return inventorySummaryService.updateInventory(pendingInventoryDto, officialInventoryDto);
    }
}
main-business/src/main/java/com/ruoyi/business/service/impl/InventorySummaryServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,99 @@
package com.ruoyi.business.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.business.dto.OfficialInventoryDto;
import com.ruoyi.business.dto.PendingInventoryDto;
import com.ruoyi.business.entity.*;
import com.ruoyi.business.mapper.InventorySummaryMapper;
import com.ruoyi.business.mapper.OfficialInventoryMapper;
import com.ruoyi.business.mapper.PendingInventoryMapper;
import com.ruoyi.business.service.InputInventoryRecordService;
import com.ruoyi.business.service.InventorySummaryService;
import com.ruoyi.business.service.OutputInventoryRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import static com.ruoyi.business.constant.InventoryRecordConstant.OFFICIAL_INVENTORY;
import static com.ruoyi.business.constant.InventoryRecordConstant.PENDING_INVENTORY;
/**
 * <p>
 * åº“存汇总表 æœåŠ¡å®žçŽ°ç±»
 * </p>
 *
 * @author chenhj
 * @since 2025-06-14
 */
@Service
@RequiredArgsConstructor
public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMapper, InventorySummary> implements InventorySummaryService {
    @Autowired
    private InventorySummaryMapper inventorySummaryMapper;
    @Autowired
    private InputInventoryRecordService inputInventoryRecordService;
    @Autowired
    private OutputInventoryRecordService outputInventoryRecordService;
    @Autowired
    private PendingInventoryMapper pendingInventoryMapper;
    @Autowired
    private OfficialInventoryMapper officialInventoryMapper;
    @Override
    public int updateInventory(PendingInventoryDto pendingInventoryDto, OfficialInventoryDto officialInventoryDto) {
        if ((pendingInventoryDto != null && officialInventoryDto != null) || (pendingInventoryDto == null && officialInventoryDto == null)) {
            throw new RuntimeException("库存记录异常");
        }
        String inventoryType = pendingInventoryDto != null ? PENDING_INVENTORY : OFFICIAL_INVENTORY;
        Long inventoryId = pendingInventoryDto != null ? pendingInventoryDto.getId() : officialInventoryDto.getId();
        Long inputEndRecordId = 0L;
        Long outputEndRecordId = 0L;
        InventorySummary inventorySummary = inventorySummaryMapper.selectOne(new LambdaQueryWrapper<InventorySummary>()
                .eq(InventorySummary::getInventoryId, inventoryId)
                .eq(InventorySummary::getInventoryType, inventoryType));
        if (inventorySummary != null) {
            inputEndRecordId = inventorySummary.getInputEndRecordId();
            outputEndRecordId  = inventorySummary.getOutputEndRecordId();
        }
        // æŸ¥è¯¢èŠ‚ç‚¹ä»¥åŽæ‰€æœ‰å…¥åº“è®°å½•
        List<InputInventoryRecord> inputInventoryRecords = inputInventoryRecordService.list(new LambdaQueryWrapper<InputInventoryRecord>()
                .eq(InputInventoryRecord::getInventoryId, inventoryId)
                .eq(InputInventoryRecord::getInventoryType, inventoryType)
                .gt(InputInventoryRecord::getId, inputEndRecordId));
        // æŸ¥è¯¢èŠ‚ç‚¹ä»¥åŽæ‰€æœ‰å‡ºåº“è®°å½•
        List<OutputInventoryRecord> outputInventoryRecords = outputInventoryRecordService.list(new LambdaQueryWrapper<OutputInventoryRecord>()
                .eq(OutputInventoryRecord::getInventoryId, inventoryId)
                .eq(OutputInventoryRecord::getInventoryType, inventoryType)
                .gt(OutputInventoryRecord::getId, outputEndRecordId));
        // å¦‚果入库数量大于出库数量,则库存数量为入库数量减去出库数量,反之则为0
        BigDecimal quantity = BigDecimal.ZERO;
        BigDecimal totalInputQuantity = inputInventoryRecords.stream().map(InputInventoryRecord::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
        BigDecimal totalOutputQuantity = outputInventoryRecords.stream().map(OutputInventoryRecord::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
        if (totalInputQuantity.compareTo(totalOutputQuantity) > 0) {
            quantity = totalInputQuantity.subtract(totalOutputQuantity);
        }
        if (inventoryType.equals(PENDING_INVENTORY)) {
            // å˜æ›´å¾…入库值
            PendingInventory pendingInventory = pendingInventoryMapper.getPendingInventoryForUpdateById(pendingInventoryDto.getId());
            if (pendingInventory == null) {
                throw new RuntimeException("库存记录不存在");
            }
            pendingInventory.setInventoryQuantity(quantity);
           return pendingInventoryMapper.updateById(pendingInventory);
        } else {
            OfficialInventory officialInventory = officialInventoryMapper.getOfficialInventoryForUpdateById(officialInventoryDto.getId());
            if (officialInventory == null) {
                throw new RuntimeException("库存记录不存在");
            }
            officialInventory.setInventoryQuantity(quantity);
            return officialInventoryMapper.updateById(officialInventory);
        }
    }
}
main-business/src/main/java/com/ruoyi/business/service/impl/OutputInventoryRecordServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,56 @@
package com.ruoyi.business.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.business.dto.OfficialInventoryDto;
import com.ruoyi.business.dto.PendingInventoryDto;
import com.ruoyi.business.entity.OutputInventoryRecord;
import com.ruoyi.business.mapper.OutputInventoryRecordMapper;
import com.ruoyi.business.service.InventorySummaryService;
import com.ruoyi.business.service.OutputInventoryRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import static com.ruoyi.business.constant.InventoryRecordConstant.OFFICIAL_INVENTORY;
import static com.ruoyi.business.constant.InventoryRecordConstant.PENDING_INVENTORY;
/**
 * <p>
 * å‡ºåº“记录表 æœåŠ¡å®žçŽ°ç±»
 * </p>
 *
 * @author chenhj
 * @since 2025-06-14
 */
@Service
@RequiredArgsConstructor
public class OutputInventoryRecordServiceImpl extends ServiceImpl<OutputInventoryRecordMapper, OutputInventoryRecord> implements OutputInventoryRecordService {
    @Autowired
    private OutputInventoryRecordMapper outputInventoryRecordMapper;
    @Autowired
    private InventorySummaryService inventorySummaryService;
    @Override
    public int insertOutputInventoryRecord(PendingInventoryDto pendingInventoryDto, OfficialInventoryDto officialInventoryDto, BigDecimal quantity) {
        if ((pendingInventoryDto != null && officialInventoryDto != null) || (pendingInventoryDto == null && officialInventoryDto == null)) {
            throw new RuntimeException("库存记录异常");
        }
        OutputInventoryRecord outputInventoryRecord = new OutputInventoryRecord();
        if (officialInventoryDto != null) {
            outputInventoryRecord.setInventoryType(OFFICIAL_INVENTORY);
            outputInventoryRecord.setId(officialInventoryDto.getId());
        } else {
            outputInventoryRecord.setInventoryType(PENDING_INVENTORY);
            outputInventoryRecord.setId(pendingInventoryDto.getId());
        }
        outputInventoryRecord.setQuantity(quantity);
        outputInventoryRecordMapper.insert(outputInventoryRecord);
        // å˜æ›´åŽŸåº“å­˜ä¿¡æ¯
        return inventorySummaryService.updateInventory(pendingInventoryDto, officialInventoryDto);
    }
}
main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java
@@ -136,6 +136,8 @@
                pendingInventoryMapper.deleteById(pendingInventoryDto.getPId());
            }
            officialInventoryMapper.delete(new LambdaQueryWrapper<OfficialInventory>().eq(OfficialInventory::getPendingId, pendingInventoryDto.getPId()));
            OfficialInventory officialInventory = new OfficialInventory();
            BeanUtils.copyProperties(pendingInventory, officialInventory);
            officialInventory.setId(null);
main-business/src/main/java/com/ruoyi/business/task/InventorySummaryTask.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,144 @@
package com.ruoyi.business.task;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.business.entity.*;
import com.ruoyi.business.mapper.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.ruoyi.business.constant.InventoryRecordConstant.OFFICIAL_INVENTORY;
import static com.ruoyi.business.constant.InventoryRecordConstant.PENDING_INVENTORY;
@Slf4j
@Component
public class InventorySummaryTask {
    @Autowired
    private PendingInventoryMapper pendingInventoryMapper;
    @Autowired
    private OfficialInventoryMapper officialInventoryMapper;
    @Autowired
    private InventorySummaryMapper inventorySummaryMapper;
    @Autowired
    private InputInventoryRecordMapper inputInventoryRecordMapper;
    @Autowired
    private OutputInventoryRecordMapper outputInventoryRecordMapper;
    private final ExecutorService executor = Executors.newFixedThreadPool(5);
    // æ¯éš”10天的凌晨3点执行
    @Scheduled(cron = "0 0 3 1/10 * ?")
    @Transactional
    public void updateInventorySummary() {
        log.info("开始执行库存节点统计定时任务: " + System.currentTimeMillis());
        log.info("更新待入库库存节点");
        updatePendingInventory();
        log.info("更新正式库存节点");
        updateOfficialInventory();
        log.info("结束执行库存节点统计定时任务: " + System.currentTimeMillis());
    }
    // æ›´æ–°å¾…入库库存节点
    private void updatePendingInventory() {
        pendingInventoryMapper.selectList(Wrappers.emptyWrapper(), new ResultHandler<PendingInventory>() {
            @Override
            public void handleResult(ResultContext<? extends PendingInventory> resultContext) {
                PendingInventory pendingInventory = resultContext.getResultObject();
                executor.submit(() -> {
                    handleInventorySummary(pendingInventory, null);
                });
            }
        });
    }
    // æ›´æ–°æ­£å¼åº“存节点
    private void updateOfficialInventory() {
        officialInventoryMapper.selectList(Wrappers.emptyWrapper(), new ResultHandler<OfficialInventory>() {
            @Override
            public void handleResult(ResultContext<? extends OfficialInventory> resultContext) {
                OfficialInventory officialInventory = resultContext.getResultObject();
                executor.submit(() -> {
                    handleInventorySummary(null, officialInventory);
                });
            }
        });
    }
    // æ›´æ–°èŠ‚ç‚¹æ•°æ®
    private void handleInventorySummary(PendingInventory pendingInventory, OfficialInventory officialInventory) {
        InventorySummary inventorySummary = null;
        List<InputInventoryRecord> inputInventoryRecordList = new ArrayList<>();
        List<OutputInventoryRecord> outputInventoryRecordList = new ArrayList<>();
        if (pendingInventory != null) {
            inventorySummary = inventorySummaryMapper.getInventorySummaryForUpdateByInventoryIdAndType(pendingInventory.getId(), PENDING_INVENTORY);
            inputInventoryRecordList = inputInventoryRecordMapper.selectList(new LambdaQueryWrapper<InputInventoryRecord>()
                    .eq(InputInventoryRecord::getInventoryId, pendingInventory.getId())
                    .eq(InputInventoryRecord::getInventoryType, PENDING_INVENTORY)
                    .gt(InputInventoryRecord::getId, inventorySummary == null ? 0 : inventorySummary.getInputEndRecordId()));
            outputInventoryRecordList = outputInventoryRecordMapper.selectList(new LambdaQueryWrapper<OutputInventoryRecord>()
                    .eq(OutputInventoryRecord::getInventoryId, pendingInventory.getId())
                    .eq(OutputInventoryRecord::getInventoryType, PENDING_INVENTORY)
                    .gt(OutputInventoryRecord::getId, inventorySummary == null ? 0 : inventorySummary.getOutputEndRecordId()));
            if (inventorySummary == null) {
                inventorySummary = new InventorySummary();
                inventorySummary.setInventoryQuantity(BigDecimal.ZERO);
                inventorySummary.setInventoryId(pendingInventory.getId());
                inventorySummary.setInventoryType(PENDING_INVENTORY);
            }
        }
        if (officialInventory != null) {
            inventorySummary = inventorySummaryMapper.getInventorySummaryForUpdateByInventoryIdAndType(officialInventory.getId(), OFFICIAL_INVENTORY);
            inputInventoryRecordList = inputInventoryRecordMapper.selectList(new LambdaQueryWrapper<InputInventoryRecord>()
                    .eq(InputInventoryRecord::getInventoryId, officialInventory.getId())
                    .eq(InputInventoryRecord::getInventoryType, OFFICIAL_INVENTORY)
                    .gt(InputInventoryRecord::getId, inventorySummary == null ? 0 : inventorySummary.getInputEndRecordId()));
            outputInventoryRecordList = outputInventoryRecordMapper.selectList(new LambdaQueryWrapper<OutputInventoryRecord>()
                    .eq(OutputInventoryRecord::getInventoryId, officialInventory.getId())
                    .eq(OutputInventoryRecord::getInventoryType, OFFICIAL_INVENTORY)
                    .gt(OutputInventoryRecord::getId, inventorySummary == null ? 0 : inventorySummary.getOutputEndRecordId()));
            if (inventorySummary == null) {
                inventorySummary = new InventorySummary();
                inventorySummary.setInventoryQuantity(BigDecimal.ZERO);
                inventorySummary.setInventoryId(officialInventory.getId());
                inventorySummary.setInventoryType(OFFICIAL_INVENTORY);
            }
        }
        BigDecimal total = inventorySummary.getInventoryQuantity();
        BigDecimal inputTotal = BigDecimal.ZERO;
        if (CollectionUtils.isNotEmpty(inputInventoryRecordList)) {
            inputTotal = inputInventoryRecordList.stream().map(InputInventoryRecord::getQuantity).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
            inventorySummary.setInputEndRecordId(inputInventoryRecordList.get(inputInventoryRecordList.size() - 1).getId());
        }
        BigDecimal outputTotal = BigDecimal.ZERO;
        if (CollectionUtils.isNotEmpty(outputInventoryRecordList)) {
            outputTotal = outputInventoryRecordList.stream().map(OutputInventoryRecord::getQuantity).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
            inventorySummary.setOutputEndRecordId(outputInventoryRecordList.get(outputInventoryRecordList.size() - 1).getId());
        }
        if (inputTotal.compareTo(outputTotal) > 0) {
            total = total.add(inputTotal.subtract(outputTotal));
        }
        inventorySummary.setInventoryQuantity(total);
        inventorySummaryMapper.insertOrUpdate(inventorySummary);
    }
}
main-business/src/main/resources/db/migration/postgresql/V20250614110410__create_table_input_inventory_record.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,29 @@
DROP TABLE IF EXISTS input_inventory_record;
-- åˆ›å»ºå…¥åº“记录表
CREATE TABLE input_inventory_record
(
    id             BIGSERIAL PRIMARY KEY,             -- ä¸»é”®ID
    inventory_id   bigint         not null default 0,
    inventory_type varchar(10)    not null default '',
    quantity       DECIMAL(10, 2) not null default 0,
    deleted        INT            NOT NULL DEFAULT 0, -- è½¯åˆ é™¤æ ‡å¿—:0=未删除,1=已删除
    create_by      VARCHAR(255),                      -- åˆ›å»ºäººç”¨æˆ·å
    create_time    TIMESTAMP WITHOUT TIME ZONE        -- åˆ›å»ºæ—¶é—´ï¼Œé»˜è®¤å½“前时间
);
-- åˆ›å»ºç´¢å¼•
create index index_inventory_id_and_inventory_type_and_quantity_for_input_inventory_record on input_inventory_record (inventory_id, inventory_type, quantity);
-- æ·»åŠ è¡¨æ³¨é‡Š
COMMENT ON TABLE input_inventory_record IS '入库记录表';
-- æ·»åŠ å­—æ®µæ³¨é‡Š
COMMENT ON COLUMN input_inventory_record.id IS '主键ID';
COMMENT ON COLUMN input_inventory_record.inventory_id IS '库id';
COMMENT ON COLUMN input_inventory_record.inventory_type IS '库类型';
COMMENT ON COLUMN input_inventory_record.quantity IS '记录数量';
COMMENT ON COLUMN input_inventory_record.deleted IS '软删除标志,0=未删除,1=已删除';
COMMENT ON COLUMN input_inventory_record.create_by IS '创建该记录的用户';
COMMENT ON COLUMN input_inventory_record.create_time IS '记录创建时间';
main-business/src/main/resources/db/migration/postgresql/V20250614111500__create_table_output_inventory_record.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,29 @@
DROP TABLE IF EXISTS output_inventory_record;
-- åˆ›å»ºå‡ºåº“记录表
CREATE TABLE output_inventory_record
(
    id             BIGSERIAL PRIMARY KEY,             -- ä¸»é”®ID
    inventory_id   bigint         not null default 0,
    inventory_type varchar(10)    not null default '',
    quantity       DECIMAL(10, 2) not null default 0,
    deleted        INT            NOT NULL DEFAULT 0, -- è½¯åˆ é™¤æ ‡å¿—:0=未删除,1=已删除
    create_by      VARCHAR(255),                      -- åˆ›å»ºäººç”¨æˆ·å
    create_time    TIMESTAMP WITHOUT TIME ZONE        -- åˆ›å»ºæ—¶é—´ï¼Œé»˜è®¤å½“前时间
);
-- åˆ›å»ºç´¢å¼•
create index index_inventory_id_and_inventory_type_and_quantity_for_output_inventory_record on output_inventory_record (inventory_id, inventory_type, quantity);
-- æ·»åŠ è¡¨æ³¨é‡Š
COMMENT ON TABLE output_inventory_record IS '出库记录表';
-- æ·»åŠ å­—æ®µæ³¨é‡Š
COMMENT ON COLUMN output_inventory_record.id IS '主键ID';
COMMENT ON COLUMN output_inventory_record.inventory_id IS '库id';
COMMENT ON COLUMN output_inventory_record.inventory_type IS '库类型';
COMMENT ON COLUMN output_inventory_record.quantity IS '记录数量';
COMMENT ON COLUMN output_inventory_record.deleted IS '软删除标志,0=未删除,1=已删除';
COMMENT ON COLUMN output_inventory_record.create_by IS '创建该记录的用户';
COMMENT ON COLUMN output_inventory_record.create_time IS '记录创建时间';
main-business/src/main/resources/db/migration/postgresql/V20250614111811__create_table_inventory_summary.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,30 @@
DROP TABLE IF EXISTS inventory_summary;
-- åˆ›å»ºåº“存汇总表
CREATE TABLE inventory_summary
(
    id                 BIGSERIAL PRIMARY KEY,             -- ä¸»é”®ID
    inventory_id       bigint         not null default 0,
    inventory_type     varchar(10)    not null default '',
    inventory_quantity DECIMAL(10, 2) not null default 0,
    input_end_record_id      bigint         not null default 0,
    output_end_record_id      bigint         not null default 0,
    deleted            INT            NOT NULL DEFAULT 0, -- è½¯åˆ é™¤æ ‡å¿—:0=未删除,1=已删除
    create_time        TIMESTAMP WITHOUT TIME ZONE,       -- åˆ›å»ºæ—¶é—´ï¼Œé»˜è®¤å½“前时间
    update_time        TIMESTAMP WITHOUT TIME ZONE        -- æœ€åŽæ›´æ–°æ—¶é—´ï¼Œé»˜è®¤å½“前时间
);
-- æ·»åŠ è¡¨æ³¨é‡Š
COMMENT ON TABLE inventory_summary IS '库存汇总表';
-- æ·»åŠ å­—æ®µæ³¨é‡Š
COMMENT ON COLUMN inventory_summary.id IS '主键ID';
COMMENT ON COLUMN inventory_summary.inventory_id IS '库id';
COMMENT ON COLUMN inventory_summary.inventory_type IS '库类型';
COMMENT ON COLUMN inventory_summary.inventory_quantity IS '库存数量';
COMMENT ON COLUMN inventory_summary.input_end_record_id IS '入库中止明细记录id';
COMMENT ON COLUMN inventory_summary.output_end_record_id IS '出库中止明细记录id';
COMMENT ON COLUMN inventory_summary.deleted IS '软删除标志,0=未删除,1=已删除';
COMMENT ON COLUMN inventory_summary.create_time IS '记录创建时间';
COMMENT ON COLUMN inventory_summary.update_time IS '记录最后更新时间';
main-business/src/main/resources/mapper/InputInventoryRecordMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.InputInventoryRecordMapper">
        <!-- é€šç”¨æŸ¥è¯¢æ˜ å°„结果 -->
        <resultMap id="BaseResultMap" type="com.ruoyi.business.entity.InputInventoryRecord">
                    <id column="id" property="id" />
                <result column="deleted" property="deleted" />
                <result column="create_by" property="createBy" />
                <result column="create_time" property="createTime" />
                    <result column="inventory_id" property="inventoryId" />
                    <result column="inventory_type" property="inventoryType" />
                    <result column="quantity" property="quantity" />
        </resultMap>
        <!-- é€šç”¨æŸ¥è¯¢ç»“果列 -->
        <sql id="Base_Column_List">
                deleted,
                create_by,
                create_time,
            id, inventory_id, inventory_type, quantity
        </sql>
</mapper>
main-business/src/main/resources/mapper/InventorySummaryMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.InventorySummaryMapper">
    <!-- é€šç”¨æŸ¥è¯¢æ˜ å°„结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.business.entity.InventorySummary">
        <id column="id" property="id"/>
        <result column="deleted" property="deleted"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="inventory_id" property="inventoryId"/>
        <result column="inventory_type" property="inventoryType"/>
        <result column="inventory_quantity" property="inventoryQuantity"/>
        <result column="input_end_record_id" property="inputEndRecordId"/>
        <result column="output_end_record_id" property="outputEndRecordId"/>
    </resultMap>
    <!-- é€šç”¨æŸ¥è¯¢ç»“果列 -->
        <sql id="Base_Column_List">
                deleted,
                create_time,
                update_time,
            id, inventory_id, inventory_type, inventory_quantity, input_end_record_id, output_end_record_id
        </sql>
    <select id="getInventorySummaryForUpdateById" resultType="com.ruoyi.business.entity.InventorySummary">
        select *
        from inventory_summary
        where id = #{id} for update
    </select>
    <select id="getInventorySummaryForUpdateByInventoryIdAndType" resultType="com.ruoyi.business.entity.InventorySummary">
        select *
        from inventory_summary
        where inventory_id = #{inventoryId} and inventory_type = #{type} for update
    </select>
</mapper>
main-business/src/main/resources/mapper/OfficialInventoryMapper.xml
@@ -30,5 +30,11 @@
                update_time,
            id, supplier_name, coal, unit, inventory_quantity, price_including_tax, total_price_including_tax, pending_replenishment, registrant_id, registration_date
        </sql>
    <select id="getOfficialInventoryForUpdateById" resultType="com.ruoyi.business.entity.OfficialInventory">
        select *
        from official_inventory
        where id = #{id} for update
    </select>
</mapper>
main-business/src/main/resources/mapper/OutputInventoryRecordMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.OutputInventoryRecordMapper">
        <!-- é€šç”¨æŸ¥è¯¢æ˜ å°„结果 -->
        <resultMap id="BaseResultMap" type="com.ruoyi.business.entity.OutputInventoryRecord">
                    <id column="id" property="id" />
                <result column="deleted" property="deleted" />
                <result column="create_by" property="createBy" />
                <result column="create_time" property="createTime" />
                    <result column="inventory_id" property="inventoryId" />
                    <result column="inventory_type" property="inventoryType" />
                    <result column="quantity" property="quantity" />
        </resultMap>
        <!-- é€šç”¨æŸ¥è¯¢ç»“果列 -->
        <sql id="Base_Column_List">
                deleted,
                create_by,
                create_time,
            id, inventory_id, inventory_type, quantity
        </sql>
</mapper>
main-business/src/main/resources/mapper/PendingInventoryMapper.xml
@@ -29,5 +29,11 @@
                update_time,
            id, supplier_name, coal, unit, inventory_quantity, price_including_tax, total_price_including_tax, registrant, registration_time
        </sql>
    <select id="getPendingInventoryForUpdateById" resultType="com.ruoyi.business.entity.PendingInventory">
        select *
        from pending_inventory
        where id = #{id} for update
    </select>
</mapper>
ruoyi-admin/src/main/java/com/ruoyi/PlusCodeGenerator.java
@@ -28,18 +28,18 @@
public class PlusCodeGenerator {
    // æ•°æ®åº“配置
    private static final String DB_URL = "jdbc:postgresql://localhost:5432/ruoyi-zd";
    private static final String DB_URL = "jdbc:postgresql://192.168.1.35:5432/ruoyi-zd";
    private static final String DB_USERNAME = "postgres";
    private static final String DB_PASSWORD = "123456";
    // é¡¹ç›®åŸºç¡€é…ç½®
    private static final String BASE_PACKAGE = "com.ruoyi";
    private static final String MODULE_NAME = "basic"; // æ¨¡å—名
    private static final String MODULE_NAME = "business"; // æ¨¡å—名
    public static void main(String[] args) {
        String projectPath = System.getProperty("user.dir"); // èŽ·å–é¡¹ç›®æ ¹è·¯å¾„
        String path = "basic-server"; // æ¨¡å—名称
        String table = "coal_info"; // è¡¨åï¼Œå¤šä¸ªè¡¨é€—号隔开
        String path = "main-business"; // æ¨¡å—名称
        String table = "input_inventory_record,output_inventory_record,inventory_summary"; // è¡¨åï¼Œå¤šä¸ªè¡¨é€—号隔开
        // ä»£ç è¾“出路径配置
        String outputBasePath = Paths.get(projectPath, path, "src", "main", "java").toString();
@@ -48,7 +48,7 @@
        // ä»£ç ç”Ÿæˆæ ¸å¿ƒé…ç½®
        FastAutoGenerator.create(DB_URL, DB_USERNAME, DB_PASSWORD)
                .globalConfig(builder -> {
                    builder.author("ld") // ä½œè€…信息
                    builder.author("chenhj") // ä½œè€…信息
                            .outputDir(outputBasePath) // ä»£ç è¾“出目录
                            .dateType(DateType.ONLY_DATE) // æ—¥æœŸç±»åž‹
                            .commentDate("yyyy-MM-dd") // æ³¨é‡Šæ—¥æœŸæ ¼å¼
@@ -128,7 +128,7 @@
                    )); // åŸºç±»å­—段
                    customMap.put("idType", "AUTO"); // ä¸»é”®ç±»åž‹
                    customMap.put("superEntityClass", "com.ruoyi.common.core.domain.MyBaseEntity"); // åŸºç±»å…¨è·¯å¾„
                    customMap.put("author", "ruoyi"); // ä½œè€…信息
                    customMap.put("author", "chenhj"); // ä½œè€…信息
                    customMap.put("packageName", BASE_PACKAGE + "." + MODULE_NAME); // åŒ…名
                    customMap.put("tableName", table); // è¡¨å
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
@@ -3,6 +3,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
 * å¯åŠ¨ç¨‹åº
@@ -10,6 +11,7 @@
 * @author ruoyi
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@EnableScheduling
public class RuoYiApplication
{
    public static void main(String[] args)