机场项目推送改成https

This commit is contained in:
guoshengxiong 2025-12-15 10:12:06 +08:00
parent e7202983b2
commit 9820582762
3 changed files with 56 additions and 6 deletions

View File

@ -8,6 +8,8 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.collect.Lists;
import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.call.util.jc.AESUtil;
import com.zhgd.xmgl.call.util.jc.JcHttpUtil;
import com.zhgd.xmgl.modules.electrical.entity.ElectricalData;
import com.zhgd.xmgl.modules.electrical.entity.ElectricalDev;
import com.zhgd.xmgl.modules.environment.entity.DustNoiseData;
@ -21,8 +23,6 @@ import com.zhgd.xmgl.modules.worker.service.IWorkerCertificateService;
import com.zhgd.xmgl.modules.worker.service.IWorkerTypeService;
import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl;
import com.zhgd.xmgl.util.*;
import com.zhgd.xmgl.call.util.jc.AESUtil;
import com.zhgd.xmgl.call.util.jc.JcHttpUtil;
import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.core.SchedulerLock;
import org.apache.commons.lang3.StringUtils;
@ -105,7 +105,7 @@ public class JcCall {
form.setPhone(AESUtil.Encrypt(workerInfo.getPhoneNumber(), AESUtil.SECRET));
}
if (StrUtil.isNotBlank(workerInfo.getIdCardUpPhotoUrl())) {
form.setHeadImg(PathUtil.getServerUrl() + "/image/" + workerInfo.getIdCardUpPhotoUrl());
form.setHeadImg(JcHttpUtil.replaceUrlToHttps(FileUtils.getOnlineUrl(workerInfo.getIdCardUpPhotoUrl())));
}
form.setNation(workerInfo.getNation());
form.setIdcardType(1);
@ -139,7 +139,7 @@ public class JcCall {
JcHttpUtil.UserSyncRequest.CertificateInfo certificateInfo = new JcHttpUtil.UserSyncRequest.CertificateInfo();
if (StrUtil.isNotBlank(o.get("photoUrl"))) {
try {
certificateInfo.setCertificate(FileUtils.getOnlineUrl(o.get("photoUrl")));
certificateInfo.setCertificate(JcHttpUtil.replaceUrlToHttps(FileUtils.getOnlineUrl(o.get("photoUrl"))));
} catch (Exception e) {
e.printStackTrace();
}
@ -243,7 +243,7 @@ public class JcCall {
form.setDeviceName(ufaceDev.getDevName());
}
form.setDirection(Objects.equals(workerAttendance.getPassType(), 2) ? 0 : 1);
form.setPhotoUrl(FileUtils.getOnlineUrl(workerAttendance.getImageUrl()));
form.setPhotoUrl(JcHttpUtil.replaceUrlToHttps(FileUtils.getOnlineUrl(workerAttendance.getImageUrl())));
form.setShowTime(workerAttendance.getCreateTime());
form.setIdcardNo(AESUtil.Encrypt(workerInfo.getIdCard(), AESUtil.SECRET));
form.setCreateDate(DateUtil.now());

View File

@ -1,11 +1,13 @@
package com.zhgd.xmgl.call.util.jc;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.gexin.fastjson.JSON;
import com.zhgd.xmgl.util.EnvironmentUtil;
import lombok.Data;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
@ -34,6 +36,7 @@ public class JcHttpUtil {
*/
public static String jcAllPush;
public static EnvironmentUtil environmentUtil;
private static String jcHttpsUrl;
public static String getJcProjectId() {
return jcProjectId;
@ -191,6 +194,28 @@ public class JcHttpUtil {
log.info("机场项目推送考勤记录,rs:{}", result);
}
public static String getJcHttpsUrl() {
return jcHttpsUrl;
}
@Value("${jcHttpsUrl:https://jc.zhgdyun.com:12112}")
public void setJcHttpsUrl(String jcHttpsUrl) {
JcHttpUtil.jcHttpsUrl = jcHttpsUrl;
}
/**
* 替换成https
*
* @param onlineUrl
* @return
*/
public static String replaceUrlToHttps(String onlineUrl) {
if (StrUtil.isBlank(onlineUrl)) {
return null;
}
return StringUtils.replace(onlineUrl, "http://101.43.164.214:11111", getJcHttpsUrl());
}
@Data
public static class DustDataSyncRequest {
private String projectId;
@ -638,7 +663,6 @@ public class JcHttpUtil {
}
}
/**
* 配电数据同步接口请求参数
*/

View File

@ -0,0 +1,26 @@
package com.zhgd.xmgl.call.util.jc;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.junit.jupiter.MockitoExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mockStatic;
@ExtendWith(MockitoExtension.class)
class JcHttpUtilTest {
@Test
void replaceUrlToHttps() {
try (MockedStatic<JcHttpUtil> mockedStatic = mockStatic(JcHttpUtil.class);) {
mockedStatic.when(() -> JcHttpUtil.getJcHttpsUrl()).thenReturn("https://jc.zhgdyun.com:12112");
mockedStatic.when(() -> JcHttpUtil.replaceUrlToHttps(any())).thenCallRealMethod();
String expectedUrl = "https://jc.zhgdyun.com:12112/image/693b60ba45fca3742d953f19.jpg";
String actualUrl = JcHttpUtil.replaceUrlToHttps("http://101.43.164.214:11111/image/693b60ba45fca3742d953f19.jpg");
// 验证结果
assertEquals(expectedUrl, actualUrl);
}
}
}