胶料快检实验类型、胶料快检数据点、胶料快检实验方法新增

This commit is contained in:
2026-05-25 11:01:00 +08:00
parent fa1c5c9b42
commit af8bf14b5e
44 changed files with 4476 additions and 1 deletions

View File

@@ -103,3 +103,79 @@ jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecMo
-- author:cursor---date:20260521--for: 【配合示方】编辑打开时基本资料闪清修复 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
-- author:jiangxh---date:20260522--for: 【MES】胶料快检实验类型质量管理目录、001自动编号、CRUD与菜单权限 ---
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_97__mes_xsl_rubber_quick_test_type.sql
jeecg-boot/db/mes-xsl-rubber-quick-test-type-menu-permission.sql
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslRubberQuickTestType.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslRubberQuickTestTypeMapper.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslRubberQuickTestTypeService.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslRubberQuickTestTypeServiceImpl.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslRubberQuickTestTypeController.java
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestType/MesXslRubberQuickTestTypeList.vue
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestType/MesXslRubberQuickTestType.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestType/MesXslRubberQuickTestType.api.ts
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestType/components/MesXslRubberQuickTestTypeModal.vue
-- author:jiangxh---date:20260522--for: 【MES】胶料快检实验方法质量管理菜单、001编号、名称唯一、关联实验类型 ---
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_99__mes_xsl_rubber_quick_test_method.sql
jeecg-boot/db/mes-xsl-rubber-quick-test-method-menu-permission.sql
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslRubberQuickTestMethod.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslRubberQuickTestMethodMapper.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslRubberQuickTestMethodService.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslRubberQuickTestMethodServiceImpl.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslRubberQuickTestMethodController.java
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethodList.vue
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethod.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethod.api.ts
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/components/MesXslRubberQuickTestMethodModal.vue
-- author:jiangxh---date:20260522--for: 【MES】撤销胶料快检实验方法功能删代码+库清理脚本)---
jeecg-boot/db/mes-xsl-rubber-quick-test-method-drop.sql
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_100__drop_mes_xsl_rubber_quick_test_method.sql
-- author:jiangxh---date:20260522--for: 【MES】胶料快检数据点质量管理菜单、名称唯一、关联实验类型、单位手填 ---
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_101__mes_xsl_rubber_quick_test_data_point.sql
jeecg-boot/db/mes-xsl-rubber-quick-test-data-point-menu-permission.sql
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslRubberQuickTestDataPoint.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslRubberQuickTestDataPointMapper.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslRubberQuickTestDataPointService.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslRubberQuickTestDataPointServiceImpl.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslRubberQuickTestDataPointController.java
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestDataPoint/MesXslRubberQuickTestDataPointList.vue
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestDataPoint/MesXslRubberQuickTestDataPoint.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestDataPoint/MesXslRubberQuickTestDataPoint.api.ts
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestDataPoint/components/MesXslRubberQuickTestDataPointModal.vue
-- author:jiangxh---date:20260522--for: 【MES】胶料快检实验类型名称同租户不可重复Service兜底+唯一索引)---
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_98__mes_xsl_rubber_quick_test_type_name_unique.sql
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslRubberQuickTestTypeServiceImpl.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslRubberQuickTestTypeController.java
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestType/MesXslRubberQuickTestType.data.ts
-- author:jiangxh---date:20260522--for: 【MES】胶料快检实验方法主子表质量管理菜单177段、001编号、名称唯一、选择数据点明细 ---
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_102__mes_xsl_rubber_quick_test_method.sql
jeecg-boot/db/mes-xsl-rubber-quick-test-method-menu-permission.sql
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslRubberQuickTestMethod.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslRubberQuickTestMethodLine.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/vo/MesXslRubberQuickTestMethodPage.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslRubberQuickTestMethodMapper.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslRubberQuickTestMethodLineMapper.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslRubberQuickTestMethodService.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslRubberQuickTestMethodServiceImpl.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslRubberQuickTestMethodController.java
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethodList.vue
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethod.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethod.api.ts
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/components/MesXslRubberQuickTestMethodModal.vue
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/components/MesXslRubberQuickTestDataPointSelectModal.vue
-- author:jiangxh---date:20260522--for: 【MES】胶料快检实验方法明细字典单位必选、不可清空 ---
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethod.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/components/MesXslRubberQuickTestMethodModal.vue
-- author:jiangxh---date:20260522--for: 【MES】胶料快检实验方法明细单位字典默认取首项非空选---
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethod.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslRubberQuickTestMethod/components/MesXslRubberQuickTestMethodModal.vue
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslRubberQuickTestMethodController.java
jeecgboot-vue3/src/components/jeecg/JVxeTable/src/components/cells/JVxeSelectCell.vue

View File

