|
|
|
|
@ -1,25 +1,42 @@
|
|
|
|
|
package com.zhehekeji.web.controller;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.sun.jna.ptr.IntByReference;
|
|
|
|
|
import com.zhehekeji.common.util.PathUtil;
|
|
|
|
|
import com.zhehekeji.common.util.ValidatorUtil;
|
|
|
|
|
import com.zhehekeji.core.pojo.Result;
|
|
|
|
|
import com.zhehekeji.web.config.ConfigProperties;
|
|
|
|
|
import com.zhehekeji.web.entity.LightSource;
|
|
|
|
|
import com.zhehekeji.web.entity.Street;
|
|
|
|
|
import com.zhehekeji.web.lib.CameraConnMap;
|
|
|
|
|
import com.zhehekeji.web.lib.hik.HCNetSDK;
|
|
|
|
|
import com.zhehekeji.web.lib.hik.HikLoginModuleImpl;
|
|
|
|
|
import com.zhehekeji.web.mapper.StreetMapper;
|
|
|
|
|
import com.zhehekeji.web.pojo.OrderSaveReq;
|
|
|
|
|
import com.zhehekeji.web.pojo.OrderSearch;
|
|
|
|
|
import com.zhehekeji.web.pojo.OrderVO;
|
|
|
|
|
import com.zhehekeji.web.service.OrderService;
|
|
|
|
|
import com.zhehekeji.web.service.PlcCmdInfo;
|
|
|
|
|
import com.zhehekeji.web.service.PlcService;
|
|
|
|
|
import com.zhehekeji.web.service.*;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
|
import io.swagger.models.auth.In;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static com.zhehekeji.web.lib.hik.HCNetSDK.NET_DVR_GET_PTZPOS;
|
|
|
|
|
import static com.zhehekeji.web.lib.hik.HCNetSDK.NET_DVR_SET_PTZPOS;
|
|
|
|
|
|
|
|
|
|
@Api(value = "OrderController",tags = "订单管理")
|
|
|
|
|
@RestController(value = "OrderController")
|
|
|
|
|
@RequestMapping("/order")
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class OrderController {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
@ -29,6 +46,9 @@ public class OrderController {
|
|
|
|
|
@Resource
|
|
|
|
|
private ValidatorUtil validatorUtil;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private CameraControlController cameracheckLogin;
|
|
|
|
|
|
|
|
|
|
@Value("${zhehe.filter.postToken}")
|
|
|
|
|
private String postToken;
|
|
|
|
|
|
|
|
|
|
@ -84,4 +104,157 @@ public class OrderController {
|
|
|
|
|
return Result.success(orderService.orders(orderSearch));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
ConfigProperties configProperties;
|
|
|
|
|
@Resource
|
|
|
|
|
CodeService codeService;
|
|
|
|
|
@Resource
|
|
|
|
|
StreetMapper streetMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
LightSourceService lightSourceService;
|
|
|
|
|
@PostMapping("/test1/{id}")
|
|
|
|
|
@ApiOperation(value = "test1")
|
|
|
|
|
//@SessionHandler
|
|
|
|
|
public Result<String> test1(@PathVariable Integer id) {
|
|
|
|
|
//validatorUtil.validate(orderSearch);
|
|
|
|
|
Street street = streetMapper.selectOne(new QueryWrapper<Street>().eq("camera1_Id", id).or().eq("camera2_Id", id));
|
|
|
|
|
List<LightSource> lightSources = lightSourceService.getLightSourceByStreetId(street.getId());
|
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
|
lightSourceService.controllerLightSource(lightSource,1);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//球机调用指定预置点位
|
|
|
|
|
|
|
|
|
|
plcService.gyrateCameraByCode(id,"E1");
|
|
|
|
|
//球机拍照
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(3000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
String path = "work\\1.jpg";
|
|
|
|
|
|
|
|
|
|
plcService.cameraCapture(id,false,null,path);
|
|
|
|
|
|
|
|
|
|
//交予灵闪识别
|
|
|
|
|
HashMap<String,String> stringMap = new HashMap<>();
|
|
|
|
|
stringMap.put("code","");
|
|
|
|
|
|
|
|
|
|
stringMap.put("location","");
|
|
|
|
|
CodeService.readOCR("127.0.0.1",9040,stringMap);
|
|
|
|
|
System.out.println("stringMap: "+stringMap);
|
|
|
|
|
//2560,1440
|
|
|
|
|
if(!"".equals(stringMap.get("location"))){
|
|
|
|
|
//调整位置
|
|
|
|
|
ge( id, stringMap.get("location"));
|
|
|
|
|
}
|
|
|
|
|
//球机拍照
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(8000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
plcService.cameraCapture(id,false,null,path);
|
|
|
|
|
//交予灵闪识别
|
|
|
|
|
String code = CodeService.readOCR("127.0.0.1",9040,stringMap);
|
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
|
lightSourceService.controllerLightSource(lightSource,0);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Result.success(code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/test/{id}")
|
|
|
|
|
@ApiOperation(value = "test")
|
|
|
|
|
//@SessionHandler
|
|
|
|
|
public Result<String> test(@PathVariable Integer id) {
|
|
|
|
|
//validatorUtil.validate(orderSearch);
|
|
|
|
|
Street street = streetMapper.selectOne(new QueryWrapper<Street>().eq("camera1_Id", id).or().eq("camera2_Id", id));
|
|
|
|
|
List<LightSource> lightSources = lightSourceService.getLightSourceByStreetId(street.getId());
|
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
|
lightSourceService.controllerLightSource(lightSource,1);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//球机调用指定预置点位
|
|
|
|
|
|
|
|
|
|
plcService.gyrateCameraByCode(id,"E1");
|
|
|
|
|
//球机拍照
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(3000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
String path = "work\\1.jpg";
|
|
|
|
|
|
|
|
|
|
plcService.cameraCapture(id,false,null,path);
|
|
|
|
|
//交予灵闪识别
|
|
|
|
|
HashMap<String,String> stringMap = new HashMap<>();
|
|
|
|
|
stringMap.put("code","");
|
|
|
|
|
|
|
|
|
|
stringMap.put("location","");
|
|
|
|
|
String code = CodeService.readOCR("127.0.0.1",9040,stringMap);
|
|
|
|
|
//2560,1440
|
|
|
|
|
|
|
|
|
|
return Result.success(code);
|
|
|
|
|
}
|
|
|
|
|
////2560,1440
|
|
|
|
|
void ge(int id,String location){
|
|
|
|
|
String[] locations = location.split(",");
|
|
|
|
|
cameracheckLogin.checkLogin(id);
|
|
|
|
|
HCNetSDK.NET_DVR_PTZPOS struPtTZPos = new HCNetSDK.NET_DVR_PTZPOS();
|
|
|
|
|
|
|
|
|
|
IntByReference intByReference = new IntByReference(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean b_GetPTZ = HikLoginModuleImpl.hcNetsdk.NET_DVR_GetDVRConfig( CameraConnMap.getConnId(id).intValue(), NET_DVR_GET_PTZPOS, 1,struPtTZPos.getPointer(), struPtTZPos.size(),intByReference);
|
|
|
|
|
if (b_GetPTZ==false){
|
|
|
|
|
System.out.println("获取PTZ坐标信息失败,错误码:" + HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError());
|
|
|
|
|
return;
|
|
|
|
|
}else {
|
|
|
|
|
System.out.println("获取PTZ坐标信息成功");
|
|
|
|
|
|
|
|
|
|
struPtTZPos.read();
|
|
|
|
|
}
|
|
|
|
|
//水平
|
|
|
|
|
int p = ((int) Math.round( Double.parseDouble(locations[0]))-(2560/2))/30;
|
|
|
|
|
//垂直
|
|
|
|
|
int t = ((int) Math.round( Double.parseDouble(locations[1]))-(1440/2))/30;
|
|
|
|
|
|
|
|
|
|
struPtTZPos.wAction = 1;
|
|
|
|
|
//水平
|
|
|
|
|
|
|
|
|
|
System.out.println(struPtTZPos.wPanPos);
|
|
|
|
|
struPtTZPos.wPanPos = (short) (struPtTZPos.wPanPos+0x10*p);
|
|
|
|
|
System.out.println(struPtTZPos.wPanPos);
|
|
|
|
|
//垂直
|
|
|
|
|
System.out.println();
|
|
|
|
|
System.out.println(struPtTZPos.wTiltPos);
|
|
|
|
|
struPtTZPos.wTiltPos = (short) (struPtTZPos.wTiltPos+0x10*t);
|
|
|
|
|
|
|
|
|
|
System.out.println(struPtTZPos.wTiltPos);
|
|
|
|
|
struPtTZPos.wZoomPos = 0x0150;
|
|
|
|
|
struPtTZPos.write();
|
|
|
|
|
boolean flag = HikLoginModuleImpl.hcNetsdk.NET_DVR_SetDVRConfig( CameraConnMap.getConnId(id).intValue(), NET_DVR_SET_PTZPOS, 1,struPtTZPos.getPointer(), struPtTZPos.size());
|
|
|
|
|
if(!flag){
|
|
|
|
|
System.out.println("设置PTZ坐标信息失败,错误码:" + HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError());
|
|
|
|
|
}else {
|
|
|
|
|
System.out.println("设置PTZ坐标信息成功 p:"+p+" t:"+t);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
|
|
|
|
String location = "963.465209960937500,1373.154296875000000";
|
|
|
|
|
|
|
|
|
|
String[] locations = location.split(",");
|
|
|
|
|
|
|
|
|
|
int p = ((int) Math.round( Double.parseDouble(locations[0]))-(2560/2))/30;
|
|
|
|
|
int t = ((int) Math.round( Double.parseDouble(locations[1]))-(1440/2))/32;
|
|
|
|
|
System.out.println(p+" "+t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|