Browse Source

调整文件结构

ximinghao 4 tháng trước cách đây
mục cha
commit
87c1b90844

+ 18 - 0
src/main/java/com/skyversation/xjcy/dms/DMSColumn.java

@@ -0,0 +1,18 @@
+package com.skyversation.xjcy.dms;
+
+import lombok.Getter;
+
+public enum DMSColumn {
+    INDUSTRIAL_PARK("1580"),
+    ENTERPRISE("1593"),
+    ENTERPRISE_ECONOMIC("1594"),
+    ORDER("1587"),
+    LEASE_DETAIL("1574");
+    @Getter
+    private String id;
+
+    DMSColumn(String id) {
+        id = id;
+    }
+
+}

+ 82 - 0
src/main/java/com/skyversation/xjcy/dms/DMSQuery.java

@@ -0,0 +1,82 @@
+package com.skyversation.xjcy.dms;
+
+import com.skyversation.xjcy.bean.*;
+import com.skyversation.xjcy.util.SpecialisationStringCollector;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.HashSet;
+import java.util.Set;
+
+@AllArgsConstructor
+@Getter
+public enum DMSQuery {
+
+    INDUSTRIAL_PARK(DMSColumn.INDUSTRIAL_PARK, IndustrialPark.class) {
+        @Override
+        public DMSRequest preRequest(LocalDate now) {
+            return new DMSRequest();
+        }
+    },
+    ENTERPRISE(DMSColumn.ENTERPRISE, Enterprise.class) {
+        @Override
+        public DMSRequest preRequest(LocalDate now) {
+            return new DMSRequest();
+        }
+    },
+    ECONOMIC_ALL_INDEED(DMSColumn.ENTERPRISE_ECONOMIC, EnterpriseEconomic.class) {
+        @Override
+        public DMSRequest preRequest(LocalDate now) {
+            DMSRequest request = new DMSRequest();
+            Set<String> monthInDeed = new HashSet<>();
+            monthInDeed.addAll(SpecialisationStringCollector.YearMonthByLast12Month(now));
+            monthInDeed.addAll(SpecialisationStringCollector.YearMonthByYtd(now));
+            monthInDeed.addAll(SpecialisationStringCollector.YearMonthByYtd(1, now));
+            request.addWhere("c_year_month", "5", monthInDeed);
+            return request;
+        }
+    },
+    ORDER(DMSColumn.ORDER, Order.class) {
+        @Override
+        public DMSRequest preRequest(LocalDate now) {
+            return new DMSRequest();
+        }
+    },
+    LAST_LEASE_DETAIL(DMSColumn.LEASE_DETAIL, LeaseDetail.class) {
+        @Override
+        public DMSRequest preRequest(LocalDate now) {
+            DMSRequest request = new DMSRequest();
+            request.addWhere("c_is_latest_lease", "1", "2");
+            return request;
+        }
+    },
+    LAST_YEAR_LEASE_DETAIL(DMSColumn.LEASE_DETAIL, LeaseDetail.class) {
+        @Override
+        public DMSRequest preRequest(LocalDate now) {
+            DMSRequest request = new DMSRequest();
+            LocalDate indeedStartTime = now.minusMonths(13).withDayOfMonth(1);
+            LocalDate indeedEndTime = now.minusMonths(1)                     // 上个月
+                    .withDayOfMonth(
+                            now.minusMonths(1)
+                                    .lengthOfMonth());
+
+            LocalDate timeOfFarBefore = LocalDate.of(1970, 1, 1);
+            LocalDate timeOfFarAfter = indeedEndTime.plusYears(100);
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            request.addWhere("c_start_date", "3", timeOfFarBefore.format(formatter), indeedEndTime.format(formatter));
+            request.addWhere("c_end_date", "3", indeedStartTime.format(formatter), timeOfFarAfter.format(formatter));
+            return request;
+        }
+    };
+
+    private final DMSColumn column;
+    private final Class<? extends FromJSON> resultType;
+
+    abstract DMSRequest preRequest(LocalDate now);
+
+    public String getColumnId() {
+        return column.getId();
+    }
+}

+ 66 - 0
src/main/java/com/skyversation/xjcy/dms/DMSRequest.java

