Browse Source

修改调用ruoyi逻辑

master
HAHA 3 years ago
parent
commit
1eecfcee1d
  1. 15
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaLoudongServiceImpl.java
  2. 15
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaPingfangServiceImpl.java
  3. 13
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaRentalServiceImpl.java
  4. 15
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaResidentServiceImpl.java
  5. 13
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaRotatorsServiceImpl.java
  6. 78
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/util/AesUtils.java

15
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaLoudongServiceImpl.java

@ -21,6 +21,7 @@ import com.epmet.opendata.dto.result.CaLoudongResultDTO;
import com.epmet.opendata.entity.CaLoudongEntity;
import com.epmet.opendata.redis.CaLoudongRedis;
import com.epmet.opendata.service.CaLoudongService;
import com.epmet.opendata.util.AesUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.gson.JsonObject;
@ -107,7 +108,7 @@ public class CaLoudongServiceImpl extends BaseServiceImpl<CaLoudongDao, CaLoudon
@Override
public PageData<CaLoudongResultDTO> getPage(CaLoudongFormDTO dto) {
PageHelper.startPage(dto.getPage(), dto.getLimit());
List<CaLoudongResultDTO> result = baseDao.getPage(dto.getCommunityName(),dto.getBuildingName());
List<CaLoudongResultDTO> result = baseDao.getPage(dto.getCommunityName(), dto.getBuildingName());
PageInfo<CaLoudongResultDTO> info = new PageInfo<>(result);
return new PageData<>(result, info.getTotal());
}
@ -150,15 +151,20 @@ public class CaLoudongServiceImpl extends BaseServiceImpl<CaLoudongDao, CaLoudon
int total = 0;
do {
try {
total = listLouDong(dto);
pageNo++;
dto.setPageNo(pageNo);
} catch (Exception e) {
System.out.println(e);
}
} while (total > (pageNo * NumConstant.FIFTY));
}
enum loudongEnum {
LD("unicom", "ca_loudong"),
AES("key", "hriajrutnbghajsd")
;
private String name;
@ -172,8 +178,11 @@ public class CaLoudongServiceImpl extends BaseServiceImpl<CaLoudongDao, CaLoudon
}
private int listLouDong(PreserVationFormDTO dto) {
String data = HttpClientManager.getInstance().sendPostByJSON("http://120.221.72.83:9090/bridge/unicom/page", JSON.toJSONString(dto)).getData();
private int listLouDong(PreserVationFormDTO dto) throws Exception {
String aes = AesUtils.encryptByAES(JSONObject.toJSONString(dto), loudongEnum.AES.code);
JSONObject obj = new JSONObject();
obj.put("unicomCondition", aes);
String data = HttpClientManager.getInstance().sendPostByJSON("http://120.221.72.83:9090/bridge/unicom/page", obj.toJSONString()).getData();
JSONObject toResult = JSON.parseObject(data);
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
if (!result.success()) {

15
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaPingfangServiceImpl.java

@ -23,6 +23,7 @@ import com.epmet.opendata.entity.CaLoudongEntity;
import com.epmet.opendata.entity.CaPingfangEntity;
import com.epmet.opendata.redis.CaPingfangRedis;
import com.epmet.opendata.service.CaPingfangService;
import com.epmet.opendata.util.AesUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
@ -99,7 +100,7 @@ public class CaPingfangServiceImpl extends BaseServiceImpl<CaPingfangDao, CaPing
@Override
public PageData getPage(CaPingfangFormDTO dto) {
PageHelper.startPage(dto.getPage(), dto.getLimit());
List<CaPingfangResultDTO> result = baseDao.getPage(dto.getBuildingName(),dto.getCommunityName());
List<CaPingfangResultDTO> result = baseDao.getPage(dto.getBuildingName(), dto.getCommunityName());
PageInfo<CaPingfangResultDTO> info = new PageInfo<>(result);
return new PageData<>(result, info.getTotal());
}
@ -129,9 +130,13 @@ public class CaPingfangServiceImpl extends BaseServiceImpl<CaPingfangDao, CaPing
int total = 0;
do {
try {
total = listPingFang(dto);
pageNo++;
dto.setPageNo(pageNo);
} catch (Exception e) {
System.out.println(e);
}
} while (total > (pageNo * NumConstant.FIFTY));
}
@ -145,6 +150,7 @@ public class CaPingfangServiceImpl extends BaseServiceImpl<CaPingfangDao, CaPing
enum pingFangEnum {
PF("unicom", "ca_pingfang"),
AES("key", "hriajrutnbghajsd")
;
pingFangEnum(String name, String code) {
@ -156,8 +162,11 @@ public class CaPingfangServiceImpl extends BaseServiceImpl<CaPingfangDao, CaPing
private String code;
}
private int listPingFang(PreserVationFormDTO dto) {
String data = HttpClientManager.getInstance().sendPostByJSON("http://120.221.72.83:9090/bridge/unicom/page", JSON.toJSONString(dto)).getData();
private int listPingFang(PreserVationFormDTO dto) throws Exception {
String aes = AesUtils.encryptByAES(JSONObject.toJSONString(dto), pingFangEnum.AES.code);
JSONObject obj = new JSONObject();
obj.put("unicomCondition",aes);
String data = HttpClientManager.getInstance().sendPostByJSON("http://120.221.72.83:9090/bridge/unicom/page", obj.toJSONString()).getData();
JSONObject toResult = JSON.parseObject(data);
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
if (!result.success()) {

13
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaRentalServiceImpl.java

@ -24,6 +24,7 @@ import com.epmet.opendata.entity.CaLoudongEntity;
import com.epmet.opendata.entity.CaRentalEntity;
import com.epmet.opendata.redis.CaRentalRedis;
import com.epmet.opendata.service.CaRentalService;
import com.epmet.opendata.util.AesUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
@ -134,9 +135,13 @@ public class CaRentalServiceImpl extends BaseServiceImpl<CaRentalDao, CaRentalEn
int total = 0;
do {
try {
total = listRental(dto);
pageNo++;
dto.setPageNo(pageNo);
} catch (Exception e) {
System.out.println(e);
}
} while (total > (pageNo * NumConstant.FIFTY));
}
@ -150,6 +155,7 @@ public class CaRentalServiceImpl extends BaseServiceImpl<CaRentalDao, CaRentalEn
enum rentalEnum {
CZF("unicom", "ca_rental"),
AES("key", "hriajrutnbghajsd")
;
private String name;
@ -163,8 +169,11 @@ public class CaRentalServiceImpl extends BaseServiceImpl<CaRentalDao, CaRentalEn
}
private int listRental(PreserVationFormDTO dto) {
String data = HttpClientManager.getInstance().sendPostByJSON("http://120.221.72.83:9090/bridge/unicom/page", JSON.toJSONString(dto)).getData();
private int listRental(PreserVationFormDTO dto) throws Exception {
String aes = AesUtils.encryptByAES(JSONObject.toJSONString(dto), rentalEnum.AES.code);
JSONObject obj = new JSONObject();
obj.put("unicomCondition",aes);
String data = HttpClientManager.getInstance().sendPostByJSON("http://120.221.72.83:9090/bridge/unicom/page", obj.toJSONString()).getData();
JSONObject toResult = JSON.parseObject(data);
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
if (!result.success()) {

15
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaResidentServiceImpl.java

@ -25,6 +25,7 @@ import com.epmet.opendata.entity.CaLoudongEntity;
import com.epmet.opendata.entity.CaResidentEntity;
import com.epmet.opendata.redis.CaResidentRedis;
import com.epmet.opendata.service.CaResidentService;
import com.epmet.opendata.util.AesUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
@ -138,9 +139,13 @@ public class CaResidentServiceImpl extends BaseServiceImpl<CaResidentDao, CaResi
int total = 0;
do {
try {
total = listResident(dto);
pageNo++;
dto.setPageNo(pageNo);
} catch (Exception e) {
System.out.println(e);
}
} while (total > (pageNo * NumConstant.FIFTY));
}
@ -153,6 +158,7 @@ public class CaResidentServiceImpl extends BaseServiceImpl<CaResidentDao, CaResi
enum residentEnum {
RK("unicom", "ca_resident"),
AES("key", "hriajrutnbghajsd")
;
private String name;
@ -165,8 +171,11 @@ public class CaResidentServiceImpl extends BaseServiceImpl<CaResidentDao, CaResi
}
}
private int listResident(PreserVationFormDTO dto) {
String data = HttpClientManager.getInstance().sendPostByJSON("http://120.221.72.83:9090/bridge/unicom/page", JSON.toJSONString(dto)).getData();
private int listResident(PreserVationFormDTO dto) throws Exception {
String aes = AesUtils.encryptByAES(JSONObject.toJSONString(dto), residentEnum.AES.code);
JSONObject obj = new JSONObject();
obj.put("unicomCondition",aes);
String data = HttpClientManager.getInstance().sendPostByJSON("http://120.221.72.83:9090/bridge/unicom/page", obj.toJSONString()).getData();
JSONObject toResult = JSON.parseObject(data);
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
if (!result.success()) {
@ -176,7 +185,7 @@ public class CaResidentServiceImpl extends BaseServiceImpl<CaResidentDao, CaResi
ReturnDate returnDate = JSONObject.parseObject(JSONObject.toJSONString(result.getData()), ReturnDate.class);
returnDate.getList().forEach(item -> {
if(StringUtils.isNotBlank(item.getIdCard())) {
if (StringUtils.isNotBlank(item.getIdCard())) {
Result<IcResiUserDTO> client = openFeignClient.getByResiIdCard(item.getIdCard());
IcResiUserDTO clientData = client.getData();
item.setIcResiUser(clientData.getId());

13
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaRotatorsServiceImpl.java

@ -25,6 +25,7 @@ import com.epmet.opendata.entity.CaLoudongEntity;
import com.epmet.opendata.entity.CaRotatorsEntity;
import com.epmet.opendata.redis.CaRotatorsRedis;
import com.epmet.opendata.service.CaRotatorsService;
import com.epmet.opendata.util.AesUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
@ -137,9 +138,13 @@ public class CaRotatorsServiceImpl extends BaseServiceImpl<CaRotatorsDao, CaRota
int total = 0;
do {
try {
total = listRotators(dto);
pageNo++;
dto.setPageNo(pageNo);
} catch (Exception e) {
System.out.println(e);
}
} while (total > (pageNo * NumConstant.FIFTY));
}
@ -152,6 +157,7 @@ public class CaRotatorsServiceImpl extends BaseServiceImpl<CaRotatorsDao, CaRota
enum rotatorsEnum {
LDRK("unicom", "ca_rotators"),
AES("key", "hriajrutnbghajsd")
;
private String name;
@ -165,8 +171,11 @@ public class CaRotatorsServiceImpl extends BaseServiceImpl<CaRotatorsDao, CaRota
}
private int listRotators(PreserVationFormDTO dto) {
String data = HttpClientManager.getInstance().sendPostByJSON("http://120.221.72.83:9090/bridge/unicom/page", JSON.toJSONString(dto)).getData();
private int listRotators(PreserVationFormDTO dto) throws Exception {
String aes = AesUtils.encryptByAES(JSONObject.toJSONString(dto), rotatorsEnum.AES.code);
JSONObject obj = new JSONObject();
obj.put("unicomCondition",aes);
String data = HttpClientManager.getInstance().sendPostByJSON("http://120.221.72.83:9090/bridge/unicom/page", obj.toJSONString()).getData();
JSONObject toResult = JSON.parseObject(data);
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
if (!result.success()) {

78
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/util/AesUtils.java

@ -0,0 +1,78 @@
package com.epmet.opendata.util;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
/***
* Aes加解密工具类
* @author www
* @date 2022/6/6/0006 11:07
*/
public class AesUtils {
public static String encryptByAES(String input, String key) throws Exception {
// 算法
String algorithm = "AES";
String transformation = "AES";
// Cipher:密码,获取加密对象
// transformation:参数表示使用什么类型加密
Cipher cipher = Cipher.getInstance(transformation);
// 指定秘钥规则
// 第一个参数表示:密钥,key的字节数组 长度必须是16位
// 第二个参数表示:算法
SecretKeySpec sks = new SecretKeySpec(key.getBytes(), algorithm);
// 对加密进行初始化
// 第一个参数:表示模式,有加密模式和解密模式
// 第二个参数:表示秘钥规则
cipher.init(Cipher.ENCRYPT_MODE, sks);
// 进行加密
byte[] bytes = cipher.doFinal(input.getBytes());
return bytesToHexString(bytes);
}
public static String decryptByAES(String input, String key) throws Exception {
// 算法
String algorithm = "AES";
String transformation = "AES";
// Cipher:密码,获取加密对象
// transformation:参数表示使用什么类型加密
Cipher cipher = Cipher.getInstance(transformation);
// 指定秘钥规则
// 第一个参数表示:密钥,key的字节数组 长度必须是16位
// 第二个参数表示:算法
SecretKeySpec sks = new SecretKeySpec(key.getBytes(), algorithm);
// 对加密进行初始化
// 第一个参数:表示模式,有加密模式和解密模式
// 第二个参数:表示秘钥规则
cipher.init(Cipher.DECRYPT_MODE, sks);
// 进行解密
byte[] inputBytes = hexStringToBytes(input);
byte[] bytes = cipher.doFinal(inputBytes);
return new String(bytes);
}
private static byte[] hexStringToBytes(String hexString) {
if (hexString.length() % 2 != 0) throw new IllegalArgumentException("hexString length not valid");
int length = hexString.length() / 2;
byte[] resultBytes = new byte[length];
for (int index = 0; index < length; index++) {
String result = hexString.substring(index * 2, index * 2 + 2);
resultBytes[index] = Integer.valueOf(Integer.parseInt(result, 16)).byteValue();
}
return resultBytes;
}
private static String bytesToHexString(byte[] sources) {
if (sources == null) return null;
StringBuilder stringBuffer = new StringBuilder();
for (byte source : sources) {
String result = Integer.toHexString(source & 0xff);
if (result.length() < 2) {
result = "0" + result;
}
stringBuffer.append(result);
}
return stringBuffer.toString();
}
}
Loading…
Cancel
Save