bug
This commit is contained in:
@ -4,16 +4,26 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.contractor.domain.SubConstructionUser;
|
||||||
|
import org.dromara.contractor.service.ISubConstructionUserService;
|
||||||
import org.dromara.project.domain.BusAttendanceRule;
|
import org.dromara.project.domain.BusAttendanceRule;
|
||||||
|
import org.dromara.system.domain.vo.SysOssVo;
|
||||||
import org.dromara.transferData.domain.ConstructionUserCopy;
|
import org.dromara.transferData.domain.ConstructionUserCopy;
|
||||||
import org.dromara.transferData.domain.OldAttendance;
|
import org.dromara.transferData.domain.OldAttendance;
|
||||||
import org.dromara.transferData.mapper.TransferDataMapper;
|
import org.dromara.transferData.mapper.TransferDataMapper;
|
||||||
import org.dromara.project.domain.BusAttendance;
|
import org.dromara.project.domain.BusAttendance;
|
||||||
import org.dromara.project.service.IBusAttendanceRuleService;
|
import org.dromara.project.service.IBusAttendanceRuleService;
|
||||||
import org.dromara.transferData.service.TransferDataService;
|
import org.dromara.transferData.service.TransferDataService;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.http.HttpRequest;
|
||||||
|
import java.net.http.HttpResponse;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
@ -40,6 +50,7 @@ public class TransferDataController {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 两个候选基础URL
|
// 两个候选基础URL
|
||||||
private static final String[] BASE_URLS = {
|
private static final String[] BASE_URLS = {
|
||||||
"http://xny.yj-3d.com:7464",
|
"http://xny.yj-3d.com:7464",
|
||||||
@ -184,4 +195,13 @@ public class TransferDataController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/transferSpecialWorkPic")
|
||||||
|
private void handleFaceImage() {
|
||||||
|
transferDataService.handleSpecialWorkPic();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.transferData.service;
|
package org.dromara.transferData.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import jakarta.activation.MimetypesFileTypeMap;
|
import jakarta.activation.MimetypesFileTypeMap;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -17,6 +18,7 @@ import org.dromara.system.service.ISysOssService;
|
|||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -162,6 +164,7 @@ public class TransferDataService {
|
|||||||
try (InputStream inputStream = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()).body()) {
|
try (InputStream inputStream = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()).body()) {
|
||||||
// 从响应头获取真实Content-Type(比文件名解析更准确)
|
// 从响应头获取真实Content-Type(比文件名解析更准确)
|
||||||
HttpResponse<?> response = httpClient.send(request, HttpResponse.BodyHandlers.discarding());
|
HttpResponse<?> response = httpClient.send(request, HttpResponse.BodyHandlers.discarding());
|
||||||
|
if(response.statusCode() == 200){
|
||||||
contentType = response.headers().firstValue("Content-Type").orElse(contentType);
|
contentType = response.headers().firstValue("Content-Type").orElse(contentType);
|
||||||
long contentLength = response.headers().firstValueAsLong("Content-Length").orElse(-1);
|
long contentLength = response.headers().firstValueAsLong("Content-Length").orElse(-1);
|
||||||
|
|
||||||
@ -170,6 +173,8 @@ public class TransferDataService {
|
|||||||
attendance.setFacePic(ossVo.getOssId() == null ? "" : ossVo.getOssId().toString());
|
attendance.setFacePic(ossVo.getOssId() == null ? "" : ossVo.getOssId().toString());
|
||||||
return; // 成功则跳出所有循环
|
return; // 成功则跳出所有循环
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("尝试URL失败(重试{}次): {}", retry + 1, fullUrl, e);
|
log.warn("尝试URL失败(重试{}次): {}", retry + 1, fullUrl, e);
|
||||||
continue; // 重试下一个URL
|
continue; // 重试下一个URL
|
||||||
@ -267,6 +272,7 @@ public class TransferDataService {
|
|||||||
try (InputStream inputStream = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()).body()) {
|
try (InputStream inputStream = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()).body()) {
|
||||||
// 从响应头获取真实Content-Type(比文件名解析更准确)
|
// 从响应头获取真实Content-Type(比文件名解析更准确)
|
||||||
HttpResponse<?> response = httpClient.send(request, HttpResponse.BodyHandlers.discarding());
|
HttpResponse<?> response = httpClient.send(request, HttpResponse.BodyHandlers.discarding());
|
||||||
|
if(response.statusCode() == 200){
|
||||||
contentType = response.headers().firstValue("Content-Type").orElse(contentType);
|
contentType = response.headers().firstValue("Content-Type").orElse(contentType);
|
||||||
long contentLength = response.headers().firstValueAsLong("Content-Length").orElse(-1);
|
long contentLength = response.headers().firstValueAsLong("Content-Length").orElse(-1);
|
||||||
|
|
||||||
@ -274,6 +280,8 @@ public class TransferDataService {
|
|||||||
SysOssVo ossVo = ossService.upload(inputStream, filename, contentType, contentLength);
|
SysOssVo ossVo = ossService.upload(inputStream, filename, contentType, contentLength);
|
||||||
return ossVo.getOssId(); // 成功则跳出所有循环
|
return ossVo.getOssId(); // 成功则跳出所有循环
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("尝试URL失败(重试{}次): {}", retry + 1, fullUrl, e);
|
log.warn("尝试URL失败(重试{}次): {}", retry + 1, fullUrl, e);
|
||||||
continue; // 重试下一个URL
|
continue; // 重试下一个URL
|
||||||
@ -285,4 +293,21 @@ public class TransferDataService {
|
|||||||
log.error("照片处理失败,所有URL重试完毕,relativePath={}", normalizedPath);
|
log.error("照片处理失败,所有URL重试完毕,relativePath={}", normalizedPath);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void handleSpecialWorkPic() {
|
||||||
|
List<SubConstructionUser> list = constructionUserService.list(Wrappers.<SubConstructionUser>lambdaQuery()
|
||||||
|
.isNotNull(SubConstructionUser::getSpecialWorkPic));
|
||||||
|
for (SubConstructionUser constructionUser : list) {
|
||||||
|
String facePicRelativePath = constructionUser.getSpecialWorkPic();
|
||||||
|
Long l = handleSinglePhoto1(facePicRelativePath);
|
||||||
|
constructionUser.setSpecialWorkPic(l==null?"":l.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
constructionUserService.updateBatchById(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user