From 4162bc5d79a97971522615d8aca811034374d48e Mon Sep 17 00:00:00 2001 From: cl <418351270@qq.com> Date: 星期五, 16 八月 2024 10:29:15 +0800 Subject: [PATCH] 修改1P1S --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 61 +++++++++++++++++++++++++++++- 1 files changed, 59 insertions(+), 2 deletions(-) diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java index 9001f14..3852bd2 100644 --- a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java +++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java @@ -9,6 +9,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.common.core.domain.AjaxResult; import com.jcdm.framework.websocket.WebSocketUsers; import com.jcdm.main.constant.Constants; @@ -20,6 +21,8 @@ import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; +import com.jcdm.main.da.psConf.domain.DaPsConf; +import com.jcdm.main.da.psConf.service.IDaPsConfService; import com.jcdm.main.da.testDeviceInterfaceTemp.domain.DaTestDeviceInterfaceTemp; import com.jcdm.main.da.testDeviceInterfaceTemp.service.IDaTestDeviceInterfaceTempService; import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; @@ -32,12 +35,14 @@ import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; import com.kangaroohy.milo.service.MiloService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.GetMapping; import javax.websocket.Session; import java.text.SimpleDateFormat; +import java.time.LocalDate; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @@ -65,7 +70,7 @@ public static IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService; public static IDaCellDataService daCellDataService; - + public static IDaPsConfService daPsConfService; /* @Value("${orderLineUrl}") private static String orderLineUrl;*/ @@ -75,7 +80,8 @@ IDaParamCollectionService daParamCollectionService, IOmProductionOrdeInfoService omProductionOrdeInfoService, IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService, - IDaCellDataService daCellDataService) { + IDaCellDataService daCellDataService, + IDaPsConfService daPsConfService) { OPCUaSubscription.miloService = miloService; OPCUaSubscription.daPassingStationCollectionService = daPassingStationCollectionService; OPCUaSubscription.collectionParamConfService = collectionParamConfService; @@ -83,6 +89,7 @@ OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService; OPCUaSubscription.daTestDeviceInterfaceTempService = daTestDeviceInterfaceTempService; OPCUaSubscription.daCellDataService = daCellDataService; + OPCUaSubscription.daPsConfService = daPsConfService; } @@ -1070,6 +1077,11 @@ ); if (CollUtil.isNotEmpty(list)){ for(DaCollectionParamConf conf:list){ + //1P1S鐢熸垚 + if(conf.getCollectParameterId().equals("1P1S")){ + String result = get1P1S(sfcCode); + conf.setParamCentral(result); + } ChildVO childVO = new ChildVO(); childVO.setItemCode(conf.getCollectParameterId());//鍙傛暟 childVO.setItemType(conf.getItemType()); @@ -1096,7 +1108,52 @@ throw new RuntimeException(e); } } + /** + * 鐢熸垚1P1S鐮� + * @param sfcCode + * @return list + */ + public static String get1P1S(String sfcCode) { + String result = ""; + LocalDate now = LocalDate.now(); + String supplierCode = sfcCode.substring(0,3); + try { + List<DaPsConf> list = daPsConfService.list(new LambdaQueryWrapper<DaPsConf>() + .eq(DaPsConf::getSpareField1, supplierCode)//渚涘簲鍟嗚瘑鍒爜 + .eq(DaPsConf::getState,"1"));//鐘舵�� + if(!list.isEmpty()){ + String mfCode = list.get(0).getMfCode();//鍘傚晢浠g爜 + String proTypeCode = list.get(0).getProTypeCode();//浜у搧绫诲瀷浠g爜 + String batteryTypeCode = list.get(0).getBatteryTypeCode();//鐢垫睜绫诲瀷浠g爜 + String specificationsCode = list.get(0).getSpecificationsCode();//瑙勬牸浠g爜 + String traceInfoCode = list.get(0).getTraceInfoCode();//杩芥函淇℃伅浠g爜 + String proDateCode = Constants.YEARSMAP.get(now.getYear()) + + Constants.MONTHSMAP.get(now.getMonthValue()) + + Constants.DAYMAP.get(now.getDayOfMonth());//鐢熶骇鏃ユ湡 + + String code = list.get(0).getSfcCode();//搴忓垪鍙� + code = StringUtils.leftPad(String.valueOf(Integer.valueOf(code)+1),7, "0");;//搴忓垪鍙� + result = mfCode+proTypeCode+batteryTypeCode+specificationsCode+traceInfoCode+proDateCode+code; + + log.info("璇诲彇鍒扮數鑺爜涓猴細{},1P1S鐮佷负锛歿}",sfcCode,result); + + //鏇存柊鏃ユ湡鍜屽簭鍒楀彿 + LambdaUpdateWrapper<DaPsConf> lambdaUpdateWrapper = new LambdaUpdateWrapper<DaPsConf>(); + lambdaUpdateWrapper.set(DaPsConf::getProDateCode,proDateCode);//鐢熶骇鏃ユ湡 + lambdaUpdateWrapper.set(DaPsConf::getSfcCode,code);//搴忓垪鍙� + lambdaUpdateWrapper.eq(DaPsConf::getSpareField1,supplierCode);//渚涘簲鍟嗚瘑鍒爜 + lambdaUpdateWrapper.eq(DaPsConf::getState,"1");//鐘舵�� + daPsConfService.update(lambdaUpdateWrapper); + + }else{ + log.info("璇峰厛鍘�1P1S閰嶇疆椤甸潰閰嶇疆瑙勫垯!"); + } + return result; + }catch (Exception e) { + throw new RuntimeException(e); + } + } } -- Gitblit v1.9.3