|
|
@@ -49,6 +49,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
+import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.StatementCallback;
|
|
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
|
@@ -62,6 +63,7 @@ import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.sql.PreparedStatement;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
import java.sql.Statement;
|
|
|
@@ -1797,7 +1799,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
return null;
|
|
|
}
|
|
|
Map<String, Object> map = new HashedMap();
|
|
|
- List<Product> products = new ArrayList<>();
|
|
|
+ List<ReleaseProductByBatch> productsfromRelease = new ArrayList<>();
|
|
|
List<ProductPrivate> productPrivates = new ArrayList<>();
|
|
|
Set<Long> prIds = new HashSet<>();
|
|
|
Set<Long> reIds = new HashSet<>();
|
|
|
@@ -1828,14 +1830,11 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if (releaseProductByBatch.getReleaseCode().equals(ReleaseStatus.failure.value()) ||
|
|
|
releaseProductByBatch.getReleaseCode().equals(ReleaseStatus.success.value())) {
|
|
|
if (releaseProductByBatch.getProductid() == null) {
|
|
|
- Product product = new Product();
|
|
|
- product.setReleaseByBatch(releaseProductByBatch);
|
|
|
// releaseProductByBatch.getCode(); 在公有库生成
|
|
|
prodNum = "PNUM" + time + CreateNumberServiceImpl.formatIntToStr(++num, 8);
|
|
|
- product.setProdNum(prodNum);
|
|
|
releaseProductByBatch.setProductNum(prodNum);
|
|
|
proNums.add(prodNum);
|
|
|
- products.add(product);
|
|
|
+ productsfromRelease.add(releaseProductByBatch);
|
|
|
} else {
|
|
|
//对于已经存在于物料库的信息,如果规格信息已存在,则做更新,如果是
|
|
|
prIds.add(releaseProductByBatch.getProductid());
|
|
|
@@ -1866,15 +1865,14 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
propertyMap.put(SystemSession.getUser().getEnterprise().getUu().toString().concat(prodNum), propertyValues);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
long l2 = System.currentTimeMillis();
|
|
|
System.err.println("打印l2 ----------- l1" + (l2 - l1));
|
|
|
List<ReleaseProductByBatch> reList = new ArrayList<>();
|
|
|
- if (products.size() != 0) {
|
|
|
- List<Product> productes = productDao.save(products);
|
|
|
- //List<Product> productes = productService.findProductsByProdNums(proNums);
|
|
|
+ if (productsfromRelease.size() != 0) {
|
|
|
+ productService.saveByJdbcTemplate(productsfromRelease);
|
|
|
+ List<Product> productes = productService.findProductsByProdNums(proNums);
|
|
|
for (Product producte : productes) {
|
|
|
ProductPrivate productPrivate = new ProductPrivate();
|
|
|
productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
|
|
|
@@ -1896,7 +1894,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
long l3 = System.currentTimeMillis();
|
|
|
System.err.println("打印l3 ----------- l2" + (l3 - l2));
|
|
|
if (CollectionUtils.isNotEmpty(reList)) {
|
|
|
- releaseProductByBatchDao.save(reList);
|
|
|
+ udpatePridAndRrodnum(reList);
|
|
|
}
|
|
|
long l4 = System.currentTimeMillis();
|
|
|
System.err.println("打印l4 ----------- l3" + (l4 - l3));
|
|
|
@@ -1987,4 +1985,32 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新物料主键和物料编号
|
|
|
+ *
|
|
|
+ * @param list
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void udpatePridAndRrodnum(List<ReleaseProductByBatch> list) {
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ jdbcTemplate.batchUpdate("update trade$releasebybatch set rel_productid=?,rel_pronum=? where rel_id=?", new BatchPreparedStatementSetter() {
|
|
|
+ @Override
|
|
|
+ public void setValues(PreparedStatement ps, int i) throws SQLException {
|
|
|
+ ReleaseProductByBatch releaseProductByBatch = list.get(i);
|
|
|
+ ps.setLong(1, releaseProductByBatch.getProductid());
|
|
|
+ ps.setString(2, releaseProductByBatch.getProductNum());
|
|
|
+ ps.setLong(3, releaseProductByBatch.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getBatchSize() {
|
|
|
+ return list.size();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|