|
@@ -11,6 +11,8 @@ import com.zkqy.business.domain.vo.ProductCodeListVO;
|
|
|
import com.zkqy.business.domain.vo.ProductInvoiceVO;
|
|
|
import com.zkqy.business.mapper.*;
|
|
|
import com.zkqy.business.service.IOldProductOutboundRecordService;
|
|
|
+import com.zkqy.business.service.IProductOutboundRecordService;
|
|
|
+import com.zkqy.business.service.ISaleAccountsReceivableDetailService;
|
|
|
import com.zkqy.common.core.domain.AjaxResult;
|
|
|
import com.zkqy.common.utils.DateUtils;
|
|
|
import com.zkqy.common.utils.SecurityUtils;
|
|
@@ -32,7 +34,7 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
@Autowired
|
|
|
private ProductInventoryMapper productInventoryMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Autowired // 码单
|
|
|
private ProductCodeListMapper productCodeListMapper;
|
|
|
|
|
|
@Autowired
|
|
@@ -56,6 +58,12 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
@Autowired // 出库批次
|
|
|
private ProductOutboundRecordBatchMapper productOutboundRecordBatchMapper;
|
|
|
|
|
|
+ @Autowired // 应收账明细
|
|
|
+ private ISaleAccountsReceivableDetailService saleAccountsReceivableDetailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IProductOutboundRecordService productOutboundRecordService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询产品库存
|
|
|
*
|
|
@@ -533,9 +541,14 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
|
|
|
@Override
|
|
|
public List<ProductCodeListVO> comprehensiveInventoryList(ProductCodeListVO productCodeListVO) {
|
|
|
+ // 查询老库存
|
|
|
if (productCodeListVO.getInventoryType() != null && productCodeListVO.getInventoryType().equals("2")) {
|
|
|
return productInventoryMapper.selectComprehensiveInventoryListTwo(productCodeListVO);
|
|
|
}
|
|
|
+ // 查询报废库存
|
|
|
+ if (productCodeListVO.getInventoryType() != null && productCodeListVO.getInventoryType().equals("3")) {
|
|
|
+ return productInventoryMapper.selectComprehensiveInventoryListTwo(productCodeListVO);
|
|
|
+ }
|
|
|
if (productCodeListVO.getIsLotNum()) { // 是否累加批次库存
|
|
|
return productInventoryMapper.selectComprehensiveInventoryListTwo(productCodeListVO);
|
|
|
} else {
|
|
@@ -572,34 +585,140 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public AjaxResult returnStorage(List<ProductCodeListVO> productCodeListVOList) {
|
|
|
- /**
|
|
|
- * 如果当前产品已经登账
|
|
|
- */
|
|
|
+ List<ProductCodeListVO> retList = new ArrayList<>();
|
|
|
+ // 循环处理当前退库操作
|
|
|
for (ProductCodeListVO productCodeListVO : productCodeListVOList) {
|
|
|
- // 判断当前货品是否已出库,出库删除出库记录
|
|
|
- ProductOutboundRecord productOutboundRecord = productOutboundRecordMapper.selectProductOutboundRecordByQrCodeId(productCodeListVO.getQrCodeId());
|
|
|
- if (productOutboundRecord == null) {
|
|
|
- return AjaxResult.warn("当前货品未出库");
|
|
|
+ /**
|
|
|
+ * 如果当前产品已经登账->只有当前是撤销登账状态才可以进行退库
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * 根据当前出库的码单信息定位到订单信息-》定位应收明细(如若可以定位那么不可以进行退库操作)
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+// productCodeListVO.getQrCodeId();
|
|
|
+// productCodeListVO.getQrCode();
|
|
|
+
|
|
|
+ // 得到当前码单出库信息
|
|
|
+ ProductOutboundRecord productOutboundRecord = productOutboundRecordMapper.selectProductOutboundRecordWhetherExist(productCodeListVO.getQrCodeId(), productCodeListVO.getQrCode());
|
|
|
+ productOutboundRecord.getNoticeNumber(); // 通知单号
|
|
|
+
|
|
|
+ // 根据通知单号查询出库单信息
|
|
|
+ ProductInvoice productInvoice = productInvoiceMapper.selectProductInvoiceByNoticeNumber(productOutboundRecord.getNoticeNumber());
|
|
|
+ productInvoice.getSaleOrderNo(); // 订单编号
|
|
|
+
|
|
|
+ // 查询应收明细根据通知单号、销售单号
|
|
|
+// SaleAccountsReceivableDetail saleAccountsReceivableDetail = new SaleAccountsReceivableDetail();
|
|
|
+// saleAccountsReceivableDetail.setSaleNo(productInvoice.getSaleOrderNo());
|
|
|
+// saleAccountsReceivableDetail.setNoticeNumber(productOutboundRecord.getNoticeNumber());
|
|
|
+// List<SaleAccountsReceivableDetail> saleAccountsReceivableDetailList = saleAccountsReceivableDetailService.selectSaleAccountsReceivableDetailList(saleAccountsReceivableDetail);
|
|
|
+
|
|
|
+ // 查询批次表
|
|
|
+ ProductOutboundRecordBatch productOutboundRecordBatch = new ProductOutboundRecordBatch();
|
|
|
+ productOutboundRecordBatch.setSaleNo(productInvoice.getSaleOrderNo());
|
|
|
+ productOutboundRecordBatch.setNoticeNumber(productOutboundRecord.getNoticeNumber());
|
|
|
+ List<ProductOutboundRecordBatch> productOutboundRecordBatchList = productOutboundRecordBatchMapper.selectProductOutboundRecordBatchList(productOutboundRecordBatch);
|
|
|
+
|
|
|
+ ProductOutboundRecordBatch find = productOutboundRecordBatchList
|
|
|
+ .stream()
|
|
|
+ .filter(item -> item.getOutboundRecordId() == productOutboundRecord.getId())
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+
|
|
|
+ // getBatchState() 0 表示正常登账状态不可以退库 1表示撤销登账状态可以退库
|
|
|
+ if (find != null && find.getBatchState() == 1) {
|
|
|
+ retList.add(productCodeListVO);
|
|
|
+ continue;
|
|
|
}
|
|
|
+
|
|
|
+// // 判断当前货品是否已出库,出库删除出库记录
|
|
|
+// ProductOutboundRecord productOutboundRecord = productOutboundRecordMapper.selectProductOutboundRecordByQrCodeId(productCodeListVO.getQrCodeId());
|
|
|
+// if (productOutboundRecord == null) {
|
|
|
+// return AjaxResult.warn("当前货品未出库");
|
|
|
+// }
|
|
|
// 库存累加
|
|
|
- ProductInventory productInventory = productInventoryMapper.selectProductInventoryByQrCode(productCodeListVO.getQrCode());
|
|
|
- ProductInventory editProductInventory = new ProductInventory();
|
|
|
- editProductInventory.setId(productInventory.getId());//编号
|
|
|
- editProductInventory.setTotalCanisterNum(productInventory.getTotalCanisterNum() + productOutboundRecord.getCanisterNum());//合计筒数
|
|
|
- editProductInventory.setTotalBoxNum(productInventory.getTotalBoxNum() + 1);//合计箱数
|
|
|
- editProductInventory.setTotalSuttle(handlingWeight(productInventory.getTotalSuttle() + productOutboundRecord.getSuttle()));//合计净重
|
|
|
- editProductInventory.setTotalGrossWeight(handlingWeight(productInventory.getTotalGrossWeight() + productOutboundRecord.getGrossWeight()));//合计毛重
|
|
|
- productInventoryMapper.updateProductInventory(editProductInventory);
|
|
|
+// ProductInventory productInventory = productInventoryMapper.selectProductInventoryByQrCode(productCodeListVO.getQrCode());
|
|
|
+// ProductInventory editProductInventory = new ProductInventory();
|
|
|
+// editProductInventory.setId(productInventory.getId());//编号
|
|
|
+// editProductInventory.setTotalCanisterNum(productInventory.getTotalCanisterNum() + productOutboundRecord.getCanisterNum());//合计筒数
|
|
|
+// editProductInventory.setTotalBoxNum(productInventory.getTotalBoxNum() + 1);//合计箱数
|
|
|
+// editProductInventory.setTotalSuttle(handlingWeight(productInventory.getTotalSuttle() + productOutboundRecord.getSuttle()));//合计净重
|
|
|
+// editProductInventory.setTotalGrossWeight(handlingWeight(productInventory.getTotalGrossWeight() + productOutboundRecord.getGrossWeight()));//合计毛重
|
|
|
+// productInventoryMapper.updateProductInventory(editProductInventory);
|
|
|
|
|
|
// 修改码单标识为已退库
|
|
|
ProductCodeList productCodeList = productCodeListMapper.selectProductCodeListById(productCodeListVO.getId());
|
|
|
productCodeList.setWithdrawingFlag("1");
|
|
|
productCodeListMapper.updateProductCodeList(productCodeList);
|
|
|
|
|
|
+ // 进行退库操作
|
|
|
+ productOutboundRecordService.removeErrorOutboundRecord(productInvoice.getId());
|
|
|
// 删除出库记录
|
|
|
- productOutboundRecordMapper.deleteProductOutboundRecordById(productOutboundRecord.getId());
|
|
|
+// productOutboundRecordMapper.deleteProductOutboundRecordById(productOutboundRecord.getId());
|
|
|
}
|
|
|
- return AjaxResult.success();
|
|
|
+ if (retList.size() == 0) {
|
|
|
+ return AjaxResult.success();
|
|
|
+ } else {
|
|
|
+ return AjaxResult.warn("已登账!无法退库", retList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult invalidated(List<ProductCodeListVO> productCodeListVOList) {
|
|
|
+
|
|
|
+ //返回无法报废库存
|
|
|
+ List<ProductCodeListVO> retList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 可以进行报废处理的码单
|
|
|
+ List<ProductCodeListVO> invalidatedList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 循环处理当前退库操作
|
|
|
+ for (ProductCodeListVO productCodeListVO : productCodeListVOList) {
|
|
|
+ // 得到当前码单出库信息
|
|
|
+ ProductOutboundRecord productOutboundRecord = productOutboundRecordMapper.selectProductOutboundRecordWhetherExist(productCodeListVO.getQrCodeId(), productCodeListVO.getQrCode());
|
|
|
+ productOutboundRecord.getNoticeNumber(); // 通知单号
|
|
|
+
|
|
|
+ // 根据通知单号查询出库单信息
|
|
|
+ ProductInvoice productInvoice = productInvoiceMapper.selectProductInvoiceByNoticeNumber(productOutboundRecord.getNoticeNumber());
|
|
|
+ productInvoice.getSaleOrderNo(); // 订单编号
|
|
|
+
|
|
|
+ // 查询批次表
|
|
|
+ ProductOutboundRecordBatch productOutboundRecordBatch = new ProductOutboundRecordBatch();
|
|
|
+ productOutboundRecordBatch.setSaleNo(productInvoice.getSaleOrderNo());
|
|
|
+ productOutboundRecordBatch.setNoticeNumber(productOutboundRecord.getNoticeNumber());
|
|
|
+ List<ProductOutboundRecordBatch> productOutboundRecordBatchList = productOutboundRecordBatchMapper.selectProductOutboundRecordBatchList(productOutboundRecordBatch);
|
|
|
+
|
|
|
+ ProductOutboundRecordBatch find = productOutboundRecordBatchList
|
|
|
+ .stream()
|
|
|
+ .filter(item -> item.getOutboundRecordId() == productOutboundRecord.getId())
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+
|
|
|
+ // getBatchState() 0 表示正常登账状态不可以退库 1表示撤销登账状态可以退库
|
|
|
+ if (find != null && find.getBatchState() == 1) {
|
|
|
+ retList.add(productCodeListVO);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 修改码单标识为报废
|
|
|
+ ProductCodeList productCodeList = productCodeListMapper.selectProductCodeListById(productCodeListVO.getId());
|
|
|
+ // 报废状态
|
|
|
+ productCodeList.setWithdrawingFlag("2");
|
|
|
+ productCodeListMapper.updateProductCodeList(productCodeList);
|
|
|
+ // 进行退库操作
|
|
|
+ productOutboundRecordService.removeErrorOutboundRecord(productInvoice.getId());
|
|
|
+ // 报废状态
|
|
|
+ productCodeListVO.setInventoryType("3");
|
|
|
+ // 添加报废库存List
|
|
|
+ invalidatedList.add(productCodeListVO);
|
|
|
+ }
|
|
|
+ // 增加报废库存 inventory_type:3 报废类型库存
|
|
|
+ if (productCodeListVOList.size() != 0) this.productStorage(productCodeListVOList);
|
|
|
+ if (retList.size() == 0) {
|
|
|
+ return AjaxResult.success();
|
|
|
+ } else {
|
|
|
+ return AjaxResult.warn("已登账!无法报废", retList);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -747,4 +866,7 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
return Double.parseDouble(df.format(weight));
|
|
|
}
|
|
|
+
|
|
|
+ // find
|
|
|
+
|
|
|
}
|