| @@ -1,14 +1,17 @@ | |||||
| package com.iformall.controller.basic; | package com.iformall.controller.basic; | ||||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.annotation.TenantIgnore; | import com.iformall.annotation.TenantIgnore; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.WxShop; | import com.iformall.domain.po.WxShop; | ||||
| import com.iformall.domain.po.WxUserDataRule; | import com.iformall.domain.po.WxUserDataRule; | ||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.WxShopService; | import com.iformall.service.WxShopService; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -17,10 +20,17 @@ import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | 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.Map; | ||||
| import java.util.concurrent.TimeUnit; | |||||
| /** | /** | ||||
| * @author gongbiao | * @author gongbiao | ||||
| @@ -32,6 +42,9 @@ public class WxShopController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxShopService wxShopService; | private WxShopService wxShopService; | ||||
| @Autowired | |||||
| private String fmUploadDir; | |||||
| private void setDataRule(WxShop wxShop) { | private void setDataRule(WxShop wxShop) { | ||||
| @@ -176,6 +189,65 @@ public class WxShopController extends BaseController { | |||||
| setDataRule(wxShop); | setDataRule(wxShop); | ||||
| wxShopService.exportShop(wxShop, request, response); | 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 | @TenantIgnore | ||||
| @ApiOperation("导出未出租店铺") | @ApiOperation("导出未出租店铺") | ||||
| @@ -124,14 +124,6 @@ public class WxEnergyController extends BaseController { | |||||
| public ResultData floorAndMeterList(@ModelAttribute WxEnergyMeter record) { | public ResultData floorAndMeterList(@ModelAttribute WxEnergyMeter record) { | ||||
| record.updateTenantInfo(getTenantInfo()); | record.updateTenantInfo(getTenantInfo()); | ||||
| List<WxMallFloor> retList = new ArrayList<WxMallFloor>(); | List<WxMallFloor> retList = new ArrayList<WxMallFloor>(); | ||||
| //根据楼座查询楼层 | |||||
| WxMallFloor mfq = new WxMallFloor(); | |||||
| mfq.updateTenantInfo(record); | |||||
| mfq.setBuildingId(record.getBuilding()); | |||||
| PageInfo<WxMallFloor> floorPage = wxMallFloorService.listAsPage(mfq, 1,1000); | |||||
| if (null != floorPage && null != floorPage.getList() && floorPage.getList().size() > 0 ) { | |||||
| retList.addAll(floorPage.getList()); | |||||
| } | |||||
| //根据楼错查询关联的公共表 | //根据楼错查询关联的公共表 | ||||
| WxEnergyMeterShopFloor msf = new WxEnergyMeterShopFloor(); | WxEnergyMeterShopFloor msf = new WxEnergyMeterShopFloor(); | ||||
| msf.updateTenantInfo(record); | msf.updateTenantInfo(record); | ||||
| @@ -163,6 +155,15 @@ public class WxEnergyController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| //根据楼座查询楼层 | |||||
| WxMallFloor mfq = new WxMallFloor(); | |||||
| mfq.updateTenantInfo(record); | |||||
| mfq.setBuildingId(record.getBuilding()); | |||||
| PageInfo<WxMallFloor> floorPage = wxMallFloorService.listAsPage(mfq, 1,1000); | |||||
| if (null != floorPage && null != floorPage.getList() && floorPage.getList().size() > 0 ) { | |||||
| retList.addAll(floorPage.getList()); | |||||
| } | |||||
| return new ResultData(retList); | return new ResultData(retList); | ||||
| } | } | ||||
| @@ -12,6 +12,10 @@ import lombok.ToString; | |||||
| public class WxShopVo extends WxShop { | public class WxShopVo extends WxShop { | ||||
| private static final long serialVersionUID = 6687964942922444531L; | 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") | @Excel(name="楼座",width = 20,orderNum = "3") | ||||
| @io.swagger.annotations.ApiModelProperty(value="楼座",name="buildingName") | @io.swagger.annotations.ApiModelProperty(value="楼座",name="buildingName") | ||||
| private String buildingName; | private String buildingName; | ||||
| @@ -45,4 +49,8 @@ public class WxShopVo extends WxShop { | |||||
| @io.swagger.annotations.ApiModelProperty(value="计租面积",name="operationArea") | @io.swagger.annotations.ApiModelProperty(value="计租面积",name="operationArea") | ||||
| @Excel(name="计租面积",width = 20,orderNum = "13") | @Excel(name="计租面积",width = 20,orderNum = "13") | ||||
| private String operationArea; | private String operationArea; | ||||
| @io.swagger.annotations.ApiModelProperty(value="计租面积",name="publicRate") | |||||
| @Excel(name="公摊系数",width = 20,orderNum = "14") | |||||
| private String publicRate; | |||||
| } | } | ||||
| @@ -10,6 +10,8 @@ import com.iformall.domain.vo.WxShopVo; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.io.File; | |||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| import java.util.Collection; | import java.util.Collection; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -82,6 +84,8 @@ public interface WxShopService { | |||||
| * @param response | * @param response | ||||
| */ | */ | ||||
| void exportShop(WxShop wxShop, HttpServletRequest request, HttpServletResponse response); | void exportShop(WxShop wxShop, HttpServletRequest request, HttpServletResponse response); | ||||
| void importShop(TenantEntity tenantEntity,File file,HttpServletRequest request, HttpServletResponse response); | |||||
| /** | /** | ||||
| * 导出未出租商铺数据 | * 导出未出租商铺数据 | ||||
| @@ -17,6 +17,9 @@ import com.iformall.mapper.WxMerchantShopMapper; | |||||
| import com.iformall.mapper.WxRentContractMapper; | import com.iformall.mapper.WxRentContractMapper; | ||||
| import com.iformall.mapper.WxShopMapper; | import com.iformall.mapper.WxShopMapper; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||||
| import org.apache.commons.beanutils.BeanUtils; | import org.apache.commons.beanutils.BeanUtils; | ||||
| import org.apache.commons.collections.CollectionUtils; | import org.apache.commons.collections.CollectionUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -28,6 +31,8 @@ import org.springframework.stereotype.Service; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.io.File; | |||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.*; | import java.util.*; | ||||
| @@ -283,6 +288,7 @@ public class WxShopServiceImpl implements WxShopService { | |||||
| BeanUtils.copyProperties(vo, shop); | BeanUtils.copyProperties(vo, shop); | ||||
| vo.setBuildingName(buildingMap.get(vo.getBuilding())); | vo.setBuildingName(buildingMap.get(vo.getBuilding())); | ||||
| vo.setFloorName(floorMap.get(vo.getFloor())); | vo.setFloorName(floorMap.get(vo.getFloor())); | ||||
| vo.setPublicRate(shop.getPulicRate()); | |||||
| Long merchangId = shopMerchantIdMap.get(vo.getId()); | Long merchangId = shopMerchantIdMap.get(vo.getId()); | ||||
| if (null != merchangId) { | if (null != merchangId) { | ||||
| WxMerchant merchant = merchantMap.get(merchangId); | WxMerchant merchant = merchantMap.get(merchangId); | ||||
| @@ -565,6 +571,14 @@ public class WxShopServiceImpl implements WxShopService { | |||||
| String name = EnumRentShopType.SHOP.getCode().equals(wxShop.getType())?"店铺列表":"多经点位列表"; | String name = EnumRentShopType.SHOP.getCode().equals(wxShop.getType())?"店铺列表":"多经点位列表"; | ||||
| excelService.exportExcel(list, null, name, WxShopVo.class, name + ".xlsx", response, false); | 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 | @Override | ||||
| public void exportNotRentShop(WxShop wxShop, HttpServletRequest request, HttpServletResponse response) { | public void exportNotRentShop(WxShop wxShop, HttpServletRequest request, HttpServletResponse response) { | ||||