浏览代码

非订单手动模式优化返回内容,下料拆夹具、rfid接口预留beta

yejian016332 3 年之前
父节点
当前提交
72c6f760b4

+ 1 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/impl/StockInfoServiceImpl.java

@@ -652,6 +652,7 @@ public class StockInfoServiceImpl extends SuperServiceImpl<StockInfoMapper, Stoc
         baseMapper.deleteById(stockInfo.getId());
         //库存日志
         stockLogService.saveLog(stockInfo,BizConstant.STOCK_TYPE_OUT);
+
         return R.success();
     }
 }

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

@@ -79,4 +79,8 @@ public interface TaskService extends SuperService<TTask> {
     R getStationTasks(Map<String, Object> map);
 
     R updateTaskStatus(Map<String, Object> map);
+
+    R releaseClamp(Map<String, Object> map);
+
+    R procesRfid(Map<String, Object> map);
 }

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

@@ -13,7 +13,11 @@ import com.github.zuihou.business.DemoLine.DemoLineConstant;
 import com.github.zuihou.business.aps.algorithm.ga.GAScheduler;
 import com.github.zuihou.business.aps.instance.domain.basicdata.*;
 import com.github.zuihou.business.classSchedule.dao.ScheduleUserDateMapper;
+import com.github.zuihou.business.edgeLibrary.dao.StockInfoMapper;
+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.StockLogService;
 import com.github.zuihou.business.edgeLibrary.service.StorgeService;
 import com.github.zuihou.business.operationManagementCenter.dao.OrderMapper;
 import com.github.zuihou.business.operationManagementCenter.dao.TTaskMapper;
@@ -25,11 +29,14 @@ import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureProducti
 import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureProgramMapper;
 import com.github.zuihou.business.productionReadyCenter.entity.*;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
 import com.github.zuihou.business.productionResourceCenter.dao.ZZoneMapper;
 import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
+import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
 import com.github.zuihou.business.productionResourceCenter.entity.Repair;
 import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
 import com.github.zuihou.business.productionResourceCenter.service.RepairService;
+import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.common.constant.CacheKey;
 import com.github.zuihou.common.constant.CodeRuleModule;
 import com.github.zuihou.common.util.DateUtil;
@@ -39,7 +46,6 @@ 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;
@@ -91,6 +97,14 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
     private UserMapper userMapper;
     @Autowired
     private ProductionresourceBizMapper productionresourceBizMapper;
+    @Autowired
+    private StockInfoService stockInfoService;
+
+    @Autowired
+    private ProductionresourcePositionMapper productionresourcePositionMapper;
+
+    @Autowired
+    private StockLogService stockLogService;
 
     @Override
     public List<TTask> createTaskByPlan(List<PlanProduct> planProductList, Map<Long,List<BomProcedure>> bomProcedureMap,String taskBatchNo) {
@@ -1013,4 +1027,39 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
         }
         return  R.success();
     }
+
+    @Override
+    public R releaseClamp(Map<String, Object> map){
+        TTask tTask = baseMapper.selectById(Long.valueOf(map.get("id").toString()));
+        // 根据设备点位信息删除对应的库位上的夹具信息
+        Map queryMap = new HashMap();
+        queryMap.put("resourceId", tTask.getResourceId());
+        List<ProductionresourcePosition> list = productionresourcePositionMapper.getStorgeIdByResource(queryMap);
+
+        if(CollectionUtil.isEmpty(list)){
+            return R.fail("设备不存在");
+        }
+        ProductionresourcePosition productionresourcePosition = list.get(0);
+
+        List<StockInfo> StockInfos  = stockInfoService.list(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId,productionresourcePosition.getStorgeId()));
+       if(CollectionUtil.isEmpty(StockInfos)){
+           return R.fail("当前库位无料");
+       }
+
+        for(StockInfo stockInfo : StockInfos){
+            baseMapper.deleteById(stockInfo.getId());
+            //库存日志
+            stockLogService.saveLog(stockInfo, BizConstant.STOCK_TYPE_OUT);
+        }
+        return R.success();
+    }
+
+    @Override
+    public R procesRfid(Map<String, Object> map){
+        // 先读取rfid内容是否有子盘信息
+        // 第一次使用子盘写入子盘唯一编码
+        TTask tTask = baseMapper.selectById(Long.valueOf(map.get("id").toString()));
+        // 调用rfid读取接口判断rfid里面是否子盘信息,第一次内容为空,写入自盘信息,后续只需更新夹具、和原材料信息
+        return R.success();
+    }
 }

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

