|
@@ -2,6 +2,7 @@ package com.technology.huahai.web.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
|
+import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
|
|
import com.technology.huahai.common.constant.RedisKeyConstant;
|
|
@@ -10,13 +11,12 @@ import com.technology.huahai.common.core.page.TableDataInfo;
|
|
|
import com.technology.huahai.common.exception.CsmException;
|
|
|
import com.technology.huahai.common.utils.JsonUtils;
|
|
|
import com.technology.huahai.common.utils.RedisUtils;
|
|
|
-import com.technology.huahai.common.utils.StringUtils;
|
|
|
import com.technology.huahai.common.utils.file.FileUtils;
|
|
|
-import com.technology.huahai.web.dto.ChannelDto;
|
|
|
import com.technology.huahai.web.dto.ScanRecordDto;
|
|
|
import com.technology.huahai.web.vo.*;
|
|
|
import com.technology.huahai.web.mapper.coremapper.CsmMapper;
|
|
|
import com.technology.huahai.web.service.CsmService;
|
|
|
+import com.technology.huahai.web.zx.ZxService;
|
|
|
import net.glxn.qrgen.core.image.ImageType;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -27,8 +27,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.util.Base64Utils;
|
|
|
-import org.springframework.util.LinkedMultiValueMap;
|
|
|
-import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.io.*;
|
|
@@ -47,6 +45,9 @@ public class CsmServiceImpl implements CsmService {
|
|
|
|
|
|
@Autowired
|
|
|
private RestTemplate restTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZxService zxService;
|
|
|
@Autowired
|
|
|
RedisUtils redisUtils;
|
|
|
|
|
@@ -95,7 +96,7 @@ public class CsmServiceImpl implements CsmService {
|
|
|
|
|
|
@Override
|
|
|
public boolean realPersonAuthentication(RealPersonAuthenticationVo realPersonAuthenticationVo) {
|
|
|
- String token = getZxTokenByRedis();
|
|
|
+ /*String token = getZxTokenByRedis();
|
|
|
if(StringUtils.isBlank(token)){
|
|
|
throw new CsmException("总线token获取失败");
|
|
|
}else{
|
|
@@ -125,16 +126,19 @@ public class CsmServiceImpl implements CsmService {
|
|
|
}else{
|
|
|
throw new CsmException(zxResultDto.getMessage());
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void saveScanCodeRecord(ScanCodeRecordVo scanCodeRecordVo) {
|
|
|
+ public AjaxResult saveScanCodeRecord(ScanCodeRecordVo scanCodeRecordVo) {
|
|
|
//本地留存一份只保留扫码时间及姓名及场所码id
|
|
|
csmMapper.saveScanRecord(scanCodeRecordVo);
|
|
|
- AjaxResult ajaxResult = cmsEmsInterfaceOperation(csmCtMethodKey,scanCodeRecordVo,"saveScanRecord");
|
|
|
+ AjaxResult ajaxResult = zxService.cmsEmsInterfaceOperation(scanCodeRecordVo,"saveScanRecord");
|
|
|
if(0!=ajaxResult.getCode()){
|
|
|
throw new CsmException(ajaxResult.getMsg());
|
|
|
+ }else{
|
|
|
+ return ajaxResult;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -155,7 +159,7 @@ public class CsmServiceImpl implements CsmService {
|
|
|
ResponseEntity<TableDataInfo> response = restTemplate.postForEntity(url, requestEntity, TableDataInfo.class);
|
|
|
tableDataInfo = response.getBody();
|
|
|
}else{
|
|
|
- tableDataInfo = cmsEmsInterfaceQueryList(csmCtMethodKey, technologyQueryVo,"getCsmList");
|
|
|
+ tableDataInfo = zxService.cmsEmsInterfaceQueryList(technologyQueryVo,"getCsmList");
|
|
|
}
|
|
|
return tableDataInfo;
|
|
|
}
|
|
@@ -176,8 +180,24 @@ public class CsmServiceImpl implements CsmService {
|
|
|
logger.info("请求地址"+url);
|
|
|
ResponseEntity<TableDataInfo> response = restTemplate.postForEntity(url, requestEntity, TableDataInfo.class);
|
|
|
tableDataInfo = response.getBody();
|
|
|
+ List rows = tableDataInfo.getRows();
|
|
|
+ List<TechnologyListResultVo> rowList = JsonUtils.parseJson(JsonUtils.writeValueAsString(rows),new TypeReference<List<TechnologyListResultVo>>() {});
|
|
|
+ for(TechnologyListResultVo technologyListResultVo:rowList){
|
|
|
+ Object labelName = redisUtils.get(RedisKeyConstant.dictKey+"SCENARIO_LABEL"+"::"+technologyListResultVo.getLabelId());
|
|
|
+ if(labelName!=null){
|
|
|
+ technologyListResultVo.setLabelName(labelName.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tableDataInfo.setRows(rowList);
|
|
|
}else{
|
|
|
- tableDataInfo = cmsEmsInterfaceQueryList(csmCtMethodKey, technologyQueryVo,"getDdSelect");
|
|
|
+ tableDataInfo = zxService.cmsEmsInterfaceQueryList(technologyQueryVo,"getDdSelect");
|
|
|
+ List<TechnologyListResultVo> rows = tableDataInfo.getRows();
|
|
|
+ for(TechnologyListResultVo technologyListResultVo:rows){
|
|
|
+ Object labelName = redisUtils.get(RedisKeyConstant.dictKey+"SCENARIO_LABEL"+"::"+technologyListResultVo.getLabelId());
|
|
|
+ if(labelName!=null){
|
|
|
+ technologyListResultVo.setLabelName(labelName.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return tableDataInfo;
|
|
|
}
|
|
@@ -219,7 +239,7 @@ public class CsmServiceImpl implements CsmService {
|
|
|
ajaxResult = response.getBody();*/
|
|
|
ajaxResult.setData(fileName);
|
|
|
}else{
|
|
|
- ajaxResult = cmsEmsInterfaceOperation(csmCtMethodKey,technologyGenerateVo,"saveCsm");
|
|
|
+ ajaxResult = zxService.cmsEmsInterfaceOperation(technologyGenerateVo,"saveCsm");
|
|
|
if(0!=ajaxResult.getCode()){
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
}
|
|
@@ -250,14 +270,14 @@ public class CsmServiceImpl implements CsmService {
|
|
|
ResponseEntity<AjaxResult> response = restTemplate.postForEntity(url, requestEntity, AjaxResult.class);
|
|
|
ajaxResult = response.getBody();
|
|
|
}else{
|
|
|
- ajaxResult = cmsEmsInterfaceOperation(csmCtMethodKey,queryAdressVo,"getAdressByBzdzbm");
|
|
|
+ ajaxResult = zxService.cmsEmsInterfaceOperation(queryAdressVo,"getAdressByBzdzbm");
|
|
|
}
|
|
|
return ajaxResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public AjaxResult getAdressByDz(QueryAdressByDzVo queryAdressByDzVo) {
|
|
|
- return cmsEmsInterfaceOperation(csmCtMethodKey,queryAdressByDzVo,"getAdressByDz");
|
|
|
+ public AjaxResult getAddressByBzdzbm(QueryAddressByBzdzbmVo queryAdressByDzVo) {
|
|
|
+ return zxService.cmsEmsInterfaceOperation(queryAdressByDzVo,"getAddressByBzdzbm");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -305,7 +325,7 @@ public class CsmServiceImpl implements CsmService {
|
|
|
throw new CsmException(ajaxResult.getMsg());
|
|
|
}
|
|
|
}else{
|
|
|
- ajaxResult = cmsEmsInterfaceOperation(csmCtMethodKey,feedbackVo,"generateFeedback");
|
|
|
+ ajaxResult = zxService.cmsEmsInterfaceOperation(feedbackVo,"generateFeedback");
|
|
|
if(0!=ajaxResult.getCode()){
|
|
|
throw new CsmException(ajaxResult.getMsg());
|
|
|
}
|
|
@@ -315,13 +335,13 @@ public class CsmServiceImpl implements CsmService {
|
|
|
|
|
|
@Override
|
|
|
public AjaxResult queryLevelByLevelId(QueryDdLevelVo queryDdLevelVo) {
|
|
|
- AjaxResult ajaxResult = cmsEmsInterfaceOperation(csmCtMethodKey,queryDdLevelVo,"queryLevelByLevelId");
|
|
|
+ AjaxResult ajaxResult = zxService.cmsEmsInterfaceOperation(queryDdLevelVo,"queryLevelByLevelId");
|
|
|
return ajaxResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public TableDataInfo queryDdByLevelAndName(QueryDdLevelVo queryDdLevelVo) {
|
|
|
- TableDataInfo tableDataInfo = cmsEmsInterfaceQueryList(csmCtMethodKey,queryDdLevelVo,"queryDdByLevelAndName");
|
|
|
+ TableDataInfo tableDataInfo = zxService.cmsEmsInterfaceQueryList(queryDdLevelVo,"queryDdByLevelAndName");
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
|
|
@@ -350,44 +370,7 @@ public class CsmServiceImpl implements CsmService {
|
|
|
}*/
|
|
|
|
|
|
|
|
|
- public String getZxTokenByRedis(){
|
|
|
- Object o = redisUtils.get(RedisKeyConstant.zxtokenKey);
|
|
|
- if(null != o && StringUtils.isNotEmpty(String.valueOf(o)) && !"null".equals(String.valueOf(o))){
|
|
|
- return String.valueOf(o);
|
|
|
- }else{
|
|
|
- return getZxTokenByInterface();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public synchronized String getZxTokenByInterface(){
|
|
|
- Object o = redisUtils.get(RedisKeyConstant.zxtokenKey);
|
|
|
- if(null != o && StringUtils.isNotEmpty(String.valueOf(o)) && !"null".equals(String.valueOf(o))){
|
|
|
- return String.valueOf(o);
|
|
|
- }else{
|
|
|
- MultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
|
|
|
- formData.add("userID", userId);
|
|
|
- formData.add("userKey", userKey);
|
|
|
-
|
|
|
- // 4. 构造请求头,指定 Content-Type 为 application/x-www-form-urlencoded
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
|
|
-
|
|
|
- // 5. 构造请求实体(包含头和体)
|
|
|
- HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(formData, headers);
|
|
|
|
|
|
- // 6. 发送请求并获取响应(假设返回的是 String 类型)
|
|
|
- JSONObject jsonObject = restTemplate.postForObject(loginUrl, requestEntity, JSONObject.class);
|
|
|
- logger.info("总线token获取结果 {}",jsonObject);
|
|
|
- Object access_token = jsonObject.get("access_token");
|
|
|
- if(null == access_token){
|
|
|
- throw new CsmException("获取总线token失败");
|
|
|
- }else{
|
|
|
- String token = String.valueOf(access_token);
|
|
|
- redisUtils.set(RedisKeyConstant.zxtokenKey,token,7000);
|
|
|
- return token;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
public static String getBase64UrlStr(String bzdzbm){
|
|
|
String url = "https://ywtb.ga.tj.gov.cn/csm/?bzdzbm="+bzdzbm;
|
|
@@ -423,95 +406,6 @@ public class CsmServiceImpl implements CsmService {
|
|
|
return base64Str;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 场所码内网透传接口(操作类)
|
|
|
- * @param emsMethodkey
|
|
|
- * @param o
|
|
|
- * @param o
|
|
|
- * methodName
|
|
|
- * @return
|
|
|
- */
|
|
|
- public AjaxResult cmsEmsInterfaceOperation(String emsMethodkey,Object o,String methodName){
|
|
|
- String token = getZxTokenByRedis();
|
|
|
- if(StringUtils.isBlank(token)){
|
|
|
- throw new CsmException("总线token获取失败");
|
|
|
- }else{
|
|
|
- ChannelDto channelDto = new ChannelDto();
|
|
|
- channelDto.setMethod(methodName);
|
|
|
- channelDto.setData(o);
|
|
|
- String jsonStr = JsonUtils.writeValueAsString(channelDto);
|
|
|
- MultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
|
|
|
- formData.add("methodkey", emsMethodkey);
|
|
|
- formData.add("postDataJson", jsonStr);
|
|
|
-
|
|
|
- // 4. 构造请求头,指定 Content-Type 为 application/x-www-form-urlencoded
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
|
|
- headers.set("Authorization","Bearer "+token);
|
|
|
- //headers.set("X-Service-Name",methodName);
|
|
|
-
|
|
|
- // 5. 构造请求实体(包含头和体)
|
|
|
- HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(formData, headers);
|
|
|
- // 6. 发送请求并获取响应
|
|
|
- logger.info("本次总线请求参数为:{}",jsonStr);
|
|
|
- logger.info("本次总线请求token为:{}",headers.get("Authorization"));
|
|
|
- ResponseEntity<String> zxResult = restTemplate.postForEntity(outinterfaceUrl, requestEntity, String.class);
|
|
|
- logger.info("总线响应结果 {}", zxResult.getBody());
|
|
|
- ZxResultDto zxResultDto = JsonUtils.parseJson(zxResult.getBody(),ZxResultDto.class);
|
|
|
- if(0==zxResultDto.getStatus()){
|
|
|
- String data = zxResultDto.getData();
|
|
|
- AjaxResult ajaxResult = JsonUtils.parseJson(data, AjaxResult.class);
|
|
|
- return ajaxResult;
|
|
|
- }else{
|
|
|
- throw new CsmException(zxResultDto.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 场所码内网透传接口(查询列表类)
|
|
|
- * @param emsMethodkey
|
|
|
- * @param o
|
|
|
- * @param methodName
|
|
|
- * @return
|
|
|
- */
|
|
|
- public TableDataInfo cmsEmsInterfaceQueryList(String emsMethodkey,Object o,String methodName){
|
|
|
- String token = getZxTokenByRedis();
|
|
|
- if(StringUtils.isBlank(token)){
|
|
|
- throw new CsmException("总线token获取失败");
|
|
|
- }else{
|
|
|
- ChannelDto channelDto = new ChannelDto();
|
|
|
- channelDto.setMethod(methodName);
|
|
|
- channelDto.setData(o);
|
|
|
- String jsonStr = JsonUtils.writeValueAsString(channelDto);
|
|
|
- MultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
|
|
|
- formData.add("methodkey", emsMethodkey);
|
|
|
- formData.add("postDataJson", jsonStr);
|
|
|
-
|
|
|
- // 4. 构造请求头,指定 Content-Type 为 application/x-www-form-urlencoded
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
|
|
- headers.set("Authorization","Bearer "+token);
|
|
|
- //headers.set("X-Service-Name",methodName);
|
|
|
-
|
|
|
- // 5. 构造请求实体(包含头和体)
|
|
|
- HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(formData, headers);
|
|
|
- // 6. 发送请求并获取响应
|
|
|
- logger.info("本次总线请求参数为:{}",jsonStr);
|
|
|
- logger.info("本次总线请求token为:{}",headers.get("Authorization"));
|
|
|
- ResponseEntity<String> zxResult = restTemplate.postForEntity(outinterfaceUrl, requestEntity, String.class);
|
|
|
- logger.info("总线响应结果 {}", zxResult.getBody());
|
|
|
- ZxResultDto zxResultDto = JsonUtils.parseJson(zxResult.getBody(),ZxResultDto.class);
|
|
|
- if(0==zxResultDto.getStatus()){
|
|
|
- String data = zxResultDto.getData();
|
|
|
- TableDataInfo tableDataInfo = JsonUtils.parseJson(data, TableDataInfo.class);
|
|
|
- return tableDataInfo;
|
|
|
- }else{
|
|
|
- throw new CsmException(zxResultDto.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 获取微信token
|
|
|
*/
|