Browse Source

联建单位和活动数据导入

dev_shibei_match
zhaoqifeng 4 years ago
parent
commit
d8cda36bab
  1. 59
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/PartyUnitTypeEnum.java
  2. 16
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyActivityController.java
  3. 16
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java
  4. 66
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyActivityImportExcel.java
  5. 62
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyUnitImportExcel.java
  6. 17
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyActivityService.java
  7. 15
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyUnitService.java
  8. 106
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java
  9. 106
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java
  10. 3
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java
  11. 3
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java
  12. 8
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java

59
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/PartyUnitTypeEnum.java

@ -0,0 +1,59 @@
package com.epmet.commons.tools.enums;
import com.epmet.commons.tools.exception.EpmetErrorCode;
/**
* @author Administrator
*/
public enum PartyUnitTypeEnum {
//房屋类型,1楼房,2平房,3别墅
LOUYU("0", "楼宇党建"),
ZUZHI("1", "两新组织"),
DANWEI("2", "区域单位党建"),
JIGUAN("3", "机关直属部门"),
QITA("4", "其他");
private String code;
private String name;
PartyUnitTypeEnum(String code, String name) {
this.code = code;
this.name = name;
}
public static String getName(String code) {
PartyUnitTypeEnum[] houseTypeEnums = values();
for (PartyUnitTypeEnum houseTypeEnum : houseTypeEnums) {
if (houseTypeEnum.getCode() == code) {
return houseTypeEnum.getName();
}
}
return EpmetErrorCode.SERVER_ERROR.getMsg();
}
public static String getCode(String name) {
PartyUnitTypeEnum[] houseTypeEnums = values();
for (PartyUnitTypeEnum houseTypeEnum : houseTypeEnums) {
if (houseTypeEnum.getName().equals(name)) {
return houseTypeEnum.getCode();
}
}
return null;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

16
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyActivityController.java

@ -33,8 +33,10 @@ import com.epmet.service.IcPartyActivityService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@ -100,4 +102,18 @@ public class IcPartyActivityController {
}
ExcelUtils.exportExcelToTarget(response, null, excelList, IcPartyActivityExcel.class);
}
/**
* 数据导入
* @Param tokenDto
* @Param response
* @Param file
* @Return {@link Result}
* @Author zhaoqifeng
* @Date 2021/11/30 14:42
*/
@PostMapping("import")
public Result importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException {
return icPartyActivityService.importData(tokenDto, response, file);
}
}

16
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java

@ -36,8 +36,10 @@ import com.epmet.service.IcPartyUnitService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@ -133,4 +135,18 @@ public class IcPartyUnitController {
AssertUtils.isBlank(dto.getAgencyId(), "agencyId");
return new Result<List<OptionDTO>>().ok(icPartyUnitService.option(dto));
}
/**
* 数据导入
* @Param tokenDto
* @Param response
* @Param file
* @Return {@link Result}
* @Author zhaoqifeng
* @Date 2021/11/30 14:42
*/
@PostMapping("import")
public Result importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException {
return icPartyUnitService.importData(tokenDto, response, file);
}
}

66
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyActivityImportExcel.java

@ -0,0 +1,66 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.epmet.commons.tools.utils.ExcelVerifyInfo;
import lombok.Data;
/**
* 联建活动
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-19
*/
@Data
public class IcPartyActivityImportExcel extends ExcelVerifyInfo {
@Excel(name = "单位名称")
private String unitName;
@Excel(name = "服务事项")
private String serviceMatter;
@Excel(name = "活动标题")
private String title;
@Excel(name = "活动目标")
private String target;
@Excel(name = "活动内容")
private String content;
@Excel(name = "活动地址")
private String address;
@Excel(name = "活动地址经度")
private String longitude;
@Excel(name = "活动地址纬度")
private String latitude;
@Excel(name = "服务人数")
private Integer peopleCount;
@Excel(name = "活动时间")
private String activityTime;
@Excel(name = "活动结果")
private String result;
}

62
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyUnitImportExcel.java

