liding
2025-06-26 bb5bf872de5e67d7b406e3a305c9dfcbd0f218a6
采购,正式库优化
已修改14个文件
250 ■■■■ 文件已修改
main-business/src/main/java/com/ruoyi/business/controller/PurchaseRegistrationController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/dto/OfficialInventoryDto.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/dto/ProductionMasterDto.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/entity/OfficialInventory.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/entity/PendingInventory.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/entity/PurchaseRegistration.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/PurchaseRegistrationService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/resources/db/migration/postgresql/V20250603160101__create_table_purchase_registration.sql 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/resources/db/migration/postgresql/V20250604104500__create_table_pending_inventory.sql 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/resources/db/migration/postgresql/V20250604111200__create_table_official_inventory.sql 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/controller/PurchaseRegistrationController.java
@@ -25,16 +25,16 @@
    private PurchaseRegistrationService purchaseRegistrationService;
    /**
     * 查询
     * 采购登记表查询
     */
    @GetMapping("/list")
    public R<IPage<PurchaseRegistration>> list(Page page, PurchaseRegistrationDto purchaseRegistrationDto) {
    public R<IPage<PurchaseRegistration>> list(Page<PurchaseRegistration> page, PurchaseRegistrationDto purchaseRegistrationDto) {
        IPage<PurchaseRegistration> list = purchaseRegistrationService.selectPurchaseRegistrationList(page,purchaseRegistrationDto);
        return R.ok(list);
    }
    /**
     * 新增修改
     * 采购登记表新增修改
     */
    @PostMapping("/addOrEditPR")
    public R addOrEditSupply(@RequestBody PurchaseRegistrationDto purchaseRegistrationDto) {
@@ -42,7 +42,7 @@
    }
    /**
     * 删除
     * 采购登记表删除
     */
    @DeleteMapping("/delPR")
    public R remove(@RequestBody Long[] ids) {
main-business/src/main/java/com/ruoyi/business/dto/OfficialInventoryDto.java
@@ -9,13 +9,12 @@
@Data
public class OfficialInventoryDto extends OfficialInventory {
    private List<Map<String, String>> fields;
    private List<Map<String, String>> fields;//查询返回的煤种信息键值对
    private List<Long> ids;
    private List<Long> ids;//要合并的正式库的id
    /**
     * 煤种
     */
    private String coal;
    private String coal; //煤种
    private String supplierName; //供应商
}
main-business/src/main/java/com/ruoyi/business/dto/ProductionMasterDto.java
@@ -10,6 +10,8 @@
@Data
public class ProductionMasterDto extends ProductionMaster {
    private String searchAll;
    private List<Production> productionList;  //生产明细
    private List<ProductionInventory>  productionInventoryList; //使用库存明细
main-business/src/main/java/com/ruoyi/business/entity/OfficialInventory.java
@@ -33,10 +33,11 @@
    @TableField(value = "pending_id")
    private Long pendingId;
    /**
     * 供货商名称
     * 供货商ID
     */
    @TableField(value = "supplier_name")
    private String supplierName;
    @TableField(value = "supplier_id")
    private Long supplierId;
    /**
     * 煤种
     */
@@ -81,7 +82,8 @@
     * 登记人id
     */
    @TableField(value = "registrant_id")
    private String registrantId;
    private Long registrantId;
    /**
     * 登记日期
     */
@@ -89,6 +91,12 @@
    private LocalDate registrationDate;
    /**
     * 煤质方案id
     */
    @TableField(value = "coal_plan_id")
    private Long coalPlanId;
    /**
     * 合并id
     */
    @TableField(value = "merge_id")
main-business/src/main/java/com/ruoyi/business/entity/PendingInventory.java
@@ -34,6 +34,12 @@
    @TableField(value = "master_id")
    private Long masterId;
    /**
     *
     * 采购id
     */
    @TableField(value = "purchase_id")
    private Long purchaseId;
    /**
     * 供货商名称
     */
    @TableField(value = "supplier_name")
@@ -84,6 +90,11 @@
    @TableField(value = "registrant_id")
    private Long registrantId;
    /**
     * 煤质方案id
     */
    @TableField(value = "coal_plan_id")
    private Long coalPlanId;
    /**
     * 登记日期
     */
    @TableField(value = "registration_date")
main-business/src/main/java/com/ruoyi/business/entity/PurchaseRegistration.java
@@ -82,7 +82,7 @@
     * 登记人id
     */
    @TableField(value = "registrant_id")
    private String registrantId;
    private Long registrantId;
    /**
     * 登记日期
     */
main-business/src/main/java/com/ruoyi/business/service/PurchaseRegistrationService.java
@@ -2,9 +2,9 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.business.dto.PurchaseRegistrationDto;
import com.ruoyi.business.entity.PurchaseRegistration;
import com.baomidou.mybatisplus.extension.service.IService;
/**
 * <p>
@@ -16,7 +16,7 @@
 */
public interface PurchaseRegistrationService extends IService<PurchaseRegistration> {
    IPage<PurchaseRegistration> selectPurchaseRegistrationList(Page page, PurchaseRegistrationDto purchaseRegistrationDto);
    IPage<PurchaseRegistration> selectPurchaseRegistrationList(Page<PurchaseRegistration> page, PurchaseRegistrationDto purchaseRegistrationDto);
    int addOrEditPR(PurchaseRegistrationDto purchaseRegistrationDto);
main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java
@@ -9,9 +9,11 @@
import com.ruoyi.basic.entity.CoalField;
import com.ruoyi.basic.entity.CoalInfo;
import com.ruoyi.basic.entity.CoalValue;
import com.ruoyi.basic.entity.Supply;
import com.ruoyi.basic.mapper.CoalFieldMapper;
import com.ruoyi.basic.mapper.CoalInfoMapper;
import com.ruoyi.basic.mapper.CoalValueMapper;
import com.ruoyi.basic.mapper.SupplyMapper;
import com.ruoyi.business.dto.OfficialInventoryDto;
import com.ruoyi.business.entity.OfficialInventory;
import com.ruoyi.business.mapper.OfficialInventoryMapper;
@@ -48,12 +50,15 @@
    private final CoalInfoMapper coalInfoMapper;
    private final SupplyMapper supplyMapper;
    @Override
    public IPage<OfficialInventoryDto> selectOfficialInventoryList(Page page, OfficialInventoryDto officialInventoryDto) {
        //  先查出原始数据(OfficialInventory)
        LambdaQueryWrapper<OfficialInventory> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.orderByAsc(OfficialInventory::getCreateTime);
        IPage<OfficialInventory> entityPage = officialInventoryMapper.selectPage(page, queryWrapper);
        //  创建一个新的 Dto 分页结果
@@ -61,6 +66,19 @@
        BeanUtils.copyProperties(entityPage, dtoPage);
        List<OfficialInventoryDto> dtoList = new ArrayList<>();
        List<Long> supplierIds = entityPage.getRecords().stream()
                .map(OfficialInventory::getSupplierId)
                .toList();
        Map<Long, Supply> supplyMap;
        if (!supplierIds.isEmpty()) {
            List<Supply> infos = supplyMapper.selectList(new LambdaQueryWrapper<Supply>().in(Supply::getId, supplierIds));
            supplyMap = infos.stream().collect(Collectors.toMap(Supply::getId, Function.identity()));
        } else {
            supplyMap = new HashMap<>();
        }
        //  查询所有可用字段(CoalField)
        List<CoalField> coalFields = coalFieldMapper.selectList(null);
@@ -88,6 +106,13 @@
        for (OfficialInventory entity : entityPage.getRecords()) {
            OfficialInventoryDto dto = new OfficialInventoryDto();
            BeanUtils.copyProperties(entity, dto);
            // 供应商信息
            Supply supply = supplyMap.get(entity.getSupplierId());
            if (supply != null) {
                dto.setSupplierName(supply.getSupplierName());
            }
            List<CoalValue> coalValues;
            if (entity.getMergeId() == null) {
                coalValues = coalValueMapper.selectList(new LambdaQueryWrapper<CoalValue>()
@@ -136,6 +161,64 @@
    public int editOfficial(OfficialInventoryDto officialInventoryDto) {
        OfficialInventory officialInventory = new OfficialInventory();
        BeanUtils.copyProperties(officialInventoryDto, officialInventory);
        if (officialInventoryDto.getMergeId() != null) {
            // 1. 构建查询条件
            LambdaQueryWrapper<CoalValue> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(CoalValue::getPlanId, officialInventoryDto.getId())
                    .eq(CoalValue::getType, "2");
            // 2. 查询多个符合条件的CoalValue记录
            List<CoalValue> coalValues = coalValueMapper.selectList(queryWrapper);
            if (!CollectionUtils.isEmpty(coalValues) && !CollectionUtils.isEmpty(officialInventoryDto.getFields())) {
                // 3. 创建字段映射关系 (field key -> coal_value)
                Map<String, String> fieldValueMap = new HashMap<>();
                for (Map<String, String> fieldMap : officialInventoryDto.getFields()) {
                    fieldValueMap.putAll(fieldMap);
                }
                // 4. 更新
                for (CoalValue coalValue : coalValues) {
                    String fieldKey = coalValue.getFields(); // 数据库中的field key
                    if (fieldValueMap.containsKey(fieldKey)) {
                        String newValue = fieldValueMap.get(fieldKey);
                        if (!Objects.equals(coalValue.getCoalValue(), newValue)) {
                            coalValue.setCoalValue(newValue);
                            coalValueMapper.updateById(coalValue);
                        }
                    }
                }
            }
        } else {
            // 构建查询条件
            LambdaQueryWrapper<CoalValue> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(CoalValue::getPlanId, officialInventoryDto.getPendingId())
                    .eq(CoalValue::getType, "1");
            // 2. 查询多个符合条件的CoalValue记录
            List<CoalValue> coalValues = coalValueMapper.selectList(queryWrapper);
            if (!CollectionUtils.isEmpty(coalValues) && !CollectionUtils.isEmpty(officialInventoryDto.getFields())) {
                // 3. 创建字段映射关系 (field key -> coal_value)
                Map<String, String> fieldValueMap = new HashMap<>();
                for (Map<String, String> fieldMap : officialInventoryDto.getFields()) {
                    fieldValueMap.putAll(fieldMap);
                }
                // 4. 更新
                for (CoalValue coalValue : coalValues) {
                    String fieldKey = coalValue.getFields(); // 数据库中的field key
                    if (fieldValueMap.containsKey(fieldKey)) {
                        String newValue = fieldValueMap.get(fieldKey);
                        if (!Objects.equals(coalValue.getCoalValue(), newValue)) {
                            coalValue.setCoalValue(newValue);
                            coalValueMapper.updateById(coalValue);
                        }
                    }
                }
            }
        }
        return officialInventoryMapper.updateById(officialInventory);
    }
@@ -185,7 +268,8 @@
        BeanUtils.copyProperties(officialInventoryDto, officialInventory);
        officialInventory.setId(null);
        officialInventory.setMergeId(ids.toString());
        officialInventory.setRegistrantId(SecurityUtils.getLoginUser().getUser().getUserName());
        officialInventory.setSupplierId(officialInventoryDto.getSupplierId());
        officialInventory.setRegistrantId(SecurityUtils.getLoginUser().getUser().getUserId());
        if (officialInventoryMapper.insert(officialInventory) <= 0) {
            throw new BaseException("库存记录创建失败");
        }
main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java
@@ -233,6 +233,7 @@
            BigDecimal left = pendingInventory.getInventoryQuantity().subtract(quantity);
            if (left.compareTo(BigDecimal.ZERO) > 0) {
                pendingInventory.setInventoryQuantity(left);
                pendingInventory.setCoalPlanId(pendingInventoryDto.getCoalPlanId());
                pendingInventoryMapper.updateById(pendingInventory);
            } else {
                pendingInventoryMapper.deleteById(pendingInventoryDto.getPId());
@@ -242,8 +243,11 @@
                OfficialInventory officialInventory = new OfficialInventory();
                BeanUtils.copyProperties(pendingInventory, officialInventory);
                officialInventory.setId(null);
                officialInventory.setCoalPlanId(pendingInventoryDto.getCoalPlanId());
                officialInventory.setPendingId(pendingInventoryDto.getPId());
                officialInventory.setInventoryQuantity(quantity);
                officialInventory.setRegistrantId(1L);
                officialInventory.setSupplierId(pendingInventoryDto.getSupplierId());
                officialInventoryMapper.insert(officialInventory);
            } else {
                OfficialInventory officialInventory = officialInventoryMapper.selectById(pendingInventoryDto.getOfficialId());
main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java
@@ -50,6 +50,11 @@
        // 1. 构建主表查询条件
        LambdaQueryWrapper<ProductionMaster> masterQueryWrapper = new LambdaQueryWrapper<>();
        // 2. 执行主表分页查询
        IPage<ProductionMaster> entityPage = productionMasterMapper.selectPage(page, masterQueryWrapper);
main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java
@@ -1,7 +1,6 @@
package com.ruoyi.business.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -24,7 +23,10 @@
import org.springframework.util.Assert;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
 * <p>
@@ -48,16 +50,29 @@
    private final SupplyMapper supplyMapper;
    @Override
    public IPage<PurchaseRegistration> selectPurchaseRegistrationList(Page page, PurchaseRegistrationDto purchaseRegistrationDto) {
    public IPage<PurchaseRegistration> selectPurchaseRegistrationList(Page<PurchaseRegistration> page, PurchaseRegistrationDto dto) {
        LambdaQueryWrapper<PurchaseRegistration> queryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotBlank(purchaseRegistrationDto.getSearchAll())){
            queryWrapper.and(wrapper -> wrapper
                    .like(PurchaseRegistration::getCoalId, purchaseRegistrationDto.getSearchAll())
                    .or()
                    .like(PurchaseRegistration::getSupplierName, purchaseRegistrationDto.getSearchAll())
            );
        String keyword = dto.getSearchAll();
        if (StringUtils.isNotBlank(keyword)) {
            // 查询煤种名称中模糊匹配的coalId列表
            List<Long> matchedCoalIds = coalInfoMapper.selectList(
                            new LambdaQueryWrapper<CoalInfo>().like(CoalInfo::getCoal, keyword)
                    ).stream()
                    .map(CoalInfo::getId)
                    .collect(Collectors.toList());
            // 组装查询条件:煤种ID在匹配的列表中 或 供应商名称匹配
            queryWrapper.and(w -> {
                if (!matchedCoalIds.isEmpty()) {
                    w.in(PurchaseRegistration::getCoalId, matchedCoalIds).or();
                }
                w.like(PurchaseRegistration::getSupplierName, keyword);
            });
        }
        queryWrapper.orderByDesc(PurchaseRegistration::getCreateTime);
        return purchaseRegistrationMapper.selectPage(page, queryWrapper);
    }
@@ -74,7 +89,6 @@
        if (coalInfo == null) {
            throw new BaseException("煤种信息不存在");
        }
//        purchaseRegistration.setCoal(coalInfo.getCoal());
        Supply supply = supplyMapper.selectById(purchaseRegistrationDto.getSupplierId());
        if (supply == null) {
            throw new BaseException("供应商信息不存在");
@@ -109,22 +123,27 @@
        BeanUtils.copyProperties(purchaseRegistration, pendingInventory);
        // 设置待入库记录特有的属性(如果有)
        pendingInventory.setId(null);
        pendingInventory.setPurchaseId(purchaseRegistration.getId());
        pendingInventory.setCoalId(purchaseRegistration.getCoalId());
        pendingInventory.setInventoryQuantity(purchaseRegistration.getPurchaseQuantity());
        return pendingInventory;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int delByIds(Long[] ids) {
        // 检查参数
        if (ids == null || ids.length == 0) {
            return 0;
        }
        // 构造更新条件
        UpdateWrapper<PurchaseRegistration> updateWrapper = new UpdateWrapper<>();
        updateWrapper.in("id", ids)
                .set("deleted", 1);  // 设置 deleted 为 1 表示已删除
        // 执行批量逻辑删除
        return purchaseRegistrationMapper.update(null, updateWrapper);
        // 1. 删除关联的PendingInventory记录
        LambdaQueryWrapper<PendingInventory> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(PendingInventory::getPurchaseId, Arrays.asList(ids));
        pendingInventoryMapper.delete(wrapper);  // 改为delete操作
        // 2. 批量删除采购注册记录
        return purchaseRegistrationMapper.deleteByIds(Arrays.asList(ids));
    }
}
main-business/src/main/resources/db/migration/postgresql/V20250603160101__create_table_purchase_registration.sql
@@ -1,26 +1,26 @@
-- 创建 purchase_registration 表
CREATE TABLE purchase_registration
(
    id                        BIGSERIAL PRIMARY KEY,                              -- 主键ID,自动递增
    supplier_id               BIGINT         NOT NULL,                            -- 供应商名称ID,不允许为空
    supplier_name             VARCHAR(255)   NOT NULL,                            -- 供应商名称,不允许为空
    unit                      VARCHAR(50)    NOT NULL,                            -- 单位,不允许为空
    coal_id                   BIGINT         NOT NULL,                            -- 煤种类型id
    coal                      VARCHAR(255),                                       -- 煤种类型
    purchase_quantity         DECIMAL(10, 2) NOT NULL,                            -- 采购数量,不允许为空
    price_including_tax       DECIMAL(10, 2) NOT NULL,                            -- 单价(含税),不允许为空
    total_price_including_tax DECIMAL(10, 2) NOT NULL,                            -- 总价(含税),不允许为空
    tax_rate                  DECIMAL(5, 2)  NOT NULL,                            -- 税率,不允许为空
    price_excluding_tax       DECIMAL(10, 2) NOT NULL,                            -- 不含税单价,不允许为空
    total_price_excluding_tax DECIMAL(10, 2) NOT NULL,                            -- 不含税总价,不允许为空
    registrant_id             VARCHAR(255)   NOT NULL,                            -- 登记人id,不允许为空
    registration_date         DATE           NOT NULL,                            -- 登记日期,不允许为空
    id                        BIGSERIAL PRIMARY KEY,             -- 主键ID,自动递增
    supplier_id               BIGINT         NOT NULL,           -- 供应商名称ID,不允许为空
    supplier_name             VARCHAR(255)   NOT NULL,           -- 供应商名称,不允许为空
    unit                      VARCHAR(50)    NOT NULL,           -- 单位,不允许为空
    coal_id                   BIGINT         NOT NULL,           -- 煤种类型id
    coal                      VARCHAR(255),                      -- 煤种类型
    purchase_quantity         DECIMAL(10, 2) NOT NULL,           -- 采购数量,不允许为空
    price_including_tax       DECIMAL(10, 2) NOT NULL,           -- 单价(含税),不允许为空
    total_price_including_tax DECIMAL(10, 2) NOT NULL,           -- 总价(含税),不允许为空
    tax_rate                  DECIMAL(5, 2)  NOT NULL,           -- 税率,不允许为空
    price_excluding_tax       DECIMAL(10, 2) NOT NULL,           -- 不含税单价,不允许为空
    total_price_excluding_tax DECIMAL(10, 2) NOT NULL,           -- 不含税总价,不允许为空
    registrant_id             BIGINT         NOT NULL,           -- 登记人id,不允许为空
    registration_date         DATE           NOT NULL,           -- 登记日期,不允许为空
    deleted                   INT            NOT NULL  DEFAULT 0,                 -- 软删除标志:0=未删除,1=已删除
    create_by                 VARCHAR(255),                                       -- 创建人用户名
    create_time               TIMESTAMP WITHOUT TIME ZONE, -- 创建时间,默认当前时间
    update_by                 VARCHAR(255),                                       -- 最后更新人用户名
    update_time               TIMESTAMP WITHOUT TIME ZONE  -- 最后更新时间,默认当前时间
    deleted                   INT            NOT NULL DEFAULT 0, -- 软删除标志:0=未删除,1=已删除
    create_by                 VARCHAR(255),                      -- 创建人用户名
    create_time               TIMESTAMP WITHOUT TIME ZONE,       -- 创建时间,默认当前时间
    update_by                 VARCHAR(255),                      -- 最后更新人用户名
    update_time               TIMESTAMP WITHOUT TIME ZONE        -- 最后更新时间,默认当前时间
);
-- 为表添加注释
main-business/src/main/resources/db/migration/postgresql/V20250604104500__create_table_pending_inventory.sql
@@ -17,6 +17,8 @@
    supplier_id               BIGINT,                                 -- 供货商ID
    coal_id                   BIGINT,                                 -- 煤种ID
    master_id                 BIGINT,                                 -- 生产加工id
    purchase_id               BIGINT,                                 -- 采购id
    coal_plan_id               BIGINT,                                 -- 煤质方案id
    deleted                   INTEGER      DEFAULT 0,                 -- 软删除标志,0=未删除,1=已删除
    create_by                 VARCHAR(255),                           -- 创建该记录的用户
@@ -45,6 +47,8 @@
COMMENT ON COLUMN pending_inventory.supplier_id IS '供货商ID';
COMMENT ON COLUMN pending_inventory.coal_id IS '煤种ID';
COMMENT ON COLUMN pending_inventory.master_id IS '生产加工id';
COMMENT ON COLUMN pending_inventory.purchase_id IS '采购id';
COMMENT ON COLUMN pending_inventory.coal_plan_id IS '煤质方案id';
COMMENT ON COLUMN pending_inventory.deleted IS '软删除标志,0=未删除,1=已删除';
COMMENT ON COLUMN pending_inventory.create_by IS '创建该记录的用户';
main-business/src/main/resources/db/migration/postgresql/V20250604111200__create_table_official_inventory.sql
@@ -2,7 +2,7 @@
CREATE TABLE official_inventory
(
    id                        BIGSERIAL PRIMARY KEY,             -- 主键ID
    supplier_name             VARCHAR(255)   NOT NULL,           -- 供货商名称
    supplier_id               BIGINT,                            -- 供货商id
    coal_id                   BIGINT         NOT NULL,           -- 煤种
    unit                      VARCHAR(50)    NOT NULL,           -- 单位
    inventory_quantity        DECIMAL(10, 0),                    -- 库存数量
@@ -11,9 +11,10 @@
    price_excluding_tax       DECIMAL(10, 2) NOT NULL,           -- 不含税单价
    total_price_excluding_tax DECIMAL(10, 2) NOT NULL,           -- 不含税总价
    pending_replenishment     DECIMAL(10, 0),                    -- 待补库
    registrant_id             VARCHAR(50)    NOT NULL,           -- 登记人id
    registrant_id             BIGINT         NOT NULL,           -- 登记人id
    type                      VARCHAR(50),                       -- 类型       1 采购/ 2 正式   入库
    pending_id                BIGINT,                            -- 待入库id
    coal_plan_id               BIGINT,                                 -- 煤质方案id
    merge_id                  VARCHAR(255),                      -- 合并id
    registration_date         TIMESTAMP WITHOUT TIME ZONE,
@@ -29,7 +30,7 @@
-- 添加字段注释
COMMENT ON COLUMN official_inventory.id IS '主键ID';
COMMENT ON COLUMN official_inventory.supplier_name IS '供货商名称';
COMMENT ON COLUMN official_inventory.supplier_id IS '供货商id';
COMMENT ON COLUMN official_inventory.coal_id IS '煤种id';
COMMENT ON COLUMN official_inventory.unit IS '单位';
COMMENT ON COLUMN official_inventory.inventory_quantity IS '库存数量';
@@ -39,6 +40,7 @@
COMMENT ON COLUMN official_inventory.registrant_id IS '登记人id';
COMMENT ON COLUMN official_inventory.registration_date IS '登记日期';
COMMENT ON COLUMN official_inventory.merge_id IS '合并id';
COMMENT ON COLUMN official_inventory.coal_plan_id IS '煤质方案id';
COMMENT ON COLUMN official_inventory.deleted IS '软删除标志,0=未删除,1=已删除';
COMMENT ON COLUMN official_inventory.create_by IS '创建该记录的用户';