自动化立体仓库 - WCS系统
zyx
2024-01-31 1b410cd3e265568909aaba902923d166c2a73fe9
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -4,21 +4,14 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.R;
import com.core.common.SpringUtils;
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.TaskOverToWms;
import com.zy.asrs.entity.param.WMSAndAGVInterfaceParam;
import com.zy.asrs.entity.param.taskCreateParam;
import com.zy.asrs.mapper.*;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.CommandUtils;
import com.zy.asrs.utils.PostMesDataUtils;
import com.zy.asrs.utils.Utils;
import com.zy.common.service.CommonService;
import com.zy.common.utils.HttpHandler;
import com.zy.core.CrnThread;
import com.zy.core.DevpThread;
@@ -34,7 +27,6 @@
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.BarcodeThread;
import com.zy.core.thread.LedThread;
import com.zy.core.thread.SiemensDevpThread;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
@@ -43,6 +35,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.io.IOException;
import java.util.*;
@@ -100,6 +93,9 @@
    public void generateStoreWrkFile() throws IOException, InterruptedException {
        try {
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历入库口
@@ -186,20 +182,23 @@
                        // 请求wms接口,获取工作号和目标库位
                        ToWmsDTO toWmsDTO = new ToWmsDTO(barcode,staProtocol.getSiteId());
                        String response;
                        try {
                            response = new HttpHandler.Builder()
                                    .setHeaders(null)
                                    .setUri(wmsUrl)
                                    .setPath(inboundTaskApplyPath)
                                    .setJson(JSON.toJSONString(toWmsDTO))
                                    .build()
                                    .doPost();
                        }catch (Exception e){
                            log.error("wms通讯失败,"+e.getMessage());
                            continue;
                        }
                        response = new HttpHandler.Builder()
                                .setHeaders(null)
                                .setUri(wmsUrl)
                                .setPath(inboundTaskApplyPath)
                                .setJson(JSON.toJSONString(toWmsDTO))
                                .build()
                                .doPost();
                        JSONObject jsonObject = JSON.parseObject(response);
                        apiLogService.save("wms请求入库货位接口"
                                ,wmsUrl+inboundTaskApplyPath
                                ,null
                                ,"127.0.0.1"
                                ,JSON.toJSONString(toWmsDTO)
                                ,response
                                ,true
                        );
                        if (jsonObject.getInteger("code").equals(200) && !Cools.isEmpty(jsonObject.get("data").toString())) {
                            GetWmsDto getWmsDto = JSON.parseObject(jsonObject.get("data").toString(), GetWmsDto.class);
                            // 创新一个入库工作档
@@ -301,6 +300,10 @@
            }
        }
        } catch (Exception e) {
            log.error("generateStoreWrkFile e", e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }