Browse Source

Merge branch 'dev_ic_v2' into develop

dev_shibei_match
zhaoqifeng 4 years ago
parent
commit
33e1e764e4
  1. 3
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java
  2. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java
  3. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java
  4. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java
  5. 19
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java
  6. 10
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java
  7. 44
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleImportExcel.java
  8. 15
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java
  9. 103
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java

3
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java

@ -528,4 +528,7 @@ public interface GovOrgOpenFeignClient {
@PostMapping("/gov/org/icneighborhood/getlistbyids")
Result<List<IcNeighborHoodDTO>> getListByIds(@RequestBody List<String> ids);
@GetMapping("/gov/org/customergrid/getGridIListByAgency/{agencyId}")
Result<List<CustomerGridDTO>> getGridIListByAgency(@PathVariable("agencyId") String agencyId)
}

5
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java

@ -329,6 +329,11 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getListByIds", ids);
}
@Override
public Result<List<CustomerGridDTO>> getGridIListByAgency(String agencyId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridIListByAgency", agencyId);
}
@Override
public Result<String> selectPidsByGridId(String gridId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "selectPidsByGridId", gridId);

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java

@ -302,4 +302,10 @@ public class CustomerGridController {
ValidatorUtils.validateEntity(formDTO);
return new Result<List<OptionResultDTO>>().ok(customerGridService.getGridOption(formDTO.getAgencyId(),formDTO.getPurpose()));
}
@GetMapping("getGridIListByAgency/{agencyId}")
public Result<List<CustomerGridDTO>> getGridIListByAgency(@PathVariable("agencyId") String agencyId) {
List<CustomerGridDTO> resultDTOS = customerGridService.getGridIListByAgency(agencyId);
return new Result<List<CustomerGridDTO>>().ok(resultDTOS);
}
}

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java

@ -338,4 +338,14 @@ public interface CustomerGridService extends BaseService<CustomerGridEntity> {
* @Date 2021/10/26 14:01
*/
List<OptionResultDTO> getGridOption(String agencyId,String purpose);
/**
* @Description 获取组织下网格
* @Param agencyId
* @Return {@link List< CustomerGridDTO>}
* @Author zhaoqifeng
* @Date 2021/11/29 17:00
*/
List<CustomerGridDTO> getGridIListByAgency(String agencyId);
}

19
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java

@ -873,4 +873,23 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
}).collect(Collectors.toList());
}
/**
* @param agencyId
* @Description 获取组织下网格
* @Param agencyId
* @Return {@link List< CustomerGridDTO>}
* @Author zhaoqifeng
* @Date 2021/11/29 17:00
*/
@Override
public List<CustomerGridDTO> getGridIListByAgency(String agencyId) {
LambdaQueryWrapper<CustomerGridEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CustomerGridEntity::getPid, agencyId);
List<CustomerGridEntity> list = baseDao.selectList(wrapper);
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
return ConvertUtils.sourceToTarget(list, CustomerGridDTO.class);
}
}

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

@ -31,11 +31,14 @@ import com.epmet.modules.partymember.excel.IcPartymemberStyleExcel;
import com.epmet.modules.partymember.service.IcPartymemberStyleService;
import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO;
import com.epmet.resi.partymember.dto.partymember.form.PartyMemberStyleFormDTO;
import lombok.extern.slf4j.Slf4j;
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.Map;
@ -49,6 +52,7 @@ import java.util.stream.Collectors;
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-18
*/
@Slf4j
@RestController
@RequestMapping("icpartymemberstyle")
public class IcPartymemberStyleController {
@ -107,6 +111,10 @@ public class IcPartymemberStyleController {
return new Result<PageData<IcPartymemberStyleDTO>>().ok(icPartymemberStyleService.search(formDTO));
}
@PostMapping("import")
public Result importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException {
icPartymemberStyleService.importData(tokenDto, response, file);
return new Result();
}
}

44
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleImportExcel.java

@ -0,0 +1,44 @@
/**
* 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.modules.partymember.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-18
*/
@Data
public class IcPartymemberStyleImportExcel extends ExcelVerifyInfo {
@Excel(name = "所属网格")
private String gridName;
@Excel(name = "党员姓名")
private String name;
@Excel(name = "主要事迹")
private String mainDeed;
@Excel(name = "照片")
private String imageUrl;
}

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

@ -23,7 +23,10 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.modules.partymember.entity.IcPartymemberStyleEntity;
import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO;
import com.epmet.resi.partymember.dto.partymember.form.PartyMemberStyleFormDTO;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@ -93,4 +96,16 @@ public interface IcPartymemberStyleService extends BaseService<IcPartymemberStyl
* @Date 2021/11/19 9:30
*/
PageData<IcPartymemberStyleDTO> search(PartyMemberStyleFormDTO formDTO);
/**
* 导入数据
* @Param tokenDto
* @Param response
* @Param file
* @Return
* @Author zhaoqifeng
* @Date 2021/11/29 11:01
*/
void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException;
}

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

