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

Merge branch 'hotfix-0713-yuj' into feature-201818-wangcz

# Conflicts:
#	src/test/java/com/uas/platform/b2c/DesTest.java
yujia 7 лет назад
Родитель
Сommit
34cddc5b5a

+ 1 - 2
src/main/java/com/uas/platform/b2c/common/account/model/UsageLog.java

@@ -7,7 +7,6 @@ import org.codehaus.jackson.annotate.JsonIgnore;
 import org.springframework.util.StringUtils;
 
 import javax.persistence.*;
-import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.util.Date;
 
@@ -62,7 +61,7 @@ public class UsageLog extends BufferedLogable implements Serializable {
 	/**
 	 * 具体操作信息
 	 */
-	@Column(name = "log_message",length = 2000)
+	@Column(name = "log_message", columnDefinition = "TEXT")
 	private String message;
 
 	/**

+ 19 - 15
src/main/java/com/uas/platform/b2c/common/psmessage/util/JsonObjectUtil.java

@@ -9,6 +9,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.util.StringUtils;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -23,21 +24,24 @@ public class JsonObjectUtil {
      * jsonobject 转换成page
      * @return
      */
-    public static Page<Object> convertToPage(JSONObject jsonObject, Class cls) {
-//        String content  = String.valueOf(jsonObject.get("content"));
-//        if (!StringUtils.isEmpty(content)) {
-//            try {
-//                List<? extends Class> array = FastjsonUtils.fromJsonArray(content, cls.getClass());
-//                Object number = jsonObject.get("number");
-//                PageImpl<T> page = new PageImpl<T>(array);
-//            } catch (Exception e) {
-//                e.printStackTrace();
-//                return new PageImpl<?>(Collections.<T>emptyList(), new PageInfo(new PageParams(1, 10, null, null)), 0);
-//            }
-//        }
-//        return new PageImpl<T>(Collections.<T>emptyList(), new PageInfo(new PageParams(1, 10, null, null)), 0);
-        //TODO
-        return null;
+    public static <T> Page<T> convertToPage(JSONObject jsonObject, Class<T> cls) {
+        String content  = String.valueOf(jsonObject.get("content"));
+        if (!StringUtils.isEmpty(content)) {
+            try {
+                List<? extends Class> list = FastjsonUtils.fromJsonArray(content, cls.getClass());
+                List<T> listT = new ArrayList<>();
+                for (Class aClass : list) {
+                    T t = cls.cast(aClass);
+                    listT.add(t);
+                }
+                Object number = jsonObject.get("number");
+                PageImpl<T> page = new PageImpl<T>(listT);
+            } catch (Exception e) {
+                e.printStackTrace();
+                return new PageImpl<T>(Collections.<T>emptyList(), new PageInfo(new PageParams(1, 10, null, null)), 0);
+            }
+        }
+        return new PageImpl<T>(Collections.<T>emptyList(), new PageInfo(new PageParams(1, 10, null, null)), 0);
     }
 
 

+ 4 - 4
src/main/java/com/uas/platform/b2c/prod/commodity/dao/ReleaseProductByBatchDao.java

@@ -79,8 +79,8 @@ public interface ReleaseProductByBatchDao
      * @param publisherUu the publisher uu 发布人
      * @param batchid     the batchid 批次号
      */
-    @Procedure(procedureName = "PRODUCT_RELEASE_VALID_V3")
-	public void callValidProcedure(Long publisherUu, String batchid);
+    @Procedure(procedureName = "PRODUCT_RELEASE_VALID_V4")
+	void callValidProcedure(Long publisherUu, String batchid);
 
 
 	/**
@@ -89,7 +89,7 @@ public interface ReleaseProductByBatchDao
 	 * @param isPersonal 是否是个人
 	 * @param enuu 公司enuu
 	 */
-	@Procedure(procedureName = "PRODUCT_RELEASE_EXIST_VALID_V1")
+	@Procedure(procedureName = "PRODUCT_RELEASE_EXIST_VALID_V2")
 	void callReleaseExistValidProcedure(String batch, Boolean isPersonal, Long enuu);
 
 	/**
@@ -98,7 +98,7 @@ public interface ReleaseProductByBatchDao
 	 * @param batchid
 	 */
 	@Procedure(procedureName = "PRODUCT_RELEASE_VALID_V2_PCB")
-	public void callValidProcedurePcb(Long publisherUu, String batchid);
+	String callValidProcedurePcb(Long publisherUu, String batchid);
 
     /**
      * 创建时间 :2017年1月6日 下午8:25:57

+ 127 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/model/ReleaseProductByBatch.java

@@ -498,7 +498,7 @@ public class ReleaseProductByBatch implements Serializable {
 	 * 错误的信息
 	 */
 	@Column(name = "rel_errmsg", length = 4000)
-	private String errmsg;
+	private String errmsg = "";
 
 	/**
 	 * 本批次的最低人民币价格
@@ -1838,4 +1838,130 @@ public class ReleaseProductByBatch implements Serializable {
 		this.productid = productid;
 		return this;
 	}
+
+	@Override
+	public String toString() {
+		return "ReleaseProductByBatch{" +
+				"id=" + id +
+				", relbatchid='" + relbatchid + '\'' +
+				", batchCode='" + batchCode + '\'' +
+				", status=" + status +
+				", statusStr='" + statusStr + '\'' +
+				", saleMethod='" + saleMethod + '\'' +
+				", brandNameCn='" + brandNameCn + '\'' +
+				", brandNameEn='" + brandNameEn + '\'' +
+				", b2cBrandcn='" + b2cBrandcn + '\'' +
+				", b2cBranden='" + b2cBranden + '\'' +
+				", brandId=" + brandId +
+				", branduuid='" + branduuid + '\'' +
+				", code='" + code + '\'' +
+				", b2cCode='" + b2cCode + '\'' +
+				", componentUuId='" + componentUuId + '\'' +
+				", unit='" + unit + '\'' +
+				", original=" + original +
+				", reserve=" + reserve +
+				", reserveStr='" + reserveStr + '\'' +
+				", minBuyQty=" + minBuyQty +
+				", minBuyQtyStr='" + minBuyQtyStr + '\'' +
+				", qtyPrice='" + qtyPrice + '\'' +
+				", prices=" + prices +
+				", productDate='" + productDate + '\'' +
+				", createDate=" + createDate +
+				", minPackage=" + minPackage +
+				", minPackageStr='" + minPackageStr + '\'' +
+				", breakUp=" + breakUp +
+				", breakUpStr='" + breakUpStr + '\'' +
+				", packaging='" + packaging + '\'' +
+				", encapsulation='" + encapsulation + '\'' +
+				", tagstr='" + tagstr + '\'' +
+				", tag='" + tag + '\'' +
+				", selfMaxDelivery=" + selfMaxDelivery +
+				", selfMinDelivery=" + selfMinDelivery +
+				", selfMaxDeliveryStr='" + selfMaxDeliveryStr + '\'' +
+				", selfMinDeliveryStr='" + selfMinDeliveryStr + '\'' +
+				", size='" + size + '\'' +
+				", color='" + color + '\'' +
+				", thickCopper='" + thickCopper + '\'' +
+				", thick='" + thick + '\'' +
+				", remark='" + remark + '\'' +
+				", publisherName='" + publisherName + '\'' +
+				", publisherUu=" + publisherUu +
+				", publisherTel='" + publisherTel + '\'' +
+				", currency='" + currency + '\'' +
+				", sampleqty=" + sampleqty +
+				", rmbTaxRate=" + rmbTaxRate +
+				", usdTaxRate=" + usdTaxRate +
+				", returnInWeek=" + returnInWeek +
+				", releaseCode=" + releaseCode +
+				", releaseStatus='" + releaseStatus + '\'' +
+				", shipArea='" + shipArea + '\'' +
+				", rmbMinPackPrice=" + rmbMinPackPrice +
+				", usdMinPackPrice=" + usdMinPackPrice +
+				", minPackPriceStr='" + minPackPriceStr + '\'' +
+				", img='" + img + '\'' +
+				", kindName='" + kindName + '\'' +
+				", kindUuid=" + kindUuid +
+				", qty1Str='" + qty1Str + '\'' +
+				", qty2Str='" + qty2Str + '\'' +
+				", qty3Str='" + qty3Str + '\'' +
+				", price1='" + price1 + '\'' +
+				", price2='" + price2 + '\'' +
+				", price3='" + price3 + '\'' +
+				", errmsg='" + errmsg + '\'' +
+				", minPriceRMB=" + minPriceRMB +
+				", maxPriceRMB=" + maxPriceRMB +
+				", minPriceUSD=" + minPriceUSD +
+				", maxPriceUSD=" + maxPriceUSD +
+				", storeid='" + storeid + '\'' +
+				", storeName='" + storeName + '\'' +
+				", spec='" + spec + '\'' +
+				", productid=" + productid +
+				", attach='" + attach + '\'' +
+				", goodsCount=" + goodsCount +
+				'}';
+	}
+
+	/**
+	 *
+	 * @param batch 上架批次
+	 * @return 相同则true,否则false
+	 */
+	public Boolean compareSameProductTagInfo(ReleaseProductByBatch batch) {
+		if (batch != null) {
+			return StringUtilB2C.equals(batch.getB2cBranden(), this.b2cBranden) && StringUtilB2C.equals(batch.getB2cCode(), this.b2cCode) && StringUtilB2C.equals(batch.getTag(), this.tag);
+		} else {
+			return Boolean.FALSE;
+		}
+	}
+
+	/**
+	 * 六要素比较
+	 */
+
+	public Boolean compareSameProductSixEle(ReleaseProductByBatch batch) {
+		if (batch != null) {
+			Boolean result = false;
+			if (StringUtils.isEmpty(batch.getMinBuyQtyStr()) || StringUtils.isEmpty(this.getMinBuyQtyStr()) || (!StringUtilB2C.equals(batch.getMinBuyQtyStr(), this.getMinBuyQtyStr()))) {
+				return false;
+			}
+			if (StringUtils.isEmpty(batch.getProductDate()) || StringUtils.isEmpty(this.getProductDate()) || (!StringUtilB2C.equals(batch.getProductDate(), this.getProductDate()))) {
+				return false;
+			}
+			if (StringUtils.isEmpty(batch.getPackaging()) || StringUtils.isEmpty(this.getPackaging()) || (!StringUtilB2C.equals(batch.getPackaging(), this.getPackaging()))) {
+				return false;
+			}
+			if (StringUtils.isEmpty(batch.getMinPackageStr()) || StringUtils.isEmpty(this.getMinPackageStr()) || (!StringUtilB2C.equals(batch.getMinPackageStr(), this.getMinPackageStr()))) {
+				return false;
+			}
+			if (StringUtils.isEmpty(batch.getSelfMaxDeliveryStr()) || StringUtils.isEmpty(this.getSelfMaxDeliveryStr()) || (!StringUtilB2C.equals(batch.getSelfMaxDeliveryStr(), this.getSelfMaxDeliveryStr()))) {
+				return false;
+			}
+			if (StringUtils.isEmpty(batch.getSelfMinDeliveryStr()) || StringUtils.isEmpty(this.getSelfMinDeliveryStr()) || (!StringUtilB2C.equals(batch.getSelfMinDeliveryStr(), this.getSelfMinDeliveryStr()))) {
+				return false;
+			}
+			return true;
+		} else {
+			return Boolean.FALSE;
+		}
+	}
 }

+ 97 - 11
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -182,6 +182,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		Row headerRow = sheet.getRow(0);
 		int total = 0;
 		int blankNum = 0;
+		long l = System.currentTimeMillis();
 		if (headerRow != null) {
 			// 验证模板是否为商城模板
 			validateTemplate(headerRow, colNum, currency, isAPerson, isPcb);
@@ -221,15 +222,37 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				}
 			}
 		}
