|
@@ -59,15 +59,14 @@ import java.math.RoundingMode;
|
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
+import static com.ydtech.modules.order.constants.OrderCacheConstant.BS_ACCESS_TOKEN;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
@@ -929,7 +928,7 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
}
|
|
}
|
|
|
// 将返回参数放入redis
|
|
// 将返回参数放入redis
|
|
|
redisTemplate.opsForValue()
|
|
redisTemplate.opsForValue()
|
|
|
- .set(OrderCacheConstant.TS_ACCESS_TOKEN + attributionDto.getUsername(), JSON.toJSONString(response.getData()), OrderCacheConstant.TS_ACCESS_TOKEN_TIME,
|
|
|
|
|
|
|
+ .set("TSBX"+OrderCacheConstant.BS_ACCESS_TOKEN + attributionDto.getUsername(), JSON.toJSONString(response.getData()), OrderCacheConstant.TS_ACCESS_TOKEN_TIME,
|
|
|
TimeUnit.SECONDS);
|
|
TimeUnit.SECONDS);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -943,7 +942,7 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
throw new SystemException(response.getMessage());
|
|
throw new SystemException(response.getMessage());
|
|
|
}
|
|
}
|
|
|
// 将返回参数放入redis
|
|
// 将返回参数放入redis
|
|
|
- redisTemplate.opsForValue().set(OrderCacheConstant.TS_ACCESS_TOKEN + attributionDto.getUsername(), JSON.toJSONString(response.getData()), OrderCacheConstant.TS_ACCESS_TOKEN_TIME,
|
|
|
|
|
|
|
+ redisTemplate.opsForValue().set("TSBX"+OrderCacheConstant.BS_ACCESS_TOKEN + attributionDto.getUsername(), JSON.toJSONString(response.getData()), OrderCacheConstant.TS_ACCESS_TOKEN_TIME,
|
|
|
TimeUnit.SECONDS);
|
|
TimeUnit.SECONDS);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -952,7 +951,7 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
// 获取协议的用户名密码
|
|
// 获取协议的用户名密码
|
|
|
|
|
|
|
|
String apiUrl = ptlCrawlerApiService.getByTemplateId(agreement.getAttribution().getTemplateId(), PtlCrawlerApiType.API_1);
|
|
String apiUrl = ptlCrawlerApiService.getByTemplateId(agreement.getAttribution().getTemplateId(), PtlCrawlerApiType.API_1);
|
|
|
- String token = redisTemplate.opsForValue().get(OrderCacheConstant.TS_ACCESS_TOKEN + agreement.getAttribution().getUsername());
|
|
|
|
|
|
|
+ String token = redisTemplate.opsForValue().get("TSBX"+OrderCacheConstant.BS_ACCESS_TOKEN + agreement.getAttribution().getUsername());
|
|
|
if (StringUtils.isNotBlank(token)) {
|
|
if (StringUtils.isNotBlank(token)) {
|
|
|
TsCrawlerLoginRequest request = JSON.parseObject(token).toJavaObject(TsCrawlerLoginRequest.class);
|
|
TsCrawlerLoginRequest request = JSON.parseObject(token).toJavaObject(TsCrawlerLoginRequest.class);
|
|
|
TsCrawlerLoginRequest tsRequest = new TsCrawlerLoginRequest(agreement.getAttribution(), agreement.getAgreement().getSmsCode(), request);
|
|
TsCrawlerLoginRequest tsRequest = new TsCrawlerLoginRequest(agreement.getAttribution(), agreement.getAgreement().getSmsCode(), request);
|
|
@@ -978,7 +977,7 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
attributionDto.setFields(attributionTemplateDtos);
|
|
attributionDto.setFields(attributionTemplateDtos);
|
|
|
String apiUrl = ptlCrawlerApiService.getByTemplateId(attribution.getTemplateId(), PtlCrawlerApiType.API_1);
|
|
String apiUrl = ptlCrawlerApiService.getByTemplateId(attribution.getTemplateId(), PtlCrawlerApiType.API_1);
|
|
|
String token = redisTemplate.opsForValue()
|
|
String token = redisTemplate.opsForValue()
|
|
|
- .get(OrderCacheConstant.TS_ACCESS_TOKEN + attributionDto.getUsername());
|
|
|
|
|
|
|
+ .get("TSBX"+OrderCacheConstant.BS_ACCESS_TOKEN + attributionDto.getUsername());
|
|
|
if (StringUtils.isNotBlank(token)) {
|
|
if (StringUtils.isNotBlank(token)) {
|
|
|
TsCrawlerLoginRequest request = JSON.parseObject(token).toJavaObject(TsCrawlerLoginRequest.class);
|
|
TsCrawlerLoginRequest request = JSON.parseObject(token).toJavaObject(TsCrawlerLoginRequest.class);
|
|
|
TsCrawlerLoginRequest tsRequest = new TsCrawlerLoginRequest(attributionDto, smscode, request);
|
|
TsCrawlerLoginRequest tsRequest = new TsCrawlerLoginRequest(attributionDto, smscode, request);
|
|
@@ -1031,6 +1030,98 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
|
|
|
return response;
|
|
return response;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public JSONObject sendLoginSmsCode(PtlAgreementAttributionDto agreementAttributionDto) {
|
|
|
|
|
+// InsAreaCompany insAreaCompany = insAreaCompanyService.getById(companyId);
|
|
|
|
|
+ PtlAgreementAttribution attribution = ptlAgreementAttributionService.getOne(new LambdaQueryWrapper<PtlAgreementAttribution>()
|
|
|
|
|
+ .eq(PtlAgreementAttribution::getTemplateId,agreementAttributionDto.getTemplateId()));
|
|
|
|
|
+
|
|
|
|
|
+ PtlAgreementAttributionDto attributionDto = new PtlAgreementAttributionDto();
|
|
|
|
|
+ BeanUtils.copyProperties(attribution, attributionDto);
|
|
|
|
|
+
|
|
|
|
|
+ String apiUrl = ptlCrawlerApiService.getByTemplateId(attribution.getTemplateId(), PtlCrawlerApiType.API_11);
|
|
|
|
|
+ JSONObject response = new JSONObject();
|
|
|
|
|
+ // 国任发送验证码
|
|
|
|
|
+ if (attribution.getInsCompanyId().equals("XDCX1000000")) {
|
|
|
|
|
+ GuoRenCrawlerSendSmsCodeRequest crawlerSendSmsCodeRequest = new GuoRenCrawlerSendSmsCodeRequest(attribution.getUsername(),attribution.getPassword());
|
|
|
|
|
+ response = insCrawlerOrderComponents.request(apiUrl, InsuranceEnum.XDCX.getCode(), "校验验证码",
|
|
|
|
|
+ crawlerSendSmsCodeRequest, JSONObject.class);
|
|
|
|
|
+ // 返回失败
|
|
|
|
|
+ if (response.getInteger("code") != 200){
|
|
|
|
|
+ throw new SystemException(response.getString("message"));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 将返回参数放入redis
|
|
|
|
|
+ redisTemplate.opsForValue().set(InsuranceEnum.XDCX.getCode()+ BS_ACCESS_TOKEN + attribution.getUsername(), response.getString("secretKey"), OrderCacheConstant.TS_ACCESS_TOKEN_TIME,
|
|
|
|
|
+ TimeUnit.SECONDS);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 泰山发送验证码
|
|
|
|
|
+ if (attribution.getInsCompanyId().equals("TSBX1000000")){
|
|
|
|
|
+ TsCrawlerLoginRequest crawlerLoginRequest = new TsCrawlerLoginRequest(attributionDto);
|
|
|
|
|
+ TsCrawlerBaseResponse tsResponse = insCrawlerOrderComponents.request(apiUrl, InsuranceEnum.TSBX.getCode(), "获取验证码",
|
|
|
|
|
+ crawlerLoginRequest, TsCrawlerBaseResponse.class);
|
|
|
|
|
+ if (!tsResponse.getCode().equals(200)) {
|
|
|
|
|
+ throw new SystemException(tsResponse.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 将返回参数放入redis
|
|
|
|
|
+ redisTemplate.opsForValue().set(InsuranceEnum.TSBX.getCode()+OrderCacheConstant.BS_ACCESS_TOKEN + attributionDto.getUsername(), JSON.toJSONString(tsResponse.getData()), OrderCacheConstant.TS_ACCESS_TOKEN_TIME,
|
|
|
|
|
+ TimeUnit.SECONDS);
|
|
|
|
|
+ }
|
|
|
|
|
+// if (attribution.getInsCompanyId().equals(""))
|
|
|
|
|
+ return response;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean verifyLoginSmsCode(PtlAgreementSaveVo agreement) {
|
|
|
|
|
+ // 获取协议的用户名密码
|
|
|
|
|
+ String apiUrl = ptlCrawlerApiService.getByTemplateId(agreement.getAttribution().getTemplateId(), PtlCrawlerApiType.API_1);
|
|
|
|
|
+
|
|
|
|
|
+ String companyCode = agreement.getAgreement().getPartnerCompaniesId().substring(0,4);
|
|
|
|
|
+
|
|
|
|
|
+ // 泰山登录
|
|
|
|
|
+ if (companyCode.equals(InsuranceEnum.TSBX.getCode())){
|
|
|
|
|
+ String token = redisTemplate.opsForValue().get(InsuranceEnum.TSBX.getCode()+OrderCacheConstant.BS_ACCESS_TOKEN + agreement.getAttribution().getUsername());
|
|
|
|
|
+ if (StringUtils.isNotBlank(token)) {
|
|
|
|
|
+ TsCrawlerLoginRequest request = JSON.parseObject(token).toJavaObject(TsCrawlerLoginRequest.class);
|
|
|
|
|
+ TsCrawlerLoginRequest tsRequest = new TsCrawlerLoginRequest(agreement.getAttribution(), agreement.getAgreement().getSmsCode(), request);
|
|
|
|
|
+ TsCrawlerBaseResponse response = insCrawlerOrderComponents.request(apiUrl, agreement.getAgreement().getPartnerCompaniesId(), "登录",
|
|
|
|
|
+ tsRequest, TsCrawlerBaseResponse.class);
|
|
|
|
|
+ if (!response.getCode().equals(200)) {
|
|
|
|
|
+ throw new SystemException("泰山登录失败:" + response.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new SystemException("验证码已失效!请重新发送!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 国任登录
|
|
|
|
|
+ else if (companyCode.equals(InsuranceEnum.XDCX.getCode())){
|
|
|
|
|
+ String secretKey = redisTemplate.opsForValue().get(InsuranceEnum.XDCX.getCode()+OrderCacheConstant.BS_ACCESS_TOKEN + agreement.getAttribution().getUsername());
|
|
|
|
|
+ if (StringUtils.isNotBlank(secretKey)) {
|
|
|
|
|
+ JSONObject grRequest = new JSONObject();
|
|
|
|
|
+ grRequest.put("username",agreement.getAttribution().getUsername());
|
|
|
|
|
+ grRequest.put("pwd",agreement.getAttribution().getPassword());
|
|
|
|
|
+ grRequest.put("smscode",agreement.getAgreement().getSmsCode());
|
|
|
|
|
+ grRequest.put("secretKey",secretKey);
|
|
|
|
|
+ // 组装 Other 信息
|
|
|
|
|
+ Map<String,String> otherMap = new HashMap<>();
|
|
|
|
|
+ agreement.getAttribution().getFields().forEach(item->{
|
|
|
|
|
+ otherMap.put(item.getField(),item.getValue());
|
|
|
|
|
+ });
|
|
|
|
|
+ grRequest.put("other",otherMap);
|
|
|
|
|
+ JSONObject response = insCrawlerOrderComponents.request(apiUrl, agreement.getAgreement().getPartnerCompaniesId(), "登录",
|
|
|
|
|
+ grRequest, JSONObject.class);
|
|
|
|
|
+ if (response.getInteger("code") != 200) {
|
|
|
|
|
+ throw new SystemException("登录失败:" + response.getString("message"));
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new SystemException("验证码已失效!请重新发送!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ // 正常登录流程
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
public BufferedImage ImageFromUrl(String urlAddr) {
|
|
public BufferedImage ImageFromUrl(String urlAddr) {
|
|
|
try {
|
|
try {
|