Browse Source

Merge branch 'develop' of http://git.elinkit.com.cn:7070/r/epmet-cloud into release_temp

master
jianjun 4 years ago
parent
commit
ee830cc80c
  1. 1
      epmet-gateway/src/main/resources/bootstrap.yml
  2. 2
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java
  3. 66
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyActivityController.java
  4. 77
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java
  5. 38
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyActivityImportFailedExcel.java
  6. 38
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyUnitImportFailedExcel.java
  7. 3
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyActivityService.java
  8. 3
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyUnitService.java
  9. 261
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java
  10. 197
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java
  11. 4
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java
  12. 1
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java
  13. 24
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java

1
epmet-gateway/src/main/resources/bootstrap.yml

@ -234,6 +234,7 @@ spring:
- Path=${server.servlet.context-path}/commonservice/**
filters:
- StripPrefix=1
- CpAuth=true
#党建园地
- id: resi-home-server
uri: @gateway.routes.resi-home-server.uri@

2
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java

@ -13,6 +13,8 @@ public interface ImportTaskConstants {
String BIZ_TYPE_HOUSE = "house";
String BIZ_TYPE_PARTY_MEMBER = "party_member";
String BIZ_TYPE_COMMUNITY_SELF_ORG = "community_self_org";
String BIZ_TYPE_PARTY_UNIT = "party_unit";
String BIZ_TYPE_PARTY_ACTIVITY = "party_activity";
/**
* 处理状态处理中

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

@ -19,6 +19,8 @@ package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.DateUtils;
@ -27,20 +29,28 @@ import com.epmet.commons.tools.utils.Result;
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.constants.ImportTaskConstants;
import com.epmet.dto.IcPartyActivityDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.form.PartyActivityFormDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.excel.IcPartyActivityExcel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.service.IcPartyActivityService;
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.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -51,12 +61,15 @@ import java.util.stream.Collectors;
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-19
*/
@Slf4j
@RestController
@RequestMapping("icpartyactivity")
public class IcPartyActivityController {
@Autowired
private IcPartyActivityService icPartyActivityService;
@Resource
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@PostMapping("search")
public Result<PageData<IcPartyActivityDTO>> page(@RequestBody PartyActivityFormDTO formDTO){
@ -116,7 +129,58 @@ public class IcPartyActivityController {
*/
@PostMapping("import")
public Result importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException {
return icPartyActivityService.importData(tokenDto, response, file);
if (file.isEmpty()) {
throw new RenException("请上传文件");
}
String originalFilename = file.getOriginalFilename();
// 校验文件类型
String extension = FilenameUtils.getExtension(originalFilename);
if (!"xls".equals(extension) && !"xlsx".equals(extension)) {
throw new RenException("文件类型不匹配");
}
//1.查询当前工作人员是否有再导入的党员先锋数据,有则不允许导入,没有则进行新的导入
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO();
importTaskForm.setOriginFileName(file.getOriginalFilename());
importTaskForm.setOperatorId(tokenDto.getUserId());
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_UNIT);
Result<ImportTaskCommonResultDTO> result = commonServiceOpenFeignClient.createImportTask(importTaskForm);
if (!result.success()) {
throw new RenException(result.getInternalMsg());
}
// 异步执行导入
CompletableFuture.runAsync(() -> {
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
submitResiImportTask(tokenDto, response, file, result.getData().getTaskId());
});
return new Result();
}
private void submitResiImportTask(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String importTaskId) {
try {
icPartyActivityService.importData(tokenDto, response, file, importTaskId);
} catch (Throwable e) {
String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(e);
log.error("【导入联建活动信息失败】导入失败:{}", errorMsg);
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO();
importTaskForm.setOperatorId(tokenDto.getUserId());
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_ACTIVITY);
importTaskForm.setTaskId(importTaskId);
importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
importTaskForm.setResultDesc("联建活动信息导入失败,请查看系统日志");
Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm);
if (!result.success()) {
throw new RenException(result.getInternalMsg());
}
}
}
/**

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

@ -21,6 +21,8 @@ import com.epmet.commons.rocketmq.messages.ServerSatisfactionCalFormDTO;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.dto.result.OptionDataResultDTO;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ExcelUtils;
@ -29,23 +31,33 @@ import com.epmet.commons.tools.validator.AssertUtils;
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.constants.ImportTaskConstants;
import com.epmet.dto.IcPartyUnitDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.form.PartyActivityFormDTO;
import com.epmet.dto.form.PartyUnitFormDTO;
import com.epmet.dto.form.demand.ServiceQueryFormDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.dto.result.PartyUnitDistributionResultDTO;
import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.excel.IcPartyUnitExcel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.service.IcPartyUnitService;
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.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -56,12 +68,21 @@ import java.util.stream.Collectors;
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-19
*/
@Slf4j
@RestController
@RequestMapping("icpartyunit")
public class IcPartyUnitController {
@Autowired
private IcPartyUnitService icPartyUnitService;
@Resource
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
/**
* 联建单位上传临时目录
*/
private Path IC_PARTY_UNIT_UPLOAD_DIR;
@PostMapping("list")
public Result<PageData<IcPartyUnitDTO>> search(@LoginUser TokenDto tokenDto, @RequestBody PartyUnitFormDTO formDTO){
@ -151,8 +172,39 @@ public class IcPartyUnitController {
* @Date 2021/11/30 14:42
*/
@PostMapping("import")
public Result importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException {
return icPartyUnitService.importData(tokenDto, response, file);
public Result importData(@LoginUser TokenDto tokenDto, HttpServletRequest multipartRequest, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException {
if (file.isEmpty()) {
throw new RenException("请上传文件");
}
String originalFilename = file.getOriginalFilename();
// 校验文件类型
String extension = FilenameUtils.getExtension(originalFilename);
if (!"xls".equals(extension) && !"xlsx".equals(extension)) {
throw new RenException("文件类型不匹配");
}
//1.查询当前工作人员是否有再导入的党员先锋数据,有则不允许导入,没有则进行新的导入
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO();
importTaskForm.setOriginFileName(file.getOriginalFilename());
importTaskForm.setOperatorId(tokenDto.getUserId());
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_UNIT);
Result<ImportTaskCommonResultDTO> result = commonServiceOpenFeignClient.createImportTask(importTaskForm);
if (!result.success()) {
throw new RenException(result.getInternalMsg());
}
// 异步执行导入
CompletableFuture.runAsync(() -> {
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
submitResiImportTask(tokenDto, response, file, result.getData().getTaskId());
});
return new Result();
}
/**
@ -194,4 +246,25 @@ public class IcPartyUnitController {
icPartyUnitService.calPartyUnitSatisfation(formDTO);
return new Result();
}
private void submitResiImportTask(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String importTaskId) {
try {
icPartyUnitService.importData(tokenDto, response, file, importTaskId);
} catch (Throwable e) {
String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(e);
log.error("【导入联建单位信息失败】导入失败:{}", errorMsg);
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO();
importTaskForm.setOperatorId(tokenDto.getUserId());
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_UNIT);
importTaskForm.setTaskId(importTaskId);
importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
importTaskForm.setResultDesc("联建单位信息导入失败,请查看系统日志");
Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm);
if (!result.success()) {
throw new RenException(result.getInternalMsg());
}
}
}
}

38
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyActivityImportFailedExcel.java

@ -0,0 +1,38 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.epmet.commons.tools.utils.ExcelVerifyInfo;
import lombok.Data;
/**
* 联建活动
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-19
*/
@Data
public class IcPartyActivityImportFailedExcel extends ExcelVerifyInfo {
@Excel(name = "活动标题", width = 40)
private String title;
@Excel(name = "错误信息", width = 50)
private String errorInfo;
}

38
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyUnitImportFailedExcel.java

@ -0,0 +1,38 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.epmet.commons.tools.utils.ExcelVerifyInfo;
import lombok.Data;
/**
* 联建单位
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-19
*/
@Data
public class IcPartyUnitImportFailedExcel extends ExcelVerifyInfo {
@Excel(name = "单位名称", width = 40)
private String unitName;
@Excel(name = "错误信息", width = 50)
private String errorInfo;
}

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

@ -20,7 +20,6 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IcPartyActivityDTO;
import com.epmet.dto.form.PartyActivityFormDTO;
import com.epmet.dto.result.demand.OptionDTO;
@ -98,7 +97,7 @@ public interface IcPartyActivityService extends BaseService<IcPartyActivityEntit
* @Author zhaoqifeng
* @Date 2021/11/29 11:01
*/
Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException;
void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException;
/**
* 联建活动统计

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

@ -22,7 +22,6 @@ import com.epmet.commons.rocketmq.messages.ServerSatisfactionCalFormDTO;
import com.epmet.commons.tools.dto.result.OptionDataResultDTO;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IcPartyUnitDTO;
import com.epmet.dto.form.PartyActivityFormDTO;
import com.epmet.dto.form.PartyUnitFormDTO;
@ -132,7 +131,7 @@ public interface IcPartyUnitService extends BaseService<IcPartyUnitEntity> {
* @Author zhaoqifeng
* @Date 2021/11/29 11:01
*/
Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException;
void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException;
/**
* @Description 按类型统计单位数量

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

@ -17,13 +17,16 @@
package com.epmet.service.impl;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
@ -31,29 +34,42 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.ExcelPoiUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.IcPartyActivityDao;
import com.epmet.dto.IcPartyActivityDTO;
import com.epmet.dto.IcPartyUnitDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.form.PartyActivityFormDTO;
import com.epmet.dto.result.ActivityStatisticsDTO;
import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.entity.IcActivityServiceRelationEntity;
import com.epmet.entity.IcActivityUnitRelationEntity;
import com.epmet.entity.IcPartyActivityEntity;
import com.epmet.excel.IcPartyActivityImportExcel;
import com.epmet.excel.IcPartyActivityImportFailedExcel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.OssFeignClient;
import com.epmet.service.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -76,7 +92,10 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl<IcPartyActivityD
private IcActivityUnitRelationService icActivityUnitRelationService;
@Resource
private IcActivityServiceRelationService icActivityServiceRelationService;
@Resource
private OssFeignClient ossFeignClient;
@Resource
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Override
@ -233,16 +252,18 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl<IcPartyActivityD
* @Date 2021/11/29 11:01
*/
@Override
public Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException {
public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException {
List<IcPartyActivityImportFailedExcel> fileList = new ArrayList<>();
ExcelImportResult<IcPartyActivityImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartyActivityImportExcel.class);
List<IcPartyActivityImportExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if (!org.springframework.util.CollectionUtils.isEmpty(failList)) {
for (IcPartyActivityImportExcel entity : failList) {
//打印失败的行 和失败的信息
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());
numList.add(entity.getRowNum());
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(entity, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo(entity.getErrorMsg());
fileList.add(failed);
}
}
List<IcPartyActivityImportExcel> result = importResult.getList();
@ -262,14 +283,18 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl<IcPartyActivityD
IcPartyActivityImportExcel obj = iterator.next();
//单位名称校验
if (StringUtils.isBlank(obj.getUnitName())) {
numList.add(obj.getRowNum());
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo("单位名称为空");
fileList.add(failed);
log.warn(String.format("单位名称为空,行号->%s", obj.getRowNum()));
iterator.remove();
} else {
List<String> unitList = Arrays.asList(obj.getUnitName().split(StrConstant.COMMA));
unitList.forEach(unit -> {
if (null == option.get(unit)) {
numList.add(obj.getRowNum());
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo("单位名称不存在");
fileList.add(failed);
log.warn(String.format("单位名称不存在,行号->%s", obj.getRowNum()));
iterator.remove();
}
@ -277,14 +302,18 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl<IcPartyActivityD
}
//服务事项校验
if (StringUtils.isBlank(obj.getServiceMatter())) {
numList.add(obj.getRowNum());
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo("服务事项为空");
fileList.add(failed);
log.warn(String.format("服务事项为空,行号->%s", obj.getRowNum()));
iterator.remove();
} else {
List<String> serviceList = Arrays.asList(obj.getServiceMatter().split(StrConstant.SEMICOLON));
serviceList.forEach(service -> {
if (null == categoryMap.get(service)) {
numList.add(obj.getRowNum());
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo("服务事项不存在");
fileList.add(failed);
log.warn(String.format("服务事项不存在,行号->%s", obj.getRowNum()));
iterator.remove();
}
@ -292,79 +321,163 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl<IcPartyActivityD
}
//活动标题 活动目标 活动内容 活动时间 活动地址 活动地址经度 活动地址纬度 活动结果
if(StringUtils.isBlank(obj.getTitle()) || StringUtils.isBlank(obj.getTarget()) ||
StringUtils.isBlank(obj.getContent()) ||
StringUtils.isBlank(obj.getActivityTime()) ||
StringUtils.isBlank(obj.getAddress()) ||
StringUtils.isBlank(obj.getLatitude()) ||
StringUtils.isBlank(obj.getLongitude()) ||
StringUtils.isBlank(obj.getResult())) {
numList.add(obj.getRowNum());
log.warn(String.format("活动标题、活动目标、活动内容、活动时间、活动地址、活动地址经度、活动地址纬度、活动结果为空,行号->%s", obj.getRowNum()));
if(StringUtils.isBlank(obj.getTitle())) {
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo("活动标题为空");
fileList.add(failed);
log.warn(String.format("活动标题为空,行号->%s", obj.getRowNum()));
iterator.remove();
} else if(StringUtils.isBlank(obj.getTarget())) {
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo("活动目标为空");
fileList.add(failed);
log.warn(String.format("活动目标为空,行号->%s", obj.getRowNum()));
} else if(StringUtils.isBlank(obj.getContent())) {
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo("活动内容为空");
fileList.add(failed);
log.warn(String.format("活动内容为空,行号->%s", obj.getRowNum()));
} else if(StringUtils.isBlank(obj.getActivityTime())) {
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo("活动时间为空");
fileList.add(failed);
log.warn(String.format("活动时间为空,行号->%s", obj.getRowNum()));
} else if(StringUtils.isBlank(obj.getAddress())) {
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo("活动地址为空");
fileList.add(failed);
log.warn(String.format("活动地址为空,行号->%s", obj.getRowNum()));
} else if(StringUtils.isBlank(obj.getLatitude())) {
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo("活动地址纬度为空");
fileList.add(failed);
log.warn(String.format("活动地址纬度为空,行号->%s", obj.getRowNum()));
} else if(StringUtils.isBlank(obj.getLongitude())) {
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo("活动地址经度为空");
fileList.add(failed);
log.warn(String.format("活动地址经度为空,行号->%s", obj.getRowNum()));
} else if(StringUtils.isBlank(obj.getResult())) {
IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class);
failed.setErrorInfo("活动结果为空");
fileList.add(failed);
log.warn(String.format("活动结果为空,行号->%s", obj.getRowNum()));
}
}
if (CollectionUtils.isEmpty(result)) {
Collections.sort(numList);
String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、"));
return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "第" + subList + "行未成功!");
if (CollectionUtils.isNotEmpty(result)) {
result.forEach(item -> {
IcPartyActivityEntity entity = new IcPartyActivityEntity();
entity.setCustomerId(tokenDto.getCustomerId());
entity.setAgencyId(staffInfoCache.getAgencyId());
entity.setPids(staffInfoCache.getAgencyPIds());
entity.setTitle(item.getTitle());
entity.setTarget(item.getTarget());
entity.setContent(item.getContent());
entity.setPeopleCount(item.getPeopleCount());
entity.setActivityTime(DateUtils.parse(item.getActivityTime(), DateUtils.DATE_TIME_PATTERN));
entity.setAddress(item.getAddress());
entity.setLatitude(item.getLatitude());
entity.setLongitude(item.getLongitude());
entity.setResult(item.getResult());
insert(entity);
//保存活动与单位关系
icActivityUnitRelationService.deleteByActivity(entity.getId());
AtomicInteger i = new AtomicInteger(NumConstant.ONE);
List<IcActivityUnitRelationEntity> unitRelationList = Arrays.stream(item.getUnitName().split(StrConstant.COMMA)).map(unit -> {
IcActivityUnitRelationEntity relation = new IcActivityUnitRelationEntity();
relation.setCustomerId(entity.getCustomerId());
relation.setAgencyId(entity.getAgencyId());
relation.setPids(entity.getPids());
relation.setActivityId(entity.getId());
relation.setUnitId(option.get(unit));
relation.setSort(i.getAndIncrement());
return relation;
}).collect(Collectors.toList());
icActivityUnitRelationService.insertBatch(unitRelationList);
//保存活动与服务关系
icActivityServiceRelationService.deleteByActivity(entity.getId());
AtomicInteger j = new AtomicInteger(NumConstant.ONE);
List<IcActivityServiceRelationEntity> serviceRelationList = Arrays.stream(item.getServiceMatter().split(StrConstant.SEMICOLON)).map(service -> {
IcActivityServiceRelationEntity relation = new IcActivityServiceRelationEntity();
relation.setCustomerId(entity.getCustomerId());
relation.setAgencyId(entity.getAgencyId());
relation.setPids(entity.getPids());
relation.setActivityId(entity.getId());
relation.setServiceMatter(categoryMap.get(service));
relation.setSort(j.getAndIncrement());
return relation;
}).collect(Collectors.toList());
icActivityServiceRelationService.insertBatch(serviceRelationList);
});
}
String str = String.format("共%s条,成功导入%s条。", fileList.size() + result.size(), fileList.size() + result.size() - fileList.size());
result.forEach(item -> {
IcPartyActivityEntity entity = new IcPartyActivityEntity();
entity.setCustomerId(tokenDto.getCustomerId());
entity.setAgencyId(staffInfoCache.getAgencyId());
entity.setPids(staffInfoCache.getAgencyPIds());
entity.setTitle(item.getTitle());
entity.setTarget(item.getTarget());
entity.setContent(item.getContent());
entity.setPeopleCount(item.getPeopleCount());
entity.setActivityTime(DateUtils.parse(item.getActivityTime(), DateUtils.DATE_TIME_PATTERN));
entity.setAddress(item.getAddress());
entity.setLatitude(item.getLatitude());
entity.setLongitude(item.getLongitude());
entity.setResult(item.getResult());
insert(entity);
//保存活动与单位关系
icActivityUnitRelationService.deleteByActivity(entity.getId());
AtomicInteger i = new AtomicInteger(NumConstant.ONE);
List<IcActivityUnitRelationEntity> unitRelationList = Arrays.stream(item.getUnitName().split(StrConstant.COMMA)).map(unit -> {
IcActivityUnitRelationEntity relation = new IcActivityUnitRelationEntity();
relation.setCustomerId(entity.getCustomerId());
relation.setAgencyId(entity.getAgencyId());
relation.setPids(entity.getPids());
relation.setActivityId(entity.getId());
relation.setUnitId(option.get(unit));
relation.setSort(i.getAndIncrement());
return relation;
}).collect(Collectors.toList());
icActivityUnitRelationService.insertBatch(unitRelationList);
//保存活动与服务关系
icActivityServiceRelationService.deleteByActivity(entity.getId());
AtomicInteger j = new AtomicInteger(NumConstant.ONE);
List<IcActivityServiceRelationEntity> serviceRelationList = Arrays.stream(item.getServiceMatter().split(StrConstant.SEMICOLON)).map(service -> {
IcActivityServiceRelationEntity relation = new IcActivityServiceRelationEntity();
relation.setCustomerId(entity.getCustomerId());
relation.setAgencyId(entity.getAgencyId());
relation.setPids(entity.getPids());
relation.setActivityId(entity.getId());
relation.setServiceMatter(categoryMap.get(service));
relation.setSort(j.getAndIncrement());
return relation;
}).collect(Collectors.toList());
icActivityServiceRelationService.insertBatch(serviceRelationList);
});
String str = String.format("共%s条,成功导入%s条。", numList.size() + result.size(), numList.size() + result.size() - numList.size());
if (numList.size() > NumConstant.ZERO) {
Collections.sort(numList);
if (fileList.size() > NumConstant.ZERO) {
List<Integer> numList = fileList.stream().map(IcPartyActivityImportFailedExcel::getRowNum).sorted().collect(Collectors.toList());
String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、"));
log.warn(str + "第" + subList + "行未成功!");
return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str + "第" + subList + "行未成功!");
}
return new Result().ok(str);
//错误数据生成文件,修改导入任务状态
erroeImport(fileList, taskId, tokenDto.getUserId());
}
private void erroeImport(List<IcPartyActivityImportFailedExcel> fileList, String importTaskId, String staffId) throws IOException {
String url = "";
//1.有错误数据则生成错误数据存放文件传到阿里云服务
if (CollectionUtils.isNotEmpty(fileList)) {
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表", "导入失败的数据列表"),
IcPartyActivityImportFailedExcel.class, fileList);
// 文件名
String resultDescFileName = UUID.randomUUID().toString().concat(".xlsx");
FileItemFactory factory = new DiskFileItemFactory(16, null);
FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName);
OutputStream os = fileItem.getOutputStream();
Result<UploadImgResultDTO> uploadResult = null;
try {
workbook.write(os);
uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem));
} catch (Exception e) {
String errormsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【联建活动信息导入】上传错误描述文件:{}", errormsg);
} finally {
try {
os.close();
} catch (IOException e) {
String errormsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【联建活动信息导入】上传错误描述文件关闭输出流:{}", errormsg);
}
try {
fileItem.delete();
} catch (Exception e) {
String errormsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【联建活动信息导入】上传错误描述文件删除临时文件:{}", errormsg);
}
}
if (uploadResult == null || !uploadResult.success()) {
log.error("【联建活动信息导入】调用OSS上传结果描述文件失败");
} else {
url = uploadResult.getData().getUrl();
}
}
//2.更新导入任务数据
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO();
importTaskForm.setOperatorId(staffId);
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_ACTIVITY);
importTaskForm.setTaskId(importTaskId);
importTaskForm.setResultDescFilePath(url);
importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS);
if (CollectionUtils.isNotEmpty(fileList)) {
importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
importTaskForm.setResultDesc("联建活动导入存在错误数据");
}
Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm);
if (!result.success()) {
throw new RenException(result.getInternalMsg());
}
}
/**

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

@ -17,6 +17,8 @@
package com.epmet.service.impl;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -34,6 +36,8 @@ import com.epmet.commons.tools.enums.DictTypeEnum;
import com.epmet.commons.tools.enums.PartyUnitTypeEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
@ -41,17 +45,23 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.ExcelPoiUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.UserDemandConstant;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.IcPartyUnitDao;
import com.epmet.dto.IcPartyUnitDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.form.PartyActivityFormDTO;
import com.epmet.dto.form.PartyUnitFormDTO;
import com.epmet.dto.form.demand.ServiceQueryFormDTO;
import com.epmet.dto.result.PartyUnitDistributionResultDTO;
import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.dto.result.demand.ServiceStatDTO;
import com.epmet.entity.IcPartyUnitEntity;
import com.epmet.excel.IcPartyUnitImportExcel;
import com.epmet.excel.IcPartyUnitImportFailedExcel;
import com.epmet.feign.EpmetAdminOpenFeignClient;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.OssFeignClient;
import com.epmet.service.IcPartyUnitService;
import com.epmet.service.IcResiDemandDictService;
import com.epmet.service.IcServiceItemDictService;
@ -60,14 +70,21 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@ -90,6 +107,10 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
private IcResiDemandDictService icResiDemandDictService;
@Resource
private IcServiceItemDictService icServiceItemDictService;
@Resource
private OssFeignClient ossFeignClient;
@Resource
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Override
public PageData<IcPartyUnitDTO> search(PartyUnitFormDTO formDTO) {
@ -303,16 +324,19 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
* @Date 2021/11/29 11:01
*/
@Override
public Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException {
public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException {
List<IcPartyUnitImportFailedExcel> fileList = new ArrayList<>();
ExcelImportResult<IcPartyUnitImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartyUnitImportExcel.class);
List<IcPartyUnitImportExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if (!org.springframework.util.CollectionUtils.isEmpty(failList)) {
for (IcPartyUnitImportExcel entity : failList) {
//打印失败的行 和失败的信息
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());
numList.add(entity.getRowNum());
IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(entity, IcPartyUnitImportFailedExcel.class);
failed.setErrorInfo(entity.getErrorMsg());
fileList.add(failed);
}
}
List<IcPartyUnitImportExcel> result = importResult.getList();
@ -329,7 +353,9 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
IcPartyUnitImportExcel obj = iterator.next();
//单位名称不能为空,不可重复
if (StringUtils.isBlank(obj.getUnitName())) {
numList.add(obj.getRowNum());
IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class);
failed.setErrorInfo("单位名称为空");
fileList.add(failed);
log.warn(String.format("单位名称为空,行号->%s", obj.getRowNum()));
iterator.remove();
} else {
@ -338,14 +364,18 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
wrapper.eq(IcPartyUnitEntity::getUnitName, obj.getUnitName());
List<IcPartyUnitEntity> list = baseDao.selectList(wrapper);
if (CollectionUtils.isNotEmpty(list)) {
numList.add(obj.getRowNum());
IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class);
failed.setErrorInfo("单位名称已存在");
fileList.add(failed);
log.warn(String.format("单位名称已存在,行号->%s", obj.getRowNum()));
iterator.remove();
}
}
//分类校验
if (StringUtils.isBlank(obj.getType()) || null == PartyUnitTypeEnum.getCode(obj.getType())) {
numList.add(obj.getRowNum());
IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class);
failed.setErrorInfo("分类名不存在");
fileList.add(failed);
log.warn(String.format("分类名不存在,行号->%s", obj.getRowNum()));
iterator.remove();
}
@ -354,62 +384,139 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
List<String> matters = Arrays.asList(obj.getServiceMatter().split(StrConstant.COLON));
matters.forEach(item -> {
if (null == categoryMap.get(item)) {
numList.add(obj.getRowNum());
IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class);
failed.setErrorInfo("服务事项不存在");
fileList.add(failed);
log.warn(String.format("服务事项不存在,行号->%s", obj.getRowNum()));
iterator.remove();
}
});
}
//联系人 联系电话 在职党员 地址 中心位置经度 中心位置纬度 校验
if (StringUtils.isBlank(obj.getContact()) || StringUtils.isBlank(obj.getContactMobile()) ||
StringUtils.isBlank(obj.getContact()) ||
null == obj.getMemberCount() ||
StringUtils.isBlank(obj.getLatitude()) ||
StringUtils.isBlank(obj.getLongitude())) {
numList.add(obj.getRowNum());
log.warn(String.format("联系人、联系电话、在职党员、地址、中心位置经度、中心位置纬度为空,行号->%s", obj.getRowNum()));
if (StringUtils.isBlank(obj.getContact())) {
IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class);
failed.setErrorInfo("联系人为空");
fileList.add(failed);
log.warn(String.format("联系人为空,行号->%s", obj.getRowNum()));
iterator.remove();
} else if (StringUtils.isBlank(obj.getContactMobile())) {
IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class);
failed.setErrorInfo("联系电话为空");
fileList.add(failed);
log.warn(String.format("联系电话为空,行号->%s", obj.getRowNum()));
} else if (StringUtils.isBlank(obj.getAddress())) {
IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class);
failed.setErrorInfo("地址为空");
fileList.add(failed);
log.warn(String.format("地址为空,行号->%s", obj.getRowNum()));
} else if (null == obj.getMemberCount()) {
IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class);
failed.setErrorInfo("在职党员为空");
fileList.add(failed);
log.warn(String.format("在职党员为空,行号->%s", obj.getRowNum()));
} else if (StringUtils.isBlank(obj.getLatitude())) {
IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class);
failed.setErrorInfo("中心位置纬度为空");
fileList.add(failed);
log.warn(String.format("中心位置纬度为空,行号->%s", obj.getRowNum()));
} else if (StringUtils.isBlank(obj.getLongitude())) {
IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class);
failed.setErrorInfo("中心位置经度为空");
fileList.add(failed);
log.warn(String.format("中心位置经度为空,行号->%s", obj.getRowNum()));
}
}
if (CollectionUtils.isEmpty(result)) {
Collections.sort(numList);
String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、"));
return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "第" + subList + "行未成功!");
}
List<IcPartyUnitEntity> list = result.stream().map(item -> {
IcPartyUnitEntity entity = new IcPartyUnitEntity();
entity.setCustomerId(tokenDto.getCustomerId());
entity.setAgencyId(staffInfoCache.getAgencyId());
entity.setPids(staffInfoCache.getAgencyPIds());
entity.setUnitName(item.getUnitName());
entity.setType(PartyUnitTypeEnum.getCode(item.getType()));
if (StringUtils.isNotBlank(item.getServiceMatter())) {
entity.setServiceMatter(getServiceMatter(categoryMap, item.getServiceMatter()));
}
entity.setContact(item.getContact());
entity.setContactMobile(item.getContactMobile());
entity.setAddress(item.getAddress());
entity.setLatitude(item.getLatitude());
entity.setLongitude(item.getLongitude());
entity.setMemberCount(item.getMemberCount());
entity.setRemark(item.getRemark());
return entity;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(result)) {
List<IcPartyUnitEntity> list = result.stream().map(item -> {
IcPartyUnitEntity entity = new IcPartyUnitEntity();
entity.setCustomerId(tokenDto.getCustomerId());
entity.setAgencyId(staffInfoCache.getAgencyId());
entity.setPids(staffInfoCache.getAgencyPIds());
entity.setUnitName(item.getUnitName());
entity.setType(PartyUnitTypeEnum.getCode(item.getType()));
if (StringUtils.isNotBlank(item.getServiceMatter())) {
entity.setServiceMatter(getServiceMatter(categoryMap, item.getServiceMatter()));
}
entity.setContact(item.getContact());
entity.setContactMobile(item.getContactMobile());
entity.setAddress(item.getAddress());
entity.setLatitude(item.getLatitude());
entity.setLongitude(item.getLongitude());
entity.setMemberCount(item.getMemberCount());
entity.setRemark(item.getRemark());
return entity;
}).collect(Collectors.toList());
insertBatch(list);
insertBatch(list);
}
String str = String.format("共%s条,成功导入%s条。", numList.size() + result.size(), numList.size() + result.size() - numList.size());
if (numList.size() > NumConstant.ZERO) {
Collections.sort(numList);
String str = String.format("共%s条,成功导入%s条。", fileList.size() + result.size(), fileList.size() + result.size() - fileList.size());
if (fileList.size() > NumConstant.ZERO) {
List<Integer> numList = fileList.stream().map(IcPartyUnitImportFailedExcel::getRowNum).sorted().collect(Collectors.toList());
String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、"));
log.warn(str + "第" + subList + "行未成功!");
return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str + "第" + subList + "行未成功!");
}
return new Result().ok(str);
//错误数据生成文件,修改导入任务状态
erroeImport(fileList, taskId, tokenDto.getUserId());
}
private void erroeImport(List<IcPartyUnitImportFailedExcel> fileList, String importTaskId, String staffId) throws IOException {
String url = "";
//1.有错误数据则生成错误数据存放文件传到阿里云服务
if (CollectionUtils.isNotEmpty(fileList)) {
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表", "导入失败的数据列表"),
IcPartyUnitImportFailedExcel.class, fileList);
// 文件名
String resultDescFileName = UUID.randomUUID().toString().concat(".xlsx");
FileItemFactory factory = new DiskFileItemFactory(16, null);
FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName);
OutputStream os = fileItem.getOutputStream();
Result<UploadImgResultDTO> uploadResult = null;
try {
workbook.write(os);
uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem));
} catch (Exception e) {
String errormsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【联建单位信息导入】上传错误描述文件:{}", errormsg);
} finally {
try {
os.close();
} catch (IOException e) {
String errormsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【联建单位信息导入】上传错误描述文件关闭输出流:{}", errormsg);
}
try {
fileItem.delete();
} catch (Exception e) {
String errormsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【联建单位信息导入】上传错误描述文件删除临时文件:{}", errormsg);
}
}
if (uploadResult == null || !uploadResult.success()) {
log.error("【联建单位信息导入】调用OSS上传结果描述文件失败");
} else {
url = uploadResult.getData().getUrl();
}
}
//2.更新导入任务数据
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO();
importTaskForm.setOperatorId(staffId);
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_UNIT);
importTaskForm.setTaskId(importTaskId);
importTaskForm.setResultDescFilePath(url);
importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS);
if (CollectionUtils.isNotEmpty(fileList)) {
importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
importTaskForm.setResultDesc("联建单位导入存在错误数据");
}
Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm);
if (!result.success()) {
throw new RenException(result.getInternalMsg());
}
}
/**
* @param formDTO
* @Description 按类型统计单位数量

4
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java

@ -52,6 +52,10 @@ public class ShiftProjectFormDTO implements Serializable {
* 议题标签
*/
private List<IssueTagsDTO> tagList;
/**
* token中客户Id
*/
private String customerId;
}

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

