This commit is contained in:
liulu
2024-12-05 17:33:52 +08:00
parent 0f61f4be5b
commit bcf8dfb5f3
4 changed files with 18 additions and 145 deletions
@@ -1,7 +1,6 @@
package com.sunyard.chsm.sdf.adapter;
import com.sunyard.chsm.enums.ManufacturerModelEnum;
import com.sunyard.chsm.sdf.context.DeviceContext;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.util.Assert;
@@ -14,20 +13,20 @@ import java.util.Objects;
public class SdfApiAdapterFactory {
public static SdfApiAdapter newInstance(DeviceContext device) {
public static SdfApiAdapter newInstance(String model, String ip, Integer port) {
Assert.hasText(device.getManufacturerModel(), "设备型号不能为空");
ManufacturerModelEnum model = ManufacturerModelEnum.of(device.getManufacturerModel());
Assert.hasText(model, "设备型号不能为空");
ManufacturerModelEnum modelEnum = ManufacturerModelEnum.of(model);
if (Objects.isNull(model) && Objects.equals(BouncyCastleProvider.PROVIDER_NAME, device.getManufacturerModel())) {
if (Objects.isNull(modelEnum) && Objects.equals(BouncyCastleProvider.PROVIDER_NAME, model)) {
// bc adaptor
return new BcSdfApiAdaptor();
}
switch (model) {
switch (modelEnum) {
case enc001:
return new SunyardJnaSdfAdaptor(device.getServiceIp(), device.getServicePort());
return new SunyardJnaSdfAdaptor(ip, port);
default:
throw new UnsupportedOperationException("不支持的设备型号: " + device.getManufacturerModel());
throw new UnsupportedOperationException("不支持的设备型号: " + model);
}
}