function remove_for_proc($proc_id) { $proc = Process::find_by_id($proc_id); $proc->image = ''; $proc->save(); echo 'success'; }
function search_order_by_proc_name($start_date, $end_date) { // 按工序名称查询指定时间段内的工序 // 投产日期非空 $procs = Process::find('all', array('conditions' => array('DATE(`production_date`) > ? AND `is_done` = ? AND DATE(`planned_completion_date`) >= ? AND DATE(`planned_completion_date`) <= ?', 0, 0, $start_date, $end_date), 'order' => 'name asc')); //debug( $procs ); // 过滤急件,将工序对应的零件分类存储 $results = array(); foreach ($procs as $proc) { // 急件 if ($proc->part->production->is_urgent) { $part = $proc->part; // 创建 part if (!isset($results[$proc->name][$part->id])) { $results[$proc->name][$part->id] = array('part_num' => $part->num, 'part_name' => $part->name, 'part_count' => $part->count, 'procs' => array(array('proc_priority' => $proc->priority, 'proc_planned_completion_date' => $proc->planned_completion_date ? date('Y-m-d', strtotime($proc->planned_completion_date)) : '', 'proc_production_date' => $proc->production_date ? date('Y-m-d', strtotime($proc->production_date)) : '', 'proc_completion_date' => $proc->completion_date ? date('Y-m-d', strtotime($proc->completion_date)) : ''))); } else { // 追加 procs $results[$proc->name][$part->id]['procs'][] = array('proc_priority' => $proc->priority, 'proc_planned_completion_date' => $proc->planned_completion_date ? date('Y-m-d', strtotime($proc->planned_completion_date)) : '', 'proc_production_date' => $proc->production_date ? date('Y-m-d', strtotime($proc->production_date)) : '', 'proc_completion_date' => $proc->completion_date ? date('Y-m-d', strtotime($proc->completion_date)) : ''); } } } //debug( $results ); render_with_layout('misc.php', 'Urgent/list_group_by_proc.php', compact('results')); }
function month_item_plan($start_date, $end_date, $_group_id = '') { $groups = Process::stat_item_month_plan($start_date, $end_date, $_group_id = ''); render_with_layout('misc.php', 'Statistics/item_month_plan.php', compact('groups')); }
function auto_cal_proc_planned_completion_date($start_date, $end_date) { if (!has_perm(2, 4)) { exit; } $procs = Process::find('all', array('conditions' => array(" is_done = ? AND ( planned_completion_date is NULL OR planned_completion_date = 0 ) AND takt_time > 0 AND production_date >= ? AND production_date <= ?", 0, $start_date, $end_date))); foreach ($procs as $proc) { $cycle = cal_proc_production_cycle($proc); $proc->cycle = $cycle; $proc->planned_completion_date = cal_proc_planned_completion_date($proc->production_date, $cycle); $proc->save(); } render_with_layout('misc.php', 'Misc/auto_cal_proc_planned_completion_date.php', array('count' => count($procs))); }
function copy_parts($target_id, $id) { $part = Part::find_by_id($id); // 复制零件节点 $item['num'] = str_replace('*', '', $part->num) . '-' . rand(0, 100) . '*'; $item['name'] = $part->name; $item['graphic_num'] = $part->graphic_num; $item['count'] = 0; //$part->count; $item['planned_completion_date'] = ''; //date('Y-m-d'); $item['feeding_price'] = 0; $item['production_date'] = ''; //date('Y-m-d'); // 零件的投产日期 $item['stuff'] = $part->stuff; $item['roughcast'] = $part->roughcast; $item['remark'] = $part->remark; $item['production_id'] = $target_id; $item['user_id'] = $_SESSION['user_id']; $_part = Part::create($item); // 复制该零件包含的所有工序 $procs = $part->processes; if (!empty($procs)) { foreach ($procs as $proc) { // 取值 $item = array(); $item['priority'] = $proc->priority; $item['name'] = $proc->name; $item['content'] = $proc->content; $item['part_id'] = $_part->id; $item['takt_time'] = ''; $item['preparation_time'] = ''; $item['price'] = ''; $item['production_date'] = ''; //date('Y-m-d'); $item['planned_completion_date'] = ''; //date('Y-m-d'); $item['remark'] = ''; $item['is_done'] = 0; $item['count'] = 0; //$_part->count; $item['count_done'] = 0; $item['user_id'] = $_SESSION['user_id']; // 保存节点 $_proc = Process::create($item); $_proc->save(); } } // 创建Part节点 $node = array('id' => $_part->id, 'name' => $_part->num . ' ' . $_part->name . ' (' . count($procs) . ')', 'font' => array('color' => $_part->is_done ? 'green' : 'black'), 'isParent' => count($procs) == 0 ? false : true, 'type' => 'part', 'icon' => get_path('/webroot/css/img/diy/3.png', true)); echo json_encode($node); }
function quick_list_get_html($part) { $app = get_app(); $cur_proc_id = ''; // 查找当前工序 foreach ($part->processes as $proc) { if (!empty($proc->production_date) && !$proc->is_done) { $cur_proc_id = $proc->id; } } if (empty($cur_proc_id)) { $processes = $part->processes; $cur_proc_id = $processes[0]->id; } // 渲染现场工时列表View $staffs = Staff::find('all', array('order' => 'id asc')); $works = Work::find_all_by_process_id($cur_proc_id, array('order' => 'id asc')); if (count($works)) { $slider_step = get_slider_step($works); $loongest_float_work = get_loongest_float_num_work($works); $fixed_num = get_float_num($loongest_float_work->count); } else { $slider_step = 1; $fixed_num = 2; } $available_count = Process::get_available_count($cur_proc_id, $fixed_num); $proc_id = $cur_proc_id; return array('html' => $app->view->fetch('Works/list.php', compact('proc_id', 'works', 'staffs', 'available_count', 'slider_step')), 'cur_proc_id' => $cur_proc_id); }
function reset_done($proc_id) { if (!has_perm(2, 4)) { exit; } $proc = Process::find_by_id($proc_id); if ($proc) { $proc->count_done = 0; $proc->is_done = false; $proc->completion_date = ''; $proc->save(); // 更新上一级节点 Part::update_count($proc->part); Production::update_count($proc->part->production); // echo 'success'; } }