@@ -0,0 +1,66 @@
+package com.skyversation.xjcy.dms;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+class DMSRequest {
+    DMSRequestType type;
+    Map<String, String> params = new HashMap<>();
+    String token;
+    JSONArray where = new JSONArray();
+    JSONArray order = new JSONArray();
+
+     void addWhere(String field, String type, String content) {
+        this.where.add(summonWhere(field, type, content));
+    }
+
+    void addWhere(String field, String type, Set<String> content) {
+        this.where.add(summonWhere(field, type, content));
+    }
+
+    JSONObject summonWhere(String field, String type, Object content) {
+        JSONObject where = new JSONObject();
+        where.put("field", field);
+        where.put("searchType", type);
+        JSONObject contents = new JSONObject();
+        contents.put("value", content);
+        where.put("content", contents);
+        return where;
+    }
+
+    void addWhere(String field, String type, String start, String end) {
+        JSONObject where = new JSONObject();
+        where.put("field", field);
+        where.put("searchType", type);
+        JSONObject contents = new JSONObject();
+        contents.put("start", start);
+        contents.put("end", end);
+        where.put("content", contents);
+        this.where.add(where);
+    }
+
+    void addOrder(DMSRequest request) {
+
+    }
+
+    void setPage(String page, String pageSize) {
+        this.params.put("page", page);
+        this.params.put("pageSize", pageSize);
+    }
+
+    void setState() {
+        this.params.put("states", "0,1,2,3");
+    }
+
+    void setColumnId(String columnId) {
+        this.params.put("columnId", columnId);
+    }
+
+    enum DMSRequestType {
+        List, JOIN_LIST
+    }
+}

+ 183 - 0
src/main/java/com/skyversation/xjcy/dms/DMSService.java

