1
0
فهرست منبع

Merge branch 'master' of hyq/kmall-pt into master

黄亚琴 6 سال پیش
والد
کامیت
efbad6bca1
36فایلهای تغییر یافته به همراه1867 افزوده شده و 113 حذف شده
  1. 40 2
      kmall-admin/src/main/java/com/kmall/admin/controller/GoodsController.java
  2. 1 1
      kmall-admin/src/main/java/com/kmall/admin/controller/SysOssController.java
  3. 5 1
      kmall-admin/src/main/java/com/kmall/admin/dao/BrandDao.java
  4. 4 0
      kmall-admin/src/main/java/com/kmall/admin/dao/CategoryDao.java
  5. 3 0
      kmall-admin/src/main/java/com/kmall/admin/dao/FreightDao.java
  6. 3 0
      kmall-admin/src/main/java/com/kmall/admin/dao/GoodsDao.java
  7. 3 0
      kmall-admin/src/main/java/com/kmall/admin/dao/GoodsGalleryDao.java
  8. 4 1
      kmall-admin/src/main/java/com/kmall/admin/dao/SupplierDao.java
  9. 4 1
      kmall-admin/src/main/java/com/kmall/admin/dao/SysCusNationCodeDao.java
  10. 4 1
      kmall-admin/src/main/java/com/kmall/admin/dao/SysCusUnitCodeDao.java
  11. 464 0
      kmall-admin/src/main/java/com/kmall/admin/dto/GoodsDto.java
  12. 53 50
      kmall-admin/src/main/java/com/kmall/admin/entity/GoodsEntity.java
  13. 6 11
      kmall-admin/src/main/java/com/kmall/admin/entity/SupplierEntity.java
  14. 3 2
      kmall-admin/src/main/java/com/kmall/admin/service/GoodsService.java
  15. 291 17
      kmall-admin/src/main/java/com/kmall/admin/service/impl/GoodsServiceImpl.java
  16. 15 8
      kmall-admin/src/main/java/com/kmall/admin/service/impl/ProductStoreRelaServiceImpl.java
  17. 29 0
      kmall-admin/src/main/resources/XmlTemplate/GeneralGoodsDtoList.xml
  18. 38 0
      kmall-admin/src/main/resources/XmlTemplate/GoodsDtoList.xml
  19. 18 0
      kmall-admin/src/main/resources/mybatis/mapper/BrandDao.xml
  20. 21 0
      kmall-admin/src/main/resources/mybatis/mapper/CategoryDao.xml
  21. 12 0
      kmall-admin/src/main/resources/mybatis/mapper/FreightDao.xml
  22. 11 0
      kmall-admin/src/main/resources/mybatis/mapper/GoodsDao.xml
  23. 11 0
      kmall-admin/src/main/resources/mybatis/mapper/GoodsGalleryDao.xml
  24. 19 6
      kmall-admin/src/main/resources/mybatis/mapper/SupplierDao.xml
  25. 18 0
      kmall-admin/src/main/resources/mybatis/mapper/SysCusNationCodeDao.xml
  26. 15 0
      kmall-admin/src/main/resources/mybatis/mapper/SysCusUnitCodeDao.xml
  27. BIN
      kmall-admin/src/main/webapp/WEB-INF/page/shop/file/general_goods_export_yyyy_mm_dd_v1.0.0.xls
  28. BIN
      kmall-admin/src/main/webapp/WEB-INF/page/shop/file/goods_export_yyyy_mm_dd_v1.0.0.xls
  29. 30 6
      kmall-admin/src/main/webapp/WEB-INF/page/shop/goods.html
  30. 2 2
      kmall-admin/src/main/webapp/WEB-INF/page/shop/supplier.html
  31. 24 1
      kmall-admin/src/main/webapp/js/shop/goods.js
  32. 2 0
      kmall-admin/src/main/webapp/js/shop/storeProductStock.js
  33. 3 3
      kmall-admin/src/main/webapp/js/shop/supplier.js
  34. 11 0
      kmall-common/src/main/java/com/kmall/common/constant/JxlsXmlTemplateName.java
  35. 294 0
      kmall-common/src/main/java/com/kmall/common/utils/excel/ExcelUtil.java
  36. 406 0
      kmall-common/src/main/java/com/kmall/common/utils/excel/FileUtil.java

+ 40 - 2
kmall-admin/src/main/java/com/kmall/admin/controller/GoodsController.java

@@ -1,15 +1,18 @@
 package com.kmall.admin.controller;
 
+import com.kmall.admin.dto.GoodsDto;
 import com.kmall.admin.entity.GoodsEntity;
 import com.kmall.admin.entity.GoodsGalleryEntity;
 import com.kmall.admin.service.GoodsGalleryService;
 import com.kmall.admin.service.GoodsService;
 import com.kmall.admin.service.OfflineCartService;
+import com.kmall.common.constant.JxlsXmlTemplateName;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.PageUtils;
 import com.kmall.common.utils.Query;
 import com.kmall.common.utils.R;
 import com.kmall.common.utils.ShiroUtils;
