|
|
|
@@ -9,20 +9,28 @@ import com.iformall.common.Result; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.*; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.domain.vo.MerchantPoiT; |
|
|
|
import com.iformall.domain.vo.MerchantPoiTNew; |
|
|
|
import com.iformall.domain.vo.WxNotRentShopVo; |
|
|
|
import com.iformall.domain.vo.WxShopVo; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.mapper.WxMerchantMapper; |
|
|
|
import com.iformall.mapper.WxMerchantShopMapper; |
|
|
|
import com.iformall.mapper.WxRentContractMapper; |
|
|
|
import com.iformall.mapper.WxShopMapper; |
|
|
|
import com.iformall.service.*; |
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelImportUtil; |
|
|
|
import cn.afterturn.easypoi.excel.entity.ImportParams; |
|
|
|
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; |
|
|
|
import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; |
|
|
|
import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; |
|
|
|
|
|
|
|
import org.apache.commons.beanutils.BeanUtils; |
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.shiro.session.UnknownSessionException; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@@ -288,7 +296,6 @@ 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); |
|
|
|
@@ -577,7 +584,69 @@ public class WxShopServiceImpl implements WxShopService { |
|
|
|
ImportParams params = new ImportParams(); |
|
|
|
// 需要验证 |
|
|
|
String[] needFields = new String[]{"ID", "公摊系数"}; |
|
|
|
String[] allFields = new String[] {"ID","楼座","楼层"}; |
|
|
|
String[] allFields = new String[] {"ID","楼座","楼层","租赁商户","负责人电话","负责人","品牌","经营业态","计租面积","公摊系数"}; |
|
|
|
ExcelImportResult<WxShopVo> datalist = handleImportFile(file,WxShopVo.class,allFields,needFields,new ExcelHandler()); |
|
|
|
if (null == datalist) { |
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"解析模版失败,请检查模版格式"); |
|
|
|
} |
|
|
|
|
|
|
|
List<WxShopVo> successList = datalist.getList(); |
|
|
|
if(null != successList && successList.size() > 0 ) { |
|
|
|
try { |
|
|
|
successList.parallelStream().forEach(shopBase -> { |
|
|
|
try { |
|
|
|
Long shopId = shopBase.getId(); |
|
|
|
if (null != shopId) { |
|
|
|
WxShop s = new WxShop(); |
|
|
|
s.updateTenantInfo(tenantEntity); |
|
|
|
s.setId(shopId); |
|
|
|
s.setPulicRate(shopBase.getPulicRate()); |
|
|
|
wxShopMapper.updateById(s); |
|
|
|
} |
|
|
|
} catch (UnknownSessionException ue) { |
|
|
|
logger.error("session :"+ue.getMessage()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("更新地理信息失败:"+e.getMessage(),e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private class ExcelHandler extends ExcelDataHandlerDefaultImpl<MerchantPoiTNew> { |
|
|
|
@Override |
|
|
|
public Object importHandler(MerchantPoiTNew obj, String name, Object value) { |
|
|
|
if (value == null) { |
|
|
|
value = ""; |
|
|
|
} |
|
|
|
return super.importHandler(obj, name, value); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private ExcelImportResult handleImportFile(File file,Class dataClazz,String[] importFields,String[] needFields,IExcelDataHandler handler) { |
|
|
|
ImportParams params = new ImportParams(); |
|
|
|
// 需要验证 |
|
|
|
params.setImportFields(importFields); |
|
|
|
handler.setNeedHandlerFields(needFields); |
|
|
|
params.setNeedVerify(true); |
|
|
|
ExcelImportResult<MerchantPoiT> datalist = null; |
|
|
|
try { |
|
|
|
datalist = ExcelImportUtil.importExcelMore(file, dataClazz, params); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage(),e); |
|
|
|
// 删除缓存文件 |
|
|
|
file.delete(); |
|
|
|
return null; |
|
|
|
} |
|
|
|
// 删除缓存文件 |
|
|
|
file.delete(); |
|
|
|
|
|
|
|
if(datalist == null) { |
|
|
|
logger.error("导入模板失败: 模板数据解析失败"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
return datalist; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|