code
stringlengths
1
1.73M
language
stringclasses
1 value
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attac...
Ruby
# Be sure to restart your server when you modify this file. TrainSegmentMaintain::Application.config.session_store :cookie_store, :key => '_TrainSegmentMaintain_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create th...
Ruby
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a probl...
Ruby
TrainSegmentMaintain::Application.configure do # Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching...
Ruby
TrainSegmentMaintain::Application.configure do # Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to rest...
Ruby
TrainSegmentMaintain::Application.configure do # Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" ...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application TrainSegmentMaintain::Application.initialize!
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. gemfile = File.expand_path('../../Gemfile', __FILE__) begin ENV['BUNDLE_GEMFILE'] = gemfile require 'bundler' Bundler.setup rescue Bundler::GemNotFound => e STDERR.puts e.message STDERR.puts "Try running `bundle install`." exit! end if File.exist?(gem...
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined?(Bundler) module TrainSegmentMaintain class Application < Rails::Appl...
Ruby
TrainSegmentMaintain::Application.routes.draw do get "log/logList" # The priority is based upon order of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action # Sample ...
Ruby
module WorkerHelper end
Ruby
module ApplicationHelper end
Ruby
module ErrorsHelper end
Ruby
module RecordHelper end
Ruby
module CheckrecordHelper end
Ruby
module TrackHelper end
Ruby
module LogHelper end
Ruby
module TestHelper end
Ruby
class Maintenance < ActiveRecord::Base belongs_to :work belongs_to :team belongs_to :train_task belongs_to :worker has_many :checkrecords has_one :train, :through => :train_task #根据train_task_id来查找记录,并且进行分页 def self.findPageByTrainTaskId(offset, limit ,train_task_id) find(:all, :offse...
Ruby
class Errortime < ActiveRecord::Base end
Ruby
class Track < ActiveRecord::Base has_many :records belongs_to :sametrack,:class_name => "Track",:foreign_key => "same_track" has_one :atrack,:class_name => "Track" def self.findPage offset,limit find(:all,:offset => offset,:limit => limit) end end
Ruby
class Log < ActiveRecord::Base end
Ruby
class Router < ActiveRecord::Base has_many :trains, :through => :train_router def self.findByTrainNumber trainNumber find(:first,:conditions => ['train_number = ?',trainNumber]) end def self.findPage offset,limit find( :all, :offset => offset, :limit => limit ) end end
Ruby
class Worker < ActiveRecord::Base belongs_to :team has_many :maintenances has_many :records def self.findWorkersByTeam team_id,start,limit find(:all,:conditions => ['team_id = ? AND is_locked = 0',team_id],:offset => start, :limit => limit,:order=> 'number') end def self.countWorkersByTeam team_id ...
Ruby
class Record < ActiveRecord::Base belongs_to :worker belongs_to :track def self.findRecords name,begin_time,end_time,track_id,start,limit conditionsStr = '(worker_id in (select id from workers where name like :name))' conditionsHash = Hash.new conditionsHash[:name] = '%'+name+'%' if begin_time !...
Ruby
class Template < ActiveRecord::Base has_many :standardMaintenance end
Ruby
class Checkrecord < ActiveRecord::Base belongs_to :maintenance belongs_to :worker belongs_to :train_task def self.find_by_train_task train_task_id find_by_sql "select w.name worker_name,t.name team_name,tr.sn train_name,tt.stop_track track,cr.check_in_time,cr.check_out_time,cr.dynamic_check_in_time,cr.d...
Ruby
class Team < ActiveRecord::Base has_many :maintenance has_many :standardMaintenance has_many :work has_many :worker belongs_to :leader, :class_name=>"Worker", :foreign_key=>"worker_id" has_many :managers, :class_name => "Worker",:foreign_key => "team_id",:conditions => {:is_manager => 1} ...
Ruby
class Account < ActiveRecord::Base def self.findByNameAndPassword username,password find(:first,:conditions => ['username = ? AND password = ?',username,password]) end def self.findPage offset,limit find( :all, :offset => offset, :limit => limit ) end end
Ruby
class StandardMaintenance < ActiveRecord::Base belongs_to :work belongs_to :team belongs_to :template end
Ruby
class TrainTask < ActiveRecord::Base has_many :maintenances , :dependent => :destroy belongs_to :train has_many :checkrecords, :dependent => :destroy def self.findBySn sn find(:first,:conditions => ['sn = ?',sn]) end def self.findPageByTrainId(offset, limit ,train_id) find(:all, :offset ...
Ruby
class Work < ActiveRecord::Base has_many :maintenance has_many :standardMaintenance def self.findPage offset,limit find( :all, :offset => offset, :limit => limit ) end end
Ruby
class TrainRouter < ActiveRecord::Base belongs_to :train belongs_to :router def self.findPageByTrainId(offset, limit ,trainId) find(:all, :offset => offset, :limit => limit, :conditions => ['train_id = ?', trainId], :order => 'sequence') end def self.findByTrainIdAn...
Ruby
class Train < ActiveRecord::Base has_many :daily has_many :train_task has_many :routers , :through => :train_router def self.findPage offset,limit find(:all,:offset => offset,:limit => limit) end #已经锁定的记录,不进行选择。 def self.findBySn sn find(:all,:conditions=>['is_locked = 0 AND sn like ?','%'+sn+'%...
Ruby
class Daily < ActiveRecord::Base belongs_to :train def self.findFirstByDate find( :first, :order=>'date DESC' ) end def self.findAllByDate date find(:all, :conditions => ['date = ?',date] ) end def self.findDistinctDate find( :all, :select => "DISTINCT da...
Ruby
class DbLog < ActiveRecord::Base scope :paginate, lambda { |start,limit| { :offset => start.to_i,:limit => limit.to_i,:order=>"id DESC" }} def self.info( cName , aName ,ip, info) dbLog = DbLog.new dbLog.c_name = cName dbLog.a_name = aName dbLog.ip = ip dbLog.description = info dbLog.save! ...
Ruby
class Number < ActiveRecord::Base def self.findPage offset,limit find( :all, :offset => offset, :limit => limit ) end end
Ruby
class TrackController < ApplicationController before_filter :sys_before_log #获取所有组队的信息 def getTracks total = Track.count tracks = Track.findPage params[:start].to_i,params[:limit].to_i jsonStr="{track:"+tracks.to_json()+",total:"+total.to_s+"}" render :text => jsonStr,:layout => false end d...
Ruby
class ErrorsController < ApplicationController end
Ruby
class RouterController < ApplicationController before_filter :sys_before_log #获取所有固定的信息 def getRouters total = Router.count routers = Router.findPage params[:start].to_i,params[:limit].to_i jsonStr="{router:"+routers.to_json()+",total:"+total.to_s+"}" render :text => jsonStr,:layout => false en...
Ruby
class NumberController < ApplicationController before_filter :sys_before_log #获取所有列车的信息 def getNumbers total = Number.count numbers = Number.findPage params[:start].to_i,params[:limit].to_i jsonStr="{number:"+numbers.to_json()+",total:"+total.to_s+"}" render :text => jsonStr,:layout => false en...
Ruby
class WorkerController < ApplicationController before_filter :sys_before_log def getAllWorkers name = params[:query] || '' #这种情况一般是抓取所有数据,如Combobox直接下拉或直接显示列表 if params[:worker_id].nil? || params[:worker_id] == "" #如果有start说明是列表中抓取数据。否则是combobx,当然也有combobx分页的,但这儿没有给combobox分布。 if params[:st...
Ruby
class TraintaskController < ApplicationController before_filter :sys_before_log #得到trainTask列表,带分页 def getTrainTasks pageBegin = params[:start].to_i pageEnd = params[:limit].to_i conditionsStr = "" #定义一个str,里面存储所有的搜索条件,后面他会不断被加长 condition...
Ruby
class TrainController < ApplicationController before_filter :sys_before_log #获取所有列车的信息,在读取列车列表的时候,不传递所有的交路信息,只把当前应该的交路信息发送到前端 def getTrains total = Train.count nowDate = Time.now.to_date #得到当前日期 trains = Train.findPage params[:start].to_i,params[:limit...
Ruby
class CheckrecordController < ApplicationController def getCheckrecords crs = Checkrecord.find_by_train_task params[:train_task_id].to_i total = crs.length jsonStr="{checkrecord:"+crs.to_json()+",total:"+total.to_s+"}" puts jsonStr render :text => jsonStr,:layout => false end #待修改 def pri...
Ruby
class LogController < ApplicationController def getAllSysLog start = params[:start] limit = params[:limit] dblogs = DbLog.paginate start,limit jsonStr="{totalProperty:"+DbLog.count.to_s+",root:"+dblogs.to_json(:include=>[:company,:department,:employee])+"}" logger.info jsonStr render :text=>...
Ruby
#任务模板,包含多个标准养护任务 class TemplateController < ApplicationController before_filter :sys_before_log #获取所有的标准模板信息 def getTemplates forCBB = params[:for_cbb] if forCBB.nil? total = Template.count templates = Template.all else templates = Template.where("is_locked = ?",forCBB) total ...
Ruby
class TestController < ApplicationController def testTime logger.info Time.now.to_json logger.info ((DateTime.parse("2011/07/13 05:39:35 +0800") - DateTime.parse("2011-07-11 16:28:12 UTC"))*24*60) end def newworker worker = Worker.new worker.name = "" worker.save! end end
Ruby
class MaintenanceController < ApplicationController before_filter :sys_before_log #获取maintenance列表,带分页 def getMaintenances total_property = Maintenance.countByTrainTaskId(params[:trainTaskId]) maintenances = Maintenance.findPageByTrainTaskId(params[:start].to_i, params[:limit].to_i,params[:trainT...
Ruby
#标准养护任务,用于构成养护任务模板 class StandardmaintenanceController < ApplicationController before_filter :sys_before_log #获取指定模板的任务列表 def getStandardMaintenances standardMaintenances = StandardMaintenance.find_all_by_template_id params[:templateId] total = standardMaintenances.length jsonStr="{standardMaintenanc...
Ruby
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base helper :all # include all helpers, all the ti...
Ruby
class DailyController < ApplicationController #在刷新dailyList页面的之前,准备以下数据发送至前台 def dailyList if(Daily.findLastedDate) date = Daily.findLastedDate.date else date = '没有日报记录' end @lastedDate = date.to_s #被自动塞进了dailyList.html.erb文件中。其他的contr...
Ruby
class AccountController < ApplicationController before_filter :sys_before_log #获取所有的账号信息 def getAccounts total = Account.count accounts = Account.findPage(params[:start].to_i, params[:limit].to_i) jsonStr="{account:"+accounts.to_json()+",total:"+total.to_s+"}" render :text => jsonStr,:layout => f...
Ruby
class TrainrouterController < ApplicationController before_filter :sys_before_log def update begin trainRouters = TrainRouter.find_all_by_train_id(params[:id]) #根据id找到对象 for trainRouter in trainRouters #删除掉所有关于此列车的router trainRouter.des...
Ruby
class IndexController < ApplicationController before_filter :sys_before_log def index if session[:account_id] == nil redirect_to '/index/login' end if session[:user_type] == 'user' @menus = @@menuMap[2] elsif session[:user_type] == 'admin' @menus = @@menuMap[1] end @menus ...
Ruby
class DemoController < ApplicationController before_filter :sys_before_log def index crs = Checkrecord.all crs.each do |cr| cr.train_task_id = cr.maintenance ? cr.maintenance.train_task_id : nil cr.save end end def text puts params[:anInOutMode]+"。。。。。。。。。。"+params[:vnDev...
Ruby
class WorkController < ApplicationController before_filter :sys_before_log #获取所有任务的信息 def getWorks total = Work.count works = Work.findPage(params[:start].to_i, params[:limit].to_i) jsonStr="{work:"+works.to_json()+",total:"+total.to_s+"}" render :text => jsonStr,:layout => false end def get...
Ruby
class TeamController < ApplicationController before_filter :sys_before_log #获取所有组队的信息 def getTeams total = Team.count teams = Team.findPage params[:start].to_i,params[:limit].to_i jsonStr="{team:"+teams.to_json(:include => {:managers => {:only => :name}})+",total:"+total.to_s+"}" render :tex...
Ruby
class RecordController < ApplicationController before_filter :sys_before_log def getRecords total = Record.countRecords params[:name].to_s,params[:begin_time].to_s,params[:end_time].to_s,params[:track_id].to_s records = Record.findRecords params[:name].to_s,params[:begin_time].to_s,params[:end_time].to_s,p...
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) require 'rake' TrainSegmentMaintain::Application.load_tasks
Ruby
source 'http://rubygems.org' gem 'rails', '3.0.9' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql', :require => 'mysql' #gem 'mysql2' # gem 'mongrel' # Use unicorn as the web server # gem 'unicorn' ...
Ruby
class AddSameTrackToTrack < ActiveRecord::Migration def self.up add_column :tracks,:same_track,:integer #标记两个在同一轨道上的股道,用于长车作业的判断 end def self.down remove_column :tracks,:same_track end end
Ruby
class CreateRecords < ActiveRecord::Migration def self.up create_table :records do |t| t.integer :worker_id #员工ID t.datetime :check_time #打卡时间 t.string :check_type ...
Ruby
#账户表,用以存储登录系统的用户名和密码 class CreateAccounts < ActiveRecord::Migration def self.up create_table :accounts do |t| t.string :username #登录名 t.string :password #密码 t.string :user_type ...
Ruby
class CreateErrortimes < ActiveRecord::Migration def self.up create_table :errortimes do |t| t.integer :errortime, :default => 10 #误差时间 t.integer :is_locked ,:limit => 1 ,:default => 0 #锁定 1为True 0为False t.integer :lock_version ...
Ruby
class AddIsManagerToWorkers < ActiveRecord::Migration def self.up add_column :workers, :is_manager, :string #是否控制任务 0-不控制 1-控制 end def self.down remove_column :workers, :is_manager end end
Ruby
class AddDynamicToMaintenance < ActiveRecord::Migration def self.up add_column :maintenances,:dynamic_check_in_time,:datetime add_column :maintenances,:dynamic_check_out_time,:datetime add_column :maintenances,:dynamic_flag,:integer,:default => 0 #标志位,0-只有静态或者动态作业,1-包括静动态作业 add_column :maintenanc...
Ruby
#团队表,用以存储团队的信息 class CreateTeams < ActiveRecord::Migration def self.up create_table :teams do |t| t.string :name #团队名称 t.integer :worker_id #组长ID t.integer :is_locked ,:limit => 1 ,:default => 0 #锁定 1为...
Ruby
class AddEndTimeToTrainTask < ActiveRecord::Migration def self.up add_column :train_tasks, :end_time, :datetime end def self.down remove_column :train_tasks, :end_time end end
Ruby
class AddDynamicToCheckreocrd < ActiveRecord::Migration def self.up add_column :checkrecords,:dynamic_check_in_time,:datetime add_column :checkrecords,:dynamic_check_out_time,:datetime add_column :checkrecords,:dynamic_flag,:integer,:default => 0 end def self.down remove_column :checkrecords,:dyn...
Ruby
class CreateRouters < ActiveRecord::Migration def self.up #固定交路表 create_table :routers do |t| t.string :train_number #车次组合 t.string :line #行车路线 t.integer :length #一次行走公里数 ...
Ruby
#标准维护任务表,用以存储具体的任务和具体的工作团队 class CreateStandardMaintenances < ActiveRecord::Migration def self.up create_table :standard_maintenances do |t| t.integer :work_id #工作id t.integer :team_id #团队id t.integer :template_i...
Ruby
class CreateCheckrecords < ActiveRecord::Migration def self.up create_table :checkrecords do |t| t.integer :maintenance_id #属于哪个任务 t.integer :worker_id #打卡员工 t.datetime :check_in_time ...
Ruby
#模板表,代表维护计划的模板,每个模板包含若干个细分的任务 class CreateTemplates < ActiveRecord::Migration def self.up create_table :templates do |t| t.string :name #模板名称 t.integer :is_locked ,:limit => 1 ,:default => 0 #锁定 1为True 0为False t.integer :lock_version ,:...
Ruby
class AddTrainNameToRecords < ActiveRecord::Migration def self.up add_column :records, :train_name, :string end def self.down remove_column :records, :train_name end end
Ruby
#维护表,代表一列车一次完整的维护总任务 class CreateMaintenances < ActiveRecord::Migration def self.up create_table :maintenances do |t| t.integer :train_task_id #火车维护任务id t.integer :work_id #工作id t.integer :team_id ...
Ruby
class AddFlagToStandardmaintenance < ActiveRecord::Migration def self.up add_column :standard_maintenances,:flag,:integer,:default => 0 #标志位,0-只有静态或者动态作业,1-包括静动态作业 add_column :standard_maintenances,:dynamic_begin_minute,:integer add_column :standard_maintenances,:dynamic_during_minute,:integer e...
Ruby
class AddTrainTaskIdToCheckrecord < ActiveRecord::Migration def self.up add_column :checkrecords, :train_task_id, :integer end def self.down remove_column :checkrecords, :train_task end end
Ruby
class CreateLogs < ActiveRecord::Migration def self.up create_table :logs do |t| t.integer :device_id #设备ID t.integer :worker_id #员工ID t.integer :is_locked ,:limit => 1 ,:default...
Ruby
#工作表,细分的工作内容表 class CreateWorks < ActiveRecord::Migration def self.up create_table :works do |t| t.string :name #工作名称 t.string :description #工作备注 t.integer :is_locked ,:limit => 1 ,:default => 0 #锁定 1为T...
Ruby
class CreateDailies < ActiveRecord::Migration def self.up create_table :dailies do |t| t.integer :train_id #火车id号 t.string :sn #动车编号 t.date :date ...
Ruby
class CreateTracks < ActiveRecord::Migration def self.up create_table :tracks do |t| t.string :track_name #股道名 t.integer :device_id #设备ID t.integer :is_locked ,:limit => 1 ,:defa...
Ruby
class CreateTrainRouters < ActiveRecord::Migration def self.up create_table :train_routers do |t| t.integer :train_id #列车id t.integer :router_id #交路id t.integer :sequence ...
Ruby
class CreateDbLogs < ActiveRecord::Migration def self.up create_table :db_logs do |t| t.string :c_name ,:null => false #Controller的名字 t.string :a_name ,:null => false #Action的名字 t.string :ip ,:null => false #使用者的IP ...
Ruby
class CreateWorkers < ActiveRecord::Migration def self.up create_table :workers do |t| t.integer :team_id #组队id t.string :name #人员名称 t.integer :number ...
Ruby
#列车信息表 class CreateTrains < ActiveRecord::Migration def self.up create_table :trains do |t| t.string :sn #动车编号 t.integer :train_type #动车类型 2代表二型车,5代表五型车 t.integer :router_number ...
Ruby
class CreateNumbers < ActiveRecord::Migration def self.up #车次表 create_table :numbers do |t| t.string :sn #车次编号 t.string :line #行车路线 t.integer :length #一次行驶公里数 t.timestamps end Number.create(:...
Ruby
#列车计划表,用以存储所有的列车的所有维护计划,一辆列车拥有多个维护计划 class CreateTrainTasks < ActiveRecord::Migration def self.up create_table :train_tasks do |t| t.integer :train_id #列车id t.string :sn #列车维护单的编号 t...
Ruby
class AddPowerTimeToTrainTask < ActiveRecord::Migration def self.up add_column :train_tasks,:power_time,:datetime #供电时间 end def self.down remove_column :train_tasks,:power_time end end
Ruby
class AddTeamNameToRecords < ActiveRecord::Migration def self.up add_column :records, :team_name, :string end def self.down remove_column :records, :team_name end end
Ruby
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Mayor.create(:name =>...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run TrainSegmentMaintain::Application
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integrati...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Full error repor...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between...
Ruby
# Be sure to restart your web server when you modify this file. # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION ...
Ruby
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb unless defined?(RAILS_ROOT) root_path = File.join(File.dirname(__FILE__), '..') unless RUBY_PLATFORM =~ /mswin32/ require 'pathname' root_path = Pathname.new(root_path).cleanpath(true).to_s end RAILS...
Ruby
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # ...
Ruby