Browse Source

订单审批之后对接仓储

wudingsheng 2 months ago
parent
commit
b6b0b236d8

+ 2 - 0
imcs-admin-boot/imcs-authority-server/src/main/resources/application-test.yml

@@ -72,3 +72,5 @@ three-dimensiona:
   file-path: Y:\three-dimensional
 hz:
   wms: http://localhost/task
+plc:
+  ip: 192.168.1.10

+ 3 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/dao/StockInfoMapper.java

@@ -9,6 +9,7 @@ import com.github.zuihou.business.centralToolMagazine.entity.ToolStorge;
 import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
 
 import com.github.zuihou.business.productionReadyCenter.entity.CuttingTool;
+import com.github.zuihou.business.productionReadyCenter.entity.Tray;
 import com.github.zuihou.database.mybatis.auth.DataScope;
 import com.github.zuihou.tenant.vo.DeviceResourceDetailVo;
 import org.apache.ibatis.annotations.Param;
@@ -82,4 +83,6 @@ public interface StockInfoMapper extends SuperMapper<StockInfo> {
     void addFinishedNumByStorgeId(Long storgeId);
 
     String getTrayLatheTypeCode(Long id);
+
+    Tray getTrayNoByStorgeId(Long storgeId);
 }

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

@@ -53,4 +53,6 @@ public interface StorgeMapper extends SuperMapper<Storge> {
     List<Storge> findListStorgeByGoodsID(Long goodsId);
 
     List<Storge> getAGVStorgeList(@Param("zoneId") Long zoneId,@Param("name") String name);
+
+    Storge getStorgeByPointId(String start);
 }

+ 22 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/WmsAgvInfoService.java

@@ -0,0 +1,22 @@
+package com.github.zuihou.business.externalApi.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.base.service.SuperCacheService;
+import com.github.zuihou.business.externalApi.entity.WmsAgvInfo;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+
+/**
+ * <p>
+ * 业务接口
+ * agv任务管理
+ * </p>
+ *
+ * @author imcs
+ * @date 2021-07-12
+ */
+public interface WmsAgvInfoService extends SuperCacheService<WmsAgvInfo> {
+
+    IPage<WmsAgvInfo> pageList(IPage page, LbqWrapper<WmsAgvInfo> wrapper);
+
+
+}

+ 9 - 5
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/PlcServiceImpl.java

