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" + select top(1) type_id, type_no from c_material_type where type_no = #{typeNo} and type_state = '0' + + diff --git a/ruoyi-ui/src/views/clMaterial/clMaterial/index.vue b/ruoyi-ui/src/views/clMaterial/clMaterial/index.vue index 75f765e..e53fabd 100644 --- a/ruoyi-ui/src/views/clMaterial/clMaterial/index.vue +++ b/ruoyi-ui/src/views/clMaterial/clMaterial/index.vue @@ -241,7 +241,7 @@ export default { materialNo: null, materialName: null, materialPrice: null, - materialState: "0" + materialState: '0' }; this.resetForm("form"); }, @@ -267,6 +267,7 @@ export default { this.open = true; this.title = "添加材料管理"; this.isDis = false; + this.materialState = '0' }, /** 修改按钮操作 */ handleUpdate(row) { diff --git a/ruoyi-ui/src/views/material/material/index.vue b/ruoyi-ui/src/views/material/material/index.vue index c1aefa5..6d86375 100644 --- a/ruoyi-ui/src/views/material/material/index.vue +++ b/ruoyi-ui/src/views/material/material/index.vue @@ -376,7 +376,7 @@ export default { materialGuig: null, materialDiany: null, materialDw: null, - materialState: 0 + materialState: '0' }; this.cMaterialCostList = []; this.resetForm("form"); @@ -402,6 +402,7 @@ export default { this.reset(); this.open = true; this.title = "添加物料管理"; + this.materialState = '0'; this.getClMaterials(); this.getMaterialType(); }, diff --git a/ruoyi-ui/src/views/materialType/materialType/index.vue b/ruoyi-ui/src/views/materialType/materialType/index.vue index 61c985e..2220850 100644 --- a/ruoyi-ui/src/views/materialType/materialType/index.vue +++ b/ruoyi-ui/src/views/materialType/materialType/index.vue @@ -218,7 +218,8 @@ export default { typeId: null, typeNo: null, typeName: null, - factoryId: null + factoryId: null, + typeState: '0' }; this.resetForm("form"); }, @@ -244,6 +245,7 @@ export default { this.open = true; this.title = "添加物料类别"; this.isDis = false; + this.form.typeState = '0'; }, /** 修改按钮操作 */ handleUpdate(row) {