@@ -1,6 +1,7 @@
 package com.github.zuihou.business.operationManagementCenter.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -17,7 +18,6 @@ import com.github.zuihou.business.operationManagementCenter.service.TaskNodeServ
 import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
 import com.github.zuihou.business.productionReadyCenter.dao.BBomMapper;
 import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureMapper;
-import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
 import com.github.zuihou.business.productionReadyCenter.entity.MToolClamp;
 import com.github.zuihou.business.productionReadyCenter.entity.Tray;
 import com.github.zuihou.business.productionReadyCenter.service.MToolClampService;
@@ -37,8 +37,6 @@ import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.tenant.dao.ProductionresourceMapper;
-import com.github.zuihou.tenant.dto.ProductionresourcePageDTO;
-import com.github.zuihou.tenant.entity.Productionresource;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpEntity;
@@ -47,7 +45,10 @@ import org.springframework.http.MediaType;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 import static java.util.stream.Collectors.groupingBy;
@@ -325,6 +326,64 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
         }
     }
 
+    private List<Map> processStockInfo(String zZoneCode, String resourceId, String pointId) {
+        List<Map> returnList = new ArrayList<>();
+        Map map = new HashMap();
+        map.put("resourceId", resourceId);
+        map.put("pointId", pointId);
+        List<ProductionresourcePosition> list = productionresourcePositionMapper.getProductlineStockInfo(map);
+        Map<String, List<ProductionresourcePosition>> pointMap = list.stream().collect(groupingBy(ProductionresourcePosition::getPointId));
+        for (String key : pointMap.keySet()) {
+            Map returnMap = new HashMap();
+            List<ProductionresourcePosition> subList = pointMap.get(key);
+            if (CollectionUtil.isEmpty(subList)) {
+                continue;
+            }
+            ProductionresourcePosition position0 = subList.get(0);
+            returnMap.put("unitename", zZoneCode);
+            returnMap.put("pointId", key);
+            returnMap.put("storgeId", position0.getStorgeId());
+            returnMap.put("name", position0.getName());
+            returnMap.put("lockStatus", position0.getLockStatus());
+            returnMap.put("resourceId", position0.getResourceId());
+            List<Map> l = new ArrayList<>();
+            for (ProductionresourcePosition p : subList) {
+                if (p.getGoodsId() != null) {
+                    Map m = new HashMap();
+                    m.put("goodsName", p.getGoodsName());
+                    m.put("goodsId", p.getGoodsId());
+                    m.put("uniqueCode", p.getUniqueCode());
+                    m.put("storgeId", p.getStorgeId());
+                    m.put("category", p.getCategory());
+                    if ("5".equals(p.getCategory())) {//如果是托板。
+                        List<Map> childL = new ArrayList<>();
+                        //根据托盘ID,找到对应的点位
+                        Map queryMap = new HashMap();
+                        queryMap.put("plateId", p.getGoodsId() == null ? "" : p.getGoodsId().toString());
+                        List<ProductionresourcePosition> childList = productionresourcePositionMapper.getProductlineStockInfo(queryMap);
+                        for (ProductionresourcePosition c : childList) {
+                            Map childMap = new HashMap();
+                            childMap.put("pointId", c.getPointId());
+                            childMap.put("goodsName", c.getGoodsName());
+                            childMap.put("goodsId", c.getGoodsId());
+                            childMap.put("uniqueCode", c.getUniqueCode());
+                            childMap.put("storgeId", c.getStorgeId());
+                            childMap.put("category", c.getCategory());
+                            childL.add(childMap);
+                        }
+                        m.put("childList", childL);
+                    }
+                    l.add(m);
+                }
+            }
+            if (CollectionUtil.isNotEmpty(l)) {
+                returnMap.put("goodsList", l);
+            }
+            returnList.add(returnMap);
+        }
+        return returnList;
+    }
+
     @Override
     public String  execute(Map map) {
         BaseContextHandler.setTenant("0000");
@@ -349,12 +408,25 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
     @Override
     public R delete(Map conMap) {
         BaseContextHandler.setTenant("0000");
-        return taskNodeService.handModeStockOut(conMap);
+        String deviceUnit = conMap.get("deviceUnit").toString();
+        String pointId = conMap.get("pointId").toString();
+        String resourceId = conMap.get("resourceId").toString();
+        R result =  taskNodeService.handModeStockOut(conMap);
+
+        List<Map> allReturnList = new ArrayList<>();
+        List<Map> returnStockList =  processStockInfo(deviceUnit ,resourceId, pointId);
+        allReturnList.addAll(returnStockList);
+        Map<String, Object> retStockInfo = new HashMap<String, Object>();
+        retStockInfo.put("data",allReturnList);
+        result.setData(retStockInfo);
+        return result;
     }
 
     @Override
     public R  lock(Map map) {
         BaseContextHandler.setTenant("0000");
+
+        String deviceUnit = map.get("deviceUnit").toString();
         String resourceId = map.get("resourceId").toString();
         String pointId = map.get("pointId").toString();
         String lockType = map.get("lockType").toString();
@@ -381,7 +453,13 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
             storgeMapper.updateById(storge);
         }
 
-        return R.success();
+        List<Map> allReturnList = new ArrayList<>();
+        List<Map> returnStockList =  processStockInfo(deviceUnit ,resourceId, pointId);
+        allReturnList.addAll(returnStockList);
+        Map<String, Object> retStockInfo = new HashMap<String, Object>();
+        retStockInfo.put("data",allReturnList);
+
+        return R.success(retStockInfo);
 
     }
 
