| | |
| | | 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.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.EnumUtil; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.execl.StockInRecordExportData; |
| | | import com.ruoyi.stock.execl.StockInventoryExportData; |
| | | import com.ruoyi.stock.mapper.StockInRecordMapper; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.mapper.StockUninventoryMapper; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import com.ruoyi.stock.pojo.StockInventory; |
| | | import com.ruoyi.stock.pojo.StockUninventory; |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class StockInRecordServiceImpl extends ServiceImpl<StockInRecordMapper, StockInRecord> implements StockInRecordService { |
| | | @Autowired |
| | | |
| | | private StockInRecordMapper stockInRecordMapper; |
| | | @Autowired |
| | | private StockInventoryMapper stockInventoryMapper; |
| | | private StockUninventoryMapper stockUninventoryMapper; |
| | | |
| | | @Override |
| | | public IPage<StockInRecordDto> listPage(Page page, StockInRecordDto stockInRecordDto) { |
| | |
| | | public int batchDelete(List<Long> ids) { |
| | | for (Long id : ids) { |
| | | StockInRecord stockInRecord = stockInRecordMapper.selectById(id); |
| | | StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>().eq(StockInventory::getProductModelId, id)); |
| | | if (stockInventory == null) { |
| | | throw new BaseException("该入库记录下没有对应的产品,无法删除!!!"); |
| | | }else { |
| | | StockInventoryDto stockInRecordDto = new StockInventoryDto(); |
| | | stockInRecordDto.setProductModelId(stockInventory.getProductModelId()); |
| | | stockInRecordDto.setQualitity(stockInRecord.getStockInNum()); |
| | | stockInventoryMapper.updateSubtractStockInventory(stockInRecordDto); |
| | | if (stockInRecord.getType().equals("0")) { |
| | | StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>().eq(StockInventory::getProductModelId, stockInRecord.getProductModelId())); |
| | | if (stockInventory == null) { |
| | | throw new BaseException("库存记录中没有对应的产品,无法删除!!!"); |
| | | }else { |
| | | StockInventoryDto stockInRecordDto = new StockInventoryDto(); |
| | | stockInRecordDto.setProductModelId(stockInventory.getProductModelId()); |
| | | stockInRecordDto.setQualitity(stockInRecord.getStockInNum()); |
| | | stockInventoryMapper.updateAddStockInventory(stockInRecordDto); |
| | | } |
| | | }else if (stockInRecord.getType().equals("1")) { |
| | | StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>().eq(StockUninventory::getProductModelId, stockInRecord.getProductModelId())); |
| | | if (stockUninventory == null) { |
| | | throw new BaseException("库存记录中没有对应的产品,无法删除!!!"); |
| | | }else { |
| | | StockUninventoryDto stockUninventoryDto = new StockUninventoryDto(); |
| | | stockUninventoryDto.setProductModelId(stockUninventory.getProductModelId()); |
| | | stockUninventoryDto.setQualitity(stockInRecord.getStockInNum()); |
| | | stockUninventoryMapper.updateAddStockUnInventory(stockUninventoryDto); |
| | | } |
| | | } |
| | | } |
| | | return stockInRecordMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public void exportStockInRecord(HttpServletResponse response, StockInRecordDto stockInRecordDto) { |
| | | List<StockInRecordExportData> list = stockInRecordMapper.listStockInRecordExportData(stockInRecordDto); |
| | | for (StockInRecordExportData stockInRecordExportData : list) { |
| | | if (stockInRecordExportData.getType().equals("0")) { |
| | | stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockQualifiedRecordTypeEnum.class, Integer.valueOf(stockInRecordExportData.getRecordType())).getValue()); |
| | | }else { |
| | | stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockUnQualifiedRecordTypeEnum.class, Integer.valueOf(stockInRecordExportData.getRecordType())).getValue()); |
| | | } |
| | | } |
| | | ExcelUtil<StockInRecordExportData> util = new ExcelUtil<>(StockInRecordExportData.class); |
| | | util.exportExcel(response,list, "入库记录信息"); |
| | | } |
| | | } |