@@ -0,0 +1,297 @@
package org.jeecg.modules.xslmes.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestDataPoint;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestType;
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestDataPointService;
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestTypeService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
/**
* MES 胶料快检数据点
*/
@Tag(name = "MES胶料快检数据点")
@RestController
@RequestMapping("/xslmes/mesXslRubberQuickTestDataPoint")
@Slf4j
public class MesXslRubberQuickTestDataPointController
extends JeecgController<MesXslRubberQuickTestDataPoint, IMesXslRubberQuickTestDataPointService> {
@Autowired
private IMesXslRubberQuickTestDataPointService mesXslRubberQuickTestDataPointService;
@Autowired
private IMesXslRubberQuickTestTypeService mesXslRubberQuickTestTypeService;
@Operation(summary = "MES胶料快检数据点-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MesXslRubberQuickTestDataPoint>> queryPageList(
MesXslRubberQuickTestDataPoint model,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MesXslRubberQuickTestDataPoint> queryWrapper =
QueryGenerator.initQueryWrapper(model, req.getParameterMap());
Page<MesXslRubberQuickTestDataPoint> page = new Page<>(pageNo, pageSize);
IPage<MesXslRubberQuickTestDataPoint> pageList = mesXslRubberQuickTestDataPointService.page(page, queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "MES胶料快检数据点-添加")
@Operation(summary = "MES胶料快检数据点-添加")
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_data_point:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody MesXslRubberQuickTestDataPoint model) {
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检数据点保存校验、实验类型回填-----------
String err = validateForSave(model, null);
if (err != null) {
return Result.error(err);
}
try {
mesXslRubberQuickTestDataPointService.save(model);
} catch (JeecgBootException e) {
return Result.error(e.getMessage());
}
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检数据点保存校验、实验类型回填-----------
return Result.OK("添加成功!");
}
@AutoLog(value = "MES胶料快检数据点-编辑")
@Operation(summary = "MES胶料快检数据点-编辑")
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_data_point:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesXslRubberQuickTestDataPoint model) {
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检数据点编辑校验-----------
if (oConvertUtils.isEmpty(model.getId())) {
return Result.error("缺少主键");
}
MesXslRubberQuickTestDataPoint old = mesXslRubberQuickTestDataPointService.getById(model.getId());
if (old == null) {
return Result.error("未找到对应数据");
}
String err = validateForSave(model, model.getId());
if (err != null) {
return Result.error(err);
}
old.setPointName(model.getPointName());
old.setQuickTestTypeId(model.getQuickTestTypeId());
old.setQuickTestTypeName(model.getQuickTestTypeName());
old.setUnitType(model.getUnitType());
old.setPointDesc(model.getPointDesc());
try {
mesXslRubberQuickTestDataPointService.updateById(old);
} catch (JeecgBootException e) {
return Result.error(e.getMessage());
}
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检数据点编辑校验-----------
return Result.OK("编辑成功!");
}
@AutoLog(value = "MES胶料快检数据点-删除")
@Operation(summary = "MES胶料快检数据点-通过id删除")
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_data_point:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
mesXslRubberQuickTestDataPointService.removeById(id);
return Result.OK("删除成功!");
}
@AutoLog(value = "MES胶料快检数据点-批量删除")
@Operation(summary = "MES胶料快检数据点-批量删除")
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_data_point:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
mesXslRubberQuickTestDataPointService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@Operation(summary = "MES胶料快检数据点-通过id查询")
@GetMapping(value = "/queryById")
public Result<MesXslRubberQuickTestDataPoint> queryById(@RequestParam(name = "id", required = true) String id) {
MesXslRubberQuickTestDataPoint entity = mesXslRubberQuickTestDataPointService.getById(id);
if (entity == null) {
return Result.error("未找到对应数据");
}
return Result.OK(entity);
}
@Operation(summary = "校验数据点名称是否重复")
@GetMapping(value = "/checkPointName")
public Result<String> checkPointName(
@RequestParam(name = "pointName", required = true) String pointName,
@RequestParam(name = "dataId", required = false) String dataId) {
if (oConvertUtils.isEmpty(pointName) || pointName.trim().isEmpty()) {
return Result.OK("该值可用!");
}
MesXslRubberQuickTestDataPoint ctx = new MesXslRubberQuickTestDataPoint();
if (mesXslRubberQuickTestDataPointService.isPointNameDuplicated(pointName.trim(), dataId, ctx)) {
return Result.error("该数据点名称已存在");
}
return Result.OK("该值可用!");
}
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_data_point:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesXslRubberQuickTestDataPoint model) {
return super.exportXls(request, model, MesXslRubberQuickTestDataPoint.class, "MES胶料快检数据点");
}
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_data_point:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检数据点导入校验-----------
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> ent : fileMap.entrySet()) {
MultipartFile file = ent.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<MesXslRubberQuickTestDataPoint> list =
ExcelImportUtil.importExcel(file.getInputStream(), MesXslRubberQuickTestDataPoint.class, params);
if (list == null) {
list = List.of();
}
Set<String> namesInFile = new HashSet<>();
for (int i = 0; i < list.size(); i++) {
MesXslRubberQuickTestDataPoint row = list.get(i);
int rowNo = i + 1;
if (row == null) {
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
}
String err = validateImportRow(row, rowNo, namesInFile);
if (err != null) {
return Result.error(err);
}
}
for (MesXslRubberQuickTestDataPoint row : list) {
try {
mesXslRubberQuickTestDataPointService.save(row);
} catch (JeecgBootException e) {
return Result.error("文件导入失败:" + e.getMessage());
}
}
log.info("胶料快检数据点Excel导入完成行数={}", list.size());
return Result.ok("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
String msg = e.getMessage();
log.error(msg, e);
return Result.error("文件导入失败:" + e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检数据点导入校验-----------
return Result.error("文件导入失败!");
}
private String validateForSave(MesXslRubberQuickTestDataPoint model, String excludeId) {
if (oConvertUtils.isEmpty(model.getPointName()) || model.getPointName().trim().isEmpty()) {
return "数据点名称不能为空";
}
model.setPointName(model.getPointName().trim());
if (mesXslRubberQuickTestDataPointService.isPointNameDuplicated(model.getPointName(), excludeId, model)) {
return "数据点名称已存在";
}
if (oConvertUtils.isNotEmpty(model.getUnitType())) {
model.setUnitType(model.getUnitType().trim());
}
if (oConvertUtils.isNotEmpty(model.getPointDesc())) {
model.setPointDesc(model.getPointDesc().trim());
}
return resolveAndFillQuickTestType(model);
}
private String validateImportRow(MesXslRubberQuickTestDataPoint row, int rowNo, Set<String> namesInFile) {
if (oConvertUtils.isEmpty(row.getPointName()) || row.getPointName().trim().isEmpty()) {
return "文件导入失败:第 " + rowNo + " 条数据点名称不能为空";
}
row.setPointName(row.getPointName().trim());
if (!namesInFile.add(row.getPointName())) {
return "文件导入失败:数据点名称【" + row.getPointName() + "】在导入文件中重复";
}
if (mesXslRubberQuickTestDataPointService.isPointNameDuplicated(row.getPointName(), null, row)) {
return "文件导入失败:第 " + rowNo + " 条数据点名称【" + row.getPointName() + "】已存在";
}
if (oConvertUtils.isEmpty(row.getQuickTestTypeId()) && oConvertUtils.isNotEmpty(row.getImportQuickTestTypeName())) {
row.setQuickTestTypeName(row.getImportQuickTestTypeName().trim());
}
if (oConvertUtils.isEmpty(row.getQuickTestTypeId()) && oConvertUtils.isNotEmpty(row.getQuickTestTypeName())) {
MesXslRubberQuickTestType type = findQuickTestTypeByName(row.getQuickTestTypeName(), row);
if (type == null) {
return "文件导入失败:第 " + rowNo + " 条实验类型【" + row.getQuickTestTypeName() + "】不存在";
}
row.setQuickTestTypeId(type.getId());
}
String typeErr = resolveAndFillQuickTestType(row);
if (typeErr != null) {
return "文件导入失败:第 " + rowNo + "" + typeErr;
}
if (oConvertUtils.isNotEmpty(row.getUnitType())) {
row.setUnitType(row.getUnitType().trim());
}
return null;
}
private String resolveAndFillQuickTestType(MesXslRubberQuickTestDataPoint model) {
if (oConvertUtils.isEmpty(model.getQuickTestTypeId())) {
return "请选择实验类型";
}
MesXslRubberQuickTestType type = mesXslRubberQuickTestTypeService.getById(model.getQuickTestTypeId());
if (type == null) {
return "实验类型不存在或已删除";
}
model.setQuickTestTypeName(type.getTypeName());
return null;
}
private MesXslRubberQuickTestType findQuickTestTypeByName(String typeName, MesXslRubberQuickTestDataPoint context) {
LambdaQueryWrapper<MesXslRubberQuickTestType> w = new LambdaQueryWrapper<>();
w.eq(MesXslRubberQuickTestType::getTypeName, typeName.trim());
w.and(
q ->
q.eq(MesXslRubberQuickTestType::getDelFlag, CommonConstant.DEL_FLAG_0)
.or()
.isNull(MesXslRubberQuickTestType::getDelFlag));
Integer tenantId = context != null ? context.getTenantId() : null;
if (tenantId != null) {
w.eq(MesXslRubberQuickTestType::getTenantId, tenantId);
}
w.last("LIMIT 1");
return mesXslRubberQuickTestTypeService.getOne(w, false);
}
}

View File

@@ -0,0 +1,508 @@
package org.jeecg.modules.xslmes.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestDataPoint;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethodLine;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestType;
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestDataPointService;
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestMethodService;
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestTypeService;
import org.jeecg.modules.xslmes.vo.MesXslRubberQuickTestMethodPage;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
/**
* MES 胶料快检实验方法(主子表)
*/
@Tag(name = "MES胶料快检实验方法")
@RestController
@RequestMapping("/xslmes/mesXslRubberQuickTestMethod")
@Slf4j
public class MesXslRubberQuickTestMethodController
extends JeecgController<MesXslRubberQuickTestMethod, IMesXslRubberQuickTestMethodService> {
@Autowired
private IMesXslRubberQuickTestMethodService mesXslRubberQuickTestMethodService;
@Autowired
private IMesXslRubberQuickTestTypeService mesXslRubberQuickTestTypeService;
@Autowired
private IMesXslRubberQuickTestDataPointService mesXslRubberQuickTestDataPointService;
@Operation(summary = "MES胶料快检实验方法-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MesXslRubberQuickTestMethod>> queryPageList(
MesXslRubberQuickTestMethod model,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MesXslRubberQuickTestMethod> queryWrapper =
QueryGenerator.initQueryWrapper(model, req.getParameterMap());
queryWrapper.orderByDesc("create_time");
Page<MesXslRubberQuickTestMethod> page = new Page<>(pageNo, pageSize);
IPage<MesXslRubberQuickTestMethod> pageList = mesXslRubberQuickTestMethodService.page(page, queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "MES胶料快检实验方法-添加")
@Operation(summary = "MES胶料快检实验方法-添加")
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_method:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody MesXslRubberQuickTestMethodPage page) {
MesXslRubberQuickTestMethod main = new MesXslRubberQuickTestMethod();
BeanUtils.copyProperties(page, main);
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检实验方法保存校验与明细从数据点带出-----------
String err = validateForSave(main, page.getLineList(), null);
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检实验方法保存校验与明细从数据点带出-----------
try {
mesXslRubberQuickTestMethodService.saveMain(main, page.getLineList());
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error(e.getMessage());
}
return Result.OK("添加成功!");
}
@AutoLog(value = "MES胶料快检实验方法-编辑")
@Operation(summary = "MES胶料快检实验方法-编辑")
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_method:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesXslRubberQuickTestMethodPage page) {
MesXslRubberQuickTestMethod main = new MesXslRubberQuickTestMethod();
BeanUtils.copyProperties(page, main);
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检实验方法保存校验与明细从数据点带出-----------
String err = validateForSave(main, page.getLineList(), main.getId());
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检实验方法保存校验与明细从数据点带出-----------
try {
mesXslRubberQuickTestMethodService.updateMain(main, page.getLineList());
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error(e.getMessage());
}
return Result.OK("编辑成功!");
}
@AutoLog(value = "MES胶料快检实验方法-删除")
@Operation(summary = "MES胶料快检实验方法-通过id删除")
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_method:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
mesXslRubberQuickTestMethodService.delMain(id);
return Result.OK("删除成功!");
}
@AutoLog(value = "MES胶料快检实验方法-批量删除")
@Operation(summary = "MES胶料快检实验方法-批量删除")
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_method:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
mesXslRubberQuickTestMethodService.delBatchMain(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@Operation(summary = "MES胶料快检实验方法-通过id查询")
@GetMapping(value = "/queryById")
public Result<MesXslRubberQuickTestMethod> queryById(@RequestParam(name = "id", required = true) String id) {
MesXslRubberQuickTestMethod entity = mesXslRubberQuickTestMethodService.getById(id);
if (entity == null) {
return Result.error("未找到对应数据");
}
return Result.OK(entity);
}
@Operation(summary = "MES胶料快检实验方法-查询明细")
@GetMapping(value = "/queryLineListByMethodId")
public Result<List<MesXslRubberQuickTestMethodLine>> queryLineListByMethodId(
@RequestParam(name = "id", required = true) String id) {
return Result.OK(mesXslRubberQuickTestMethodService.selectLinesByMethodId(id));
}
@Operation(summary = "MES胶料快检实验方法-下一编号")
@GetMapping(value = "/nextMethodCode")
public Result<String> nextMethodCode() {
MesXslRubberQuickTestMethod ctx = new MesXslRubberQuickTestMethod();
return Result.OK(mesXslRubberQuickTestMethodService.generateNextMethodCode(ctx));
}
@Operation(summary = "MES胶料快检实验方法-校验名称唯一")
@GetMapping(value = "/checkMethodName")
public Result<?> checkMethodName(
@RequestParam(name = "methodName") String methodName,
@RequestParam(name = "dataId", required = false) String dataId) {
if (oConvertUtils.isEmpty(methodName) || methodName.trim().isEmpty()) {
return Result.OK();
}
MesXslRubberQuickTestMethod ctx = new MesXslRubberQuickTestMethod();
if (mesXslRubberQuickTestMethodService.isMethodNameDuplicated(methodName.trim(), dataId, ctx)) {
return Result.error("实验方法名称已存在");
}
return Result.OK();
}
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_method:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesXslRubberQuickTestMethod model) {
return super.exportXls(request, model, MesXslRubberQuickTestMethod.class, "MES胶料快检实验方法");
}
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_method:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, MesXslRubberQuickTestMethod.class);
}
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检实验方法保存校验与明细从数据点带出-----------
private String validateForSave(
MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList, String excludeId) {
if (main == null) {
return "参数不能为空";
}
if (oConvertUtils.isEmpty(main.getMethodName())) {
return "实验方法名称不能为空";
}
main.setMethodName(main.getMethodName().trim());
if (mesXslRubberQuickTestMethodService.isMethodNameDuplicated(main.getMethodName(), excludeId, main)) {
return "实验方法名称已存在";
}
if (oConvertUtils.isEmpty(main.getQuickTestTypeId())) {
return "请选择实验类型";
}
MesXslRubberQuickTestType type = mesXslRubberQuickTestTypeService.getById(main.getQuickTestTypeId());
if (type == null || isDeleted(type.getDelFlag())) {
return "实验类型不存在或已删除";
}
main.setQuickTestTypeName(type.getTypeName());
if (lineList == null || lineList.isEmpty()) {
return "请通过「选择数据点」至少添加一条明细";
}
Set<String> pointIds = new HashSet<>();
int sort = 0;
for (int i = 0; i < lineList.size(); i++) {
MesXslRubberQuickTestMethodLine line = lineList.get(i);
if (line == null) {
continue;
}
int rowNo = i + 1;
if (oConvertUtils.isEmpty(line.getDataPointId())) {
return "" + rowNo + " 行未选择数据点";
}
String pointId = line.getDataPointId().trim();
if (!pointIds.add(pointId)) {
return "" + rowNo + " 行数据点与前面行重复,同一方法中数据点不能重复";
}
MesXslRubberQuickTestDataPoint point = mesXslRubberQuickTestDataPointService.getById(pointId);
if (point == null || isDeleted(point.getDelFlag())) {
return "" + rowNo + " 行数据点不存在或已删除";
}
if (!main.getQuickTestTypeId().equals(point.getQuickTestTypeId())) {
return "" + rowNo + " 行数据点的实验类型与主表实验类型不一致";
}
line.setDataPointId(pointId);
line.setPointName(point.getPointName());
line.setUnitType(point.getUnitType());
if (oConvertUtils.isEmpty(line.getTorqueUnitType())) {
return "" + rowNo + " 行请选择扭矩单位类型";
}
if (oConvertUtils.isEmpty(line.getTimeUnitType())) {
return "" + rowNo + " 行请选择时间单位类型";
}
if (oConvertUtils.isEmpty(line.getMooneyUnitType())) {
return "" + rowNo + " 行请选择门尼单位类型";
}
line.setSortNo(sort++);
}
if (pointIds.isEmpty()) {
return "请通过「选择数据点」至少添加一条明细";
}
return null;
}
private static boolean isDeleted(Integer delFlag) {
return delFlag != null && delFlag.equals(CommonConstant.DEL_FLAG_1);
}
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检实验方法保存校验与明细从数据点带出-----------
}

