|
|
|
|
@ -3,11 +3,16 @@ package com.zhehekeji.web.controller;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.zhehekeji.core.pojo.Result;
|
|
|
|
|
import com.zhehekeji.web.entity.CheckLog;
|
|
|
|
|
import com.zhehekeji.web.entity.Street;
|
|
|
|
|
import com.zhehekeji.web.pojo.stock.CheckLogSearch;
|
|
|
|
|
import com.zhehekeji.web.pojo.street.StreetVO;
|
|
|
|
|
import com.zhehekeji.web.service.EmptyCheckService;
|
|
|
|
|
import com.zhehekeji.web.service.client.ClientChanel;
|
|
|
|
|
import com.zhehekeji.web.service.client.ECTransmission;
|
|
|
|
|
import com.zhehekeji.web.service.client.TMTransmission;
|
|
|
|
|
import com.zhehekeji.web.service.PlcService;
|
|
|
|
|
import com.zhehekeji.web.service.StreetService;
|
|
|
|
|
import com.zhehekeji.web.service.client.*;
|
|
|
|
|
import com.zhehekeji.web.service.putian.PTData;
|
|
|
|
|
import com.zhehekeji.web.service.putian.PTEmptyCheckContent;
|
|
|
|
|
import com.zhehekeji.web.service.putian.PuTianNettyClient;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
|
@ -23,42 +28,135 @@ public class ClientTestController {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private EmptyCheckService emptyCheckService;
|
|
|
|
|
@Resource
|
|
|
|
|
private StreetService streetService;
|
|
|
|
|
@Resource
|
|
|
|
|
private PlcService plcService;
|
|
|
|
|
|
|
|
|
|
@ApiOperation("空货位盘点【发起】")
|
|
|
|
|
@ApiOperation("模拟普天 空货位盘点【发起】")
|
|
|
|
|
@GetMapping("/emptyCheck/start")
|
|
|
|
|
public Result<Boolean> startEmptyCheck(@ApiParam("巷道标识") String SRMNumber,@ApiParam("盘点批次ID") String taskId, @ApiParam("检测第几行") Integer row){
|
|
|
|
|
|
|
|
|
|
ClientChanel.write(ECTransmission.toEmptyCheckStartString(SRMNumber),SRMNumber);
|
|
|
|
|
|
|
|
|
|
return Result.success();
|
|
|
|
|
public Result<String> startEmptyCheck(@ApiParam("巷道标识")@RequestParam String SRMNumber,@ApiParam("盘点批次ID") @RequestParam String taskId, @ApiParam("检测第几行")@RequestParam Integer row,
|
|
|
|
|
@ApiParam("开始列")@RequestParam Integer startColumn,@ApiParam("结束列")@RequestParam Integer endColumn){
|
|
|
|
|
emptyCheckService.emptyCheckStart(SRMNumber,taskId,row);
|
|
|
|
|
String msg = ECTransmission.toEmptyCheckStartString(SRMNumber);
|
|
|
|
|
ClientChanel.write(msg,SRMNumber);
|
|
|
|
|
return Result.success(msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("空货位盘点 【结束】")
|
|
|
|
|
@ApiOperation("模拟普天 空货位盘点 【结束】")
|
|
|
|
|
@GetMapping("/emptyCheck/stop")
|
|
|
|
|
public Result<Boolean> stopEmptyCheck(@ApiParam("巷道标识") String SRMNumber,@ApiParam("盘点批次ID") String taskId, @ApiParam("检测第几行") Integer row){
|
|
|
|
|
emptyCheckService.emptyCheckStart(SRMNumber,taskId,row);
|
|
|
|
|
ClientChanel.write(ECTransmission.toEmptyCheckEndString(SRMNumber),SRMNumber);
|
|
|
|
|
return Result.success();
|
|
|
|
|
public Result<String> stopEmptyCheck(@ApiParam("巷道标识")@RequestParam String SRMNumber,@ApiParam("盘点批次ID") @RequestParam String taskId, @ApiParam("检测第几行")@RequestParam Integer row,
|
|
|
|
|
@ApiParam("开始列")@RequestParam Integer startColumn,@ApiParam("结束列")@RequestParam Integer endColumn){
|
|
|
|
|
String msg = ECTransmission.toEmptyCheckEndString(SRMNumber);
|
|
|
|
|
ClientChanel.write(msg,SRMNumber);
|
|
|
|
|
//获取空货位的结果信息
|
|
|
|
|
// 返回给普天
|
|
|
|
|
Street street = streetService.getStreetByPlcId(SRMNumber);
|
|
|
|
|
PTEmptyCheckContent ptEmptyCheckContent = null;
|
|
|
|
|
PTData ptData = null;
|
|
|
|
|
String shevel = null;
|
|
|
|
|
if(street.getLeftType() == 0){
|
|
|
|
|
//单伸
|
|
|
|
|
String SingleLeft = emptyCheckService.getEmptyStatus(SRMNumber,taskId,1,1,row);
|
|
|
|
|
shevel = "L01";
|
|
|
|
|
ptEmptyCheckContent = PTEmptyCheckContent.emptyCheckResponse(SRMNumber,taskId,row,startColumn,endColumn,shevel,SingleLeft);
|
|
|
|
|
ptData = PTData.EmptyStatusResponse(ptEmptyCheckContent);
|
|
|
|
|
PuTianNettyClient.write(ptData);
|
|
|
|
|
String SingleRight = emptyCheckService.getEmptyStatus(SRMNumber,taskId,1,2,row);
|
|
|
|
|
shevel = "R01";
|
|
|
|
|
ptEmptyCheckContent = PTEmptyCheckContent.emptyCheckResponse(SRMNumber,taskId,row,startColumn,endColumn,shevel,SingleRight);
|
|
|
|
|
ptData = PTData.EmptyStatusResponse(ptEmptyCheckContent);
|
|
|
|
|
PuTianNettyClient.write(ptData);
|
|
|
|
|
}else {
|
|
|
|
|
String SingleInLeft = emptyCheckService.getEmptyStatus(SRMNumber,taskId,1,1,row);
|
|
|
|
|
shevel = "L01";
|
|
|
|
|
ptEmptyCheckContent = PTEmptyCheckContent.emptyCheckResponse(SRMNumber,taskId,row,startColumn,endColumn,shevel,SingleInLeft);
|
|
|
|
|
ptData = PTData.EmptyStatusResponse(ptEmptyCheckContent);
|
|
|
|
|
PuTianNettyClient.write(ptData);
|
|
|
|
|
String SingleInRight = emptyCheckService.getEmptyStatus(SRMNumber,taskId,1,2,row);
|
|
|
|
|
shevel = "R01";
|
|
|
|
|
ptEmptyCheckContent = PTEmptyCheckContent.emptyCheckResponse(SRMNumber,taskId,row,startColumn,endColumn,shevel,SingleInRight);
|
|
|
|
|
ptData = PTData.EmptyStatusResponse(ptEmptyCheckContent);
|
|
|
|
|
PuTianNettyClient.write(ptData);
|
|
|
|
|
String SingleOutLeft = emptyCheckService.getEmptyStatus(SRMNumber,taskId,2,1,row);
|
|
|
|
|
shevel = "L02";
|
|
|
|
|
ptEmptyCheckContent = PTEmptyCheckContent.emptyCheckResponse(SRMNumber,taskId,row,startColumn,endColumn,shevel,SingleOutLeft);
|
|
|
|
|
ptData = PTData.EmptyStatusResponse(ptEmptyCheckContent);
|
|
|
|
|
PuTianNettyClient.write(ptData);
|
|
|
|
|
String SingleOutRight = emptyCheckService.getEmptyStatus(SRMNumber,taskId,2,2,row);
|
|
|
|
|
shevel = "R02";
|
|
|
|
|
ptEmptyCheckContent = PTEmptyCheckContent.emptyCheckResponse(SRMNumber,taskId,row,startColumn,endColumn,shevel,SingleOutRight);
|
|
|
|
|
ptData = PTData.EmptyStatusResponse(ptEmptyCheckContent);
|
|
|
|
|
PuTianNettyClient.write(ptData);
|
|
|
|
|
}
|
|
|
|
|
return Result.success(msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("盘点具体货位 第一步 【发起盘点】")
|
|
|
|
|
@ApiOperation("模拟普天 盘点具体货位 第一步 【发起盘点】")
|
|
|
|
|
@GetMapping("/stockCheck/start")
|
|
|
|
|
public Result<Boolean> startStockCheck(@ApiParam("巷道标识") String SRMNumber,@ApiParam("盘点批次ID") String taskId,
|
|
|
|
|
@ApiParam("货位号,如L0100010002 ,R/L表示左右,01是浅货位(02深),0001是X,0002是Y") String goodsLocation,@ApiParam("品规")String code,@ApiParam("数量")Integer count,
|
|
|
|
|
@ApiParam("是否是虚拟检测 Y:是 N:不是")String V){
|
|
|
|
|
public Result<String> startStockCheck(@ApiParam("巷道标识")@RequestParam String SRMNumber,@ApiParam("盘点批次ID") @RequestParam String taskId,
|
|
|
|
|
@ApiParam("货位号,如L0100010002 ,R/L表示左右,01是浅货位(02深),0001是X,0002是Y") @RequestParam String goodsLocation,@ApiParam("品规")@RequestParam String code,@ApiParam("数量") @RequestParam Integer count,
|
|
|
|
|
@ApiParam("是否是虚拟检测 Y:是 N:不是") @RequestParam String V){
|
|
|
|
|
|
|
|
|
|
TMTransmission tmTransmission = new TMTransmission(SRMNumber,taskId,goodsLocation,code,count,V);
|
|
|
|
|
ClientChanel.write(tmTransmission.toString(),SRMNumber);
|
|
|
|
|
String msg = tmTransmission.toString();
|
|
|
|
|
ClientChanel.write(msg,SRMNumber);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("盘点具体货位 第二步 【取货到载货台完成】")
|
|
|
|
|
@ApiOperation("模拟普天 盘点具体货位 第二步 【取货到载货台完成,客户端拍照】")
|
|
|
|
|
@GetMapping("/stockCheck/goodsMoveOver")
|
|
|
|
|
public Result<Boolean> goodsMoveOver(@ApiParam("巷道标识") String SRMNumber,@ApiParam("盘点批次ID") String taskId){
|
|
|
|
|
public Result<String> goodsMoveOver(@ApiParam("巷道标识") @RequestParam String SRMNumber,@ApiParam("盘点批次ID") @RequestParam String taskId){
|
|
|
|
|
|
|
|
|
|
TMTransmission tmTransmission = new TMTransmission(SRMNumber,taskId);
|
|
|
|
|
ClientChanel.write(tmTransmission.toSC02String(),SRMNumber);
|
|
|
|
|
String msg = tmTransmission.toSC02String();
|
|
|
|
|
ClientChanel.write(msg,SRMNumber);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("模拟普天 货物入库 【货位入库】")
|
|
|
|
|
@GetMapping("/intoStock/picOver")
|
|
|
|
|
public Result<String> picOver(@ApiParam("巷道标识") @RequestParam String SRMNumber,@ApiParam("盘点批次ID") @RequestParam String taskId,
|
|
|
|
|
@ApiParam("货位号,如L0100010002 ,R/L表示左右,01是浅货位(02深),0001是X,0002是Y") @RequestParam String goodsLocation){
|
|
|
|
|
//todo 顶部拍照
|
|
|
|
|
Integer row = Integer.valueOf(goodsLocation.substring(3,7));
|
|
|
|
|
Integer column = Integer.valueOf(goodsLocation.substring(7));
|
|
|
|
|
String picPath = plcService.IntoStock(SRMNumber,"C1",row,column);
|
|
|
|
|
//返回普天
|
|
|
|
|
PTData ptData = PTData.IntoStock(SRMNumber,taskId,goodsLocation,picPath);
|
|
|
|
|
PuTianNettyClient.write(ptData);
|
|
|
|
|
return Result.success(ptData.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("模拟普天 货物入库完成 【货物入库完成】")
|
|
|
|
|
@GetMapping("/intoStock/goodsOver")
|
|
|
|
|
public Result<String> goodsOver(@ApiParam("巷道标识") @RequestParam String SRMNumber,@ApiParam("盘点批次ID") @RequestParam String taskId,
|
|
|
|
|
@ApiParam("货位号,如L0100010002 ,R/L表示左右,01是浅货位(02深),0001是X,0002是Y") @RequestParam String goodsLocation){
|
|
|
|
|
//拍入库完成后的照片
|
|
|
|
|
Integer row = Integer.valueOf(goodsLocation.substring(3,7));
|
|
|
|
|
Integer column = Integer.valueOf(goodsLocation.substring(7));
|
|
|
|
|
String picPath = plcService.IntoStock(SRMNumber,"C2",row,column);
|
|
|
|
|
//向客户端发送读码指令,等待客户端返回条码
|
|
|
|
|
ISTransmission isTransmission = new ISTransmission(SRMNumber,taskId,goodsLocation);
|
|
|
|
|
//为防万一,先清除code
|
|
|
|
|
ClientCodeMap.removeCode(SRMNumber);
|
|
|
|
|
ClientChanel.write(isTransmission.toString(),SRMNumber);
|
|
|
|
|
//发送结果给普天
|
|
|
|
|
//若1分钟内仍为收到 则放弃
|
|
|
|
|
Long start = System.currentTimeMillis();
|
|
|
|
|
while (ClientCodeMap.getCode(SRMNumber) == null && (System.currentTimeMillis()-start)<60000){
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(300l);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String code = ClientCodeMap.getCode(SRMNumber);
|
|
|
|
|
PTData ptData = PTData.IntoStock04(SRMNumber,taskId,goodsLocation,picPath,code);
|
|
|
|
|
PuTianNettyClient.write(ptData);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|