@@ -26,6 +26,7 @@ import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.exception.BizException;
 import com.github.zuihou.tenant.service.CodeRuleService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -48,6 +49,9 @@ public class PlcServiceImpl implements PlcService {
 
     private static final String CCS_URL="http://localhost:8089/api/";
 
+    @Value("${plc.ip}")
+    private String plcIp;
+
     @Autowired
     private ToolTaskNodeService toolTaskNodeService;
 
@@ -69,11 +73,11 @@ public class PlcServiceImpl implements PlcService {
     public Map<String, Map<String, Object>> getPointInfo() {
         Map<String,Map<String, Object>> pointInfoMap = new HashMap<>();
 
-        Object pcToPlcPointObj = msgUtil.redis_get("PC_TO_PLC_POINT"); //PC 到 PLC的点位
+        Object pcToPlcPointObj = msgUtil.redis_get("hz:PC_TO_PLC_POINT"); //PC 到 PLC的点位
         Map<String, Object> pcToPlcMaps = requestCCS(pcToPlcPointObj);
         pointInfoMap.put("pcToPlcMap",pcToPlcMaps);
 
-        Object plcToPcPoint = msgUtil.redis_get("PLC_TO_PC_POINT"); //PC 到 PLC的点位
+        Object plcToPcPoint = msgUtil.redis_get("hz:PLC_TO_PC_POINT"); //PC 到 PLC的点位
         Map<String, Object> plcToPcMaps = requestCCS(plcToPcPoint);
         pointInfoMap.put("plcToPcMap",plcToPcMaps);
         return pointInfoMap;
@@ -83,12 +87,12 @@ public class PlcServiceImpl implements PlcService {
     public void clearPlcPoint(String point,String flag) {
         //请求CCS
         JSONObject param = new JSONObject();
-        param.put("url","10.161.30.248");
+        param.put("url",plcIp);
         param.put("port","102");
 
         if("1".equals(flag)){
             //一键清零
-            Object pcToPlcPointObj = msgUtil.redis_get("PC_TO_PLC_POINT"); //PC 到 PLC的点位
+            Object pcToPlcPointObj = msgUtil.redis_get("hz:PC_TO_PLC_POINT"); //PC 到 PLC的点位
             if(pcToPlcPointObj !=null) {
                 JSONArray jsonArray = JSONUtil.parseArray(pcToPlcPointObj);
                 List<Map> list = JSONUtil.toList(jsonArray, Map.class);
@@ -244,7 +248,7 @@ public class PlcServiceImpl implements PlcService {
 
             //请求CCS
             JSONObject param = new JSONObject();
-            param.put("url","10.161.10.248");
+            param.put("url",plcIp);
             param.put("port","102");
             Map<String,Object> map = new HashMap();
             map.put("pointList",pointList);

+ 42 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/WmsAgvInfoServiceImpl.java

@@ -0,0 +1,42 @@
+package com.github.zuihou.business.externalApi.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.base.service.SuperCacheServiceImpl;
+import com.github.zuihou.business.externalApi.dao.WmsAgvInfoMapper;
+import com.github.zuihou.business.externalApi.entity.WmsAgvInfo;
+import com.github.zuihou.business.externalApi.service.WmsAgvInfoService;
+import com.github.zuihou.common.constant.CacheKey;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import com.github.zuihou.injection.annonation.InjectionResult;
+import com.github.zuihou.utils.BeanPlusUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * <p>
+ * 业务实现类
+ * 出入库管理
+ * </p>
+ *
+ * @author imcs
+ * @date 2021-07-12
+ */
+@Slf4j
+@Service
+
+public class WmsAgvInfoServiceImpl extends SuperCacheServiceImpl<WmsAgvInfoMapper, WmsAgvInfo> implements WmsAgvInfoService {
+
+    @Override
+    protected String getRegion() {
+        return CacheKey.USER;
+    }
+
+    @Override
+    @InjectionResult
+    public IPage<WmsAgvInfo> pageList(IPage page, LbqWrapper<WmsAgvInfo> wrapper) {
+        return baseMapper.pageList(page, wrapper);
+    }
+
+}

+ 4 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/edgeLibrary/StockInfoMapper.xml

@@ -339,4 +339,8 @@
          INNER JOIN  imcs_t_tray tt on ssi.goods_id=tt.id and ssi.goods_type=1
         where ssi.storge_id=#{storgeId}
     </select>
+
+    <select id="getTrayNoByStorgeId" resultType="com.github.zuihou.business.productionReadyCenter.entity.Tray">
+        select tt.* from imcs_s_stock_info ssi INNER JOIN imcs_t_tray tt on ssi.goods_id=tt.id where storge_id=#{storgeId}
+    </select>
 </mapper>

+ 6 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/edgeLibrary/StorgeMapper.xml

@@ -137,4 +137,10 @@
         where zz.id=#{zoneId} and sst.name=#{name}
     </select>
 
+    <select id="getStorgeByPointId" resultType="com.github.zuihou.business.edgeLibrary.entity.Storge">
+        select * from imcs_s_storge where point_id=#{start}
+                                       OR r_point_id LIKE CONCAT('%', #{start}, '%')
+    </select>
+
+
 </mapper>

+ 7 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/externalApi/WmsAgvInfoMapper.xml

@@ -2,4 +2,11 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.github.zuihou.business.externalApi.dao.WmsAgvInfoMapper">
 
+    <select id="pageList">
+        select
+
+        from (
+
+        ) s ${ew.customSqlSegment}
+    </select>
 </mapper>

+ 98 - 0
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/WmsAgvInfoController.java

@@ -0,0 +1,98 @@
+package com.github.zuihou.business.controller.externalApi;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ReflectUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.base.R;
+import com.github.zuihou.base.controller.SuperSimpleController;
+import com.github.zuihou.base.request.PageParams;
+import com.github.zuihou.business.externalApi.entity.WmsAgvInfo;
+import com.github.zuihou.business.externalApi.service.WmsAgvInfoService;
+import com.github.zuihou.business.productionReadyCenter.entity.AAutoNodeLog;
+import com.github.zuihou.database.mybatis.conditions.Wraps;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
+import com.github.zuihou.log.annotation.SysLog;
+import com.github.zuihou.utils.DateUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.lang.reflect.Field;
+import java.util.Iterator;
+import java.util.Map;
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("/wmsAgvInfo")
+@Api(value = "dispatchRecord", tags = "调度对话")
+@SysLog(enabled = true)
+public class WmsAgvInfoController extends SuperSimpleController<WmsAgvInfoService, WmsAgvInfo> {
+
+    @Autowired
+    private WmsAgvInfoService wmsAgvInfoService;
+
+    @ApiOperation(value = "查询对话调度记录", notes = "查询对话调度记录")
+    @PostMapping("/page")
+    public R<IPage<WmsAgvInfo>> page(@RequestBody @Validated PageParams<WmsAgvInfo> params) {
+        IPage<WmsAgvInfo> page = params.buildPage();
+        QueryWrap<WmsAgvInfo> wrap = handlerWrapper(null, params);
+        LbqWrapper<WmsAgvInfo> wrapper = wrap.lambda();
+
+        wrapper.orderByDesc(WmsAgvInfo::getCreateTime);
+        wmsAgvInfoService.pageList(page, wrapper);
+        return this.success(page);
+    }
+
+    private QueryWrap<WmsAgvInfo> handlerWrapper(WmsAgvInfo model, PageParams<WmsAgvInfo> params) {
+        QueryWrap<WmsAgvInfo> wrapper = model == null ? Wraps.q() : Wraps.q(model);
+        if (CollUtil.isNotEmpty(params.getMap())) {
+            Map<String, String> map = params.getMap();
+            Iterator var5 = map.entrySet().iterator();
+
+            while (var5.hasNext()) {
+                Map.Entry<String, String> field = (Map.Entry) var5.next();
+                String key = (String) field.getKey();
+                String value = (String) field.getValue();
+                if (!StrUtil.isEmpty(value)) {
+                    String beanField;
+                    if (key.endsWith("_st")) {
+                        beanField = StrUtil.subBefore(key, "_st", true);
+                        wrapper.ge(this.getDbField(beanField, this.getEntityClass()), DateUtils.getStartTime(value));
+                    }
+
+                    if (key.endsWith("_ed")) {
+                        beanField = StrUtil.subBefore(key, "_ed", true);
+                        wrapper.le(this.getDbField(beanField, this.getEntityClass()), DateUtils.getEndTime(value));
+                    }
+                }
+            }
+        }
+        return wrapper;
+    }
+    private String getDbField(String beanField, Class<?> clazz) {
+        Field field = ReflectUtil.getField(clazz, beanField);
+        if (field == null) {
+            return "";
+        } else {
+            TableField tf = (TableField)field.getAnnotation(TableField.class);
+            if (tf != null && StringUtils.isNotEmpty(tf.value())) {
+                String str = tf.value();
+                return str;
+            } else {
+                return "";
+            }
+        }
+    }
+
+}

+ 29 - 5
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/ToolbarController.java

@@ -17,6 +17,8 @@ import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.DemoLine.DemoLineConstant;
 import com.github.zuihou.business.DemoLine.YunjianConstant;
 import com.github.zuihou.business.controller.productionResourceCenter.StationUserController;
+import com.github.zuihou.business.edgeLibrary.dao.StockInfoMapper;
+import com.github.zuihou.business.edgeLibrary.dao.StorgeMapper;
 import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
 import com.github.zuihou.business.edgeLibrary.entity.Storge;
 import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
@@ -35,6 +37,7 @@ import com.github.zuihou.business.operationManagementCenter.service.TaskService;
 import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
 import com.github.zuihou.business.productionReadyCenter.entity.AAutoNodeLog;
 import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureProductionresource;
+import com.github.zuihou.business.productionReadyCenter.entity.Tray;
 import com.github.zuihou.business.productionReadyCenter.service.AAutoNodeLogService;
 import com.github.zuihou.business.productionReadyCenter.service.BomProcedureProductionresourceService;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
@@ -43,6 +46,7 @@ import com.github.zuihou.business.productionResourceCenter.entity.Productionreso
 import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
 import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
+import com.github.zuihou.business.util.CommonUtil;
 import com.github.zuihou.business.util.DynamicRabbitMq;
 import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.common.constant.BizConstant;
@@ -96,6 +100,10 @@ public class ToolbarController {
     @Autowired
     private StorgeService storgeService;
     @Autowired
+    private StorgeMapper storgeMapper;
+    @Autowired
+    private StockInfoMapper stockInfoMapper;
+    @Autowired
     private MsgUtil msgUtil;
     @Autowired
     private TaskNodeService taskNodeService;
@@ -153,10 +161,21 @@ public class ToolbarController {
         String goal = data.containsKey("goal")? data.get("goal").toString() : null;
         if(StringUtils.isEmpty(start) || StringUtils.isEmpty(goal)) return R.fail("数据传参为空");
 
-        if(start.length()!=10 || goal.length()!=10)return R.fail("参数长度不为10");
 
         String instructionUrl = "/api/RobotAction";
 
+        Storge startStorge = storgeMapper.getStorgeByPointId(start);
+        Storge endStorge = storgeMapper.getStorgeByPointId(goal);
+        if(startStorge==null || endStorge==null){
+            return R.fail("库位不存在");
+        }
+        String trayLatheTypeCode = stockInfoMapper.getTrayLatheTypeCode(startStorge.getId());
+        Tray trayNoByStorgeId = stockInfoMapper.getTrayNoByStorgeId(startStorge.getId());
+        if(trayLatheTypeCode==null){
+            return R.fail("托盘类型未知");
+        }
+
+
         JSONObject jsonParam = new JSONObject();
         jsonParam.put("taskId",  "1");
         jsonParam.put("taskNodeId",  "1");
@@ -164,17 +183,22 @@ public class ToolbarController {
         jsonParam.put("code",  "1");
 
         JSONObject sub = new JSONObject();
-        sub.put("location",  start);
-        sub.put("destLocation",  goal);
+        sub.put("location", CommonUtil.getLocationValue(startStorge.getPointId(),trayLatheTypeCode));
+        sub.put("destLocation",  CommonUtil.getLocationValue(endStorge.getPointId(),trayLatheTypeCode));
         sub.put("taskType",  "1");
         sub.put("carryType",  "1");
-
+        sub.put("trayLatheType",  trayLatheTypeCode);
+        sub.put("trayLatheCode",  trayNoByStorgeId.getNo());
         jsonParam.put("data", sub);
 
         TaskNode taskNode = new TaskNode();
-        taskNode.setResourceId(1496354880934117376L);
+        taskNode.setResourceId(1943971692378902529L);
 
         String returnData = msgUtil.getCcsData(instructionUrl, jsonParam, taskNode);
+
+        UpdateWrapper<StockInfo> updateWrapper = new UpdateWrapper<StockInfo>();
+        updateWrapper.lambda().eq(StockInfo::getStorgeId, startStorge.getId()).le(StockInfo::getGoodsType, 4).set(StockInfo::getStorgeId, endStorge.getId());
+        stockInfoService.update(null, updateWrapper);
         return R.success(returnData);
     }