View File

@@ -0,0 +1,235 @@
package org.jeecg.modules.xslmes.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestType;
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestTypeService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
/**
* MES 胶料快检实验类型
*/
@Tag(name = "MES胶料快检实验类型")
@RestController
@RequestMapping("/xslmes/mesXslRubberQuickTestType")
@Slf4j
public class MesXslRubberQuickTestTypeController
extends JeecgController<MesXslRubberQuickTestType, IMesXslRubberQuickTestTypeService> {
@Autowired
private IMesXslRubberQuickTestTypeService mesXslRubberQuickTestTypeService;
@Operation(summary = "MES胶料快检实验类型-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MesXslRubberQuickTestType>> queryPageList(
MesXslRubberQuickTestType model,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MesXslRubberQuickTestType> queryWrapper =
QueryGenerator.initQueryWrapper(model, req.getParameterMap());
Page<MesXslRubberQuickTestType> page = new Page<>(pageNo, pageSize);
IPage<MesXslRubberQuickTestType> pageList = mesXslRubberQuickTestTypeService.page(page, queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "MES胶料快检实验类型-添加")
@Operation(summary = "MES胶料快检实验类型-添加")
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_type:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody MesXslRubberQuickTestType model) {
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检实验类型新增校验与自动编号-----------
if (oConvertUtils.isEmpty(model.getTypeName()) || model.getTypeName().trim().isEmpty()) {
return Result.error("实验类型名称不能为空");
}
model.setTypeName(model.getTypeName().trim());
if (mesXslRubberQuickTestTypeService.isTypeNameDuplicated(model.getTypeName(), null, model)) {
return Result.error("实验类型名称已存在");
}
model.setTypeCode(null);
try {
mesXslRubberQuickTestTypeService.save(model);
} catch (JeecgBootException e) {
return Result.error(e.getMessage());
}
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检实验类型新增校验与自动编号-----------
return Result.OK("添加成功!");
}
@AutoLog(value = "MES胶料快检实验类型-编辑")
@Operation(summary = "MES胶料快检实验类型-编辑")
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_type:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesXslRubberQuickTestType model) {
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检实验类型编辑仅改名称、编号只读-----------
if (oConvertUtils.isEmpty(model.getId())) {
return Result.error("缺少主键");
}
if (oConvertUtils.isEmpty(model.getTypeName()) || model.getTypeName().trim().isEmpty()) {
return Result.error("实验类型名称不能为空");
}
model.setTypeName(model.getTypeName().trim());
if (mesXslRubberQuickTestTypeService.isTypeNameDuplicated(model.getTypeName(), model.getId(), model)) {
return Result.error("实验类型名称已存在");
}
MesXslRubberQuickTestType old = mesXslRubberQuickTestTypeService.getById(model.getId());
if (old == null) {
return Result.error("未找到对应数据");
}
old.setTypeName(model.getTypeName());
try {
mesXslRubberQuickTestTypeService.updateById(old);
} catch (JeecgBootException e) {
return Result.error(e.getMessage());
}
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检实验类型编辑仅改名称、编号只读-----------
return Result.OK("编辑成功!");
}
@AutoLog(value = "MES胶料快检实验类型-删除")
@Operation(summary = "MES胶料快检实验类型-通过id删除")
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_type:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
mesXslRubberQuickTestTypeService.removeById(id);
return Result.OK("删除成功!");
}
@AutoLog(value = "MES胶料快检实验类型-批量删除")
@Operation(summary = "MES胶料快检实验类型-批量删除")
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_type:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
mesXslRubberQuickTestTypeService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@Operation(summary = "MES胶料快检实验类型-通过id查询")
@GetMapping(value = "/queryById")
public Result<MesXslRubberQuickTestType> queryById(@RequestParam(name = "id", required = true) String id) {
MesXslRubberQuickTestType entity = mesXslRubberQuickTestTypeService.getById(id);
if (entity == null) {
return Result.error("未找到对应数据");
}
return Result.OK(entity);
}
@Operation(summary = "预览下一实验类型编号001起")
@GetMapping(value = "/nextTypeCode")
public Result<String> nextTypeCode() {
MesXslRubberQuickTestType ctx = new MesXslRubberQuickTestType();
return Result.OK(mesXslRubberQuickTestTypeService.generateNextTypeCode(ctx));
}
@Operation(summary = "校验实验类型名称是否重复")
@GetMapping(value = "/checkTypeName")
public Result<String> checkTypeName(
@RequestParam(name = "typeName", required = true) String typeName,
@RequestParam(name = "dataId", required = false) String dataId) {
if (oConvertUtils.isEmpty(typeName) || typeName.trim().isEmpty()) {
return Result.OK("该值可用!");
}
MesXslRubberQuickTestType ctx = new MesXslRubberQuickTestType();
if (mesXslRubberQuickTestTypeService.isTypeNameDuplicated(typeName.trim(), dataId, ctx)) {
return Result.error("该实验类型名称已存在");
}
return Result.OK("该值可用!");
}
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_type:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesXslRubberQuickTestType model) {
return super.exportXls(request, model, MesXslRubberQuickTestType.class, "MES胶料快检实验类型");
}
@RequiresPermissions("mes:mes_xsl_rubber_quick_test_type:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检实验类型导入名称必填且不重复编号可空则自动生成-----------
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> ent : fileMap.entrySet()) {
MultipartFile file = ent.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<MesXslRubberQuickTestType> list =
ExcelImportUtil.importExcel(file.getInputStream(), MesXslRubberQuickTestType.class, params);
if (list == null) {
list = List.of();
}
Set<String> namesInFile = new HashSet<>();
for (int i = 0; i < list.size(); i++) {
MesXslRubberQuickTestType row = list.get(i);
int rowNo = i + 1;
if (row == null) {
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
}
if (oConvertUtils.isEmpty(row.getTypeName()) || row.getTypeName().trim().isEmpty()) {
return Result.error("文件导入失败:第 " + rowNo + " 条实验类型名称不能为空");
}
row.setTypeName(row.getTypeName().trim());
if (!namesInFile.add(row.getTypeName())) {
return Result.error("文件导入失败:实验类型名称【" + row.getTypeName() + "】在导入文件中重复");
}
if (mesXslRubberQuickTestTypeService.isTypeNameDuplicated(row.getTypeName(), null, row)) {
return Result.error("文件导入失败:第 " + rowNo + " 条实验类型名称【" + row.getTypeName() + "】已存在");
}
if (oConvertUtils.isNotEmpty(row.getTypeCode())) {
row.setTypeCode(row.getTypeCode().trim());
} else {
row.setTypeCode(null);
}
}
for (MesXslRubberQuickTestType row : list) {
try {
mesXslRubberQuickTestTypeService.save(row);
} catch (JeecgBootException e) {
return Result.error("文件导入失败:" + e.getMessage());
}
}
log.info("胶料快检实验类型Excel导入完成行数={}", list.size());
return Result.ok("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
String msg = e.getMessage();
log.error(msg, e);
return Result.error("文件导入失败:" + e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检实验类型导入名称必填且不重复编号可空则自动生成-----------
return Result.error("文件导入失败!");
}
}

View File

@@ -0,0 +1,74 @@
package org.jeecg.modules.xslmes.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
* MES 胶料快检数据点
*/
@Data
@TableName("mes_xsl_rubber_quick_test_data_point")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES胶料快检数据点")
public class MesXslRubberQuickTestDataPoint implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Excel(name = "数据点名称", width = 24)
@Schema(description = "数据点名称(同租户未删除唯一)")
private String pointName;
@Excel(name = "实验类型", width = 20, dictTable = "mes_xsl_rubber_quick_test_type", dicText = "type_name", dicCode = "id")
@Dict(dictTable = "mes_xsl_rubber_quick_test_type", dicText = "type_name", dicCode = "id")
@Schema(description = "实验类型ID")
private String quickTestTypeId;
@Excel(name = "实验类型名称", width = 20)
@Schema(description = "实验类型名称冗余")
private String quickTestTypeName;
@Excel(name = "单位类型", width = 16)
@Schema(description = "单位类型(手填)")
private String unitType;
@Excel(name = "描述", width = 40)
@Schema(description = "描述")
private String pointDesc;
@TableField(exist = false)
@Excel(name = "实验类型名称导入", width = 20)
@Schema(description = "导入用实验类型名称")
private String importQuickTestTypeName;
private Integer tenantId;
private String sysOrgCode;
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
@TableLogic
@Schema(description = "删除状态0正常 1已删除")
private Integer delFlag;
}

