This commit is contained in:
闫阳 2022-11-25 10:06:25 +08:00
parent a3cc4df25c
commit 1b9c3499a3
4 changed files with 73 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package com.cnbm.processInspection.controller; package com.cnbm.processInspection.controller;
import com.cnbm.admin.annotation.LogOperation; import com.cnbm.admin.annotation.LogOperation;
import com.cnbm.basic.dto.ProductFeaturesDTO;
import com.cnbm.common.constant.Constant; import com.cnbm.common.constant.Constant;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
import com.cnbm.common.utils.ExcelUtils; import com.cnbm.common.utils.ExcelUtils;
@ -11,6 +12,7 @@ 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.influx.param.QueryDataParam; import com.cnbm.influx.param.QueryDataParam;
import com.cnbm.processInspection.dto.InspectionSampleDTO;
import com.cnbm.processInspection.dto.InspectionSheetDTO; import com.cnbm.processInspection.dto.InspectionSheetDTO;
import com.cnbm.processInspection.excel.InspectionSheetExcel; import com.cnbm.processInspection.excel.InspectionSheetExcel;
import com.cnbm.processInspection.service.IInspectionSheetService; import com.cnbm.processInspection.service.IInspectionSheetService;
@ -154,4 +156,13 @@ public class InspectionSheetController {
return inspectionSheetService.getFluxParamList(params); return inspectionSheetService.getFluxParamList(params);
} }
@PutMapping("saveFluxParamList")
@ApiOperation("将样本检测参数写入influxdb")
public Result saveFluxParamList(@RequestBody InspectionSampleDTO[] lists){
inspectionSheetService.saveFluxParamList(lists);
return new Result();
}
} }

View File

@ -0,0 +1,25 @@
package com.cnbm.processInspection.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 检验样本
*
* @author yanyang
* @since 2022-11-24
*/
@Data
@ApiModel(value = "检验样本 DTO对象")
public class InspectionSampleDTO implements Serializable {
@ApiModelProperty(value = "工序名称关联working_procedure表")
private String workingProcedureName;
@ApiModelProperty(value = "检验单id")
private String inspectionSheetId;
}

View File

@ -3,6 +3,7 @@ package com.cnbm.processInspection.service;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
import com.cnbm.common.service.CrudService; import com.cnbm.common.service.CrudService;
import com.cnbm.influx.param.QueryDataParam; import com.cnbm.influx.param.QueryDataParam;
import com.cnbm.processInspection.dto.InspectionSampleDTO;
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;
@ -32,4 +33,6 @@ public interface IInspectionSheetService extends CrudService<InspectionSheet, In
List<FluxTable> getFluxParamList(Map<String, Object> params); List<FluxTable> getFluxParamList(Map<String, Object> params);
void saveFluxParamList(InspectionSampleDTO[] lists);
} }

View File

@ -3,6 +3,8 @@ package com.cnbm.processInspection.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.ProductFactoryRelationDTO;
import com.cnbm.basic.dto.ProductFeaturesDTO;
import com.cnbm.basic.entity.Machine; import com.cnbm.basic.entity.Machine;
import com.cnbm.basic.entity.Product; import com.cnbm.basic.entity.Product;
import com.cnbm.basic.entity.Shift; import com.cnbm.basic.entity.Shift;
@ -14,25 +16,30 @@ 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.utils.ConvertUtils; import com.cnbm.common.utils.ConvertUtils;
import com.cnbm.common.validator.ValidatorUtils;
import com.cnbm.common.validator.group.AddGroup;
import com.cnbm.common.validator.group.DefaultGroup;
import com.cnbm.influx.config.InfluxClient; import com.cnbm.influx.config.InfluxClient;
import com.cnbm.influx.param.QueryDataParam; import com.cnbm.influx.param.QueryDataParam;
import com.cnbm.influx.param.Range; import com.cnbm.influx.param.Range;
import com.cnbm.influx.template.Event; import com.cnbm.influx.template.Event;
import com.cnbm.processInspection.dto.InspectionSampleDTO;
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;
import com.cnbm.processInspection.service.IInspectionSheetService; import com.cnbm.processInspection.service.IInspectionSheetService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.influxdb.query.FluxTable; import com.influxdb.query.FluxTable;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import java.time.Instant; import java.time.Instant;
import java.util.Arrays; import java.time.LocalDateTime;
import java.util.Date; import java.time.ZoneOffset;
import java.util.List; import java.util.*;
import java.util.Map;
/** /**
* 检验单 * 检验单
@ -167,4 +174,27 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
List<FluxTable> list = InfluxClient.Client.query(queryDataParam); List<FluxTable> list = InfluxClient.Client.query(queryDataParam);
return list; return list;
} }
@Override
public void saveFluxParamList(@RequestBody InspectionSampleDTO[] lists){
for(InspectionSampleDTO dto:lists){
String equipmentName = dto.getWorkingProcedureName();
LocalDateTime eventTimestamp = LocalDateTime.now();
Instant eventTime = eventTimestamp.toInstant(ZoneOffset.UTC);
String inspectionSheetId =dto.getInspectionSheetId();
// Event event = new Event(eventTime,inspectionSheetId,"ppExecName",ppExecName);
// InfluxClient.Client.insert(event,equipmentName);
}
}
private Event newEvent(Instant time,String inspectionSheetId,String argName,Double argValue){
Event event = new Event();
event.setInspectionSheetId(inspectionSheetId);
event.setTime(time);
event.setArgName(argName);
if(!Objects.equals(argValue, "") && argValue != null ){
event.setArgValue(argValue);
}
return event;
}
} }