增加 street与shelves的关联关系表
parent
6b955832d8
commit
3f7ba8dbfa
@ -0,0 +1,36 @@
|
|||||||
|
package com.zhehekeji.web.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@TableName
|
||||||
|
@Data
|
||||||
|
public class OrderLastMedia {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private String shelveId;
|
||||||
|
|
||||||
|
@TableField("`row`")
|
||||||
|
private Integer row;
|
||||||
|
|
||||||
|
@TableField("`column`")
|
||||||
|
private Integer column;
|
||||||
|
|
||||||
|
private Long lastPutOrderId;
|
||||||
|
|
||||||
|
@ApiModelProperty("入库照片")
|
||||||
|
private String putPath;
|
||||||
|
|
||||||
|
private Long lastOutOrderId;
|
||||||
|
|
||||||
|
@ApiModelProperty("出库照片")
|
||||||
|
private String outPutPath;
|
||||||
|
|
||||||
|
private Long lastGoodsOrderId;
|
||||||
|
|
||||||
|
@ApiModelProperty("货位照片")
|
||||||
|
private String goodsPath;
|
||||||
|
}
|
||||||
@ -0,0 +1,125 @@
|
|||||||
|
package com.zhehekeji.web.lib;
|
||||||
|
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import com.zhehekeji.common.util.PathUtil;
|
||||||
|
import com.zhehekeji.web.entity.Order;
|
||||||
|
import com.zhehekeji.web.entity.OrderLastMedia;
|
||||||
|
import com.zhehekeji.web.mapper.OrderLastMediaMapper;
|
||||||
|
import com.zhehekeji.web.mapper.OrderMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class CaptureRunnable implements Runnable {
|
||||||
|
|
||||||
|
private int CmdSerial;
|
||||||
|
|
||||||
|
private String fileType;
|
||||||
|
|
||||||
|
private Integer RevLen;
|
||||||
|
|
||||||
|
private String mediaPath;
|
||||||
|
|
||||||
|
private Pointer pBuf;
|
||||||
|
|
||||||
|
private OrderMapper orderMapper;
|
||||||
|
|
||||||
|
private OrderLastMediaMapper lastMediaMapper;
|
||||||
|
|
||||||
|
public CaptureRunnable(int cmdSerial, String fileType, Integer revLen, String mediaPath,
|
||||||
|
Pointer pBuf, OrderMapper orderMapper, OrderLastMediaMapper lastMediaMapper) {
|
||||||
|
this.CmdSerial = cmdSerial;
|
||||||
|
this.fileType = fileType;
|
||||||
|
this.RevLen = revLen;
|
||||||
|
this.mediaPath = mediaPath;
|
||||||
|
this.pBuf = pBuf;
|
||||||
|
this.orderMapper = orderMapper;
|
||||||
|
this.lastMediaMapper = lastMediaMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
OrderInfo orderInfo = OrderCmdSerial.getOrderInfo(CmdSerial);
|
||||||
|
OrderCmdSerial.remove(CmdSerial);
|
||||||
|
if(orderInfo != null){
|
||||||
|
String path = PathUtil.createFileName(fileType);
|
||||||
|
String picPath = savePic(pBuf,RevLen,mediaPath+path);
|
||||||
|
if(picPath == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.debug("save pic orderId:{} path:{}",orderInfo.getOrderId(),picPath);
|
||||||
|
|
||||||
|
OrderLastMedia orderLastMedia = lastMediaMapper.selectById("qqq");
|
||||||
|
if(orderLastMedia == null){
|
||||||
|
orderLastMedia = initLastOrder();
|
||||||
|
}
|
||||||
|
Order order = new Order();
|
||||||
|
order.setId(orderInfo.getOrderId());
|
||||||
|
if(OrderInfo.OrderPathType.GOODS.getType().equals(orderInfo.getType())){
|
||||||
|
order.setGoodsPath(path);
|
||||||
|
if(orderInfo.getOrderId()>orderLastMedia.getLastGoodsOrderId()){
|
||||||
|
orderLastMedia.setGoodsPath(path);
|
||||||
|
lastMediaMapper.updateById(orderLastMedia);
|
||||||
|
}
|
||||||
|
}else if(OrderInfo.OrderPathType.PUT.getType().equals(orderInfo.getType())){
|
||||||
|
order.setPutPath(path);
|
||||||
|
if(orderInfo.getOrderId()>orderLastMedia.getLastPutOrderId()){
|
||||||
|
orderLastMedia.setPutPath(path);
|
||||||
|
lastMediaMapper.updateById(orderLastMedia);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(OrderInfo.OrderPathType.OUTPUT.getType().equals(orderInfo.getType())){
|
||||||
|
order.setOutPutPath(path);
|
||||||
|
if(orderInfo.getOrderId()>orderLastMedia.getLastOutOrderId()){
|
||||||
|
orderLastMedia.setOutPutPath(path);
|
||||||
|
lastMediaMapper.updateById(orderLastMedia);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
orderMapper.updateById(order);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.warn("no order");
|
||||||
|
}
|
||||||
|
|
||||||
|
private OrderLastMedia initLastOrder(){
|
||||||
|
OrderLastMedia orderLastMedia = new OrderLastMedia();
|
||||||
|
orderLastMedia.setShelveId("qqq");
|
||||||
|
orderLastMedia.setLastOutOrderId(0L);
|
||||||
|
orderLastMedia.setLastPutOrderId(0L);
|
||||||
|
orderLastMedia.setLastGoodsOrderId(0L);
|
||||||
|
lastMediaMapper.insert(orderLastMedia);
|
||||||
|
return orderLastMedia;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String savePic(Pointer pBuf, int RevLen,String path){
|
||||||
|
BufferedImage bufferedImage = null;
|
||||||
|
if(pBuf != null && RevLen > 0) {
|
||||||
|
byte[] buf = pBuf.getByteArray(0, RevLen);
|
||||||
|
ByteArrayInputStream byteArrInput = new ByteArrayInputStream(buf);
|
||||||
|
try {
|
||||||
|
bufferedImage = ImageIO.read(byteArrInput);
|
||||||
|
if(bufferedImage == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
File file = PathUtil.getFile(path);
|
||||||
|
ImageIO.write(bufferedImage, fileType, file);
|
||||||
|
return path;
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}finally {
|
||||||
|
if(bufferedImage != null){
|
||||||
|
bufferedImage.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.zhehekeji.web.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zhehekeji.web.entity.OrderLastMedia;
|
||||||
|
|
||||||
|
public interface OrderLastMediaMapper extends BaseMapper<OrderLastMedia> {
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue