Ejemplo n.º 1
0
 public function indexAction()
 {
     echo '<pre>';
     $tTime = time();
     $tBSDMO = new BqeschedulingdetailModel();
     $tUAMO = new UserassessmentModel();
     $Oci = new Orm_Oci();
     #$tHSql = 'select to_char(SCHEDULING_DATE,\'YYYY-mm-dd\') scheduling_date,machine_id,time_code,patient_id,status,close_operator,to_char(close_time,\'YYYY-mm-dd HH:ii:ss\') close_time from  scheduling_detail  where to_char(SCHEDULING_DATE,\'YYYY-mm-dd\') between \''.date('Y-m-d',$tTime-86400*90).'\'  and \''.date('Y-m-d',$tTime+86400*3).'\' order by SCHEDULING_DATE desc';
     $tHSql = 'select to_char(SCHEDULING_DATE,\'YYYY-mm-dd\') scheduling_date,machine_id,time_code,patient_id,status,close_operator,to_char(close_time,\'YYYY-mm-dd HH:ii:ss\') close_time from  scheduling_detail  where to_char(SCHEDULING_DATE,\'YYYY-mm-dd\') between \'' . date('Y-m-d', $tTime - 86400) . '\'  and \'' . date('Y-m-d', $tTime + 86400 * 3) . '\' order by SCHEDULING_DATE desc';
     $tDatas = $Oci->getAll($tHSql);
     foreach ($tDatas as $tRow) {
         $tBSDRow = $tBSDMO->field('id,status,time_code,uid')->where('patient_id = \'' . $tRow['PATIENT_ID'] . '\' and scheduling_date = \'' . $tRow['SCHEDULING_DATE'] . '\'')->fRow();
         if (count($tBSDRow)) {
             #记录存在
             $tData = array();
             if ($tBSDRow['status'] != $tRow['STATUS']) {
                 $tData['status'] = $tRow['STATUS'];
             }
             if ($tBSDRow['time_code'] != $tRow['TIME_CODE']) {
                 $tData['time_code'] = $tRow['TIME_CODE'];
             }
             if (empty($tBSDRow['uid'])) {
                 #获取UID,纠正注册完白求恩用户
                 $tUARow = $tUAMO->field('uid')->where('patient_id = \'' . $tRow['PATIENT_ID'] . '\'')->fRow();
                 $tData['uid'] = empty($tUARow['uid']) ? 0 : $tUARow['uid'];
             }
             if (!count($tData)) {
                 continue;
             }
             $tData = array_merge($tData, array('updated' => $tTime, 'id' => $tBSDRow['id'], 'close_operator' => $tRow['CLOSE_OPERATOR'], 'close_time' => $tRow['CLOSE_TIME']));
             $tBSDMO->update($tData);
         } else {
             $tData = array('scheduling_date' => $tRow['SCHEDULING_DATE'], 'machine_id' => $tRow['MACHINE_ID'], 'time_code' => $tRow['TIME_CODE'], 'patient_id' => $tRow['PATIENT_ID'], 'status' => $tRow['STATUS'], 'close_operator' => $tRow['CLOSE_OPERATOR'], 'close_time' => $tRow['CLOSE_TIME'], 'created' => $tTime);
             $tUARow = $tUAMO->field('uid')->where('patient_id = \'' . $tRow['PATIENT_ID'] . '\'')->fRow();
             $tData['uid'] = empty($tUARow['uid']) ? 0 : $tUARow['uid'];
             $tBSDMO->insert($tData);
         }
     }
     exit;
 }