@ -0,0 +1,62 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.epmet.commons.tools.utils.ExcelVerifyInfo;
import lombok.Data;
/**
* 联建单位
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-19
*/
@Data
public class IcPartyUnitImportExcel extends ExcelVerifyInfo {
@Excel(name = "单位名称")
private String unitName;
@Excel(name = "分类")
private String type;
@Excel(name = "服务事项")
private String serviceMatter;
@Excel(name = "联系人")
private String contact;
@Excel(name = "联系电话")
private String contactMobile;
@Excel(name = "在职党员")
private Integer memberCount;
@Excel(name = "地址")
private String address;
@Excel(name = "中心位置经度")
private String longitude;
@Excel(name = "中心位置纬度")
private String latitude;
@Excel(name = "备注")
private String remark;
}

17
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyActivityService.java

@ -20,10 +20,14 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IcPartyActivityDTO;
import com.epmet.dto.form.PartyActivityFormDTO;
import com.epmet.entity.IcPartyActivityEntity;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
@ -77,10 +81,21 @@ public interface IcPartyActivityService extends BaseService<IcPartyActivityEntit
/**
* 批量删除
*
* @param ids
* @param id
* @return void
* @author generator
* @date 2021-11-19
*/
void delete(String id);
/**
* 导入数据
* @Param tokenDto
* @Param response
* @Param file
* @Return
* @Author zhaoqifeng
* @Date 2021/11/29 11:01
*/
Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException;
}

15
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyUnitService.java

@ -20,12 +20,16 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IcPartyUnitDTO;
import com.epmet.dto.form.PartyUnitFormDTO;
import com.epmet.dto.form.demand.ServiceQueryFormDTO;
import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.entity.IcPartyUnitEntity;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
@ -105,4 +109,15 @@ public interface IcPartyUnitService extends BaseService<IcPartyUnitEntity> {
* @Date 2021/11/22 14:35
*/
List<OptionDTO> option(IcPartyUnitDTO dto);
/**
* 导入数据
* @Param tokenDto
* @Param response
* @Param file
* @Return
* @Author zhaoqifeng
* @Date 2021/11/29 11:01
*/
Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException;
}

106
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java

@ -17,35 +17,44 @@
package com.epmet.service.impl;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.ExcelPoiUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcPartyActivityDao;
import com.epmet.dto.IcPartyActivityDTO;
import com.epmet.dto.IcPartyUnitDTO;
import com.epmet.dto.form.PartyActivityFormDTO;
import com.epmet.dto.form.demand.SubCodeFormDTO;
import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.entity.IcPartyActivityEntity;
import com.epmet.excel.IcPartyActivityImportExcel;
import com.epmet.service.IcPartyActivityService;
import com.epmet.service.IcPartyUnitService;
import com.epmet.service.IcResiDemandDictService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -54,11 +63,14 @@ import java.util.stream.Collectors;
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-19
*/
@Slf4j
@Service
public class IcPartyActivityServiceImpl extends BaseServiceImpl<IcPartyActivityDao, IcPartyActivityEntity> implements IcPartyActivityService {
@Resource
private IcPartyUnitService icPartyUnitService;
@Resource
private IcResiDemandDictService icResiDemandDictService;
@Override
public PageData<IcPartyActivityDTO> search(PartyActivityFormDTO formDTO) {
@ -162,4 +174,92 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl<IcPartyActivityD
baseDao.deleteById(id);
}
/**
* 导入数据
*
* @param tokenDto
* @param response
* @param file
* @Param tokenDto
* @Param response
* @Param file
* @Return
* @Author zhaoqifeng
* @Date 2021/11/29 11:01
*/
@Override
public Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException {
ExcelImportResult<IcPartyActivityImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartyActivityImportExcel.class);
List<IcPartyActivityImportExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if (!org.springframework.util.CollectionUtils.isEmpty(failList)) {
for (IcPartyActivityImportExcel entity : failList) {
//打印失败的行 和失败的信息
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());
numList.add(entity.getRowNum());
}
}
List<IcPartyActivityImportExcel> result = importResult.getList();
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
//获取服务事项
SubCodeFormDTO codeFormDTO = new SubCodeFormDTO();
codeFormDTO.setCustomerId(tokenDto.getCustomerId());
codeFormDTO.setParentCategoryCode("1010");
Map<String, String> categoryMap = icResiDemandDictService.querySubCodeList(codeFormDTO).stream().collect(Collectors.toMap(OptionDTO::getLabel, OptionDTO::getValue));
//获取联建单位
IcPartyUnitDTO unitDTO = new IcPartyUnitDTO();
unitDTO.setAgencyId(staffInfoCache.getAgencyId());
Map<String, String> option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getLabel, OptionDTO::getValue));
//1.数据校验
Iterator<IcPartyActivityImportExcel> iterator = result.iterator();
while (iterator.hasNext()) {
IcPartyActivityImportExcel obj = iterator.next();
//单位名称不能为空,不可重复
if (StringUtils.isBlank(obj.getUnitName().trim())) {
numList.add(obj.getRowNum());
log.warn(String.format("单位名称为空,行号->%s", obj.getRowNum()));
iterator.remove();
}
}
if (CollectionUtils.isEmpty(result)) {
Collections.sort(numList);
String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、"));
return new Result().error(9999, "第" + subList + "行未成功!");
}
List<IcPartyActivityEntity> list = result.stream().map(item -> {
IcPartyActivityEntity entity = new IcPartyActivityEntity();
entity.setCustomerId(tokenDto.getCustomerId());
entity.setAgencyId(staffInfoCache.getAgencyId());
entity.setPids(staffInfoCache.getAgencyPIds());
entity.setTitle(item.getTitle());
entity.setTarget(item.getTarget());
entity.setContent(item.getContent());
entity.setUnitId(option.get(item.getUnitName()));
entity.setServiceMatter(categoryMap.get(item.getServiceMatter()));
entity.setPeopleCount(item.getPeopleCount());
entity.setActivityTime(DateUtils.parse(item.getActivityTime(), DateUtils.DATE_TIME_PATTERN));
entity.setAddress(item.getAddress());
entity.setLatitude(item.getLatitude());
entity.setLongitude(item.getLongitude());
entity.setResult(item.getResult());
return entity;
}).collect(Collectors.toList());
insertBatch(list);
String str = String.format("共%s条,成功导入%s条。", numList.size() + result.size(), numList.size() + result.size() - numList.size());
if (numList.size() > NumConstant.ZERO) {
Collections.sort(numList);
String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、"));
log.warn(str + "第" + subList + "行未成功!");
return new Result().error(9999, str + "第" + subList + "行未成功!");
}
return new Result().ok(str);
}
}

