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/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/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/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