Browse Source

手动模式移到后回调手动模式更新库位信息

yejian016332 3 năm trước cách đây
mục cha
commit
2d2bd9cbdb

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

@@ -2,6 +2,7 @@ package com.github.zuihou.business.operationManagementCenter.service.impl;
 
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -30,6 +31,7 @@ import com.github.zuihou.business.productionResourceCenter.dao.Productionresourc
 import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourceConf;
 import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourceConf;
 import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
 import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
 import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
 import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
+import com.github.zuihou.business.productionResourceCenter.entity.ZZoneProductionresource;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
 import com.github.zuihou.business.productionResourceCenter.service.ResourceAutoCodeService;
 import com.github.zuihou.business.productionResourceCenter.service.ResourceAutoCodeService;
 import com.github.zuihou.business.productionResourceCenter.service.ResourceBusinessService;
 import com.github.zuihou.business.productionResourceCenter.service.ResourceBusinessService;
@@ -282,6 +284,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
 
 
 
 
 
+    @Override
     public void saveTaskNodeByTaskBatchNoNew(String taskBatchNo, SysUser sysUser) {
     public void saveTaskNodeByTaskBatchNoNew(String taskBatchNo, SysUser sysUser) {
         //生成节点任务
         //生成节点任务
         List<TTask> taskList = taskService.list(Wraps.<TTask>lbQ().eq(TTask::getTaskBatchNo, taskBatchNo).orderByDesc(TTask::getPrority));
         List<TTask> taskList = taskService.list(Wraps.<TTask>lbQ().eq(TTask::getTaskBatchNo, taskBatchNo).orderByDesc(TTask::getPrority));
@@ -1609,7 +1612,6 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
                 List<ProductionresourcePosition> targetList = productionresourcePositionMapper.getStorgeIdByResource(queryMap);
                 List<ProductionresourcePosition> targetList = productionresourcePositionMapper.getStorgeIdByResource(queryMap);
 
 
                 // 先将原库位上所有物料信息读取出来
                 // 先将原库位上所有物料信息读取出来
-
                 List<StockInfo> stockInfos = stockInfoMapper.selectList(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId, sourceList.get(0).getStorgeId()));
                 List<StockInfo> stockInfos = stockInfoMapper.selectList(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId, sourceList.get(0).getStorgeId()));
                 for(StockInfo stockInfo : stockInfos){
                 for(StockInfo stockInfo : stockInfos){
                     // 更新出库信息
                     // 更新出库信息
@@ -1621,6 +1623,43 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
                     stockInfoMapper.updateById(stockInfo);
                     stockInfoMapper.updateById(stockInfo);
                 }
                 }
                 msgUtil.redis_del(manualInfo.getManualId());
                 msgUtil.redis_del(manualInfo.getManualId());
+
+                // 通知手动页面刷新库位信息
+                // 组装参数
+                String returnData = "";
+                //组装接口参数
+                HttpHeaders headers = new HttpHeaders();
+                headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
+
+                R r = R.success();
+
+                Map<String, Object> retStockInfo = new HashMap<String, Object>();
+
+                List<Map> allReturnList = new ArrayList<>();
+
+                List<Map> returnBeginStockList =  processStockInfo(manualInfo.getDeviceUnit() ,manualInfo.getStartResourceId(),manualInfo.getStartpointId());
+                allReturnList.addAll(returnBeginStockList);
+                List<Map> returnEndStockList =  processStockInfo(manualInfo.getDeviceUnit() ,manualInfo.getEndResourceId(),manualInfo.getEndpointId());
+                allReturnList.addAll(returnEndStockList);
+
+                HttpEntity<String> formEntity = new HttpEntity<String>(JSON.toJSON(allReturnList).toString(), headers);
+                //调用接口
+                try {
+                    JSONObject returnDataObject = new JSONObject();
+                    returnData = restTemplate.postForObject("http://192.168.10.136:8089", formEntity, String.class);
+                    returnDataObject = JSONObject.parseObject(returnData);
+                    if("0".equals(returnDataObject.get("code"))){
+                    }else{
+                        log.error("手动模式同步库位信息发生异常");
+                    }
+                }catch (Exception e) {
+                    e.printStackTrace();
+                    JSONObject errJsonObject = new JSONObject();
+                    errJsonObject.put("msg", e.getMessage());
+                    returnData = errJsonObject.toJSONString();
+                    log.error("调用接口发生异常" + e.getMessage());
+                }
+
                 return R.success();
                 return R.success();
             }else{
             }else{
                 // 继续执行后续结点
                 // 继续执行后续结点
@@ -1787,4 +1826,61 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         return logBean;
         return logBean;
     }
     }
 
 
+    private List<Map> processStockInfo(String zZoneCode, String resourceId, String pointId) {
+        List<Map> returnList = new ArrayList<>();
+        Map map = new HashMap();
+        map.put("resourceId", resourceId);
+        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;
+    }
+
 }
 }

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

@@ -107,7 +107,12 @@
              zuihou_base_yj_0000.imcs_s_storge s left join zuihou_base_yj_0000.imcs_s_stock_info i on (p.storge_id = i.storge_id)
              zuihou_base_yj_0000.imcs_s_storge s left join zuihou_base_yj_0000.imcs_s_stock_info i on (p.storge_id = i.storge_id)
         WHERE 1=1
         WHERE 1=1
         AND p.storge_id = s.id
         AND p.storge_id = s.id
-        AND p.resource_id = #{resourceId}
+        <if test="resourceId != null and resourceId != ''">
+            and p.resource_id = #{resourceId}
+        </if>
+        <if test="pointId != null and pointId != ''">
+            and p.point_id = #{pointId}
+        </if>
     </select>
     </select>
 
 
 </mapper>
 </mapper>