Haha, 8 million data finally finished, and wrote a Template in the evening.

xiaoxiao2021-03-06  141

Today, the mood is good, 8 million data is finally in accordance with the requirements of the boss to guide the TXT file, cool.

Python makes the file processing is really cool. Today, I wrote a loop built directory with Python, saving me a lot of mouse.

I will make a "/ n" of all files to "/ r / n", and a few words are set, the speed is very fast, this is better than Java.

I have n'thing to go home at night, I read a book for design patterns, and then combined with the Dongdong to do, I wrote a small practice, only the Lord uses the template mode, I don't know the right to use.

Here is the source code:

1. A bean, this is as long as a bean deposited in the mobile phone number, I make Hibernate's Pojo ....

Public class smscustom {string CID; // SMS user ID string mobile; // mobile phone number / ** * @Return Returns the cid. * / public string getCID () {Return CID;} / ** * @Param Cid the CID To set. * / public void setcid (string CID) {this.cid = CID;} / ** * @Return Returns the mobile. * / public string getMobile () {Return Mobile;} / ** * @Param Mobile THE Mobile to set. * / public void setmobile (string mobile) {this.mobile = mobile;}}

2. Second Bean, this is a bean who wrote MT downlink log after SMS

public class MTLog {private String content; // message content private SmsCustom send_cid; // SMS users Bean private String rec_mobile; // receiving a phone number private int feeCode; // amount charged private Date send_time; // send time public Date getSend_time ( ) {return send_time;} / ** * @return Returns the content * / public String getContent (). {return content;}. / ** * @return Returns the feeCode * / public int getFeeCode () {return feeCode;} . / ** * @return Returns the rec_mobile * / public String getRec_mobile () {return rec_mobile;}. / ** * @return Returns the send_cid * / public SmsCustom getSend_cid () {return send_cid;} / ** * @return Returns the send_time. * /

/ ** * @Param content the content to set. * / Public void setcontent (string content) {this.content = content;} / ** * @Param feecode the feecode to set. * / Public void setFeecode (int feecode) {this.feeCode = feeCode;} / ** * @param rec_mobile The rec_mobile to set * / public void setRec_mobile (String rec_mobile) {this.rec_mobile = rec_mobile;}. / ** * @param send_cid The send_cid to set *. / public void setSend_cid (SmsCustom send_cid) {this.send_cid = send_cid;}. / ** * @param send_time The send_time to set * / public void setSend_time (Date send_time) {this.send_time = send_time;}} 3.Template abstract Class, oh, don't explain, look

Public abstract class sendsms {public void run () {smscustom sc = checkmobileAndaddsmsMscustomifnotexist (getMobile ()); // Check if the SMS user system.out.println ("Turn into wireless CGI interface"); // Send SMS / / TODO calls the wireless CGI interface Send SMS and receives the sending report. If successfully add MT log mtlog = new mtlog (); // Establish MT downlink bean mtlog.setContent (getContent ()); mtlog.setsend_cid (sc); MTLOG.SETREC_MOBILE (GetRec_Mobile ()); mtlog.setsend_time (getsend_time ()); System.out.Println ("Insert a to MTLog Table"); // Write Database System.out. Println (MTLOG.GETSEND_CID (). getMobile () "in" mtlog.getsend_time () "give" mtlog.getRec_Mobile () "Send SMS," mtlog.getContent () "spend" mtlog.getfeecode ()); // mtldao.addmtlong (mtlog);} / ** * Check that the transferred mobile phone (param) is a SMS user, if you do not automatically add SMS users, and return SMS users bean if it is directly obtain the corresponding SMS users Bean * @param mobile * @return * / protected abstract SmsCustom checkMobileAndAddSmsCustomIfNotExist (String mobile); protected abstract String getMobile (); protected abstract String getContent (); protected abstract String getRec_mobile (); protected abstract int getfeecode (); Protected Abstract Date GetSend_Time ();} 4.Template Implementation

public class SendSmsTemplateMethod extends SendSms {private String send_mobile; private String content; private SmsCustom send_cid; private String rec_mobile; private int feeCode; private Date send_time;

public static void main (String [] args) throws Exception {SendSmsTemplateMethod t = new SendSmsTemplateMethod (); t.send_mobile = "12345678901"; t.content = "Yes texting, texting"; // t.send_cid = "10000 "; T.rec_mobile =" 1111111111 "; T.Feecode = 0; t.send_time = new date (); T.Run ();}

/ * (Non-Javadoc) * @see AddMTLog # getContent () * / protected String getContent () {return this.content;} / * (non-Javadoc) * @see AddMTLog # getRec_mobile () * / protected String getRec_mobile ( ) {Return this.rec_mobile;}

/ * (Non-javadoc) * @see addmtlog # getFeecode () * / protected int getFeecode () {return this.feecode;}

/ * (Non-javadoc) * @see addmtlog # getsend_time () * / protected Date getsend_time () {return this.send_time;}

/ * (Non-Javadoc) * @see AddMTLog # addSmsCustom () * / protected SmsCustom addSmsCustom (String mobile) {SmsCustom sc = new SmsCustom (); sc.setCid ( "2"); sc.setMobile (mobile); System .out.println ("Add a SMS User"); Return Sc;}

/ * (Non-Javadoc) * @see AddMTLog # checkMobileAndAddSmsCustomIfNotExist (java.lang.String) * / protected SmsCustom checkMobileAndAddSmsCustomIfNotExist (String mobile) {SmsCustom sc = null; // SmsCustom sc = new SmsCustom (); // sc.setCid ("1"); // sc.SETMOBILE ("12345678901"); if (sc == null) {sc = addsmscustom (mobile);} Return sc;

/ * (Non-javadoc) * @see addmtlog # getMobile () * / protected string getMobile () {return this.send_mobile;

}

2004-23-17

转载请注明原文地址:https://www.9cbs.com/read-127796.html

New Post(0)