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;
|
||||||
@ -66,11 +68,11 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
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");
|
||||||
String inspectionSite = (String)params.get("inspectionSite");
|
String inspectionSite = (String) params.get("inspectionSite");
|
||||||
String orderNumber = (String)params.get("orderNumber");
|
String orderNumber = (String) params.get("orderNumber");
|
||||||
String batchNumber = (String)params.get("batchNumber");
|
String batchNumber = (String) params.get("batchNumber");
|
||||||
|
|
||||||
QueryWrapper<InspectionSheet> wrapper = new QueryWrapper<>();
|
QueryWrapper<InspectionSheet> wrapper = new QueryWrapper<>();
|
||||||
wrapper.like(ObjectUtils.isNotNull(id), "id", id);
|
wrapper.like(ObjectUtils.isNotNull(id), "id", id);
|
||||||
@ -84,15 +86,15 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageData<InspectionSheetDTO> page (Map<String, Object> params){
|
public PageData<InspectionSheetDTO> page(Map<String, Object> params) {
|
||||||
IPage<InspectionSheet> page = baseDao.selectPage(
|
IPage<InspectionSheet> page = baseDao.selectPage(
|
||||||
getPage(params, "id", true),
|
getPage(params, "id", true),
|
||||||
getWrapper(params)
|
getWrapper(params)
|
||||||
);
|
);
|
||||||
PageData<InspectionSheetDTO> inspectionSheetDTOPageData = getPageData(page, InspectionSheetDTO.class);
|
PageData<InspectionSheetDTO> inspectionSheetDTOPageData = getPageData(page, InspectionSheetDTO.class);
|
||||||
|
|
||||||
if(!inspectionSheetDTOPageData.getList().isEmpty()){
|
if (!inspectionSheetDTOPageData.getList().isEmpty()) {
|
||||||
for(InspectionSheetDTO dto:inspectionSheetDTOPageData.getList()){
|
for (InspectionSheetDTO dto : inspectionSheetDTOPageData.getList()) {
|
||||||
Product product = productService.selectById(dto.getProductId());
|
Product product = productService.selectById(dto.getProductId());
|
||||||
WorkingProcedure workingProcedure = workingProcedureService.selectById(dto.getWorkingProcedureId());
|
WorkingProcedure workingProcedure = workingProcedureService.selectById(dto.getWorkingProcedureId());
|
||||||
Machine machine = machineService.selectById(dto.getMachineId());
|
Machine machine = machineService.selectById(dto.getMachineId());
|
||||||
@ -103,16 +105,16 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
String machineName = null;
|
String machineName = null;
|
||||||
String shiftName = null;
|
String shiftName = null;
|
||||||
|
|
||||||
if (product!=null){
|
if (product != null) {
|
||||||
productName = product.getName();
|
productName = product.getName();
|
||||||
}
|
}
|
||||||
if (workingProcedure!=null){
|
if (workingProcedure != null) {
|
||||||
workingProcedureName = workingProcedure.getName();
|
workingProcedureName = workingProcedure.getName();
|
||||||
}
|
}
|
||||||
if (machine!=null){
|
if (machine != null) {
|
||||||
machineName = machine.getName();
|
machineName = machine.getName();
|
||||||
}
|
}
|
||||||
if (shift!=null){
|
if (shift != null) {
|
||||||
shiftName = shift.getName();
|
shiftName = shift.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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
|
||||||
@ -136,16 +143,16 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
public void save(InspectionSheetDTO dto) {
|
public void save(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){
|
if (inspectionSheetFeaturesList == null || inspectionSheetFeaturesList.size() == 0) {
|
||||||
throw new RuntimeException("没有发现检验参数");
|
throw new RuntimeException("没有发现检验参数");
|
||||||
}else{
|
} else {
|
||||||
//分组样本数=样本大小=检验特性分组数的最大值
|
//分组样本数=样本大小=检验特性分组数的最大值
|
||||||
Integer numbersOfSamples = inspectionSheetFeaturesList.stream().max(Comparator.comparing(ProductFeaturesDTO::getSampleSize)).get().getSampleSize();
|
Integer numbersOfSamples = inspectionSheetFeaturesList.stream().max(Comparator.comparing(ProductFeaturesDTO::getSampleSize)).get().getSampleSize();
|
||||||
if(numbersOfSamples!=null){
|
if (numbersOfSamples != null) {
|
||||||
dto.setNumberOfGroupedSamples(numbersOfSamples);
|
dto.setNumberOfGroupedSamples(numbersOfSamples);
|
||||||
dto.setNumberOfSamples(numbersOfSamples);
|
dto.setNumberOfSamples(numbersOfSamples);
|
||||||
}
|
}
|
||||||
@ -179,103 +186,65 @@ 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") + ":"
|
eventList.add(newEvent(time, inspectionSheetId, argName, argValue, batchNum, sampleNo));
|
||||||
// + fluxRecord.getValueByKey("_value") + ": " + fluxRecord.getValueByKey("batchNum"));
|
|
||||||
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));
|
Map<String, List<Event>> map = eventList.stream().collect(Collectors.groupingBy(Event::getSampleNumber));
|
||||||
//获取的产品特性参照值
|
|
||||||
InspectionSheetDTO dto = get((Long) params.get("inspectionSheetId"));
|
|
||||||
Map<String, Object> params2 = new HashMap<>();
|
|
||||||
params2.put("productId",dto.getProductId());
|
|
||||||
params2.put("workingProcedureId",dto.getWorkingProcedureId());
|
|
||||||
params2.put("inspectionStage",dto.getInspectionStage());
|
|
||||||
//缺陷
|
|
||||||
Integer numberOfDefects = 0;
|
|
||||||
//不良
|
|
||||||
Integer defectiveQuantity = 0;
|
|
||||||
|
|
||||||
List<ProductFeaturesDTO> featuresList = getInspectionSheetFeaturesList(params2);
|
|
||||||
//循环每个样本组
|
|
||||||
for (Map.Entry<String, List<Event>> entry : map.entrySet()) {
|
for (Map.Entry<String, List<Event>> entry : map.entrySet()) {
|
||||||
//该样本的缺陷数
|
String sampleNumber = entry.getKey();
|
||||||
Integer eventDefects = 0;
|
List<Event> events = entry.getValue();
|
||||||
//该样本的属性列表
|
|
||||||
List<Event> eventList1 = entry.getValue();
|
|
||||||
for(Event event : eventList1){
|
|
||||||
String featureName = event.getArgName();
|
|
||||||
ProductFeaturesDTO feature = featuresList.stream().filter(u -> u.getName().equals(featureName)).findAny().orElse(null);
|
|
||||||
if(feature!=null){
|
|
||||||
//1 计量型;2 计数型
|
|
||||||
if(feature.getType()==1){
|
|
||||||
Double featureValue = Double.valueOf(event.getArgValue());
|
|
||||||
if(featureValue>feature.getUsl()||featureValue<feature.getLsl()) {
|
|
||||||
eventDefects = eventDefects + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(feature.getType()==2){
|
|
||||||
Integer featureValue = Integer.valueOf(event.getArgValue());
|
|
||||||
if(featureValue==1){
|
|
||||||
eventDefects = eventDefects + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(eventDefects!=0){
|
|
||||||
numberOfDefects = numberOfDefects + eventDefects;
|
|
||||||
defectiveQuantity = defectiveQuantity + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
InspectionSheetDTO updateDto = new InspectionSheetDTO();
|
|
||||||
updateDto.setId((Long)params.get("inspectionSheetId"));
|
|
||||||
updateDto.setNumberOfDefects(numberOfDefects);
|
|
||||||
updateDto.setDefectiveQuantity(defectiveQuantity);
|
|
||||||
update(updateDto);
|
|
||||||
|
|
||||||
return eventList;
|
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
|
@Override
|
||||||
public void saveFluxParamList(InspectionSampleDTO[] lists){
|
public void saveFluxParamList(InspectionSampleDTO[] lists) {
|
||||||
for(InspectionSampleDTO dto:lists) {
|
for (InspectionSampleDTO dto : lists) {
|
||||||
//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();
|
||||||
@ -285,27 +254,37 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
JSONObject json = JSON.parseObject(jsonData);
|
JSONObject json = JSON.parseObject(jsonData);
|
||||||
LocalDateTime sampleTime = dto.getSampleTime();
|
LocalDateTime sampleTime = dto.getSampleTime();
|
||||||
Instant eventTime = sampleTime.toInstant(ZoneOffset.UTC);
|
Instant eventTime = sampleTime.toInstant(ZoneOffset.UTC);
|
||||||
|
|
||||||
List<Event> list = new ArrayList<>();
|
List<Event> list = new ArrayList<>();
|
||||||
for (Map.Entry entry : json.entrySet()) {
|
for (Map.Entry entry : json.entrySet()) {
|
||||||
String key = entry.getKey().toString();
|
String key = entry.getKey().toString();
|
||||||
Double v = Double.valueOf(entry.getValue().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));
|
list.add(newEvent(eventTime, inspectionSheetId, key, v, batchNum, sampleNumber));
|
||||||
}
|
}
|
||||||
InfluxClient.Client.batchInsert(list, workingProcedureName);
|
InfluxClient.Client.batchInsert(list, workingProcedureName);
|
||||||
}
|
}
|
||||||
|
// //样本数据更新后 计算检验单缺陷数不良数
|
||||||
|
// System.out.println("--------------------------------------");
|
||||||
|
// calculate(Long.valueOf(lists[0].getInspectionSheetId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Event newEvent(Instant time,String inspectionSheetId,String argName,Double argValue,String batchNum,String sampleNo){
|
private Event newEvent(Instant time, String inspectionSheetId, String argName, String argValue, String batchNum, 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);
|
||||||
if(!Objects.equals(argValue, "") && argValue != null ){
|
event.setArgValue(argValue);
|
||||||
event.setArgValue(argValue.toString());
|
// if (Objects.equals(argValue, "")){
|
||||||
}
|
// event.setArgValue("");
|
||||||
|
// }else if (argValue != null) {
|
||||||
|
// event.setArgValue(argValue.toString());
|
||||||
|
// }
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,4 +297,115 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
public List<ProductFeaturesDTO> getInspectionSheetFeaturesList(Map<String, Object> params) {
|
public List<ProductFeaturesDTO> getInspectionSheetFeaturesList(Map<String, Object> params) {
|
||||||
return mapper.getInspectionSheetFeaturesList(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));
|
||||||
|
//获取的产品特性参照值
|
||||||
|
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());
|
||||||
|
//缺陷
|
||||||
|
Integer numberOfDefects = 0;
|
||||||
|
//不良
|
||||||
|
Integer defectiveQuantity = 0;
|
||||||
|
|
||||||
|
List<ProductFeaturesDTO> featuresList = getInspectionSheetFeaturesList(params2);
|
||||||
|
//循环每个样本组
|
||||||
|
for (Map.Entry<String, List<Event>> entry : map.entrySet()) {
|
||||||
|
//该样本的缺陷数
|
||||||
|
Integer eventDefects = 0;
|
||||||
|
//该样本的属性列表
|
||||||
|
List<Event> eventList1 = entry.getValue();
|
||||||
|
for (Event event : eventList1) {
|
||||||
|
String featureName = event.getArgName();
|
||||||
|
ProductFeaturesDTO feature = featuresList.stream().filter(u -> u.getName().equals(featureName)).findAny().orElse(null);
|
||||||
|
if (feature != null && !Objects.equals(event.getArgValue(), "") && event.getArgValue() != null) {
|
||||||
|
//1 计量型;2 计数型
|
||||||
|
if (feature.getType() == 1) {
|
||||||
|
Double featureValue = Double.valueOf(event.getArgValue());
|
||||||
|
if (featureValue > feature.getUsl() || featureValue < feature.getLsl()) {
|
||||||
|
eventDefects = eventDefects + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (feature.getType() == 2) {
|
||||||
|
Integer featureValue = Integer.valueOf(event.getArgValue());
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user