|
|
@@ -2,6 +2,7 @@ package com.github.zuihou.business.operationManagementCenter.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@@ -10,18 +11,18 @@ import com.github.zuihou.base.service.SuperServiceImpl;
|
|
|
import com.github.zuihou.business.DemoLine.DemoCacheKey;
|
|
|
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.Storge;
|
|
|
import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
|
|
|
import com.github.zuihou.business.edgeLibrary.service.StorgeService;
|
|
|
+import com.github.zuihou.business.externalApi.dto.ManualInfo;
|
|
|
import com.github.zuihou.business.mq.TaskWorkNode;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dao.*;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dto.TaskNodeCallBackDTO;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.*;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.*;
|
|
|
-import com.github.zuihou.business.productionReadyCenter.dao.AAutoNodeLogMapper;
|
|
|
-import com.github.zuihou.business.productionReadyCenter.dao.AutoNodeMapper;
|
|
|
-import com.github.zuihou.business.productionReadyCenter.dao.BBomMapper;
|
|
|
+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;
|
|
|
@@ -32,6 +33,7 @@ import com.github.zuihou.business.productionResourceCenter.service.ResourceAutoC
|
|
|
import com.github.zuihou.business.productionResourceCenter.service.ResourceBusinessService;
|
|
|
import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
|
|
|
import com.github.zuihou.business.util.DynamicRabbitMq;
|
|
|
+import com.github.zuihou.business.util.ManualTaskOperatorUtil;
|
|
|
import com.github.zuihou.business.util.MsgUtil;
|
|
|
import com.github.zuihou.common.constant.BizConstant;
|
|
|
import com.github.zuihou.common.constant.CacheKey;
|
|
|
@@ -51,8 +53,13 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.NumberFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
@@ -162,6 +169,9 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
|
|
|
@Autowired
|
|
|
private MsgUtil msgUtil;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RestTemplate restTemplate;
|
|
|
+
|
|
|
//总控IP
|
|
|
private String ZK_ip = "192.168.1.41";
|
|
|
|
|
|
@@ -188,6 +198,12 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
|
|
|
|
|
|
@Autowired
|
|
|
private ZZoneService zoneService;
|
|
|
+ @Autowired
|
|
|
+ private StockLogMapper stockLogMapper;
|
|
|
+ @Autowired
|
|
|
+ private TrayMapper trayMapper;
|
|
|
+ @Autowired
|
|
|
+ private MToolClampMapper mToolClampMapper;
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(TaskNodeServiceImpl.class);
|
|
|
|
|
|
@@ -537,6 +553,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
//下料直接操作结束
|
|
|
if (BizConstant.TASK_NODE_MANUALNODE_CUTTING.equals(taskNode.getAutoNodeCode())) {
|
|
|
+
|
|
|
//下料,需要手动把物料放到接驳位B
|
|
|
Storge sxlzstorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo());
|
|
|
jsonObject.put("srcPosition", sxlzstorge.getId());
|
|
|
@@ -552,6 +569,13 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
|
|
|
this.taskNodeCallbackBiz(taskNode, task, taskNodeList, lg, jsonObject.toJSONString());
|
|
|
return taskNode;
|
|
|
} else {//上料
|
|
|
+
|
|
|
+ // TODO 调用CCS读取写入rfid信息
|
|
|
+ // 拼接写入rfid的信息
|
|
|
+ // 当前托盘的id
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
Storge jbwFromStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo());
|
|
|
//2、取出上下料站
|
|
|
Storge sxlzstorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.SXLZ + taskNode.getId());
|
|
|
@@ -1545,64 +1569,73 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
|
|
|
* @param callBackJson
|
|
|
* @return
|
|
|
*/
|
|
|
+ @Override
|
|
|
public R<String> handModeStock(JSONObject callBackJson) {
|
|
|
- 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));
|
|
|
+ String manualId = callBackJson.getString("taskId");
|
|
|
+ String taskInfos = msgUtil.redis_get(manualId).toString();
|
|
|
+ JSONObject taskInfosObject = JSONObject.parseObject(taskInfos);
|
|
|
+ List<String> taskNodes = JSONArray.parseArray(taskInfosObject.getString("taskNodes"),String.class);
|
|
|
+ ManualInfo manualInfo = JSONObject.parseObject(taskInfosObject.getString("taskInfo"),ManualInfo.class);
|
|
|
|
|
|
- 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(manualInfo.getNextTaskNodeIndex() > taskNodes.size() -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());
|
|
|
}
|
|
|
+ }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"));
|
|
|
}
|
|
|
- if (!result.getIsSuccess()) {
|
|
|
- break;
|
|
|
- }
|
|
|
+ return R.success(returnDataObject.getString("msg"));
|
|
|
}
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public R<String> handModeStockOut(Map conMap) {
|
|
|
- String pointId = conMap.get("pointId")==null?"":conMap.get("pointId").toString();
|
|
|
- String category = conMap.get("category")==null?"":conMap.get("category").toString();
|
|
|
- String goodsId = conMap.get("goodsId")==null?"":conMap.get("goodsId").toString();
|
|
|
- Map queryMap = new HashMap();
|
|
|
- queryMap.put("pointId", pointId);
|
|
|
- List<ProductionresourcePosition> list = productionresourcePositionMapper.getPPList(queryMap);
|
|
|
-
|
|
|
- R<String> result = R.success("");
|
|
|
|
|
|
+// 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))
|
|
|
@@ -1612,46 +1645,85 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
|
|
|
// 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());
|
|
|
-// result = stockInfoService.meterialStockOut(meterial, p.getStorgeId(), "");
|
|
|
+// 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;
|
|
|
- }
|
|
|
+// return result;
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
- public R<String> handModeStockIn(Map conMap) {
|
|
|
- String pointId = conMap.get("pointId")==null?"":conMap.get("pointId").toString();
|
|
|
- String category = conMap.get("category")==null?"":conMap.get("category").toString();
|
|
|
- String goodsId = conMap.get("goodsId")==null?"":conMap.get("goodsId").toString();
|
|
|
+ public R handModeStockOut(Map conMap) {
|
|
|
+ String resourceId = conMap.get("resourceId").toString();
|
|
|
+ String pointId = conMap.get("pointId").toString();
|
|
|
+ String category = conMap.get("category").toString();
|
|
|
+ String goodsId = conMap.get("goodsId").toString();
|
|
|
Map queryMap = new HashMap();
|
|
|
queryMap.put("pointId", pointId);
|
|
|
- List<ProductionresourcePosition> list = productionresourcePositionMapper.getPPList(queryMap);
|
|
|
+ queryMap.put("resourceId", resourceId);
|
|
|
+ List<ProductionresourcePosition> list = productionresourcePositionMapper.getStorgeIdByResource(queryMap);
|
|
|
+ R result = R.success();
|
|
|
+ ProductionresourcePosition productionresourcePosition = list.get(0);
|
|
|
+ return stockInfoService.manualStockOut(goodsId, productionresourcePosition.getStorgeId());
|
|
|
+ }
|
|
|
|
|
|
- R<String> result = R.success("");
|
|
|
|
|
|
- for(ProductionresourcePosition p:list){
|
|
|
+ @Override
|
|
|
+ public R handModeStockIn(Map conMap) {
|
|
|
+ String pointId = conMap.get("pointId").toString();
|
|
|
+ String category = conMap.get("category").toString();
|
|
|
+ String goodsId = conMap.get("goodsId").toString();
|
|
|
+ String resourceId = conMap.get("resourceId").toString();
|
|
|
|
|
|
+ Map queryMap = new HashMap();
|
|
|
+ queryMap.put("pointId", pointId);
|
|
|
+ queryMap.put("resourceId", resourceId);
|
|
|
+ queryMap.put("goodsId", goodsId);
|
|
|
+ queryMap.put("type", BizConstant.STOCK_TYPE_IN);
|
|
|
+
|
|
|
+ List<ProductionresourcePosition> list = productionresourcePositionMapper.getStorgeIdByResource(queryMap);
|
|
|
+ R result = R.success();
|
|
|
+ for(ProductionresourcePosition p:list){
|
|
|
if("1".equals(category)){//托盘夹具
|
|
|
- Tray tray = new Tray();
|
|
|
- tray.setId(Long.parseLong(goodsId));
|
|
|
- result = stockInfoService.procedureTrayStockIn(tray, list.get(0).getStorgeId());
|
|
|
+ // 查询当前子盘夹具使用的数量,根据出入库日志查询当前的子盘夹具最大数量和库存数量进行比较进行累加
|
|
|
+ Tray tray = trayMapper.selectById(goodsId);
|
|
|
+ int maxTrayNo = stockLogMapper.selectMaxNoByProductId(queryMap);
|
|
|
+ int sumTray = stockInfoMapper.selectSumInStockByProductId(queryMap);
|
|
|
+ BigDecimal uniqueCode;
|
|
|
+ if(sumTray < tray.getNum()){
|
|
|
+ uniqueCode = BigDecimal.valueOf(maxTrayNo).add(new BigDecimal(1));
|
|
|
+ }else{
|
|
|
+ return R.fail("当前托盘数量已用完");
|
|
|
+ }
|
|
|
+ result = stockInfoService.procedureTrayStockIn(uniqueCode, Long.valueOf(goodsId), list.get(0).getStorgeId());
|
|
|
}else if("2".equals(p.getCategory())){
|
|
|
- MToolClamp clamp = new MToolClamp();
|
|
|
- clamp.setId(Long.parseLong(goodsId));
|
|
|
- result = stockInfoService.procedureToolClampStockIn(clamp, list.get(0).getStorgeId());
|
|
|
- }
|
|
|
-
|
|
|
- if (!result.getIsSuccess()) {
|
|
|
- break;
|
|
|
+ // 查询当前子盘夹具使用的数量,根据出入库日志查询当前的子盘夹具最大数量和库存数量进行比较进行累加
|
|
|
+ MToolClamp mToolClamp = mToolClampMapper.selectById(goodsId);
|
|
|
+ int maxMToolClampNo = stockLogMapper.selectMaxNoByProductId(queryMap);
|
|
|
+ int sumMToolClamp = stockInfoMapper.selectSumInStockByProductId(queryMap);
|
|
|
+ BigDecimal uniqueCode;
|
|
|
+ if(sumMToolClamp < mToolClamp.getNum()){
|
|
|
+ uniqueCode = BigDecimal.valueOf(maxMToolClampNo).add(new BigDecimal(1));;
|
|
|
+ }else{
|
|
|
+ return R.fail("当前夹具数量已用完");
|
|
|
+ }
|
|
|
+ result = stockInfoService.procedureToolClampStockIn(uniqueCode, Long.valueOf(goodsId), list.get(0).getStorgeId());
|
|
|
}
|
|
|
}
|
|
|
return result;
|