|
|
@@ -13,10 +13,7 @@ import com.uas.platform.b2c.common.base.dao.CommonDao;
|
|
|
import com.uas.platform.b2c.common.search.rpc.service.SearchService;
|
|
|
import com.uas.platform.b2c.common.search.util.SPage;
|
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
|
-import com.uas.platform.b2c.core.constant.IntegerConstant;
|
|
|
-import com.uas.platform.b2c.core.constant.ShortConstant;
|
|
|
-import com.uas.platform.b2c.core.constant.SplitChar;
|
|
|
-import com.uas.platform.b2c.core.constant.Status;
|
|
|
+import com.uas.platform.b2c.core.constant.*;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.utils.FastjsonUtils;
|
|
|
import com.uas.platform.b2c.core.utils.NumberUtil;
|
|
|
@@ -2357,77 +2354,71 @@ public class ProductServiceImpl implements ProductService {
|
|
|
* @param inOutMap 出入库的map
|
|
|
*/
|
|
|
@Override
|
|
|
- public void updateProductsByReleaseProductByBatch(Set<ReleaseProductByBatch> reList, Integer ignoreImport, Set<InOutboundDetail> newInOutboundDetail, Map<String, Set<InOutboundDetail>> inOutMap) {
|
|
|
- if (CollectionUtils.isNotEmpty(reList)) {
|
|
|
- Set<Long> prIds = new HashSet<>();
|
|
|
+ public void updateProductsByReleaseProductByBatch(Set<Long> prIds, List<ReleaseProductByBatch> reList, Integer ignoreImport, Set<InOutboundDetail> newInOutboundDetail, Map<String, Set<InOutboundDetail>> inOutMap) {
|
|
|
+ if (CollectionUtils.isEmpty(prIds) || CollectionUtils.isEmpty(reList)) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ List<Product> products = productDao.findAll(prIds);
|
|
|
+ List<Product> freshProducts = new ArrayList<>();
|
|
|
+ InOutboundDetail detail = null;
|
|
|
+ for (Product product : products) {
|
|
|
for (ReleaseProductByBatch productByBatch : reList) {
|
|
|
- if (productByBatch.getProductid() != null) {
|
|
|
- prIds.add(productByBatch.getProductid());
|
|
|
+ if (!productByBatch.getReleaseCode().equals(ReleaseStatus.failure.value()) &&
|
|
|
+ !productByBatch.getReleaseCode().equals(ReleaseStatus.success.value())) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- }
|
|
|
- if (CollectionUtils.isNotEmpty(prIds)) {
|
|
|
- List<Product> products = productDao.findAll(prIds);
|
|
|
- List<Product> freshProducts = new ArrayList<>();
|
|
|
- InOutboundDetail detail = null;
|
|
|
- for (Product product : products) {
|
|
|
- for (ReleaseProductByBatch productByBatch : reList) {
|
|
|
- if ((productByBatch.getId() != null) &&(productByBatch.getId().longValue() == product.getId().longValue()) ) {
|
|
|
- // ignoreImport 1表示忽略导入,0代表覆盖导入
|
|
|
- if (StringUtils.isEmpty(product.getPackaging()) || (ignoreImport == IntegerConstant.NO_SHORT)) {
|
|
|
- product.setPackaging(productByBatch.getPackaging());
|
|
|
- }
|
|
|
- if ((product.getMinPackQty() == null) || (ignoreImport == IntegerConstant.NO_SHORT)) {
|
|
|
- product.setMinPackQty(productByBatch.getMinPackage());
|
|
|
- }
|
|
|
- if ((product.getMinPackQty() == null) || (ignoreImport == IntegerConstant.NO_SHORT)) {
|
|
|
- product.setMinPackQty(productByBatch.getMinPackage());
|
|
|
- }
|
|
|
- if ((product.getKind() == null) || (ignoreImport == IntegerConstant.NO_SHORT)) {
|
|
|
- product.setKind(productByBatch.getKindName());
|
|
|
- product.setKindid(productByBatch.getKindUuid());
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(product.getSpec()) || (ignoreImport == IntegerConstant.NO_SHORT)) {
|
|
|
- product.setSpec(productByBatch.getSpec());
|
|
|
- }
|
|
|
- if ((ignoreImport == IntegerConstant.NO_SHORT) || (NumberUtil.compare(product.getErpReserve(), DoubleConstant.zero) < 1)) {
|
|
|
- Double qty = productByBatch.getReserve();
|
|
|
- if (NumberUtil.compare(product.getErpReserve(), DoubleConstant.zero) > 0) {
|
|
|
- qty = NumberUtil.sub(qty, product.getErpReserve());
|
|
|
- }
|
|
|
- if (NumberUtil.compare(qty, DoubleConstant.zero) != 0) {
|
|
|
- //做出入库记录
|
|
|
- product.setErpReserve(productByBatch.getReserve());
|
|
|
- detail = new InOutboundDetail(product);
|
|
|
- detail.setQty(qty);
|
|
|
- detail.setPrice(productByBatch.getCostPrice());
|
|
|
- newInOutboundDetail.add(detail);
|
|
|
- }
|
|
|
- }
|
|
|
- freshProducts.add(product);
|
|
|
- }
|
|
|
+ if ((productByBatch.getId() != null) &&(productByBatch.getId().longValue() == product.getId().longValue()) ) {
|
|
|
+ // ignoreImport 1表示忽略导入,0代表覆盖导入
|
|
|
+ if (StringUtils.isEmpty(product.getPackaging()) || (ignoreImport == IntegerConstant.NO_SHORT)) {
|
|
|
+ product.setPackaging(productByBatch.getPackaging());
|
|
|
}
|
|
|
- }
|
|
|
- productDao.save(freshProducts);
|
|
|
- if (CollectionUtils.isNotEmpty(newInOutboundDetail)) {
|
|
|
- Set<InOutboundDetail> inBoundDetail = new HashSet<>();
|
|
|
- Set<InOutboundDetail> outBoundDetail = new HashSet<>();
|
|
|
- for (InOutboundDetail detail1 : newInOutboundDetail) {
|
|
|
- if (NumberUtil.compare(detail1.getQty(), DoubleConstant.zero) < 0) {
|
|
|
- detail1.setQty(Math.abs(detail1.getQty()));
|
|
|
- outBoundDetail.add(detail1);
|
|
|
- } else if (NumberUtil.compare(detail1.getQty(), DoubleConstant.zero) > 0) {
|
|
|
- inBoundDetail.add(detail1);
|
|
|
- }
|
|
|
+ if ((product.getMinPackQty() == null) || (ignoreImport == IntegerConstant.NO_SHORT)) {
|
|
|
+ product.setMinPackQty(productByBatch.getMinPackage());
|
|
|
+ }
|
|
|
+ if ((product.getMinPackQty() == null) || (ignoreImport == IntegerConstant.NO_SHORT)) {
|
|
|
+ product.setMinPackQty(productByBatch.getMinPackage());
|
|
|
+ }
|
|
|
+ if ((product.getKind() == null) || (ignoreImport == IntegerConstant.NO_SHORT)) {
|
|
|
+ product.setKind(productByBatch.getKindName());
|
|
|
+ product.setKindid(productByBatch.getKindUuid());
|
|
|
}
|
|
|
- if (CollectionUtils.isNotEmpty(inBoundDetail)) {
|
|
|
- inOutMap.put(InOutBoundType.OTHER_INBOUND, inBoundDetail);
|
|
|
+ if (StringUtils.isEmpty(product.getSpec()) || (ignoreImport == IntegerConstant.NO_SHORT)) {
|
|
|
+ product.setSpec(productByBatch.getSpec());
|
|
|
}
|
|
|
- if (CollectionUtils.isNotEmpty(outBoundDetail)) {
|
|
|
- inOutMap.put(InOutBoundType.OTHER_OUTBOUND, outBoundDetail);
|
|
|
+ if ((ignoreImport == IntegerConstant.NO_SHORT) || (NumberUtil.compare(product.getErpReserve(), DoubleConstant.zero) != 0)) {
|
|
|
+ Double qty = NumberUtil.sub(productByBatch.getReserve(), product.getErpReserve());
|
|
|
+ if (NumberUtil.compare(qty, DoubleConstant.zero) != 0) {
|
|
|
+ //做出入库记录
|
|
|
+ product.setErpReserve(productByBatch.getReserve());
|
|
|
+ detail = new InOutboundDetail(product);
|
|
|
+ detail.setQty(qty);
|
|
|
+ detail.setPrice(productByBatch.getCostPrice());
|
|
|
+ newInOutboundDetail.add(detail);
|
|
|
+ }
|
|
|
}
|
|
|
+ freshProducts.add(product);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ productDao.save(freshProducts);
|
|
|
+ if (CollectionUtils.isNotEmpty(newInOutboundDetail)) {
|
|
|
+ Set<InOutboundDetail> inBoundDetail = new HashSet<>();
|
|
|
+ Set<InOutboundDetail> outBoundDetail = new HashSet<>();
|
|
|
+ for (InOutboundDetail detail1 : newInOutboundDetail) {
|
|
|
+ if (NumberUtil.compare(detail1.getQty(), DoubleConstant.zero) < 0) {
|
|
|
+ detail1.setQty(Math.abs(detail1.getQty()));
|
|
|
+ outBoundDetail.add(detail1);
|
|
|
+ } else if (NumberUtil.compare(detail1.getQty(), DoubleConstant.zero) > 0) {
|
|
|
+ inBoundDetail.add(detail1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(inBoundDetail)) {
|
|
|
+ inOutMap.put(InOutBoundType.OTHER_INBOUND, inBoundDetail);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(outBoundDetail)) {
|
|
|
+ inOutMap.put(InOutBoundType.OTHER_OUTBOUND, outBoundDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2542,5 +2533,25 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据物料id获取物料信息
|
|
|
+ *
|
|
|
+ * @param ids 物料拼接
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Product> getProductByIds(String ids) {
|
|
|
+ if (StringUtils.isEmpty(ids)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ } else {
|
|
|
+ String[] splits = ids.split(SplitChar.COMMA);
|
|
|
+ List<Long> idList = new ArrayList<>();
|
|
|
+ for (String id : splits) {
|
|
|
+ idList.add(Long.valueOf(id));
|
|
|
+ }
|
|
|
+ return productDao.findAll(idList);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|