@@ -0,0 +1,183 @@
+package com.skyversation.xjcy.dms;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.skyversation.xjcy.bean.*;
+import com.skyversation.xjcy.util.HttpUtil;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.util.StringUtils;
+
+import java.time.LocalDate;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+public class DMSService {
+    @Value("${app.dms.path}")
+    private String path;
+    @Value("${app.oauth.login-name}")
+    private String loginName;
+    @Value("${app.oauth.password}")
+    private String password;
+    @Value("${app.oauth.path}")
+    private String oauthPath;
+
+    public String loginForToken() throws Exception {
+        if (!StringUtils.hasText(loginName) || !StringUtils.hasText(password)) {
+            throw new Exception("请提供用于访问DMS的账号密码");
+        }
+        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+        params.add("userName", loginName);
+        params.add("password", password);
+        params.add("clientId", "2");
+        String response = HttpUtil.requestPost(oauthPath, params, new HashMap<>());
+        JSONObject jsonObject = JSON.parseObject(response);
+        if ("密码错误".equals(jsonObject.getString("message"))) {
+            loginName = null;
+            password = null;
+            throw new Exception("请检查使用的账户和密码是否正确,已停止使用该账号密码以避免锁定账号");
+        }
+        if (!Objects.equals(jsonObject.getString("code"), "200")) {
+            throw new Exception(jsonObject.getString("message"));
+        }
+        return jsonObject.getString("message");
+    }
+
+
+    private JSONObject sendQueryToDms(DMSRequest request) {
+        JSONObject jsonObject;
+        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+        request.params.forEach(params::add);
+        params.add("search", request.where.toJSONString());
+        try {
+            String response;
+            switch (request.type) {
+                case List: {
+                    response = HttpUtil.requestPost(path + "/content/selectContentListInfo", params,
+                            Collections.singletonMap("token", request.token));
+                    break;
+                }
+                case JOIN_LIST: {
+                    response = "";
+                    break;
+                }
+                default: {
+                    return null;
+                }
+            }
+            jsonObject = JSON.parseObject(response);
+        } catch (Exception e) {
+            return null;
+        }
+        if (Objects.equals(jsonObject.getString("message"), "无效token")) {
+            return null;
+        }
+        return jsonObject;
+    }
+
+    public void updateToDms(List<JSONObject> objs,String token,DMSColumn column) {
+
+    }
+    public void importToDms(List<JSONObject> objs,String token,DMSColumn column) {
+
+    }
+
+    private List<JSONObject> queryDmsList(DMSRequest request, String token, String columnId) {
+        request.token = token;
+        request.type = DMSRequest.DMSRequestType.List;
+        request.setColumnId(columnId);
+        request.setState();
+        int page = 0;
+        int pageSize = 2000;
+        List<JSONObject> list = new ArrayList<>();
+        do {
+            try {
+                request.setPage(page + "", pageSize + "");
+                JSONObject jsonObject = sendQueryToDms(request);
+                if ("成功".equals(jsonObject.getString("message"))) {
+                    JSONArray content = jsonObject.getJSONArray("content");
+                    if (content.isEmpty()) {
+                        break;
+                    }
+                    for (int i = 0; i < content.size(); i++) {
+                        list.add(content.getJSONObject(i));
+                    }
+                } else {
+                    break;
+                }
+            } catch (Exception e) {
+                break;
+            } finally {
+                page++;
+            }
+        } while (true);
+
+        return list;
+    }
+
+    public List<JSONObject> simpleQuery(String token, String columId) {
+        return queryDmsList(new DMSRequest(), token, columId);
+    }
+
+    public int getLargestCode(String token, String columId, String codeColumn, String today) {
+        DMSRequest request = new DMSRequest();
+        request.addWhere(codeColumn, "2", "%" + today + "%");
+        List<JSONObject> list = null;
+        try {
+            list = queryDmsList(request, token, columId);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("无法获取流水号:无法获取DMS中流水号对应的表。");
+        }
+        String pattern = ".*" + today;
+        int max = 0;
+        for (JSONObject jsonObject : list) {
+            try {
+                int code = Integer.parseInt(jsonObject.get(codeColumn).toString().replaceAll(pattern, ""));
+                if (code > max) {
+                    max = code;
+                }
+            } catch (NumberFormatException e) {
+                e.printStackTrace();
+                throw new RuntimeException("无法获取流水号:出现了未预期的流水号");
+            }
+        }
+        return max;
+    }
+
+    public <T extends FromJSON> List<T> query(String token, DMSQuery query, Class<T> clazz, LocalDate now) {
+        if (query.getResultType() != clazz) {
+            throw new RuntimeException("类型与枚举提供的类型不符,请确认枚举中的类型");
+        }
+        List<JSONObject> dmsResult = queryDmsList(query.preRequest(now), token, query.getColumnId());
+
+        return dmsResult.stream().map(jsonObject -> JSON.toJavaObject(jsonObject, clazz)).collect(Collectors.toList());
+    }
+
+    //下面几个接口是重计算用的,有重新插入的需求,不能放进queryEnum,不能领域化
+    public List<JSONObject> getAllParkByLy(String lyCode,String token) {
+        DMSRequest request = new DMSRequest();
+        request.addWhere("parent_cyy_code", "1", lyCode);
+        return queryDmsList(request, token, DMSColumn.INDUSTRIAL_PARK.getId());
+    }
+
+    public List<JSONObject> getAllPark(String token) {
+        DMSRequest request = new DMSRequest();
+        return queryDmsList(request, token, DMSColumn.INDUSTRIAL_PARK.getId());
+    }
+
+    public List<JSONObject> getAllLeaseByRooms(Set<String> roomString,String token) {
+        DMSRequest request = new DMSRequest();
+        request.addWhere("c_room_code","5",roomString);
+        return queryDmsList(request,token,DMSColumn.LEASE_DETAIL.getId());
+    }
+
+    public List<JSONObject> getAllLease(String token) {
+        DMSRequest request = new DMSRequest();
+        return queryDmsList(request,token,DMSColumn.LEASE_DETAIL.getId());
+    }
+}

+ 0 - 294
src/main/java/com/skyversation/xjcy/service/DMSService.java

