图片使用工业相机

bozhou-古井贡酒
LAPTOP-S9HJSOEB\昊天 2 years ago
parent 805e0a8dac
commit 8b8051fc35

@ -2,12 +2,19 @@ package com.zhehekeji.web.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
// 设置连接超时时间(单位:毫秒)
factory.setConnectTimeout(1000);
// 设置读取数据超时时间(单位:毫秒)
factory.setReadTimeout(10);
return new RestTemplate(factory);
}
}

@ -4,11 +4,8 @@ import com.github.pagehelper.PageInfo;
import com.zhehekeji.common.util.ValidatorUtil;
import com.zhehekeji.core.pojo.Result;
import com.zhehekeji.web.entity.CheckLog;
import com.zhehekeji.web.entity.StockLog;
import com.zhehekeji.web.pojo.stock.CheckLogSearch;
import com.zhehekeji.web.pojo.stock.StockLogSearch;
import com.zhehekeji.web.service.CheckLogService;
import com.zhehekeji.web.service.StockLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;

@ -4,6 +4,7 @@ import com.zhehekeji.core.pojo.Result;
import com.zhehekeji.web.entity.AlgorithmPojo;
import com.zhehekeji.web.service.RFID.RFIDSocket;
import com.zhehekeji.web.service.TestService;
import com.zhehekeji.web.service.algorithm.AlgorithmService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
@ -15,6 +16,9 @@ import javax.annotation.Resource;
@RestController
public class TestController {
@Resource
AlgorithmService algorithmService;
@Resource
private TestService testService;
@ -32,13 +36,12 @@ public class TestController {
return Result.success();
}
@ApiOperation("自动盘点")
@PostMapping("/1")
public Result test(@RequestBody String id){
System.out.println("656+565+29+5" +
"62+95+65");
return Result.success();
algorithmService.getGoodResult(new AlgorithmPojo());
return new Result<>();
}
@ApiOperation("自动盘点")
@PostMapping("/2")

@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class CheckLog {
@ -32,6 +33,8 @@ public class CheckLog {
@TableField("`column`")
private Integer column;
private String TaskId;
private String code;
private String wmsCode;
@ -52,6 +55,20 @@ public class CheckLog {
private String checkNum;
private String pic;
@TableField(exist = false)
private String pic1;
@TableField(exist = false)
private String pic2;
@TableField(exist = false)
private String pic3;
@TableField(exist = false)
private String pic4;
@TableField(exist = false)
private String pic5;
@TableField(exist = false)
private String pic6;
@TableField(exist = false)
private List<String> pics;
private String lotnum;

@ -12,7 +12,11 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
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 CheckLogService {
@ -39,6 +43,7 @@ public class CheckLogService {
wrapper.orderByDesc("create_time");
List<CheckLog> stockChecks = checkLogMapper.selectList(wrapper);
List<StreetVO> streetVOS = streetService.listVo();
Map<Integer,StreetVO> streetVOMap =streetVOS.stream().collect(Collectors.toMap(StreetVO::getId,v->v));
for (CheckLog checkLog : stockChecks) {
for (StreetVO streetVO : streetVOS) {
if (streetVO.getId().equals(checkLog.getStreetId())) {
@ -46,6 +51,18 @@ public class CheckLogService {
break;
}
}
String ip ="http://"+ streetVOMap.get(checkLog.getStreetId()).getPlcIp()+":9009/pic/"+checkLog.getTaskId();
ArrayList<String> stock = new ArrayList<>();
stock.add(String.format("%s_1.JPEG",ip));
stock.add(String.format("%s_2.JPEG",ip));
checkLog.setPic1(String.format("%s_1.JPEG",ip));
checkLog.setPic2(String.format("%s_2.JPEG",ip));
checkLog.setPic3(String.format("%s_3.JPEG",ip));
checkLog.setPic4(String.format("%s_4.JPEG",ip));
checkLog.setPic5(String.format("%s_5.JPEG",ip));
checkLog.setPic6(String.format("%s_6.JPEG",ip));
checkLog.setPics(stock);
}
return new PageInfo<>(stockChecks);
}

@ -84,8 +84,8 @@ public class OrderService {
if(orderVO.getRow1()!= 0 && orderVO.getColumn1()!=0) {
goodsLocation.append(orderVO.getLeftRight1() == 1 ? "左侧" : "右侧") ;
goodsLocation.append( orderVO.getInOut1() == 1 ? "浅货位" : "深货位");
goodsLocation.append( orderVO.getRow1()+"行");
goodsLocation.append( orderVO.getColumn1() +"列");
goodsLocation.append( orderVO.getRow1()+"层");
@ -97,8 +97,8 @@ public class OrderService {
if(orderVO.getColumn2()!= 0 && orderVO.getRow2()!=0) {
goodsLocation.append(orderVO.getLeftRight2() == 1 ? "左侧" : "右侧") ;
goodsLocation.append( orderVO.getInOut2() == 1 ? "浅货位" : "深货位");
goodsLocation.append(orderVO.getRow2()).append("行");
goodsLocation.append(orderVO.getColumn2()).append("列");
goodsLocation.append(orderVO.getRow2()).append("层");

@ -18,6 +18,8 @@ import com.zhehekeji.web.pojo.websocket.WebSocketVo;
import com.zhehekeji.web.service.RFID.RFIDMap;
import com.zhehekeji.web.service.RFID.RFIDSocket;
import com.zhehekeji.web.service.algorithm.AlgorithmService;
import com.zhehekeji.web.service.damLightSource.JYDAMEquip;
import com.zhehekeji.web.service.damLightSource.JYDamHelper;
import com.zhehekeji.web.service.hikLightSource.HikControlSocket;
import com.zhehekeji.web.service.interfaces.RfidLiveService;
import com.zhehekeji.web.service.ksec.KsecDataInfo;
@ -673,19 +675,9 @@ public class PlcService {
plcCmdInfo.setStreetName(street.getName());
List<LightSource> lightSources = lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id", street.getId()));
lightSources.forEach(lightSource -> {
HikControlSocket.openLight(lightSource.getIp(), lightSource.getPort(), configProperties.getLightSource().getIndex(), 1);
});
Thread thread = new Thread(() -> {
try {
Thread.sleep(30000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
//关闭光源
streetController.closeStreetLightSource(street.getId());
});
thread.start();
//关闭光源
streetController.openStreetLightSource(street.getId());
log.info("盘点摄像头变化参数:" + plcCmdInfo.toString());
Integer cameraId = getCameraByPlcCmdE(plcCmdInfo, plcCmdInfo.getLeftRight1());
@ -710,6 +702,17 @@ public class PlcService {
//货物使用球机扫码
log.info("盘点信息:{}", algorithmPojo.toString());
//关闭光源
Thread thread = new Thread(() -> {
try {
Thread.sleep(30000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
//关闭光源
streetController.closeStreetLightSource(street.getId());
});
thread.start();
//核对异常
Integer status = 1;
//托盘和货物都正确
@ -762,6 +765,7 @@ public class PlcService {
checkLog.setPic(stock.getCheckPic());
checkLog.setStreetId(stock.getStreetId());
checkLog.setDirection(stock.getDirection());
checkLog.setTaskId(stock.getCheckNum());
checkLog.setSide(stock.getSide());
checkLog.setCode(stock.getCode());
checkLog.setWmsCode(stock.getWmsCode());
@ -853,11 +857,14 @@ public class PlcService {
plcCmdInfo.setToSeparation(dataInfo.getToSeparation());
plcCmdInfo.setFromAround(dataInfo.getFromAround());
plcCmdInfo.setToSide(dataInfo.getToSeparation());
//古井贡增加层概念,等于行
if( dataInfo.getToStorey()!=null ){
plcCmdInfo.setToRow(dataInfo.getToStorey());
plcCmdInfo.setRow2(dataInfo.getToStorey());
}
if( dataInfo.getFromStorey()!=null ){
plcCmdInfo.setFromRow(dataInfo.getFromStorey());
plcCmdInfo.setRow1(dataInfo.getFromStorey());
}
//左右不交换

@ -349,13 +349,23 @@ public class StockService {
stock.setPreoperationPic(stockLogs.get(1).getPic());
}
String ip ="http://"+ street.getPlcIp()+":9009/pic/"+stock.getCode()+"/"+stock.getCheckNum()+"/";
stock.setSidePic1(String.format("%s1.png",ip));
stock.setSidePic2(String.format("%s2.png",ip));
stock.setSidePic3(String.format("%s3.png",ip));
stock.setSidePic4(String.format("%s4.png",ip));
stock.setTopPic1(String.format("%s5.png",ip));
stock.setTopPic2(String.format("%s6.png",ip));
String ip ="http://"+ street.getPlcIp()+":9009/pic/"+stock.getCheckNum();
//古井贡酒
/*
* &#x6D4B;4 #{task}_1
* &#x9876;&#x90E8;01 #{task}_2
* &#x9876;&#x90E8;8 #{task}_3
* &#x4FA7;2 #{task}_4
* &#x4FA7;02 #{task}_5
* &#x4FA7;03 #{task}_6
* */
stock.setSidePic1(String.format("%s_1.JPEG",ip));
stock.setSidePic2(String.format("%s_6.JPEG",ip));
stock.setSidePic3(String.format("%s_4.JPEG",ip));
stock.setSidePic4(String.format("%s_5.JPEG",ip));
stock.setTopPic1(String.format("%s_2.JPEG",ip));
stock.setTopPic2(String.format("%s_3.JPEG",ip));
return stock;
}
@ -364,12 +374,12 @@ public class StockService {
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(street.getId(),stockCheckSearch.getDirection(),stockCheckSearch.getSeparation(),stockCheckSearch.getRow(),stockCheckSearch.getColumn());
if(stock != null){
String ip ="http://"+ street.getPlcIp()+":9009/pic/"+stock.getCode()+"/"+stock.getLotnum()+"/"+stock.getLotnum()+"/";
stock.setSidePic1(String.format("%s1.png",ip));
stock.setSidePic2(String.format("%s2.png",ip));
stock.setSidePic3(String.format("%s3.png",ip));
stock.setSidePic4(String.format("%s4.png",ip));
stock.setTopPic1(String.format("%s5.png",ip));
stock.setTopPic2(String.format("%s6.png",ip));
stock.setSidePic1(String.format("%s_1.JPEG",ip));
stock.setSidePic2(String.format("%s_5.JPEG",ip));
stock.setSidePic3(String.format("%s_6.JPEG",ip));
stock.setSidePic4(String.format("%s_4.JPEG",ip));
stock.setTopPic1(String.format("%s_2.JPEG",ip));
stock.setTopPic2(String.format("%s_3.JPEG",ip));
}
return stock;
}

@ -10,6 +10,7 @@ import com.zhehekeji.web.service.ksec.KsecDataInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
@ -27,6 +28,7 @@ public class AlgorithmService {
@Resource
ConfigProperties configProperties;
public static void main(String[] args) {
AlgorithmPojo algorithmPojo= new AlgorithmPojo();
algorithmPojo.setGoodsTypeResult("qqq");
@ -46,8 +48,7 @@ public class AlgorithmService {
public AlgorithmPojo getGoodResult(AlgorithmPojo algorithmPojo) {
String url = "http://"+algorithmPojo.getIp()+":"+algorithmPojo.getPort()+configProperties.getVisualSense().getUrl();
RestTemplate restTemplate =new RestTemplate();
restTemplate = new RestTemplate();

@ -68,8 +68,10 @@ public class KsecNettyClient {
} catch (Exception e) {
//没连上 继续
log.error("reconnect error num:{}", num);
if(channel!= null)
channel.close();
if(channel!= null) {
channel.disconnect();
channel.close();
}
num++;
try {
Thread.sleep(ksec.getReconnectInterval()*1000);

Loading…
Cancel
Save