Authored by caoyan

商品池导出功能

@@ -36,4 +36,7 @@ public interface UfoProductDetailsMapper { @@ -36,4 +36,7 @@ public interface UfoProductDetailsMapper {
36 36
37 List<ProductDetails> getProductDetailsPageList(@Param("productDetails") ProductDetails productDetails, @Param("page") PageModel pageModel); 37 List<ProductDetails> getProductDetailsPageList(@Param("productDetails") ProductDetails productDetails, @Param("page") PageModel pageModel);
38 38
  39 + int selectAllCountByPoolId(@Param("poolId") Integer poolId);
  40 +
  41 + List<ProductDetails> selectAllByPoolId(@Param("poolId") Integer poolId);
39 } 42 }
@@ -2,6 +2,8 @@ package com.yoho.ufo.model.goodsmanage; @@ -2,6 +2,8 @@ package com.yoho.ufo.model.goodsmanage;
2 2
3 import java.io.Serializable; 3 import java.io.Serializable;
4 4
  5 +import com.yoho.ufo.annotation.BatchExportField;
  6 +
5 /** 7 /**
6 * 商品池详情中的商品信息 8 * 商品池详情中的商品信息
7 * @author kun.wang 9 * @author kun.wang
@@ -24,6 +26,7 @@ public class ProductDetails implements Serializable { @@ -24,6 +26,7 @@ public class ProductDetails implements Serializable {
24 /** 26 /**
25 * 商品id 27 * 商品id
26 */ 28 */
  29 + @BatchExportField(name = "商品编码")
27 private Integer productId; 30 private Integer productId;
28 31
29 /** 32 /**
@@ -58,6 +61,7 @@ public class ProductDetails implements Serializable { @@ -58,6 +61,7 @@ public class ProductDetails implements Serializable {
58 */ 61 */
59 private Integer delStatus; 62 private Integer delStatus;
60 63
  64 + @BatchExportField(name = "排序值")
