多查询-分页导出

main
暴炳林 2025-02-17 14:05:44 +08:00
parent 39a6e9d1d6
commit d76a6d10cf
19 changed files with 323 additions and 560 deletions

View File

@ -91,6 +91,7 @@
import FileSaver from 'file-saver'
// eslint-disable-next-line no-unused-vars
import XLSX from 'xlsx'
import { downloadExcel } from '@/util/excelUtils';
export default {
// eslint-disable-next-line vue/multi-word-component-names
name:"拣货任务效率统计",
@ -209,11 +210,6 @@ export default {
minWidth: '150px',
label: '拣货-合单时间'
},
{
prop: '拣货-合单时间',
minWidth: '150px',
label: '拣货-合单时间'
},
{
prop: '合单-交单时间',
minWidth: '150px',
@ -337,46 +333,15 @@ export default {
},
// excelExcel
downExcel(){
//
this.tableloding=true;
///Jianhuojiemian/downloadpost {responseType:'blob'}
//
let a = 1;
let t = this.total;
// eslint-disable-next-line no-constant-condition,no-empty
while (true){
/* 分文件导出*/
let b=500000;
if (t<b){
b = t;
}
t=t-b;
console.log(a+","+b+","+t)
this.$axios.post(this.$httpUrl + '/JianHuoXiaoLv/download', {
pageSize: b,
pageNum: a,
param: this.param,
},{responseType:'blob'}).then(res => {
this.tableloding=false;
//
this.downloadFile(res.data,'拣货任务效率统计'+ '数据', 'xlsx')
});
if (t<=0) {
break;
}
}
},
downloadFile(obj, name, suffix) {
//
const url = window.URL.createObjectURL(new Blob([obj]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
const fileName = this.parseTime(new Date()) + '-' + name + '.' + suffix
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
this.tableloding = true;
downloadExcel('/JianHuoXiaoLv/download', '拣货任务效率统计', this.total, this.param)
.then(() => {
this.tableloding = false;
})
.catch(error => {
console.error('系统错误:', error);
this.tableloding = false;
});
},
KuS(){
//
@ -412,7 +377,7 @@ export default {
this.tableloding=false;
})
},
parseTime(time, cFormat) {
/*parseTime(time, cFormat) {
//
if (arguments.length === 0) {
return null
@ -451,7 +416,7 @@ export default {
return value || 0
})
return time_str
},
},*/
Allquesr(){
//
if(this.checked){

View File

@ -625,6 +625,7 @@
</template>
<script>
import { downloadExcel } from '@/util/excelUtils';
export default {
data() {
return {
@ -919,73 +920,15 @@ export default {
this.downExcel();
},
downExcel() {
//
this.tableloding=true;
///Jianhuojiemian/downloadpost {responseType:'blob'}
//
this.$axios.post(this.$httpUrl + '/Jianhuojiemian/download', {
pageSize: this.total,
pageNum: 1,
param: this.param,
},{responseType:'blob'}).then(res => {
this.tableloding=false;
//
this.downloadFile(res.data,'拣货界面'+ '数据', 'xlsx')
});
//
},
downloadFile(obj, name, suffix) {
//
const url = window.URL.createObjectURL(new Blob([obj]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
const fileName = this.parseTime(new Date()) + '-' + name + '.' + suffix
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
},
parseTime(time, cFormat) {
//
if (arguments.length === 0) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'undefined' || time === null || time === 'null') {
return ''
} else if (typeof time === 'object') {
date = time
} else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time)
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
this.tableloding = true;
downloadExcel('/Jianhuojiemian/download', '拣货界面', this.total, this.param)
.then(() => {
this.tableloding = false;
})
.catch(error => {
console.error('系统错误:', error);
this.tableloding = false;
});
},
Allquesr(){
//

View File

@ -612,6 +612,7 @@
</template>
<script>
import { downloadExcel } from '@/util/excelUtils';
export default {
data() {
return {
@ -833,73 +834,15 @@ export default {
this.downExcel();
},
downExcel() {
//
this.tableloding=true;
///Jianhuojiemian/downloadpost {responseType:'blob'}
//
this.$axios.post(this.$httpUrl + '/Kucunhuizong/download', {
pageSize: this.total,
pageNum: 1,
param: this.param,
},{responseType:'blob'}).then(res => {
this.tableloding=false;
//
this.downloadFile(res.data,'库存汇总'+ '数据', 'xlsx')
});
//
},
downloadFile(obj, name, suffix) {
//
const url = window.URL.createObjectURL(new Blob([obj]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
const fileName = this.parseTime(new Date()) + '-' + name + '.' + suffix
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
},
parseTime(time, cFormat) {
//
if (arguments.length === 0) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'undefined' || time === null || time === 'null') {
return ''
} else if (typeof time === 'object') {
date = time
} else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time)
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
this.tableloding = true;
downloadExcel('/Kucunhuizong/download', '库存汇总', this.total, this.param)
.then(() => {
this.tableloding = false;
})
.catch(error => {
console.error('系统错误:', error);
this.tableloding = false;
});
},
Allquesr(){
//

View File

@ -346,6 +346,7 @@
</template>
<script>
import { downloadExcel } from '@/util/excelUtils';
export default {
name: "Kucunrizhi",
data() {
@ -418,7 +419,6 @@ export default {
mounted() {
this.queryUser();
this.LOC();
this.LogS();
},
methods: {
handleEdit(index, row) {
@ -484,73 +484,15 @@ export default {
this.downExcel();
},
downExcel() {
//
this.tableloding=true;
///Jianhuojiemian/downloadpost {responseType:'blob'}
//
this.$axios.post(this.$httpUrl + '/Kucunrizhi/download', {
pageSize: this.pageSize,
pageNum: this.pageNum,
param: this.param,
},{responseType:'blob'}).then(res => {
this.tableloding=false;
//
this.downloadFile(res.data,'库存操作日志'+ '数据', 'xlsx')
});
//
},
downloadFile(obj, name, suffix) {
//
const url = window.URL.createObjectURL(new Blob([obj]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
const fileName = this.parseTime(new Date()) + '-' + name + '.' + suffix
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
},
parseTime(time, cFormat) {
//
if (arguments.length === 0) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'undefined' || time === null || time === 'null') {
return ''
} else if (typeof time === 'object') {
date = time
} else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time)
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
this.tableloding = true;
downloadExcel('/Kucunrizhi/download', '库存操作日志', this.total, this.param)
.then(() => {
this.tableloding = false;
})
.catch(error => {
console.error('系统错误:', error);
this.tableloding = false;
});
},
Allquesr(){
//

View File

@ -155,6 +155,7 @@
</template>
<script>
import { downloadExcel } from '@/util/excelUtils';
export default {
data() {
return {
@ -334,73 +335,15 @@ export default {
this.downExcel();
},
downExcel() {
//
this.tableloding=true;
///Jianhuojiemian/downloadpost {responseType:'blob'}
//
this.$axios.post(this.$httpUrl + '/dcx/download', {
pageSize: this.total,
pageNum: 1,
param: this.param,
},{responseType:'blob'}).then(res => {
this.tableloding=false;
//
this.downloadFile(res.data,'料箱监控'+ '数据', 'xlsx')
});
//
},
downloadFile(obj, name, suffix) {
//
const url = window.URL.createObjectURL(new Blob([obj]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
const fileName = this.parseTime(new Date()) + '-' + name + '.' + suffix
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
},
parseTime(time, cFormat) {
//
if (arguments.length === 0) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'undefined' || time === null || time === 'null') {
return ''
} else if (typeof time === 'object') {
date = time
} else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time)
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
this.tableloding = true;
downloadExcel('/dcx/download', '料箱监控', this.total, this.param)
.then(() => {
this.tableloding = false;
})
.catch(error => {
console.error('系统错误:', error);
this.tableloding = false;
});
},
Allquesr(){
//

View File

@ -419,6 +419,7 @@
</template>
<script>
import { downloadExcel } from '@/util/excelUtils';
export default {
data() {
return {
@ -590,73 +591,15 @@ export default {
this.downExcel();
},
downExcel() {
//
this.tableloding=true;
///Jianhuojiemian/downloadpost {responseType:'blob'}
//
this.$axios.post(this.$httpUrl + '/Pandianmingxi/download', {
pageSize: this.total,
pageNum: 1,
param: this.param,
},{responseType:'blob'}).then(res => {
this.tableloding=false;
//
this.downloadFile(res.data,'盘点明细查询'+ '数据', 'xlsx')
});
//
},
downloadFile(obj, name, suffix) {
//
const url = window.URL.createObjectURL(new Blob([obj]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
const fileName = this.parseTime(new Date()) + '-' + name + '.' + suffix
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
},
parseTime(time, cFormat) {
//
if (arguments.length === 0) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'undefined' || time === null || time === 'null') {
return ''
} else if (typeof time === 'object') {
date = time
} else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time)
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
this.tableloding = true;
downloadExcel('/Pandianmingxi/download', '盘点明细查询', this.total, this.param)
.then(() => {
this.tableloding = false;
})
.catch(error => {
console.error('系统错误:', error);
this.tableloding = false;
});
},
Allquesr(){
//

View File

@ -410,6 +410,8 @@
</template>
<script>
import { downloadExcel } from '@/util/excelUtils';
export default {
name: "Rukuzhengli",
data() {
@ -559,73 +561,15 @@ export default {
this.downExcel();
},
downExcel() {
//
this.tableloding=true;
///Jianhuojiemian/downloadpost {responseType:'blob'}
//
this.$axios.post(this.$httpUrl + '/Rukuzhengli/download', {
pageSize: this.total,
pageNum: 1,
param: this.param,
},{responseType:'blob'}).then(res => {
this.tableloding=false;
//
this.downloadFile(res.data,'入库整理'+ '数据', 'xlsx')
});
//
},
downloadFile(obj, name, suffix) {
//
const url = window.URL.createObjectURL(new Blob([obj]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
const fileName = this.parseTime(new Date()) + '-' + name + '.' + suffix
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
},
parseTime(time, cFormat) {
//
if (arguments.length === 0) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'undefined' || time === null || time === 'null') {
return ''
} else if (typeof time === 'object') {
date = time
} else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time)
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
this.tableloding = true;
downloadExcel('/Rukuzhengli/download', '入库整理', this.total, this.param)
.then(() => {
this.tableloding = false;
})
.catch(error => {
console.error('系统错误:', error);
this.tableloding = false;
});
},
Allquesr(){
//

View File

@ -346,6 +346,7 @@
</template>
<script>
import { downloadExcel } from '@/util/excelUtils';
export default {
data() {
return {
@ -580,73 +581,15 @@ export default {
this.downExcel();
},
downExcel() {
//
this.tableloding=true;
///Jianhuojiemian/downloadpost {responseType:'blob'}
//
this.$axios.post(this.$httpUrl + '/Xuliehaoqingdan/download', {
pageSize: this.total,
pageNum: 1,
param: this.param,
},{responseType:'blob'}).then(res => {
this.tableloding=false;
//
this.downloadFile(res.data,'序列号库存清点'+ '数据', 'xlsx')
});
//
},
downloadFile(obj, name, suffix) {
//
const url = window.URL.createObjectURL(new Blob([obj]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
const fileName = this.parseTime(new Date()) + '-' + name + '.' + suffix
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
},
parseTime(time, cFormat) {
//
if (arguments.length === 0) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'undefined' || time === null || time === 'null') {
return ''
} else if (typeof time === 'object') {
date = time
} else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time)
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
this.tableloding = true;
downloadExcel('/Xuliehaoqingdan/download', '序列号库存清点', this.total, this.param)
.then(() => {
this.tableloding = false;
})
.catch(error => {
console.error('系统错误:', error);
this.tableloding = false;
});
},
Allquesr(){
//

View File

@ -495,6 +495,7 @@
// import horizontalScroll from 'el-table-horizontal-scroll'
import {outFile} from "@/util/excel.vue";
import { downloadExcel } from '@/util/excelUtils';
export default {
name: "Main",
@ -728,33 +729,15 @@ export default {
this.downExcel();
},
downExcel() {
//
this.tableloding=true;
///Jianhuojiemian/downloadpost {responseType:'blob'}
//
this.$axios.post(this.$httpUrl + '/Zhengliqingdan/download', {
pageSize: this.total,
pageNum: 1,
param: this.param,
},{responseType:'blob'}).then(res => {
this.tableloding=false;
//
this.downloadFile(res.data,'整理完成未上架清单'+ '数据', 'xlsx')
});
//
},
downloadFile(obj, name, suffix) {
//
const url = window.URL.createObjectURL(new Blob([obj]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
const fileName = this.parseTime(new Date()) + '-' + name + '.' + suffix
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
this.tableloding = true;
downloadExcel('/Zhengliqingdan/download', '整理完成未上架清单', this.total, this.param)
.then(() => {
this.tableloding = false;
})
.catch(error => {
console.error('系统错误:', error);
this.tableloding = false;
});
},
parseTime(time, cFormat) {
//

View File

@ -0,0 +1,20 @@
// src/plugins/axiosPlugin.js
import axios from 'axios';
export default {
install(Vue, options) {
// 创建 axios 实例
const instance = axios.create({
baseURL: options.httpUrl, // 假设 httpUrl 作为选项传递
timeout: 10000,
headers: {
'Content-Type': 'application/json'
}
});
// 将 axios 实例挂载到 Vue 原型上
Vue.prototype.$axios = instance;
Vue.prototype.$httpUrl = options.httpUrl;
}
};

View File

@ -0,0 +1,98 @@
// src/utils/excelUtils.js
import axios from 'axios';
import Vue from "vue";
export function downloadExcel(url, fileNamePrefix, total, param) {
console.log(fileNamePrefix);
let i = 1;
let a = 1;
let t = total;
const requests = [];
const httpUrl = Vue.prototype.$httpUrl; // 确保这里使用正确的 API URL
// eslint-disable-next-line no-constant-condition,no-empty
while (true) {
/* 分文件导出*/
let b = 500000;
if (t < b) {
b = t;
}
t = t - b;
console.log(a + "," + b + "," + t);
requests.push(
axios.post(httpUrl + url, {
pageSize: b,
pageNum: a,
param: param,
}, { responseType: 'blob' }).then(res => {
// 重命名文件
downloadFile(res.data, fileNamePrefix + '数据_' + i, 'xlsx');
i++;
}).catch(error => {
console.error('下载失败:', error);
alert("下载失败")
})
);
if (t <= 0) {
break;
}
}
return Promise.all(requests);
}
export function downloadFile(obj, name, suffix) {
//解析流文件,进行下载保存
const url = window.URL.createObjectURL(new Blob([obj]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
const fileName = parseTime(new Date()) + '-' + name + '.' + suffix
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
export function parseTime(time, cFormat) {
// 获取当前时间
if (arguments.length === 0) {
return null;
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}';
let date;
if (typeof time === 'undefined' || time === null || time === 'null') {
return '';
} else if (typeof time === 'object') {
date = time;
} else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time);
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000;
}
date = new Date(time);
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
};
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key];
// Note: getDay() returns 0 on Sunday
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value]; }
if (result.length > 0 && value < 10) {
value = '0' + value;
}
return value || 0;
});
return time_str;
}

View File

@ -1,5 +1,8 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false
lintOnSave: false,
devServer: {
port: 18084 //
}
})

View File

@ -47,7 +47,7 @@ public class GGZXiaoLvController {
endDate=sdf.format(param.getJSONArray("日期").getDate(1));
}
/* 基础sql数据查询*/
String sql=" select Row_number() OVER(order by v.库区,v.工作站 asc) as id,v.库区, "
String sql=" select Row_number() OVER(order by v.库区,v.工作站,v.业务类型 asc) as id,v.库区, "
+" v.工作站,sum(v.有效时效) '有效时效', v.业务类型 ,sum(v.有效时效)/540 '有效时间占比' ," +
" count(DISTINCT(v.任务号)) 任务数 from ( "
+" select (case when left(agv.targetArea,1)='1' then '货架到人' when left(agv.targetArea,1)='2' then '料箱到人' end) as '库区', "
@ -60,8 +60,7 @@ public class GGZXiaoLvController {
+" from agvtask agv "
+" where CONVERT(VARCHAR,agv.createTime , 23)>='"+startDate+"' "
+" and CONVERT(VARCHAR,agv.createTime , 23)<='"+endDate+"' ) v "
+" GROUP BY v.库区,v.工作站 ,v.业务类型 "
+" order BY v.库区,v.工作站 ,v.业务类型 ";
+" GROUP BY v.库区,v.工作站 ,v.业务类型 ";
String sqlCount = "select count(t.id) as nums from (" + sql+") t";
/* 总条数*/
List<Integer> counts = entityManager.createNativeQuery(sqlCount).getResultList();

View File

@ -1,5 +1,6 @@
package com.yc.wms.controller;
import cn.hutool.core.date.DateUnit;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.yc.wms.bean.Xuliehao;
@ -7,6 +8,7 @@ import com.yc.wms.service.Xuliehaoqingdan;
import com.yc.wms.until.QueryPageUtil;
import com.yc.wms.until.Result;
import com.yc.wms.utils.FileUtil;
import com.yc.wms.utils.QueryUtil;
import com.yc.wms.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -23,6 +25,10 @@ import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
@RestController
@ -35,7 +41,8 @@ public class JianHuoXiaoLvController {
private NamedParameterJdbcTemplate jdbcTemplate;
@Autowired
private Xuliehaoqingdan xuliehaoqingdan;
@Autowired
private QueryUtil queryUtil;
private static /* 基础sql数据查询*/
String sql=" select t.id,bt.NAME as '单据类型',pt.sourceType as '出库类型',pt.id as '任务号',t.BILLCODE as '子任务号', "
+" z.NAME as '库区',ptd.LINE_NUMBER as '拣货行' ,pt.UPDATE_TIME as '创建时间',t.dateBill3 as '生成合单任务时间', "
@ -83,21 +90,25 @@ public class JianHuoXiaoLvController {
}
/* 当前页数据*/
int pageNum = query.getPageNum();//当前页
int pageSize = query.getPageSize();//条数
int pageSize = query.getPageSize();//查询条数
String sqlFa = "select * from( "
+ sql
+ ") t where 1=1 "
+ querySql ;
String sqlFy= sqlFa+" ORDER BY id "
+" OFFSET "+ (pageNum-1) * pageSize +" ROWS "
+" FETCH NEXT "+pageSize+" ROWS ONLY ";
/* 总条数*/
String sqlCount = "select count(t.id) as nums from (" + sqlFa+") t";
List<Integer> counts = entityManager.createNativeQuery(sqlCount).getResultList();
/* 查询所有数据*/
List<Map<String,Object>> maps = jdbcTemplate.queryForList(sqlFy, new HashMap<>());
/* 返回数据集合*/
List<Map<String,Object>> maps;
if (pageSize>100000){
maps = queryUtil.multiThreadedQuery(sqlFa, pageSize, pageNum);
}else {
String sqlFy= sqlFa+" ORDER BY id "
+" OFFSET "+ (pageNum-1) * pageSize +" ROWS "
+" FETCH NEXT "+pageSize+" ROWS ONLY ";
maps = jdbcTemplate.queryForList(sqlFy, new HashMap<>());
}
for (int i = 0; i < maps.size(); i++) {
Map<String,Object> map=maps.get(i);
map.put("mergeData",new HashMap() {{
@ -122,7 +133,7 @@ public class JianHuoXiaoLvController {
return result;
}
@PostMapping(value = "/download")
public void exportCompany(HttpServletResponse response, @RequestBody String json) throws Exception {
public synchronized void exportCompany(HttpServletResponse response, @RequestBody String json) throws Exception {
download( (List<Map<String,Object>>)queryList(json).getData(), response);
}
public void download(List<Map<String, Object>> all, HttpServletResponse response) throws Exception {

View File

@ -53,7 +53,7 @@ public class KucunhuizongController {
@PostMapping(value = "/download")
public void exportCompany(HttpServletResponse response, @RequestBody String json) throws Exception {
public synchronized void exportCompany(HttpServletResponse response, @RequestBody String json) throws Exception {
QueryPageUtil query =new QueryPageUtil();
JSONObject jsonObject= JSONUtil.parseObj(json);

View File

@ -104,6 +104,11 @@ public class RongQiController {
/* 当前页数据*/
int pageNum = query.getPageNum();//当前页
int pageSize = counts.get(0);//条数
if (pageSize==0){
Result result=Result.result(400,"未查询到数据",Long.parseLong(counts.get(0).toString()), null);
return result;
}
String querySql="";//查询条件
String sqlFy = "select * from( "

View File

@ -185,7 +185,8 @@ public class PandianmingxiImpl implements Pandianmingxi {
if(pandianming.issued_Date!=null&&pandianming.issued_Date.length>0){
String startDate = simpleDateFormat.format(pandianming.issued_Date[0]);
String endDate = simpleDateFormat.format(pandianming.issued_Date[1]);
sql+=" and CONVERT(DATE, cr.issued_Date) "+"'"+startDate+"'"+" and "+ "'"+endDate+"'";
sql+=" AND CONVERT(DATE, cr.issued_Date, 20) >= '"+startDate+"' "
+" AND CONVERT(DATE, cr.issued_Date, 20) <= '"+endDate+"' ";
}

View File

@ -0,0 +1,76 @@
package com.yc.wms.utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.*;
@Slf4j
@Component
public class QueryUtil {
@Autowired
private NamedParameterJdbcTemplate jdbcTemplate;
private static boolean isQueryInProgress = false;
public List<Map<String, Object>> multiThreadedQuery(String sqlFa, int pageSize, int pageNum) {
if (isQueryInProgress) {
throw new RuntimeException("查询导出其他文件,请稍后重试");
}
isQueryInProgress = true;
Date currentDate1 = new Date();
List<Map<String, Object>> maps = new ArrayList<>();
try {
int batchSize = 20000; // 每次查询的数量
int totalCount = pageSize; // 查询条数
int numThreads = Math.min(Math.max(totalCount / batchSize, 1), 50); // 线程数量,最大为 10
ExecutorService executorService = Executors.newFixedThreadPool(numThreads);
List<Future<List<Map<String, Object>>>> futures = new ArrayList<>();
int batchesPerThread = (int) Math.ceil((double) (totalCount / batchSize) / numThreads);
for (int threadIndex = 0; threadIndex < numThreads; threadIndex++) {
int startBatch = threadIndex * batchesPerThread + (pageNum - 1) * pageSize;
int endBatch = Math.min(startBatch + batchesPerThread, totalCount / batchSize);
Callable<List<Map<String, Object>>> task = () -> {
List<Map<String, Object>> threadResults = new ArrayList<>();
for (int batch = startBatch; batch < endBatch; batch++) {
int offset = batch * batchSize;
String batchSql = sqlFa + " ORDER BY id "
+ " OFFSET " + offset + " ROWS "
+ " FETCH NEXT " + batchSize + " ROWS ONLY ";
threadResults.addAll(jdbcTemplate.queryForList(batchSql, new HashMap<>()));
log.info("运行线程 offset: {}", offset);
}
return threadResults;
};
futures.add(executorService.submit(task));
}
for (Future<List<Map<String, Object>>> future : futures) {
try {
maps.addAll(future.get());
} catch (Exception e) {
log.error("Error while processing query", e);
}
}
executorService.shutdown();
} catch (Exception e) {
log.error("Error in multiThreadedQuery", e);
}finally {
isQueryInProgress = false;
}
Date currentDate2 = new Date();
log.info("线程多查询耗时: {} ms", currentDate2.getTime() - currentDate1.getTime());
return maps;
}
}

View File

@ -1,4 +1,5 @@
server:
address: 0.0.0.0
port: 8084
# url: jdbc:sqlserver://47.100.54.81:1433;DatabaseName=zwwms
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
@ -27,7 +28,7 @@ spring:
idle-timeout: 60000
login-timeout: 5
max-lifetime: 60000
maximum-pool-size: 10
maximum-pool-size: 100
minimum-idle: 10
read-only: false
# 文件存储路径