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.processInspection.dto.InspectionSampleDTO;
|
||||
import com.cnbm.processInspection.dto.InspectionSheetDTO;
|
||||
import com.cnbm.processInspection.entity.InspectionSheet;
|
||||
import com.cnbm.processInspection.excel.InspectionSheetExcel;
|
||||
import com.cnbm.processInspection.service.IInspectionSheetService;
|
||||
import com.influxdb.query.FluxTable;
|
||||
@ -85,16 +86,23 @@ public class InspectionSheetController {
|
||||
@ApiOperation("保存")
|
||||
@LogOperation("保存")
|
||||
@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);
|
||||
|
||||
try {
|
||||
inspectionSheetService.save(dto);
|
||||
}catch (Exception e){
|
||||
// try {
|
||||
// inspectionSheetService.saveSheet(dto);
|
||||
// }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>().ok(dto.getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
|
@ -26,7 +26,7 @@ public interface IInspectionSheetService extends CrudService<InspectionSheet, In
|
||||
|
||||
InspectionSheetDTO get(Long id);
|
||||
|
||||
void save(InspectionSheetDTO dto);
|
||||
InspectionSheet saveSheet(InspectionSheetDTO dto);
|
||||
|
||||
void update(InspectionSheetDTO dto);
|
||||
|
||||
|
@ -33,6 +33,7 @@ import com.google.gson.JsonObject;
|
||||
import com.influxdb.query.FluxRecord;
|
||||
import com.influxdb.query.FluxTable;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -140,13 +141,22 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(InspectionSheetDTO dto) {
|
||||
public InspectionSheet saveSheet(InspectionSheetDTO dto) {
|
||||
// 验证是否有检验参数
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("productId", dto.getProductId());
|
||||
params.put("workingProcedureId", dto.getWorkingProcedureId());
|
||||
params.put("inspectionStage", dto.getInspectionStage());
|
||||
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) {
|
||||
throw new RuntimeException("没有发现检验参数");
|
||||
} else {
|
||||
@ -157,8 +167,11 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
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
|
||||
@ -210,9 +223,8 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
Instant time = fluxRecord.getTime();
|
||||
String argName = (String) fluxRecord.getValueByKey("argName");
|
||||
String argValue = (String)fluxRecord.getValueByKey("_value");
|
||||
String batchNum = (String) fluxRecord.getValueByKey("batchNum");
|
||||
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();
|
||||
sampleDTO.setSampleNumber(sampleNumber);
|
||||
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());
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
@ -235,8 +247,8 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
jsonObject.put(event.getArgName(),event.getArgValue());
|
||||
}
|
||||
sampleDTO.setJsonData(jsonObject.toString());
|
||||
|
||||
System.out.println(entry);
|
||||
//System.out.println(entry);
|
||||
list.add(sampleDTO);
|
||||
}
|
||||
}
|
||||
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 workingProcedureName = dto.getWorkingProcedureName();
|
||||
String inspectionSheetId = dto.getInspectionSheetId();
|
||||
String batchNum = dto.getBatchNum();
|
||||
// String batchNum = dto.getBatchNum();
|
||||
String sampleNumber = dto.getSampleNumber();
|
||||
String jsonData = dto.getJsonData();
|
||||
JSONObject json = JSON.parseObject(jsonData);
|
||||
@ -263,7 +275,7 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
// v= Double.valueOf(entry.getValue().toString());
|
||||
// }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);
|
||||
}
|
||||
@ -272,11 +284,11 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
||||
// 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.setInspectionSheetId(inspectionSheetId);
|
||||
event.setTime(time);
|
||||
event.setBatchNum(batchNum);
|
||||
// event.setBatchNum(batchNum);
|
||||
event.setSampleNumber(sampleNo);
|
||||
event.setArgName(argName);
|
||||
event.setArgValue(argValue);
|
||||
|
Loading…
Reference in New Issue
Block a user