BOSS要遠程考勤。只有幾個人而已。然后用AAU寫了一個考勤的,RUBY這個是查詢MYSQL,然后發(fā)送郵件到人事那邊用的(以附件方式發(fā))。代碼如下。
為濱城等地區(qū)用戶提供了全套網(wǎng)頁設計制作服務,及濱城網(wǎng)站建設行業(yè)解決方案。主營業(yè)務為網(wǎng)站制作、網(wǎng)站建設、濱城網(wǎng)站設計,以傳統(tǒng)方式定制建設網(wǎng)站,并提供域名空間備案等一條龍服務,秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!#!/usr/bin/ruby require 'mysql' require 'time' require 'net/smtp' require 'mailfactory' csv_str = "id,name,start work,get off work,hour\n" day = Time.now.strftime("%Y-%m-%d") filename = "/home/163/check_in/" + Time.now.to_s.split[0] + ".csv" db = Mysql.init db.options(Mysql::SET_CHARSET_NAME, 'utf8') db = Mysql.real_connect("192.168.1.4", "kq", "123123", "kq123", 3306) db.query("SET NAMES utf8") user = db.query("select * from username") def writefile(str,filename) aFile = File.new(filename,"w") aFile.puts str aFile.close end def sendmail(text, file) mail = MailFactory.new mail.from = "test@163.com" mail.subject = text mail.text = text mail.attach(file); mail.to = 'you@163.com' acct = 'test@163.com' domain = "163.com" pass = '123123' Net::SMTP.start('smtp.163.com', 25, domain, acct, pass, :login) do |smtp| smtp.send_message mail.to_s(),'test@163.com','you@163.com' end end while row = user.fetch_row do next if row[0] == '1' time_max = db.query("select max(time) from kqtime where time>\"#{day + " 06:00"}\" and time <\"#{day + " 23:00"}\" and userid=#{row[0]}").fetch_row[0] time_min = db.query("select min(time) from kqtime where time>\"#{day + " 06:00"}\" and time <\"#{day + " 23:00"}\" and userid=#{row[0]}").fetch_row[0] if time_min.nil? && time_max.nil? csv_str = csv_str + row[0] + "," + row[1] + ",,,0.0\n" elsif time_min.nil? csv_str = csv_str + row[0] + "," + row[1] + "," + time_min.to_s.split[-1][0..-4] + ",,0.0\n" elsif time_max.nil? csv_str = csv_str + row[0] + "," + row[1] + ",," + time_max.to_s.split[-1][0..-4] + ",0.0\n" else time_ok = Time.parse(time_max.to_s) - Time.parse(time_min.to_s) min = time_ok % (60) if time_ok < 3600 && time_min.to_s.split(':')[0][-2..-1].to_i < 13 csv_str = csv_str + row[0] + "," + row[1] + "," + time_min.to_s.split[-1][0..-4] + ",,0.0\n" elsif time_ok < 3600 && time_max.to_s.split(':')[0][-2..-1].to_i > 13 csv_str = csv_str + row[0] + "," + row[1] + ",," + time_max.to_s.split[-1][0..-4] + ",0.0\n" else min = time_ok % (60) if min < 15 min = time_ok.div(60).div(60) + 0.0 elsif min >= 15 && min < 45 min = time_ok.div(60).div(60) + 0.5 elsif min >= 45 min = time_ok.div(60).div(60) + 1.0 end csv_str = csv_str + row[0] + "," + row[1] + "," + time_min.to_s.split[-1][0..-4] + "," + time_max.to_s.split[-1][0..-4] + "," + min.to_s + "\n" end end end writefile(csv_str, filename) sendmail(Time.now.to_s.split[0] + " Check-In", filename)
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。