!65 refactor(bgpartymatter): 合并重复的导入导出接口,通过参数区分会议类型
* refactor(bgpartymatter): 合并重复的导入导出接口,通过参数区分会议类型 * feat(excel): 导入支持收集实体 ID 和注入默认值,新增 BgPartymatter 常量类
This commit is contained in:
+31
-4
@@ -204,6 +204,16 @@ public class JeecgController<T, S extends IService<T>> {
|
|||||||
* 通过EasyExcel导入数据,基于 @Excel 注解读取列配置
|
* 通过EasyExcel导入数据,基于 @Excel 注解读取列配置
|
||||||
*/
|
*/
|
||||||
protected Result<?> importExcelByEasyExcel(HttpServletRequest request, Class<T> clazz) {
|
protected Result<?> importExcelByEasyExcel(HttpServletRequest request, Class<T> clazz) {
|
||||||
|
return importExcelByEasyExcel(request, clazz, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过EasyExcel导入数据,基于 @Excel 注解读取列配置
|
||||||
|
*
|
||||||
|
* @param defaultValues 为每行数据注入的默认字段值(key 为实体属性名),在 saveBatch 前设置,可为 null
|
||||||
|
*/
|
||||||
|
protected Result<?> importExcelByEasyExcel(HttpServletRequest request, Class<T> clazz,
|
||||||
|
Map<String, Object> defaultValues) {
|
||||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||||
MultipartFile file = fileMap.values().stream().findFirst().orElse(null);
|
MultipartFile file = fileMap.values().stream().findFirst().orElse(null);
|
||||||
@@ -213,21 +223,38 @@ public class JeecgController<T, S extends IService<T>> {
|
|||||||
try (InputStream inputStream = file.getInputStream()) {
|
try (InputStream inputStream = file.getInputStream()) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
List<ExcelAnnotationUtils.ValidationError> errors = new ArrayList<>();
|
List<ExcelAnnotationUtils.ValidationError> errors = new ArrayList<>();
|
||||||
|
List<String> importedIds = new ArrayList<>();
|
||||||
int total = ExcelAnnotationUtils.read(
|
int total = ExcelAnnotationUtils.read(
|
||||||
inputStream,
|
inputStream,
|
||||||
clazz,
|
clazz,
|
||||||
batch -> service.saveBatch(batch),
|
batch -> {
|
||||||
|
if (defaultValues != null && !defaultValues.isEmpty()) {
|
||||||
|
for (T item : batch) {
|
||||||
|
for (Map.Entry<String, Object> entry : defaultValues.entrySet()) {
|
||||||
|
try {
|
||||||
|
PropertyUtils.setProperty(item, entry.getKey(), entry.getValue());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【EasyExcel导入】注入默认值失败, field: {}, value: {}",
|
||||||
|
entry.getKey(), entry.getValue(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
service.saveBatch(batch);
|
||||||
|
},
|
||||||
BATCH_NUM,
|
BATCH_NUM,
|
||||||
errors::addAll,
|
errors::addAll,
|
||||||
dictQuery());
|
dictQuery(),
|
||||||
log.info("【EasyExcel导入】导入完成, 数据行数: {}, 耗时: {}毫秒", total, System.currentTimeMillis() - start);
|
batch -> batch.forEach(item -> importedIds.add(getId(item))));
|
||||||
|
log.info("【EasyExcel导入】导入完成, 数据行数: {}, 导入ID数: {}, 耗时: {}毫秒",
|
||||||
|
total, importedIds.size(), System.currentTimeMillis() - start);
|
||||||
if (!errors.isEmpty()) {
|
if (!errors.isEmpty()) {
|
||||||
for (ExcelAnnotationUtils.ValidationError err : errors) {
|
for (ExcelAnnotationUtils.ValidationError err : errors) {
|
||||||
log.error("【EasyExcel导入】校验失败, 行号: {}, 错误: {}", err.row(), err.messages());
|
log.error("【EasyExcel导入】校验失败, 行号: {}, 错误: {}", err.row(), err.messages());
|
||||||
}
|
}
|
||||||
return Result.error("文件导入失败: 存在" + errors.size() + "行数据校验不通过,请修改后重新导入", errors);
|
return Result.error("文件导入失败: 存在" + errors.size() + "行数据校验不通过,请修改后重新导入", errors);
|
||||||
}
|
}
|
||||||
return Result.ok("文件导入成功!数据行数:" + total);
|
return Result.OK("文件导入成功!数据行数:" + total, importedIds);
|
||||||
} catch (DuplicateKeyException e) {
|
} catch (DuplicateKeyException e) {
|
||||||
log.error("【EasyExcel导入】存在重复数据", e);
|
log.error("【EasyExcel导入】存在重复数据", e);
|
||||||
return Result.error("文件导入失败:有重复数据!");
|
return Result.error("文件导入失败:有重复数据!");
|
||||||
|
|||||||
+15
-1
@@ -177,6 +177,20 @@ public final class ExcelAnnotationUtils {
|
|||||||
Consumer<List<T>> batchHandler, int batchSize,
|
Consumer<List<T>> batchHandler, int batchSize,
|
||||||
Consumer<List<ValidationError>> errorHandler,
|
Consumer<List<ValidationError>> errorHandler,
|
||||||
DictQuery dictQuery) {
|
DictQuery dictQuery) {
|
||||||
|
return read(inputStream, clazz, batchHandler, batchSize, errorHandler, dictQuery, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 Excel 输入流分批导入数据,基于 @ExcelColumn 注解读取列配置。
|
||||||
|
*
|
||||||
|
* @param dictQuery 字典查询接口,可为 null(不启用字典翻译)
|
||||||
|
* @param idCollector 导入成功后的实体 ID 收集器,在每批 batchHandler 执行后调用(此时实体已被保存,ID 已回填),可为 null
|
||||||
|
*/
|
||||||
|
public static <T> int read(InputStream inputStream, Class<T> clazz,
|
||||||
|
Consumer<List<T>> batchHandler, int batchSize,
|
||||||
|
Consumer<List<ValidationError>> errorHandler,
|
||||||
|
DictQuery dictQuery,
|
||||||
|
Consumer<List<T>> idCollector) {
|
||||||
|
|
||||||
List<ColumnMeta> columns = parseColumns(clazz, dictQuery);
|
List<ColumnMeta> columns = parseColumns(clazz, dictQuery);
|
||||||
|
|
||||||
@@ -189,7 +203,7 @@ public final class ExcelAnnotationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExcelImportListener<T> listener = new ExcelImportListener<>(
|
ExcelImportListener<T> listener = new ExcelImportListener<>(
|
||||||
clazz, batchSize, nameToCol, displayToCode, batchHandler, errorHandler
|
clazz, batchSize, nameToCol, displayToCode, batchHandler, idCollector, errorHandler
|
||||||
);
|
);
|
||||||
|
|
||||||
EasyExcel.read(inputStream, listener).sheet().doRead();
|
EasyExcel.read(inputStream, listener).sheet().doRead();
|
||||||
|
|||||||
+14
-3
@@ -21,6 +21,7 @@ public class ExcelImportListener<T> implements ReadListener<Map<Integer, String>
|
|||||||
private final Class<T> clazz;
|
private final Class<T> clazz;
|
||||||
private final int batchSize;
|
private final int batchSize;
|
||||||
private final Consumer<List<T>> batchHandler;
|
private final Consumer<List<T>> batchHandler;
|
||||||
|
private final Consumer<List<T>> idCollector;
|
||||||
private final Consumer<List<ValidationError>> errorHandler;
|
private final Consumer<List<ValidationError>> errorHandler;
|
||||||
|
|
||||||
// 外部传入的数据支撑
|
// 外部传入的数据支撑
|
||||||
@@ -40,12 +41,14 @@ public class ExcelImportListener<T> implements ReadListener<Map<Integer, String>
|
|||||||
|
|
||||||
public ExcelImportListener(Class<T> clazz, int batchSize,
|
public ExcelImportListener(Class<T> clazz, int batchSize,
|
||||||
Map<String, ColumnMeta> nameToCol, Map<String, String> displayToCode,
|
Map<String, ColumnMeta> nameToCol, Map<String, String> displayToCode,
|
||||||
Consumer<List<T>> batchHandler, Consumer<List<ValidationError>> errorHandler) {
|
Consumer<List<T>> batchHandler, Consumer<List<T>> idCollector,
|
||||||
|
Consumer<List<ValidationError>> errorHandler) {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
this.batchSize = batchSize;
|
this.batchSize = batchSize;
|
||||||
this.nameToCol = nameToCol;
|
this.nameToCol = nameToCol;
|
||||||
this.displayToCode = displayToCode;
|
this.displayToCode = displayToCode;
|
||||||
this.batchHandler = batchHandler;
|
this.batchHandler = batchHandler;
|
||||||
|
this.idCollector = idCollector;
|
||||||
this.errorHandler = errorHandler;
|
this.errorHandler = errorHandler;
|
||||||
this.batch = batchHandler != null ? new ArrayList<>(batchSize) : null;
|
this.batch = batchHandler != null ? new ArrayList<>(batchSize) : null;
|
||||||
this.errorBatch = new ArrayList<>(batchSize);
|
this.errorBatch = new ArrayList<>(batchSize);
|
||||||
@@ -138,7 +141,11 @@ public class ExcelImportListener<T> implements ReadListener<Map<Integer, String>
|
|||||||
if (batchHandler != null) {
|
if (batchHandler != null) {
|
||||||
batch.add(obj);
|
batch.add(obj);
|
||||||
if (batch.size() >= batchSize) {
|
if (batch.size() >= batchSize) {
|
||||||
batchHandler.accept(new ArrayList<>(batch));
|
List<T> batchCopy = new ArrayList<>(batch);
|
||||||
|
batchHandler.accept(batchCopy);
|
||||||
|
if (idCollector != null) {
|
||||||
|
idCollector.accept(batchCopy);
|
||||||
|
}
|
||||||
batch.clear();
|
batch.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +169,11 @@ public class ExcelImportListener<T> implements ReadListener<Map<Integer, String>
|
|||||||
@Override
|
@Override
|
||||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||||
if (batchHandler != null && batch != null && !batch.isEmpty()) {
|
if (batchHandler != null && batch != null && !batch.isEmpty()) {
|
||||||
batchHandler.accept(new ArrayList<>(batch));
|
List<T> batchCopy = new ArrayList<>(batch);
|
||||||
|
batchHandler.accept(batchCopy);
|
||||||
|
if (idCollector != null) {
|
||||||
|
idCollector.accept(batchCopy);
|
||||||
|
}
|
||||||
batch.clear();
|
batch.clear();
|
||||||
}
|
}
|
||||||
if (!errorBatch.isEmpty()) {
|
if (!errorBatch.isEmpty()) {
|
||||||
|
|||||||
+55
@@ -0,0 +1,55 @@
|
|||||||
|
package org.jeecg.modules.demo.bgpartymatter.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 党委/所务会事项模块常量类
|
||||||
|
*/
|
||||||
|
public final class BgPartymatterConstant {
|
||||||
|
|
||||||
|
private BgPartymatterConstant() {
|
||||||
|
throw new UnsupportedOperationException("This is a constant class and cannot be instantiated");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 会议类型 */
|
||||||
|
public static final class MeetingType {
|
||||||
|
/** 党委会 */
|
||||||
|
public static final String PARTY = "party";
|
||||||
|
/** 所务会 */
|
||||||
|
public static final String OFFICE = "office";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 是/否(字典 yn,replace {"是_1","否_0"}) */
|
||||||
|
public static final class Yn {
|
||||||
|
/** 是 */
|
||||||
|
public static final String YES = "1";
|
||||||
|
/** 否 */
|
||||||
|
public static final String NO = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 密级(字典 secret_level) */
|
||||||
|
public static final class SecretLevel {
|
||||||
|
/** 一般 */
|
||||||
|
public static final String NORMAL = "0";
|
||||||
|
/** 秘密 */
|
||||||
|
public static final String SECRET = "1";
|
||||||
|
/** 机密 */
|
||||||
|
public static final String CONFIDENTIAL = "2";
|
||||||
|
/** 绝密 */
|
||||||
|
public static final String TOP_SECRET = "3";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除标记 */
|
||||||
|
public static final class DelFlag {
|
||||||
|
/** 未删除 */
|
||||||
|
public static final String NORMAL = "0";
|
||||||
|
/** 已删除 */
|
||||||
|
public static final String DELETED = "1";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 类字段名 */
|
||||||
|
public static final class ClassFieldName {
|
||||||
|
/** 未删除 */
|
||||||
|
public static final String MEETING_TYPE_NAME = "meeting_type";
|
||||||
|
/** 已删除 */
|
||||||
|
public static final String DEL_FLAG_NAME = "del_flag";
|
||||||
|
}
|
||||||
|
}
|
||||||
+48
-16
@@ -14,17 +14,22 @@ import org.jeecg.modules.bg.xispeak.entity.BgXiSpeak;
|
|||||||
import org.jeecg.modules.demo.dqinspecttask.entity.DqInspectTask;
|
import org.jeecg.modules.demo.dqinspecttask.entity.DqInspectTask;
|
||||||
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.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
import org.jeecg.modules.demo.bgpartymatter.dto.BgPartymatterBpmSaveDTO;
|
import org.jeecg.modules.demo.bgpartymatter.dto.BgPartymatterBpmSaveDTO;
|
||||||
import org.jeecg.modules.demo.bgpartymatter.entity.BgPartymatterFeedback;
|
import org.jeecg.modules.demo.bgpartymatter.entity.BgPartymatterFeedback;
|
||||||
import org.jeecg.modules.demo.bgpartymatter.entity.BgPartymatter;
|
import org.jeecg.modules.demo.bgpartymatter.entity.BgPartymatter;
|
||||||
import org.jeecg.modules.demo.bgpartymatter.service.IBgPartymatterService;
|
import org.jeecg.modules.demo.bgpartymatter.service.IBgPartymatterService;
|
||||||
import org.jeecg.modules.demo.bgpartymatter.service.IBgPartymatterFeedbackService;
|
import org.jeecg.modules.demo.bgpartymatter.service.IBgPartymatterFeedbackService;
|
||||||
|
import org.jeecg.modules.demo.bgpartymatter.constant.BgPartymatterConstant;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
@@ -37,13 +42,16 @@ import org.jeecgframework.poi.excel.entity.ImportParams;
|
|||||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.shiro.authz.annotation.Logical;
|
import org.apache.shiro.authz.annotation.Logical;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 党委会
|
* @Description: 党委会
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
@@ -56,8 +64,6 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class BgPartymatterController extends JeecgController<BgPartymatter, IBgPartymatterService> {
|
public class BgPartymatterController extends JeecgController<BgPartymatter, IBgPartymatterService> {
|
||||||
|
|
||||||
private static final String DEFAULT_MEETING_TYPE = "party";
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IBgPartymatterService bgPartymatterService;
|
private IBgPartymatterService bgPartymatterService;
|
||||||
|
|
||||||
@@ -71,6 +77,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页列表查询
|
* 分页列表查询
|
||||||
|
*
|
||||||
* @param bgPartymatter
|
* @param bgPartymatter
|
||||||
* @param pageNo
|
* @param pageNo
|
||||||
* @param pageSize
|
* @param pageSize
|
||||||
@@ -99,8 +106,10 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
}
|
}
|
||||||
return Result.OK(bgPartymatter);
|
return Result.OK(bgPartymatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加
|
* 添加
|
||||||
|
*
|
||||||
* @param bgPartymatter
|
* @param bgPartymatter
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -110,7 +119,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
public Result<String> add(@RequestBody BgPartymatter bgPartymatter) {
|
public Result<String> add(@RequestBody BgPartymatter bgPartymatter) {
|
||||||
if (oConvertUtils.isEmpty(bgPartymatter.getDelFlag())) {
|
if (oConvertUtils.isEmpty(bgPartymatter.getDelFlag())) {
|
||||||
bgPartymatter.setDelFlag("0");
|
bgPartymatter.setDelFlag(BgPartymatterConstant.DelFlag.NORMAL);
|
||||||
}
|
}
|
||||||
fillDefaultMeetingTypeForCreate(bgPartymatter);
|
fillDefaultMeetingTypeForCreate(bgPartymatter);
|
||||||
fillGeneratedNumber(bgPartymatter);
|
fillGeneratedNumber(bgPartymatter);
|
||||||
@@ -120,6 +129,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
|
*
|
||||||
* @param bgPartymatter
|
* @param bgPartymatter
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -133,8 +143,10 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
bgPartymatterService.updateById(bgPartymatter);
|
bgPartymatterService.updateById(bgPartymatter);
|
||||||
return Result.OK("编辑成功!");
|
return Result.OK("编辑成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
|
*
|
||||||
* @param dto
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -161,7 +173,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
*/
|
*/
|
||||||
private void fillDefaultMeetingTypeForCreate(BgPartymatter bgPartymatter) {
|
private void fillDefaultMeetingTypeForCreate(BgPartymatter bgPartymatter) {
|
||||||
if (bgPartymatter != null && oConvertUtils.isEmpty(bgPartymatter.getMeetingType())) {
|
if (bgPartymatter != null && oConvertUtils.isEmpty(bgPartymatter.getMeetingType())) {
|
||||||
bgPartymatter.setMeetingType(DEFAULT_MEETING_TYPE);
|
bgPartymatter.setMeetingType(BgPartymatterConstant.MeetingType.PARTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +191,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bgPartymatter.setMeetingType(DEFAULT_MEETING_TYPE);
|
bgPartymatter.setMeetingType(BgPartymatterConstant.MeetingType.PARTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -196,6 +208,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id删除
|
* 通过id删除
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -210,6 +223,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除
|
* 批量删除
|
||||||
|
*
|
||||||
* @param ids
|
* @param ids
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -224,17 +238,19 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出
|
* 导出
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions(value = {"bgpartymatter:bg_partymatter:exportXls", "bgofficematter:bg_officematter:exportXls"}, logical = Logical.OR)
|
@RequiresPermissions(value = {"bgpartymatter:bg_partymatter:exportXls", "bgofficematter:bg_officematter:exportXls"}, logical = Logical.OR)
|
||||||
@RequestMapping(value = "/exportXls")
|
@RequestMapping(value = "/exportXls")
|
||||||
public ModelAndView exportXls(HttpServletRequest request, BgPartymatter bgPartymatter) {
|
public ModelAndView exportXls(HttpServletRequest request, BgPartymatter bgPartymatter) {
|
||||||
String exportName = "office".equals(bgPartymatter.getMeetingType()) ? "所务会" : "党委会";
|
String exportName = BgPartymatterConstant.MeetingType.OFFICE.equals(bgPartymatter.getMeetingType()) ? "所务会" : "党委会";
|
||||||
return super.exportXls(request, bgPartymatter, BgPartymatter.class, exportName);
|
return super.exportXls(request, bgPartymatter, BgPartymatter.class, exportName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入
|
* 导入
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions(value = {"bgpartymatter:bg_partymatter:importExcel", "bgofficematter:bg_officematter:importExcel"}, logical = Logical.OR)
|
@RequiresPermissions(value = {"bgpartymatter:bg_partymatter:importExcel", "bgofficematter:bg_officematter:importExcel"}, logical = Logical.OR)
|
||||||
@@ -246,8 +262,10 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
|
|
||||||
|
|
||||||
/*--------------------------------子表处理-党委会反馈表-begin----------------------------------------------*/
|
/*--------------------------------子表处理-党委会反馈表-begin----------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过主表ID查询
|
* 通过主表ID查询
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
//@AutoLog(value = "党委会反馈表-通过主表ID查询")
|
//@AutoLog(value = "党委会反馈表-通过主表ID查询")
|
||||||
@@ -265,6 +283,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加
|
* 添加
|
||||||
|
*
|
||||||
* @param bgPartymatterFeedback
|
* @param bgPartymatterFeedback
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -273,7 +292,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
@PostMapping(value = "/addBgPartymatterFeedback")
|
@PostMapping(value = "/addBgPartymatterFeedback")
|
||||||
public Result<String> addBgPartymatterFeedback(@RequestBody BgPartymatterFeedback bgPartymatterFeedback) {
|
public Result<String> addBgPartymatterFeedback(@RequestBody BgPartymatterFeedback bgPartymatterFeedback) {
|
||||||
if (oConvertUtils.isEmpty(bgPartymatterFeedback.getDelFlag())) {
|
if (oConvertUtils.isEmpty(bgPartymatterFeedback.getDelFlag())) {
|
||||||
bgPartymatterFeedback.setDelFlag("0");
|
bgPartymatterFeedback.setDelFlag(BgPartymatterConstant.DelFlag.NORMAL);
|
||||||
}
|
}
|
||||||
bgPartymatterFeedbackService.save(bgPartymatterFeedback);
|
bgPartymatterFeedbackService.save(bgPartymatterFeedback);
|
||||||
return Result.OK("添加成功!");
|
return Result.OK("添加成功!");
|
||||||
@@ -281,6 +300,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
|
*
|
||||||
* @param bgPartymatterFeedback
|
* @param bgPartymatterFeedback
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -294,6 +314,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id删除
|
* 通过id删除
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -307,6 +328,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除
|
* 批量删除
|
||||||
|
*
|
||||||
* @param ids
|
* @param ids
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -320,6 +342,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出
|
* 导出
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/exportBgPartymatterFeedback")
|
@RequestMapping(value = "/exportBgPartymatterFeedback")
|
||||||
@@ -353,6 +376,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入
|
* 导入
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/importBgPartymatterFeedback/{mainId}")
|
@RequestMapping(value = "/importBgPartymatterFeedback/{mainId}")
|
||||||
@@ -390,6 +414,7 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------子表处理-党委会反馈表-end----------------------------------------------*/
|
/*--------------------------------子表处理-党委会反馈表-end----------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过EasyExcel校验数据,只返回校验结果,不保存到数据库
|
* 通过EasyExcel校验数据,只返回校验结果,不保存到数据库
|
||||||
*/
|
*/
|
||||||
@@ -400,33 +425,40 @@ public class BgPartymatterController extends JeecgController<BgPartymatter, IBgP
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过EasyExcel导入数据,支持字典校验和Hibernate Validator
|
* 通过EasyExcel导入数据,支持字典校验和Hibernate Validator,通过 meetingType 参数指定导入类型
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("bgpartymatter:bg_partymatter:importExcel")
|
@RequiresPermissions("bgpartymatter:bg_partymatter:importExcel")
|
||||||
@PostMapping(value = "/importExcelByEasyExcel")
|
@PostMapping(value = "/importExcelByEasyExcel")
|
||||||
public Result<?> importExcelByEasyExcel(HttpServletRequest request) {
|
public Result<?> importExcelByEasyExcel(HttpServletRequest request,
|
||||||
return super.importExcelByEasyExcel(request, BgPartymatter.class);
|
@RequestParam(defaultValue = "party") String meetingType) {
|
||||||
|
return super.importExcelByEasyExcel(request, BgPartymatter.class,
|
||||||
|
Map.of(
|
||||||
|
BgPartymatterConstant.ClassFieldName.MEETING_TYPE_NAME, meetingType,
|
||||||
|
BgPartymatterConstant.ClassFieldName.DEL_FLAG_NAME,
|
||||||
|
BgPartymatterConstant.DelFlag.NORMAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过EasyExcel导出数据
|
* 通过EasyExcel导出数据,根据 meetingType 动态切换标题
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("bgpartymatter:bg_partymatter:exportXls")
|
@RequiresPermissions("bgpartymatter:bg_partymatter:exportXls")
|
||||||
@GetMapping(value = "/exportXlsByEasyExcel")
|
@GetMapping(value = "/exportXlsByEasyExcel")
|
||||||
public void exportXlsByEasyExcel(HttpServletRequest request, HttpServletResponse response,
|
public void exportXlsByEasyExcel(HttpServletRequest request, HttpServletResponse response,
|
||||||
BgPartymatter bgPartymatter) throws IOException {
|
BgPartymatter bgPartymatter) throws IOException {
|
||||||
super.exportXlsByEasyExcel(request, response, bgPartymatter, BgPartymatter.class, "dq_inspect_task");
|
String title = BgPartymatterConstant.MeetingType.OFFICE.equals(bgPartymatter.getMeetingType()) ? "所务会" : "党委会";
|
||||||
|
super.exportXlsByEasyExcel(request, response, bgPartymatter, BgPartymatter.class, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仅导出Excel表头(EasyExcel)
|
* 仅导出Excel表头(EasyExcel),通过 meetingType 参数指定模板类型
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("bgpartymatter:bg_partymatter:exportXls")
|
@RequiresPermissions("bgpartymatter:bg_partymatter:exportXls")
|
||||||
@GetMapping(value = "/exportXlsHeaders")
|
@GetMapping(value = "/exportXlsHeaders")
|
||||||
public void exportXlsHeaders(HttpServletResponse response) throws IOException {
|
public void exportXlsHeaders(HttpServletResponse response,
|
||||||
super.exportXlsHeadersByEasyExcel(response, BgPartymatter.class, "dq_inspect_task");
|
@RequestParam(defaultValue = "party") String meetingType) throws IOException {
|
||||||
|
String title = BgPartymatterConstant.MeetingType.OFFICE.equals(meetingType) ? "所务会" : "党委会";
|
||||||
|
super.exportXlsHeadersByEasyExcel(response, BgPartymatter.class, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user