|
@@ -13,8 +13,10 @@ import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
|
|
|
import com.github.zuihou.business.edgeLibrary.entity.Storge;
|
|
|
import com.github.zuihou.business.externalApi.dto.ManualInfo;
|
|
|
import com.github.zuihou.business.mq.HandModeWorkNode;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.dao.PlanMapper;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dao.TTaskMapper;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dao.WorkpieceMapper;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.Plan;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.TTask;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
|
|
@@ -40,6 +42,7 @@ 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.DictionaryKey;
|
|
|
+import com.github.zuihou.common.util.DateUtil;
|
|
|
import com.github.zuihou.common.util.StringUtil;
|
|
|
import com.github.zuihou.context.BaseContextHandler;
|
|
|
import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
@@ -55,10 +58,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static java.util.stream.Collectors.groupingBy;
|
|
@@ -120,6 +120,8 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
|
|
|
private BBomMapper bBomMapper;
|
|
|
@Autowired
|
|
|
private DynamicRabbitMq dynamicRabbitMq;
|
|
|
+ @Autowired
|
|
|
+ private PlanMapper planMapper;
|
|
|
|
|
|
private static ArrayList<String> robotTaskNodes = new ArrayList<>();
|
|
|
static {
|
|
@@ -200,30 +202,61 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
|
|
|
@Override
|
|
|
public List getOrderInfo() {
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
- List<Map>returnList = new ArrayList<Map>();
|
|
|
- List<TWorkpiece> list = baseMapper.selectList(Wraps.<TWorkpiece>lbQ().eq(TWorkpiece::getProduceStatus,"1"));
|
|
|
+ List<Map> returnList = new ArrayList<Map>();
|
|
|
+ // 查找执行中计划
|
|
|
+ List<String> planStatus = new ArrayList<>();
|
|
|
+ planStatus.add("1");
|
|
|
+ planStatus.add("2");
|
|
|
+ List<Plan> plans = planMapper.selectList(Wraps.<Plan>lbQ().eq(Plan::getProduceStatus,2));
|
|
|
+ List<Long> planIds = plans.stream().map(p -> p.getOrderId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 查找执行中的订单下未完成的工件
|
|
|
+ List<String> workpieceStatus = new ArrayList<>();
|
|
|
+ workpieceStatus.add("1");
|
|
|
+ workpieceStatus.add("2");
|
|
|
+ List<TWorkpiece> list = baseMapper.selectList(Wraps.<TWorkpiece>lbQ().in(TWorkpiece::getProduceStatus,workpieceStatus));// .in(TWorkpiece::getOrderId,planIds)
|
|
|
|
|
|
// 取得工件对应加工设备首个工序任务
|
|
|
- Map existResource = new HashedMap();
|
|
|
+ Map<Long,Map<String,String>> existResource = new HashMap<Long,Map<String,String>>();
|
|
|
+ Map<String,String> map = null;
|
|
|
for(TWorkpiece workpiece:list){
|
|
|
- Map<String,String> map = new<String,String> HashMap();
|
|
|
List<String> taskStatus = new ArrayList<>();
|
|
|
taskStatus.add("1");
|
|
|
taskStatus.add("2");
|
|
|
// 查找工件第一个任务信息及所在设备
|
|
|
- TTask task = tTaskMapper.selectOne(Wraps.<TTask>lbQ().in(TTask::getStatus,taskStatus).orderByAsc(TTask::getProcedureSort).last("limit 1"));
|
|
|
+ TTask task = tTaskMapper.selectOne(Wraps.<TTask>lbQ().eq(TTask::getCompleteBatchNo,workpiece.getCompleteBatchNo()).in(TTask::getStatus,taskStatus).orderByAsc(TTask::getProcedureSort).last("limit 1"));
|
|
|
+ ProductionresourcePosition productionresourcePosition = productionresourcePositionMapper.selectOne(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getResourceId,task.getResourceId()).last("limit 1"));
|
|
|
+ ZZoneProductionresource zZoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId,task.getResourceId()));
|
|
|
+ ZZone zZone = zZoneMapper.selectById(zZoneProductionresource.getZoneId());
|
|
|
if(!existResource.containsKey(task.getResourceId())){
|
|
|
- existResource.put(task.getResourceId(),task.getResourceId());
|
|
|
// 查找设备点位信息,先判断库位信息是否有数据,如果库位信息有数据,直接用库位信息表里面的点位,可能移动到线边库,如果没有直接显示在工序目标设备的点位上
|
|
|
- StockInfo stockInfo = stockInfoMapper.selectOne(Wraps.<StockInfo>lbQ().eq(StockInfo::getCompleteBatchNo,workpiece.getCompleteBatchNo()).last("limit 1"));
|
|
|
- long storgeId = stockInfo.getStorgeId();
|
|
|
- ProductionresourcePosition productionresourcePosition = productionresourcePositionMapper.selectOne(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getStorgeId,storgeId).last("limit 1"));
|
|
|
- map.put("pointId",StringUtil.isEmpty(productionresourcePosition.getPointId())?"":workpiece.getPointId());
|
|
|
+// StockInfo stockInfo = stockInfoMapper.selectOne(Wraps.<StockInfo>lbQ().eq(StockInfo::getCompleteBatchNo,workpiece.getCompleteBatchNo()).last("limit 1"));
|
|
|
+// long storgeId = stockInfo.getStorgeId();
|
|
|
+ map = new<String,String> HashMap();
|
|
|
+ map.put("pointId",StringUtil.isEmpty(workpiece.getPointId()) ? productionresourcePosition.getPointId() : workpiece.getPointId());
|
|
|
map.put("taskId",String.valueOf(task.getId()));
|
|
|
map.put("orderName",StringUtil.isEmpty(workpiece.getOrderName())?"":workpiece.getOrderName());
|
|
|
map.put("bomNo",StringUtil.isEmpty(workpiece.getBomNo())?"":workpiece.getBomNo());
|
|
|
map.put("bomName",StringUtil.isEmpty(workpiece.getBomName())?"":workpiece.getBomName());
|
|
|
- map.put("procedureName",StringUtil.isEmpty(workpiece.getProcedureName())?"":workpiece.getProcedureName());
|
|
|
+ map.put("procedureName",StringUtil.isEmpty(task.getProcedureName())?"":task.getProcedureName());
|
|
|
+ map.put("status",task.getStatus());
|
|
|
+ map.put("deviceUnit",zZone.getNo());
|
|
|
+ map.put("expectStartTime", DateUtil.formatTime(task.getExpectStartTime()));
|
|
|
+ existResource.put(task.getResourceId(),map);
|
|
|
+ }else{
|
|
|
+ // 判断当前工序任务是否早于之前的任务,如果是,将本工序任务覆盖之前的任务
|
|
|
+ if (existResource.get(task.getResourceId()).get("expectStartTime").compareTo(DateUtil.formatTime(task.getExpectStartTime())) > 0){
|
|
|
+ map = new<String,String> HashMap();
|
|
|
+ map.put("pointId",StringUtil.isEmpty(productionresourcePosition.getPointId())?"":workpiece.getPointId());
|
|
|
+ map.put("taskId",String.valueOf(task.getId()));
|
|
|
+ map.put("orderName",StringUtil.isEmpty(workpiece.getOrderName())?"":workpiece.getOrderName());
|
|
|
+ map.put("bomNo",StringUtil.isEmpty(workpiece.getBomNo())?"":workpiece.getBomNo());
|
|
|
+ map.put("bomName",StringUtil.isEmpty(workpiece.getBomName())?"":workpiece.getBomName());
|
|
|
+ map.put("procedureName",StringUtil.isEmpty(task.getProcedureName())?"":task.getProcedureName());
|
|
|
+ map.put("status",task.getStatus());
|
|
|
+ map.put("expectStartTime", DateUtil.formatTime(task.getExpectStartTime()));
|
|
|
+ existResource.put(task.getResourceId(),map);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// if(workpiece.getTaskNodeId()!=null){
|
|
@@ -234,7 +267,13 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
|
|
|
// map.put("nodeName",nextTaskNode.getNodeName());
|
|
|
// map.put("nodeId",nextTaskNode.getId().toString());
|
|
|
// }
|
|
|
- returnList.add(map);
|
|
|
+ }
|
|
|
+ // 遍历map
|
|
|
+ Iterator<Long> itr = existResource.keySet().iterator();
|
|
|
+ while(itr.hasNext()){
|
|
|
+ long key = itr.next();
|
|
|
+ Map value = existResource.get(key);
|
|
|
+ returnList.add(value);
|
|
|
}
|
|
|
|
|
|
return returnList;
|
|
@@ -657,6 +696,7 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
|
|
|
@Override
|
|
|
public R executeOrder(Map paraMap) {
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
+ log.info(paraMap.toString());
|
|
|
// 根据taskid查找工序任务
|
|
|
long taskId = Long.valueOf(paraMap.get("taskId").toString());
|
|
|
TTask tTask = tTaskMapper.selectById(taskId);
|