m
This commit is contained in:
parent
1b9c3499a3
commit
4864545f12
@ -95,7 +95,7 @@ public enum InfluxClient {
|
||||
Point point = Point.measurement(measurement)
|
||||
.addTag("transationId", event.getTransationId())
|
||||
.addTag("inspectionSheetId", event.getInspectionSheetId())
|
||||
.addTag("batchNum", event.getBatchNum().toString())
|
||||
.addTag("batchNum", event.getBatchNum())
|
||||
.addTag("argName", event.getArgName())
|
||||
.addField("argValue", event.getArgValue())
|
||||
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
|
||||
|
@ -64,7 +64,7 @@ public class S7DemoController {
|
||||
Double d = r.nextDouble() * 2.5 + 66;
|
||||
event.setInspectionSheetId(j+"");
|
||||
event.setArgValue(d);
|
||||
event.setBatchNum(i);
|
||||
event.setBatchNum(i+"");
|
||||
list.add(event);
|
||||
}
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class S7DemoController {
|
||||
|
||||
event.setInspectionSheetId(i+"");
|
||||
|
||||
event.setBatchNum(i);
|
||||
event.setBatchNum(i+"");
|
||||
list.add(event);
|
||||
}
|
||||
InfluxClient.Client.batchInsert(list,"WeightHeiHei");
|
||||
|
@ -26,5 +26,5 @@ public class Event {
|
||||
private Double argValue;
|
||||
|
||||
//批次号,可选的
|
||||
private Integer batchNum;
|
||||
private String batchNum;
|
||||
}
|
@ -14,6 +14,8 @@
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<!-- fastjson -->
|
||||
<fastjson.version>1.2.75</fastjson.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -38,5 +40,10 @@
|
||||
<artifactId>ym-quality-planning</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -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);
|
||||
}
|
||||
}
|
@ -64,4 +64,11 @@
|
||||
order by i.id asc
|
||||
</select>
|
||||
|
||||
<select id="getNumberOfSamples" resultType="Integer">
|
||||
select max(sample_size) from product_features
|
||||
<where>
|
||||
valid = 1 AND product_id = #{id}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user