MARK
This commit is contained in:
parent
c9d01c9e11
commit
d03a3e06a3
@ -17,6 +17,7 @@ import com.cnbm.influx.param.QueryDataParam;
|
|||||||
import com.cnbm.influx.template.Event;
|
import com.cnbm.influx.template.Event;
|
||||||
import com.cnbm.processInspection.dto.InspectionSampleDTO;
|
import com.cnbm.processInspection.dto.InspectionSampleDTO;
|
||||||
import com.cnbm.processInspection.dto.InspectionSheetDTO;
|
import com.cnbm.processInspection.dto.InspectionSheetDTO;
|
||||||
|
import com.cnbm.processInspection.entity.InspectionSheet;
|
||||||
import com.cnbm.processInspection.excel.InspectionSheetExcel;
|
import com.cnbm.processInspection.excel.InspectionSheetExcel;
|
||||||
import com.cnbm.processInspection.service.IInspectionSheetService;
|
import com.cnbm.processInspection.service.IInspectionSheetService;
|
||||||
import com.influxdb.query.FluxTable;
|
import com.influxdb.query.FluxTable;
|
||||||
@ -85,16 +86,23 @@ public class InspectionSheetController {
|
|||||||
@ApiOperation("保存")
|
@ApiOperation("保存")
|
||||||
@LogOperation("保存")
|
@LogOperation("保存")
|
||||||
@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:save')")
|
@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:save')")
|
||||||
public Result save(@RequestBody InspectionSheetDTO dto){
|
public Result<Long> save(@RequestBody InspectionSheetDTO dto){
|
||||||
//效验数据
|
//效验数据
|
||||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
inspectionSheetService.save(dto);
|
// inspectionSheetService.saveSheet(dto);
|
||||||
}catch (Exception e){
|
// }catch (Exception e){
|
||||||
|
// return new Result<Long>().error(1,"没有发现检验参数");
|
||||||
|
// }
|
||||||
|
InspectionSheet entity = inspectionSheetService.saveSheet(dto);
|
||||||
|
if(entity.getNumberOfSamples()!=null){
|
||||||
|
inspectionSheetService.insert(entity);
|
||||||
|
return new Result<Long>().ok(entity.getId());
|
||||||
|
}
|
||||||
|
else{
|
||||||
return new Result<Long>().error(1,"没有发现检验参数");
|
return new Result<Long>().error(1,"没有发现检验参数");
|
||||||
}
|
}
|
||||||
return new Result<Long>().ok(dto.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
|
@ -26,7 +26,7 @@ public interface IInspectionSheetService extends CrudService<InspectionSheet, In
|
|||||||
|
|
||||||
InspectionSheetDTO get(Long id);
|
InspectionSheetDTO get(Long id);
|
||||||
|
|
||||||
void save(InspectionSheetDTO dto);
|
InspectionSheet saveSheet(InspectionSheetDTO dto);
|
||||||
|
|
||||||
void update(InspectionSheetDTO dto);
|
void update(InspectionSheetDTO dto);
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ 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;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -140,13 +141,22 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void save(InspectionSheetDTO dto) {
|
public InspectionSheet saveSheet(InspectionSheetDTO dto) {
|
||||||
// 验证是否有检验参数
|
// 验证是否有检验参数
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<String, Object>();
|
||||||
params.put("productId", dto.getProductId());
|
params.put("productId", dto.getProductId());
|
||||||
params.put("workingProcedureId", dto.getWorkingProcedureId());
|
params.put("workingProcedureId", dto.getWorkingProcedureId());
|
||||||
params.put("inspectionStage", dto.getInspectionStage());
|
params.put("inspectionStage", dto.getInspectionStage());
|
||||||
List<ProductFeaturesDTO> inspectionSheetFeaturesList = getInspectionSheetFeaturesList(params);
|
List<ProductFeaturesDTO> inspectionSheetFeaturesList = getInspectionSheetFeaturesList(params);
|
||||||
|
if (inspectionSheetFeaturesList != null && inspectionSheetFeaturesList.size() != 0) {
|
||||||
|
//分组样本数=样本大小=检验特性分组数的最大值
|
||||||
|
Integer numbersOfSamples = inspectionSheetFeaturesList.stream().max(Comparator.comparing(ProductFeaturesDTO::getSampleSize)).get().getSampleSize();
|
||||||
|
if (numbersOfSamples != null) {
|
||||||
|
dto.setNumberOfGroupedSamples(numbersOfSamples);
|
||||||
|
dto.setNumberOfSamples(numbersOfSamples);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
if (inspectionSheetFeaturesList == null || inspectionSheetFeaturesList.size() == 0) {
|
if (inspectionSheetFeaturesList == null || inspectionSheetFeaturesList.size() == 0) {
|
||||||
throw new RuntimeException("没有发现检验参数");
|
throw new RuntimeException("没有发现检验参数");
|
||||||
} else {
|
} else {
|
||||||
@ -157,8 +167,11 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
dto.setNumberOfSamples(numbersOfSamples);
|
dto.setNumberOfSamples(numbersOfSamples);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InspectionSheet entity = ConvertUtils.sourceToTarget(dto, InspectionSheet.class);
|
*/
|
||||||
insert(entity);
|
//InspectionSheet entity = ConvertUtils.sourceToTarget(dto, InspectionSheet.class);
|
||||||
|
InspectionSheet entity = new InspectionSheet();
|
||||||
|
BeanUtils.copyProperties(dto, entity);
|
||||||
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -210,9 +223,8 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
Instant time = fluxRecord.getTime();
|
Instant time = fluxRecord.getTime();
|
||||||
String argName = (String) fluxRecord.getValueByKey("argName");
|
String argName = (String) fluxRecord.getValueByKey("argName");
|
||||||
String argValue = (String)fluxRecord.getValueByKey("_value");
|
String argValue = (String)fluxRecord.getValueByKey("_value");
|
||||||
String batchNum = (String) fluxRecord.getValueByKey("batchNum");
|
|
||||||
String sampleNo = (String) fluxRecord.getValueByKey("sampleNumber");
|
String sampleNo = (String) fluxRecord.getValueByKey("sampleNumber");
|
||||||
eventList.add(newEvent(time, inspectionSheetId, argName, argValue, batchNum, sampleNo));
|
eventList.add(newEvent(time, inspectionSheetId, argName, argValue, sampleNo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,7 +239,7 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
InspectionSampleDTO sampleDTO = new InspectionSampleDTO();
|
InspectionSampleDTO sampleDTO = new InspectionSampleDTO();
|
||||||
sampleDTO.setSampleNumber(sampleNumber);
|
sampleDTO.setSampleNumber(sampleNumber);
|
||||||
sampleDTO.setSampleTime(LocalDateTime.ofInstant(events.get(0).getTime(), ZoneId.systemDefault()));
|
sampleDTO.setSampleTime(LocalDateTime.ofInstant(events.get(0).getTime(), ZoneId.systemDefault()));
|
||||||
sampleDTO.setBatchNum(events.get(0).getBatchNum());
|
sampleDTO.setBatchNum(dto.getBatchNumber());
|
||||||
sampleDTO.setInspectionSheetId(events.get(0).getInspectionSheetId());
|
sampleDTO.setInspectionSheetId(events.get(0).getInspectionSheetId());
|
||||||
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
@ -235,8 +247,8 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
jsonObject.put(event.getArgName(),event.getArgValue());
|
jsonObject.put(event.getArgName(),event.getArgValue());
|
||||||
}
|
}
|
||||||
sampleDTO.setJsonData(jsonObject.toString());
|
sampleDTO.setJsonData(jsonObject.toString());
|
||||||
|
//System.out.println(entry);
|
||||||
System.out.println(entry);
|
list.add(sampleDTO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@ -248,7 +260,7 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
//String jsonData = {"workingProcedureName":"test","inspectionSheetId":"116","param1":"0.47","param2":"0.687","param2":"0.53"};
|
//String jsonData = {"workingProcedureName":"test","inspectionSheetId":"116","param1":"0.47","param2":"0.687","param2":"0.53"};
|
||||||
String workingProcedureName = dto.getWorkingProcedureName();
|
String workingProcedureName = dto.getWorkingProcedureName();
|
||||||
String inspectionSheetId = dto.getInspectionSheetId();
|
String inspectionSheetId = dto.getInspectionSheetId();
|
||||||
String batchNum = dto.getBatchNum();
|
// String batchNum = dto.getBatchNum();
|
||||||
String sampleNumber = dto.getSampleNumber();
|
String sampleNumber = dto.getSampleNumber();
|
||||||
String jsonData = dto.getJsonData();
|
String jsonData = dto.getJsonData();
|
||||||
JSONObject json = JSON.parseObject(jsonData);
|
JSONObject json = JSON.parseObject(jsonData);
|
||||||
@ -263,7 +275,7 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
// v= Double.valueOf(entry.getValue().toString());
|
// v= Double.valueOf(entry.getValue().toString());
|
||||||
// }catch (Exception e){
|
// }catch (Exception e){
|
||||||
// }
|
// }
|
||||||
list.add(newEvent(eventTime, inspectionSheetId, key, v, batchNum, sampleNumber));
|
list.add(newEvent(eventTime, inspectionSheetId, key, v, sampleNumber));
|
||||||
}
|
}
|
||||||
InfluxClient.Client.batchInsert(list, workingProcedureName);
|
InfluxClient.Client.batchInsert(list, workingProcedureName);
|
||||||
}
|
}
|
||||||
@ -272,11 +284,11 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
// calculate(Long.valueOf(lists[0].getInspectionSheetId()));
|
// calculate(Long.valueOf(lists[0].getInspectionSheetId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Event newEvent(Instant time, String inspectionSheetId, String argName, String argValue, String batchNum, String sampleNo) {
|
private Event newEvent(Instant time, String inspectionSheetId, String argName, String argValue, String sampleNo) {
|
||||||
Event event = new Event();
|
Event event = new Event();
|
||||||
event.setInspectionSheetId(inspectionSheetId);
|
event.setInspectionSheetId(inspectionSheetId);
|
||||||
event.setTime(time);
|
event.setTime(time);
|
||||||
event.setBatchNum(batchNum);
|
// event.setBatchNum(batchNum);
|
||||||
event.setSampleNumber(sampleNo);
|
event.setSampleNumber(sampleNo);
|
||||||
event.setArgName(argName);
|
event.setArgName(argName);
|
||||||
event.setArgValue(argValue);
|
event.setArgValue(argValue);
|
||||||
|
Loading…
Reference in New Issue
Block a user