diff --git a/ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java b/ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java
index f88342c..2146bbf 100644
--- a/ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java
+++ b/ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java
@@ -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);
diff --git a/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java b/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java
index aadadcc..d52e148 100644
--- a/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java
+++ b/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java
@@ -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");
diff --git a/ym-influx/src/main/java/com/cnbm/influx/template/Event.java b/ym-influx/src/main/java/com/cnbm/influx/template/Event.java
index d7ed0ae..5c5009e 100644
--- a/ym-influx/src/main/java/com/cnbm/influx/template/Event.java
+++ b/ym-influx/src/main/java/com/cnbm/influx/template/Event.java
@@ -26,5 +26,5 @@ public class Event {
private Double argValue;
//批次号,可选的
- private Integer batchNum;
+ private String batchNum;
}
\ No newline at end of file
diff --git a/ym-process-inspection/pom.xml b/ym-process-inspection/pom.xml
index 039f26f..cfd9f6f 100644
--- a/ym-process-inspection/pom.xml
+++ b/ym-process-inspection/pom.xml
@@ -14,6 +14,8 @@
8
8
+
+ 1.2.75
@@ -38,5 +40,10 @@
ym-quality-planning
1.0-SNAPSHOT
+
+ com.alibaba
+ fastjson
+ ${fastjson.version}
+
\ No newline at end of file
diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java
index 812ac64..916bc9f 100644
--- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java
+++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java
@@ -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();
}
diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/InspectionSampleDTO.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/InspectionSampleDTO.java
index f1f603a..e3da3e1 100644
--- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/InspectionSampleDTO.java
+++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/InspectionSampleDTO.java
@@ -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;
+
}
diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/mapper/InspectionSheetMapper.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/mapper/InspectionSheetMapper.java
index e6334e1..6afee49 100644
--- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/mapper/InspectionSheetMapper.java
+++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/mapper/InspectionSheetMapper.java
@@ -17,4 +17,5 @@ import java.util.Map;
@Mapper
public interface InspectionSheetMapper extends BaseDao {
List list(Map params);
+ Integer getNumberOfSamples(Long productId);
}
\ No newline at end of file
diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/IInspectionSheetService.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/IInspectionSheetService.java
index 0550160..9f3da4a 100644
--- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/IInspectionSheetService.java
+++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/IInspectionSheetService.java
@@ -33,6 +33,6 @@ public interface IInspectionSheetService extends CrudService getFluxParamList(Map params);
- void saveFluxParamList(InspectionSampleDTO[] lists);
-
+ void saveFluxParamList(InspectionSampleDTO dto);
+
}
\ No newline at end of file
diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/impl/InspectionSheetServiceImpl.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/impl/InspectionSheetServiceImpl.java
index 69bdd99..c156944 100644
--- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/impl/InspectionSheetServiceImpl.java
+++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/impl/InspectionSheetServiceImpl.java
@@ -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 getWrapper(Map params){
Long id = (Long)params.get("id");
@@ -131,6 +134,12 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl 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);
+ }
}
\ No newline at end of file
diff --git a/ym-process-inspection/src/main/resources/mapper/InspectionSheetMapper.xml b/ym-process-inspection/src/main/resources/mapper/InspectionSheetMapper.xml
index 4475f45..19df41b 100644
--- a/ym-process-inspection/src/main/resources/mapper/InspectionSheetMapper.xml
+++ b/ym-process-inspection/src/main/resources/mapper/InspectionSheetMapper.xml
@@ -64,4 +64,11 @@
order by i.id asc
+
+