|
@@ -37,77 +37,81 @@ public class SapEmployeeTimeService extends BaseService {
|
|
|
List<String> allSapUserIds = wxUserService.selectSapUserId();
|
|
|
String url = null;
|
|
|
for (String userId : allSapUserIds) {
|
|
|
- url = String.format("https://api15.sapsf.cn/odata/v2/EmployeeTime?$filter=userId in %s&$format=json",
|
|
|
- userId);
|
|
|
- log.info("saveEmployeeTimes url = {} ,headers = {}",url,getHttpHeaders());
|
|
|
- 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()) {
|
|
|
- JsonNode userNode = iterator.next();
|
|
|
- String externalCode = JsonNodeUtil.getValue(userNode, "externalCode");
|
|
|
- String lastModifiedDateTime = JsonNodeUtil.getValue(userNode, "lastModifiedDateTime");
|
|
|
- String loaActualReturnDate = JsonNodeUtil.getValue(userNode, "loaActualReturnDate");
|
|
|
- String createdDateTime = JsonNodeUtil.getValue(userNode, "createdDateTime");
|
|
|
- String timeType = JsonNodeUtil.getValue(userNode, "timeType");
|
|
|
- String loaExpectedReturnDate = JsonNodeUtil.getValue(userNode, "loaExpectedReturnDate");
|
|
|
- String flexibleRequesting = JsonNodeUtil.getValue(userNode, "flexibleRequesting");
|
|
|
- String timeRecordOrigin = JsonNodeUtil.getValue(userNode, "timeRecordOrigin");
|
|
|
- String mdfSystemRecordStatus = JsonNodeUtil.getValue(userNode, "mdfSystemRecordStatus");
|
|
|
- String custPeriod = JsonNodeUtil.getValue(userNode, "cust_period");
|
|
|
- String quantityInHours = JsonNodeUtil.getValue(userNode, "quantityInHours");
|
|
|
- String loaStartJobInfoId = JsonNodeUtil.getValue(userNode, "loaStartJobInfoId");
|
|
|
- String startDate = JsonNodeUtil.getValue(userNode, "startDate");
|
|
|
- String startDateTime = JsonNodeUtil.getTime(userNode, "startDate");
|
|
|
- String endDate = JsonNodeUtil.getValue(userNode, "endDate");
|
|
|
- String endDateTime = JsonNodeUtil.getTime(userNode, "endDate");
|
|
|
- String displayQuantity = JsonNodeUtil.getValue(userNode, "displayQuantity");
|
|
|
- String quantityInDays = JsonNodeUtil.getValue(userNode, "quantityInDays");
|
|
|
- String startTime = JsonNodeUtil.getValue(userNode, "startTime");
|
|
|
- String loaEndJobInfoId = JsonNodeUtil.getValue(userNode, "loaEndJobInfoId");
|
|
|
- String approvalStatus = JsonNodeUtil.getValue(userNode, "approvalStatus");
|
|
|
- String cwr = JsonNodeUtil.getValue(userNode, "cancellationWorkflowRequestId");
|
|
|
- String deductionQuantity = JsonNodeUtil.getValue(userNode, "deductionQuantity");
|
|
|
- String editable = JsonNodeUtil.getValue(userNode, "editable");
|
|
|
- String lastModifiedBy = JsonNodeUtil.getValue(userNode, "lastModifiedBy");
|
|
|
- String workflowRequestId = JsonNodeUtil.getValue(userNode, "workflowRequestId");
|
|
|
- String undeterminedEndDate = JsonNodeUtil.getValue(userNode, "undeterminedEndDate");
|
|
|
- String recurrenceGroup = JsonNodeUtil.getValue(userNode, "recurrenceGroup");
|
|
|
- String createdBy = JsonNodeUtil.getValue(userNode, "createdBy");
|
|
|
- String workflowInitiatedByAdmin = JsonNodeUtil.getValue(userNode, "workflowInitiatedByAdmin");
|
|
|
- String comment = JsonNodeUtil.getValue(userNode, "comment");
|
|
|
- String fractionQuantity = JsonNodeUtil.getValue(userNode, "fractionQuantity");
|
|
|
- String endTime = JsonNodeUtil.getValue(userNode, "endTime");
|
|
|
- String originalQuantityInDays = JsonNodeUtil.getValue(userNode, "originalQuantityInDays");
|
|
|
- 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(cwr)
|
|
|
- .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);
|
|
|
+ try {
|
|
|
+ url = String.format("https://api15.sapsf.cn/odata/v2/EmployeeTime?$filter=userId in %s&$format=json",
|
|
|
+ userId);
|
|
|
+ log.info("saveEmployeeTimes url = {} ,headers = {}",url,getHttpHeaders());
|
|
|
+ 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()) {
|
|
|
+ JsonNode userNode = iterator.next();
|
|
|
+ String externalCode = JsonNodeUtil.getValue(userNode, "externalCode");
|
|
|
+ String lastModifiedDateTime = JsonNodeUtil.getValue(userNode, "lastModifiedDateTime");
|
|
|
+ String loaActualReturnDate = JsonNodeUtil.getValue(userNode, "loaActualReturnDate");
|
|
|
+ String createdDateTime = JsonNodeUtil.getValue(userNode, "createdDateTime");
|
|
|
+ String timeType = JsonNodeUtil.getValue(userNode, "timeType");
|
|
|
+ String loaExpectedReturnDate = JsonNodeUtil.getValue(userNode, "loaExpectedReturnDate");
|
|
|
+ String flexibleRequesting = JsonNodeUtil.getValue(userNode, "flexibleRequesting");
|
|
|
+ String timeRecordOrigin = JsonNodeUtil.getValue(userNode, "timeRecordOrigin");
|
|
|
+ String mdfSystemRecordStatus = JsonNodeUtil.getValue(userNode, "mdfSystemRecordStatus");
|
|
|
+ String custPeriod = JsonNodeUtil.getValue(userNode, "cust_period");
|
|
|
+ String quantityInHours = JsonNodeUtil.getValue(userNode, "quantityInHours");
|
|
|
+ String loaStartJobInfoId = JsonNodeUtil.getValue(userNode, "loaStartJobInfoId");
|
|
|
+ String startDate = JsonNodeUtil.getValue(userNode, "startDate");
|
|
|
+ String startDateTime = JsonNodeUtil.getTime(userNode, "startDate");
|
|
|
+ String endDate = JsonNodeUtil.getValue(userNode, "endDate");
|
|
|
+ String endDateTime = JsonNodeUtil.getTime(userNode, "endDate");
|
|
|
+ String displayQuantity = JsonNodeUtil.getValue(userNode, "displayQuantity");
|
|
|
+ String quantityInDays = JsonNodeUtil.getValue(userNode, "quantityInDays");
|
|
|
+ String startTime = JsonNodeUtil.getValue(userNode, "startTime");
|
|
|
+ String loaEndJobInfoId = JsonNodeUtil.getValue(userNode, "loaEndJobInfoId");
|
|
|
+ String approvalStatus = JsonNodeUtil.getValue(userNode, "approvalStatus");
|
|
|
+ String cwr = JsonNodeUtil.getValue(userNode, "cancellationWorkflowRequestId");
|
|
|
+ String deductionQuantity = JsonNodeUtil.getValue(userNode, "deductionQuantity");
|
|
|
+ String editable = JsonNodeUtil.getValue(userNode, "editable");
|
|
|
+ String lastModifiedBy = JsonNodeUtil.getValue(userNode, "lastModifiedBy");
|
|
|
+ String workflowRequestId = JsonNodeUtil.getValue(userNode, "workflowRequestId");
|
|
|
+ String undeterminedEndDate = JsonNodeUtil.getValue(userNode, "undeterminedEndDate");
|
|
|
+ String recurrenceGroup = JsonNodeUtil.getValue(userNode, "recurrenceGroup");
|
|
|
+ String createdBy = JsonNodeUtil.getValue(userNode, "createdBy");
|
|
|
+ String workflowInitiatedByAdmin = JsonNodeUtil.getValue(userNode, "workflowInitiatedByAdmin");
|
|
|
+ String comment = JsonNodeUtil.getValue(userNode, "comment");
|
|
|
+ String fractionQuantity = JsonNodeUtil.getValue(userNode, "fractionQuantity");
|
|
|
+ String endTime = JsonNodeUtil.getValue(userNode, "endTime");
|
|
|
+ String originalQuantityInDays = JsonNodeUtil.getValue(userNode, "originalQuantityInDays");
|
|
|
+ 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(cwr)
|
|
|
+ .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);
|
|
|
}
|
|
|
- } else {
|
|
|
- saveOne(employeeTime);
|
|
|
}
|
|
|
}
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|