# Conflicts:
#	ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java
This commit is contained in:
caixiang 2023-01-03 09:24:49 +08:00
commit 9b545a9a03
13 changed files with 289 additions and 89 deletions

View File

@ -2,9 +2,7 @@ package com.cnbm.basic.controller;
import com.cnbm.admin.annotation.LogOperation; import com.cnbm.admin.annotation.LogOperation;
import com.cnbm.admin.params.IdParam; import com.cnbm.admin.params.IdParam;
import com.cnbm.basic.dto.FeaturesProcedureDTO; import com.cnbm.basic.dto.*;
import com.cnbm.basic.dto.FeaturesStageProcedureRelationDTO;
import com.cnbm.basic.dto.WorkingProcedureDTO;
import com.cnbm.basic.entity.ProductFeatures; import com.cnbm.basic.entity.ProductFeatures;
import com.cnbm.common.constant.Constant; import com.cnbm.common.constant.Constant;
import com.cnbm.common.page.PageData; 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.AddGroup;
import com.cnbm.common.validator.group.DefaultGroup; import com.cnbm.common.validator.group.DefaultGroup;
import com.cnbm.common.validator.group.UpdateGroup; import com.cnbm.common.validator.group.UpdateGroup;
import com.cnbm.basic.dto.ProductFeaturesDTO;
import com.cnbm.basic.excel.ProductFeaturesExcel; import com.cnbm.basic.excel.ProductFeaturesExcel;
import com.cnbm.basic.service.IProductFeaturesService; import com.cnbm.basic.service.IProductFeaturesService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -162,4 +159,11 @@ public class ProductFeaturesController {
return new Result<List<ProductFeaturesDTO>>().ok(list); return new Result<List<ProductFeaturesDTO>>().ok(list);
} }
@PostMapping(value = "list")
@ApiOperation(value = "获取特性列表")
@LogOperation("获取特性列表")
public List<ProductFeaturesDTO> list() {
return productFeaturesService.list();
}
} }

View File

@ -112,4 +112,10 @@ public class ProductFeaturesDTO implements Serializable {
@ApiModelProperty(value = "版本号") @ApiModelProperty(value = "版本号")
private Integer version; private Integer version;
@ApiModelProperty(value = "工序id,关联 working_procedure 表")
private Long workingProcedureId;
@ApiModelProperty(value = "工序 名,关联working_procedure表")
private String workingProcedureName;
} }

View File

@ -25,4 +25,6 @@ public interface ProductFeaturesMapper extends BaseDao<ProductFeatures> {
List<ProductFeaturesDTO> getFeaturesList(Map<String, Object> params); List<ProductFeaturesDTO> getFeaturesList(Map<String, Object> params);
String getControlGraphNameById(Long id); String getControlGraphNameById(Long id);
List<ProductFeaturesDTO> list();
} }

View File

@ -1,5 +1,6 @@
package com.cnbm.basic.service; package com.cnbm.basic.service;
import com.cnbm.basic.dto.FactoryDTO;
import com.cnbm.basic.dto.FeaturesProcedureDTO; import com.cnbm.basic.dto.FeaturesProcedureDTO;
import com.cnbm.basic.dto.FeaturesStageProcedureRelationDTO; import com.cnbm.basic.dto.FeaturesStageProcedureRelationDTO;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
@ -34,4 +35,6 @@ public interface IProductFeaturesService extends CrudService<ProductFeatures, Pr
void batchUpdate(ProductFeaturesDTO[] lists); void batchUpdate(ProductFeaturesDTO[] lists);
List<ProductFeaturesDTO> getFeaturesList(Map<String, Object> params); List<ProductFeaturesDTO> getFeaturesList(Map<String, Object> params);
List<ProductFeaturesDTO> list();;
} }

View File

@ -64,6 +64,7 @@ public class ProductFeaturesServiceImpl extends CrudServiceImpl<ProductFeaturesM
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void save(ProductFeaturesDTO dto) { public void save(ProductFeaturesDTO dto) {
ProductFeatures entity = ConvertUtils.sourceToTarget(dto, ProductFeatures.class); ProductFeatures entity = ConvertUtils.sourceToTarget(dto, ProductFeatures.class);
insert(entity); insert(entity);
} }
@ -154,4 +155,12 @@ public class ProductFeaturesServiceImpl extends CrudServiceImpl<ProductFeaturesM
List<ProductFeaturesDTO> list = mapper.getFeaturesList(params); List<ProductFeaturesDTO> list = mapper.getFeaturesList(params);
return list; return list;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public List<ProductFeaturesDTO> list() {
List<ProductFeaturesDTO> list = mapper.list();
return list;
}
} }

