| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.BarcodeThread; |
| | | import com.zy.core.thread.DevpThread; |
| | | import com.zy.asrs.entity.BasMap; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.service.BasMapService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.enums.MapNodeType; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/8/6 |
| | | * 立体仓库WCS系统主流程业务 |
| | | */ |
| | | @Slf4j |
| | | @Service("mainService") |
| | | public class MainServiceImpl { |
| | | |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | private BasMapService basMapService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | /** |
| | | * 入库站,根据条码扫描生成入库工作档,工作状态1 |
| | | */ |
| | | @Transactional |
| | | public void generateStoreWrkFile() { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历入库口 |
| | | for (DevpSlave.InSta inSta : devp.getInSta()) { |
| | | // 获取条码 |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); |
| | | String barcode = barcodeThread.getBarcode(); |
| | | // 获取入库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); |
| | | // 判断是否满足入库条件 |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInreq1() |
| | | && !staProtocol.isEmptyMk() && staProtocol.isInreq1() && staProtocol.getWorkNO() ==0 |
| | | && !Cools.isEmpty(barcode)) { |
| | | // 生成工作档 |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | //初始化库位地图数据结构 |
| | | public void initLocMap() { |
| | | Object object = redisUtil.get(RedisKeyType.LOC_MAP_BASE.key); |
| | | if (object != null) { |
| | | return; |
| | | } |
| | | |
| | | BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", 1)); |
| | | if (Cools.isEmpty(basMap)){ |
| | | //缺少初始化库位地图 |
| | | return; |
| | | } |
| | | |
| | | List<List<JSONObject>> dataList = JSON.parseObject(basMap.getData(), List.class); |
| | | List<List<HashMap<String, Object>>> mapNodeList = new ArrayList<>(); |
| | | for (int i = 0; i < dataList.size(); i++) { |
| | | List<JSONObject> row = dataList.get(i); |
| | | List<HashMap<String, Object>> mapNodeRow = new ArrayList<>(); |
| | | |
| | | for (int j = 0; j < row.size(); j++) { |
| | | JSONObject map = row.get(j); |
| | | |
| | | HashMap<String, Object> mapNode = new HashMap<>(); |
| | | mapNode.put("id", i + "-" + j); |
| | | |
| | | String nodeType = map.getString("type"); |
| | | if("shelf".equals(nodeType)) { |
| | | mapNode.put("value", MapNodeType.NORMAL_PATH.id); |
| | | }else { |
| | | mapNode.put("value", MapNodeType.DISABLE.id); |
| | | } |
| | | |
| | | mapNodeRow.add(mapNode); |
| | | } |
| | | mapNodeList.add(mapNodeRow); |
| | | } |
| | | |
| | | redisUtil.set(RedisKeyType.LOC_MAP_BASE.key, mapNodeList); |
| | | } |
| | | |
| | | } |