Browse Source

Merge remote-tracking branch 'remotes/origin/develop' into release_temp

dev
jianjun 4 years ago
parent
commit
86214d683e
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java
  2. 3
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  3. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java
  4. 11
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java
  5. 6
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java
  6. 55
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java
  7. 1
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java
  8. 6
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java
  9. 13
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java
  10. 3
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java
  11. 3
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java
  12. 231
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java
  13. 30
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java
  14. 59
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
  15. 19
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java
  16. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java
  17. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java
  18. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java
  19. 14
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  20. 45
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
  21. 47
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
  22. 20
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java
  23. 8
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java
  24. 6
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java
  25. 2
      epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java

@ -66,6 +66,7 @@ public class LogMsgSendFilter extends LevelFilter {
}
if (StringUtils.isNotBlank(activeEnv)) {
stringBuilder.append("告警环境:").append(activeEnv);
stringBuilder.append("\n");
}
@ -112,7 +113,6 @@ public class LogMsgSendFilter extends LevelFilter {
if (!flag) {
logger.warn("msgSender.sendMsg fail,param:{}", stringBuilder.toString());
}
stringBuilder.append("告警环境:").append(activeEnv);
} catch (Exception e) {
logger.warn("decide exception", e);
}

3
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -733,4 +733,7 @@ public class RedisKeys {
return rootPrefix.concat("temporary:").concat("temporaryResult:").concat(customerId).concat(":").concat(userId);
}
public static String getCustomerMenuList(String customerId, Integer type) {
return rootPrefix.concat("oper:access:nav:customerId:").concat(customerId).concat(":type:")+type;
}
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.epmet.commons.rocketmq.constants.MQUserPropertys;
import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg;
import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
@ -111,12 +112,19 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
String customerId = msgObj.getCustomerId();
distributedLock = SpringContextUtils.getBean(DistributedLock.class);
lock = distributedLock.getLock(String.format("lock:project_changed:%s:%s", customerId, msgObj.getProjectId())
,30L, 30L, TimeUnit.SECONDS);
,60L, 60L, TimeUnit.SECONDS);
if (StringUtils.isBlank(customerId)){
logger.error("consumer project_changed fail,msg:{}",customerId);
return;
}
//睡一秒 要不然那边执行不完
try {
Thread.sleep(NumConstant.ONE_THOUSAND);
} catch (InterruptedException e) {
log.error("consumeMessage exception",e);
}
ExtractOriginFormDTO extractOriginFormDTO = new ExtractOriginFormDTO();
extractOriginFormDTO.setCustomerId(customerId);

11
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java

