From add0eea2acd7acc64b7f5bdb1d3d1ea8cadaf491 Mon Sep 17 00:00:00 2001 From: yanyang Date: Wed, 28 Dec 2022 10:31:27 +0800 Subject: [PATCH] =?UTF-8?q?influx=E5=8F=82=E6=95=B0=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProductFeaturesController.java | 12 +- .../cnbm/basic/dto/ProductFeaturesDTO.java | 6 + .../basic/mapper/ProductFeaturesMapper.java | 2 + .../service/IProductFeaturesService.java | 3 + .../impl/ProductFeaturesServiceImpl.java | 9 + .../mapper/ProductFeaturesMapper.xml | 6 + .../java/com/cnbm/influx/template/Sample.java | 30 +++ .../com/cnbm/influx/template/SampleParam.java | 27 +++ .../controller/InspectionSheetController.java | 18 ++ .../dto/InspectionSampleDTO3.java | 37 +++ .../service/IInspectionSheetService.java | 4 + .../impl/InspectionSheetServiceImpl.java | 222 +++++++++++------- .../mapper/InspectionSheetMapper.xml | 9 +- 13 files changed, 293 insertions(+), 92 deletions(-) create mode 100644 ym-influx/src/main/java/com/cnbm/influx/template/Sample.java create mode 100644 ym-influx/src/main/java/com/cnbm/influx/template/SampleParam.java create mode 100644 ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/InspectionSampleDTO3.java diff --git a/ym-baisc/src/main/java/com/cnbm/basic/controller/ProductFeaturesController.java b/ym-baisc/src/main/java/com/cnbm/basic/controller/ProductFeaturesController.java index 89e4387..308dc78 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/controller/ProductFeaturesController.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/controller/ProductFeaturesController.java @@ -2,9 +2,7 @@ package com.cnbm.basic.controller; import com.cnbm.admin.annotation.LogOperation; import com.cnbm.admin.params.IdParam; -import com.cnbm.basic.dto.FeaturesProcedureDTO; -import com.cnbm.basic.dto.FeaturesStageProcedureRelationDTO; -import com.cnbm.basic.dto.WorkingProcedureDTO; +import com.cnbm.basic.dto.*; import com.cnbm.basic.entity.ProductFeatures; import com.cnbm.common.constant.Constant; import com.cnbm.common.page.PageData; @@ -15,7 +13,6 @@ import com.cnbm.common.validator.ValidatorUtils; import com.cnbm.common.validator.group.AddGroup; import com.cnbm.common.validator.group.DefaultGroup; import com.cnbm.common.validator.group.UpdateGroup; -import com.cnbm.basic.dto.ProductFeaturesDTO; import com.cnbm.basic.excel.ProductFeaturesExcel; import com.cnbm.basic.service.IProductFeaturesService; import io.swagger.annotations.Api; @@ -162,4 +159,11 @@ public class ProductFeaturesController { return new Result>().ok(list); } + @PostMapping(value = "list") + @ApiOperation(value = "获取特性列表") + @LogOperation("获取特性列表") + public List list() { + return productFeaturesService.list(); + } + } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/dto/ProductFeaturesDTO.java b/ym-baisc/src/main/java/com/cnbm/basic/dto/ProductFeaturesDTO.java index 3b1959b..bec18fe 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/dto/ProductFeaturesDTO.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/dto/ProductFeaturesDTO.java @@ -112,4 +112,10 @@ public class ProductFeaturesDTO implements Serializable { @ApiModelProperty(value = "版本号") private Integer version; + @ApiModelProperty(value = "工序id,关联 working_procedure 表") + private Long workingProcedureId; + + @ApiModelProperty(value = "工序 名,关联working_procedure表") + private String workingProcedureName; + } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/mapper/ProductFeaturesMapper.java b/ym-baisc/src/main/java/com/cnbm/basic/mapper/ProductFeaturesMapper.java index af5bec6..975bbc2 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/mapper/ProductFeaturesMapper.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/mapper/ProductFeaturesMapper.java @@ -25,4 +25,6 @@ public interface ProductFeaturesMapper extends BaseDao { List getFeaturesList(Map params); String getControlGraphNameById(Long id); + + List list(); } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/service/IProductFeaturesService.java b/ym-baisc/src/main/java/com/cnbm/basic/service/IProductFeaturesService.java index 224dde9..4cdeaea 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/service/IProductFeaturesService.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/service/IProductFeaturesService.java @@ -1,5 +1,6 @@ package com.cnbm.basic.service; +import com.cnbm.basic.dto.FactoryDTO; import com.cnbm.basic.dto.FeaturesProcedureDTO; import com.cnbm.basic.dto.FeaturesStageProcedureRelationDTO; import com.cnbm.common.page.PageData; @@ -34,4 +35,6 @@ public interface IProductFeaturesService extends CrudService getFeaturesList(Map params); + + List list();; } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/service/impl/ProductFeaturesServiceImpl.java b/ym-baisc/src/main/java/com/cnbm/basic/service/impl/ProductFeaturesServiceImpl.java index 0257cd0..491d5dc 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/service/impl/ProductFeaturesServiceImpl.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/service/impl/ProductFeaturesServiceImpl.java @@ -64,6 +64,7 @@ public class ProductFeaturesServiceImpl extends CrudServiceImpl list = mapper.getFeaturesList(params); return list; } + + @Override + @Transactional(rollbackFor = Exception.class) + public List list() { + List list = mapper.list(); + return list; + } + } \ No newline at end of file diff --git a/ym-baisc/src/main/resources/mapper/ProductFeaturesMapper.xml b/ym-baisc/src/main/resources/mapper/ProductFeaturesMapper.xml index 68e2d03..023a079 100644 --- a/ym-baisc/src/main/resources/mapper/ProductFeaturesMapper.xml +++ b/ym-baisc/src/main/resources/mapper/ProductFeaturesMapper.xml @@ -73,4 +73,10 @@ + + + diff --git a/ym-influx/src/main/java/com/cnbm/influx/template/Sample.java b/ym-influx/src/main/java/com/cnbm/influx/template/Sample.java new file mode 100644 index 0000000..601ee50 --- /dev/null +++ b/ym-influx/src/main/java/com/cnbm/influx/template/Sample.java @@ -0,0 +1,30 @@ +package com.cnbm.influx.template; + +import com.influxdb.annotations.Column; +import com.influxdb.annotations.Measurement; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.time.Instant; + +/** + * @Desc: "常规计量值 - entity" + * @Author: caixiang + * @DATE: 2022/6/25 11:13 + */ +@Data +public class Sample { + + private String inspectionSheetId; + + private Instant sampleTime; + + private String workingProcedureName; + + private String sampleNumber; + + private String argName; + + private String argValue; + +} diff --git a/ym-influx/src/main/java/com/cnbm/influx/template/SampleParam.java b/ym-influx/src/main/java/com/cnbm/influx/template/SampleParam.java new file mode 100644 index 0000000..f462bda --- /dev/null +++ b/ym-influx/src/main/java/com/cnbm/influx/template/SampleParam.java @@ -0,0 +1,27 @@ +package com.cnbm.influx.template; + +import com.influxdb.annotations.Column; +import com.influxdb.annotations.Measurement; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.time.Instant; + +/** + * @Desc: "常规计量值 - entity" + * @Author: caixiang + * @DATE: 2022/6/25 11:13 + */ +@Data +public class SampleParam { + + private String workingProcedureName; + + //private String transationId; + + private String argName; + + private String argValue; + +} diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java index 6a77494..33b9dc8 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java @@ -17,6 +17,7 @@ import com.cnbm.common.validator.group.UpdateGroup; import com.cnbm.processInspection.dto.InspectionSampleDTO; import com.cnbm.processInspection.dto.InspectionSampleDTO2; +import com.cnbm.processInspection.dto.InspectionSampleDTO3; import com.cnbm.processInspection.dto.InspectionSheetDTO; import com.cnbm.processInspection.entity.InspectionSheet; import com.cnbm.processInspection.excel.InspectionSheetExcel; @@ -174,6 +175,12 @@ public class InspectionSheetController { return inspectionSheetService.getFluxParamList(inspectionSheetId); } + @PostMapping(value = "getFluxParamList3") + @ApiOperation(value = "从influxdb中获取检测参数3") + List getFluxParamList3(@RequestParam("inspectionSheetId") Long inspectionSheetId){ + return inspectionSheetService.getFluxParamList3(inspectionSheetId); + } + @PostMapping("saveFluxParamList") @ApiOperation("将样本检测参数写入influxdb") public Result saveFluxParamList(@RequestBody InspectionSampleDTO[] lists) throws InterruptedException{ @@ -196,6 +203,17 @@ public class InspectionSheetController { return new Result(); } + @PostMapping("saveFluxParamList3") + @ApiOperation("将样本检测参数写入influxdb3") + public Result saveFluxParamList3(@RequestBody InspectionSampleDTO3[] lists) throws InterruptedException{ + + inspectionSheetService.saveFluxParamList3(lists); + Thread.sleep(1000); + //样本数据更新后 计算检验单缺陷数不良数 + inspectionSheetService.calculate(Long.valueOf(lists[0].getInspectionSheetId())); + return new Result(); + } + @PostMapping("getInspectionSheetFeaturesList") @ApiOperation("获取检验单对应检验属性") @ApiImplicitParams({ diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/InspectionSampleDTO3.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/InspectionSampleDTO3.java new file mode 100644 index 0000000..5916c3f --- /dev/null +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/InspectionSampleDTO3.java @@ -0,0 +1,37 @@ +package com.cnbm.processInspection.dto; + +import com.cnbm.influx.template.Event; +import com.cnbm.influx.template.SampleParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.Instant; +import java.util.List; + +/** + * 检验样本 表 + * + * @author yanyang + * @since 2022-11-24 + */ +@Data +@ApiModel(value = "检验样本 DTO3对象") +public class InspectionSampleDTO3 implements Serializable { + + @ApiModelProperty(value = "检验单id") + private String inspectionSheetId; + + @ApiModelProperty(value = "取样时间") + private Instant sampleTime; + + @ApiModelProperty(value = "批次号") + private String batchNum; + + @ApiModelProperty(value = "样本号") + private String sampleNumber; + + @ApiModelProperty(value = "检验参数") + private List sampleParamList; +} diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/IInspectionSheetService.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/IInspectionSheetService.java index 490bbd5..f860517 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/IInspectionSheetService.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/IInspectionSheetService.java @@ -8,6 +8,7 @@ import com.cnbm.influx.param.QueryDataParam; import com.cnbm.influx.template.Event; import com.cnbm.processInspection.dto.InspectionSampleDTO; import com.cnbm.processInspection.dto.InspectionSampleDTO2; +import com.cnbm.processInspection.dto.InspectionSampleDTO3; import com.cnbm.processInspection.dto.InspectionSheetDTO; import com.cnbm.processInspection.entity.InspectionSheet; import com.influxdb.query.FluxTable; @@ -37,9 +38,12 @@ public interface IInspectionSheetService extends CrudService getFluxParamList(Map params); List getFluxParamList(Long inspectionSheetId); + List getFluxParamList3(Long inspectionSheetId); void saveFluxParamList(InspectionSampleDTO[] lists); void saveFluxParamList2(InspectionSampleDTO2[] lists); + void saveFluxParamList3(InspectionSampleDTO3[] lists); + List getInspectionSheetFeaturesList(Map params); void calculate(Long inspectionSheetId); diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/impl/InspectionSheetServiceImpl.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/impl/InspectionSheetServiceImpl.java index 126331f..dc16d93 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/impl/InspectionSheetServiceImpl.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/impl/InspectionSheetServiceImpl.java @@ -6,14 +6,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.cnbm.basic.dto.ProductFeaturesDTO; -import com.cnbm.basic.entity.Machine; -import com.cnbm.basic.entity.Product; -import com.cnbm.basic.entity.Shift; -import com.cnbm.basic.entity.WorkingProcedure; -import com.cnbm.basic.service.impl.MachineServiceImpl; -import com.cnbm.basic.service.impl.ProductServiceImpl; -import com.cnbm.basic.service.impl.ShiftServiceImpl; -import com.cnbm.basic.service.impl.WorkingProcedureServiceImpl; +import com.cnbm.basic.dto.WorkingProcedureDTO; +import com.cnbm.basic.entity.*; +import com.cnbm.basic.service.impl.*; import com.cnbm.common.page.PageData; import com.cnbm.common.service.impl.CrudServiceImpl; import com.cnbm.common.spc.util.DataUtils; @@ -25,8 +20,11 @@ import com.cnbm.influx.param.Range; import com.cnbm.influx.param.Tag; import com.cnbm.influx.template.Event; +import com.cnbm.influx.template.Sample; +import com.cnbm.influx.template.SampleParam; import com.cnbm.processInspection.dto.InspectionSampleDTO; import com.cnbm.processInspection.dto.InspectionSampleDTO2; +import com.cnbm.processInspection.dto.InspectionSampleDTO3; import com.cnbm.processInspection.dto.InspectionSheetDTO; import com.cnbm.processInspection.entity.InspectionSheet; import com.cnbm.processInspection.mapper.InspectionSheetMapper; @@ -69,6 +67,10 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl getWrapper(Map params) { Long id = (Long) params.get("id"); @@ -133,9 +135,12 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl sampleDTOList = getFluxParamList(inspectionSheetId); + List sampleDTOList = getFluxParamList3(inspectionSheetId); if (sampleDTOList != null || sampleDTOList.size() > 0) { //缺陷 Integer numberOfDefects = 0; //不良 Integer defectiveQuantity = 0; - //获取的产品特性参照值 - InspectionSheetDTO dto = get(inspectionSheetId); - Map params2 = new HashMap<>(); - params2.put("productId", dto.getProductId()); - params2.put("workingProcedureId", dto.getWorkingProcedureId()); - params2.put("inspectionStage", dto.getInspectionStage()); - List featuresList = getInspectionSheetFeaturesList(params2); + Long productId = get(inspectionSheetId).getProductId(); + List featuresList = productFeaturesService.getProductFeaturesByProductId(productId); + Map featureMap = featuresList.stream().collect(Collectors.groupingBy(ProductFeaturesDTO::getName, Collectors.collectingAndThen(Collectors.toList(), f -> f.get(0)))); //循环每个样本组 - for (InspectionSampleDTO sampleDTO : sampleDTOList) { + for (InspectionSampleDTO3 sampleDTO : sampleDTOList) { //该样本的缺陷数 Integer eventDefects = 0; //该样本的属性列表 - String jsonData = sampleDTO.getJsonData(); - JSONObject json = JSON.parseObject(jsonData); - for (ProductFeaturesDTO feature : featuresList) { - String v = (String)json.get(feature.getName()); - if (!Objects.equals(v, "") && v != null) { + List sampleParamList = sampleDTO.getSampleParamList(); + for(SampleParam sampleParam : sampleParamList){ + String argName = sampleParam.getArgName(); + String argValue = sampleParam.getArgValue(); + ProductFeaturesDTO feature = featureMap.get(argName); + //属性值非空 对应产品特性非空 + if(!Objects.equals(argValue, "") && argValue != null && feature!=null){ //1 计量型;2 计数型 if (feature.getType() == 1) { - Double featureValue = Double.valueOf(v); + Double featureValue = Double.valueOf(argValue); if (featureValue > feature.getUsl() || featureValue < feature.getLsl()) { eventDefects = eventDefects + 1; } } if (feature.getType() == 2) { - Integer featureValue = Integer.valueOf(v); + Double featureValue = Double.valueOf(argValue); if (featureValue == 1) { eventDefects = eventDefects + 1; } } } - if (eventDefects != 0) { - numberOfDefects = numberOfDefects + eventDefects; - defectiveQuantity = defectiveQuantity + 1; - } + } + //该样本是否有缺陷 + if (eventDefects != 0) { + numberOfDefects = numberOfDefects + eventDefects; + defectiveQuantity = defectiveQuantity + 1; } } InspectionSheetDTO updateDto = new InspectionSheetDTO(); @@ -388,61 +391,112 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl eventList = getFluxParamList(inspectionSheetId); - if (eventList != null || eventList.size() > 0) { - //根据样本号分组 - Map> map = eventList.stream().collect(Collectors.groupingBy(Event::getSampleNumber)); - //获取的产品特性参照值 - InspectionSheetDTO dto = get(inspectionSheetId); - Map params2 = new HashMap<>(); - params2.put("productId", dto.getProductId()); - params2.put("workingProcedureId", dto.getWorkingProcedureId()); - params2.put("inspectionStage", dto.getInspectionStage()); - //缺陷 - Integer numberOfDefects = 0; - //不良 - Integer defectiveQuantity = 0; - List featuresList = getInspectionSheetFeaturesList(params2); - //循环每个样本组 - for (Map.Entry> entry : map.entrySet()) { - //该样本的缺陷数 - Integer eventDefects = 0; - //该样本的属性列表 - List eventList1 = entry.getValue(); - for (Event event : eventList1) { - String featureName = event.getArgName(); - ProductFeaturesDTO feature = featuresList.stream().filter(u -> u.getName().equals(featureName)).findAny().orElse(null); - if (feature != null && !Objects.equals(event.getArgValue(), "") && event.getArgValue() != null) { - //1 计量型;2 计数型 - if (feature.getType() == 1) { - Double featureValue = Double.valueOf(event.getArgValue()); - if (featureValue > feature.getUsl() || featureValue < feature.getLsl()) { - eventDefects = eventDefects + 1; - } - } - if (feature.getType() == 2) { - Integer featureValue = Integer.valueOf(event.getArgValue()); - if (featureValue == 1) { - eventDefects = eventDefects + 1; - } - } - } - if (eventDefects != 0) { - numberOfDefects = numberOfDefects + eventDefects; - defectiveQuantity = defectiveQuantity + 1; - } + @Override + public void saveFluxParamList3(InspectionSampleDTO3[] lists){ + for (InspectionSampleDTO3 dto : lists) { + String inspectionSheetId = dto.getInspectionSheetId(); + Instant eventTime = dto.getSampleTime(); + String sampleNumber = dto.getSampleNumber(); + + List sampleParamList = dto.getSampleParamList(); + for(SampleParam sampleParam : sampleParamList){ + String workingProcedureName = sampleParam.getWorkingProcedureName(); + String paramName = sampleParam.getArgName(); + String paramValue = sampleParam.getArgValue(); + Event event = newEvent(eventTime, inspectionSheetId, paramName, paramValue, sampleNumber); + InfluxClient.Client.insert(event, workingProcedureName); + } + } + } + + @Override + public List getFluxParamList3(Long id) { + List sampleList = new ArrayList<>(); + //获取influx查询参数 + InspectionSheetDTO dto = get(id); + if(dto!=null){ + //检验单-单一工序 + if(dto.getWorkingProcedureName()!=null){ + String workingProcedureName = dto.getWorkingProcedureName(); + sampleList = getEventList(id.toString(),workingProcedureName); + + } + //检验单-所有工序 + else { + List workingProcedureDTOList = workingProcedureService.getWorkingProcedureByProductId(dto.getProductId()); + for(WorkingProcedureDTO workingProcedureDTO:workingProcedureDTOList){ + List sampleList1 = getEventList(id.toString(),workingProcedureDTO.getName()); + sampleList.addAll(sampleList1); } } - InspectionSheetDTO updateDto = new InspectionSheetDTO(); - updateDto.setId(inspectionSheetId); - updateDto.setNumberOfDefects(numberOfDefects); - updateDto.setDefectiveQuantity(defectiveQuantity); - update(updateDto); } - }*/ + List list = new ArrayList<>(); + if (sampleList != null || sampleList.size() > 0) { + //根据样本号分组 + Map> map = sampleList.stream().collect(Collectors.groupingBy(Sample::getSampleNumber)); + for (Map.Entry> entry : map.entrySet()) { + String sampleNumber = entry.getKey(); + List samples = entry.getValue(); + InspectionSampleDTO3 sampleDTO = new InspectionSampleDTO3(); + sampleDTO.setSampleNumber(sampleNumber); + sampleDTO.setSampleTime(samples.get(0).getSampleTime()); + sampleDTO.setBatchNum(dto.getBatchNumber()); + sampleDTO.setInspectionSheetId(samples.get(0).getInspectionSheetId()); + List sampleParamList = new ArrayList<>(); + for(Sample sample:samples){ + SampleParam sampleParam = new SampleParam(); + sampleParam.setArgName(sample.getArgName()); + sampleParam.setArgValue(sample.getArgValue()); + sampleParam.setWorkingProcedureName(sample.getWorkingProcedureName()); + sampleParamList.add(sampleParam); + } + sampleDTO.setSampleParamList(sampleParamList); + list.add(sampleDTO); + } + } + //返回先按时间排序 再按样本号排序 + List sortedList = list.stream() + .sorted(Comparator.comparing(InspectionSampleDTO3::getSampleTime).thenComparing(InspectionSampleDTO3::getSampleNumber)) + .collect(Collectors.toList()); + return sortedList; + } + + private List getEventList(String inspectionSheetId, String workingProcedureName) { + List sampleList = new ArrayList<>(); + QueryDataParam queryDataParam = new QueryDataParam(); + queryDataParam.setMeasurement(workingProcedureName); + queryDataParam.setBucket("qgs-bucket"); + queryDataParam.setTags(Arrays.asList(new Tag("inspectionSheetId", inspectionSheetId.toString()))); + List dropNames = new ArrayList<>(); + dropNames.add("transationId"); + queryDataParam.setDropedTagNames(dropNames); + queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(), DataUtils.getAfterDate(999).toInstant())); + queryDataParam.setPageInfo(new PageInfo(1, 10)); + List fluxTableList = InfluxClient.Client.query(queryDataParam); + for (FluxTable fluxTable : fluxTableList) { + List records = fluxTable.getRecords(); // 获取实际的记录操作 + for (FluxRecord fluxRecord : records) { + Instant time = fluxRecord.getTime(); + String argName = (String) fluxRecord.getValueByKey("argName"); + String argValue = (String) fluxRecord.getValueByKey("_value"); + String sampleNo = (String) fluxRecord.getValueByKey("sampleNumber"); + sampleList.add(newSample(time, inspectionSheetId, workingProcedureName, argName, argValue, sampleNo)); + } + } + return sampleList; + } + + private Sample newSample(Instant time, String inspectionSheetId, String workingProcedureName, String argName, String argValue, String sampleNo) { + Sample sample = new Sample(); + sample.setInspectionSheetId(inspectionSheetId); + sample.setWorkingProcedureName(workingProcedureName); + sample.setSampleTime(time); + sample.setSampleNumber(sampleNo); + sample.setArgName(argName); + sample.setArgValue(argValue); + return sample; + } + } \ No newline at end of file diff --git a/ym-process-inspection/src/main/resources/mapper/InspectionSheetMapper.xml b/ym-process-inspection/src/main/resources/mapper/InspectionSheetMapper.xml index 2549658..cff136c 100644 --- a/ym-process-inspection/src/main/resources/mapper/InspectionSheetMapper.xml +++ b/ym-process-inspection/src/main/resources/mapper/InspectionSheetMapper.xml @@ -83,18 +83,19 @@