Authored by caoyan

商品池导出功能

... ... @@ -36,4 +36,7 @@ public interface UfoProductDetailsMapper {
List<ProductDetails> getProductDetailsPageList(@Param("productDetails") ProductDetails productDetails, @Param("page") PageModel pageModel);
int selectAllCountByPoolId(@Param("poolId") Integer poolId);
List<ProductDetails> selectAllByPoolId(@Param("poolId") Integer poolId);
}
... ...
... ... @@ -2,6 +2,8 @@ package com.yoho.ufo.model.goodsmanage;
import java.io.Serializable;
import com.yoho.ufo.annotation.BatchExportField;
/**
* 商品池详情中的商品信息
* @author kun.wang
... ... @@ -24,6 +26,7 @@ public class ProductDetails implements Serializable {
/**
* 商品id
*/
@BatchExportField(name = "商品编码")
private Integer productId;
/**
... ... @@ -58,6 +61,7 @@ public class ProductDetails implements Serializable {
*/
private Integer delStatus;
@BatchExportField(name = "排序值")
private Integer orderBy;
public Integer getId() {
... ...
... ... @@ -64,5 +64,17 @@
order by pool_detail.order_by desc
limit #{page.startIndex}, #{page.pageSize}
</select>
<select id="selectAllCountByPoolId" resultType="java.lang.Integer">
select count(1) from product_pool_detail
where pool_id=#{poolId}
</select>
<select id="selectAllByPoolId" parameterType="java.lang.Integer" resultMap="productDetails">
select product_id, order_by
from product_pool_detail
where pool_id=#{poolId}
order by order_by desc
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -3,21 +3,27 @@ package com.yoho.ufo.service.impl;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.error.exception.ServiceException;
import com.yoho.ufo.dal.UfoProductDetailsMapper;
import com.yoho.ufo.dal.UfoProductPoolDetailMapper;
import com.yoho.ufo.dal.UfoProductPoolMapper;
import com.yoho.ufo.exception.PlatformException;
import com.yoho.ufo.model.ChannelSkuCompareRspBo;
import com.yoho.ufo.model.goodsmanage.ProductDetails;
import com.yoho.ufo.model.goodsmanage.ProductPool;
import com.yoho.ufo.model.goodsmanage.ProductPoolDetails;
import com.yoho.ufo.service.IBusinessExportService;
import com.yoho.ufo.service.IProductPoolDetailsService;
import com.yoho.ufo.util.OrikaUtils;
import com.yohobuy.ufo.model.common.PageModel;
... ... @@ -32,7 +38,7 @@ import com.yohobuy.ufo.model.request.productpool.ProductPoolDetailsResponseBo;
* @date 2018/9/14
*/
@Service
public class ProductPoolDetailsServiceImpl implements IProductPoolDetailsService {
public class ProductPoolDetailsServiceImpl implements IProductPoolDetailsService, IBusinessExportService {
private static final Logger LOGGER = LoggerFactory.getLogger(ProductPoolDetailsServiceImpl.class);
... ... @@ -101,6 +107,32 @@ public class ProductPoolDetailsServiceImpl implements IProductPoolDetailsService
return ufoProductPoolDetailMapper.updateProductOrderBy(requestBo.getPoolId(), requestBo.getProductId(), requestBo.getOrderBy());
}
@Override
public Class getDataClass() {
return ProductDetails.class;
}
@Override
public List<? extends Object> batchExport(String confStr) {
try {
Integer poolId = null;
if(StringUtils.isNotEmpty(confStr)) {
poolId = JSONObject.parseObject(confStr, Integer.class);
}
int total = ufoProductDetailsMapper.selectAllCountByPoolId(poolId);
if (total == 0) {
throw new ServiceException(400, "没有要导出的数据");
}
return ufoProductDetailsMapper.selectAllByPoolId(poolId);
} catch (JSONException e) {
LOGGER.warn("parse confStr error: confStr {}, e {}", confStr, e);
throw new ServiceException(400, "传入数据格式错误");
} catch (com.yoho.error.exception.ServiceException e) {
LOGGER.warn("make url error params is confStr {}, e {}", confStr, e);
throw new ServiceException(e.getCode(), e.getErrorMessage());
}
}
private void checkParam(ProductPoolDetailsRequestBo requestBo) throws PlatformException{
Integer poolId = requestBo.getPoolId();
Integer productId = requestBo.getProductId();
... ...
... ... @@ -92,6 +92,7 @@
value-type="com.yoho.ufo.service.IBusinessExportService">
<entry key="couponServiceImpl" value-ref="couponServiceImpl"></entry>
<entry key="channelSkuCompareServiceImpl" value-ref="channelSkuCompareServiceImpl"/>
<entry key="productPoolDetailsServiceImpl" value-ref="productPoolDetailsServiceImpl"/>
</util:map>
</beans>
\ No newline at end of file
... ...
... ... @@ -34,6 +34,7 @@
<a id="searchAllLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">全部</a>
<a id="returnList" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">返回列表</a>
<a id="addProduct" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-add'">添加商品</a>
<a id="exportButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-add'">导出</a>
</div>
</div>
<div region="center">
... ... @@ -61,7 +62,7 @@
$(function () {
$('#returnList').linkbutton({
onClick: function () {
location.href = contextPath + "/html/commodityManage/commodityPoolManage/commodityPoolManage.html";
... ... @@ -74,6 +75,13 @@
addPage(poolId);
}
});
$("#exportButton").linkbutton({
onClick : function() {
// var params = {"poolId": poolId.toString()};
window.open(contextPath + "/batch/export.do?type=productPoolDetailsServiceImpl&queryConf=" + poolId);
}
});
$("#id").textbox({
... ...