xinwei #3

Merged
root merged 30 commits from xinwei into master 2024-08-15 09:53:30 +08:00
5 changed files with 180 additions and 1 deletions
Showing only changes of commit 4ab42970a3 - Show all commits

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.parking.controller.admin.blacklistdelivery; package cn.iocoder.yudao.module.parking.controller.admin.blacklistdelivery;
import cn.iocoder.yudao.module.parking.util.BlueCardResult;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -37,7 +38,21 @@ public class BlacklistDeliveryController {
@Resource @Resource
private BlacklistDeliveryService blacklistDeliveryService; private BlacklistDeliveryService blacklistDeliveryService;
//黑名单下发(新增或修改)
@PostMapping("/insertBlacklist")
public BlueCardResult insertBlacklist(@RequestBody BlacklistDeliverySaveReqVO blacklistDelivery){
return blacklistDeliveryService.doBlacklistDelivery(blacklistDelivery);
}
//黑名单删除
@PostMapping("/deleteBlacklist")
public BlueCardResult deleteBlacklist(@RequestBody BlacklistDeliverySaveReqVO deleteBlacklistVo){
return blacklistDeliveryService.deleteBlacklistDelivery(deleteBlacklistVo);
}
//查询黑名单
@PostMapping("/selectBlacklist")
public CommonResult<String> selectBlacklist(@RequestBody BlacklistDeliverySaveReqVO selectWhitelistVo) {
return blacklistDeliveryService.findBlacklist(selectWhitelistVo);
}
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建黑名单配置") @Operation(summary = "创建黑名单配置")
@PreAuthorize("@ss.hasPermission('parking:blacklist-delivery:create')") @PreAuthorize("@ss.hasPermission('parking:blacklist-delivery:create')")

View File

@ -2,10 +2,13 @@ package cn.iocoder.yudao.module.parking.service.blacklistdelivery;
import java.util.*; import java.util.*;
import javax.validation.*; import javax.validation.*;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.parking.controller.admin.blacklistdelivery.vo.*; import cn.iocoder.yudao.module.parking.controller.admin.blacklistdelivery.vo.*;
import cn.iocoder.yudao.module.parking.dal.dataobject.blacklistdelivery.BlacklistDeliveryDO; import cn.iocoder.yudao.module.parking.dal.dataobject.blacklistdelivery.BlacklistDeliveryDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.module.parking.util.BlueCardResult;
/** /**
* 黑名单配置 Service 接口 * 黑名单配置 Service 接口
@ -52,4 +55,24 @@ public interface BlacklistDeliveryService {
*/ */
PageResult<BlacklistDeliveryDO> getBlacklistDeliveryPage(BlacklistDeliveryPageReqVO pageReqVO); PageResult<BlacklistDeliveryDO> getBlacklistDeliveryPage(BlacklistDeliveryPageReqVO pageReqVO);
/**
* 黑名单下发(新增或修改)
* @param blacklistDelivery
* @return cn.iocoder.yudao.module.parking.util.BlueCardResult
*/
BlueCardResult doBlacklistDelivery(BlacklistDeliverySaveReqVO blacklistDelivery);
/**
* 黑名单删除
* @param deleteBlacklistVo
* @return cn.iocoder.yudao.module.parking.util.BlueCardResult
*/
BlueCardResult deleteBlacklistDelivery(BlacklistDeliverySaveReqVO deleteBlacklistVo);
/**
* 查询黑名单
* @param selectWhitelistVo
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.String>
*/
CommonResult<String> findBlacklist(BlacklistDeliverySaveReqVO selectWhitelistVo);
} }

View File

