MARK FOR PULL
This commit is contained in:
parent
6829169a4a
commit
b15ad64d76
@ -19,7 +19,6 @@ public class ProductFeaturesDTO implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "ID")
|
@ApiModelProperty(value = "ID")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@ -31,6 +31,6 @@ public class QueryDataParam extends BaseParam{
|
|||||||
private List<String> dropedTagNames;
|
private List<String> dropedTagNames;
|
||||||
private String bucket;
|
private String bucket;
|
||||||
private String groupName;
|
private String groupName;
|
||||||
private String inspectionSheetId;
|
//private String inspectionSheetId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.cnbm.processInspection.controller;
|
package com.cnbm.processInspection.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.cnbm.admin.annotation.LogOperation;
|
import com.cnbm.admin.annotation.LogOperation;
|
||||||
import com.cnbm.basic.dto.FeaturesProcedureDTO;
|
import com.cnbm.basic.dto.FeaturesProcedureDTO;
|
||||||
import com.cnbm.basic.dto.ProductFeaturesDTO;
|
import com.cnbm.basic.dto.ProductFeaturesDTO;
|
||||||
@ -64,7 +65,7 @@ public class InspectionSheetController {
|
|||||||
@ApiImplicitParam(name = "batchNumber", value = "批次号", paramType = "query", dataTypeClass = String.class),
|
@ApiImplicitParam(name = "batchNumber", value = "批次号", paramType = "query", dataTypeClass = String.class),
|
||||||
@ApiImplicitParam(name = "id", value = "检验单号", paramType = "query", dataTypeClass = Integer.class)
|
@ApiImplicitParam(name = "id", value = "检验单号", paramType = "query", dataTypeClass = Integer.class)
|
||||||
})
|
})
|
||||||
// @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:page')")
|
@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:page')")
|
||||||
public Result<PageData<InspectionSheetDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
public Result<PageData<InspectionSheetDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||||
PageData<InspectionSheetDTO> page = inspectionSheetService.page(params);
|
PageData<InspectionSheetDTO> page = inspectionSheetService.page(params);
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ public class InspectionSheetController {
|
|||||||
|
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
@ApiOperation("信息")
|
@ApiOperation("信息")
|
||||||
//@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:info')")
|
@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:info')")
|
||||||
public Result<InspectionSheetDTO> get(@PathVariable("id") Long id){
|
public Result<InspectionSheetDTO> get(@PathVariable("id") Long id){
|
||||||
InspectionSheetDTO data = inspectionSheetService.get(id);
|
InspectionSheetDTO data = inspectionSheetService.get(id);
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ public class InspectionSheetController {
|
|||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("保存")
|
@ApiOperation("保存")
|
||||||
@LogOperation("保存")
|
@LogOperation("保存")
|
||||||
// @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:save')")
|
@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:save')")
|
||||||
public Result save(@RequestBody InspectionSheetDTO dto){
|
public Result save(@RequestBody InspectionSheetDTO dto){
|
||||||
//效验数据
|
//效验数据
|
||||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||||
@ -99,7 +100,7 @@ public class InspectionSheetController {
|
|||||||
@PutMapping
|
@PutMapping
|
||||||
@ApiOperation("修改")
|
@ApiOperation("修改")
|
||||||
@LogOperation("修改")
|
@LogOperation("修改")
|
||||||
//@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:update')")
|
@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:update')")
|
||||||
public Result<Long> update(@RequestBody InspectionSheetDTO dto){
|
public Result<Long> update(@RequestBody InspectionSheetDTO dto){
|
||||||
//效验数据
|
//效验数据
|
||||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||||
@ -112,7 +113,7 @@ public class InspectionSheetController {
|
|||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
@ApiOperation("删除")
|
@ApiOperation("删除")
|
||||||
@LogOperation("删除")
|
@LogOperation("删除")
|
||||||
//@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:delete')")
|
@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:delete')")
|
||||||
public Result delete(@RequestBody Long[] ids){
|
public Result delete(@RequestBody Long[] ids){
|
||||||
//效验数据
|
//效验数据
|
||||||
AssertUtils.isArrayEmpty(ids, "id");
|
AssertUtils.isArrayEmpty(ids, "id");
|
||||||
@ -125,7 +126,7 @@ public class InspectionSheetController {
|
|||||||
@GetMapping("export")
|
@GetMapping("export")
|
||||||
@ApiOperation("导出")
|
@ApiOperation("导出")
|
||||||
@LogOperation("导出")
|
@LogOperation("导出")
|
||||||
//@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:export')")
|
@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:export')")
|
||||||
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
||||||
List<InspectionSheetDTO> list = inspectionSheetService.list(params);
|
List<InspectionSheetDTO> list = inspectionSheetService.list(params);
|
||||||
|
|
||||||
@ -151,14 +152,17 @@ public class InspectionSheetController {
|
|||||||
|
|
||||||
@PostMapping(value = "getFluxParamList")
|
@PostMapping(value = "getFluxParamList")
|
||||||
@ApiOperation(value = "从influxdb中获取检测参数")
|
@ApiOperation(value = "从influxdb中获取检测参数")
|
||||||
@ApiImplicitParams({
|
// @ApiImplicitParams({
|
||||||
// @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataTypeClass = LocalDateTime.class),
|
// @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataTypeClass = LocalDateTime.class),
|
||||||
// @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataTypeClass = LocalDateTime.class),
|
// @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataTypeClass = LocalDateTime.class),
|
||||||
@ApiImplicitParam(name = "inspectionSheetId", value = "检验单号", paramType = "query", dataTypeClass = Long.class),
|
// @ApiImplicitParam(name = "inspectionSheetId", value = "检验单号", paramType = "query", dataTypeClass = String.class),
|
||||||
@ApiImplicitParam(name = "workingProcedureName", value = "工序名称", paramType = "query", dataTypeClass = String.class)
|
// @ApiImplicitParam(name = "workingProcedureName", value = "工序名称", paramType = "query", dataTypeClass = String.class)
|
||||||
})
|
// })
|
||||||
List<Event> getFluxParamList(@ApiIgnore @RequestParam Map<String, Object> params){
|
// List<Event> getFluxParamList(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||||
return inspectionSheetService.getFluxParamList(params);
|
// return inspectionSheetService.getFluxParamList(params);
|
||||||
|
// }
|
||||||
|
List<InspectionSampleDTO> getFluxParamList(@RequestParam("inspectionSheetId") Long inspectionSheetId){
|
||||||
|
return inspectionSheetService.getFluxParamList(inspectionSheetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("saveFluxParamList")
|
@PostMapping("saveFluxParamList")
|
||||||
@ -166,7 +170,8 @@ public class InspectionSheetController {
|
|||||||
public Result saveFluxParamList(@RequestBody InspectionSampleDTO[] lists){
|
public Result saveFluxParamList(@RequestBody InspectionSampleDTO[] lists){
|
||||||
|
|
||||||
inspectionSheetService.saveFluxParamList(lists);
|
inspectionSheetService.saveFluxParamList(lists);
|
||||||
|
//样本数据更新后 计算检验单缺陷数不良数
|
||||||
|
inspectionSheetService.calculate(Long.valueOf(lists[0].getInspectionSheetId()));
|
||||||
return new Result();
|
return new Result();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,4 +187,11 @@ public class InspectionSheetController {
|
|||||||
return new Result<List<ProductFeaturesDTO>>().ok(list);
|
return new Result<List<ProductFeaturesDTO>>().ok(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "calculate")
|
||||||
|
@ApiOperation(value = "检验单统计计算")
|
||||||
|
public Result<Long> calculate(@RequestParam("inspectionSheetId") Long inspectionSheetId){
|
||||||
|
inspectionSheetService.calculate(inspectionSheetId);
|
||||||
|
return new Result<Long>().ok(inspectionSheetId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.cnbm.processInspection.service;
|
package com.cnbm.processInspection.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.cnbm.basic.dto.ProductFeaturesDTO;
|
import com.cnbm.basic.dto.ProductFeaturesDTO;
|
||||||
import com.cnbm.common.page.PageData;
|
import com.cnbm.common.page.PageData;
|
||||||
import com.cnbm.common.service.CrudService;
|
import com.cnbm.common.service.CrudService;
|
||||||
@ -33,10 +34,13 @@ public interface IInspectionSheetService extends CrudService<InspectionSheet, In
|
|||||||
|
|
||||||
List<InspectionSheetDTO> list(Map<String, Object> params);
|
List<InspectionSheetDTO> list(Map<String, Object> params);
|
||||||
|
|
||||||
List<Event> getFluxParamList(Map<String, Object> params);
|
// List<Event> getFluxParamList(Map<String, Object> params);
|
||||||
|
List<InspectionSampleDTO> getFluxParamList(Long inspectionSheetId);
|
||||||
|
|
||||||
void saveFluxParamList(InspectionSampleDTO[] lists);
|
void saveFluxParamList(InspectionSampleDTO[] lists);
|
||||||
|
|
||||||
List<ProductFeaturesDTO> getInspectionSheetFeaturesList(Map<String, Object> params);
|
List<ProductFeaturesDTO> getInspectionSheetFeaturesList(Map<String, Object> params);
|
||||||
|
|
||||||
|
void calculate(Long inspectionSheetId);
|
||||||
|
|
||||||
}
|
}
|
@ -29,6 +29,7 @@ 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.google.gson.JsonObject;
|
||||||
import com.influxdb.query.FluxRecord;
|
import com.influxdb.query.FluxRecord;
|
||||||
import com.influxdb.query.FluxTable;
|
import com.influxdb.query.FluxTable;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -40,6 +41,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -128,7 +130,12 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
@Override
|
@Override
|
||||||
public InspectionSheetDTO get(Long id) {
|
public InspectionSheetDTO get(Long id) {
|
||||||
InspectionSheet entity = baseDao.selectById(id);
|
InspectionSheet entity = baseDao.selectById(id);
|
||||||
return ConvertUtils.sourceToTarget(entity, InspectionSheetDTO.class);
|
InspectionSheetDTO dto = ConvertUtils.sourceToTarget(entity, InspectionSheetDTO.class);
|
||||||
|
WorkingProcedure workingProcedure = workingProcedureService.selectById(dto.getWorkingProcedureId());
|
||||||
|
if(workingProcedure!=null){
|
||||||
|
dto.setWorkingProcedureName(workingProcedure.getName());
|
||||||
|
}
|
||||||
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -179,51 +186,181 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Event> getFluxParamList(Map<String, Object> params){
|
public List<InspectionSampleDTO> getFluxParamList(Long id) {
|
||||||
|
List<Event> eventList = new ArrayList<>();
|
||||||
|
InspectionSheetDTO dto = get(id);
|
||||||
|
if (dto != null && dto.getWorkingProcedureName()!=null) {
|
||||||
QueryDataParam queryDataParam = new QueryDataParam();
|
QueryDataParam queryDataParam = new QueryDataParam();
|
||||||
String workingProcedureName = (String)params.get("workingProcedureName");
|
String inspectionSheetId = id.toString();
|
||||||
String inspectionSheetId = (String)params.get("inspectionSheetId");
|
String workingProcedureName = dto.getWorkingProcedureName();
|
||||||
queryDataParam.setMeasurement(workingProcedureName);
|
queryDataParam.setMeasurement(workingProcedureName);
|
||||||
queryDataParam.setInspectionSheetId(inspectionSheetId);
|
//queryDataParam.setInspectionSheetId(inspectionSheetId);
|
||||||
queryDataParam.setBucket("qgs-bucket");
|
queryDataParam.setBucket("qgs-bucket");
|
||||||
|
queryDataParam.setTag(new Tag("inspectionSheetId", inspectionSheetId));
|
||||||
// Instant startTime = (Instant) params.get("startTime");
|
|
||||||
// Instant endTime = (Instant) params.get("endTime");
|
|
||||||
// Range range = new Range(startTime,endTime);
|
|
||||||
// queryDataParam.setRange(range);
|
|
||||||
List<String> dropNames = new ArrayList<>();
|
List<String> dropNames = new ArrayList<>();
|
||||||
dropNames.add("transationId");
|
dropNames.add("transationId");
|
||||||
// dropNames.add("inspectionSheetId");
|
|
||||||
queryDataParam.setDropedTagNames(dropNames);
|
queryDataParam.setDropedTagNames(dropNames);
|
||||||
// queryDataParam.setTag(new Tag("argName","forUpdate"));
|
|
||||||
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(), DataUtils.getAfterDate(999).toInstant()));
|
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(), DataUtils.getAfterDate(999).toInstant()));
|
||||||
queryDataParam.setPageInfo(new PageInfo(1, 10));
|
queryDataParam.setPageInfo(new PageInfo(1, 10));
|
||||||
|
|
||||||
List<FluxTable> fluxTableList = InfluxClient.Client.query(queryDataParam);
|
List<FluxTable> fluxTableList = InfluxClient.Client.query(queryDataParam);
|
||||||
List<Event> eventList = new ArrayList<>();
|
|
||||||
|
|
||||||
for (FluxTable fluxTable : fluxTableList) {
|
for (FluxTable fluxTable : fluxTableList) {
|
||||||
List<FluxRecord> records = fluxTable.getRecords(); // 获取实际的记录操作
|
List<FluxRecord> records = fluxTable.getRecords(); // 获取实际的记录操作
|
||||||
// List<FluxColumn> columns = fluxTable.getColumns(); // 获取返回的列
|
|
||||||
// System.out.println(columns); // 下面的数据显示是按照当前的column中的label名称获取的数据
|
|
||||||
//System.out.println(records);
|
|
||||||
for (FluxRecord fluxRecord : records) {
|
for (FluxRecord fluxRecord : records) {
|
||||||
Instant time = fluxRecord.getTime();
|
Instant time = fluxRecord.getTime();
|
||||||
String argName = (String) fluxRecord.getValueByKey("argName");
|
String argName = (String) fluxRecord.getValueByKey("argName");
|
||||||
Double argValue = Double.valueOf(fluxRecord.getValueByKey("_value").toString());
|
String argValue = (String)fluxRecord.getValueByKey("_value");
|
||||||
String batchNum = (String) fluxRecord.getValueByKey("batchNum");
|
String batchNum = (String) fluxRecord.getValueByKey("batchNum");
|
||||||
String sampleNo = (String)fluxRecord.getValueByKey("sampleNo");
|
String sampleNo = (String) fluxRecord.getValueByKey("sampleNumber");
|
||||||
// System.out.println(fluxRecord.getTime() + ": " + fluxRecord.getValueByKey("argName") + ":"
|
|
||||||
// + fluxRecord.getValueByKey("_value") + ": " + fluxRecord.getValueByKey("batchNum"));
|
|
||||||
eventList.add(newEvent(time, inspectionSheetId, argName, argValue, batchNum, sampleNo));
|
eventList.add(newEvent(time, inspectionSheetId, argName, argValue, batchNum, sampleNo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
List<InspectionSampleDTO> list = new ArrayList<>();
|
||||||
|
if (eventList != null || eventList.size() > 0) {
|
||||||
|
//根据样本号分组
|
||||||
|
Map<String, List<Event>> map = eventList.stream().collect(Collectors.groupingBy(Event::getSampleNumber));
|
||||||
|
for (Map.Entry<String, List<Event>> entry : map.entrySet()) {
|
||||||
|
String sampleNumber = entry.getKey();
|
||||||
|
List<Event> events = entry.getValue();
|
||||||
|
|
||||||
//更新检验单缺陷数不良数
|
InspectionSampleDTO sampleDTO = new InspectionSampleDTO();
|
||||||
|
sampleDTO.setSampleNumber(sampleNumber);
|
||||||
|
sampleDTO.setSampleTime(LocalDateTime.ofInstant(events.get(0).getTime(), ZoneId.systemDefault()));
|
||||||
|
sampleDTO.setBatchNum(events.get(0).getBatchNum());
|
||||||
|
sampleDTO.setInspectionSheetId(events.get(0).getInspectionSheetId());
|
||||||
|
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
for(Event event:events){
|
||||||
|
jsonObject.put(event.getArgName(),event.getArgValue());
|
||||||
|
}
|
||||||
|
sampleDTO.setJsonData(jsonObject.toString());
|
||||||
|
|
||||||
|
System.out.println(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveFluxParamList(InspectionSampleDTO[] lists) {
|
||||||
|
for (InspectionSampleDTO dto : lists) {
|
||||||
|
//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 sampleNumber = dto.getSampleNumber();
|
||||||
|
String jsonData = dto.getJsonData();
|
||||||
|
JSONObject json = JSON.parseObject(jsonData);
|
||||||
|
LocalDateTime sampleTime = dto.getSampleTime();
|
||||||
|
Instant eventTime = sampleTime.toInstant(ZoneOffset.UTC);
|
||||||
|
List<Event> list = new ArrayList<>();
|
||||||
|
for (Map.Entry entry : json.entrySet()) {
|
||||||
|
String key = entry.getKey().toString();
|
||||||
|
String v = entry.getValue().toString();
|
||||||
|
// Double v = null;
|
||||||
|
// try {
|
||||||
|
// v= Double.valueOf(entry.getValue().toString());
|
||||||
|
// }catch (Exception e){
|
||||||
|
// }
|
||||||
|
list.add(newEvent(eventTime, inspectionSheetId, key, v, batchNum, sampleNumber));
|
||||||
|
}
|
||||||
|
InfluxClient.Client.batchInsert(list, workingProcedureName);
|
||||||
|
}
|
||||||
|
// //样本数据更新后 计算检验单缺陷数不良数
|
||||||
|
// System.out.println("--------------------------------------");
|
||||||
|
// calculate(Long.valueOf(lists[0].getInspectionSheetId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Event newEvent(Instant time, String inspectionSheetId, String argName, String argValue, String batchNum, String sampleNo) {
|
||||||
|
Event event = new Event();
|
||||||
|
event.setInspectionSheetId(inspectionSheetId);
|
||||||
|
event.setTime(time);
|
||||||
|
event.setBatchNum(batchNum);
|
||||||
|
event.setSampleNumber(sampleNo);
|
||||||
|
event.setArgName(argName);
|
||||||
|
event.setArgValue(argValue);
|
||||||
|
// if (Objects.equals(argValue, "")){
|
||||||
|
// event.setArgValue("");
|
||||||
|
// }else if (argValue != null) {
|
||||||
|
// event.setArgValue(argValue.toString());
|
||||||
|
// }
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public Integer getNumberOfSamples(Map<String, Object> params) {
|
||||||
|
// return mapper.getNumberOfSamples(params);
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ProductFeaturesDTO> getInspectionSheetFeaturesList(Map<String, Object> params) {
|
||||||
|
return mapper.getInspectionSheetFeaturesList(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算并更新检验单缺陷数不良数
|
||||||
|
@Override
|
||||||
|
public void calculate(Long inspectionSheetId) {
|
||||||
|
List<InspectionSampleDTO> sampleDTOList = getFluxParamList(inspectionSheetId);
|
||||||
|
if (sampleDTOList != null || sampleDTOList.size() > 0) {
|
||||||
|
//缺陷
|
||||||
|
Integer numberOfDefects = 0;
|
||||||
|
//不良
|
||||||
|
Integer defectiveQuantity = 0;
|
||||||
|
|
||||||
|
//获取的产品特性参照值
|
||||||
|
InspectionSheetDTO dto = get(inspectionSheetId);
|
||||||
|
Map<String, Object> params2 = new HashMap<>();
|
||||||
|
params2.put("productId", dto.getProductId());
|
||||||
|
params2.put("workingProcedureId", dto.getWorkingProcedureId());
|
||||||
|
params2.put("inspectionStage", dto.getInspectionStage());
|
||||||
|
List<ProductFeaturesDTO> featuresList = getInspectionSheetFeaturesList(params2);
|
||||||
|
//循环每个样本组
|
||||||
|
for (InspectionSampleDTO sampleDTO : sampleDTOList) {
|
||||||
|
//该样本的缺陷数
|
||||||
|
Integer eventDefects = 0;
|
||||||
|
//该样本的属性列表
|
||||||
|
String jsonData = sampleDTO.getJsonData();
|
||||||
|
JSONObject json = JSON.parseObject(jsonData);
|
||||||
|
for (ProductFeaturesDTO feature : featuresList) {
|
||||||
|
String v = (String)json.get(feature.getName());
|
||||||
|
if (!Objects.equals(v, "") && v != null) {
|
||||||
|
//1 计量型;2 计数型
|
||||||
|
if (feature.getType() == 1) {
|
||||||
|
Double featureValue = Double.valueOf(v);
|
||||||
|
if (featureValue > feature.getUsl() || featureValue < feature.getLsl()) {
|
||||||
|
eventDefects = eventDefects + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (feature.getType() == 2) {
|
||||||
|
Integer featureValue = Integer.valueOf(v);
|
||||||
|
if (featureValue == 1) {
|
||||||
|
eventDefects = eventDefects + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (eventDefects != 0) {
|
||||||
|
numberOfDefects = numberOfDefects + eventDefects;
|
||||||
|
defectiveQuantity = defectiveQuantity + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
InspectionSheetDTO updateDto = new InspectionSheetDTO();
|
||||||
|
updateDto.setId(inspectionSheetId);
|
||||||
|
updateDto.setNumberOfDefects(numberOfDefects);
|
||||||
|
updateDto.setDefectiveQuantity(defectiveQuantity);
|
||||||
|
update(updateDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
//获取该检验单的所有样本数据
|
||||||
|
List<Event> eventList = getFluxParamList(inspectionSheetId);
|
||||||
|
if (eventList != null || eventList.size() > 0) {
|
||||||
//根据样本号分组
|
//根据样本号分组
|
||||||
Map<String, List<Event>> map = eventList.stream().collect(Collectors.groupingBy(Event::getSampleNumber));
|
Map<String, List<Event>> map = eventList.stream().collect(Collectors.groupingBy(Event::getSampleNumber));
|
||||||
//获取的产品特性参照值
|
//获取的产品特性参照值
|
||||||
InspectionSheetDTO dto = get((Long) params.get("inspectionSheetId"));
|
InspectionSheetDTO dto = get(inspectionSheetId);
|
||||||
Map<String, Object> params2 = new HashMap<>();
|
Map<String, Object> params2 = new HashMap<>();
|
||||||
params2.put("productId", dto.getProductId());
|
params2.put("productId", dto.getProductId());
|
||||||
params2.put("workingProcedureId", dto.getWorkingProcedureId());
|
params2.put("workingProcedureId", dto.getWorkingProcedureId());
|
||||||
@ -243,7 +380,7 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
for (Event event : eventList1) {
|
for (Event event : eventList1) {
|
||||||
String featureName = event.getArgName();
|
String featureName = event.getArgName();
|
||||||
ProductFeaturesDTO feature = featuresList.stream().filter(u -> u.getName().equals(featureName)).findAny().orElse(null);
|
ProductFeaturesDTO feature = featuresList.stream().filter(u -> u.getName().equals(featureName)).findAny().orElse(null);
|
||||||
if(feature!=null){
|
if (feature != null && !Objects.equals(event.getArgValue(), "") && event.getArgValue() != null) {
|
||||||
//1 计量型;2 计数型
|
//1 计量型;2 计数型
|
||||||
if (feature.getType() == 1) {
|
if (feature.getType() == 1) {
|
||||||
Double featureValue = Double.valueOf(event.getArgValue());
|
Double featureValue = Double.valueOf(event.getArgValue());
|
||||||
@ -265,57 +402,10 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
InspectionSheetDTO updateDto = new InspectionSheetDTO();
|
InspectionSheetDTO updateDto = new InspectionSheetDTO();
|
||||||
updateDto.setId((Long)params.get("inspectionSheetId"));
|
updateDto.setId(inspectionSheetId);
|
||||||
updateDto.setNumberOfDefects(numberOfDefects);
|
updateDto.setNumberOfDefects(numberOfDefects);
|
||||||
updateDto.setDefectiveQuantity(defectiveQuantity);
|
updateDto.setDefectiveQuantity(defectiveQuantity);
|
||||||
update(updateDto);
|
update(updateDto);
|
||||||
|
|
||||||
return eventList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveFluxParamList(InspectionSampleDTO[] lists){
|
|
||||||
for(InspectionSampleDTO dto:lists) {
|
|
||||||
//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 sampleNumber = dto.getSampleNumber();
|
|
||||||
String jsonData = dto.getJsonData();
|
|
||||||
JSONObject json = JSON.parseObject(jsonData);
|
|
||||||
LocalDateTime sampleTime = dto.getSampleTime();
|
|
||||||
Instant eventTime = sampleTime.toInstant(ZoneOffset.UTC);
|
|
||||||
|
|
||||||
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, sampleNumber));
|
|
||||||
}
|
|
||||||
InfluxClient.Client.batchInsert(list, workingProcedureName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Event newEvent(Instant time,String inspectionSheetId,String argName,Double argValue,String batchNum,String sampleNo){
|
|
||||||
Event event = new Event();
|
|
||||||
event.setInspectionSheetId(inspectionSheetId);
|
|
||||||
event.setTime(time);
|
|
||||||
event.setBatchNum(batchNum);
|
|
||||||
event.setSampleNumber(sampleNo);
|
|
||||||
event.setArgName(argName);
|
|
||||||
if(!Objects.equals(argValue, "") && argValue != null ){
|
|
||||||
event.setArgValue(argValue.toString());
|
|
||||||
}
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public Integer getNumberOfSamples(Map<String, Object> params) {
|
|
||||||
// return mapper.getNumberOfSamples(params);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ProductFeaturesDTO> getInspectionSheetFeaturesList(Map<String, Object> params) {
|
|
||||||
return mapper.getInspectionSheetFeaturesList(params);
|
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user