parent
93566cd40a
commit
2855993386
|
|
@ -151,36 +151,21 @@ public class PersonnelPositioningBiQueryExe {
|
|||
}
|
||||
|
||||
private List<BiPersonLocationCO> loadMatchedPersonLocations(BiPersonLocationQry query) {
|
||||
boolean terminalOnly = isTerminalOnlyQuery(query);
|
||||
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 {
|
||||
List<StaffSnapshot> staffRows = loadAllStaffSnapshots();
|
||||
Set<String> phones = new LinkedHashSet<>();
|
||||
for (StaffSnapshot staff : staffRows) {
|
||||
if (StringUtils.hasText(staff.staffNo)) {
|
||||
phones.add(staff.staffNo);
|
||||
}
|
||||
}
|
||||
localPeople = localLookupService.findUniquePeopleByPhones(phones);
|
||||
}
|
||||
Map<String, PositionPersonLocalLookupService.LocalPerson> localPeople =
|
||||
localLookupService.findUniquePeopleByPhones(phones);
|
||||
|
||||
List<MatchedStaffSnapshot> matchedStaff = new ArrayList<>();
|
||||
Set<Long> matchedUserIds = new HashSet<>();
|
||||
Set<String> terminalNos = new LinkedHashSet<>();
|
||||
for (StaffSnapshot staff : staffRows) {
|
||||
PositionPersonLocalLookupService.LocalPerson local = terminalOnly
|
||||
? localPeople.get(staff.terminalNo) : localPeople.get(staff.staffNo);
|
||||
PositionPersonLocalLookupService.LocalPerson local = localPeople.get(staff.staffNo);
|
||||
if (local == null) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -190,6 +175,10 @@ public class PersonnelPositioningBiQueryExe {
|
|||
if (!StringUtils.hasText(staff.terminalNo)) {
|
||||
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)) {
|
||||
terminalNos.add(staff.terminalNo);
|
||||
}
|
||||
|
|
@ -200,15 +189,14 @@ public class PersonnelPositioningBiQueryExe {
|
|||
for (MatchedStaffSnapshot matched : matchedStaff) {
|
||||
matchedSnapshots.add(matched.staff);
|
||||
}
|
||||
Map<String, JsonNode> locationMap = locateStaffRows(matchedSnapshots,
|
||||
terminalOnly ? query.getTerminalNo() : null);
|
||||
Map<String, JsonNode> locationMap = locateStaffRows(matchedSnapshots, query.getTerminalNo());
|
||||
Map<String, PositionPersonLocalLookupService.TerminalSnapshot> localTerminals =
|
||||
localLookupService.findTerminals(terminalNos);
|
||||
List<BiPersonLocationCO> rows = new ArrayList<>();
|
||||
List<BiAreaFenceCO> fences = listAllAreaFence();
|
||||
for (MatchedStaffSnapshot matched : matchedStaff) {
|
||||
StaffSnapshot staff = matched.staff;
|
||||
String terminalNo = terminalOnly ? query.getTerminalNo() : staff.terminalNo;
|
||||
String terminalNo = staff.terminalNo;
|
||||
JsonNode location = locationMap.get(terminalNo);
|
||||
BiPersonLocationCO co = mapPersonLocation(staff, matched.local, terminalNo,
|
||||
localTerminals.get(terminalNo), location, fences);
|
||||
|
|
@ -482,19 +470,6 @@ public class PersonnelPositioningBiQueryExe {
|
|||
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) {
|
||||
JsonNode rows = extractRows(data);
|
||||
List<StaffSnapshot> result = new ArrayList<>();
|
||||
|
|
@ -510,10 +485,12 @@ public class PersonnelPositioningBiQueryExe {
|
|||
private StaffSnapshot mapStaffSnapshot(JsonNode row) {
|
||||
StaffSnapshot snapshot = new StaffSnapshot();
|
||||
snapshot.rawNode = row;
|
||||
JsonNode terminalInfo = child(row, "terminalInfo");
|
||||
snapshot.staffName = textValue(firstPresentAny(child(row, "staffName"), child(row, "name"),
|
||||
child(row, "realName"), child(row, "userName")));
|
||||
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"),
|
||||
child(row, "certificateNo"), child(row, "cardNo")));
|
||||
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")));
|
||||
snapshot.lastLocation = firstPresentAny(child(row, "lastLocation"), child(row, "location"), child(row, "point"));
|
||||
snapshot.terminalNo = firstText(textValue(child(row, "terminalNo")),
|
||||
textValue(child(terminalInfo, "terminalNo")),
|
||||
textValue(child(snapshot.lastLocation, "terminalNo")),
|
||||
textValue(child(child(row, "bindTerminal"), "terminalNo")),
|
||||
textValue(child(child(row, "terminal"), "terminalNo")),
|
||||
|
|
|
|||
|
|
@ -145,7 +145,10 @@ public class PositionPersonQueryExe {
|
|||
|
||||
private FindsStaff mapFindsStaff(JsonNode row) {
|
||||
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.sourceDepartmentName = text(firstPresent(row, "departmentName", "deptName", "orgDepartmentName"));
|
||||
staff.lastLocation = firstPresent(row, "lastLocation", "location", "point");
|
||||
|
|
@ -153,6 +156,7 @@ public class PositionPersonQueryExe {
|
|||
timeMillis(firstPresent(row, "lastReportTime", "lastLocationTime", "lastOnlineTime")));
|
||||
staff.terminalNo = firstText(
|
||||
text(firstPresent(row, "terminalNo")),
|
||||
text(firstPresent(terminalInfo, "terminalNo")),
|
||||
text(firstPresent(staff.lastLocation, "terminalNo")),
|
||||
text(firstPresent(row.path("terminal"), "terminalNo")),
|
||||
text(firstPresent(row.path("bindTerminal"), "terminalNo")),
|
||||
|
|
|
|||
Loading…
Reference in New Issue