|
|
@@ -1,6 +1,5 @@
|
|
|
package com.uas.platform.b2c.prod.commodity.service.impl;
|
|
|
|
|
|
-import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
import com.uas.platform.b2c.common.base.dao.CommonDao;
|
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
|
import com.uas.platform.b2c.core.constant.IntegerConstant;
|
|
|
@@ -28,6 +27,8 @@ import com.uas.platform.b2c.prod.store.model.StoreIn;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreStatus;
|
|
|
import com.uas.platform.b2c.prod.store.service.StoreInService;
|
|
|
import com.uas.platform.b2c.trade.order.StringConstant.Currency;
|
|
|
+import com.uas.platform.b2c.trade.presale.model.TradeDeliveryDelayTime;
|
|
|
+import com.uas.platform.b2c.trade.presale.service.TradeDeliveryDelayTimeService;
|
|
|
import com.uas.platform.b2c.trade.support.ResultMap;
|
|
|
import com.uas.platform.b2c.trade.util.BoundedExecutor;
|
|
|
import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
@@ -136,6 +137,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
@Autowired
|
|
|
private GoodsHistoryService goodsHistoryService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TradeDeliveryDelayTimeService tradeDeliveryDelayTimeService;
|
|
|
+
|
|
|
private final Logger logger = Logger.getLogger(getClass());
|
|
|
|
|
|
/**
|
|
|
@@ -210,7 +214,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if (rowNum > 2002) {
|
|
|
throw new IllegalOperatorException ("您上传的信息超过2000条,请拆分成2000以下再上传");
|
|
|
}
|
|
|
- if (rowNum < 3) {
|
|
|
+ if (rowNum < 2) {
|
|
|
throw new IllegalOperatorException ("请填写上传信息");
|
|
|
}
|
|
|
List<ReleaseProductByBatch> releaseProductByBatchs = new ArrayList<>(rowNum);
|
|
|
@@ -1728,26 +1732,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if (isPcb) {
|
|
|
savePcbInfo(idSet, map);
|
|
|
}
|
|
|
- System.err.println("测试信息的1-2" + "---------------------");
|
|
|
- Enterprise enterprise = SystemSession.getUser().getEnterprise();
|
|
|
- final Object[] obj = new Object[]{enterprise.getUu(), enterprise.getEnName(), batch};
|
|
|
- String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @enName = '%s'; set @batch = '%s'; call RELEASE_TO_GOODS_V5(@enuu, @enName, @batch, @out); select @out; commit;";
|
|
|
- final String updateSql = String.format(sql, obj);
|
|
|
- String num = jdbcTemplate.execute(new StatementCallback<String>() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public String doInStatement(Statement stmt) throws SQLException, DataAccessException {
|
|
|
- stmt.executeUpdate(updateSql);
|
|
|
- ResultSet rs = stmt.getResultSet();
|
|
|
- System.err.println("测试信息的1-3" + "---------------------");
|
|
|
- if (null != rs) {
|
|
|
- rs.next();
|
|
|
- System.err.println("测试信息的1-3" + "---------------------" + rs.getString(1));
|
|
|
- return rs.getString(1);
|
|
|
- }
|
|
|
- return "0";
|
|
|
- }
|
|
|
- });
|
|
|
+ Integer num = releaseToGoods(releaseProductByBatchList);
|
|
|
System.err.println("测试信息的1" + "---------------------");
|
|
|
String updateReleaseSql = "/*#mycat:db_type=master*/ update trade$releasebybatch set rel_releasecode = 101,rel_releasestatus = '已发布' where (rel_releasecode = 112 OR rel_releasecode = 113) and rel_batchid = '%s';";
|
|
|
final String updateRelease = String.format(updateReleaseSql, new Object[]{batch});
|
|
|
@@ -1760,6 +1745,55 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
return StringUtilB2C.getStr(num);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 临时表保存到goods信息
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Integer releaseToGoods(List<ReleaseProductByBatch> list) {
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ List<Goods> goodses = new ArrayList<>();
|
|
|
+ Goods goods = null;
|
|
|
+ TradeDeliveryDelayTime delayTime = null;
|
|
|
+ ReleaseProductByBatch releaseProductByBatch1 = list.get(0);
|
|
|
+ if (releaseProductByBatch1.getStoreid().equals(SysConf.getStoreid())) {
|
|
|
+ // 增加交货延长期限
|
|
|
+ List<TradeDeliveryDelayTime> tradeDeliveryDelayTime = tradeDeliveryDelayTimeService.getTradeDeliveryDelayTime();
|
|
|
+ if (releaseProductByBatch1.getCurrency().equals(StringConstant.RMB)) {
|
|
|
+ for (TradeDeliveryDelayTime deliveryDelayTime : tradeDeliveryDelayTime) {
|
|
|
+ if (deliveryDelayTime.getType() == IntegerConstant.DOMESTIC_DELAY) {
|
|
|
+ delayTime = deliveryDelayTime;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (TradeDeliveryDelayTime deliveryDelayTime : tradeDeliveryDelayTime) {
|
|
|
+ if (deliveryDelayTime.getType() == IntegerConstant.ABROAD_DELAY) {
|
|
|
+ delayTime = deliveryDelayTime;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (delayTime == null) {
|
|
|
+ throw new IllegalOperatorException("平台未设置供应商延长时间,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (ReleaseProductByBatch releaseProductByBatch : list) {
|
|
|
+ if (releaseProductByBatch.getReleaseCode().intValue() == ReleaseStatus.success.value() || releaseProductByBatch.getReleaseCode().intValue() == ReleaseStatus.failure.value()) {
|
|
|
+ goods = new Goods();
|
|
|
+ goods.setGoodsByReleaseProductByBatch(releaseProductByBatch, delayTime);
|
|
|
+ goodses.add(goods);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(goodses)) {
|
|
|
+ commonDao.save(goodses, Goods.class);
|
|
|
+ }
|
|
|
+ return goodses.size();
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 批量保存pcb的信息
|
|
|
* @param idSet id
|
|
|
@@ -1963,6 +1997,17 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
final Runnable afterPublishToGoodsRunnable = new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
+
|
|
|
+ //创建历史库存
|
|
|
+ List<Goods> goodses1 = goodsService.findByBatchId(batchid);
|
|
|
+ List<GoodsHistory> list = new ArrayList<>();
|
|
|
+ for (Goods goods : goodses1) {
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false);
|
|
|
+ list.add(goodsHistory);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ goodsHistoryService.save(list);
|
|
|
+ }
|
|
|
//创建物料的私有信息
|
|
|
productPrivateService.newProductPrivateIfNotExist(productIds);
|
|
|
|
|
|
@@ -1970,12 +2015,14 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
List<ReleaseProductByBatch> productByBatches = releaseProductByBatchDao.findAll(reIds);
|
|
|
List<Long> prIds = new ArrayList<>();
|
|
|
for (ReleaseProductByBatch productByBatch : productByBatches) {
|
|
|
- prIds.add(productByBatch.getProductid());
|
|
|
+ if (productByBatch.getProductid() != null) {
|
|
|
+ prIds.add(productByBatch.getProductid());
|
|
|
+ }
|
|
|
}
|
|
|
List<Product> products = productService.findByProductId(prIds);
|
|
|
for (Product product : products) {
|
|
|
for (ReleaseProductByBatch productByBatch : productByBatches) {
|
|
|
- if ((productByBatch.getProductid() != null ) && (product.getId().longValue() == productByBatch.getProductid().longValue())) {
|
|
|
+ if ((productByBatch.getProductid() != null) && (product.getId().longValue() == productByBatch.getProductid().longValue())) {
|
|
|
product.setSpec(productByBatch.getSpec());
|
|
|
}
|
|
|
}
|