+import com.kmall.common.utils.excel.ExcelUtil;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -33,6 +36,8 @@ public class GoodsController {
     private GoodsGalleryService goodsGalleryService;
     @Autowired
     private OfflineCartService offlineCartService;
+    @Autowired
+    private ExcelUtil excelUtil;
 
     /**
      * 查看列表
@@ -201,8 +206,41 @@ public class GoodsController {
      * 上传文件
      */
     @RequestMapping("/upload")
-    public R upload(@RequestParam("file") MultipartFile file) throws Exception {
-        goodsService.uploadExcel(file);
+    public R upload(@RequestParam("file") MultipartFile file) {
+        List<GoodsDto> goodsDtoList = new ArrayList<>();//商品信息
+        try {
+            Map<String, Object> beans = new HashMap<String, Object>();
+            beans.put("GoodsDtoList", goodsDtoList);
+            if (file.isEmpty()) {
+                return R.error("文件不能为空!");
+            }
+            excelUtil.readExcel(JxlsXmlTemplateName.GOODS_DTO_LIST, beans, file.getInputStream());
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.error("导入失败!");
+        }
+        goodsService.uploadExcel(goodsDtoList);
+        //上传文件
+        return R.ok();
+    }
+    /**
+     * 上传文件
+     */
+    @RequestMapping("/generalGoodsUpload")
+    public R generalGoodsUpload(@RequestParam("file") MultipartFile file) {
+        List<GoodsDto> generalGoodsDtoList = new ArrayList<>();//商品信息
+        try {
+            Map<String, Object> beans = new HashMap<String, Object>();
+            beans.put("GeneralGoodsDtoList", generalGoodsDtoList);
+            if (file.isEmpty()) {
+                return R.error("文件不能为空!");
+            }
+            excelUtil.readExcel(JxlsXmlTemplateName.GENERAL_GOODS_DTO_LIST, beans, file.getInputStream());
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.error("导入失败!");
+        }
+        goodsService.uploadExcel(generalGoodsDtoList);
         //上传文件
         return R.ok();
     }

+ 1 - 1
kmall-admin/src/main/java/com/kmall/admin/controller/SysOssController.java

@@ -109,7 +109,7 @@ public class SysOssController {
             throw new RRException("上传文件不能为空");
         }
         //上传文件
-        String url = FileManager.upload(file);;
+        String url = FileManager.upload(file);
 
         //保存文件信息
         SysOssEntity ossEntity = new SysOssEntity();

+ 5 - 1
kmall-admin/src/main/java/com/kmall/admin/dao/BrandDao.java

@@ -2,6 +2,10 @@ package com.kmall.admin.dao;
 
 import com.kmall.admin.entity.BrandEntity;
 import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
 /**
  * Dao
  *
@@ -10,5 +14,5 @@ import com.kmall.common.dao.BaseDao;
  * @date 2017-08-19 17:59:15
  */
 public interface BrandDao extends BaseDao<BrandEntity> {
-
+    BrandEntity queryObjectByName(@Param("brandName")String brandName);
 }

+ 4 - 0
kmall-admin/src/main/java/com/kmall/admin/dao/CategoryDao.java

@@ -2,6 +2,9 @@ package com.kmall.admin.dao;
 
 import com.kmall.admin.entity.CategoryEntity;
 import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * Dao
@@ -11,5 +14,6 @@ import com.kmall.common.dao.BaseDao;
  * @date 2017-08-21 15:32:31
  */
 public interface CategoryDao extends BaseDao<CategoryEntity> {
+    CategoryEntity queryObjectByName(@Param("cateGoryName") String cateGoryName);
 
 }

+ 3 - 0
kmall-admin/src/main/java/com/kmall/admin/dao/FreightDao.java

@@ -3,6 +3,7 @@ package com.kmall.admin.dao;
 
 import com.kmall.admin.entity.FreightEntity;
 import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -18,4 +19,6 @@ public interface FreightDao extends BaseDao<FreightEntity> {
     Integer queryMaxId();
 
     List<FreightEntity> queryEntity(Map<String, Object> map);
+
+    FreightEntity queryObjectByName(@Param("defaultFreight")String defaultFreight);
 }

+ 3 - 0
kmall-admin/src/main/java/com/kmall/admin/dao/GoodsDao.java

@@ -2,6 +2,7 @@ package com.kmall.admin.dao;
 
 import com.kmall.admin.entity.GoodsEntity;
 import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -21,4 +22,6 @@ public interface GoodsDao extends BaseDao<GoodsEntity> {
     GoodsEntity queryObjectByProdBarcodeAndBizType(String goodsSn);
 
     List<GoodsEntity> querySame(Map<String, Object> map);
+
+    GoodsEntity queryObjectByProdBarcode(@Param("prodBarcode") String prodBarcode, @Param("merchSn") String merchSn,@Param("goodsId")Long id);
 }

+ 3 - 0
kmall-admin/src/main/java/com/kmall/admin/dao/GoodsGalleryDao.java

@@ -3,6 +3,7 @@ package com.kmall.admin.dao;
 import com.kmall.admin.entity.GoodsGalleryEntity;
 import com.kmall.common.dao.BaseDao;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -16,4 +17,6 @@ public interface GoodsGalleryDao extends BaseDao<GoodsGalleryEntity> {
     int deleteByGoodsId(Long goodsId);
 
     GoodsGalleryEntity queryVideoObjectByGoodId(Long goodId);
+
+    List<GoodsGalleryEntity> queryObjectByGoodId(Long goodId);
 }

+ 4 - 1
kmall-admin/src/main/java/com/kmall/admin/dao/SupplierDao.java

@@ -2,6 +2,9 @@ package com.kmall.admin.dao;
 
 import com.kmall.admin.entity.SupplierEntity;
 import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * Dao
@@ -11,5 +14,5 @@ import com.kmall.common.dao.BaseDao;
  * @date 2018-11-26 15:14:24
  */
 public interface SupplierDao extends BaseDao<SupplierEntity> {
-
+    SupplierEntity queryObjectByName(@Param("supplierName")String supplierName);
 }

+ 4 - 1
kmall-admin/src/main/java/com/kmall/admin/dao/SysCusNationCodeDao.java

@@ -2,6 +2,9 @@ package com.kmall.admin.dao;
 
 import com.kmall.admin.entity.SysCusNationCodeEntity;
 import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 国别地区代码Dao
@@ -11,5 +14,5 @@ import com.kmall.common.dao.BaseDao;
  * @date 2018-11-10 15:26:44
  */
 public interface SysCusNationCodeDao extends BaseDao<SysCusNationCodeEntity> {
-
+    SysCusNationCodeEntity queryObjectByName(@Param("nationName")String nationName);
 }

+ 4 - 1
kmall-admin/src/main/java/com/kmall/admin/dao/SysCusUnitCodeDao.java

@@ -2,6 +2,9 @@ package com.kmall.admin.dao;
 
 import com.kmall.admin.entity.SysCusUnitCodeEntity;
 import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 计量单位代码Dao
@@ -11,5 +14,5 @@ import com.kmall.common.dao.BaseDao;
  * @date 2018-11-10 15:34:36
  */
 public interface SysCusUnitCodeDao extends BaseDao<SysCusUnitCodeEntity> {
-
+    SysCusUnitCodeEntity queryObjectByName(@Param("unitName")String unitName);
 }

+ 464 - 0
kmall-admin/src/main/java/com/kmall/admin/dto/GoodsDto.java

@@ -0,0 +1,464 @@
+package com.kmall.admin.dto;
+
+import com.kmall.admin.entity.GoodsAttributeEntity;
+import com.kmall.admin.entity.GoodsGalleryEntity;
+import com.kmall.admin.entity.ProductEntity;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-13 10:41:08
+ */
+public class GoodsDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+    //主键
+    private Long id;
+    //商品序列号
+    private String goodsSn;
+    //名称
+    private String name;
+    //品牌
+    private String brand;
+    //商品库存
+    private Integer goodsNumber;
+    //关键字
+    private String keywords;
+    //简明介绍
+    private String goodsBrief;
+    //商品描述
+    private String goodsDesc;
+    //添加时间
+    private Date addTime;
+    //排序
+    private Integer sortOrder;
+    //库存价格
+    private String counterPrice;
+    //附加价格
+    private String extraPrice;
+    //商品单位
+    private String goodsUnit;
+    //商品税率
+    private String goodsRate;
+    //零售价格
+    private String retailPrice;
+    //销售量
+    private Integer sellVolume;
+    //单位价格,单价
+    private String unitPrice;
+    //推广描述
+    private String promotionDesc;
+    //市场价
+    private String marketPrice;
+    /**
+     * 产品条码
+     */
+    private String prodBarcode;
+    /**
+     * 计量单位代码,参见海关编码
+     */
+    private String unitCode;
+    /**
+     * 海关商品编码
+     */
+    private String cusGoodsCode;
+    /**
+     * 国检规格型号
+     */
+    private String ciqProdModel;
+    /**
+     * 原产国代码,海关编码
+     */
+    private String oriCntCode;
+    /**
+     * 海关申报要素,报统一版
+     */
+    private String cusDeclEle;
+    /**
+     * 海关备案编号,企业自编,用于报园区
+     */
+    private String cusRecCode;
+
+    private String sku;
+
+    private String goodsBizType;
+    // 商品类型
+    private Integer goodsType = 0; // 0普通 1 2团购
+
+    private String stockNum;
+
+    private String storeName;
+
+    private String productId;
+
+    private Integer storeId;
+    //商品类型
+    private String categoryName;
+    //品牌
+    private String brandName;
+
+    private String unitName;
+
+    private String oriCntName;
+
+    private String supplierName;
+
+    private String defaultFreight;
+    //上架
+    private String isOnSaleStr;
+    //热销
+    private String isHotStr;
+
+    public Integer getStoreId() {
+        return storeId;
+    }
+
+    public void setStoreId(Integer storeId) {
+        this.storeId = storeId;
+    }
+
+    public String getProductId() {
+        return productId;
+    }
+
+    public void setProductId(String productId) {
+        this.productId = productId;
+    }
+
+    public String getStockNum() {
+        return stockNum;
+    }
+
+    public void setStockNum(String stockNum) {
+        this.stockNum = stockNum;
+    }
+
+    public String getStoreName() {
+        return storeName;
+    }
+
+    public void setStoreName(String storeName) {
+        this.storeName = storeName;
+    }
+
+    public String getSku() {
+        return sku;
+    }
+
+    public void setSku(String sku) {
+        this.sku = sku;
+    }
+
+    public String getGoodsBizType() {
+        return goodsBizType;
+    }
+
+    public void setGoodsBizType(String goodsBizType) {
+        this.goodsBizType = goodsBizType;
+    }
+
+    public String getBrandName() {
+        return brandName;
+    }
+
+    public void setBrandName(String brandName) {
+        this.brandName = brandName;
+    }
+
+    public String getCategoryName() {
+        return categoryName;
+    }
+
+    public void setCategoryName(String categoryName) {
+        this.categoryName = categoryName;
+    }
+
+    /**
+     * 设置:主键
+     */
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    /**
+     * 获取:主键
+     */
+    public Long getId() {
+        return id;
+    }
+
+    /**
+     * 设置:商品序列号
+     */
+    public void setGoodsSn(String goodsSn) {
+        this.goodsSn = goodsSn;
+    }
+
+    /**
+     * 获取:商品序列号
+     */
+    public String getGoodsSn() {
+        return goodsSn;
+    }
+
+    /**
+     * 设置:名称
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 获取:名称
+     */
+    public String getName() {
+        return name;
+    }
+
+    public String getBrand() {
+        return brand;
+    }
+
+    public void setBrand(String brand) {
+        this.brand = brand;
+    }
+
+    /**
+     * 设置:商品序列号
+     */
+    public void setGoodsNumber(Integer goodsNumber) {
+        this.goodsNumber = goodsNumber;
+    }
+
+    /**
+     * 获取:商品序列号
+     */
+    public Integer getGoodsNumber() {
+        return goodsNumber;
+    }
+
+    /**
+     * 设置:关键字
+     */
+    public void setKeywords(String keywords) {
+        this.keywords = keywords;
+    }
+
+    /**
+     * 获取:关键字
+     */
+    public String getKeywords() {
+        return keywords;
+    }
+
+    /**
+     * 设置:简明介绍
+     */
+    public void setGoodsBrief(String goodsBrief) {
+        this.goodsBrief = goodsBrief;
+    }
+
+    /**
+     * 获取:简明介绍
+     */
+    public String getGoodsBrief() {
+        return goodsBrief;
+    }
+
+    /**
+     * 设置:商品描述
+     */
+    public void setGoodsDesc(String goodsDesc) {
+        this.goodsDesc = goodsDesc;
+    }
+
+    /**
+     * 获取:商品描述
+     */
+    public String getGoodsDesc() {
+        return goodsDesc;
+    }
+
+    /**
+     * 设置:添加时间
+     */
+    public void setAddTime(Date addTime) {
+        this.addTime = addTime;
+    }
+
+    /**
+     * 获取:添加时间
+     */
+    public Date getAddTime() {
+        return addTime;
+    }
+
+    /**
+     * 设置:排序
+     */
+    public void setSortOrder(Integer sortOrder) {
+        this.sortOrder = sortOrder;
+    }
+
+    /**
+     * 获取:排序
+     */
+    public Integer getSortOrder() {
+        return sortOrder;
+    }
+
+    /**
+     * 设置:商品单位
+     */
+    public void setGoodsUnit(String goodsUnit) {
+        this.goodsUnit = goodsUnit;
+    }
+
+    /**
+     * 获取:商品单位
+     */
+    public String getGoodsUnit() {
+        return goodsUnit;
+    }
+
+
+    public String getGoodsRate() {
+        return goodsRate;
+    }
+
+    public void setGoodsRate(String goodsRate) {
+        this.goodsRate = goodsRate;
+    }
+
+    /**
+     * 设置:零售价格
+     */
+    public void setRetailPrice(String retailPrice) {
+        this.retailPrice = retailPrice;
+    }
+
+    /**
+     * 获取:零售价格
+     */
+    public String getRetailPrice() {
+        return retailPrice;
+    }
+
+    public String getMarketPrice() {
+        return marketPrice;
+    }
+
+    public void setMarketPrice(String marketPrice) {
+        this.marketPrice = marketPrice;
+    }
+
+    public String getProdBarcode() {
+        return prodBarcode;
+    }
+
+    public void setProdBarcode(String prodBarcode) {
+        this.prodBarcode = prodBarcode;
+    }
+
+    public String getUnitCode() {
+        return unitCode;
+    }
+
+    public void setUnitCode(String unitCode) {
+        this.unitCode = unitCode;
+    }
+
+    public String getCusGoodsCode() {
+        return cusGoodsCode;
+    }
+
+    public void setCusGoodsCode(String cusGoodsCode) {
+        this.cusGoodsCode = cusGoodsCode;
+    }
+
+    public String getCiqProdModel() {
+        return ciqProdModel;
+    }
+
+    public void setCiqProdModel(String ciqProdModel) {
+        this.ciqProdModel = ciqProdModel;
+    }
+
+    public String getOriCntCode() {
+        return oriCntCode;
+    }
+
+    public void setOriCntCode(String oriCntCode) {
+        this.oriCntCode = oriCntCode;
+    }
+
+    public String getCusDeclEle() {
+        return cusDeclEle;
+    }
+
+    public void setCusDeclEle(String cusDeclEle) {
+        this.cusDeclEle = cusDeclEle;
+    }
+
+    public String getCusRecCode() {
+        return cusRecCode;
+    }
+
+    public void setCusRecCode(String cusRecCode) {
+        this.cusRecCode = cusRecCode;
+    }
+
+    public String getSupplierName() {
+        return supplierName;
+    }
+
+    public void setSupplierName(String supplierName) {
+        this.supplierName = supplierName;
+    }
+
+    public String getDefaultFreight() {
+        return defaultFreight;
+    }
+
+    public void setDefaultFreight(String defaultFreight) {
+        this.defaultFreight = defaultFreight;
+    }
+
+    public String getUnitName() {
+        return unitName;
+    }
+
+    public void setUnitName(String unitName) {
+        this.unitName = unitName;
+    }
+
+    public String getOriCntName() {
+        return oriCntName;
+    }
+
+    public void setOriCntName(String oriCntName) {
+        this.oriCntName = oriCntName;
+    }
+
+    public String getIsOnSaleStr() {
+        return isOnSaleStr;
+    }
+
+    public void setIsOnSaleStr(String isOnSaleStr) {
+        this.isOnSaleStr = isOnSaleStr;
+    }
+
+    public String getIsHotStr() {
+        return isHotStr;
+    }
+
+    public void setIsHotStr(String isHotStr) {
+        this.isHotStr = isHotStr;
+    }
+}

+ 53 - 50
kmall-admin/src/main/java/com/kmall/admin/entity/GoodsEntity.java

@@ -39,8 +39,6 @@ public class GoodsEntity implements Serializable {
     private String goodsBrief;
     //商品描述
     private String goodsDesc;
-    //上架
-    private Integer isOnSale;
     //添加时间
     private Date addTime;
     //修改时间
@@ -83,10 +81,55 @@ public class GoodsEntity implements Serializable {
     private Integer isAppExclusive;
     //限购
     private Integer isLimited;
+    //上架
+    private Integer isOnSale;
     //热销
     private Integer isHot;
     //市场价
     private BigDecimal marketPrice;
+
+    /**
+     * 产品条码
+     */
+    private String prodBarcode;
+    /**
+     * 计量单位代码,参见海关编码
+     */
+    private String unitCode;
+    /**
+     * 海关商品编码
+     */
+    private String cusGoodsCode;
+    /**
+     * 国检规格型号
+     */
+    private String ciqProdModel;
+    /**
+     * 原产国代码,海关编码
+     */
+    private String oriCntCode;
+    /**
+     * 海关申报要素,报统一版
+     */
+    private String cusDeclEle;
+    /**
+     * 海关备案编号,企业自编,用于报园区
+     */
+    private String cusRecCode;
+
+    private String sku;
+
+    private String goodsBizType;
+
+    private String createrSn;
+
+    private Date createTime;
+
+    private String moderSn;
+
+    private Date modTime;
+
+    private Date tstm;
     /**
      * 用户ID
      */
@@ -108,27 +151,8 @@ public class GoodsEntity implements Serializable {
     /**
      * 翻译用字段
      */
-    //商品类型
-    private String categoryName;
     //属性类别
     private String attributeCategoryName;
-    //品牌
-    private String brandName;
-
-    private String sku;
-
-    private String goodsBizType;
-
-    private String createrSn;
-
-    private Date createTime;
-
-    private String moderSn;
-
-    private Date modTime;
-
-    private Date tstm;
-
     //视频地址
     private String videoUrl;
 
@@ -140,6 +164,14 @@ public class GoodsEntity implements Serializable {
 
     private Integer storeId;
 
+    /**
+     * 导入翻译数据
+     */
+    //商品类型
+    private String categoryName;
+    //品牌
+    private String brandName;
+
     public Integer getStoreId() {
         return storeId;
     }
@@ -785,35 +817,6 @@ public class GoodsEntity implements Serializable {
         this.goodsType = goodsType;
     }
 
-    /**
-     * 产品条码
-     */
-    private String prodBarcode;
-    /**
-     * 计量单位代码,参见海关编码
-     */
-    private String unitCode;
-    /**
-     * 海关商品编码
-     */
-    private String cusGoodsCode;
-    /**
-     * 国检规格型号
-     */
-    private String ciqProdModel;
-    /**
-     * 原产国代码,海关编码
-     */
-    private String oriCntCode;
-    /**
-     * 海关申报要素,报统一版
-     */
-    private String cusDeclEle;
-    /**
-     * 海关备案编号,企业自编,用于报园区
-     */
-    private String cusRecCode;
-
     public String getProdBarcode() {
         return prodBarcode;
     }

+ 6 - 11
kmall-admin/src/main/java/com/kmall/admin/entity/SupplierEntity.java

@@ -29,7 +29,7 @@ public class SupplierEntity implements Serializable {
     /**
      * 二级供货商名称
      */
-    private String childSupplierSn;
+    private String childSupplierName;
     /**
      * 二级供货商标识
      */
@@ -82,18 +82,13 @@ public class SupplierEntity implements Serializable {
     public String getLevelMerchFlag() {
         return levelMerchFlag;
     }
-    /**
-     * 设置:二级供货商名称
-     */
-    public void setChildSupplierSn(String childSupplierSn) {
-        this.childSupplierSn = childSupplierSn;
+
+    public String getChildSupplierName() {
+        return childSupplierName;
     }
 
-    /**
-     * 获取:二级供货商名称
-     */
-    public String getChildSupplierSn() {
-        return childSupplierSn;
+    public void setChildSupplierName(String childSupplierName) {
+        this.childSupplierName = childSupplierName;
     }
     /**
      * 设置:二级供货商标识

+ 3 - 2
kmall-admin/src/main/java/com/kmall/admin/service/GoodsService.java

@@ -1,5 +1,6 @@
 package com.kmall.admin.service;
 
+import com.kmall.admin.dto.GoodsDto;
 import com.kmall.admin.entity.GoodsEntity;
 import com.kmall.common.utils.R;
 import org.springframework.web.multipart.MultipartFile;
@@ -118,8 +119,8 @@ public interface GoodsService {
     /**
      * 导入商品
      *
-     * @param file
+     * @param goodsEntityList
      * @return
      */
-    int uploadExcel(MultipartFile file);
+    int uploadExcel(List<GoodsDto> goodsEntityList);
 }

+ 291 - 17
kmall-admin/src/main/java/com/kmall/admin/service/impl/GoodsServiceImpl.java

@@ -2,6 +2,7 @@ package com.kmall.admin.service.impl;
 
 import com.google.common.collect.ImmutableBiMap;
 import com.kmall.admin.dao.*;
+import com.kmall.admin.dto.GoodsDto;
 import com.kmall.admin.entity.*;
 import com.kmall.admin.service.GoodsService;
 import com.kmall.api.contants.Dict;
@@ -14,10 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.math.BigDecimal;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * Service实现类
@@ -48,6 +46,16 @@ public class GoodsServiceImpl implements GoodsService {
     private GoodsGroupDao goodsGroupDao;
     @Autowired
     private CategoryDao categoryDao;
+    @Autowired
+    private SupplierDao supplierDao;
+    @Autowired
+    private BrandDao brandDao;
+    @Autowired
+    private FreightDao freightDao;
+    @Autowired
+    private SysCusNationCodeDao sysCusNationCodeDao;
+    @Autowired
+    private SysCusUnitCodeDao sysCusUnitCodeDao;
 
     @Override
     public GoodsEntity queryObject(Integer id) {
@@ -91,16 +99,17 @@ public class GoodsServiceImpl implements GoodsService {
         builder.put("attributeCategory", "商品分类");
         builder.put("categoryId", "商品二级分类");
         builder.put("goodsSn", "商品编码");
-        builder.put("goodsBizType", "货品业务类型");
         builder.put("name", "商品名称");
+        builder.put("goodsUnit", "商品单位");
+        builder.put("prodBarcode", "产品条码");
+        builder.put("goodsBizType", "货品业务类型");
         builder.put("brandId", "品牌");
         builder.put("supplierId", "供应商");
         builder.put("freightId", "运费模版");
-        builder.put("goodsDesc", "商品描述");
-        builder.put("isOnSale", "上架");
-        builder.put("goodsUnit", "商品单位");
         builder.put("primaryPicUrl", "商品主图");
         builder.put("listPicUrl", "商品列表图");
+        builder.put("goodsDesc", "商品描述");
+        builder.put("isOnSale", "上架");
         builder.put("isHot", "热销");
 
         R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
@@ -112,7 +121,6 @@ public class GoodsServiceImpl implements GoodsService {
                 builder.put("sku", "SKU");
                 builder.put("goodsRate", "商品税率");
                 builder.put("retailPrice", "零售价");
-                builder.put("prodBarcode", "产品编码");
                 builder.put("brand", "产品品牌");
                 builder.put("unitCode", "计量单位代码");
                 builder.put("cusGoodsCode", "海关商品编码");
@@ -132,6 +140,10 @@ public class GoodsServiceImpl implements GoodsService {
         if (galleryEntityList == null || galleryEntityList.size() <= 0) {
             throw new RRException("至少添加一张商品轮播图!");
         }
+        GoodsEntity prodbarGoods = goodsDao.queryObjectByProdBarcode(goods.getProdBarcode(),"",null);
+        if(prodbarGoods != null){
+            throw new RRException("不能有重复的产品条码信息!");
+        }
 
         SysUserEntity user = ShiroUtils.getUserEntity();
         Map<String, Object> map = new HashMap<>();
@@ -224,16 +236,17 @@ public class GoodsServiceImpl implements GoodsService {
         builder.put("attributeCategory", "商品分类");
         builder.put("categoryId", "商品二级分类");
         builder.put("goodsSn", "商品编码");
-        builder.put("goodsBizType", "货品业务类型");
         builder.put("name", "商品名称");
+        builder.put("goodsUnit", "商品单位");
+        builder.put("prodBarcode", "产品条码");
+        builder.put("goodsBizType", "货品业务类型");
         builder.put("brandId", "品牌");
         builder.put("supplierId", "供应商");
         builder.put("freightId", "运费模版");
-        builder.put("goodsDesc", "商品描述");
-        builder.put("isOnSale", "上架");
-        builder.put("goodsUnit", "商品单位");
         builder.put("primaryPicUrl", "商品主图");
         builder.put("listPicUrl", "商品列表图");
+        builder.put("goodsDesc", "商品描述");
+        builder.put("isOnSale", "上架");
         builder.put("isHot", "热销");
 
 
@@ -246,14 +259,13 @@ public class GoodsServiceImpl implements GoodsService {
                 builder.put("sku", "SKU");
                 builder.put("goodsRate", "商品税率");
                 builder.put("retailPrice", "零售价");
-                builder.put("prodBarcode", "产品编码");
                 builder.put("brand", "产品品牌");
                 builder.put("unitCode", "计量单位代码");
                 builder.put("cusGoodsCode", "海关商品编码");
                 builder.put("ciqProdModel", "国检规格型号");
                 builder.put("oriCntCode", "原产国代码");
-                builder.put("cusDeclEle", "海关申报要素");
                 builder.put("cusRecCode", "海关备案编号");
+                builder.put("cusDeclEle", "海关申报要素");
             }
             r = ValidatorUtil.isEmpty(builder.build(), valideDate);
             if (Integer.valueOf(r.get("code").toString()) != 0) {
@@ -266,7 +278,10 @@ public class GoodsServiceImpl implements GoodsService {
         if (galleryEntityList == null || galleryEntityList.size() <= 0) {
             throw new RRException("至少保留一张商品轮播图!");
         }
-
+        GoodsEntity prodbarGoods = goodsDao.queryObjectByProdBarcode(goods.getProdBarcode(),"",goods.getId());
+        if(prodbarGoods != null){
+            throw new RRException("不能有重复的产品条码信息!");
+        }
         SysUserEntity user = ShiroUtils.getUserEntity();
         Map<String, Object> map = new HashMap<>();
         map.put("isSame", "true");
@@ -476,6 +491,265 @@ public class GoodsServiceImpl implements GoodsService {
 
     @Override
     @Transactional
+    public int uploadExcel(List<GoodsDto> goodsEntityList) {
+        SysUserEntity user = ShiroUtils.getUserEntity();
+        boolean isSuccess = false;
+        List<String> failSameSkuList = new ArrayList<>(), failHotSkuList = new ArrayList<>(), failCateSkuList = new ArrayList<>(),
+                failBrandSkuList = new ArrayList<>(), failFreightSkuList = new ArrayList<>(), failSuppSkuList = new ArrayList<>(),
+                failUnitSkuList = new ArrayList<>(), failNationSkuList = new ArrayList<>(),failProdbarSkuList = new ArrayList<>(),
+                failCateL2SkuList = new ArrayList<>(), failTypeSkuList = new ArrayList<>();
+        List<String> failGoodsSnList = new ArrayList<>();
+        List<String> failGoodsTypeList = new ArrayList<>();
+        List<String> failFreightList = new ArrayList<>();
+        if (goodsEntityList != null && goodsEntityList.size() > 0) {
+            for (int i = 0; i < goodsEntityList.size(); i++) {
+                GoodsDto goodsDto = goodsEntityList.get(i);
+                GoodsEntity goodsEntity = new GoodsEntity();
+                Map<String, Object> valideDate = MapBeanUtil.fromObject(goodsDto);
+                ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
+                builder.put("goodsSn", "商品编码");
+                builder.put("categoryName", "商品分类");
+                builder.put("goodsBizType", "货品业务类型");
+                builder.put("name", "商品名称");
+                builder.put("brandName", "商品品牌名称");
+                builder.put("defaultFreight", "运费");
+                builder.put("isOnSaleStr", "上架");
+                builder.put("goodsUnit", "商品单位");
+                builder.put("isHotStr", "热销");
+                builder.put("prodBarcode", "产品条码");
+                builder.put("marketPrice", "市场价");
+                builder.put("retailPrice", "零售价");
+                builder.put("supplierName", "供应商");
+                R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
+                if (Integer.valueOf(r.get("code").toString()) != 0) {
+                    throw new RRException(r.get("msg").toString());
+                } else {
+                    if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
+                        // 海关信息,普通货物可不添加
+                        builder.put("goodsRate", "商品税率");
+                        builder.put("sku", "SKU");
+                        builder.put("brand", "产品品牌");
+                        builder.put("unitName", "计量单位");
+                        builder.put("oriCntName", "原产国");
+                        builder.put("cusGoodsCode", "海关商品编码");
+                        builder.put("ciqProdModel", "国检规格型号");
+                        builder.put("cusDeclEle", "海关申报要素");
+                        builder.put("cusRecCode", "海关备案编号");
+                    }
+                    r = ValidatorUtil.isEmpty(builder.build(), valideDate);
+                    if (Integer.valueOf(r.get("code").toString()) != 0) {
+                        throw new RRException(r.get("msg").toString());
+                    }
+                }
+                if(!Dict.orderBizType.item_11.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())){
+                    if(!(Dict.orderBizType.item_02.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())
+                            || Dict.orderBizType.item_10.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType())
+                            || Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goodsDto.getGoodsBizType()))){
+                        isSuccess = true;
+                        failTypeSkuList.add(goodsDto.getSku());
+                    }
+                }
+                Map<String, Object> map = new HashMap<>();
+                map.put("isSame", "true");
+                map.put("sku", goodsDto.getSku());
+                map.put("goodsSn", goodsDto.getGoodsSn());
+                map.put("goodsBizType", goodsDto.getGoodsBizType());
+                List<GoodsEntity> list = querySame(map);
+                if (list != null && list.size() != 0) {
+                    isSuccess = true;
+                    if(goodsDto.getSku()!=null) {
+                        failSameSkuList.add(goodsDto.getGoodsSn());
+                    }
+                    failGoodsSnList.add(goodsDto.getGoodsSn());
+                    failGoodsTypeList.add(goodsDto.getGoodsBizType());
+                }
+                GoodsEntity prodbarGoods = goodsDao.queryObjectByProdBarcode(goodsDto.getProdBarcode(),"",null);
+                if(prodbarGoods != null){
+                    isSuccess = true;
+                    failProdbarSkuList.add(goodsDto.getGoodsSn());
+                }else{
+                    goodsEntity.setProdBarcode(goodsDto.getProdBarcode());
+                }
+                if (Dict.orderBizType.item_02.getItem().equals(goodsDto.getGoodsBizType())
+                        || Dict.orderBizType.item_10.getItem().equals(goodsDto.getGoodsBizType())) {
+                    if(goodsDto.getIsHotStr().equalsIgnoreCase("1")){
+                        isSuccess = true;
+                        failHotSkuList.add(goodsDto.getGoodsSn());
+                    }
+                }
+                CategoryEntity categoryEntity = categoryDao.queryObjectByName(goodsDto.getCategoryName());
+                if(categoryEntity==null){
+                    isSuccess = true;
+                    failCateSkuList.add(goodsDto.getGoodsSn());
+                }else{
+                    if(categoryEntity.getLevel().equalsIgnoreCase("L2")) {
+                        goodsEntity.setCategoryId(categoryEntity.getId());
+                        goodsEntity.setAttributeCategory(categoryEntity.getParentId());
+                    }else{
+                        isSuccess = true;
+                        failCateL2SkuList.add(goodsDto.getGoodsSn());
+                    }
+                }
+                BrandEntity brandEntity = brandDao.queryObjectByName(goodsDto.getBrandName());
+                if (brandEntity == null) {
+                    isSuccess = true;
+                    failBrandSkuList.add(goodsDto.getGoodsSn());
+                } else {
+                    goodsEntity.setBrandId(brandEntity.getId());
+                }
+                //运费
+                FreightEntity freightEntity = freightDao.queryObjectByName(goodsDto.getDefaultFreight());
+                if(freightEntity==null){
+                    isSuccess = true;
+                    failFreightSkuList.add(goodsDto.getGoodsSn());
+                    failFreightList.add(goodsDto.getDefaultFreight());
+                }else {
+                    goodsEntity.setFreightId(freightEntity.getId());
+                }
+                if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
+                    SupplierEntity supplierEntity = supplierDao.queryObjectByName(goodsDto.getSupplierName());
+                    if (supplierEntity == null) {
+                        isSuccess = true;
+                        failSuppSkuList.add(goodsDto.getGoodsSn());
+                    } else {
+                        goodsEntity.setSupplierId(supplierEntity.getId());
+                    }
+                    SysCusUnitCodeEntity sysCusUnitCodeEntity = sysCusUnitCodeDao.queryObjectByName(goodsDto.getUnitName());
+                    if (sysCusUnitCodeEntity == null) {
+                        isSuccess = true;
+                        failUnitSkuList.add(goodsDto.getGoodsSn());
+                    } else {
+                        goodsEntity.setUnitCode(sysCusUnitCodeEntity.getCode());
+                    }
+                    //原产国
+                    SysCusNationCodeEntity sysCusNationCodeEntity = sysCusNationCodeDao.queryObjectByName(goodsDto.getOriCntName());
+                    if (sysCusNationCodeEntity == null) {
+                        isSuccess = true;
+                        failNationSkuList.add(goodsDto.getGoodsSn());
+                    } else {
+                        goodsEntity.setOriCntCode(sysCusNationCodeEntity.getCode());
+                    }
+                    goodsEntity.setGoodsRate(BigDecimal.valueOf(Integer.valueOf(goodsDto.getGoodsRate())));
+                }
+                goodsEntity.setIsOnSale(Integer.parseInt(goodsDto.getIsOnSaleStr()));
+                goodsEntity.setIsHot(Integer.parseInt(goodsDto.getIsHotStr()));
+                goodsEntity.setRetailPrice(BigDecimal.valueOf(Integer.valueOf(goodsDto.getRetailPrice())));
+                goodsEntity.setMarketPrice(BigDecimal.valueOf(Integer.valueOf(goodsDto.getMarketPrice())));
+                goodsEntity.setGoodsSn(goodsDto.getGoodsSn());
+                goodsEntity.setSku(goodsDto.getSku());
+                goodsEntity.setName(goodsDto.getName());
+                goodsEntity.setGoodsUnit(goodsDto.getGoodsUnit());
+                goodsEntity.setGoodsBizType(goodsDto.getGoodsBizType());
+                goodsEntity.setBrand(goodsDto.getBrand());
+                goodsEntity.setCusDeclEle(goodsDto.getCusDeclEle());
+                goodsEntity.setCusGoodsCode(goodsDto.getCusGoodsCode());
+                goodsEntity.setCusRecCode(goodsDto.getCusRecCode());
+                goodsEntity.setCiqProdModel(goodsDto.getCiqProdModel());
+                goodsEntity.setIsDelete(0);
+                goodsEntity.setIsNew(0);
+                goodsEntity.setUpdateUserId(user.getUserId());
+                goodsEntity.setAddTime(new Date());
+                goodsEntity.setCreateTime(new Date());
+                goodsEntity.setUpdateTime(new Date());
+                goodsEntity.setModTime(new Date());
+
+                if(!isSuccess){
+                    GoodsEntity goods = goodsDao.queryObjectBySn(goodsDto.getGoodsSn());
+                    if(goods!=null) {// 修改商品
+                        goodsEntity.setId(goods.getId());
+                        goodsDao.update(goodsEntity);
+                    }else{
+                        goodsDao.save(goodsEntity);
+                    }
+                    // 保税商品修改各个门店商品价格
+                    if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
+                        List<ProductStoreRelaEntity> productStoreRelaEntityList = productStoreRelaDao.queryByGoodsId(goodsDto.getId());
+                        if (productStoreRelaEntityList != null && productStoreRelaEntityList.size() > 0) {
+                            for (ProductStoreRelaEntity productStoreRela : productStoreRelaEntityList) {
+                                productStoreRela.setMarketPrice(goodsEntity.getMarketPrice());
+                                productStoreRela.setRetailPrice(goodsEntity.getRetailPrice());
+                                productStoreRelaDao.update(productStoreRela);
+                            }
+                        }
+                    }
+                    // 修改产品
+                    ProductEntity product = productDao.queryObjectBySn(goodsDto.getGoodsSn());
+
+                    GoodsSpecificationEntity goodsSpecification = new GoodsSpecificationEntity();
+                    // 保税商品,普通货物暂不添加商品规格
+                    if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
+                        // 添加商品规格
+                        GoodsSpecificationEntity specificationEntity = goodsSpecificationDao.queryByGoodsId(goodsEntity.getId());
+                        if(specificationEntity ==null) {
+                            goodsSpecification.setGoodsId(goodsEntity.getId() );
+                            goodsSpecification.setValue(goodsEntity.getCiqProdModel());
+                            goodsSpecification.setSpecificationId(1);
+                            goodsSpecificationDao.save(goodsSpecification);
+                        }else {
+                            goodsSpecification.setValue(goodsDto.getCiqProdModel());
+                            goodsSpecificationDao.update(goodsSpecification);
+                        }
+                    }
+
+                    if(product == null){
+                        product = new ProductEntity();
+                        product.setGoodsSn(goodsDto.getGoodsSn());
+                        product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
+                        product.setGoodsSpecificationIds(goodsSpecification.getSpecificationId()+"");
+                        product.setGoodsId(goodsEntity.getId());
+                        product.setGoodsDefault(0);
+                        product.setGoodsNumber(goodsEntity.getGoodsNumber());
+                        productDao.save(product);
+                    }else{
+                        product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
+                        productDao.update(product);
+                    }
+                }
+            }
+            if(failGoodsSnList != null && failGoodsSnList.size() > 0){
+                if(failSameSkuList.size()>0) {
+                    throw new RRException("不能有重复的商品编码、sku信息!请检查商品编码【" + failGoodsSnList + "】,业务类型【" +
+                            failGoodsTypeList + "】,SKU【" + failSameSkuList + "】的商品信息");
+                }else{
+                    throw new RRException("不能有重复的商品编码、sku信息!请检查商品编码【" + failGoodsSnList + "】,业务类型【" +
+                            failGoodsTypeList + "】的商品信息");
+                }
+            }
+            if(failTypeSkuList != null && failTypeSkuList.size() > 0){
+                throw new RRException("货品业务类型只能是【00保税备货、02保税补货、10保税展示】!请检查SKU【"+failTypeSkuList+"】的商品信息");
+            }
+            if(failProdbarSkuList != null && failProdbarSkuList.size() > 0){
+                throw new RRException("不能有重复的产品条码信息!请检查SKU【"+failProdbarSkuList+"】的商品产品条码信息");
+            }
+            if(failHotSkuList != null && failHotSkuList.size() > 0){
+                throw new RRException("请检查业务类型为【保税补货或保税展示】的商品,sku【"+failHotSkuList+"】的商品不能设置为热销!");
+            }
+            if(failCateSkuList != null && failCateSkuList.size() > 0){
+                throw new RRException("分类信息请在商城配置》商品分类中维护,不存在的商品sku【"+failCateSkuList+"】");
+            }
+            if(failCateL2SkuList != null && failCateL2SkuList.size() > 0){
+                throw new RRException("分类信息请在商城配置》商品分类中查看,商品分类必须为二级分类,错误的商品sku【"+failCateL2SkuList+"】");
+            }
+            if(failBrandSkuList != null && failBrandSkuList.size() > 0){
+                throw new RRException("品牌信息请在商城配置》品牌制造商中维护,不存在的商品sku【" + failBrandSkuList + "】");
+            }
+            if(failFreightSkuList != null && failFreightSkuList.size() > 0){
+                throw new RRException("运费信息请在商城配置》运费模板中维护,不存在的商品sku【"+failFreightSkuList+"】,运费【"+failFreightList+"】");
+            }
+            if(failSuppSkuList != null && failSuppSkuList.size() > 0){
+                throw new RRException("供应商信息请在商城配置》商品供应商中维护,不存在的商品sku【" + failSuppSkuList + "】");
+            }
+            if(failUnitSkuList != null && failUnitSkuList.size() > 0){
+                throw new RRException("计算单位信息请在商城配置》计算单位中维护,不存在的商品sku【" + failUnitSkuList + "】");
+            }
+            if(failNationSkuList != null && failNationSkuList.size() > 0){
+                throw new RRException("原产国信息请在商城配置》原产国中维护,不存在的商品sku【" + failNationSkuList + "】");
+            }
+        }
+        return 1;
+    }
+/*  @Override
+    @Transactional
     public int uploadExcel(MultipartFile file) {
         SysUserEntity user = ShiroUtils.getUserEntity();
 
@@ -519,7 +793,7 @@ public class GoodsServiceImpl implements GoodsService {
             }
         }
         return 1;
-    }
+    }*/
 
     public GoodsEntity queryObjectBySn(String goodsSn) {
         return goodsDao.queryObjectBySn(goodsSn);

+ 15 - 8
kmall-admin/src/main/java/com/kmall/admin/service/impl/ProductStoreRelaServiceImpl.java

@@ -1,18 +1,13 @@
 package com.kmall.admin.service.impl;
 
 import com.google.common.collect.ImmutableBiMap;
-import com.kmall.admin.dao.GoodsDao;
-import com.kmall.admin.dao.GoodsSpecificationDao;
-import com.kmall.admin.dao.ProductDao;
-import com.kmall.admin.dao.ProductStoreRelaDao;
-import com.kmall.admin.entity.GoodsEntity;
-import com.kmall.admin.entity.GoodsSpecificationEntity;
-import com.kmall.admin.entity.ProductEntity;
-import com.kmall.admin.entity.ProductStoreRelaEntity;
+import com.kmall.admin.dao.*;
+import com.kmall.admin.entity.*;
 import com.kmall.admin.service.ProductStoreRelaService;
 import com.kmall.api.contants.Dict;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.*;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -38,6 +33,8 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
     private GoodsSpecificationDao goodsSpecificationDao;
     @Autowired
     private ProductDao productDao;
+    @Autowired
+    private GoodsGalleryDao goodsGalleryDao;
 
     @Override
     public ProductStoreRelaEntity queryObject(Integer id) {
@@ -83,6 +80,16 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
             if (Integer.valueOf(r.get("code").toString()) != 0) {
                 throw new RRException(r.get("msg").toString());
             }
+            if(!StringUtils.isNotEmpty(goodsEntity.getListPicUrl())){
+                throw new RRException("该商品列表图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品列表图信息,再来操作门店商品数据");
+            }
+            if(!StringUtils.isNotEmpty(goodsEntity.getPrimaryPicUrl())){
+                throw new RRException("该商品主图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品主图信息,再来操作门店商品数据");
+            }
+            List<GoodsGalleryEntity> galleryEntityList = goodsGalleryDao.queryObjectByGoodId(goodsEntity.getId());
+            if (galleryEntityList == null || galleryEntityList.size() <= 0) {
+                throw new RRException("该商品轮播图不能为空!请先在商品管理》所有商品中维护商品编号为【"+goodsEntity.getGoodsSn()+"】的商品详情轮播图信息,再来操作门店商品数据");
+            }
         }
 
         Map<String, Object> map = new HashMap();

+ 29 - 0
kmall-admin/src/main/resources/XmlTemplate/GeneralGoodsDtoList.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<workbook>
+    <worksheet name="Sheet1">
+        <section startRow="0" endRow="1"/>
+        <loop startRow="1" endRow="1" items="GeneralGoodsDtoList" var="GoodsDto"
+              varType="com.kmall.admin.dto.GoodsDto">
+            <section startRow="1" endRow="1">
+                <mapping row="1" col="0">GoodsDto.goodsSn</mapping>
+                <mapping row="1" col="1">GoodsDto.categoryName</mapping>
+                <mapping row="1" col="2">GoodsDto.goodsBizType</mapping>
+                <mapping row="1" col="3">GoodsDto.name</mapping>
+                <mapping row="1" col="4">GoodsDto.prodBarcode</mapping>
+                <mapping row="1" col="5">GoodsDto.supplierName</mapping>
+                <mapping row="1" col="6">GoodsDto.brandName</mapping>
+                <mapping row="1" col="7">GoodsDto.defaultFreight</mapping>
+                <mapping row="1" col="8">GoodsDto.isOnSaleStr</mapping>
+                <mapping row="1" col="9">GoodsDto.goodsUnit</mapping>
+                <mapping row="1" col="10">GoodsDto.isHotStr</mapping>
+                <mapping row="1" col="11">GoodsDto.marketPrice</mapping>
+                <mapping row="1" col="12">GoodsDto.retailPrice</mapping>
+            </section>
+            <loopbreakcondition>
+                <rowcheck offset="0">
+                    <cellcheck offset="0"></cellcheck>
+                </rowcheck>
+            </loopbreakcondition>
+        </loop>
+    </worksheet>
+</workbook>

+ 38 - 0
kmall-admin/src/main/resources/XmlTemplate/GoodsDtoList.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<workbook>
+    <worksheet name="Sheet1">
+        <section startRow="0" endRow="1"/>
+        <loop startRow="1" endRow="1" items="GoodsDtoList" var="GoodsDto"
+              varType="com.kmall.admin.dto.GoodsDto">
+            <section startRow="1" endRow="1">
+                <mapping row="1" col="0">GoodsDto.goodsSn</mapping>
+                <mapping row="1" col="1">GoodsDto.categoryName</mapping>
+                <mapping row="1" col="2">GoodsDto.goodsBizType</mapping>
+                <mapping row="1" col="3">GoodsDto.name</mapping>
+                <mapping row="1" col="4">GoodsDto.prodBarcode</mapping>
+                <mapping row="1" col="5">GoodsDto.supplierName</mapping>
+                <mapping row="1" col="6">GoodsDto.sku</mapping>
+                <mapping row="1" col="7">GoodsDto.brandName</mapping>
+                <mapping row="1" col="8">GoodsDto.defaultFreight</mapping>
+                <mapping row="1" col="9">GoodsDto.isOnSaleStr</mapping>
+                <mapping row="1" col="10">GoodsDto.goodsUnit</mapping>
+                <mapping row="1" col="11">GoodsDto.isHotStr</mapping>
+                <mapping row="1" col="12">GoodsDto.cusGoodsCode</mapping>
+                <mapping row="1" col="13">GoodsDto.ciqProdModel</mapping>
+                <mapping row="1" col="14">GoodsDto.goodsRate</mapping>
+                <mapping row="1" col="15">GoodsDto.marketPrice</mapping>
+                <mapping row="1" col="16">GoodsDto.retailPrice</mapping>
+                <mapping row="1" col="17">GoodsDto.brand</mapping>
+                <mapping row="1" col="18">GoodsDto.unitName</mapping>
+                <mapping row="1" col="19">GoodsDto.oriCntName</mapping>
+                <mapping row="1" col="20">GoodsDto.cusDeclEle</mapping>
+                <mapping row="1" col="21">GoodsDto.cusRecCode</mapping>
+            </section>
+            <loopbreakcondition>
+                <rowcheck offset="0">
+                    <cellcheck offset="0"></cellcheck>
+                </rowcheck>
+            </loopbreakcondition>
+        </loop>
+    </worksheet>
+</workbook>

+ 18 - 0
kmall-admin/src/main/resources/mybatis/mapper/BrandDao.xml

@@ -36,6 +36,24 @@
 		where id = #{id}
 	</select>
 
+    <select id="queryObjectByName" resultType="com.kmall.admin.entity.BrandEntity">
+        select
+        `id`,
+        `name`,
+        `list_pic_url`,
+        `simple_desc`,
+        `pic_url`,
+        `sort_order`,
+        `is_show`,
+        `floor_price`,
+        `app_list_pic_url`,
+        `is_new`,
+        `new_pic_url`,
+        `new_sort_order`
+        from mall_brand
+        where `name` = #{brandName}
+    </select>
+
     <select id="queryList" resultType="com.kmall.admin.entity.BrandEntity">
         select
         `id`,

+ 21 - 0
kmall-admin/src/main/resources/mybatis/mapper/CategoryDao.xml

@@ -42,6 +42,27 @@
 		from mall_category
 		where id = #{id}
 	</select>
+	<select id="queryObjectByName" resultType="com.kmall.admin.entity.CategoryEntity">
+		select
+		`id`,
+		`name`,
+		`keywords`,
+		`front_desc`,
+		`parent_id`,
+		`sort_order`,
+		`show_index`,
+		`is_show`,
+		`banner_url`,
+		`icon_url`,
+		`img_url`,
+		`wap_banner_url`,
+		`level`,
+		`type`,
+		`front_name`,
+		`is_show` as `show`
+		from mall_category
+		where name = #{cateGoryName} and is_show = 1
+	</select>
 
 	<select id="queryList" resultType="com.kmall.admin.entity.CategoryEntity">
 		select

+ 12 - 0
kmall-admin/src/main/resources/mybatis/mapper/FreightDao.xml

@@ -24,6 +24,18 @@
 		where id = #{id}
 	</select>
 
+	<select id="queryObjectByName" resultType="com.kmall.admin.entity.FreightEntity">
+		select
+		`id`,
+		`name`,
+		`template_type`,
+		`pricing_manner`,
+		`default_freight`,
+		`is_default`
+		from mall_freight
+		where default_freight = #{defaultFreight}
+	</select>
+
 	<select id="queryList" resultType="com.kmall.admin.entity.FreightEntity">
 		select
     		`id`,

+ 11 - 0
kmall-admin/src/main/resources/mybatis/mapper/GoodsDao.xml

@@ -81,6 +81,17 @@
         where a.prod_barcode = #{prodBarcode} and a.goods_biz_type = 11
     </select>
 
+    <select id="queryObjectByProdBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
+        SELECT
+        a.id,a.sku,a.goods_sn,a.name,a.list_pic_url,a.prod_barcode
+        FROM
+        mall_goods a
+        where a.prod_barcode = #{prodBarcode}
+        <if test="goodsId != null and goodsId != ''">
+            AND a.id != #{goodsId}
+        </if>
+    </select>
+
     <select id="queryObjectBySn" resultType="com.kmall.admin.entity.GoodsEntity">
         SELECT
             a.*, CASE

+ 11 - 0
kmall-admin/src/main/resources/mybatis/mapper/GoodsGalleryDao.xml

@@ -34,6 +34,17 @@
         from mall_goods_gallery
         where goods_id = #{goodId} and file_type = 1 and sort_order = 0
     </select>
+    <select id="queryObjectByGoodId" resultType="com.kmall.admin.entity.GoodsGalleryEntity">
+        select
+        `id`,
+        `goods_id`,
+        `img_url`,
+        `img_desc`,
+        `file_type`,
+        `sort_order`
+        from mall_goods_gallery
+        where goods_id = #{goodId} and file_type != 1
+    </select>
 
     <select id="queryList" resultType="com.kmall.admin.entity.GoodsGalleryEntity">
         select

+ 19 - 6
kmall-admin/src/main/resources/mybatis/mapper/SupplierDao.xml

@@ -7,7 +7,7 @@
         <result property="id" column="id"/>
         <result property="levelMerchSn" column="level_merch_sn"/>
         <result property="levelMerchFlag" column="level_merch_flag"/>
-        <result property="childSupplierSn" column="child_supplier_sn"/>
+        <result property="childSupplierName" column="child_supplier_name"/>
         <result property="childSupplierFlag" column="child_supplier_flag"/>
         <result property="sortOrder" column="sort_order"/>
         <result property="isShow" column="is_show"/>
@@ -18,7 +18,7 @@
 			`id`,
 			`level_merch_sn`,
 			`level_merch_flag`,
-			`child_supplier_sn`,
+			`child_supplier_name`,
 			`child_supplier_flag`,
 			`sort_order`,
 			`is_show`
@@ -26,12 +26,25 @@
 		where id = #{id}
 	</select>
 
+	<select id="queryObjectByName" resultType="com.kmall.admin.entity.SupplierEntity">
+		select
+		`id`,
+		`level_merch_sn`,
+		`level_merch_flag`,
+		`child_supplier_name`,
+		`child_supplier_flag`,
+		`sort_order`,
+		`is_show`
+		from mall_supplier
+		where child_supplier_name = #{supplierName}
+	</select>
+
 	<select id="queryList" resultType="com.kmall.admin.entity.SupplierEntity">
 		select
     		`id`,
     		`level_merch_sn`,
     		`level_merch_flag`,
-    		`child_supplier_sn`,
+    		`child_supplier_name`,
     		`child_supplier_flag`,
     		`sort_order`,
     		`is_show`
@@ -65,14 +78,14 @@
 		insert into mall_supplier(
 			`level_merch_sn`,
 			`level_merch_flag`,
-			`child_supplier_sn`,
+			`child_supplier_name`,
 			`child_supplier_flag`,
 			`sort_order`,
 			`is_show`)
 		values(
 			#{levelMerchSn},
 			#{levelMerchFlag},
-			#{childSupplierSn},
+			#{childSupplierName},
 			#{childSupplierFlag},
 			#{sortOrder},
 			#{isShow})
@@ -83,7 +96,7 @@
 		<set>
 			<if test="levelMerchSn != null">`level_merch_sn` = #{levelMerchSn}, </if>
 			<if test="levelMerchFlag != null">`level_merch_flag` = #{levelMerchFlag}, </if>
-			<if test="childSupplierSn != null">`child_supplier_sn` = #{childSupplierSn}, </if>
+			<if test="childSupplierName != null">`child_supplier_name` = #{childSupplierName}, </if>
 			<if test="childSupplierFlag != null">`child_supplier_flag` = #{childSupplierFlag}, </if>
 			<if test="sortOrder != null">`sort_order` = #{sortOrder}, </if>
 			<if test="isShow != null">`is_show` = #{isShow}</if>

+ 18 - 0
kmall-admin/src/main/resources/mybatis/mapper/SysCusNationCodeDao.xml

@@ -36,6 +36,24 @@
 		where sn = #{id}
 	</select>
 
+	<select id="queryObjectByName" resultType="com.kmall.admin.entity.SysCusNationCodeEntity">
+		select
+		`sn`,
+		`code`,
+		`name`,
+		`ename`,
+		`discounts_tax_type`,
+		`remark`,
+		`is_valid`,
+		`creater_sn`,
+		`create_time`,
+		`moder_sn`,
+		`mod_time`,
+		`tstm`
+		from sys_cus_nation_code
+		where `name` = #{nationName}
+	</select>
+
 	<select id="queryList" resultType="com.kmall.admin.entity.SysCusNationCodeEntity">
 		select
     		`sn`,

+ 15 - 0
kmall-admin/src/main/resources/mybatis/mapper/SysCusUnitCodeDao.xml

@@ -32,6 +32,21 @@
 		where sn = #{id}
 	</select>
 
+	<select id="queryObjectByName" resultType="com.kmall.admin.entity.SysCusUnitCodeEntity">
+		select
+		`sn`,
+		`code`,
+		`name`,
+		`remark`,
+		`is_valid`,
+		`creater_sn`,
+		`create_time`,
+		`moder_sn`,
+		`mod_time`,
+		`tstm`
+		from sys_cus_unit_code
+		where `name` = #{unitName}
+	</select>
 	<select id="queryList" resultType="com.kmall.admin.entity.SysCusUnitCodeEntity">
 		select
     		`sn`,

BIN
kmall-admin/src/main/webapp/WEB-INF/page/shop/file/general_goods_export_yyyy_mm_dd_v1.0.0.xls


BIN
kmall-admin/src/main/webapp/WEB-INF/page/shop/file/goods_export_yyyy_mm_dd_v1.0.0.xls


+ 30 - 6
kmall-admin/src/main/webapp/WEB-INF/page/shop/goods.html

@@ -56,7 +56,7 @@
     <div v-show="showList">
         <Row :gutter="16">
             <div class="search-group">
-                <i-col span="4">
+                <i-col span="3">
                     <i-input v-model="q.goodsSn" @on-enter="query" placeholder="商品编码"/>
                 </i-col>
                 <i-col span="3">
@@ -80,7 +80,7 @@
                 <i-button @click="query">查询</i-button>
                 <i-button @click="reloadSearch">重置</i-button>
             </div>
-            <div class="buttons-group">
+            <div class="buttons-group" style="width: 100%;margin-top: 8px; padding-left: 10px;">
                 #if($shiro.hasPermission("goods:save"))
                 <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
                 #end
@@ -92,6 +92,30 @@
                 #end
                 <i-button type="primary" @click="enSale"><i class="fa fa-hand-o-up"></i>&nbsp;上架</i-button>
                 <i-button type="dashed" @click="unSale"><i class="fa fa-hand-o-down"></i>&nbsp;下架</i-button>
+                <!--<i-button type="info" @click="goodsExport"><i class="fa fa-plus"></i>&nbsp;商品导入</i-button>-->
+                <!--<i-button type="info" @click="sameGoodsExport"><i class="fa fa-plus"></i>&nbsp;普货商品导入</i-button>-->
+
+                #if($shiro.hasPermission("goods:upload"))
+                <i-col style="display: inline-grid;">
+                    <Upload :show-upload-list="false" :on-success="uploadExcelSuccess" :on-error="uploadExcelError" :on-format-error="uploadExcelFormatError"
+                            :format="['xls','xlsx']"
+                            action="../goods/upload">
+                        <i-button type="ghost" icon="ios-cloud-upload-outline">商品导入</i-button>
+                    </Upload>
+                </i-col>
+                #end
+                #if($shiro.hasPermission("goods:generalGoodsUpload"))
+                <i-col style="display: inline-grid;">
+                    <Upload :show-upload-list="false" :on-success="uploadExcelSuccess" :on-error="uploadExcelError" :on-format-error="uploadExcelFormatError"
+                            :format="['xls','xlsx']"
+                            action="../goods/generalGoodsUpload">
+                        <i-button type="ghost" icon="ios-cloud-upload-outline">普货商品导入</i-button>
+                    </Upload>
+                </i-col>
+                #end
+                &nbsp;&nbsp;&nbsp;&nbsp;
+                <a href="file/goods_export_yyyy_mm_dd_v1.0.0.xls">商品模板下载</a>&nbsp;&nbsp;&nbsp;&nbsp;
+                <a href="file/general_goods_export_yyyy_mm_dd_v1.0.0.xls">普货商品模板下载</a>
             </div>
         </Row>
         <table id="jqGrid"></table>
@@ -142,6 +166,9 @@
                     <Form-item label="SKU" prop="sku">
                         <i-input v-model="goods.sku" placeholder="SKU" style="width: 268px;"/>
                     </Form-item>
+                    <Form-item label="产品条码" prop="prodBarcode">
+                        <i-input v-model="goods.prodBarcode" placeholder="产品条码"/>
+                    </Form-item>
                     <Form-item label="货品业务类型" prop="goodsBizType" >
                         <i-select v-model="goods.goodsBizType" filterable placeholder="货品业务类型"
                                   label-in-value style="width: 268px;" @on-change="changeGoodsBizType">
@@ -159,7 +186,7 @@
                 <Form-item label="供应商" prop="supplierId">
                     <i-select v-model="goods.supplierId" filterable placeholder="供应商"
                               label-in-value style="width: 268px;">
-                        <i-option v-for="supplier in suppliers" :value="supplier.id" :key="supplier.id">{{supplier.childSupplierSn}}
+                        <i-option v-for="supplier in suppliers" :value="supplier.id" :key="supplier.id">{{supplier.childSupplierName}}
                         </i-option>
                     </i-select>
                 </Form-item>
@@ -270,9 +297,6 @@
                     <Form-item label="产品品牌" prop="brand">
                         <i-input v-model="goods.brand" placeholder="产品品牌"/>
                     </Form-item>
-                    <Form-item label="产品条码" prop="prodBarcode">
-                        <i-input v-model="goods.prodBarcode" placeholder="产品条码"/>
-                    </Form-item>
                     <Form-item label="海关备案编号" prop="cusRecCode">
                         <i-input v-model="goods.cusRecCode" placeholder="海关备案编号"/>
                     </Form-item>

+ 2 - 2
kmall-admin/src/main/webapp/WEB-INF/page/shop/supplier.html

@@ -40,8 +40,8 @@
             <Form-item label="一级商户标识" prop="levelMerchFlag">
                 <i-input v-model="supplier.levelMerchFlag" placeholder="一级商户标识" readonly/>
             </Form-item>
-            <Form-item label="二级供货商名称" prop="childSupplierSn">
-                <i-input v-model="supplier.childSupplierSn" placeholder="二级供货商名称"/>
+            <Form-item label="二级供货商名称" prop="childSupplierName">
+                <i-input v-model="supplier.childSupplierName" placeholder="二级供货商名称"/>
             </Form-item>
             <Form-item label="二级供货商标识" prop="childSupplierFlag">
                 <i-input v-model="supplier.childSupplierFlag" placeholder="二级供货商标识"/>

+ 24 - 1
kmall-admin/src/main/webapp/js/shop/goods.js

@@ -111,6 +111,7 @@ var vm = new Vue({
     el: '#rrapp',
     data: {
         showList: true,
+        fileList: true,
         title: null,
         uploadList: [],
         imgName: '',
@@ -497,6 +498,25 @@ var vm = new Vue({
                 vm.categoriesTwo = r.list;
             });
         },
+        uploadExcelSuccess: function (data) {
+            console.log(data);
+            if(data.code==0){
+                alert('导入成功', function (index) {
+                    $("#jqGrid").trigger("reloadGrid");
+                });
+            }else{
+                alert(data.msg);
+            }
+        },
+        uploadExcelError: function () {
+            alert('上传出现异常,请重试!');
+        },
+        uploadExcelFormatError: function (file) {
+            this.$Notice.warning({
+                title: '文件格式不正确',
+                desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。'
+            });
+        },
         handleRemove(file) {
             // 从 upload 实例删除数据
             const fileList = vm.uploadList;
@@ -572,7 +592,10 @@ var vm = new Vue({
         },
         handleSuccessListVideoUrl: function (res, file) {
             vm.goods.videoUrl = file.response.url;
-        }
+        },
+        goodsExport: function () {
+            vm.fileList = false;
+        },
     },
     mounted() {
         // this.uploadList = this.$refs.upload.fileList;

+ 2 - 0
kmall-admin/src/main/webapp/js/shop/storeProductStock.js

@@ -136,6 +136,8 @@ var vm = new Vue({
                 $.get("../goods/info/" + goodsId, function (r) {
                     if (r.goods.goodsBizType == 11) {
                         vm.showInput = true;
+                        vm.productStoreRela.retailPrice = r.goods.retailPrice;
+                        vm.productStoreRela.marketPrice = r.goods.marketPrice;
                     } else {
                         vm.showInput = false;
                     }

+ 3 - 3
kmall-admin/src/main/webapp/js/shop/supplier.js

@@ -6,7 +6,7 @@ $(function () {
 			{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
 			{label: '一级商户编号', name: 'levelMerchSn', index: 'level_merch_sn', width: 80},
 			{label: '一级商户标识', name: 'levelMerchFlag', index: 'level_merch_flag', width: 80},
-			{label: '二级供货商名称', name: 'childSupplierSn', index: 'child_supplier_sn', width: 80},
+			{label: '二级供货商名称', name: 'childSupplierName', index: 'child_supplier_sn', width: 80},
 			{label: '二级供货商标识', name: 'childSupplierFlag', index: 'child_supplier_flag', width: 80},
 			{label: '排序', name: 'sortOrder', index: 'sort_order', width: 80},
 			{label: '是否禁用:0:否;1:是', name: 'isShow', index: 'is_show', width: 80}],
@@ -41,9 +41,9 @@ let vm = new Vue({
 	data: {
         showList: true,
         title: null,
-		supplier: {childSupplierSn: '', childSupplierFlag: '', isShow: 0},
+		supplier: {childSupplierName: '', childSupplierFlag: '', isShow: 0},
 		ruleValidate: {
-            childSupplierSn: [
+            childSupplierName: [
 				{required: true, message: '二级供货商名称不能为空', trigger: 'blur'}
 			],
             childSupplierFlag: [

+ 11 - 0
kmall-common/src/main/java/com/kmall/common/constant/JxlsXmlTemplateName.java

@@ -0,0 +1,11 @@
+package com.kmall.common.constant;
+
+/**
+ *
+ */
+public class JxlsXmlTemplateName {
+    //商品信息导入
+    public static final String GOODS_DTO_LIST = "/XmlTemplate/GoodsDtoList.xml";
+    //普通商品导入
+    public static final String GENERAL_GOODS_DTO_LIST = "/XmlTemplate/GeneralGoodsDtoList.xml";
+}

+ 294 - 0
kmall-common/src/main/java/com/kmall/common/utils/excel/ExcelUtil.java

@@ -0,0 +1,294 @@
+package com.kmall.common.utils.excel;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jxls.reader.ReaderBuilder;
+import org.jxls.reader.XLSReader;
+import org.springframework.stereotype.Component;
+import org.xml.sax.SAXException;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipInputStream;
+
+
+/**
+ * 导出EXCEL表格
+ *
+ * @author 曾俊
+ * @create 2017-05-27 10:26
+ */
+@Component
+public class ExcelUtil {
+
+    /**
+     * @param
+     * @return
+     * @info 写出Excel标题内容
+     */
+    public static void exportExcel(String fileName, String[] titles,
+                                   List<Map<Integer, String>> lists, HttpServletResponse response, HttpServletRequest request) throws IOException {
+        XSSFWorkbook xls = new XSSFWorkbook();
+        XSSFSheet sheet = xls.createSheet("Sheet1");
+        XSSFRow row = sheet.createRow(0);// 第一行
+        for (int i = 0; i < titles.length; i++) {
+            sheet.setColumnWidth(i, (short) 5000);
+            sheet.setColumnWidth(0, (short) 1300);
+            row.createCell(i).setCellValue(titles[i]);
+        }
+        // 内容
+        int rowNum = 1;   //第二行开始
+        for (Map<Integer, String> map : lists) {
+            XSSFRow rowTmp = sheet.createRow(rowNum);
+            int cols = map.size();
+            for (int i = 0; i < cols; i++) {
+                rowTmp.createCell(i).setCellValue(map.get(i));
+            }
+            rowNum++;
+        }
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        xls.write(os);
+        byte[] content = os.toByteArray();
+        InputStream is = new ByteArrayInputStream(content);
+        //根据浏览器不同,对文件的名字进行不同的编码设置
+        final String userAgent = request.getHeader("USER-AGENT");
+        String finalFileName = null;
+        if (userAgent.contains("MSIE") || userAgent.contains("Trident")) {    //IE浏览器
+            finalFileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
+        } else if (StringUtils.contains(userAgent, "Mozilla")) {   //google,火狐浏览器
+            finalFileName = new String((fileName + ".xlsx").getBytes("UTF-8"), "ISO-8859-1");
+        } else {
+            finalFileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");   //其他浏览器
+        }
+        // 设置response参数,可以打开下载页面
+        response.reset();
+        response.setContentType("application/vnd.ms-excel;charset=utf-8");
+        response.setHeader("Content-Disposition", "attachment;filename="
+                + finalFileName);
+        ServletOutputStream out = response.getOutputStream();
+        BufferedInputStream bis = null;
+        BufferedOutputStream bos = null;
+        try {
+            bis = new BufferedInputStream(is);
+            bos = new BufferedOutputStream(out);
+            byte[] buff = new byte[2048];
+            int bytesRead;
+            while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
+                bos.write(buff, 0, bytesRead);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (bis != null)
+                bis.close();
+            if (bos != null)
+                bos.close();
+        }
+        os.close();
+
+    }
+
+
+    /**
+     * 导出文件
+     *
+     * @param fileName
+     * @param response
+     * @param inStream
+     * @throws Exception
+     */
+    public static void exportFile(String fileName, HttpServletResponse response, InputStream inStream) throws Exception {
+        byte[] data = FileUtil.readInputStream(inStream);
+        ServletOutputStream os = null;
+        try {
+            os = response.getOutputStream();
+            response.setContentType("application/octet-stream ");
+            response.setHeader("Connection", "close"); // 表示不能用浏览器直接打开
+            response.setHeader("Accept-Ranges", "bytes");// 告诉客户端允许断点续传多线程连接下载
+            response.setHeader("Content-Disposition",
+                    "attachment;filename=" + new String(fileName.getBytes("GB2312"), "ISO8859-1"));
+            response.setCharacterEncoding("UTF-8");
+            os.write(data);
+        } catch (IOException e) {
+            throw e;
+        } finally {
+            if (inStream != null)
+                inStream.close();
+        }
+        os.close();
+    }
+
+    /**
+     * 读取导入excel
+     *
+     * @param name
+     * @param beans
+     * @param in
+     * @throws InvalidFormatException
+     * @throws SAXException
+     * @throws IOException
+     */
+    public void readExcel(String name, Map<String, Object> beans, InputStream in) throws InvalidFormatException, SAXException, IOException {
+        InputStream inputXML = null;
+        InputStream inputXLS = null;
+        try {
+            inputXML = new BufferedInputStream(this.getClass().getResourceAsStream(name));
+            XLSReader mainReader = ReaderBuilder.buildFromXML(inputXML);
+            inputXLS = new BufferedInputStream(in);
+            mainReader.read(inputXLS, beans);
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            if (inputXML != null) {
+                inputXML.close();
+            }
+            if (inputXLS != null) {
+                inputXLS.close();
+            }
+
+        }
+
+    }
+
+    /**
+     * 读取导入excel  只用于ZipInputStream 因为ZipInputStream不能在这个时候关闭
+     *
+     * @param name
+     * @param beans
+     * @param in
+     * @throws InvalidFormatException
+     * @throws SAXException
+     * @throws IOException
+     */
+    public void readZipExcel(String name, Map<String, Object> beans, ZipInputStream in) throws InvalidFormatException, SAXException, IOException {
+        InputStream inputXML = null;
+        InputStream inputXLS = null;
+        try {
+            inputXML = new BufferedInputStream(this.getClass().getResourceAsStream(name));
+            XLSReader mainReader = ReaderBuilder.buildFromXML(inputXML);
+            inputXLS = new BufferedInputStream(in);
+            mainReader.read(in, beans);
+        } catch (Exception e) {
+            throw e;
+        } finally {
+//            if (inputXML != null) {
+//                inputXML.close();
+//            }
+        }
+
+    }
+
+
+    /**
+     * @desc 拿到图片OSS路径转换为流
+     * @author 曾俊
+     * @create 2017/7/25 0025 17:31
+     **/
+    public static InputStream getInputStream(String path) throws IOException {
+        InputStream inputStream = null;
+        HttpURLConnection httpURLConnection = null;
+        try {
+            URL url = new URL(path);
+            if (url != null) {
+                httpURLConnection = (HttpURLConnection) url.openConnection();
+                httpURLConnection.setConnectTimeout(3000);
+                httpURLConnection.setRequestMethod("GET");
+                int responseCode = httpURLConnection.getResponseCode();
+                if (responseCode == 200) {
+                    inputStream = httpURLConnection.getInputStream();
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+        return inputStream;
+
+    }
+
+    /**
+     * @param
+     * @return
+     * @info 写出Excel标题内容
+     */
+    public static void exportFormatExcel(String fileName, String[] titles,String width[],
+                                         List<Map<Integer, String>> lists, HttpServletResponse response, HttpServletRequest request) throws IOException {
+        XSSFWorkbook xls = new XSSFWorkbook();
+        XSSFSheet sheet = xls.createSheet("Sheet1");
+        XSSFRow row = sheet.createRow(0);// 第一行
+        row.setHeight((short)600);
+
+        for (int i = 0; i < titles.length; i++) {
+            row.createCell(i).setCellValue(titles[i]);
+            sheet.setColumnWidth(i, Integer.valueOf(width[i]));
+        }
+        if(lists.size()>1){//合并单元格
+            sheet.addMergedRegion(new CellRangeAddress(1,lists.size(),8,8));
+            sheet.addMergedRegion(new CellRangeAddress(1,lists.size(),9,9));
+            sheet.addMergedRegion(new CellRangeAddress(1,lists.size(),10,10));
+        }
+
+        // 内容
+        int rowNum = 1;   //第二行开始
+        for (Map<Integer, String> map : lists) {
+            XSSFRow rowTmp = sheet.createRow(rowNum);
+            int cols = map.size();
+            for (int i = 0; i < cols; i++) {
+                rowTmp.createCell(i).setCellValue(map.get(i));
+            }
+            rowNum++;
+        }
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        xls.write(os);
+        byte[] content = os.toByteArray();
+        InputStream is = new ByteArrayInputStream(content);
+        //根据浏览器不同,对文件的名字进行不同的编码设置
+        final String userAgent = request.getHeader("USER-AGENT");
+        String finalFileName = null;
+        if (userAgent.contains("MSIE") || userAgent.contains("Trident")) {    //IE浏览器
+            finalFileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
+        } else if (StringUtils.contains(userAgent, "Mozilla")) {   //google,火狐浏览器
+            finalFileName = new String((fileName + ".xlsx").getBytes("UTF-8"), "ISO-8859-1");
+        } else {
+            finalFileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");   //其他浏览器
+        }
+        // 设置response参数,可以打开下载页面
+        response.reset();
+        response.setContentType("application/vnd.ms-excel;charset=utf-8");
+        response.setHeader("Content-Disposition", "attachment;filename="
+                + finalFileName);
+        ServletOutputStream out = response.getOutputStream();
+        BufferedInputStream bis = null;
+        BufferedOutputStream bos = null;
+        try {
+            bis = new BufferedInputStream(is);
+            bos = new BufferedOutputStream(out);
+            byte[] buff = new byte[2048];
+            int bytesRead;
+            while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
+                bos.write(buff, 0, bytesRead);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (bis != null)
+                bis.close();
+            if (bos != null)
+                bos.close();
+        }
+        os.close();
+
+    }
+
+}

+ 406 - 0
kmall-common/src/main/java/com/kmall/common/utils/excel/FileUtil.java

@@ -0,0 +1,406 @@
+package com.kmall.common.utils.excel;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.*;
+import java.util.zip.ZipInputStream;
+
+/**
+ * FileUtil. Simple file operation class.
+ * 
+ * @author BeanSoft
+ */
+public class FileUtil {
+	/**
+	 * The buffer.
+	 */
+	protected static byte buf[] = new byte[1024];
+
+	/**
+	 * 创建路径
+	 * 
+	 * @param path
+	 * @return
+	 */
+	public static boolean mkdirs(String path) {
+		try {
+			File f = new File(path);
+			if (!f.exists()) {
+				f.mkdirs();
+			}
+		} catch (Exception e) {
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * Read content from local file. FIXME How to judge UTF-8 and GBK, the correct code should be: FileReader fr = new FileReader(new
+	 * InputStreamReader(fileName, "ENCODING")); Might let the user select the encoding would be a better idea. While reading UTF-8 files, the content
+	 * is bad when saved out.
+	 * 
+	 * @param fileName
+	 *            - local file name to read
+	 * @return
+	 * @throws Exception
+	 */
+	public static String readFileAsString(String fileName) throws Exception {
+		String content = new String(readFileBinary(fileName));
+
+		return content;
+	}
+
+	/**
+	 * 读取文件并返回为给定字符集的字符串.
+	 * 
+	 * @param fileName
+	 * @param encoding
+	 * @return
+	 * @throws Exception
+	 */
+	public static String readFileAsString(String fileName, String encoding) throws Exception {
+		String content = new String(readFileBinary(fileName), encoding);
+
+		return content;
+	}
+
+	/**
+	 * 读取文件并返回为给定字符集的字符串.
+	 *
+	 * @return
+	 * @throws IOException
+	 * @throws Exception
+	 */
+	public static String readFileAsString(InputStream in) throws IOException {
+		String content = new String(readFileBinary(in));
+		return content;
+	}
+
+	/**
+	 * Read content from local file to binary byte array.
+	 * 
+	 * @param fileName
+	 *            - local file name to read
+	 * @return
+	 * @throws Exception
+	 */
+	public static byte[] readFileBinary(String fileName) throws Exception {
+		FileInputStream fin = new FileInputStream(fileName);
+
+		return readFileBinary(fin);
+	}
+
+	/**
+	 * 从输入流读取数据为二进制字节数组.
+	 * 
+	 * @param streamIn
+	 * @return
+	 * @throws IOException
+	 */
+	public static byte[] readFileBinary(InputStream streamIn) throws IOException {
+		BufferedInputStream in = new BufferedInputStream(streamIn);
+
+		ByteArrayOutputStream out = new ByteArrayOutputStream(10240);
+
+		int len;
+		while ((len = in.read(buf)) >= 0)
+			out.write(buf, 0, len);
+		in.close();
+
+		return out.toByteArray();
+	}
+
+	/**
+	 * Write string content to local file.
+	 * 
+	 * @param fileName
+	 *            - local file name will write to
+	 * @param content
+	 *            String text
+	 * @return true if success
+	 * @throws IOException
+	 */
+	public static boolean writeFileString(String fileName, String content) throws IOException {
+		FileWriter fout = new FileWriter(fileName);
+		fout.write(content);
+		fout.close();
+		return true;
+	}
+
+	/**
+	 * Write string content to local file using given character encoding.
+	 * 
+	 * @param fileName
+	 *            - local file name will write to
+	 * @param content
+	 *            String text
+	 * @param encoding
+	 *            the encoding
+	 * @return true if success
+	 * @throws IOException
+	 */
+	public static boolean writeFileString(String fileName, String content, String encoding) throws IOException {
+		OutputStreamWriter fout = new OutputStreamWriter(new FileOutputStream(fileName), encoding);
+
+		fout.write(content);
+		fout.close();
+		return true;
+	}
+
+	/**
+	 * Write binary byte array to local file.
+	 * 
+	 * @param fileName
+	 *            - local file name will write to
+	 * @param content
+	 *            binary byte array
+	 * @return true if success
+	 * @throws IOException
+	 */
+	public static boolean writeFileBinary(String fileName, byte[] content) throws IOException {
+		if (content == null || StringUtils.isEmpty(fileName)) {
+			return false;
+		}
+		FileOutputStream fout = null;
+		try {
+			fout = new FileOutputStream(fileName);
+			fout.write(content);
+		} catch (IOException e) {
+			throw e;
+		} finally {
+			if (fout != null) {
+				try {
+					fout.close();
+				} catch (IOException e) {
+				}
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * 检查文件名是否合法.文件名字不能包含字符\/:*?"<>|
+	 *
+	 *            ,不包含路径
+	 * @return boolean is valid file name
+	 */
+	public static boolean isValidFileName(String fileName) {
+		boolean isValid = true;
+		String errChar = "\\/:*?\"<>|"; //
+		if (fileName == null || fileName.length() == 0) {
+			isValid = false;
+		} else {
+			for (int i = 0; i < errChar.length(); i++) {
+				if (fileName.indexOf(errChar.charAt(i)) != -1) {
+					isValid = false;
+					break;
+				}
+			}
+		}
+		return isValid;
+	}
+
+	/**
+	 * 把非法文件名转换为合法文件名.
+	 * 
+	 * @param fileName
+	 * @return
+	 */
+	public static String replaceInvalidFileChars(String fileName) {
+		StringBuffer out = new StringBuffer();
+
+		for (int i = 0; i < fileName.length(); i++) {
+			char ch = fileName.charAt(i);
+			// Replace invlid chars: \\/:*?\"<>|
+			switch (ch) {
+			case '\\':
+			case '/':
+			case ':':
+			case '*':
+			case '?':
+			case '\"':
+			case '<':
+			case '>':
+			case '|':
+				out.append('_');
+				break;
+			default:
+				out.append(ch);
+			}
+		}
+
+		return out.toString();
+	}
+
+	/**
+	 * Convert a given file name to a URL(URI) string.
+	 * 
+	 * @param fileName
+	 *            - the file to parse
+	 * @return - URL string
+	 */
+	public static String filePathToURL(String fileName) {
+		String fileUrl = new File(fileName).toURI().toString();
+		return fileUrl;
+	}
+
+	/**
+	 * Write string content to local file.
+	 * 
+	 * @param fileName
+	 *            - local file name will write to
+	 * @param content
+	 *            String text
+	 * @return true if success
+	 * @throws IOException
+	 */
+	public static boolean appendFileString(String fileName, String content) throws IOException {
+		OutputStreamWriter fout = new OutputStreamWriter(new FileOutputStream(fileName, true), "UTF-8");
+		fout.write(content);
+		fout.close();
+		return true;
+	}
+
+	/**
+	 * 根据文件路径和文件名获取文件名
+	 * 
+	 * @param filePathAndName
+	 * @return
+	 */
+	public static String getFileName(String filePathAndName) {
+		int a = filePathAndName.lastIndexOf("\\");
+		int b = filePathAndName.lastIndexOf("/");
+		String fileName = filePathAndName.substring((a > b ? a : b) + 1, filePathAndName.length());
+		return fileName;
+	}
+
+	public static boolean copy(String fileFrom, String fileTo) {
+		FileInputStream in = null;
+		FileOutputStream out = null;
+		try {
+			in = new FileInputStream(fileFrom);
+			out = new FileOutputStream(fileTo);
+			byte[] bt = new byte[1024];
+			int count;
+			while ((count = in.read(bt)) > 0) {
+				out.write(bt, 0, count);
+			}
+			return true;
+		} catch (IOException ex) {
+			ex.printStackTrace();
+			return false;
+		} finally {
+			try {
+				if (in != null) {
+					in.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			try {
+				if (out != null) {
+					out.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	/**
+	 * 读取输入流
+	 * @param inStream
+	 * @return
+	 * @throws Exception
+	 */
+	public static byte[] readInputStream(InputStream inStream) throws Exception {
+		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+		//创建一个Buffer字符串
+		byte[] buffer = new byte[1024];
+		//每次读取的字符串长度,如果为-1,代表全部读取完毕
+		int len = 0;
+		//读取一定数量的字节从输入流并存入缓冲区 buffer
+		while ((len = inStream.read(buffer)) != -1) {
+			//用输出流往buffer里写入数据,中间参数代表从哪个位置开始读,len代表读取的长度
+			//写 len字节指定字节数组中的偏移 off开始到输出流。
+			outStream.write(buffer, 0, len);
+		}
+		//关闭输入流
+		inStream.close();
+		//把outStream里的数据写入内存
+		return outStream.toByteArray();
+	}
+
+
+	/**
+	 * 读取输入流
+	 * @param inStream
+	 * @return
+	 * @throws Exception
+	 */
+	public static byte[] readZipInputStream(ZipInputStream inStream) throws Exception {
+		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+		//创建一个Buffer字符串
+		byte[] buffer = new byte[1024];
+		//每次读取的字符串长度,如果为-1,代表全部读取完毕
+		int len = 0;
+		//读取一定数量的字节从输入流并存入缓冲区 buffer
+		while ((len = inStream.read(buffer)) != -1) {
+			//用输出流往buffer里写入数据,中间参数代表从哪个位置开始读,len代表读取的长度
+			//写 len字节指定字节数组中的偏移 off开始到输出流。
+			outStream.write(buffer, 0, len);
+		}
+		//关闭当前的压缩条目并将流用于读取下一个条目。
+		inStream.closeEntry();
+		//把outStream里的数据写入内存
+		return outStream.toByteArray();
+	}
+
+
+
+
+	//删除指定文件夹下所有文件
+//param path 文件夹完整绝对路径
+	public static boolean delAllFile(String path) {
+		boolean flag = false;
+		File file = new File(path);
+		if (!file.exists()) {
+			return flag;
+		}
+		if (!file.isDirectory()) {
+			return flag;
+		}
+		String[] tempList = file.list();
+		File temp = null;
+		for (int i = 0; i < tempList.length; i++) {
+			if (path.endsWith(File.separator)) {
+				temp = new File(path + tempList[i]);
+			} else {
+				temp = new File(path + File.separator + tempList[i]);
+			}
+			if (temp.isFile()) {
+				temp.delete();
+			}
+			if (temp.isDirectory()) {
+				delAllFile(path + "/" + tempList[i]);//先删除文件夹里面的文件
+				delFolder(path + "/" + tempList[i]);//再删除空文件夹
+				flag = true;
+			}
+		}
+		return flag;
+	}
+
+
+	public static void delFolder(String folderPath) {
+		try {
+			delAllFile(folderPath); //删除完里面所有内容
+			String filePath = folderPath;
+			filePath = filePath.toString();
+			File myFilePath = new File(filePath);
+			myFilePath.delete(); //删除空文件夹
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+}