大差法:流水步距计算工期

大差法:流水步距计算工期

纯前端 + javascript,实现大差法

异节奏流水施工:异节奏流水施工就是每个施工过程的流水步距都不相等,且每个施工段上的流水节拍也不相等。

大差法公式:T=T1+(n-1)K。
式中T为施工总工期;T1为一个施工段或一个单位工程的工期;n为施工段或单位工程的数目;K为流水步距。

即“累加数列、错位相减、取大差”。
大差法:流水步距计算工期_第1张图片
大差法:流水步距计算工期_第2张图片
大差法:流水步距计算工期_第3张图片
第一步:累加
大差法:流水步距计算工期_第4张图片
第二步:错位相减、取大差
大差法:流水步距计算工期_第5张图片
第三步:计算工期
大差法:流水步距计算工期_第6张图片


<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <base href="<%=basePath%>">

    <title>testtitle>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">

    <style type="text/css">
        .right {
            margin: 0% 10%;
            width: 600px;
        }

        .right table {
            background: white;
            width: 100%;
            border: 1px solid #499B33;
        }

        .right td {
            background: blue;
            text-align: center;
            padding: 2px;
            border: 1px solid #499B33;
        }

        .right td {
            background: #8FBC8F;
        }

        .item {
            text-align: center;
            width: 100px;
        }

        .assigned {
            border: 1px solid #BC2A4D;
        }
    style>
    <script>
        // 全局变量
        var tList = [];
        var hljList = [];
        var maxList = [];
        //
        function table() {
            if (document.getElementById("Col").value == "" || document.getElementById("Col").value.search("^[0-9]*$") ==
                -1) {
                document.getElementById("errmsg1").style.display = "block"; //判断payNum是否为空或不是数字    提示错误
                document.getElementById("errmsg1").innerHTML = "提示信息:列数数为空或不是数字!";
                return;
            }
            if (document.getElementById("Num").value == "" || document.getElementById("Num").value.search("^[0-9]*$") ==
                -1) {
                document.getElementById("errmsg1").style.display = "block"; //判断payNum是否为空或不是数字    提示错误
                document.getElementById("errmsg1").innerHTML = "提示信息:行数为空或不是数字!";
                return;
            } else {
                document.getElementById("errmsg1").style.display = "none"; //隐藏提示信息
                var Col = parseInt(document.getElementById("Col").value); //获取列数
                var Num = parseInt(document.getElementById("Num").value); //获取行数
                var flag = true;
                var data = "";
                data += " ";
                data +=" ";for(var j =0; j <= Col; j++){if(j ==0){
                        data +="";}else{
                        data +="";}}
                data +="";// for(var i =1; i <= Num; i++){
                    data +="";for(var j =0; j <= Col; j++){if(j ==0){
                            data +="";}else{
                            data +="";}}
                    data +="";}

                data +="
分项 数据" + j + "
分类" + i + "
"
; document.getElementById("div1").style.display = "block"; document.getElementById("table1").innerHTML = data; } } function cumulativeSummation() { // var pElement = document.getElementById("div1"); // var childList = getElementsByClassName(pElement, "dataInput"); // var Col = parseInt(document.getElementById("Col").value); //获取列数 var Num = parseInt(document.getElementById("Num").value); //获取行数 tList = []; for (var i = 1; i <= Num; i++) { var tArray = []; for (var j = 1; j <= Col; j++) { var tValue = Number(document.getElementById('rc_' + i + "_" + j).value); tArray.push(tValue); } tList.push(tArray); } // hljList = []; for (var i = 0; i < tList.length; i++) { var hljArray = []; for (var j = 0; j < tList[i].length; j++) { var tijList = tList[i].slice(0, j + 1); var hangleijia = arraySum(tijList); hljArray.push(hangleijia); } hljList.push(hljArray); } // var divHtml = ""; for (var i = 0; i < hljList.length; i++) { divHtml += "
"; divHtml += "分类" + (i + 1) + ":(累加求和)"; for (var j = 0; j < hljList[i].length; j++) { divHtml += "" + hljList[i][j] + ""; } divHtml += "
"
; } document.getElementById("div2").innerHTML = divHtml; } function dislocationSubtraction() { var hljList_new_str = JSON.stringify(hljList); var hljList_new = JSON.parse(hljList_new_str); // var divHtml = ""; for (var i = 0; i < hljList_new.length - 1; i++) { // var maxArray = []; // hljList_new[i].push(0); hljList_new[i + 1].unshift(0); divHtml += "
"; divHtml += "分类" + (i + 1) + " - 分类" + (i + 2) + ":"; for (var j = 0; j < hljList_new[i].length; j++) { var j_j = hljList_new[i][j] - hljList_new[i + 1][j] maxArray.push(j_j); divHtml += "" + j_j + ""; } var max_j_j = Math.max.apply(null, maxArray); maxList.push(max_j_j); divHtml += "最大值:" + max_j_j + ""; divHtml += "
"
; // if (i == hljList_new.length - 2) { // } else { hljList_new[i + 1].splice(0, 1); } } document.getElementById("div3").innerHTML = divHtml; } function calculateConstructionPeriod() { var divHtml = ""; divHtml += "("; for (let i = 0; i < maxList.length; i++) { if(i == maxList.length - 1){ divHtml += "" + maxList[i] + ""; } else { divHtml += "" + maxList[i] + " + " + ""; } } divHtml += ")+"; // divHtml += "("; for (let i = 0; i < tList[tList.length - 1].length; i++) { if(i == tList[tList.length - 1].length - 1){ divHtml += "" + tList[tList.length - 1][i] + ""; } else { divHtml += "" + tList[tList.length - 1][i] + " + " + ""; } } divHtml += ")"; divHtml += "" + " = " + ""; // var max1 = arraySum(maxList); var max2 = arraySum(tList[tList.length - 1]); var max3 = max1 + max2; // divHtml += "" + max3 + ""; document.getElementById("div4").innerHTML = divHtml; } function getElementsByClassName(node, classname) { if (node.getElementsByClassName) { return node.getElementsByClassName(classname); } else { var results = new Array(); var elems = node.getElementsByTag("*"); for (var i = 0; i < elems.length; i++) { if (elems[i].className.indexOf(classname) != -1) { results[elems.length] = elems[i]; } } return results; } } function arraySum(arr) { var s = 0; for (var i = arr.length - 1; i >= 0; i--) { s += arr[i]; } return s; }
script> head> <body> <br> <div style="width:750px;"> <div class="right"> <table> <tr> <td>动态生成表格td> <td><input id="Col" type="text" class="input" size="10" name="Col" />td> <td><input id="Num" type="text" class="input" size="10" name="Num" />td> tr> table> br> <input name="" type="button" value="生成" class="buttton" onclick="table()" />br> br> <div id="div1" style="display: none" mce_style="display: none"> <div id="table1">div> div> br> <input name="" type="button" value="第一步:累加求和" class="buttton" onclick="cumulativeSummation()" />br> br> <div id="div2">div> br> <input name="" type="button" value="第二步:两两错位相减取最大值" class="buttton" onclick="dislocationSubtraction()" />br> br> <div id="div3">div> br> <input name="" type="button" value="第三步:计算工期(第二步的最大值累加 + 最后一行原始数值的累加)" class="buttton" onclick="calculateConstructionPeriod()" />br> br> <div id="div4">div> br> <div id="errmsg1" class="formmsg">div> div> div> body> html>

源代码:https://download.csdn.net/download/liuliwei09/25635306

你可能感兴趣的:(js+css,算法,前端,javascript,前端,开发语言)