@@ -1,294 +0,0 @@
-package com.skyversation.xjcy.service;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.skyversation.xjcy.bean.*;
-import com.skyversation.xjcy.util.HttpUtil;
-import com.skyversation.xjcy.util.SpecialisationStringCollector;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
-import org.springframework.util.StringUtils;
-import org.springframework.web.client.RestClientException;
-
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
-import java.util.*;
-import java.util.stream.Collectors;
-
-@Service
-public class DMSService {
-    @Value("${app.dms.path}")
-    private String path;
-    @Value("${app.oauth.login-name}")
-    private String loginName;
-    @Value("${app.oauth.password}")
-    private String password;
-    @Value("${app.oauth.path}")
-    private String oauthPath;
-
-    @AllArgsConstructor
-    @Getter
-    public enum DMSQuery {
-
-        INDUSTRIAL_PARK("1580", IndustrialPark.class) {
-            @Override
-            public DMSRequest preRequest(LocalDate now) {
-                return new DMSRequest();
-            }
-        },
-        ENTERPRISE("1593", Enterprise.class) {
-            @Override
-            public DMSRequest preRequest(LocalDate now) {
-                return new DMSRequest();
-            }
-        },
-        ECONOMIC_ALL_INDEED("1594", EnterpriseEconomic.class) {
-            @Override
-            public DMSRequest preRequest(LocalDate now) {
-                DMSRequest request = new DMSRequest();
-                Set<String> monthInDeed = new HashSet<>();
-                monthInDeed.addAll(SpecialisationStringCollector.YearMonthByLast12Month(now));
-                monthInDeed.addAll(SpecialisationStringCollector.YearMonthByYtd(now));
-                monthInDeed.addAll(SpecialisationStringCollector.YearMonthByYtd(1, now));
-                request.addWhere("c_year_month", "5", monthInDeed);
-                return request;
-            }
-        },
-        ORDER("1587", Order.class) {
-            @Override
-            public DMSRequest preRequest(LocalDate now) {
-                return new DMSRequest();
-            }
-        },
-        LAST_LEASE_DETAIL("1574", LeaseDetail.class) {
-            @Override
-            public DMSRequest preRequest(LocalDate now) {
-                DMSRequest request = new DMSRequest();
-                request.addWhere("c_is_latest_lease", "1", "2");
-                return request;
-            }
-        },
-        LAST_YEAR_LEASE_DETAIL("1574", LeaseDetail.class) {
-            @Override
-            public DMSRequest preRequest(LocalDate now) {
-                DMSRequest request = new DMSRequest();
-                LocalDate indeedStartTime = now.minusMonths(13).withDayOfMonth(1); // 2024-06-01
-                LocalDate indeedEndTime = now.minusMonths(1)                     // 上个月
-                        .withDayOfMonth(
-                                now.minusMonths(1)
-                                        .lengthOfMonth());
-
-                LocalDate timeOfFarBefore = LocalDate.of(1970, 1, 1);
-                LocalDate timeOfFarAfter = indeedEndTime.plusYears(100);
-                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-                request.addWhere("c_start_date", "3", timeOfFarBefore.format(formatter), indeedEndTime.format(formatter));
-                request.addWhere("c_end_date", "3", indeedStartTime.format(formatter), timeOfFarAfter.format(formatter));
-                return request;
-            }
-        };
-
-        private final String columnId;
-        private final Class<? extends FromJSON> resultType;
-
-        abstract DMSRequest preRequest(LocalDate now);
-
-    }
-
-    private static class DMSRequest {
-        DMSRequestType type;
-        Map<String, String> params = new HashMap<>();
-        String token;
-        JSONArray where = new JSONArray();
-        JSONArray order = new JSONArray();
-
-        private void addWhere(String field, String type, String content) {
-            this.where.add(summonWhere(field, type, content));
-        }
-
-        private void addWhere(String field, String type, Set<String> content) {
-            this.where.add(summonWhere(field, type, content));
-        }
-
-        private JSONObject summonWhere(String field, String type, Object content) {
-            JSONObject where = new JSONObject();
-            where.put("field", field);
-            where.put("searchType", type);
-            JSONObject contents = new JSONObject();
-            contents.put("value", content);
-            where.put("content", contents);
-            return where;
-        }
-
-        private void addWhere(String field, String type, String start, String end) {
-            JSONObject where = new JSONObject();
-            where.put("field", field);
-            where.put("searchType", type);
-            JSONObject contents = new JSONObject();
-            contents.put("start", start);
-            contents.put("end", end);
-            where.put("content", contents);
-            this.where.add(where);
-        }
-
-        private void addOrder(DMSRequest request) {
-
-        }
-
-        private void setPage(String page, String pageSize) {
-            this.params.put("page", page);
-            this.params.put("pageSize", pageSize);
-        }
-
-        private void setState() {
-            this.params.put("states", "0,1,2,3");
-        }
-
-        private void setColumnId(String columnId) {
-            this.params.put("columnId", columnId);
-        }
-    }
-
-    private enum DMSRequestType {
-        List, JOIN_LIST
-    }
-
-    public String loginForToken() throws Exception {
-        if (!StringUtils.hasText(loginName) || !StringUtils.hasText(password)) {
-            throw new Exception("请提供用于访问DMS的账号密码");
-        }
-        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
-        params.add("userName", loginName);
-        params.add("password", password);
-        params.add("clientId", "2");
-        String response = HttpUtil.requestPost(oauthPath, params, new HashMap<>());
-        JSONObject jsonObject = JSON.parseObject(response);
-        if ("密码错误".equals(jsonObject.getString("message"))) {
-            loginName = null;
-            password = null;
-            throw new Exception("请检查使用的账户和密码是否正确,已停止使用该账号密码以避免锁定账号");
-        }
-        if (!Objects.equals(jsonObject.getString("code"), "200")) {
-            throw new Exception(jsonObject.getString("message"));
-        }
-        return jsonObject.getString("message");
-    }
-
-    private JSONObject sendToDms(DMSRequest request, int depth) {
-        JSONObject jsonObject;
-        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
-        request.params.forEach(params::add);
-        params.add("search", request.where.toJSONString());
-        try {
-            String response;
-            switch (request.type) {
-                case List: {
-                    response = HttpUtil.requestPost(path + "/content/selectContentListInfo", params,
-                            Collections.singletonMap("token", request.token));
-                    break;
-                }
-                case JOIN_LIST: {
-                    response = "";
-                    break;
-                }
-                default: {
-                    return null;
-                }
-            }
-            jsonObject = JSON.parseObject(response);
-        } catch (RestClientException e) {
-            if (depth < 3) {
-                return sendToDms(request, depth + 1);
-            }
-            return null;
-        } catch (Exception e) {
-            return null;
-        }
-        if (Objects.equals(jsonObject.getString("message"), "无效token") && depth < 3) {
-            return null;
-        }
-        return jsonObject;
-    }
-
-    private JSONObject sendToDms(DMSRequest request) {
-        return sendToDms(request, 0);
-    }
-
-    private List<JSONObject> queryDmsList(DMSRequest request, String token, String columnId) {
-        request.token = token;
-        request.type = DMSRequestType.List;
-        request.setColumnId(columnId);
-        request.setState();
-        int page = 0;
-        int pageSize = 2000;
-        List<JSONObject> list = new ArrayList<>();
-        do {
-            try {
-                request.setPage(page + "", pageSize + "");
-                JSONObject jsonObject = sendToDms(request);
-                if ("成功".equals(jsonObject.getString("message"))) {
-                    JSONArray content = jsonObject.getJSONArray("content");
-                    if (content.isEmpty()) {
-                        break;
-                    }
-                    for (int i = 0; i < content.size(); i++) {
-                        list.add(content.getJSONObject(i));
-                    }
-                } else {
-                    break;
-                }
-            } catch (Exception e) {
-                break;
-            } finally {
-                page++;
-            }
-        } while (true);
-
-        return list;
-    }
-
-    public List<JSONObject> simpleQuery(String token, String columId) {
-        return queryDmsList(new DMSRequest(), token, columId);
-    }
-
-    public int getLargestCode(String token,String columId,String codeColumn,String today){
-        DMSRequest request = new DMSRequest();
-        request.addWhere(codeColumn,"2","%"+today+"%");
-        List<JSONObject> list = null;
-        try {
-            list = queryDmsList(request,token,columId);
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new RuntimeException("无法获取流水号:无法获取DMS中流水号对应的表。");
-        }
-        String pattern = ".*"+today;
-        int max = 0;
-        for (JSONObject jsonObject : list) {
-            try {
-                int code = Integer.parseInt(jsonObject.get(codeColumn).toString().replaceAll(pattern,""));
-                if (code > max) {
-                    max = code;
-                }
-            } catch (NumberFormatException e) {
-                e.printStackTrace();
-                throw new RuntimeException("无法获取流水号:出现了未预期的流水号");
-            }
-        }
-        return max;
-    }
-
-    public <T extends FromJSON> List<T> query(String token, DMSQuery query, Class<T> clazz, LocalDate now) {
-        if (query.getResultType() != clazz) {
-            throw new RuntimeException("类型与枚举提供的类型不符,请确认枚举中的类型");
-        }
-        List<JSONObject> dmsResult = queryDmsList(query.preRequest(now), token, query.getColumnId());
-
-        return dmsResult.stream().map(jsonObject -> JSON.toJavaObject(jsonObject, clazz)).collect(Collectors.toList());
-    }
-
-
-}

