m
This commit is contained in:
parent
1b9c3499a3
commit
4864545f12
@ -95,7 +95,7 @@ public enum InfluxClient {
|
|||||||
Point point = Point.measurement(measurement)
|
Point point = Point.measurement(measurement)
|
||||||
.addTag("transationId", event.getTransationId())
|
.addTag("transationId", event.getTransationId())
|
||||||
.addTag("inspectionSheetId", event.getInspectionSheetId())
|
.addTag("inspectionSheetId", event.getInspectionSheetId())
|
||||||
.addTag("batchNum", event.getBatchNum().toString())
|
.addTag("batchNum", event.getBatchNum())
|
||||||
.addTag("argName", event.getArgName())
|
.addTag("argName", event.getArgName())
|
||||||
.addField("argValue", event.getArgValue())
|
.addField("argValue", event.getArgValue())
|
||||||
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
|
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
|
||||||
|
@ -64,7 +64,7 @@ public class S7DemoController {
|
|||||||
Double d = r.nextDouble() * 2.5 + 66;
|
Double d = r.nextDouble() * 2.5 + 66;
|
||||||
event.setInspectionSheetId(j+"");
|
event.setInspectionSheetId(j+"");
|
||||||
event.setArgValue(d);
|
event.setArgValue(d);
|
||||||
event.setBatchNum(i);
|
event.setBatchNum(i+"");
|
||||||
list.add(event);
|
list.add(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ public class S7DemoController {
|
|||||||
|
|
||||||
event.setInspectionSheetId(i+"");
|
event.setInspectionSheetId(i+"");
|
||||||
|
|
||||||
event.setBatchNum(i);
|
event.setBatchNum(i+"");
|
||||||
list.add(event);
|
list.add(event);
|
||||||
}
|
}
|
||||||
InfluxClient.Client.batchInsert(list,"WeightHeiHei");
|
InfluxClient.Client.batchInsert(list,"WeightHeiHei");
|
||||||
|
@ -26,5 +26,5 @@ public class Event {
|
|||||||
private Double argValue;
|
private Double argValue;
|
||||||
|
|
||||||
//批次号,可选的
|
//批次号,可选的
|
||||||
private Integer batchNum;
|
private String batchNum;
|
||||||
}
|
}
|
@ -14,6 +14,8 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<!-- fastjson -->
|
||||||
|
<fastjson.version>1.2.75</fastjson.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -38,5 +40,10 @@
|
|||||||
<artifactId>ym-quality-planning</artifactId>
|
<artifactId>ym-quality-planning</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>${fastjson.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -156,11 +156,11 @@ public class InspectionSheetController {
|
|||||||
return inspectionSheetService.getFluxParamList(params);
|
return inspectionSheetService.getFluxParamList(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("saveFluxParamList")
|
@PostMapping("saveFluxParamList")
|
||||||
@ApiOperation("将样本检测参数写入influxdb")
|
@ApiOperation("将样本检测参数写入influxdb")
|
||||||
public Result saveFluxParamList(@RequestBody InspectionSampleDTO[] lists){
|
public Result saveFluxParamList(@RequestBody InspectionSampleDTO dto){
|
||||||
|
|
||||||
inspectionSheetService.saveFluxParamList(lists);
|
inspectionSheetService.saveFluxParamList(dto);
|
||||||
|
|
||||||
return new Result();
|
return new Result();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检验样本 表
|
* 检验样本 表
|
||||||
@ -22,4 +23,13 @@ public class InspectionSampleDTO implements Serializable {
|
|||||||
@ApiModelProperty(value = "检验单id")
|
@ApiModelProperty(value = "检验单id")
|
||||||
private String inspectionSheetId;
|
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
|
@Mapper
|
||||||
public interface InspectionSheetMapper extends BaseDao<InspectionSheet> {
|
public interface InspectionSheetMapper extends BaseDao<InspectionSheet> {
|
||||||
List<InspectionSheetDTO> list(Map<String, Object> params);
|
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);
|
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;
|
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.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;
|
||||||
@ -36,6 +38,7 @@ 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 org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
@ -61,7 +64,7 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShiftServiceImpl shiftService;
|
private ShiftServiceImpl shiftService;
|
||||||
|
|
||||||
@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");
|
||||||
@ -131,6 +134,12 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void save(InspectionSheetDTO dto) {
|
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);
|
InspectionSheet entity = ConvertUtils.sourceToTarget(dto, InspectionSheet.class);
|
||||||
insert(entity);
|
insert(entity);
|
||||||
}
|
}
|
||||||
@ -149,7 +158,7 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
deleteBatchIds(Arrays.asList(ids));
|
deleteBatchIds(Arrays.asList(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private InspectionSheetMapper mapper;
|
private InspectionSheetMapper mapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -176,25 +185,39 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveFluxParamList(@RequestBody InspectionSampleDTO[] lists){
|
public void saveFluxParamList(InspectionSampleDTO dto){
|
||||||
for(InspectionSampleDTO dto:lists){
|
//String jsonData = {"workingProcedureName":"test","inspectionSheetId":"116","param1":"0.47","param2":"0.687","param2":"0.53"};
|
||||||
String equipmentName = dto.getWorkingProcedureName();
|
String workingProcedureName = dto.getWorkingProcedureName();
|
||||||
LocalDateTime eventTimestamp = LocalDateTime.now();
|
String inspectionSheetId = dto.getInspectionSheetId();
|
||||||
Instant eventTime = eventTimestamp.toInstant(ZoneOffset.UTC);
|
String batchNum = dto.getBatchNum();
|
||||||
String inspectionSheetId =dto.getInspectionSheetId();
|
String jsonData = dto.getJsonData();
|
||||||
// Event event = new Event(eventTime,inspectionSheetId,"ppExecName",ppExecName);
|
JSONObject json = JSON.parseObject(jsonData);
|
||||||
// InfluxClient.Client.insert(event,equipmentName);
|
// 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 event = new Event();
|
||||||
event.setInspectionSheetId(inspectionSheetId);
|
event.setInspectionSheetId(inspectionSheetId);
|
||||||
event.setTime(time);
|
event.setTime(time);
|
||||||
|
event.setBatchNum(batchNum);
|
||||||
event.setArgName(argName);
|
event.setArgName(argName);
|
||||||
if(!Objects.equals(argValue, "") && argValue != null ){
|
if(!Objects.equals(argValue, "") && argValue != null ){
|
||||||
event.setArgValue(argValue);
|
event.setArgValue(argValue);
|
||||||
}
|
}
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getNumberOfSamples(Long id) {
|
||||||
|
return mapper.getNumberOfSamples(id);
|
||||||
|
}
|
||||||
}
|
}
|
@ -64,4 +64,11 @@
|
|||||||
order by i.id asc
|
order by i.id asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getNumberOfSamples" resultType="Integer">
|
||||||
|
select max(sample_size) from product_features
|
||||||
|
<where>
|
||||||
|
valid = 1 AND product_id = #{id}
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user