View File

@@ -0,0 +1,104 @@
package org.jeecg.modules.xslmes.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
* MES 胶料快检实验方法主表
*/
@Data
@TableName("mes_xsl_rubber_quick_test_method")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES胶料快检实验方法")
public class MesXslRubberQuickTestMethod implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Excel(name = "方法编号", width = 14)
@Schema(description = "方法编号租户内从001递增自动生成只读")
private String methodCode;
@Excel(name = "实验方法名称", width = 24)
@Schema(description = "实验方法名称(同租户未删除唯一)")
private String methodName;
@Excel(name = "实验类型", width = 20, dictTable = "mes_xsl_rubber_quick_test_type", dicText = "type_name", dicCode = "id")
@Dict(dictTable = "mes_xsl_rubber_quick_test_type", dicText = "type_name", dicCode = "id")
@Schema(description = "实验类型ID")
private String quickTestTypeId;
@Excel(name = "实验类型名称", width = 20)
@Schema(description = "实验类型名称冗余")
private String quickTestTypeName;

View File

@@ -0,0 +1,64 @@
package org.jeecg.modules.xslmes.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.springframework.format.annotation.DateTimeFormat;
/**
* MES 胶料快检实验方法明细
*/
@Data
@TableName("mes_xsl_rubber_quick_test_method_line")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES胶料快检实验方法明细")
public class MesXslRubberQuickTestMethodLine implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Schema(description = "主表主键 mes_xsl_rubber_quick_test_method.id")
private String methodId;

