smartor/src/main/java/com/smartor/mapper/PatMedOuthospMapper.java
@@ -92,6 +92,8 @@ */ void createPatMedOuthosp(@Param("templateName") String templateName, @Param("newName") String newName); void createPatMedOuthospAutoAdd(@Param("newName") String newName); void setAutoIncrement(@Param("tableName") String tableName, @Param("autoInc") long autoInc); smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -920,7 +920,7 @@ int count = patMedOuthospMapper.countPatMedOuthosp(); if (count > 3000000) { // 2. 冷藏表并新建 String timeSuffix = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); String timeSuffix = new SimpleDateFormat("yyyyMM").format(new Date()); String oldName = "pat_med_outhosp"; String newName = oldName + "_" + timeSuffix; @@ -937,9 +937,10 @@ } } // 4. 新建 patMedOuthospMapper.createPatMedOuthosp(oldName, newName); // 4. 新建(此时只剩冷表,PatMedOuthosp没了,需要新建一个) patMedOuthospMapper.createPatMedOuthosp(newName, oldName); //设置新表自增主键 patMedOuthospMapper.createPatMedOuthospAutoAdd(oldName); // 5. 设置新表自增起始值 patMedOuthospMapper.setAutoIncrement(oldName, maxId + 1); smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml
@@ -382,6 +382,10 @@ CREATE TABLE ${newName} LIKE ${templateName} </update> <update id="createPatMedOuthospAutoAdd"> ALTER TABLE ${newName} MODIFY COLUMN id BIGINT NOT NULL AUTO_INCREMENT; </update> <update id="setAutoIncrement"> ALTER TABLE ${tableName} AUTO_INCREMENT = #{autoInc} </update>