瀏覽代碼

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

shiyue 6 月之前
父節點
當前提交
31b76832fd

+ 8 - 6
energy-manage-service/src/main/java/com/energy/manage/service/controller/units/UnitController.java

@@ -2,6 +2,8 @@ package com.energy.manage.service.controller.units;
 
 
 import com.dtflys.forest.annotation.Get;
+import com.energy.manage.common.po.units.UnitBearingsPO;
+import com.energy.manage.common.po.units.UnitDynamoPO;
 import com.energy.manage.common.reponse.ResultResp;
 import com.energy.manage.service.config.annotations.UserLoginToken;
 import com.energy.manage.service.controller.base.BaseServiceController;
@@ -61,7 +63,7 @@ public class UnitController extends BaseServiceController {
     @ApiOperation(value = "更新部件相关信息")
     public ResultResp modificationUnit(@RequestBody @Valid UnitDto unitDto) {
 
-        if(StringUtils.isEmpty(unitDto.getMillTypeCode())){
+        if (StringUtils.isEmpty(unitDto.getMillTypeCode())) {
             return ResultResp.NOTNULLPARAM();
         }
         // 验证主轴数据
@@ -93,17 +95,17 @@ public class UnitController extends BaseServiceController {
             return ResultResp.FAIL("所有数据均为空,不进行部件数据维护!");
         }
 
-
-        if(!unitService.verifyUnitBearingByMillTypeCode(unitDto.getMillTypeCode())){
+        UnitBearingsPO unitBearingsPO = unitService.verifyUnitBearingByMillTypeCode(unitDto.getMillTypeCode());
+        if (unitBearingsPO != null && unitBearingsPO.getId().intValue() != unitDto.getUnitBearingsDto().getId().intValue()) {
             return ResultResp.FAIL("此机型编号已经绑定部件信息,不可重复绑定");
         }
 
-        if(!unitService.verifyUnitDynamoByMillTypeCode(unitDto.getMillTypeCode())){
+        UnitDynamoPO unitDynamoPO = unitService.verifyUnitDynamoByMillTypeCode(unitDto.getMillTypeCode());
+        if (unitDynamoPO != null && unitDynamoPO.getId().intValue() != unitDto.getUnitDynamoDto().getId().intValue()) {
             return ResultResp.FAIL("此机型编号已经绑定部件信息,不可重复绑定");
         }
 
-
-        boolean flg = unitService.modificationUnit(unitDto,getUserId());
+        boolean flg = unitService.modificationUnit(unitDto, getUserId());
         return flg ? ResultResp.SUCCESS() : ResultResp.FAIL();
     }
 

+ 4 - 2
energy-manage-service/src/main/java/com/energy/manage/service/service/units/UnitService.java

@@ -1,5 +1,7 @@
 package com.energy.manage.service.service.units;
 
+import com.energy.manage.common.po.units.UnitBearingsPO;
+import com.energy.manage.common.po.units.UnitDynamoPO;
 import com.energy.manage.service.domain.dto.units.UnitDictBrandModelDto;
 import com.energy.manage.service.domain.dto.units.UnitDictRoutineDto;
 import com.energy.manage.service.domain.dto.units.UnitDto;
@@ -47,7 +49,7 @@ public interface UnitService {
      * @param millTypeCode
      * @return
      */
-    boolean verifyUnitBearingByMillTypeCode(String millTypeCode);
+    UnitBearingsPO verifyUnitBearingByMillTypeCode(String millTypeCode);
 
 
     /**
@@ -55,6 +57,6 @@ public interface UnitService {
      * @param millTypeCode
      * @return
      */
-    boolean verifyUnitDynamoByMillTypeCode(String millTypeCode);
+    UnitDynamoPO verifyUnitDynamoByMillTypeCode(String millTypeCode);
 
 }

+ 5 - 4
energy-manage-service/src/main/java/com/energy/manage/service/service/units/impl/UnitServiceImpl.java

@@ -169,6 +169,7 @@ public class UnitServiceImpl implements UnitService {
             //更新齿轮箱总表
             if (unitDto.getUnitGearDto().getId() != null && unitDto.getUnitGearDto().getId() > 0) {
                 unitGearboxPO.setId(unitDto.getUnitGearDto().getId());
+                unitGearboxPO.setCode(unitDto.getUnitGearDto().getCode());
                 Example queryExample = new Example(UnitDynamoPO.class);
                 Example.Criteria criteria = queryExample.createCriteria();
                 criteria.andEqualTo("id", unitGearboxPO.getId());
@@ -311,23 +312,23 @@ public class UnitServiceImpl implements UnitService {
     }
 
     @Override
-    public boolean verifyUnitBearingByMillTypeCode(String millTypeCode) {
+    public UnitBearingsPO 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;
+        return unitBearingsMapper.selectOneByExample(queryExample);
     }
 
     @Override
-    public boolean verifyUnitDynamoByMillTypeCode(String millTypeCode) {
+    public UnitDynamoPO 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;
+        return unitDynamoMapper.selectOneByExample(queryExample) ;
     }