|
|
|
@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
package com.zhehekeji.web.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
|
|
|
import com.zhehekeji.core.pojo.Result;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.entity.CheckLog;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.pojo.Cmd;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.pojo.stock.CheckLogSearch;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.service.GoodsActionTimes;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.service.PlcCmdInfo;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.service.PlcService;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.service.ksec.KsecDataInfo;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.service.ksec.KsecInfo;
|
|
|
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Api(tags = "盘点历史")
|
|
|
|
|
|
|
|
@RequestMapping("/Ksec")
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
|
|
|
public class KsecController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private PlcService plcService;
|
|
|
|
|
|
|
|
@ApiOperation("盘点历史")
|
|
|
|
|
|
|
|
@PostMapping("")
|
|
|
|
|
|
|
|
public Result<String> list(@RequestBody KsecInfo ksecInfo){
|
|
|
|
|
|
|
|
if (Cmd.A.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
return Result.success("SUCCESS");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
KsecDataInfo dataInfo = ksecInfo.getData();
|
|
|
|
|
|
|
|
String lotnum = dataInfo.getLotnum();
|
|
|
|
|
|
|
|
PlcCmdInfo plcCmdInfo = null;
|
|
|
|
|
|
|
|
String srmNumber = null;
|
|
|
|
|
|
|
|
String cmdName = null;
|
|
|
|
|
|
|
|
if(dataInfo != null){
|
|
|
|
|
|
|
|
plcCmdInfo = new PlcCmdInfo(dataInfo.getSRMNumber(), dataInfo.getTaskId(),
|
|
|
|
|
|
|
|
dataInfo.getFromSide(), dataInfo.getFromDirection(), dataInfo.getFromColumn(),
|
|
|
|
|
|
|
|
dataInfo.getFromRow(), dataInfo.getFromSeparation(),dataInfo.getToSide(),
|
|
|
|
|
|
|
|
dataInfo.getToDirection(), dataInfo.getToColumn(), dataInfo.getToRow(),
|
|
|
|
|
|
|
|
dataInfo.getToSeparation(),lotnum);
|
|
|
|
|
|
|
|
plcCmdInfo.setFromDirection(dataInfo.getFromDirection());
|
|
|
|
|
|
|
|
plcCmdInfo.setToDirection(dataInfo.getToDirection());
|
|
|
|
|
|
|
|
plcCmdInfo.setToColumn(dataInfo.getToColumn());
|
|
|
|
|
|
|
|
plcCmdInfo.setToRow(dataInfo.getToRow());
|
|
|
|
|
|
|
|
plcCmdInfo.setFromRow(dataInfo.getFromRow());
|
|
|
|
|
|
|
|
plcCmdInfo.setFromColumn(dataInfo.getFromColumn());
|
|
|
|
|
|
|
|
plcCmdInfo.setFromSide(dataInfo.getFromSide());
|
|
|
|
|
|
|
|
plcCmdInfo.setFromSeparation(dataInfo.getFromSeparation());
|
|
|
|
|
|
|
|
plcCmdInfo.setToSeparation(dataInfo.getToSeparation());
|
|
|
|
|
|
|
|
plcCmdInfo.setToSide(dataInfo.getToSide());
|
|
|
|
|
|
|
|
//左右不换过来
|
|
|
|
|
|
|
|
if(dataInfo.getFromDirection() == 1){
|
|
|
|
|
|
|
|
//dataInfo.setFromDirection(2);
|
|
|
|
|
|
|
|
plcCmdInfo.setLeftRight1(dataInfo.getFromDirection());
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
//dataInfo.setFromDirection(1);
|
|
|
|
|
|
|
|
plcCmdInfo.setLeftRight1(dataInfo.getFromDirection());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dataInfo.getToDirection() != null && dataInfo.getToDirection() == 1){
|
|
|
|
|
|
|
|
//dataInfo.setToDirection(2);
|
|
|
|
|
|
|
|
plcCmdInfo.setLeftRight2(dataInfo.getToDirection());
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
//dataInfo.setToDirection(1);
|
|
|
|
|
|
|
|
plcCmdInfo.setLeftRight2(dataInfo.getToDirection());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
srmNumber = dataInfo.getSRMNumber();
|
|
|
|
|
|
|
|
cmdName = dataInfo.getCmdName();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Cmd.A.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
//心跳
|
|
|
|
|
|
|
|
log.debug("receieve heart ");
|
|
|
|
|
|
|
|
} else if (Cmd.B.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
//任务
|
|
|
|
|
|
|
|
if (Cmd.B1.name().equals(cmdName)) {
|
|
|
|
|
|
|
|
//昆船盘点模式下也会发B1 ,但是不会发送B2
|
|
|
|
|
|
|
|
//这里判断下,是否存在盘点批次号 若存在,既是盘点的B1,无需处理;若不存在lotnum,则是随行的B1
|
|
|
|
|
|
|
|
if(StringUtils.isEmpty(dataInfo.getLotnum())){
|
|
|
|
|
|
|
|
//任务开始 旋转到原点位
|
|
|
|
|
|
|
|
plcService.gyrateCamera(plcCmdInfo,Cmd.C5.name());
|
|
|
|
|
|
|
|
plcService.orderStart(plcCmdInfo);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
log.info("check move");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (Cmd.B2.name().equals(cmdName)) {
|
|
|
|
|
|
|
|
//B2 C4 一起发的,需要停止等B2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//这里判断是不是双伸
|
|
|
|
|
|
|
|
if(plcCmdInfo.getSeparation2() == 2){
|
|
|
|
|
|
|
|
//深测货架延迟
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(plcService.getConfigProperties().getCameraConfig().getB2OutDelayTime());
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
//浅侧延迟
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(plcService.getConfigProperties().getCameraConfig().getB2DelayTime());
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
plcService.gyrateCamera(plcCmdInfo,Cmd.C5.name());
|
|
|
|
|
|
|
|
plcService.orderStop(plcCmdInfo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (Cmd.C.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//动作
|
|
|
|
|
|
|
|
String code = dataInfo.getCmdName();
|
|
|
|
|
|
|
|
log.info("action code,{},orderInfo:{}", code, plcCmdInfo.toString());
|
|
|
|
|
|
|
|
if (Cmd.isBaseAction(code)) {
|
|
|
|
|
|
|
|
//执行动作,需要保存执行到第几步了
|
|
|
|
|
|
|
|
Integer times = GoodsActionTimes.put(plcCmdInfo.getOrderNum());
|
|
|
|
|
|
|
|
plcCmdInfo.setTimes(times);
|
|
|
|
|
|
|
|
code = code + "-" + plcCmdInfo.getLeftRightStr(times) + plcCmdInfo.getInOutStr(times);
|
|
|
|
|
|
|
|
//执行动作
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
plcService.action(plcCmdInfo, times, code);
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
log.info("other C code :{}",code);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (Cmd.D.name().equals(ksecInfo.getType())) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//柳州去掉告警
|
|
|
|
|
|
|
|
// String code = dataInfo.getCmdName();
|
|
|
|
|
|
|
|
// if(code.equals(Cmd.D1.name())){
|
|
|
|
|
|
|
|
// log.info("plcId:{},warn start",plcCmdInfo.getPlcId());
|
|
|
|
|
|
|
|
// //根据告警code转动camera
|
|
|
|
|
|
|
|
// String warnCode = dataInfo.getWarnCode();
|
|
|
|
|
|
|
|
// if(!StringUtils.isEmpty(warnCode)){
|
|
|
|
|
|
|
|
// String warnCode0 = Cmd.D1.name()+"-"+warnCode.split(",")[0];
|
|
|
|
|
|
|
|
// plcService.warnAction(plcCmdInfo,warnCode0);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// plcService.warnStart(plcCmdInfo.getPlcId(),dataInfo.getWarnCode());
|
|
|
|
|
|
|
|
// }else if(code.equals(Cmd.D2.name())){
|
|
|
|
|
|
|
|
// log.info("plcId:{},warn stop",plcCmdInfo.getPlcId());
|
|
|
|
|
|
|
|
// plcService.warnStop(plcCmdInfo.getPlcId());
|
|
|
|
|
|
|
|
// }else {
|
|
|
|
|
|
|
|
// log.info("other D code :{}",code);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
} else if (Cmd.E.name().equals(ksecInfo.getType()) ) {
|
|
|
|
|
|
|
|
//rfid的逻辑
|
|
|
|
|
|
|
|
String code = dataInfo.getCmdName();
|
|
|
|
|
|
|
|
log.info("盘点指令:{}", ksecInfo);
|
|
|
|
|
|
|
|
plcService.check(plcCmdInfo,ksecInfo.getType(),dataInfo.getCode(),dataInfo.getTrayCode());
|
|
|
|
|
|
|
|
ksecInfo.getData().setAckStatus(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("盘点完成");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//找到该货位的最后一张照片与现在的照片比照
|
|
|
|
|
|
|
|
//plcService.recordStock(plcCmdInfo, dataInfo.getCode(), 0, 0);
|
|
|
|
|
|
|
|
return Result.success("SUCCESS");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|