Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master' into master

laoyao před 3 roky
rodič
revize
ede0b4f93e

+ 5 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java

@@ -736,8 +736,11 @@ public class TaskWorkNode {
             map.put("result", false);
         }else{
             // 获取锁定节点设备ID
-            //Long campId = xbkStorage.getCampId();
-            Long targetId = xbkStorage.getTargetId();
+            Long campId = xbkStorage.getCampId();
+            // 获取锁定设备ID
+            TaskNode targetNode = taskNodeService.getById(campId);
+            // 锁定节点对应设备ID
+            Long targetId = targetNode.getResourceId();
             if(!taskNodeService.getRunStatus(targetId)){
                 map.put("result", false);
                 map.put("msg", DictionaryKey.NodeException.RUNNING_FALSE);

+ 2 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/dao/TTaskMapper.java

@@ -54,4 +54,6 @@ public interface TTaskMapper extends SuperMapper<TTask> {
     public List<Map> getTaskCountStatistics(Map<String, String> map);
 
     public List<TaskNode> getInstructions(TaskNode taskNode);
+
+    List<Map> getStationTasks(Map<String, Object> map);
 }

+ 3 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/TaskService.java

@@ -1,6 +1,7 @@
 package com.github.zuihou.business.operationManagementCenter.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.base.R;
 import com.github.zuihou.base.service.SuperService;
 import com.github.zuihou.business.operationManagementCenter.entity.OrderProduct;
 import com.github.zuihou.business.operationManagementCenter.entity.PlanProduct;
@@ -75,5 +76,7 @@ public interface TaskService extends SuperService<TTask> {
     Map handleChangeHand(Map handMap,Map paramMap);
 
 
+    R getStationTasks(Map<String, Object> map);
 
+    R updateTaskStatus(Map<String, Object> map);
 }

+ 28 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskServiceImpl.java

@@ -6,6 +6,7 @@ import com.github.zuihou.authority.dao.auth.StationUserLoginInfoMapper;
 import com.github.zuihou.authority.dao.auth.UserMapper;
 import com.github.zuihou.authority.entity.auth.StationUserLoginInfo;
 import com.github.zuihou.authority.entity.auth.User;
+import com.github.zuihou.base.R;
 import com.github.zuihou.base.service.SuperServiceImpl;
 import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.DemoLine.DemoLineConstant;
@@ -38,6 +39,7 @@ import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.tenant.service.CodeRuleService;
 import com.google.common.collect.Maps;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
@@ -982,7 +984,33 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
             }
         }
         return map;
+    }
 
+    @Override
+    public R getStationTasks(Map<String, Object> map){
+        List<Map> stationTasks = baseMapper.getStationTasks(map);
+        for(int i = 1; i<= stationTasks.size() ; i++){
+            stationTasks.get(i-1).put("step",i);
+        }
+        return  R.success(stationTasks);
+    }
 
+    @Override
+    public R updateTaskStatus(Map<String, Object> map){
+        TTask tTask = baseMapper.selectById(Long.valueOf(map.get("id").toString()));
+        String type = map.get("updateType").toString();
+        if("begin".equals(type)) {
+            if(null == tTask.getStartTime()) {
+                tTask.setStartTime(Calendar.getInstance().getTime());
+                baseMapper.updateById(tTask);
+            }
+        }else if("end".equals(type)) {
+            if(null == tTask.getEndTime()) {
+                tTask.setEndTime(Calendar.getInstance().getTime());
+                tTask.setStatus("3");
+                baseMapper.updateById(tTask);
+            }
+        }
+        return  R.success();
     }
 }

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/WorkpieceServiceImpl.java

@@ -468,7 +468,7 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
         String devicePort = "";
         if("execProgram".equals(manualInfo.getManualIdType())){
             // 机加设备执行程序,直接执行机床接口
-            Productionresource productionresource = productionresourceMapper.selectOne(Wraps.<Productionresource>lbQ().eq(Productionresource::getId, manualInfo.getStartResourceId()));
+            com.github.zuihou.business.productionResourceCenter.entity.Productionresource productionresource = productionresourceBizMapper.selectOne(Wraps.<com.github.zuihou.business.productionResourceCenter.entity.Productionresource>lbQ().eq(com.github.zuihou.business.productionResourceCenter.entity.Productionresource::getId, manualInfo.getStartResourceId()));
             deviceUrl = productionresource.getIp();
             devicePort = productionresource.getPort();
         }

+ 59 - 28
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/RobotNodeServiceImpl.java

@@ -95,6 +95,8 @@ public class RobotNodeServiceImpl implements NodeOperationService {
 
     private List<ProductionresourcePosition> xbkList;
 
+    private List<ProductionresourcePosition> jbwList;
+
     @Override
     public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
         //productionresourcePosition = getResourcePosition(taskNode);
@@ -113,6 +115,12 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                     DictionaryKey.YJ_ZONE_XBK.get(dataMap.get("robotType").toString())
                 }: new String[]{DemoLineConstant.NODE_RESOURCE_ZLZX_XBK};
         xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(xbkArr);
+        //jbwArr = modules.stream().map(Module::getNo).toArray(String[]::new);
+        List<Productionresource> dataList = productionresourceService.list(new QueryWrapper<Productionresource>().like("name", robotType));
+        if(dataList.size()>0) {
+            jbwArr = dataList.stream().map(Productionresource::getId).toArray(String[]::new);
+            jbwList = productionresourcePositionService.getFreeProductionresourcePositionByIds(jbwArr);
+        }
     }
 
     @Override
@@ -121,7 +129,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
         String carryType = dataMap.get("carryType") == null ? "" : dataMap.get("carryType").toString();
         String robotType = dataMap.get("robotType") == null ? "" : dataMap.get("robotType").toString();
 
-        Map<String, Object> map = new HashMap<>();
+        //Map<String, Object> map = new HashMap<>();
         map.put("taskNode", taskNode);
         map.put("task", task);
 
