|
|
@@ -13,7 +13,6 @@ import com.uas.platform.b2c.core.support.log.ErpB2cBufferedLogger;
|
|
|
import com.uas.platform.b2c.external.erp.order.util.ModelConverter;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.GoodsHistoryDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.GoodsHistory;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.Product;
|
|
|
import com.uas.platform.b2c.trade.order.dao.OrderDao;
|
|
|
import com.uas.platform.b2c.trade.order.dao.PurchaseDao;
|
|
|
@@ -25,6 +24,7 @@ import com.uas.platform.core.model.Status;
|
|
|
import com.uas.platform.core.persistence.criteria.LogicalExpression;
|
|
|
import com.uas.platform.core.persistence.criteria.PredicateUtils;
|
|
|
import com.uas.platform.core.persistence.criteria.SimpleExpression;
|
|
|
+import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
@@ -33,7 +33,9 @@ import javax.persistence.criteria.CriteriaBuilder;
|
|
|
import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
public class OrderServiceImpl implements OrderService {
|
|
|
@@ -59,6 +61,8 @@ public class OrderServiceImpl implements OrderService {
|
|
|
@Autowired
|
|
|
private EnterpriseDao enterpriseDao;
|
|
|
|
|
|
+ private final Logger loggerInfo = Logger.getLogger(getClass());
|
|
|
+
|
|
|
private static final ErpB2cBufferedLogger logger = BufferedLoggerManager.getLogger(ErpB2cBufferedLogger.class);
|
|
|
|
|
|
@Override
|
|
|
@@ -96,8 +100,13 @@ public class OrderServiceImpl implements OrderService {
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
List<Order> orders = new ArrayList<Order>();
|
|
|
+ String sourceapp = "ERP";
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ loggerInfo.info(String.format(" erp总共下载订单数 %s", orders.size()));
|
|
|
for (Purchase purchase : purcs) {
|
|
|
+ Date startDate = new Date();
|
|
|
boolean codeExists = false;
|
|
|
Order order = ModelConverter.getOrder(purchase);
|
|
|
UserBaseInfo buyer = userBaseInfoDao.findUserByUserUU(purchase.getBuyeruu());
|
|
|
@@ -109,20 +118,19 @@ public class OrderServiceImpl implements OrderService {
|
|
|
if (enterprise != null) {// 设置买方企业信息
|
|
|
order.setBuyerEn(com.uas.platform.b2c.external.erp.common.util.ModelConverter.convert(enterprise));
|
|
|
}
|
|
|
-
|
|
|
for (OrderDetail orderDetail : order.getDetails()) {
|
|
|
- List<GoodsHistory> goodsHistorys = goodsHistoryDao.findByBatchCode(orderDetail.getBatchCode());// 获取上架历史信息
|
|
|
- if (!CollectionUtils.isEmpty(goodsHistorys)) {
|
|
|
- orderDetail.setPublisheruu(goodsHistorys.get(0).getPublisherUU());// 添加发布人uu
|
|
|
- List<Product> products = productDao.findByEnUUAndCmpUuId(SystemSession.getUser().getEnterprise().getUu(), goodsHistorys.get(0).getUuid());//获取物料信息
|
|
|
- if (!CollectionUtils.isEmpty(products)) {
|
|
|
- orderDetail.setCode(products.get(0).getProdNum());// 设置物料编号,有物料编号才回传到ERP
|
|
|
- codeExists = true;
|
|
|
- }
|
|
|
+ List<Product> products = productDao.findByEnUUAndCmpUuIdAndSourceApp(SystemSession.getUser().getEnterprise().getUu(), orderDetail.getUuid(), sourceapp);//获取物料信息
|
|
|
+ if (!CollectionUtils.isEmpty(products)) {
|
|
|
+ orderDetail.setCode(products.get(0).getProdNum());// 设置物料编号,有物料编号才回传到ERP
|
|
|
+ codeExists = true;
|
|
|
}
|
|
|
}
|
|
|
- if (codeExists)
|
|
|
+ if (codeExists) {
|
|
|
orders.add(order);
|
|
|
+ }
|
|
|
+
|
|
|
+ Date endDate = new Date();
|
|
|
+ loggerInfo.info(String.format("处理历时" + (endDate.getTime() - startDate.getTime()) + "毫秒"));
|
|
|
}
|
|
|
return orders;
|
|
|
}
|