add 球机sdk
parent
7546531224
commit
f09deed134
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
#ifndef AVGLOBAL_H
|
||||||
|
#define AVGLOBAL_H
|
||||||
|
|
||||||
|
typedef int AV_int32;
|
||||||
|
typedef unsigned int AV_uint32;
|
||||||
|
|
||||||
|
#ifndef __OBJC__
|
||||||
|
typedef int AV_BOOL;
|
||||||
|
#else
|
||||||
|
typedef BOOL AV_BOOL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef void* AV_HANDLE;
|
||||||
|
typedef unsigned char AV_BYTE;
|
||||||
|
typedef float AV_float;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
typedef __int64 AV_int64;
|
||||||
|
typedef unsigned __int64 AV_uint64;
|
||||||
|
#else
|
||||||
|
typedef long long AV_int64;
|
||||||
|
typedef unsigned long long AV_uint64;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@ -0,0 +1,275 @@
|
|||||||
|
package com.zhehekeji.web.controller;
|
||||||
|
|
||||||
|
import com.zhehekeji.core.pojo.Result;
|
||||||
|
import com.zhehekeji.core.util.Assert;
|
||||||
|
import com.zhehekeji.web.entity.Camera;
|
||||||
|
import com.zhehekeji.web.lib.CameraConnMap;
|
||||||
|
import com.zhehekeji.web.lib.LoginModule;
|
||||||
|
import com.zhehekeji.web.lib.NetSDKLib;
|
||||||
|
import com.zhehekeji.web.lib.PtzControlModule;
|
||||||
|
import com.zhehekeji.web.mapper.CameraMapper;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Api(value = "CameraControl",tags = "球机控制管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/camera/control")
|
||||||
|
public class CameraControlController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CameraMapper cameraMapper;
|
||||||
|
|
||||||
|
@PostMapping("/{id}")
|
||||||
|
@ApiOperation(value = "球机登录")
|
||||||
|
public Result<Long> login(@PathVariable Integer id) {
|
||||||
|
Camera camera = cameraMapper.selectById(id);
|
||||||
|
Assert.notNull(camera,"球机不存在");
|
||||||
|
NetSDKLib.LLong lLong = LoginModule.login(camera.getIp(),camera.getPort(),camera.getUser(),camera.getPassword(),id);
|
||||||
|
Assert.isTrue(lLong.longValue() > 0,"登陆失败");
|
||||||
|
CameraConnMap.conn(id,lLong);
|
||||||
|
return Result.success(lLong.longValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/up/{id}")
|
||||||
|
@ApiOperation(value = "球机控制向上")
|
||||||
|
public Result up(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlUpStart(id,0,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/up/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制向上 停止")
|
||||||
|
public Result upStop(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlUpEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/down/{id}")
|
||||||
|
@ApiOperation(value = "球机控制向下")
|
||||||
|
public Result down(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlDownStart(id,0,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/down/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制向下-停止")
|
||||||
|
public Result downStop(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlDownEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/left/{id}")
|
||||||
|
@ApiOperation(value = "球机控制向左")
|
||||||
|
public Result left(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlLeftStart(id,0,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/left/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制左-停止")
|
||||||
|
public Result leftStop(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlLeftEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/leftUp/{id}")
|
||||||
|
@ApiOperation(value = "球机控制向左上")
|
||||||
|
public Result leftUp(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlLeftUpStart(id,0,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/leftUp/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制左上-停止")
|
||||||
|
public Result leftUpStop(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlLeftUpEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/leftDown/{id}")
|
||||||
|
@ApiOperation(value = "球机控制向左下")
|
||||||
|
public Result leftDown(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlLeftDownStart(id,0,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/leftDown/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制左下-停止")
|
||||||
|
public Result leftDownStop(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlLeftDownEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/right/{id}")
|
||||||
|
@ApiOperation(value = "球机控制向右")
|
||||||
|
public Result right(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlRightStart(id,0,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/right/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制右-停止")
|
||||||
|
public Result rightStop(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlRightEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/rightUp/{id}")
|
||||||
|
@ApiOperation(value = "球机控制向右上")
|
||||||
|
public Result rightUp(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlRightUpStart(id,0,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/rightUp/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制右上-停止")
|
||||||
|
public Result rightUpStop(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlRightUpEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/rightDown/{id}")
|
||||||
|
@ApiOperation(value = "球机控制向右下")
|
||||||
|
public Result rightDown(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlLeftDownStart(id,0,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/rightDown/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制右下-停止")
|
||||||
|
public Result rightDownStop(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlRightDownEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/zoomAdd/start/{id}")
|
||||||
|
@ApiOperation(value = "球机控制 变倍+")
|
||||||
|
public Result ZoomAddStart(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlZoomAddStart(id,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/zoomAdd/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制 变倍+ 停止")
|
||||||
|
public Result ZoomAddEnd(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlZoomAddEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/zoomDec/start/{id}")
|
||||||
|
@ApiOperation(value = "球机控制 变倍-")
|
||||||
|
public Result ZoomDecStart(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlZoomDecStart(id,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/zoomDec/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制 变倍- 停止")
|
||||||
|
public Result ZoomDecEnd(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlZoomDecEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/focusAdd/start/{id}")
|
||||||
|
@ApiOperation(value = "球机控制 变焦 +")
|
||||||
|
public Result FocusAddStart(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlFocusAddStart(id,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/focusAdd/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制 变焦+ 停止")
|
||||||
|
public Result focusAddEnd(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlFocusAddEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/focusDec/start/{id}")
|
||||||
|
@ApiOperation(value = "球机控制 变焦 -")
|
||||||
|
public Result FocusDecStart(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlFocusDecStart(id,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/focusDec/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制 变焦+ 停止")
|
||||||
|
public Result focusDecEnd(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlFocusDecEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/irisAdd/start/{id}")
|
||||||
|
@ApiOperation(value = "球机控制 变焦 +")
|
||||||
|
public Result irisAddStart(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlIrisAddStart(id,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/irisAdd/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制 变焦+ 停止")
|
||||||
|
public Result irisAddEnd(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlIrisAddEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/irisDec/start/{id}")
|
||||||
|
@ApiOperation(value = "球机控制 变焦 -")
|
||||||
|
public Result irisDecStart(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlIrisDecStart(id,0,1);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/irisDec/stop/{id}")
|
||||||
|
@ApiOperation(value = "球机控制 变焦+ 停止")
|
||||||
|
public Result irisDecEnd(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
PtzControlModule.ptzControlIrisDecEnd(id,0);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/pic/{id}")
|
||||||
|
@ApiOperation(value = "立即拍照")
|
||||||
|
public Result pic(@PathVariable Integer id) {
|
||||||
|
checkLogin(id);
|
||||||
|
System.out.println(PtzControlModule.pic(id,0));
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkLogin(Integer cameraId){
|
||||||
|
if(CameraConnMap.getConnId(cameraId) == null){
|
||||||
|
login(cameraId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package com.zhehekeji.web.controller;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Login {
|
||||||
|
|
||||||
|
private String user;
|
||||||
|
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private Integer port;
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.zhehekeji.web.controller;
|
||||||
|
|
||||||
|
import com.zhehekeji.core.pojo.Result;
|
||||||
|
import com.zhehekeji.web.entity.Order;
|
||||||
|
import com.zhehekeji.web.pojo.OrderSearch;
|
||||||
|
import com.zhehekeji.web.pojo.realTime.RealTime;
|
||||||
|
import com.zhehekeji.web.service.RealTimeService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Api(value = "realTime",tags = "实时监控")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/realTime")
|
||||||
|
public class RealTimeController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RealTimeService realTimeService;
|
||||||
|
|
||||||
|
@PostMapping("")
|
||||||
|
@ApiOperation(value = "实时列表")
|
||||||
|
//@SessionHandler
|
||||||
|
public Result<List<RealTime>> realTimes() {
|
||||||
|
return Result.success(realTimeService.realTimes());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.zhehekeji.web.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("`stock`")
|
||||||
|
public class Stock {
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
private String shelveId;
|
||||||
|
|
||||||
|
private Integer count;
|
||||||
|
|
||||||
|
private Integer row;
|
||||||
|
|
||||||
|
private Integer column;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
private LocalDateTime exportTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package com.zhehekeji.web.lib;
|
||||||
|
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
|
||||||
|
public class CameraAction implements ApplicationRunner {
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.zhehekeji.web.lib;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class CameraConnMap{
|
||||||
|
|
||||||
|
public static Map<Integer, NetSDKLib.LLong> cameraMap = new HashMap<>();
|
||||||
|
|
||||||
|
public static void conn(Integer cameraId,NetSDKLib.LLong handlerId){
|
||||||
|
cameraMap.put(cameraId,handlerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void disConn(Integer cameraId){
|
||||||
|
cameraMap.remove(cameraId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NetSDKLib.LLong getConnId(Integer cameraId){
|
||||||
|
return cameraMap.get(cameraId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.zhehekeji.web.lib;
|
||||||
|
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class DisConnectCallBack implements NetSDKLib.fDisConnect {
|
||||||
|
|
||||||
|
private Integer cameraId;
|
||||||
|
|
||||||
|
public DisConnectCallBack(Integer id){
|
||||||
|
cameraId = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(NetSDKLib.LLong lLoginID, String pchDVRIP, int nDVRPort, Pointer dwUser) {
|
||||||
|
log.info("球机:{}掉线",cameraId);
|
||||||
|
CameraConnMap.disConn(cameraId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,124 @@
|
|||||||
|
package com.zhehekeji.web.lib;
|
||||||
|
|
||||||
|
import com.sun.jna.Memory;
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.nio.CharBuffer;
|
||||||
|
|
||||||
|
|
||||||
|
/** Provides a temporary allocation of an immutable C string
|
||||||
|
* (<code>const char*</code> or <code>const wchar_t*</code>) for use when
|
||||||
|
* converting a Java String into a native memory function argument.
|
||||||
|
*
|
||||||
|
* @author Todd Fast, todd.fast@sun.com
|
||||||
|
* @author twall@users.sf.net
|
||||||
|
*/
|
||||||
|
public class NativeString implements CharSequence, Comparable<Object> {
|
||||||
|
|
||||||
|
private Pointer pointer;
|
||||||
|
private boolean wide;
|
||||||
|
|
||||||
|
/** Create a native string (NUL-terminated array of <code>char</code>).<p>
|
||||||
|
* If the system property <code>jna.encoding</code> is set, its value will
|
||||||
|
* be used to encode the native string. If not set or if the encoding
|
||||||
|
* is unavailable, the default platform encoding will be used.
|
||||||
|
*/
|
||||||
|
public NativeString(String string) {
|
||||||
|
this(string, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create a native string as a NUL-terminated array of <code>wchar_t</code>
|
||||||
|
* (if <code>wide</code> is true) or <code>char</code>.<p>
|
||||||
|
* If the system property <code>jna.encoding</code> is set, its value will
|
||||||
|
* be used to encode the native <code>char</code>string.
|
||||||
|
* If not set or if the encoding is unavailable, the default platform
|
||||||
|
* encoding will be used.
|
||||||
|
*
|
||||||
|
* @param string value to write to native memory
|
||||||
|
* @param wide whether to store the String as <code>wchar_t</code>
|
||||||
|
*/
|
||||||
|
public NativeString(String string, boolean wide) {
|
||||||
|
if (string == null) {
|
||||||
|
throw new NullPointerException("String must not be null");
|
||||||
|
}
|
||||||
|
// Allocate the memory to hold the string. Note, we have to
|
||||||
|
// make this 1 element longer in order to accommodate the terminating
|
||||||
|
// NUL (which is generated in Pointer.setString()).
|
||||||
|
this.wide = wide;
|
||||||
|
if (wide) {
|
||||||
|
int len = (string.length() + 1 ) * Native.WCHAR_SIZE;
|
||||||
|
pointer = new Memory(len);
|
||||||
|
pointer.setString(0, string);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
byte[] data = getBytes(string);
|
||||||
|
pointer = new Memory(data.length + 1);
|
||||||
|
pointer.write(0, data, 0, data.length);
|
||||||
|
pointer.setByte(data.length, (byte)0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static byte[] getBytes(String s) {
|
||||||
|
try {
|
||||||
|
return getBytes(s, System.getProperty("jna.encoding"));
|
||||||
|
}
|
||||||
|
catch (UnsupportedEncodingException e) {
|
||||||
|
return s.getBytes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a byte array corresponding to the given String, using the given
|
||||||
|
encoding.
|
||||||
|
*/
|
||||||
|
static byte[] getBytes(String s, String encoding) throws UnsupportedEncodingException {
|
||||||
|
if (encoding != null) {
|
||||||
|
return s.getBytes(encoding);
|
||||||
|
}
|
||||||
|
return s.getBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return toString().hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
|
||||||
|
if (other instanceof CharSequence) {
|
||||||
|
return compareTo(other) == 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
String s = wide ? "const wchar_t*" : "const char*";
|
||||||
|
s += "(" + pointer.getString(0) + ")";
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pointer getPointer() {
|
||||||
|
return pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char charAt(int index) {
|
||||||
|
return toString().charAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int length() {
|
||||||
|
return toString().length();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence subSequence(int start, int end) {
|
||||||
|
return CharBuffer.wrap(toString()).subSequence(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(Object other) {
|
||||||
|
|
||||||
|
if (other == null)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return toString().compareTo(other.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,99 @@
|
|||||||
|
package com.zhehekeji.web.lib;
|
||||||
|
|
||||||
|
import com.sun.jna.Platform;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
public Utils() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取操作平台信息
|
||||||
|
public static String getOsPrefix() {
|
||||||
|
String arch = System.getProperty("os.arch").toLowerCase();
|
||||||
|
final String name = System.getProperty("os.name");
|
||||||
|
String osPrefix;
|
||||||
|
switch(Platform.getOSType()) {
|
||||||
|
case Platform.WINDOWS: {
|
||||||
|
if ("i386".equals(arch))
|
||||||
|
arch = "x86";
|
||||||
|
osPrefix = "win32-" + arch;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Platform.LINUX: {
|
||||||
|
if ("x86".equals(arch)) {
|
||||||
|
arch = "i386";
|
||||||
|
}
|
||||||
|
else if ("x86_64".equals(arch)) {
|
||||||
|
arch = "amd64";
|
||||||
|
}
|
||||||
|
osPrefix = "linux-" + arch;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: {
|
||||||
|
osPrefix = name.toLowerCase();
|
||||||
|
if ("x86".equals(arch)) {
|
||||||
|
arch = "i386";
|
||||||
|
}
|
||||||
|
if ("x86_64".equals(arch)) {
|
||||||
|
arch = "amd64";
|
||||||
|
}
|
||||||
|
int space = osPrefix.indexOf(" ");
|
||||||
|
if (space != -1) {
|
||||||
|
osPrefix = osPrefix.substring(0, space);
|
||||||
|
}
|
||||||
|
osPrefix += "-" + arch;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return osPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getOsName() {
|
||||||
|
String osName = "";
|
||||||
|
String osPrefix = getOsPrefix();
|
||||||
|
if(osPrefix.toLowerCase().startsWith("win32-x86")
|
||||||
|
||osPrefix.toLowerCase().startsWith("win32-amd64") ) {
|
||||||
|
osName = "win";
|
||||||
|
} else if(osPrefix.toLowerCase().startsWith("linux-i386")
|
||||||
|
|| osPrefix.toLowerCase().startsWith("linux-amd64")) {
|
||||||
|
osName = "linux";
|
||||||
|
}
|
||||||
|
|
||||||
|
return osName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取加载库
|
||||||
|
public static String getLoadLibrary(String library) {
|
||||||
|
if (isChecking()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String loadLibrary = "";
|
||||||
|
String osPrefix = getOsPrefix();
|
||||||
|
if(osPrefix.toLowerCase().startsWith("win32-x86")) {
|
||||||
|
loadLibrary = "./libs/win32/";
|
||||||
|
} else if(osPrefix.toLowerCase().startsWith("win32-amd64") ) {
|
||||||
|
loadLibrary = "./libs/win64/";
|
||||||
|
} else if(osPrefix.toLowerCase().startsWith("linux-i386")) {
|
||||||
|
loadLibrary = "";
|
||||||
|
}else if(osPrefix.toLowerCase().startsWith("linux-amd64")) {
|
||||||
|
loadLibrary = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.printf("[Load %s Path : %s]\n", library, loadLibrary + library);
|
||||||
|
return loadLibrary + library;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checking = false;
|
||||||
|
public static void setChecking() {
|
||||||
|
checking = true;
|
||||||
|
}
|
||||||
|
public static void clearChecking() {
|
||||||
|
checking = false;
|
||||||
|
}
|
||||||
|
public static boolean isChecking() {
|
||||||
|
return checking;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package com.zhehekeji.web.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zhehekeji.web.entity.Stock;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface StockMapper extends BaseMapper<Stock> {
|
||||||
|
|
||||||
|
void batchInsert(List<Stock> stocks);
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.zhehekeji.web.pojo.realTime;
|
||||||
|
|
||||||
|
import com.zhehekeji.web.entity.Camera;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RealTime {
|
||||||
|
|
||||||
|
private Integer streetId;
|
||||||
|
|
||||||
|
private String streetName;
|
||||||
|
|
||||||
|
private List<Camera> cameras;
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.zhehekeji.web.pojo.stock;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class StockExcel {
|
||||||
|
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
private String shelveId;
|
||||||
|
|
||||||
|
private Integer count;
|
||||||
|
|
||||||
|
private Integer row;
|
||||||
|
|
||||||
|
private Integer column;
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
package com.zhehekeji.web.service;
|
||||||
|
|
||||||
|
import com.zhehekeji.web.entity.Camera;
|
||||||
|
import com.zhehekeji.web.entity.Street;
|
||||||
|
import com.zhehekeji.web.mapper.CameraMapper;
|
||||||
|
import com.zhehekeji.web.mapper.StreetMapper;
|
||||||
|
import com.zhehekeji.web.pojo.realTime.RealTime;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class RealTimeService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private StreetMapper streetMapper;
|
||||||
|
@Resource
|
||||||
|
private CameraMapper cameraMapper;
|
||||||
|
|
||||||
|
public List<RealTime> realTimes(){
|
||||||
|
List<Street> streets = streetMapper.selectByMap(new HashMap<>(0));
|
||||||
|
List<Camera> cameras = cameraMapper.selectByMap(new HashMap<>(0));
|
||||||
|
Map<Integer,Camera> cameraMap = new HashMap<>(cameras.size());
|
||||||
|
cameras.forEach(camera -> {
|
||||||
|
cameraMap.put(camera.getId(),camera);
|
||||||
|
});
|
||||||
|
List<RealTime> realTimes = new ArrayList<>();
|
||||||
|
streets.forEach(street -> {
|
||||||
|
RealTime realTime = new RealTime();
|
||||||
|
realTime.setStreetId(street.getId());
|
||||||
|
realTime.setStreetName(street.getName());
|
||||||
|
List<Camera> cameraList = new ArrayList<>(2);
|
||||||
|
cameraList.add(cameraMap.get(street.getCamera1Id()));
|
||||||
|
cameraList.add(cameraMap.get(street.getCamera2Id()));
|
||||||
|
realTime.setCameras(cameras);
|
||||||
|
realTimes.add(realTime);
|
||||||
|
});
|
||||||
|
return realTimes;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
package com.zhehekeji.web.service;
|
||||||
|
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
|
import com.zhehekeji.web.entity.Stock;
|
||||||
|
import com.zhehekeji.web.mapper.StockMapper;
|
||||||
|
import com.zhehekeji.web.pojo.stock.StockExcel;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class StockImport extends AnalysisEventListener<StockExcel> {
|
||||||
|
|
||||||
|
private static Integer LENGTH = 5000;
|
||||||
|
|
||||||
|
private StockMapper stockMapper;
|
||||||
|
|
||||||
|
public StockImport (StockMapper stockMapper){
|
||||||
|
this.stockMapper = stockMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Stock> stocks = new ArrayList<>(LENGTH);
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(StockExcel stockExcel, AnalysisContext analysisContext) {
|
||||||
|
Stock stock = new Stock();
|
||||||
|
BeanUtils.copyProperties(stockExcel,stock);
|
||||||
|
stocks.add(stock);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||||
|
if (stocks.size() >= LENGTH) {
|
||||||
|
//保存 清零
|
||||||
|
save(stocks);
|
||||||
|
stocks.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void save(List<Stock> stocks) {
|
||||||
|
//todo 批量保存
|
||||||
|
stockMapper.batchInsert(stocks);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.zhehekeji.web.service;
|
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.zhehekeji.web.mapper.StockMapper;
|
||||||
|
import com.zhehekeji.web.pojo.stock.StockExcel;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class StockService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private StockMapper stockMapper;
|
||||||
|
|
||||||
|
public void importExcel(MultipartFile file) throws IOException {
|
||||||
|
EasyExcel.read(file.getInputStream(), StockExcel.class, new StockImport(stockMapper)).sheet().doRead();
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.zhehekeji.web.mapper.StockMapper">
|
||||||
|
|
||||||
|
<insert id="batchInsert" parameterType="java.util.List">
|
||||||
|
insert into stock(
|
||||||
|
category,count,shelve_id,row,column,status,export_time
|
||||||
|
) values
|
||||||
|
<foreach collection="stocks" item="item" separator=",">
|
||||||
|
(#{item.category},#{item.count},#{item.shelveId},#{item.row},#{item.column},#{item.status},#{item.exportTime})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue