From dcfec00d95f91bd696107642f7e68cd2fbc6a7a1 Mon Sep 17 00:00:00 2001 From: winter Date: Fri, 6 Sep 2024 22:23:53 +0800 Subject: [PATCH] fix --- .../controller/basic/WxShopController.java | 72 +++++++++++++++++++ .../controller/market/WxEnergyController.java | 17 ++--- .../java/com/iformall/domain/vo/WxShopVo.java | 8 +++ .../com/iformall/service/WxShopService.java | 4 ++ .../service/impl/WxShopServiceImpl.java | 14 ++++ 5 files changed, 107 insertions(+), 8 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxShopController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxShopController.java index d810e6daf..a9d1ab890 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxShopController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxShopController.java @@ -1,14 +1,17 @@ package com.iformall.controller.basic; +import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; import com.github.pagehelper.PageInfo; import com.iformall.annotation.SystemControllerLog; import com.iformall.annotation.TenantIgnore; +import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; import com.iformall.domain.po.WxShop; import com.iformall.domain.po.WxUserDataRule; import com.iformall.domain.po.base.BaseEntity; +import com.iformall.exception.MallinkException; import com.iformall.service.WxShopService; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -17,10 +20,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.Map; +import java.util.concurrent.TimeUnit; /** * @author gongbiao @@ -32,6 +42,9 @@ public class WxShopController extends BaseController { @Autowired private WxShopService wxShopService; + + @Autowired + private String fmUploadDir; private void setDataRule(WxShop wxShop) { @@ -176,6 +189,65 @@ public class WxShopController extends BaseController { setDataRule(wxShop); wxShopService.exportShop(wxShop, request, response); } + + @ApiOperation("导入") + @PostMapping(value = "/importShop", consumes = "multipart/*") + public void importShop(@RequestParam("poiFile") MultipartFile mFile,HttpServletRequest request, HttpServletResponse response) { + File lFile = handlerImportFile(mFile,"wxshop"); + wxShopService.importShop(getTenantInfo(), lFile,request, response); + } + + private File handlerImportFile(MultipartFile mFile,String fileNamePre) { + if (mFile.isEmpty()) { + throw new MallinkException(Result.ERROR, "上传文件不能为空"); + } + + String fpath = fmUploadDir; + File targetFile = new File(fpath); + if (!targetFile.exists()) { + targetFile.mkdirs(); + } + String fileName = fileNamePre + Math.round(Math.random() * 100000000000L); + int dot = mFile.getOriginalFilename().lastIndexOf('.'); + fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length()); + + File lFile = new File(fpath + File.separator + fileName); + + FileOutputStream fos = null; + BufferedInputStream fs = null; + try { + fos = new FileOutputStream(lFile); + fs = (BufferedInputStream) mFile.getInputStream(); + byte[] buffer = new byte[1024]; + int len = 0; + while ((len = fs.read(buffer)) != -1) { + fos.write(buffer, 0, len); + } + fos.close(); + fs.close(); + return lFile; + } catch (Exception e) { + logger.error("poi import error.",e); + throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + logger.error("poi import error.",e); + throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); + } + } + if (fs != null) { + try { + fs.close(); + } catch (IOException e) { + logger.error("poi import error.",e); + throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); + } + } + } + } @TenantIgnore @ApiOperation("导出未出租店铺") diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxEnergyController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxEnergyController.java index aca331d0c..a1507d9e9 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxEnergyController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxEnergyController.java @@ -124,14 +124,6 @@ public class WxEnergyController extends BaseController { public ResultData floorAndMeterList(@ModelAttribute WxEnergyMeter record) { record.updateTenantInfo(getTenantInfo()); List retList = new ArrayList(); - //根据楼座查询楼层 - WxMallFloor mfq = new WxMallFloor(); - mfq.updateTenantInfo(record); - mfq.setBuildingId(record.getBuilding()); - PageInfo floorPage = wxMallFloorService.listAsPage(mfq, 1,1000); - if (null != floorPage && null != floorPage.getList() && floorPage.getList().size() > 0 ) { - retList.addAll(floorPage.getList()); - } //根据楼错查询关联的公共表 WxEnergyMeterShopFloor msf = new WxEnergyMeterShopFloor(); msf.updateTenantInfo(record); @@ -163,6 +155,15 @@ public class WxEnergyController extends BaseController { } } } + + //根据楼座查询楼层 + WxMallFloor mfq = new WxMallFloor(); + mfq.updateTenantInfo(record); + mfq.setBuildingId(record.getBuilding()); + PageInfo floorPage = wxMallFloorService.listAsPage(mfq, 1,1000); + if (null != floorPage && null != floorPage.getList() && floorPage.getList().size() > 0 ) { + retList.addAll(floorPage.getList()); + } return new ResultData(retList); } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxShopVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxShopVo.java index 6f785f82e..80f12da7b 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxShopVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxShopVo.java @@ -12,6 +12,10 @@ import lombok.ToString; public class WxShopVo extends WxShop { private static final long serialVersionUID = 6687964942922444531L; + @Excel(name="ID",width = 20,orderNum = "1") + @io.swagger.annotations.ApiModelProperty(value="id",name="id") + private Long id; + @Excel(name="楼座",width = 20,orderNum = "3") @io.swagger.annotations.ApiModelProperty(value="楼座",name="buildingName") private String buildingName; @@ -45,4 +49,8 @@ public class WxShopVo extends WxShop { @io.swagger.annotations.ApiModelProperty(value="计租面积",name="operationArea") @Excel(name="计租面积",width = 20,orderNum = "13") private String operationArea; + + @io.swagger.annotations.ApiModelProperty(value="计租面积",name="publicRate") + @Excel(name="公摊系数",width = 20,orderNum = "14") + private String publicRate; } diff --git a/mallinkService/src/main/java/com/iformall/service/WxShopService.java b/mallinkService/src/main/java/com/iformall/service/WxShopService.java index c06e81e43..4e38857a2 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxShopService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxShopService.java @@ -10,6 +10,8 @@ import com.iformall.domain.vo.WxShopVo; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import java.io.File; import java.io.Serializable; import java.util.Collection; import java.util.List; @@ -82,6 +84,8 @@ public interface WxShopService { * @param response */ void exportShop(WxShop wxShop, HttpServletRequest request, HttpServletResponse response); + + void importShop(TenantEntity tenantEntity,File file,HttpServletRequest request, HttpServletResponse response); /** * 导出未出租商铺数据 diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java index e89dbece1..ca517ce9e 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java @@ -17,6 +17,9 @@ import com.iformall.mapper.WxMerchantShopMapper; import com.iformall.mapper.WxRentContractMapper; import com.iformall.mapper.WxShopMapper; import com.iformall.service.*; + +import cn.afterturn.easypoi.excel.entity.ImportParams; + import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -28,6 +31,8 @@ import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import java.io.File; import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.util.*; @@ -283,6 +288,7 @@ public class WxShopServiceImpl implements WxShopService { BeanUtils.copyProperties(vo, shop); vo.setBuildingName(buildingMap.get(vo.getBuilding())); vo.setFloorName(floorMap.get(vo.getFloor())); + vo.setPublicRate(shop.getPulicRate()); Long merchangId = shopMerchantIdMap.get(vo.getId()); if (null != merchangId) { WxMerchant merchant = merchantMap.get(merchangId); @@ -565,6 +571,14 @@ public class WxShopServiceImpl implements WxShopService { String name = EnumRentShopType.SHOP.getCode().equals(wxShop.getType())?"店铺列表":"多经点位列表"; excelService.exportExcel(list, null, name, WxShopVo.class, name + ".xlsx", response, false); } + + @Override + public void importShop(TenantEntity tenantEntity,File file,HttpServletRequest request, HttpServletResponse response) { + ImportParams params = new ImportParams(); + // 需要验证 + String[] needFields = new String[]{"ID", "公摊系数"}; + String[] allFields = new String[] {"ID","楼座","楼层"}; + } @Override public void exportNotRentShop(WxShop wxShop, HttpServletRequest request, HttpServletResponse response) {