From d4c615a74c287c4df896fe51493d7ad177643378 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Tue, 1 Aug 2017 12:45:21 -0400 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=95=B0=E6=8D=AE=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E8=BF=9B=E8=A1=8C=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usvisatrack/core/dao/model/UscisCase.java | 21 ++---- core/src/main/resources/hbm/UscisCase.hbm.xml | 4 ++ .../resources/hbm/UscisCaseStatus.hbm.xml | 2 +- .../services/UscisCaseImporter.java | 65 ++++++++++--------- 4 files changed, 43 insertions(+), 49 deletions(-) diff --git a/core/src/main/java/com/usvisatrack/core/dao/model/UscisCase.java b/core/src/main/java/com/usvisatrack/core/dao/model/UscisCase.java index 341ff0b..716ee67 100644 --- a/core/src/main/java/com/usvisatrack/core/dao/model/UscisCase.java +++ b/core/src/main/java/com/usvisatrack/core/dao/model/UscisCase.java @@ -19,8 +19,7 @@ public class UscisCase extends DataObject { private UscisCaseStatus uscisCaseStatus; private String uscisCaseNumber; private Date dateUscisCaseReceived; - private Date dateVisaIssued; - private Date dateVisaCheckCompleted; + private Date dateUscisCaseUpdated; public UscisCase() { Date date = new Date(); @@ -44,8 +43,6 @@ public class UscisCase extends DataObject { this.uscisForm = uscisForm; } - - public UscisCaseStatus getUscisCaseStatus() { return uscisCaseStatus; } @@ -70,20 +67,12 @@ public class UscisCase extends DataObject { this.dateUscisCaseReceived = dateUscisCaseReceived; } - public Date getDateVisaIssued() { - return dateVisaIssued; + public Date getDateUscisCaseUpdated() { + return dateUscisCaseUpdated; } - public void setDateVisaIssued(Date dateVisaIssued) { - this.dateVisaIssued = dateVisaIssued; - } - - public Date getDateVisaCheckCompleted() { - return dateVisaCheckCompleted; - } - - public void setDateVisaCheckCompleted(Date dateVisaCheckCompleted) { - this.dateVisaCheckCompleted = dateVisaCheckCompleted; + public void setDateUscisCaseUpdated(Date dateUscisCaseUpdated) { + this.dateUscisCaseUpdated = dateUscisCaseUpdated; } } diff --git a/core/src/main/resources/hbm/UscisCase.hbm.xml b/core/src/main/resources/hbm/UscisCase.hbm.xml index bac05bc..8dcbde5 100644 --- a/core/src/main/resources/hbm/UscisCase.hbm.xml +++ b/core/src/main/resources/hbm/UscisCase.hbm.xml @@ -22,6 +22,10 @@ + + + + diff --git a/core/src/main/resources/hbm/UscisCaseStatus.hbm.xml b/core/src/main/resources/hbm/UscisCaseStatus.hbm.xml index c9991c4..cff014c 100644 --- a/core/src/main/resources/hbm/UscisCaseStatus.hbm.xml +++ b/core/src/main/resources/hbm/UscisCaseStatus.hbm.xml @@ -6,7 +6,7 @@ - + diff --git a/services/src/main/java/com/usvisatrack/services/UscisCaseImporter.java b/services/src/main/java/com/usvisatrack/services/UscisCaseImporter.java index c492ecd..db9dbe4 100644 --- a/services/src/main/java/com/usvisatrack/services/UscisCaseImporter.java +++ b/services/src/main/java/com/usvisatrack/services/UscisCaseImporter.java @@ -2,7 +2,6 @@ package com.usvisatrack.services; import java.io.IOException; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.List; @@ -16,23 +15,12 @@ import org.joda.time.Days; import org.joda.time.format.DateTimeFormat; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; import org.slf4j.Logger; 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.User; -import com.usvisatrack.core.dao.model.Visa; import com.usvisatrack.core.dao.model.VisaClass; -import com.usvisatrack.core.factories.USFactory; import com.usvisatrack.core.factories.UscisCaseFactory; -import com.usvisatrack.core.factories.UserFactory; -import com.usvisatrack.core.factories.VisaFactory; import com.usvisatrack.services.common.DataCrawl; /** @@ -105,9 +93,12 @@ public class UscisCaseImporter extends DataCrawl { // CASE DATE String[] caseContentArray = StringUtils.split(doc.select("p").get(0).text(), ","); - String caseDate = StringUtils.trim(StringUtils.substringAfter(caseContentArray[0], "On")); - caseDate = caseDate + "," + StringUtils.trim(caseContentArray[1]); - DateTime dt = DateTimeFormat.forPattern("MMMMM dd,yyyy").parseDateTime(caseDate); + DateTime dt = null; + if (StringUtils.startsWithIgnoreCase(caseContentArray[0], "On")) { + 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 String uscisFormCode = StringUtils.trim(StringUtils.substringAfter(caseContentArray[2], "Form")); @@ -118,7 +109,17 @@ public class UscisCaseImporter extends DataCrawl { uscisCase.setUscisCaseNumber(caseNumber); uscisCase.setUscisCaseStatus(UscisCaseFactory.getUscisCaseStatusByCode(StringUtils.capitalize(caseStatus))); 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); @@ -134,7 +135,7 @@ public class UscisCaseImporter extends DataCrawl { */ private void initData() { logger.error("Init Data from Database"); - String caseNumber = "SRC1790476518"; + String caseNumber = "SRC1790472682"; String preCaseNumber = StringUtils.left(caseNumber, 8); long ascCaseNumberDigital = NumberUtils.createLong(StringUtils.right(caseNumber, 5)); @@ -142,20 +143,20 @@ public class UscisCaseImporter extends DataCrawl { // ASC int i = 0; - do { - ascCaseNumberDigital = ascCaseNumberDigital + 1; - String newCaseNumber = StringUtils.upperCase(preCaseNumber + Long.toString(ascCaseNumberDigital)); - UscisCase uscisCase = UscisCaseFactory.getUscisCaseByCaseNumber(newCaseNumber); - if (uscisCase == null) { - caseNumberList.add(newCaseNumber); - i++; - } else { - if (Days.daysBetween(new DateTime(), new DateTime(uscisCase.getModifyDate())).getDays() > 3) { - caseNumberList.add(newCaseNumber); - i++; - } - } - } while (i <= 500); +// do { +// ascCaseNumberDigital = ascCaseNumberDigital + 1; +// String newCaseNumber = StringUtils.upperCase(preCaseNumber + Long.toString(ascCaseNumberDigital)); +// UscisCase uscisCase = UscisCaseFactory.getUscisCaseByCaseNumber(newCaseNumber); +// if (uscisCase == null) { +// caseNumberList.add(newCaseNumber); +// i++; +// } else { +// if (Days.daysBetween(new DateTime(), new DateTime(uscisCase.getModifyDate())).getDays() > 3) { +// caseNumberList.add(newCaseNumber); +// i++; +// } +// } +// } while (i <= 100); // DESC i = 0; @@ -172,7 +173,7 @@ public class UscisCaseImporter extends DataCrawl { i++; } } - } while (i <= 500); + } while (i <= 1000); logger.debug("caseNumberList Size - [{}]", caseNumberList.size()); }