@@ -389,7 +467,18 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
     @Override
     public R add(Map map) {
         BaseContextHandler.setTenant("0000");
-        return taskNodeService.handModeStockIn(map);
+        String deviceUnit = map.get("deviceUnit").toString();
+        String pointId = map.get("pointId").toString();
+        String resourceId = map.get("resourceId").toString();
+        R result =  taskNodeService.handModeStockIn(map);
+
+        List<Map> allReturnList = new ArrayList<>();
+        List<Map> returnStockList =  processStockInfo(deviceUnit ,resourceId, pointId);
+        allReturnList.addAll(returnStockList);
+        Map<String, Object> retStockInfo = new HashMap<String, Object>();
+        retStockInfo.put("data",allReturnList);
+        result.setData(retStockInfo);
+        return result;
     }
 
 

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

@@ -179,6 +179,14 @@ public class ManualTaskOperatorUtil {
             String hostSyetemTaskUrl = hostSyetemUrl + "/api/StartCoordinateMeasuringMachine";
             String location = manualInfo.getStartpointId();
             setProcessInfo( new ArrayList(), processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
+        }else if("readRFID".equals(manualType)) {
+            String hostSyetemTaskUrl = hostSyetemUrl + "/api/ReadRFID";
+            String location = manualInfo.getStartpointId();
+            setProcessInfo( new ArrayList(), processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
+        }else if("writeRFID".equals(manualType)) {
+            String hostSyetemTaskUrl = hostSyetemUrl + "/api/WriteRFID";
+            String location = manualInfo.getStartpointId();
+            setProcessInfo( new ArrayList(), processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
         }
     }
 

+ 7 - 1
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionResourceCenter/ProductionresourcePositionMapper.xml

@@ -82,7 +82,13 @@
         </if>
     </select>
     <select id="getStorgeIdByResource" resultType="com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition">
-        select * from imcs_p_productionresource_position where resource_id = #{resourceId} and point_id = #{pointId}
+        select * from imcs_p_productionresource_position where 1=1
+        <if test="resourceId != null and resourceId != ''">
+            and resource_id = #{resourceId}
+        </if>
+        <if test="pointId != null and pointId != ''">
+            and point_id = #{pointId}
+        </if>
     </select>
     <select id="getProductlineStockInfo" resultType="com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition">
         SELECT

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

@@ -205,4 +205,18 @@ public class TaskController extends SuperController<TaskService, Long, TTask, TT
         return baseService.updateTaskStatus(map);
     }
 
+    @ApiOperation(value = "人工上下料拆除夹具", notes = "人工上下料拆除夹具")
+    @PostMapping("/releaseClamp")
+    public R releaseClamp(@RequestBody Map<String,Object> map) {
+        log.info("开始人工拆除上下料站夹具,请求参数{}",map);
+        return baseService.releaseClamp(map);
+    }
+
+    @ApiOperation(value = "rfid内容处理", notes = "rfid内容处理")
+    @PostMapping("/procesRfid")
+    public R procesRfid(@RequestBody Map<String,Object> map) {
+        log.info("开始rfid内容处理,请求参数{}",map);
+        return baseService.procesRfid(map);
+    }
+
 }