Browse Source

修改适用公有域

hulh 8 years ago
parent
commit
e84afd98a8

+ 2 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/dao/ProductDao.java

@@ -54,7 +54,8 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
      * @param standard the standard 标准状态
      * @return count by enuu and status
      */
-    @Query(value = "select count(1) from products where pr_enuu =:enuu and pr_standard =:standard and pr_b2cenabled =:enabled", nativeQuery = true)
+    @Query(value = "select p.* from products p left join product$private pp on pp.pr_id = p.pr_id where " +
+            "p.pr_enuu=:enuu and p.pr_standard = :standard and pp.pr_b2cenabled = :enabled", nativeQuery = true)
     Integer getCountByEnuuAndStatusAndEnabled(@Param("enuu") Long enuu, @Param("standard") Short standard, @Param("enabled") Integer enabled);
 
     /**

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

@@ -61,6 +61,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.StatementCallback;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.ui.ModelMap;
 import org.springframework.util.StringUtils;
 import org.springframework.web.client.RestTemplate;
 
@@ -96,6 +97,9 @@ public class ProductServiceImpl implements ProductService {
     @Autowired
     private JdbcTemplate jdbcTemplate;
 
+    @Autowired
+    private RestTemplate restTemplate;
+
     @Autowired
     private ProductStoreStatusDao productStoreStatusDao;
 
@@ -699,8 +703,7 @@ public class ProductServiceImpl implements ProductService {
      * @return
      */
     @Override
-    public ResultMap matchNonStandardProduct(){
-        Map<String, Object> map = new HashMap<>();
+    public ResultMap matchNonStandardProduct() {
         final Long uu = SystemSession.getUser().getUserUU();
         final Long enUU = SystemSession.getUser().getEnterprise().getUu();
         ProductStoreStatus status = productStoreStatusDao.findByEnuu(enUU);
@@ -727,25 +730,16 @@ public class ProductServiceImpl implements ProductService {
             status = productStoreStatusDao.save(storeStatus);
         }
 
-        int total = productDao.getCountByEnuuAndStatusAndEnabled(enUU, ShortConstant.NO_SHORT, IntegerConstant.YES_SHORT);
+//        int total = productDao.getCountByEnuuAndStatusAndEnabled(enUU, ShortConstant.NO_SHORT, IntegerConstant.YES_SHORT);
+        int total = productDao.getCountByEnuuAndStatus(enUU, ShortConstant.NO_SHORT);
         int success = 0;
         int fail = 0;
-
-        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;
+        Map<String, Long> queryMap = new HashMap<>();
+        queryMap.put("enUU", enUU);
+        String successUrl = "http://192.168.253.129:8099/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");
 
         status.setStatus(Status.FINISH.value());
         productStoreStatusDao.save(status);

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/product/brand/api/BrandController.java

@@ -262,7 +262,7 @@ public class BrandController {
 	 * @throws UnsupportedEncodingException
 	 */
 	@RequestMapping(value = "/byName/brand", method = RequestMethod.GET)
-	public BrandInfo getBrandInfoByName(String name) throws UnsupportedEncodingException{
+	public BrandInfo getBrandInfoByName(String name) throws UnsupportedEncodingException {
 		name = URLDecoder.decode(name, "utf-8");
 		return brandService.findByName(name, name);
 	}