福利收货地址导出
This commit is contained in:
@@ -107,11 +107,19 @@ public class WelfareListController {
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("welfare.list.mange")
|
||||
@ApiOperation("导出收货地址")
|
||||
@Ok("void")
|
||||
public void exportAddress(WelfareListPageForm pageForm, HttpServletResponse response) {
|
||||
welfareListService.exportAddress(pageForm, response);
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("welfare.list.mange")
|
||||
@ApiOperation("导出")
|
||||
@Ok("void")
|
||||
public void exportXlsx(@Param("pageForm") WelfareListPageForm pageForm, HttpServletResponse response) {
|
||||
public void exportXlsx(WelfareListPageForm pageForm, HttpServletResponse response) {
|
||||
welfareListService.exportXlsx(pageForm, response);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@@ -55,4 +57,7 @@ public class WelfareListPageForm extends PageForm {
|
||||
@ApiModelProperty("在职状态")
|
||||
private String[] userStates;
|
||||
|
||||
@ApiModelProperty("导出的数据")
|
||||
private List<Map<String, String>> columns;
|
||||
|
||||
}
|
||||
|
||||
@@ -46,6 +46,13 @@ public interface WelfareListService extends BaseService<WelfareList> {
|
||||
*/
|
||||
void addWelfareUser(WelfareFilterUserPageForm pageForm);
|
||||
|
||||
/**
|
||||
* 导出收货地址
|
||||
* @param pageForm
|
||||
* @param response
|
||||
*/
|
||||
void exportAddress(WelfareListPageForm pageForm, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 导出
|
||||
* @param pageForm
|
||||
|
||||
+113
-17
@@ -553,6 +553,82 @@ public class WelfareListServiceImpl extends BaseServiceImpl<WelfareList> impleme
|
||||
dao().insert(welfareList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportAddress(WelfareListPageForm pageForm, HttpServletResponse response) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
t1.*,
|
||||
t2.loginname,
|
||||
t2.username,
|
||||
t2.sex,
|
||||
DATE_FORMAT(t2.birthday, '%Y-%m-%d') AS birthday,
|
||||
CONCAT('收货人:',t3.userName,' 电话:',t3.tel,' 详细地址:',t3.province, t3.city, t3.county, t3.addressDetail) AS address
|
||||
FROM
|
||||
`welfare_list` t1
|
||||
LEFT JOIN sys_user t2 ON t2.id = t1.userId
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
userId,
|
||||
userName,
|
||||
tel,
|
||||
province,
|
||||
city,
|
||||
county,
|
||||
addressDetail,
|
||||
ROW_NUMBER() OVER (PARTITION BY userId ORDER BY isDefault DESC, id) as rn
|
||||
FROM welfare_member_address
|
||||
) t3 ON t3.userId = t1.userId AND t3.rn = 1
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("t1.projectId", "=", pageForm.getProjectId());
|
||||
if (StrUtil.isNotBlank(pageForm.getUserName())) {
|
||||
cnd.where().andLike("t2.username", pageForm.getUserName());
|
||||
}
|
||||
if (StrUtil.isNotBlank(pageForm.getLoginName())) {
|
||||
cnd.where().andLike("t2.loginname", pageForm.getLoginName());
|
||||
}
|
||||
cnd.andEX("t2.sex", "=", pageForm.getSex());
|
||||
cnd.andEX("t2.birthday", "=", pageForm.getBirthday());
|
||||
if (pageForm.getBirthMonths() != null && pageForm.getBirthMonths().length > 0) {
|
||||
cnd.andEX("MONTH(t2.birthday)", "in", pageForm.getBirthMonths());
|
||||
}
|
||||
cnd.andEX("t1.welfareUnitId", "in", pageForm.getUnitIds());
|
||||
cnd.andEX("t1.welfareUnionId", "=", pageForm.getUnionId());
|
||||
cnd.andEX("t1.personType", "in", pageForm.getPersonTypes());
|
||||
cnd.andEX("t1.preparedBy", "in", pageForm.getPreparedBys());
|
||||
cnd.andEX("t1.userState", "in", pageForm.getUserStates());
|
||||
|
||||
if (StrUtil.isAllBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) {
|
||||
cnd.asc("t1.welfareUnionName");
|
||||
cnd.asc("t1.welfareUnitName");
|
||||
} else {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), PageUtil.getOrder(pageForm.getPageOrderBy()));
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = listMap(sql);
|
||||
|
||||
try {
|
||||
Workbook workbook = null;
|
||||
List<ExcelExportEntity> exportEntities = new ArrayList<>();
|
||||
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
exportEntities.add(new ExcelExportEntity("收货地址", "address", 70));
|
||||
exportEntities.add(new ExcelExportEntity("所属工会", "welfareUnionName", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所属单位", "welfareUnitName", 30));
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, list);
|
||||
|
||||
|
||||
CommonDownloadUtil.download("收货地址汇总.xlsx", workbook, response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportXlsx(WelfareListPageForm pageForm, HttpServletResponse response) {
|
||||
Sql sql = Sqls.create("""
|
||||
@@ -596,26 +672,46 @@ public class WelfareListServiceImpl extends BaseServiceImpl<WelfareList> impleme
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = listMap(sql);
|
||||
|
||||
List<ExcelExportEntity> entities = new ArrayList<>();
|
||||
entities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
entities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
entities.add(new ExcelExportEntity("性别", "sex", 20));
|
||||
entities.add(new ExcelExportEntity("出生日期", "birthday", 20));
|
||||
entities.add(new ExcelExportEntity("人员类型", "personType", 20));
|
||||
entities.add(new ExcelExportEntity("聘用方式", "preparedBy", 20));
|
||||
entities.add(new ExcelExportEntity("在职状态", "userState", 20));
|
||||
entities.add(new ExcelExportEntity("所属工会", "welfareUnionName", 20));
|
||||
entities.add(new ExcelExportEntity("所属单位", "welfareUnitName", 20));
|
||||
entities.add(new ExcelExportEntity("备注", "remark", 20));
|
||||
try {
|
||||
Workbook workbook = null;
|
||||
if (Lang.isNotEmpty(pageForm.getColumns())) {
|
||||
List<ExcelExportEntity> exportEntities = new ArrayList<>();
|
||||
|
||||
pageForm.getColumns().forEach(column -> {
|
||||
exportEntities.add(new ExcelExportEntity(column.get("label"), column.get("prop"), 20));
|
||||
});
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
|
||||
workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, list);
|
||||
} else {
|
||||
workbook = setHistoryExcelData(list);
|
||||
}
|
||||
|
||||
// 设置导出参数
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
// 导出Excel并下载
|
||||
try (Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entities, list)) {
|
||||
CommonDownloadUtil.download("福利名单.xlsx", workbook, response);
|
||||
} catch (Exception e) {
|
||||
log.error("导出Excel失败", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Workbook setHistoryExcelData(List<NutMap> list) {
|
||||
List<ExcelExportEntity> exportEntities = new ArrayList<>();
|
||||
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
exportEntities.add(new ExcelExportEntity("性别", "sex", 20));
|
||||
exportEntities.add(new ExcelExportEntity("联系电话", "mobile", 20));
|
||||
exportEntities.add(new ExcelExportEntity("身份证号", "idCard", 30));
|
||||
exportEntities.add(new ExcelExportEntity("在职状态", "userState", 20));
|
||||
exportEntities.add(new ExcelExportEntity("聘用方式", "preparedBy", 20));
|
||||
exportEntities.add(new ExcelExportEntity("人员类型", "personType", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所属工会", "unionName", 20));
|
||||
exportEntities.add(new ExcelExportEntity("所属单位", "unitName", 30));
|
||||
// exportEntities.add(new ExcelExportEntity("来校年月", "comeSchoolDate", 30));
|
||||
// exportEntities.add(new ExcelExportEntity("所在科室", "threeUnitName", 20));
|
||||
// exportEntities.add(new ExcelExportEntity("工会小组", "unionGroupName", 30));
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
return ExcelExportUtil.exportExcel(exportParams, exportEntities, list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,9 @@ layout("/layouts/platform.html"){
|
||||
|
||||
<el-card class="mt10" shadow="never">
|
||||
<table-tool :app="this" label="福利名单">
|
||||
<el-button :disabled="!pageForm.projectId" @click="exportAddress" icon="el-icon-download" size="small" type="primary">
|
||||
导出收货地址
|
||||
</el-button>
|
||||
<el-button :disabled="!pageForm.projectId" @click="openExport" icon="el-icon-download" size="small" type="primary">
|
||||
导出名单
|
||||
</el-button>
|
||||
@@ -145,6 +148,38 @@ layout("/layouts/platform.html"){
|
||||
>
|
||||
添加人员
|
||||
</el-button>
|
||||
|
||||
<el-popover
|
||||
placement="bottom"
|
||||
trigger="click"
|
||||
width="200">
|
||||
|
||||
<div style="padding:4px 0;border-bottom:1px solid #eee;">
|
||||
<el-button size="mini" @click="checkAll">全选</el-button>
|
||||
<el-button size="mini" @click="invertCheck">反选</el-button>
|
||||
</div>
|
||||
|
||||
<div style="max-height:40vh;overflow-y:auto;padding:6px 0;">
|
||||
<el-checkbox-group v-model="checkedFields">
|
||||
<el-checkbox
|
||||
v-for="f in tableColumns"
|
||||
:key="f.prop"
|
||||
:label="f.prop"
|
||||
style="display:block;margin:6px 0;">
|
||||
{{ f.label }}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
|
||||
<el-button
|
||||
slot="reference"
|
||||
type="text"
|
||||
icon="el-icon-s-operation"
|
||||
size="small"
|
||||
style="margin-left:12px;">
|
||||
列设置
|
||||
</el-button>
|
||||
</el-popover>
|
||||
</table-tool>
|
||||
|
||||
<el-table
|
||||
@@ -159,15 +194,16 @@ layout("/layouts/platform.html"){
|
||||
<el-table-column :index="indexMethod" label="序号" type="index" width="80px"></el-table-column>
|
||||
|
||||
<el-table-column
|
||||
:key="column.prop"
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
:sortable="column.sortable"
|
||||
:width="column.width"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
v-for="column in tableColumns"
|
||||
v-if="checkedFields.includes(column.prop)"
|
||||
:key="column.prop"
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
:sortable="column.sortable"
|
||||
:width="column.width"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
v-for="column in tableColumns"
|
||||
>
|
||||
<template scope="{row}" v-if="column.prop=='isChoose'">
|
||||
<span class="text-primary" v-if="row.isChoose">已选择</span>
|
||||
@@ -241,8 +277,14 @@ layout("/layouts/platform.html"){
|
||||
return null
|
||||
}
|
||||
return null
|
||||
},
|
||||
showColumns() {
|
||||
return this.tableColumns.filter(c => this.checkedFields.includes(c.prop));
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.checkedFields = this.tableColumns.filter(c => c.checked !== 0).map(c => c.prop);
|
||||
},
|
||||
components: {
|
||||
add_welfare_list_by_select: ADD_WELFARE_LIST_BY_SELECT,
|
||||
"file-import": httpVueLoader("/components/plugins/sysImport/index.vue?v=" + new Date().getTime()),
|
||||
@@ -251,6 +293,7 @@ layout("/layouts/platform.html"){
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
checkedFields: [],
|
||||
pageForm: {
|
||||
searchName: "username",
|
||||
year: new Date().getFullYear().toString()
|
||||
@@ -282,13 +325,26 @@ layout("/layouts/platform.html"){
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 导出收货地址
|
||||
exportAddress() {
|
||||
this.$downLoad("/platform/welfare/list/mange/exportAddress", this.pageForm)
|
||||
},
|
||||
// 导出名单
|
||||
openExport() {
|
||||
this.$downLoad("/platform/welfare/list/mange/exportXlsx", {
|
||||
pageForm: JSON.stringify(this.pageForm)
|
||||
const pageForm = clone(this.pageForm)
|
||||
const data = this.tableColumns.filter(item => this.checkedFields.includes(item.prop)).map(item => {
|
||||
return {prop: item.prop, label: item.label}
|
||||
})
|
||||
pageForm.columns = JSON.stringify(data)
|
||||
this.$downLoad("/platform/welfare/list/mange/exportXlsx", pageForm)
|
||||
},
|
||||
checkAll() {
|
||||
this.checkedFields = this.tableColumns.map(c => c.prop);
|
||||
},
|
||||
invertCheck() {
|
||||
const all = this.tableColumns.map(c => c.prop);
|
||||
this.checkedFields = all.filter(p => !this.checkedFields.includes(p));
|
||||
},
|
||||
|
||||
successImport() {
|
||||
this.doSearch()
|
||||
this.importDialog = false
|
||||
|
||||
Reference in New Issue
Block a user