소스 검색

销售订单的卖方企业可能为空

sunyj 8 년 전
부모
커밋
9d1843964f

+ 6 - 2
search-console/src/main/java/com/uas/search/console/util/DocumentToObjectUtils.java

@@ -227,8 +227,12 @@ public class DocumentToObjectUtils {
 		buyerEnterprise.setEnName(document.get(SearchConstants.ORDER_BUYERENNAME_FIELD));
 		order.setBuyerEnterprise(buyerEnterprise);
 		EnterpriseSimpleInfo sellerEnterprise = new EnterpriseSimpleInfo();
-		sellerEnterprise.setUu(Long.valueOf(document.get(SearchConstants.ORDER_SELLERENUU_FIELD)));
-		sellerEnterprise.setEnName(document.get(SearchConstants.ORDER_SELLERENNAME_FIELD));
+		if (document.get(SearchConstants.ORDER_SELLERENUU_FIELD) != null) {
+			sellerEnterprise.setUu(Long.valueOf(document.get(SearchConstants.ORDER_SELLERENUU_FIELD)));
+		}
+		if (document.get(SearchConstants.ORDER_SELLERENNAME_FIELD) != null) {
+			sellerEnterprise.setEnName(document.get(SearchConstants.ORDER_SELLERENNAME_FIELD));
+		}
 		order.setSellerEnterprise(sellerEnterprise);
 		Date createtime = new Date(Long.valueOf(document.get(SearchConstants.CREATETIME_FIELD)));
 		order.setCreatetime(createtime);

+ 9 - 7
search-console/src/main/java/com/uas/search/console/util/ObjectToDocumentUtils.java

@@ -280,9 +280,7 @@ public class ObjectToDocumentUtils {
 		if (order == null || order.getId() == null || StringUtils.isEmpty(order.getCode()) || order.getBuyeruu() == null
 				|| StringUtils.isEmpty(order.getBuyername()) || order.getBuyerEnterprise() == null
 				|| order.getBuyerEnterprise().getUu() == null
-				|| StringUtils.isEmpty(order.getBuyerEnterprise().getEnName()) || order.getSellerEnterprise() == null
-				|| order.getSellerEnterprise().getUu() == null
-				|| StringUtils.isEmpty(order.getSellerEnterprise().getEnName()) || order.getCreatetime() == null
+				|| StringUtils.isEmpty(order.getBuyerEnterprise().getEnName()) || order.getCreatetime() == null
 				|| order.getStatus() == null) {
 			return null;
 		}
@@ -298,10 +296,14 @@ public class ObjectToDocumentUtils {
 				String.valueOf(order.getBuyerEnterprise().getUu()), Store.YES));
 		document.add(new StringField(SearchConstants.ORDER_BUYERENNAME_FIELD, order.getBuyerEnterprise().getEnName(),
 				Store.YES));
-		document.add(new StringField(SearchConstants.ORDER_SELLERENUU_FIELD,
-				String.valueOf(order.getSellerEnterprise().getUu()), Store.YES));
-		document.add(new StringField(SearchConstants.ORDER_SELLERENNAME_FIELD, order.getSellerEnterprise().getEnName(),
-				Store.YES));
+		if (order.getSellerEnterprise().getUu() != null) {
+			document.add(new StringField(SearchConstants.ORDER_SELLERENUU_FIELD,
+					String.valueOf(order.getSellerEnterprise().getUu()), Store.YES));
+		}
+		if (order.getSellerEnterprise().getEnName() != null) {
+			document.add(new StringField(SearchConstants.ORDER_SELLERENNAME_FIELD,
+					order.getSellerEnterprise().getEnName(), Store.YES));
+		}
 		document.add(new LongField(SearchConstants.CREATETIME_FIELD, order.getCreatetime().getTime(), Store.YES));
 		document.add(new StringField(SearchConstants.ORDER_STATUS_FIELD, String.valueOf(order.getStatus()), Store.YES));
 		// 明细以json的格式存储