PHP代码改写成JavaScript代码,求大年夜神协助!!!

方圆百里我最屌 发布于 05/22 15:53
浏览 168
收藏 0
public function actionHandle()
{
    // 对应 Y 轴 关系
    $relation = [
    '3002a' => ['name' => '2#回火炉', 'index' => 0],
    '3001a' => ['name' => '1#回火炉', 'index' => 1],
    '2002a' => ['name' => '2#冷水机', 'index' => 2],
    '2001a' => ['name' => '1#清洗机', 'index' => 3],
    '1004a' => ['name' => '4#加热炉', 'index' => 4],
    '1003a' => ['name' => '3#加热炉', 'index' => 5],
    '1002a' => ['name' => '2#加热炉', 'index' => 6],
    '1001a' => ['name' => '1#加热炉', 'index' => 7],
    ];
    // sql 语句
    $sql = "select * from ctrl_lmstask";
    // 履行 sql
    $result = Yii::$app->db->createCommand($sql)->queryAll();

    $data = [ ];
    foreach ($result as $key => $value) {
        $tempData = [isset($relation[$value['EquipSerial']]['index']) ? 
            $relation[$value['EquipSerial']]['index'] : '', $value['PlanStartTime'], 
            $value['PlanEndTime']];
        $name = $value['BatchIndex'];
        $temp[$name][] = $tempData;
        // 不克不及持续轮回 或许 下次轮回的 name 和以后值不合,解释以后 name 处理停止
        if (!isset($result[$key + 1]) || $result[$key + 1]['BatchIndex'] != $name) {
            $data[] = [
                    'name' => $name,
                    'data' => $temp[$name]
            ];
        }
    }
    echo json_encode($temp);
    echo "\n";
    echo json_encode($data);
    echo "\n";
}

 

加载中
0
梅开源
梅开源

你们公司哪个要用node.js的叫他来改

 

前往顶部
顶部