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

新增品牌产品数和品类产品数导出功能

hejq 7 лет назад
Родитель
Сommit
7afe1179ed

+ 72 - 4
src/main/java/com/uas/platform/b2c/prod/commodity/controller/GoodsController.java

@@ -851,14 +851,14 @@ public class GoodsController {
      * @return ModelAndView
      */
 	@RequestMapping(value = "/background/download", method = RequestMethod.GET)
-        public ModelAndView exportProductsStandard(GoodsFilter goodsFilter, HttpServletRequest request,
-                                               @RequestParam(required = false, value = "isAjax", defaultValue = "false") Boolean isAjax) {
+    public ModelAndView exportProductsStandard(GoodsFilter goodsFilter, HttpServletRequest request, PageParams params,
+                                           @RequestParam(required = false, value = "isAjax", defaultValue = "false") Boolean isAjax) {
         HttpSession session = request.getSession();
-	    ModelAndView modelAndView = AjaxUtil.checkIsAjax(session, isAjax);
+        ModelAndView modelAndView = AjaxUtil.checkIsAjax(session, isAjax);
         if (!modelAndView.isEmpty()) {
             return modelAndView;
         }
-	    PageInfo info = new PageInfo(1, JxlsExcelView.MAX_SIZE);
+        PageInfo info = new PageInfo(params);
         Page<Goods> productsGoods = goodsService.getPageDataOfBackground(info, goodsFilter);
         if (CollectionUtils.isNotEmpty(productsGoods.getContent())) {
             logger.info("产品导出结果 products: " + productsGoods.getContent().size());
@@ -900,6 +900,40 @@ public class GoodsController {
         return goodsService.getBrandProductsCount(info, startTime, endTime);
     }
 
+    /**
+     * 通过传入参数导出品牌数量
+     *
+     * @param startTime 开始时间
+     * @param endTime 截止时间
+     * @param request 请求
+     * @param isAjax 是否ajax
+     * @return ModelAndView
+     */
+    @RequestMapping(value = "/brandProductsCount/export", method = RequestMethod.GET)
+    public ModelAndView exportBrandProductsCount(@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime, HttpServletRequest request,
+                                                @RequestParam(required = false, value = "isAjax", defaultValue = "false") Boolean isAjax) {
+        HttpSession session = request.getSession();
+        ModelAndView modelAndView = AjaxUtil.checkIsAjax(session, isAjax);
+        if (!modelAndView.isEmpty()) {
+            return modelAndView;
+        }
+        PageInfo info = new PageInfo(1, JxlsExcelView.MAX_SIZE);
+        com.uas.sso.support.Page<BrandCount> brandCountPage = goodsService.getBrandProductsCount(info, startTime, endTime);
+        if (CollectionUtils.isNotEmpty(brandCountPage.getContent())) {
+            logger.info("品牌数量导出结果 size: " + brandCountPage.getContent().size());
+        } else {
+            logger.info("品牌数量导出结果 size: 0");
+        }
+        FastDateFormat dateFormat = FastDateFormat.getInstance("yyyy年MM月dd日 HH:mm");
+        modelAndView.addObject("dateFormat", dateFormat);
+        modelAndView.addObject("data", brandCountPage.getContent());
+        modelAndView.addObject("goodsService", goodsService);
+        modelAndView.addObject("title", "品牌数量列表");
+        modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/trade/brandCount", "优软商城--品牌数量列表"));
+        session.setAttribute("loading", false);
+        return modelAndView;
+    }
+
     /**
      * 通过分页参数获取类目数量
      *
@@ -914,4 +948,38 @@ public class GoodsController {
         PageInfo info = new PageInfo(params);
         return goodsService.getKindProductsCount(info, startTime, endTime);
     }
+
+    /**
+     * 通过传入参数导出品类产品数
+     *
+     * @param startTime 开始时间
+     * @param endTime 截止时间
+     * @param request 请求
+     * @param isAjax 是否ajax
+     * @return ModelAndView
+     */
+    @RequestMapping(value = "/kindProductsCount/export", method = RequestMethod.GET)
+    public ModelAndView exportKindProductsCount(@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime, HttpServletRequest request,
+                                               @RequestParam(required = false, value = "isAjax", defaultValue = "false") Boolean isAjax) {
+        HttpSession session = request.getSession();
+        ModelAndView modelAndView = AjaxUtil.checkIsAjax(session, isAjax);
+        if (!modelAndView.isEmpty()) {
+            return modelAndView;
+        }
+        PageInfo info = new PageInfo(1, JxlsExcelView.MAX_SIZE);
+        com.uas.sso.support.Page<KindHierarchicalCount> kindProductsCount = goodsService.getKindProductsCount(info, startTime, endTime);
+        if (CollectionUtils.isNotEmpty(kindProductsCount.getContent())) {
+            logger.info("品类产品数导出结果 size: " + kindProductsCount.getContent().size());
+        } else {
+            logger.info("品类产品数导出结果 size: 0");
+        }
+        FastDateFormat dateFormat = FastDateFormat.getInstance("yyyy年MM月dd日 HH:mm");
+        modelAndView.addObject("dateFormat", dateFormat);
+        modelAndView.addObject("data", kindProductsCount.getContent());
+        modelAndView.addObject("goodsService", goodsService);
+        modelAndView.addObject("title", "品类产品数列表");
+        modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/trade/kindHierarchical", "优软商城--品类产品数列表"));
+        session.setAttribute("loading", false);
+        return modelAndView;
+    }
 }

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

@@ -3630,10 +3630,14 @@ public class GoodsServiceImpl implements GoodsService {
 
 	private void convertPageInfo(PageInfo info, GoodsFilter goodsFilter) {
         if (!StringUtils.isEmpty(goodsFilter.getStartTime())) {
-            info.expression(PredicateUtils.gte("createdDate", new java.sql.Date(goodsFilter.getStartTime()), true));
+            java.sql.Date startDate = new java.sql.Date(goodsFilter.getStartTime());
+            info.expression(PredicateUtils.gte("createdDate", startDate, true));
         }
         if (!StringUtils.isEmpty(goodsFilter.getEndTime())) {
-            info.expression(PredicateUtils.lte("createdDate", new java.sql.Date(goodsFilter.getEndTime()), true));
+            // 截止日期是到当天23:59:59,java.sql.Date精确到天,这里采用加一天小于的方法设置截止日期判断
+            Integer addend = 60 * 60 * 24 * 1000;
+            java.sql.Date endDate = new java.sql.Date(goodsFilter.getEndTime() + addend);
+            info.expression(PredicateUtils.lt("createdDate", endDate, true));
         }
 		if (!StringUtils.isEmpty(goodsFilter.getCode())) {
 			info.filter("code", goodsFilter.getCode());
@@ -3721,15 +3725,6 @@ public class GoodsServiceImpl implements GoodsService {
         if (goodsFilter.getSaleNum() != null && 603 == goodsFilter.getSaleNum()) {
             info.expression(PredicateUtils.eq("reserve", 0, true));
         }
-        if (goodsFilter.getEndTime() != null) {
-            Integer addend = 60 * 60 * 24 * 1000;
-            java.sql.Date endDate = new java.sql.Date(goodsFilter.getEndTime() + addend);
-            info.expression(PredicateUtils.lt("createdDate", endDate, true));
-        }
-        if (goodsFilter.getStartTime() != null) {
-            java.sql.Date startDate = new java.sql.Date(goodsFilter.getEndTime());
-            info.expression(PredicateUtils.gte("createdDate", startDate, true));
-        }
 	}
 
     @Override

BIN
src/main/resources/jxls-tpl/trade/brandCount.xls


BIN
src/main/resources/jxls-tpl/trade/kindHierarchical.xls


+ 1 - 1
src/main/webapp/resources/js/admin/controllers/product/brandProductsCountCtrl.js

@@ -24,7 +24,7 @@ define(['app/app'], function(app) {
 
             // 导出
             $scope.exportXls = function () {
-                window.location.href = 'store-service/export?startTime='+ $scope.startFormatDate + '&endTime=' + $scope.endFormatDate
+                window.location.href = '/trade/goods/brandProductsCount/export?startTime='+ $scope.startFormatDate + '&endTime=' + $scope.endFormatDate;
             }
         }])
 })

+ 1 - 1
src/main/webapp/resources/js/admin/controllers/product/categoryNumberCtrl.js

@@ -24,7 +24,7 @@ define(['app/app'], function(app) {
 
             // 导出
             $scope.exportXls = function () {
-                window.location.href = 'store-service/export?startTime='+ $scope.startFormatDate + '&endTime=' + $scope.endFormatDate
+                window.location.href = '/trade/goods/kindProductsCount/export?startTime='+ $scope.startFormatDate + '&endTime=' + $scope.endFormatDate;
             }
         }])
 })

