Browse Source

处理合并后的代码bug

hulh 8 years ago
parent
commit
d5b9cfa6b0

+ 2 - 3
src/main/java/com/uas/platform/b2c/prod/commodity/controller/ProductController.java

@@ -234,7 +234,7 @@ public class ProductController {
 	 * 匹配非标产品,非标上架版本
 	 * @return
 	 */
-	@RequestMapping(value = "/match/nonProduct")
+	@RequestMapping(value = "/match/nonProduct", method = RequestMethod.GET)
 	public ResultMap matchNonProduct(){
 		return productService.matchNonStandardProduct();
 	}
@@ -276,8 +276,7 @@ public class ProductController {
 	 * @return
 	 */
 	@RequestMapping(value = "/{id}", method = RequestMethod.GET)
-	public Product getProducts(@PathVariable
-										   ("id") Long id) {
+	public Product getProducts(@PathVariable("id") Long id) {
 		return productService.getProductById(id);
 	}
 

+ 27 - 27
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -610,12 +610,13 @@ public class ProductServiceImpl implements ProductService {
         final Long enUU = SystemSession.getUser().getEnterprise().getUu();
         ProductStoreStatus status = productStoreStatusDao.findByEnuu(enUU);
         if (status != null) {
-            if (status.getStatus().equals(Status.RUNNING.value())) {// 有人正在操作这张单据,不能进行操作
+            // 有人正在操作这张单据,不能进行操作
+            if (status.getStatus().equals(Status.RUNNING.value())) {
                 Date date = new Date();
                 long l = date.getTime() - status.getDate().getTime();
-                if(l > 600000) {
+                if (l > 600000) {
                     status.setStatus(Status.FINISH.value());
-                }else {
+                } else {
                     return new ResultMap(CodeType.NOT_PERMIT, "当前有人正在进行匹配操作,无法进行匹配");
                 }
             } else {
@@ -633,24 +634,22 @@ public class ProductServiceImpl implements ProductService {
 
         int total = productDao.getCountByEnuuAndStatusAndEnabled(enUU, ShortConstant.NO_SHORT, IntegerConstant.YES_SHORT);
         int success = 0;
-        int fail = 0 ;
-
-        success = (Integer) jdbcTemplate.execute(
-                new CallableStatementCreator() {
-                    public CallableStatement createCallableStatement(java.sql.Connection con) throws SQLException {
-                        String sp = "{call PRODUCT_MATCHES_TEST(?,?,?)}";
-                        CallableStatement cs = con.prepareCall(sp);
-                        cs.setLong(1, enUU);
-                        cs.setLong(2, uu);
-                        cs.registerOutParameter(3, OracleType.STYLE_INT);
-                        return cs;
-                    }
-                }, new CallableStatementCallback() {
-                    public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
-                        cs.execute();
-                        return cs.getInt(3);
-                    }
-                });
+        int fail = 0;
+
+        String sql = "/*#mycat:db_type=master*/ call PRODUCT_MATCHES_TEST(%s, %s, @out); select @out";
+        final String formatSql = String.format(sql, enUU, uu);
+        success = jdbcTemplate.execute(new StatementCallback<Integer>() {
+            @Override
+            public Integer doInStatement(Statement statement) throws SQLException, DataAccessException {
+                statement.execute(formatSql);
+                ResultSet rs = statement.getResultSet();
+                if (null != rs) {
+                    rs.next();
+                    return rs.getInt(1);
+                }
+                return 0;
+            }
+        });
         fail = total - success;
 
         status.setStatus(Status.FINISH.value());
@@ -880,8 +879,8 @@ public class ProductServiceImpl implements ProductService {
      * @param goods
      * @param historyByBatch
      */
-    private void updateBrowsingHistory(Goods goods, List<GoodsBrowsingHistory> historyByBatch){
-        for (GoodsBrowsingHistory gb : historyByBatch){
+    private void updateBrowsingHistory(Goods goods, List<GoodsBrowsingHistory> historyByBatch) {
+        for (GoodsBrowsingHistory gb : historyByBatch) {
             gb.setCode(goods.getCode());
             gb.setKindNameCn(goods.getKindNameCn());
             gb.setBrandNameCn(goods.getBrandNameCn());
@@ -893,8 +892,8 @@ public class ProductServiceImpl implements ProductService {
     /**
      * 更新GoodsHistory信息
      */
-    private void updateGoodsHistoryInfo(Goods goods, List<GoodsHistory> history){
-        for (GoodsHistory gh : history){
+    private void updateGoodsHistoryInfo(Goods goods, List<GoodsHistory> history) {
+        for (GoodsHistory gh : history) {
             gh.setCode(goods.getCode());
             gh.setUuid(goods.getUuid());
             gh.setKindNameCn(goods.getKindNameCn());
@@ -914,7 +913,7 @@ public class ProductServiceImpl implements ProductService {
      * @param goods
      * @param cartList
      */
-    private void updateCartsInfo(Goods goods, List<Cart> cartList){
+    private void updateCartsInfo(Goods goods, List<Cart> cartList) {
         for (Cart cart : cartList){
             cart.setCode(goods.getCode());
             cart.setBrName(goods.getBrandNameEn());
@@ -926,8 +925,9 @@ public class ProductServiceImpl implements ProductService {
     /**
      * 更新在售信息
      */
-    private void updateGoodsInfo(Goods goods, Product product){
+    private void updateGoodsInfo(Goods goods, Product product) {
         goods.setProductid(product.getId());
+        goods.setProdNum(product.getProdNum());
         goods.setUuid(product.getCmpUuId());
         goods.setCode(product.getPcmpcode());
         goods.setImg(product.getCmpImg());

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

@@ -932,30 +932,29 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 	@Override
 	public String publishByBatch(String batch) {
 		Enterprise enterprise = SystemSession.getUser().getEnterprise();
-		final Object [] obj = new Object[]{enterprise.getUu(), enterprise.getEnName(), batch};
-		String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @enName = '%s'; set @batch = '%s'; call RELEASE_TO_PRODUCT_TEST(@enuu, @enName, @batch, @out)";
+		final Object[] obj = new Object[]{enterprise.getUu(), enterprise.getEnName(), batch};
+		String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @enName = '%s'; set @batch = '%s'; call RELEASE_TO_PRODUCT_TEST(@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.executeUpdate(updateSql);
-				stmt.execute("select @out");
+				stmt.executeQuery(updateSql);
 				ResultSet rs = stmt.getResultSet();
 				if (null != rs) {
 					rs.next();
 					return rs.getString(1);
 				}
-				return null;
+				return "0";
 			}
 		});
-		if(!"0".equals(num)) {
+		if (!"0".equals(num)) {
 			List<Goods> goodsList = goodsDao.findByBatchid(batch);
 			Set<String> uuids = new HashSet<String>();
 			for (Goods goods : goodsList) {
-				if (goods.getUuid() != null){
+				if (goods.getUuid() != null) {
 					uuids.add(goods.getUuid());
-					goodsService.saveOrUpdatePriceInfos(goods, "NORMAL");
+//					goodsService.saveOrUpdatePriceInfos(goods, "NORMAL");
 				}
 			}
 			// TODO 之后删除