liusheng
2 天以前 1fb7fc160753c4283f7b84c14f931d87b6c922e4
smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -826,6 +826,9 @@
    @Override
    public Boolean addFinshJZInfo(Map dataMap) {
        log.info("ServiceExternalServiceImpl---addFinshJZInfo的新增的值为:{}", dataMap);
        //先对表进行维护
        tableMaintenance();
        Map yeWuXX = (Map) dataMap.get("YeWuXX");
        Map XiaoXiTou = (Map) dataMap.get("XiaoXiTou");
        String FaSongJGID = ObjectUtils.isNotEmpty(XiaoXiTou.get("FaSongJGID")) ? XiaoXiTou.get("FaSongJGID").toString() : null;
@@ -908,10 +911,53 @@
        if (i > 0) {
            return true;
        }
        return false;
    }
    public void tableMaintenance() {
        // 1. 判断表数据量
        int count = patMedOuthospMapper.countPatMedOuthosp();
        if (count > 3000000) {
            // 2. 冷藏表并新建
            String timeSuffix = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
            String oldName = "pat_med_outhosp";
            String newName = oldName + "_" + timeSuffix;
            // 冷藏
            patMedOuthospMapper.renameTable(oldName, newName);
            // 3. 计算所有表的最大id
            List<String> tableNames = patMedOuthospMapper.getAllOuthospTableNames();
            long maxId = 0;
            for (String tableName : tableNames) {
                Long tableMaxId = patMedOuthospMapper.getMaxIdFromTable(tableName);
                if (tableMaxId != null && tableMaxId > maxId) {
                    maxId = tableMaxId;
                }
            }
            // 4. 新建
            patMedOuthospMapper.createPatMedOuthosp(oldName, newName);
            // 5. 设置新表自增起始值
            patMedOuthospMapper.setAutoIncrement(oldName, maxId + 1);
            // 6. 更新/新建视图
            // 重新获取所有表名(包含刚新建的主表)
            List<String> allTables = patMedOuthospMapper.getAllOuthospTableNames();
            StringBuilder sb = new StringBuilder();
            sb.append("CREATE OR REPLACE VIEW v_pat_med_outhosp AS ");
            for (int i = 0; i < allTables.size(); i++) {
                sb.append("SELECT * FROM ").append(allTables.get(i));
                if (i < allTables.size() - 1) {
                    sb.append(" UNION ALL ");
                }
            }
            patMedOuthospMapper.createOrReplaceView(sb.toString());
        }
    }
    @Override
    public Boolean addDiseaseInfo(Map dataMap) {
        log.info("ServiceExternalServiceImpl---addDiseaseInfo的新增的值为:{}", dataMap);