增加全巷道盘点测试

merge-requests/5/merge
yiming 4 years ago
parent 071176ccf6
commit 4f45f8548d

@ -43,6 +43,12 @@ public class CameraController {
return new Result<>(cameraService.cameras(streetSearch)); return new Result<>(cameraService.cameras(streetSearch));
} }
@GetMapping("/{id}")
@ApiOperation(value = "球机")
public Result<Camera> list(@PathVariable Integer id) {
return new Result<>(cameraService.detail(id));
}
@PostMapping("") @PostMapping("")
@ApiOperation(value = "球机新增 ") @ApiOperation(value = "球机新增 ")
public Result<Integer> add(@RequestBody Camera camera) { public Result<Integer> add(@RequestBody Camera camera) {

@ -0,0 +1,39 @@
package com.zhehekeji.web.controller;
import com.github.pagehelper.PageInfo;
import com.zhehekeji.common.util.ValidatorUtil;
import com.zhehekeji.core.pojo.Result;
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.TestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@Api(value = "TestController",tags = "扫码测试")
@RequestMapping("/test")
@RestController
public class TestController {
@Resource
private TestService testService;
@ApiOperation("新增")
@GetMapping("/check/{id}")
public Result save(@PathVariable Integer id){
testService.CheckTest(id);
return Result.success();
}
}

@ -92,6 +92,7 @@ public class HikLoginModuleImpl implements CameraControlLoginModule {
int m_lUserID = hcNetsdk.NET_DVR_Login_V30(m_strIp,(short) m_nPort,m_strUser,m_strPassword,m_strDeviceInfo30); int m_lUserID = hcNetsdk.NET_DVR_Login_V30(m_strIp,(short) m_nPort,m_strUser,m_strPassword,m_strDeviceInfo30);
if(m_lUserID < 0){ if(m_lUserID < 0){
log.error("hik login error,ip:{},port:{},errorCode:{}",m_strIp,m_nPort,hcNetsdk.NET_DVR_GetLastError()); log.error("hik login error,ip:{},port:{},errorCode:{}",m_strIp,m_nPort,hcNetsdk.NET_DVR_GetLastError());
return null;
}else { }else {
log.info("hik login success"); log.info("hik login success");
} }

@ -16,6 +16,7 @@ import com.zhehekeji.web.mapper.StreetMapper;
import com.zhehekeji.web.pojo.camera.CameraConfigSearchReq; import com.zhehekeji.web.pojo.camera.CameraConfigSearchReq;
import com.zhehekeji.web.pojo.camera.IOImport; import com.zhehekeji.web.pojo.camera.IOImport;
import com.zhehekeji.web.pojo.street.StreetSearch; import com.zhehekeji.web.pojo.street.StreetSearch;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
@ -95,6 +96,10 @@ public class CameraService {
return new PageInfo<>(cameras); return new PageInfo<>(cameras);
} }
public Camera detail(Integer id){
return cameraMapper.selectById(id);
}
public List<Camera> allCameras(){ public List<Camera> allCameras(){
return cameraMapper.selectByMap(new HashMap<>()); return cameraMapper.selectByMap(new HashMap<>());
} }

@ -126,7 +126,9 @@ public class InitService implements ApplicationRunner {
public void run() { public void run() {
cameras.forEach(camera -> { cameras.forEach(camera -> {
NetSDKLib.LLong lLong = cameraControlLoginModule().login(camera.getIp(),camera.getPort(),camera.getUser(),camera.getPassword()); NetSDKLib.LLong lLong = cameraControlLoginModule().login(camera.getIp(),camera.getPort(),camera.getUser(),camera.getPassword());
if(lLong != null){
CameraConnMap.conn(camera.getId(),lLong); CameraConnMap.conn(camera.getId(),lLong);
}
}); });
} }
} }

@ -493,7 +493,7 @@ public class PlcService {
log.error("no sensor gun config in database ,street id:{},direction:{}",street.getId(),plcCmdInfo.getLeftRight1()); log.error("no sensor gun config in database ,street id:{},direction:{}",street.getId(),plcCmdInfo.getLeftRight1());
}else { }else {
trayCode = SickSocket.readOCR(sensorGun.getIp(),sensorGun.getPort()); trayCode = SickSocket.readOCR(sensorGun.getIp(),sensorGun.getPort());
log.info("sencor:{}",trayCode); log.info("sensor tray code:{}",trayCode);
if(StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")){ if(StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")){
trayCode = "识别异常"; trayCode = "识别异常";
trayCheck = Boolean.FALSE; trayCheck = Boolean.FALSE;
@ -508,11 +508,11 @@ public class PlcService {
} }
log.info("code:{}",scanCode); log.info("code:{}",scanCode);
//核对正确 //核对异常
Integer status = 2; Integer status = 1;
//托盘和货物都正确 //托盘和货物都正确
if(!trayCheck || !codeCheck){ if(trayCheck && codeCheck){
status = 1; status = 2;
} }
if(stock == null){ if(stock == null){
stock = new Stock(); stock = new Stock();

@ -22,6 +22,7 @@ import org.springframework.cache.annotation.Caching;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -84,11 +85,14 @@ public class StreetService {
} }
}); });
thread.start(); thread.start();
if(!StringUtils.isEmpty(streetVO.getLightSourceIp()) && streetVO.getLightSourcePort() != null){
LightSource lightSource = new LightSource(); LightSource lightSource = new LightSource();
lightSource.setStreetId(street.getId()); lightSource.setStreetId(street.getId());
lightSource.setIp(streetVO.getLightSourceIp()); lightSource.setIp(streetVO.getLightSourceIp());
lightSource.setPort(streetVO.getLightSourcePort()); lightSource.setPort(streetVO.getLightSourcePort());
lightSourceMapper.insert(lightSource); lightSourceMapper.insert(lightSource);
}
streetVO.setId(street.getId());
return street; return street;
} }

@ -0,0 +1,58 @@
package com.zhehekeji.web.service;
import com.zhehekeji.web.entity.Street;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Service
@Slf4j
public class TestService {
@Resource
private PlcService plcService;
@Resource
private StreetService streetService;
private static Boolean isRunning = Boolean.FALSE;
public void CheckTest(Integer StreetId){
if(!isRunning){
isRunning = Boolean.TRUE;
Street street = streetService.streetById(StreetId);
Integer row = street.getLeftRow();
Integer column = street.getLeftColumn();
for(int i = 1;i<=row;i++){
for(int j = 0; j<= column;j++){
String code = null;
if(j % 2 == 0){
code = "3224112150069";
}else {
code = "1111";
}
String taskId = i +"-"+ j+"-"+LocalDateTime.now().format(DateTimeFormatter.ofPattern("hhmmss"));
PlcCmdInfo plcCmdInfo = new PlcCmdInfo(street.getPlcId(),taskId,1,1,j,i,1,1,1,1,1,1);
plcService.check(plcCmdInfo,"E1",code,"21234-trayCode");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
plcService.gyrateCameraByCode(street.getCamera1Id(),"C5");
}
}
isRunning = Boolean.FALSE;
return;
}
log.info("test running");
}
}
Loading…
Cancel
Save