对数据扫描功能进行更新

This commit is contained in:
YuCheng Hu 2017-08-01 12:45:21 -04:00
parent 703913e30c
commit d4c615a74c
4 changed files with 43 additions and 49 deletions

View File

@ -19,8 +19,7 @@ public class UscisCase extends DataObject {
private UscisCaseStatus uscisCaseStatus; private UscisCaseStatus uscisCaseStatus;
private String uscisCaseNumber; private String uscisCaseNumber;
private Date dateUscisCaseReceived; private Date dateUscisCaseReceived;
private Date dateVisaIssued; private Date dateUscisCaseUpdated;
private Date dateVisaCheckCompleted;
public UscisCase() { public UscisCase() {
Date date = new Date(); Date date = new Date();
@ -44,8 +43,6 @@ public class UscisCase extends DataObject {
this.uscisForm = uscisForm; this.uscisForm = uscisForm;
} }
public UscisCaseStatus getUscisCaseStatus() { public UscisCaseStatus getUscisCaseStatus() {
return uscisCaseStatus; return uscisCaseStatus;
} }
@ -70,20 +67,12 @@ public class UscisCase extends DataObject {
this.dateUscisCaseReceived = dateUscisCaseReceived; this.dateUscisCaseReceived = dateUscisCaseReceived;
} }
public Date getDateVisaIssued() { public Date getDateUscisCaseUpdated() {
return dateVisaIssued; return dateUscisCaseUpdated;
} }
public void setDateVisaIssued(Date dateVisaIssued) { public void setDateUscisCaseUpdated(Date dateUscisCaseUpdated) {
this.dateVisaIssued = dateVisaIssued; this.dateUscisCaseUpdated = dateUscisCaseUpdated;
}
public Date getDateVisaCheckCompleted() {
return dateVisaCheckCompleted;
}
public void setDateVisaCheckCompleted(Date dateVisaCheckCompleted) {
this.dateVisaCheckCompleted = dateVisaCheckCompleted;
} }
} }

View File

@ -22,6 +22,10 @@
<column name="date_uscis_case_received" /> <column name="date_uscis_case_received" />
</property> </property>
<property name="dateUscisCaseUpdated" type="date">
<column name="date_uscis_case_updated" />
</property>
<property name="createDate" type="timestamp"> <property name="createDate" type="timestamp">
<column name="date_add" /> <column name="date_add" />
</property> </property>

View File

@ -6,7 +6,7 @@
<class name="UscisCaseStatus" table="uscis_case_status" catalog="northtecom_usvisatrack"> <class name="UscisCaseStatus" table="uscis_case_status" catalog="northtecom_usvisatrack">
<id name="id" type="long"> <id name="id" type="long">
<column name="uscis_case_status_id" /> <column name="uscis_case_status_id" />
<generator class="identity" /> <generator class="assigned" />
</id> </id>
<property name="uscisCaseStatusName" type="string"> <property name="uscisCaseStatusName" type="string">
<column name="uscis_case_status_name" length="128" /> <column name="uscis_case_status_name" length="128" />

View File

