zrg
2025-03-17 e4f24e81dc1f484cd91b965ed3eada9865b0bf85
WebTM/views/Éú²ú¹ÜÀí/Éú²ú¼Æ»®Æ½Ì¨/JIT_DayPlanPlatForm_TK.html
@@ -948,7 +948,7 @@
            var myDate = new Date();
            var oneday = 1000 * 60 * 60 * 24;
             columns.push({ type: 'checkbox', fixed: 'left', sort: true });
            columns.push({ type: 'checkbox', fixed: 'left', sort: true });
            columns.push({ type: 'numbers', field: '序号', title: '序号', sort: true, filter: true });
            columns.push({ field: '单据号', title: '单据号', hide: true, sort: true, filter: true});
            columns.push({ field: '销售订单号', title: '销售订单号', width: 150, sort: true, filter: true });
@@ -959,13 +959,13 @@
            columns.push({ field: '物料名称', title: '物料名称', width: 150, sort: true, filter: true });
            columns.push({ field: '规格型号', title: '规格型号', width: 150, sort: true, filter: true });
            columns.push({ field: '小时产能', title: '小时产能', width: 150, sort: true, edit: 'text', filter: true });
            columns.push({ field: '产线总产能', title: '产线总产能', width: 150, sort: true, edit: 'text', filter: true });
            columns.push({ field: '计划数量', title: '生产订单数量', width: 150, sort: true, filter: true });//0
            columns.push({ field: '日计划数量总量', title: '日计划数量总量', width: 150, sort: true, filter: true});//0
            columns.push({ field: '订单可排数量', title: '订单可排数量', width: 150, filter: true});
            columns.push({ field: '拆单数量', title: '拆单数量', width: 150, edit: 'text', filter: true});
            columns.push({ field: '昨日数量', title: '昨日数量', filter: true});
            columns.push({ field: '优先级', title: '优先级', width: 150, edit: 'text', sort: true, filter: true });
            columns.push({ field: '生产资源', title: '生产资源', width: 150, edit: 'text', event: "HSourceID", filter: true });
            columns.push({ field: '使用工装', title: '使用工装', width: 150, filter: true });
            columns.push({ field: '最早开工日期', title: '最早开工日期', width: 150, templet: "<div>{{d.最早开工日期 ==null ?'':layui.util.toDateString(d.最早开工日期, 'yyyy-MM-dd')}}</div>", event: "HEarlyDate", sort: true, filter: { type: 'date[yyyy-MM-dd HH:mm:ss]' } });
            columns.push({
@@ -1181,6 +1181,8 @@
            columns.push({ field: 'HEmpID', title: 'HEmpID', hide: true });
            columns.push({ field: '拆单汇报数量', title: '拆单汇报数量', width: 150, edit: 'text', sort: true });
            columns.push({ field: '销售订单数量', title: '销售订单数量', width: 150, sort: true, filter: true });//0
            columns.push({ field: '日计划数量总量', title: '日计划数量总量', width: 150, sort: true, filter: true });//0
            columns.push({ field: '拆单数量', title: '拆单数量', width: 150, edit: 'text', filter: true });
            columns.push({ field: '今日之前日计划数量', title: '今日之前日计划数量', width: 150, sort: true, filter: true });//0
            columns.push({ field: '计划开始日期', title: '预计开工日期', width: 150, templet: "<div>{{d.计划开始日期 ==null ?'':layui.util.toDateString(d.计划开始日期, 'yyyy-MM-dd')}}</div>", sort: true, filter: { type: 'date[yyyy-MM-dd HH:mm:ss]' } });
            columns.push({ field: '计划结束日期', title: '计划结束日期', width: 150, templet: "<div>{{d.计划结束日期 ==null ?'':layui.util.toDateString(d.计划结束日期, 'yyyy-MM-dd')}}</div>", event: "HPlanEndDate", sort: true, filter: { type: 'date[yyyy-MM-dd HH:mm:ss]' } });
@@ -1188,6 +1190,7 @@
            columns.push({ field: '操作工', title: '操作工', width: 150, edit: 'text', event: "HEmpID" });
            columns.push({ field: 'HMouldID', title: 'HMouldID', width: 150, hide: true });
            columns.push({ field: 'HMouldPCTime', title: 'HMouldPCTime', width: 150, hide: true });
            columns.push({ field: '所需工位数', title: '所需工位数', width: 150 });
            columns.push({ fixed: 'right', title: '操作', toolbar: '#barDemo' });
            option_columns = columns;
            option = {
@@ -2214,7 +2217,7 @@
                        i = option.data.length - 1;
                    }
                }
                console.log("1.开始排产第" + (i + 1) + "行订单:" + option.data[i].生产订单号 + ",当前排产日期:" + HPCDate + ",最早开工日期:" + option.data[i].最早开工日期);
                //console.log("1.开始排产第" + (i + 1) + "行订单:" + option.data[i].生产订单号 + ",当前排产日期:" + HPCDate + ",最早开工日期:" + option.data[i].最早开工日期);
                //排产最后一笔订单(若本次为最后一笔订单排产,但当前排产日期还不满足最早开工日期,则当前日期进行累加,直到满足最早开工日期为止)
                if (HArrIndex_PC.length == option.data.length - 1 && HArrIndex.length > 0 && Format(option.data[HArrIndex[0]].最早开工日期, 'yyyy/MM/dd') > HPCDate) {
                    for (var k = 0; k < 100; k++) {
@@ -2305,21 +2308,9 @@
                sMaterNumber = option.data[i]["物料代码"];
                sMaterName = option.data[i]["物料名称"];
                sMaterModel = option.data[i]["规格型号"];
                sWorkQty = option.data[i]["小时产能"];
                sYX = option.data[i]["优先级"];
                HReportQty = option.data[i]["拆单汇报数量"];
                if (SDSum > 0) {
                    sPlanQty = sPlanQty - SDSum - HReportQty;
                }
                //剩余需求工时
                iLeftQty = sPlanQty - HReportQty;
                if (sWorkQty <= 0) {
                    sLeftProdTimes = 0;
                }
                else {
                    sLeftProdTimes = iLeftQty / sWorkQty;
                }
                //若本任务单已有安排资源(上次排程或者手工排程) åˆ™ä¸å†å¯»æ‰¾èµ„源,直接排程
                if (option.data[i]["HSourceID"] != 0 && option.data[i]["生产资源"] != "") {
                    //获取该生产资源的剩余工时进行排程。
@@ -2336,6 +2327,9 @@
                        success: function (data1) {
                            if (data1.count == 1) {
                                ds = data1.data
                                if (ds.length > 0) {
                                    option.data[i]["产线总产能"] = option.data[i]["小时产能"] * ds[0]["产线人数"]
                                }
                            } else {
                                layer.alert(data1.code + data1.Message, { icon: 5 });
                            }
@@ -2356,6 +2350,9 @@
                        success: function (data1) {
                            if (data1.count == 1) {
                                ds = data1.data
                                if (ds.length > 0) {
                                    option.data[i]["产线总产能"] = option.data[i]["小时产能"] * ds[0]["产线人数"]
                                }
                            } else {
                                layer.alert(data1.code + data1.Message, { icon: 5 });
                            }
@@ -2364,6 +2361,22 @@
                        }
                    });
                }
                //获取小时产能
                sWorkQty = option.data[i]["产线总产能"];
                //获取更新计划数量
                if (SDSum > 0) {
                    sPlanQty = sPlanQty - SDSum - HReportQty;
                }
                //剩余需求工时
                iLeftQty = sPlanQty - HReportQty;
                if (sWorkQty <= 0) {
                    sLeftProdTimes = 0;
                }
                else {
                    sLeftProdTimes = iLeftQty / sWorkQty;
                }
                if (ds == null || ds.length == 0) //没有可以排的资源
                {
                    get_HFData(1, i);
@@ -2391,7 +2404,7 @@
                                option.data[i]["生产资源"] = sSourceName;
                                option.data[i]["生产资源代码"] = sSourceNumber;
                                console.log("======" + "第" + (i + 1) + "行订单:" + option.data[i].生产订单号 + ", è‡ªåŠ¨åŒ¹é…" + ds.length + "个生产资源,最终选择:" + sSourceName);
                                //console.log("======" + "第" + (i + 1) + "行订单:" + option.data[i].生产订单号 + ", è‡ªåŠ¨åŒ¹é…" + ds.length + "个生产资源,最终选择:" + sSourceName);
                                var sql = "exec h_p_Sc_ICMOGetWorkSourceTime " + lSourceID;
                                $.ajax({
@@ -2430,15 +2443,7 @@
                            get_HFData(1, i);
                        }
                    }
                }
                var new_date = new Date();
                var difftime = (new_date - old_date) / 1000; //计算时间差,并把毫秒转换成秒
                var days = parseInt(difftime / 86400); // å¤©  24*60*60*1000
                var hours = parseInt(difftime / 3600) - 24 * days;    // å°æ—¶ 60*60 æ€»å°æ—¶æ•°-过去的小时数=现在的小时数
                var minutes = parseInt(difftime % 3600 / 60); // åˆ†é’Ÿ -(day*24) ä»¥60秒为一整份 å–ä½™ å‰©ä¸‹ç§’æ•° ç§’æ•°/60 å°±æ˜¯åˆ†é’Ÿæ•°
                var seconds = parseInt(difftime % 60);  // ä»¥60秒为一整份 å–ä½™ å‰©ä¸‹ç§’æ•°
                console.log("时间差是: " + days + "天, " + hours + "小时, " + minutes + "分钟, " + seconds + "秒");
                }
            }
            table.render(option);
            get_FastQuery(2);
