|
@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import com.zkqy.business.domain.*;
|
|
|
import com.zkqy.business.domain.vo.ProductCodeListVO;
|
|
|
+import com.zkqy.business.domain.vo.ProductInventoryTypeTotalSubCodeList;
|
|
|
import com.zkqy.business.domain.vo.ProductInventoryVo;
|
|
|
import com.zkqy.business.domain.vo.ProductInvoiceVO;
|
|
|
import com.zkqy.business.mapper.*;
|
|
@@ -67,6 +68,9 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
@Autowired
|
|
|
private IProductOutboundRecordService productOutboundRecordService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IProductInventoryService iProductInventoryService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询产品库存
|
|
|
*
|
|
@@ -89,6 +93,83 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
return productInventoryMapper.selectProductInventoryList(productInventory);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int selectCodeListWarehousing(ProductInventoryTypeTotalSubCodeList productInventoryTypeTotalSubCodeList) {
|
|
|
+
|
|
|
+
|
|
|
+// //普通码单
|
|
|
+// if(productInventoryTypeTotalSubCodeList.getOtherStates().equals("0")){
|
|
|
+// //总码单信息
|
|
|
+// List<ProductCodeList> productCodeLists = productCodeListMapper.selectProductCodeListByQrCodeIn(productInventoryTypeTotalSubCodeList);
|
|
|
+//
|
|
|
+// //List容器集合
|
|
|
+// List<ProductCodeListVO> productCodeListVOList = new ArrayList<>();
|
|
|
+//
|
|
|
+// //循环Copy相关内容
|
|
|
+// productCodeLists.stream().forEach(item->{
|
|
|
+// ProductCodeListVO productCodeListVO=new ProductCodeListVO();
|
|
|
+// BeanUtils.copyProperties(item,productCodeListVO);
|
|
|
+// productCodeListVOList.add(productCodeListVO);
|
|
|
+// });
|
|
|
+// //入库操作Or修改库存成功
|
|
|
+// String s = iProductInventoryService.productStorage(productCodeListVOList);
|
|
|
+// if(s.equals("入库成功")){
|
|
|
+// return 1;
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// //子码单信息
|
|
|
+// List<ProductCodeList> productCodeLists = productCodeListMapper.selectProductCodeListByQrCodeIn(productInventoryTypeTotalSubCodeList);
|
|
|
+//
|
|
|
+// //List容器集合
|
|
|
+// List<ProductCodeListVO> productCodeListVOList = new ArrayList<>();
|
|
|
+//
|
|
|
+// //循环Copy相关内容
|
|
|
+// productCodeLists.stream().forEach(item->{
|
|
|
+// ProductCodeListVO productCodeListVO=new ProductCodeListVO();
|
|
|
+// BeanUtils.copyProperties(item,productCodeListVO);
|
|
|
+// productCodeListVOList.add(productCodeListVO);
|
|
|
+// });
|
|
|
+//
|
|
|
+// //入库操作Or修改库存成功
|
|
|
+// String s = iProductInventoryService.productStorage(productCodeListVOList);
|
|
|
+// if(s.equals("入库成功")){
|
|
|
+// return 1;
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+ List<ProductCodeList> productCodeLists = productCodeListMapper.selectProductCodeListByQrCodeIn(productInventoryTypeTotalSubCodeList.getListCodeWarehousing());
|
|
|
+
|
|
|
+ //List容器集合
|
|
|
+ List<ProductCodeListVO> productCodeListVOList = new ArrayList<>();
|
|
|
+
|
|
|
+ //循环Copy相关内容
|
|
|
+ productCodeLists.stream().forEach(item->{
|
|
|
+
|
|
|
+ ProductCodeListVO productCodeListVO=new ProductCodeListVO();
|
|
|
+ BeanUtils.copyProperties(item,productCodeListVO);
|
|
|
+ //库存信息
|
|
|
+ productCodeListVO.setWarehouseId(Long.valueOf(productInventoryTypeTotalSubCodeList.getWarehouseId()));
|
|
|
+ //列表信息
|
|
|
+ productCodeListVOList.add(productCodeListVO);
|
|
|
+ });
|
|
|
+
|
|
|
+ //入库操作Or修改库存成功
|
|
|
+ String s = iProductInventoryService.productStorageTwo(productCodeListVOList);
|
|
|
+
|
|
|
+ //修改码单的库位信息
|
|
|
+
|
|
|
+ if(s.equals("入库成功")){
|
|
|
+ productCodeLists.forEach(item->{
|
|
|
+ item.setWarehouseregionId(Long.valueOf(productInventoryTypeTotalSubCodeList.getWarehouseId()));
|
|
|
+ productCodeListMapper.updateProductCodeList(item);//更改码单的库位信息
|
|
|
+ });
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ //入库失败
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新增产品库存
|
|
|
*
|
|
@@ -137,7 +218,7 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public void productStorage(List<ProductCodeListVO> productCodeListVOList) {
|
|
|
+ public String productStorage(List<ProductCodeListVO> productCodeListVOList) {
|
|
|
|
|
|
for (ProductCodeListVO vo : productCodeListVOList) {
|
|
|
// 日志
|
|
@@ -197,6 +278,7 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
productInventoryMapper.insertProductInventory(addProductInventory);
|
|
|
}
|
|
|
}
|
|
|
+ return "入库成功";
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1017,6 +1099,69 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
return productInventoryMapper.updateProductInventory(productInventory);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String productStorageTwo(List<ProductCodeListVO> productCodeListVOList) {
|
|
|
+ for (ProductCodeListVO vo : productCodeListVOList) {
|
|
|
+ // 日志
|
|
|
+ ProductCodeList productCodeList = new ProductCodeList(vo);
|
|
|
+ //校验当前货品是否已入库,已入库跳过本次循环
|
|
|
+ ProductWarehousingRecord productWarehousingRecord1 =
|
|
|
+ productWarehousingRecordMapper.selectProductWarehousingRecordWhetherExist(productCodeList.getQrCode(), vo.getQrCodeId());
|
|
|
+ if (productWarehousingRecord1 != null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 入库记录信息
|
|
|
+ ProductWarehousingRecord productWarehousingRecord = new ProductWarehousingRecord();
|
|
|
+ BeanUtils.copyProperties(productCodeList, productWarehousingRecord);
|
|
|
+ productWarehousingRecord.setQrCodeId(vo.getQrCodeId());
|
|
|
+ productWarehousingRecord.setCanisterNum(vo.getCanisterNum());//筒数
|
|
|
+ productWarehousingRecord.setSuttle(vo.getSuttle());//净重
|
|
|
+ productWarehousingRecord.setGrossWeight(vo.getGrossWeight());//毛重
|
|
|
+ productWarehousingRecord.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ productWarehousingRecord.setCreateTime(DateUtils.getNowDate());
|
|
|
+ productWarehousingRecord.setCreateById(SecurityUtils.getUserId());
|
|
|
+ productWarehousingRecord.setDepositor(SecurityUtils.getLoginUser().getUser().getNickName());//入库人
|
|
|
+ productWarehousingRecord.setWarehousingTime(DateUtils.getNowDate());
|
|
|
+ productWarehousingRecord.setWarehouseId(vo.getWarehouseId());//入库仓库编号
|
|
|
+ productWarehousingRecord.setRemark(productCodeList.getRemark());
|
|
|
+ productWarehousingRecordMapper.insertProductWarehousingRecord(productWarehousingRecord);
|
|
|
+ // 库存
|
|
|
+ //查询当前库存是否存在,如果存在则更新,如果不存在则新增
|
|
|
+ ProductInventory productInventory = productInventoryMapper.selectProductInventoryByQrCode(vo.getQrCode());
|
|
|
+ if (productInventory != null) {
|
|
|
+ //计算合计箱数、筒数、净重、毛重
|
|
|
+ ProductInventory editProductInventory = new ProductInventory();
|
|
|
+ editProductInventory.setId(productInventory.getId());
|
|
|
+ editProductInventory.setTotalCanisterNum(productInventory.getTotalCanisterNum() == null ? vo.getCanisterNum() : productInventory.getTotalCanisterNum() + vo.getCanisterNum());//合计筒数数
|
|
|
+ editProductInventory.setTotalBoxNum(productInventory.getTotalBoxNum() + 1);//合计箱数
|
|
|
+ Double suttle = productInventory.getTotalSuttle() == null ? vo.getSuttle() : productInventory.getTotalSuttle() + vo.getSuttle();
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
+ String suttle1 = df.format(suttle);
|
|
|
+ editProductInventory.setTotalSuttle(Double.parseDouble(suttle1));//合计净重
|
|
|
+ Double grossWeight = productInventory.getTotalGrossWeight() == null ? vo.getGrossWeight() : productInventory.getTotalGrossWeight() + vo.getGrossWeight();
|
|
|
+ String grossWeight1 = df.format(grossWeight);
|
|
|
+ editProductInventory.setTotalGrossWeight(Double.parseDouble(grossWeight1));//合计毛重
|
|
|
+ editProductInventory.setUpdateById(SecurityUtils.getUserId());
|
|
|
+ editProductInventory.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ editProductInventory.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ productInventoryMapper.updateProductInventory(editProductInventory);
|
|
|
+ } else {
|
|
|
+ ProductInventory addProductInventory = new ProductInventory();
|
|
|
+ BeanUtils.copyProperties(productCodeList, addProductInventory);
|
|
|
+ addProductInventory.setWarehouseId(vo.getWarehouseId());
|
|
|
+ addProductInventory.setTotalCanisterNum(vo.getCanisterNum());//合计筒数
|
|
|
+ addProductInventory.setTotalBoxNum(1);//合计箱数
|
|
|
+ addProductInventory.setTotalSuttle(vo.getSuttle());//合计净重
|
|
|
+ addProductInventory.setTotalGrossWeight(vo.getGrossWeight());//合计毛重
|
|
|
+ addProductInventory.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ addProductInventory.setCreateTime(DateUtils.getNowDate());
|
|
|
+ addProductInventory.setCreateById(SecurityUtils.getUserId());
|
|
|
+ productInventoryMapper.insertProductInventory(addProductInventory);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "入库成功";
|
|
|
+ }
|
|
|
+
|
|
|
//保留两位小数
|
|
|
public Double handlingWeight(Double weight) {
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|