@ -2,7 +2,6 @@ package com.usvisatrack.services;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -16,23 +15,12 @@ import org.joda.time.Days;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.usvisatrack.core.dao.model.data.UserStatus;
import com.usvisatrack.core.dao.model.data.VisaEntry;
import com.usvisatrack.core.dao.model.data.VisaStatus;
import com.usvisatrack.core.dao.model.CheckeeVisa;
import com.usvisatrack.core.dao.model.UscisCase; import com.usvisatrack.core.dao.model.UscisCase;
import com.usvisatrack.core.dao.model.User;
import com.usvisatrack.core.dao.model.Visa;
import com.usvisatrack.core.dao.model.VisaClass; import com.usvisatrack.core.dao.model.VisaClass;
import com.usvisatrack.core.factories.USFactory;
import com.usvisatrack.core.factories.UscisCaseFactory; import com.usvisatrack.core.factories.UscisCaseFactory;
import com.usvisatrack.core.factories.UserFactory;
import com.usvisatrack.core.factories.VisaFactory;
import com.usvisatrack.services.common.DataCrawl; import com.usvisatrack.services.common.DataCrawl;
/** /**
@ -105,9 +93,12 @@ public class UscisCaseImporter extends DataCrawl {
// CASE DATE // CASE DATE
String[] caseContentArray = StringUtils.split(doc.select("p").get(0).text(), ","); String[] caseContentArray = StringUtils.split(doc.select("p").get(0).text(), ",");
String caseDate = StringUtils.trim(StringUtils.substringAfter(caseContentArray[0], "On")); DateTime dt = null;
caseDate = caseDate + "," + StringUtils.trim(caseContentArray[1]); if (StringUtils.startsWithIgnoreCase(caseContentArray[0], "On")) {
DateTime dt = DateTimeFormat.forPattern("MMMMM dd,yyyy").parseDateTime(caseDate); String caseDate = StringUtils.trim(StringUtils.substringAfter(caseContentArray[0], "On"));
caseDate = caseDate + "," + StringUtils.trim(caseContentArray[1]);
dt = DateTimeFormat.forPattern("MMMMM dd,yyyy").parseDateTime(caseDate);
}
// CASE FORM // CASE FORM
String uscisFormCode = StringUtils.trim(StringUtils.substringAfter(caseContentArray[2], "Form")); String uscisFormCode = StringUtils.trim(StringUtils.substringAfter(caseContentArray[2], "Form"));
@ -118,7 +109,17 @@ public class UscisCaseImporter extends DataCrawl {
uscisCase.setUscisCaseNumber(caseNumber); uscisCase.setUscisCaseNumber(caseNumber);
uscisCase.setUscisCaseStatus(UscisCaseFactory.getUscisCaseStatusByCode(StringUtils.capitalize(caseStatus))); uscisCase.setUscisCaseStatus(UscisCaseFactory.getUscisCaseStatusByCode(StringUtils.capitalize(caseStatus)));
uscisCase.setUscisForm(UscisCaseFactory.getUscisFormByCode(uscisFormCode)); uscisCase.setUscisForm(UscisCaseFactory.getUscisFormByCode(uscisFormCode));
uscisCase.setDateUscisCaseReceived(dt.toDate()); if (uscisCase.getUscisForm() == null) {
uscisCase.setUscisForm(UscisCaseFactory.getUscisFormByCode("UNKNOW"));
}
if (dt != null) {
if (uscisCase.getUscisCaseStatus().getId() != 1000 && uscisCase.getUscisCaseStatus().getId() != 1001) {
uscisCase.setDateUscisCaseUpdated(dt.toDate());
} else {
uscisCase.setDateUscisCaseReceived(dt.toDate());
}
}
UscisCaseFactory.save(uscisCase); UscisCaseFactory.save(uscisCase);
@ -134,7 +135,7 @@ public class UscisCaseImporter extends DataCrawl {
*/ */
private void initData() { private void initData() {
logger.error("Init Data from Database"); logger.error("Init Data from Database");
String caseNumber = "SRC1790476518"; String caseNumber = "SRC1790472682";
String preCaseNumber = StringUtils.left(caseNumber, 8); String preCaseNumber = StringUtils.left(caseNumber, 8);
long ascCaseNumberDigital = NumberUtils.createLong(StringUtils.right(caseNumber, 5)); long ascCaseNumberDigital = NumberUtils.createLong(StringUtils.right(caseNumber, 5));
@ -142,20 +143,20 @@ public class UscisCaseImporter extends DataCrawl {
// ASC // ASC
int i = 0; int i = 0;
do { // do {
ascCaseNumberDigital = ascCaseNumberDigital + 1; // ascCaseNumberDigital = ascCaseNumberDigital + 1;
String newCaseNumber = StringUtils.upperCase(preCaseNumber + Long.toString(ascCaseNumberDigital)); // String newCaseNumber = StringUtils.upperCase(preCaseNumber + Long.toString(ascCaseNumberDigital));
UscisCase uscisCase = UscisCaseFactory.getUscisCaseByCaseNumber(newCaseNumber); // UscisCase uscisCase = UscisCaseFactory.getUscisCaseByCaseNumber(newCaseNumber);
if (uscisCase == null) { // if (uscisCase == null) {
caseNumberList.add(newCaseNumber); // caseNumberList.add(newCaseNumber);
i++; // i++;
} else { // } else {
if (Days.daysBetween(new DateTime(), new DateTime(uscisCase.getModifyDate())).getDays() > 3) { // if (Days.daysBetween(new DateTime(), new DateTime(uscisCase.getModifyDate())).getDays() > 3) {
caseNumberList.add(newCaseNumber); // caseNumberList.add(newCaseNumber);
i++; // i++;
} // }
} // }
} while (i <= 500); // } while (i <= 100);
// DESC // DESC
i = 0; i = 0;
@ -172,7 +173,7 @@ public class UscisCaseImporter extends DataCrawl {
i++; i++;
} }
} }
} while (i <= 500); } while (i <= 1000);
logger.debug("caseNumberList Size - [{}]", caseNumberList.size()); logger.debug("caseNumberList Size - [{}]", caseNumberList.size());
} }