Browse Source

品类查询增加注释

hejq 7 years ago
parent
commit
8f41fe52e6

+ 23 - 14
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/GoodsServiceImpl.java

@@ -4138,7 +4138,10 @@ public class GoodsServiceImpl implements GoodsService {
      */
     @Override
     public com.uas.sso.support.Page<KindHierarchicalCount> getKindProductsCount(Pageable pageable, Date startTime, Date endTime) {
+        // 查询一段时间内类目数量,按类目分组查询统计数量
         StringBuffer sql = new StringBuffer("select pr_kind as thirdKind, pr_kindid as kindId, count(1) as count from products where pr_kind is not null ");
+
+        // 根据物料创建时间筛选
         if (null != startTime) {
             sql.append(" and pr_create_time >= '").append(new java.sql.Date(startTime.getTime())).append("' ");
         }
@@ -4146,30 +4149,34 @@ public class GoodsServiceImpl implements GoodsService {
             sql.append(" and pr_create_time < '").append(new java.sql.Date(endTime.getTime() + IntegerConstant.ONE_DAY_MILLISECONDS)).append("' ");
         }
         sql.append("group by pr_kind, pr_kindid");
+
+        // 统计数量
         StringBuffer countSql = new StringBuffer("select count(1) from (").append(sql).append(") as a");
         Integer count = commonDao.queryForObject(countSql.toString(), Integer.class);
+
         // 分页参数
         Integer offset = (pageable.getPageNumber() - 1) * pageable.getPageSize();
         sql.append(" limit ? offset ?");
         List<KindHierarchicalCount> kindList = commonDao.query(sql.toString(), KindHierarchicalCount.class, pageable.getPageSize(), offset);
+
+        // 根据父级类目id一层层判断是否存在
         if (CollectionUtils.isNotEmpty(kindList)) {
-            kindList.forEach(kind -> {
-                if (null != kind.getKindId()) {
-                    KindInfo kindInfo = kindInfoDao.findOne(kind.getKindId());
-                    if (null != kindInfo && null != kindInfo.getParentid() && kindInfo.getParentid() != 0) {
-                        KindInfo parentKind = kindInfoDao.findOne(kindInfo.getParentid());
-                        if (null != parentKind) {
-                            kind.setSecondKind(parentKind.getNameCn());
-                            if (null != parentKind.getParentid() && parentKind.getParentid() != 0) {
-                                KindInfo firstKind = kindInfoDao.findOne(parentKind.getParentid());
-                                if (null != firstKind) {
-                                    kind.setFirstKind(firstKind.getNameCn());
+            kindList.stream().filter(kind -> null != kind.getKindId())
+                    .forEach(kind -> {
+                        KindInfo kindInfo = kindInfoDao.findOne(kind.getKindId());
+                        if (null != kindInfo && null != kindInfo.getParentid() && 0 != kindInfo.getParentid()) {
+                            KindInfo parentKind = kindInfoDao.findOne(kindInfo.getParentid());
+                            if (null != parentKind) {
+                                kind.setSecondKind(parentKind.getNameCn());
+                                if (null != parentKind.getParentid() && 0 != parentKind.getParentid()) {
+                                    KindInfo firstKind = kindInfoDao.findOne(parentKind.getParentid());
+                                    if (null != firstKind) {
+                                        kind.setFirstKind(firstKind.getNameCn());
+                                    }
                                 }
                             }
                         }
-                    }
-                }
-            });
+                    });
         }
         return new com.uas.sso.support.Page<>(pageable.getPageNumber(), pageable.getPageSize(), kindList, count);
     }
@@ -4218,10 +4225,12 @@ public class GoodsServiceImpl implements GoodsService {
          * 线程序号
          */
         Integer i;
+
         /**
          * 过滤条件
          */
         GoodsFilter goodsFilter;
+
         /**
          * 分页大小
          */