首页
关于
友链
推荐
肥啾解析
百度一下
肥啾GPT
Search
1
宝塔面板登录 phpMyAdmin 提示服务器和客户端上指示的HTTPS之间不匹配
269 阅读
2
Customer complaints evolve with in-car tech
188 阅读
3
JavaScript解析
153 阅读
4
内连接,左连接,右连接作用及区别
111 阅读
5
所谓关系
109 阅读
默认分类
网游架设
手机游戏
python
PHP
Mysql
VBA
C++
JAVASCRIPT
javascript基础
Oracle
生产管理
计划控制
ERP系统开发
APS排产
MES研究
考勤系统
CPA
财管
实务
经济法
战略
审计
税法
藏书架
古典名著
世界名著
编程秘籍
攻防渗透
经管书籍
大佬传经
风雅读物
考试相关
心情格言
拾玉良言
外文报刊
外刊随选
Facebook
Twitter
China Daily
软考
登录
Search
标签搜索
期刊读物
古文
何瑜明
累计撰写
160
篇文章
累计收到
154
条评论
首页
栏目
默认分类
网游架设
手机游戏
python
PHP
Mysql
VBA
C++
JAVASCRIPT
javascript基础
Oracle
生产管理
计划控制
ERP系统开发
APS排产
MES研究
考勤系统
CPA
财管
实务
经济法
战略
审计
税法
藏书架
古典名著
世界名著
编程秘籍
攻防渗透
经管书籍
大佬传经
风雅读物
考试相关
心情格言
拾玉良言
外文报刊
外刊随选
Facebook
Twitter
China Daily
软考
页面
关于
友链
推荐
肥啾解析
百度一下
肥啾GPT
搜索到
160
篇与
的结果
2025-03-26
排产代码优化备份
<!DOCTYPE html><meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>缺件排产优化工具</title> <script src="https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js"></script> <style> /* 保持原有样式不变 */ </style> <!-- 保持原有HTML结构不变 --> <script> // [之前的所有函数保持不变...] // 修改后的生成排产计划函数(优化版) function generateSchedule() { const btn = document.getElementById('generateBtn'); const loading = document.getElementById('loading'); btn.disabled = true; loading.style.display = 'inline'; setTimeout(() => { try { console.log("开始生成优化排产计划..."); // [之前的参数检查和数据验证保持不变...] const workers = parseInt(document.getElementById('workers').value) || 3; const productivity = parseInt(document.getElementById('productivity').value) || 70; const startDateStr = document.getElementById('startDate').value; const dailyCapacity = workers * productivity; // 1. 按交付日期升序排序(最早交付的优先) const sortedData = [...rawData].sort((a, b) => { return new Date(a.deliveryDate) - new Date(b.deliveryDate); }); // 2. 计算每个项目的最晚开始日期(交付日期前一天) const itemsWithDeadline = sortedData.map(item => { const deadline = new Date(item.deliveryDate); deadline.setDate(deadline.getDate() - 1); // 交付前一天 return { ...item, deadline: deadline, productionDays: Math.ceil(item.quantity / dailyCapacity) }; }); // 3. 初始化排产计划 scheduleData = []; warningData = []; let currentDate = new Date(startDateStr); let dailyRemaining = dailyCapacity; // 4. 优化排产算法 - 尽可能在截止日期前完成 for (const item of itemsWithDeadline) { let productionDate = new Date(currentDate); let quantityRemaining = item.quantity; let isLate = false; // 计算最合理的开始生产日期 // 尝试从截止日期倒推需要的生产天数 const requiredDays = Math.ceil(item.quantity / dailyCapacity); let idealStartDate = new Date(item.deadline); idealStartDate.setDate(idealStartDate.getDate() - requiredDays + 1); // 如果理想开始日期比当前日期早,就从当前日期开始 if (idealStartDate < currentDate) { idealStartDate = new Date(currentDate); } productionDate = new Date(idealStartDate); // 分配生产日期 while (quantityRemaining > 0) { if (dailyRemaining === 0) { // 转到下一天 productionDate.setDate(productionDate.getDate() + 1); dailyRemaining = dailyCapacity; } const allocate = Math.min(quantityRemaining, dailyRemaining); // 检查是否超期 const currentIsLate = productionDate > item.deadline; isLate = isLate || currentIsLate; scheduleData.push({ productId: item.productId, quantity: allocate, deliveryDate: item.deliveryDate, productionDate: productionDate.toISOString().split('T')[0], isLate: currentIsLate }); quantityRemaining -= allocate; dailyRemaining -= allocate; } // 更新当前日期到最后生产日期的下一天 currentDate = new Date(productionDate); currentDate.setDate(currentDate.getDate() + 1); dailyRemaining = dailyCapacity; // 如果整个项目超期,添加到预警 if (isLate) { const lastProdDate = new Date( scheduleData.filter(x => x.productId === item.productId) .reduce((latest, curr) => new Date(curr.productionDate) > new Date(latest.productionDate) ? curr : latest ).productionDate ); const lateDays = Math.ceil( (new Date(lastProdDate) - new Date(item.deadline)) / (1000 * 60 * 60 * 24) ); warningData.push({ productId: item.productId, quantity: item.quantity, deliveryDate: item.deliveryDate, productionDate: lastProdDate, lateDays: lateDays }); } } // [保持原有的显示和摘要更新函数不变...] } catch (error) { console.error("生成排产计划时出错:", error); alert('生成排产计划时出错: ' + error.message); } finally { btn.disabled = false; loading.style.display = 'none'; } }, 100); } // [其余函数保持不变...] </script>
2025年03月26日
7 阅读
0 评论
0 点赞
2025-03-26
缺件排产代码备份
<!DOCTYPE html><meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>缺件排产</title> <script src="https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js"></script> <style> body { font-family: Arial, sans-serif; margin: 20px; line-height: 1.6; } .container { max-width: 1200px; margin: 0 auto; } h1, h2 { color: #333; } .section { margin-bottom: 30px; padding: 20px; border: 1px solid #ddd; border-radius: 5px; background-color: #f9f9f9; } table { width: 100%; border-collapse: collapse; margin-top: 15px; } th, td { border: 1px solid #ddd; padding: 8px; text-align: left; } th { background-color: #f2f2f2; } tr:nth-child(even) { background-color: #f9f9f9; } .warning { color: #d9534f; font-weight: bold; } .input-group { margin-bottom: 15px; } label { display: inline-block; width: 200px; margin-right: 10px; } input, button { padding: 8px; margin-right: 10px; } button { background-color: #4CAF50; color: white; border: none; cursor: pointer; border-radius: 4px; } button:hover { background-color: #45a049; } #fileInput { display: none; } .file-upload { display: inline-block; padding: 8px 12px; background: #337ab7; color: white; border-radius: 4px; cursor: pointer; } .file-upload:hover { background: #286090; } #loading { display: none; margin-left: 10px; color: #337ab7; font-weight: bold; } .summary { margin-top: 15px; padding: 10px; background-color: #e7f3fe; border-left: 5px solid #2196F3; } </style> <div class="container"> <h1>缺件排产分析工具</h1> <div class="section"> <h2>产能设置</h2> <div class="input-group"> <label for="workers">每日生产人数:</label> <input type="number" id="workers" value="3" min="1"> </div> <div class="input-group"> <label for="productivity">每人每日产量:</label> <input type="number" id="productivity" value="70" min="1"> </div> <div class="input-group"> <label for="startDate">排产开始日期:</label> <input type="date" id="startDate"> </div> </div> <div class="section"> <h2>数据导入</h2> <div class="input-group"> <label>Excel数据导入:</label> <label for="fileInput" class="file-upload">选择Excel文件</label> <input type="file" id="fileInput" accept=".xlsx, .xls" onchange="handleFileUpload(this.files)"> <span id="fileName" style="margin-left:10px;"></span> </div> <div class="input-group"> <label>Excel格式要求:</label> <span>第一列:产品编号, 第二列:交付日期, 第三列:缺件数量</span> </div> </div> <div class="section"> <h2>原始数据</h2> <div id="rawDataSummary" class="summary"></div> <table id="rawDataTable"> <thead> <tr> <th>产品编号</th> <th>交付日期</th> <th>缺件数量</th> </tr> </thead> <tbody></tbody> </table> </div> <div class="section"> <h2>排产计划</h2> <button onclick="generateSchedule()" id="generateBtn">生成排产计划</button> <span id="loading">正在计算中,请稍候...</span> <div id="scheduleSummary" class="summary"></div> <table id="scheduleTable"> <thead> <tr> <th>产品编号</th> <th>缺件数量</th> <th>交付日期</th> <th>排产日期</th> <th>是否超期</th> </tr> </thead> <tbody></tbody> </table> </div> <div class="section"> <h2>预警清单</h2> <div id="warningSummary" class="summary"></div> <table id="warningTable"> <thead> <tr> <th>产品编号</th> <th>缺件数量</th> <th>交付日期</th> <th>预计排产日期</th> <th>超期天数</th> </tr> </thead> <tbody></tbody> </table> </div> </div> <script> // 全局变量 let rawData = []; let scheduleData = []; let warningData = []; // 页面加载时设置默认日期为今天 window.onload = function() { const today = new Date(); const formattedDate = today.toISOString().split('T')[0]; document.getElementById('startDate').value = formattedDate; }; // 解析Excel日期数字 function parseExcelDate(excelDate) { // Excel日期是从1900年1月1日开始的天数 // 注意:Excel错误地认为1900年是闰年,所以需要调整 const utcDays = Math.floor(excelDate - 25569); const utcValue = utcDays * 86400 * 1000; let date = new Date(utcValue); // 处理Excel的1900年闰年错误 if (excelDate >= 60) { date.setTime(date.getTime() - 86400 * 1000); } return date.toISOString().split('T')[0]; } // 处理Excel文件上传 function handleFileUpload(files) { if (files.length === 0) return; const file = files[0]; document.getElementById('fileName').textContent = file.name; const reader = new FileReader(); reader.onload = function(e) { try { const data = new Uint8Array(e.target.result); const workbook = XLSX.read(data, { type: 'array' }); // 假设数据在第一个工作表 const firstSheet = workbook.Sheets[workbook.SheetNames[0]]; const jsonData = XLSX.utils.sheet_to_json(firstSheet, { header: 1 }); // 提取数据 (假设第一行是标题) rawData = []; for (let i = 1; i < jsonData.length; i++) { if (jsonData[i].length >= 3) { // 处理日期 - 可能是数字或字符串 let deliveryDate = ''; const dateValue = jsonData[i][1]; if (typeof dateValue === 'number') { // Excel数字日期 deliveryDate = parseExcelDate(dateValue); } else if (dateValue instanceof Date) { // 已经是Date对象 deliveryDate = dateValue.toISOString().split('T')[0]; } else if (typeof dateValue === 'string') { // 尝试解析字符串日期 const parsedDate = new Date(dateValue); if (!isNaN(parsedDate.getTime())) { deliveryDate = parsedDate.toISOString().split('T')[0]; } } // 处理数量 let quantity = 0; if (typeof jsonData[i][2] === 'number') { quantity = Math.floor(jsonData[i][2]); } else if (typeof jsonData[i][2] === 'string') { quantity = parseInt(jsonData[i][2]) || 0; } rawData.push({ productId: String(jsonData[i][0] || ''), deliveryDate: deliveryDate, quantity: quantity }); } } console.log("解析后的数据:", rawData); displayRawData(); updateRawDataSummary(); } catch (error) { console.error("解析Excel文件时出错:", error); alert('解析Excel文件时出错: ' + error.message); } }; reader.onerror = function() { alert('读取文件时出错'); }; reader.readAsArrayBuffer(file); } // 显示原始数据 function displayRawData() { const tbody = document.querySelector('#rawDataTable tbody'); tbody.innerHTML = ''; rawData.forEach(item => { const row = document.createElement('tr'); row.innerHTML = ` <td>${item.productId}</td> <td>${item.deliveryDate}</td> <td>${item.quantity}</td> `; tbody.appendChild(row); }); } // 更新原始数据摘要 function updateRawDataSummary() { const summary = document.getElementById('rawDataSummary'); const totalItems = rawData.length; const totalQuantity = rawData.reduce((sum, item) => sum + item.quantity, 0); summary.innerHTML = ` 共 ${totalItems} 条记录,总缺件数量: ${totalQuantity} 件 ${rawData.some(item => !item.deliveryDate) ? '<span class="warning"> (警告: 部分记录缺少交付日期)</span>' : ''} `; } // 生成排产计划 function generateSchedule() { const btn = document.getElementById('generateBtn'); const loading = document.getElementById('loading'); btn.disabled = true; loading.style.display = 'inline'; // 使用setTimeout让UI有机会更新 setTimeout(() => { try { console.log("开始生成排产计划..."); if (rawData.length === 0) { alert('请先导入Excel数据'); return; } // 检查无效数据 const invalidData = rawData.filter(item => !item.deliveryDate || isNaN(new Date(item.deliveryDate).getTime()) || isNaN(item.quantity) ); if (invalidData.length > 0) { console.error("无效数据:", invalidData); alert(`发现 ${invalidData.length} 条无效记录,请检查数据`); return; } const workers = parseInt(document.getElementById('workers').value) || 3; const productivity = parseInt(document.getElementById('productivity').value) || 70; const startDateStr = document.getElementById('startDate').value; if (!startDateStr) { alert('请设置排产开始日期'); return; } const dailyCapacity = workers * productivity; let currentDate = new Date(startDateStr); let dailyRemaining = dailyCapacity; scheduleData = []; warningData = []; // 按交付日期排序 const sortedData = [...rawData].sort((a, b) => { return new Date(a.deliveryDate) - new Date(b.deliveryDate); }); console.log("排序后的数据:", sortedData); // 分配生产日期 for (const item of sortedData) { let productionDate = new Date(currentDate); let quantityRemaining = item.quantity; while (quantityRemaining > 0) { if (dailyRemaining === 0) { // 转到下一天 currentDate.setDate(currentDate.getDate() + 1); dailyRemaining = dailyCapacity; productionDate = new Date(currentDate); console.log(`转到下一天: ${productionDate.toISOString().split('T')[0]}, 剩余产能: ${dailyRemaining}`); } const allocate = Math.min(quantityRemaining, dailyRemaining); const isLate = productionDate > new Date(item.deliveryDate); scheduleData.push({ productId: item.productId, quantity: allocate, deliveryDate: item.deliveryDate, productionDate: productionDate.toISOString().split('T')[0], isLate: isLate }); quantityRemaining -= allocate; dailyRemaining -= allocate; console.log(`分配 ${allocate} 件, 剩余 ${quantityRemaining} 件, 当日剩余产能: ${dailyRemaining}`); } } // 生成预警清单 generateWarnings(); // 显示结果 displaySchedule(); displayWarnings(); updateSummary(); console.log("排产计划生成完成"); console.log("排产数据:", scheduleData); console.log("预警数据:", warningData); } catch (error) { console.error("生成排产计划时出错:", error); alert('生成排产计划时出错: ' + error.message); } finally { btn.disabled = false; loading.style.display = 'none'; } }, 100); } // 生成预警清单 function generateWarnings() { warningData = []; // 按产品分组 const productGroups = scheduleData.reduce((groups, item) => { if (!groups[item.productId]) { groups[item.productId] = []; } groups[item.productId].push(item); return groups; }, {}); // 检查每个产品的最后生产日期 for (const productId in productGroups) { const items = productGroups[productId]; const lastItem = items.reduce((latest, curr) => { return new Date(curr.productionDate) > new Date(latest.productionDate) ? curr : latest; }); if (lastItem.isLate) { const lateDays = Math.ceil( (new Date(lastItem.productionDate) - new Date(lastItem.deliveryDate)) / (1000 * 60 * 60 * 24) ); warningData.push({ productId: productId, quantity: items.reduce((sum, item) => sum + item.quantity, 0), deliveryDate: lastItem.deliveryDate, productionDate: lastItem.productionDate, lateDays: lateDays }); } } } // 更新摘要信息 function updateSummary() { const scheduleSummary = document.getElementById('scheduleSummary'); const warningSummary = document.getElementById('warningSummary'); const totalItems = scheduleData.length; const totalQuantity = scheduleData.reduce((sum, item) => sum + item.quantity, 0); const lateItems = scheduleData.filter(item => item.isLate).length; scheduleSummary.innerHTML = ` 共 ${totalItems} 条排产记录,总排产量: ${totalQuantity} 件,超期项目: ${lateItems} 个 `; const warningCount = warningData.length; const warningQuantity = warningData.reduce((sum, item) => sum + item.quantity, 0); warningSummary.innerHTML = ` 共 ${warningCount} 个产品需要预警,总数量: ${warningQuantity} 件 `; } // 显示排产计划 function displaySchedule() { const tbody = document.querySelector('#scheduleTable tbody'); tbody.innerHTML = ''; scheduleData.forEach(item => { const row = document.createElement('tr'); if (item.isLate) { row.classList.add('warning'); } row.innerHTML = ` <td>${item.productId}</td> <td>${item.quantity}</td> <td>${item.deliveryDate}</td> <td>${item.productionDate}</td> <td>${item.isLate ? '是' : '否'}</td> `; tbody.appendChild(row); }); } // 显示预警清单 function displayWarnings() { const tbody = document.querySelector('#warningTable tbody'); tbody.innerHTML = ''; // 按产品分组,只显示每个产品的最后一条记录 const groupedWarnings = warningData.reduce((acc, curr) => { acc[curr.productId] = curr; return acc; }, {}); Object.values(groupedWarnings).forEach(item => { const row = document.createElement('tr'); row.classList.add('warning'); row.innerHTML = ` <td>${item.productId}</td> <td>${item.quantity}</td> <td>${item.deliveryDate}</td> <td>${item.productionDate}</td> <td>${item.lateDays}</td> `; tbody.appendChild(row); }); } </script>
2025年03月26日
4 阅读
0 评论
0 点赞
2024-04-16
Climate change could affect timekeeping, study says
{mp3 name="听力" url="http://v-hls.chinadaily.com.cn/stream/607212/903f9e1b-f05d-485d-b69c-e37ae16606b4/571fde86-381d-4d12-8cf6-bc045c95a981.mp3" cover="https://img2.chinadaily.com.cn/images/202404/08/66139dd2a31082fc2b6bcb5b.jpeg" theme="#f0ad4e" autoplay="autoplay"/}Climate change is affecting the speed of the Earth's rotation and could impact how we keep time, a study says.一项研究称,气候变化正在影响地球的自转速度,并可能影响人类的计时方式。"Global warming is already affecting global timekeeping," says the study, published in the journal Nature.这项发表在《自然》(Nature)杂志上的研究指出:"全球变暖已经在影响全球计时。"Coordinated Universal Time (UTC) - which is used by most of the world to regulate clocks and time - is calculated by the Earth's rotation."协调世界时"(UTC)是根据地球自转计算出来的,世界上大多数国家都用它来管理时钟和时间。But the Earth's rotation rate is not constant and can therefore have an effect on how long our days and nights are.但地球的自转速度并不是恒定的,因此会对我们的昼夜长短产生影响。Changes to the planet's liquid core have meant the Earth has been spinning slightly quicker.地球液态内核的变化意味着地球自转速度略快。Since the 1970s, to correct for this, about 27 leap seconds have been added to the global clock, with timekeepers planning on subtracting a second for the first time in 2026. This is known as a "negative leap second."自 20 世纪 70 年代以来,为了纠正这一现象,全球时钟已经增加了约 27 个闰秒,计时员计划将在 2026 年首次减少一秒。这被称为 "负闰秒"。However, the study finds that ice melting caused by climate change has partly offset that acceleration.然而,研究发现,气候变化导致的冰雪融化部分抵消了这一加速。Ice sheets are now losing mass five times faster than they were 30 years ago, meaning that the negative leap second change will not be needed until 2029, the study suggests.研究表明,冰盖现在的质量损失速度是30年前的5倍,这意味着可能直到2029年才需要负闰秒的变化。"It's kind of impressive, even to me, we've done something that measurably changes how fast the Earth rotates," Duncan Agnew, the author of the study, told NBC News.这项研究的作者邓肯•阿格纽告诉美国全国广播公司新闻(NBC News):"即使对我来说,我们已经做了一些可以适度地改变地球旋转速度的事情,这也是令人印象深刻的。""Things are happening that are unprecedented.""正在发生的事情是前所未有的。"The negative leap second has never been used before and, according to the study, its use "will pose an unprecedented problem" for computer systems across the world.负闰秒以前从未使用过,根据这项研究,负闰秒的使用将给全球计算机系统 "带来前所未有的问题"。"This has never happened before, and poses a major challenge to making sure that all parts of the global timing infrastructure show the same time," Mr Agnew, who is a researcher at the University of California, San Diego told AFP news agency.加利福尼亚大学圣迭戈分校的研究员阿格纽先生告诉法新社记者:"这种情况以前从未发生过,这对确保全球计时基础设施的所有部分都显示相同的时间构成了重大挑战。""Many computer programs for leap seconds assume they are all positive, so these would have to be rewritten," he added.他补充说:"许多计算闰秒的计算机程序都假定它们都是正数,因此这些程序必须重写。"There has been some skepticism of the study, however.然而,也有一些人对这项研究持怀疑态度。Demetrios Matsakis, former chief scientist for time services at the US Naval Observatory, told AFP that "Earth is too unpredictable to be sure" if a negative leap second would be needed any time soon.美国海军天文台负责时间服务的前首席科学家德米特里奥斯•马萨基斯告诉法新社说,"地球太不可预测了,无法确定是否在不久的将来就需要负闰秒。"Human activities like burning fossil fuels are causing world temperatures to rise.燃烧化石燃料等人类活动正在导致全球气温上升。That temperature rise is having a huge effect on the environment, including the rapid melting of glaciers and ice sheets.气温上升对环境产生了巨大影响,包括冰川和冰盖的迅速融化。
2024年04月16日
7 阅读
0 评论
0 点赞
2024-01-30
mysql配置外网权限
好久不用都忘记了,这次再整理一下,方便以后查找。查看所有用户:SELECT user, host FROM mysql.user;查看特定用户的权限:SHOW GRANTS FOR 'username'@'hostname';查看用户的连接信息和权限:SELECT user, host, authentication_string FROM mysql.user;查看当前登录的用户:SELECT USER();查询所有用户的权限信息,使用以下命令:SHOW GRANTS;使用以下步骤来创建用户并授权外网访问:使用root用户登录到MySQL服务器上。如果尚未设置root密码,请使用以下命令更改或设置root密码:ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';创建新用户并授予外网访问权限。假设要创建一个名为new_user,允许从任何主机('%')访问数据库,并设置密码为user_password,可以使用以下命令:CREATE USER 'new_user'@'%' IDENTIFIED BY 'user_password';授予新用户对数据库的访问权限。例如,如果希望new_user用户有SELECT, INSERT, UPDATE和DELETE权限:GRANT SELECT, INSERT, UPDATE, DELETE ON database_name.* TO 'new_user'@'%';替换database_name为实际数据库的名称。刷新权限使更改生效:FLUSH PRIVILEGES;
2024年01月30日
37 阅读
0 评论
0 点赞
2024-01-29
解决Edge浏览器提示“此网站已被人举报不安全”
1月29日下午开始,大量用户反馈通过Edge浏览器的必应搜索百度内容时,会提示“此网站已被人举报不安全”,估计是Microsoft Defender SmartScreen 的库出问题了。直接关闭Microsoft Defender SmartScreen https://img-blog.csdnimg.cn/direct/28a39261640c498395f92177641bf80c.png
2024年01月29日
92 阅读
10 评论
0 点赞
1
...
16
17
18
...
32
0:00