@@ -2474,6 +2479,9 @@
            JDTLen = (100 / option.data.length).toFixed(2);
            var HJDLen = 0;
            var HReportQty = 0;
            var HProducedTogether = [];
            var HProducedTogetherIndex = [];
            var HChildSourceData = []; //子生产资源
            //如果锁定计划,则不需要再排程
            //查询本车间是否有锁定计划的数据
@@ -2520,7 +2528,7 @@
            });
            //根据车间删除器具占用时间
            var sql2 = "delete from Gy_MouldOccupancyTime where HICMOEntryID not in ( select HICMOEntryID from Sc_WorkBillSortBillMain where HInterID in (select HInterID from Sc_WorkBillSortBillSub))";
            var sql2 = "delete from Gy_MouldOccupancyTime where HICMOEntryID not in ( select HICMOEntryID from Sc_WorkBillSortBillMain where HInterID in (select HInterID from Sc_WorkBillSortBillSub where HMasterDate>=convert(varchar(10) ,DATEADD(DAY," + HPlanDay + ",GETDATE()),20)))";
            $.ajax({
                url: GetWEBURL() + '/Gy_SOPBillList/UpDelSQL',
                type: "GET",
@@ -2568,8 +2576,7 @@
                HCount++;
                if (HCount > 50000) {
                    break;
                }
                var old_date = new Date();
                }
                //element.progress('demo', (i + 1) * HProgress + '%')
                //判断数组长度是否发生变化,是则重置数组长度
@@ -2579,7 +2586,7 @@
                        i = option.data.length - 1;
                    }
                }
                console.log("1.开始排产第" + (i + 1) + "行订单:" + option.data[i].生产订单号 + ",当前排产日期:" + HPCDate + ",最早开工日期:" + option.data[i].最早开工日期);
                //console.log("1.开始排产第" + (i + 1) + "行订单:" + option.data[i].生产订单号 + ",当前排产日期:" + HPCDate + ",最早开工日期:" + option.data[i].最早开工日期);
                //排产最后一笔订单(若本次为最后一笔订单排产,但当前排产日期还不满足最早开工日期,则当前日期进行累加,直到满足最早开工日期为止)
                if (HArrIndex_PC.length == option.data.length - 1 && HArrIndex.length > 0 && Format(option.data[HArrIndex[0]].最早开工日期, 'yyyy/MM/dd') > HPCDate) {
                    for (var k = 0; k < 100; k++) {
@@ -2688,6 +2695,7 @@
                
                var HIsContinue = false;    //是否能匹配到合适的产品器具清单,匹配不到则跳过当前订单
                //#region å·²åŒ¹é…äº†èµ„源,直接排产
                //若本任务单已有安排资源(上次排程或者手工排程) åˆ™ä¸å†å¯»æ‰¾èµ„源,直接排程
                if (option.data[i]["HSourceID"] != 0 && option.data[i]["生产资源"] != "") {
                    //获取该生产资源的剩余工时进行排程。
@@ -2704,13 +2712,16 @@
                        success: function (data1) {
                            if (data1.count == 1) {
                                ds = data1.data
                                //看是否能匹配到满足生产条件的产品器具清单
                                var HMaterMouldData = get_MouldByMater(lMaterID, lSourceID);
                                var HMaterMouldData = get_MouldByMater(lMaterID, lSourceID, Format(HPCDate, 'yyyy-MM-dd'));
                                console.log("第" + (i + 1) + "行,生产订单:" + option.data[i].生产订单号 + " exec h_p_Gy_MaterialMouldByMater " + lMaterID + "," + lSourceID + ",'" + Format(HPCDate, 'yyyy-MM-dd') + "' ã€‚匹配器具清单数为:" + HMaterMouldData.length);
                                if (HMaterMouldData.length < 1) {
                                    //没有匹配到器具,生产不了,把订单挂到待排产列表中,先匹配下一优先级的订单
                                    if (HArrIndex.indexOf(i) == -1) {
                                        HArrIndex.push(i);
                                    }
                                    HIsPriority = true;
                                    //为满足最后一笔匹配订单也能进行排产,改变总排产订单数组长度,继续循环匹配
                                    if (HArrIndex.length > 0 && i == HDataLen - 1) {
@@ -2718,20 +2729,29 @@
                                    }
                                    HIsContinue = true;
                                } else {
                                    //判断匹配出的器具是否能在此资源上使用
                                    var HSourceMouldData = get_MouldBySource(lSourceID, HMaterMouldData[0].HMouldID);
                                    if (HSourceMouldData.length < 1) {
                                        //没有匹配到资源器具清单,生产不了,把订单挂到待排产列表中,先匹配下一优先级的订单
                                        if (HArrIndex.indexOf(i) == -1) {
                                            HArrIndex.push(i);
                                        }
                                        HIsPriority = true;
                                        //为满足最后一笔匹配订单也能进行排产,改变总排产订单数组长度,继续循环匹配
                                        if (HArrIndex.length > 0 && i == HDataLen - 1) {
                                            HDataLen = HDataLen + 1;
                                        }
                                        HIsContinue = true;
                                    }
                                    //var HSourceMouldData = [];
                                    ////判断匹配出的器具是否能在此资源上使用
                                    //for (var index = 0; index < HMaterMouldData.length; index++) {
                                    //    HSourceMouldData = get_MouldBySource(lSourceID, HMaterMouldData[index].HMouldID);
                                    //    if (HSourceMouldData.length > 0) {
                                    //        break;
                                    //    }
                                    //}
                                    //if (HSourceMouldData.length < 1) {
                                    //    //没有匹配到资源器具清单,生产不了,把订单挂到待排产列表中,先匹配下一优先级的订单
                                    //    if (HArrIndex.indexOf(i) == -1) {
                                    //        HArrIndex.push(i);
                                    //    }
                                    //    HIsPriority = true;
                                    //    //为满足最后一笔匹配订单也能进行排产,改变总排产订单数组长度,继续循环匹配
                                    //    if (HArrIndex.length > 0 && i == HDataLen - 1) {
                                    //        HDataLen = HDataLen + 1;
                                    //    }
                                    //    HIsContinue = true;
                                    //}
                                    option.data[i].HMouldID = HMaterMouldData[0].HMouldID;
                                    option.data[i].HMouldPCTime = HMaterMouldData[0].HPCTime;
                                }
@@ -2744,6 +2764,8 @@
                    });
                   
                }
                //#endregion
                //#region æ²¡æœ‰èµ„源则 è‡ªåŠ¨æ‰¾åˆ°èµ„æº
                else //没有资源则 è‡ªåŠ¨æ‰¾åˆ°èµ„æº
                {
                    //查询生产资源的剩余工时进行排程。
@@ -2758,24 +2780,12 @@
                                ds = data1.data
                                if (ds.length > 0) {
                                    //看是否能匹配到满足生产条件的产品器具清单
                                    var HMaterMouldData = get_MouldByMater(lMaterID, ds[0]["HitemID"]);
                                    if (HMaterMouldData.length < 1) {
                                        //没有匹配到器具,生产不了,把订单挂到待排产列表中,先匹配下一优先级的订单
                                        if (HArrIndex.indexOf(i) == -1) {
                                            HArrIndex.push(i);
                                        }
                                        HIsPriority = true;
                                        //为满足最后一笔匹配订单也能进行排产,改变总排产订单数组长度,继续循环匹配
                                        if (HArrIndex.length > 0 && i == HDataLen - 1) {
                                            HDataLen = HDataLen + 1;
                                        }
                                        HIsContinue = true;
                                    } else {
                                        //判断匹配出的器具是否能在此资源上使用
                                        var HSourceMouldData = get_MouldBySource(ds[0]["HitemID"], HMaterMouldData[0].HMouldID);
                                        if (HSourceMouldData.length < 1) {
                                            //没有匹配到资源器具清单,生产不了,把订单挂到待排产列表中,先匹配下一优先级的订单
                                    //#region èµ„源工位数等于需求工位数
                                    if (ds[0].资源工位数 == ds[0].所需工位数) {
                                        //看是否能匹配到满足生产条件的产品器具清单
                                        var HMaterMouldData = get_MouldByMater(lMaterID, ds[0]["HitemID"], Format(HPCDate, 'yyyy-MM-dd'));
                                        if (HMaterMouldData.length < 1) {
                                            //没有匹配到器具,生产不了,把订单挂到待排产列表中,先匹配下一优先级的订单
                                            if (HArrIndex.indexOf(i) == -1) {
                                                HArrIndex.push(i);
                                            }
@@ -2785,17 +2795,112 @@
                                                HDataLen = HDataLen + 1;
                                            }
                                            HIsContinue = true;
                                        } else {
                                            ////判断匹配出的器具是否能在此资源上使用
                                            //var HSourceMouldData = get_MouldBySource(ds[0]["HitemID"], HMaterMouldData[0].HMouldID);
                                            //if (HSourceMouldData.length < 1) {
                                            //    //没有匹配到资源器具清单,生产不了,把订单挂到待排产列表中,先匹配下一优先级的订单
                                            //    if (HArrIndex.indexOf(i) == -1) {
                                            //        HArrIndex.push(i);
                                            //    }
                                            //    HIsPriority = true;
                                            //    //为满足最后一笔匹配订单也能进行排产,改变总排产订单数组长度,继续循环匹配
                                            //    if (HArrIndex.length > 0 && i == HDataLen - 1) {
                                            //        HDataLen = HDataLen + 1;
                                            //    }
                                            //    HIsContinue = true;
                                            //}
                                            option.data[i].HMouldID = HMaterMouldData[0].HMouldID;
                                            option.data[i].HMouldPCTime = HMaterMouldData[0].HPCTime;
                                        }
                                    }
                                }
                                    //#endregion
                                    //#region èµ„源工位数大于需求工位数
                                    else if (ds[0].资源工位数 > ds[0].所需工位数) {
                                        //看是否能匹配到满足生产条件的产品器具清单
                                        var HMaterMouldData = get_MouldByMater(lMaterID, ds[0]["HitemID"], Format(HPCDate, 'yyyy-MM-dd'));
                                        if (HMaterMouldData.length < 1) {
                                            //没有匹配到器具,生产不了,把订单挂到待排产列表中,先匹配下一优先级的订单
                                            if (HArrIndex.indexOf(i) == -1) {
                                                HArrIndex.push(i);
                                            }
                                            HIsPriority = true;
                                            //为满足最后一笔匹配订单也能进行排产,改变总排产订单数组长度,继续循环匹配
                                            if (HArrIndex.length > 0 && i == HDataLen - 1) {
                                                HDataLen = HDataLen + 1;
                                            }
                                            HIsContinue = true;
                                        } else {
                                            option.data[i].HMouldID = HMaterMouldData[0].HMouldID;
                                            option.data[i].HMouldPCTime = HMaterMouldData[0].HPCTime;
                                        }
                                        //匹配此生产资源下的子生产资源
                                        HChildSourceData = get_ChildSource(ds[0]["HitemID"]);
                                        option.data[i].生产资源 = "";
                                        for (var k = 0; k < option.data[i].所需工位数; k++) {
                                            if (k == 0) {
                                                option.data[i].HSourceID = HChildSourceData[k].子资源ID;
                                            }
                                            option.data[i].生产资源 += HChildSourceData[k].子资源名称 + "&";
                                        }
                                        option.data[i].生产资源 = option.data[i].生产资源.substring(0, option.data[i].生产资源.length - 1)
                                        //判断资源是否有剩余工位,接着匹配其他订单同时生产
                                        var HRestCubicleQty = ds[0].资源工位数 - ds[0].所需工位数
                                        for (var x = i + 1; x < option.data.length; x++) {
                                            if (HRestCubicleQty >= option.data[x].所需工位数 && HArrIndex_PC.indexOf(x) == -1) {
                                                console.log("&&&&&第" + (i + 1) + "行有订单一起参与匹配," + option.data[x].HMaterID)
                                                //判断此订单(物料)是否也能放在此生产资源上生产
                                                var HMaterSourceData = get_MaterSource(option.data[x].HMaterID);
                                                for (var y = 0; y < HMaterSourceData.length; y++) {
                                                    if (ds[0]["HitemID"] == HMaterSourceData[y]["HitemID"]) {
                                                        //看是否能匹配到满足生产条件的产品器具清单
                                                        var HMaterMouldData_Level2 = get_MouldByMater(option.data[x].HMaterID, ds[0]["HitemID"], Format(HPCDate, 'yyyy-MM-dd'));
                                                        if (HMaterMouldData_Level2.length >= 1) {
                                                            option.data[x].HMouldID = HMaterMouldData_Level2[0].HMouldID;
                                                            option.data[x].HMouldPCTime = HMaterMouldData_Level2[0].HPCTime;
                                                            option.data[x].生产资源 = "";
                                                            for (var k = HChildSourceData.length - HRestCubicleQty; k < HChildSourceData.length; k++) {
                                                                if (k == HChildSourceData.length - HRestCubicleQty) {
                                                                    option.data[x].HSourceID = HChildSourceData[k].子资源ID;
                                                                }
                                                                option.data[x].生产资源 += HChildSourceData[k].子资源名称 + "&";
                                                            }
                                                            option.data[x].生产资源 = option.data[x].生产资源.substring(0, option.data[x].生产资源.length - 1)
                                                            HProducedTogether.push(HMaterSourceData[y]);
                                                            HProducedTogetherIndex.push(x);
                                                            console.log("生产订单:" + option.data[x].生产订单号 + ",可以与订单" + option.data[i].生产订单号 + "一起进行生产")
                                                            HArrIndex_PC.push(x);
                                                            break;
                                                        } else {
                                                            //没有匹配到产品器具清单,继续匹配下一优先级订单共同生产
                                                            continue;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    //#endregion
                                } else {
                                    console.log("第" + (i + 1) + "行,优先级" + option.data[i].优先级 + ",没有匹配到生产资源:" + sql);
                                }
                            } else {
                                layer.alert(data1.code + data1.Message, { icon: 5 });
                                layer.alert(data1.code + data1.Message, { icon: 5 });
                            }
                        }, error: function () {
                            layer.alert("接口请求失败!", { icon: 5 });
                        }
                    });
                }
                //#endregion
                //是否能匹配到合适的产品器具清单,匹配不到则跳过当前订单
                if (HIsContinue) {
@@ -2825,13 +2930,13 @@
                                lSourceID = ds[j]["HitemID"];
                                sSourceName = ds[j]["资源名称"];
                                sSourceNumber = ds[j]["资源代码"];
                                option.data[i]["HSourceID"] = lSourceID;
                                option.data[i]["生产资源"] = sSourceName;
                                option.data[i]["HSourceID"] = option.data[i]["HSourceID"] == null ? lSourceID : option.data[i]["HSourceID"];
                                option.data[i]["生产资源"] = option.data[i]["生产资源"] == null ? sSourceName : option.data[i]["生产资源"];
                                option.data[i]["生产资源代码"] = sSourceNumber;
                                console.log("======" + "第" + (i + 1) + "行订单:" + option.data[i].生产订单号 + ", è‡ªåŠ¨åŒ¹é…" + ds.length + "个生产资源,最终选择:" + sSourceName);
                                //console.log("======" + "第" + (i + 1) + "行订单:" + option.data[i].生产订单号 + ", è‡ªåŠ¨åŒ¹é…" + ds.length + "个生产资源,最终选择:" + sSourceName);
                                var sql = "exec h_p_Sc_ICMOGetWorkSourceTime " + lSourceID;
                                var sql = "exec h_p_Sc_ICMOGetWorkSourceTime_TK_HJPC " + option.data[i]["HSourceID"] + "," + option.data[i].HMouldID;
                                $.ajax({
                                    url: GetWEBURL() + '/Gy_SOPBillList/WindowPrintList',
                                    type: "GET",
@@ -2858,7 +2963,14 @@
                                    //将数据排到网格中
                                    SetInfoToGrid(option, dsSub, null, (iRow - 1), iLeftQty, sWorkQty, false, HPlanDay);
                                    set_AddNew_HJPC(option.data[i]);
                                    for (var z = 0; z < option.data[i].所需工位数; z++) {
                                        if (z == 0) {
                                            set_AddNew_HJPC(option.data[i]);
                                        } else {
                                            //option.data[i].HSourceID = HChildSourceData[z].子资源ID;
                                            //set_AddNew_HJPC(option.data[i]);
                                        }
                                    }
                                }
                                bFind = true;
@@ -2869,14 +2981,84 @@
                        }
                    }
                }
                var new_date = new Date();
                var difftime = (new_date - old_date) / 1000; //计算时间差,并把毫秒转换成秒
                //共同生产订单排产
                if (HProducedTogether.length > 0) {
                    //开始排单
                    bFind = false;
                    //超交货期  ä»ç„¶æŽ’程
                    for (var j = 0; j < HProducedTogether.length; j++) {
                        $("tr[data-index='" + HProducedTogetherIndex[j] + "']").attr({ "style": "background:White;color:black;" });
                var days = parseInt(difftime / 86400); // å¤©  24*60*60*1000
                var hours = parseInt(difftime / 3600) - 24 * days;    // å°æ—¶ 60*60 æ€»å°æ—¶æ•°-过去的小时数=现在的小时数
                var minutes = parseInt(difftime % 3600 / 60); // åˆ†é’Ÿ -(day*24) ä»¥60秒为一整份 å–ä½™ å‰©ä¸‹ç§’æ•° ç§’æ•°/60 å°±æ˜¯åˆ†é’Ÿæ•°
                var seconds = parseInt(difftime % 60);  // ä»¥60秒为一整份 å–ä½™ å‰©ä¸‹ç§’æ•°
                console.log("时间差是: " + days + "天, " + hours + "小时, " + minutes + "分钟, " + seconds + "秒");
                        sPlanQty = option.data[HProducedTogetherIndex[j]]["拆单数量"];
                        HReportQty = option.data[HProducedTogetherIndex[j]]["拆单汇报数量"];
                        sWorkQty = option.data[HProducedTogetherIndex[j]]["小时产能"];
                        if (SDSum > 0) {
                            sPlanQty = sPlanQty - SDSum - HReportQty;
                        }
                        //剩余需求工时
                        iLeftQty = sPlanQty - HReportQty;
                        if (sWorkQty <= 0) {
                            sLeftProdTimes = 0;
                        }
                        else {
                            sLeftProdTimes = iLeftQty / sWorkQty;
                        }
                        //判断资源剩余工时,是否大于 ç”Ÿäº§å‘¨æœŸ
                        if (parseFloat(HProducedTogether[j]["剩余工时"]) >= sLeftProdTimes) {
                            if (iLeftQty > 0) // ç”Ÿäº§è®¢å•剩余数量
                            {
                                //在本资源上生产
                                //获取该生产资源的剩余工时进行排程。
                                lSourceID = HProducedTogether[j]["HitemID"];
                                sSourceName = HProducedTogether[j]["资源名称"];
                                sSourceNumber = HProducedTogether[j]["资源代码"];
                                option.data[HProducedTogetherIndex[j]]["HSourceID"] = option.data[HProducedTogetherIndex[j]]["HSourceID"] == null ? lSourceID : option.data[HProducedTogetherIndex[j]]["HSourceID"]
                                option.data[HProducedTogetherIndex[j]]["生产资源"] = option.data[HProducedTogetherIndex[j]]["生产资源"] == null ? sSourceName : option.data[HProducedTogetherIndex[j]]["生产资源"];
                                option.data[HProducedTogetherIndex[j]]["生产资源代码"] = sSourceNumber;
                                //console.log("======" + "第" + (i + 1) + "行订单:" + option.data[i].生产订单号 + ", è‡ªåŠ¨åŒ¹é…" + ds.length + "个生产资源,最终选择:" + sSourceName);
                                var sql = "exec h_p_Sc_ICMOGetWorkSourceTime_TK_HJPC " + option.data[HProducedTogetherIndex[j]]["HSourceID"] + "," + option.data[HProducedTogetherIndex[j]].HMouldID;
                                $.ajax({
                                    url: GetWEBURL() + '/Gy_SOPBillList/WindowPrintList',
                                    type: "GET",
                                    async: false,
                                    data: { "sWhere": sql },
                                    success: function (data1) {
                                        if (data1.count == 1) {
                                            dsSub = data1.data
                                        } else {
                                            layer.alert(data1.code + data1.Message, { icon: 5 });
                                        }
                                    }, error: function () {
                                        layer.alert("接口请求失败!", { icon: 5 });
                                    }
                                });
                                if (dsSub == null || dsSub.length == 0) {
                                    get_HFData(1, HProducedTogetherIndex[j]);
                                    continue;//如果没有剩余则 æ‰§è¡Œä¸‹ä¸€ä¸ªç”Ÿäº§è®¢å•
                                }
                                if (dsSub != null)//不加班排程
                                {
                                    iRow = HProducedTogetherIndex[j] + 1;
                                    //将数据排到网格中
                                    SetInfoToGrid(option, dsSub, null, (iRow - 1), iLeftQty, sWorkQty, false, HPlanDay);
                                    set_AddNew_HJPC(option.data[HProducedTogetherIndex[j]]);
                                }
                                bFind = true;
                                break;
                            }
                        } else {
                            get_HFData(1, HProducedTogetherIndex[j]);
                        }
                    }
                    HProducedTogether = [];
                }
            }
            table.render(option);
            get_FastQuery(2);
@@ -3150,13 +3332,13 @@
        }
        //物料匹配产品器具清单
        function get_MouldByMater(HMaterID, HSourceID) {
        function get_MouldByMater(HMaterID, HSourceID, HPCDate) {
            var HReturnData = [];
            $.ajax({
                url: GetWEBURL() + '/JIT_DayPlanPlatFormBill/GetMouldByMater',
                type: "GET",
                async: false,
                data: { "HMaterID": HMaterID, "HSourceID": HSourceID },
                data: { "HMaterID": HMaterID, "HSourceID": HSourceID, "HPCDate": HPCDate},
                success: function (data1) {
                    if (data1.count == 1) {
                        HReturnData = data1.data;
@@ -3164,7 +3346,7 @@
                        console.log(new Date() + ",匹配产品器具清单出错1");
                    }
                }, error: function () {
                    console.log(new Date() + ",匹配产品器具清单出错1");
                    console.log(new Date() + ",匹配产品器具清单出错2");
                }
            });
            return HReturnData;
@@ -3182,13 +3364,55 @@
                    if (data1.count == 1) {
                        HReturnData = data1.data;
                    } else {
                        console.log(new Date() + ",匹配产品器具清单出错1");
                        console.log(new Date() + ",匹配产品器具清单出错2");
                    }
                }, error: function () {
                    console.log(new Date() + ",匹配产品器具清单出错1");
                }
            });
            return HReturnData;
        }
        //判断多个订单是否能一起放到同一个生产资源进行生产
        function get_MaterSource(HMaterID) {
            var HMaterSourceData = [];
            $.ajax({
                url: GetWEBURL() + '/JIT_DayPlanPlatFormBill/GetSourceByMater',
                type: "GET",
                async: false,
                data: { "HMaterID": HMaterID },
                success: function (data1) {
                    if (data1.count == 1) {
                        HMaterSourceData = data1.data;
                    } else {
                        console.log(new Date() + ",匹配物料资源出错1");
                    }
                }, error: function () {
                    console.log(new Date() + ",匹配物料资源出错2");
                }
            });
            return HMaterSourceData;
        }
        //通过主生产资源匹配出子生产资源
        function get_ChildSource(HSourceID) {
            var HChildSource = [];
            $.ajax({
                url: GetWEBURL() + '/JIT_DayPlanPlatFormBill/GetChildSource',
                type: "GET",
                async: false,
                data: { "HSourceID": HSourceID },
                success: function (data1) {
                    if (data1.count == 1) {
                        HChildSource = data1.data;
                    } else {
                        console.log(new Date() + ",获取子生产资源2");
                    }
                }, error: function () {
                    console.log(new Date() + ",获取子生产资源1");
                }
            });
            return HChildSource;
        }
        //查询生产订单
