parent
93566cd40a
commit
2855993386
|
|
@ -151,36 +151,21 @@ public class PersonnelPositioningBiQueryExe {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<BiPersonLocationCO> loadMatchedPersonLocations(BiPersonLocationQry query) {
|
private List<BiPersonLocationCO> loadMatchedPersonLocations(BiPersonLocationQry query) {
|
||||||
boolean terminalOnly = isTerminalOnlyQuery(query);
|
List<StaffSnapshot> staffRows = loadAllStaffSnapshots();
|
||||||
List<StaffSnapshot> staffRows;
|
|
||||||
if (terminalOnly) {
|
|
||||||
StaffSnapshot snapshot = new StaffSnapshot();
|
|
||||||
snapshot.terminalNo = query.getTerminalNo();
|
|
||||||
staffRows = Collections.singletonList(snapshot);
|
|
||||||
} else {
|
|
||||||
staffRows = loadAllStaffSnapshots();
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, PositionPersonLocalLookupService.LocalPerson> localPeople;
|
|
||||||
if (terminalOnly) {
|
|
||||||
localPeople = localLookupService.findUniquePeopleByTerminalNos(
|
|
||||||
Collections.singleton(query.getTerminalNo()));
|
|
||||||
} else {
|
|
||||||
Set<String> phones = new LinkedHashSet<>();
|
Set<String> phones = new LinkedHashSet<>();
|
||||||
for (StaffSnapshot staff : staffRows) {
|
for (StaffSnapshot staff : staffRows) {
|
||||||
if (StringUtils.hasText(staff.staffNo)) {
|
if (StringUtils.hasText(staff.staffNo)) {
|
||||||
phones.add(staff.staffNo);
|
phones.add(staff.staffNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localPeople = localLookupService.findUniquePeopleByPhones(phones);
|
Map<String, PositionPersonLocalLookupService.LocalPerson> localPeople =
|
||||||
}
|
localLookupService.findUniquePeopleByPhones(phones);
|
||||||
|
|
||||||
List<MatchedStaffSnapshot> matchedStaff = new ArrayList<>();
|
List<MatchedStaffSnapshot> matchedStaff = new ArrayList<>();
|
||||||
Set<Long> matchedUserIds = new HashSet<>();
|
Set<Long> matchedUserIds = new HashSet<>();
|
||||||
Set<String> terminalNos = new LinkedHashSet<>();
|
Set<String> terminalNos = new LinkedHashSet<>();
|
||||||
for (StaffSnapshot staff : staffRows) {
|
for (StaffSnapshot staff : staffRows) {
|
||||||
PositionPersonLocalLookupService.LocalPerson local = terminalOnly
|
PositionPersonLocalLookupService.LocalPerson local = localPeople.get(staff.staffNo);
|
||||||
? localPeople.get(staff.terminalNo) : localPeople.get(staff.staffNo);
|
|
||||||
if (local == null) {
|
if (local == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -190,6 +175,10 @@ public class PersonnelPositioningBiQueryExe {
|
||||||
if (!StringUtils.hasText(staff.terminalNo)) {
|
if (!StringUtils.hasText(staff.terminalNo)) {
|
||||||
staff.terminalNo = resolveTerminalNo(staff.staffNo, staff.idCardNo, staff.mobileNo, false);
|
staff.terminalNo = resolveTerminalNo(staff.staffNo, staff.idCardNo, staff.mobileNo, false);
|
||||||
}
|
}
|
||||||
|
if (StringUtils.hasText(query.getTerminalNo())
|
||||||
|
&& !query.getTerminalNo().equals(staff.terminalNo)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (StringUtils.hasText(staff.terminalNo)) {
|
if (StringUtils.hasText(staff.terminalNo)) {
|
||||||
terminalNos.add(staff.terminalNo);
|
terminalNos.add(staff.terminalNo);
|
||||||
}
|
}
|
||||||
|
|
@ -200,15 +189,14 @@ public class PersonnelPositioningBiQueryExe {
|
||||||
for (MatchedStaffSnapshot matched : matchedStaff) {
|
for (MatchedStaffSnapshot matched : matchedStaff) {
|
||||||
matchedSnapshots.add(matched.staff);
|
matchedSnapshots.add(matched.staff);
|
||||||
}
|
}
|
||||||
Map<String, JsonNode> locationMap = locateStaffRows(matchedSnapshots,
|
Map<String, JsonNode> locationMap = locateStaffRows(matchedSnapshots, query.getTerminalNo());
|
||||||
terminalOnly ? query.getTerminalNo() : null);
|
|
||||||
Map<String, PositionPersonLocalLookupService.TerminalSnapshot> localTerminals =
|
Map<String, PositionPersonLocalLookupService.TerminalSnapshot> localTerminals =
|
||||||
localLookupService.findTerminals(terminalNos);
|
localLookupService.findTerminals(terminalNos);
|
||||||
List<BiPersonLocationCO> rows = new ArrayList<>();
|
List<BiPersonLocationCO> rows = new ArrayList<>();
|
||||||
List<BiAreaFenceCO> fences = listAllAreaFence();
|
List<BiAreaFenceCO> fences = listAllAreaFence();
|
||||||
for (MatchedStaffSnapshot matched : matchedStaff) {
|
for (MatchedStaffSnapshot matched : matchedStaff) {
|
||||||
StaffSnapshot staff = matched.staff;
|
StaffSnapshot staff = matched.staff;
|
||||||
String terminalNo = terminalOnly ? query.getTerminalNo() : staff.terminalNo;
|
String terminalNo = staff.terminalNo;
|
||||||
JsonNode location = locationMap.get(terminalNo);
|
JsonNode location = locationMap.get(terminalNo);
|
||||||
BiPersonLocationCO co = mapPersonLocation(staff, matched.local, terminalNo,
|
BiPersonLocationCO co = mapPersonLocation(staff, matched.local, terminalNo,
|
||||||
localTerminals.get(terminalNo), location, fences);
|
localTerminals.get(terminalNo), location, fences);
|
||||||
|
|
@ -482,19 +470,6 @@ public class PersonnelPositioningBiQueryExe {
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTerminalOnlyQuery(BiPersonLocationQry qry) {
|
|
||||||
return StringUtils.hasText(qry.getTerminalNo())
|
|
||||||
&& qry.getCorpinfoId() == null
|
|
||||||
&& !StringUtils.hasText(qry.getCompanyName())
|
|
||||||
&& !StringUtils.hasText(qry.getOrgName())
|
|
||||||
&& !StringUtils.hasText(qry.getOrgCode())
|
|
||||||
&& !StringUtils.hasText(qry.getCreditCode())
|
|
||||||
&& !StringUtils.hasText(qry.getStaffName())
|
|
||||||
&& !StringUtils.hasText(qry.getStaffNo())
|
|
||||||
&& !StringUtils.hasText(qry.getIdCardNo())
|
|
||||||
&& !StringUtils.hasText(qry.getMobileNo());
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<StaffSnapshot> mapStaffSnapshots(JsonNode data) {
|
private List<StaffSnapshot> mapStaffSnapshots(JsonNode data) {
|
||||||
JsonNode rows = extractRows(data);
|
JsonNode rows = extractRows(data);
|
||||||
List<StaffSnapshot> result = new ArrayList<>();
|
List<StaffSnapshot> result = new ArrayList<>();
|
||||||
|
|
@ -510,10 +485,12 @@ public class PersonnelPositioningBiQueryExe {
|
||||||
private StaffSnapshot mapStaffSnapshot(JsonNode row) {
|
private StaffSnapshot mapStaffSnapshot(JsonNode row) {
|
||||||
StaffSnapshot snapshot = new StaffSnapshot();
|
StaffSnapshot snapshot = new StaffSnapshot();
|
||||||
snapshot.rawNode = row;
|
snapshot.rawNode = row;
|
||||||
|
JsonNode terminalInfo = child(row, "terminalInfo");
|
||||||
snapshot.staffName = textValue(firstPresentAny(child(row, "staffName"), child(row, "name"),
|
snapshot.staffName = textValue(firstPresentAny(child(row, "staffName"), child(row, "name"),
|
||||||
child(row, "realName"), child(row, "userName")));
|
child(row, "realName"), child(row, "userName")));
|
||||||
snapshot.staffNo = textValue(firstPresentAny(child(row, "staffNo"), child(row, "code"),
|
snapshot.staffNo = textValue(firstPresentAny(child(row, "staffNo"), child(row, "code"),
|
||||||
child(row, "employeeNo"), child(row, "workNo")));
|
child(row, "employeeNo"), child(row, "workNo"), child(row, "trackNo"),
|
||||||
|
child(terminalInfo, "trackNo"), child(terminalInfo, "staffNo")));
|
||||||
snapshot.idCardNo = textValue(firstPresentAny(child(row, "idCardNo"), child(row, "identityNo"),
|
snapshot.idCardNo = textValue(firstPresentAny(child(row, "idCardNo"), child(row, "identityNo"),
|
||||||
child(row, "certificateNo"), child(row, "cardNo")));
|
child(row, "certificateNo"), child(row, "cardNo")));
|
||||||
snapshot.mobileNo = textValue(firstPresentAny(child(row, "mobileNo"), child(row, "phone"),
|
snapshot.mobileNo = textValue(firstPresentAny(child(row, "mobileNo"), child(row, "phone"),
|
||||||
|
|
@ -526,6 +503,7 @@ public class PersonnelPositioningBiQueryExe {
|
||||||
child(row, "unifiedSocialCreditCode"), child(row, "unifiedCreditCode"), child(row, "creditNo")));
|
child(row, "unifiedSocialCreditCode"), child(row, "unifiedCreditCode"), child(row, "creditNo")));
|
||||||
snapshot.lastLocation = firstPresentAny(child(row, "lastLocation"), child(row, "location"), child(row, "point"));
|
snapshot.lastLocation = firstPresentAny(child(row, "lastLocation"), child(row, "location"), child(row, "point"));
|
||||||
snapshot.terminalNo = firstText(textValue(child(row, "terminalNo")),
|
snapshot.terminalNo = firstText(textValue(child(row, "terminalNo")),
|
||||||
|
textValue(child(terminalInfo, "terminalNo")),
|
||||||
textValue(child(snapshot.lastLocation, "terminalNo")),
|
textValue(child(snapshot.lastLocation, "terminalNo")),
|
||||||
textValue(child(child(row, "bindTerminal"), "terminalNo")),
|
textValue(child(child(row, "bindTerminal"), "terminalNo")),
|
||||||
textValue(child(child(row, "terminal"), "terminalNo")),
|
textValue(child(child(row, "terminal"), "terminalNo")),
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,10 @@ public class PositionPersonQueryExe {
|
||||||
|
|
||||||
private FindsStaff mapFindsStaff(JsonNode row) {
|
private FindsStaff mapFindsStaff(JsonNode row) {
|
||||||
FindsStaff staff = new FindsStaff();
|
FindsStaff staff = new FindsStaff();
|
||||||
staff.staffNo = normalize(text(firstPresent(row, "staffNo", "code", "employeeNo", "workNo")));
|
JsonNode terminalInfo = row.path("terminalInfo");
|
||||||
|
staff.staffNo = normalize(firstText(
|
||||||
|
text(firstPresent(row, "staffNo", "code", "employeeNo", "workNo", "trackNo")),
|
||||||
|
text(firstPresent(terminalInfo, "trackNo", "staffNo"))));
|
||||||
staff.sourceCompanyName = text(firstPresent(row, "companyName", "corpName", "enterpriseName", "orgName"));
|
staff.sourceCompanyName = text(firstPresent(row, "companyName", "corpName", "enterpriseName", "orgName"));
|
||||||
staff.sourceDepartmentName = text(firstPresent(row, "departmentName", "deptName", "orgDepartmentName"));
|
staff.sourceDepartmentName = text(firstPresent(row, "departmentName", "deptName", "orgDepartmentName"));
|
||||||
staff.lastLocation = firstPresent(row, "lastLocation", "location", "point");
|
staff.lastLocation = firstPresent(row, "lastLocation", "location", "point");
|
||||||
|
|
@ -153,6 +156,7 @@ public class PositionPersonQueryExe {
|
||||||
timeMillis(firstPresent(row, "lastReportTime", "lastLocationTime", "lastOnlineTime")));
|
timeMillis(firstPresent(row, "lastReportTime", "lastLocationTime", "lastOnlineTime")));
|
||||||
staff.terminalNo = firstText(
|
staff.terminalNo = firstText(
|
||||||
text(firstPresent(row, "terminalNo")),
|
text(firstPresent(row, "terminalNo")),
|
||||||
|
text(firstPresent(terminalInfo, "terminalNo")),
|
||||||
text(firstPresent(staff.lastLocation, "terminalNo")),
|
text(firstPresent(staff.lastLocation, "terminalNo")),
|
||||||
text(firstPresent(row.path("terminal"), "terminalNo")),
|
text(firstPresent(row.path("terminal"), "terminalNo")),
|
||||||
text(firstPresent(row.path("bindTerminal"), "terminalNo")),
|
text(firstPresent(row.path("bindTerminal"), "terminalNo")),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue