|
@@ -36,6 +36,8 @@ public class SapEmployeeTimeService extends BaseService {
|
|
|
String url = "https://api15.sapsf.cn/odata/v2/EmployeeTime?$filter=userId in %s&$format=json";
|
|
|
url = String.format(url, getUserIdList(userIds));
|
|
|
JsonNode node = requestService.getForObject(url, getHttpHeaders());
|
|
|
+ SapEmployeeTime dbEmployeeTime = null;
|
|
|
+ SapEmployeeTime employeeTime = null;
|
|
|
if (node != null) {
|
|
|
Iterator<JsonNode> iterator = node.get("d").get("results").elements();
|
|
|
while (iterator.hasNext()) {
|
|
@@ -76,24 +78,30 @@ public class SapEmployeeTimeService extends BaseService {
|
|
|
String endTime = JsonNodeUtil.getValue(userNode, "endTime");
|
|
|
String originalQuantityInDays = JsonNodeUtil.getValue(userNode, "originalQuantityInDays");
|
|
|
|
|
|
- if (selectById(externalCode) == null) {
|
|
|
- SapEmployeeTime employeeTime = SapEmployeeTime.builder().externalCode(externalCode)
|
|
|
- .lastModifiedDateTime(lastModifiedDateTime).loaActualReturnDate(loaActualReturnDate)
|
|
|
- .createdDateTime(createdDateTime).timeType(timeType)
|
|
|
- .loaExpectedReturnDate(loaExpectedReturnDate).flexibleRequesting(flexibleRequesting)
|
|
|
- .timeRecordOrigin(timeRecordOrigin).mdfSystemRecordStatus(mdfSystemRecordStatus)
|
|
|
- .custPeriod(custPeriod).quantityInHours(quantityInHours)
|
|
|
- .loaStartJobInfoId(loaStartJobInfoId).startDate(startDate).startDateTime(startDateTime)
|
|
|
- .endDate(endDate).endDateTime(endDateTime).displayQuantity(displayQuantity)
|
|
|
- .quantityInDays(quantityInDays).startTime(startTime).loaEndJobInfoId(loaEndJobInfoId)
|
|
|
- .approvalStatus(approvalStatus).cancellationWorkflowRequestId(cancellationWorkflowRequestId)
|
|
|
- .deductionQuantity(deductionQuantity).editable(editable).lastModifiedBy(lastModifiedBy)
|
|
|
- .workflowRequestId(workflowRequestId).undeterminedEndDate(undeterminedEndDate)
|
|
|
- .userId(userId).recurrenceGroup(recurrenceGroup).createdBy(createdBy)
|
|
|
- .workflowInitiatedByAdmin(workflowInitiatedByAdmin).comment(comment)
|
|
|
- .fractionQuantity(fractionQuantity).endTime(endTime)
|
|
|
- .originalQuantityInDays(originalQuantityInDays).build();
|
|
|
-
|
|
|
+ employeeTime = SapEmployeeTime.builder().externalCode(externalCode)
|
|
|
+ .lastModifiedDateTime(lastModifiedDateTime).loaActualReturnDate(loaActualReturnDate)
|
|
|
+ .createdDateTime(createdDateTime).timeType(timeType)
|
|
|
+ .loaExpectedReturnDate(loaExpectedReturnDate).flexibleRequesting(flexibleRequesting)
|
|
|
+ .timeRecordOrigin(timeRecordOrigin).mdfSystemRecordStatus(mdfSystemRecordStatus)
|
|
|
+ .custPeriod(custPeriod).quantityInHours(quantityInHours).loaStartJobInfoId(loaStartJobInfoId)
|
|
|
+ .startDate(startDate).startDateTime(startDateTime).endDate(endDate).endDateTime(endDateTime)
|
|
|
+ .displayQuantity(displayQuantity).quantityInDays(quantityInDays).startTime(startTime)
|
|
|
+ .loaEndJobInfoId(loaEndJobInfoId).approvalStatus(approvalStatus)
|
|
|
+ .cancellationWorkflowRequestId(cancellationWorkflowRequestId)
|
|
|
+ .deductionQuantity(deductionQuantity).editable(editable).lastModifiedBy(lastModifiedBy)
|
|
|
+ .workflowRequestId(workflowRequestId).undeterminedEndDate(undeterminedEndDate).userId(userId)
|
|
|
+ .recurrenceGroup(recurrenceGroup).createdBy(createdBy)
|
|
|
+ .workflowInitiatedByAdmin(workflowInitiatedByAdmin).comment(comment)
|
|
|
+ .fractionQuantity(fractionQuantity).endTime(endTime)
|
|
|
+ .originalQuantityInDays(originalQuantityInDays).build();
|
|
|
+ dbEmployeeTime = selectById(externalCode);
|
|
|
+ if (dbEmployeeTime != null) {
|
|
|
+ // 值变化,删掉重新插入
|
|
|
+ if (!dbEmployeeTime.getKeyString().equals(employeeTime.getKeyString())) {
|
|
|
+ deleteByExternalCode(externalCode);
|
|
|
+ saveOne(employeeTime);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
saveOne(employeeTime);
|
|
|
}
|
|
|
}
|
|
@@ -119,6 +127,10 @@ public class SapEmployeeTimeService extends BaseService {
|
|
|
save("SapEmployeeTimeMapper.saveOne", employeeTime);
|
|
|
}
|
|
|
|
|
|
+ public void deleteByExternalCode(String externalCode) throws Exception {
|
|
|
+ update("SapEmployeeTimeMapper.deleteByExternalCode", externalCode);
|
|
|
+ }
|
|
|
+
|
|
|
public SapEmployeeTime selectById(String externalCode) throws Exception {
|
|
|
return (SapEmployeeTime) findObject("SapEmployeeTimeMapper.selectById", externalCode);
|
|
|
}
|