|
|
@@ -8,6 +8,7 @@ import com.uas.platform.b2c.common.account.service.EnterpriseService;
|
|
|
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.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.utils.FastjsonUtils;
|
|
|
import com.uas.platform.b2c.core.utils.NumberUtil;
|
|
|
@@ -228,22 +229,22 @@ public class ProductServiceImpl implements ProductService {
|
|
|
page.filter("enUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
page.filter("b2cEnabled", com.uas.platform.b2c.prod.commodity.constant.IntegerConstant.YES_INT);
|
|
|
//产品部要求导出是非标和标准全部导出,先注释这条代码
|
|
|
-// if(StringUtils.isEmpty(type)) {
|
|
|
-// type = "all";
|
|
|
-// }
|
|
|
-// if(type.contains("standard")) {
|
|
|
-// page.filter("standard", (short)1);
|
|
|
-// }else if(type.contains("nStandard")){
|
|
|
-// page.filter("standard", (short)0);
|
|
|
-// }
|
|
|
-// if(StringUtils.hasText(keyword)) {
|
|
|
-// SimpleExpression code = PredicateUtils.like("kind", keyword, true);
|
|
|
-// SimpleExpression brandEn = PredicateUtils.like("pbranden", keyword, true);
|
|
|
-// SimpleExpression cmpCode = PredicateUtils.like("pcmpcode", keyword, true);
|
|
|
-// SimpleExpression[] expressions2 = new SimpleExpression[] {code, brandEn, cmpCode};
|
|
|
-// LogicalExpression logicalExpression2 = PredicateUtils.or(expressions2);
|
|
|
-// page.expression(logicalExpression2);
|
|
|
-// }
|
|
|
+ if (StringUtils.isEmpty(type)) {
|
|
|
+ type = "all";
|
|
|
+ }
|
|
|
+ if (type.contains("standard")) {
|
|
|
+ page.filter("standard", (short)1);
|
|
|
+ } else if (type.contains("nStandard")) {
|
|
|
+ page.filter("standard", (short)0);
|
|
|
+ }
|
|
|
+ if (StringUtils.hasText(keyword)) {
|
|
|
+ SimpleExpression code = PredicateUtils.like("kind", keyword, true);
|
|
|
+ SimpleExpression brandEn = PredicateUtils.like("pbranden", keyword, true);
|
|
|
+ SimpleExpression cmpCode = PredicateUtils.like("pcmpcode", keyword, true);
|
|
|
+ SimpleExpression[] expressions2 = new SimpleExpression[] {code, brandEn, cmpCode};
|
|
|
+ LogicalExpression logicalExpression2 = PredicateUtils.or(expressions2);
|
|
|
+ page.expression(logicalExpression2);
|
|
|
+ }
|
|
|
products = productDao.findAll(new Specification<Product>() {
|
|
|
@Override
|
|
|
public Predicate toPredicate(Root<Product> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
@@ -265,18 +266,45 @@ public class ProductServiceImpl implements ProductService {
|
|
|
return o2.getStandard().compareTo(o1.getStandard());
|
|
|
}
|
|
|
});
|
|
|
- List<Goods> goodses = new ArrayList<>();
|
|
|
- for (Product product : products) {
|
|
|
- System.out.println(product.getId() + " -" + product.getStandard());
|
|
|
- List<Goods> goodses1 = goodsDao.findByProductIdOrderByGoodsId(product.getId());
|
|
|
- if(goodses1.size() > 0) {
|
|
|
- goodses.addAll(goodses1);
|
|
|
- }else {
|
|
|
+
|
|
|
+ return exportGoodsByProduct(products);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将获取的product转化为goods信息导出
|
|
|
+ * @param productList 产品列表
|
|
|
+ * @return List<Goods>
|
|
|
+ */
|
|
|
+ private List<Goods> exportGoodsByProduct(List<Product> productList) {
|
|
|
+ List<Goods> resultList = new ArrayList<>();
|
|
|
+ for (Product product : productList) {
|
|
|
+ List<Goods> goodsList = goodsDao.findByProductIdOrderByGoodsId(product.getId());
|
|
|
+ if (!CollectionUtils.isEmpty(goodsList)) {
|
|
|
+ resultList.addAll(goodsList);
|
|
|
+ } else {
|
|
|
Goods g = Goods.productConvertGoods(product);
|
|
|
- goodses.add(g);
|
|
|
+ resultList.add(g);
|
|
|
}
|
|
|
}
|
|
|
- return goodses;
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Goods> getSelectedProducts(String idList) {
|
|
|
+ String[] idArray = idList.split(SplitChar.COMMA);
|
|
|
+ List<Long> longList = new ArrayList<>();
|
|
|
+ for (String id : idArray) {
|
|
|
+ longList.add(Long.valueOf(id));
|
|
|
+ }
|
|
|
+ List<Product> productList = productDao.findProductInId(longList);
|
|
|
+ //先按照id降序排列
|
|
|
+ Collections.sort(productList, new Comparator<Product>() {
|
|
|
+ @Override
|
|
|
+ public int compare(Product o1, Product o2) {
|
|
|
+ return (o2.getId().compareTo(o1.getId()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return exportGoodsByProduct(productList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -294,13 +322,12 @@ public class ProductServiceImpl implements ProductService {
|
|
|
for (OrderDetail detail : orderList) {
|
|
|
Order order = detail.getOrder();
|
|
|
int status = order.getStatus() == null ? detail.getStatus() : order.getStatus();
|
|
|
- if (codes.indexOf(String.valueOf(status)) < 0) {
|
|
|
+ if (!codes.contains(String.valueOf(status))) {
|
|
|
// 区分是否是假单,or_orderids 不为空
|
|
|
if (StringUtils.isEmpty(order.getOrderids())) {
|
|
|
isExistOrder = true;
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
if (isExistOrder) {
|
|
|
@@ -314,8 +341,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
goodsService.deleteGoods(goodses);
|
|
|
productDao.delete(id);
|
|
|
} else {
|
|
|
- throw new
|
|
|
- IllegalOperatorException("该产品中存在已下单的在售产品信息,不能删除");
|
|
|
+ throw new IllegalOperatorException("该产品中存在已下单的在售产品信息,不能删除");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -331,9 +357,9 @@ public class ProductServiceImpl implements ProductService {
|
|
|
Integer fail = 0;
|
|
|
Integer success = 0;
|
|
|
Long uu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- if(ProductConstant.STANDARD.equals(type)) {
|
|
|
+ if (ProductConstant.STANDARD.equals(type)) {
|
|
|
standard = IntegerConstant.YES_SHORT;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
standard = IntegerConstant.NO_SHORT;
|
|
|
}
|
|
|
List<Product> products = productDao.findProductByEnuuAndStandard(uu, standard);
|
|
|
@@ -349,7 +375,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
for (OrderDetail detail : orderList) {
|
|
|
Order order = detail.getOrder();
|
|
|
Integer status = order.getStatus() == null ? detail.getStatus() : order.getStatus();
|
|
|
- if(codes.indexOf(String.valueOf(status)) < 0) {
|
|
|
+ if (!codes.contains(String.valueOf(status))) {
|
|
|
//防止虚拟单据
|
|
|
if (StringUtils.isEmpty(order.getOrderids())) {
|
|
|
isExistOrder = true;
|
|
|
@@ -358,12 +384,12 @@ public class ProductServiceImpl implements ProductService {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- if(isExistOrder) {
|
|
|
+ if (isExistOrder) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if(!isExistOrder) {
|
|
|
- //删除外键关联的匹配结果列表,不然删除product失败
|
|
|
+ if (!isExistOrder) {
|
|
|
+ // 删除外键关联的匹配结果列表,不然删除product失败
|
|
|
Set<ProductMatchResult> productMatchResultSet = product.getMatchresults();
|
|
|
productMatchResultDao.delete(productMatchResultSet);
|
|
|
goodsService.deleteGoods(goodses);
|
|
|
@@ -372,7 +398,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
uuids.add(product.getCmpUuId());
|
|
|
}
|
|
|
success++;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
fail++;
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -382,17 +408,17 @@ public class ProductServiceImpl implements ProductService {
|
|
|
|
|
|
Integer status = CodeType.OK.code();
|
|
|
String message = "";
|
|
|
- if(success != 0) {
|
|
|
+ if (success != 0) {
|
|
|
message += "成功删除" + success + "条";
|
|
|
}
|
|
|
- if(fail != 0) {
|
|
|
+ if (fail != 0) {
|
|
|
if(success != 0) {
|
|
|
message += ",";
|
|
|
}
|
|
|
message += "删除失败" + fail + "条,原因:该产品可能已经被其他单据引用,无法删除";
|
|
|
}
|
|
|
- //如果是全部都不能删除,才能设置失败的状态码
|
|
|
- if((products.size() != 0) && (products.size() == fail.intValue())) {
|
|
|
+ // 如果是全部都不能删除,才能设置失败的状态码
|
|
|
+ if ((products.size() != 0) && (products.size() == fail)) {
|
|
|
status = CodeType.ERROR_STATE.code();
|
|
|
}
|
|
|
for (String uuid : uuids) {
|