绕过SSL验证

This commit is contained in:
lym
2025-03-11 15:44:57 +08:00
parent 0e2971df4f
commit 9577b83ad0
15 changed files with 164 additions and 53 deletions
@@ -208,7 +208,7 @@ public class OrderController {
@Parameter(name = "orderNo", description = "订单号", required = false),
@Parameter(name = "customOrderNo", description = "自定义单号", required = false)
})
@PreAuthorize("@ss.hasPermission('production:manager-list:detail')")
@PreAuthorize("@ss.hasPermission('productManager:List')")
public CommonResult<List<ApiOrderRespVO>> getApiOrder(@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime,
@RequestParam(value = "orderNo", required = false) String orderNo,
@@ -107,10 +107,10 @@ public class OrderDO extends BaseDO {
* 备注
*/
private String remark;
// /**
// * 是否删除
// */
// private Boolean deleted;
/**
* 是否删除
*/
private Boolean deleted;
/**
* 自定义板编号配置id
@@ -78,8 +78,8 @@ public class OrderBodyDO extends BaseDO {
* 备注
*/
private String remark;
// /**
// * 是否删除
// */
// private Boolean deleted;
/**
* 是否删除
*/
private Boolean deleted;
}
@@ -79,9 +79,9 @@ public class OrderGroupDO extends BaseDO {
* 备注
*/
private String remark;
// /**
// * 是否删除
// */
// private Boolean deleted;
/**
* 是否删除
*/
private Boolean deleted;
}
@@ -102,9 +102,9 @@ public class OrderPartsDO extends BaseDO {
* 备注
*/
private String remark;
// /**
// * 是否删除
// */
// private Boolean deleted;
/**
* 是否删除
*/
private Boolean deleted;
}
@@ -185,10 +185,10 @@ public class PlateDO extends BaseDO {
* 是否作废
*/
private Boolean isCancel;
// /**
// * 是否删除
// */
// private Boolean deleted;
/**
* 是否删除
*/
private Boolean deleted;
private String customPlateNo;
@@ -57,9 +57,9 @@ public class OrderProcessDO extends BaseDO {
* 下一工序 ID
*/
private Long nextStepId;
// /**
// * 是否删除
// */
// private Boolean deleted;
/**
* 是否删除
*/
private Boolean deleted;
}
@@ -90,9 +90,9 @@ public class ProcessStepDO extends BaseDO {
* 工序处理日期
*/
private LocalDateTime processDate;
// /**
// * 是否删除
// */
// private Boolean deleted;
/**
* 是否删除
*/
private Boolean deleted;
}
@@ -71,9 +71,9 @@ public class RawGoodsDO extends BaseDO {
* 规格
*/
private String spec;
// /**
// * 是否删除
// */
// private Boolean deleted;
/**
* 是否删除
*/
private Boolean deleted;
}
@@ -51,6 +51,7 @@ public class ApiDataAchieve {
String appId = app.getString("appId");
String appSecret = app.getString("appSecret");
SSLUtils.ignoreSsl();
JSONObject json = apiDataProduction.getApiTokenMessage(appId, appSecret);
if (!json.getString(ERR_MSG_KEY).equals("success")) {
log.error(APP_TOKEN_ERROR.getMsg());
@@ -62,6 +63,7 @@ public class ApiDataAchieve {
// 获取板件生产数据信息
public JSONObject getApiPlateProData(String token, String orderNo) {
SSLUtils.ignoreSsl();
JSONObject jsonPlatesData = new JSONObject();
jsonPlatesData.put(ORDER_NO_KEY, "N" + orderNo);//生产单号需要传入赋值
jsonPlatesData.put("format", "json");
@@ -73,6 +75,7 @@ public class ApiDataAchieve {
// 获取配件信息 分页获取
public JSONObject getApiPartsMessage(String token, String orderNo, JSONObject jsonParts) {
SSLUtils.ignoreSsl();
JSONObject parts = apiDataProduction.getApiOrderPartsMessage(token, jsonParts);
if (!parts.getString(ERR_CODE_KEY).equals("0")) {
log.error("N" + orderNo + "配件数据获取错误:" + parts.getString(ERR_MSG_KEY));
@@ -87,6 +90,8 @@ public class ApiDataAchieve {
// 柜体信息转换
public JSONObject getApiBodyMessage(String token, String orderNo) {
SSLUtils.ignoreSsl();
JSONObject jsonBody = new JSONObject();
jsonBody.put(CURR_PAGE_KEY, 1);
jsonBody.put(PAGE_COUNT_KEY, PARTS_PAGE_MAX);
@@ -109,6 +114,8 @@ public class ApiDataAchieve {
// 商品信息转换
public JSONObject getApiGoodsMessage(String token, String orderNo) {
SSLUtils.ignoreSsl();
JSONObject jsonGoods = new JSONObject();
jsonGoods.put(CURR_PAGE_KEY, 1);
jsonGoods.put(PAGE_COUNT_KEY, PARTS_PAGE_MAX);
@@ -131,6 +138,8 @@ public class ApiDataAchieve {
// 板材明细信息转换
public JSONObject getApiPlateDetailMessage(String token, String orderNo, JSONObject jsonPlates) {
SSLUtils.ignoreSsl();
JSONObject plates = apiDataProduction.getApiBlocksDataMessage(token, jsonPlates);
if (!plates.getString(ERR_CODE_KEY).equals("0")) {
log.error("N" + orderNo + "板材明细信息获取错误" + plates.getString(ERR_MSG_KEY));
@@ -145,6 +154,8 @@ public class ApiDataAchieve {
// 加工组信息转换
public JSONObject getApiGroupMessage(String token, String orderNo) {
SSLUtils.ignoreSsl();
JSONObject jsonModule = new JSONObject();
jsonModule.put(ORDER_NO_KEY, "N" + orderNo);
return apiDataProduction.getApiModuleTypeDataMessage(token, jsonModule);
@@ -152,6 +163,8 @@ public class ApiDataAchieve {
// 板材数据信息转换
public JSONObject getApiBlocksMessage(String token, String orderNo) {
SSLUtils.ignoreSsl();
JSONObject jsonBlocks = new JSONObject();
jsonBlocks.put(CURR_PAGE_KEY, 1);
jsonBlocks.put(PAGE_COUNT_KEY, PARTS_PAGE_MAX);
@@ -173,6 +186,8 @@ public class ApiDataAchieve {
// 商品列表信息转换
@Async
public Future<JSONObject> getApiGoodsMessage(String token, Long[] id) {
SSLUtils.ignoreSsl();
JSONObject jsonGoods = new JSONObject();
jsonGoods.put(GOODS_ID, id);
JSONObject good = apiDataProduction.getApiGoods(token, jsonGoods);
@@ -186,6 +201,8 @@ public class ApiDataAchieve {
// 订单获取
public JSONObject getApiOrder(String token, String orderNo) {
SSLUtils.ignoreSsl();
JSONObject jsonOrders = new JSONObject();
orderNo = "N" +orderNo;
JSONArray orderList = new JSONArray();
@@ -224,6 +241,8 @@ public class ApiDataAchieve {
}
// 订单列表
public Future<JSONObject> getApiOrderList(String token,String shopId,String createDateMin, String createDateMax, String orderNo, String customOrderNo) {
SSLUtils.ignoreSsl();
JSONObject jsonOrders = new JSONObject();
if (createDateMin != null && createDateMax != null){
getDate(createDateMin, createDateMax, jsonOrders);
@@ -6,8 +6,7 @@ import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.web.bind.annotation.*;
@FeignClient(url = "https://chenfeng.tech:7779", name = "apiOrderService", configuration = FeignClientsConfiguration.class )
@FeignClient(url = "${api.order.apiOrderService.url}", name = "apiOrderService", configuration = FeignClientsConfiguration.class ) // FeignClientsConfiguration
public interface ApiDataProduction {
// 登陆token
@@ -0,0 +1,66 @@
package com.cf.imes.module.executor.util.fileConversion.admin.api.webcad;
import javax.net.ssl.*;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
/**
* @projectName: cf_imes_server
* @author: 晨丰科技
* @date: 2025/3/11 14:51
*/
public class SSLUtils {
private static void trustAllHttpsCertificates() throws Exception {
TrustManager[] trustAllCerts = new TrustManager[1];
TrustManager tm = new miTM();
trustAllCerts[0] = tm;
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
static class miTM implements TrustManager, X509TrustManager {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public boolean isServerTrusted(X509Certificate[] certs) {
return true;
}
public boolean isClientTrusted(X509Certificate[] certs) {
return true;
}
public void checkServerTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
return;
}
public void checkClientTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
return;
}
}
/**
* 忽略HTTPS请求的SSL证书,必须在openConnection之前调用
*
* @throws Exception
*/
public static void ignoreSsl() {
try {
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
return true;
}
};
trustAllHttpsCertificates();
HttpsURLConnection.setDefaultHostnameVerifier(hv);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -69,12 +69,12 @@ public class XmlTypeRealize {
for (RoomXmlVO roomXmlVO : roomXmlVOS.getRoomXmlVOList()) {
for (BoxXmlVO boxXmlVO : roomXmlVO.getBoxXmlVOList()) {
BasePosition basePosition = BasePosition.builder()
.basePointX(Double.valueOf(boxXmlVO.getBasePointX()))
.basePointY(Double.valueOf(boxXmlVO.getBasePointY()))
.basePointZ(Double.valueOf(boxXmlVO.getBasePointZ()))
.axisXrotate(Double.valueOf(boxXmlVO.getAxisXrotate()))
.axisYrotate(Double.valueOf(boxXmlVO.getAxisYrotate()))
.axisZrotate(Double.valueOf(boxXmlVO.getAxisZrotate()))
.basePointX(Double.valueOf(boxXmlVO.getBasePointX() == null ? "0" : boxXmlVO.getBasePointX()))
.basePointY(Double.valueOf(boxXmlVO.getBasePointY() == null ? "0" : boxXmlVO.getBasePointY()))
.basePointZ(Double.valueOf(boxXmlVO.getBasePointZ() == null ? "0" : boxXmlVO.getBasePointZ()))
.axisXrotate(Double.valueOf(boxXmlVO.getAxisXrotate() == null ? "0" : boxXmlVO.getAxisXrotate()))
.axisYrotate(Double.valueOf(boxXmlVO.getAxisYrotate() == null ? "0" : boxXmlVO.getAxisYrotate()))
.axisZrotate(Double.valueOf(boxXmlVO.getAxisZrotate() == null ? "0" : boxXmlVO.getAxisZrotate()))
.build();
basePositions.put(boxXmlVO.getCode(), basePosition);
}
@@ -116,6 +116,13 @@ public class XmlTypeRealize {
Long roomId = (Long) snowFlakeGenerator.nextId(null);
setDefaultsForRoomXmlVO(roomXmlVO);
if (roomXmlVO.getBoxXmlVOList() == null || roomXmlVO.getBoxXmlVOList().isEmpty()) {
BoxXmlVO boxXmlVO = new BoxXmlVO();
setDefaultsForBoxXmlVO(boxXmlVO);
List<BoxXmlVO> boxXmlVOList = new ArrayList<>();
boxXmlVOList.add(boxXmlVO);
roomXmlVO.setBoxXmlVOList(boxXmlVOList);
}
for (BoxXmlVO boxXmlVO : roomXmlVO.getBoxXmlVOList()) {
setDefaultsForBoxXmlVO(boxXmlVO);
OrderBodyDO orderBodyDO = createOrderBodyDO(boxXmlVO, roomId, orderId, organId, roomXmlVO.getName());
@@ -128,9 +135,7 @@ public class XmlTypeRealize {
}
private void setDefaultsForRoomXmlVO(RoomXmlVO roomXmlVO) {
if (roomXmlVO.getName() == null) {
roomXmlVO.setName(NOT_ASSIGNED);
}
if (roomXmlVO.getCode() == null) {
if (roomXmlVO.getName() == null) {
roomXmlVO.setCode(NOT_ASSIGNED_CODE);
@@ -138,12 +143,13 @@ public class XmlTypeRealize {
roomXmlVO.setCode(NOT_ASSIGNED_CODE + roomXmlVO.getName());
}
}
if (roomXmlVO.getName() == null) {
roomXmlVO.setName(NOT_ASSIGNED);
}
}
private void setDefaultsForBoxXmlVO(BoxXmlVO boxXmlVO) {
if (boxXmlVO.getName() == null) {
boxXmlVO.setName(NOT_ASSIGNED);
}
if (boxXmlVO.getCode() == null) {
if (boxXmlVO.getName() == null) {
boxXmlVO.setCode(NOT_ASSIGNED_CODE);
@@ -151,6 +157,9 @@ public class XmlTypeRealize {
boxXmlVO.setCode(NOT_ASSIGNED_CODE + boxXmlVO.getName());
}
}
if (boxXmlVO.getName() == null || boxXmlVO.getName().isEmpty()) {
boxXmlVO.setName(NOT_ASSIGNED);
}
}
private OrderBodyDO createOrderBodyDO(BoxXmlVO boxXmlVO, Long roomId, Long orderId, Long organId, String roomName) {
@@ -161,9 +170,9 @@ public class XmlTypeRealize {
.roomId(roomId)
.roomName(roomName) // 假设 BoxXmlVO 中有 roomName 字段
.name(boxXmlVO.getName())
.width(Double.parseDouble(boxXmlVO.getWidth()))
.height(Double.parseDouble(boxXmlVO.getHeight()))
.depth(Double.parseDouble(boxXmlVO.getLength()))
.width(Double.parseDouble(boxXmlVO.getWidth() == null ? "0" : boxXmlVO.getWidth()))
.height(Double.parseDouble(boxXmlVO.getHeight() == null ? "0" : boxXmlVO.getHeight()))
.depth(Double.parseDouble(boxXmlVO.getLength() == null ? "0" : boxXmlVO.getLength()))
.plateNum(0)
.unregularNum(0)
.build();
@@ -450,8 +459,9 @@ public class XmlTypeRealize {
String boxNo = positionVO.getBoxCode();
OrderBodyDO bodyDO = bodyMap.get(boxNo);
plateNum = plateNum + unregularNum;
if (bodyDO != null) {
bodyDO.setPlateNum((int) (bodyDO.getPlateNum() + plateNum + unregularNum))
bodyDO.setPlateNum((int) (bodyDO.getPlateNum() + plateNum))
.setUnregularNum((int) (bodyDO.getUnregularNum() + unregularNum));
} else {
Long roomId = (Long) identifierGenerator.nextId(null);
@@ -174,3 +174,12 @@ justauth:
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志
--- #################### 生产接口url配置 ####################
api:
order:
apiOrderService:
url: https://www.leye.site/ # 生产环境
@@ -154,3 +154,11 @@ chenfeng:
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志
--- #################### 生产接口url配置 ####################
api:
order:
apiOrderService:
url: https://chenfeng.tech:7779/ # 开发环境 https://www.leye.site/ 生产环境