效果:
代码
php
电子看板
近半年良率、不良率
0) {
?>
月份
良品数量
不良数量
良品率 (%)
不良率 (%)
$value) {
$goodnum1[] = $value['total_transaction_quantity'];
$badnum1[] = $value['total_bad_quantity'];
$arr_good_quantity1[] = $value['good_rate'];
$arr_bad_quantity1[] = $value['bad_rate'];
$arrvendor1[] = $value['operation_code'];
}
} else {
$goodnum1[] = 0;
$badnum1[] = 0;
$arr_good_quantity1[] = 0;
$arr_bad_quantity1[] = 0;
$arrvendor1[] = 0;
}
echo "";
//计算机半年内的总良品和不良
$sql2 = "SELECT
SUM(IFNULL(transaction_quantity, 0)) AS total_transaction_quantity,
SUM(IFNULL(bad_quantity, 0)) AS total_bad_quantity,
CASE
WHEN (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0))) = 0 THEN 0
ELSE ROUND((SUM(IFNULL(transaction_quantity, 0)) / (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0)))*100), 2)
END AS good_rate,
CASE
WHEN (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0))) = 0 THEN 0
ELSE ROUND((SUM(IFNULL(bad_quantity, 0)) / (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0)))*100), 2)
END AS bad_rate,
DATE(DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-%d'), INTERVAL 6 MONTH)) AS six_months_ago
FROM
wip_transactions
WHERE
transaction_date >= UNIX_TIMESTAMP(DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-%d'), INTERVAL 6 MONTH))
AND transaction_date <= UNIX_TIMESTAMP(DATE_FORMAT(NOW(), '%Y-%m-%d'));
";
$result2 = DB_query($sql2, $db);
if ($array2 = mysqli_fetch_assoc($result2)) {
$good_rate2 = $array2['good_rate'];
$bad_rate2 = $array2['bad_rate'];
$six_months_ago2 = $array2['six_months_ago'];
} else {
$good_rate2 = 0;
$bad_rate2 = 0;
$six_months_ago2 = 0;
}
$array2 = array(
(object)array('value' => $good_rate2, 'name' => '良品率'),
(object)array('value' => $bad_rate2, 'name' => '不良率')
);
echo "";
//计算总的良品和不良
$sql3 = "SELECT
SUM( IFNULL( transaction_quantity, 0 ) ) AS total_transaction_quantity,
SUM( IFNULL( bad_quantity, 0 ) ) AS total_bad_quantity,
CASE
WHEN (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0))) = 0 THEN 0
ELSE ROUND((SUM(IFNULL(transaction_quantity, 0)) / (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0)))*100), 2)
END AS good_rate,
CASE
WHEN (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0))) = 0 THEN 0
ELSE ROUND((SUM(IFNULL(bad_quantity, 0)) / (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0)))*100), 2)
END AS bad_rate
FROM wip_transactions";
$result3 = DB_query($sql3, $db);
if ($array3 = mysqli_fetch_assoc($result3)) {
$good_rate3 = $array3['good_rate'];
$bad_rate3 = $array3['bad_rate'];
} else {
$good_rate3 = 0;
$bad_rate3 = 0;
}
$array3 = array(
(object)array('value' => $good_rate3, 'name' => '良品率'),
(object)array('value' => $bad_rate3, 'name' => '不良率')
);
echo "";
//计算总的良品和不良
$sql4 = "SELECT
wt.employee_num,
he.employee_name,
SUM(IFNULL(wt.transaction_quantity, 0)) AS total_transaction_quantity,
SUM(IFNULL(wt.bad_quantity, 0)) AS total_bad_quantity,
CASE
WHEN (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0))) = 0 THEN 0
ELSE ROUND((SUM(IFNULL(transaction_quantity, 0)) / (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0)))*100), 2)
END AS good_rate,
CASE
WHEN (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0))) = 0 THEN 0
ELSE ROUND((SUM(IFNULL(bad_quantity, 0)) / (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0)))*100), 2)
END AS bad_rate
FROM
wip_transactions wt, hr_employees he
WHERE
wt.employee_num = he.employee_num
-- AND transaction_date >= UNIX_TIMESTAMP(DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-%d'), INTERVAL 6 MONTH))
-- AND transaction_date <= UNIX_TIMESTAMP(DATE_FORMAT(NOW(), '%Y-%m-%d'))
GROUP BY
wt.employee_num
ORDER BY
bad_rate desc
";
$result4 = DB_query($sql4, $db);
while ($array4 = mysqli_fetch_assoc($result4)) {
$arrays4[] = $array4;
}
if (is_array($arrays4)) {
foreach ($arrays4 as $key => $value) {
$good_rate4[] = $value['good_rate'];
$bad_rate4[] = $value['bad_rate'];
$goodnum4[] = $value['total_transaction_quantity'];
$badnum4[] = $value['total_bad_quantity'];
$employee_name[] = $value['employee_name'];
}
} else {
$good_rate4[] = 0;
$bad_rate4[] = 0;
$goodnum4[] = 0;
$badnum4[] = 0;
$employee_name[] = 0;
}
echo "";
//查询站别的良率、不良率
// $sql5 = "SELECT
// operation_code,
// SUM(IFNULL(transaction_quantity, 0)) AS total_transaction_quantity,
// SUM(IFNULL(bad_quantity, 0)) AS total_bad_quantity,
// CASE
// WHEN (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0))) = 0 THEN 0
// ELSE ROUND((SUM(IFNULL(transaction_quantity, 0)) / (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0)))*100), 2)
// END AS good_rate,
// CASE
// WHEN (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0))) = 0 THEN 0
// ELSE ROUND((SUM(IFNULL(bad_quantity, 0)) / (SUM(IFNULL(transaction_quantity, 0)) + SUM(IFNULL(bad_quantity, 0)))*100), 2)
// END AS bad_rate
// FROM wip_transactions
// GROUP BY operation_code";
// $result5 = DB_query($sql5, $db);
//员工工时
$sql6 = "SELECT
wt.employee_num,he.employee_name,
SUM((end_date - begin_date) / 3600) AS total_hours,
SUM((end_date - begin_date) / (3600 * 24)) AS total_days,
SUM((end_date - begin_date) / (3600 * 24 * 365)) AS total_years
FROM wip_transactions wt, hr_employees he
WHERE wt.employee_num = he.employee_num
GROUP BY wt.employee_num";
$result6 = DB_query($sql6, $db);
while ($array6 = mysqli_fetch_assoc($result6)) {
$arrays6[] = $array6;
}
if (is_array($arrays6)) {
foreach ($arrays6 as $key => $value) {
$total_hours6[] = $value['total_hours'];
$total_days6[] = $value['total_days'];
$total_years6[] = $value['total_years'];
$employee_name6[] = $value['employee_name'];
}
} else {
$total_hours6[] = 0;
$total_days6[] = 0;
$total_years6[] = 0;
$employee_name6[] = 0;
}
echo "";
// 待生产工时统计
$sql7 = "SELECT a.operation_code,operation_name,sum(begin_quantity*standard_time) as paipei,sum(a.output_quantity*standard_time) wancheng,sum((begin_quantity-a.output_quantity)*standard_time) wait
from wip_operation_plan a,bom_parameters b,wip_jobs_all c
where a.operation_code=b.operation_code
and begin_quantity>a.output_quantity
and standard_time>0
and a.wip_entity_name=c.wip_entity_name
GROUP BY a.operation_code,operation_name
order by a.operation_code desc";
$result7 = DB_query($sql7, $db);
while ($array7 = mysqli_fetch_assoc($result7)) {
$arrays7[] = $array7;
}
if (is_array($arrays7)) {
foreach ($arrays7 as $key => $value) {
$arramount7[] = $value['wait'];
$arrvendor7[] = $value['operation_name'];
}
} else {
$arramount7[] = 0;
$arrvendor7[] = 0;
}
echo "";
css
body {
background-color: #f3f6fb;
padding: 0px;
margin: 0px;
}
.kanban_all {
/* border: 1px solid black; */
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.kanban_all_position {
/* border: 1px solid black; */
width: 98%;
display: flex;
flex-wrap: wrap;
}
.kanban_line {
/* border: 1px solid black; */
width: calc(50% - 2%);
margin: 1% 1% 0 1%;
background-color: #fff;
}
.kanban_title {
background-color: #fff;
padding: 2%;
font-size: 120%;
font-weight: bold;
font-family: '华文细黑';
border-left: 4px solid #75b2fa;
border-bottom: 1px solid #f3f6fb;
}
.kanban_content {
padding: 1%;
background-color: #fff;
}
.kanban_content table {
width: 100%;
/* border: 1px solid green; */
}
.kanban_content table td {
width: 100%;
/* 或者您可以根据需求设置其他百分比值,例如33.33% */
}
.kanban_line_double {
/* border: 1px solid blue; */
display: flex;
justify-content: center;
width: 100%;
height: 100%;
}
.kanban_line_double .left {
/* border: 1px solid red; */
width: 48%;
height: 100%;
}
.kanban_line_double .left .kanban_title {
padding: 4%;
}
/*
.kanban_line_double .left .kanban_content {
padding: 2%;
} */
.kanban_line_double .middle {
background-color: #f3f6fb;
width: 4%;
}
.kanban_line_double .right {
/* border: 1px solid black; */
width: 48%;
height: 100%;
}
.kanban_line_double .right .kanban_title {
padding: 4%;
}
/*
.kanban_line_double .right .kanban_content {
padding: 2%;
} */
/* 表格 */
.table {
text-align: center;
/* border: 1px solid black; */
border-collapse: collapse;
}
.table tr th {
width: 20%;
/* border: 1px solid black; */
color: #5a5a5a;
font-weight: bold;
}
.table tr td {
width: 20%;
text-align: center;
padding-top: 1%;
color: #5a5a5a;
}