Browse Source

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

master
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. 57
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java
  7. 3
      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)) { if (StringUtils.isNotBlank(activeEnv)) {
stringBuilder.append("告警环境:").append(activeEnv);
stringBuilder.append("\n"); stringBuilder.append("\n");
} }
@ -112,7 +113,6 @@ public class LogMsgSendFilter extends LevelFilter {
if (!flag) { if (!flag) {
logger.warn("msgSender.sendMsg fail,param:{}", stringBuilder.toString()); logger.warn("msgSender.sendMsg fail,param:{}", stringBuilder.toString());
} }
stringBuilder.append("告警环境:").append(activeEnv);
} catch (Exception e) { } catch (Exception e) {
logger.warn("decide 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); 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.constants.MQUserPropertys;
import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg; import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg;
import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; 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.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
@ -111,12 +112,19 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
String customerId = msgObj.getCustomerId(); String customerId = msgObj.getCustomerId();
distributedLock = SpringContextUtils.getBean(DistributedLock.class); distributedLock = SpringContextUtils.getBean(DistributedLock.class);
lock = distributedLock.getLock(String.format("lock:project_changed:%s:%s", customerId, msgObj.getProjectId()) 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)){ if (StringUtils.isBlank(customerId)){
logger.error("consumer project_changed fail,msg:{}",customerId); logger.error("consumer project_changed fail,msg:{}",customerId);
return; return;
} }
//睡一秒 要不然那边执行不完
try {
Thread.sleep(NumConstant.ONE_THOUSAND);
} catch (InterruptedException e) {
log.error("consumeMessage exception",e);
}
ExtractOriginFormDTO extractOriginFormDTO = new ExtractOriginFormDTO(); ExtractOriginFormDTO extractOriginFormDTO = new ExtractOriginFormDTO();
extractOriginFormDTO.setCustomerId(customerId); 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; 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.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.exception.RenException; 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.collections4.CollectionUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -143,7 +140,9 @@ public class IcCommunitySelfOrganizationController {
* @date 2021/11/25 9:03 上午 * @date 2021/11/25 9:03 上午
*/ */
@PostMapping("importcommunityselforganization") @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()) { if (file.isEmpty()) {
throw new RenException("请上传文件"); throw new RenException("请上传文件");
} }
@ -164,6 +163,8 @@ public class IcCommunitySelfOrganizationController {
} }
//2.执行导入程序 //2.执行导入程序
icCommunitySelfOrganizationService.importCommunitySelfOrganization(tokenDto, response, file, result.getData().getTaskId()); 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.http.entity.ContentType;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -80,6 +82,7 @@ import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN;
*/ */
@Service @Service
@Slf4j @Slf4j
@EnableAsync
public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCommunitySelfOrganizationDao, IcCommunitySelfOrganizationEntity> implements IcCommunitySelfOrganizationService { public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCommunitySelfOrganizationDao, IcCommunitySelfOrganizationEntity> implements IcCommunitySelfOrganizationService {
@Autowired @Autowired
@ -471,7 +474,8 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo
* @author sun * @author sun
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) //@Transactional(rollbackFor = Exception.class)
@Async
public void importCommunitySelfOrganization(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException { public void importCommunitySelfOrganization(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException {
List<CommunitySelfOrgImportExcel> fileList = new ArrayList<>(); List<CommunitySelfOrgImportExcel> fileList = new ArrayList<>();
CommunitySelfOrgImportExcel excel = null; CommunitySelfOrgImportExcel excel = null;

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

@ -17,31 +17,72 @@
package com.epmet.redis; package com.epmet.redis;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
/** /**
* 客户菜单配置表 * 客户菜单配置表
* *
* @author generator generator@elink-cn.com * @author generator generator@elink-cn.com
* @since v1.0.0 2021-03-16 * @since v1.0.0 2021-03-16
*/ */
@Slf4j
@Component @Component
public class GovCustomerMenuRedis { public class GovCustomerMenuRedis {
@Autowired @Autowired
private RedisUtils redisUtils; 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){ private boolean checkParam(String customerId, Integer type) {
return null; if (StringUtils.isBlank(customerId) || type == null){
log.warn("checkParam fail, param is null");
return false;
}
return true;
} }
}
}

3
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); String key = RedisKeys.getUserPermissionsKey(userId, app, client);
return (Set<String>)redisUtils.get(key); 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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; 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.NumConstant;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.GovCustomerMenuDao; import com.epmet.dao.GovCustomerMenuDao;
import com.epmet.dto.GovCustomerMenuDTO; import com.epmet.dto.GovCustomerMenuDTO;
import com.epmet.dto.form.MenuConfigFormDTO; import com.epmet.dto.form.MenuConfigFormDTO;
import com.epmet.entity.GovCustomerMenuEntity; import com.epmet.entity.GovCustomerMenuEntity;
import com.epmet.enums.MenuTypeEnum;
import com.epmet.redis.GovCustomerMenuRedis; import com.epmet.redis.GovCustomerMenuRedis;
import com.epmet.service.GovCustomerMenuService; import com.epmet.service.GovCustomerMenuService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -105,6 +106,7 @@ public class GovCustomerMenuServiceImpl extends BaseServiceImpl<GovCustomerMenuD
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void saveCustomerMenu(MenuConfigFormDTO formDTO) { public void saveCustomerMenu(MenuConfigFormDTO formDTO) {
baseDao.deleteBatchTableIds(formDTO.getTableId()); baseDao.deleteBatchTableIds(formDTO.getTableId());
if (NumConstant.ZERO < formDTO.getCustomerIds().size()) { if (NumConstant.ZERO < formDTO.getCustomerIds().size()) {
@ -117,6 +119,8 @@ public class GovCustomerMenuServiceImpl extends BaseServiceImpl<GovCustomerMenuD
} }
insertBatch(entities); insertBatch(entities);
} }
//删除缓存
formDTO.getCustomerIds().forEach(customerId-> govCustomerMenuRedis.delCustomerMenu(customerId, MenuTypeEnum.MENU.value()));
} }
@Override @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.dto.GovMenuDTO;
import com.epmet.entity.GovMenuEntity; import com.epmet.entity.GovMenuEntity;
import com.epmet.enums.MenuTypeEnum; import com.epmet.enums.MenuTypeEnum;
import com.epmet.feign.EpmetUserFeignClient; import com.epmet.redis.GovCustomerMenuRedis;
import com.epmet.redis.GovMenuRedis; import com.epmet.redis.GovMenuRedis;
import com.epmet.service.*; import com.epmet.service.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*; import java.util.*;
@ -57,7 +58,7 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
@Autowired @Autowired
private GovMenuRedis govMenuRedis; private GovMenuRedis govMenuRedis;
@Autowired @Autowired
private EpmetUserFeignClient epmetUserFeignClient; private GovCustomerMenuRedis govCustomerMenuRedis;
@Autowired @Autowired
private GovRoleMenuService govRoleMenuService; private GovRoleMenuService govRoleMenuService;
@Autowired @Autowired
@ -208,9 +209,15 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
* @Date 15:51 2021-03-16 * @Date 15:51 2021-03-16
**/ **/
private List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type) { 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<GovMenuEntity> menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage());
List<GovMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); List<GovMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class);
return TreeUtils.buildTree(dtoList); govMenuDTOS = TreeUtils.buildTree(dtoList);
govCustomerMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS);
return govMenuDTOS;
} }
@Override @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) { public Result shiftProjectV2(@LoginUser TokenDto tokenDTO, @RequestBody ShiftProjectFormDTO formDTO) {
formDTO.setStaffId(tokenDTO.getUserId()); formDTO.setStaffId(tokenDTO.getUserId());
ValidatorUtils.validateEntity(formDTO); ValidatorUtils.validateEntity(formDTO);
issueService.shiftProjectV2(formDTO); return issueService.shiftProjectV2(formDTO);
return new Result();
} }
/** /**

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.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IssueDTO; import com.epmet.dto.IssueDTO;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
@ -219,7 +220,7 @@ public interface IssueService extends BaseService<IssueEntity> {
* @param formDTO * @param formDTO
* @return void * @return void
*/ */
void shiftProjectV2(ShiftProjectFormDTO formDTO); Result shiftProjectV2(ShiftProjectFormDTO formDTO);
/** /**
* @Description 已关闭列表 政府端 * @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.AppClientConstant;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; 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.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.AchievementTypeEnum;
import com.epmet.commons.tools.enums.EventEnum; import com.epmet.commons.tools.enums.EventEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException; 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.IssueProcessEntity;
import com.epmet.entity.IssueProjectRelationEntity; import com.epmet.entity.IssueProjectRelationEntity;
import com.epmet.feign.*; import com.epmet.feign.*;
import com.epmet.commons.tools.enums.AchievementTypeEnum;
import com.epmet.redis.GovIssueRedis; import com.epmet.redis.GovIssueRedis;
import com.epmet.redis.IssueVoteDetailRedis; import com.epmet.redis.IssueVoteDetailRedis;
import com.epmet.resi.group.dto.group.form.AllIssueFormDTO; 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.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.redisson.api.RLock;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -136,6 +138,8 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
private GovProjectOpenFeignClient govProjectOpenFeignClient; private GovProjectOpenFeignClient govProjectOpenFeignClient;
@Autowired @Autowired
private IssueVoteDetailService issueVoteDetailService; private IssueVoteDetailService issueVoteDetailService;
@Autowired
private DistributedLock distributedLock;
@Value("${openapi.scan.server.url}") @Value("${openapi.scan.server.url}")
@ -957,127 +961,138 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
* @date 2020/12/9 10:01 * @date 2020/12/9 10:01
*/ */
@Override @Override
public void shiftProjectV2(ShiftProjectFormDTO formDTO) { public Result shiftProjectV2(ShiftProjectFormDTO formDTO) {
//1:查询议题数据 RLock lock = null;
IssueEntity entity = baseDao.selectById(formDTO.getIssueId()); try {
if (null == entity) { // 锁持有10分钟,等待10s
throw new RenException(IssueConstant.SELECT_EXCEPTION); lock = distributedLock.tryLock(formDTO.getIssueId());
} //1:查询议题数据
if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) { IssueEntity entity = baseDao.selectById(formDTO.getIssueId());
throw new RenException(IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION); if (null == entity) {
} throw new RenException(IssueConstant.SELECT_EXCEPTION);
if (!IssueConstant.ISSUE_VOTING.equals(entity.getIssueStatus())) { }
throw new RenException(IssueConstant.ISSUE_VOTING_EXCEPTION); if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) {
} throw new RenException(IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION);
formDTO.setIssueDTO(ConvertUtils.sourceToTarget(entity, IssueDTO.class)); }
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()); List<IssueCategoryDTO> categoryList = issueCategoryService.getCategoryByIssue(formDTO.getIssueId());
if (CollectionUtils.isEmpty(categoryList)) { if (CollectionUtils.isEmpty(categoryList)) {
throw new RenException(EpmetErrorCode.CATEGORY_IS_NULL.getCode()); throw new RenException(EpmetErrorCode.CATEGORY_IS_NULL.getCode());
} }
//公开回复内容审核 //公开回复内容审核
if (StringUtils.isNotBlank(formDTO.getPublicReply())) { if (StringUtils.isNotBlank(formDTO.getPublicReply())) {
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); TextScanParamDTO textScanParamDTO = new TextScanParamDTO();
TextTaskDTO taskDTO = new TextTaskDTO(); TextTaskDTO taskDTO = new TextTaskDTO();
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); taskDTO.setDataId(UUID.randomUUID().toString().replace("-", ""));
taskDTO.setContent(formDTO.getPublicReply()); taskDTO.setContent(formDTO.getPublicReply());
textScanParamDTO.getTasks().add(taskDTO); textScanParamDTO.getTasks().add(taskDTO);
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO);
if (!textSyncScanResult.success()) { if (!textSyncScanResult.success()) {
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
} else { } else {
if (!textSyncScanResult.getData().isAllPass()) { if (!textSyncScanResult.getData().isAllPass()) {
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); 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:更新议题相关业务表数据 //2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用
//4.1:更新议题表数据 Result<ResiTopicDTO> resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId());
entity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT); if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) {
entity.setShiftedTime(issueProjectResultDTO.getShiftedTime()); throw new RenException(IssueConstant.SELECT_TOPIC_EXCEPTION);
baseDao.updateById(entity); }
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:议题处理进展表新增数据 //4:更新议题相关业务表数据
IssueProcessEntity processEntity = new IssueProcessEntity(); //4.1:更新议题表数据
processEntity.setIssueId(entity.getId()); entity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT);
processEntity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT); entity.setShiftedTime(issueProjectResultDTO.getShiftedTime());
processEntity.setOrgType(IssueConstant.ISSUE_GRID); baseDao.updateById(entity);
processEntity.setOrgId(entity.getGridId());
processEntity.setOrgName(issueProjectResultDTO.getOrgName()); //4.2:议题处理进展表新增数据
issueProcessDao.insert(processEntity); 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:议题项目关系表新增数据 //6:缓存中网格下表决中的议题总数减1
IssueProjectRelationEntity relationEntity = new IssueProjectRelationEntity(); govIssueRedis.subtractWorkGrassrootsIssueRedDotValue(entity.getGridId());
relationEntity.setIssueId(entity.getId()); try{
relationEntity.setProjectId(issueProjectResultDTO.getProjectId()); issueVoteStatisticalService.syncVotingCacheToDbByParams(formDTO.getIssueId(),entity.getGridId(),null);
issueProjectRelationDao.insert(relationEntity); }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 //7:发送话题转议题积分事件
govIssueRedis.subtractWorkGrassrootsIssueRedDotValue(entity.getGridId()); TopicEventFormDTO eventParam = new TopicEventFormDTO();
try{ eventParam.setTopicId(entity.getSourceId());
issueVoteStatisticalService.syncVotingCacheToDbByParams(formDTO.getIssueId(),entity.getGridId(),null); eventParam.setEvent(EventEnum.TOPIC_SHIFTED_TO_PROJECT);
}catch(RenException e){ if(!resiGroupOpenFeignClient.sendEvent(eventParam).success()){
logger.error(e.getInternalMsg()); 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:发送话题转议题积分事件 //8.记录日志
TopicEventFormDTO eventParam = new TopicEventFormDTO(); //SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient).sendProjectChangedMqMsg();
eventParam.setTopicId(entity.getSourceId()); return new Result();
eventParam.setEvent(EventEnum.TOPIC_SHIFTED_TO_PROJECT); } catch (Exception e) {
if(!resiGroupOpenFeignClient.sendEvent(eventParam).success()){ return new Result().error("议题数据正在处理中,请勿重复提交!");
logger.warn("com.epmet.service.impl.IssueServiceImpl.shiftProjectV2,话题被转为项目积分事件发送失败,参数:{}", JSON.toJSONString(formDTO)); } 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.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; 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.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; 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.dao.IcBuildingUnitDao;
import com.epmet.dto.BuildingTreeLevelDTO; import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.form.IcBulidingFormDTO; import com.epmet.dto.form.*;
import com.epmet.dto.form.IcBulidingUnitFormDTO;
import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.BuildingResultDTO; import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.BuildingResultPagedDTO; import com.epmet.dto.result.BuildingResultPagedDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.entity.IcBuildingUnitEntity; import com.epmet.entity.IcBuildingUnitEntity;
import com.epmet.excel.IcBuildingExcel; import com.epmet.excel.IcBuildingExcel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.service.BuildingService; import com.epmet.service.BuildingService;
import com.epmet.service.IcBuildingService; import com.epmet.service.IcBuildingService;
import com.epmet.service.NeighborHoodService; import com.epmet.service.NeighborHoodService;
@ -66,17 +68,12 @@ import java.util.stream.Collectors;
@RequestMapping("building") @RequestMapping("building")
public class BuildingController { public class BuildingController {
@Autowired
private NeighborHoodService neighborHoodService;
@Autowired
private IcBuildingService icBuildingService;
@Autowired @Autowired
private BuildingService buildingService; private BuildingService buildingService;
@Autowired @Autowired
private IcBuildingUnitDao icBuildingUnitDao; private IcBuildingUnitDao icBuildingUnitDao;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@PostMapping("buildinglist") @PostMapping("buildinglist")
@ -219,7 +216,16 @@ public class BuildingController {
formDTO.setOrgType(orgType); formDTO.setOrgType(orgType);
formDTO.setOrgId(orgId); formDTO.setOrgId(orgId);
formDTO.setUserId(tokenDTO.getUserId()); 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 com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.tomcat.util.http.MimeHeaders;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -83,8 +90,6 @@ public class HouseController implements ResultDataResolver {
@Autowired @Autowired
private IcHouseRedis icHouseRedis; private IcHouseRedis icHouseRedis;
@Autowired @Autowired
private IcNeighborHoodService neighborHoodService;
@Autowired
private IcHouseService icHouseService; private IcHouseService icHouseService;
@Autowired @Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@ -255,52 +260,22 @@ public class HouseController implements ResultDataResolver {
@PostMapping("houseimport") @PostMapping("houseimport")
public Result houseImport(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file, public Result houseImport(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file,
@RequestParam("orgId")String orgId, @RequestParam("orgId")String orgId,
@RequestParam("orgType")String orgType){ @RequestParam("orgType")String orgType,HttpServletRequest multipartRequest){
ImportInfoFormDTO formDTO = new ImportInfoFormDTO(); ImportInfoFormDTO formDTO = new ImportInfoFormDTO();
formDTO.setCustomerId(tokenDTO.getCustomerId()); formDTO.setCustomerId(tokenDTO.getCustomerId());
formDTO.setOrgType(orgType); formDTO.setOrgType(orgType);
formDTO.setOrgId(orgId); formDTO.setOrgId(orgId);
formDTO.setUserId(tokenDTO.getUserId()); formDTO.setUserId(tokenDTO.getUserId());
ExcelReader excelReader = null; ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO();
try { importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_HOUSE);
InputStream inputStream = null; importFormDTO.setOperatorId(formDTO.getUserId());
try { importFormDTO.setOriginFileName(ImportErrorMsgConstants.HOUSE_ERROR_NAME);
inputStream = file.getInputStream(); Result<ImportTaskCommonResultDTO> importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO);
} catch (IOException e) { if (!importTask.success()){
return new Result<String>().error("读取文件失败"); throw new EpmetException("当前存在上传任务");
}
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()));
} }
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.annotation.LoginUser;
import com.epmet.commons.tools.dto.result.OptionResultDTO; 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.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; 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.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup; 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.IcNeighborHoodDTO;
import com.epmet.dto.form.ImportInfoFormDTO; 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 com.epmet.service.IcNeighborHoodService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -51,6 +57,8 @@ public class IcNeighborHoodController {
@Autowired @Autowired
private IcNeighborHoodService icNeighborHoodService; private IcNeighborHoodService icNeighborHoodService;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@GetMapping("page") @GetMapping("page")
public Result<PageData<IcNeighborHoodDTO>> page(@RequestParam Map<String, Object> params){ public Result<PageData<IcNeighborHoodDTO>> page(@RequestParam Map<String, Object> params){
@ -128,7 +136,16 @@ public class IcNeighborHoodController {
formDTO.setOrgType(orgType); formDTO.setOrgType(orgType);
formDTO.setOrgId(orgId); formDTO.setOrgId(orgId);
formDTO.setUserId(tokenDTO.getUserId()); 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.BuildingResultDTO;
import com.epmet.dto.result.BuildingResultPagedDTO; import com.epmet.dto.result.BuildingResultPagedDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.excel.IcBuildingExcel; import com.epmet.excel.IcBuildingExcel;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -74,6 +75,6 @@ public interface BuildingService {
* @author zxc * @author zxc
* @date 2022/2/13 10:18 上午 * @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; package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.IcHouseFormDTO; import com.epmet.dto.form.IcHouseFormDTO;
import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.HouseInfoDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.excel.IcHouseExcel; import com.epmet.excel.IcHouseExcel;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@ -62,4 +66,6 @@ public interface HouseService {
void exportBuildinginfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception; void exportBuildinginfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception;
List<HouseInfoDTO> queryListHouseInfo(Set<String> houseIds, String customerId); 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.IcNeighborHoodDTO;
import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.ImportGeneralDTO;
import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.entity.IcNeighborHoodEntity; import com.epmet.entity.IcNeighborHoodEntity;
import com.epmet.entity.IcNeighborHoodPropertyEntity; import com.epmet.entity.IcNeighborHoodPropertyEntity;
import com.epmet.entity.IcPropertyManagementEntity; import com.epmet.entity.IcPropertyManagementEntity;
@ -128,7 +129,7 @@ public interface IcNeighborHoodService extends BaseService<IcNeighborHoodEntity>
* @author zxc * @author zxc
* @date 2022/2/12 11:11 上午 * @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 * 获取导入小区楼栋单元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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -61,6 +63,7 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
@EnableAsync
public class BuildingServiceImpl implements BuildingService { public class BuildingServiceImpl implements BuildingService {
@ -401,7 +404,8 @@ public class BuildingServiceImpl implements BuildingService {
* @date 2022/2/13 10:15 上午 * @date 2022/2/13 10:15 上午
*/ */
@Override @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; ExcelReader excelReader = null;
try { try {
InputStream inputStream = null; InputStream inputStream = null;
@ -410,14 +414,6 @@ public class BuildingServiceImpl implements BuildingService {
} catch (IOException e) { } catch (IOException e) {
return new Result<String>().error("读取文件失败"); 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(); excelReader = EasyExcel.read(inputStream).build();
// 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
ReadSheet readSheet = EasyExcel.readSheet(0).head(BuildingInfoModel.class) 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.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.hutool.core.bean.BeanUtil; 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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.epmet.commons.tools.constant.NumConstant; 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.feign.ResultDataResolver;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcBuildingDao; import com.epmet.dao.IcBuildingDao;
import com.epmet.dao.IcBuildingUnitDao; import com.epmet.dao.IcBuildingUnitDao;
import com.epmet.dao.IcHouseDao; import com.epmet.dao.IcHouseDao;
@ -23,15 +27,20 @@ import com.epmet.dto.IcBuildingDTO;
import com.epmet.dto.IcBuildingUnitDTO; import com.epmet.dto.IcBuildingUnitDTO;
import com.epmet.dto.IcHouseDTO; import com.epmet.dto.IcHouseDTO;
import com.epmet.dto.form.IcHouseFormDTO; import com.epmet.dto.form.IcHouseFormDTO;
import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.HouseInfoDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.entity.IcHouseEntity; import com.epmet.entity.IcHouseEntity;
import com.epmet.enums.HousePurposeEnums; import com.epmet.enums.HousePurposeEnums;
import com.epmet.enums.HouseRentFlagEnums; import com.epmet.enums.HouseRentFlagEnums;
import com.epmet.enums.HouseTypeEnums; import com.epmet.enums.HouseTypeEnums;
import com.epmet.excel.IcHouseExcel; import com.epmet.excel.IcHouseExcel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.model.HouseInfoModel;
import com.epmet.model.ImportHouseInfoListener;
import com.epmet.redis.IcHouseRedis; import com.epmet.redis.IcHouseRedis;
import com.epmet.service.HouseService; import com.epmet.service.HouseService;
import com.epmet.service.IcBuildingService; import com.epmet.service.IcBuildingService;
@ -42,17 +51,23 @@ import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
@EnableAsync
public class HouseServiceImpl implements HouseService, ResultDataResolver { public class HouseServiceImpl implements HouseService, ResultDataResolver {
@ -77,6 +92,11 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver {
private IcHouseRedis icHouseRedis; private IcHouseRedis icHouseRedis;
@Autowired @Autowired
private AgencyService agencyservice; private AgencyService agencyservice;
@Autowired
private IcNeighborHoodService neighborHoodService;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@Override @Override
@ -329,4 +349,29 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver {
}); });
return result; 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.http.entity.ContentType;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -93,6 +95,7 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
@EnableAsync
public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao, IcNeighborHoodEntity> implements IcNeighborHoodService { public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao, IcNeighborHoodEntity> implements IcNeighborHoodService {
@Autowired @Autowired
@ -230,21 +233,9 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
* @date 2022/2/12 11:11 上午 * @date 2022/2/12 11:11 上午
*/ */
@Override @Override
public Result neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file) throws IOException { @Async
/*ExcelImportResult<IcNeighborHoodExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcNeighborHoodExcel.class); public void neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file,Result<ImportTaskCommonResultDTO> importTask) throws IOException {
List<IcNeighborHoodExcel> failList = importResult.getFailList(); importNeighbor(formDTO,file,importTask);
//存放错误数据行号
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);
} }
/** /**
@ -407,7 +398,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
return new Result().ok(str); 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; ExcelReader excelReader = null;
try { try {
InputStream inputStream = null; InputStream inputStream = null;
@ -416,14 +407,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
} catch (IOException e) { } catch (IOException e) {
return new Result<String>().error("读取文件失败"); 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(); excelReader = EasyExcel.read(inputStream).build();
// 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
ReadSheet readSheet = EasyExcel.readSheet(0).head(NeighborHoodInfoModel.class) ReadSheet readSheet = EasyExcel.readSheet(0).head(NeighborHoodInfoModel.class)
@ -435,19 +419,8 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
excelReader.finish(); excelReader.finish();
} }
} }
ImportResultDTO dto = icHouseRedis.getImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId());
if (null == dto){ return new Result<>();
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));
} }
/** /**

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, Integer workMinutes = calculateDelta_T(ProjectConstant.PRECISE_CALCULATION,
ProjectConstant.CALCULATION_TYPE_DEFAULT, fromDTO.getProjectId(), projectEntity.getCreatedTime(), current); ProjectConstant.CALCULATION_TYPE_DEFAULT, fromDTO.getProjectId(), projectEntity.getCreatedTime(), current);
projectEntity.setStatus(ProjectConstant.CLOSED); ProjectEntity newProject = new ProjectEntity();
projectEntity.setClosedStatus(fromDTO.getClosedStatus()); newProject.setId(fromDTO.getProjectId());
projectEntity.setWorkMinutes(workMinutes); newProject.setStatus(ProjectConstant.CLOSED);
baseDao.updateById(projectEntity); newProject.setClosedStatus(fromDTO.getClosedStatus());
newProject.setWorkMinutes(workMinutes);
baseDao.updateById(newProject);
//更新项目关联表 //更新项目关联表
ProjectStaffEntity projectStaffEntity = new ProjectStaffEntity(); ProjectStaffEntity projectStaffEntity = new ProjectStaffEntity();
projectStaffEntity.setId(fromDTO.getProjectStaffId()); projectStaffEntity.setId(fromDTO.getProjectStaffId());
@ -655,10 +657,12 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
Integer workMinutes = calculateDelta_T(ProjectConstant.PRECISE_CALCULATION, Integer workMinutes = calculateDelta_T(ProjectConstant.PRECISE_CALCULATION,
ProjectConstant.CALCULATION_TYPE_DEFAULT, fromDTO.getProjectId(), projectEntity.getCreatedTime(), current); ProjectConstant.CALCULATION_TYPE_DEFAULT, fromDTO.getProjectId(), projectEntity.getCreatedTime(), current);
projectEntity.setStatus(ProjectConstant.CLOSED); ProjectEntity newProject = new ProjectEntity();
projectEntity.setClosedStatus(fromDTO.getClosedStatus()); newProject.setId(fromDTO.getProjectId());
projectEntity.setWorkMinutes(workMinutes); newProject.setStatus(ProjectConstant.CLOSED);
baseDao.updateById(projectEntity); newProject.setClosedStatus(fromDTO.getClosedStatus());
newProject.setWorkMinutes(workMinutes);
baseDao.updateById(newProject);
//更新项目关联表 //更新项目关联表
ProjectStaffEntity projectStaffEntity = new ProjectStaffEntity(); ProjectStaffEntity projectStaffEntity = new ProjectStaffEntity();
projectStaffEntity.setId(fromDTO.getProjectStaffId()); 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; 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.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant; 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.collections4.CollectionUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -124,7 +126,9 @@ public class IcPartymemberStyleController {
} }
@PostMapping("import") @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()); String extension = FilenameUtils.getExtension(file.getOriginalFilename());
if (!"xls".equals(extension) && !"xlsx".equals(extension)) { if (!"xls".equals(extension) && !"xlsx".equals(extension)) {
@ -141,6 +145,8 @@ public class IcPartymemberStyleController {
} }
//2.执行导入程序 //2.执行导入程序
icPartymemberStyleService.importData(tokenDto, response, file, result.getData().getTaskId()); 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.http.entity.ContentType;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -92,6 +94,7 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
@EnableAsync
public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymemberStyleDao, IcPartymemberStyleEntity> implements IcPartymemberStyleService { public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymemberStyleDao, IcPartymemberStyleEntity> implements IcPartymemberStyleService {
@Resource @Resource
@ -254,7 +257,8 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
* @Date 2021/11/29 11:01 * @Date 2021/11/29 11:01
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) //@Transactional(rollbackFor = Exception.class)
@Async
public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException { public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException {
List<PartyMemberImportExcel> fileList = new ArrayList<>(); List<PartyMemberImportExcel> fileList = new ArrayList<>();
PartyMemberImportExcel excel = null; 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); String ip = IpUtils.getIpAddr(request);
SetOperations setOperations = redisTemplate.opsForSet(); SetOperations setOperations = redisTemplate.opsForSet();
if (!setOperations.isMember(RedisKeys.getWhiteList(), ip)) { 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())); String result = JSON.toJSONString(new Result<>().error(EpmetErrorCode.ERR401.getCode(), EpmetErrorCode.ERR401.getMsg()));
responseJson(response, result); responseJson(response, result);
return false; return false;

Loading…
Cancel
Save