فهرست منبع

部件字典管理接口和部件po

shiyue 6 ماه پیش
والد
کامیت
bbb663a2d5

+ 15 - 0
energy-manage-service/src/main/java/com/energy/manage/service/controller/units/UnitController.java

@@ -15,6 +15,7 @@ import com.energy.manage.service.service.units.UnitService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -60,6 +61,9 @@ public class UnitController extends BaseServiceController {
     @ApiOperation(value = "更新部件相关信息")
     public ResultResp modificationUnit(@RequestBody @Valid UnitDto unitDto) {
 
+        if(StringUtils.isEmpty(unitDto.getMillTypeCode())){
+            return ResultResp.NOTNULLPARAM();
+        }
         // 验证主轴数据
         UnitDto.validateAndSetEmptyToNull(unitDto.getUnitBearingsDto());
         if (unitDto.getUnitBearingsDto().allPropertiesAreNull()) {
@@ -88,6 +92,17 @@ public class UnitController extends BaseServiceController {
                 unitDto.getUnitGearDto() == null) {
             return ResultResp.FAIL("所有数据均为空,不进行部件数据维护!");
         }
+
+
+        if(!unitService.verifyUnitBearingByMillTypeCode(unitDto.getMillTypeCode())){
+            return ResultResp.FAIL("此机型编号已经绑定部件信息,不可重复绑定");
+        }
+
+        if(!unitService.verifyUnitDynamoByMillTypeCode(unitDto.getMillTypeCode())){
+            return ResultResp.FAIL("此机型编号已经绑定部件信息,不可重复绑定");
+        }
+
+
         boolean flg = unitService.modificationUnit(unitDto,getUserId());
         return flg ? ResultResp.SUCCESS() : ResultResp.FAIL();
     }

+ 15 - 0
energy-manage-service/src/main/java/com/energy/manage/service/service/units/UnitService.java

@@ -42,4 +42,19 @@ public interface UnitService {
      */
     UnitVo getUnitVo(String millTypeCode);
 
+    /**
+     * 验证主轴是否绑定机型
+     * @param millTypeCode
+     * @return
+     */
+    boolean verifyUnitBearingByMillTypeCode(String millTypeCode);
+
+
+    /**
+     * 验证发电机是否绑定机型
+     * @param millTypeCode
+     * @return
+     */
+    boolean verifyUnitDynamoByMillTypeCode(String millTypeCode);
+
 }

+ 28 - 6
energy-manage-service/src/main/java/com/energy/manage/service/service/units/impl/UnitServiceImpl.java

@@ -83,24 +83,24 @@ public class UnitServiceImpl implements UnitService {
 
     @Override
     public List<String> getBrandModelNameOrModelNumber(UnitDictBrandModelDto unitDictBrandModelDto) {
-        if(StringUtils.isEmpty(unitDictBrandModelDto.getManufacture())){
-           return unitDictConstantsService.getUnitDictBrandModelList(unitDictBrandModelDto);
+        if (StringUtils.isEmpty(unitDictBrandModelDto.getManufacture())) {
+            return unitDictConstantsService.getUnitDictBrandModelList(unitDictBrandModelDto);
         }
         String brandlistKey = ManagerRedisKeyConstant.build(ManagerRedisKeyConstant.IDGENERATOR_UDPB_KEY, unitDictBrandModelDto.getManufacture());
         String val = cacheService.get(brandlistKey);
-        if(StringUtils.isEmpty(val)){
+        if (StringUtils.isEmpty(val)) {
             List<String> valueString = unitDictConstantsService.getUnitDictBrandModelList(unitDictBrandModelDto);
             log.info("品牌对应型号 ===> " + JSON.toJSONString(valueString));
             cacheService.add(brandlistKey, JSON.toJSONString(valueString));
             return valueString;
         }
-        List<String> modelList = JSONArray.parseArray(val,String.class);
+        List<String> modelList = JSONArray.parseArray(val, String.class);
         return modelList;
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public boolean modificationUnit(UnitDto unitDto,Integer userId) {
+    public boolean modificationUnit(UnitDto unitDto, Integer userId) {
 
         boolean flg = false;
         // 处理主轴
@@ -185,7 +185,7 @@ public class UnitServiceImpl implements UnitService {
 
         }
 
-        if(unitGearboxPO!=null){
+        if (unitGearboxPO != null) {
             // 处理齿轮箱轴承处理
             if (!CollectionUtils.isEmpty(unitDto.getUnitGearDto().getUnitGearboxBearingsDtoList())) {
                 UnitGearboxBearingsPO unitGearboxBearingsPO = null;
@@ -309,4 +309,26 @@ public class UnitServiceImpl implements UnitService {
         }
         return unitVo;
     }
+
+    @Override
+    public boolean verifyUnitBearingByMillTypeCode(String millTypeCode) {
+
+        Example queryExample = new Example(UnitBearingsPO.class);
+        Example.Criteria criteria = queryExample.createCriteria();
+        criteria.andEqualTo("millTypeCode", millTypeCode);
+
+        return unitBearingsMapper.selectCountByExample(queryExample) > 0 ? false : true;
+    }
+
+    @Override
+    public boolean verifyUnitDynamoByMillTypeCode(String millTypeCode) {
+
+        Example queryExample = new Example(UnitDynamoPO.class);
+        Example.Criteria criteria = queryExample.createCriteria();
+        criteria.andEqualTo("millTypeCode", millTypeCode);
+
+        return unitDynamoMapper.selectCountByExample(queryExample) > 0 ? false : true;
+    }
+
+
 }