View File

@@ -0,0 +1,54 @@
package org.jeecg.modules.xslmes.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
* MES 胶料快检实验类型
*/
@Data
@TableName("mes_xsl_rubber_quick_test_type")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES胶料快检实验类型")
public class MesXslRubberQuickTestType implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Excel(name = "实验类型编号", width = 16)
@Schema(description = "实验类型编号租户内从001递增自动生成只读")
private String typeCode;
@Excel(name = "实验类型名称", width = 24)
@Schema(description = "实验类型名称")
private String typeName;
private Integer tenantId;
private String sysOrgCode;
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
@TableLogic
@Schema(description = "删除状态0正常 1已删除")
private Integer delFlag;
}

View File

@@ -0,0 +1,11 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestDataPoint;
/**
* MES 胶料快检数据点 Mapper
*/
@Mapper
public interface MesXslRubberQuickTestDataPointMapper extends BaseMapper<MesXslRubberQuickTestDataPoint> {}

View File

@@ -0,0 +1,8 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

View File

@@ -0,0 +1,19 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
@Mapper
public interface MesXslRubberQuickTestMethodMapper extends BaseMapper<MesXslRubberQuickTestMethod> {

View File

@@ -0,0 +1,22 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestType;
/**
* MES 胶料快检实验类型 Mapper
*/
@Mapper
public interface MesXslRubberQuickTestTypeMapper extends BaseMapper<MesXslRubberQuickTestType> {
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检实验类型租户内最大三位数字编号-----------
@Select(
"SELECT IFNULL(MAX(CAST(type_code AS UNSIGNED)), 0) FROM mes_xsl_rubber_quick_test_type "
+ "WHERE del_flag = 0 AND type_code REGEXP '^[0-9]+$' "
+ "AND (#{tenantId} IS NULL OR tenant_id = #{tenantId})")
Integer selectMaxNumericTypeCode(@Param("tenantId") Integer tenantId);
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检实验类型租户内最大三位数字编号-----------
}

View File

@@ -0,0 +1,9 @@
package org.jeecg.modules.xslmes.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestDataPoint;
public interface IMesXslRubberQuickTestDataPointService extends IService<MesXslRubberQuickTestDataPoint> {
boolean isPointNameDuplicated(String pointName, String excludeId, MesXslRubberQuickTestDataPoint context);
}

View File

@@ -0,0 +1,25 @@
package org.jeecg.modules.xslmes.service;
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethodLine;
public interface IMesXslRubberQuickTestMethodService extends IService<MesXslRubberQuickTestMethod> {
String generateNextMethodCode(MesXslRubberQuickTestMethod context);

View File

@@ -0,0 +1,17 @@
package org.jeecg.modules.xslmes.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestType;
public interface IMesXslRubberQuickTestTypeService extends IService<MesXslRubberQuickTestType> {
/**
* 生成下一实验类型编号001 起,三位数字,租户维度)
*/
String generateNextTypeCode(MesXslRubberQuickTestType context);
/**
* 实验类型名称是否重复(仅未删除数据,同租户)
*/
boolean isTypeNameDuplicated(String typeName, String excludeId, MesXslRubberQuickTestType context);
}

View File

@@ -0,0 +1,94 @@
package org.jeecg.modules.xslmes.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestDataPoint;
import org.jeecg.modules.xslmes.mapper.MesXslRubberQuickTestDataPointMapper;
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestDataPointService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class MesXslRubberQuickTestDataPointServiceImpl
extends ServiceImpl<MesXslRubberQuickTestDataPointMapper, MesXslRubberQuickTestDataPoint>
implements IMesXslRubberQuickTestDataPointService {
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检数据点名称同租户唯一-----------
@Override
public boolean isPointNameDuplicated(String pointName, String excludeId, MesXslRubberQuickTestDataPoint context) {
if (oConvertUtils.isEmpty(pointName)) {
return false;
}
Integer tenantId = resolveTenantId(context);
LambdaQueryWrapper<MesXslRubberQuickTestDataPoint> w = new LambdaQueryWrapper<>();
w.eq(MesXslRubberQuickTestDataPoint::getPointName, pointName.trim());
w.and(
q ->
q.eq(MesXslRubberQuickTestDataPoint::getDelFlag, CommonConstant.DEL_FLAG_0)
.or()
.isNull(MesXslRubberQuickTestDataPoint::getDelFlag));
if (oConvertUtils.isNotEmpty(excludeId)) {
w.ne(MesXslRubberQuickTestDataPoint::getId, excludeId);
}
if (tenantId != null) {
w.eq(MesXslRubberQuickTestDataPoint::getTenantId, tenantId);
}
return this.count(w) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean save(MesXslRubberQuickTestDataPoint entity) {
assertPointNameUniqueForSave(entity, null);
return super.save(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateById(MesXslRubberQuickTestDataPoint entity) {
if (oConvertUtils.isEmpty(entity.getId())) {
throw new JeecgBootException("缺少主键");
}
assertPointNameUniqueForSave(entity, entity.getId());
return super.updateById(entity);
}
private void assertPointNameUniqueForSave(MesXslRubberQuickTestDataPoint entity, String excludeId) {
if (entity == null || oConvertUtils.isEmpty(entity.getPointName())) {
throw new JeecgBootException("数据点名称不能为空");
}
String name = entity.getPointName().trim();
entity.setPointName(name);
if (isPointNameDuplicated(name, excludeId, entity)) {
throw new JeecgBootException("数据点名称已存在");
}
}
private static Integer resolveTenantId(MesXslRubberQuickTestDataPoint context) {
if (context != null && context.getTenantId() != null) {
return context.getTenantId();
}
String ts = TenantContext.getTenant();
if (oConvertUtils.isEmpty(ts)) {
try {
ts = TokenUtils.getTenantIdByRequest(SpringContextUtils.getHttpServletRequest());
} catch (Exception ignored) {
}
}
if (oConvertUtils.isEmpty(ts)) {
return null;
}
try {
return Integer.parseInt(ts.trim());
} catch (NumberFormatException e) {
return null;
}
}
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检数据点名称同租户唯一-----------
}

View File

@@ -0,0 +1,166 @@
package org.jeecg.modules.xslmes.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethodLine;
import org.jeecg.modules.xslmes.mapper.MesXslRubberQuickTestMethodLineMapper;
import org.jeecg.modules.xslmes.mapper.MesXslRubberQuickTestMethodMapper;
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestMethodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@Service
public class MesXslRubberQuickTestMethodServiceImpl
extends ServiceImpl<MesXslRubberQuickTestMethodMapper, MesXslRubberQuickTestMethod>
implements IMesXslRubberQuickTestMethodService {
@Autowired
private MesXslRubberQuickTestMethodLineMapper mesXslRubberQuickTestMethodLineMapper;
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检实验方法编号001递增、名称同租户唯一、主子保存-----------
@Override
public String generateNextMethodCode(MesXslRubberQuickTestMethod context) {
Integer tenantId = resolveTenantId(context);
Integer max = baseMapper.selectMaxNumericMethodCode(tenantId);
int next = (max == null ? 0 : max) + 1;
if (next > 999) {
throw new IllegalStateException("实验方法编号已超过999请联系管理员");
}
return String.format("%03d", next);
}
@Override
public boolean isMethodNameDuplicated(String methodName, String excludeId, MesXslRubberQuickTestMethod context) {
if (oConvertUtils.isEmpty(methodName)) {
return false;
}
Integer tenantId = resolveTenantId(context);
LambdaQueryWrapper<MesXslRubberQuickTestMethod> w = new LambdaQueryWrapper<>();
w.eq(MesXslRubberQuickTestMethod::getMethodName, methodName.trim());
w.and(
q ->
q.eq(MesXslRubberQuickTestMethod::getDelFlag, CommonConstant.DEL_FLAG_0)
.or()
.isNull(MesXslRubberQuickTestMethod::getDelFlag));
if (oConvertUtils.isNotEmpty(excludeId)) {
w.ne(MesXslRubberQuickTestMethod::getId, excludeId);
}
if (tenantId != null) {
w.eq(MesXslRubberQuickTestMethod::getTenantId, tenantId);
}
return this.count(w) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void saveMain(MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList) {
assertMethodNameUniqueForSave(main, null);
if (oConvertUtils.isEmpty(main.getMethodCode())) {
main.setMethodCode(generateNextMethodCode(main));
}
this.save(main);
insertLines(main.getId(), lineList);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateMain(MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList) {
if (oConvertUtils.isEmpty(main.getId())) {
throw new JeecgBootException("缺少主键");
}
MesXslRubberQuickTestMethod old = this.getById(main.getId());

View File

@@ -0,0 +1,108 @@
package org.jeecg.modules.xslmes.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestType;
import org.jeecg.modules.xslmes.mapper.MesXslRubberQuickTestTypeMapper;
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestTypeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class MesXslRubberQuickTestTypeServiceImpl
extends ServiceImpl<MesXslRubberQuickTestTypeMapper, MesXslRubberQuickTestType>
implements IMesXslRubberQuickTestTypeService {
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检实验类型编号001递增、名称同租户唯一-----------
@Override
public String generateNextTypeCode(MesXslRubberQuickTestType context) {
Integer tenantId = resolveTenantId(context);
Integer max = baseMapper.selectMaxNumericTypeCode(tenantId);
int next = (max == null ? 0 : max) + 1;
if (next > 999) {
throw new IllegalStateException("实验类型编号已超过999请联系管理员");
}
return String.format("%03d", next);
}
@Override
public boolean isTypeNameDuplicated(String typeName, String excludeId, MesXslRubberQuickTestType context) {
if (oConvertUtils.isEmpty(typeName)) {
return false;
}
Integer tenantId = resolveTenantId(context);
LambdaQueryWrapper<MesXslRubberQuickTestType> w = new LambdaQueryWrapper<>();
w.eq(MesXslRubberQuickTestType::getTypeName, typeName.trim());
w.and(
q ->
q.eq(MesXslRubberQuickTestType::getDelFlag, CommonConstant.DEL_FLAG_0)
.or()
.isNull(MesXslRubberQuickTestType::getDelFlag));
if (oConvertUtils.isNotEmpty(excludeId)) {
w.ne(MesXslRubberQuickTestType::getId, excludeId);
}
if (tenantId != null) {
w.eq(MesXslRubberQuickTestType::getTenantId, tenantId);
}
return this.count(w) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean save(MesXslRubberQuickTestType entity) {
assertTypeNameUniqueForSave(entity, null);
if (oConvertUtils.isEmpty(entity.getTypeCode())) {
entity.setTypeCode(generateNextTypeCode(entity));
}
return super.save(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateById(MesXslRubberQuickTestType entity) {
if (oConvertUtils.isEmpty(entity.getId())) {
throw new JeecgBootException("缺少主键");
}
assertTypeNameUniqueForSave(entity, entity.getId());
return super.updateById(entity);
}
private void assertTypeNameUniqueForSave(MesXslRubberQuickTestType entity, String excludeId) {
if (entity == null || oConvertUtils.isEmpty(entity.getTypeName())) {
throw new JeecgBootException("实验类型名称不能为空");
}
String name = entity.getTypeName().trim();
entity.setTypeName(name);
if (isTypeNameDuplicated(name, excludeId, entity)) {
throw new JeecgBootException("实验类型名称已存在");
}
}
private static Integer resolveTenantId(MesXslRubberQuickTestType context) {
if (context != null && context.getTenantId() != null) {
return context.getTenantId();
}
String ts = TenantContext.getTenant();
if (oConvertUtils.isEmpty(ts)) {
try {
ts = TokenUtils.getTenantIdByRequest(SpringContextUtils.getHttpServletRequest());
} catch (Exception ignored) {
}
}
if (oConvertUtils.isEmpty(ts)) {
return null;
}
try {
return Integer.parseInt(ts.trim());
} catch (NumberFormatException e) {
return null;
}
}
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检实验类型编号001递增、名称同租户唯一-----------
}

View File

@@ -0,0 +1,12 @@
package org.jeecg.modules.xslmes.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;