Explorar el Código

[chg]新增电梯逻辑修改

别傲 hace 5 años
padre
commit
2d8a2fba66

+ 9 - 5
lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/LiftService.java

@@ -152,14 +152,17 @@ public class LiftService {
     public RestResponse add(LiftExtensionRequest request) {
         //获取新增标记 (0:新增,1:查询后带入)
         String mark = request.getMark();
-        Lift lift = request.getLift();
         //公司id
         Long mtCompanyId = request.getMtCompanyId();
+        //电梯id
+        Long id;
         /*if (judge(mtCompanyId))
         return RestResponse.fail(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.limit.num"));*/
-        RestResponse response = preJudgment(mtCompanyId, lift.getRegistrationCode(), null);
+        RestResponse response = preJudgment(mtCompanyId, request.getCode(), null);
         if (ApiConstants.RESULT_ERROR.equals(response.getMessage())) return response;
+        //新增标记 (0:新增,1:查询后带入)
         if ("0".equals(mark)) {
+            Lift lift = request.getLift();
             //按当前日期时间戳自动生成电梯编号
             String liftCode = ApiConstants.STRAIGHT_LADDER + DateUtils.generateCode();
             if (CommonEnum.LiftType.STAIRCASE.getCode().equals(Objects.toString(lift.getLiftType()))) {
@@ -170,9 +173,10 @@ public class LiftService {
             if (liftResult == 0) {
                 return RestResponse.fail(MessageUtils.get("msg.add.fail"));
             }
+            id = lift.getId();
+        } else {
+            id = Long.parseLong(request.getId());
         }
-        //电梯id
-        Long id = lift.getId();
         //新增电梯来源
         String source = request.getSource();
         switch (source) {
@@ -225,7 +229,7 @@ public class LiftService {
             liftId = lift.getId().toString();
         }
         RestResponse response = preJudgment(null, lift.getRegistrationCode(), liftId);
-        if (ObjectUtil.isNotEmpty(response.getData())) return response;
+        if (ApiConstants.RESULT_ERROR.equals(response.getMessage())) return response;
         int result = liftMapper.updateById(lift);
         if (result > 0) {
             return RestResponse.success();