|
@@ -59,6 +59,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -917,6 +918,82 @@ public class SasDeviceServiceImpl extends AbstractCrudService<SasDeviceMapper, S
|
|
|
return ids;
|
|
return ids;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void updateHikDeviceIp(UpdateDeviceIpAddrRequest request) {
|
|
|
|
|
+ if (request == null
|
|
|
|
|
+ || StrUtil.isBlank(request.getIpAddr())
|
|
|
|
|
+ || request.getPort() == null
|
|
|
|
|
+ || StrUtil.isBlank(request.getNetMask())
|
|
|
|
|
+ || StrUtil.isBlank(request.getGateway())
|
|
|
|
|
+ || StrUtil.isBlank(request.getMacAddr())) {
|
|
|
|
|
+ throw new BusinessException("修改设备IP参数不完整");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String setIp = request.getIpAddr();
|
|
|
|
|
+ String netmask = request.getNetMask();
|
|
|
|
|
+ String gateway = request.getGateway();
|
|
|
|
|
+ String macAddr = request.getMacAddr();
|
|
|
|
|
+ String password = request.getPassword() != null ? request.getPassword() : "";
|
|
|
|
|
+
|
|
|
|
|
+ Sadp.SADP_DEV_NET_PARAM netParam = new Sadp.SADP_DEV_NET_PARAM();
|
|
|
|
|
+
|
|
|
|
|
+ byte[] ipBytes = setIp.getBytes(StandardCharsets.US_ASCII);
|
|
|
|
|
+ System.arraycopy(ipBytes, 0, netParam.szIPv4Address, 0,
|
|
|
|
|
+ Math.min(ipBytes.length, netParam.szIPv4Address.length));
|
|
|
|
|
+
|
|
|
|
|
+ byte[] maskBytes = netmask.getBytes(StandardCharsets.US_ASCII);
|
|
|
|
|
+ System.arraycopy(maskBytes, 0, netParam.szIPv4SubNetMask, 0,
|
|
|
|
|
+ Math.min(maskBytes.length, netParam.szIPv4SubNetMask.length));
|
|
|
|
|
+
|
|
|
|
|
+ byte[] gwBytes = gateway.getBytes(StandardCharsets.US_ASCII);
|
|
|
|
|
+ System.arraycopy(gwBytes, 0, netParam.szIPv4Gateway, 0,
|
|
|
|
|
+ Math.min(gwBytes.length, netParam.szIPv4Gateway.length));
|
|
|
|
|
+
|
|
|
|
|
+ netParam.wPort = request.getPort().shortValue();
|
|
|
|
|
+ netParam.wHttpPort = 80;
|
|
|
|
|
+ netParam.byDhcpEnable = 0;
|
|
|
|
|
+ netParam.byIPv6MaskLen = 64;
|
|
|
|
|
+
|
|
|
|
|
+ Sadp.SADP_DEV_RET_NET_PARAM retNetParam = new Sadp.SADP_DEV_RET_NET_PARAM();
|
|
|
|
|
+
|
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
|
|
+ boolean flag = InitSadp.sadp.SADP_ModifyDeviceNetParam_V40(macAddr, password, netParam, retNetParam, retNetParam.size());
|
|
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
|
|
+ log.info("修改设备IP耗时: {}s", (endTime - startTime) / 1000L);
|
|
|
|
|
+
|
|
|
|
|
+ if (!flag) {
|
|
|
|
|
+ int error = InitSadp.sadp.SADP_GetLastError();
|
|
|
|
|
+ log.error("修改设备IP失败 : errorCode {}", error);
|
|
|
|
|
+ throw new BusinessException("修改设备IP失败,错误码: " + error);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ log.info("修改设备IP成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<DeviceProtocolOptionVO> getProtocolCodes() {
|
|
|
|
|
+ List<DeviceProtocolOptionVO> list = new ArrayList<>();
|
|
|
|
|
+ for (ProtocolEnum p : ProtocolEnum.values()) {
|
|
|
|
|
+ DeviceProtocolOptionVO vo = new DeviceProtocolOptionVO();
|
|
|
|
|
+ vo.setCode(p.getCode());
|
|
|
|
|
+ vo.setName(p.getDesc());
|
|
|
|
|
+ list.add(vo);
|
|
|
|
|
+ }
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<DeviceVideoTypeOptionVO> getVideoTypeCodes() {
|
|
|
|
|
+ List<DeviceVideoTypeOptionVO> list = new ArrayList<>();
|
|
|
|
|
+ for (DeviceTypeEnum t : DeviceTypeEnum.values()) {
|
|
|
|
|
+ DeviceVideoTypeOptionVO vo = new DeviceVideoTypeOptionVO();
|
|
|
|
|
+ vo.setCode(t.getCode());
|
|
|
|
|
+ vo.setName(t.getDesc());
|
|
|
|
|
+ list.add(vo);
|
|
|
|
|
+ }
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private String deviceTypeName(Integer code) {
|
|
private String deviceTypeName(Integer code) {
|
|
|
SystemTypeCodeEnum e = SystemTypeCodeEnum.getByCode(code);
|
|
SystemTypeCodeEnum e = SystemTypeCodeEnum.getByCode(code);
|
|
|
return e != null ? e.getMessage() : null;
|
|
return e != null ? e.getMessage() : null;
|