| | |
| | | ); |
| | | |
| | | alter table stock_inventory |
| | | add manufacturer_id bigint not null default 0 comment 'åå®¶id'; |
| | | add manufacturer_id bigint not null default 0 comment 'åå®¶id', |
| | | add source varchar(255) not null default '' comment 'æ¥æº'; |
| | | alter table stock_in_record |
| | | add manufacturer_id bigint not null default 0 comment 'åå®¶id'; |
| | | add manufacturer_id bigint not null default 0 comment 'åå®¶id', |
| | | add source varchar(255) not null default '' comment 'æ¥æº'; |
| | | alter table stock_uninventory |
| | | add manufacturer_id bigint not null default 0 comment 'åå®¶id'; |
| | | add manufacturer_id bigint not null default 0 comment 'åå®¶id', |
| | | add source varchar(255) not null default '' comment 'æ¥æº'; |
| | |
| | | |
| | | @Schema(description = "产åid") |
| | | private Long productId; |
| | | |
| | | @Schema(description = "åæ ¼åºåæ¥æº") |
| | | private String qualifiedSource; |
| | | |
| | | @Schema(description = "åæ ¼åºåæ¥æºææ¬") |
| | | private String qualifiedSourceText; |
| | | |
| | | @Schema(description = "ä¸åæ ¼åºåæ¥æº") |
| | | private String unQualifiedSource; |
| | | |
| | | @Schema(description = "ä¸åæ ¼åºåæ¥æºææ¬") |
| | | private String unQualifiedSourceText; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.stock.enums; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonCreator; |
| | | import com.ruoyi.common.enums.BaseEnum; |
| | | import lombok.Getter; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author buhuazhen |
| | | * @date 2026/3/9 |
| | | * @email 3038525872@qq.com |
| | | */ |
| | | @Getter |
| | | public enum StockInventorySourceEnum implements BaseEnum<String>, Serializable { |
| | | PURCHASE_RECEIPT("purchaseReceipt", "éè´å
¥åº"), |
| | | PRODUCTION_RECEIPT("productionReceipt", "ç产å
¥åº"), |
| | | OUTSOURCED_RECEIPT("outsourcedReceipt", "å¤åå
¥åº"), |
| | | REPAIR_RECEIPT("repairReceipt", "ä¿®å¤å
¥åº"), |
| | | PROD_GENERATED("prodGenerated", "ç产产ç"), |
| | | TRANS_GENERATED("transGenerated", "è¿è¾äº§ç"), |
| | | CUTTING_GENERATED("cuttingGenerated", "è£åªäº§ç"), |
| | | CUSTOM("custom", "èªå®ä¹"); |
| | | |
| | | @EnumValue |
| | | private final String code; |
| | | |
| | | private final String value; |
| | | |
| | | StockInventorySourceEnum(String code, String value) { |
| | | this.code = code; |
| | | this.value = value; |
| | | } |
| | | |
| | | @JsonCreator |
| | | public static StockInventorySourceEnum fromCode(String code) { |
| | | if (code == null) { |
| | | return null; |
| | | } |
| | | for (StockInventorySourceEnum e : StockInventorySourceEnum.values()) { |
| | | if (e.getCode().equals(code)) { |
| | | return e; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | |
| | | @Schema(description = "åå®¶ID") |
| | | private Long manufacturerId; |
| | | |
| | | @Schema(description = "æ¥æº") |
| | | private String source; |
| | | } |
| | |
| | | @Schema(description = "ååid") |
| | | private Long manufacturerId; |
| | | |
| | | @Schema(description = "æ¥æº") |
| | | private String source; |
| | | } |
| | |
| | | |
| | | @Schema(description = "åå®¶ID") |
| | | private Long manufacturerId; |
| | | |
| | | @Schema(description = "æ¥æº") |
| | | private String source; |
| | | } |
| | |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.AllArgsConstructor; |
| | | import org.jspecify.annotations.NonNull; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | if ("0".equals(stockInRecord.getType())) { |
| | | // åæ ¼å
¥åº -> å
æ¥åºåï¼åå¨åæ´æ°ï¼ä¸åå¨åæ°å¢ |
| | | StockInventory stockInventory = getStockInventory(stockInRecord.getProductModelId(), stockInRecord.getBatchNo()); |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setProductModelId(stockInRecord.getProductModelId()); |
| | | stockInventoryDto.setBatchNo(stockInRecord.getBatchNo()); |
| | | stockInventoryDto.setQualitity(stockInRecord.getStockInNum()); |
| | | stockInventoryDto.setRemark(stockInRecord.getRemark()); |
| | | stockInventoryDto.setManufacturerId(stockInRecord.getManufacturerId()); |
| | | StockInventoryDto stockInventoryDto = getStockInventoryDto(stockInRecord); |
| | | if (stockInventory == null) { |
| | | stockInventoryMapper.insert(new StockInventory() {{ |
| | | setProductModelId(stockInRecord.getProductModelId()); |
| | |
| | | setRemark(stockInRecord.getRemark()); |
| | | setWarnNum(stockInRecord.getWarnNum()); |
| | | setManufacturerId(stockInRecord.getManufacturerId()); |
| | | setSource(stockInRecord.getSource()); |
| | | setVersion(1); |
| | | }}); |
| | | } else { |
| | |
| | | stockUninventoryDto.setQualitity(stockInRecord.getStockInNum()); |
| | | stockUninventoryDto.setRemark(stockInRecord.getRemark()); |
| | | stockUninventoryDto.setManufacturerId(stockInRecord.getManufacturerId()); |
| | | stockUninventoryDto.setSource(stockInRecord.getSource()); |
| | | if (stockUninventory == null) { |
| | | stockUninventoryMapper.insert(new StockUninventory() {{ |
| | | setProductModelId(stockInRecord.getProductModelId()); |
| | |
| | | setBatchNo(stockInRecord.getBatchNo()); |
| | | setRemark(stockInRecord.getRemark()); |
| | | setManufacturerId(stockInRecord.getManufacturerId()); |
| | | setSource(stockInRecord.getSource()); |
| | | setVersion(1); |
| | | }}); |
| | | } else { |
| | |
| | | return ids.size(); |
| | | } |
| | | |
| | | private static @NonNull StockInventoryDto getStockInventoryDto(StockInRecord stockInRecord) { |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setProductModelId(stockInRecord.getProductModelId()); |
| | | stockInventoryDto.setBatchNo(stockInRecord.getBatchNo()); |
| | | stockInventoryDto.setQualitity(stockInRecord.getStockInNum()); |
| | | stockInventoryDto.setRemark(stockInRecord.getRemark()); |
| | | stockInventoryDto.setManufacturerId(stockInRecord.getManufacturerId()); |
| | | stockInventoryDto.setSource(stockInRecord.getSource()); |
| | | return stockInventoryDto; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int batchReAudit(List<Long> ids) { |
| | |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.stock.enums.StockInventorySourceEnum; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.domain.R; |
| | |
| | | |
| | | @Override |
| | | public IPage<StockInventoryDto> pageListCombinedStockInventory(Page page, StockInventoryDto stockInventoryDto) { |
| | | return stockInventoryMapper.pageListCombinedStockInventory(page, stockInventoryDto); |
| | | IPage<StockInventoryDto> result = stockInventoryMapper.pageListCombinedStockInventory(page, stockInventoryDto); |
| | | // è½¬æ¢æ¥æºç¼ç ä¸ºæ¥æºåç§° |
| | | for (StockInventoryDto dto : result.getRecords()) { |
| | | // åæ ¼åºåæ¥æº |
| | | if (StringUtils.isNotBlank(dto.getQualifiedSource())) { |
| | | StockInventorySourceEnum qualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getQualifiedSource()); |
| | | if (qualifiedSourceEnum != null) { |
| | | dto.setQualifiedSourceText(qualifiedSourceEnum.getValue()); |
| | | } |
| | | } |
| | | // ä¸åæ ¼åºåæ¥æº |
| | | if (StringUtils.isNotBlank(dto.getUnQualifiedSource())) { |
| | | StockInventorySourceEnum unQualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getUnQualifiedSource()); |
| | | if (unQualifiedSourceEnum != null) { |
| | | dto.setUnQualifiedSourceText(unQualifiedSourceEnum.getValue()); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | //å
¥åºè°ç¨ |
| | |
| | | stockInRecordDto.setRemark(stockInventoryDto.getRemark()); |
| | | stockInRecordDto.setWarnNum(stockInventoryDto.getWarnNum()); |
| | | stockInRecordDto.setManufacturerId(stockInventoryDto.getManufacturerId()); |
| | | stockInRecordDto.setSource(stockInventoryDto.getSource()); |
| | | stockInRecordService.add(stockInRecordDto); |
| | | return true; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public IPage<StockInventoryDto> getBatchNoQty(Page page, StockInventoryDto stockInventoryDto) { |
| | | return stockInventoryMapper.getBatchNoQty(page, stockInventoryDto); |
| | | IPage<StockInventoryDto> resultPage = stockInventoryMapper.getBatchNoQty(page, stockInventoryDto); |
| | | |
| | | // éåç»æï¼è®¾ç½®æ¥æºä¸æå |
| | | resultPage.getRecords().forEach(dto -> { |
| | | // è®¾ç½®åæ ¼åºåæ¥æºä¸æå |
| | | if (StringUtils.isNotEmpty(dto.getQualifiedSource())) { |
| | | System.out.println("åæ ¼åºåæ¥æºï¼" + dto.getQualifiedSource()); |
| | | StockInventorySourceEnum qualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getQualifiedSource()); |
| | | if (qualifiedSourceEnum != null) { |
| | | dto.setQualifiedSourceText(qualifiedSourceEnum.getValue()); |
| | | System.out.println("åæ ¼åºåæ¥æºå¼ï¼" + qualifiedSourceEnum.getValue()); |
| | | } |
| | | } |
| | | |
| | | // 设置ä¸åæ ¼åºåæ¥æºä¸æå |
| | | if (StringUtils.isNotEmpty(dto.getUnQualifiedSource())) { |
| | | StockInventorySourceEnum unQualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getUnQualifiedSource()); |
| | | if (unQualifiedSourceEnum != null) { |
| | | dto.setUnQualifiedSourceText(unQualifiedSourceEnum.getValue()); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | return resultPage; |
| | | } |
| | | } |
| | |
| | | stockInRecordDto.setProductModelId(stockUninventoryDto.getProductModelId()); |
| | | stockInRecordDto.setType("1"); |
| | | stockInRecordDto.setManufacturerId(stockUninventoryDto.getManufacturerId()); |
| | | stockInRecordDto.setSource(stockUninventoryDto.getSource()); |
| | | stockInRecordService.add(stockInRecordDto); |
| | | //审æ¹åæ·»å |
| | | return 1; |
| | |
| | | unit, |
| | | product_name, |
| | | product_id, |
| | | MAX(manufacturer_id) as manufacturer_id, |
| | | MAX(manufacturer_name) as manufacturerName, |
| | | MAX(qualifiedSource) as qualifiedSource, |
| | | MAX(unQualifiedSource) as unQualifiedSource, |
| | | |
| | | MAX(create_time) as create_time, |
| | | MAX(update_time) as update_time, |
| | |
| | | pm.unit, |
| | | p.product_name, |
| | | p.id as product_id, |
| | | si.manufacturer_id, |
| | | m.name as manufacturer_name, |
| | | si.source as qualifiedSource, |
| | | null as unQualifiedSource, |
| | | |
| | | si.create_time, |
| | | si.update_time, |
| | |
| | | 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 |
| | | left join manufacturer m on si.manufacturer_id = m.id |
| | | |
| | | union all |
| | | |
| | |
| | | pm.unit, |
| | | p.product_name, |
| | | p.id as product_id, |
| | | su.manufacturer_id, |
| | | m.name as manufacturer_name, |
| | | null as qualifiedSource, |
| | | su.source as unQualifiedSource, |
| | | |
| | | su.create_time, |
| | | su.update_time, |
| | |
| | | from stock_uninventory su |
| | | left join product_model pm on su.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | left join manufacturer m on su.manufacturer_id = m.id |
| | | ) as combined |
| | | <where> |
| | | <if test="ew.productModelId != null and ew.productModelId > 0"> |
| | |
| | | model, |
| | | unit, |
| | | product_name, |
| | | product_id |
| | | product_id, |
| | | manufacturer_id, |
| | | manufacturer_name |
| | | order by |
| | | batch_no |
| | | </select> |