@ -17,10 +17,6 @@
package com.epmet.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.hutool.poi.excel.ExcelUtil;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.exception.RenException;
@ -49,6 +45,7 @@ import com.epmet.service.IcCommunitySelfOrganizationService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -143,7 +140,9 @@ public class IcCommunitySelfOrganizationController {
* @date 2021/11/25 9:03 上午
*/
@PostMapping("importcommunityselforganization")
public void importCommunitySelfOrganization(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws Exception {
//service方法是异步的,需要事务注解加在被调用方 否则事务不起作用
@Transactional(rollbackFor = Exception.class)
public Result importCommunitySelfOrganization(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws Exception {
if (file.isEmpty()) {
throw new RenException("请上传文件");
}
@ -164,6 +163,8 @@ public class IcCommunitySelfOrganizationController {
}
//2.执行导入程序
icCommunitySelfOrganizationService.importCommunitySelfOrganization(tokenDto, response, file, result.getData().getTaskId());
return new Result();
}
/**

6
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java

@ -57,6 +57,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@ -80,6 +82,7 @@ import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN;
*/
@Service
@Slf4j
@EnableAsync
public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCommunitySelfOrganizationDao, IcCommunitySelfOrganizationEntity> implements IcCommunitySelfOrganizationService {
@Autowired
@ -471,7 +474,8 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo
* @author sun
*/
@Override
@Transactional(rollbackFor = Exception.class)
//@Transactional(rollbackFor = Exception.class)
@Async
public void importCommunitySelfOrganization(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException {
List<CommunitySelfOrgImportExcel> fileList = new ArrayList<>();
CommunitySelfOrgImportExcel excel = null;

55
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java

@ -17,31 +17,72 @@
package com.epmet.redis;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.dto.GovMenuDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 客户菜单配置表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-03-16
*/
@Slf4j
@Component
public class GovCustomerMenuRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
/**
* desc:保存客户菜单缓存
* @param customerId
* @param type
* @see com.epmet.enums.MenuTypeEnum
*/
public void setCustomerMenuList(String customerId, Integer type, List<GovMenuDTO> govMenuDTOS) {
if (checkParam(customerId, type)) {
String key = RedisKeys.getCustomerMenuList(customerId, type);
redisUtils.set(key, govMenuDTOS, RedisUtils.DEFAULT_EXPIRE);
}
}
/**
* desc:获取客户菜单缓存
* @param customerId
* @param type
* @see com.epmet.enums.MenuTypeEnum
*/
public List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type) {
if (checkParam(customerId, type)) {
String key = RedisKeys.getCustomerMenuList(customerId, type);
return (List<GovMenuDTO>) redisUtils.get(key);
}
return null;
}
public void set(){
/**
* desc:删除客户菜单缓存
* @param customerId
* @param type
* @see com.epmet.enums.MenuTypeEnum
*/
public void delCustomerMenu(String customerId, Integer type) {
if (checkParam(customerId, type)) {
String key = RedisKeys.getCustomerMenuList(customerId, type);
redisUtils.delete(key);
}
}
public String get(String id){
return null;
private boolean checkParam(String customerId, Integer type) {
if (StringUtils.isBlank(customerId) || type == null){
log.warn("checkParam fail, param is null");
return false;
}
return true;
}
}

1
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java

@ -70,5 +70,4 @@ public class GovMenuRedis {
String key = RedisKeys.getUserPermissionsKey(userId, app, client);
return (Set<String>)redisUtils.get(key);
}
}

6
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java

@ -20,14 +20,15 @@ package com.epmet.service.impl;
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.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.GovCustomerMenuDao;
import com.epmet.dto.GovCustomerMenuDTO;
import com.epmet.dto.form.MenuConfigFormDTO;
import com.epmet.entity.GovCustomerMenuEntity;
import com.epmet.enums.MenuTypeEnum;
import com.epmet.redis.GovCustomerMenuRedis;
import com.epmet.service.GovCustomerMenuService;
import org.apache.commons.lang3.StringUtils;
@ -105,6 +106,7 @@ public class GovCustomerMenuServiceImpl extends BaseServiceImpl<GovCustomerMenuD
}
@Override
@Transactional(rollbackFor = Exception.class)
public void saveCustomerMenu(MenuConfigFormDTO formDTO) {
baseDao.deleteBatchTableIds(formDTO.getTableId());
if (NumConstant.ZERO < formDTO.getCustomerIds().size()) {
@ -117,6 +119,8 @@ public class GovCustomerMenuServiceImpl extends BaseServiceImpl<GovCustomerMenuD
}
insertBatch(entities);
}
//删除缓存
formDTO.getCustomerIds().forEach(customerId-> govCustomerMenuRedis.delCustomerMenu(customerId, MenuTypeEnum.MENU.value()));
}
@Override

13
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java

@ -33,7 +33,7 @@ import com.epmet.dao.GovMenuDao;
import com.epmet.dto.GovMenuDTO;
import com.epmet.entity.GovMenuEntity;
import com.epmet.enums.MenuTypeEnum;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.redis.GovCustomerMenuRedis;
import com.epmet.redis.GovMenuRedis;
import com.epmet.service.*;
import org.apache.commons.lang3.StringUtils;
@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*;
@ -57,7 +58,7 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
@Autowired
private GovMenuRedis govMenuRedis;
@Autowired
private EpmetUserFeignClient epmetUserFeignClient;
private GovCustomerMenuRedis govCustomerMenuRedis;
@Autowired
private GovRoleMenuService govRoleMenuService;
@Autowired
@ -208,9 +209,15 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
* @Date 15:51 2021-03-16
**/
private List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type) {
List<GovMenuDTO> govMenuDTOS = govCustomerMenuRedis.getCustomerMenuList(customerId,type);
if (!CollectionUtils.isEmpty(govMenuDTOS)){
return govMenuDTOS;
}
List<GovMenuEntity> menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage());
List<GovMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class);
return TreeUtils.buildTree(dtoList);
govMenuDTOS = TreeUtils.buildTree(dtoList);
govCustomerMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS);
return govMenuDTOS;
}
@Override

3
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java

