zjj
2023-11-30 f6e955d57bf5e885afde54a8c6eefe80bc1bec26
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -4,7 +4,9 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.R;
import com.core.exception.CoolException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zy.asrs.domain.enums.TaskStatusType;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.WMSAndAGVInterfaceParam;
@@ -23,6 +25,7 @@
import com.zy.core.model.CrnSlave;
import com.zy.core.model.DevpSlave;
import com.zy.core.model.Task;
import com.zy.core.model.command.CommandPackage;
import com.zy.core.model.command.CrnCommand;
import com.zy.core.model.protocol.CrnProtocol;
import com.zy.core.model.protocol.StaProtocol;
@@ -39,8 +42,11 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 立体仓库WCS系统主流程业务
@@ -77,6 +83,9 @@
    private StaDescMapper staDescMapper;
    @Autowired
    private CommandInfoService commandInfoService;
    @Autowired
    private OpenServiceImpl openServiceImpl;
    @Value("${wms.url}")
    private String wmsUrl;
@@ -157,7 +166,29 @@
                    }
                    String barcode = barcodeThread.getBarcode();
                    if(!Cools.isEmpty(barcode)) {
//                        ToWmsDTO toWmsDTO = new ToWmsDTO();
//                        Map<String, Object> map = new HashMap<>();
//                        map.put("x-api-key","7a15b5db-29b6-552c-8cff-0cfec3756da2");
//                        List<Integer> list = openServiceImpl.getInEnableRoadway();
//
//                        //TaskWrk taskWrk = taskWrkService.selectByTaskNo(param.getTaskNo());
//                        toWmsDTO.setWarehouseId("1688469798893297665");
//                        toWmsDTO.setContainerCode(param.getContainerCode());
//                        toWmsDTO.setApplyType("TUNNEL");
//                        toWmsDTO.setWharfSource(null);
//                        toWmsDTO.setCanInboundTunnels(list);
//                        String response = null;
//                        try {
//                            response = new HttpHandler.Builder()
//                                    .setHeaders(map)
//                                    .setUri(wmsUrl)
//                                    .setPath("wcsManager/wcsInterface/inboundTaskApply")
//                                    .setJson(JSON.toJSONString(toWmsDTO))
//                                    .build()
//                                    .doPost();
//                        }catch (Exception e){
//
//                        }
                    }
                }
@@ -211,9 +242,14 @@
                                if (commandInfos.isEmpty()) {
                                    continue;//命令空
                                }
//                                CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//取出命令报文
//                                CrnCommand crnCommand = JSON.parseObject(commandPackage.getCommand().toString(), CrnCommand.class);
                                Integer commandStep = taskWrk.getCommandStep();
                                CommandInfo commandInfo = commandInfos.get(commandStep);
                                StaProtocol staProtocol1 = JSON.parseObject(commandInfo.getCommand(), StaProtocol.class);
                                CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//取出命令报文
                                //StaProtocol staProtocol1 = JSON.parseObject(commandInfo.getCommand(), StaProtocol.class);
                                StaProtocol staProtocol1 = JSON.parseObject(commandPackage.getCommand().toString(), StaProtocol.class);
                                if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol1))) {
                                    log.error("输送线命令下方失败!!! [工作号:{}]", taskWrk.getWrkNo());
                                    continue;//命令下发失败
@@ -234,7 +270,7 @@
    /**
     * 入出库  ===>>  堆垛机入出库作业下发
     */
    public synchronized void crnIoExecute(){
    public synchronized void crnIoExecute() throws IOException {
        for (CrnSlave crn : slaveProperties.getCrn()) {
            // 获取堆垛机信息
            CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
@@ -279,7 +315,7 @@
    /**
     * 入库  ===>>  堆垛机站到库位
     */
    public void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol){
    public void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol) throws IOException {
        for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) {
            List<StaDesc> staDescs = staDescMapper.selectList(new EntityWrapper<StaDesc>().eq("crn_no", slave.getId()).eq("crn_stn", crnStn.getStaNo()));
            for (StaDesc staDesc : staDescs) {
@@ -328,7 +364,8 @@
                    continue;//命令空
                }
                CommandInfo commandInfo = commandInfos.get(commandStep);
                CrnCommand crnCommand = JSON.parseObject(commandInfo.getCommand(), CrnCommand.class);//取出命令报文
                CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//取出命令报文
                CrnCommand crnCommand = JSON.parseObject(commandPackage.getCommand().toString(), CrnCommand.class);
                if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) {
                    log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand));
@@ -468,7 +505,8 @@
                            continue;//命令空
                        }
                        CommandInfo commandInfo = commandInfos.get(commandStep);
                        CrnCommand crnCommand = JSON.parseObject(commandInfo.getCommand(), CrnCommand.class);//取出命令报文
                        CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//取出命令报文
                        CrnCommand crnCommand = JSON.parseObject(commandPackage.getCommand().toString(), CrnCommand.class);
                        if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) {
                            log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand));