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

[商铺][新增][列表导出]

release_toaliyun_real
luozukai 7 лет назад
Родитель
Сommit
72b44d8fbd
8 измененных файлов: 375 добавлений и 39 удалений
  1. +19
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxShopController.java
  2. +43
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumPointType.java
  3. +1
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxShopMapper.java
  4. +9
    -0
      mallinkService/src/main/java/com/iformall/service/WxShopService.java
  5. +4
    -33
      mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java
  6. +139
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java
  7. +40
    -0
      mallinkService/src/main/java/com/iformall/utils/DownFileUtil.java
  8. +120
    -2
      mallinkService/src/main/resources/mapper/WxShopMapper.xml

+ 19
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxShopController.java Просмотреть файл

@@ -3,16 +3,20 @@ package com.iformall.controller;
import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCUserBasicInfo;
import com.iformall.domain.po.WxShop;
import com.iformall.service.WxShopService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
@@ -119,4 +123,19 @@ public class WxShopController extends BaseController {
return new ResultData(page);
}

@ApiOperation("导出店铺")
@GetMapping("/exportShop")
public void exportShop(@ModelAttribute WxShop wxShop, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxShopController::exportShop");
if (null == wxShop){
wxShop = new WxShop();
}
wxShop.setTenantId(getTenantId());
wxShop.setSortColumns(WxShop.Field.Id_DESC);
wxShopService.exportShop(wxShop, request, response);
}




}

+ 43
- 0
mallinkService/src/main/java/com/iformall/enums/EnumPointType.java Просмотреть файл

@@ -0,0 +1,43 @@
package com.iformall.enums;


/**
* @author luozukai
* 点位类型1固定点位2临时促销点位3宣传点位4ATM点位5仓库点位6其他点位
*/

public enum EnumPointType {

POINT1(1, "固定点位"),
POINT2(2, "临时促销点位"),
POINT3(3, "宣传点位"),
POINT4(4, "ATM点位"),
POINT5(5, "仓库点位"),
OTHER(6, "其他点位"),
;

public static EnumPointType getEnum(Integer code) {
for (EnumPointType value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumPointType(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

+ 1
- 0
mallinkService/src/main/java/com/iformall/mapper/WxShopMapper.java Просмотреть файл

@@ -26,4 +26,5 @@ public interface WxShopMapper extends CommonMapper<WxShop, String> {

int hasShopNumber(WxShop wxShop);

List<Map<String,Object>> findListWithMerchantMap(WxShop record);
}

+ 9
- 0
mallinkService/src/main/java/com/iformall/service/WxShopService.java Просмотреть файл

@@ -4,6 +4,8 @@ import java.util.*;
import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxShop;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public interface WxShopService {

@@ -50,4 +52,11 @@ public interface WxShopService {

PageInfo<Map<String,Object>> listShopFromContract(WxShop wxShop, Integer pageNum, Integer pageSize);

/**
* 导出商铺数据
* @param wxShop
* @param request
* @param response
*/
void exportShop(WxShop wxShop, HttpServletRequest request, HttpServletResponse response);
}

+ 4
- 33
mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java Просмотреть файл

@@ -19,6 +19,7 @@ import com.iformall.service.WxCUserBasicInfoService;
import com.iformall.service.WxCUserTagsService;
import com.iformall.service.WxScoreRulesService;
import com.iformall.utils.Constant;
import com.iformall.utils.DownFileUtil;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
@@ -267,43 +268,13 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService {
workbook.write(fileOut);
fileOut.close();
workbook.close();
downFile(filepath, filename,"会员信息数据.xlsx",response, request);
DownFileUtil.downFile(filepath,"会员信息数据.xlsx",response, request);
FileUtils.forceDelete(file);
} catch (Exception e) {
e.printStackTrace();
}
}

public void downFile(String filePath, String filename,String exportFileName, HttpServletResponse response,
HttpServletRequest req) throws IOException {
try {
response.reset();
response.setContentType("bin");
String agent = req.getHeader("user-agent");
if (agent.contains("Firefox")) {
response.setHeader("Content-disposition",
"attachment; filename="
+ new String(exportFileName.getBytes("GB2312"),
"ISO-8859-1"));
} else {
response
.setHeader("Content-disposition",
"attachment; filename="
+ java.net.URLEncoder.encode(exportFileName,
"UTF-8"));
}
// 循环取出流中的数据
byte[] b = new byte[1024];
int len;
InputStream inStream = new FileInputStream(filePath);
while ((len = inStream.read(b)) > 0)
response.getOutputStream().write(b, 0, len);
inStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void exportTemplate(HttpServletRequest request, HttpServletResponse response, String tenantId) {

@@ -424,7 +395,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService {
workbook.write(fileOut);
fileOut.close();
workbook.close();
downFile(filepath, filename, "会员信息模板.xlsx",response, request);
DownFileUtil.downFile(filepath, "会员信息模板.xlsx",response, request);
FileUtils.forceDelete(file);
} catch (Exception e) {
logger.error("导出模板:" + e.getMessage());
@@ -699,7 +670,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService {
fileOut.close();
workbook.close();
String name = (record.getIsPay()!=null && 1==record.getIsPay())?"线上缴费车辆数据":"进出车辆数据";
downFile(filepath, filename,name+".xlsx",response, request);
DownFileUtil.downFile(filepath,name+".xlsx",response, request);
FileUtils.forceDelete(file);
} catch (Exception e) {
e.printStackTrace();


+ 139
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java Просмотреть файл

@@ -1,20 +1,29 @@
package com.iformall.service.impl;

import java.io.*;
import java.util.*;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxShop;
import com.iformall.enums.EnumShopStatus;
import com.iformall.enums.*;
import com.iformall.mapper.WxShopMapper;
import com.iformall.service.WxShopService;
import com.iformall.utils.Constant;
import com.iformall.utils.DownFileUtil;
import org.apache.commons.io.FileUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iformall.common.IdWorker;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Service
public class WxShopServiceImpl implements WxShopService {
@@ -23,7 +32,6 @@ public class WxShopServiceImpl implements WxShopService {
@Autowired
WxShopMapper wxShopMapper;


@Override
public PageInfo<WxShop> listAsPage(WxShop record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxShopMapper.findList(record));
@@ -31,7 +39,6 @@ public class WxShopServiceImpl implements WxShopService {

@Override
public PageInfo<Map<String,Object>> listMapAsPage(WxShop record, Integer pageIndex, Integer pageSize) {
PageHelper.startPage(pageIndex, pageSize);
List<Map<String,Object>> shops = wxShopMapper.findListMap(record);
PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(shops);

@@ -103,4 +110,132 @@ public class WxShopServiceImpl implements WxShopService {
return pageInfo;
}

@Override
public void exportShop(WxShop wxShop, HttpServletRequest request, HttpServletResponse response) {
List<Map<String,Object>> shopList = wxShopMapper.findListWithMerchantMap(wxShop);

SXSSFWorkbook workbook;
String filepath = Constant.fileDirectory;
File savefile = new File(filepath);
if (!savefile.exists()) {
savefile.mkdirs();
}
String filename = UUID.randomUUID() + ".xlsx";
filepath = filepath + filename;

try {
File file = new File(filepath);
workbook = new SXSSFWorkbook(100);
String sheetName = EnumRentShopType.SHOP.getCode().equals(wxShop.getType())?"店铺列表":"多经点位列表";
SXSSFSheet sheetTwo = workbook.createSheet(sheetName);
Row rowtwo = sheetTwo.createRow(0);

Cell cell1,cell2,cell3,cell4,cell5,cell6,cell7,cell8,cell9,cell10,cell11;
if(EnumRentShopType.POINT.getCode().equals(wxShop.getType())){
Cell cell0 = rowtwo.createCell(0);
cell0.setCellValue("多经点位类型");
cell1 = rowtwo.createCell(1);
cell2 = rowtwo.createCell(2);
cell3 = rowtwo.createCell(3);
cell4 = rowtwo.createCell(4);
cell5 = rowtwo.createCell(5);
cell6 = rowtwo.createCell(6);
cell7 = rowtwo.createCell(7);
cell8 = rowtwo.createCell(8);
cell9 = rowtwo.createCell(9);
cell10 = rowtwo.createCell(10);
cell11 = rowtwo.createCell(11);
}else{
cell1 = rowtwo.createCell(0);
cell2 = rowtwo.createCell(1);
cell3 = rowtwo.createCell(2);
cell4 = rowtwo.createCell(3);
cell5 = rowtwo.createCell(4);
cell6 = rowtwo.createCell(5);
cell7 = rowtwo.createCell(6);
cell8 = rowtwo.createCell(7);
cell9 = rowtwo.createCell(8);
cell10 = rowtwo.createCell(9);
cell11 = rowtwo.createCell(10);
}

cell1.setCellValue(EnumRentShopType.SHOP.getCode().equals(wxShop.getType())?"店铺号":"多经点位号");
cell2.setCellValue("租赁商户");
cell3.setCellValue("楼层");
cell4.setCellValue("楼座");
cell5.setCellValue("建筑面积(㎡)");
cell6.setCellValue("计租面积(㎡)");
cell7.setCellValue("状态");
// 商户信息
cell8.setCellValue("经营业态");
cell9.setCellValue("品牌");
cell10.setCellValue("负责人");
cell11.setCellValue("负责人电话");

for (int i = 0; i < shopList.size(); i++) {
rowtwo = sheetTwo.createRow(i + 1);
Map<String,Object> entity = shopList.get(i);

if(EnumRentShopType.POINT.getCode().equals(wxShop.getType())){
Cell cell0 = rowtwo.createCell(0);
if (entity.get("pointType") != null) {
cell0.setCellValue(EnumPointType.getEnum((Integer) entity.get("pointType")).getMessage());
}
cell1 = rowtwo.createCell(1);
cell2 = rowtwo.createCell(2);
cell3 = rowtwo.createCell(3);
cell4 = rowtwo.createCell(4);
cell5 = rowtwo.createCell(5);
cell6 = rowtwo.createCell(6);
cell7 = rowtwo.createCell(7);
cell8 = rowtwo.createCell(8);
cell9 = rowtwo.createCell(9);
cell10 = rowtwo.createCell(10);
cell11 = rowtwo.createCell(11);
}else{
cell1 = rowtwo.createCell(0);
cell2 = rowtwo.createCell(1);
cell3 = rowtwo.createCell(2);
cell4 = rowtwo.createCell(3);
cell5 = rowtwo.createCell(4);
cell6 = rowtwo.createCell(5);
cell7 = rowtwo.createCell(6);
cell8 = rowtwo.createCell(7);
cell9 = rowtwo.createCell(8);
cell10 = rowtwo.createCell(9);
cell11 = rowtwo.createCell(10);
}
cell1.setCellValue((String)entity.get("shopNumber"));
cell2.setCellValue((String)entity.get("merchantName"));
cell3.setCellValue((String)entity.get("floor"));
cell4.setCellValue((String)entity.get("building"));
cell5.setCellValue((String)entity.get("buildArea"));
cell6.setCellValue((String)entity.get("operationArea"));
if(entity.get("status") != null) {
if(EnumShopStatus.RENT.getCode().equals(entity.get("status"))) {
cell7.setCellValue("已出租");
// 查询商户信息
cell8.setCellValue((String)entity.get("title"));
cell9.setCellValue((String)entity.get("brand"));
cell10.setCellValue((String)entity.get("link_person"));
cell11.setCellValue((String)entity.get("link_phone"));
}else{
cell7.setCellValue("未出租");
}
}
}

FileOutputStream fileOut = new FileOutputStream(file);
workbook.write(fileOut);
fileOut.close();
workbook.close();
String name = "店铺列表";
DownFileUtil.downFile(filepath,name+".xlsx",response, request);
FileUtils.forceDelete(file);
} catch (Exception e) {
e.printStackTrace();
}
}


}

+ 40
- 0
mallinkService/src/main/java/com/iformall/utils/DownFileUtil.java Просмотреть файл

@@ -0,0 +1,40 @@
package com.iformall.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
* @author luozukai
* 文件下载
* @date 2019/2/13 15:32
*/
public class DownFileUtil {

public static void downFile(String filePath,String exportFileName, HttpServletResponse response,
HttpServletRequest req) throws IOException {
response.reset();
response.setContentType("bin");
String agent = req.getHeader("user-agent");
if (agent.contains("Firefox")) {
response.setHeader("Content-disposition",
"attachment; filename="
+ new String(exportFileName.getBytes("GB2312"),
"ISO-8859-1"));
} else {
response.setHeader("Content-disposition",
"attachment; filename="
+ java.net.URLEncoder.encode(exportFileName,
"UTF-8"));
}
// 循环取出流中的数据
byte[] b = new byte[1024];
int len;
InputStream inStream = new FileInputStream(filePath);
while ((len = inStream.read(b)) > 0)
response.getOutputStream().write(b, 0, len);
inStream.close();
}
}

+ 120
- 2
mallinkService/src/main/resources/mapper/WxShopMapper.xml Просмотреть файл

@@ -152,7 +152,8 @@
s.img_url imgUrl,s.operation_area operationArea,
s.status,b.building_name building,f.floor_name floor,m.`name` merchantName,m.id merchantId,
m.link_person linkPerson,m.link_phone linkPhone,s.manager,s.manager_phone managerPhone,
s.type,s.point_type pointType,s.addr
s.type,s.point_type pointType,s.addr,
m.
from wx_shop s left join wx_merchant_shop ms on ms.shop_id=s.id and ms.is_del=0
left join wx_merchant m on ms.merchant_id=m.id
left join wx_mall_building b on s.building=b.id
@@ -258,10 +259,127 @@
</foreach>
</if>
<if test=" null != sortColumns">order by s.${sortColumns}</if>
</select>


<select id="findListWithMerchantMap" parameterType="com.iformall.domain.po.WxShop" resultType="hashmap">
select s.id,s.shop_number shopNumber,s.build_area buildArea,
s.img_url imgUrl,s.operation_area operationArea,
s.status,b.building_name building,f.floor_name floor,m.`name` merchantName,m.id merchantId,
m.link_person linkPerson,m.link_phone linkPhone,s.manager,s.manager_phone managerPhone,
s.type,s.point_type pointType,s.addr,
brand.name brand,m.link_person,m.link_phone,bus.title
from wx_shop s left join wx_merchant_shop ms on ms.shop_id=s.id and ms.is_del=0
left join wx_merchant m on ms.merchant_id=m.id
left join wx_mall_building b on s.building=b.id
left join wx_mall_floor f on s.floor=f.id
left join wx_business bus on m.business_id = bus.id
left join wx_brand brand on m.brand = brand.id
where 1 = 1

</select>
<if test=" null != id ">
and s.`id` = #{id}

</if>

<if test=" null != tenantId ">
and s.`tenant_id`= #{tenantId}

</if>

<if test=" null != shopNumber and ''!=shopNumber">
and s.`shop_number` like concat('%', #{shopNumber},'%')

</if>

<if test=" null != buildArea ">
and s.`build_area` like concat('%', #{buildArea},'%')

</if>

<if test=" null != operationArea ">
and s.`operation_area` like concat('%', #{operationArea},'%')

</if>

<if test=" null != building ">
and s.`building`= #{building}

</if>

<if test=" null != floor ">
and s.`floor` = #{floor}

</if>

<if test=" null != status">
and s.`status` = #{status}

</if>

<if test=" null != x ">
and s.`x` = #{x}

</if>

<if test=" null != y ">
and s.`y` = #{y}

</if>

<if test=" null != addr ">
and s.`addr` like concat('%', #{addr},'%')

</if>

<if test=" null != baiduPoi ">
and s.`baidu_poi` like concat('%', #{baiduPoi},'%')

</if>

<if test=" null != longitude ">
and s.`longitude` = #{longitude}

</if>

<if test=" null != latitude ">
and s.`latitude` = #{latitude}

</if>

<if test=" null != createDate ">
and s.`create_date` = #{createDate}

</if>

<if test=" null != updateDate ">
and s.`update_date` = #{updateDate}
</if>

<if test=" null != manager ">
and s.`manager` = #{manager}
</if>
<if test=" null != managerPhone ">
and s.`manager_phone` = #{managerPhone}
</if>
<if test=" null != type ">
and s.`type` = #{type}
</if>

<if test=" null != pointType ">
and s.`point_type` = #{pointType}
</if>
<if test=" null != ids ">
and s.id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns">order by s.${sortColumns}</if>



</select>

<select id="getbshoplist" resultType="hashmap" parameterType="hashmap">
select id,shop_number shopNumber from wx_shop


Загрузка…
Отмена
Сохранить