|
|
@@ -33,6 +33,8 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
+import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
@@ -40,6 +42,8 @@ import javax.persistence.criteria.CriteriaBuilder;
|
|
|
import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
+import java.sql.PreparedStatement;
|
|
|
+import java.sql.SQLException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
@@ -69,6 +73,9 @@ public class ProdServiceImpl implements ProdService {
|
|
|
@Autowired
|
|
|
private ProductPrivateDao productPrivateDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ReleaseProductByBatchService releaseProductByBatchService;
|
|
|
|
|
|
@@ -229,19 +236,34 @@ public class ProdServiceImpl implements ProdService {
|
|
|
List<V_ProductPrivate> content = productPrivates.getContent();
|
|
|
List<Prod> content1 = new ArrayList<>();
|
|
|
for (V_ProductPrivate v_productPrivate : content) {
|
|
|
- Prod prod = ModelConvertUtil.vProductPrivateConvertProd(v_productPrivate);
|
|
|
+ Prod prod = ModelConvertUtil.vProductPrivateConvertProd(v_productPrivate);
|
|
|
if (prod != null) {
|
|
|
content1.add(prod);
|
|
|
}
|
|
|
}
|
|
|
- PageImpl<Prod> page = new PageImpl<>(content1, new PageInfo(pageParams), productPrivates.getTotalElements());
|
|
|
+ PageImpl<Prod> page = new PageImpl<>(content1, info, productPrivates.getTotalElements());
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateNewProdDowned(List<String> list) {
|
|
|
+ public void updateNewProdDowned(final List<String> list) {
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
- productDao.updateProductMallERPDowned(list);
|
|
|
+ final String sql = "update products set pr_erpdown = '已上传' where pr_pcmpcode = ? and pr_pbranden = ?";
|
|
|
+ int[] batchUpdate = jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
|
|
+ @Override
|
|
|
+ public void setValues(PreparedStatement ps, int i) throws SQLException {
|
|
|
+ String str = list.get(i);
|
|
|
+ String[] split = str.split("-----");
|
|
|
+ ps.setString(1, split[0]);
|
|
|
+ ps.setString(2, split[1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getBatchSize() {
|
|
|
+ return list.size();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ System.out.println(batchUpdate.length);
|
|
|
}
|
|
|
}
|
|
|
}
|