View File

@ -73,4 +73,10 @@
<select id="getControlGraphNameById" resultType="String"> <select id="getControlGraphNameById" resultType="String">
select name from control_graph where id = #{id} select name from control_graph where id = #{id}
</select> </select>
<select id="list" resultType="com.cnbm.basic.dto.ProductFeaturesDTO">
select * from product_features
order by id asc
</select>
</mapper> </mapper>

View File

@ -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;
}

View File

@ -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;
}

View File

@ -17,6 +17,7 @@ import com.cnbm.common.validator.group.UpdateGroup;
import com.cnbm.processInspection.dto.InspectionSampleDTO; import com.cnbm.processInspection.dto.InspectionSampleDTO;
import com.cnbm.processInspection.dto.InspectionSampleDTO2; import com.cnbm.processInspection.dto.InspectionSampleDTO2;
import com.cnbm.processInspection.dto.InspectionSampleDTO3;
import com.cnbm.processInspection.dto.InspectionSheetDTO; import com.cnbm.processInspection.dto.InspectionSheetDTO;
import com.cnbm.processInspection.entity.InspectionSheet; import com.cnbm.processInspection.entity.InspectionSheet;
import com.cnbm.processInspection.excel.InspectionSheetExcel; import com.cnbm.processInspection.excel.InspectionSheetExcel;
@ -174,6 +175,11 @@ public class InspectionSheetController {
return inspectionSheetService.getFluxParamList(inspectionSheetId); return inspectionSheetService.getFluxParamList(inspectionSheetId);
} }
@PostMapping(value = "getFluxParamList3")
@ApiOperation(value = "从influxdb中获取检测参数3")
List<InspectionSampleDTO3> getFluxParamList3(@RequestParam("inspectionSheetId") Long inspectionSheetId){
return inspectionSheetService.getFluxParamList3(inspectionSheetId);
}
@PostMapping("saveFluxParamList") @PostMapping("saveFluxParamList")
@ApiOperation("将样本检测参数写入influxdb") @ApiOperation("将样本检测参数写入influxdb")
@ -197,6 +203,17 @@ public class InspectionSheetController {
return new Result(); 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") @PostMapping("getInspectionSheetFeaturesList")
@ApiOperation("获取检验单对应检验属性") @ApiOperation("获取检验单对应检验属性")
@ApiImplicitParams({ @ApiImplicitParams({

View File

@ -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<SampleParam> sampleParamList;
}

View File

@ -8,6 +8,7 @@ import com.cnbm.influx.param.QueryDataParam;
import com.cnbm.influx.template.Event; import com.cnbm.influx.template.Event;
import com.cnbm.processInspection.dto.InspectionSampleDTO; import com.cnbm.processInspection.dto.InspectionSampleDTO;
import com.cnbm.processInspection.dto.InspectionSampleDTO2; import com.cnbm.processInspection.dto.InspectionSampleDTO2;
import com.cnbm.processInspection.dto.InspectionSampleDTO3;
import com.cnbm.processInspection.dto.InspectionSheetDTO; import com.cnbm.processInspection.dto.InspectionSheetDTO;
import com.cnbm.processInspection.entity.InspectionSheet; import com.cnbm.processInspection.entity.InspectionSheet;
import com.influxdb.query.FluxTable; import com.influxdb.query.FluxTable;
@ -37,9 +38,12 @@ public interface IInspectionSheetService extends CrudService<InspectionSheet, In
// List<Event> getFluxParamList(Map<String, Object> params); // List<Event> getFluxParamList(Map<String, Object> params);
List<InspectionSampleDTO> getFluxParamList(Long inspectionSheetId); List<InspectionSampleDTO> getFluxParamList(Long inspectionSheetId);
List<InspectionSampleDTO3> getFluxParamList3(Long inspectionSheetId);
void saveFluxParamList(InspectionSampleDTO[] lists); void saveFluxParamList(InspectionSampleDTO[] lists);
void saveFluxParamList2(InspectionSampleDTO2[] lists); void saveFluxParamList2(InspectionSampleDTO2[] lists);
void saveFluxParamList3(InspectionSampleDTO3[] lists);
List<ProductFeaturesDTO> getInspectionSheetFeaturesList(Map<String, Object> params); List<ProductFeaturesDTO> getInspectionSheetFeaturesList(Map<String, Object> params);
void calculate(Long inspectionSheetId); void calculate(Long inspectionSheetId);

View File

@ -6,14 +6,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.cnbm.basic.dto.ProductFeaturesDTO; import com.cnbm.basic.dto.ProductFeaturesDTO;
import com.cnbm.basic.entity.Machine; import com.cnbm.basic.dto.WorkingProcedureDTO;
import com.cnbm.basic.entity.Product; import com.cnbm.basic.entity.*;
import com.cnbm.basic.entity.Shift; import com.cnbm.basic.service.impl.*;
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.common.page.PageData; import com.cnbm.common.page.PageData;
import com.cnbm.common.service.impl.CrudServiceImpl; import com.cnbm.common.service.impl.CrudServiceImpl;
import com.cnbm.common.spc.util.DataUtils; 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.param.Tag;
import com.cnbm.influx.template.Event; 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.InspectionSampleDTO;
import com.cnbm.processInspection.dto.InspectionSampleDTO2; import com.cnbm.processInspection.dto.InspectionSampleDTO2;
import com.cnbm.processInspection.dto.InspectionSampleDTO3;
import com.cnbm.processInspection.dto.InspectionSheetDTO; import com.cnbm.processInspection.dto.InspectionSheetDTO;
import com.cnbm.processInspection.entity.InspectionSheet; import com.cnbm.processInspection.entity.InspectionSheet;
import com.cnbm.processInspection.mapper.InspectionSheetMapper; import com.cnbm.processInspection.mapper.InspectionSheetMapper;
@ -69,6 +67,10 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
@Autowired @Autowired
private ShiftServiceImpl shiftService; private ShiftServiceImpl shiftService;
@Autowired
private ProductFeaturesServiceImpl productFeaturesService;
@Override @Override
public QueryWrapper<InspectionSheet> getWrapper(Map<String, Object> params) { public QueryWrapper<InspectionSheet> getWrapper(Map<String, Object> params) {
Long id = (Long) params.get("id"); Long id = (Long) params.get("id");
@ -133,10 +135,13 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
public InspectionSheetDTO get(Long id) { public InspectionSheetDTO get(Long id) {
InspectionSheet entity = baseDao.selectById(id); InspectionSheet entity = baseDao.selectById(id);
InspectionSheetDTO dto = ConvertUtils.sourceToTarget(entity, InspectionSheetDTO.class); InspectionSheetDTO dto = ConvertUtils.sourceToTarget(entity, InspectionSheetDTO.class);
if(dto.getWorkingProcedureId()!=null) {
WorkingProcedure workingProcedure = workingProcedureService.selectById(dto.getWorkingProcedureId()); WorkingProcedure workingProcedure = workingProcedureService.selectById(dto.getWorkingProcedureId());
if(workingProcedure!=null){ if (workingProcedure != null) {
dto.setWorkingProcedureName(workingProcedure.getName()); dto.setWorkingProcedureName(workingProcedure.getName());
} }
}
return dto; return dto;
} }
@ -263,7 +268,6 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
@Override @Override
public void saveFluxParamList(InspectionSampleDTO[] lists){ public void saveFluxParamList(InspectionSampleDTO[] lists){
for (InspectionSampleDTO dto : lists) { for (InspectionSampleDTO dto : lists) {
//String jsonData = {"workingProcedureName":"test","inspectionSheetId":"116","param1":"0.47","param2":"0.687","param2":"0.53"};
String workingProcedureName = dto.getWorkingProcedureName(); String workingProcedureName = dto.getWorkingProcedureName();
String inspectionSheetId = dto.getInspectionSheetId(); String inspectionSheetId = dto.getInspectionSheetId();
// String batchNum = dto.getBatchNum(); // String batchNum = dto.getBatchNum();
@ -328,111 +332,161 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
//计算并更新检验单缺陷数不良数 //计算并更新检验单缺陷数不良数
@Override @Override
public void calculate(Long inspectionSheetId) { public void calculate(Long inspectionSheetId) {
List<InspectionSampleDTO> sampleDTOList = getFluxParamList(inspectionSheetId); List<InspectionSampleDTO3> sampleDTOList = getFluxParamList3(inspectionSheetId);
if (sampleDTOList != null || sampleDTOList.size() > 0) { if (sampleDTOList != null || sampleDTOList.size() > 0) {
//缺陷 //缺陷
Integer numberOfDefects = 0; Integer numberOfDefects = 0;
//不良 //不良
Integer defectiveQuantity = 0; Integer defectiveQuantity = 0;
//获取的产品特性参照值 //获取的产品特性参照值
InspectionSheetDTO dto = get(inspectionSheetId); Long productId = get(inspectionSheetId).getProductId();
Map<String, Object> params2 = new HashMap<>(); List<ProductFeaturesDTO> featuresList = productFeaturesService.getProductFeaturesByProductId(productId);
params2.put("productId", dto.getProductId()); Map<String, ProductFeaturesDTO> featureMap = featuresList.stream().collect(Collectors.groupingBy(ProductFeaturesDTO::getName, Collectors.collectingAndThen(Collectors.toList(), f -> f.get(0))));
params2.put("workingProcedureId", dto.getWorkingProcedureId());
params2.put("inspectionStage", dto.getInspectionStage());
List<ProductFeaturesDTO> featuresList = getInspectionSheetFeaturesList(params2);
//循环每个样本组 //循环每个样本组
for (InspectionSampleDTO sampleDTO : sampleDTOList) { for (InspectionSampleDTO3 sampleDTO : sampleDTOList) {
//该样本的缺陷数 //该样本的缺陷数
Integer eventDefects = 0; Integer eventDefects = 0;
//该样本的属性列表 //该样本的属性列表
String jsonData = sampleDTO.getJsonData(); List<SampleParam> sampleParamList = sampleDTO.getSampleParamList();
JSONObject json = JSON.parseObject(jsonData); for(SampleParam sampleParam : sampleParamList){
for (ProductFeaturesDTO feature : featuresList) { String argName = sampleParam.getArgName();
String v = (String)json.get(feature.getName()); String argValue = sampleParam.getArgValue();
if (!Objects.equals(v, "") && v != null) { ProductFeaturesDTO feature = featureMap.get(argName);
//属性值非空 对应产品特性非空
if(!Objects.equals(argValue, "") && argValue != null && feature!=null){
//1 计量型2 计数型 //1 计量型2 计数型
if (feature.getType() == 1) { if (feature.getType() == 1) {
Double featureValue = Double.valueOf(v); Double featureValue = Double.valueOf(argValue);
if (featureValue > feature.getUsl() || featureValue < feature.getLsl()) { if (featureValue > feature.getUsl() || featureValue < feature.getLsl()) {
eventDefects = eventDefects + 1; eventDefects = eventDefects + 1;
} }
} }
if (feature.getType() == 2) { if (feature.getType() == 2) {
Integer featureValue = Integer.valueOf(v); Double featureValue = Double.valueOf(argValue);
if (featureValue == 1) { if (featureValue == 1) {
eventDefects = eventDefects + 1; eventDefects = eventDefects + 1;
} }
} }
} }
}
//该样本是否有缺陷
if (eventDefects != 0) { if (eventDefects != 0) {
numberOfDefects = numberOfDefects + eventDefects; numberOfDefects = numberOfDefects + eventDefects;
defectiveQuantity = defectiveQuantity + 1; defectiveQuantity = defectiveQuantity + 1;
} }
} }
}
InspectionSheetDTO updateDto = new InspectionSheetDTO(); InspectionSheetDTO updateDto = new InspectionSheetDTO();
updateDto.setId(inspectionSheetId); updateDto.setId(inspectionSheetId);
updateDto.setNumberOfDefects(numberOfDefects); updateDto.setNumberOfDefects(numberOfDefects);
updateDto.setDefectiveQuantity(defectiveQuantity); updateDto.setDefectiveQuantity(defectiveQuantity);
update(updateDto); update(updateDto);
} }
}
@Override
public void saveFluxParamList3(InspectionSampleDTO3[] lists){
for (InspectionSampleDTO3 dto : lists) {
String inspectionSheetId = dto.getInspectionSheetId();
Instant eventTime = dto.getSampleTime();
String sampleNumber = dto.getSampleNumber();
List<SampleParam> 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<InspectionSampleDTO3> getFluxParamList3(Long id) {
List<Sample> 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<Event> eventList = getFluxParamList(inspectionSheetId); List<WorkingProcedureDTO> workingProcedureDTOList = workingProcedureService.getWorkingProcedureByProductId(dto.getProductId());
if (eventList != null || eventList.size() > 0) { for(WorkingProcedureDTO workingProcedureDTO:workingProcedureDTOList){
List<Sample> sampleList1 = getEventList(id.toString(),workingProcedureDTO.getName());
sampleList.addAll(sampleList1);
}
}
}
List<InspectionSampleDTO3> list = new ArrayList<>();
if (sampleList != null || sampleList.size() > 0) {
//根据样本号分组 //根据样本号分组
Map<String, List<Event>> map = eventList.stream().collect(Collectors.groupingBy(Event::getSampleNumber)); Map<String, List<Sample>> map = sampleList.stream().collect(Collectors.groupingBy(Sample::getSampleNumber));
//获取的产品特性参照值 for (Map.Entry<String, List<Sample>> entry : map.entrySet()) {
InspectionSheetDTO dto = get(inspectionSheetId); String sampleNumber = entry.getKey();
Map<String, Object> params2 = new HashMap<>(); List<Sample> samples = entry.getValue();
params2.put("productId", dto.getProductId()); InspectionSampleDTO3 sampleDTO = new InspectionSampleDTO3();
params2.put("workingProcedureId", dto.getWorkingProcedureId()); sampleDTO.setSampleNumber(sampleNumber);
params2.put("inspectionStage", dto.getInspectionStage()); sampleDTO.setSampleTime(samples.get(0).getSampleTime());
//缺陷 sampleDTO.setBatchNum(dto.getBatchNumber());
Integer numberOfDefects = 0; sampleDTO.setInspectionSheetId(samples.get(0).getInspectionSheetId());
//不良 List<SampleParam> sampleParamList = new ArrayList<>();
Integer defectiveQuantity = 0; 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<InspectionSampleDTO3> sortedList = list.stream()
.sorted(Comparator.comparing(InspectionSampleDTO3::getSampleTime).thenComparing(InspectionSampleDTO3::getSampleNumber))
.collect(Collectors.toList());
return sortedList;
}
List<ProductFeaturesDTO> featuresList = getInspectionSheetFeaturesList(params2); private List<Sample> getEventList(String inspectionSheetId, String workingProcedureName) {
//循环每个样本组 List<Sample> sampleList = new ArrayList<>();
for (Map.Entry<String, List<Event>> entry : map.entrySet()) { QueryDataParam queryDataParam = new QueryDataParam();
//该样本的缺陷数 queryDataParam.setMeasurement(workingProcedureName);
Integer eventDefects = 0; queryDataParam.setBucket("qgs-bucket");
//该样本的属性列表 queryDataParam.setTags(Arrays.asList(new Tag("inspectionSheetId", inspectionSheetId.toString())));
List<Event> eventList1 = entry.getValue(); List<String> dropNames = new ArrayList<>();
for (Event event : eventList1) { dropNames.add("transationId");
String featureName = event.getArgName(); queryDataParam.setDropedTagNames(dropNames);
ProductFeaturesDTO feature = featuresList.stream().filter(u -> u.getName().equals(featureName)).findAny().orElse(null); queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(), DataUtils.getAfterDate(999).toInstant()));
if (feature != null && !Objects.equals(event.getArgValue(), "") && event.getArgValue() != null) { queryDataParam.setPageInfo(new PageInfo(1, 10));
//1 计量型2 计数型 List<FluxTable> fluxTableList = InfluxClient.Client.query(queryDataParam);
if (feature.getType() == 1) { for (FluxTable fluxTable : fluxTableList) {
Double featureValue = Double.valueOf(event.getArgValue()); List<FluxRecord> records = fluxTable.getRecords(); // 获取实际的记录操作
if (featureValue > feature.getUsl() || featureValue < feature.getLsl()) { for (FluxRecord fluxRecord : records) {
eventDefects = eventDefects + 1; 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));
} }
} }
if (feature.getType() == 2) { return sampleList;
Integer featureValue = Integer.valueOf(event.getArgValue());
if (featureValue == 1) {
eventDefects = eventDefects + 1;
} }
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;
} }
}
if (eventDefects != 0) {
numberOfDefects = numberOfDefects + eventDefects;
defectiveQuantity = defectiveQuantity + 1;
}
}
}
InspectionSheetDTO updateDto = new InspectionSheetDTO();
updateDto.setId(inspectionSheetId);
updateDto.setNumberOfDefects(numberOfDefects);
updateDto.setDefectiveQuantity(defectiveQuantity);
update(updateDto);
}
}*/
} }

View File

@ -83,9 +83,10 @@
</select> </select>
<select id="getInspectionSheetFeaturesList" resultType="com.cnbm.basic.dto.ProductFeaturesDTO"> <select id="getInspectionSheetFeaturesList" resultType="com.cnbm.basic.dto.ProductFeaturesDTO">
select pf.* select pf.*,fspr.working_procedure_id AS workingProcedureId,wp.name AS workingProcedureName
from features_stage_procedure_relation fspr from features_stage_procedure_relation fspr
LEFT JOIN product_features pf ON pf.id=fspr.product_features_id LEFT JOIN product_features pf ON pf.id=fspr.product_features_id
LEFT JOIN working_procedure wp ON fspr.working_procedure_id=wp.id
<where> <where>
pf.valid = 1 and fspr.valid = 1 pf.valid = 1 and fspr.valid = 1
<if test="productId != null"> <if test="productId != null">