| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.jcdm.common.core.domain.AjaxResult; |
| | | 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.domain.DaCellData; |
| | |
| | | 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; |
| | |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | 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; |
| | |
| | | public class OPCUaSubscription implements SubscriptionCallback { |
| | | |
| | | public static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | public static Calendar calendar = Calendar.getInstance(); |
| | | |
| | | Map<String, Session> map = WebSocketUsers.getUsers(); |
| | | public static MiloService miloService; |
| | |
| | | |
| | | public static IDaCellDataService daCellDataService; |
| | | |
| | | public static IDaPsConfService daPsConfService; |
| | | |
| | | /* @Value("${orderLineUrl}") |
| | | private static String orderLineUrl;*/ |
| | | |
| | |
| | | IDaParamCollectionService daParamCollectionService, |
| | | IOmProductionOrdeInfoService omProductionOrdeInfoService, |
| | | IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService, |
| | | IDaCellDataService daCellDataService) { |
| | | IDaCellDataService daCellDataService, |
| | | IDaPsConfService daPsConfService) { |
| | | OPCUaSubscription.miloService = miloService; |
| | | OPCUaSubscription.daPassingStationCollectionService = daPassingStationCollectionService; |
| | | OPCUaSubscription.collectionParamConfService = collectionParamConfService; |
| | |
| | | OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService; |
| | | OPCUaSubscription.daTestDeviceInterfaceTempService = daTestDeviceInterfaceTempService; |
| | | OPCUaSubscription.daCellDataService = daCellDataService; |
| | | OPCUaSubscription.daPsConfService = daPsConfService; |
| | | } |
| | | |
| | | |
| | |
| | | if (CollUtil.isNotEmpty(list)){ |
| | | for(DaCollectionParamConf conf:list){ |
| | | //1P1S生成 |
| | | if(conf.getCollectParameterId().equals("OCV_1P1SMID")){ |
| | | String result = ""; |
| | | if(conf.getCollectParameterId().equals("1P1S")){ |
| | | String result = get1P1S(sfcCode); |
| | | conf.setParamCentral(result); |
| | | } |
| | | ChildVO childVO = new ChildVO(); |
| | |
| | | basicList.add(childVO); |
| | | |
| | | DaParamCollection daParamCollection = new DaParamCollection(); |
| | | daParamCollection.setSfcCode(sfcCode);//模组码 |
| | | daParamCollection.setSfcCode(sfcCode);//总成码 |
| | | daParamCollection.setParamCode(conf.getCollectParameterId());//参数编码 |
| | | daParamCollection.setParamName(conf.getCollectParameterName());//参数名称 |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 生成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();//厂商代码 |
| | | String proTypeCode = list.get(0).getProTypeCode();//产品类型代码 |
| | | String batteryTypeCode = list.get(0).getBatteryTypeCode();//电池类型代码 |
| | | String specificationsCode = list.get(0).getSpecificationsCode();//规格代码 |
| | | String traceInfoCode = list.get(0).getTraceInfoCode();//追溯信息代码 |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | } |