| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.pojo.BorrowInfo; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.dto.StockOutRecordDto; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import com.ruoyi.stock.execl.StockInventoryExportData; |
| | | import com.ruoyi.stock.pojo.StockInventory; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.stock.service.StockOutRecordService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private StockInventoryMapper stockInventoryMapper; |
| | | private StockInRecordService stockInRecordService; |
| | | private StockOutRecordService stockOutRecordService; |
| | | |
| | | private SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private StockUtils stockUtils; |
| | | @Override |
| | | public IPage<StockInventoryDto> pagestockInventory(Page page, StockInventoryDto stockInventoryDto) { |
| | | return stockInventoryMapper.pagestockInventory(page, stockInventoryDto); |
| | |
| | | stockInRecordDto.setRecordType(stockInventoryDto.getRecordType()); |
| | | stockInRecordDto.setStockInNum(stockInventoryDto.getQualitity()); |
| | | stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId()); |
| | | stockInRecordDto.setType("0"); |
| | | stockInRecordService.add(stockInRecordDto); |
| | | //再进行新增库存数量库存 |
| | | //先查询库存表中的产品是否存在,不存在新增,存在更新 |
| | |
| | | newStockInventory.setProductModelId(stockInventoryDto.getProductModelId()); |
| | | newStockInventory.setQualitity(stockInventoryDto.getQualitity()); |
| | | newStockInventory.setVersion(1); |
| | | newStockInventory.setRemark(stockInventoryDto.getRemark()); |
| | | stockInventoryMapper.insert(newStockInventory); |
| | | }else { |
| | | stockInventoryMapper.updateAddStockInventory(stockInventoryDto); |
| | |
| | | stockOutRecordDto.setRecordType(stockInventoryDto.getRecordType()); |
| | | stockOutRecordDto.setStockOutNum(stockInventoryDto.getQualitity()); |
| | | stockOutRecordDto.setProductModelId(stockInventoryDto.getProductModelId()); |
| | | stockOutRecordDto.setType("0"); |
| | | stockOutRecordService.add(stockOutRecordDto); |
| | | StockInventory oldStockInventory = stockInventoryMapper.selectOne(new QueryWrapper<StockInventory>().lambda().eq(StockInventory::getProductModelId, stockInventoryDto.getProductModelId())); |
| | | if (ObjectUtils.isEmpty(oldStockInventory)) { |
| | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public R importStockInventory(MultipartFile file) { |
| | | // try { |
| | | // final StringBuffer[] errorMsg = {new StringBuffer()}; |
| | | // //查询所有的产品 |
| | | // List<SalesLedgerProduct> salesLedgerProducts =salesLedgerProductMapper.selectProduct(); |
| | | // |
| | | // ExcelUtil<StockInventoryExportData> util = new ExcelUtil<StockInventoryExportData>(StockInventoryExportData.class); |
| | | // List<StockInventoryExportData> list = util.importExcel(file.getInputStream()); |
| | | // list.stream().forEach(dto -> { |
| | | // salesLedgerProducts.stream().forEach(item->{ |
| | | // if (item.getProductCategory().equals(dto.getProductName())&&item.getSpecificationModel().equals(dto.getModel())) { |
| | | // //更新库存 |
| | | // stockUtils.addStock(item.getId(),dto.getQualitity(), StockQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode(),0L); |
| | | // }else { |
| | | // errorMsg[0] = errorMsg[0].append("产品名称:"+dto.getProductName()+"规格:"+dto.getModel()+"不存在").append("\n"); |
| | | // } |
| | | // }); |
| | | // }); |
| | | // return R.ok(errorMsg[0]); |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public void exportStockInventory(HttpServletResponse response, StockInventoryDto stockInventoryDto) { |
| | | |
| | | List<StockInventoryExportData> list = stockInventoryMapper.listStockInventoryExportData(stockInventoryDto); |
| | | ExcelUtil<StockInventoryExportData> util = new ExcelUtil<>(StockInventoryExportData.class); |
| | | util.exportExcel(response,list, "库存信息"); |
| | | } |
| | | } |