@ -1,11 +1,18 @@
package cn.iocoder.yudao.module.parking.service.blacklistdelivery; package cn.iocoder.yudao.module.parking.service.blacklistdelivery;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.parking.util.BlueCarRequestUtil;
import cn.iocoder.yudao.module.parking.util.BlueCardResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import cn.iocoder.yudao.module.parking.controller.admin.blacklistdelivery.vo.*; import cn.iocoder.yudao.module.parking.controller.admin.blacklistdelivery.vo.*;
import cn.iocoder.yudao.module.parking.dal.dataobject.blacklistdelivery.BlacklistDeliveryDO; import cn.iocoder.yudao.module.parking.dal.dataobject.blacklistdelivery.BlacklistDeliveryDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -28,6 +35,8 @@ public class BlacklistDeliveryServiceImpl implements BlacklistDeliveryService {
@Resource @Resource
private BlacklistDeliveryMapper blacklistDeliveryMapper; private BlacklistDeliveryMapper blacklistDeliveryMapper;
@Resource
private BlueCarRequestUtil blueCarRequestUtil;
@Override @Override
public Long createBlacklistDelivery(BlacklistDeliverySaveReqVO createReqVO) { public Long createBlacklistDelivery(BlacklistDeliverySaveReqVO createReqVO) {
@ -71,4 +80,46 @@ public class BlacklistDeliveryServiceImpl implements BlacklistDeliveryService {
return blacklistDeliveryMapper.selectPage(pageReqVO); return blacklistDeliveryMapper.selectPage(pageReqVO);
} }
@Override
public BlueCardResult doBlacklistDelivery(BlacklistDeliverySaveReqVO blacklistDelivery) {
this.createBlacklistDelivery(blacklistDelivery);
Map<String, Object> map = new HashMap<>();
map.put("id", blacklistDelivery.getId());
map.put("parkNumber", blacklistDelivery.getParkNumber());
map.put("source", blacklistDelivery.getSource());
map.put("size", blacklistDelivery.getSize());
List<Map<String, Object>> datasList = new ArrayList<>();
Map<String, Object> datasMap = new HashMap<>();
datasMap.put("plate", blacklistDelivery.getPlate());
if (blacklistDelivery.getMemo() != null) {
datasMap.put("memo", blacklistDelivery.getMemo());
}
datasList.add(datasMap);
map.put("datas", datasList);
blueCarRequestUtil.doBlueCarPost(map, "bcopenapi/out/synBlack");
return BlueCardResult.success();
}
@Override
public BlueCardResult deleteBlacklistDelivery(BlacklistDeliverySaveReqVO deleteBlacklistVo) {
Map<String, String> map = new HashMap<>();
map.put("parkNumber", deleteBlacklistVo.getParkNumber());
map.put("plate", deleteBlacklistVo.getPlate());
blueCarRequestUtil.doBlueCarPost(map, "bcopenapi/out/delBlack");
return BlueCardResult.success();
}
@Override
public CommonResult<String> findBlacklist(BlacklistDeliverySaveReqVO selectWhitelistVo) {
Map<String, Object> map = new HashMap<>();
map.put("parkNumber", selectWhitelistVo.getParkNumber());
map.put("size", selectWhitelistVo.getSize());
List<Map<String, String>> datasList = new ArrayList<>();
Map<String, String> datasMap = new HashMap<>();
datasMap.put("plate", selectWhitelistVo.getPlate());
datasList.add(datasMap);
map.put("datas", datasList);
return blueCarRequestUtil.doBlueCarPost(map, "bcopenapi/out/queryBlack");
}
} }

View File

@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.parking.util;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.HexUtil;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.parking.controller.admin.blacklistdelivery.vo.BlacklistDeliverySaveReqVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.security.MessageDigest;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* 蓝卡post请求工具类
*/
@Component
public class BlueCarRequestUtil {
@Value("${blueCar.key}")
private String key;
@Value("${blueCar.parkNumber}")
private String parkNumber;
// @Value("${blueCar.Request.host}")
private String host;
// @Value("${blueCar.Request.port}")
private String port;
@Value("${blueCar.Request.ip}")
private String ip;
public CommonResult<String> doBlueCarPost(Object t, String portAddress){
//请求地址
String url = "http://"+ip+"/"+portAddress;
System.out.println(url);
//请求参数
JSONObject jsonData = JSONUtil.parseObj(t);
// 构建sign字符串
String s = key+parkNumber;
// 对sign字符串进行MD5加密
String sign = md5(s);
// 发送POST请求
HttpResponse response = HttpUtil.createPost(url)
.header("sign", sign) // 添加sign请求头
.body(JSONUtil.toJsonStr(jsonData), "application/json")
.charset("UTF-8") // 设置编码格式为UTF-8
.execute();
// 获取响应状态码
int status = response.getStatus();
System.out.println(sign);
System.out.println("Response Code: " + status);
// 获取响应内容
String responseBody = response.body();
System.out.println("Response Body: " + responseBody);
// 关闭连接
response.close();
return success(responseBody);
}
// 对sign参数进行MD5加密
private String md5(String data) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] md5Bytes = md.digest(data.getBytes(CharsetUtil.CHARSET_UTF_8));
return HexUtil.encodeHexStr(md5Bytes, true); // 小写格式
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

View File

@ -118,3 +118,19 @@ lundu:
basePath: /home/upload/bcinterface/Uplmage/ basePath: /home/upload/bcinterface/Uplmage/
#Windows下的文件路径 #Windows下的文件路径
imgPath: https://yyxh.ptzykjgs.com/api/img/ imgPath: https://yyxh.ptzykjgs.com/api/img/
#蓝卡
blueCar:
key: 7h5bdg7k926s28lzb5fny8pcrbtr426m
parkNumber: p230613141235
Request:
host: 127.0.0.1
port: 8080
ip: swapi.bluecardsoft.com/bcopenapi
parkName: 石家庄联调专用
#海康
haiKang:
appKey: abcdefg
appSecret: hijklmn
host: 127.0.0.1
port: 8088