106
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java

@ -17,6 +17,7 @@
package com.epmet.service.impl;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -25,31 +26,39 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.DictTypeEnum;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.enums.PartyUnitTypeEnum;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.ExcelPoiUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcPartyUnitDao;
import com.epmet.dto.IcPartyUnitDTO;
import com.epmet.dto.form.GridOptionFormDTO;
import com.epmet.dto.form.PartyUnitFormDTO;
import com.epmet.dto.form.demand.ServiceQueryFormDTO;
import com.epmet.dto.form.demand.SubCodeFormDTO;
import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.entity.IcPartyUnitEntity;
import com.epmet.excel.IcPartyUnitImportExcel;
import com.epmet.feign.EpmetAdminOpenFeignClient;
import com.epmet.service.IcPartyUnitService;
import com.epmet.service.IcResiDemandDictService;
import com.epmet.service.IcUserDemandRecService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@ -59,6 +68,7 @@ import java.util.stream.Collectors;
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-19
*/
@Slf4j
@Service
public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPartyUnitEntity> implements IcPartyUnitService {
@ -186,7 +196,7 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
List<OptionDTO> resultList = new ArrayList<>();
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId());
if (null == staffInfoCacheResult || StringUtils.isBlank(staffInfoCacheResult.getAgencyId())) {
throw new RenException("工作人员所属组织信息查询异常");
throw new EpmetException("工作人员所属组织信息查询异常");
}
List<String> agencyIds = new ArrayList<>();
if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) {
@ -227,4 +237,96 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
}).collect(Collectors.toList());
}
/**
* 导入数据
*
* @param tokenDto
* @param response
* @param file
* @Param tokenDto
* @Param response
* @Param file
* @Return
* @Author zhaoqifeng
* @Date 2021/11/29 11:01
*/
@Override
public Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException {
ExcelImportResult<IcPartyUnitImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartyUnitImportExcel.class);
List<IcPartyUnitImportExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if (!org.springframework.util.CollectionUtils.isEmpty(failList)) {
for (IcPartyUnitImportExcel entity : failList) {
//打印失败的行 和失败的信息
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());
numList.add(entity.getRowNum());
}
}
List<IcPartyUnitImportExcel> result = importResult.getList();
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
//获取组织下网格信息
GridOptionFormDTO formDTO = new GridOptionFormDTO();
formDTO.setAgencyId(staffInfoCache.getAgencyId());
//1.数据校验 只允许导入当前组织下的网格的数据
//网格名称不一样的数据舍弃
Iterator<IcPartyUnitImportExcel> iterator = result.iterator();
while (iterator.hasNext()) {
IcPartyUnitImportExcel obj = iterator.next();
//单位名称不能为空,不可重复
if (StringUtils.isBlank(obj.getUnitName().trim())) {
numList.add(obj.getRowNum());
log.warn(String.format("单位名称为空,行号->%s", obj.getRowNum()));
iterator.remove();
}
}
if (CollectionUtils.isEmpty(result)) {
Collections.sort(numList);
String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、"));
return new Result().error(9999, "第" + subList + "行未成功!");
}
SubCodeFormDTO codeFormDTO = new SubCodeFormDTO();
codeFormDTO.setCustomerId(tokenDto.getCustomerId());
codeFormDTO.setParentCategoryCode("1010");
Map<String, String> categoryMap = icResiDemandDictService.querySubCodeList(codeFormDTO).stream().collect(Collectors.toMap(OptionDTO::getLabel, OptionDTO::getValue));
List<IcPartyUnitEntity> list = result.stream().map(item -> {
IcPartyUnitEntity entity = new IcPartyUnitEntity();
entity.setCustomerId(tokenDto.getCustomerId());
entity.setAgencyId(staffInfoCache.getAgencyId());
entity.setPids(staffInfoCache.getAgencyPIds());
entity.setUnitName(item.getUnitName());
entity.setType(PartyUnitTypeEnum.getCode(item.getType()));
if (StringUtils.isNotBlank(item.getServiceMatter())) {
entity.setServiceMatter(getServiceMatter(categoryMap, item.getServiceMatter()));
}
entity.setContact(item.getContact());
entity.setContactMobile(item.getContactMobile());
entity.setAddress(item.getAddress());
entity.setLatitude(item.getLatitude());
entity.setLongitude(item.getLongitude());
entity.setMemberCount(item.getMemberCount());
entity.setRemark(item.getRemark());
return entity;
}).collect(Collectors.toList());
insertBatch(list);
String str = String.format("共%s条,成功导入%s条。", numList.size() + result.size(), numList.size() + result.size() - numList.size());
if (numList.size() > NumConstant.ZERO) {
Collections.sort(numList);
String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、"));
log.warn(str + "第" + subList + "行未成功!");
return new Result().error(9999, str + "第" + subList + "行未成功!");
}
return new Result().ok(str);
}
private String getServiceMatter(Map<String, String> map, String matter) {
List<String> matters = Arrays.asList(matter.split(StrConstant.COLON));
List<String> list = matters.stream().map(map::get).collect(Collectors.toList());
return StringUtils.join(list, StrConstant.COMMA);
}
}

