增加 street与shelves的关联关系表
parent
d1ad225dee
commit
6b955832d8
@ -0,0 +1,36 @@
|
|||||||
|
package com.zhehekeji.common.util;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class PathUtil {
|
||||||
|
|
||||||
|
public static String createFileName(String fileType) {
|
||||||
|
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd/HH"));
|
||||||
|
return time + "/" + UUID.randomUUID() + "."+fileType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File getFile(String url){
|
||||||
|
File file = new File(url);
|
||||||
|
//如果文件不存在,则新建一个
|
||||||
|
if(!file.exists()){
|
||||||
|
if(!file.getParentFile().exists()){
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
file.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("创建文件出错:{}",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.zhehekeji.web.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName
|
||||||
|
public class StreetShelve {
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private Integer streetId;
|
||||||
|
|
||||||
|
private String shelveId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,87 @@
|
|||||||
|
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.mapper.OrderMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 抓图回调函数
|
||||||
|
* @Author wangyiming1031@aliyun.com
|
||||||
|
* @Date 2020/12/14 16:11
|
||||||
|
**/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class CaptureReceiveCB implements NetSDKLib.fSnapRev{
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderMapper orderMapper;
|
||||||
|
|
||||||
|
@Value("${mediaPath}")
|
||||||
|
private String mediaPath;
|
||||||
|
|
||||||
|
private static String fileType = "jpg";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(NetSDKLib.LLong lLoginID, Pointer pBuf, int RevLen, int EncodeType, int CmdSerial, Pointer dwUser) {
|
||||||
|
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);
|
||||||
|
Order order = new Order();
|
||||||
|
order.setId(orderInfo.getOrderId());
|
||||||
|
if(OrderInfo.OrderPathType.GOODS.getType().equals(orderInfo.getType())){
|
||||||
|
order.setGoodsPath(path);
|
||||||
|
}else if(OrderInfo.OrderPathType.PUT.getType().equals(orderInfo.getType())){
|
||||||
|
order.setPutPath(path);
|
||||||
|
}else if(OrderInfo.OrderPathType.OUTPUT.getType().equals(orderInfo.getType())){
|
||||||
|
order.setOutPutPath(path);
|
||||||
|
}
|
||||||
|
orderMapper.updateById(order);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.warn("no order");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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,38 @@
|
|||||||
|
package com.zhehekeji.web.lib;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
public class OrderCmdSerial {
|
||||||
|
|
||||||
|
public static ConcurrentHashMap<Integer, OrderInfo> orderCmdSerialMap = new ConcurrentHashMap<>(Short.MAX_VALUE * 4);
|
||||||
|
|
||||||
|
private static AtomicInteger serialIntId = new AtomicInteger(0);
|
||||||
|
|
||||||
|
public static Integer nextSerial() {
|
||||||
|
return serialIntId.addAndGet(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void put(Integer serialId, OrderInfo orderInfo) {
|
||||||
|
orderCmdSerialMap.put(serialId, orderInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void remove(Integer serialId) {
|
||||||
|
orderCmdSerialMap.remove(serialId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OrderInfo getOrderInfo(Integer serialId) {
|
||||||
|
return orderCmdSerialMap.get(serialId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
AtomicInteger integer = new AtomicInteger(Integer.MAX_VALUE);
|
||||||
|
System.out.println(integer);
|
||||||
|
//System.out.println(integer.addAndGet(1));
|
||||||
|
System.out.println((short) integer.addAndGet(1));
|
||||||
|
AtomicInteger next = new AtomicInteger(integer.addAndGet(1));
|
||||||
|
System.out.println(next.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.zhehekeji.web.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zhehekeji.web.entity.Stock;
|
||||||
|
import com.zhehekeji.web.entity.StreetShelve;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface StreetShelveMapper extends BaseMapper<StreetShelve> {
|
||||||
|
|
||||||
|
void batchInsert(List<StreetShelve> streetShelves);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.zhehekeji: debug
|
||||||
|
org.springframework.web: info
|
||||||
|
root: info
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
initialSize: 15
|
||||||
|
maxActive: 20
|
||||||
|
maxPoolPreparedStatementPerConnectionSize: 20
|
||||||
|
maxWait: 60000
|
||||||
|
minEvictableIdleTimeMillis: 300000
|
||||||
|
minIdle: 15
|
||||||
|
password: lipoLiPo
|
||||||
|
poolPreparedStatements: true
|
||||||
|
testOnBorrow: true
|
||||||
|
testOnReturn: false
|
||||||
|
testWhileIdle: false
|
||||||
|
timeBetweenEvictionRunsMillis: 60000
|
||||||
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
url: jdbc:mysql://47.98.255.48:8008/lipo_duoji?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||||
|
username: lipo
|
||||||
|
validationQuery: SELECT 1 FROM DUAL
|
||||||
|
zhehe:
|
||||||
|
common:
|
||||||
|
redis:
|
||||||
|
prefix: spring
|
||||||
|
filter:
|
||||||
|
enable: true
|
||||||
|
postToken: w89euijon2&UHBTY$%huni34ri
|
||||||
|
server:
|
||||||
|
port: 8099
|
||||||
|
userUrl: http://115.236.65.98:8007
|
||||||
|
picPort: 8544
|
||||||
|
mediaPath: d:\\media\
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.zhehekeji.web.mapper.StreetShelveMapper">
|
||||||
|
|
||||||
|
<insert id="batchInsert" parameterType="java.util.List">
|
||||||
|
insert into street_shelve(
|
||||||
|
shelve_id,street_id
|
||||||
|
) values
|
||||||
|
<foreach collection="streetShelves" item="item" separator=",">
|
||||||
|
(#{item.shelveId},#{item.streetId})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue