|
@@ -1,84 +1,84 @@
|
|
|
-package com.juxin.client.rpa.test;
|
|
|
|
|
-
|
|
|
|
|
-import com.google.gson.Gson;
|
|
|
|
|
-import com.juxin.client.rpa.constant.TaieOcConstants;
|
|
|
|
|
-import com.juxin.client.rpa.constant.TaieOcManageCode;
|
|
|
|
|
-import com.juxin.client.rpa.dto.DubboResult;
|
|
|
|
|
-import com.juxin.client.rpa.dto.MachineLicenseAcquireReqDto;
|
|
|
|
|
-import com.juxin.client.rpa.dto.MachineLicensePo;
|
|
|
|
|
-import com.juxin.client.rpa.dto.MachineLicenseRespDto;
|
|
|
|
|
-import com.juxin.client.rpa.mapper.MachineLicenseMapper;
|
|
|
|
|
-import com.juxin.client.rpa.utils.SM2Utils;
|
|
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
-
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
|
-import java.util.Calendar;
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
-
|
|
|
|
|
-@Service
|
|
|
|
|
-@Slf4j
|
|
|
|
|
-public class LicenseManager {
|
|
|
|
|
- private static final Gson gson = new Gson();
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private MachineLicenseMapper machineLicenseMapper;
|
|
|
|
|
-
|
|
|
|
|
- public DubboResult<MachineLicenseRespDto> createLicense(MachineLicenseAcquireReqDto reqDto, String datetime) {
|
|
|
|
|
- // 根据机器信息判定是否需要登录
|
|
|
|
|
- DubboResult<MachineLicenseRespDto> result;
|
|
|
|
|
- try {
|
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat(TaieOcConstants.DATE_LONG_FORMAT);
|
|
|
|
|
-// Calendar cal = Calendar.getInstance();
|
|
|
|
|
-// cal.add(Calendar.YEAR, licenseExpireDate);
|
|
|
|
|
-// 时间戳毫秒设置为零,对应处理入库时间预防 秒级四舍五入情况,导致入库时间+1s,导致rpa登录校验失败
|
|
|
|
|
-// cal.set(Calendar.MILLISECOND, 0); //毫秒
|
|
|
|
|
|
|
+//package com.juxin.client.rpa.test;
|
|
|
|
|
+//
|
|
|
|
|
+//import com.google.gson.Gson;
|
|
|
|
|
+//import com.juxin.client.rpa.constant.TaieOcConstants;
|
|
|
|
|
+//import com.juxin.client.rpa.constant.TaieOcManageCode;
|
|
|
|
|
+//import com.juxin.client.rpa.dto.DubboResult;
|
|
|
|
|
+//import com.juxin.client.rpa.dto.MachineLicenseAcquireReqDto;
|
|
|
|
|
+//import com.juxin.client.rpa.dto.MachineLicensePo;
|
|
|
|
|
+//import com.juxin.client.rpa.dto.MachineLicenseRespDto;
|
|
|
|
|
+//import com.juxin.client.rpa.mapper.MachineLicenseMapper;
|
|
|
|
|
+//import com.juxin.client.rpa.utils.SM2Utils;
|
|
|
|
|
+//import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+//import org.springframework.stereotype.Service;
|
|
|
|
|
+//import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
+//
|
|
|
|
|
+//import java.text.SimpleDateFormat;
|
|
|
|
|
+//import java.util.Calendar;
|
|
|
|
|
+//import java.util.Date;
|
|
|
|
|
+//
|
|
|
|
|
+//@Service
|
|
|
|
|
+//@Slf4j
|
|
|
|
|
+//public class LicenseManager {
|
|
|
|
|
+// private static final Gson gson = new Gson();
|
|
|
|
|
+//
|
|
|
|
|
+// @Autowired
|
|
|
|
|
+// private MachineLicenseMapper machineLicenseMapper;
|
|
|
|
|
+//
|
|
|
|
|
+// public DubboResult<MachineLicenseRespDto> createLicense(MachineLicenseAcquireReqDto reqDto, String datetime) {
|
|
|
|
|
+// // 根据机器信息判定是否需要登录
|
|
|
|
|
+// DubboResult<MachineLicenseRespDto> result;
|
|
|
|
|
+// try {
|
|
|
// SimpleDateFormat sdf = new SimpleDateFormat(TaieOcConstants.DATE_LONG_FORMAT);
|
|
// SimpleDateFormat sdf = new SimpleDateFormat(TaieOcConstants.DATE_LONG_FORMAT);
|
|
|
-// DubboResult<SmartRobotDto> smartRobotResult = robotManager.queryRobotByKey(reqDto.getMachineCode() + reqDto.getUser());
|
|
|
|
|
-// if (!smartRobotResult.success()) {
|
|
|
|
|
-// return DubboResult.newFailure(smartRobotResult.getCode(), smartRobotResult.getMessage());
|
|
|
|
|
-// }
|
|
|
|
|
- // 先判断是否获取过license信息
|
|
|
|
|
-// List<MachineLicensePo> machineLicensePos = machineLicenseMapper.selectMachineLicense(MachineLicenseFilterDto.MachineLicenseFilterBuilder()
|
|
|
|
|
|
|
+//// Calendar cal = Calendar.getInstance();
|
|
|
|
|
+//// cal.add(Calendar.YEAR, licenseExpireDate);
|
|
|
|
|
+//// 时间戳毫秒设置为零,对应处理入库时间预防 秒级四舍五入情况,导致入库时间+1s,导致rpa登录校验失败
|
|
|
|
|
+//// cal.set(Calendar.MILLISECOND, 0); //毫秒
|
|
|
|
|
+//// SimpleDateFormat sdf = new SimpleDateFormat(TaieOcConstants.DATE_LONG_FORMAT);
|
|
|
|
|
+//// DubboResult<SmartRobotDto> smartRobotResult = robotManager.queryRobotByKey(reqDto.getMachineCode() + reqDto.getUser());
|
|
|
|
|
+//// if (!smartRobotResult.success()) {
|
|
|
|
|
+//// return DubboResult.newFailure(smartRobotResult.getCode(), smartRobotResult.getMessage());
|
|
|
|
|
+//// }
|
|
|
|
|
+// // 先判断是否获取过license信息
|
|
|
|
|
+//// List<MachineLicensePo> machineLicensePos = machineLicenseMapper.selectMachineLicense(MachineLicenseFilterDto.MachineLicenseFilterBuilder()
|
|
|
|
|
+//// .machineKey(reqDto.getMachineCode() + reqDto.getUser())
|
|
|
|
|
+//// .licenseType(reqDto.getLicenseType())
|
|
|
|
|
+//// .machineType(reqDto.getMachineType())
|
|
|
|
|
+//// .requestParam(reqDto.getParamsMap() == null ? TaieOcConstants.EMPTY_STRING : gson.toJson(reqDto.getParamsMap()))
|
|
|
|
|
+//// .build());
|
|
|
|
|
+//// if (CollectionUtils.isNotEmpty(machineLicensePos)) {
|
|
|
|
|
+//// return DubboResult.newSuccess(machineLicensePos.get(0).createRespDto(smartRobotResult.getObject().getAuthState()));
|
|
|
|
|
+//// }
|
|
|
|
|
+// // 获取license信息
|
|
|
|
|
+//// Date endTime = cal.getTime();
|
|
|
|
|
+// Date endTime = sdf.parse(datetime);
|
|
|
|
|
+// String license = SM2Utils.generateLicense(reqDto.getLicenseType(), reqDto.getMachineType()
|
|
|
|
|
+// , sdf.format(endTime), reqDto.getParamsMap());
|
|
|
|
|
+//
|
|
|
|
|
+// // license申请信息落库
|
|
|
|
|
+// MachineLicensePo licensePo = MachineLicensePo.builder()
|
|
|
|
|
+// .license(license)
|
|
|
// .machineKey(reqDto.getMachineCode() + reqDto.getUser())
|
|
// .machineKey(reqDto.getMachineCode() + reqDto.getUser())
|
|
|
-// .licenseType(reqDto.getLicenseType())
|
|
|
|
|
// .machineType(reqDto.getMachineType())
|
|
// .machineType(reqDto.getMachineType())
|
|
|
// .requestParam(reqDto.getParamsMap() == null ? TaieOcConstants.EMPTY_STRING : gson.toJson(reqDto.getParamsMap()))
|
|
// .requestParam(reqDto.getParamsMap() == null ? TaieOcConstants.EMPTY_STRING : gson.toJson(reqDto.getParamsMap()))
|
|
|
|
|
+// .startTime(Calendar.getInstance().getTime())
|
|
|
|
|
+// .endTime(endTime)
|
|
|
|
|
+// .licenseType(reqDto.getLicenseType())
|
|
|
|
|
+// .build();
|
|
|
|
|
+// machineLicenseMapper.insert(licensePo);
|
|
|
|
|
+// log.info("入库许可数据信息licensePo = {MachineLicensePo@7487} \"MachineLicensePo(id=null, machineKey=PE3ZVJ9NS9592TJS6XG06CREWC3ZP9T3FHAD5TVCXSPAN50872M0admin, machineType=design, license=3045022054ae9fe57b7bb8c0489bd435e7c1c18e128d9fb0a6351ea381065226060c2bc6022100a2882713d129f247d30cef9a80a57f55810215997f9a4c4005c4f2d9cf90b219==2026-01-01 00:00:00, licenseType=local, startTime=Thu Aug 28 17:49:00 GMT+08:00 2025, endTime=Thu Jan 01 00:00:00 GMT+08:00 2026, isValid=0, requestParam=)\":" + licensePo);
|
|
|
|
|
+// result = DubboResult.newSuccess(MachineLicenseRespDto.builder()
|
|
|
|
|
+// .license(license)
|
|
|
|
|
+// .licenseType(reqDto.getLicenseType())
|
|
|
|
|
+// .expireTime(sdf.format(endTime))
|
|
|
// .build());
|
|
// .build());
|
|
|
-// if (CollectionUtils.isNotEmpty(machineLicensePos)) {
|
|
|
|
|
-// return DubboResult.newSuccess(machineLicensePos.get(0).createRespDto(smartRobotResult.getObject().getAuthState()));
|
|
|
|
|
-// }
|
|
|
|
|
- // 获取license信息
|
|
|
|
|
-// Date endTime = cal.getTime();
|
|
|
|
|
- Date endTime = sdf.parse(datetime);
|
|
|
|
|
- String license = SM2Utils.generateLicense(reqDto.getLicenseType(), reqDto.getMachineType()
|
|
|
|
|
- , sdf.format(endTime), reqDto.getParamsMap());
|
|
|
|
|
-
|
|
|
|
|
- // license申请信息落库
|
|
|
|
|
- MachineLicensePo licensePo = MachineLicensePo.builder()
|
|
|
|
|
- .license(license)
|
|
|
|
|
- .machineKey(reqDto.getMachineCode() + reqDto.getUser())
|
|
|
|
|
- .machineType(reqDto.getMachineType())
|
|
|
|
|
- .requestParam(reqDto.getParamsMap() == null ? TaieOcConstants.EMPTY_STRING : gson.toJson(reqDto.getParamsMap()))
|
|
|
|
|
- .startTime(Calendar.getInstance().getTime())
|
|
|
|
|
- .endTime(endTime)
|
|
|
|
|
- .licenseType(reqDto.getLicenseType())
|
|
|
|
|
- .build();
|
|
|
|
|
- machineLicenseMapper.insert(licensePo);
|
|
|
|
|
- log.info("入库许可数据信息licensePo = {MachineLicensePo@7487} \"MachineLicensePo(id=null, machineKey=PE3ZVJ9NS9592TJS6XG06CREWC3ZP9T3FHAD5TVCXSPAN50872M0admin, machineType=design, license=3045022054ae9fe57b7bb8c0489bd435e7c1c18e128d9fb0a6351ea381065226060c2bc6022100a2882713d129f247d30cef9a80a57f55810215997f9a4c4005c4f2d9cf90b219==2026-01-01 00:00:00, licenseType=local, startTime=Thu Aug 28 17:49:00 GMT+08:00 2025, endTime=Thu Jan 01 00:00:00 GMT+08:00 2026, isValid=0, requestParam=)\":" + licensePo);
|
|
|
|
|
- result = DubboResult.newSuccess(MachineLicenseRespDto.builder()
|
|
|
|
|
- .license(license)
|
|
|
|
|
- .licenseType(reqDto.getLicenseType())
|
|
|
|
|
- .expireTime(sdf.format(endTime))
|
|
|
|
|
- .build());
|
|
|
|
|
- return result;
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- log.error(e.getMessage(), e);
|
|
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
|
- return DubboResult.newFailure(TaieOcManageCode.LICENSE_AQUIRE.getCode(), TaieOcManageCode.LICENSE_AQUIRE.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+// return result;
|
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
|
+// e.printStackTrace();
|
|
|
|
|
+// log.error(e.getMessage(), e);
|
|
|
|
|
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
|
+// return DubboResult.newFailure(TaieOcManageCode.LICENSE_AQUIRE.getCode(), TaieOcManageCode.LICENSE_AQUIRE.getMessage());
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//}
|