@ -182,8 +182,7 @@ public class IssueManageController {
public Result shiftProjectV2(@LoginUser TokenDto tokenDTO, @RequestBody ShiftProjectFormDTO formDTO) {
formDTO.setStaffId(tokenDTO.getUserId());
ValidatorUtils.validateEntity(formDTO);
issueService.shiftProjectV2(formDTO);
return new Result();
return issueService.shiftProjectV2(formDTO);
}
/**

3
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java

@ -3,6 +3,7 @@ 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.IssueDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
@ -219,7 +220,7 @@ public interface IssueService extends BaseService<IssueEntity> {
* @param formDTO
* @return void
*/
void shiftProjectV2(ShiftProjectFormDTO formDTO);
Result shiftProjectV2(ShiftProjectFormDTO formDTO);
/**
* @Description 已关闭列表 政府端

231
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java

@ -9,7 +9,9 @@ import com.epmet.commons.rocketmq.messages.GroupAchievementMQMsg;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.AchievementTypeEnum;
import com.epmet.commons.tools.enums.EventEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
@ -41,7 +43,6 @@ import com.epmet.entity.IssueEntity;
import com.epmet.entity.IssueProcessEntity;
import com.epmet.entity.IssueProjectRelationEntity;
import com.epmet.feign.*;
import com.epmet.commons.tools.enums.AchievementTypeEnum;
import com.epmet.redis.GovIssueRedis;
import com.epmet.redis.IssueVoteDetailRedis;
import com.epmet.resi.group.dto.group.form.AllIssueFormDTO;
@ -62,6 +63,7 @@ import com.epmet.utils.ModuleConstants;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.redisson.api.RLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -136,6 +138,8 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
private GovProjectOpenFeignClient govProjectOpenFeignClient;
@Autowired
private IssueVoteDetailService issueVoteDetailService;
@Autowired
private DistributedLock distributedLock;
@Value("${openapi.scan.server.url}")
@ -957,127 +961,138 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
* @date 2020/12/9 10:01
*/
@Override
public void shiftProjectV2(ShiftProjectFormDTO formDTO) {
//1:查询议题数据
IssueEntity entity = baseDao.selectById(formDTO.getIssueId());
if (null == entity) {
throw new RenException(IssueConstant.SELECT_EXCEPTION);
}
if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) {
throw new RenException(IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION);
}
if (!IssueConstant.ISSUE_VOTING.equals(entity.getIssueStatus())) {
throw new RenException(IssueConstant.ISSUE_VOTING_EXCEPTION);
}
formDTO.setIssueDTO(ConvertUtils.sourceToTarget(entity, IssueDTO.class));
public Result shiftProjectV2(ShiftProjectFormDTO formDTO) {
RLock lock = null;
try {
// 锁持有10分钟,等待10s
lock = distributedLock.tryLock(formDTO.getIssueId());
//1:查询议题数据
IssueEntity entity = baseDao.selectById(formDTO.getIssueId());
if (null == entity) {
throw new RenException(IssueConstant.SELECT_EXCEPTION);
}
if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) {
throw new RenException(IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION);
}
if (!IssueConstant.ISSUE_VOTING.equals(entity.getIssueStatus())) {
throw new RenException(IssueConstant.ISSUE_VOTING_EXCEPTION);
}
formDTO.setIssueDTO(ConvertUtils.sourceToTarget(entity, IssueDTO.class));
//获取议题分类
List<IssueCategoryDTO> categoryList = issueCategoryService.getCategoryByIssue(formDTO.getIssueId());
if (CollectionUtils.isEmpty(categoryList)) {
throw new RenException(EpmetErrorCode.CATEGORY_IS_NULL.getCode());
}
//获取议题分类
List<IssueCategoryDTO> categoryList = issueCategoryService.getCategoryByIssue(formDTO.getIssueId());
if (CollectionUtils.isEmpty(categoryList)) {
throw new RenException(EpmetErrorCode.CATEGORY_IS_NULL.getCode());
}
//公开回复内容审核
if (StringUtils.isNotBlank(formDTO.getPublicReply())) {
TextScanParamDTO textScanParamDTO = new TextScanParamDTO();
TextTaskDTO taskDTO = new TextTaskDTO();
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", ""));
taskDTO.setContent(formDTO.getPublicReply());
textScanParamDTO.getTasks().add(taskDTO);
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO);
if (!textSyncScanResult.success()) {
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
} else {
if (!textSyncScanResult.getData().isAllPass()) {
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode());
//公开回复内容审核
if (StringUtils.isNotBlank(formDTO.getPublicReply())) {
TextScanParamDTO textScanParamDTO = new TextScanParamDTO();
TextTaskDTO taskDTO = new TextTaskDTO();
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", ""));
taskDTO.setContent(formDTO.getPublicReply());
textScanParamDTO.getTasks().add(taskDTO);
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO);
if (!textSyncScanResult.success()) {
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
} else {
if (!textSyncScanResult.getData().isAllPass()) {
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode());
}
}
}
}
//因需要保证议题表中的转项目时间与创建项目时间一致 因此先新增项目数据再更新议题数据
//2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用
Result<ResiTopicDTO> resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId());
if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) {
throw new RenException(IssueConstant.SELECT_TOPIC_EXCEPTION);
}
ResiTopicDTO topicDTO = resultTopicDTO.getData();
formDTO.setTopicDTO(topicDTO);
//3:调用gov-project服务,新增项目各业务表初始数据
formDTO.setCategoryList(categoryList);
List<IssueTagsDTO> tagList = issueTagsService.getTagsByIssue(formDTO.getIssueId());
formDTO.setTagList(tagList);
Result<IssueProjectResultDTO> resultDTO = govProjectFeignClient.issueShiftProject(formDTO);
if (!resultDTO.success() || null == resultDTO.getData()) {
logger.error(resultDTO.getInternalMsg());
throw new RenException(IssueConstant.GOV_PRJECT_EXCEPTION);
}
IssueProjectResultDTO issueProjectResultDTO = resultDTO.getData();
//更新项目对标签的引用次数
if (CollectionUtils.isNotEmpty(tagList)) {
tagList.forEach(item -> {
IssueProjectTagDictDTO tag = issueProjectTagDictService.get(item.getTagId());
tag.setProjectUseCount(tag.getProjectUseCount() + NumConstant.ONE);
issueProjectTagDictService.update(tag);
});
}
//因需要保证议题表中的转项目时间与创建项目时间一致 因此先新增项目数据再更新议题数据
//4:更新议题相关业务表数据
//4.1:更新议题表数据
entity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT);
entity.setShiftedTime(issueProjectResultDTO.getShiftedTime());
baseDao.updateById(entity);
//2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用
Result<ResiTopicDTO> resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId());
if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) {
throw new RenException(IssueConstant.SELECT_TOPIC_EXCEPTION);
}
ResiTopicDTO topicDTO = resultTopicDTO.getData();
formDTO.setTopicDTO(topicDTO);
//3:调用gov-project服务,新增项目各业务表初始数据
formDTO.setCategoryList(categoryList);
List<IssueTagsDTO> tagList = issueTagsService.getTagsByIssue(formDTO.getIssueId());
formDTO.setTagList(tagList);
Result<IssueProjectResultDTO> resultDTO = govProjectFeignClient.issueShiftProject(formDTO);
if (!resultDTO.success() || null == resultDTO.getData()) {
logger.error(resultDTO.getInternalMsg());
throw new RenException(IssueConstant.GOV_PRJECT_EXCEPTION);
}
IssueProjectResultDTO issueProjectResultDTO = resultDTO.getData();
//更新项目对标签的引用次数
if (CollectionUtils.isNotEmpty(tagList)) {
tagList.forEach(item -> {
IssueProjectTagDictDTO tag = issueProjectTagDictService.get(item.getTagId());
tag.setProjectUseCount(tag.getProjectUseCount() + NumConstant.ONE);
issueProjectTagDictService.update(tag);
});
}
//4.2:议题处理进展表新增数据
IssueProcessEntity processEntity = new IssueProcessEntity();
processEntity.setIssueId(entity.getId());
processEntity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT);
processEntity.setOrgType(IssueConstant.ISSUE_GRID);
processEntity.setOrgId(entity.getGridId());
processEntity.setOrgName(issueProjectResultDTO.getOrgName());
issueProcessDao.insert(processEntity);
//4:更新议题相关业务表数据
//4.1:更新议题表数据
entity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT);
entity.setShiftedTime(issueProjectResultDTO.getShiftedTime());
baseDao.updateById(entity);
//4.2:议题处理进展表新增数据
IssueProcessEntity processEntity = new IssueProcessEntity();
processEntity.setIssueId(entity.getId());
processEntity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT);
processEntity.setOrgType(IssueConstant.ISSUE_GRID);
processEntity.setOrgId(entity.getGridId());
processEntity.setOrgName(issueProjectResultDTO.getOrgName());
issueProcessDao.insert(processEntity);
//4.3:议题项目关系表新增数据
IssueProjectRelationEntity relationEntity = new IssueProjectRelationEntity();
relationEntity.setIssueId(entity.getId());
relationEntity.setProjectId(issueProjectResultDTO.getProjectId());
issueProjectRelationDao.insert(relationEntity);
//5:调用epmet-message服务,给居民端话题创建人、议题发起人以及政府端工作人员发送消息
if (!shiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) {
throw new RenException(IssueConstant.SAVE_MSG_EXCEPTION);
}
//5-1:2020.10.26 添加给居民端话题创建人、议题发起人以及政府端工作人员推送微信订阅消息功能 sun
if (!wxmpShiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) {
logger.error("议题转项目,推送微信订阅消息失败!");
}
//4.3:议题项目关系表新增数据
IssueProjectRelationEntity relationEntity = new IssueProjectRelationEntity();
relationEntity.setIssueId(entity.getId());
relationEntity.setProjectId(issueProjectResultDTO.getProjectId());
issueProjectRelationDao.insert(relationEntity);
//6:缓存中网格下表决中的议题总数减1
govIssueRedis.subtractWorkGrassrootsIssueRedDotValue(entity.getGridId());
try{
issueVoteStatisticalService.syncVotingCacheToDbByParams(formDTO.getIssueId(),entity.getGridId(),null);
}catch(RenException e){
logger.error(e.getInternalMsg());
}
//5:调用epmet-message服务,给居民端话题创建人、议题发起人以及政府端工作人员发送消息
if (!shiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) {
throw new RenException(IssueConstant.SAVE_MSG_EXCEPTION);
}
//5-1:2020.10.26 添加给居民端话题创建人、议题发起人以及政府端工作人员推送微信订阅消息功能 sun
if (!wxmpShiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) {
logger.error("议题转项目,推送微信订阅消息失败!");
}
//6:缓存中网格下表决中的议题总数减1
govIssueRedis.subtractWorkGrassrootsIssueRedDotValue(entity.getGridId());
try{
issueVoteStatisticalService.syncVotingCacheToDbByParams(formDTO.getIssueId(),entity.getGridId(),null);
}catch(RenException e){
logger.error(e.getInternalMsg());
}
//7:发送话题转议题积分事件
TopicEventFormDTO eventParam = new TopicEventFormDTO();
eventParam.setTopicId(entity.getSourceId());
eventParam.setEvent(EventEnum.TOPIC_SHIFTED_TO_PROJECT);
if(!resiGroupOpenFeignClient.sendEvent(eventParam).success()){
logger.warn("com.epmet.service.impl.IssueServiceImpl.shiftProjectV2,话题被转为项目积分事件发送失败,参数:{}", JSON.toJSONString(formDTO));
}
// 8.数据库更新表决统计
SelectIssueVotingDetailFormDTO dto = new SelectIssueVotingDetailFormDTO();
dto.setGridId(entity.getGridId());
dto.setIssueId(formDTO.getIssueId());
issueVoteDetailService.updateVote(dto);
//7:发送话题转议题积分事件
TopicEventFormDTO eventParam = new TopicEventFormDTO();
eventParam.setTopicId(entity.getSourceId());
eventParam.setEvent(EventEnum.TOPIC_SHIFTED_TO_PROJECT);
if(!resiGroupOpenFeignClient.sendEvent(eventParam).success()){
logger.warn("com.epmet.service.impl.IssueServiceImpl.shiftProjectV2,话题被转为项目积分事件发送失败,参数:{}", JSON.toJSONString(formDTO));
//8.记录日志
//SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient).sendProjectChangedMqMsg();
return new Result();
} catch (Exception e) {
return new Result().error("议题数据正在处理中,请勿重复提交!");
} finally {
distributedLock.unLock(lock);
}
// 8.数据库更新表决统计
SelectIssueVotingDetailFormDTO dto = new SelectIssueVotingDetailFormDTO();
dto.setGridId(entity.getGridId());
dto.setIssueId(formDTO.getIssueId());
issueVoteDetailService.updateVote(dto);
//8.记录日志
//SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient).sendProjectChangedMqMsg();
}
/**

30
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java

@ -25,20 +25,22 @@ import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constant.ImportErrorMsgConstants;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.IcBuildingUnitDao;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.form.IcBulidingFormDTO;
import com.epmet.dto.form.IcBulidingUnitFormDTO;
import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.BuildingResultPagedDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.entity.IcBuildingUnitEntity;
import com.epmet.excel.IcBuildingExcel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.service.BuildingService;
import com.epmet.service.IcBuildingService;
import com.epmet.service.NeighborHoodService;
@ -66,17 +68,12 @@ import java.util.stream.Collectors;
@RequestMapping("building")
public class BuildingController {
@Autowired
private NeighborHoodService neighborHoodService;
@Autowired
private IcBuildingService icBuildingService;
@Autowired
private BuildingService buildingService;
@Autowired
private IcBuildingUnitDao icBuildingUnitDao;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@PostMapping("buildinglist")
@ -219,7 +216,16 @@ public class BuildingController {
formDTO.setOrgType(orgType);
formDTO.setOrgId(orgId);
formDTO.setUserId(tokenDTO.getUserId());
return buildingService.buildingImportExcel(formDTO,file);
ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO();
importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_BUILDING);
importFormDTO.setOperatorId(formDTO.getUserId());
importFormDTO.setOriginFileName(ImportErrorMsgConstants.BUILDING_ERROR_NAME);
Result<ImportTaskCommonResultDTO> importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO);
if (!importTask.success()){
throw new EpmetException("当前存在上传任务");
}
buildingService.buildingImportExcel(formDTO,file,importTask);
return new Result();
}
/**

59
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java

@ -50,15 +50,22 @@ import com.epmet.service.IcNeighborHoodService;
import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.tomcat.util.http.MimeHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@ -83,8 +90,6 @@ public class HouseController implements ResultDataResolver {
@Autowired
private IcHouseRedis icHouseRedis;
@Autowired
private IcNeighborHoodService neighborHoodService;
@Autowired
private IcHouseService icHouseService;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@ -255,52 +260,22 @@ public class HouseController implements ResultDataResolver {
@PostMapping("houseimport")
public Result houseImport(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file,
@RequestParam("orgId")String orgId,
@RequestParam("orgType")String orgType){
@RequestParam("orgType")String orgType,HttpServletRequest multipartRequest){
ImportInfoFormDTO formDTO = new ImportInfoFormDTO();
formDTO.setCustomerId(tokenDTO.getCustomerId());
formDTO.setOrgType(orgType);
formDTO.setOrgId(orgId);
formDTO.setUserId(tokenDTO.getUserId());
ExcelReader excelReader = null;
try {
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
} catch (IOException e) {
return new Result<String>().error("读取文件失败");
}
ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO();
importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_HOUSE);
importFormDTO.setOperatorId(formDTO.getUserId());
importFormDTO.setOriginFileName(ImportErrorMsgConstants.HOUSE_ERROR_NAME);
Result<ImportTaskCommonResultDTO> importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO);
if (!importTask.success()){
throw new EpmetException("创建任务失败");
}
excelReader = EasyExcel.read(inputStream).build();
// 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
ReadSheet readSheet = EasyExcel.readSheet(0).head(HouseInfoModel.class)
.registerReadListener(new ImportHouseInfoListener(formDTO,icBuildingDao,icHouseRedis,neighborHoodService,icHouseService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId()))
.build();
excelReader.read(readSheet);
} finally {
if (excelReader != null) {
excelReader.finish();
}
}
ImportResultDTO dto = icHouseRedis.getImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId());
if (null == dto){
return new Result<>();
}
List<Integer> nums = dto.getNums();
Integer num = dto.getNum();
String s = "共%s条数据,导入成功%s条。";
if (nums.size() > NumConstant.ZERO){
Collections.sort(nums);
s = s + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"条导入失败";
return new Result<>().error(9999,String.format(s,num,num - nums.size()));
ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO();
importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_HOUSE);
importFormDTO.setOperatorId(formDTO.getUserId());
importFormDTO.setOriginFileName(ImportErrorMsgConstants.HOUSE_ERROR_NAME);
Result<ImportTaskCommonResultDTO> importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO);
if (!importTask.success()){
throw new EpmetException("当前存在上传任务");
}
return new Result<>().error(9999,String.format(s,num,num));
houseService.dispose(file,formDTO,importTask);
return new Result<>();
}
}

19
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java

@ -19,6 +19,7 @@ package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.dto.result.OptionResultDTO;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
@ -27,8 +28,13 @@ import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.constant.ImportErrorMsgConstants;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dto.IcNeighborHoodDTO;
import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.service.IcNeighborHoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -51,6 +57,8 @@ public class IcNeighborHoodController {
@Autowired
private IcNeighborHoodService icNeighborHoodService;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@GetMapping("page")
public Result<PageData<IcNeighborHoodDTO>> page(@RequestParam Map<String, Object> params){
@ -128,7 +136,16 @@ public class IcNeighborHoodController {
formDTO.setOrgType(orgType);
formDTO.setOrgId(orgId);
formDTO.setUserId(tokenDTO.getUserId());
return icNeighborHoodService.neighborhoodImport(formDTO,file);
ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO();
importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_NEIGHBOR_HOOD);
importFormDTO.setOperatorId(formDTO.getUserId());
importFormDTO.setOriginFileName(ImportErrorMsgConstants.NEIGHBORHOOD_ERROR_NAME);
Result<ImportTaskCommonResultDTO> importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO);
if (!importTask.success()){
throw new EpmetException("当前存在上传任务");
}
icNeighborHoodService.neighborhoodImport(formDTO,file,importTask);
return new Result();
}
}

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java

@ -25,6 +25,7 @@ import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.BuildingResultPagedDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.excel.IcBuildingExcel;
import org.springframework.web.multipart.MultipartFile;
@ -74,6 +75,6 @@ public interface BuildingService {
* @author zxc
* @date 2022/2/13 10:18 上午
*/
Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file) throws IOException;
Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file,Result<ImportTaskCommonResultDTO> importTask) throws IOException;
}

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java

