diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/clMaterial/CYlMaterialController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/clMaterial/CYlMaterialController.java
index 41b4ec3..d2d0574 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/clMaterial/CYlMaterialController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/clMaterial/CYlMaterialController.java
@@ -83,7 +83,7 @@ public class CYlMaterialController extends BaseController
{
if (!cYlMaterialService.checkMaterialNoUnique(cYlMaterial))
{
- return error("新增材料'" + cYlMaterial.getMaterialNo() + "'失败,编码已存在");
+ return error("添加材料失败,编码:'" + cYlMaterial.getMaterialNo() + "' 已存在");
}
return toAjax(cYlMaterialService.insertCYlMaterial(cYlMaterial));
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/factory/CFactoryController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/factory/CFactoryController.java
index 337a8c3..f46a522 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/factory/CFactoryController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/factory/CFactoryController.java
@@ -104,7 +104,7 @@ public class CFactoryController extends BaseController
{
if (!cFactoryService.checkFactoryNoUnique(cFactory))
{
- return error("新增车间'" + cFactory.getFactoryNo() + "'失败,编码已存在");
+ return error("添加车间失败,编码:'" + cFactory.getFactoryNo() + "' 已存在");
}
return toAjax(cFactoryService.insertCFactory(cFactory));
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/materialType/CMaterialTypeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/materialType/CMaterialTypeController.java
index 79389bd..1646577 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/materialType/CMaterialTypeController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/materialType/CMaterialTypeController.java
@@ -81,6 +81,11 @@ public class CMaterialTypeController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody CMaterialType cMaterialType)
{
+
+ if (!cMaterialTypeService.checkTypeNoUnique(cMaterialType))
+ {
+ return error("添加物料类型失败,编码:'" + cMaterialType.getTypeNo() + "' 已存在");
+ }
return toAjax(cMaterialTypeService.insertCMaterialType(cMaterialType));
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/materialType/mapper/CMaterialTypeMapper.java b/ruoyi-system/src/main/java/com/ruoyi/materialType/mapper/CMaterialTypeMapper.java
index 7f5f140..4a01780 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/materialType/mapper/CMaterialTypeMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/materialType/mapper/CMaterialTypeMapper.java
@@ -5,15 +5,15 @@ import com.ruoyi.materialType.domain.CMaterialType;
/**
* 物料类别Mapper接口
- *
+ *
* @author ruoyi
* @date 2024-03-01
*/
-public interface CMaterialTypeMapper
+public interface CMaterialTypeMapper
{
/**
* 查询物料类别
- *
+ *
* @param typeId 物料类别主键
* @return 物料类别
*/
@@ -21,7 +21,7 @@ public interface CMaterialTypeMapper
/**
* 查询物料类别列表
- *
+ *
* @param cMaterialType 物料类别
* @return 物料类别集合
*/
@@ -29,7 +29,7 @@ public interface CMaterialTypeMapper
/**
* 新增物料类别
- *
+ *
* @param cMaterialType 物料类别
* @return 结果
*/
@@ -37,7 +37,7 @@ public interface CMaterialTypeMapper
/**
* 修改物料类别
- *
+ *
* @param cMaterialType 物料类别
* @return 结果
*/
@@ -45,7 +45,7 @@ public interface CMaterialTypeMapper
/**
* 删除物料类别
- *
+ *
* @param typeId 物料类别主键
* @return 结果
*/
@@ -53,9 +53,16 @@ public interface CMaterialTypeMapper
/**
* 批量删除物料类别
- *
+ *
* @param typeIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteCMaterialTypeByTypeIds(Long[] typeIds);
+
+ /**
+ * 检查物料编码是否存在
+ * @param typeNo
+ * @return
+ */
+ CMaterialType checkTypeNoUnique(String typeNo);
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/materialType/service/ICMaterialTypeService.java b/ruoyi-system/src/main/java/com/ruoyi/materialType/service/ICMaterialTypeService.java
index 66587c4..a52ebfe 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/materialType/service/ICMaterialTypeService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/materialType/service/ICMaterialTypeService.java
@@ -5,15 +5,15 @@ import com.ruoyi.materialType.domain.CMaterialType;
/**
* 物料类别Service接口
- *
+ *
* @author ruoyi
* @date 2024-03-01
*/
-public interface ICMaterialTypeService
+public interface ICMaterialTypeService
{
/**
* 查询物料类别
- *
+ *
* @param typeId 物料类别主键
* @return 物料类别
*/
@@ -21,7 +21,7 @@ public interface ICMaterialTypeService
/**
* 查询物料类别列表
- *
+ *
* @param cMaterialType 物料类别
* @return 物料类别集合
*/
@@ -29,7 +29,7 @@ public interface ICMaterialTypeService
/**
* 新增物料类别
- *
+ *
* @param cMaterialType 物料类别
* @return 结果
*/
@@ -37,7 +37,7 @@ public interface ICMaterialTypeService
/**
* 修改物料类别
- *
+ *
* @param cMaterialType 物料类别
* @return 结果
*/
@@ -45,7 +45,7 @@ public interface ICMaterialTypeService
/**
* 批量删除物料类别
- *
+ *
* @param typeIds 需要删除的物料类别主键集合
* @return 结果
*/
@@ -53,9 +53,16 @@ public interface ICMaterialTypeService
/**
* 删除物料类别信息
- *
+ *
* @param typeId 物料类别主键
* @return 结果
*/
public int deleteCMaterialTypeByTypeId(Long typeId);
+
+ /**
+ * 检查物料编码是否存在
+ * @param cMaterialType
+ * @return
+ */
+ boolean checkTypeNoUnique(CMaterialType cMaterialType);
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/materialType/service/impl/CMaterialTypeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/materialType/service/impl/CMaterialTypeServiceImpl.java
index c5ebdd1..075d172 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/materialType/service/impl/CMaterialTypeServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/materialType/service/impl/CMaterialTypeServiceImpl.java
@@ -1,6 +1,10 @@
package com.ruoyi.materialType.service.impl;
import java.util.List;
+
+import com.ruoyi.common.constant.UserConstants;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.materialType.mapper.CMaterialTypeMapper;
@@ -9,19 +13,19 @@ import com.ruoyi.materialType.service.ICMaterialTypeService;
/**
* 物料类别Service业务层处理
- *
+ *
* @author ruoyi
* @date 2024-03-01
*/
@Service
-public class CMaterialTypeServiceImpl implements ICMaterialTypeService
+public class CMaterialTypeServiceImpl implements ICMaterialTypeService
{
@Autowired
private CMaterialTypeMapper cMaterialTypeMapper;
/**
* 查询物料类别
- *
+ *
* @param typeId 物料类别主键
* @return 物料类别
*/
@@ -33,7 +37,7 @@ public class CMaterialTypeServiceImpl implements ICMaterialTypeService
/**
* 查询物料类别列表
- *
+ *
* @param cMaterialType 物料类别
* @return 物料类别
*/
@@ -45,7 +49,7 @@ public class CMaterialTypeServiceImpl implements ICMaterialTypeService
/**
* 新增物料类别
- *
+ *
* @param cMaterialType 物料类别
* @return 结果
*/
@@ -57,7 +61,7 @@ public class CMaterialTypeServiceImpl implements ICMaterialTypeService
/**
* 修改物料类别
- *
+ *
* @param cMaterialType 物料类别
* @return 结果
*/
@@ -69,7 +73,7 @@ public class CMaterialTypeServiceImpl implements ICMaterialTypeService
/**
* 批量删除物料类别
- *
+ *
* @param typeIds 需要删除的物料类别主键
* @return 结果
*/
@@ -81,7 +85,7 @@ public class CMaterialTypeServiceImpl implements ICMaterialTypeService
/**
* 删除物料类别信息
- *
+ *
* @param typeId 物料类别主键
* @return 结果
*/
@@ -90,4 +94,20 @@ public class CMaterialTypeServiceImpl implements ICMaterialTypeService
{
return cMaterialTypeMapper.deleteCMaterialTypeByTypeId(typeId);
}
+
+ /**
+ * 检查物料编码是否存在
+ * @param cMaterialType
+ * @return
+ */
+ @Override
+ public boolean checkTypeNoUnique(CMaterialType cMaterialType) {
+ Long typeId = StringUtils.isNull(cMaterialType.getTypeId()) ? -1L : cMaterialType.getTypeId();
+ CMaterialType info = cMaterialTypeMapper.checkTypeNoUnique(cMaterialType.getTypeNo());
+ if (StringUtils.isNotNull(info) && info.getTypeId().longValue() != typeId.longValue())
+ {
+ return UserConstants.NOT_UNIQUE;
+ }
+ return UserConstants.UNIQUE;
+ }
}
diff --git a/ruoyi-system/src/main/resources/mapper/clMaterial/CYlMaterialMapper.xml b/ruoyi-system/src/main/resources/mapper/clMaterial/CYlMaterialMapper.xml
index 8cbf677..cf7d395 100644
--- a/ruoyi-system/src/main/resources/mapper/clMaterial/CYlMaterialMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/clMaterial/CYlMaterialMapper.xml
@@ -69,7 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"