-
+		System.out.println("获取订单信息缺失");
+		long l1 = System.currentTimeMillis();
+		System.err.println("l1--------------l testyuj" + (l1 - l));
 		Long userUU = SystemSession.getUser().getUserUU();
 		Long enUU = SystemSession.getUser().getEnterprise().getUu();
-		List<ReleaseProductByBatch> addList = new ArrayList<>(releaseProductByBatchs.size());
-		addList.addAll(releaseProductByBatchs);
-        commonDao.save(addList, ReleaseProductByBatch.class);
+		if (!isAPerson) {
+			//1:比较品牌、型号、自定义标签是否重复,2:比较六要素是否重复
+			for(int i = releaseProductByBatchs.size() - 1; i > -1; i--) {
+				ReleaseProductByBatch releaseProductByBatch = releaseProductByBatchs.get(i);
+				for(int j = i - 1; j > 0; j--) {
+					ReleaseProductByBatch byBatch = releaseProductByBatchs.get(j);
+					if(releaseProductByBatch.compareSameProductTagInfo(byBatch)) {
+						releaseProductByBatch.setTag("");
+						releaseProductByBatch.setTagstr("");
+						if (releaseProductByBatch.compareSameProductSixEle(byBatch)) {
+							releaseProductByBatch.addErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
+							releaseProductByBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
+							releaseProductByBatch.setReleaseCode(ReleaseStatus.had_exists.value());
+						}
+					}
+				}
+			}
+		}
+		commonDao.save(releaseProductByBatchs, ReleaseProductByBatch.class);
+		long l2 = System.currentTimeMillis();
+		System.err.println("l2--------------l1 testyuj" + (l2 - l1));
         releaseProductByBatchDao.callReleaseExistValidProcedure(batch, isAPerson, enUU);