@ -17,37 +17,48 @@
package com.epmet.modules.partymember.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.baomidou.mybatisplus.core.metadata.IPage;
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.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
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.dto.CustomerGridDTO;
import com.epmet.dto.form.GridOptionFormDTO;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.modules.partymember.dao.IcPartymemberStyleDao;
import com.epmet.modules.partymember.entity.IcPartymemberStyleEntity;
import com.epmet.modules.partymember.entity.IcPartymemberStyleImageEntity;
import com.epmet.modules.partymember.excel.IcPartymemberStyleImportExcel;
import com.epmet.modules.partymember.service.IcPartymemberStyleImageService;
import com.epmet.modules.partymember.service.IcPartymemberStyleService;
import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO;
import com.epmet.resi.partymember.dto.partymember.form.PartyMemberStyleFormDTO;
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.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -57,11 +68,14 @@ import java.util.stream.Collectors;
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-18
*/
@Slf4j
@Service
public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymemberStyleDao, IcPartymemberStyleEntity> implements IcPartymemberStyleService {
@Resource
private IcPartymemberStyleImageService icPartymemberStyleImageService;
@Resource
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Override
public PageData<IcPartymemberStyleDTO> page(Map<String, Object> params) {
@ -179,4 +193,87 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
return new PageData<>(dtoList, pageInfo.getTotal());
}
/**
* 导入数据
*
* @Param tokenDto
* @Param response
* @Param file
* @Return
* @Author zhaoqifeng
* @Date 2021/11/29 11:01
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException {
ExcelImportResult<IcPartymemberStyleImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class);
List<IcPartymemberStyleImportExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if (!org.springframework.util.CollectionUtils.isEmpty(failList)) {
for (IcPartymemberStyleImportExcel entity : failList) {
//打印失败的行 和失败的信息
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());
numList.add(entity.getRowNum());
}
}
List<IcPartymemberStyleImportExcel> result = importResult.getList();
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
//获取组织下网格信息
GridOptionFormDTO formDTO = new GridOptionFormDTO();
formDTO.setAgencyId(staffInfoCache.getAgencyId());
Result<List<CustomerGridDTO>> gridOptionResult = govOrgOpenFeignClient.getGridIListByAgency(staffInfoCache.getAgencyId());
if (!gridOptionResult.success()) {
throw new EpmetException(gridOptionResult.getCode(), gridOptionResult.getMsg());
}
Map<String, String> gridMap = gridOptionResult.getData().stream().collect(Collectors.toMap(CustomerGridDTO::getGridName, CustomerGridDTO::getId));
//1.数据校验 只允许导入当前组织下的网格的数据
//网格名称不一样的数据舍弃
Iterator<IcPartymemberStyleImportExcel> iterator = result.iterator();
while (iterator.hasNext()) {
IcPartymemberStyleImportExcel obj = iterator.next();
if (null == gridMap.get(obj.getGridName().trim())) {
numList.add(obj.getRowNum());
log.warn(String.format("不是当前组织下可导入的数据,网格名称->%s,行号->%s", obj.getGridName(), obj.getRowNum()));
iterator.remove();
}
}
if (CollectionUtils.isEmpty(result)) {
return;
}
List<IcPartymemberStyleImageEntity> imageList = new ArrayList<>();
List<IcPartymemberStyleEntity> list = result.stream().map(item -> {
IcPartymemberStyleEntity entity = new IcPartymemberStyleEntity();
entity.setId(UUID.randomUUID().toString().replace("-", ""));
entity.setCustomerId(tokenDto.getCustomerId());
entity.setAgencyId(staffInfoCache.getAgencyId());
entity.setGridId(gridMap.get(item.getGridName()));
entity.setName(item.getName());
entity.setMainDeed(item.getMainDeed());
AtomicInteger i = new AtomicInteger();
if (StringUtils.isNotBlank(item.getImageUrl())) {
Arrays.asList(item.getImageUrl().split(StrConstant.COMMA)).forEach(url -> {
IcPartymemberStyleImageEntity urlEntity = new IcPartymemberStyleImageEntity();
urlEntity.setImageUrl(url);
urlEntity.setCustomerId(tokenDto.getCustomerId());
urlEntity.setStyleId(entity.getId());
urlEntity.setSort(i.getAndIncrement());
imageList.add(urlEntity);
});
}
return entity;
}).collect(Collectors.toList());
insertBatch(list);
icPartymemberStyleImageService.insertBatch(imageList);
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 + "行未成功!");
}
}
}
Loading…
Cancel
Save