Merge branch 'master' of http://10.153.19.25:10105/r/ERP_override
| | |
| | | <template> |
| | | <div> |
| | | <el-button id="button" type="primary" @click="previewReport" style="position: fixed; top: 90px; right: 40px; padding: 20px; background: #409eff; color: white; border: none; border-radius: 5px; cursor: pointer;"> |
| | | 预览 |
| | | </el-button> |
| | | <!-- <el-button id="button" type="primary" @click="printReport" style="position: fixed; top: 90px; right: 20px; padding: 20px; background: #409eff; color: white; border: none; border-radius: 5px; cursor: pointer;">--> |
| | | <!-- <el-button id="button" type="primary" @click="printReports" style="position: fixed; top: 90px; right: 20px; padding: 20px; background: #409eff; color: white; border: none; border-radius: 5px; cursor: pointer;">--> |
| | | <!-- 打印--> |
| | | <!-- </el-button>--> |
| | | <el-button |
| | | id="button" |
| | | type="primary" |
| | | @click="previewReport" |
| | | :loading="loading" style="position: fixed; top: 90px; right: 40px; padding: 20px; background: #409eff; color: white; border: none; border-radius: 5px; cursor: pointer;" |
| | | :disabled="loading"> |
| | | {{ loading ? '生成中...' : '预览' }} |
| | | </el-button> |
| | | |
| | | <div style="display: flex; align-items: center; gap: 20px; margin-bottom: 20px;"> |
| | | <span>工程编号:</span> |
| | | <el-input readonly placeholder="" style="width: 150px" v-model="processId"></el-input> |
| | | <el-checkbox v-model="config.printLayouts"> |
| | | 打印版图 |
| | | </el-checkbox> |
| | | <el-checkbox v-model="config.printReport"> |
| | | 打印报告 |
| | | </el-checkbox> |
| | | <div style="margin-right: 30px;"></div> |
| | | <span>布局选择:</span> |
| | | <el-select v-model="config.columnTypes" style="width: 120px;"> |
| | | <el-option v-for="type in columnTypes" :key="type" :value="type" /> |
| | | </el-select> |
| | | <el-select v-model="config.rowTypes" style="width: 120px;"> |
| | | <el-option v-for="type in rowTypes" :key="type" :value="type" /> |
| | | </el-select> |
| | | </div> |
| | | <div style="display: flex; align-items: center; gap: 20px; margin-bottom: 20px;"> |
| | | <span>显示小片信息:</span> |
| | | <el-select v-model="config.glassInfo" style="width: 120px;"> |
| | | <el-option v-for="type in glassInfo" :key="type" :value="type" /> |
| | | </el-select> |
| | | <span>显示切割信息:</span> |
| | | <el-select v-model="config.cutInfo" style="width: 120px;"> |
| | | <el-option v-for="type in cutInfo" :key="type" :value="type" /> |
| | | </el-select> |
| | | </div> |
| | | |
| | | <div v-if="pdfUrl" style="margin-top: 20px;"> |
| | | <div v-if="pdfUrl || pdfLoading" style="margin-top: 20px;"> |
| | | <!-- PDF加载时显示美化后的加载动画 --> |
| | | <div v-if="pdfLoading" style="display: flex; justify-content: center; align-items: center; height: 800px; border: 1px solid #ddd; background-color: #f5f5f5;"> |
| | | <div style="text-align: center;"> |
| | | <div class="loading-animation"> |
| | | <div class="dot-flashing"></div> |
| | | </div> |
| | | <p style="margin-top: 20px; font-size: 18px; color: #666;">PDF文档加载中...</p> |
| | | <p style="font-size: 14px; color: #999; margin-top: 10px;">正在为您准备预览内容</p> |
| | | </div> |
| | | </div> |
| | | <!-- PDF加载完成时显示PDF --> |
| | | <iframe |
| | | :src="pdfUrl" |
| | | style="width: 100%; height: 800px; border: 1px solid #ddd;" |
| | | v-else |
| | | :src="pdfUrl" style="width: 100%; height: 800px; border: 1px solid #ddd;" |
| | | title="PDF预览"> |
| | | </iframe> |
| | | </div> |
| | | |
| | | <div v-else style="margin-top: 20px;"> |
| | | <div style="display: flex; justify-content: center; align-items: center; height: 800px; border: 1px solid #ddd; background-color: white;"> |
| | | <div style="text-align: center; color: #999;"> |
| | | <p style="font-size: 20px; margin-bottom: 10px;">优化报告预览区</p> |
| | | <p style="font-size: 14px;">点击上方"预览"按钮生成并查看优化报告</p> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <div ref="printContainer" style="position: relative;"> |
| | |
| | | import request from "@/utils/request"; |
| | | import {ElMessage, ElMessageBox} from "element-plus"; |
| | | import requestOptimize from "@/utils/requestOptimize"; |
| | | import useUserInfoStore from "@/stores/userInfo"; |
| | | |
| | | const userStore = useUserInfoStore(); |
| | | |
| | | const props = defineProps({ |
| | | project : null, |
| | |
| | | const layoutData = ref(); |
| | | const optimizeUse = ref(); |
| | | const reportData = ref(); |
| | | const layoutSet = ref(); |
| | | const materialList = ref(); |
| | | const productList = ref(); |
| | | const dataLoaded = ref(false); |
| | | const materialDetails = ref(); |
| | | const injectedProjectNo = inject('projectNo', null); |
| | | const state = ref(); |
| | | const columnTypes = ['一列', '两列'] |
| | | const rowTypes = ['一行', '两行', '三行', '四行'] |
| | | const glassInfo = ['不显示', '显示在右侧', '显示在下侧'] |
| | | const cutInfo = ['不显示', '显示'] |
| | | const filePath = ref(''); |
| | | const loading = ref(false); |
| | | const pdfLoading = ref(false); |
| | | const printLayouts = ref(); |
| | | const printReport = ref(); |
| | | const layoutRows = ref(); |
| | | const layoutColumns = ref(); |
| | | const glassInfoShow = ref(); |
| | | const cutInfoShow = ref(); |
| | | const username = userStore.user.userName; |
| | | |
| | | const pdfUrl = ref(''); |
| | | |
| | |
| | | }); |
| | | }; |
| | | |
| | | const fetchSettings = async (username) => { |
| | | try { |
| | | const response = await request.post(`/glassOptimize/selectOptimizeParms/${username}`); |
| | | if (response.code == 200) { |
| | | if (!response.data) { |
| | | console.error('响应数据为空'); |
| | | return; |
| | | } |
| | | const parsedData = JSON.parse(response.data); |
| | | console.log('设置内容:', parsedData); |
| | | printLayouts.value = parsedData.server.printLayouts; |
| | | printReport.value = parsedData.server.printReport; |
| | | layoutRows.value = parsedData.server.layoutRows; |
| | | layoutColumns.value = parsedData.server.layoutColumns; |
| | | glassInfoShow.value = parsedData.server.glassInfoShow; |
| | | cutInfoShow.value = parsedData.server.cutInfoShow; |
| | | } else { |
| | | console.error('请求失败,状态码:', response.code); |
| | | } |
| | | } catch (error) { |
| | | console.error('请求发生错误:', error); |
| | | } |
| | | }; |
| | | |
| | | |
| | | const selectMaterialData= () => { |
| | | request.post(`/glassOptimize/materialInfo/${processId.value}`) |
| | |
| | | return; |
| | | } |
| | | |
| | | // 映射 rowTypes 到 layoutRows |
| | | const layoutRowsMap = { |
| | | '一行': 1, |
| | | '两行': 2, |
| | | '三行': 3, |
| | | '四行': 4 |
| | | }; |
| | | |
| | | // 映射 columnTypes 到 layoutColumns |
| | | const layoutColumnsMap = { |
| | | '一列': 1, |
| | | '两列': 2, |
| | | }; |
| | | |
| | | // 映射 glassInfo 到 glassInfoShow |
| | | const glassInfoMap = { |
| | | '不显示': 0, |
| | | '显示在右侧': 1, |
| | | '显示在下侧': 2 |
| | | }; |
| | | |
| | | // 映射 cutInfo 到 cutInfoShow |
| | | const cutInfoMap = { |
| | | '不显示': 0, |
| | | '显示': 1 |
| | | }; |
| | | |
| | | const response = await requestOptimize.post('/api/reports', { |
| | | fileName: processId.value, |
| | | projectNo: processId.value, |
| | |
| | | glassThickness : optimizeUse.value.thickness, |
| | | glassType : optimizeUse.value.model, |
| | | quantity : String(optimizeUse.value.processingQuantity), |
| | | printLayouts : config.printLayouts ? '1' : '0', |
| | | printReport : config.printReport ? '1' : '0', |
| | | printLayouts : printLayouts.value === '0' ? '1' : '0', // 0表示是,1表示否 |
| | | printReport : printReport.value === '0' ? '1' : '0', // 0表示是,1表示否 |
| | | layouts : layoutData.value, |
| | | reportData:{ |
| | | rectangleQuantity: reportData.value.rectangleQuantity, |
| | |
| | | productList: productList.value, |
| | | }, |
| | | layoutSet: { |
| | | layoutRows: layoutRowsMap[config.rowTypes] || 1, |
| | | layoutColumns: layoutColumnsMap[config.columnTypes] || 1, |
| | | glassInfoShow: glassInfoMap[config.glassInfo] || 0, |
| | | cutInfoShow: cutInfoMap[config.cutInfo] || 0 |
| | | layoutRows: parseInt(layoutRows.value) || 2, |
| | | layoutColumns: parseInt(layoutColumns.value) || 2, |
| | | glassInfoShow: parseInt(glassInfoShow.value) || 0, |
| | | cutInfoShow: parseInt(cutInfoShow.value) || 0 |
| | | } |
| | | |
| | | }, { |
| | |
| | | } |
| | | }; |
| | | |
| | | const printReport = async () => { |
| | | const printReports = async () => { |
| | | try { |
| | | await generateReport(); |
| | | if (!filePath.value) { |
| | |
| | | |
| | | const previewReport = async () => { |
| | | try { |
| | | loading.value = true; |
| | | ElMessage.info('正在生成报告,请稍候...') |
| | | await generateReport(); |
| | | if (!filePath.value) { |
| | | ElMessage.error('未收到有效的PDF文件路径'); |
| | | loading.value = false; |
| | | return; |
| | | } |
| | | const encodedFilePath = encodeURIComponent(filePath.value); |
| | | |
| | | // 设置PDF加载状态为true |
| | | pdfLoading.value = true; |
| | | |
| | | const response = await request.get('/glassOptimize/reports/pdf', { |
| | | params: { filePath: encodedFilePath }, |
| | |
| | | // 检查响应数据是否存在且有效 |
| | | if (!response) { |
| | | ElMessage.error('未能获取到PDF数据'); |
| | | loading.value = false; |
| | | pdfLoading.value = false; // 设置PDF加载状态为false |
| | | return; |
| | | } |
| | | |
| | |
| | | // 检查 blob 是否有效 |
| | | if (blob.size === 0) { |
| | | ElMessage.error('接收到空的PDF文件'); |
| | | loading.value = false; |
| | | pdfLoading.value = false; // 设置PDF加载状态为false |
| | | return; |
| | | } |
| | | |
| | |
| | | pdfUrl.value = url; |
| | | |
| | | ElMessage.success('报告生成成功,正在预览...'); |
| | | loading.value = false; |
| | | |
| | | // 可选:添加清理机制,当组件卸载时清理URL |
| | | // 这里可以使用 onUnmounted 钩子进行清理 |
| | | // 延迟一小段时间后设置PDF加载完成,确保用户能看到加载状态 |
| | | setTimeout(() => { |
| | | pdfLoading.value = false; |
| | | }, 500); |
| | | |
| | | } catch (error) { |
| | | console.error('预览流程异常:', error); |
| | | |
| | | loading.value = false; |
| | | pdfLoading.value = false; // 设置PDF加载状态为false |
| | | if (error.response) { |
| | | const status = error.response.status; |
| | | if (status === 400) { |
| | |
| | | selectReportData(); |
| | | selectMaterialData(); |
| | | selectProductData(); |
| | | fetchSettings(username); |
| | | } |
| | | |
| | | }); |
| | | |
| | | const handlePrint = () => { |
| | |
| | | handleLayoutChange(); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .loading-animation { |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | } |
| | | |
| | | .dot-flashing { |
| | | position: relative; |
| | | width: 10px; |
| | | height: 10px; |
| | | border-radius: 5px; |
| | | background-color: #409eff; |
| | | color: #409eff; |
| | | animation: dotFlashing 1s infinite linear alternate; |
| | | animation-delay: .5s; |
| | | } |
| | | |
| | | .dot-flashing::before, .dot-flashing::after { |
| | | content: ''; |
| | | display: inline-block; |
| | | position: absolute; |
| | | top: 0; |
| | | width: 10px; |
| | | height: 10px; |
| | | border-radius: 5px; |
| | | background-color: #409eff; |
| | | color: #409eff; |
| | | } |
| | | |
| | | .dot-flashing::before { |
| | | left: -15px; |
| | | animation: dotFlashing 1s infinite alternate; |
| | | animation-delay: 0s; |
| | | } |
| | | |
| | | .dot-flashing::after { |
| | | left: 15px; |
| | | animation: dotFlashing 1s infinite alternate; |
| | | animation-delay: 1s; |
| | | } |
| | | |
| | | @keyframes dotFlashing { |
| | | 0% { |
| | | background-color: #409eff; |
| | | } |
| | | 50%, |
| | | 100% { |
| | | background-color: #c0d9f7; |
| | | } |
| | | } |
| | | </style> |
| | |
| | | };
|
| | |
|
| | | const saveToDatabase = () => {
|
| | | if (settings.server.printLayouts === '1' && settings.server.printReport === '1') {
|
| | | ElMessage.warning('版图和报告不能同时不打印,请至少选择一项');
|
| | | return;
|
| | | }
|
| | | console.log(settings)
|
| | | request.post(`/glassOptimize/optimizeParms/${username}`, settings).then((res) => {
|
| | | if (res.code == 200 && res.data === true) {
|
| | |
| | | const parsedData = JSON.parse(response.data);
|
| | | if (!parsedData.server) {
|
| | | parsedData.server = {};
|
| | | }
|
| | | if (!parsedData.server.printLayouts) {
|
| | | parsedData.server.printLayouts = '0'; // 默认打印版图
|
| | | }
|
| | | if (!parsedData.server.printReport) {
|
| | | parsedData.server.printReport = '0'; // 默认打印报告
|
| | | }
|
| | | if (!parsedData.server.layoutRows) {
|
| | | parsedData.server.layoutRows = '2'; // 默认2行
|
| | | }
|
| | | if (!parsedData.server.layoutColumns) {
|
| | | parsedData.server.layoutColumns = '2'; // 默认2列
|
| | | }
|
| | | if (!parsedData.server.glassInfoShow) {
|
| | | parsedData.server.glassInfoShow = '2'; // 默认显示在下侧
|
| | | }
|
| | | if (!parsedData.server.cutInfoShow) {
|
| | | parsedData.server.cutInfoShow = '1'; // 默认显示
|
| | | }
|
| | | if (!parsedData.server.fileMode) {
|
| | | parsedData.server.fileMode = '1'; // 默认为单文件模式
|
| | |
| | | >
|
| | | <div class="sidebar-header">钢化</div>
|
| | | <div class="sidebar-content">钢化设置</div>
|
| | | </div>
|
| | | <div
|
| | | @click="selectComponent('print')"
|
| | | :class="{ active: currentComponent === 'print' }"
|
| | | class="sidebar-item"
|
| | | >
|
| | | <div class="sidebar-header">打印</div>
|
| | | <div class="sidebar-content">打印设置</div>
|
| | | </div>
|
| | | </div>
|
| | |
|
| | |
| | | <div class="form-group">
|
| | | <label>抬刀退缩</label>
|
| | | <input type="number" v-model="settings.cutting.lift_retract" />
|
| | | </div>
|
| | | </div>
|
| | | </template>
|
| | | <template v-else-if="currentComponent === 'print'">
|
| | | <div class="display-settings">
|
| | | <h2>打印设置</h2>
|
| | | <div class="form-group">
|
| | | <label>是否打印版图</label>
|
| | | <div style="margin-left: 3px;"></div>
|
| | | <div class="radio-group">
|
| | | <input
|
| | | type="radio"
|
| | | id="printLayouts"
|
| | | value="0"
|
| | | v-model="settings.server.printLayouts"
|
| | | />
|
| | | <label for="printLayouts">是</label>
|
| | |
|
| | | <input
|
| | | type="radio"
|
| | | id="noPrintLayouts"
|
| | | value="1"
|
| | | v-model="settings.server.printLayouts"
|
| | | style="margin-left: 20px;"
|
| | | />
|
| | | <label for="noPrintLayouts">否</label>
|
| | | </div>
|
| | | </div>
|
| | | <div class="form-group">
|
| | | <label>是否打印报告</label>
|
| | | <div style="margin-left: 3px;"></div>
|
| | | <div class="radio-group">
|
| | | <input
|
| | | type="radio"
|
| | | id="printReport"
|
| | | value="0"
|
| | | v-model="settings.server.printReport"
|
| | | />
|
| | | <label for="printReport">是</label>
|
| | | <input
|
| | | type="radio"
|
| | | id="noPrintReport"
|
| | | value="1"
|
| | | v-model="settings.server.printReport"
|
| | | style="margin-left: 20px;"
|
| | | />
|
| | | <label for="noPrintReport">否</label>
|
| | | </div>
|
| | | </div>
|
| | | <div class="form-group">
|
| | | <label>布局选择</label>
|
| | | <select v-model="settings.server.layoutRows" class="cs" style="width: 10px; margin-right: 5px;">
|
| | | <option value="1">一行</option>
|
| | | <option value="2">两行</option>
|
| | | <option value="3">三行</option>
|
| | | <option value="4">四行</option>
|
| | | </select>
|
| | | <select v-model="settings.server.layoutColumns" class="cs" style="width: 10px;">
|
| | | <option value="1">一列</option>
|
| | | <option value="2">两列</option>
|
| | | </select>
|
| | | </div>
|
| | | <div class="form-group">
|
| | | <label>显示小片信息</label>
|
| | | <select v-model="settings.server.glassInfoShow" class="cs" style="width: 10px; margin-right: 10px;">
|
| | | <option value="0">不显示</option>
|
| | | <option value="1">显示在右侧</option>
|
| | | <option value="2">显示在下侧</option>
|
| | | </select>
|
| | | </div>
|
| | | <div class="form-group">
|
| | | <label>显示切割信息</label>
|
| | | <select v-model="settings.server.cutInfoShow" class="cs" style="width: 10px; margin-right: 10px;">
|
| | | <option value="0">不显示</option>
|
| | | <option value="1">显示</option>
|
| | | </select>
|
| | | </div>
|
| | | </div>
|
| | | </template>
|
| | |
| | | </div>
|
| | | </div>
|
| | | </template>
|
| | |
|
| | |
|
| | | </div>
|
| | |
|
| | | <button class="button" style="height: 40px;" @click="saveToDatabase">保存</button>
|
| | |
| | | |
| | | //点击查询 |
| | | const getWorkOrder = () => { |
| | | |
| | | gridOptions.loading = true |
| | | |
| | | request.post(`/processCard/selectAddProcess/${orderInfo.workOrderDate}`, filterData.value).then((res) => { |
| | | if (res.code == 200) { |
| | |
| | | xGrid.value.loadData(res.data.data) |
| | | orderInfo.workOrderDate = res.data.selectDate |
| | | gridOptions.loading = false |
| | | |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | gridOptions.loading = false |
| | | } |
| | | }) |
| | | } |
| | |
| | | }) |
| | | |
| | | const getFlowCardList = async () => { |
| | | gridOptions.loading = true |
| | | //第一次加载数据 |
| | | await request.post(`/processCard/flowCard/1/${total.pageSize}/${orderInfo.workOrderDate}`, filterData.value).then((res) => { |
| | | |
| | |
| | | } |
| | | }); |
| | | xGrid.value.loadData(produceList.value) |
| | | gridOptions.loading = false |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | gridOptions.loading = false |
| | | } |
| | | }) |
| | | } |
| | |
| | | }) |
| | | //页脚翻页查询 |
| | | const selectPageList = () => { |
| | | gridOptions.loading = true |
| | | request.post(`/processCard/flowCard/${pageNum.value}/${total.pageSize}/${orderInfo.workOrderDate}`, filterData.value).then((res) => { |
| | | if (res.code == 200) { |
| | | |
| | |
| | | } |
| | | }); |
| | | xGrid.value.loadData(produceList.value) |
| | | gridOptions.loading = false |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | gridOptions.loading = false |
| | | } |
| | | }) |
| | | } |
| | | |
| | | //点击查询 |
| | | const getWorkOrder = () => { |
| | | |
| | | gridOptions.loading = true |
| | | request.post(`/processCard/flowCard/${pageNum.value}/${total.pageSize}/${orderInfo.workOrderDate}`, filterData.value).then((res) => { |
| | | if (res.code == 200) { |
| | | total.dataTotal = res.data.total.total * 1 |
| | |
| | | gridOptions.loading = false |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | gridOptions.loading = false |
| | | } |
| | | }) |
| | | } |
| | |
| | | orderInfo.selectProcessCardFilter.data = filterData.value |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | gridOptions.loading = false |
| | | } |
| | | }) |
| | | } |
| | |
| | | //子组件接收参数 |
| | | |
| | | const gridOptions = reactive({ |
| | | loading: true, |
| | | border: "full",//表格加边框 |
| | | keepSource: true,//保持源数据 |
| | | align: 'center',//文字居中 |
| | |
| | | const getWorkOrder = () => { |
| | | let startTime = form.date1[0] |
| | | let endTime = form.date1[1] |
| | | gridOptions.loading=true |
| | | // 第一次加载查询 |
| | | request.post(`/Replenish/selectPrint/${startTime}/${endTime}`, filterData.value).then((res) => { |
| | | |
| | |
| | | gridOptions.loading=false |
| | | }else{ |
| | | ElMessage.warning(res.msg) |
| | | gridOptions.loading = false |
| | | } |
| | | }) |
| | | |
| | |
| | | //子组件接收参数 |
| | | const xGrid = ref() |
| | | const gridOptions = reactive({ |
| | | loading: true, |
| | | border: "full",//表格加边框 |
| | | keepSource: true,//保持源数据 |
| | | align: 'center',//文字居中 |
| | |
| | | |
| | | |
| | | const selectOrderList = ()=>{ |
| | | gridOptions.loading = true |
| | | request.post(`/Replenish/SelectReplenish/${pageNum.value}/${total.pageSize}/${selectDate.value}`,filterData.value).then((res) => { |
| | | if(res.code==200){ |
| | | console.log(res.data) |
| | | if (res.data.total!=null){ |
| | | total.dataTotal = res.data.total.total*1 |
| | | total.pageTotal= res.data.total.pageTotal |
| | |
| | | return `${year}-${month}-${day} 08:00:00`; |
| | | }; |
| | | |
| | | //计算时间差 |
| | | function getDaysBetween(startTime, endTime, includeEnd = false) { |
| | | const start = new Date(startTime) |
| | | const end = new Date(endTime) |
| | | |
| | | // 转为时间戳计算差值 |
| | | const diffMs = end.setHours(0, 0, 0, 0) - start.setHours(0, 0, 0, 0) |
| | | const diffDays = diffMs / (1000 * 60 * 60 * 24) |
| | | |
| | | // 返回整数天数 |
| | | return includeEnd ? diffDays + 1 : diffDays |
| | | } |
| | | |
| | | const now = new Date(); |
| | | const startDate = new Date(now.getTime() - 3600 * 1000 * 24 * 3); // 三天前 |
| | |
| | | |
| | | return [start, end]; |
| | | } |
| | | |
| | | //计算时间差 |
| | | function getDaysBetween(startTime, endTime, includeEnd = false) { |
| | | const start = new Date(startTime) |
| | | const end = new Date(endTime) |
| | | |
| | | // 转为时间戳计算差值 |
| | | const diffMs = end.setHours(0, 0, 0, 0) - start.setHours(0, 0, 0, 0) |
| | | const diffDays = diffMs / (1000 * 60 * 60 * 24) |
| | | |
| | | // 返回整数天数 |
| | | return includeEnd ? diffDays + 1 : diffDays |
| | | } |
| | | |
| | | |
| | | |
| | | //第一次加载获取近七天时间和默认状态 |
| | |
| | | |
| | | //页脚翻页查询 |
| | | const selectPageList = () => { |
| | | gridOptions.loading = true |
| | | const rawStart = new Date(form.date1[0]); |
| | | const rawEnd = new Date(form.date1[1]); |
| | | // 如果时间部分是 00:00,则设置为 08:00 |
| | |
| | | total.value = res.data.footSum |
| | | produceList = deepClone(res.data.data) |
| | | xGrid.value.reloadData(produceList) |
| | | gridOptions.loading = false |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | } |
| | |
| | | }) |
| | | |
| | | function exportExcel(url, fileName,date) { |
| | | gridOptions.loading = true |
| | | if(date===null){ |
| | | ElMessage.warning(t('report.pleaseSelectADateFirst')) |
| | | return |
| | |
| | | elink.click() |
| | | URL.revokeObjectURL(elink.href) // 释放URL 对象 |
| | | document.body.removeChild(elink) |
| | | gridOptions.loading = false |
| | | } else { // IE10+下载 |
| | | navigator.msSaveBlob(blob, fileName) |
| | | } |
| | |
| | | ElMessage.warning(t('report.pleaseSelectAProcessFirst')) |
| | | return |
| | | } |
| | | |
| | | gridOptions.loading = true |
| | | const date1 = new Date(date[0]); |
| | | const date2 = new Date(date[1]); |
| | | const timeDiff = Math.abs(date2.getTime() - date1.getTime()); |
| | |
| | | elink.click() |
| | | URL.revokeObjectURL(elink.href) // 释放URL 对象 |
| | | document.body.removeChild(elink) |
| | | gridOptions.loading = false |
| | | } else { // IE10+下载 |
| | | navigator.msSaveBlob(blob, fileName) |
| | | } |
| | |
| | | ElMessage.warning(t('report.pleaseSelectAProcessFirst')) |
| | | return |
| | | } |
| | | |
| | | gridOptions.loading = true |
| | | const date1 = new Date(date[0]); |
| | | const date2 = new Date(date[1]); |
| | | const timeDiff = Math.abs(date2.getTime() - date1.getTime()); |
| | |
| | | elink.click() |
| | | URL.revokeObjectURL(elink.href) // 释放URL 对象 |
| | | document.body.removeChild(elink) |
| | | gridOptions.loading = false |
| | | } else { // IE10+下载 |
| | | navigator.msSaveBlob(blob, fileName) |
| | | } |
| | |
| | | }) |
| | | |
| | | function exportExcel(url, fileName,date) { |
| | | gridOptions.loading = true |
| | | let processes = procseeValue.value |
| | | if(date===null){ |
| | | ElMessage.warning(t('report.pleaseSelectADateFirst')) |
| | |
| | | elink.click() |
| | | URL.revokeObjectURL(elink.href) // 释放URL 对象 |
| | | document.body.removeChild(elink) |
| | | gridOptions.loading = false |
| | | } else { // IE10+下载 |
| | | navigator.msSaveBlob(blob, fileName) |
| | | } |
| | |
| | | optionVal = null |
| | | } |
| | | //第一次加载数据 |
| | | request.post(`/report/workInProgress/1/${total.pageSize}/${inputVal}/${inputProject}/${selectProcesses}/${optionVal}`, filterData.value).then((res) => { |
| | | request.post(`/report/workInProgressCombinationProcess/1/${total.pageSize}/${inputVal}/${inputProject}/${selectProcesses}/${optionVal}`, filterData.value).then((res) => { |
| | | |
| | | if (res.code == 200) { |
| | | total.dataTotal = res.data.total.total*1 |
| | | total.pageTotal= res.data.total.pageTotal |
| | | pageTotal.value = res.data.total |
| | | // total.dataTotal = res.data.total.total*1 |
| | | // total.pageTotal= res.data.total.pageTotal |
| | | // pageTotal.value = res.data.total |
| | | total.value = res.data.total |
| | | produceList = produceList.value.concat(deepClone(res.data.data)) |
| | | //produceList = produceList.value.concat(deepClone(res.data.data)) |
| | | titleSelectJson.value.processType = res.data.process |
| | | titleSelectJson.value.processType.splice(0,1) |
| | | //xGrid.value.reloadData(produceList) |
| | |
| | | ElMessage.warning(t('report.pleaseSelectAProcessFirst')) |
| | | return |
| | | } |
| | | |
| | | gridOptions.loading = true |
| | | const date1 = new Date(date[0]); |
| | | const date2 = new Date(date[1]); |
| | | const timeDiff = Math.abs(date2.getTime() - date1.getTime()); |
| | |
| | | elink.click() |
| | | URL.revokeObjectURL(elink.href) // 释放URL 对象 |
| | | document.body.removeChild(elink) |
| | | gridOptions.loading = false |
| | | } else { // IE10+下载 |
| | | navigator.msSaveBlob(blob, fileName) |
| | | } |
| | |
| | | } |
| | | |
| | | function exportExcel(url, fileName,date) { |
| | | |
| | | let processes = value.value |
| | | let inputVal = form.orderId |
| | | if (inputVal == '') { |
| | |
| | | ElMessage.warning(t('report.pleaseSelectADateFirst')) |
| | | return |
| | | } |
| | | |
| | | gridOptions.loading = true |
| | | if(processes===null){ |
| | | ElMessage.warning(t('report.pleaseSelectAProcessFirst')) |
| | | return |
| | |
| | | elink.click() |
| | | URL.revokeObjectURL(elink.href) // 释放URL 对象 |
| | | document.body.removeChild(elink) |
| | | gridOptions.loading = false |
| | | } else { // IE10+下载 |
| | | navigator.msSaveBlob(blob, fileName) |
| | | } |
| | |
| | | //route.query.reportingWorkId = 'BG2403150004' |
| | | //判断是否传入报工编号 |
| | | if(route.query.reportingWorkId !== '' && route.query.reportingWorkId!=null){ |
| | | gridOptions.loading = true |
| | | request.post(`reportingWork/selectUpdateReportingWork/${route.query.reportingWorkId}`).then(res=>{ |
| | | if(res.code === '200'){ |
| | | titleUploadData.value = res.data.reportingWork |
| | |
| | | } |
| | | } |
| | | // getQuantity() |
| | | gridOptions.loading = false |
| | | inputDisabled.value = true |
| | | }) |
| | | } |
| | |
| | | |
| | | //点击查询 |
| | | const getWorkOrder = () => { |
| | | |
| | | gridOptions.loading = true |
| | | let selectState = optionVal.value |
| | | request.post(`/workOrder/orderGlassDetail/${orderInfo.workOrderDate}/${selectState}`, filterData.value).then((res) => { |
| | | if (res.code == 200) { |
| | |
| | | gridOptions.loading = false |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | gridOptions.loading = false |
| | | } |
| | | }) |
| | | } |
| New file |
| | |
| | | package com.example.erp.common; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PreDestroy; |
| | | import java.util.concurrent.*; |
| | | |
| | | /** |
| | | * 全局异步查询执行器 |
| | | * 统一管理线程池,支持在多个 Service 并行执行 SQL 查询任务 |
| | | */ |
| | | @Component |
| | | public class AsyncQueryExecutor { |
| | | |
| | | // 全局可复用线程池 |
| | | private final ExecutorService executorService = new ThreadPoolExecutor( |
| | | 16, // 核心线程数 |
| | | 32, // 最大线程数 |
| | | 60L, TimeUnit.SECONDS, // 空闲线程存活时间 |
| | | new LinkedBlockingQueue<>(500), // 阻塞队列容量 |
| | | new ThreadFactory() { |
| | | private final ThreadFactory defaultFactory = Executors.defaultThreadFactory(); |
| | | private int counter = 1; |
| | | |
| | | @Override |
| | | public Thread newThread(Runnable r) { |
| | | Thread thread = defaultFactory.newThread(r); |
| | | thread.setName("async-query-pool-" + counter++); |
| | | thread.setDaemon(true); |
| | | return thread; |
| | | } |
| | | }, |
| | | new ThreadPoolExecutor.CallerRunsPolicy() // 队列满时主线程执行,防止丢任务 |
| | | ); |
| | | |
| | | /** |
| | | * 异步执行任务 |
| | | * @param supplier 要执行的函数(返回任意类型) |
| | | * @param <T> 返回类型 |
| | | * @return CompletableFuture<T> |
| | | */ |
| | | public <T> CompletableFuture<T> runAsync(SupplierWithException<T> supplier) { |
| | | return CompletableFuture.supplyAsync(() -> { |
| | | try { |
| | | return supplier.get(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("异步任务执行异常: " + e.getMessage(), e); |
| | | } |
| | | }, executorService); |
| | | } |
| | | |
| | | /** |
| | | * 应用关闭时安全关闭线程池 |
| | | */ |
| | | @PreDestroy |
| | | public void shutdown() { |
| | | executorService.shutdown(); |
| | | try { |
| | | if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) { |
| | | executorService.shutdownNow(); |
| | | } |
| | | } catch (InterruptedException e) { |
| | | executorService.shutdownNow(); |
| | | Thread.currentThread().interrupt(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 自定义函数式接口,允许抛出受检异常 |
| | | */ |
| | | @FunctionalInterface |
| | | public interface SupplierWithException<T> { |
| | | T get() throws Exception; |
| | | } |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.example.erp.common.AsyncQueryExecutor; |
| | | import com.example.erp.dto.pp.PatchLogAddDTO; |
| | | import com.example.erp.dto.pp.PatchLogDTO; |
| | | import com.example.erp.entity.pp.FlowCard; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import javax.annotation.PreDestroy; |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | |
| | | |
| | | @Service |
| | |
| | | |
| | | final LogService logService; |
| | | |
| | | //多线程池 |
| | | @Resource |
| | | private AsyncQueryExecutor asyncExecutor; |
| | | |
| | | public ReplenishService(PatchLogMapper patchMapper, SysErrorService sysErrorService, ReportingWorkMapper reportingWorkMapper,FlowCardMapper flowCardMapper,LogService logService) { |
| | | this.patchMapper = patchMapper; |
| | | this.sysErrorService = sysErrorService; |
| | |
| | | |
| | | } |
| | | |
| | | public Map<String, Object> SelectReplenish(Integer pageNum, Integer pageSize, List<String> selectDate, PatchLogDTO patchLogDTO) { |
| | | Integer offset = (pageNum-1)*pageSize; |
| | | // public Map<String, Object> SelectReplenish(Integer pageNum, Integer pageSize, List<String> selectDate, PatchLogDTO patchLogDTO) { |
| | | // Integer offset = (pageNum-1)*pageSize; |
| | | // String endDate = LocalDate.now().toString(); |
| | | // String startDate = LocalDate.now().minusDays(15).toString(); |
| | | // if(selectDate !=null && selectDate.size()==2){ |
| | | // if(!selectDate.get(0).isEmpty()){ |
| | | // startDate = selectDate.get(0); |
| | | // } |
| | | // if(!selectDate.get(1).isEmpty()){ |
| | | // endDate = selectDate.get(1); |
| | | // } |
| | | // } |
| | | // Map<String,Object> map = new HashMap<>(); |
| | | // map.put("data",patchMapper.SelectReplenish(offset,pageSize,startDate,endDate,patchLogDTO)); |
| | | // map.put("total",patchMapper.SelectReplenishPageTotal(offset,pageSize,startDate,endDate,patchLogDTO)); |
| | | // |
| | | // List<String> list = new ArrayList<>(); |
| | | // list.add(startDate); |
| | | // list.add(endDate); |
| | | // map.put("selectDate",list); |
| | | // return map; |
| | | // } |
| | | |
| | | public Map<String, Object> SelectReplenish( |
| | | Integer pageNum, Integer pageSize, |
| | | List<String> selectDate, PatchLogDTO patchLogDTO) { |
| | | |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | |
| | | // 默认时间范围:过去15天 |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | |
| | | // 用户自定义时间段 |
| | | if (selectDate != null && selectDate.size() == 2) { |
| | | if (!selectDate.get(0).isEmpty()) { |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | if (!selectDate.get(1).isEmpty()) { |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("data",patchMapper.SelectReplenish(offset,pageSize,startDate,endDate,patchLogDTO)); |
| | | map.put("total",patchMapper.SelectReplenishPageTotal(offset,pageSize,startDate,endDate,patchLogDTO)); |
| | | |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | Map<String, Object> result = new HashMap<>(); |
| | | |
| | | try { |
| | | // 使用线程池并行执行两个SQL |
| | | String finalStartDate = startDate; |
| | | String finalEndDate = endDate; |
| | | CompletableFuture<List<PatchLogDTO>> dataFuture = |
| | | asyncExecutor.runAsync(() -> |
| | | patchMapper.SelectReplenish(offset, pageSize, finalStartDate, finalEndDate, patchLogDTO)); |
| | | |
| | | CompletableFuture<Map<String, Integer>> totalFuture = |
| | | asyncExecutor.runAsync(() -> |
| | | patchMapper.SelectReplenishPageTotal(offset, pageSize, finalStartDate, finalEndDate, patchLogDTO)); |
| | | |
| | | // 等待两个任务都完成 |
| | | CompletableFuture.allOf(dataFuture, totalFuture).join(); |
| | | |
| | | result.put("data", dataFuture.get()); |
| | | result.put("total", totalFuture.get()); |
| | | |
| | | // 返回时间段 |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | result.put("selectDate", list); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("并行查询补片记录异常:" + e.getMessage(), e); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | public Boolean saveReplenish(Map<String,Object> object) { |
| | | boolean saveState = true; |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.example.erp.common.AsyncQueryExecutor; |
| | | import com.example.erp.tools.AreaComputed.*; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.PreDestroy; |
| | | import javax.annotation.Resource; |
| | | import java.lang.reflect.Field; |
| | | import java.math.BigDecimal; |
| | | import java.sql.Date; |
| | |
| | | FlowCardMapper flowCardMapper; |
| | | private ReportingWorkMapper reportingWorkMapper; |
| | | |
| | | private static final ExecutorService EXECUTOR = new ThreadPoolExecutor( |
| | | 4, 8, 60L, TimeUnit.SECONDS, |
| | | new LinkedBlockingQueue<>(100), |
| | | new ThreadFactory() { |
| | | private final ThreadFactory defaultFactory = Executors.defaultThreadFactory(); |
| | | private int counter = 1; |
| | | @Resource |
| | | private AsyncQueryExecutor asyncExecutor; |
| | | |
| | | @Override |
| | | public Thread newThread(Runnable r) { |
| | | Thread thread = defaultFactory.newThread(r); |
| | | thread.setName("damage-report-query-" + counter++); |
| | | thread.setDaemon(true); |
| | | return thread; |
| | | } |
| | | }, |
| | | new ThreadPoolExecutor.CallerRunsPolicy() |
| | | ); |
| | | |
| | | //上工序报工班组 |
| | | private void mergeTeamsGroupsName( List<WorkInProgressDTO> dataList1,List<WorkInProgressDTO> dataList2) { |
| | |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> crossProcessBreakingSv(Integer pageNum, Integer pageSize, List<String> selectDate, CrossProcessBreakingDTO crossProcessBreakingDTO) { |
| | | // public Map<String, Object> crossProcessBreakingSv(Integer pageNum, Integer pageSize, List<String> selectDate, CrossProcessBreakingDTO crossProcessBreakingDTO) { |
| | | // Integer offset = (pageNum - 1) * pageSize; |
| | | // String endDate = LocalDate.now().toString(); |
| | | // String startDate = LocalDate.now().minusDays(15).toString(); |
| | | // if (selectDate != null && selectDate.size() == 2) { |
| | | // if (!selectDate.get(0).isEmpty()) { |
| | | // startDate = selectDate.get(0); |
| | | // } |
| | | // if (!selectDate.get(1).isEmpty()) { |
| | | // endDate = selectDate.get(1); |
| | | // } |
| | | // } |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // map.put("data", reportMapper.getProcessBreaking(offset, pageSize, startDate, endDate, crossProcessBreakingDTO)); |
| | | // map.put("total", reportMapper.getProcessBreakingTotal(offset, pageSize, startDate, endDate, crossProcessBreakingDTO)); |
| | | // List<String> list = new ArrayList<>(); |
| | | // list.add(startDate); |
| | | // list.add(endDate); |
| | | // map.put("selectDate", list); |
| | | // return map; |
| | | // } |
| | | |
| | | public Map<String, Object> crossProcessBreakingSv(Integer pageNum, Integer pageSize, |
| | | List<String> selectDate, |
| | | CrossProcessBreakingDTO crossProcessBreakingDTO) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | |
| | | // 默认时间范围:过去 15 天 |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | |
| | | if (selectDate != null && selectDate.size() == 2) { |
| | | if (!selectDate.get(0).isEmpty()) { |
| | | startDate = selectDate.get(0); |
| | |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", reportMapper.getProcessBreaking(offset, pageSize, startDate, endDate, crossProcessBreakingDTO)); |
| | | map.put("total", reportMapper.getProcessBreakingTotal(offset, pageSize, startDate, endDate, crossProcessBreakingDTO)); |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | |
| | | // 使用异步线程池 |
| | | String finalEndDate = endDate; |
| | | String finalStartDate = startDate; |
| | | CompletableFuture<List<CrossProcessBreakingDTO>> dataFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.getProcessBreaking(offset, pageSize, finalStartDate, finalEndDate, crossProcessBreakingDTO)); |
| | | |
| | | CompletableFuture<Map<String, Integer>> totalFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.getProcessBreakingTotal(offset, pageSize, finalStartDate, finalEndDate, crossProcessBreakingDTO)); |
| | | |
| | | // 等待两个任务执行完毕 |
| | | CompletableFuture.allOf(dataFuture, totalFuture).join(); |
| | | |
| | | try { |
| | | result.put("data", dataFuture.get()); |
| | | result.put("total", totalFuture.get()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("并行查询异常:" + e.getMessage(), e); |
| | | } |
| | | |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate", list); |
| | | return map; |
| | | result.put("selectDate", list); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | public Map<String, Object> workInProgressSv(Integer pageNum, Integer pageSize, String orderId, String inputProject, String selectProcesses, String optionVal, WorkInProgressDTO workInProgressDTO) { |
| | | // public Map<String, Object> workInProgressSv(Integer pageNum, Integer pageSize, String orderId, String inputProject, String selectProcesses, String optionVal, WorkInProgressDTO workInProgressDTO) { |
| | | // Integer offset = (pageNum - 1) * pageSize; |
| | | // if ("null".equals(orderId)) { |
| | | // orderId = ""; |
| | | // } |
| | | // if ("null".equals(inputProject)) { |
| | | // inputProject = ""; |
| | | // } |
| | | // if ("null".equals(optionVal)) { |
| | | // optionVal = (""); |
| | | // } |
| | | // if (selectProcesses.equals("all")){ |
| | | // selectProcesses=""; |
| | | // } |
| | | // String laminating = reportMapper.getLaminating(selectProcesses); |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // List<WorkInProgressDTO> dataList2 =reportMapper.workInProgressMpdataList2(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); |
| | | // if (optionVal.equals("1")){ |
| | | // /* 根据销售单号汇总*/ |
| | | // List<WorkInProgressDTO> dataList1 =reportMapper.workInProgressOrderMpList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); |
| | | // mergeTeamsGroupsName(dataList1, dataList2); |
| | | // map.put("data",dataList1); |
| | | // map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | // }else if(optionVal.equals("2")){ |
| | | // /* 根据流程卡号汇总*/ |
| | | // List<WorkInProgressDTO> dataList1 =reportMapper.workInProgressProcessMpList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); |
| | | // mergeTeamsGroupsName(dataList1, dataList2); |
| | | // map.put("data",dataList1); |
| | | // map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | // |
| | | // } else if (optionVal.equals("3")) { |
| | | // |
| | | // } else { |
| | | // //没有选择分组 |
| | | // List<WorkInProgressDTO> dataList1 =reportMapper.workInProgressMpdataList1(offset, pageSize, orderId, inputProject, selectProcesses,laminating, workInProgressDTO); |
| | | // mergeTeamsGroupsName(dataList1, dataList2); |
| | | // map.put("data",dataList1); |
| | | // map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | // |
| | | // } |
| | | // map.put("process", productionSchedulingMapper.selectProcess()); |
| | | // return map; |
| | | // } |
| | | |
| | | public Map<String, Object> workInProgressSv( |
| | | Integer pageNum, Integer pageSize, |
| | | String orderId, String inputProject, String selectProcesses, |
| | | String optionVal, WorkInProgressDTO workInProgressDTO) { |
| | | |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | if ("null".equals(orderId)) { |
| | | orderId = ""; |
| | | } |
| | | if ("null".equals(inputProject)) { |
| | | inputProject = ""; |
| | | } |
| | | if ("null".equals(optionVal)) { |
| | | optionVal = (""); |
| | | } |
| | | if (selectProcesses.equals("all")){ |
| | | selectProcesses=""; |
| | | } |
| | | |
| | | if ("null".equals(orderId)) orderId = ""; |
| | | if ("null".equals(inputProject)) inputProject = ""; |
| | | if ("null".equals(optionVal)) optionVal = ""; |
| | | if ("all".equals(selectProcesses)) selectProcesses = ""; |
| | | |
| | | String laminating = reportMapper.getLaminating(selectProcesses); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<WorkInProgressDTO> dataList2 =reportMapper.workInProgressMpdataList2(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); |
| | | if (optionVal.equals("1")){ |
| | | /* 根据销售单号汇总*/ |
| | | //map.put("data", reportMapper.workInProgressOrderMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | List<WorkInProgressDTO> dataList1 =reportMapper.workInProgressOrderMpList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); |
| | | mergeTeamsGroupsName(dataList1, dataList2); |
| | | map.put("data",dataList1); |
| | | // map.put("total", reportMapper.workInProgressOrderTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | }else if(optionVal.equals("2")){ |
| | | /* 根据流程卡号汇总*/ |
| | | //map.put("data", reportMapper.workInProgressProcessMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | List<WorkInProgressDTO> dataList1 =reportMapper.workInProgressProcessMpList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); |
| | | mergeTeamsGroupsName(dataList1, dataList2); |
| | | map.put("data",dataList1); |
| | | // map.put("total", reportMapper.workInProgressProcessTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | Map<String, Object> result = new HashMap<>(); |
| | | |
| | | } else if (optionVal.equals("3")) { |
| | | try { |
| | | // dataList2 是所有分组下的基础数据,独立执行 |
| | | String finalOrderId = orderId; |
| | | String finalInputProject = inputProject; |
| | | String finalSelectProcesses = selectProcesses; |
| | | CompletableFuture<List<WorkInProgressDTO>> dataList2Future = |
| | | asyncExecutor.runAsync(() -> |
| | | reportMapper.workInProgressMpdataList2( |
| | | offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, workInProgressDTO)); |
| | | |
| | | } else { |
| | | //没有选择分组 |
| | | //map.put("data", reportMapper.workInProgressMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | List<WorkInProgressDTO> dataList1 =reportMapper.workInProgressMpdataList1(offset, pageSize, orderId, inputProject, selectProcesses,laminating, workInProgressDTO); |
| | | CompletableFuture<List<WorkInProgressDTO>> dataList1Future; |
| | | CompletableFuture<Map<String, Float>> totalFuture; |
| | | |
| | | // 根据 optionVal 决定查询类型 |
| | | if ("1".equals(optionVal)) { |
| | | // 销售单号汇总 |
| | | dataList1Future = asyncExecutor.runAsync(() -> |
| | | reportMapper.workInProgressOrderMpList1( |
| | | offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, workInProgressDTO)); |
| | | |
| | | totalFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.workInProgressOrderFootSum( |
| | | offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, workInProgressDTO)); |
| | | |
| | | } else if ("2".equals(optionVal)) { |
| | | // 流程卡号汇总 |
| | | dataList1Future = asyncExecutor.runAsync(() -> |
| | | reportMapper.workInProgressProcessMpList1( |
| | | offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, workInProgressDTO)); |
| | | |
| | | totalFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.workInProgressOrderFootSum( |
| | | offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, workInProgressDTO)); |
| | | |
| | | } else if ("3".equals(optionVal)) { |
| | | dataList1Future = asyncExecutor.runAsync(() -> |
| | | reportMapper.workInProgressMpdataList1( |
| | | offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, laminating, workInProgressDTO)); |
| | | totalFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.workInProgressOrderFootSum( |
| | | offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, workInProgressDTO)); |
| | | |
| | | } else { |
| | | // 不分组 |
| | | dataList1Future = asyncExecutor.runAsync(() -> |
| | | reportMapper.workInProgressMpdataList1( |
| | | offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, laminating, workInProgressDTO)); |
| | | |
| | | totalFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.workInProgressOrderFootSum( |
| | | offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, workInProgressDTO)); |
| | | } |
| | | |
| | | // 等待全部任务完成 |
| | | CompletableFuture.allOf(dataList1Future, dataList2Future, totalFuture).join(); |
| | | |
| | | List<WorkInProgressDTO> dataList1 = dataList1Future.get(); |
| | | List<WorkInProgressDTO> dataList2 = dataList2Future.get(); |
| | | mergeTeamsGroupsName(dataList1, dataList2); |
| | | map.put("data",dataList1); |
| | | //map.put("total", reportMapper.workInProgressTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO)); |
| | | |
| | | result.put("data", dataList1); |
| | | result.put("total", totalFuture.get()); |
| | | |
| | | // 并行查询工序信息 |
| | | List<Map<String, String>> process = productionSchedulingMapper.selectProcess(); |
| | | result.put("process", process); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("并行查询在制品信息异常:" + e.getMessage(), e); |
| | | } |
| | | map.put("process", productionSchedulingMapper.selectProcess()); |
| | | return map; |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | public Map<String, Object> selectProcessToBeCompletedSv(Date selectTime1, Date selectTime2, String orderId, String inputProject, String selectProcesses, Report report) { |
| | | if ("null".equals(orderId)) { |
| | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | |
| | | // 异步任务定义 |
| | | CompletableFuture<List<DamageReportDTO>> dataFuture = CompletableFuture.supplyAsync(() -> |
| | | reportMapper.selectDamageReportMp(offset, pageSize, selectTime1, selectTime2, damageReportDTO), EXECUTOR); |
| | | |
| | | CompletableFuture<Map<String, Integer>> totalFuture = CompletableFuture.supplyAsync(() -> |
| | | reportMapper.getDamageReportPageTotal(offset, pageSize, selectTime1, selectTime2, damageReportDTO), EXECUTOR); |
| | | CompletableFuture<List<DamageReportDTO>> dataFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.selectDamageReportMp(offset, pageSize, selectTime1, selectTime2, damageReportDTO)); |
| | | |
| | | CompletableFuture<Map<String, Float>> footSumFuture = CompletableFuture.supplyAsync(() -> |
| | | reportMapper.damageReportFootSum(selectTime1, selectTime2, damageReportDTO), EXECUTOR); |
| | | CompletableFuture<Map<String, Integer>> totalFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.getDamageReportPageTotal(offset, pageSize, selectTime1, selectTime2, damageReportDTO)); |
| | | |
| | | CompletableFuture<Map<String, Float>> footSumFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.damageReportFootSum(selectTime1, selectTime2, damageReportDTO)); |
| | | |
| | | //等待全部任务完成 |
| | | CompletableFuture.allOf(dataFuture, totalFuture, footSumFuture).join(); |
| | | |
| | | try { |
| | | //等待全部任务完成 |
| | | CompletableFuture.allOf(dataFuture, totalFuture, footSumFuture).join(); |
| | | |
| | | result.put("data", dataFuture.get()); |
| | | result.put("total", totalFuture.get()); |
| | | result.put("footSum", footSumFuture.get()); |
| | |
| | | |
| | | String laminating = reportMapper.getLaminating(selectProcesses); |
| | | |
| | | // 并行执行四个查询任务 |
| | | String finalSelectProcesses = selectProcesses; |
| | | CompletableFuture<List<TeamOutputDTO>> dataFuture = CompletableFuture.supplyAsync(() -> |
| | | reportMapper.teamOutputMp(offset, pageSize, selectTime1, selectTime2, finalSelectProcesses, laminating, teamOutputDTO), EXECUTOR); |
| | | CompletableFuture<List<TeamOutputDTO>> dataFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.teamOutputMp(offset, pageSize, selectTime1, selectTime2, finalSelectProcesses, laminating, teamOutputDTO)); |
| | | |
| | | CompletableFuture<List<Map<String, String>>> processFuture = CompletableFuture.supplyAsync(() -> |
| | | productionSchedulingMapper.selectProcess(), EXECUTOR); |
| | | CompletableFuture<List<Map<String, String>>> processFuture = asyncExecutor.runAsync(() -> |
| | | productionSchedulingMapper.selectProcess()); |
| | | |
| | | CompletableFuture<Map<String, Integer>> totalFuture = CompletableFuture.supplyAsync(() -> |
| | | reportMapper.teamOutputPageTotal(offset, pageSize, selectTime1, selectTime2, finalSelectProcesses, laminating, teamOutputDTO), EXECUTOR); |
| | | CompletableFuture<Map<String, Integer>> totalFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.teamOutputPageTotal(offset, pageSize, selectTime1, selectTime2, finalSelectProcesses, laminating, teamOutputDTO)); |
| | | |
| | | CompletableFuture<Map<String, Float>> footSumFuture = CompletableFuture.supplyAsync(() -> |
| | | reportMapper.teamOutputFootSum(selectTime1, selectTime2, finalSelectProcesses, laminating, teamOutputDTO), EXECUTOR); |
| | | |
| | | CompletableFuture<Map<String, Float>> footSumFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.teamOutputFootSum(selectTime1, selectTime2, finalSelectProcesses, laminating, teamOutputDTO)); |
| | | |
| | | // 等待所有任务完成 |
| | | CompletableFuture.allOf(dataFuture, processFuture, totalFuture, footSumFuture).join(); |
| | | |
| | | try { |
| | | // 等待全部任务执行完毕 |
| | | CompletableFuture.allOf(dataFuture, processFuture, totalFuture, footSumFuture).join(); |
| | | |
| | | result.put("data", dataFuture.get()); |
| | | result.put("process", processFuture.get()); |
| | | result.put("total", totalFuture.get()); |
| | | result.put("footSum", footSumFuture.get()); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("并行查询异常:" + e.getMessage(), e); |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.example.erp.common.AsyncQueryExecutor; |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.dto.pp.OrderNumberTransferDTO; |
| | | import com.example.erp.entity.pp.*; |
| | |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | |
| | | import javax.annotation.PreDestroy; |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | |
| | | @Service |
| | | @DS("pp") |
| | |
| | | private final BasicDataMapper basicDataMapper; |
| | | private final FinishedGoodsInventoryService finishedGoodsInventoryService; |
| | | |
| | | |
| | | @Resource |
| | | private AsyncQueryExecutor asyncExecutor; |
| | | /*public ReportingWorkService(ReportingWorkMapper reportingWorkMapper, BasicDateProduceMapper basicDateProduceMapper, DamageDetailsMapper damageDetailsMapper, ReportingWorkDetailMapper reportingWorkDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, OrderProcessDetailService orderProcessDetailService, OrderMapper orderMapper, FlowCardMapper flowCardMapper, LogService logService, LogMapper logMapper, OrderGlassDetailMapper orderGlassDetailMapper, SysErrorService sysErrorService, OrderDetailMapper orderDetailMapper, FinishedOperateLogMapper finishedOperateLogMapper, ReportingWorkTransferMapper reportingWorkTransferMapper) { |
| | | this.reportingWorkMapper = reportingWorkMapper; |
| | | this.basicDateProduceMapper = basicDateProduceMapper; |
| | |
| | | } |
| | | |
| | | //报工管理查询 |
| | | public Map<String, Object> selectReportingWorkSv(Integer pageNum, Integer pageSize, List<String> selectDate, String orderId, ReportingWork reportingWork) { |
| | | // public Map<String, Object> selectReportingWorkSv(Integer pageNum, Integer pageSize, List<String> selectDate, String orderId, ReportingWork reportingWork) { |
| | | // Integer offset = (pageNum - 1) * pageSize; |
| | | // if ("null".equals(orderId)) { |
| | | // orderId = ""; |
| | | // } |
| | | // String endDate = LocalDate.now().toString(); |
| | | // String startDate = LocalDate.now().minusDays(3).toString(); |
| | | // if(selectDate !=null && selectDate.size()==2){ |
| | | // if(!selectDate.get(0).isEmpty()){ |
| | | // startDate = selectDate.get(0); |
| | | // } |
| | | // if(!selectDate.get(1).isEmpty()){ |
| | | // endDate = selectDate.get(1); |
| | | // } |
| | | // } |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // map.put("data", reportingWorkMapper.selectReportingWorkMp(offset, pageSize, startDate, endDate, orderId, reportingWork)); |
| | | // map.put("total" ,reportingWorkMapper.getFootSum(offset, pageSize, startDate, endDate, orderId, reportingWork)); |
| | | // List<String> list = new ArrayList<>(); |
| | | // list.add(startDate); |
| | | // list.add(endDate); |
| | | // map.put("selectDate",list); |
| | | // return map; |
| | | // } |
| | | |
| | | |
| | | public Map<String, Object> selectReportingWorkSv( |
| | | Integer pageNum, Integer pageSize, |
| | | List<String> selectDate, String orderId, |
| | | ReportingWork reportingWork) { |
| | | |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | |
| | | if ("null".equals(orderId)) { |
| | | orderId = ""; |
| | | } |
| | | |
| | | // 默认时间:最近 3 天 |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(3).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | |
| | | // 如果传入自定义日期 |
| | | if (selectDate != null && selectDate.size() == 2) { |
| | | if (!selectDate.get(0).isEmpty()) { |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | if (!selectDate.get(1).isEmpty()) { |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", reportingWorkMapper.selectReportingWorkMp(offset, pageSize, startDate, endDate, orderId, reportingWork)); |
| | | // map.put("total", reportingWorkMapper.getPageTotal(offset, pageSize, selectTime1, selectTime2, orderId, reportingWork)); |
| | | map.put("total" ,reportingWorkMapper.getFootSum(offset, pageSize, startDate, endDate, orderId, reportingWork)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | |
| | | try { |
| | | // 并行执行两条 SQL 查询 |
| | | String finalStartDate = startDate; |
| | | String finalEndDate = endDate; |
| | | String finalOrderId = orderId; |
| | | CompletableFuture<List<ReportingWork>> dataFuture = |
| | | asyncExecutor.runAsync(() -> |
| | | reportingWorkMapper.selectReportingWorkMp( |
| | | offset, pageSize, finalStartDate, finalEndDate, finalOrderId, reportingWork)); |
| | | |
| | | CompletableFuture<Map<String, Float>> totalFuture = |
| | | asyncExecutor.runAsync(() -> |
| | | reportingWorkMapper.getFootSum( |
| | | offset, pageSize, finalStartDate, finalEndDate, finalOrderId, reportingWork)); |
| | | |
| | | // 等待全部完成 |
| | | CompletableFuture.allOf(dataFuture, totalFuture).join(); |
| | | |
| | | result.put("data", dataFuture.get()); |
| | | result.put("total", totalFuture.get()); |
| | | |
| | | // 日期范围 |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | result.put("selectDate", list); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("并行查询报工记录异常:" + e.getMessage(), e); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | //删除报工 |
| | |
| | | from |
| | | sd.`order` as o left join sd.order_detail as od on o.order_id=od.order_id |
| | | left join sd.order_glass_detail as ogd on ogd.order_id=od.order_id and ogd.order_number=od.order_number |
| | | left join reporting_work as rw on rw.order_id=o.order_id |
| | | left join damage_details as dd on dd.reporting_work_id=rw.reporting_work_id and dd.order_number=ogd.order_number |
| | | left join pp.reporting_work as rw on rw.order_id=o.order_id |
| | | left join pp.damage_details as dd on dd.reporting_work_id=rw.reporting_work_id and dd.order_number=ogd.order_number |
| | | and dd.technology_number=ogd.technology_number |
| | | where date(rw.reporting_work_time) >= #{startDate} |
| | | and date(rw.reporting_work_time) <= #{endDate} |
| | |
| | | <select id="getProcessBreakingTotal"> |
| | | select CEILING(count(dd.id) / #{pageSize}) as 'pageTotal', |
| | | count(distinct dd.id) as 'total' |
| | | from damage_details as dd |
| | | left join reporting_work as rw |
| | | from pp.damage_details as dd |
| | | left join pp.reporting_work as rw |
| | | on rw.reporting_work_id = dd.reporting_work_id |
| | | left join sd.order as o |
| | | on rw.order_id = o.order_id |
| | |
| | | rwd.wornArea |
| | | # (IF(rw.reviewed_state = 0, '未审核', IF(rw.reviewed_state = 1, '审核通过', '审核不通过'))) as reviewed_state |
| | | from |
| | | reporting_work as rw |
| | | pp.reporting_work as rw |
| | | left join ( |
| | | SELECT cc.reporting_work_id,cc.goup,round(sum(cc.completedArea),2) as completedArea ,round(sum(cc.wornArea),2) as wornArea from (SELECT rwds.reporting_work_id, GROUP_CONCAT(distinct rwds.technology_number SEPARATOR '') as goup, |
| | | sum(rwds.child_width*rwds.child_height*completed_quantity/1000000)as completedArea, |
| | | sum(rwds.child_width*rwds.child_height*rwds.breakage_quantity/1000000) as wornArea from reporting_work_detail as rwds GROUP BY rwds.reporting_work_id,order_number ) as cc GROUP BY cc.reporting_work_id)as rwd on rw.reporting_work_id=rwd.reporting_work_id |
| | | sum(rwds.child_width*rwds.child_height*rwds.breakage_quantity/1000000) as wornArea from pp.reporting_work_detail as rwds GROUP BY rwds.reporting_work_id,order_number ) as cc GROUP BY cc.reporting_work_id)as rwd on rw.reporting_work_id=rwd.reporting_work_id |
| | | |
| | | left join sd.`order` as o on o.order_id=rw.order_id |
| | | where rw.reviewed_state != 2 |
| | |
| | | ROUND(SUM(rwd.wornArea), 2) AS wornArea, |
| | | CEILING(count(rw.reporting_work_id)/#{pageSize}) as 'pageTotal', |
| | | count(distinct rw.reporting_work_id) as 'total' |
| | | FROM reporting_work AS rw |
| | | FROM pp.reporting_work AS rw |
| | | LEFT JOIN |
| | | (SELECT cc.reporting_work_id,cc.goup,round(sum(cc.completedArea),2) as completedArea ,round(sum(cc.wornArea),2) as wornArea from (SELECT rwds.reporting_work_id, GROUP_CONCAT(distinct rwds.technology_number SEPARATOR '') as goup, |
| | | sum(rwds.child_width*rwds.child_height*completed_quantity/1000000)as completedArea, |
| | | sum(rwds.child_width*rwds.child_height*rwds.breakage_quantity/1000000) as wornArea from reporting_work_detail as rwds GROUP BY rwds.reporting_work_id,order_number ) as cc GROUP BY cc.reporting_work_id) |
| | | sum(rwds.child_width*rwds.child_height*rwds.breakage_quantity/1000000) as wornArea from pp.reporting_work_detail as rwds GROUP BY rwds.reporting_work_id,order_number ) as cc GROUP BY cc.reporting_work_id) |
| | | AS rwd |
| | | ON rw.reporting_work_id = rwd.reporting_work_id |
| | | /*LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = rw.order_id |