@ -181,6 +181,7 @@ public class IssueManageController {
@PostMapping("shiftproject-v2")
public Result shiftProjectV2(@LoginUser TokenDto tokenDTO, @RequestBody ShiftProjectFormDTO formDTO) {
formDTO.setStaffId(tokenDTO.getUserId());
formDTO.setCustomerId(tokenDTO.getCustomerId());
ValidatorUtils.validateEntity(formDTO);
return issueService.shiftProjectV2(formDTO);
}

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

@ -964,25 +964,25 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
public Result shiftProjectV2(ShiftProjectFormDTO formDTO) {
RLock lock = null;
try {
// 锁持有10分钟,等待10s
lock = distributedLock.tryLock(formDTO.getIssueId());
//获取锁,判断当前议题是否已处理
lock = distributedLock.tryLock(formDTO.getCustomerId() + formDTO.getIssueId());
//1:查询议题数据
IssueEntity entity = baseDao.selectById(formDTO.getIssueId());
if (null == entity) {
throw new RenException(IssueConstant.SELECT_EXCEPTION);
throw new EpmetException(9999,IssueConstant.SELECT_EXCEPTION,IssueConstant.SELECT_EXCEPTION);
}
if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) {
throw new RenException(IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION);
throw new EpmetException(9999,IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION,IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION);
}
if (!IssueConstant.ISSUE_VOTING.equals(entity.getIssueStatus())) {
throw new RenException(IssueConstant.ISSUE_VOTING_EXCEPTION);
throw new EpmetException(9999,IssueConstant.ISSUE_VOTING_EXCEPTION,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());
throw new EpmetException(EpmetErrorCode.CATEGORY_IS_NULL.getCode(),EpmetErrorCode.CATEGORY_IS_NULL.getMsg(),EpmetErrorCode.CATEGORY_IS_NULL.getMsg());
}
//公开回复内容审核
@ -994,10 +994,10 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
textScanParamDTO.getTasks().add(taskDTO);
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO);
if (!textSyncScanResult.success()) {
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(),EpmetErrorCode.SERVER_ERROR.getMsg(),EpmetErrorCode.SERVER_ERROR.getMsg());
} else {
if (!textSyncScanResult.getData().isAllPass()) {
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode());
throw new EpmetException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode(),EpmetErrorCode.TEXT_SCAN_FAILED.getMsg(),EpmetErrorCode.TEXT_SCAN_FAILED.getMsg());
}
}
}
@ -1007,7 +1007,7 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
//2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用
Result<ResiTopicDTO> resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId());
if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) {
throw new RenException(IssueConstant.SELECT_TOPIC_EXCEPTION);
throw new EpmetException(9999,IssueConstant.SELECT_TOPIC_EXCEPTION,IssueConstant.SELECT_TOPIC_EXCEPTION);
}
ResiTopicDTO topicDTO = resultTopicDTO.getData();
formDTO.setTopicDTO(topicDTO);
@ -1019,7 +1019,7 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
Result<IssueProjectResultDTO> resultDTO = govProjectFeignClient.issueShiftProject(formDTO);
if (!resultDTO.success() || null == resultDTO.getData()) {
logger.error(resultDTO.getInternalMsg());
throw new RenException(IssueConstant.GOV_PRJECT_EXCEPTION);
throw new EpmetException(9999,IssueConstant.GOV_PRJECT_EXCEPTION,IssueConstant.GOV_PRJECT_EXCEPTION);
}
IssueProjectResultDTO issueProjectResultDTO = resultDTO.getData();
//更新项目对标签的引用次数
@ -1054,7 +1054,7 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
//5:调用epmet-message服务,给居民端话题创建人、议题发起人以及政府端工作人员发送消息
if (!shiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) {
throw new RenException(IssueConstant.SAVE_MSG_EXCEPTION);
throw new EpmetException(9999,IssueConstant.SAVE_MSG_EXCEPTION,IssueConstant.SAVE_MSG_EXCEPTION);
}
//5-1:2020.10.26 添加给居民端话题创建人、议题发起人以及政府端工作人员推送微信订阅消息功能 sun
if (!wxmpShiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) {
@ -1088,7 +1088,7 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
//SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient).sendProjectChangedMqMsg();
return new Result();
} catch (Exception e) {
return new Result().error("议题数据正在处理中,请勿重复提交!");
return new Result().error(e.getMessage());
} finally {
distributedLock.unLock(lock);
}

Loading…
Cancel
Save