|
@@ -2,6 +2,7 @@ package org.fouram.service;
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import org.fouram.core.base.service.BaseService;
|
|
|
import org.fouram.core.base.service.RequestService;
|
|
@@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
+import com.google.common.collect.Sets;
|
|
|
|
|
|
@Service
|
|
|
public class SapEmployeeTimeService extends BaseService {
|
|
@@ -19,7 +21,7 @@ public class SapEmployeeTimeService extends BaseService {
|
|
|
private RequestService requestService;
|
|
|
@Autowired
|
|
|
private WxUserService wxUserService;
|
|
|
-
|
|
|
+
|
|
|
public String getUserIdList(List<String> sapUsers) {
|
|
|
String userIds = "";
|
|
|
for (String sapUser : sapUsers) {
|
|
@@ -28,6 +30,7 @@ public class SapEmployeeTimeService extends BaseService {
|
|
|
return userIds;
|
|
|
}
|
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
public void saveEmployeeTimes() throws Exception {
|
|
|
List<String> userIds = wxUserService.selectAllUserIds();
|
|
|
String url = "https://api15.sapsf.cn/odata/v2/EmployeeTime?$filter=userId in %s&$format=json";
|
|
@@ -72,21 +75,21 @@ public class SapEmployeeTimeService extends BaseService {
|
|
|
String fractionQuantity = JsonNodeUtil.getValue(userNode, "fractionQuantity");
|
|
|
String endTime = JsonNodeUtil.getValue(userNode, "endTime");
|
|
|
String originalQuantityInDays = JsonNodeUtil.getValue(userNode, "originalQuantityInDays");
|
|
|
-
|
|
|
- if(selectById(externalCode) == null) {
|
|
|
+
|
|
|
+ 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)
|
|
|
+ .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)
|
|
|
+ .workflowRequestId(workflowRequestId).undeterminedEndDate(undeterminedEndDate)
|
|
|
+ .userId(userId).recurrenceGroup(recurrenceGroup).createdBy(createdBy)
|
|
|
.workflowInitiatedByAdmin(workflowInitiatedByAdmin).comment(comment)
|
|
|
.fractionQuantity(fractionQuantity).endTime(endTime)
|
|
|
.originalQuantityInDays(originalQuantityInDays).build();
|
|
@@ -95,14 +98,29 @@ public class SapEmployeeTimeService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 更新所有未通过的为无效
|
|
|
+ update("SapEmployeeTimeMapper.updateUnApprovedDelete", null);
|
|
|
+
|
|
|
+ // 去除重复数据
|
|
|
+ List<SapEmployeeTime> employeeTimes = (List<SapEmployeeTime>) findList("SapEmployeeTimeMapper.selectRepeat",
|
|
|
+ null);
|
|
|
+ Set<String> checkinDays = Sets.newHashSet();
|
|
|
+ for (SapEmployeeTime sapCheck : employeeTimes) {
|
|
|
+ if (!checkinDays.contains(sapCheck.getStartDate() + sapCheck.getUserId())) {
|
|
|
+ checkinDays.add(sapCheck.getStartDate() + sapCheck.getUserId());
|
|
|
+ } else {
|
|
|
+ update("SapEmployeeTimeMapper.updateDeleteByCode", sapCheck);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void saveOne(SapEmployeeTime employeeTime) throws Exception {
|
|
|
save("SapEmployeeTimeMapper.saveOne", employeeTime);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public SapEmployeeTime selectById(String externalCode) throws Exception {
|
|
|
return (SapEmployeeTime) findObject("SapEmployeeTimeMapper.selectById", externalCode);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|