瀏覽代碼

:white_check_mark:接口防抖以及机位更新安检处理逻辑

Twelve615 1 年之前
父節點
當前提交
67951f0b32

+ 2 - 0
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/controller/APIController.java

@@ -55,6 +55,7 @@ import org.jeecg.modules.admin_security_check.service.IAdminSecurityCheckPicServ
 import org.jeecg.modules.admin_security_check.service.IAdminSecurityCheckService;
 import org.jeecg.modules.admin_user_staff.entity.AdminUserStaff;
 import org.jeecg.modules.admin_user_staff.service.IAdminUserStaffService;
+import org.jeecg.modules.aop.annotation.AvoidRepeatRequest;
 import org.jeecg.modules.api.entity.*;
 import org.jeecg.modules.base.service.BaseCommonService;
 import org.jeecg.modules.system.entity.SysDepart;
@@ -80,6 +81,7 @@ import java.util.*;
 @RestController
 @RequestMapping("/api")
 @Slf4j
+@AvoidRepeatRequest()
 public class APIController {
 
     @Value(value = "${jeecg.path.upload}")

+ 77 - 15
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/imf/msg/StlsImfMsg.java

@@ -47,24 +47,60 @@ public class StlsImfMsg extends ImfMsgAbstract {
             return;
         }
         // 原机位
-        String positionCode = dfdlList.getPositionCode();
-        // 计划时间
+        String oldPositionCode = dfdlList.getPositionCode();
+        // 计划时间与机位
         setStlsStnd(dfdlList);
-        if (!Strings.isNullOrEmpty(positionCode) && !positionCode.equals(dfdlList.getPositionCode())) {
+        // 新机位
+        String newPositionCode = dfdlList.getPositionCode();
+        if (!Strings.isNullOrEmpty(oldPositionCode) && !oldPositionCode.equals(newPositionCode)) {
             // 机位变更了,更新安检,更新机位
-            // 修改安检 根据机位
-            LambdaUpdateWrapper<AdminSecurityCheck> adminSecurityCheckLambdaUpdateWrapper1 = new LambdaUpdateWrapper<>();
-            adminSecurityCheckLambdaUpdateWrapper1.eq(AdminSecurityCheck::getAircraftPositionNum, positionCode);
-            // 修改安检
-            adminSecurityCheckLambdaUpdateWrapper1
-                    .set(AdminSecurityCheck::getAircraftNum, null)
-                    .set(AdminSecurityCheck::getDropTime, null)
-                    .set(AdminSecurityCheck::getFlightNum, null)
-                    .set(AdminSecurityCheck::getFlightSole, null)
-                    .set(AdminSecurityCheck::getFlightAfid, null);
-            adminSecurityCheckService.update(adminSecurityCheckLambdaUpdateWrapper1);
+            if (Strings.isNullOrEmpty(newPositionCode)) {
+                // 新机位是空的
+                // 修改安检为空信息
+                updateSecurityCheckIsNull(null, oldPositionCode);
+            } else {
+                // 新机位不是空的
+                // 查询新机位有没有订单
+                List<AdminSecurityCheck> list = adminSecurityCheckService.lambdaQuery().eq(AdminSecurityCheck::getAircraftPositionNum, newPositionCode).list();
+                if (list == null || list.isEmpty()) {
+                    // 没有新的机位的订单
+                    LambdaUpdateWrapper<AdminSecurityCheck> securityCheckLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+                    securityCheckLambdaUpdateWrapper.eq(AdminSecurityCheck::getAircraftPositionNum, oldPositionCode);
+                    // 修改安检旧机位为新机位
+                    securityCheckLambdaUpdateWrapper.set(AdminSecurityCheck::getAircraftPositionNum, newPositionCode);
+                    // 修改安检 根据机位
+                    adminSecurityCheckService.update(securityCheckLambdaUpdateWrapper);
+                } else {
+                    //有新机位的订单
+                    // 原机位安检飞机号一致就设置为空,不一致不设置
+                    List<AdminSecurityCheck> oldScList = adminSecurityCheckService.lambdaQuery().eq(AdminSecurityCheck::getAircraftPositionNum, oldPositionCode).list();
+                    if (oldScList == null || oldScList.isEmpty()) {
+                        // 旧机位没有,保险起见置空一下
+                        updateSecurityCheckIsNull(null, oldPositionCode);
+                    } else {
+                        // 旧机位有
+                        for (AdminSecurityCheck adminSecurityCheck : oldScList) {
+                            if (Strings.isNullOrEmpty(adminSecurityCheck.getAircraftNum()) || dfdlList.getCfno().equals(adminSecurityCheck.getAircraftNum())) {
+                                // 飞机号一致或者为空设置空, 防止两个不同的飞机互换
+                                updateSecurityCheckIsNull(adminSecurityCheck.getId(), null);
+                            } else {
+                                // 不一致不设置
+                            }
+                        }
+                    }
+                    // 新机位安检设置参数
+                    for (AdminSecurityCheck adminSecurityCheck : list) {
+                        adminSecurityCheck.setAircraftNum(dfdlList.getCfno());
+                        adminSecurityCheck.setDropTime(dfdlList.getFrlt());
+                        adminSecurityCheck.setFlightNum(dfdlList.getFlio() + "-" + dfdlList.getFlno());
+                        adminSecurityCheck.setFlightSole(String.valueOf(dfdlList.getFlid()).replace("null", ""));
+                        adminSecurityCheck.setFlightAfid(String.valueOf(dfdlList.getAfid()).replace("null", ""));
+                        adminSecurityCheckService.updateById(adminSecurityCheck);
+                    }
+                }
+            }
             // 查询旧的机位并置空
-            AdminAircraftPosition one = getApByCode(positionCode);
+            AdminAircraftPosition one = getApByCode(oldPositionCode);
             if (ImfMsgUtil.setNullPosition(one)) {
                 getAdminAircraftPositionService().updateById(one);
             }
@@ -74,6 +110,32 @@ public class StlsImfMsg extends ImfMsgAbstract {
     }
 
     /**
+     * 修改机位对应的安检航班数据为空
+     *
+     * @param positionCode 机位
+     */
+    private boolean updateSecurityCheckIsNull(String id, String positionCode) {
+        if (Strings.isNullOrEmpty(id) && Strings.isNullOrEmpty(positionCode)) {
+            return false;
+        }
+        LambdaUpdateWrapper<AdminSecurityCheck> updateWrapper = new LambdaUpdateWrapper<>();
+        if (!Strings.isNullOrEmpty(id)) {
+            updateWrapper.eq(AdminSecurityCheck::getId, id);
+        }
+        if (!Strings.isNullOrEmpty(positionCode)) {
+            updateWrapper.eq(AdminSecurityCheck::getAircraftPositionNum, positionCode);
+        }
+        updateWrapper
+                .set(AdminSecurityCheck::getAircraftNum, null)
+                .set(AdminSecurityCheck::getDropTime, null)
+                .set(AdminSecurityCheck::getFlightNum, null)
+                .set(AdminSecurityCheck::getFlightSole, null)
+                .set(AdminSecurityCheck::getFlightAfid, null);
+        // 修改安检 根据机位
+        return adminSecurityCheckService.update(updateWrapper);
+    }
+
+    /**
      * 通过机位编号获取机位信息
      *
      * @param CODE