+ 15 - 13
src/main/java/com/skyversation/xjcy/service/DataCountService.java

@@ -3,6 +3,8 @@ package com.skyversation.xjcy.service;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.skyversation.xjcy.bean.*;
+import com.skyversation.xjcy.dms.DMSQuery;
+import com.skyversation.xjcy.dms.DMSService;
 import com.skyversation.xjcy.enums.EnterpriseLevel;
 import com.skyversation.xjcy.util.SpecialisationStringCollector;
 import com.skyversation.xjcy.util.TimeUtil;
@@ -121,12 +123,12 @@ public class DataCountService {
         LocalDate now = LocalDate.now();
 
         //统一查询所有需要的数据避免处理时间太长token过期,数据量大不了所以不做流式
-        List<IndustrialPark> allIndustrialPark = dmsService.query(token, DMSService.DMSQuery.INDUSTRIAL_PARK, IndustrialPark.class, now);
-        List<Enterprise> allEnterprise = dmsService.query(token, DMSService.DMSQuery.ENTERPRISE, Enterprise.class, now);
-        List<EnterpriseEconomic> inDateEnterpriseEconomic = dmsService.query(token, DMSService.DMSQuery.ECONOMIC_ALL_INDEED, EnterpriseEconomic.class, now);
-        List<Order> allOrder = dmsService.query(token, DMSService.DMSQuery.ORDER, Order.class, now);
-        List<LeaseDetail> lastLeaseDetail = dmsService.query(token, DMSService.DMSQuery.LAST_LEASE_DETAIL, LeaseDetail.class, now);
-        List<LeaseDetail> lastYearLease = dmsService.query(token, DMSService.DMSQuery.LAST_YEAR_LEASE_DETAIL, LeaseDetail.class, now);
+        List<IndustrialPark> allIndustrialPark = dmsService.query(token, DMSQuery.INDUSTRIAL_PARK, IndustrialPark.class, now);
+        List<Enterprise> allEnterprise = dmsService.query(token, DMSQuery.ENTERPRISE, Enterprise.class, now);
+        List<EnterpriseEconomic> inDateEnterpriseEconomic = dmsService.query(token, DMSQuery.ECONOMIC_ALL_INDEED, EnterpriseEconomic.class, now);
+        List<Order> allOrder = dmsService.query(token, DMSQuery.ORDER, Order.class, now);
+        List<LeaseDetail> lastLeaseDetail = dmsService.query(token, DMSQuery.LAST_LEASE_DETAIL, LeaseDetail.class, now);
+        List<LeaseDetail> lastYearLease = dmsService.query(token, DMSQuery.LAST_YEAR_LEASE_DETAIL, LeaseDetail.class, now);
         //处理一下拿到的数据,建一建索引
         Map<String, List<EnterpriseEconomic>> enterpriseEconomicMap = new HashMap<>();
         inDateEnterpriseEconomic.forEach(e -> {
@@ -637,22 +639,22 @@ public class DataCountService {
                     roomBuckets.get(vacant).add(room);
                     continue;
                 }
-                if (lease.getCEndDate().isAfter(now) && lease.getCStartDate().isBefore(now)) {
+                if (!lease.getCEndDate().isBefore(now) && !lease.getCEndDate().isAfter(now.plusMonths(3))) {
+                    roomBuckets.get(expiringSoon).add(room);
+                    continue;
+                }
+                if (!lease.getCEndDate().isBefore(now) && !lease.getCStartDate().isAfter(now)) {
                     roomBuckets.get(utilized).add(room);
                     continue;
                 }
-                if (lease.getCStartDate().isAfter(now) && lease.getCEndDate().isAfter(now)) {
+                if (lease.getCStartDate().isAfter(now)) {
                     roomBuckets.get(reserved).add(room);
                     continue;
                 }
-                if (lease.getCEndDate().isBefore(now) && lease.getCEndDate().plusMonths(1).isAfter(now)) {
+                if (!lease.getCEndDate().plusMonths(1).isBefore(now)) {
                     roomBuckets.get(terminated).add(room);
                     continue;
                 }
-                if (lease.getCEndDate().isAfter(now) && lease.getCEndDate().isBefore(now.plusMonths(3))) {
-                    roomBuckets.get(expiringSoon).add(room);
-                    continue;
-                }
                 roomBuckets.get(vacant).add(room);
             }
         }

+ 1 - 0
src/main/java/com/skyversation/xjcy/service/SerialNumberGenerator.java

@@ -1,5 +1,6 @@
 package com.skyversation.xjcy.service;
 
+import com.skyversation.xjcy.dms.DMSService;
 import lombok.Getter;
 import org.springframework.stereotype.Service;