From 3ca0af49b87942c86cdd973d5a0aea5757b87e71 Mon Sep 17 00:00:00 2001 From: maven <2163098428@qq.com> Date: 星期二, 08 七月 2025 13:22:54 +0800 Subject: [PATCH] yys 修改表名称 --- src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java | 61 ++++++++++++++++++++++-------- 1 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java b/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java index 112e168..6abb7cf 100644 --- a/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java +++ b/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java @@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.framework.security.LoginUser; import com.ruoyi.procurementrecord.dto.*; import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper; import com.ruoyi.procurementrecord.pojo.ProcurementRecord; import com.ruoyi.procurementrecord.service.ProcurementRecordService; +import com.ruoyi.quality.pojo.QualityInspect; import com.ruoyi.sales.mapper.SalesLedgerProductMapper; import com.ruoyi.sales.pojo.SalesLedgerProduct; import lombok.RequiredArgsConstructor; @@ -17,6 +19,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; @@ -58,6 +61,7 @@ // 濡傛灉娌℃湁鐩稿叧鐨勫叆搴撹褰曪紝璺宠繃璇ユ潯鏁版嵁 if(CollectionUtils.isEmpty(collect1)){ + dto.setQuantity0(dto.getQuantity()); continue; } @@ -72,14 +76,41 @@ return procurementDtos; } - @Override - public int updatePro(ProcurementUpdateDto procurementDto) { - ProcurementRecord procurementRecord = procurementRecordMapper.selectById(procurementDto.getId()); + public ProcurementRecord getProcurementRecordById(Integer id){ + ProcurementRecord procurementRecord = procurementRecordMapper.selectById(id); if(procurementRecord == null) { throw new RuntimeException("鏈壘鍒拌閲囪喘鍏ュ簱璁板綍"); } - procurementRecord.setInboundNum(procurementDto.getQuantityStock()); - return procurementRecordMapper.updateById(procurementRecord); + return procurementRecord; + } + + public List<ProcurementRecord> getProcurementRecordByIds(List<Integer> id){ + List<ProcurementRecord> procurementRecord = procurementRecordMapper.selectBatchIds(id); + if(procurementRecord == null) { + throw new RuntimeException("鏈壘鍒拌閲囪喘鍏ュ簱璁板綍"); + } + return procurementRecord; + } + + @Override + public int updatePro(ProcurementUpdateDto procurementDto) { + ProcurementRecord procurementRecordById = getProcurementRecordById(procurementDto.getId()); + procurementRecordById.setInboundNum(procurementDto.getQuantityStock()); + return procurementRecordMapper.updateById(procurementRecordById); + } + + @Override + public int deletePro(ProcurementUpdateDto procurementDto) { + List<ProcurementRecord> procurementRecordById = getProcurementRecordByIds(procurementDto.getIds()); + procurementRecordMapper.deleteBatchIds(procurementRecordById.stream().map(ProcurementRecord::getId).collect(Collectors.toList())); + return 0; + } + + @Override + public void export(HttpServletResponse response) { + List<ProcurementPageDto> list =procurementRecordMapper.list(); + ExcelUtil<ProcurementPageDto> util = new ExcelUtil<ProcurementPageDto>(ProcurementPageDto.class); + util.exportExcel(response, list, "鍏ュ簱鍙拌处"); } @Override @@ -89,13 +120,11 @@ for (Details detail : procurementDto.getDetails()) { // 鏌ヨ閲囪喘鍏ュ簱鏁伴噺 LambdaQueryWrapper<ProcurementRecord> procurementRecordLambdaQueryWrapper = new LambdaQueryWrapper<>(); - procurementRecordLambdaQueryWrapper.eq(ProcurementRecord::getSalesLedgerProductId, detail.getId()) - .eq(ProcurementRecord::getProcurementCategory, 1); + procurementRecordLambdaQueryWrapper.eq(ProcurementRecord::getSalesLedgerProductId, detail.getId()); Long aLong = procurementRecordMapper.selectCount(procurementRecordLambdaQueryWrapper); ProcurementRecord.ProcurementRecordBuilder procurementRecordBuilder = ProcurementRecord.builder() .salesLedgerProductId(detail.getId()) - .procurementCategory(1) .inboundBatches(aLong.equals(0L) ? "绗�1鎵规" : "绗�"+ (aLong + 1) + "鎵规") .inboundNum(detail.getInboundQuantity()) .createDate(LocalDateTime.now()) @@ -103,14 +132,14 @@ .createBy(procurementDto.getNickName()); this.save(procurementRecordBuilder.build()); // 鍏ュ簱鎴愬姛鍑忔帀閲囪喘鏁伴噺 - LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductLambdaQueryWrapper = new LambdaQueryWrapper<>(); - salesLedgerProductLambdaQueryWrapper.eq(SalesLedgerProduct::getId, detail.getId()); - SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectOne(salesLedgerProductLambdaQueryWrapper); - if(salesLedgerProduct == null){ - throw new RuntimeException("鏈壘鍒拌鍟嗗搧"); - } - salesLedgerProduct.setQuantity(salesLedgerProduct.getQuantity().subtract(detail.getInboundQuantity())); - salesLedgerProductMapper.updateById(salesLedgerProduct); +// LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductLambdaQueryWrapper = new LambdaQueryWrapper<>(); +// salesLedgerProductLambdaQueryWrapper.eq(SalesLedgerProduct::getId, detail.getId()); +// SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectOne(salesLedgerProductLambdaQueryWrapper); +// if(salesLedgerProduct == null){ +// throw new RuntimeException("鏈壘鍒拌鍟嗗搧"); +// } +// salesLedgerProduct.setQuantity(salesLedgerProduct.getQuantity().subtract(detail.getInboundQuantity())); +// salesLedgerProductMapper.updateById(salesLedgerProduct); } return 1; } -- Gitblit v1.9.3