m
This commit is contained in:
@@ -156,11 +156,11 @@ public class InspectionSheetController {
|
||||
return inspectionSheetService.getFluxParamList(params);
|
||||
}
|
||||
|
||||
@PutMapping("saveFluxParamList")
|
||||
@PostMapping("saveFluxParamList")
|
||||
@ApiOperation("将样本检测参数写入influxdb")
|
||||
public Result saveFluxParamList(@RequestBody InspectionSampleDTO[] lists){
|
||||
public Result saveFluxParamList(@RequestBody InspectionSampleDTO dto){
|
||||
|
||||
inspectionSheetService.saveFluxParamList(lists);
|
||||
inspectionSheetService.saveFluxParamList(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 检验样本 表
|
||||
@@ -22,4 +23,13 @@ public class InspectionSampleDTO implements Serializable {
|
||||
@ApiModelProperty(value = "检验单id")
|
||||
private String inspectionSheetId;
|
||||
|
||||
@ApiModelProperty(value = "检验参数,json格式")
|
||||
private String jsonData;
|
||||
|
||||
@ApiModelProperty(value = "批次号")
|
||||
private String batchNum;
|
||||
|
||||
@ApiModelProperty(value = "取样时间")
|
||||
private LocalDateTime sampleTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,5 @@ import java.util.Map;
|
||||
@Mapper
|
||||
public interface InspectionSheetMapper extends BaseDao<InspectionSheet> {
|
||||
List<InspectionSheetDTO> list(Map<String, Object> params);
|
||||
Integer getNumberOfSamples(Long productId);
|
||||
}
|
||||
@@ -33,6 +33,6 @@ public interface IInspectionSheetService extends CrudService<InspectionSheet, In
|
||||
|
||||
List<FluxTable> getFluxParamList(Map<String, Object> params);
|
||||
|
||||
void saveFluxParamList(InspectionSampleDTO[] lists);
|
||||
|
||||
void saveFluxParamList(InspectionSampleDTO dto);
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.cnbm.processInspection.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
@@ -36,6 +38,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
@@ -61,7 +64,7 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
|
||||
@Autowired
|
||||
private ShiftServiceImpl shiftService;
|
||||
|
||||
|
||||
@Override
|
||||
public QueryWrapper<InspectionSheet> getWrapper(Map<String, Object> params){
|
||||
Long id = (Long)params.get("id");
|
||||
@@ -131,6 +134,12 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(InspectionSheetDTO dto) {
|
||||
//分组样本数=样本大小=检验特性分组数的最大值
|
||||
Integer numbersOfSamples = getNumberOfSamples(dto.getProductId());
|
||||
if(numbersOfSamples!=null){
|
||||
dto.setNumberOfGroupedSamples(numbersOfSamples);
|
||||
dto.setNumberOfSamples(numbersOfSamples);
|
||||
}
|
||||
InspectionSheet entity = ConvertUtils.sourceToTarget(dto, InspectionSheet.class);
|
||||
insert(entity);
|
||||
}
|
||||
@@ -149,7 +158,7 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private InspectionSheetMapper mapper;
|
||||
|
||||
@Override
|
||||
@@ -176,25 +185,39 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
}
|
||||
|
||||
@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);
|
||||
public void saveFluxParamList(InspectionSampleDTO dto){
|
||||
//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();
|
||||
String jsonData = dto.getJsonData();
|
||||
JSONObject json = JSON.parseObject(jsonData);
|
||||
// LocalDateTime sampleTime = dto.getSampleTime();
|
||||
// Instant eventTime = sampleTime.toInstant(ZoneOffset.UTC);
|
||||
Instant eventTime = new Date().toInstant();
|
||||
|
||||
List<Event> list = new ArrayList<>();
|
||||
for (Map.Entry entry : json.entrySet()) {
|
||||
String key = entry.getKey().toString();
|
||||
Double v = Double.valueOf(entry.getValue().toString());
|
||||
list.add(newEvent(eventTime,inspectionSheetId,key,v,batchNum));
|
||||
}
|
||||
InfluxClient.Client.batchInsert(list,workingProcedureName);
|
||||
}
|
||||
|
||||
private Event newEvent(Instant time,String inspectionSheetId,String argName,Double argValue){
|
||||
private Event newEvent(Instant time,String inspectionSheetId,String argName,Double argValue,String batchNum){
|
||||
Event event = new Event();
|
||||
event.setInspectionSheetId(inspectionSheetId);
|
||||
event.setTime(time);
|
||||
event.setBatchNum(batchNum);
|
||||
event.setArgName(argName);
|
||||
if(!Objects.equals(argValue, "") && argValue != null ){
|
||||
event.setArgValue(argValue);
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
public Integer getNumberOfSamples(Long id) {
|
||||
return mapper.getNumberOfSamples(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user