Просмотр исходного кода

物料导出,id数量超过1000条时切割查找,避免参数超长。

dongbw 8 лет назад
Родитель
Сommit
80bccfa27b

+ 11 - 1
src/main/java/com/uas/platform/b2b/search/SearchServiceImpl.java

@@ -758,7 +758,17 @@ public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchServ
 	@Override
 	public SPage<Product> searchProductsCheckIds(String keyword, PageParams pageParams) {
 		SPage<Long> idsPage = searchService.searchIds(keyword, Table_name.V$PRODUCTS, pageParams);
-		List<Product> content = productDao.findAll(idsPage.getContent());
+		List<Product> content = new ArrayList<>();
+		// 超过1000就切割
+		if (idsPage.getContent().size() > SplitArray.QUERY_MAX_NUMBER) {
+			List<List<Long>> idLists = SplitArray.splitAry(idsPage.getContent(), SplitArray.QUERY_MAX_NUMBER);
+			for (List<Long> idList : idLists) {
+				List<Product> products = productDao.findAll(idList);
+				content.addAll(products);
+			}
+		} else {
+			content = productDao.findAll(idsPage.getContent());
+		}
 		sortByProperty(content, Product.class, "id", idsPage.getContent());
 		return toSPage(idsPage, content);
 	}

+ 7 - 4
src/main/java/com/uas/platform/b2b/service/impl/BaseInfoServiceImpl.java

@@ -58,6 +58,7 @@ import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.ui.ModelMap;
@@ -451,10 +452,12 @@ public class BaseInfoServiceImpl implements BaseInfoService {
             if (CollectionUtils.isEmpty(existedProdStatus)) {
 				ProductStatus productStatus = new ProductStatus(product.getId(), Constant.YES);
 				productStatusDao.save(productStatus);
-				product.setErpDate(new Date());
-				product.setIsPurchase(Constant.NO);
-				product.setIsSale(Constant.NO);
-                ProductUtils.updateOne(product);
+				Product newProduct = new Product();
+				BeanUtils.copyProperties(product, newProduct);
+				newProduct.setErpDate(new Date());
+				newProduct.setIsPurchase(Constant.NO);
+				newProduct.setIsSale(Constant.NO);
+                ProductUtils.updateOne(newProduct);
             }
 		}
 	}

+ 1 - 1
src/main/webapp/resources/tpl/index/purc/uploadByBatch.html

@@ -319,7 +319,7 @@ table.table.table-striped  thead {
 				总共上传物料<span class="text-inverse">{{result.total}}</span>个,上传成功<span class="text-inverse">{{result.success || 0}}</span>个
 			</div>
 			<div ng-repeat="alter in alters">
-				物料 <span class="text-inverse">{{alter}}</span> 已存在,上传失败
+				物料 <span class="text-inverse">{{alter}}</span> 已存在,已更新为待购状态
 			</div>
 			<div ng-repeat="info in infos">
 				<span class="text-inverse">{{info}}</span>