@@ -144,8 +152,12 @@ public class RobotNodeServiceImpl implements NodeOperationService {
         Storge startStore = workpieceService.getWorkPieceStock(taskNode.getId(), false);
         //目的库位
         Storge jqrStorge = storgeService.getById(deviceList.get(0).getStorgeId());
-
         //目标地址判断
+        if(map.containsKey("useXbk")){
+            //目标地址是线边库
+            map.put("result", false);
+            return map;
+        }
 
         switch(robotType){
             case "质量中心机器人":
@@ -156,13 +168,13 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                 break;
             case "柔性线机器人":
                 //操作柔性线边库 具有取、移动、放三种指令
-                 //取放加工设备
+                 //取放加工设备  设备存在缓存位
                 String count = dataMap.get(taskNode.getId().toString() + "count") == null ? "0" : dataMap.get(taskNode.getId().toString() + "count").toString();
                 map = this.commandHandle(map, startStore, jqrStorge, functionName, count);
                 break;
             case "智能单元机器人":
                 //操作智能单元线边库 具有取、移动、放三种指令
-                //取放加工设备
+                //取放加工设备 无缓存位处理
                 map = this.commandHandle(map, startStore, jqrStorge, functionName);
                 break;
             case "舱体线机器人":
@@ -207,25 +219,8 @@ public class RobotNodeServiceImpl implements NodeOperationService {
     private Map<String, Object>  commandHandle(Map<String, Object> dataMap, Storge startStore, Storge jqrStorge, String... params){
         TaskNode taskNode = (TaskNode) dataMap.get("taskNode");
         TTask task = (TTask) dataMap.get("task");
-        if ("取".equals(params[0])) {
-            dataMap.put("zkIp", ZK_ip_zndy);
-            dataMap.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "fetchMaterial");
-            TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
-            //if (CollectionUtil.isNotEmpty(jqrList)) {
-            dataMap.put("fromStorge", startStore);
-            dataMap.put("Data", startStore);
-                //出入库类型
-            dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
-                //目的地为机器人手臂
-            dataMap.put("toStorge", jqrStorge);
-                //锁定机器人
-                jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
-                storgeService.lockStorge(jqrStorge, nextTaskNode.getId());
-            //}
-            //
-            map.put("result", true);
-        }
-        else if (params[1]!= null) {
+        //缓存位判断处理
+        if (params[1]!= null) {
             //int count = dataMap.get(taskNode.getId().toString() + "count") == null ? 0 : Integer.parseInt(dataMap.get(taskNode.getId().toString() + "count").toString());
              int count = Integer.parseInt(params[1]);
             //执行到第几步
@@ -290,12 +285,46 @@ public class RobotNodeServiceImpl implements NodeOperationService {
             }
 
         }
+        else if ("取".equals(params[0])) {
+            dataMap.put("zkIp", ZK_ip_zndy);
+            dataMap.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "fetchMaterial");
+            TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
+            //if (CollectionUtil.isNotEmpty(jqrList)) {
+            dataMap.put("fromStorge", startStore);
+            dataMap.put("Data", startStore);
+            //出入库类型
+            dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
+            //目的地为机器人手臂
+            dataMap.put("toStorge", jqrStorge);
+            //锁定机器人
+            jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
+            storgeService.lockStorge(jqrStorge, nextTaskNode.getId());
+            //}
+            //
+            map.put("result", true);
+        }
         else if ("放".equals(params[0])) {
             //判断目标位置是否空闲
-            String target[] = {taskNode.getAutoNode().getTargetId().toString()};
-            List<ProductionresourcePosition> targetList = productionresourcePositionService.getFreeProductionresourcePositionByNos(target);
-            List<ProductionresourcePosition> xbkList = new ArrayList<>();
-
+            String actionTarget = taskNode.getAutoNode().getTargetId().toString();
+            //1是本设备 2是接驳位
+            List<ProductionresourcePosition> targetList = "1".equals(actionTarget)? productionresourcePositionService.getFreeProductionresourcePositionByNos(new String[]{taskNode.getNodeNo()}) : jbwList;
+            ProductionresourcePosition productionresourcePosition = this.logical(targetList, true);
+            boolean bool =  productionresourcePosition!=null ? true : false;
+            if(!bool){
+                dataMap.put("result", false);
+                return dataMap;
+            }
+            boolean isXbk = dataMap.containsKey("useXbk");
+            Storge targetStorge = storgeService.getById(productionresourcePosition.getStorgeId());
+            targetStorge.setCompleteBatchNo(task.getCompleteBatchNo());
+            if(isXbk){
+                dataMap.put("result", false);
+            }else{
+                //锁定设备
+                storgeService.lockStorge(targetStorge, taskNode.getId());
+                dataMap.put("result", true);
+            }
+            /*
             if (CollectionUtil.isNotEmpty(targetList)) {//设备空闲
                 Storge targetStorge = storgeService.getById(targetList.get(0).getStorgeId());
                 //锁定加工设备库位
@@ -313,7 +342,9 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                     storgeService.lockStorge(xbkStorge, taskNode.getId());
 //                    redisTemplate.opsForValue().set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.NODE_RESOURCE_ZNSCDY_XBK + nextTaskNode.getId(), xbkStorge, 1, TimeUnit.DAYS);
                 }
-            }
+            } */
+
+
 //            if(count==0){//第一步的时候锁定资源
 //                //判断机器人是否为空
 //                String jrqarr[] = {resourceAutoCode.getResourceId().toString()};

+ 4 - 4
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/ManualTaskOperatorUtil.java

@@ -93,11 +93,11 @@ public class ManualTaskOperatorUtil {
             deviceUrl = ZK_ip_zndy;
             devicePort = ZK_ip_zndy_port;
         }else if("framework".equals(unit)){
-            deviceUrl = ZK_ip_zndy;
-            devicePort = ZK_ip_zndy_port;
+            deviceUrl = ZK_ip_rxx;
+            devicePort = ZK_ip_rxx_port;
         }else if("safeguard".equals(unit)){
-            deviceUrl = ZK_ip_zndy;
-            devicePort = ZK_ip_zndy_port;
+            deviceUrl = ZK_ip_zlzx;
+            devicePort = ZK_ip_zlzx_port;
         }
         if("general".equals(manualType)){
             if("capsule".equals(unit)){

+ 38 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/TTaskMapper.xml

@@ -248,4 +248,42 @@
         </if>
     </select>
 
+    <select id="getStationTasks" resultType="java.util.Map">
+        SELECT
+          itt.id,
+          ibbp.name AS taskName,
+          ibbp.remark AS content,
+          ibbp.no AS taskNo,
+          itt.task_no AS no,
+          ibb.name,
+          (SELECT itt1.no FROM  imcs_t_tray itt1, imcs_b_bom_procedure_tray ibbpt1 WHERE ibbpt1.biz_type = 1 AND itt1.id = ibbpt1.tray_id AND ibbpt1.procedure_id = ibbp.id) AS trayNo,
+          imfc.no  AS clampNo,
+          imfc.name  AS clampName,
+          imfc.material_type AS clampType,
+          ibbp.rated_workHours AS time,
+          itt.expect_start_time AS startTime,
+          itt.expect_end_time AS endTime,
+          itt.status,
+          imm.meterial_code AS meterialCode,
+          imm.equipment_name AS equipmentName,
+          imm.trade_mark AS tradeMark,
+          ibbpt.armor_pic AS armorPic
+        FROM imcs_t_task itt,
+             imcs_b_bom_procedure ibbp,
+             imcs_b_bom_procedure_tray ibbpt,
+             imcs_b_bom ibb,
+
+             imcs_m_frock_clamp imfc,
+             imcs_m_meterial imm
+        WHERE itt.status IN  ('1','2')
+        AND ibbp.id = itt.procedure_id
+        AND ibbp.bom_id = ibb.id
+        AND ibbpt.procedure_id = ibbp.id
+        AND ibbpt.biz_type='2'
+        AND imfc.id = ibbpt.tray_id
+        AND imm.id = ibb.meterial_id
+        AND itt.resource_id = #{resourceId}
+        ORDER BY itt.expect_start_time LIMIT 0, 2
+    </select>
+
 </mapper>

+ 14 - 0
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/TaskController.java

@@ -191,4 +191,18 @@ public class TaskController extends SuperController<TaskService, Long, TTask, TT
     }
 
 
+    @ApiOperation(value = "上下料站工作任务列表", notes = "上下料站工作任务列表")
+    @PostMapping("/getStationTasks")
+    public R getStationTasks(@RequestBody Map<String,Object> map) {
+        log.info("开始查询上下料站任务集合,请求参数{}",map);
+        return baseService.getStationTasks(map);
+    }
+
+    @ApiOperation(value = "更新上下料时间", notes = "更新上下料时间")
+    @PostMapping("/updateTaskStatus")
+    public R updateTaskStatus(@RequestBody Map<String,Object> map) {
+        log.info("开始更新上下料时间,请求参数{}",map);
+        return baseService.updateTaskStatus(map);
+    }
+
 }

+ 6 - 10
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/productionResourceCenter/StationUserController.java

@@ -21,7 +21,6 @@ import com.github.zuihou.log.annotation.SysLog;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.map.HashedMap;
 import org.apache.commons.compress.utils.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
@@ -124,11 +123,12 @@ public class StationUserController extends SuperController<StationUserService, L
 
     @ApiOperation(value = "查询上下料用户", notes = "查询上下料用户")
     @GetMapping("/stationUser")
-    public R<List<StationUser>> getStationUser(@RequestParam(value="userId",required = false) Long userId) {
+    public R getStationUser(@RequestParam(value="userId",required = false) Long userId) {
         LbqWrapper<StationUser> wrapper = Wraps.<StationUser>lbQ();
         if(userId!= null){
             wrapper.eq(StationUser::getUserId, userId);
         }
+
         return success(baseService.getStationUser(wrapper));
     }
 
@@ -140,13 +140,9 @@ public class StationUserController extends SuperController<StationUserService, L
             wrapper.eq(StationUserLoginInfo::getUserId, userId);
         }
         StationUserLoginInfo stationUserLoginInfo = stationUserLoginInfoMapper.selectOne(wrapper);
-        // 查找上下料站信息
-        Productionresource productionresource = productionresourceBizMapper.selectById(stationUserLoginInfo.getStationId());
-//        Productionresource productionresource = new Productionresource();
-//        productionresource.setId( Long.valueOf("1496363582865014784"));
-//        productionresource.setName("保障中心_上下料站1");
-        List<Productionresource> stations = new ArrayList<Productionresource>();
-        stations.add(productionresource);
-        return success(stations);
+        com.github.zuihou.business.productionResourceCenter.entity.Productionresource productionresource =  productionresourceBizMapper.selectById(stationUserLoginInfo.getStationId());
+        List<Productionresource> productionresources = new ArrayList<>();
+        productionresources.add(productionresource);
+        return success(productionresources);
     }
 }