|  | @@ -3,17 +3,25 @@ package com.kmall.admin.controller;
 | 
	
		
			
				|  |  |  import com.google.common.collect.ImmutableBiMap;
 | 
	
		
			
				|  |  |  import com.kmall.admin.dto.CopyBrandDto;
 | 
	
		
			
				|  |  |  import com.kmall.admin.dto.CopyCategoryDto;
 | 
	
		
			
				|  |  | +import com.kmall.admin.dto.StoreGoodsDto;
 | 
	
		
			
				|  |  |  import com.kmall.admin.entity.BrandEntity;
 | 
	
		
			
				|  |  | +import com.kmall.admin.entity.ProductStoreRelaEntity;
 | 
	
		
			
				|  |  |  import com.kmall.admin.service.BrandService;
 | 
	
		
			
				|  |  |  import com.kmall.admin.utils.ParamUtils;
 | 
	
		
			
				|  |  | +import com.kmall.common.constant.Dict;
 | 
	
		
			
				|  |  | +import com.kmall.common.constant.JxlsXmlTemplateName;
 | 
	
		
			
				|  |  |  import com.kmall.common.utils.*;
 | 
	
		
			
				|  |  | +import com.kmall.common.utils.excel.ExcelExport;
 | 
	
		
			
				|  |  | +import com.kmall.common.utils.excel.ExcelUtil;
 | 
	
		
			
				|  |  | +import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.apache.shiro.authz.annotation.RequiresPermissions;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  | +import org.springframework.web.multipart.MultipartFile;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  | -import java.util.Map;
 | 
	
		
			
				|  |  | -import java.util.Objects;
 | 
	
		
			
				|  |  | +import javax.servlet.http.HttpServletRequest;
 | 
	
		
			
				|  |  | +import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * Controller
 | 
	
	
		
			
				|  | @@ -28,6 +36,9 @@ public class BrandController {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private BrandService brandService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ExcelUtil excelUtil;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查看列表
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -140,4 +151,85 @@ public class BrandController {
 | 
	
		
			
				|  |  |          brandService.saveCopyCategory(copyBrandDto);
 | 
	
		
			
				|  |  |          return R.ok();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 品牌导出
 | 
	
		
			
				|  |  | +     * @param params
 | 
	
		
			
				|  |  | +     * @param response
 | 
	
		
			
				|  |  | +     * @param request
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @RequestMapping(value = "export")
 | 
	
		
			
				|  |  | +    public R export(@RequestParam Map<String, Object> params, HttpServletResponse response, HttpServletRequest request) {
 | 
	
		
			
				|  |  | +        // 根据条件查询出列表
 | 
	
		
			
				|  |  | +        List<BrandEntity> brandEntityList = brandService.queryExportList(params);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        ExcelExport ee = new ExcelExport("品牌制造商信息");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String[] header = new String[]{"品牌id","所属商户","所属商户id","所属分类","所属分类id","品牌名称","描述","是否显示","是否新品牌"};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<Map<String, Object>> list = new ArrayList<>();
 | 
	
		
			
				|  |  | +        if (brandEntityList!=null && brandEntityList.size()>0){
 | 
	
		
			
				|  |  | +            for (BrandEntity brandEntity : brandEntityList) {
 | 
	
		
			
				|  |  | +                LinkedHashMap<String, Object> map = new LinkedHashMap<>();
 | 
	
		
			
				|  |  | +                map.put("Id",brandEntity.getId());
 | 
	
		
			
				|  |  | +                map.put("MerchName",brandEntity.getMerchName());
 | 
	
		
			
				|  |  | +                map.put("MerchSn",brandEntity.getMerchSn());
 | 
	
		
			
				|  |  | +                map.put("CategoryName",brandEntity.getCategoryName());
 | 
	
		
			
				|  |  | +                map.put("CategoryId",brandEntity.getCategoryId());
 | 
	
		
			
				|  |  | +                map.put("BrandName",brandEntity.getName());
 | 
	
		
			
				|  |  | +                map.put("SimpleDesc",brandEntity.getSimpleDesc());
 | 
	
		
			
				|  |  | +                map.put("IsShow",brandEntity.getIsShow()==1?"是":"否");
 | 
	
		
			
				|  |  | +                map.put("IsNew",brandEntity.getIsNew()==1?"是":"否");
 | 
	
		
			
				|  |  | +                list.add(map);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        ee.addSheetByMap("品牌制造商信息", list, header);
 | 
	
		
			
				|  |  | +        ee.export(response);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return R.ok();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 导入品牌
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @RequestMapping("/upload")
 | 
	
		
			
				|  |  | +    @ResponseBody
 | 
	
		
			
				|  |  | +    public R upload(@RequestParam("file") MultipartFile file) {
 | 
	
		
			
				|  |  | +        List<BrandEntity> brandEntityList = new ArrayList<>();//信息
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            BrandEntity brandEntity = new BrandEntity();
 | 
	
		
			
				|  |  | +            Map<String, Object> beans = new HashMap<String, Object>();
 | 
	
		
			
				|  |  | +            beans.put("BrandEntity", brandEntity);
 | 
	
		
			
				|  |  | +            beans.put("BrandEntityList", brandEntityList);
 | 
	
		
			
				|  |  | +            if (file.isEmpty()) {
 | 
	
		
			
				|  |  | +                return R.error("文件不能为空!");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            excelUtil.readExcel(JxlsXmlTemplateName.BRAND_DTO_LIST, beans, file.getInputStream());
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            e.printStackTrace();
 | 
	
		
			
				|  |  | +            return R.error("导入失败!");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        brandService.uploadExcel(brandEntityList);
 | 
	
		
			
				|  |  | +        //上传文件
 | 
	
		
			
				|  |  | +        return R.ok("导入成功!");
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |