|
@@ -1,16 +1,23 @@
|
|
|
package com.rongwei.bscommon.sys.utils;
|
|
|
|
|
|
+import com.rongwei.bscommon.sys.service.impl.SynchronizationDataServiceImpl;
|
|
|
+import com.rongwei.bsentity.dto.ApiCallDto;
|
|
|
import com.rongwei.bsentity.dto.OrgApiDataConfigDTO;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
+import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.rongwei.bscommon.sys.utils.JXKHConstant.DatePattern.DATE_PATTERN_YMD;
|
|
@@ -23,18 +30,34 @@ import static com.rongwei.bscommon.sys.utils.JXKHConstant.DatePattern.DATE_PATTE
|
|
|
* @date 2024/12/02
|
|
|
*/
|
|
|
@Component
|
|
|
-public class ApiDattaOrgUtil {
|
|
|
+public class ApiDataOrgUtil {
|
|
|
|
|
|
public static final String IMG_SPLIT_SIGN = "\\^_\\^";
|
|
|
- private static final Logger log = LoggerFactory.getLogger(ApiDattaOrgUtil.class.getName());
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ApiDataOrgUtil.class.getName());
|
|
|
+ private static AttendanceAssessmentSdk attendanceAssessmentSdk;
|
|
|
+ private static SynchronizationDataServiceImpl synchronizationDataService;
|
|
|
+ @Autowired
|
|
|
+ private AttendanceAssessmentSdk autoAttendanceAssessmentSdk;
|
|
|
+ @Autowired
|
|
|
+ private SynchronizationDataServiceImpl autoSynchronizationDataService;
|
|
|
|
|
|
public static <T> Map<String, Object> assembleApiData(T infos,
|
|
|
List<OrgApiDataConfigDTO> orgApiDataConfigDTOS) {
|
|
|
Map<String, Object> apiData = new HashMap();
|
|
|
+ boolean emptyKeyFlag = orgApiDataConfigDTOS.stream().anyMatch(info -> StringUtils.isBlank(info.getKey()));
|
|
|
+ if (emptyKeyFlag) {
|
|
|
+ throw new CustomException("存在key为空的配置文件信息");
|
|
|
+ }
|
|
|
|
|
|
orgApiDataConfigDTOS.forEach(configDTO -> {
|
|
|
String key = configDTO.getKey();
|
|
|
- Object apply = configDTO.getGetDataFunction().apply(infos);
|
|
|
+ Function<T, Object> getDataFunction = configDTO.getGetDataFunction();
|
|
|
+ Object apply;
|
|
|
+ if (getDataFunction == null) {
|
|
|
+ apply = configDTO.getRealValue();
|
|
|
+ } else {
|
|
|
+ apply = configDTO.getGetDataFunction().apply(infos);
|
|
|
+ }
|
|
|
apiData.put(key, ObjConver(apply, configDTO));
|
|
|
});
|
|
|
return apiData;
|
|
@@ -63,11 +86,20 @@ public class ApiDattaOrgUtil {
|
|
|
}
|
|
|
return Arrays.asList(filesInfo.split(IMG_SPLIT_SIGN)).stream().map(data -> {
|
|
|
String fileId = data.split("-;-")[1];
|
|
|
- // 执行附件上传方法 返回真实的id
|
|
|
- return "";
|
|
|
+ ApiCallDto apiCallDto = new ApiCallDto();
|
|
|
+ apiCallDto.setApiCode("fileUpload");
|
|
|
+ apiCallDto.setData(fileId);
|
|
|
+ R r = synchronizationDataService.uploadFile(fileId);
|
|
|
+ return r.getData().toString();
|
|
|
}).collect(Collectors.joining(","));
|
|
|
}
|
|
|
log.debug("其他格式的数据");
|
|
|
return renturnObj;
|
|
|
}
|
|
|
+
|
|
|
+ @PostConstruct
|
|
|
+ public void init() {
|
|
|
+ attendanceAssessmentSdk = autoAttendanceAssessmentSdk;
|
|
|
+ synchronizationDataService = autoSynchronizationDataService;
|
|
|
+ }
|
|
|
}
|