+		long l3 = System.currentTimeMillis();
+		System.err.println("l3--------------l2 testyuj" + (l3 - l2));
 		if (isAPerson) {
-			for (ReleaseProductByBatch releaseProductByBatch : addList) {
+			for (ReleaseProductByBatch releaseProductByBatch : releaseProductByBatchs) {
                 Long productid = releaseProductByBatch.getProductid();
                 if (productid != null) {
                     List<ProductPerson> productPersonList = productPersonDao.findByProductId(productid);
@@ -242,16 +265,79 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
                 }
 			}
 		}
-
+		Long l4 = 0l;
+		String strCount = "";
 		if (isPcb) {
-			releaseProductByBatchDao.callValidProcedurePcb(enUU, batch);
+			strCount = releaseProductByBatchDao.callValidProcedurePcb(enUU, batch);
 		} else {
+			// final Object[] obj = new Object[]{enUU, batch};
+//			final Object[] obj = new Object[]{enUU, batch};
+//			String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @batch = '%s'; call PRODUCT_RELEASE_VALID_V4(@enuu, @batch, @rest); select @rest";
+
+//			String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @enName = '%s'; set @batch = '%s'; call RELEASE_TO_GOODS_V3(@enuu, @enName, @batch, @out); select @out";
+//			final String updateSql = String.format(sql, obj);
+//			String num = jdbcTemplate.execute(new StatementCallback<String>() {
+//
+//				@Override
+//				public String doInStatement(Statement stmt) throws SQLException, DataAccessException {
+//					stmt.executeQuery(updateSql);
+//					ResultSet rs = stmt.getResultSet();
+//					if (null != rs) {
+//						rs.next();
+//						return rs.getString(1);
+//					}
+//					return "0-0-0";
+//				}
+//			});
+//			final Long uu = enUU;
+//			final String ba = batch;
+//			jdbcTemplate.execute(
+//					new CallableStatementCreator() {
+//						@Override
+//						public CallableStatement createCallableStatement(Connection con) throws SQLException {
+//							String storedProc = "{call PRODUCT_RELEASE_VALID_V4(?, ?)}";// 调用的sql
+//							CallableStatement cs = con.prepareCall(storedProc);
+//							cs.setLong(1, uu);// 设置输入参数的值
+//							cs.setString(2, ba);// 设置输入参数的值
+//							cs.registerOutParameter(3, Types.VARCHAR);// 注册输出参数的类型
+//							return cs;
+//						}
+//					}, new CallableStatementCallback() {
+//						@Override
+//						public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
+//							boolean exist = cs.execute();
+//							ResultSet resultSet = cs.getResultSet();
+//							if (exist) {
+//								while (resultSet.next()) {
+////                            System.out.println(resultSet.getString(1));
+//									return resultSet.getString(1);
+//								}
+//							}
+//							return "";
+//						}
+//					});
 			releaseProductByBatchDao.callValidProcedure(enUU, batch);
-		}
+			l4 = System.currentTimeMillis();
+			System.err.println("l4--------------l3 testyuj" + (l4 - l3));
+		}
+		Integer filter = 0, failure = 0, success = 0;
+//		if (!StringUtilB2C.isEmpty(strCount)) {
+//			String[] split = strCount.split(SplitChar.HYPHEN);
+//			filter = Integer.valueOf(split[0]);
+//			failure = Integer.valueOf(split[1]);
+//			success = Integer.valueOf(split[2]);
+//		}
 