+ 44 - 5
src/main/webapp/resources/js/admin/controllers/product/productManageCtrl.js

@@ -143,8 +143,8 @@ define(['app/app'], function(app) {
             counts: [],
             getData: function ($defer, params) {
                 var param = BaseService.parseParams(params.url());
-                param.startTime = $scope.startFormatDate;
-                param.endTime = $scope.endFormatDate;
+                $scope.goodsFilter.startTime = $scope.startFormatDate;
+                $scope.goodsFilter.endTime = $scope.endFormatDate;
                 Goods.loadGoodsList(param, $scope.goodsFilter, function (data) {
                     $scope.totalCount = data.totalElements;
                     $scope.goodsList = data.content;
@@ -305,8 +305,47 @@ define(['app/app'], function(app) {
         };
 
         // 产品导出事件
-        $scope.exportClick = function (data) {
-            var modalInstance = $modal.open({
+        $scope.exportClick = function () {
+            // 拼装链接
+            var url = '/trade/goods/background/download?startTime=' + $scope.startDate.getTime() + "&endTime=" + $scope.endDate.getTime();
+            if (angular.isDefined($scope.goodsFilter.kindUuid)) {
+                url = url + "&kindUuid=" + $scope.goodsFilter.kindUuid;
+            }
+            if (angular.isDefined($scope.goodsFilter.code)) {
+                url = url + "&code=" + $scope.goodsFilter.code
+            }
+            if (angular.isDefined($scope.goodsFilter.brand)) {
+                url = url + "&brand=" + $scope.goodsFilter.brand
+            }
+            if (angular.isDefined($scope.goodsFilter.store)) {
+                url = url + "&store=" + $scope.goodsFilter.store
+            }
+            if (angular.isDefined($scope.goodsFilter.saleStatus)) {
+                url = url + "&saleStatus=" + $scope.goodsFilter.saleStatus
+            }
+            if (angular.isDefined($scope.goodsFilter.saleNum)) {
+                url = url + "&saleNum=" + $scope.goodsFilter.saleNum
+            }
+            if (angular.isDefined($scope.goodsFilter.currency)) {
+                url = url + "&currency=" + $scope.goodsFilter.currency
+            }
+            if (angular.isDefined($scope.goodsFilter.saleSelf)) {
+                url = url + "&saleSelf=" + $scope.goodsFilter.saleSelf
+            }
+            if (angular.isDefined($scope.goodsFilter.bredakUp)) {
+                url = url + "&breakUp=" + $scope.goodsFilter.bredakUp
+            }
+            if (angular.isDefined($scope.goodsFilter.standard)) {
+                url = url + "&standard=" + $scope.goodsFilter.standard
+            }
+            if (angular.isDefined($scope.goodsFilter.audited)) {
+                url = url + "&audited=" + $scope.goodsFilter.audited
+            }
+            if (angular.isDefined($scope.goodsFilter.haveImg)) {
+                url = url + "&haveImg=" + $scope.goodsFilter.haveImg;
+            }
+            window.open(url);
+            /*var modalInstance = $modal.open({
                 templateUrl: 'static/view/admin/modal/manage/exportProduct_modal.html',
                 controller: 'exportProductCtrl',
                 resolve: {
@@ -319,7 +358,7 @@ define(['app/app'], function(app) {
 
             }, function () {
 
-            })
+            })*/
         };
 
         // 更多信息事件

+ 2 - 2
src/main/webapp/resources/view/admin/product/productManage.html

@@ -208,8 +208,8 @@
             <span class="item-title">更多操作:</span>
             <span>
                 <a ng-click="batchDown()">批量下架</a>
-                <a title="此功能没有开放">产品导出</a>
-                <!--<a ng-click="exportClick()">产品导出</a>-->
+                <!--<a title="此功能没有开放">产品导出</a>-->
+                <a ng-click="exportClick()">产品导出</a>
             </span>
             <span style="float: right;font-size: 14px">共<span style="color: red;" ng-bind="totalCount">3424</span>个产品</span>
         </div>