Merge pull request 'influx参数覆盖' (#16) from yanyang into master
Reviewed-on: #16
This commit is contained in:
commit
04e8cc187a
@ -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<List<ProductFeaturesDTO>>().ok(list);
|
||||
}
|
||||
|
||||
@PostMapping(value = "list")
|
||||
@ApiOperation(value = "获取特性列表")
|
||||
@LogOperation("获取特性列表")
|
||||
public List<ProductFeaturesDTO> list() {
|
||||
return productFeaturesService.list();
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -25,4 +25,6 @@ public interface ProductFeaturesMapper extends BaseDao<ProductFeatures> {
|
||||
List<ProductFeaturesDTO> getFeaturesList(Map<String, Object> params);
|
||||
|
||||
String getControlGraphNameById(Long id);
|
||||
|
||||
List<ProductFeaturesDTO> list();
|
||||
}
|
@ -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<ProductFeatures, Pr
|
||||
void batchUpdate(ProductFeaturesDTO[] lists);
|
||||
|
||||
List<ProductFeaturesDTO> getFeaturesList(Map<String, Object> params);
|
||||
|
||||
List<ProductFeaturesDTO> list();;
|
||||
}
|
@ -64,6 +64,7 @@ public class ProductFeaturesServiceImpl extends CrudServiceImpl<ProductFeaturesM
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(ProductFeaturesDTO dto) {
|
||||
|
||||
ProductFeatures entity = ConvertUtils.sourceToTarget(dto, ProductFeatures.class);
|
||||
insert(entity);
|
||||
}
|
||||
@ -154,4 +155,12 @@ public class ProductFeaturesServiceImpl extends CrudServiceImpl<ProductFeaturesM
|
||||
List<ProductFeaturesDTO> list = mapper.getFeaturesList(params);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<ProductFeaturesDTO> list() {
|
||||
List<ProductFeaturesDTO> list = mapper.list();
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
@ -73,4 +73,10 @@
|
||||
<select id="getControlGraphNameById" resultType="String">
|
||||
select name from control_graph where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="list" resultType="com.cnbm.basic.dto.ProductFeaturesDTO">
|
||||
select * from product_features
|
||||
order by id asc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
30
ym-influx/src/main/java/com/cnbm/influx/template/Sample.java
Normal file
30
ym-influx/src/main/java/com/cnbm/influx/template/Sample.java
Normal 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;
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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<InspectionSampleDTO3> 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({
|
||||
|
@ -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;
|
||||
}
|
@ -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<InspectionSheet, In
|
||||
|
||||
// List<Event> getFluxParamList(Map<String, Object> params);
|
||||
List<InspectionSampleDTO> getFluxParamList(Long inspectionSheetId);
|
||||
List<InspectionSampleDTO3> getFluxParamList3(Long inspectionSheetId);
|
||||
|
||||
void saveFluxParamList(InspectionSampleDTO[] lists);
|
||||
void saveFluxParamList2(InspectionSampleDTO2[] lists);
|
||||
void saveFluxParamList3(InspectionSampleDTO3[] lists);
|
||||
|
||||
List<ProductFeaturesDTO> getInspectionSheetFeaturesList(Map<String, Object> params);
|
||||
|
||||
void calculate(Long inspectionSheetId);
|
||||
|
@ -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<InspectionSheetM
|
||||
@Autowired
|
||||
private ShiftServiceImpl shiftService;
|
||||
|
||||
@Autowired
|
||||
private ProductFeaturesServiceImpl productFeaturesService;
|
||||
|
||||
|
||||
@Override
|
||||
public QueryWrapper<InspectionSheet> getWrapper(Map<String, Object> params) {
|
||||
Long id = (Long) params.get("id");
|
||||
@ -133,9 +135,12 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
public InspectionSheetDTO get(Long id) {
|
||||
InspectionSheet entity = baseDao.selectById(id);
|
||||
InspectionSheetDTO dto = ConvertUtils.sourceToTarget(entity, InspectionSheetDTO.class);
|
||||
WorkingProcedure workingProcedure = workingProcedureService.selectById(dto.getWorkingProcedureId());
|
||||
if(workingProcedure!=null){
|
||||
dto.setWorkingProcedureName(workingProcedure.getName());
|
||||
|
||||
if(dto.getWorkingProcedureId()!=null) {
|
||||
WorkingProcedure workingProcedure = workingProcedureService.selectById(dto.getWorkingProcedureId());
|
||||
if (workingProcedure != null) {
|
||||
dto.setWorkingProcedureName(workingProcedure.getName());
|
||||
}
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
@ -263,7 +268,6 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
@Override
|
||||
public void saveFluxParamList(InspectionSampleDTO[] 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 inspectionSheetId = dto.getInspectionSheetId();
|
||||
// String batchNum = dto.getBatchNum();
|
||||
@ -338,48 +342,47 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
//计算并更新检验单缺陷数不良数
|
||||
@Override
|
||||
public void calculate(Long inspectionSheetId) {
|
||||
List<InspectionSampleDTO> sampleDTOList = getFluxParamList(inspectionSheetId);
|
||||
List<InspectionSampleDTO3> sampleDTOList = getFluxParamList3(inspectionSheetId);
|
||||
if (sampleDTOList != null || sampleDTOList.size() > 0) {
|
||||
//缺陷
|
||||
Integer numberOfDefects = 0;
|
||||
//不良
|
||||
Integer defectiveQuantity = 0;
|
||||
|
||||
//获取的产品特性参照值
|
||||
InspectionSheetDTO dto = get(inspectionSheetId);
|
||||
Map<String, Object> params2 = new HashMap<>();
|
||||
params2.put("productId", dto.getProductId());
|
||||
params2.put("workingProcedureId", dto.getWorkingProcedureId());
|
||||
params2.put("inspectionStage", dto.getInspectionStage());
|
||||
List<ProductFeaturesDTO> featuresList = getInspectionSheetFeaturesList(params2);
|
||||
Long productId = get(inspectionSheetId).getProductId();
|
||||
List<ProductFeaturesDTO> featuresList = productFeaturesService.getProductFeaturesByProductId(productId);
|
||||
Map<String, ProductFeaturesDTO> 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<SampleParam> 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<InspectionSheetM
|
||||
updateDto.setDefectiveQuantity(defectiveQuantity);
|
||||
update(updateDto);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
//获取该检验单的所有样本数据
|
||||
List<Event> eventList = getFluxParamList(inspectionSheetId);
|
||||
if (eventList != null || eventList.size() > 0) {
|
||||
//根据样本号分组
|
||||
Map<String, List<Event>> map = eventList.stream().collect(Collectors.groupingBy(Event::getSampleNumber));
|
||||
//获取的产品特性参照值
|
||||
InspectionSheetDTO dto = get(inspectionSheetId);
|
||||
Map<String, Object> 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<ProductFeaturesDTO> featuresList = getInspectionSheetFeaturesList(params2);
|
||||
//循环每个样本组
|
||||
for (Map.Entry<String, List<Event>> entry : map.entrySet()) {
|
||||
//该样本的缺陷数
|
||||
Integer eventDefects = 0;
|
||||
//该样本的属性列表
|
||||
List<Event> 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<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<WorkingProcedureDTO> workingProcedureDTOList = workingProcedureService.getWorkingProcedureByProductId(dto.getProductId());
|
||||
for(WorkingProcedureDTO workingProcedureDTO:workingProcedureDTOList){
|
||||
List<Sample> 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<InspectionSampleDTO3> list = new ArrayList<>();
|
||||
if (sampleList != null || sampleList.size() > 0) {
|
||||
//根据样本号分组
|
||||
Map<String, List<Sample>> map = sampleList.stream().collect(Collectors.groupingBy(Sample::getSampleNumber));
|
||||
for (Map.Entry<String, List<Sample>> entry : map.entrySet()) {
|
||||
String sampleNumber = entry.getKey();
|
||||
List<Sample> 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<SampleParam> 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<InspectionSampleDTO3> sortedList = list.stream()
|
||||
.sorted(Comparator.comparing(InspectionSampleDTO3::getSampleTime).thenComparing(InspectionSampleDTO3::getSampleNumber))
|
||||
.collect(Collectors.toList());
|
||||
return sortedList;
|
||||
}
|
||||
|
||||
private List<Sample> getEventList(String inspectionSheetId, String workingProcedureName) {
|
||||
List<Sample> sampleList = new ArrayList<>();
|
||||
QueryDataParam queryDataParam = new QueryDataParam();
|
||||
queryDataParam.setMeasurement(workingProcedureName);
|
||||
queryDataParam.setBucket("qgs-bucket");
|
||||
queryDataParam.setTags(Arrays.asList(new Tag("inspectionSheetId", inspectionSheetId.toString())));
|
||||
List<String> 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<FluxTable> fluxTableList = InfluxClient.Client.query(queryDataParam);
|
||||
for (FluxTable fluxTable : fluxTableList) {
|
||||
List<FluxRecord> 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;
|
||||
}
|
||||
|
||||
}
|
@ -83,18 +83,19 @@
|
||||
</select>
|
||||
|
||||
<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
|
||||
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>
|
||||
pf.valid = 1 and fspr.valid = 1
|
||||
<if test="productId != null and productId.trim() != ''">
|
||||
<if test="productId != null">
|
||||
and pf.product_id = #{productId}
|
||||
</if>
|
||||
<if test="inspectionStage != null and inspectionStage.trim() != ''">
|
||||
<if test="inspectionStage != null">
|
||||
and fspr.inspection_stage = #{inspectionStage}
|
||||
</if>
|
||||
<if test="workingProcedureId != null and workingProcedureId.trim() != ''">
|
||||
<if test="workingProcedureId != null">
|
||||
and fspr.working_procedure_id = #{workingProcedureId}
|
||||
</if>
|
||||
</where>
|
||||
|
Loading…
Reference in New Issue
Block a user