增加空货位盘点拍照返回功能

nanjing-yancao-wuliuzhongxin-qsl
LAPTOP-S9HJSOEB\昊天 3 years ago
parent 90a8d47e2d
commit a6d57218e8

@ -0,0 +1,72 @@
package com.zhehekeji.web.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@TableName("empty_check_pic")
@Data
public class EmptyCheckPic {
private String inputString;
private String fixedValue = "UL";
private String laneNumber;
private String leftOrRight;
@TableField("`row`")
private String row;
@TableField("`column`")
private String column;
private String depth;
private String end = "11";
private String taskCode ;
private String deepPic ;
private String shallowPic ;
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime creatTime ;
public EmptyCheckPic(){
}
public EmptyCheckPic(String inputString,String taskCode,String srmNumber) {
this.inputString = inputString;
this.taskCode = taskCode;
creatTime = LocalDateTime.now();
parseInputString();
laneNumber = srmNumber;
}
private void parseInputString() {
if (inputString.length() >= 14) {
fixedValue = inputString.substring(0, 2);
laneNumber = inputString.substring(2, 4);
leftOrRight = inputString.substring(4, 5);
column = inputString.substring(5, 8);
row = inputString.substring(8, 10);
depth = inputString.substring(10, 12);
end = inputString.substring(12);
}
}
public static String getShelfCodeEntityConverter(List<EmptyCheckPic> list,String webPicPath) {
StringBuffer stringBuffer = new StringBuffer(list.get(0).getInputString());
for (EmptyCheckPic shelfCodeEntityConverter :list){
stringBuffer.append(",");
stringBuffer.append(webPicPath + shelfCodeEntityConverter.getShallowPic()).append("*").append((shelfCodeEntityConverter.getDeepPic()!=null) ? webPicPath + shelfCodeEntityConverter.getDeepPic():webPicPath +shelfCodeEntityConverter.getShallowPic());
}
stringBuffer.append("$");
return stringBuffer.toString();
}
}

@ -0,0 +1,8 @@
package com.zhehekeji.web.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhehekeji.web.entity.EmptyCheck;
import com.zhehekeji.web.entity.EmptyCheckPic;
public interface EmptyCheckPicMapper extends BaseMapper<EmptyCheckPic> {
}

