|
|
@@ -7,6 +7,8 @@ import com.uas.platform.b2c.advertise.ad.service.RecommendProductService;
|
|
|
import com.uas.platform.b2c.common.account.dao.UserDao;
|
|
|
import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
import com.uas.platform.b2c.common.account.service.EnterpriseService;
|
|
|
+import com.uas.platform.b2c.common.search.rpc.service.SearchService;
|
|
|
+import com.uas.platform.b2c.common.search.util.SPage;
|
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
|
import com.uas.platform.b2c.core.constant.IntegerConstant;
|
|
|
import com.uas.platform.b2c.core.constant.ShortConstant;
|
|
|
@@ -17,9 +19,43 @@ import com.uas.platform.b2c.core.utils.FastjsonUtils;
|
|
|
import com.uas.platform.b2c.core.utils.NumberUtil;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.StringConstant;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.*;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.*;
|
|
|
-import com.uas.platform.b2c.prod.commodity.service.*;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.GoodsHistoryDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.MatchModelDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductDetailDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductMatchResultDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductModifyHistoryDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductPersonDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductPrivateDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductReplaceDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductStandardPutOnInfoDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductStoreStatusDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.StockInOutHistDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.V_ProductPersonDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.V_ProductPrivateDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.Goods;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.GoodsHistory;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.GoodsQtyPrice;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.MatchModel;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.Product;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.ProductDetail;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.ProductMatchResult;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.ProductModifyHistory;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.ProductPerson;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.ProductPrivate;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.ProductReplace;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.ProductStandardPutOnInfo;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.ProductStoreStatus;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.StockInOutHist;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.UASBatchPutOnProperty;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.V_ProductPerson;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.GoodsHistoryService;
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.GoodsService;
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.ProductService;
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.UASBatchPutOnPropertyService;
|
|
|
import com.uas.platform.b2c.prod.commodity.type.ProductConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.util.GoodsUtil;
|
|
|
import com.uas.platform.b2c.prod.product.brand.dao.BrandDao;
|
|
|
@@ -81,7 +117,15 @@ import java.lang.reflect.Field;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
import java.sql.Statement;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
/**
|
|
|
@@ -203,6 +247,9 @@ public class ProductServiceImpl implements ProductService {
|
|
|
@Autowired
|
|
|
private UserDao userDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SearchService searchService;
|
|
|
+
|
|
|
@Value("#{sys.productServiceIp}")
|
|
|
private String productServiceIp;
|
|
|
|
|
|
@@ -210,59 +257,64 @@ public class ProductServiceImpl implements ProductService {
|
|
|
|
|
|
@Override
|
|
|
public Page<V_ProductPrivate> getAllProducts(final PageInfo page, String keyword, String type, Long userUU) {
|
|
|
- Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- page.expression(PredicateUtils.eq("enUU", enuu, true));
|
|
|
- page.expression(PredicateUtils.isNotNull("pcmpcode"));
|
|
|
- page.expression(PredicateUtils.isNotNull("pbranden"));
|
|
|
+ Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+// page.expression(PredicateUtils.eq("enUU", enuu, true));
|
|
|
+// page.expression(PredicateUtils.isNotNull("pcmpcode"));
|
|
|
+// page.expression(PredicateUtils.isNotNull("pbranden"));
|
|
|
if (StringUtils.isEmpty(type)) {
|
|
|
type = "nStandard";
|
|
|
}
|
|
|
- if (type.contains("standard")) {
|
|
|
- page.filter("standard", (short)1);
|
|
|
- page.filter("b2cEnabled", (short) 1);
|
|
|
- } else if (type.contains("nStandard")) {
|
|
|
- page.filter("standard", (short)0);
|
|
|
- page.filter("b2cEnabled", (short) 1);
|
|
|
- } else if (type.contains("all")) {
|
|
|
- SimpleExpression[] arr = new SimpleExpression[2];
|
|
|
- arr[0] = PredicateUtils.eq("b2cEnabled", (short) 1, false);
|
|
|
- arr[1] = PredicateUtils.eq("standard", (short) 1, false);
|
|
|
- LogicalExpression logicalExpression = PredicateUtils.and(arr);
|
|
|
- SimpleExpression standard = PredicateUtils.eq("standard", (short) 0, false);
|
|
|
- page.orExpression(standard);
|
|
|
- page.orExpression(logicalExpression);
|
|
|
- page.sorting("standard", Sort.Direction.DESC);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.hasText(keyword)) {
|
|
|
- SimpleExpression code = PredicateUtils.like("prodNum", keyword, true);
|
|
|
- SimpleExpression kind = PredicateUtils.like("kind", keyword, true);
|
|
|
- SimpleExpression brandEn = PredicateUtils.like("pbranden", keyword, true);
|
|
|
- SimpleExpression cmpCode = PredicateUtils.like("pcmpcode", keyword, true);
|
|
|
- SimpleExpression[] expressions4 = new SimpleExpression[]{code, kind, brandEn, cmpCode};
|
|
|
- LogicalExpression logicalExpression4 = PredicateUtils.or(expressions4);
|
|
|
- page.expression(logicalExpression4);
|
|
|
- }
|
|
|
-
|
|
|
- if (!StringUtils.isEmpty(userUU)) {
|
|
|
- // 先查询userUU在当前企业 有哪些物料
|
|
|
- List<Long> ids = productPersonDao.findIdByEnuuAndUserUU(enuu, userUU);
|
|
|
-
|
|
|
- if (CollectionUtils.isEmpty(ids)) {
|
|
|
- return null;
|
|
|
- } else {
|
|
|
- page.expression(PredicateUtils.in("id", ids, true));
|
|
|
- }
|
|
|
+// if (type.contains("standard")) {
|
|
|
+// SPage<Long> ids = searchService.get
|
|
|
+// } else if (type.contains("nonStandard")) {
|
|
|
+// page.filter("standard", (short)0);
|
|
|
+// page.filter("b2cEnabled", (short) 1);
|
|
|
+// } else if (type.contains("all")) {
|
|
|
+// SimpleExpression[] arr = new SimpleExpression[2];
|
|
|
+// arr[0] = PredicateUtils.eq("b2cEnabled", (short) 1, false);
|
|
|
+// arr[1] = PredicateUtils.eq("standard", (short) 1, false);
|
|
|
+// LogicalExpression logicalExpression = PredicateUtils.and(arr);
|
|
|
+// SimpleExpression standard = PredicateUtils.eq("standard", (short) 0, false);
|
|
|
+// page.orExpression(standard);
|
|
|
+// page.orExpression(logicalExpression);
|
|
|
+// page.sorting("standard", Sort.Direction.DESC);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (StringUtils.hasText(keyword)) {
|
|
|
+// SimpleExpression code = PredicateUtils.like("prodNum", keyword, true);
|
|
|
+// SimpleExpression kind = PredicateUtils.like("kind", keyword, true);
|
|
|
+// SimpleExpression brandEn = PredicateUtils.like("pbranden", keyword, true);
|
|
|
+// SimpleExpression cmpCode = PredicateUtils.like("pcmpcode", keyword, true);
|
|
|
+// SimpleExpression[] expressions4 = new SimpleExpression[]{code, kind, brandEn, cmpCode};
|
|
|
+// LogicalExpression logicalExpression4 = PredicateUtils.or(expressions4);
|
|
|
+// page.expression(logicalExpression4);
|
|
|
+// }
|
|
|
+
|
|
|
+ // TODO 搜索用户个人物料搜索暂时未实现,之后完善
|
|
|
+// if (!StringUtils.isEmpty(userUU)) {
|
|
|
+// // 先查询userUU在当前企业 有哪些物料
|
|
|
+// List<Long> ids = productPersonDao.findIdByEnuuAndUserUU(enuu, userUU);
|
|
|
+//
|
|
|
+// if (CollectionUtils.isEmpty(ids)) {
|
|
|
+// return null;
|
|
|
+// } else {
|
|
|
+// page.expression(PredicateUtils.in("id", ids, true));
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ SPage<Long> ids = searchService.getProducts(enUU, keyword, page.getPageNumber(), page.getPageSize(), type);
|
|
|
+ if (null == ids) {
|
|
|
+ return null;
|
|
|
}
|
|
|
-
|
|
|
- Page<V_ProductPrivate> productPage = v_productPrivateDao.findAll(new Specification<V_ProductPrivate>() {
|
|
|
- @Override
|
|
|
- public Predicate toPredicate(Root<V_ProductPrivate> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
- query.where(page.getPredicates(root, query, cb));
|
|
|
- return null;
|
|
|
- }
|
|
|
- }, page);
|
|
|
- List<V_ProductPrivate> productList = productPage.getContent();
|
|
|
+// Page<V_ProductPrivate> productPage = v_productPrivateDao.findAll(new Specification<V_ProductPrivate>() {
|
|
|
+// @Override
|
|
|
+// public Predicate toPredicate(Root<V_ProductPrivate> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
+// query.where(page.getPredicates(root, query, cb));
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+// }, page);
|
|
|
+ List<Long> idList = ids.getContent();
|
|
|
+ List<V_ProductPrivate> productList = v_productPrivateDao.findAll(idList);
|
|
|
for (V_ProductPrivate product : productList) {
|
|
|
product.setAddProductPerson(false);
|
|
|
if ("ERP".equals(product.getSourceApp())) {
|
|
|
@@ -279,7 +331,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
}
|
|
|
userUU = SystemSession.getUser().getUserUU();
|
|
|
- List<Long> productIds = productPersonDao.findIdByEnuuAndUserUU(enuu, userUU);
|
|
|
+ List<Long> productIds = productPersonDao.findIdByEnuuAndUserUU(enUU, userUU);
|
|
|
for (V_ProductPrivate v_productPrivate : productList) {
|
|
|
for (Long productId : productIds) {
|
|
|
if (v_productPrivate.getId().equals(productId)) {
|
|
|
@@ -287,7 +339,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return new PageImpl<V_ProductPrivate>(productList, page, productPage.getTotalElements());
|
|
|
+ return new PageImpl<V_ProductPrivate>(productList, page, ids.getTotalElement());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -492,53 +544,58 @@ public class ProductServiceImpl implements ProductService {
|
|
|
Product product = productDao.findOne(id);
|
|
|
if (product == null)
|
|
|
throw new IllegalOperatorException("选择的产品不存在,请重新选择");
|
|
|
- //查看是否存在正常未取消的订单
|
|
|
- List<Goods> goodses = goodsDao.findByProductId(product.getId());
|
|
|
- Boolean isExistOrder = false;
|
|
|
- String codes = OrderStatus.UNAVAILABLE.getCodes() + "-" + Status.TOBECONFIRMED.value();
|
|
|
- for (Goods goods : goodses) {
|
|
|
- List<OrderDetail> orderList = orderDetailService.findOrderDetailByBatchCode(goods.getBatchCode());
|
|
|
- for (OrderDetail detail : orderList) {
|
|
|
- Order order = detail.getOrder();
|
|
|
- int status = order.getStatus() == null ? detail.getStatus() : order.getStatus();
|
|
|
- if (codes.indexOf(String.valueOf(status)) < 0) {
|
|
|
- // 区分是否是假单,or_orderids 不为空
|
|
|
- if (StringUtils.isEmpty(order.getOrderids())) {
|
|
|
- isExistOrder = true;
|
|
|
- break;
|
|
|
- }
|
|
|
+ //查看是否存在正常未取消的订单
|
|
|
+ List<Goods> goodses = goodsDao.findByProductId(product.getId());
|
|
|
+ Boolean isExistOrder = false;
|
|
|
+ String codes = OrderStatus.UNAVAILABLE.getCodes() + "-" + Status.TOBECONFIRMED.value();
|
|
|
+ for (Goods goods : goodses) {
|
|
|
+ List<OrderDetail> orderList = orderDetailService.findOrderDetailByBatchCode(goods.getBatchCode());
|
|
|
+ for (OrderDetail detail : orderList) {
|
|
|
+ Order order = detail.getOrder();
|
|
|
+ int status = order.getStatus() == null ? detail.getStatus() : order.getStatus();
|
|
|
+ if (codes.indexOf(String.valueOf(status)) < 0) {
|
|
|
+ // 区分是否是假单,or_orderids 不为空
|
|
|
+ if (StringUtils.isEmpty(order.getOrderids())) {
|
|
|
+ isExistOrder = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- if (isExistOrder) {
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
- if (!isExistOrder) {
|
|
|
- //是否被个人物料库收录
|
|
|
- int count = productPersonDao.countByProductId(id);
|
|
|
- if ( count > 0 ){
|
|
|
- throw new IllegalOperatorException("该产品已被个人物料库收录,不能删除");
|
|
|
- }
|
|
|
- //删除外键关联的匹配结果列表,不然删除product失败
|
|
|
- Set<ProductMatchResult> productMatchResultSet = product.getMatchresults();
|
|
|
- productMatchResultDao.delete(productMatchResultSet);
|
|
|
- if (CollectionUtils.isNotEmpty(goodses)) {
|
|
|
- goodsService.deleteGoods(goodses);
|
|
|
- }
|
|
|
- ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
|
|
|
- if (productPrivate == null) {
|
|
|
- productPrivate = new ProductPrivate();
|
|
|
- productPrivate.setPrId(product.getId());
|
|
|
- }
|
|
|
- productPrivate.setB2cEnabled(IntegerConstant.NO_SHORT);
|
|
|
- productPrivateDao.save(productPrivate);
|
|
|
- product.setB2cEnabled(IntegerConstant.NO_SHORT);
|
|
|
- //productDao.delete(id); 不允许删除
|
|
|
- } else {
|
|
|
- throw new
|
|
|
- IllegalOperatorException("该产品中存在已下单的在售产品信息,不能删除");
|
|
|
+ if (isExistOrder) {
|
|
|
+ break;
|
|
|
}
|
|
|
+ }
|
|
|
+ if (!isExistOrder) {
|
|
|
+ //是否被个人物料库收录
|
|
|
+ int count = productPersonDao.countByProductId(id);
|
|
|
+ if ( count > 0 ){
|
|
|
+ throw new IllegalOperatorException("该产品已被个人物料库收录,不能删除");
|
|
|
+ }
|
|
|
+ //删除外键关联的匹配结果列表,不然删除product失败
|
|
|
+ Set<ProductMatchResult> productMatchResultSet = product.getMatchresults();
|
|
|
+ productMatchResultDao.delete(productMatchResultSet);
|
|
|
+ if (CollectionUtils.isNotEmpty(goodses)) {
|
|
|
+ goodsService.deleteGoods(goodses);
|
|
|
+ }
|
|
|
+ ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
|
|
|
+ if (productPrivate == null) {
|
|
|
+ productPrivate = new ProductPrivate();
|
|
|
+ productPrivate.setPrId(product.getId());
|
|
|
+ }
|
|
|
+ productPrivate.setB2cEnabled(IntegerConstant.NO_SHORT);
|
|
|
+ productPrivateDao.save(productPrivate);
|
|
|
+ product.setB2cEnabled(IntegerConstant.NO_SHORT);
|
|
|
+ // 设置物料不可用时,为了更新索引,也需要更新物料资料
|
|
|
+ product.setIsSale(Constant.NO);
|
|
|
+ product.setIsPurchase(Constant.NO);
|
|
|
+ product.setErpDate(new Date());
|
|
|
+ productDao.save(product);
|
|
|
+ //productDao.delete(id); 不允许删除
|
|
|
+ } else {
|
|
|
+ throw new
|
|
|
+ IllegalOperatorException("该产品中存在已下单的在售产品信息,不能删除");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|