-		Integer filter = releaseProductByBatchDao.getCountOfImportFail(userUU, batch, failCode);
-		Integer failure = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.failure.value());
-		Integer success = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.success.value());
+		filter = releaseProductByBatchDao.getCountOfImportFail(userUU, batch, failCode);
+		long l5 = System.currentTimeMillis();
+		System.out.print("l5-l4---------testyuj" + (l5-l4));
+		failure = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.failure.value());
+		long l6 = System.currentTimeMillis();
+		System.out.print("l6-l5---------testyuj" + (l6-l5));
+		success = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.success.value());
+		long l7 = System.currentTimeMillis();
+		System.out.print("l7-l6---------testyuj" + (l7-l6));
+		modelMap.put("total", total);
 		modelMap.put("total", total);
 		modelMap.put("success", success);
 		modelMap.put("failure", failure);

+ 2 - 1
src/main/java/com/uas/platform/b2c/prod/product/brand/modal/BrandMap.java

@@ -14,7 +14,8 @@ import java.util.List;
  * @author hulh
  */
 @Entity
-@Table(name = "product$brand_map")
+@Table(name = "product$brand_map", indexes = {@Index(name = "enuu_cn_index", columnList = "map_enuu, map_name_cd_cn"),
+@Index(name = "enuu_en_index", columnList = "map_enuu, map_name_cd_en")})
 public class BrandMap {
 
 	private final static List<String> typeCn = Arrays.asList("代理商", "经销商", "原厂商", "寄售商");

+ 1 - 1
src/main/resources/dev/jdbc.properties

@@ -1,5 +1,5 @@
 jdbc.driverClassName=com.mysql.jdbc.Driver
-jdbc.url=7e5ef205e2ff4ca4ac98c9f833880ec6e2fe1a4579ebe694e129681326fc2cb1b5fe058042985e2f72b57c8be4fa3e1544065eabf2ab94ad017d02162675aa969997adc7fd7bd04c0eb8bcc3a1733fe6a27f40bcf87efef4566f5872030efe79859a9abb7cbad9c1aa1ae7c2bb1cb23007adc91d94a9369cec407809597189c5
+jdbc.url=7e5ef205e2ff4ca4ac98c9f833880ec6e2fe1a4579ebe6946c98747cbe3897b66b5c4cb4985aa8f22aa1cbab4bc6bfe12e09403e6255e2fda2f113bc366bbfc5d9a2cf99c34ce47ba6bd752a9bf5f04c3faf83464996ab6930a84c7d3b9f62d759eb691bc8cd1fe3225f6e7efa5ab3a583896b06178e65c56c3c4e448a0ae4fe
 jdbc.username=474e1aeadeeecac5
 jdbc.password=48981af937f010627b96e886a0d38aad
 jdbc.initialSize=1

+ 1 - 1
src/main/resources/test/jdbc.properties

@@ -1,5 +1,5 @@
 jdbc.driverClassName=com.mysql.jdbc.Driver
-jdbc.url=7e5ef205e2ff4ca4ac98c9f833880ec6e2fe1a4579ebe694e129681326fc2cb1b5fe058042985e2f72b57c8be4fa3e1544065eabf2ab94ad017d02162675aa969997adc7fd7bd04c0eb8bcc3a1733fe6a27f40bcf87efef4566f5872030efe79859a9abb7cbad9c1aa1ae7c2bb1cb23007adc91d94a9369cec407809597189c5
+jdbc.url=7e5ef205e2ff4ca4ac98c9f833880ec6e2fe1a4579ebe6946c98747cbe3897b66b5c4cb4985aa8f22aa1cbab4bc6bfe12e09403e6255e2fda2f113bc366bbfc5d9a2cf99c34ce47ba6bd752a9bf5f04c3faf83464996ab6930a84c7d3b9f62d759eb691bc8cd1fe3225f6e7efa5ab3a583896b06178e65c56c3c4e448a0ae4fe
 jdbc.username=474e1aeadeeecac5
 jdbc.password=48981af937f010627b96e886a0d38aad
 jdbc.initialSize=1