增加自定义导出
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
|
||||
package com.jeelowcode.core.framework.config.btncommand.button;
|
||||
|
||||
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
|
||||
import com.jeelowcode.core.framework.params.model.ExcelModel;
|
||||
import com.jeelowcode.core.framework.params.model.TableModel;
|
||||
|
||||
/**
|
||||
* 具体命令-新增按钮命令
|
||||
*/
|
||||
public class CustomButtonCommand implements IButtonCommand<TableModel> {
|
||||
//命令执行者
|
||||
private IButtonCommandReceiver<TableModel> recevier;
|
||||
|
||||
|
||||
/**
|
||||
* 绑定执行者
|
||||
* @param recevier 执行者
|
||||
*/
|
||||
public CustomButtonCommand(IButtonCommandReceiver recevier) {
|
||||
this.recevier = recevier;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行命令
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public TableModel execute() {
|
||||
TableModel receiver = recevier.receiver();
|
||||
return receiver;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
|
||||
package com.jeelowcode.core.framework.config.btncommand.receiver;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.jeelowcode.core.framework.entity.FormEntity;
|
||||
import com.jeelowcode.core.framework.params.model.TableModel;
|
||||
import com.jeelowcode.framework.utils.adapter.IJeeLowCodeAdapter;
|
||||
import com.jeelowcode.framework.utils.model.ResultDataModel;
|
||||
import com.jeelowcode.framework.utils.tool.CollectionUtil;
|
||||
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
|
||||
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamExport;
|
||||
import com.jeelowcode.core.framework.params.model.ExcelModel;
|
||||
import com.jeelowcode.core.framework.params.vo.role.DbFormRoleFieldVo;
|
||||
import com.jeelowcode.core.framework.service.IDbFormRoleService;
|
||||
import com.jeelowcode.core.framework.service.IExcelService;
|
||||
import com.jeelowcode.core.framework.service.IFormService;
|
||||
import com.jeelowcode.core.framework.service.IFrameService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 新增自定义执行者
|
||||
*/
|
||||
public class ButtonReceiverCustom extends ButtonReceiverBase implements IButtonCommandReceiver<TableModel> {
|
||||
|
||||
|
||||
private String pluginKey;
|
||||
|
||||
private ButtonParamExport param;
|
||||
|
||||
public ButtonReceiverCustom(ButtonParamExport param) {
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行命令
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public TableModel receiver() {
|
||||
IFormService formService = SpringUtils.getBean(IFormService.class);
|
||||
IFrameService frameService = SpringUtils.getBean(IFrameService.class);
|
||||
|
||||
Long dbFormId = param.getDbFormId();
|
||||
Map<String, Object> params = param.getParams();
|
||||
|
||||
FormEntity formEntity = formService.getFormEntityById(dbFormId);
|
||||
|
||||
//人员信息自定义导出后刷新是否背调状态为是
|
||||
if (formEntity.getTableName().toLowerCase().equals("lc_outside_person")) {
|
||||
ResultDataModel model = frameService.getExportDataList(dbFormId, params);
|
||||
|
||||
List<JSONObject> records = model.getRecords().stream()
|
||||
.map(recordMap -> new JSONObject(recordMap))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(records)) {
|
||||
for (JSONObject record : records) {
|
||||
record.set("isValidate", "是");
|
||||
}
|
||||
frameService.editBatchData(dbFormId, records);
|
||||
}
|
||||
}
|
||||
return new TableModel(formEntity.getTableName(), formEntity.getTableDescribe());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.jeelowcode.core.framework.entity.FormFieldWebEntity;
|
||||
import com.jeelowcode.core.framework.params.model.ExcelImportResultModel;
|
||||
import com.jeelowcode.core.framework.params.model.ExcelModel;
|
||||
import com.jeelowcode.core.framework.params.model.ExcelTemplateModel;
|
||||
import com.jeelowcode.core.framework.params.model.TableModel;
|
||||
import com.jeelowcode.core.framework.params.vo.FormEntityPageVo;
|
||||
import com.jeelowcode.core.framework.service.IFormService;
|
||||
import com.jeelowcode.core.framework.utils.Func;
|
||||
@@ -280,6 +281,25 @@ public class BaseController {
|
||||
return excelModel;
|
||||
}
|
||||
|
||||
//导出Excel数据后(自定义拓展)
|
||||
protected void afterExportExcelData(Long dbformId, Map<String, Object> params ){
|
||||
//封装参数
|
||||
ButtonParamExport buttonParam = new ButtonParamExport();
|
||||
buttonParam.setDbFormId(dbformId);
|
||||
buttonParam.setParams(params);
|
||||
//执行者绑定参数
|
||||
//执行者绑定参数
|
||||
IButtonCommandReceiver receiver = new ButtonReceiverCustom(buttonParam);
|
||||
|
||||
//执行者和命令绑定
|
||||
CustomButtonCommand command = new CustomButtonCommand(receiver);
|
||||
|
||||
//创建调用者
|
||||
ButtonInvoker<TableModel> invoker = new ButtonInvoker();
|
||||
invoker.setButtonCommand(command);//调用者设置命令
|
||||
invoker.executeCommand();//调用者下发命令
|
||||
}
|
||||
|
||||
//导入Excel数据
|
||||
protected ExcelImportResultModel importExcelData(ButtonParamImport buttonParam){
|
||||
//执行者绑定参数
|
||||
|
||||
@@ -87,6 +87,19 @@ public class ExcelController extends BaseController {
|
||||
JeeLowCodeExcelUtils.exportExcel(rsp, excelModel.getSheetName(), excelModel.getHeadTitleMap(), excelModel.getDataMapList());
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermission('jeelowcode:dbform-data:export:'+#dbformId)")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(tags = "Excel模块",summary = "导出Excel数据")
|
||||
@PostMapping({"/exportExcelCustom/{dbformId}"})
|
||||
public void exportExcelDataCustom(@PathVariable("dbformId") Long dbformId, HttpServletRequest req, HttpServletResponse rsp) {
|
||||
Map<String, Object> params = FuncWeb.getParameterBodyMap(req);
|
||||
ExcelModel excelModel = super.exportExcelData(dbformId, params);
|
||||
super.afterExportExcelData(dbformId, params);
|
||||
//导出
|
||||
JeeLowCodeExcelUtils.exportExcel(rsp, excelModel.getSheetName(), excelModel.getHeadTitleMap(), excelModel.getDataMapList());
|
||||
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermission('jeelowcode:dbform-data:import:'+#dbformId)")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(tags = "Excel模块",summary = "导入Excel数据")
|
||||
|
||||
Reference in New Issue
Block a user