|
|
@@ -13,6 +13,7 @@ import com.github.zuihou.business.DemoLine.DemoLineConstant;
|
|
|
import com.github.zuihou.business.edgeLibrary.dao.StockInfoMapper;
|
|
|
import com.github.zuihou.business.edgeLibrary.dao.StockLogMapper;
|
|
|
import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
|
|
|
+import com.github.zuihou.business.edgeLibrary.entity.StockLog;
|
|
|
import com.github.zuihou.business.edgeLibrary.entity.Storge;
|
|
|
import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
|
|
|
import com.github.zuihou.business.edgeLibrary.service.StorgeService;
|
|
|
@@ -26,6 +27,7 @@ import com.github.zuihou.business.productionReadyCenter.dao.*;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.*;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.*;
|
|
|
import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourceConf;
|
|
|
import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
|
|
|
import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
|
|
|
import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
|
|
|
@@ -1582,98 +1584,75 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
|
|
|
JSONObject taskInfosObject = JSONObject.parseObject(taskInfos);
|
|
|
List<String> taskNodes = JSONArray.parseArray(taskInfosObject.getString("taskNodes"),String.class);
|
|
|
ManualInfo manualInfo = JSONObject.parseObject(taskInfosObject.getString("taskInfo"),ManualInfo.class);
|
|
|
-
|
|
|
- if(manualInfo.getNextTaskNodeIndex() == -1
|
|
|
- || (manualInfo.getNextTaskNodeIndex() != -1 && manualInfo.getNextTaskNodeIndex() > taskNodes.size() -1)){
|
|
|
- // 只有机器人需要记录库位信息变化,设备序工件本身在设备上无需更新库位信息
|
|
|
-
|
|
|
-
|
|
|
+ // 动作指令,完成直接返回成功
|
|
|
+ if(manualInfo.getNextTaskNodeIndex() == -1){
|
|
|
return R.success();
|
|
|
}else{
|
|
|
- // 继续执行后续结点
|
|
|
- Map<String,Object> processInfo = ManualTaskOperatorUtil.judgeProcessInfo((LinkedList<String>) taskNodes,manualInfo);
|
|
|
- JSONObject returnDataObject = new JSONObject();
|
|
|
-
|
|
|
- // 组装参数
|
|
|
- String returnData = "";
|
|
|
- //组装接口参数
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
|
|
|
-
|
|
|
- //回调参数构建
|
|
|
- String jsonParam = ManualTaskOperatorUtil.getRequestParam(processInfo.get("location").toString(),manualInfo,processInfo.get("deviceUrl").toString(),processInfo.get("devicePort").toString());
|
|
|
-
|
|
|
- HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
|
|
|
- //调用接口
|
|
|
- try {
|
|
|
- returnData = restTemplate.postForObject(processInfo.get("hostSyetemTaskUrl").toString(), formEntity, String.class);
|
|
|
- returnDataObject = JSONObject.parseObject(returnData);
|
|
|
- if("true".equals(returnDataObject.get("result"))){
|
|
|
- // 放入redis,方便回调的时候判断是否是最后一个结点,如果是最后一个结点不在做任何逻辑,更新相应的库位信息
|
|
|
- Map<String, Object> currentTask = new HashMap<String, Object>();
|
|
|
- List<String> remindTaskNodes = (List<String>) processInfo.get("remindTaskNodes");
|
|
|
- currentTask.put("taskNodes",remindTaskNodes);
|
|
|
- currentTask.put("taskInfo",manualInfo);
|
|
|
- JSONObject redisTask = new JSONObject();
|
|
|
- redisTask.putAll(currentTask);
|
|
|
- msgUtil.redis_set(manualInfo.getManualId(),redisTask.toJSONString());
|
|
|
+ if(manualInfo.getNextTaskNodeIndex() > taskNodes.size() -1){
|
|
|
+ Map queryMap = new HashMap();
|
|
|
+ queryMap.put("pointId", manualInfo.getStartoperation());
|
|
|
+ queryMap.put("resourceId", manualInfo.getStartResourceId());
|
|
|
+
|
|
|
+ List<ProductionresourcePosition> sourceList = productionresourcePositionMapper.getStorgeIdByResource(queryMap);
|
|
|
+
|
|
|
+ queryMap.clear();
|
|
|
+ queryMap.put("pointId", manualInfo.getEndoperation());
|
|
|
+ queryMap.put("resourceId", manualInfo.getEndResourceId());
|
|
|
+ List<ProductionresourcePosition> targetList = productionresourcePositionMapper.getStorgeIdByResource(queryMap);
|
|
|
+
|
|
|
+ // 先将原库位上所有物料信息读取出来
|
|
|
+ List<StockInfo> stockInfos = stockInfoMapper.selectList(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId, sourceList.get(0).getStorgeId()));
|
|
|
+
|
|
|
+ for(StockInfo stockInfo : stockInfos){
|
|
|
+ // 更新出库信息
|
|
|
+ saveStockLog(stockInfo,BizConstant.STOCK_TYPE_OUT);
|
|
|
+ // 更新入库信息
|
|
|
+ stockInfo.setStorgeId(targetList.get(0).getStorgeId());
|
|
|
+ saveStockLog(stockInfo,BizConstant.STOCK_TYPE_IN);
|
|
|
+ // 更新库位物料信息
|
|
|
+ stockInfoMapper.updateById(stockInfo);
|
|
|
+ }
|
|
|
+ return R.success();
|
|
|
+ }else{
|
|
|
+ // 继续执行后续结点
|
|
|
+ Map<String,Object> processInfo = ManualTaskOperatorUtil.judgeProcessInfo((LinkedList<String>) taskNodes,manualInfo);
|
|
|
+ JSONObject returnDataObject = new JSONObject();
|
|
|
+
|
|
|
+ // 组装参数
|
|
|
+ String returnData = "";
|
|
|
+ //组装接口参数
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
|
|
|
+
|
|
|
+ //回调参数构建
|
|
|
+ String jsonParam = ManualTaskOperatorUtil.getRequestParam(processInfo.get("location").toString(),manualInfo,processInfo.get("deviceUrl").toString(),processInfo.get("devicePort").toString());
|
|
|
+
|
|
|
+ HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
|
|
|
+ //调用接口
|
|
|
+ try {
|
|
|
+ returnData = restTemplate.postForObject(processInfo.get("hostSyetemTaskUrl").toString(), formEntity, String.class);
|
|
|
+ returnDataObject = JSONObject.parseObject(returnData);
|
|
|
+ if("true".equals(returnDataObject.get("result"))){
|
|
|
+ // 放入redis,方便回调的时候判断是否是最后一个结点,如果是最后一个结点不在做任何逻辑,更新相应的库位信息
|
|
|
+ Map<String, Object> currentTask = new HashMap<String, Object>();
|
|
|
+ List<String> remindTaskNodes = (List<String>) processInfo.get("remindTaskNodes");
|
|
|
+ currentTask.put("taskNodes",remindTaskNodes);
|
|
|
+ currentTask.put("taskInfo",manualInfo);
|
|
|
+ JSONObject redisTask = new JSONObject();
|
|
|
+ redisTask.putAll(currentTask);
|
|
|
+ msgUtil.redis_set(manualInfo.getManualId(),redisTask.toJSONString());
|
|
|
+ }
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ JSONObject errJsonObject = new JSONObject();
|
|
|
+ errJsonObject.put("msg", e.getMessage());
|
|
|
+ returnData = errJsonObject.toJSONString();
|
|
|
+ log.error("调用接口发生异常" + e.getMessage());
|
|
|
+ return R.fail(returnDataObject.getString("msg"));
|
|
|
}
|
|
|
- }catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- JSONObject errJsonObject = new JSONObject();
|
|
|
- errJsonObject.put("msg", e.getMessage());
|
|
|
- returnData = errJsonObject.toJSONString();
|
|
|
- log.error("调用接口发生异常" + e.getMessage());
|
|
|
- return R.fail(returnDataObject.getString("msg"));
|
|
|
+ return R.success(returnDataObject.getString("msg"));
|
|
|
}
|
|
|
- return R.success(returnDataObject.getString("msg"));
|
|
|
}
|
|
|
-
|
|
|
-// String srcStorgeId = callBackJson.getString("srcPosition");
|
|
|
-// String targetStorgeId = callBackJson.getString("targetPostion");
|
|
|
-// String goodsId = callBackJson.getString("goodsId");
|
|
|
-// Map queryMap = new HashMap();
|
|
|
-// queryMap.put("pointId", srcStorgeId);
|
|
|
-// List<ProductionresourcePosition> list = productionresourcePositionMapper.getPPList(queryMap);
|
|
|
-//
|
|
|
-// List<ProductionresourcePosition> targetlist = productionresourcePositionMapper.selectList(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getPointId, targetStorgeId));
|
|
|
-//
|
|
|
-// R<String> result = R.success("");;
|
|
|
-//
|
|
|
-// if(CollectionUtil.isEmpty(targetlist))
|
|
|
-// return result;
|
|
|
-//
|
|
|
-//
|
|
|
-// for(ProductionresourcePosition p:list){
|
|
|
-// String stockGoodsId = p.getGoodsId()==null?"":p.getGoodsId().toString();
|
|
|
-// if(!goodsId.equals(stockGoodsId))
|
|
|
-// continue;
|
|
|
-//
|
|
|
-// if("1".equals(p.getCategory())||"2".equals(p.getCategory())){//托盘夹具
|
|
|
-// BomProcedureTray tray = new BomProcedureTray();
|
|
|
-// tray.setTrayId(p.getGoodsId());
|
|
|
-// result = stockInfoService.procedureTrayStockOut(tray, p.getStorgeId());
|
|
|
-// if (result.getIsSuccess()) {
|
|
|
-// result = stockInfoService.procedureTrayStockIn(tray, targetlist.get(0).getStorgeId(), result.getData(), "");
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if("4".equals(p.getCategory())){//原材料
|
|
|
-// BomProcedureMeterial meterial = new BomProcedureMeterial();
|
|
|
-// meterial.setMeterialId(p.getGoodsId());
|
|
|
-// R<String> ckresult = stockInfoService.meterialStockOut(meterial, p.getStorgeId(), "");
|
|
|
-// R<String> rkresult = null;
|
|
|
-// if (ckresult.getIsSuccess()) {
|
|
|
-// rkresult = stockInfoService.meterialStockIn(meterial, targetlist.get(0).getStorgeId(), ckresult.getData(),"");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (!result.getIsSuccess()) {
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return result;
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1762,4 +1741,21 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
|
|
|
baseMapper.delete(taskNodeWrapper);
|
|
|
}
|
|
|
|
|
|
+ public StockLog saveStockLog(StockInfo stockBean, String type) {
|
|
|
+ StockLog logBean = new StockLog();
|
|
|
+ String no = codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_STOCKLOG);
|
|
|
+ logBean.setNo(no);
|
|
|
+ logBean.setUniqueCode(stockBean.getUniqueCode());
|
|
|
+ logBean.setStorgeId(stockBean.getStorgeId());
|
|
|
+ logBean.setNum(stockBean.getNum());
|
|
|
+ logBean.setGoodsId(stockBean.getGoodsId());
|
|
|
+ logBean.setGoodsType(stockBean.getGoodsType());
|
|
|
+ logBean.setTurnTaskNo(stockBean.getTurnTaskNo());
|
|
|
+ logBean.setOptType(type);
|
|
|
+ logBean.setFeedTaskNo(stockBean.getFeedTaskNo());
|
|
|
+ logBean.setSpecId(stockBean.getSpecId());
|
|
|
+ stockLogMapper.insert(logBean);
|
|
|
+ return logBean;
|
|
|
+ }
|
|
|
+
|
|
|
}
|