盘点lotnum批次号

merge-requests/5/merge
yiming 4 years ago
parent 6e5c8fb47e
commit 1c15675ba6

@ -0,0 +1,59 @@
package com.zhehekeji.common.util;
import lombok.extern.slf4j.Slf4j;
import java.io.*;
@Slf4j
public class FileUtil {
public static void save(String text,String path){
//判断文件是否存在
File file = new File(path);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(text.getBytes());
fileOutputStream.close();
log.info("write text success :{}",text);
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getText(String path){
File file = new File(path);
if(file.exists()){
try {
FileInputStream fileInputStream = new FileInputStream(file);
byte[] bytes = new byte[1024];//定义字节长度
int len = 0;
String txt = null;
while ((len = fileInputStream.read(bytes)) != -1) {//与文件读取出来的长度比较,内部有数据读完是-1,所以不等于-1
txt = new String(bytes, 0, len);//从0取到有数据的末尾
}
fileInputStream.close();
return txt;
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
public static void main(String[] args) {
String path = "./lotnum_now";
save("www",path);
getText(path);
}
}

@ -50,7 +50,7 @@ public class StockLogService {
if(search.getColumn() != null && search.getColumn() != 0){
wrapper.eq("`column`",search.getColumn());
}
wrapper.orderByDesc("shelve_id","`row`","`column`");
wrapper.orderByDesc("shelve_id","`row`","`column`","id");
List<CheckLog>stockChecks = checkLogMapper.selectList(wrapper);
return new PageInfo<>(stockChecks);

@ -136,11 +136,13 @@ public class StockService {
for(String columnTab: rowColumnStatus.getColumnTabs()){
if(isRowColumnInTab(stock,columnTab,false)){
tabStatus(stock,columnTabStatus,columnTab);
if(columnTabCorrectCount.get(columnTab) == null){
columnTabCorrectCount.put(columnTab,1);
}else {
int c = columnTabCorrectCount.get(columnTab);
columnTabCorrectCount.put(columnTab,c+1);
if(stock.getStatus() != 0 && stock.getStatus() != 1){
if(columnTabCorrectCount.get(columnTab) == null){
columnTabCorrectCount.put(columnTab,1);
}else {
int c = columnTabCorrectCount.get(columnTab);
columnTabCorrectCount.put(columnTab,c+1);
}
}
}
}
@ -151,7 +153,7 @@ public class StockService {
String [] strings = entry.getKey().split(" - ");
Integer tabStart = Integer.valueOf(strings[0]);
Integer tabEnd = Integer.valueOf(strings[1]);
int counts = (tabEnd- tabStart) * rows;
int counts = (tabEnd- tabStart + 1) * rows;
if(counts == entry.getValue()){
rowTabStatus.put(entry.getKey(),2);
}
@ -160,7 +162,7 @@ public class StockService {
String [] strings = entry.getKey().split(" - ");
Integer tabStart = Integer.valueOf(strings[0]);
Integer tabEnd = Integer.valueOf(strings[1]);
int counts = (tabEnd- tabStart) * rows;
int counts = (tabEnd- tabStart + 1) * rows;
if(counts == entry.getValue()){
columnTabStatus.put(entry.getKey(),2);
}
@ -307,11 +309,10 @@ public class StockService {
Stock stock = stockInfo(stockCheck);
Assert.isTrue(stock != null && stock.getId() != null, "该货位暂时没有记录");
Integer oldStatus = stock.getStatus();
if(StockStatus.SUCCESS.getStatus().equals(oldStatus)){
return stock;
}
Assert.isTrue(StockStatus.ERROR.getStatus().equals(oldStatus), "无需核对");
log.info("check stock correct, shelveID:{},row:{},column:{}", stockCheck.getShelveId(), stockCheck.getRow(), stockCheck.getColumn());
stock.setStatus(StockStatus.SUCCESS.getStatus());
stock.setStatus(StockStatus.MANUAL.getStatus());
stockMapper.updateById(stock);
checkLog(stock);
return stock;
@ -322,6 +323,8 @@ public class StockService {
private void checkLog(Stock stock){
CheckLog checkLog = new CheckLog();
checkLog.setRow(stock.getRow());
checkLog.setColumn(stock.getColumn());
checkLog.setCheckNum(stock.getCheckNum());
checkLog.setPic(stock.getCheckPic());
checkLog.setShelveId(stock.getShelveId());

@ -35,12 +35,6 @@ public class WarnService {
int remainingSeconds = seconds.intValue() % 60;
String timeLength = String.format("%02d:%02d", minutes,remainingSeconds);
warnVO.setTimeLength(timeLength);
if(configProperties.getCameraConfig().getCameraType() == 1 && !StringUtils.isEmpty(warnVO.getVideoPath1())){
warnVO.setCmd1(" VSPlayer "+ warnVO.getVideoPath1());
}
if(configProperties.getCameraConfig().getCameraType() == 1 && !StringUtils.isEmpty(warnVO.getVideoPath2())){
warnVO.setCmd1(" VSPlayer "+ warnVO.getVideoPath2());
}
}
});

@ -1,6 +1,7 @@
package com.zhehekeji.web.service.ksec;
import com.alibaba.fastjson.JSONObject;
import com.zhehekeji.common.util.FileUtil;
import com.zhehekeji.web.pojo.Cmd;
import com.zhehekeji.web.service.GoodsActionTimes;
import com.zhehekeji.web.service.PlcCmdInfo;
@ -23,6 +24,10 @@ public class KsecDecoder extends DelimiterBasedFrameDecoder {
private static final Logger tcpLogger = LoggerFactory.getLogger("tcp");
public static void setLastLotnum(String lotnum){
lastLotnum = lotnum;
}
private static String lastLotnum;
private PlcService plcService;
@ -108,6 +113,7 @@ public class KsecDecoder extends DelimiterBasedFrameDecoder {
if(!StringUtils.isEmpty(lotnum) && !lotnum.equals(lastLotnum)){
//需要把stock表truncate
FileUtil.save(lotnum,"lastLotnum");
tcpLogger.info("truncate table ,last lotnum:{},new lotnum:{}",lastLotnum,lotnum);
plcService.truncateStock();
lastLotnum = lotnum;

@ -1,6 +1,7 @@
package com.zhehekeji.web.service.ksec;
import com.zhehekeji.common.util.FileUtil;
import com.zhehekeji.web.config.ConfigProperties;
import com.zhehekeji.web.service.PlcService;
import io.netty.bootstrap.Bootstrap;
@ -32,6 +33,10 @@ public class KsecNettyClient {
private static Channel channel;
public void createClient(ConfigProperties.KSEC ksec) throws InterruptedException {
String lotnum = FileUtil.getText("lastLotnum");
if(lotnum != null){
KsecDecoder.setLastLotnum(lotnum);
}
if (StringUtils.isEmpty(ksec.getIp()) || ksec.getPort() == null) {
return;
}

@ -1,6 +1,8 @@
package com.zhehekeji.web.service.sick;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.net.InetSocketAddress;
@ -13,6 +15,7 @@ import java.nio.charset.StandardCharsets;
@Slf4j
public class SickSocket {
private static final Logger tcpLogger = LoggerFactory.getLogger("sick");
public static void main(String[] args) {
String code = readOCR("192.168.8.236", 2002);
System.out.println(code);
@ -29,10 +32,12 @@ public class SickSocket {
writeCmd(os);
is = socket.getInputStream();
code = read(is);
tcpLogger.info(code);
if(code!= null){
code = code.replace("\\n","");
}
} catch (IOException e) {
tcpLogger.error("sick time out,ip:{},info:{}",ip,e);
log.error("sick time out,ip:{},info:{}",ip,e);
}finally {
if(os != null){

Loading…
Cancel
Save