hulh 8 лет назад
Родитель
Сommit
8ab928e67a

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

@@ -725,6 +725,7 @@ public class ProductServiceImpl implements ProductService {
      */
     @Override
     public ResultMap matchNonStandardProduct() {
+        Map<String, Object> map = new HashMap<>();
         final Long uu = SystemSession.getUser().getUserUU();
         final Long enUU = SystemSession.getUser().getEnterprise().getUu();
         ProductStoreStatus status = productStoreStatusDao.findByEnuu(enUU);
@@ -751,16 +752,25 @@ public class ProductServiceImpl implements ProductService {
             status = productStoreStatusDao.save(storeStatus);
         }
 
-//        int total = productDao.getCountByEnuuAndStatusAndEnabled(enUU, ShortConstant.NO_SHORT, IntegerConstant.YES_SHORT);
-        int total = productDao.getCountByEnuuAndStatus(enUU, ShortConstant.NO_SHORT);
+        int total = productDao.getCountByEnuuAndStatusAndEnabled(enUU, ShortConstant.NO_SHORT, IntegerConstant.YES_SHORT);
         int success = 0;
         int fail = 0;
-        Map<String, Long> queryMap = new HashMap<>();
-        queryMap.put("enUU", enUU);
-        String successUrl = productServiceIp + "/product/match/nonProduct";
-        String result = restTemplate.postForEntity(successUrl, queryMap, String.class).getBody();
-        ModelMap map = FastjsonUtils.fromJson(result, ModelMap.class);
-        fail = total - (int) map.get("success");
+
+        String sql = "/*#mycat:db_type=master*/ call PRODUCT_MATCHES_V1(%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());
         productStoreStatusDao.save(status);