3
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java

@ -113,8 +113,7 @@ public class IcPartymemberStyleController {
@PostMapping("import")
public Result importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException {
icPartymemberStyleService.importData(tokenDto, response, file);
return new Result();
return icPartymemberStyleService.importData(tokenDto, response, file);
}
}

3
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java

@ -20,6 +20,7 @@ package com.epmet.modules.partymember.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.modules.partymember.entity.IcPartymemberStyleEntity;
import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO;
import com.epmet.resi.partymember.dto.partymember.form.PartyMemberStyleFormDTO;
@ -106,6 +107,6 @@ public interface IcPartymemberStyleService extends BaseService<IcPartymemberStyl
* @Author zhaoqifeng
* @Date 2021/11/29 11:01
*/
void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException;
Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException;
}

8
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java

@ -205,7 +205,7 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException {
public Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException {
ExcelImportResult<IcPartymemberStyleImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class);
List<IcPartymemberStyleImportExcel> failList = importResult.getFailList();
//存放错误数据行号
@ -240,7 +240,9 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
}
}
if (CollectionUtils.isEmpty(result)) {
return;
Collections.sort(numList);
String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、"));
return new Result().error(9999, "第" + subList + "行未成功!");
}
List<IcPartymemberStyleImageEntity> imageList = new ArrayList<>();
List<IcPartymemberStyleEntity> list = result.stream().map(item -> {
@ -279,7 +281,9 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
Collections.sort(numList);
String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、"));
log.warn(str + "第" + subList + "行未成功!");
return new Result().error(9999, str + "第" + subList + "行未成功!");
}
return new Result().ok(str);
}
}
Loading…
Cancel
Save