From 4864545f1276a0c67a8e5f8eee247648ea3c9914 Mon Sep 17 00:00:00 2001 From: yanyang Date: Thu, 1 Dec 2022 15:50:30 +0800 Subject: [PATCH 1/4] m --- .../com/cnbm/influx/config/InfluxClient.java | 2 +- .../influx/controller/S7DemoController.java | 4 +- .../java/com/cnbm/influx/template/Event.java | 2 +- ym-process-inspection/pom.xml | 7 +++ .../controller/InspectionSheetController.java | 6 +-- .../dto/InspectionSampleDTO.java | 10 +++++ .../mapper/InspectionSheetMapper.java | 1 + .../service/IInspectionSheetService.java | 4 +- .../impl/InspectionSheetServiceImpl.java | 45 ++++++++++++++----- .../mapper/InspectionSheetMapper.xml | 7 +++ 10 files changed, 68 insertions(+), 20 deletions(-) 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 + + From b515eacbab5ff3761a0cf519ce38dabd7d14d1e9 Mon Sep 17 00:00:00 2001 From: yanyang Date: Wed, 7 Dec 2022 11:07:31 +0800 Subject: [PATCH 2/4] MARK FOR PULL --- .../admin/controller/SysUserController.java | 6 + .../basic/controller/MachineController.java | 8 + .../basic/controller/ProductController.java | 7 + .../basic/controller/ShiftController.java | 7 + .../cnbm/basic/controller/TeamController.java | 6 + .../com/cnbm/basic/mapper/ProductMapper.java | 2 + .../com/cnbm/basic/mapper/ShiftMapper.java | 6 +- .../com/cnbm/basic/mapper/TeamMapper.java | 6 +- .../cnbm/basic/service/IProductService.java | 3 + .../com/cnbm/basic/service/IShiftService.java | 3 + .../com/cnbm/basic/service/ITeamService.java | 3 + .../service/impl/ProductServiceImpl.java | 7 + .../basic/service/impl/ShiftServiceImpl.java | 12 ++ .../basic/service/impl/TeamServiceImpl.java | 14 +- .../main/resources/mapper/ProductMapper.xml | 5 + .../src/main/resources/mapper/ShiftMapper.xml | 5 + .../src/main/resources/mapper/TeamMapper.xml | 5 + .../cnbm/generator/build/CodeGenerator.java | 2 +- .../controller/InspectionSheetController.java | 118 +++++++++++++ .../code/dto/InspectionSheetDTO.java | 104 +++++++++++ .../code/entity/InspectionSheet.java | 106 +++++++++++ .../code/excel/InspectionSheetExcel.java | 72 ++++++++ .../code/mapper/InspectionSheetMapper.java | 16 ++ .../code/mapper/InspectionSheetMapper.xml | 33 ++++ .../code/mysql/InspectionSheetmysql.sql | 7 + .../code/service/IInspectionSheetService.java | 15 ++ .../impl/InspectionSheetServiceImpl.java | 34 ++++ .../com/cnbm/influx/config/InfluxClient.java | 6 +- .../com/cnbm/influx/param/QueryDataParam.java | 1 + .../controller/InspectionSheetController.java | 47 +++-- .../dto/InspectionSampleDTO.java | 3 + .../dto/InspectionSheetDTO.java | 4 +- .../entity/InspectionSheet.java | 4 +- .../excel/InspectionSheetExcel.java | 4 +- .../mapper/InspectionSheetMapper.java | 4 +- .../service/IInspectionSheetService.java | 8 +- .../impl/InspectionSheetServiceImpl.java | 166 ++++++++++++++---- .../mapper/InspectionSheetMapper.xml | 34 +++- 38 files changed, 828 insertions(+), 65 deletions(-) create mode 100644 ym-generator/src/main/java/com/cnbm/generator/code/controller/InspectionSheetController.java create mode 100644 ym-generator/src/main/java/com/cnbm/generator/code/dto/InspectionSheetDTO.java create mode 100644 ym-generator/src/main/java/com/cnbm/generator/code/entity/InspectionSheet.java create mode 100644 ym-generator/src/main/java/com/cnbm/generator/code/excel/InspectionSheetExcel.java create mode 100644 ym-generator/src/main/java/com/cnbm/generator/code/mapper/InspectionSheetMapper.java create mode 100644 ym-generator/src/main/java/com/cnbm/generator/code/mapper/InspectionSheetMapper.xml create mode 100644 ym-generator/src/main/java/com/cnbm/generator/code/mysql/InspectionSheetmysql.sql create mode 100644 ym-generator/src/main/java/com/cnbm/generator/code/service/IInspectionSheetService.java create mode 100644 ym-generator/src/main/java/com/cnbm/generator/code/service/impl/InspectionSheetServiceImpl.java diff --git a/ym-admin/src/main/java/com/cnbm/admin/controller/SysUserController.java b/ym-admin/src/main/java/com/cnbm/admin/controller/SysUserController.java index 7e93314..296a5ff 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/controller/SysUserController.java +++ b/ym-admin/src/main/java/com/cnbm/admin/controller/SysUserController.java @@ -160,4 +160,10 @@ public class SysUserController { ExcelUtils.exportExcelToTarget(response, null, list, SysUserExcel.class); } + + @PostMapping(value = "list") + @ApiOperation(value = "获取用户列表") + @LogOperation("获取用户列表") + public List list(@ApiIgnore @RequestParam Map params) { + return sysUserService.list(params); } } diff --git a/ym-baisc/src/main/java/com/cnbm/basic/controller/MachineController.java b/ym-baisc/src/main/java/com/cnbm/basic/controller/MachineController.java index 971f9c6..f05997b 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/controller/MachineController.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/controller/MachineController.java @@ -144,4 +144,12 @@ public class MachineController { return new Result().ok(true); } + @PostMapping(value = "list") + @ApiOperation(value = "获取机台列表") + @LogOperation("获取机台列表") + @ApiImplicitParam(name = "status", value = "状态", paramType = "query", dataTypeClass = Integer.class) + public List list(@ApiIgnore @RequestParam Map params) { + return machineService.list(params); + } + } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/controller/ProductController.java b/ym-baisc/src/main/java/com/cnbm/basic/controller/ProductController.java index da6a1f1..e96cb5f 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/controller/ProductController.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/controller/ProductController.java @@ -129,4 +129,11 @@ public class ProductController { return new Result(); } + @PostMapping(value = "list") + @ApiOperation(value = "获取产品列表") + @LogOperation("获取产品列表") + public List list() { + return productService.list(); + } + } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/controller/ShiftController.java b/ym-baisc/src/main/java/com/cnbm/basic/controller/ShiftController.java index abc6f9d..5cb3003 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/controller/ShiftController.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/controller/ShiftController.java @@ -114,4 +114,11 @@ public class ShiftController { ExcelUtils.exportExcelToTarget(response, null, list, ShiftExcel.class); } + @PostMapping(value = "list") + @ApiOperation(value = "获取班次列表") + @LogOperation("获取班次列表") + public List list() { + return shiftService.list(); + } + } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/controller/TeamController.java b/ym-baisc/src/main/java/com/cnbm/basic/controller/TeamController.java index ab65ce7..197114d 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/controller/TeamController.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/controller/TeamController.java @@ -1,6 +1,7 @@ package com.cnbm.basic.controller; import com.cnbm.admin.annotation.LogOperation; +import com.cnbm.basic.dto.ShiftDTO; import com.cnbm.common.constant.Constant; import com.cnbm.common.page.PageData; import com.cnbm.common.utils.ExcelUtils; @@ -114,4 +115,9 @@ public class TeamController { ExcelUtils.exportExcelToTarget(response, null, list, TeamExcel.class); } + @PostMapping(value = "list") + @ApiOperation(value = "获取班组列表") + @LogOperation("获取班组列表") + public List list() { return teamService.list(); } + } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/mapper/ProductMapper.java b/ym-baisc/src/main/java/com/cnbm/basic/mapper/ProductMapper.java index 830d29b..0158424 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/mapper/ProductMapper.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/mapper/ProductMapper.java @@ -7,6 +7,7 @@ import com.cnbm.basic.entity.Product; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; import java.util.Map; /** @@ -18,4 +19,5 @@ import java.util.Map; @Mapper public interface ProductMapper extends BaseDao { // IPage page(Map params); + List list(); } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/mapper/ShiftMapper.java b/ym-baisc/src/main/java/com/cnbm/basic/mapper/ShiftMapper.java index c53c5d0..60408a8 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/mapper/ShiftMapper.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/mapper/ShiftMapper.java @@ -1,9 +1,12 @@ package com.cnbm.basic.mapper; +import com.cnbm.basic.dto.ShiftDTO; import com.cnbm.common.dao.BaseDao; import com.cnbm.basic.entity.Shift; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 班次 表 * @@ -12,5 +15,6 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface ShiftMapper extends BaseDao { - + + List list(); } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/mapper/TeamMapper.java b/ym-baisc/src/main/java/com/cnbm/basic/mapper/TeamMapper.java index 9b21802..5306416 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/mapper/TeamMapper.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/mapper/TeamMapper.java @@ -1,9 +1,12 @@ package com.cnbm.basic.mapper; +import com.cnbm.basic.dto.TeamDTO; import com.cnbm.common.dao.BaseDao; import com.cnbm.basic.entity.Team; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 班组 表 * @@ -12,5 +15,6 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface TeamMapper extends BaseDao { - + + List list(); } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/service/IProductService.java b/ym-baisc/src/main/java/com/cnbm/basic/service/IProductService.java index 48c68c5..07781a4 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/service/IProductService.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/service/IProductService.java @@ -6,6 +6,7 @@ import com.cnbm.basic.dto.ProductDTO; import com.cnbm.basic.entity.Product; import com.cnbm.common.vo.IdVo; +import java.util.List; import java.util.Map; /** @@ -27,4 +28,6 @@ public interface IProductService extends CrudService { boolean changeStatus(Long id); + List list(); + } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/service/IShiftService.java b/ym-baisc/src/main/java/com/cnbm/basic/service/IShiftService.java index e236659..3616a34 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/service/IShiftService.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/service/IShiftService.java @@ -5,6 +5,7 @@ import com.cnbm.common.service.CrudService; import com.cnbm.basic.dto.ShiftDTO; import com.cnbm.basic.entity.Shift; +import java.util.List; import java.util.Map; /** @@ -23,4 +24,6 @@ public interface IShiftService extends CrudService { void update(ShiftDTO dto); void delete(Long[] ids); + + List list(); } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/service/ITeamService.java b/ym-baisc/src/main/java/com/cnbm/basic/service/ITeamService.java index 0e73b6e..05523fe 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/service/ITeamService.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/service/ITeamService.java @@ -5,6 +5,7 @@ import com.cnbm.common.service.CrudService; import com.cnbm.basic.dto.TeamDTO; import com.cnbm.basic.entity.Team; +import java.util.List; import java.util.Map; /** @@ -23,4 +24,6 @@ public interface ITeamService extends CrudService { void update(TeamDTO dto); void delete(Long[] ids); + + List list(); } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/service/impl/ProductServiceImpl.java b/ym-baisc/src/main/java/com/cnbm/basic/service/impl/ProductServiceImpl.java index 91ccf0e..0633942 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/service/impl/ProductServiceImpl.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/service/impl/ProductServiceImpl.java @@ -125,4 +125,11 @@ public class ProductServiceImpl extends CrudServiceImpl list() { + List list = mapper.list(); + return list; + } + } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/service/impl/ShiftServiceImpl.java b/ym-baisc/src/main/java/com/cnbm/basic/service/impl/ShiftServiceImpl.java index 1e1df35..af50143 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/service/impl/ShiftServiceImpl.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/service/impl/ShiftServiceImpl.java @@ -10,10 +10,12 @@ import com.cnbm.basic.entity.Shift; import com.cnbm.basic.service.IShiftService; import com.cnbm.common.utils.ConvertUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; +import java.util.List; import java.util.Map; /** @@ -25,6 +27,9 @@ import java.util.Map; @Service public class ShiftServiceImpl extends CrudServiceImpl implements IShiftService { + @Autowired + private ShiftMapper mapper; + @Override public QueryWrapper getWrapper(Map params){ String id = (String)params.get("id"); @@ -72,4 +77,11 @@ public class ShiftServiceImpl extends CrudServiceImpl list() { + List list = mapper.list(); + return list; + } + } \ No newline at end of file diff --git a/ym-baisc/src/main/java/com/cnbm/basic/service/impl/TeamServiceImpl.java b/ym-baisc/src/main/java/com/cnbm/basic/service/impl/TeamServiceImpl.java index 1181b35..18921ac 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/service/impl/TeamServiceImpl.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/service/impl/TeamServiceImpl.java @@ -2,8 +2,6 @@ package com.cnbm.basic.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.cnbm.basic.dto.ProductTypeDTO; -import com.cnbm.basic.entity.ProductType; import com.cnbm.common.page.PageData; import com.cnbm.common.service.impl.CrudServiceImpl; import com.cnbm.basic.dto.TeamDTO; @@ -12,11 +10,13 @@ import com.cnbm.basic.entity.Team; import com.cnbm.basic.service.ITeamService; import com.cnbm.common.utils.ConvertUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.Arrays; +import java.util.List; import java.util.Map; /** @@ -28,6 +28,9 @@ import java.util.Map; @Service public class TeamServiceImpl extends CrudServiceImpl implements ITeamService { + @Autowired + private TeamMapper mapper; + @Override public QueryWrapper getWrapper(Map params){ String id = (String)params.get("id"); @@ -74,4 +77,11 @@ public class TeamServiceImpl extends CrudServiceImpl deleteBatchIds(Arrays.asList(ids)); } + @Override + @Transactional(rollbackFor = Exception.class) + public List list() { + List list = mapper.list(); + return list; + } + } \ No newline at end of file diff --git a/ym-baisc/src/main/resources/mapper/ProductMapper.xml b/ym-baisc/src/main/resources/mapper/ProductMapper.xml index dc56b50..4887680 100644 --- a/ym-baisc/src/main/resources/mapper/ProductMapper.xml +++ b/ym-baisc/src/main/resources/mapper/ProductMapper.xml @@ -2,4 +2,9 @@ + + diff --git a/ym-baisc/src/main/resources/mapper/ShiftMapper.xml b/ym-baisc/src/main/resources/mapper/ShiftMapper.xml index f497457..ef87a5e 100644 --- a/ym-baisc/src/main/resources/mapper/ShiftMapper.xml +++ b/ym-baisc/src/main/resources/mapper/ShiftMapper.xml @@ -2,4 +2,9 @@ + + diff --git a/ym-baisc/src/main/resources/mapper/TeamMapper.xml b/ym-baisc/src/main/resources/mapper/TeamMapper.xml index 090496b..9907bc9 100644 --- a/ym-baisc/src/main/resources/mapper/TeamMapper.xml +++ b/ym-baisc/src/main/resources/mapper/TeamMapper.xml @@ -2,4 +2,9 @@ + + diff --git a/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java b/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java index d28c853..070557f 100644 --- a/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java +++ b/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java @@ -19,7 +19,7 @@ public class CodeGenerator { @Test public void test(){ - mybatisPlusGenerator(new String[]{"product_type"}); + mybatisPlusGenerator(new String[]{"inspection_sheet"}); } public static void mybatisPlusGenerator(String[] include){ diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/controller/InspectionSheetController.java b/ym-generator/src/main/java/com/cnbm/generator/code/controller/InspectionSheetController.java new file mode 100644 index 0000000..6078d67 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/controller/InspectionSheetController.java @@ -0,0 +1,118 @@ +package com.cnbm.generator.code.controller; + +import com.cnbm.admin.annotation.LogOperation; +import com.cnbm.common.constant.Constant; +import com.cnbm.common.page.PageData; +import com.cnbm.common.utils.ExcelUtils; +import com.cnbm.common.utils.Result; +import com.cnbm.common.validator.AssertUtils; +import com.cnbm.common.validator.ValidatorUtils; +import com.cnbm.common.validator.group.AddGroup; +import com.cnbm.common.validator.group.DefaultGroup; +import com.cnbm.common.validator.group.UpdateGroup; +import com.cnbm.generator.code.dto.InspectionSheetDTO; +import com.cnbm.generator.code.excel.InspectionSheetExcel; +import com.cnbm.generator.code.service.IInspectionSheetService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 检验单 表 前端控制器 + * + * @author why + * @since 2022-12-07 + */ +@RestController +@RequestMapping("/code/inspectionSheet") +@Api(tags="检验单 表") +public class InspectionSheetController { + @Autowired + private IInspectionSheetService inspectionSheetService; + + @GetMapping("page") + @ApiOperation("分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) + }) + @PreAuthorize("@ex.hasAuthority('code:inspectionSheet:page')") + public Result> page(@ApiIgnore @RequestParam Map params){ + PageData page = inspectionSheetService.page(params); + + return new Result>().ok(page); + } + + @GetMapping("{id}") + @ApiOperation("信息") + @PreAuthorize("@ex.hasAuthority('code:inspectionSheet:info')") + public Result get(@PathVariable("id") Long id){ + InspectionSheetDTO data = inspectionSheetService.get(id); + + return new Result().ok(data); + } + + @PostMapping + @ApiOperation("保存") + @LogOperation("保存") + @PreAuthorize("@ex.hasAuthority('code:inspectionSheet:save')") + public Result save(@RequestBody InspectionSheetDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + + try { + inspectionSheetService.save(dto); + }catch (Exception e){ + return new Result().error(1,"没有发现检验参数"); + } + return new Result().ok(dto.getId()); + } + + @PutMapping + @ApiOperation("修改") + @PreAuthorize("@ex.hasAuthority('code:inspectionSheet:update')") + public Result update(@RequestBody InspectionSheetDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + + inspectionSheetService.update(dto); + + return new Result().ok(dto.getId()); + } + + @DeleteMapping + @ApiOperation("删除") + @LogOperation("删除") + @PreAuthorize("@ex.hasAuthority('code:inspectionSheet:delete')") + public Result delete(@RequestBody Long[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + + inspectionSheetService.delete(ids); + + return new Result(); + } + + @GetMapping("export") + @ApiOperation("导出") + @LogOperation("导出") + @PreAuthorize("@ex.hasAuthority('code:inspectionSheet:export')") + public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { + List list = inspectionSheetService.list(params); + + ExcelUtils.exportExcelToTarget(response, null, list, InspectionSheetExcel.class); + } + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/dto/InspectionSheetDTO.java b/ym-generator/src/main/java/com/cnbm/generator/code/dto/InspectionSheetDTO.java new file mode 100644 index 0000000..b00c8de --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/dto/InspectionSheetDTO.java @@ -0,0 +1,104 @@ +package com.cnbm.generator.code.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import java.math.BigDecimal; + + +/** + * 检验单 表 + * + * @author why + * @since 2022-12-07 + */ +@Data +@ApiModel(value = "检验单 表DTO对象") +public class InspectionSheetDTO implements Serializable { + private static final long serialVersionUID = 1L; + + + + @ApiModelProperty(value = "ID") + private Long id; + + @ApiModelProperty(value = "订单号,手动输入") + private String orderNumber; + + @ApiModelProperty(value = "批次号,手填") + private String batchNumber; + + @ApiModelProperty(value = "检验站点,手填") + private String inspectionSite; + + @ApiModelProperty(value = "产品id,关联product表") + private Long productId; + + @ApiModelProperty(value = "检验阶段;1 进货检验、 2 过程检验、 3 成品检验、 4 出货检验") + private Integer inspectionStage; + + @ApiModelProperty(value = "工序id,关联working_procedure表") + private Long workingProcedureId; + + @ApiModelProperty(value = "机台id,关联machine表") + private Long machineId; + + @ApiModelProperty(value = "班次id,关联shift表") + private Long shiftId; + + @ApiModelProperty(value = "分组样本数(就是这个产品下所有检测参数 的 最大样本数),只给用户查看,值是后台自动计算的") + private Integer numberOfGroupedSamples; + + @ApiModelProperty(value = "样本大小(就是检验单(母体)下的子样个数),只给用户查看,值是后台自动计算的") + private Integer numberOfSamples; + + @ApiModelProperty(value = "缺陷数量,只给用户查看,值是后台自动计算的(是以 这个检验单下 样本子样 为单位的 )") + private Integer numberOfDefects; + + @ApiModelProperty(value = "不良数量,只给用户查看,值是后台自动计算的(是以 这个检验单下 样本子样 为单位的 )") + private Integer defectiveQuantity; + + @ApiModelProperty(value = "生产人") + private String producer; + + @ApiModelProperty(value = "检验人") + private String inspector; + + @ApiModelProperty(value = "产品特性类型:1 计量型;2 计数型") + private Integer type; + + @ApiModelProperty(value = "1 可用,0 不可用") + private Integer status; + + @ApiModelProperty(value = "备注") + private String remark; + + @ApiModelProperty(value = "删除标志,是否有效:1 可用 0不可用") + private Integer valid; + + @ApiModelProperty(value = "创建人") + private Long creatorId; + + @ApiModelProperty(value = "创建人姓名") + private String creatorName; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createTime; + + @ApiModelProperty(value = "更新人") + private Long updaterId; + + @ApiModelProperty(value = "更新人姓名") + private String updaterName; + + @ApiModelProperty(value = "更新时间") + private LocalDateTime updateTime; + + @ApiModelProperty(value = "版本号") + private Integer version; + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/entity/InspectionSheet.java b/ym-generator/src/main/java/com/cnbm/generator/code/entity/InspectionSheet.java new file mode 100644 index 0000000..26f9299 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/entity/InspectionSheet.java @@ -0,0 +1,106 @@ +package com.cnbm.generator.code.entity; + +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.time.LocalDateTime; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * 检验单 表 + *

+ * + * @author why + * @since 2022-12-07 + */ +@Data +@TableName("inspection_sheet") +@ApiModel(value = "InspectionSheet对象", description = "检验单 表") +public class InspectionSheet implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("ID") + private Long id; + + @ApiModelProperty("订单号,手动输入") + private String orderNumber; + + @ApiModelProperty("批次号,手填") + private String batchNumber; + + @ApiModelProperty("检验站点,手填") + private String inspectionSite; + + @ApiModelProperty("产品id,关联product表") + private Long productId; + + @ApiModelProperty("检验阶段;1 进货检验、 2 过程检验、 3 成品检验、 4 出货检验") + private Integer inspectionStage; + + @ApiModelProperty("工序id,关联working_procedure表") + private Long workingProcedureId; + + @ApiModelProperty("机台id,关联machine表") + private Long machineId; + + @ApiModelProperty("班次id,关联shift表") + private Long shiftId; + + @ApiModelProperty("分组样本数(就是这个产品下所有检测参数 的 最大样本数),只给用户查看,值是后台自动计算的") + private Integer numberOfGroupedSamples; + + @ApiModelProperty("样本大小(就是检验单(母体)下的子样个数),只给用户查看,值是后台自动计算的") + private Integer numberOfSamples; + + @ApiModelProperty("缺陷数量,只给用户查看,值是后台自动计算的(是以 这个检验单下 样本子样 为单位的 )") + private Integer numberOfDefects; + + @ApiModelProperty("不良数量,只给用户查看,值是后台自动计算的(是以 这个检验单下 样本子样 为单位的 )") + private Integer defectiveQuantity; + + @ApiModelProperty("生产人") + private String producer; + + @ApiModelProperty("检验人") + private String inspector; + + @ApiModelProperty("产品特性类型:1 计量型;2 计数型") + private Integer type; + + @ApiModelProperty("1 可用,0 不可用") + private Integer status; + + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty("删除标志,是否有效:1 可用 0不可用") + @TableLogic + private Integer valid; + + @ApiModelProperty("创建人") + private Long creatorId; + + @ApiModelProperty("创建人姓名") + private String creatorName; + + @ApiModelProperty("创建时间") + private LocalDateTime createTime; + + @ApiModelProperty("更新人") + private Long updaterId; + + @ApiModelProperty("更新人姓名") + private String updaterName; + + @ApiModelProperty("更新时间") + private LocalDateTime updateTime; + + @ApiModelProperty("版本号") + private Integer version; + + +} diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/excel/InspectionSheetExcel.java b/ym-generator/src/main/java/com/cnbm/generator/code/excel/InspectionSheetExcel.java new file mode 100644 index 0000000..fd2d7c4 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/excel/InspectionSheetExcel.java @@ -0,0 +1,72 @@ +package com.cnbm.generator.code.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.time.LocalDateTime; +import java.math.BigDecimal; + +import java.util.Date; + +/** + * 检验单 表 + * + * @author why + * @since 2022-12-07 + */ +@Data +public class InspectionSheetExcel { + @Excel(name = "ID") + private Long id; + @Excel(name = "订单号,手动输入") + private String orderNumber; + @Excel(name = "批次号,手填") + private String batchNumber; + @Excel(name = "检验站点,手填") + private String inspectionSite; + @Excel(name = "产品id,关联product表") + private Long productId; + @Excel(name = "检验阶段;1 进货检验、 2 过程检验、 3 成品检验、 4 出货检验") + private Integer inspectionStage; + @Excel(name = "工序id,关联working_procedure表") + private Long workingProcedureId; + @Excel(name = "机台id,关联machine表") + private Long machineId; + @Excel(name = "班次id,关联shift表") + private Long shiftId; + @Excel(name = "分组样本数(就是这个产品下所有检测参数 的 最大样本数),只给用户查看,值是后台自动计算的") + private Integer numberOfGroupedSamples; + @Excel(name = "样本大小(就是检验单(母体)下的子样个数),只给用户查看,值是后台自动计算的") + private Integer numberOfSamples; + @Excel(name = "缺陷数量,只给用户查看,值是后台自动计算的(是以 这个检验单下 样本子样 为单位的 )") + private Integer numberOfDefects; + @Excel(name = "不良数量,只给用户查看,值是后台自动计算的(是以 这个检验单下 样本子样 为单位的 )") + private Integer defectiveQuantity; + @Excel(name = "生产人") + private String producer; + @Excel(name = "检验人") + private String inspector; + @Excel(name = "产品特性类型:1 计量型;2 计数型") + private Integer type; + @Excel(name = "1 可用,0 不可用") + private Integer status; + @Excel(name = "备注") + private String remark; + @Excel(name = "删除标志,是否有效:1 可用 0不可用") + private Integer valid; + @Excel(name = "创建人") + private Long creatorId; + @Excel(name = "创建人姓名") + private String creatorName; + @Excel(name = "创建时间") + private LocalDateTime createTime; + @Excel(name = "更新人") + private Long updaterId; + @Excel(name = "更新人姓名") + private String updaterName; + @Excel(name = "更新时间") + private LocalDateTime updateTime; + @Excel(name = "版本号") + private Integer version; + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/mapper/InspectionSheetMapper.java b/ym-generator/src/main/java/com/cnbm/generator/code/mapper/InspectionSheetMapper.java new file mode 100644 index 0000000..6e54952 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/mapper/InspectionSheetMapper.java @@ -0,0 +1,16 @@ +package com.cnbm.generator.code.mapper; + +import com.cnbm.common.dao.BaseDao; +import com.cnbm.generator.code.entity.InspectionSheet; +import org.apache.ibatis.annotations.Mapper; + +/** + * 检验单 表 + * + * @author why + * @since 2022-12-07 + */ +@Mapper +public interface InspectionSheetMapper extends BaseDao { + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/mapper/InspectionSheetMapper.xml b/ym-generator/src/main/java/com/cnbm/generator/code/mapper/InspectionSheetMapper.xml new file mode 100644 index 0000000..ed55754 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/mapper/InspectionSheetMapper.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/mysql/InspectionSheetmysql.sql b/ym-generator/src/main/java/com/cnbm/generator/code/mysql/InspectionSheetmysql.sql new file mode 100644 index 0000000..7d8425d --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/mysql/InspectionSheetmysql.sql @@ -0,0 +1,7 @@ +-- 菜单初始SQL +INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date)VALUES (1600308190230409218, 1067246875800000035, '检验单 表', 'code/inspectionSheet', NULL, 0, 'icon-desktop', 0, 1067246875800000001, now(), 1067246875800000001, now()); +INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1600308190230409219, 1600308190230409218, '查看', NULL, 'code:inspectionSheet:page,code:inspectionSheet:info', 1, NULL, 0, 1067246875800000001, now(), 1067246875800000001, now()); +INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1600308190230409220, 1600308190230409218, '新增', NULL, 'code:inspectionSheet:save', 1, NULL, 1, 1067246875800000001, now(), 1067246875800000001, now()); +INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1600308190230409221, 1600308190230409218, '修改', NULL, 'code:inspectionSheet:update', 1, NULL, 2, 1067246875800000001, now(), 1067246875800000001, now()); +INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1600308190230409222, 1600308190230409218, '删除', NULL, 'code:inspectionSheet:delete', 1, NULL, 3, 1067246875800000001, now(), 1067246875800000001, now()); +INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1600308190230409223, 1600308190230409218, '导出', NULL, 'code:inspectionSheet:export', 1, NULL, 4, 1067246875800000001, now(), 1067246875800000001, now()); diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/service/IInspectionSheetService.java b/ym-generator/src/main/java/com/cnbm/generator/code/service/IInspectionSheetService.java new file mode 100644 index 0000000..a6ef0c4 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/service/IInspectionSheetService.java @@ -0,0 +1,15 @@ +package com.cnbm.generator.code.service; + +import com.cnbm.common.service.CrudService; +import com.cnbm.generator.code.dto.InspectionSheetDTO; +import com.cnbm.generator.code.entity.InspectionSheet; + +/** + * 检验单 表 + * + * @author why + * @since 2022-12-07 + */ +public interface IInspectionSheetService extends CrudService { + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/service/impl/InspectionSheetServiceImpl.java b/ym-generator/src/main/java/com/cnbm/generator/code/service/impl/InspectionSheetServiceImpl.java new file mode 100644 index 0000000..f79c2c6 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/service/impl/InspectionSheetServiceImpl.java @@ -0,0 +1,34 @@ +package com.cnbm.generator.code.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.cnbm.common.service.impl.CrudServiceImpl; +import com.cnbm.generator.code.dto.InspectionSheetDTO; +import com.cnbm.generator.code.mapper.InspectionSheetMapper; +import com.cnbm.generator.code.entity.InspectionSheet; +import com.cnbm.generator.code.service.IInspectionSheetService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 检验单 表 + * + * @author why + * @since 2022-12-07 + */ +@Service +public class InspectionSheetServiceImpl extends CrudServiceImpl implements IInspectionSheetService { + + @Override + public QueryWrapper getWrapper(Map params){ + String id = (String)params.get("id"); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "id", id); + + return wrapper; + } + + +} \ No newline at end of file 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 e311485..b6df360 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 @@ -146,14 +146,14 @@ public enum InfluxClient { List dropedTagNames = param.getDropedTagNames(); Range range = param.getRange(); String bucket = param.getBucket(); - String tagName = param.getTag().getTagName(); - String tagValue = param.getTag().getTagValue(); +// String tagName = param.getTag().getTagName(); +// String tagValue = param.getTag().getTagValue(); PageInfo pageInfo = param.getPageInfo(); String flux = "from(bucket:\""+bucket+"\")"; flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")"; flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")"; - flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")"; +// flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")"; //调整时区,查询出的结果 +8个小时 flux += "|> timeShift(duration: 8h)"; for(String dropName:dropedTagNames){ diff --git a/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java b/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java index f88ce6c..a6792e1 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java +++ b/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java @@ -30,5 +30,6 @@ public class QueryDataParam extends BaseParam{ private List dropedTagNames; private String bucket; private String groupName; + private String inspectionSheetId; } 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 916bc9f..66e26e4 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 @@ -1,6 +1,7 @@ package com.cnbm.processInspection.controller; import com.cnbm.admin.annotation.LogOperation; +import com.cnbm.basic.dto.FeaturesProcedureDTO; import com.cnbm.basic.dto.ProductFeaturesDTO; import com.cnbm.common.constant.Constant; import com.cnbm.common.page.PageData; @@ -12,6 +13,7 @@ import com.cnbm.common.validator.group.AddGroup; import com.cnbm.common.validator.group.DefaultGroup; import com.cnbm.common.validator.group.UpdateGroup; 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.excel.InspectionSheetExcel; @@ -62,7 +64,7 @@ public class InspectionSheetController { @ApiImplicitParam(name = "batchNumber", value = "批次号", paramType = "query", dataTypeClass = String.class), @ApiImplicitParam(name = "id", value = "检验单号", paramType = "query", dataTypeClass = Integer.class) }) - @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:page')") +// @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:page')") public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = inspectionSheetService.page(params); @@ -71,7 +73,7 @@ public class InspectionSheetController { @GetMapping("{id}") @ApiOperation("信息") - @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:info')") + //@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:info')") public Result get(@PathVariable("id") Long id){ InspectionSheetDTO data = inspectionSheetService.get(id); @@ -81,20 +83,23 @@ public class InspectionSheetController { @PostMapping @ApiOperation("保存") @LogOperation("保存") - @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:save')") - public Result save(@RequestBody InspectionSheetDTO dto){ +// @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:save')") + public Result save(@RequestBody InspectionSheetDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - inspectionSheetService.save(dto); - + try { + inspectionSheetService.save(dto); + }catch (Exception e){ + return new Result().error(1,"没有发现检验参数"); + } return new Result().ok(dto.getId()); } @PutMapping @ApiOperation("修改") @LogOperation("修改") - @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:update')") + //@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:update')") public Result update(@RequestBody InspectionSheetDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); @@ -107,7 +112,7 @@ public class InspectionSheetController { @DeleteMapping @ApiOperation("删除") @LogOperation("删除") - @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:delete')") + //@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:delete')") public Result delete(@RequestBody Long[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); @@ -120,7 +125,7 @@ public class InspectionSheetController { @GetMapping("export") @ApiOperation("导出") @LogOperation("导出") - @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:export')") + //@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:export')") public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { List list = inspectionSheetService.list(params); @@ -147,22 +152,34 @@ public class InspectionSheetController { @PostMapping(value = "getFluxParamList") @ApiOperation(value = "从influxdb中获取检测参数") @ApiImplicitParams({ - @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataTypeClass = LocalDateTime.class), - @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataTypeClass = LocalDateTime.class), - @ApiImplicitParam(name = "id", value = "检验单号", paramType = "query", dataTypeClass = Integer.class), +// @ApiImplicitParam(name = "startTime", 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 = "workingProcedureName", value = "工序名称", paramType = "query", dataTypeClass = String.class) }) - List getFluxParamList(@ApiIgnore @RequestParam Map params){ + List getFluxParamList(@ApiIgnore @RequestParam Map params){ return inspectionSheetService.getFluxParamList(params); } @PostMapping("saveFluxParamList") @ApiOperation("将样本检测参数写入influxdb") - public Result saveFluxParamList(@RequestBody InspectionSampleDTO dto){ + public Result saveFluxParamList(@RequestBody InspectionSampleDTO[] lists){ - inspectionSheetService.saveFluxParamList(dto); + inspectionSheetService.saveFluxParamList(lists); return new Result(); } + @PostMapping("getInspectionSheetFeaturesList") + @ApiOperation("获取检验单对应检验属性") + @ApiImplicitParams({ + @ApiImplicitParam(name = "productId", value = "产品", paramType = "query", dataTypeClass = Long.class), + @ApiImplicitParam(name = "workingProcedureId", value = "工序", paramType = "query", dataTypeClass = Long.class), + @ApiImplicitParam(name = "inspectionStage", value = "检测阶段", paramType = "query", dataTypeClass = Integer.class) + }) + public Result getInspectionSheetFeaturesList(@ApiIgnore @RequestParam Map params){ + List list = inspectionSheetService.getInspectionSheetFeaturesList(params); + return new Result>().ok(list); + } + } \ No newline at end of file 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 e3da3e1..929f017 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 @@ -32,4 +32,7 @@ public class InspectionSampleDTO implements Serializable { @ApiModelProperty(value = "取样时间") private LocalDateTime sampleTime; + @ApiModelProperty(value = "样本号") + private String sampleNumber; + } diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/InspectionSheetDTO.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/InspectionSheetDTO.java index 6bd2830..4f1ff46 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/InspectionSheetDTO.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/InspectionSheetDTO.java @@ -39,8 +39,8 @@ public class InspectionSheetDTO implements Serializable { @ApiModelProperty(value = "产品名称,关联product表") private String productName; - @ApiModelProperty(value = "检验阶段;1 进货检验、 2 过程检验、 3 成品检验、 4 出货检验;; 如果有多个用逗号隔开,比如 1,4 就代表选中了进货检验和出货检验") - private String inspectionStage; + @ApiModelProperty(value = "检验阶段;1 进货检验、 2 过程检验、 3 成品检验、 4 出货检验") + private Integer inspectionStage; @ApiModelProperty(value = "工序id,关联working_procedure表") private Long workingProcedureId; diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/entity/InspectionSheet.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/entity/InspectionSheet.java index 8e55714..d10abe6 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/entity/InspectionSheet.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/entity/InspectionSheet.java @@ -38,8 +38,8 @@ public class InspectionSheet implements Serializable { @ApiModelProperty("产品id,关联product表") private Long productId; - @ApiModelProperty("检验阶段;1 进货检验、 2 过程检验、 3 成品检验、 4 出货检验;; 如果有多个用逗号隔开,比如 1,4 就代表选中了进货检验和出货检验") - private String inspectionStage; + @ApiModelProperty("检验阶段;1 进货检验、 2 过程检验、 3 成品检验、 4 出货检验") + private Integer inspectionStage; @ApiModelProperty("工序id,关联working_procedure表") private Long workingProcedureId; diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/excel/InspectionSheetExcel.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/excel/InspectionSheetExcel.java index c05895f..2b8f837 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/excel/InspectionSheetExcel.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/excel/InspectionSheetExcel.java @@ -23,8 +23,8 @@ public class InspectionSheetExcel { private String inspectionSite; @Excel(name = "产品id,关联product表") private Long productId; - @Excel(name = "检验阶段;1 进货检验、 2 过程检验、 3 成品检验、 4 出货检验;; 如果有多个用逗号隔开,比如 1,4 就代表选中了进货检验和出货检验") - private String inspectionStage; + @Excel(name = "检验阶段;1 进货检验、 2 过程检验、 3 成品检验、 4 出货检验") + private Integer inspectionStage; @Excel(name = "工序id,关联working_procedure表") private Long workingProcedureId; @Excel(name = "机台id,关联machine表") 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 6afee49..5ec853b 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 @@ -1,5 +1,6 @@ package com.cnbm.processInspection.mapper; +import com.cnbm.basic.dto.ProductFeaturesDTO; import com.cnbm.common.dao.BaseDao; import com.cnbm.processInspection.dto.InspectionSheetDTO; import com.cnbm.processInspection.entity.InspectionSheet; @@ -17,5 +18,6 @@ import java.util.Map; @Mapper public interface InspectionSheetMapper extends BaseDao { List list(Map params); - Integer getNumberOfSamples(Long productId); +// Integer getNumberOfSamples(Map params); + List getInspectionSheetFeaturesList(Map params); } \ 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 9f3da4a..0b80296 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 @@ -1,8 +1,10 @@ package com.cnbm.processInspection.service; +import com.cnbm.basic.dto.ProductFeaturesDTO; import com.cnbm.common.page.PageData; import com.cnbm.common.service.CrudService; 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; @@ -31,8 +33,10 @@ public interface IInspectionSheetService extends CrudService list(Map params); - List getFluxParamList(Map params); + List getFluxParamList(Map params); - void saveFluxParamList(InspectionSampleDTO dto); + void saveFluxParamList(InspectionSampleDTO[] lists); + + List getInspectionSheetFeaturesList(Map params); } \ 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 989ba46..78b898c 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 @@ -5,6 +5,7 @@ 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; +import com.cnbm.basic.dto.ProductFeaturesDTO; import com.cnbm.basic.entity.Machine; import com.cnbm.basic.entity.Product; import com.cnbm.basic.entity.Shift; @@ -15,16 +16,20 @@ import com.cnbm.basic.service.impl.ShiftServiceImpl; import com.cnbm.basic.service.impl.WorkingProcedureServiceImpl; import com.cnbm.common.page.PageData; import com.cnbm.common.service.impl.CrudServiceImpl; +import com.cnbm.common.spc.util.DataUtils; import com.cnbm.common.utils.ConvertUtils; import com.cnbm.influx.config.InfluxClient; +import com.cnbm.influx.param.PageInfo; import com.cnbm.influx.param.QueryDataParam; import com.cnbm.influx.param.Range; +import com.cnbm.influx.param.Tag; 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.mapper.InspectionSheetMapper; import com.cnbm.processInspection.service.IInspectionSheetService; +import com.influxdb.query.FluxRecord; import com.influxdb.query.FluxTable; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -37,6 +42,7 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.*; +import java.util.stream.Collectors; /** * 检验单 表 @@ -128,11 +134,21 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl params = new HashMap(); + params.put("productId",dto.getProductId()); + params.put("workingProcedureId",dto.getWorkingProcedureId()); + params.put("inspectionStage",dto.getInspectionStage()); + List inspectionSheetFeaturesList = getInspectionSheetFeaturesList(params); + if(inspectionSheetFeaturesList==null || inspectionSheetFeaturesList.size()==0){ + throw new RuntimeException("没有发现检验参数"); + }else{ + //分组样本数=样本大小=检验特性分组数的最大值 + Integer numbersOfSamples = inspectionSheetFeaturesList.stream().max(Comparator.comparing(ProductFeaturesDTO::getSampleSize)).get().getSampleSize(); + if(numbersOfSamples!=null){ + dto.setNumberOfGroupedSamples(numbersOfSamples); + dto.setNumberOfSamples(numbersOfSamples); + } } InspectionSheet entity = ConvertUtils.sourceToTarget(dto, InspectionSheet.class); insert(entity); @@ -163,47 +179,129 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl getFluxParamList(Map params){ + public List getFluxParamList(Map params){ QueryDataParam queryDataParam = new QueryDataParam(); String workingProcedureName = (String)params.get("workingProcedureName"); + String inspectionSheetId = (String)params.get("inspectionSheetId"); queryDataParam.setMeasurement(workingProcedureName); + queryDataParam.setInspectionSheetId(inspectionSheetId); queryDataParam.setBucket("qgs-bucket"); - Instant startTime = (Instant) params.get("startTime"); - Instant endTime = (Instant) params.get("endTime"); - Range range = new Range(startTime,endTime); - queryDataParam.setRange(range); +// Instant startTime = (Instant) params.get("startTime"); +// Instant endTime = (Instant) params.get("endTime"); +// Range range = new Range(startTime,endTime); +// queryDataParam.setRange(range); + List dropNames = new ArrayList<>(); + dropNames.add("transationId"); +// dropNames.add("inspectionSheetId"); + queryDataParam.setDropedTagNames(dropNames); +// queryDataParam.setTag(new Tag("argName","forUpdate")); + queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(),DataUtils.getAfterDate(999).toInstant())); + queryDataParam.setPageInfo(new PageInfo(1,10)); - List list = InfluxClient.Client.query(queryDataParam); - return list; + List fluxTableList = InfluxClient.Client.query(queryDataParam); + List eventList = new ArrayList<>(); + + for (FluxTable fluxTable : fluxTableList) { + List records = fluxTable.getRecords(); // 获取实际的记录操作 + // List columns = fluxTable.getColumns(); // 获取返回的列 + // System.out.println(columns); // 下面的数据显示是按照当前的column中的label名称获取的数据 + //System.out.println(records); + for (FluxRecord fluxRecord : records) { + Instant time = fluxRecord.getTime(); + String argName = (String)fluxRecord.getValueByKey("argName"); + Double argValue = Double.valueOf(fluxRecord.getValueByKey("_value").toString()); + String batchNum = (String)fluxRecord.getValueByKey("batchNum"); + String sampleNo = (String)fluxRecord.getValueByKey("sampleNo"); +// System.out.println(fluxRecord.getTime() + ": " + fluxRecord.getValueByKey("argName") + ":" +// + fluxRecord.getValueByKey("_value") + ": " + fluxRecord.getValueByKey("batchNum")); + eventList.add(newEvent(time,inspectionSheetId,argName,argValue,batchNum,sampleNo)); + } + } + + //更新检验单缺陷数不良数 + //根据样本号分组 + Map> map = eventList.stream().collect(Collectors.groupingBy(Event::getSampleNumber)); + //获取的产品特性参照值 + InspectionSheetDTO dto = get((Long) params.get("inspectionSheetId")); + Map 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 featuresList = getInspectionSheetFeaturesList(params2); + //循环每个样本组 + for (Map.Entry> entry : map.entrySet()) { + //该样本的缺陷数 + Integer eventDefects = 0; + //该样本的属性列表 + List 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 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)); + List 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); } - InfluxClient.Client.batchInsert(list,workingProcedureName); } - private Event newEvent(Instant time,String inspectionSheetId,String argName,Double argValue,String batchNum){ + 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()); @@ -211,7 +309,13 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl params) { +// return mapper.getNumberOfSamples(params); +// } + + @Override + public List getInspectionSheetFeaturesList(Map params) { + return mapper.getInspectionSheetFeaturesList(params); } } \ 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 19df41b..716b160 100644 --- a/ym-process-inspection/src/main/resources/mapper/InspectionSheetMapper.xml +++ b/ym-process-inspection/src/main/resources/mapper/InspectionSheetMapper.xml @@ -65,10 +65,40 @@ + + From b15ad64d768ac7f7da17a85b8f81fdc7b3e36c27 Mon Sep 17 00:00:00 2001 From: yanyang Date: Thu, 8 Dec 2022 16:26:17 +0800 Subject: [PATCH 3/4] MARK FOR PULL --- .../cnbm/basic/dto/ProductFeaturesDTO.java | 1 - .../com/cnbm/influx/param/QueryDataParam.java | 2 +- .../controller/InspectionSheetController.java | 38 ++- .../service/IInspectionSheetService.java | 6 +- .../impl/InspectionSheetServiceImpl.java | 318 +++++++++++------- 5 files changed, 235 insertions(+), 130 deletions(-) diff --git a/ym-baisc/src/main/java/com/cnbm/basic/dto/ProductFeaturesDTO.java b/ym-baisc/src/main/java/com/cnbm/basic/dto/ProductFeaturesDTO.java index 91b04a4..3b1959b 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/dto/ProductFeaturesDTO.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/dto/ProductFeaturesDTO.java @@ -19,7 +19,6 @@ public class ProductFeaturesDTO implements Serializable { private static final long serialVersionUID = 1L; - @ApiModelProperty(value = "ID") private Long id; diff --git a/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java b/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java index db11f52..c341c08 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java +++ b/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java @@ -31,6 +31,6 @@ public class QueryDataParam extends BaseParam{ private List dropedTagNames; private String bucket; private String groupName; - private String inspectionSheetId; + //private String inspectionSheetId; } 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 66e26e4..a641f43 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 @@ -1,5 +1,6 @@ package com.cnbm.processInspection.controller; +import com.alibaba.fastjson.JSONObject; import com.cnbm.admin.annotation.LogOperation; import com.cnbm.basic.dto.FeaturesProcedureDTO; import com.cnbm.basic.dto.ProductFeaturesDTO; @@ -64,7 +65,7 @@ public class InspectionSheetController { @ApiImplicitParam(name = "batchNumber", value = "批次号", paramType = "query", dataTypeClass = String.class), @ApiImplicitParam(name = "id", value = "检验单号", paramType = "query", dataTypeClass = Integer.class) }) -// @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:page')") + @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:page')") public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = inspectionSheetService.page(params); @@ -73,7 +74,7 @@ public class InspectionSheetController { @GetMapping("{id}") @ApiOperation("信息") - //@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:info')") + @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:info')") public Result get(@PathVariable("id") Long id){ InspectionSheetDTO data = inspectionSheetService.get(id); @@ -83,7 +84,7 @@ public class InspectionSheetController { @PostMapping @ApiOperation("保存") @LogOperation("保存") -// @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:save')") + @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:save')") public Result save(@RequestBody InspectionSheetDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); @@ -99,7 +100,7 @@ public class InspectionSheetController { @PutMapping @ApiOperation("修改") @LogOperation("修改") - //@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:update')") + @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:update')") public Result update(@RequestBody InspectionSheetDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); @@ -112,7 +113,7 @@ public class InspectionSheetController { @DeleteMapping @ApiOperation("删除") @LogOperation("删除") - //@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:delete')") + @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:delete')") public Result delete(@RequestBody Long[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); @@ -125,7 +126,7 @@ public class InspectionSheetController { @GetMapping("export") @ApiOperation("导出") @LogOperation("导出") - //@PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:export')") + @PreAuthorize("@ex.hasAuthority('processInspection:inspectionSheet:export')") public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { List list = inspectionSheetService.list(params); @@ -151,14 +152,17 @@ public class InspectionSheetController { @PostMapping(value = "getFluxParamList") @ApiOperation(value = "从influxdb中获取检测参数") - @ApiImplicitParams({ +// @ApiImplicitParams({ // @ApiImplicitParam(name = "startTime", 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 = "workingProcedureName", value = "工序名称", paramType = "query", dataTypeClass = String.class) - }) - List getFluxParamList(@ApiIgnore @RequestParam Map params){ - return inspectionSheetService.getFluxParamList(params); +// @ApiImplicitParam(name = "inspectionSheetId", value = "检验单号", paramType = "query", dataTypeClass = String.class), +// @ApiImplicitParam(name = "workingProcedureName", value = "工序名称", paramType = "query", dataTypeClass = String.class) +// }) +// List getFluxParamList(@ApiIgnore @RequestParam Map params){ +// return inspectionSheetService.getFluxParamList(params); +// } + List getFluxParamList(@RequestParam("inspectionSheetId") Long inspectionSheetId){ + return inspectionSheetService.getFluxParamList(inspectionSheetId); } @PostMapping("saveFluxParamList") @@ -166,7 +170,8 @@ public class InspectionSheetController { public Result saveFluxParamList(@RequestBody InspectionSampleDTO[] lists){ inspectionSheetService.saveFluxParamList(lists); - + //样本数据更新后 计算检验单缺陷数不良数 + inspectionSheetService.calculate(Long.valueOf(lists[0].getInspectionSheetId())); return new Result(); } @@ -182,4 +187,11 @@ public class InspectionSheetController { return new Result>().ok(list); } + @PostMapping(value = "calculate") + @ApiOperation(value = "检验单统计计算") + public Result calculate(@RequestParam("inspectionSheetId") Long inspectionSheetId){ + inspectionSheetService.calculate(inspectionSheetId); + return new Result().ok(inspectionSheetId); + } + } \ 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 0b80296..e4996e3 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 @@ -1,5 +1,6 @@ package com.cnbm.processInspection.service; +import com.alibaba.fastjson.JSONObject; import com.cnbm.basic.dto.ProductFeaturesDTO; import com.cnbm.common.page.PageData; import com.cnbm.common.service.CrudService; @@ -33,10 +34,13 @@ public interface IInspectionSheetService extends CrudService list(Map params); - List getFluxParamList(Map params); +// List getFluxParamList(Map params); + List getFluxParamList(Long inspectionSheetId); void saveFluxParamList(InspectionSampleDTO[] lists); List getInspectionSheetFeaturesList(Map params); + void calculate(Long inspectionSheetId); + } \ 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 78b898c..762cff1 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 @@ -29,6 +29,7 @@ import com.cnbm.processInspection.dto.InspectionSheetDTO; import com.cnbm.processInspection.entity.InspectionSheet; import com.cnbm.processInspection.mapper.InspectionSheetMapper; import com.cnbm.processInspection.service.IInspectionSheetService; +import com.google.gson.JsonObject; import com.influxdb.query.FluxRecord; import com.influxdb.query.FluxTable; import org.apache.commons.lang3.StringUtils; @@ -40,6 +41,7 @@ import org.springframework.web.bind.annotation.RequestBody; import javax.annotation.Resource; import java.time.Instant; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.ZoneOffset; import java.util.*; import java.util.stream.Collectors; @@ -66,11 +68,11 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl getWrapper(Map params){ - Long id = (Long)params.get("id"); - String inspectionSite = (String)params.get("inspectionSite"); - String orderNumber = (String)params.get("orderNumber"); - String batchNumber = (String)params.get("batchNumber"); + public QueryWrapper getWrapper(Map params) { + Long id = (Long) params.get("id"); + String inspectionSite = (String) params.get("inspectionSite"); + String orderNumber = (String) params.get("orderNumber"); + String batchNumber = (String) params.get("batchNumber"); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.like(ObjectUtils.isNotNull(id), "id", id); @@ -82,17 +84,17 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl page (Map params){ + public PageData page(Map params) { IPage page = baseDao.selectPage( getPage(params, "id", true), getWrapper(params) ); PageData inspectionSheetDTOPageData = getPageData(page, InspectionSheetDTO.class); - if(!inspectionSheetDTOPageData.getList().isEmpty()){ - for(InspectionSheetDTO dto:inspectionSheetDTOPageData.getList()){ + if (!inspectionSheetDTOPageData.getList().isEmpty()) { + for (InspectionSheetDTO dto : inspectionSheetDTOPageData.getList()) { Product product = productService.selectById(dto.getProductId()); WorkingProcedure workingProcedure = workingProcedureService.selectById(dto.getWorkingProcedureId()); Machine machine = machineService.selectById(dto.getMachineId()); @@ -103,16 +105,16 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl params = new HashMap(); - params.put("productId",dto.getProductId()); - params.put("workingProcedureId",dto.getWorkingProcedureId()); - params.put("inspectionStage",dto.getInspectionStage()); + params.put("productId", dto.getProductId()); + params.put("workingProcedureId", dto.getWorkingProcedureId()); + params.put("inspectionStage", dto.getInspectionStage()); List inspectionSheetFeaturesList = getInspectionSheetFeaturesList(params); - if(inspectionSheetFeaturesList==null || inspectionSheetFeaturesList.size()==0){ + if (inspectionSheetFeaturesList == null || inspectionSheetFeaturesList.size() == 0) { throw new RuntimeException("没有发现检验参数"); - }else{ + } else { //分组样本数=样本大小=检验特性分组数的最大值 Integer numbersOfSamples = inspectionSheetFeaturesList.stream().max(Comparator.comparing(ProductFeaturesDTO::getSampleSize)).get().getSampleSize(); - if(numbersOfSamples!=null){ + if (numbersOfSamples != null) { dto.setNumberOfGroupedSamples(numbersOfSamples); dto.setNumberOfSamples(numbersOfSamples); } @@ -179,103 +186,65 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl getFluxParamList(Map params){ - QueryDataParam queryDataParam = new QueryDataParam(); - String workingProcedureName = (String)params.get("workingProcedureName"); - String inspectionSheetId = (String)params.get("inspectionSheetId"); - queryDataParam.setMeasurement(workingProcedureName); - queryDataParam.setInspectionSheetId(inspectionSheetId); - queryDataParam.setBucket("qgs-bucket"); - -// Instant startTime = (Instant) params.get("startTime"); -// Instant endTime = (Instant) params.get("endTime"); -// Range range = new Range(startTime,endTime); -// queryDataParam.setRange(range); - List dropNames = new ArrayList<>(); - dropNames.add("transationId"); -// dropNames.add("inspectionSheetId"); - queryDataParam.setDropedTagNames(dropNames); -// queryDataParam.setTag(new Tag("argName","forUpdate")); - queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(),DataUtils.getAfterDate(999).toInstant())); - queryDataParam.setPageInfo(new PageInfo(1,10)); - - List fluxTableList = InfluxClient.Client.query(queryDataParam); + public List getFluxParamList(Long id) { List eventList = new ArrayList<>(); + InspectionSheetDTO dto = get(id); + if (dto != null && dto.getWorkingProcedureName()!=null) { + QueryDataParam queryDataParam = new QueryDataParam(); + String inspectionSheetId = id.toString(); + String workingProcedureName = dto.getWorkingProcedureName(); + queryDataParam.setMeasurement(workingProcedureName); + //queryDataParam.setInspectionSheetId(inspectionSheetId); + queryDataParam.setBucket("qgs-bucket"); + queryDataParam.setTag(new Tag("inspectionSheetId", inspectionSheetId)); + List dropNames = new ArrayList<>(); + dropNames.add("transationId"); + queryDataParam.setDropedTagNames(dropNames); + queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(), DataUtils.getAfterDate(999).toInstant())); + queryDataParam.setPageInfo(new PageInfo(1, 10)); - for (FluxTable fluxTable : fluxTableList) { - List records = fluxTable.getRecords(); // 获取实际的记录操作 - // List columns = fluxTable.getColumns(); // 获取返回的列 - // System.out.println(columns); // 下面的数据显示是按照当前的column中的label名称获取的数据 - //System.out.println(records); - for (FluxRecord fluxRecord : records) { - Instant time = fluxRecord.getTime(); - String argName = (String)fluxRecord.getValueByKey("argName"); - Double argValue = Double.valueOf(fluxRecord.getValueByKey("_value").toString()); - String batchNum = (String)fluxRecord.getValueByKey("batchNum"); - String sampleNo = (String)fluxRecord.getValueByKey("sampleNo"); -// System.out.println(fluxRecord.getTime() + ": " + fluxRecord.getValueByKey("argName") + ":" -// + fluxRecord.getValueByKey("_value") + ": " + fluxRecord.getValueByKey("batchNum")); - eventList.add(newEvent(time,inspectionSheetId,argName,argValue,batchNum,sampleNo)); - } - } - - //更新检验单缺陷数不良数 - //根据样本号分组 - Map> map = eventList.stream().collect(Collectors.groupingBy(Event::getSampleNumber)); - //获取的产品特性参照值 - InspectionSheetDTO dto = get((Long) params.get("inspectionSheetId")); - Map 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 featuresList = getInspectionSheetFeaturesList(params2); - //循环每个样本组 - for (Map.Entry> entry : map.entrySet()) { - //该样本的缺陷数 - Integer eventDefects = 0; - //该样本的属性列表 - List 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 fluxTableList = InfluxClient.Client.query(queryDataParam); + for (FluxTable fluxTable : fluxTableList) { + List records = fluxTable.getRecords(); // 获取实际的记录操作 + for (FluxRecord fluxRecord : records) { + 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)); } } } - InspectionSheetDTO updateDto = new InspectionSheetDTO(); - updateDto.setId((Long)params.get("inspectionSheetId")); - updateDto.setNumberOfDefects(numberOfDefects); - updateDto.setDefectiveQuantity(defectiveQuantity); - update(updateDto); + List list = new ArrayList<>(); + if (eventList != null || eventList.size() > 0) { + //根据样本号分组 + Map> map = eventList.stream().collect(Collectors.groupingBy(Event::getSampleNumber)); + for (Map.Entry> entry : map.entrySet()) { + String sampleNumber = entry.getKey(); + List events = entry.getValue(); - 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 - public void saveFluxParamList(InspectionSampleDTO[] lists){ - for(InspectionSampleDTO dto:lists) { + 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(); @@ -285,27 +254,37 @@ 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()); + 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,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.setInspectionSheetId(inspectionSheetId); event.setTime(time); event.setBatchNum(batchNum); event.setSampleNumber(sampleNo); event.setArgName(argName); - if(!Objects.equals(argValue, "") && argValue != null ){ - event.setArgValue(argValue.toString()); - } + event.setArgValue(argValue); +// if (Objects.equals(argValue, "")){ +// event.setArgValue(""); +// }else if (argValue != null) { +// event.setArgValue(argValue.toString()); +// } return event; } @@ -318,4 +297,115 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl getInspectionSheetFeaturesList(Map params) { return mapper.getInspectionSheetFeaturesList(params); } + + //计算并更新检验单缺陷数不良数 + @Override + public void calculate(Long inspectionSheetId) { + List sampleDTOList = getFluxParamList(inspectionSheetId); + if (sampleDTOList != null || sampleDTOList.size() > 0) { + //缺陷 + Integer numberOfDefects = 0; + //不良 + Integer defectiveQuantity = 0; + + //获取的产品特性参照值 + InspectionSheetDTO dto = get(inspectionSheetId); + Map params2 = new HashMap<>(); + params2.put("productId", dto.getProductId()); + params2.put("workingProcedureId", dto.getWorkingProcedureId()); + params2.put("inspectionStage", dto.getInspectionStage()); + List 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 eventList = getFluxParamList(inspectionSheetId); + if (eventList != null || eventList.size() > 0) { + //根据样本号分组 + Map> map = eventList.stream().collect(Collectors.groupingBy(Event::getSampleNumber)); + //获取的产品特性参照值 + InspectionSheetDTO dto = get(inspectionSheetId); + Map 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 featuresList = getInspectionSheetFeaturesList(params2); + //循环每个样本组 + for (Map.Entry> entry : map.entrySet()) { + //该样本的缺陷数 + Integer eventDefects = 0; + //该样本的属性列表 + List 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); + } + }*/ } \ No newline at end of file From d03a3e06a3ba771ca6c9314ebe7b37dcfc8c5771 Mon Sep 17 00:00:00 2001 From: yanyang Date: Fri, 9 Dec 2022 15:27:11 +0800 Subject: [PATCH 4/4] MARK --- .../controller/InspectionSheetController.java | 18 +++++++--- .../service/IInspectionSheetService.java | 2 +- .../impl/InspectionSheetServiceImpl.java | 36 ++++++++++++------- 3 files changed, 38 insertions(+), 18 deletions(-) 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 a641f43..12850f0 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 @@ -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 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().error(1,"没有发现检验参数"); +// } + InspectionSheet entity = inspectionSheetService.saveSheet(dto); + if(entity.getNumberOfSamples()!=null){ + inspectionSheetService.insert(entity); + return new Result().ok(entity.getId()); + } + else{ return new Result().error(1,"没有发现检验参数"); } - return new Result().ok(dto.getId()); } @PutMapping 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 e4996e3..2f4b9d6 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 @@ -26,7 +26,7 @@ public interface IInspectionSheetService extends CrudService params = new HashMap(); params.put("productId", dto.getProductId()); params.put("workingProcedureId", dto.getWorkingProcedureId()); params.put("inspectionStage", dto.getInspectionStage()); List 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