提交所进行的修改

杭州-烟草
LAPTOP-S9HJSOEB\昊天 10 months ago
parent 7bdee2dc48
commit 4e6515d521

@ -19,6 +19,12 @@
<dependencies> <dependencies>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.25</version>
</dependency>
<dependency> <dependency>
<groupId>com.zhehekeji</groupId> <groupId>com.zhehekeji</groupId>
<artifactId>base-assembly</artifactId> <artifactId>base-assembly</artifactId>
@ -111,6 +117,14 @@
<includeSystemScope>true</includeSystemScope> <includeSystemScope>true</includeSystemScope>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

@ -11,6 +11,7 @@ import org.springframework.cache.jcache.JCacheCache;
import org.springframework.cache.support.SimpleCacheManager; import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -21,6 +22,11 @@ import java.util.concurrent.TimeUnit;
@EnableCaching @EnableCaching
public class CacheConfig { public class CacheConfig {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
@Bean @Bean
public CacheManager localCacheManager() { public CacheManager localCacheManager() {
SimpleCacheManager simpleCacheManager = new SimpleCacheManager(); SimpleCacheManager simpleCacheManager = new SimpleCacheManager();

@ -37,8 +37,16 @@ public class ConfigProperties {
private LightSource lightSource; private LightSource lightSource;
private ScanCodeMode scanCodeMode; private ScanCodeMode scanCodeMode;
private Zlm zlm;
@Data
public static class Zlm {
private String ip;
private Integer apiPort;
private String secret;
}
@Data @Data
public static class CameraConfig{ public static class CameraConfig{

@ -0,0 +1,202 @@
package com.zhehekeji.web.config;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
/**
* JSON
*
* @author
*/
@Slf4j
public class JsonUtils {
private static ObjectMapper objectMapper = new ObjectMapper();
static {
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // 忽略 null 值
objectMapper.registerModules(new JavaTimeModule()); // 解决 LocalDateTime 的序列化
}
/**
* objectMapper
* <p>
* 使 Spring ObjectMapper Bean
*
* @param objectMapper ObjectMapper
*/
public static void init(ObjectMapper objectMapper) {
JsonUtils.objectMapper = objectMapper;
}
@SneakyThrows
public static String toJsonString(Object object) {
return objectMapper.writeValueAsString(object);
}
@SneakyThrows
public static byte[] toJsonByte(Object object) {
return objectMapper.writeValueAsBytes(object);
}
@SneakyThrows
public static String toJsonPrettyString(Object object) {
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(object);
}
public static <T> T parseObject(String text, Class<T> clazz) {
if (StrUtil.isEmpty(text)) {
return null;
}
try {
return objectMapper.readValue(text, clazz);
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
throw new RuntimeException(e);
}
}
public static <T> T parseObject(String text, String path, Class<T> clazz) {
if (StrUtil.isEmpty(text)) {
return null;
}
try {
JsonNode treeNode = objectMapper.readTree(text);
JsonNode pathNode = treeNode.path(path);
return objectMapper.readValue(pathNode.toString(), clazz);
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
throw new RuntimeException(e);
}
}
public static <T> T parseObject(String text, Type type) {
if (StrUtil.isEmpty(text)) {
return null;
}
try {
return objectMapper.readValue(text, objectMapper.getTypeFactory().constructType(type));
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
throw new RuntimeException(e);
}
}
/**
*
* 使 {@link #parseObject(String, Class)} @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
* text class 使
*
* @param text
* @param clazz
* @return
*/
public static <T> T parseObject2(String text, Class<T> clazz) {
if (StrUtil.isEmpty(text)) {
return null;
}
return JSONUtil.toBean(text, clazz);
}
public static <T> T parseObject(byte[] bytes, Class<T> clazz) {
if (ArrayUtil.isEmpty(bytes)) {
return null;
}
try {
return objectMapper.readValue(bytes, clazz);
} catch (IOException e) {
log.error("json parse err,json:{}", bytes, e);
throw new RuntimeException(e);
}
}
public static <T> T parseObject(String text, TypeReference<T> typeReference) {
try {
return objectMapper.readValue(text, typeReference);
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
throw new RuntimeException(e);
}
}
/**
* JSON null
*
* @param text
* @param typeReference
* @return
*/
public static <T> T parseObjectQuietly(String text, TypeReference<T> typeReference) {
try {
return objectMapper.readValue(text, typeReference);
} catch (IOException e) {
return null;
}
}
public static <T> List<T> parseArray(String text, Class<T> clazz) {
if (StrUtil.isEmpty(text)) {
return new ArrayList<>();
}
try {
return objectMapper.readValue(text, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
throw new RuntimeException(e);
}
}
public static <T> List<T> parseArray(String text, String path, Class<T> clazz) {
if (StrUtil.isEmpty(text)) {
return null;
}
try {
JsonNode treeNode = objectMapper.readTree(text);
JsonNode pathNode = treeNode.path(path);
return objectMapper.readValue(pathNode.toString(), objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
throw new RuntimeException(e);
}
}
public static JsonNode parseTree(String text) {
try {
return objectMapper.readTree(text);
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
throw new RuntimeException(e);
}
}
public static JsonNode parseTree(byte[] text) {
try {
return objectMapper.readTree(text);
} catch (IOException e) {
log.error("json parse err,json:{}", text, e);
throw new RuntimeException(e);
}
}
public static boolean isJson(String text) {
return JSONUtil.isTypeJSON(text);
}
}

@ -0,0 +1,210 @@
package com.zhehekeji.web.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zhehekeji.web.config.zlm.RtspSessionResponse;
import com.zhehekeji.web.entity.Camera;
import com.zhehekeji.web.lib.CameraConnMap;
import com.zhehekeji.web.service.CameraService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import javax.annotation.Resource;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Slf4j
@Component
public class MyInitializer {
@Resource
private RestTemplate restTemplate;
@Resource
private CameraService cameraService;
@Resource
ConfigProperties configProperties;
public static void main(String[] args) {
MyInitializer myInitializer = new MyInitializer();
myInitializer.checkAndAddRtspProxies();
}
@Scheduled(fixedRate = 30000) // 每分钟执行一次
public void checkAndAddRtspProxies() {
List<Camera> list =cameraService.allCameras();
//添加流信息
zlmConf(list);
}
private void zlmConf( List<Camera> list) {
String zlmApiUrl = "http://"+configProperties.getZlm().getIp()+":"+configProperties.getZlm().getApiPort()+"/index/api/";
String zlmApiSecret = configProperties.getZlm().getSecret();
try {
// 查询当前的RTSP拉流代理
Map<String, Object> queryParams = new HashMap<>();
queryParams.put("secret", zlmApiSecret);
String queryUrl = buildUrl(zlmApiUrl +"getMediaList" , queryParams);
String response = get(queryUrl);
RtspSessionResponse rtspSessionResponse = JsonUtils.parseObject(response, RtspSessionResponse.class);
// 检查并添加缺失的RTSP代理
for (Camera entry : list) {
boolean isRtspProxyExists = false;
if (rtspSessionResponse != null && rtspSessionResponse.getData()!=null && rtspSessionResponse.getData().size()>0) {
for (RtspSessionResponse.RtspSession rtspSession : rtspSessionResponse.getData()){
if (rtspSession.getApp().equals("live")&&rtspSession.getStream().equals("camera"+entry.getId())){
isRtspProxyExists = true;
break;
}
}
}
//不存在则重新注入
if (!isRtspProxyExists){
try {
addRtspProxy(entry, zlmApiUrl, zlmApiSecret);
}catch (Exception e){
e.printStackTrace();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void stopRecord(Camera camera) {
String zlmApiUrl = "http://"+configProperties.getZlm().getIp()+":"+configProperties.getZlm().getApiPort()+"/index/api/";
String zlmApiSecret = configProperties.getZlm().getSecret();
Map<String, Object> addParams = new HashMap<>();
addParams.put("secret", zlmApiSecret);
addParams.put("vhost", "__defaultVhost__");
addParams.put("app", "live");
addParams.put("type", "1");
addParams.put("stream","camera"+ camera.getId());
String addUrl = buildUrl(zlmApiUrl+"stopRecord", addParams);
String response = get(addUrl);
log.info("stopRecord camera:"+camera.getId()+" response:"+response);
}
public String startRecord(Camera camera){
String zlmApiUrl = "http://"+configProperties.getZlm().getIp()+":"+configProperties.getZlm().getApiPort()+"/index/api/";
String zlmApiSecret = configProperties.getZlm().getSecret();
Map<String, Object> addParams = new HashMap<>();
addParams.put("secret", zlmApiSecret);
addParams.put("vhost", "__defaultVhost__");
addParams.put("app", "live");
addParams.put("type", "1");
addParams.put("stream","camera"+ camera.getId());
String addUrl = buildUrl(zlmApiUrl+"startRecord", addParams);
String response = get(addUrl);
log.info("startRecord camera:"+camera.getId()+" response:"+response);
String path = checkHiddenFilesInDirectory(camera);
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
Runnable task = () -> {
stopRecord(camera);
};
// 延迟5分钟后执行停止任务不会将录像文件录5分钟
long delay =5;
scheduler.schedule(task, delay, TimeUnit.MINUTES);
return path;
}
// 新增方法:检查指定文件夹下是否有以.为开头的文件
public String checkHiddenFilesInDirectory(Camera camera) {
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 格式化日期
String formattedDate = currentDate.format(formatter);
String directoryPath = configProperties.getSavePath().getMp4Path()+"record/live/camera"+camera.getId()+"/"+formattedDate;
Path directory = Paths.get(directoryPath);
List<String> hiddenFiles = new ArrayList<>();
try (Stream<Path> paths = Files.walk(directory, 1)) {
hiddenFiles= paths
.filter(Files::isRegularFile)
.map(Path::getFileName)
.map(Path::toString)
.filter(name -> name.startsWith("."))
.collect(Collectors.toList());
return hiddenFiles.isEmpty() ? "" : "record/live/camera"+camera.getId()+"/"+formattedDate+"/"+removeLeadingDot(hiddenFiles.get(0));
} catch (IOException e) {
e.printStackTrace();
hiddenFiles= List.of(); // 返回空列表
}
return "";
}
public static String removeLeadingDot(String input) {
if (input == null || input.isEmpty()) {
return input;
}
if (input.startsWith(".")) {
return input.substring(1);
}
return input;
}
private void addRtspProxy(Camera camera, String zlmApiUrl, String zlmApiSecret) throws IOException {
Map<String, Object> addParams = new HashMap<>();
addParams.put("secret", zlmApiSecret);
addParams.put("vhost", "__defaultVhost__");
addParams.put("app", "live");
addParams.put("stream","camera"+ camera.getId());
addParams.put("url", camera.getRtsp());
String addUrl = buildUrl(zlmApiUrl+"addStreamProxy" , addParams);
String response = get(addUrl);
System.out.println("Add RTSP Proxy Response: " + response);
}
private String buildUrl(String baseUrl, Map<String, Object> params) {
UriComponentsBuilder urlBuilder = UriComponentsBuilder.fromHttpUrl(baseUrl);
for (Map.Entry<String, Object> entry : params.entrySet()) {
urlBuilder.queryParam(entry.getKey(), entry.getValue().toString());
}
return urlBuilder.toUriString();
}
private String get(String url) {
return restTemplate.getForObject(url, String.class);
}
}

@ -0,0 +1,77 @@
package com.zhehekeji.web.config.zlm;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
public class RtspSessionResponse {
private int code;
private List<RtspSession> data;
@Data
public static class RtspSession {
private int aliveSecond;
private String app;
private Integer loss; // 映射 JSON 中的 "loss" 字段
private long bytesSpeed;
private long createStamp;
@JsonProperty("isRecordingHLS")
private boolean recordingHLS;
@JsonProperty("isRecordingMP4")
private boolean recordingMP4;
private OriginSock originSock;
private int originType;
private String originTypeStr;
private String originUrl;
private String params;
private int readerCount;
private String schema;
private String stream;
private int totalReaderCount;
private List<Track> tracks;
private String vhost;
@Data
public static class OriginSock {
private String identifier;
@JsonProperty("local_ip")
private String localIp;
@JsonProperty("local_port")
private int localPort;
@JsonProperty("peer_ip")
private String peerIp;
@JsonProperty("peer_port")
private int peerPort;
}
@Data
public static class Track {
@JsonProperty("codec_id")
private int codecId;
@JsonProperty("codec_id_name")
private String codecIdName;
@JsonProperty("codec_type")
private int codecType;
private long duration;
private int fps;
private int frames;
@JsonProperty("gop_interval_ms")
private int gopIntervalMs;
@JsonProperty("gop_size")
private int gopSize;
private int height;
@JsonProperty("key_frames")
private int keyFrames;
private boolean ready;
private int width;
private int channels;
@JsonProperty("sample_bit")
private int sampleBit;
@JsonProperty("sample_rate")
private int sampleRate;
}
}
}

@ -83,6 +83,14 @@ public class Order {
@ApiModelProperty("视频图片地址") @ApiModelProperty("视频图片地址")
@TableField("`video_path_2`") @TableField("`video_path_2`")
private String videoPath2; private String videoPath2;
@ApiModelProperty("视频图片地址")
@TableField("`video_path_3`")
private String videoPath3;
@ApiModelProperty("视频图片地址")
@TableField("`video_path_4`")
private String videoPath4;
@ApiModelProperty("图片地址,分隔") @ApiModelProperty("图片地址,分隔")
private String picPaths; private String picPaths;

@ -26,8 +26,8 @@ public class SteeringEngine {
plcCmdInfo.setPlcId(String.valueOf(steeringEngine.getWorkunitid())); plcCmdInfo.setPlcId(String.valueOf(steeringEngine.getWorkunitid()));
if(steeringEngine.getSloc()!=null && steeringEngine.getSloc().endsWith("000")){ if(steeringEngine.getSloc()!=null && steeringEngine.getSloc().endsWith("000")){
plcCmdInfo.setLeftRight1(Integer.valueOf(steeringEngine.getSloc().substring(3,4))); plcCmdInfo.setLeftRight1(Integer.valueOf(steeringEngine.getSloc().substring(3,4)));
plcCmdInfo.setColumn1(Integer.valueOf(steeringEngine.getSloc().substring(4,6))); plcCmdInfo.setColumn1(Integer.valueOf(steeringEngine.getSloc().substring(4,7)));
plcCmdInfo.setRow1(Integer.valueOf(steeringEngine.getSloc().substring(6,8))); plcCmdInfo.setRow1(Integer.valueOf(steeringEngine.getSloc().substring(7,10)));
plcCmdInfo.setSeparation1(1); plcCmdInfo.setSeparation1(1);
}else { }else {
plcCmdInfo.setLeftRight1(0); plcCmdInfo.setLeftRight1(0);
@ -37,8 +37,8 @@ public class SteeringEngine {
} }
if(steeringEngine.getDloc()!=null && steeringEngine.getDloc().endsWith("000")){ if(steeringEngine.getDloc()!=null && steeringEngine.getDloc().endsWith("000")){
plcCmdInfo.setLeftRight2(Integer.valueOf(steeringEngine.getDloc().substring(3,4))); plcCmdInfo.setLeftRight2(Integer.valueOf(steeringEngine.getDloc().substring(3,4)));
plcCmdInfo.setColumn2(Integer.valueOf(steeringEngine.getDloc().substring(4,6))); plcCmdInfo.setColumn2(Integer.valueOf(steeringEngine.getDloc().substring(4,7)));
plcCmdInfo.setRow2(Integer.valueOf(steeringEngine.getDloc().substring(6,8))); plcCmdInfo.setRow2(Integer.valueOf(steeringEngine.getDloc().substring(7,10)));
plcCmdInfo.setSeparation2(1); plcCmdInfo.setSeparation2(1);
}else { }else {
plcCmdInfo.setLeftRight2(0); plcCmdInfo.setLeftRight2(0);
@ -48,4 +48,11 @@ public class SteeringEngine {
} }
return plcCmdInfo; return plcCmdInfo;
} }
public static void main(String[] args) {
SteeringEngine steeringEngine = new SteeringEngine();
steeringEngine.setDloc("0041002003000");
PlcCmdInfo plcCmdInfo = SteeringEngine.getPlcCmdInfo(steeringEngine);
System.out.println(plcCmdInfo);
}
} }

@ -421,7 +421,6 @@ public class HikCameraControlModuleImpl implements CameraControlModule {
* *
* *
* @param ptzId ID * @param ptzId ID
* @param name
* @param cameraId ID, * @param cameraId ID,
*/ */
public void ptz(Integer ptzId, String name, Integer cameraId) public void ptz(Integer ptzId, String name, Integer cameraId)

@ -21,4 +21,6 @@ public class OrderSearch {
private Integer pageSize; private Integer pageSize;
private Integer pageNum; private Integer pageNum;
private String streetId;
} }

@ -354,6 +354,11 @@ public class CameraService {
return null; return null;
} }
public Camera getId(Integer id){
Camera camera = cameraMapper.selectById(id);
return camera;
}
public Integer getPtzId(Integer ioId){ public Integer getPtzId(Integer ioId){
CameraIO cameraIO = ioMapper.selectById(ioId); CameraIO cameraIO = ioMapper.selectById(ioId);
Assert.notNull(cameraIO,"IO配置不存在"); Assert.notNull(cameraIO,"IO配置不存在");

@ -59,7 +59,7 @@ public class CronTab {
File dir = new File(configProperties.getSavePath().getMediaPath()); File dir = new File(configProperties.getSavePath().getMediaPath());
long space = dir.getFreeSpace() / gByte; long space = dir.getFreeSpace() / gByte;
log.info(" free space :{}",space); log.info(" free space :{}",space);
if(space > 150){ if(space > 300){
return; return;
} }
checkFileTime(dir,configProperties.getDeleteFileDays()); checkFileTime(dir,configProperties.getDeleteFileDays());
@ -70,7 +70,7 @@ public class CronTab {
@Resource @Resource
SteeringEngineService steeringEngineService; SteeringEngineService steeringEngineService;
@Scheduled(fixedDelay = 5000) @Scheduled(fixedDelay = 1000)
//@Scheduled(cron = "0 0/1 * * * *") //@Scheduled(cron = "0 0/1 * * * *")
public void check() { public void check() {
steeringEngineService.check(); steeringEngineService.check();

@ -23,7 +23,7 @@ import java.util.List;
@Slf4j @Slf4j
public class LightSourceService { public class LightSourceService {
@Autowired @Resource
private LightSourceMapper lightSourceMapper; private LightSourceMapper lightSourceMapper;
@Resource @Resource
@ -70,10 +70,13 @@ public class LightSourceService {
public static void relay(String host, int port, int status) { public static void relay(String host, int port, int status) {
byte[] data; byte[] data;
byte[] data1;
if (status == 1) { if (status == 1) {
data = new byte[]{0x01, 0x05, 0x00, 0x01, (byte) 0xFF, 0x00, (byte) 0xDD, (byte) 0xFA}; data = new byte[]{0x01, 0x05, 0x00, 0x01, (byte) 0xFF, 0x00, (byte) 0xDD, (byte) 0xFA};
data1 = new byte[]{0x01, 0x05, 0x00, 0x00, (byte) 0xFF, 0x00, (byte) 0x8C, (byte) 0x3A};
} else { } else {
data = new byte[]{0x01, 0x05, 0x00, 0x01, (byte) 0x00, 0x00, (byte) 0x9C, (byte) 0x0A}; data = new byte[]{0x01, 0x05, 0x00, 0x01, (byte) 0x00, 0x00, (byte) 0x9C, (byte) 0x0A};
data1 = new byte[]{0x01, 0x05, 0x00, 0x00, (byte) 0x00, 0x00, (byte) 0xcd, (byte) 0xca};
} }
@ -83,6 +86,8 @@ public class LightSourceService {
// 发送数据 // 发送数据
outputStream.write(data); outputStream.write(data);
outputStream.flush(); outputStream.flush();
outputStream.write(data1);
outputStream.flush();
System.out.println("Data sent successfully."); System.out.println("Data sent successfully.");
@ -95,4 +100,5 @@ public class LightSourceService {
public List<LightSource> getLightSourceByStreetId(Integer streetId) { public List<LightSource> getLightSourceByStreetId(Integer streetId) {
return lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id", streetId)); return lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id", streetId));
} }
} }

@ -81,53 +81,25 @@ public class OrderService {
public String location(OrderVO orderVO,Street street){ public String location(OrderVO orderVO,Street street){
//from to 模型 //from to 模型
String from = "";
String on ="";
//库内转库内 看 to
//从哪里
if( orderVO.getRow1()==0 ){
from = "库外";
}else {
from =orderVO.getRow1()+"层"+orderVO.getColumn1()+"列"+( orderVO.getLeftRight1()==1?"左侧":"右侧");
}
if (orderVO.getInOut1() != null && orderVO.getInOut2() != null) {
//左右货架 货位号
//库内转库内 看 to
Integer column = 0;
Integer row = 0;
//左货架 右货架
Integer leftRight = 0;
if (orderVO.getInOut1() == 1 && orderVO.getInOut2() == 1) {
// 库内转库内
leftRight = orderVO.getLeftRight2();
column = orderVO.getColumn2();
row = orderVO.getRow2();
} else if (orderVO.getInOut1() == 1) {
// 库内到库外
leftRight = orderVO.getLeftRight1();
//看from
orderVO.setStreetType(orderVO.getLeftRight1());
column = orderVO.getColumn1();
row = orderVO.getRow1();
} else if (orderVO.getInOut2() == 1) {
//库外到库内
leftRight = orderVO.getLeftRight2();
//看to
orderVO.setStreetType(orderVO.getLeftRight2());
column = orderVO.getColumn2();
row = orderVO.getRow2();
}else {
return "库外转库外";
}
if (leftRight > 0) {
//PLC 1是左 2是由
if(street != null){
if(leftRight == 1){
orderVO.setStreetType(street.getLeftType());
}else {
orderVO.setStreetType(street.getRightType());
}
} //到哪里
String leftRightS = leftRight == 1 ? "左" : "右"; if( orderVO.getRow2()==0 ){
//里外 现在无法判断 这个项目全是 里 on = "库外";
String location = "%s-里-%s列%s行"; }else {
return String.format(location, leftRightS, column, row); on =orderVO.getRow2()+"层"+orderVO.getColumn2()+"列"+( orderVO.getLeftRight2()==1?"左侧":"右侧");
}
} }
return null;
return from+"->"+on;
} }

@ -4,6 +4,7 @@ import codeDetector.BarcodeDetector;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhehekeji.common.util.PathUtil; import com.zhehekeji.common.util.PathUtil;
import com.zhehekeji.web.config.ConfigProperties; import com.zhehekeji.web.config.ConfigProperties;
import com.zhehekeji.web.config.MyInitializer;
import com.zhehekeji.web.entity.*; import com.zhehekeji.web.entity.*;
import com.zhehekeji.web.lib.*; import com.zhehekeji.web.lib.*;
import com.zhehekeji.web.lib.hik.HCNetSDK; import com.zhehekeji.web.lib.hik.HCNetSDK;
@ -20,6 +21,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashSet; import java.util.HashSet;
@ -92,6 +94,8 @@ public class PlcService {
return 0; return 0;
} }
@Resource
MyInitializer myInitializer;
/** /**
* robotic plcIdplcId,plcIdsrmNumber * robotic plcIdplcId,plcIdsrmNumber
* *
@ -132,6 +136,44 @@ public class PlcService {
//todo 昆船的项目 ,取货 放货是独立的 //todo 昆船的项目 ,取货 放货是独立的
//取货是是不知道放货的位置的所以订单开始的时候只写1位置 //取货是是不知道放货的位置的所以订单开始的时候只写1位置
//订单结束写2位置 //订单结束写2位置
String path ="";
String path1 ="";
if (street.getCamera1Id() != null) {
Camera camera = cameraService.getId(street.getCamera1Id());
CameraIO cameraIO = ioMapper.selectOne(new QueryWrapper<CameraIO>()
.eq("camera_id", camera.getId())
.eq("code", "C5"));
cameraControlModule.toPtz(cameraIO.getPtzId(),camera.getId());
path = myInitializer.startRecord(camera);
order.setVideoPath1(path);
}
if (street.getCamera2Id() != null) {
Camera camera = cameraService.getId(street.getCamera2Id());
CameraIO cameraIO = ioMapper.selectOne(new QueryWrapper<CameraIO>()
.eq("camera_id", camera.getId())
.eq("code", "C5"));
cameraControlModule.toPtz(cameraIO.getPtzId(),camera.getId());
path = myInitializer.startRecord(camera);
order.setVideoPath2(path);
}
if (street.getCamera3Id() != null) {
Camera camera = cameraService.getId(street.getCamera3Id());
path = myInitializer.startRecord(camera);
order.setVideoPath3(path);
}
if (street.getCamera4Id() != null) {
Camera camera = cameraService.getId(street.getCamera4Id());
path = myInitializer.startRecord(camera);
order.setVideoPath4(path);
}
orderMapper.insert(order); orderMapper.insert(order);
OrderRealtime.startOrder(street.getId(), plcCmdInfo.getOrderNum()); OrderRealtime.startOrder(street.getId(), plcCmdInfo.getOrderNum());
} }
@ -160,30 +202,34 @@ public class PlcService {
Order update = new Order(); Order update = new Order();
update.setId(order.getId()); update.setId(order.getId());
//将最后一次的拍照算在工单时间 //将最后一次的拍照算在工单时间
LocalDateTime endDownLoadTime = endTime.plusNanos(configProperties.getCameraConfig().getC4DelayCaptureTime()*1000000);
update.setEndTime(endTime); update.setEndTime(endTime);
Duration duration = Duration.between(order.getStartTime(),endDownLoadTime); //
// LocalDateTime endDownLoadTime = endTime.plusNanos(configProperties.getCameraConfig().getC4DelayCaptureTime()*1000000);
if(duration.toMinutes() > 50){ //
endDownLoadTime = order.getStartTime().plusMinutes(50); // Duration duration = Duration.between(order.getStartTime(),endDownLoadTime);
} //
String path =""; // if(duration.toMinutes() > 50){
String path1 =""; // endDownLoadTime = order.getStartTime().plusMinutes(50);
// }
if (street.getCamera1Id() != null) { if (street.getCamera1Id() != null) {
path = cameraVideo(street.getCamera1Id(),order.getStartTime(),endDownLoadTime); Camera camera = cameraService.getId(street.getCamera1Id());
update.setVideoPath1(path);
myInitializer.stopRecord(camera);
} }
if (street.getCamera2Id() != null) { if (street.getCamera2Id() != null) {
path1 = cameraVideo(street.getCamera2Id(),order.getStartTime(),endDownLoadTime); Camera camera = cameraService.getId(street.getCamera2Id());
update.setVideoPath2(path); myInitializer.stopRecord(camera);
} }
if (street.getCamera3Id() != null) { if (street.getCamera3Id() != null) {
cameraVideo(street.getCamera1Id(),order.getStartTime(),endDownLoadTime ,path+".mp4"); Camera camera = cameraService.getId(street.getCamera3Id());
myInitializer.stopRecord(camera);
} }
if (street.getCamera4Id() != null) { if (street.getCamera4Id() != null) {
cameraVideo(street.getCamera2Id(),order.getStartTime(),endDownLoadTime,path1+".mp4"); Camera camera = cameraService.getId(street.getCamera4Id());
myInitializer.stopRecord(camera);
} }
orderMapper.updateById(update); orderMapper.updateById(update);

@ -95,4 +95,10 @@ scanCodeMode:
trayCodeTypes: trayCodeTypes:
- 14 - 14
# 照片 視頻保存多久 # 照片 視頻保存多久
deleteFileDays: 365 deleteFileDays: 365
zlm:
ip: 127.0.0.1
apiPort: 9000
zlmApiUrl: http://127.0.0.1:9000/index/api
secret: w3qQt6NyUzSZ1STH9riCVhLbdIosuwf1

@ -6,6 +6,9 @@
select t.* select t.*
from `order` t from `order` t
<where> <where>
<if test="req.streetId != null and req.streetId != ''">
and t.street_id like concat('%', #{streetId},'%')
</if>
<if test="req.orderNum != null and req.orderNum != ''"> <if test="req.orderNum != null and req.orderNum != ''">
and t.order_num like concat('%', #{req.orderNum},'%') and t.order_num like concat('%', #{req.orderNum},'%')
</if> </if>

Loading…
Cancel
Save