diff --git a/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseAreaController.java b/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseAreaController.java index cdddea1c..1483547f 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseAreaController.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseAreaController.java @@ -72,7 +72,13 @@ public class BaseAreaController extends BaseController { @Log(title = "库区", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody BaseArea baseArea) { - return toAjax(baseAreaService.insertBaseArea(baseArea)); + if (baseAreaService.checkAreaCodeUnique(baseArea)) { + return AjaxResult.error("库区编码已存在!"); + }else if(baseAreaService.checkAreaDescUnique(baseArea)){ + return AjaxResult.error("库区描述已存在!"); + }else{ + return toAjax(baseAreaService.insertBaseArea(baseArea)); + } } /** diff --git a/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseEquipmentController.java b/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseEquipmentController.java index 02d405dc..9fb4a939 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseEquipmentController.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseEquipmentController.java @@ -72,7 +72,13 @@ public class BaseEquipmentController extends BaseController { @Log(title = "设备管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody BaseEquipment baseEquipment) { - return toAjax(baseEquipmentService.insertBaseEquipment(baseEquipment)); + if (baseEquipmentService.checkEquipmentCodeUnique(baseEquipment)) { + return AjaxResult.error("设备编码已存在!"); + }else if(baseEquipmentService.checkEquipmentNameUnique(baseEquipment)){ + return AjaxResult.error("设备名称已存在!"); + }else{ + return toAjax(baseEquipmentService.insertBaseEquipment(baseEquipment)); + } } /** diff --git a/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseAreaMapper.java b/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseAreaMapper.java index 080c9a07..c6ae9163 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseAreaMapper.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseAreaMapper.java @@ -60,4 +60,7 @@ public interface BaseAreaMapper { public int deleteBaseAreaByAreaIds(String[] areaIds); public Integer queryCount(BaseArea baseArea); + + public String checkAreaCodeUnique(BaseArea baseArea); + public String checkAreaDescUnique(BaseArea baseArea); } diff --git a/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseEquipmentMapper.java b/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseEquipmentMapper.java index 4a566ad6..ac3a2205 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseEquipmentMapper.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseEquipmentMapper.java @@ -2,6 +2,7 @@ package com.op.wms.mapper; import java.util.List; +import com.baomidou.dynamic.datasource.annotation.DS; import com.op.wms.domain.BaseEquipment; /** @@ -58,4 +59,10 @@ public interface BaseEquipmentMapper { * @return 结果 */ public int deleteBaseEquipmentByEquipmentIds(Long[] equipmentIds); + @DS("master") + public String getEquipmentTypeName(BaseEquipment baseEquipment); + + //判断 + String checkEquipmentCodeUnique(BaseEquipment baseEquipment); + String checkEquipmentNameUnique(BaseEquipment baseEquipment); } diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseAreaService.java b/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseAreaService.java index eb2ff666..50010cac 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseAreaService.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseAreaService.java @@ -57,4 +57,8 @@ public interface IBaseAreaService { * @return 结果 */ public int deleteBaseAreaByAreaId(String areaId); + + boolean checkAreaCodeUnique(BaseArea baseArea); + + boolean checkAreaDescUnique(BaseArea baseArea); } diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseEquipmentService.java b/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseEquipmentService.java index dc07f16d..adfc4d4a 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseEquipmentService.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseEquipmentService.java @@ -57,4 +57,7 @@ public interface IBaseEquipmentService { * @return 结果 */ public int deleteBaseEquipmentByEquipmentId(Long equipmentId); + + boolean checkEquipmentCodeUnique(BaseEquipment baseEquipment); + boolean checkEquipmentNameUnique(BaseEquipment baseEquipment); } diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseAreaServiceImpl.java b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseAreaServiceImpl.java index 97604523..ee0e6b4c 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseAreaServiceImpl.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseAreaServiceImpl.java @@ -100,4 +100,37 @@ public class BaseAreaServiceImpl implements IBaseAreaService { public int deleteBaseAreaByAreaId(String areaId) { return baseAreaMapper.deleteBaseAreaByAreaId(areaId); } + + /** + * 判断库区信息 + * + * @return 结果 + */ + @Override + @DS("#header.poolName") + public boolean checkAreaCodeUnique(BaseArea baseArea){ + String area = baseAreaMapper.checkAreaCodeUnique(baseArea); + if(area == null){ + return false; + }else{ + return true; + } + } + + /** + * 判断库区信息 + * + * @return 结果 + */ + @Override + @DS("#header.poolName") + public boolean checkAreaDescUnique(BaseArea baseArea){ + String desc = baseAreaMapper.checkAreaDescUnique(baseArea); + if(desc== null){ + return false; + }else{ + return true; + } + } + } diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseEquipmentServiceImpl.java b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseEquipmentServiceImpl.java index 2a9f4bc5..4926df22 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseEquipmentServiceImpl.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseEquipmentServiceImpl.java @@ -4,6 +4,7 @@ import java.util.List; import com.baomidou.dynamic.datasource.annotation.DS; import com.op.common.core.utils.DateUtils; +import com.op.wms.domain.BaseArea; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.op.wms.mapper.BaseEquipmentMapper; @@ -55,6 +56,8 @@ public class BaseEquipmentServiceImpl implements IBaseEquipmentService { @DS("#header.poolName") public int insertBaseEquipment(BaseEquipment baseEquipment) { baseEquipment.setCreateTime(DateUtils.getNowDate()); + String equipmentTypeName = baseEquipmentMapper.getEquipmentTypeName(baseEquipment); + baseEquipment.setEquipmentTypeName(equipmentTypeName); return baseEquipmentMapper.insertBaseEquipment(baseEquipment); } @@ -68,6 +71,8 @@ public class BaseEquipmentServiceImpl implements IBaseEquipmentService { @DS("#header.poolName") public int updateBaseEquipment(BaseEquipment baseEquipment) { baseEquipment.setUpdateTime(DateUtils.getNowDate()); + String equipmentTypeName = baseEquipmentMapper.getEquipmentTypeName(baseEquipment); + baseEquipment.setEquipmentTypeName(equipmentTypeName); return baseEquipmentMapper.updateBaseEquipment(baseEquipment); } @@ -94,4 +99,36 @@ public class BaseEquipmentServiceImpl implements IBaseEquipmentService { public int deleteBaseEquipmentByEquipmentId(Long equipmentId) { return baseEquipmentMapper.deleteBaseEquipmentByEquipmentId(equipmentId); } + + /** + * 判断设备信息 + * + * @return 结果 + */ + @Override + @DS("#header.poolName") + public boolean checkEquipmentCodeUnique(BaseEquipment baseEquipment){ + String equipment = baseEquipmentMapper.checkEquipmentCodeUnique(baseEquipment); + if(equipment == null){ + return false; + }else{ + return true; + } + } + + /** + * 判断设备信息 + * + * @return 结果 + */ + @Override + @DS("#header.poolName") + public boolean checkEquipmentNameUnique(BaseEquipment baseEquipment){ + String equipment = baseEquipmentMapper.checkEquipmentNameUnique(baseEquipment); + if(equipment == null){ + return false; + }else{ + return true; + } + } } diff --git a/op-modules/op-wms/src/main/resources/mapper/wms/BaseAreaMapper.xml b/op-modules/op-wms/src/main/resources/mapper/wms/BaseAreaMapper.xml index 6009dd7c..2c2034c7 100644 --- a/op-modules/op-wms/src/main/resources/mapper/wms/BaseAreaMapper.xml +++ b/op-modules/op-wms/src/main/resources/mapper/wms/BaseAreaMapper.xml @@ -1,9 +1,9 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -44,11 +44,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - + insert into base_area - + area_code, area_desc, region_code, @@ -112,9 +112,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" active_flag, remark, factory_code, - + - + #{areaCode}, #{areaDesc}, #{regionCode}, @@ -145,7 +145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{activeFlag}, #{remark}, #{factoryCode}, - + @@ -190,15 +190,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from base_area where area_id in + delete from base_area where area_id in #{areaId} - + + + + + + \ No newline at end of file diff --git a/op-modules/op-wms/src/main/resources/mapper/wms/BaseEquipmentMapper.xml b/op-modules/op-wms/src/main/resources/mapper/wms/BaseEquipmentMapper.xml index 8f1fcca7..926d1274 100644 --- a/op-modules/op-wms/src/main/resources/mapper/wms/BaseEquipmentMapper.xml +++ b/op-modules/op-wms/src/main/resources/mapper/wms/BaseEquipmentMapper.xml @@ -39,12 +39,12 @@ + select dict_label + from sys_dict_data + where dict_value = #{equipmentTypeCode} + + + + + + \ No newline at end of file