cl
2024-07-30 a9072821f163cf6253cd312b5020e4b8efd19f2b
修改采集参数
已修改1个文件
44 ■■■■ 文件已修改
jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
@@ -8,6 +8,7 @@
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.jcdm.framework.websocket.WebSocketUsers;
import com.jcdm.main.constant.Constants;
import com.jcdm.main.da.cellData.service.IDaCellDataService;
@@ -117,6 +118,10 @@
                        Object stationStatusObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus").getValue();//站状态地址
                        if (ObjectUtil.isNotNull(stationStatusObjcet)){
                            String stationStatus = stationStatusObjcet.toString();
                            if(Constants.OP010.equals(device)) {
                                updateOrderStatus(snCode, "3");//OP010工位更新工单状态为执行中
                                reportFactoryMes(snCode, device, format.format(new Date()));//工厂MES报工
                            }
                            result = savePassingStation(thoroughfare, device,snCode,orderNumber,stationStatus);//保存过站
                            if(result == 21) {
                                result = saveParamCollection(device,snCode,orderNumber,stationStatus);//保存参数,发送工厂MES
@@ -247,13 +252,9 @@
                    mesList.add(childVO);
                }
               /* CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
                /*CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
                    //插入参数采集表
                    daParamCollectionService.insertBatch(collectionList);
                    //生产报工(首工位和末工位)
                    if(Constants.OP010.equals(device)) {
                        reportFactoryMes(snCode, device, format.format(new Date()));
                    }
                    //上传到工厂mes
                    ParentVO parentVO = new ParentVO();
                    parentVO.setStationCode(device);//工位
@@ -343,6 +344,25 @@
    }
    /**
     * 更新工单
     * @param snCode 产品sn
     * @param orderStatus 工单状态
     * @throws Exception e
     */
    private static void updateOrderStatus(String snCode,String orderStatus){
        try {
            //更新工单状态为已执行
            LambdaUpdateWrapper<OmProductionOrdeInfo> updateWrapper = new LambdaUpdateWrapper<>();
            updateWrapper.set(OmProductionOrdeInfo::getOrderStatus,orderStatus);
            updateWrapper.eq(OmProductionOrdeInfo::getProductNum,snCode);
            omProductionOrdeInfoService.update(new OmProductionOrdeInfo(),updateWrapper);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    /**
     * 工厂MES报工
     * @param productNum  通道
     * @param stationCode 工位
@@ -352,12 +372,16 @@
    //{"code":"success","data":{"productNum":"LCV123456P0600036","stationCode":"1HZ01","resultCode":"S","resultText":"报工成功"},"message":"API调用成功"}
    public static void reportFactoryMes(String productNum, String stationCode, String confirmTime)
    {
        String result = "";
        try {
            String url = Constants.FACTORY_EMS_UAT_GET_RUL + "workReportResultFeedback?siteCode="+Constants.FACTORY_EMS_SITE_CODE+"&stationCode="+stationCode+"&productNum="+productNum+"&confirmTime="+confirmTime;
            HttpResponse response = HttpRequest.get(url).execute();
            /*HttpRequest httpRequest = HttpRequest.get(url);*/
            result =  response.body();
            CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
                log.info("请求工厂MES报工:入参device{},productNum:{}", stationCode, productNum);
                String url = Constants.FACTORY_EMS_UAT_GET_RUL + "workReportResultFeedback?siteCode="+Constants.FACTORY_EMS_SITE_CODE+"&stationCode="+stationCode+"&productNum="+productNum+"&confirmTime="+confirmTime;
                HttpResponse response = HttpRequest.get(url).execute();
                /*HttpRequest httpRequest = HttpRequest.get(url);*/
                String result =  response.body();
                log.info("请求工厂MES报工:出参:{}", result);
            });
        }catch (Exception e){
            throw new RuntimeException(e);
        }