@ -17,11 +17,15 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.IcHouseFormDTO;
import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.HouseInfoDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.excel.IcHouseExcel;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@ -62,4 +66,6 @@ public interface HouseService {
void exportBuildinginfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception;
List<HouseInfoDTO> queryListHouseInfo(Set<String> houseIds, String customerId);
Result dispose(MultipartFile file, ImportInfoFormDTO formDTO, Result<ImportTaskCommonResultDTO> importTask);
}

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java

@ -24,6 +24,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IcNeighborHoodDTO;
import com.epmet.dto.ImportGeneralDTO;
import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.entity.IcNeighborHoodEntity;
import com.epmet.entity.IcNeighborHoodPropertyEntity;
import com.epmet.entity.IcPropertyManagementEntity;
@ -128,7 +129,7 @@ public interface IcNeighborHoodService extends BaseService<IcNeighborHoodEntity>
* @author zxc
* @date 2022/2/12 11:11 上午
*/
Result neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file) throws IOException;
void neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file,Result<ImportTaskCommonResultDTO> importTask) throws IOException;
/**
* 获取导入小区楼栋单元ID

14
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java

@ -46,6 +46,8 @@ import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -61,6 +63,7 @@ import java.util.stream.Collectors;
@Slf4j
@Service
@EnableAsync
public class BuildingServiceImpl implements BuildingService {
@ -401,7 +404,8 @@ public class BuildingServiceImpl implements BuildingService {
* @date 2022/2/13 10:15 上午
*/
@Override
public Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file) throws IOException {
@Async
public Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file,Result<ImportTaskCommonResultDTO> importTask) throws IOException {
ExcelReader excelReader = null;
try {
InputStream inputStream = null;
@ -410,14 +414,6 @@ public class BuildingServiceImpl implements BuildingService {
} catch (IOException e) {
return new Result<String>().error("读取文件失败");
}
ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO();
importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_BUILDING);
importFormDTO.setOperatorId(formDTO.getUserId());
importFormDTO.setOriginFileName(ImportErrorMsgConstants.BUILDING_ERROR_NAME);
Result<ImportTaskCommonResultDTO> importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO);
if (!importTask.success()){
throw new EpmetException("创建任务失败");
}
excelReader = EasyExcel.read(inputStream).build();
// 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
ReadSheet readSheet = EasyExcel.readSheet(0).head(BuildingInfoModel.class)

45
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java

@ -2,6 +2,9 @@ package com.epmet.service.impl;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.epmet.commons.tools.constant.NumConstant;
@ -14,6 +17,7 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcBuildingDao;
import com.epmet.dao.IcBuildingUnitDao;
import com.epmet.dao.IcHouseDao;
@ -23,15 +27,20 @@ import com.epmet.dto.IcBuildingDTO;
import com.epmet.dto.IcBuildingUnitDTO;
import com.epmet.dto.IcHouseDTO;
import com.epmet.dto.form.IcHouseFormDTO;
import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.HouseInfoDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.entity.IcHouseEntity;
import com.epmet.enums.HousePurposeEnums;
import com.epmet.enums.HouseRentFlagEnums;
import com.epmet.enums.HouseTypeEnums;
import com.epmet.excel.IcHouseExcel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.model.HouseInfoModel;
import com.epmet.model.ImportHouseInfoListener;
import com.epmet.redis.IcHouseRedis;
import com.epmet.service.HouseService;
import com.epmet.service.IcBuildingService;
@ -42,17 +51,23 @@ import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
@EnableAsync
public class HouseServiceImpl implements HouseService, ResultDataResolver {
@ -77,6 +92,11 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver {
private IcHouseRedis icHouseRedis;
@Autowired
private AgencyService agencyservice;
@Autowired
private IcNeighborHoodService neighborHoodService;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@Override
@ -329,4 +349,29 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver {
});
return result;
}
@Async
@Override
public Result dispose(MultipartFile file, ImportInfoFormDTO formDTO, Result<ImportTaskCommonResultDTO> importTask) {
ExcelReader excelReader = null;
try {
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
} catch (IOException e) {
return new Result<String>().error("读取文件失败");
}
excelReader = EasyExcel.read(inputStream).build();
// 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
ReadSheet readSheet = EasyExcel.readSheet(0).head(HouseInfoModel.class)
.registerReadListener(new ImportHouseInfoListener(formDTO,icBuildingDao,icHouseRedis,neighborHoodService,icHouseService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId()))
.build();
excelReader.read(readSheet);
} finally {
if (excelReader != null) {
excelReader.finish();
}
}
return new Result();
}
}

47
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java

@ -73,6 +73,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@ -93,6 +95,7 @@ import java.util.stream.Collectors;
*/
@Slf4j
@Service
@EnableAsync
public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao, IcNeighborHoodEntity> implements IcNeighborHoodService {
@Autowired
@ -230,21 +233,9 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
* @date 2022/2/12 11:11 上午
*/
@Override
public Result neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file) throws IOException {
/*ExcelImportResult<IcNeighborHoodExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcNeighborHoodExcel.class);
List<IcNeighborHoodExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if(CollectionUtils.isNotEmpty(failList)){
for ( IcNeighborHoodExcel entity : failList) {
//打印失败的行 和失败的信息
log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());
numList.add(entity.getRowNum());
}
}
List<IcNeighborHoodExcel> result =importResult.getList();
return disposeImportNeighborhood(formDTO,result);*/
return importNeighbor(formDTO,file);
@Async
public void neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file,Result<ImportTaskCommonResultDTO> importTask) throws IOException {
importNeighbor(formDTO,file,importTask);
}
/**
@ -407,7 +398,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
return new Result().ok(str);
}
public Result importNeighbor(ImportInfoFormDTO formDTO, MultipartFile file){
public Result importNeighbor(ImportInfoFormDTO formDTO, MultipartFile file,Result<ImportTaskCommonResultDTO> importTask){
ExcelReader excelReader = null;
try {
InputStream inputStream = null;
@ -416,14 +407,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
} catch (IOException e) {
return new Result<String>().error("读取文件失败");
}
ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO();
importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_NEIGHBOR_HOOD);
importFormDTO.setOperatorId(formDTO.getUserId());
importFormDTO.setOriginFileName(ImportErrorMsgConstants.NEIGHBORHOOD_ERROR_NAME);
Result<ImportTaskCommonResultDTO> importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO);
if (!importTask.success()){
throw new EpmetException("创建任务失败");
}
excelReader = EasyExcel.read(inputStream).build();
// 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
ReadSheet readSheet = EasyExcel.readSheet(0).head(NeighborHoodInfoModel.class)
@ -435,19 +419,8 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
excelReader.finish();
}
}
ImportResultDTO dto = icHouseRedis.getImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId());
if (null == dto){
return new Result<>();
}
List<Integer> nums = dto.getNums();
Integer num = dto.getNum();
String s = "共%s条数据,导入成功%s条。";
if (nums.size() > NumConstant.ZERO){
Collections.sort(nums);
s = s + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"条导入失败";
return new Result<>().error(9999,String.format(s,num,num - nums.size()));
}
return new Result<>().error(9999,String.format(s,num,num));
return new Result<>();
}
/**

20
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java

@ -453,10 +453,12 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
Integer workMinutes = calculateDelta_T(ProjectConstant.PRECISE_CALCULATION,
ProjectConstant.CALCULATION_TYPE_DEFAULT, fromDTO.getProjectId(), projectEntity.getCreatedTime(), current);
projectEntity.setStatus(ProjectConstant.CLOSED);
projectEntity.setClosedStatus(fromDTO.getClosedStatus());
projectEntity.setWorkMinutes(workMinutes);
baseDao.updateById(projectEntity);
ProjectEntity newProject = new ProjectEntity();
newProject.setId(fromDTO.getProjectId());
newProject.setStatus(ProjectConstant.CLOSED);
newProject.setClosedStatus(fromDTO.getClosedStatus());
newProject.setWorkMinutes(workMinutes);
baseDao.updateById(newProject);
//更新项目关联表
ProjectStaffEntity projectStaffEntity = new ProjectStaffEntity();
projectStaffEntity.setId(fromDTO.getProjectStaffId());
@ -655,10 +657,12 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
Integer workMinutes = calculateDelta_T(ProjectConstant.PRECISE_CALCULATION,
ProjectConstant.CALCULATION_TYPE_DEFAULT, fromDTO.getProjectId(), projectEntity.getCreatedTime(), current);
projectEntity.setStatus(ProjectConstant.CLOSED);
projectEntity.setClosedStatus(fromDTO.getClosedStatus());
projectEntity.setWorkMinutes(workMinutes);
baseDao.updateById(projectEntity);
ProjectEntity newProject = new ProjectEntity();
newProject.setId(fromDTO.getProjectId());
newProject.setStatus(ProjectConstant.CLOSED);
newProject.setClosedStatus(fromDTO.getClosedStatus());
newProject.setWorkMinutes(workMinutes);
baseDao.updateById(newProject);
//更新项目关联表
ProjectStaffEntity projectStaffEntity = new ProjectStaffEntity();
projectStaffEntity.setId(fromDTO.getProjectStaffId());

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

@ -17,6 +17,7 @@
package com.epmet.modules.partymember.controller;
import com.baomidou.mybatisplus.extension.api.R;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
@ -41,6 +42,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -124,7 +126,9 @@ public class IcPartymemberStyleController {
}
@PostMapping("import")
public void importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException {
//service方法是异步的,需要事务注解加在被调用方 否则事务不起作用
@Transactional(rollbackFor = Exception.class)
public Result importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException {
// 校验文件类型
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
if (!"xls".equals(extension) && !"xlsx".equals(extension)) {
@ -141,6 +145,8 @@ public class IcPartymemberStyleController {
}
//2.执行导入程序
icPartymemberStyleService.importData(tokenDto, response, file, result.getData().getTaskId());
return new Result();
}
/**

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

@ -71,6 +71,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@ -92,6 +94,7 @@ import java.util.stream.Collectors;
*/
@Slf4j
@Service
@EnableAsync
public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymemberStyleDao, IcPartymemberStyleEntity> implements IcPartymemberStyleService {
@Resource
@ -254,7 +257,8 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
* @Date 2021/11/29 11:01
*/
@Override
@Transactional(rollbackFor = Exception.class)
//@Transactional(rollbackFor = Exception.class)
@Async
public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException {
List<PartyMemberImportExcel> fileList = new ArrayList<>();
PartyMemberImportExcel excel = null;

2
epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java

@ -33,7 +33,7 @@ public class ScanApiAuthInterceptor implements HandlerInterceptor {
String ip = IpUtils.getIpAddr(request);
SetOperations setOperations = redisTemplate.opsForSet();
if (!setOperations.isMember(RedisKeys.getWhiteList(), ip)) {
log.warn("preHandle ip:{} is not in whitelist", ip);
log.error("preHandle ip:{} 不在白名单内", ip);
String result = JSON.toJSONString(new Result<>().error(EpmetErrorCode.ERR401.getCode(), EpmetErrorCode.ERR401.getMsg()));
responseJson(response, result);
return false;

Loading…
Cancel
Save