@ -9,16 +9,16 @@ import com.zhehekeji.web.mapper.*;
import com.zhehekeji.web.pojo.OrderVO;
import com.zhehekeji.web.service.RFID.RFIDMap;
import com.zhehekeji.web.service.RFID.RFIDSocket;
import com.zhehekeji.web.service.client.ECResultMessage;
import com.zhehekeji.web.service.client.TMTransmission;
import com.zhehekeji.web.service.putian.PTCheckContent;
import com.zhehekeji.web.entity.EmptyCheckPic;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.ast.Or;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
@ -47,6 +47,8 @@ public class PlcService {
private OrderService orderService;
@Resource
private StockLogMapper stockLogMapper;
@Resource
EmptyCheckPicMapper emptyCheckPicMapper;
@Resource
private ConfigProperties configProperties;
@ -620,6 +622,68 @@ public class PlcService {
return configProperties.getIP()+":9007/api/pic/"+path;
}
/**
*
* C1
* @return
*/
@Transactional
public List<EmptyCheckPic> emptyCheck04(ECResultMessage ecResultMessage ){
EmptyCheckPic emptyCheckPic = new EmptyCheckPic(
ecResultMessage.getEmptyCheckMsg().substring(ecResultMessage.getEmptyCheckMsg()
.lastIndexOf(";",ecResultMessage.getEmptyCheckMsg().lastIndexOf(";")-1)+1,
ecResultMessage.getEmptyCheckMsg().lastIndexOf(",")),ecResultMessage.getTaskId(),ecResultMessage.getSRMNumber());
Street street = streetService.getStreetByPlcId(ecResultMessage.getSRMNumber());
if (street == null){
log.error("SRMNum: {} 对应的巷道不存在", ecResultMessage.getSRMNumber());
}
String leftOrRight = emptyCheckPic.getLeftOrRight().equals("2") ? "-R" :"-L";
//南京烟草物流只有一个相机
Integer cameraId = street.getCamera1Id() == null ? street.getCamera2Id():street.getCamera1Id();
//浅相机
//转动拍照
gyrateCameraByCode(cameraId,"C2-IN"+leftOrRight);
//等待2s再拍照
try {
Thread.sleep(1000l);
} catch (InterruptedException e) {
e.printStackTrace();
}
String path = PathUtil.createFileNameByRowColumn("jpg",cameraId,
Integer.parseInt(emptyCheckPic.getRow()),
Integer.parseInt(emptyCheckPic.getColumn()),
emptyCheckPic.getInputString()+emptyCheckPic.getTaskCode()+"-IN");
cameraCapture(cameraId,false,0l,path );
emptyCheckPic.setShallowPic(path);
if( emptyCheckPic.getLeftOrRight().equals("1") ?street.getLeftType().equals(1) :street.getRightType().equals(1)){
//深相机
//转动拍照
gyrateCameraByCode(cameraId,"C2-OUT"+leftOrRight);
//等待2s再拍照
try {
Thread.sleep(1000l);
} catch (InterruptedException e) {
e.printStackTrace();
}
path = path.replace("-IN","-OUT");
cameraCapture(cameraId,false,0l,path );
emptyCheckPic.setDeepPic(path );
}
emptyCheckPicMapper.insert(emptyCheckPic);
List<EmptyCheckPic> emptyCheckPics = emptyCheckPicMapper.selectList(new QueryWrapper<EmptyCheckPic>().eq("task_code",emptyCheckPic.getTaskCode()));
return emptyCheckPics;
}
public String getWebPicPath(){
return configProperties.getIP()+":9007/api/pic/";
}
/**
*
* @param SRMNumber

@ -1,5 +1,6 @@
package com.zhehekeji.web.service.client;
import com.zhehekeji.web.entity.EmptyCheckPic;
import com.zhehekeji.web.entity.Stock;
import com.zhehekeji.web.service.EmptyCheckService;
import com.zhehekeji.web.service.PlcService;
@ -13,7 +14,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@ -48,6 +48,7 @@ public class Decoder extends DelimiterBasedFrameDecoder {
@Override
protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
in = (ByteBuf) super.decode(ctx, in);
if(in == null){
log.debug("no data");
@ -111,6 +112,7 @@ public class Decoder extends DelimiterBasedFrameDecoder {
String endEmptyCheckStr = ECTransmission.toEmptyCheckEndString(emptyCheckContent.getSRMNUmber(), emptyCheckContent.getTaskNo());
// //通知客户端结束检测
ClientChanel.write(endEmptyCheckStr, emptyCheckContent.getSRMNUmber());
//ClientChanel.write(endEmptyCheckStr, emptyCheckContent.getSRMNUmber());
in.release();
}
else if (ptData.getType().equals(PTData.STOCK_CHECK_01)){
@ -213,8 +215,20 @@ public class Decoder extends DelimiterBasedFrameDecoder {
// strBff.append(",").append(ecTransmission.getIsEmpty());
String content = strBff.toString();
PTData ptData = new PTData(content, PTData.FLOW_R, PTData.EMPTY_CHECK_03);
log.info("ptData:{}", ptData);
PuTianNettyClient.write(ptData);
//返回结尾货位两侧的照片(EC04)(易高发送)
//照片
List<EmptyCheckPic> emptyCheckPics = plcService.emptyCheck04(ecResultMessage);
String webPicPath = plcService.getWebPicPath();
if(emptyCheckPics.size() > 1){
StringBuffer strBffPic = new StringBuffer(ecResultMessage.getSRMNumber());
strBffPic.append(",").append(ecResultMessage.getTaskId()).append(",").append(EmptyCheckPic.getShelfCodeEntityConverter(emptyCheckPics,webPicPath));
PTData ptDataEmptyCheck04 = new PTData(strBffPic.toString(), PTData.FLOW_R, PTData.EMPTY_CHECK_04);
PuTianNettyClient.write(ptDataEmptyCheck04);
}
//保存空货位条码
// EmptyCheckCodeInfo.addCode(ecTransmission.getSRMNumber(),ecTransmission.getRow(),ecTransmission.getStartColumn(), ecTransmission.getEndColumn(), ecTransmission.getOriginCode());
//保存空货位信息

@ -19,6 +19,7 @@ public class NettyServer {
@Resource
private PlcService plcService;
@Resource
private EmptyCheckService emptyCheckService;

@ -53,6 +53,8 @@ public class PTData {
public static String EMPTY_CHECK_01 = "EC01";
public static String EMPTY_CHECK_02 = "EC02";
public static String EMPTY_CHECK_03 = "EC03";
public static String EMPTY_CHECK_04 = "EC04";
public static String STOCK_CHECK_01 = "SC01";
public static String STOCK_CHECK_02 = "SC02";
public static String STOCK_CHECK_03 = "SC03";
@ -111,6 +113,13 @@ public class PTData {
return ptData;
}
public static PTData EmptyCheck04(String SRMNumber,String taskId,String YN){
StringBuffer contentSB = new StringBuffer();
contentSB.append(SRMNumber).append(",").append(taskId).append(",").append(YN);
PTData ptData = new PTData(contentSB.toString(),FLOW_R,STOCK_CHECK_03);
return ptData;
}
// public static PTData StockCheck04(String SRMNumber, String taskId, String goodsLocation, Stock stock){
// StringBuffer contentSB = new StringBuffer();
@ -130,10 +139,6 @@ public class PTData {
// }
/**
*
* @param SRMNumber
* @param taskId
* @param goodsLocation
* @return
*/
public static PTData StockCheck04(TMTransmission tmTransmission){
StringBuffer contentSB = new StringBuffer();

Loading…
Cancel
Save