|
|
@@ -136,157 +136,175 @@ public class WmsAgvInfoServiceImpl extends SuperCacheServiceImpl<WmsAgvInfoMappe
|
|
|
*/
|
|
|
@Override
|
|
|
public R agvCallBack(ImcsRequestDto imcsRequestDto) {
|
|
|
+ R result=null;
|
|
|
+ try{
|
|
|
+ BaseContextHandler.setTenant("0000");
|
|
|
|
|
|
- BaseContextHandler.setTenant("0000");
|
|
|
- logAgvCallback(imcsRequestDto,null,true,null,0l);
|
|
|
- String taskNo = imcsRequestDto.getTaskNo();
|
|
|
+ String taskNo = imcsRequestDto.getTaskNo();
|
|
|
|
|
|
- List<WmsAgvInfo> wmsAgvInfos = baseMapper.selectList(Wraps.<WmsAgvInfo>lbQ().eq(WmsAgvInfo::getWmsId, imcsRequestDto.getWmsId()));
|
|
|
- if(CollectionUtil.isNotEmpty(wmsAgvInfos)){
|
|
|
- return R.fail(imcsRequestDto.getWmsId()+":重复回调");
|
|
|
- }
|
|
|
- List<WmsAgvInfo> wmsAgvInfoList = baseMapper.selectList(Wraps.<WmsAgvInfo>lbQ().eq(WmsAgvInfo::getTaskNo, taskNo));
|
|
|
- WmsAgvInfo item=new WmsAgvInfo();
|
|
|
- WmsAgvInfo wmsAgvInfo=new WmsAgvInfo();
|
|
|
- if(CollectionUtil.isEmpty(wmsAgvInfoList)){
|
|
|
- return R.fail("找不到相对应的任务编号");
|
|
|
- }else if(wmsAgvInfoList.size()==1){
|
|
|
- item = wmsAgvInfoList.get(0);
|
|
|
- wmsAgvInfo.setTaskNo(imcsRequestDto.getTaskNo());
|
|
|
- wmsAgvInfo.setTaskType(imcsRequestDto.getTaskType());
|
|
|
- }else if (wmsAgvInfoList.size() > 1){
|
|
|
- //表示已经暂时入库了,现在的回调是暂时入库的出库回调
|
|
|
- taskNo=taskNo.replace(BizWmsConstant.IN_BUFFER,BizWmsConstant.OUT_BUFFER);
|
|
|
- imcsRequestDto.setTaskType(BizWmsConstant.OUT_BUFFER);
|
|
|
- item = baseMapper.selectOne(Wraps.<WmsAgvInfo>lbQ().eq(WmsAgvInfo::getTaskNo, taskNo));
|
|
|
- wmsAgvInfo.setTaskNo(item.getTaskNo());
|
|
|
- wmsAgvInfo.setTaskType(item.getTaskType());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- item.setStatus(true);
|
|
|
- item.setStart(imcsRequestDto.getStart());
|
|
|
- item.setGoal(imcsRequestDto.getGoal());
|
|
|
- baseMapper.updateById(item);
|
|
|
-
|
|
|
-
|
|
|
- wmsAgvInfo.setWmsId(imcsRequestDto.getWmsId());
|
|
|
- wmsAgvInfo.setOrderId(item.getOrderId());
|
|
|
- wmsAgvInfo.setWmsTransferTaskId(item.getWmsTransferTaskId());
|
|
|
-
|
|
|
- wmsAgvInfo.setPriority(1);
|
|
|
- wmsAgvInfo.setStatus(true);
|
|
|
- wmsAgvInfo.setIsCallback(true);
|
|
|
- wmsAgvInfo.setWmsStart(imcsRequestDto.getStart());
|
|
|
- wmsAgvInfo.setWmsGoal(imcsRequestDto.getGoal());
|
|
|
- baseMapper.insert(wmsAgvInfo);
|
|
|
-
|
|
|
- //任务状态修改
|
|
|
- WmsTransferTask wmsTransferTask = wmsTransferTaskMapper.selectOne(Wraps.<WmsTransferTask>lbQ().eq(WmsTransferTask::getId, item.getWmsTransferTaskId()));
|
|
|
- int status = wmsTransferTask.getStatus().intValue();
|
|
|
-
|
|
|
- //查询本产品是否需要质检
|
|
|
- Boolean isQc = baseMapper.getIsQc(item.getOrderId());
|
|
|
- //任务状态(0:已发送 1:产线 2:三坐标 3:入库完成 4:暂时入库)
|
|
|
- if(isQc!=null && isQc){
|
|
|
- if(BizWmsConstant.OUT.equals(imcsRequestDto.getTaskType())
|
|
|
- ||BizWmsConstant.IN_QC.equals(imcsRequestDto.getTaskType())
|
|
|
- || BizWmsConstant.IN.equals(imcsRequestDto.getTaskType())){
|
|
|
- status+=1;
|
|
|
- }else if(BizWmsConstant.IN_BUFFER.equals(imcsRequestDto.getTaskType())){
|
|
|
- status=4;
|
|
|
- } else if (BizWmsConstant.OUT_BUFFER.equals(imcsRequestDto.getTaskType())) {
|
|
|
- status=2;
|
|
|
+ List<WmsAgvInfo> wmsAgvInfos = baseMapper.selectList(Wraps.<WmsAgvInfo>lbQ().eq(WmsAgvInfo::getWmsId, imcsRequestDto.getWmsId()));
|
|
|
+ if(CollectionUtil.isNotEmpty(wmsAgvInfos)){
|
|
|
+ return R.fail(imcsRequestDto.getWmsId()+":重复回调");
|
|
|
}
|
|
|
- }else{
|
|
|
- if(status==0){
|
|
|
- status+=1;
|
|
|
- }else if (status==1){
|
|
|
- status+=2;
|
|
|
+ List<WmsAgvInfo> wmsAgvInfoList = baseMapper.selectList(Wraps.<WmsAgvInfo>lbQ().eq(WmsAgvInfo::getTaskNo, taskNo));
|
|
|
+ WmsAgvInfo item=new WmsAgvInfo();
|
|
|
+ WmsAgvInfo wmsAgvInfo=new WmsAgvInfo();
|
|
|
+ if(CollectionUtil.isEmpty(wmsAgvInfoList)){
|
|
|
+ return R.fail("找不到相对应的任务编号");
|
|
|
+ }else if(wmsAgvInfoList.size()==1){
|
|
|
+ item = wmsAgvInfoList.get(0);
|
|
|
+ wmsAgvInfo.setTaskNo(imcsRequestDto.getTaskNo());
|
|
|
+ wmsAgvInfo.setTaskType(imcsRequestDto.getTaskType());
|
|
|
+ }else if (wmsAgvInfoList.size() > 1){
|
|
|
+ //表示已经暂时入库了,现在的回调是暂时入库的出库回调
|
|
|
+ taskNo=taskNo.replace(BizWmsConstant.IN_BUFFER,BizWmsConstant.OUT_BUFFER);
|
|
|
+ imcsRequestDto.setTaskType(BizWmsConstant.OUT_BUFFER);
|
|
|
+ item = baseMapper.selectOne(Wraps.<WmsAgvInfo>lbQ().eq(WmsAgvInfo::getTaskNo, taskNo));
|
|
|
+ wmsAgvInfo.setTaskNo(item.getTaskNo());
|
|
|
+ wmsAgvInfo.setTaskType(item.getTaskType());
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //正常流程走
|
|
|
- //如果等于4,表示从仓库中出到三坐标
|
|
|
- wmsTransferTask.setStatus(status);
|
|
|
- wmsTransferTaskMapper.updateById(wmsTransferTask);
|
|
|
- Storge endStorge = storgeMapper.selectOne(Wraps.<Storge>lbQ().eq(Storge::getPointId, imcsRequestDto.getGoal()));
|
|
|
-
|
|
|
- // 原始数据
|
|
|
- List<WmsAgvInfoDetail> materialCodeList = imcsRequestDto.getMaterialCodeList();
|
|
|
|
|
|
- //数据处理
|
|
|
- List<WmsAgvInfoDetail> normalize = AgvParamNormalizer.normalize(materialCodeList);
|
|
|
- //wmsAgvInfo.setMaterialCodeList(normalize);
|
|
|
+ item.setStatus(true);
|
|
|
+ item.setStart(imcsRequestDto.getStart());
|
|
|
+ item.setGoal(imcsRequestDto.getGoal());
|
|
|
+ baseMapper.updateById(item);
|
|
|
+
|
|
|
+
|
|
|
+ wmsAgvInfo.setWmsId(imcsRequestDto.getWmsId());
|
|
|
+ wmsAgvInfo.setOrderId(item.getOrderId());
|
|
|
+ wmsAgvInfo.setWmsTransferTaskId(item.getWmsTransferTaskId());
|
|
|
+
|
|
|
+ wmsAgvInfo.setPriority(1);
|
|
|
+ wmsAgvInfo.setStatus(true);
|
|
|
+ wmsAgvInfo.setIsCallback(true);
|
|
|
+ wmsAgvInfo.setWmsStart(imcsRequestDto.getStart());
|
|
|
+ wmsAgvInfo.setWmsGoal(imcsRequestDto.getGoal());
|
|
|
+ baseMapper.insert(wmsAgvInfo);
|
|
|
+
|
|
|
+ //任务状态修改
|
|
|
+ WmsTransferTask wmsTransferTask = wmsTransferTaskMapper.selectOne(Wraps.<WmsTransferTask>lbQ().eq(WmsTransferTask::getId, item.getWmsTransferTaskId()));
|
|
|
+ int status = wmsTransferTask.getStatus().intValue();
|
|
|
+
|
|
|
+ //查询本产品是否需要质检
|
|
|
+ Boolean isQc = baseMapper.getIsQc(wmsTransferTask.getPlanProductId());
|
|
|
+ //任务状态(0:已发送 1:产线 2:三坐标 3:入库完成 4:暂时入库)
|
|
|
+ if(isQc!=null && isQc){
|
|
|
+ if(BizWmsConstant.OUT.equals(imcsRequestDto.getTaskType())
|
|
|
+ ||BizWmsConstant.IN_QC.equals(imcsRequestDto.getTaskType())
|
|
|
+ || BizWmsConstant.IN.equals(imcsRequestDto.getTaskType())){
|
|
|
+ status+=1;
|
|
|
+ }else if(BizWmsConstant.IN_BUFFER.equals(imcsRequestDto.getTaskType())){
|
|
|
+ status=4;
|
|
|
+ } else if (BizWmsConstant.OUT_BUFFER.equals(imcsRequestDto.getTaskType())) {
|
|
|
+ status=2;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(status==0){
|
|
|
+ status+=1;
|
|
|
+ }else if (status==1){
|
|
|
+ status+=2;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- List<StockInfo> stockInfoList=new ArrayList<>();
|
|
|
+ //正常流程走
|
|
|
+ //如果等于4,表示从仓库中出到三坐标
|
|
|
+ wmsTransferTask.setStatus(status);
|
|
|
+ wmsTransferTaskMapper.updateById(wmsTransferTask);
|
|
|
+ Storge endStorge = storgeMapper.selectOne(Wraps.<Storge>lbQ().eq(Storge::getPointId, imcsRequestDto.getGoal()));
|
|
|
+
|
|
|
+ // 原始数据
|
|
|
+ List<WmsAgvInfoDetail> materialCodeList = imcsRequestDto.getMaterialCodeList();
|
|
|
+
|
|
|
+ //数据处理
|
|
|
+ List<WmsAgvInfoDetail> normalize = AgvParamNormalizer.normalize(materialCodeList);
|
|
|
+
|
|
|
+ List<StockInfo> stockInfoList=new ArrayList<>();
|
|
|
+
|
|
|
+ normalize.stream().forEach(vo->{
|
|
|
+
|
|
|
+ //MMeterial mMeterial = mMeterialMapper.selectOne(Wraps.<MMeterial>lbQ().eq(MMeterial::getMeterialCode,vo.getMaterialCode()));
|
|
|
+ //查视图
|
|
|
+ ViewStockGoods goodsByMaterialCode = stockInfoMapper.getGoodsByMaterialCode(vo.getMaterialCode());
|
|
|
+ if(goodsByMaterialCode == null){
|
|
|
+ throw new BizException(vo.getMaterialCode()+"无法识别");
|
|
|
+ }
|
|
|
+ vo.setMeterialId(goodsByMaterialCode.getId());
|
|
|
+ vo.setWmsAgvInfoId(wmsAgvInfo.getId());
|
|
|
+ vo.setGoodsType(goodsByMaterialCode.getCategory());
|
|
|
+ //终点入库
|
|
|
+ if(endStorge!=null){
|
|
|
+ StockInfo stockInfo=new StockInfo();
|
|
|
+ stockInfo.setStorgeId(endStorge.getId());
|
|
|
+ stockInfo.setLockStatus("1");
|
|
|
+ stockInfo.setGoodsId(goodsByMaterialCode.getId());
|
|
|
+ stockInfo.setGoodsType(goodsByMaterialCode.getCategory());
|
|
|
+ stockInfo.setNum(vo.getQty());
|
|
|
+ String no = codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_UNIQUE);
|
|
|
+ stockInfo.setUniqueCode(no);
|
|
|
+ stockInfoList.add(stockInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ if(CollectionUtil.isNotEmpty(normalize)){
|
|
|
+ wmsAgvInfoDetailMapper.insertBatchSomeColumn(normalize);
|
|
|
+ }
|
|
|
|
|
|
- /*materialCodeList.stream().forEach(vo->{
|
|
|
- ViewStockGoods goodsByMaterialCode = stockInfoMapper.getGoodsByMaterialCode(vo.getMaterialCode());
|
|
|
- vo.setMeterialId(goodsByMaterialCode.getId());
|
|
|
- vo.setWmsAgvInfoId(wmsAgvInfo.getId());
|
|
|
- });*/
|
|
|
+ if(CollectionUtil.isNotEmpty(stockInfoList)){
|
|
|
+ //料箱中的材料(工装、材料) 入库
|
|
|
+ stockInfoMapper.insertBatchSomeColumn(stockInfoList);
|
|
|
+ }
|
|
|
|
|
|
- normalize.stream().forEach(vo->{
|
|
|
|
|
|
- //MMeterial mMeterial = mMeterialMapper.selectOne(Wraps.<MMeterial>lbQ().eq(MMeterial::getMeterialCode,vo.getMaterialCode()));
|
|
|
- //查视图
|
|
|
- ViewStockGoods goodsByMaterialCode = stockInfoMapper.getGoodsByMaterialCode(vo.getMaterialCode());
|
|
|
- if(goodsByMaterialCode == null){
|
|
|
- throw new BizException(vo.getMaterialCode()+"无法识别");
|
|
|
- }
|
|
|
- vo.setMeterialId(goodsByMaterialCode.getId());
|
|
|
- vo.setWmsAgvInfoId(wmsAgvInfo.getId());
|
|
|
- vo.setGoodsType(goodsByMaterialCode.getCategory());
|
|
|
- //终点入库
|
|
|
if(endStorge!=null){
|
|
|
- StockInfo stockInfo=new StockInfo();
|
|
|
- stockInfo.setStorgeId(endStorge.getId());
|
|
|
- stockInfo.setLockStatus("1");
|
|
|
- stockInfo.setGoodsId(goodsByMaterialCode.getId());
|
|
|
- stockInfo.setGoodsType(goodsByMaterialCode.getCategory());
|
|
|
- stockInfo.setNum(vo.getQty());
|
|
|
- String no = codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_UNIQUE);
|
|
|
- stockInfo.setUniqueCode(no);
|
|
|
- stockInfoList.add(stockInfo);
|
|
|
+ endStorge.setTaskNo(taskNo);
|
|
|
+ endStorge.setLockStatus("1");
|
|
|
+ //终点解锁
|
|
|
+ storgeMapper.updateById(endStorge);
|
|
|
}
|
|
|
|
|
|
- });
|
|
|
|
|
|
- if(CollectionUtil.isNotEmpty(normalize)){
|
|
|
- wmsAgvInfoDetailMapper.insertBatchSomeColumn(normalize);
|
|
|
- }
|
|
|
|
|
|
- if(CollectionUtil.isNotEmpty(stockInfoList)){
|
|
|
- //料箱中的材料(工装、材料) 入库
|
|
|
- stockInfoMapper.insertBatchSomeColumn(stockInfoList);
|
|
|
- }
|
|
|
+ //imcs管理6个库位
|
|
|
+ // 加工中心 201 202
|
|
|
+ //车削 203 204
|
|
|
+ //三坐标 205 206
|
|
|
+ //起点库位出库并解锁,如果查不到就不管了
|
|
|
+ Storge startStorge = storgeMapper.selectOne(Wraps.<Storge>lbQ().eq(Storge::getPointId, imcsRequestDto.getStart()));
|
|
|
+ //交换库存信息
|
|
|
+ changeStockInfo(startStorge,endStorge);
|
|
|
|
|
|
+ if (startStorge!=null){
|
|
|
|
|
|
- if(endStorge!=null){
|
|
|
- endStorge.setTaskNo(null);
|
|
|
- endStorge.setLockStatus("1");
|
|
|
- //终点解锁
|
|
|
- storgeMapper.updateById(endStorge);
|
|
|
+ startStorge.setLockStatus("1");
|
|
|
+ startStorge.setTaskNo(null);
|
|
|
+ storgeMapper.updateById(startStorge);
|
|
|
+ }
|
|
|
|
|
|
+ setAutoNode(wmsAgvInfoList.get(0),imcsRequestDto,endStorge);
|
|
|
+ result=R.success();
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("回调异常:",e);
|
|
|
+ result = R.fail("回调失败: " + e.getMessage());
|
|
|
+ throw new RuntimeException("回调失败: " , e);
|
|
|
+ }finally {
|
|
|
+ logAgvCallback(imcsRequestDto, JSON.toJSONString(result), false, null, 0l);
|
|
|
}
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
|
|
|
- //imcs管理6个库位
|
|
|
- // 加工中心 201 202
|
|
|
- //车削 203 204
|
|
|
- //三坐标 205 206
|
|
|
- //起点库位出库并解锁,如果查不到就不管了
|
|
|
- Storge startStorge = storgeMapper.selectOne(Wraps.<Storge>lbQ().eq(Storge::getPointId, imcsRequestDto.getStart()));
|
|
|
- if (startStorge!=null){
|
|
|
+ private void changeStockInfo(Storge startStorge, Storge endStorge) {
|
|
|
+ if(startStorge!=null && endStorge!=null){
|
|
|
+ List<StockInfo> stockInfoList = stockInfoMapper.selectList(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId, startStorge.getId()));
|
|
|
+ stockInfoList.forEach(vo->{
|
|
|
+ vo.setStorgeId(endStorge.getId());
|
|
|
+ stockInfoMapper.updateById(vo);
|
|
|
+ });
|
|
|
+ }else if(startStorge!=null && endStorge==null){
|
|
|
stockInfoMapper.delete(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId,startStorge.getId()));
|
|
|
- startStorge.setLockStatus("1");
|
|
|
- startStorge.setTaskNo(null);
|
|
|
- storgeMapper.updateById(startStorge);
|
|
|
}
|
|
|
|
|
|
- setAutoNode(wmsAgvInfoList.get(0),imcsRequestDto,endStorge);
|
|
|
-
|
|
|
- return R.success();
|
|
|
}
|
|
|
|
|
|
private void setAutoNode(WmsAgvInfo wmsAgvInfo, ImcsRequestDto imcsRequestDto,Storge endStorge) {
|