61 private Integer orderBy; 65 private Integer orderBy;
62 66
63 public Integer getId() { 67 public Integer getId() {
@@ -64,5 +64,17 @@ @@ -64,5 +64,17 @@
64 order by pool_detail.order_by desc 64 order by pool_detail.order_by desc
65 limit #{page.startIndex}, #{page.pageSize} 65 limit #{page.startIndex}, #{page.pageSize}
66 </select> 66 </select>
  67 +
  68 + <select id="selectAllCountByPoolId" resultType="java.lang.Integer">
  69 + select count(1) from product_pool_detail
  70 + where pool_id=#{poolId}
  71 + </select>
  72 +
  73 + <select id="selectAllByPoolId" parameterType="java.lang.Integer" resultMap="productDetails">
  74 + select product_id, order_by
  75 + from product_pool_detail
  76 + where pool_id=#{poolId}
  77 + order by order_by desc
  78 + </select>
67 79
68 </mapper> 80 </mapper>
@@ -3,21 +3,27 @@ package com.yoho.ufo.service.impl; @@ -3,21 +3,27 @@ package com.yoho.ufo.service.impl;
3 import java.util.List; 3 import java.util.List;
4 4
5 import org.apache.commons.collections.CollectionUtils; 5 import org.apache.commons.collections.CollectionUtils;
  6 +import org.apache.commons.lang3.StringUtils;
6 import org.slf4j.Logger; 7 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory; 8 import org.slf4j.LoggerFactory;
8 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.stereotype.Service; 10 import org.springframework.stereotype.Service;
10 11
  12 +import com.alibaba.fastjson.JSONException;
  13 +import com.alibaba.fastjson.JSONObject;
11 import com.google.common.collect.Lists; 14 import com.google.common.collect.Lists;
12 import com.google.common.collect.Sets; 15 import com.google.common.collect.Sets;
13 import com.yoho.core.common.utils.DateUtil; 16 import com.yoho.core.common.utils.DateUtil;
  17 +import com.yoho.error.exception.ServiceException;
14 import com.yoho.ufo.dal.UfoProductDetailsMapper; 18 import com.yoho.ufo.dal.UfoProductDetailsMapper;
15 import com.yoho.ufo.dal.UfoProductPoolDetailMapper; 19 import com.yoho.ufo.dal.UfoProductPoolDetailMapper;
16 import com.yoho.ufo.dal.UfoProductPoolMapper; 20 import com.yoho.ufo.dal.UfoProductPoolMapper;
17 import com.yoho.ufo.exception.PlatformException; 21 import com.yoho.ufo.exception.PlatformException;
  22 +import com.yoho.ufo.model.ChannelSkuCompareRspBo;
18 import com.yoho.ufo.model.goodsmanage.ProductDetails; 23 import com.yoho.ufo.model.goodsmanage.ProductDetails;
19 import com.yoho.ufo.model.goodsmanage.ProductPool; 24 import com.yoho.ufo.model.goodsmanage.ProductPool;
20 import com.yoho.ufo.model.goodsmanage.ProductPoolDetails; 25 import com.yoho.ufo.model.goodsmanage.ProductPoolDetails;
  26 +import com.yoho.ufo.service.IBusinessExportService;
21 import com.yoho.ufo.service.IProductPoolDetailsService; 27 import com.yoho.ufo.service.IProductPoolDetailsService;
22 import com.yoho.ufo.util.OrikaUtils; 28 import com.yoho.ufo.util.OrikaUtils;
23 import com.yohobuy.ufo.model.common.PageModel; 29 import com.yohobuy.ufo.model.common.PageModel;
@@ -32,7 +38,7 @@ import com.yohobuy.ufo.model.request.productpool.ProductPoolDetailsResponseBo; @@ -32,7 +38,7 @@ import com.yohobuy.ufo.model.request.productpool.ProductPoolDetailsResponseBo;
32 * @date 2018/9/14 38 * @date 2018/9/14
33 */ 39 */
34 @Service 40 @Service
35 -public class ProductPoolDetailsServiceImpl implements IProductPoolDetailsService { 41 +public class ProductPoolDetailsServiceImpl implements IProductPoolDetailsService, IBusinessExportService {
36 42
37 private static final Logger LOGGER = LoggerFactory.getLogger(ProductPoolDetailsServiceImpl.class); 43 private static final Logger LOGGER = LoggerFactory.getLogger(ProductPoolDetailsServiceImpl.class);
38 44
@@ -101,6 +107,32 @@ public class ProductPoolDetailsServiceImpl implements IProductPoolDetailsService @@ -101,6 +107,32 @@ public class ProductPoolDetailsServiceImpl implements IProductPoolDetailsService
101 return ufoProductPoolDetailMapper.updateProductOrderBy(requestBo.getPoolId(), requestBo.getProductId(), requestBo.getOrderBy()); 107 return ufoProductPoolDetailMapper.updateProductOrderBy(requestBo.getPoolId(), requestBo.getProductId(), requestBo.getOrderBy());
102 } 108 }
103 109
  110 + @Override
  111 + public Class getDataClass() {
  112 + return ProductDetails.class;
  113 + }
  114 +
  115 + @Override
  116 + public List<? extends Object> batchExport(String confStr) {
  117 + try {
  118 + Integer poolId = null;
  119 + if(StringUtils.isNotEmpty(confStr)) {
  120 + poolId = JSONObject.parseObject(confStr, Integer.class);
  121 + }
  122 + int total = ufoProductDetailsMapper.selectAllCountByPoolId(poolId);
  123 + if (total == 0) {
  124 + throw new ServiceException(400, "没有要导出的数据");
  125 + }
  126 + return ufoProductDetailsMapper.selectAllByPoolId(poolId);
  127 + } catch (JSONException e) {
  128 + LOGGER.warn("parse confStr error: confStr {}, e {}", confStr, e);
  129 + throw new ServiceException(400, "传入数据格式错误");
  130 + } catch (com.yoho.error.exception.ServiceException e) {
  131 + LOGGER.warn("make url error params is confStr {}, e {}", confStr, e);
  132 + throw new ServiceException(e.getCode(), e.getErrorMessage());
  133 + }
  134 + }
  135 +
104 private void checkParam(ProductPoolDetailsRequestBo requestBo) throws PlatformException{ 136 private void checkParam(ProductPoolDetailsRequestBo requestBo) throws PlatformException{
105 Integer poolId = requestBo.getPoolId(); 137 Integer poolId = requestBo.getPoolId();
106 Integer productId = requestBo.getProductId(); 138 Integer productId = requestBo.getProductId();
@@ -92,6 +92,7 @@ @@ -92,6 +92,7 @@
92 value-type="com.yoho.ufo.service.IBusinessExportService"> 92 value-type="com.yoho.ufo.service.IBusinessExportService">
93 <entry key="couponServiceImpl" value-ref="couponServiceImpl"></entry> 93 <entry key="couponServiceImpl" value-ref="couponServiceImpl"></entry>
94 <entry key="channelSkuCompareServiceImpl" value-ref="channelSkuCompareServiceImpl"/> 94 <entry key="channelSkuCompareServiceImpl" value-ref="channelSkuCompareServiceImpl"/>
  95 + <entry key="productPoolDetailsServiceImpl" value-ref="productPoolDetailsServiceImpl"/>
95 </util:map> 96 </util:map>
96 97
97 </beans> 98 </beans>
@@ -34,6 +34,7 @@ @@ -34,6 +34,7 @@
34 <a id="searchAllLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">全部</a> 34 <a id="searchAllLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">全部</a>
35 <a id="returnList" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">返回列表</a> 35 <a id="returnList" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">返回列表</a>
36 <a id="addProduct" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-add'">添加商品</a> 36 <a id="addProduct" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-add'">添加商品</a>
  37 + <a id="exportButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-add'">导出</a>
37 </div> 38 </div>
38 </div> 39 </div>
39 <div region="center"> 40 <div region="center">
@@ -61,7 +62,7 @@ @@ -61,7 +62,7 @@
61 62
62 63
63 $(function () { 64 $(function () {
64 - 65 +
65 $('#returnList').linkbutton({ 66 $('#returnList').linkbutton({
66 onClick: function () { 67 onClick: function () {
67 location.href = contextPath + "/html/commodityManage/commodityPoolManage/commodityPoolManage.html"; 68 location.href = contextPath + "/html/commodityManage/commodityPoolManage/commodityPoolManage.html";
@@ -74,6 +75,13 @@ @@ -74,6 +75,13 @@
74 addPage(poolId); 75 addPage(poolId);
75 } 76 }
76 }); 77 });
  78 +
  79 + $("#exportButton").linkbutton({
  80 + onClick : function() {
  81 + // var params = {"poolId": poolId.toString()};
  82 + window.open(contextPath + "/batch/export.do?type=productPoolDetailsServiceImpl&queryConf=" + poolId);
  83 + }
  84 + });
77 85
78 86
79 $("#id").textbox({ 87 $("#id").textbox({