优化代码

main
judy 1 year ago
parent d92e13e128
commit 33bb34dd59
  1. 51
      shkj-wms/src/main/java/com/shkj/wcs/plc/PlcEventTask.java
  2. 2
      shkj-wms/src/main/java/com/shkj/wcs/service/impl/WcsPlcConnectServiceImpl.java
  3. 3
      shkj-wms/src/main/java/com/shkj/wcs/third/rcs/RCSUtil.java
  4. 41
      shkj-wms/src/main/java/com/shkj/wcs/third/stacker/StkCallUtil.java
  5. 4
      shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseAreaServiceImpl.java
  6. 2
      shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseBarcodesInServiceImpl.java
  7. 2
      shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseMoldServiceImpl.java
  8. 6
      shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinOutInPlanServiceImpl.java
  9. 2
      shkj-wms/src/main/java/com/shkj/wms/service/impl/SysStockServiceImpl.java

@ -177,7 +177,7 @@ public class PlcEventTask {
doDevStatus(propertyList,pointMap);
break;
default:
log.error("无匹配的设备类型");
log.info("无匹配的设备类型");
break;
}
@ -316,16 +316,6 @@ public class PlcEventTask {
//请求入库任务ID
String oneReqPutInTaskId = "",twoReqPutInTaskId = "";
//入库失败
String plcFailedWare = "";
String plcFailedWareVT = "";
//失败原因
String plcFailedReason = "";
String plcFailedReasonVT = "";
//入库失败任务号
String plcFailedTaskId = "";
String plcFailedTaskIdVT = "";
//货位高度
String oneHignType = "",twoHignType = "";
String oneHignTypeVT = "",twoHignTypeVT = "";
@ -461,7 +451,7 @@ public class PlcEventTask {
iBusinOutInPlanService.updPlanStatus(taskId, PlanStatusEnum.DOING.getValue());
}
//改为入库ID
redisTemplate.opsForValue().set(RedisConstant.redisContainer, taskId, 2, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(RedisConstant.redisContainer, taskId, 10, TimeUnit.SECONDS);
}
}
@ -473,7 +463,6 @@ public class PlcEventTask {
log.info("2楼入库分配请求时,有出库任务,不可分配,返回");
return;
}
//TODO 需要判断1楼是否有入库任务
//读取托盘条码内容
String barcodeValue = pointMap.get(twoPalletAddress).toString();
//根据托盘条码返回正在执行的任务号
@ -524,7 +513,7 @@ public class PlcEventTask {
iBusinOutInPlanService.updPlanStatus(taskId, PlanStatusEnum.DOING.getValue());
}
//改为入库ID
redisTemplate.opsForValue().set(RedisConstant.redisContainer, taskId, 2, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(RedisConstant.redisContainer, taskId, 10, TimeUnit.SECONDS);
}
}
@ -735,12 +724,12 @@ public class PlcEventTask {
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut);
if (taskOutId !=null && String.valueOf(taskOutId).equals(taskId.toString())){
log.error("出库完成时,删除redis中的出库任务状态记录");
log.info("出库完成时,删除redis中的出库任务状态记录");
redisTemplate.delete(RedisConstant.redisTaskOut);
}
if (taskInId != null && String.valueOf(taskInId).equals(taskId.toString())){
log.error("入库完成时,删除redis中的入库任务状态记录");
log.info("入库完成时,删除redis中的入库任务状态记录");
redisTemplate.delete(RedisConstant.redisTaskIn);
}
@ -773,8 +762,6 @@ public class PlcEventTask {
return false;
}
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut);
if (taskOutId !=null ){
log.info("有出库任务在执行,无法下发入库任务:"+taskOutId);
@ -809,13 +796,6 @@ public class PlcEventTask {
String plcToLayer = "";
String toLayerValueType="";
String plcFromRow = "";
String fromRowValueType="";
String plcFromColumn = "";
String fromColumnValueType = "";
String plcFromLayer = "";
String fromLayerValueType="";
String plcPlatform="";
String plcPlatformValueType="";
@ -836,18 +816,6 @@ public class PlcEventTask {
if (stkProperty.getPointType().equals("101")) {
plcTaskId = stkProperty.getAddress();
taskIdvalueType = stkProperty.getValueType();
} else if (stkProperty.getPointType().equals("104")) {
plcFromRow = stkProperty.getAddress();
fromRowValueType = stkProperty.getValueType();
} else if (stkProperty.getPointType().equals("103")) {
plcPlatform = stkProperty.getAddress();
plcPlatformValueType = stkProperty.getValueType();
} else if (stkProperty.getPointType().equals("105")) {
plcFromColumn = stkProperty.getAddress();
fromColumnValueType=stkProperty.getValueType();
} else if (stkProperty.getPointType().equals("106")) {
plcFromLayer = stkProperty.getAddress();
fromLayerValueType=stkProperty.getValueType();
} else if (stkProperty.getPointType().equals("108")) {
plcToRow = stkProperty.getAddress();
toRowValueType = stkProperty.getValueType();
@ -939,15 +907,6 @@ public class PlcEventTask {
Map<String, Object> plcOrderTypeMap = new HashMap<>(1);
plcOrderTypeMap.put(plcOrderTypeValue, 1);
allMap.put(plcOrderType, plcOrderTypeMap);
/* Map<String, Object> plcFromRowMap = new HashMap<>(1);
plcFromRowMap.put(fromRowValueType, fromRow);
allMap.put(plcFromRow, plcFromRowMap);
Map<String, Object> plcFromColumnMap = new HashMap<>(1);
plcFromColumnMap.put(fromColumnValueType, fromColumn);
allMap.put(plcFromColumn, plcFromColumnMap);
Map<String, Object> plcFromLayerMap = new HashMap<>(1);
plcFromLayerMap.put(fromLayerValueType, fromLayer);
allMap.put(plcFromLayer, plcFromLayerMap);*/
//入库起始站台
Map<String, Object> plcPlatformMap = new HashMap<>(1);

@ -194,7 +194,7 @@ public class WcsPlcConnectServiceImpl extends ServiceImpl<WcsPlcConnectMapper, W
redisTemplate.opsForValue().set(RedisConstant.redisPlcConnect+wcsPlcConnectAdd.getId().toString(),wcsPlcConnectAdd);
}catch (Exception e){
log.error("修改plc连接属性失败");
log.error("修改plc连接属性失败"+e.getMessage());
return Result.err().msg("修改plc连接属性失败");
}

@ -124,9 +124,6 @@ public class RCSUtil {
.body(json)
.execute().body();
Result result = parseThirdRcsResult(res);
log.error("创建任务");
log.error(result.toString());
log.error(dto.toString());
return result;
} catch (Exception e) {
e.printStackTrace();

@ -79,10 +79,11 @@ public class StkCallUtil {
log.info("有出库任务在执行,无法下发出库任务:"+taskOutId);
return Result.err().msg("有出库任务在执行,无法下发出库任");
}
SysThirdExceptionRequest one = sysThirdExceptionRequestService.getOneByOrderNo(stkMoveBo.getTaskId().toString());
Long taskId = stkMoveBo.getTaskId();
SysThirdExceptionRequest one = sysThirdExceptionRequestService.getOneByOrderNo(taskId.toString());
if (one != null){
if (!one.getCode().equals(stkMoveBo.getTaskId().toString())){
log.error("有更早未执行的任务,排队执行:"+JsonUtil.toJSONString(one));
if (!one.getCode().equals(taskId.toString())){
log.info("有更早未执行的任务,排队执行:"+JsonUtil.toJSONString(one));
return Result.err().msg("有更早未执行的任务,排队执行");
}
}
@ -90,7 +91,7 @@ public class StkCallUtil {
String fromLayer = stkMoveBo.getFromLayer();
String fromColumn = stkMoveBo.getFromColumn();
String fromRow = stkMoveBo.getFromRow();
log.info(stkMoveBo.getTaskId()+"出库对应的排层列:"+fromRow+fromLayer+fromColumn);
log.info(taskId +"出库对应的排层列:"+fromRow+fromLayer+fromColumn);
//获取堆垛机
WcsPlcConnectQueryBo plcConnect = new WcsPlcConnectQueryBo();
plcConnect.setDevType("1");
@ -140,8 +141,8 @@ public class StkCallUtil {
twoDpsidleV = dpsPointMap.get(twoDpsidle).toString();
}
log.info("1楼是否允许出库::"+oneDpsidle+" 出库的值:"+oneDpsidleV);
log.info("2楼是否允许出库::"+twoDpsidle+" 出库的值:"+twoDpsidleV);
log.info(taskId+"1楼是否允许出库::"+oneDpsidle+" 出库的值:"+oneDpsidleV);
log.info(taskId+"2楼是否允许出库::"+twoDpsidle+" 出库的值:"+twoDpsidleV);
//出库的站台
Integer layer =stkMoveBo.getLayer();
if (layer==1){
@ -158,7 +159,7 @@ public class StkCallUtil {
return Result.err().msg(msg);
}
}else {
log.info("未匹配到楼层");
log.info("出库任务未匹配到楼层");
return Result.err().msg("未匹配到楼层,不允许出库");
}
@ -172,10 +173,6 @@ public class StkCallUtil {
String plcOrderType = "";
String plcOrderTypeValue = "";
//启动设备
String plcStartEq = "";
String plcStartEqValueType = "";
//堆垛机完成状态
String finishPoint="";
String finishPointVT="";
@ -202,16 +199,7 @@ public class StkCallUtil {
} else if (stkProperty.getPointType().equals("107")) {
plcPlatform = stkProperty.getAddress();
plcPlatformValueType = stkProperty.getValueType();
} else if (stkProperty.getPointType().equals("108")) {
plcToRow = stkProperty.getAddress();
toRowValueType = stkProperty.getValueType();
} else if (stkProperty.getPointType().equals("109")) {
plcToColumn = stkProperty.getAddress();
toColumnValueType = stkProperty.getValueType();
} else if (stkProperty.getPointType().equals("110")) {
plcToLayer = stkProperty.getAddress();
toLayerValueType = stkProperty.getValueType();
}else if (stkProperty.getPointType().equals("10")) {
} else if (stkProperty.getPointType().equals("10")) {
//等于1时堆垛机自动,等于0时堆垛机手动
stkAutoManual = stkProperty.getAddress();
}else if (stkProperty.getPointType().equals("11")) {
@ -226,10 +214,7 @@ public class StkCallUtil {
} else if (stkProperty.getPointType().equals("13")) {
//等于1时堆垛机已激活(运行)
stkRun = stkProperty.getAddress();
}else if (stkProperty.getPointType().equals(PlcPropertyEnum.twentythree.getValue())){
plcStartEq=stkProperty.getAddress();
plcStartEqValueType=stkProperty.getValueType();
}if (stkProperty.getPointType().equals("4")) {
}else if (stkProperty.getPointType().equals("4")) {
finishPoint = stkProperty.getAddress();
finishPointVT =stkProperty.getValueType();
}
@ -285,7 +270,7 @@ public class StkCallUtil {
//给堆垛机写命令
Map<String, Object> allMap = new HashMap<>(1);
Map<String, Object> plcTaskIdMap = new HashMap<>(1);
plcTaskIdMap.put(taskIdvalueType, stkMoveBo.getTaskId());
plcTaskIdMap.put(taskIdvalueType, taskId);
allMap.put(plcTaskId, plcTaskIdMap);
//出库目标站台
@ -313,7 +298,7 @@ public class StkCallUtil {
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite();
if ( plcReadAndWrite.execWrite(stkOperate, JsonUtil.toJSONString(allMap)) ){
redisTemplate.opsForValue().set(RedisConstant.redisTaskTime, DateUtils.getNowDate());
redisTemplate.opsForValue().set(RedisConstant.redisTaskOut,stkMoveBo.getTaskId());
redisTemplate.opsForValue().set(RedisConstant.redisTaskOut, taskId);
return Result.ok();
} else {
log.info("堆垛机下发命令失败:"+one.getTaskId());
@ -469,7 +454,7 @@ public class StkCallUtil {
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite();
Boolean boolWrite = plcReadAndWrite.execWrite(stkOperate, JsonUtil.toJSONString(allMap));
log.error("出库给堆垛机下发命令:"+boolWrite+"任务号:"+stkMoveBo.getTaskId());
log.info("出库给堆垛机下发命令:"+boolWrite+"任务号:"+stkMoveBo.getTaskId());
return boolWrite ? Result.ok() : Result.err();
}

@ -171,7 +171,7 @@ public class BaseAreaServiceImpl extends ServiceImpl<BaseAreaMapper, BaseArea> i
+ "-" + item.getAreaCode()
)).keySet();
if (listGroup.size() != list.size()) {
log.error("请求参数存在重复数据");
log.info("请求参数存在重复数据");
return Result.err().msg("请求参数存在重复数据");
}
@ -230,7 +230,7 @@ public class BaseAreaServiceImpl extends ServiceImpl<BaseAreaMapper, BaseArea> i
.eq(BaseArea::getIsDel, IsDelEnum.NORMAL.getValue());
BaseArea one = getOne(wrapper);
if (one != null && !id.equals(one.getId())) {
log.error("存在重复数据:" + entity.toString());
log.info("存在重复数据:" + entity.toString());
return Result.err().msg("存在重复数据");
}
return Result.ok();

@ -140,7 +140,7 @@ public class BaseBarcodesInServiceImpl extends ServiceImpl<BaseBarcodesInMapper,
Result<BaseConsignor> result = iBaseGoodsDataService.getErpConsignorId();
if (!Result.isOk(result)){
log.error(result.getMsg());
log.info(result.getMsg());
}
//获取仓库ID
BaseConsignor baseConsignor = result.getData();

@ -152,7 +152,7 @@ public class BaseMoldServiceImpl extends ServiceImpl<BaseMoldMapper, BaseMold> i
.eq(BaseMold::getIsDel, IsDelEnum.NORMAL.getValue());
BaseMold one = getOne(wrapper);
if (one != null && !id.equals(one.getId())) {
log.error("存在重复数据:" + entity.getMoldNo());
log.info("存在重复数据:" + entity.getMoldNo());
return Result.err().msg("存在重复数据");
}
return Result.ok();

@ -625,12 +625,12 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper,
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut);
Long orderNo = updList.get(0).getOrderNo();
if (taskOutId !=null && String.valueOf(taskOutId).equals(orderNo.toString())){
log.error("出库完成时判断redis中的数据是否还存在,存在则删除,删除redis中的出库任务状态记录:",orderNo);
log.info("出库完成时判断redis中的数据是否还存在,存在则删除,删除redis中的出库任务状态记录:",orderNo);
redisTemplate.delete(RedisConstant.redisTaskOut);
}
}catch (Exception e){
log.error("出库确认异常 手动回滚 {}", bos);
log.info("出库确认异常 手动回滚 {}", bos+e.getMessage());
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}finally {
lockTemplate.releaseLock(lockInfo);
@ -692,7 +692,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper,
//找库存
Result<SysStockDetailVo> voResult = sysStockDetailService.findOutLocation(outPlan);
if (!Result.isOk(voResult)) {
log.error("库存不够 手动回滚 {}", voResult);
log.info("库存不够 手动回滚 {}", voResult);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Result.err().msg(voResult.getMsg());
}

@ -176,7 +176,7 @@ public class SysStockServiceImpl extends ServiceImpl<SysStockMapper, SysStock> i
if (bo.getId() != null) {
SysStock one = getById(bo.getId());
if (one == null) {
log.error("库存信息不存在:" + bo.toString());
log.info("库存信息不存在:" + bo.toString());
return Result.err().msg("库存信息不存在");
}
}

Loading…
Cancel
Save