@@ -3665,12 +3889,11 @@
                dataType: "json",
                success: function (data) {
                    if (data.count == 1) {
                        $.ajax({
                            url: GetWEBURL() + '/JIT_DayPlanPlatFormBill/AddMouldOccupancyTime',
                            type: "GET",
                            async: false,
                            data: { "HMouldID": num.HMouldID, "HSourceID": num.HSourceID, "HICMOInterID": num.HICMOInterID, "HICMOEntryID": num.HICMOEntryID, "HMouldPCTime": num.HMouldPCTime },
                            data: { "HMouldID": num.HMouldID, "HSourceID": num.HSourceID, "HICMOInterID": num.HICMOInterID, "HICMOEntryID": num.HICMOEntryID, "HICMOBillNo": num.生产订单号, "HMouldPCTime": num.HMouldPCTime },
                            success: function (data1) {
                                if (data1.count == 1) {
@@ -4191,7 +4414,17 @@
                    item.规格型号 = item.规格型号.replace(/[,]+/g, ',');  // å°†æ¢åˆ†å·æ›¿æ¢ä¸ºç©ºå­—符串
                }
            });
            for (let i = 19; i < option.cols[0].length - 42; i++)
            {
                option.cols[0][i].title = Format(option.cols[0][i].title, 'MM-dd').toString();
            }
            table.exportFile(ins.config.id, data, "xls");
            for (let i = 19; i < option.cols[0].length - 42; i++) {
                option.cols[0][i].title = Format(option.cols[0][i].title, 'MM.dd');
            }
        }
        //排产功能