导出用户信息功能

master
382696293@qq.com 2 years ago
parent b3ba3fc9fb
commit a7abf00f67

@ -0,0 +1,42 @@
package com.flossom.common.core.domain.req;
import com.flossom.common.core.web.domain.BaseEntity;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
*
*
* @author flossom
* @date 2023-12-08
*/
public class WxUserMemberExportVm extends WxUserMemberVm {
/**
*
*/
private List<String> exportFields = new ArrayList<>();
private List<Integer> userIdList = new ArrayList<>();
public List<String> getExportFields() {
return exportFields;
}
public void setExportFields(List<String> exportFields) {
this.exportFields = exportFields;
}
public List<Integer> getUserIdList() {
return userIdList;
}
public void setUserIdList(List<Integer> userIdList) {
this.userIdList = userIdList;
}
}

@ -107,10 +107,7 @@ public class WxUserMemberVm extends BaseEntity {
*/
List<Integer> miniProgramTags;
/**
*
*/
List<String> exportFields = new ArrayList<>();
public WxUserMemberVm() {
}
@ -266,11 +263,4 @@ public class WxUserMemberVm extends BaseEntity {
this.miniProgramTags = miniProgramTags;
}
public List<String> getExportFields() {
return exportFields;
}
public void setExportFields(List<String> exportFields) {
this.exportFields = exportFields;
}
}

@ -82,4 +82,6 @@ public interface WxUserMemberMapper {
List<WxUserMember> selectWxUserMemberByMobile(@Param("mobile") String mobile);
List<WxUserMember> selectWxUserMemberByIdList(@Param("userIdList") List<Integer> userIdList);
}

@ -302,5 +302,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mobile = #{mobile}
</select>
<select id="selectWxUserMemberByIdList" resultType="com.flossom.common.core.domain.entity.WxUserMember">
<include refid="selectWxUserMemberVo"/>
where id in
<foreach item="id" collection="userIdList" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>

@ -6,10 +6,7 @@ import com.flossom.common.core.domain.R;
import com.flossom.common.core.domain.entity.WxUserMember;
import com.flossom.common.core.domain.entity.WxUserTag;
import com.flossom.common.core.domain.export.WxUserMemberExport;
import com.flossom.common.core.domain.req.AllChangIntegralOperateReq;
import com.flossom.common.core.domain.req.WxUserIntegralVm;
import com.flossom.common.core.domain.req.WxUserMemberReq;
import com.flossom.common.core.domain.req.WxUserMemberVm;
import com.flossom.common.core.domain.req.*;
import com.flossom.common.core.domain.ret.WxUserMemberRet;
import com.flossom.common.core.enums.IntegralChangeTypeEnum;
import com.flossom.common.core.exception.ServiceException;
@ -30,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
import java.lang.reflect.Array;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@ -72,8 +70,27 @@ public class WxUserMemberController extends BaseController {
@RequiresPermissions("system:member:export")
@Log(title = "用户", businessType = BusinessType.EXPORT)
@PostMapping("/allExport")
public void export(HttpServletResponse response, @RequestBody WxUserMemberVm wxUserMemberVm) {
List<WxUserMemberRet> list = wxUserMemberService.selectWxUserMemberRetList(wxUserMemberVm);
public void allExport(HttpServletResponse response, WxUserMemberExportVm wxUserMemberExportVm) {
List<WxUserMemberRet> list = wxUserMemberService.selectWxUserMemberRetList(wxUserMemberExportVm);
export(response, list, wxUserMemberExportVm.getExportFields());
}
/**
*
*/
@RequiresPermissions("system:member:export")
@Log(title = "用户", businessType = BusinessType.EXPORT)
@PostMapping("/batchExport")
public void batchExport(HttpServletResponse response, WxUserMemberExportVm wxUserMemberExportVm) {
List<Integer> userIdList = wxUserMemberExportVm.getUserIdList();
if (userIdList == null || userIdList.size() == 0) {
throw new ServiceException("请选择导出用户");
}
List<WxUserMemberRet> list = wxUserMemberService.selectWxUserMemberByIdList(wxUserMemberExportVm.getUserIdList());
export(response, list, wxUserMemberExportVm.getExportFields());
}
private static void export(HttpServletResponse response, List<WxUserMemberRet> list, List<String> exportFields) {
List<WxUserMemberExport> exportList = new ArrayList<>();
WxUserMemberExport export;
for (WxUserMemberRet wxUserMemberRet : list) {
@ -90,7 +107,7 @@ public class WxUserMemberController extends BaseController {
exportList.add(export);
}
ExcelUtil<WxUserMemberExport> util = new ExcelUtil(WxUserMemberExport.class);
util.exportExcel(response, exportList, "用户数据", wxUserMemberVm.getExportFields() == null ? null : wxUserMemberVm.getExportFields());
util.exportExcel(response, exportList, "用户数据", exportFields);
}
/**

@ -87,4 +87,6 @@ public interface IWxUserMemberService
void openOrCloseActivity(Long id);
List<WxUserMemberRet> selectWxUserMemberRetList(WxUserMemberVm wxUserMemberVm);
List<WxUserMemberRet> selectWxUserMemberByIdList(List<Integer> userIdList);
}

@ -373,4 +373,25 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
}
return list;
}
@Override
public List<WxUserMemberRet> selectWxUserMemberByIdList(List<Integer> userIdList) {
List<WxUserMemberRet> list = new ArrayList<>();
List<WxUserMember> wxUserMembers = wxUserMemberMapper.selectWxUserMemberByIdList(userIdList);
if (wxUserMembers != null && wxUserMembers.size() > 0) {
WxUserMemberRet wxUserMemberRet;
for (WxUserMember wxUserMember : wxUserMembers) {
wxUserMemberRet = new WxUserMemberRet();
BeanUtils.copyProperties(wxUserMember, wxUserMemberRet);
WxUserTag wxUserTag = new WxUserTag();
wxUserTag.setUserId(wxUserMember.getId());
wxUserTag.setType(TagTypeStatus.MINI_PROGRAM.getCode());
wxUserMemberRet.setMiniProgramTags(wxUserTagMapper.selectWxUserTagList(wxUserTag));
wxUserTag.setType(TagTypeStatus.ENTERPRISE_WECHAT.getCode());
wxUserMemberRet.setWecomTags(wxUserTagMapper.selectWxUserTagList(wxUserTag));
list.add(wxUserMemberRet);
}
}
return list;
}
}

@ -276,3 +276,24 @@ export function obtainUserIntegralLog(data) {
params: data
})
}
// 全量导出用户
export function allExport(exportFields, queryForm) {
return request({
url: '/system/member/allExport',
method: 'post',
data: {
exportFields: exportFields,
wxUserMemberVm: queryForm,
}
})
}
// 批量导出用户
export function batchExport(data) {
return request({
url: '/system/member/batchExport',
method: 'post',
data: data
})
}

@ -642,6 +642,61 @@
@pagination="getUserIntegralLogList"
/>
</el-dialog>
<!-- 导出字段选择弹窗 -->
<el-dialog title="自定义导出字段" :visible.sync="exportFieldsVisible" width="50%"
:before-close="cancelExportFieldsDialog">
<el-form ref="form" label-width="150px">
<el-form-item label="全部字段" prop="allFields">
<el-switch v-model="allFields" @click.native="isExportAllFields()"/>
</el-form-item>
</el-form>
<el-form :inline="true" ref="form" :model="exportFieldList" label-width="150px">
<el-form-item label="会员昵称" prop="nickname">
<el-switch v-model="exportFieldList.nickname" :active-value="'nickname'" :inactive-value="null"/>
</el-form-item>
<el-form-item label="用户编号 " prop="id">
<el-switch v-model="exportFieldList.id" active-value="id" :inactive-value="null"/>
</el-form-item>
<el-form-item label="手机号 " prop="mobile">
<el-switch v-model="exportFieldList.mobile" active-value="mobile" :inactive-value="null"/>
</el-form-item>
<el-form-item label="生日 " prop="birthday">
<el-switch v-model="exportFieldList.birthday" active-value="birthday" :inactive-value="null"/>
</el-form-item>
<el-form-item label="地区 " prop="province" @click.native="exportArea()">
<el-switch v-model="exportFieldList.province" active-value="province" :inactive-value="null"/>
</el-form-item>
<el-form-item label="用户注册时间 " prop="createTime">
<el-switch v-model="exportFieldList.createTime" active-value="createTime" :inactive-value="null"/>
</el-form-item>
<el-form-item label="仪器数量 " prop="devicesNum">
<el-switch v-model="exportFieldList.devicesNum" active-value="devicesNum" :inactive-value="null"/>
</el-form-item>
<el-form-item label="仪器名称 " prop="devicesName">
<el-switch v-model="exportFieldList.devicesName" active-value="devicesName" :inactive-value="null"/>
</el-form-item>
<el-form-item label="小程序标签 " prop="miniProgramTags">
<el-switch v-model="exportFieldList.miniProgramTags" active-value="miniProgramTags" :inactive-value="null"/>
</el-form-item>
<el-form-item label="企微标签 " prop="wecomTags">
<el-switch v-model="exportFieldList.wecomTags" active-value="wecomTags" :inactive-value="null"/>
</el-form-item>
<el-form-item label="积分 " prop="credit">
<el-switch v-model="exportFieldList.credit" active-value="credit" :inactive-value="null"/>
</el-form-item>
<el-form-item label="即将过期积分 " prop="expireCredit">
<el-switch v-model="exportFieldList.expireCredit" active-value="expireCredit" :inactive-value="null"/>
</el-form-item>
<el-form-item label="unionid " prop="unionid">
<el-switch v-model="exportFieldList.unionid" active-value="unionid" :inactive-value="null"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelExportFieldsDialog()"> </el-button>
<el-button type="primary" @click="submitBatchOperate"> </el-button>
</div>
</el-dialog>
</div>
</template>
@ -650,7 +705,6 @@ import {
listMember,
getMember,
delMember,
addMember,
updateMember,
selectUserCount,
getMiniProgramTags,
@ -671,6 +725,7 @@ import {
scriptTreeSelect,
editRemark, delRemark,
openOrCloseClock, openOrCloseActivity, uObtainUserScriptLog, delUserScriptLog, obtainUserIntegralLog,
allExport, batchExport,
} from "@/api/system/member";
import Treeselect from "@riophae/vue-treeselect";
import {tagTreeSelect} from "@/api/system/wechatTab";
@ -681,23 +736,6 @@ export default {
components: {Treeselect},
data() {
return {
tableData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1517 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1516 弄'
}],
//
loading: true,
//
@ -811,6 +849,31 @@ export default {
orderByColumn: "createTime",
isAsc: "desc"
},
//
exportFieldsVisible: false,
exportFieldsForm: {
userIdList: null,
exportFields: null,
},
allFields: false,
exportFieldList: {
id: null,
nickname: null,
credit: null,
expireCredit: null,
unionid: null,
mobile: null,
province: null,
city: null,
area: null,
birthday: null,
devicesNum: null,
devicesName: null,
createTime: null,
wecomTags: null,
miniProgramTags: null,
},
//
queryParams: {
pageNum: 1,
@ -941,26 +1004,20 @@ export default {
this.reset();
},
//
cancelMiniProgramDialog(isclose) {
cancelMiniProgramDialog() {
this.title = null;
this.tagIdArray = [];
if (isclose) {
this.batchMiniProgramVisible = false;
}
this.batchMiniProgramVisible = false;
},
cancelIntegralDialog(isclose) {
cancelIntegralDialog() {
this.integralForm.source = null;
this.integralForm.floatScore = null;
this.integralForm.remarkContent = "后台操作";
if (isclose) {
this.batchIntegralVisible = false;
}
this.batchIntegralVisible = false;
},
cancelRemarkDialog(isclose) {
cancelRemarkDialog() {
this.remarkForm.content = null;
if (isclose) {
this.batchRemarkVisible = false;
}
this.batchRemarkVisible = false;
},
cancelUserScriptLogDialog() {
this.userScriptLogVisible = false;
@ -978,7 +1035,26 @@ export default {
this.userIntegralLogQuery.userId = null;
this.userIntegralLogQuery.userIntegralLogList = null;
},
cancelscriptDialog(isclose) {
cancelExportFieldsDialog() {
this.allFields = false;
this.exportFieldList.nickname = null;
this.exportFieldList.id = null;
this.exportFieldList.credit = null;
this.exportFieldList.expireCredit = null;
this.exportFieldList.unionid = null;
this.exportFieldList.mobile = null;
this.exportFieldList.province = null;
this.exportFieldList.city = null;
this.exportFieldList.area = null;
this.exportFieldList.birthday = null;
this.exportFieldList.devicesNum = null;
this.exportFieldList.devicesName = null;
this.exportFieldList.createTime = null;
this.exportFieldList.wecomTags = null;
this.exportFieldList.miniProgramTags = null;
this.exportFieldsVisible = false
},
cancelscriptDialog() {
this.scriptForm.isCustom = null;
this.scriptForm.scriptName = null;
this.scriptForm.titile = null;
@ -997,9 +1073,7 @@ export default {
this.tagIdArray = [];
this.scriptForm.scriptTemplateId = null;
this.scriptForm.scriptContent = null;
if (isclose) {
this.batchScriptVisible = false;
}
this.batchScriptVisible = false;
},
/** 查询部门下拉树结构 */
getDeptTree() {
@ -1213,9 +1287,11 @@ export default {
})
return
}
this.exportFieldsVisible = true;
}
if (this.batchOperateValue == 13) {
console.log("导出全量数据");
this.exportFieldsVisible = true;
}
}
},
@ -1413,6 +1489,32 @@ export default {
this.cancelRemarkDialog(true);
})
}
//
if (this.batchOperateValue == 12) {
let exportFields = Object.values(this.exportFieldList).filter(val => val != null);
if (exportFields.length == 0) {
this.$modal.msgError("请选择导出字段");
return;
}
this.exportFieldsForm.userIdList = this.ids;
this.exportFieldsForm.exportFields = exportFields;
this.download('/system/member/batchExport', {
...this.exportFieldsForm
}, `微信会员_${new Date().getTime()}.xlsx`);
this.cancelExportFieldsDialog();
}
if (this.batchOperateValue == 13) {
let exportFields = Object.values(this.exportFieldList).filter(val => val != null);
if (exportFields.length == 0) {
this.$modal.msgError("请选择导出字段");
return;
}
this.download('/system/member/allExport', {
...Object.assign({}, this.queryParams, {exportFields: exportFields})
}, `微信会员_${new Date().getTime()}.xlsx`)
this.cancelExportFieldsDialog();
}
},
//
ocEditRemarkDialog(row) {
@ -1518,8 +1620,52 @@ export default {
this.userIntegralLogQuery.orderByColumn = prop;
this.userIntegralLogQuery.isAsc = column.order == 'ascending' ? 'asc' : 'desc';
this.getUserIntegralLogList();
},
isExportAllFields() {
if (this.allFields) {
this.exportFieldList.nickname = "nickname";
this.exportFieldList.id = "id";
this.exportFieldList.credit = "credit";
this.exportFieldList.expireCredit = "expireCredit";
this.exportFieldList.unionid = "unionid";
this.exportFieldList.mobile = "mobile";
this.exportFieldList.province = "province";
this.exportFieldList.city = "city";
this.exportFieldList.area = "area";
this.exportFieldList.birthday = "birthday";
this.exportFieldList.devicesNum = "devicesNum";
this.exportFieldList.devicesName = "devicesName";
this.exportFieldList.createTime = "createTime";
this.exportFieldList.wecomTags = "wecomTags";
this.exportFieldList.miniProgramTags = "miniProgramTags";
} else {
this.exportFieldList.nickname = null;
this.exportFieldList.id = null;
this.exportFieldList.credit = null;
this.exportFieldList.expireCredit = null;
this.exportFieldList.unionid = null;
this.exportFieldList.mobile = null;
this.exportFieldList.province = null;
this.exportFieldList.city = null;
this.exportFieldList.area = null;
this.exportFieldList.birthday = null;
this.exportFieldList.devicesNum = null;
this.exportFieldList.devicesName = null;
this.exportFieldList.createTime = null;
this.exportFieldList.wecomTags = null;
this.exportFieldList.miniProgramTags = null;
}
},
exportArea() {
if (this.exportFieldList.province != null) {
this.exportFieldList.city = "city";
this.exportFieldList.area = "area";
} else {
this.exportFieldList.city = null;
this.exportFieldList.area = null;
}
}
}
},
}
;
</script>

Loading…
Cancel
Save