|
@@ -6,6 +6,7 @@ const path = require('path');
|
|
|
const fs = require('fs');
|
|
|
const url = require('url');
|
|
|
const faceUtils = require('../util/faceUtils');
|
|
|
+const excelUtils = require('../util/excelUtils');
|
|
|
|
|
|
class VisitController extends Controller {
|
|
|
tag() {
|
|
@@ -106,6 +107,83 @@ class VisitController extends Controller {
|
|
|
ctx.success(result);
|
|
|
}
|
|
|
|
|
|
+ //导出
|
|
|
+ async exportExcelByVisit() {
|
|
|
+ const { ctx, service } = this;
|
|
|
+ const query = ctx.query;
|
|
|
+ const user = ctx.user;
|
|
|
+ const level = user.dept.level;
|
|
|
+ delete query.sessionId;
|
|
|
+
|
|
|
+ // 区级以上管理员
|
|
|
+ if (level == '1' || level == '2' ) {
|
|
|
+ ctx.logger.info('区及以上');
|
|
|
+ if (!ctx.query.dept1 || !ctx.query.dept2 || !ctx.query.dept3 ) {
|
|
|
+ delete ctx.query.dept1;
|
|
|
+ delete ctx.query.dept2;
|
|
|
+ delete ctx.query.dept3;
|
|
|
+ this.ctx.error('请选择要导出的市、区乡镇村级地区');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ctx.logger.info('区以下管理员');
|
|
|
+ // 登录人的地区
|
|
|
+ if (user.dept5) {
|
|
|
+ query.dept5 = user.dept5;
|
|
|
+ } else if (user.dept4) {
|
|
|
+ query.dept4 = user.dept4;
|
|
|
+ }else if (user.dept3) {
|
|
|
+ query.dept3 = user.dept3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const result = await service.visitService.visitExportData(ctx.query);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const config = [{
|
|
|
+ sheetOptions: { pageSetup: { orientation: 'landscape', fitToHeight: true } },
|
|
|
+ sheetHeader: [
|
|
|
+ {
|
|
|
+ headerName:
|
|
|
+ '吉林省民政厅居家老年人巡视关爱探访系统探访信息',
|
|
|
+ headerConfig: { height: 40 },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ sheetKey: [
|
|
|
+ { label: '序号', key: 'num', letter: 'A', width: 6 },
|
|
|
+ { label: '老人姓名', key: 'oldInfo', letter: 'B', width: 10 },
|
|
|
+ { label: '身份证号', key: 'oldIdNumber', letter: 'C', width: 20 },
|
|
|
+ { label: '探访者', key: 'userid.loginName', letter: 'D', width: 20 },
|
|
|
+ { label: '探访备注说明', key: 'visitMessage', letter: 'E', width: 50 },
|
|
|
+ { label: '探访位置', key: 'visitLocation', letter: 'F', width: 50 },
|
|
|
+ { label: '健康状况', key: 'health', letter: 'G', width: 10 },
|
|
|
+ { label: '精神状况', key: 'mind', letter: 'H', width: 10 },
|
|
|
+ { label: '安全状况', key: 'security', letter: 'I', width: 10 },
|
|
|
+ { label: '卫生环境', key: 'hygiene', letter: 'J', width: 10 },
|
|
|
+ { label: '居住环境', key: 'live', letter: 'K', width: 10 },
|
|
|
+ { label: '老人需求说明', key: 'demand', letter: 'L', width: 50 },
|
|
|
+
|
|
|
+ ],
|
|
|
+ sheetData: result,
|
|
|
+ }];
|
|
|
+ const workbook = excelUtils.getExcel(config);
|
|
|
+ if (!workbook) {
|
|
|
+ this.ctx.error();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.ctx.set('Content-Type', 'application/vnd.openxmlformats');
|
|
|
+ this.ctx.set('Content-Disposition', "attachment;filename*=UTF-8' '" + encodeURIComponent(new Date().getTime()) + '.xlsx');
|
|
|
+ this.ctx.body = await workbook.xlsx.writeBuffer();
|
|
|
+ // const finalfilename = encodeURIComponent(new Date().getTime());
|
|
|
+ // const path = this.app.config.defaultUploadPath + finalfilename + '.xlsx';
|
|
|
+ // await workbook.xlsx.writeFile(path);
|
|
|
+ // this.ctx.body = this.app.config.defaultUrl+this.app.config.defaultWritePathPre + finalfilename + '.xlsx'+new Date().getTime()+"生成文件时间"+
|
|
|
+ // ";开始时间="+begintime+";结束时间="+endtime;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// 百度人脸对比----图片url
|
|
|
async doFace3() {
|
|
|
const { ctx } = this;
|