From 7ae14cac37f1c0c01f9858d6c6beac06df174b77 Mon Sep 17 00:00:00 2001 From: gaoben Date: Sat, 7 Oct 2023 14:30:48 +0800 Subject: [PATCH] =?UTF-8?q?v8:=E6=89=B9=E5=A4=84=E7=90=86=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-dev.yml | 3 + .../src/test/java/gb/SyncBatchAdd.java | 72 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 shapelight-admin/src/test/java/gb/SyncBatchAdd.java diff --git a/shapelight-admin/src/main/resources/application-dev.yml b/shapelight-admin/src/main/resources/application-dev.yml index c51696c..56c8b5d 100644 --- a/shapelight-admin/src/main/resources/application-dev.yml +++ b/shapelight-admin/src/main/resources/application-dev.yml @@ -6,6 +6,9 @@ spring: url: jdbc:mysql://192.168.10.20:3306/cell_db_v8_http_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&rewriteBatchedStatements=true username: user password: user@server001 +# url: jdbc:mysql://39.96.9.232:3306/cell_db_v8_http?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&rewriteBatchedStatements=true +# username: rootuser +# password: xtzg_db_USER@0325 initial-size: 50 max-active: 110 min-idle: 31 diff --git a/shapelight-admin/src/test/java/gb/SyncBatchAdd.java b/shapelight-admin/src/test/java/gb/SyncBatchAdd.java new file mode 100644 index 0000000..f7d5853 --- /dev/null +++ b/shapelight-admin/src/test/java/gb/SyncBatchAdd.java @@ -0,0 +1,72 @@ +package gb; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import lombok.extern.slf4j.Slf4j; +import net.shapelight.AdminApplication; +import net.shapelight.common.utils.SnowflakeIdWorker; +import net.shapelight.common.utils.UUIDUtil; +import net.shapelight.modules.sys.entity.SysUserEntity; +import net.shapelight.modules.sys.service.SysUserService; +import net.shapelight.modules.ten.dao.TenPersonDao; +import net.shapelight.modules.ten.dao.TenRoomDao; +import net.shapelight.modules.ten.entity.*; +import net.shapelight.modules.ten.service.*; +import net.shapelight.modules.vo.TenRoomDeptVo; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@Slf4j +@RunWith(SpringRunner.class) +@SpringBootTest(classes = AdminApplication.class) +public class SyncBatchAdd { + + @Autowired + private TenPersonDao personDao; + @Autowired + private TenPersonService tenPersonService; + @Autowired + private TenPersonSyncService tenPersonSyncService; + @Autowired + private TenRoomService tenRoomService; + @Autowired + private TenRoomDao tenRoomDao; + @Autowired + private TenCellDeptService tenCellDeptService; + @Autowired + private SysUserService sysUserService; + @Autowired + private TenCellService tenCellService; + @Autowired + private TenLabelService tenLabelService; + + /* + select * from ten_person_sync_836271798248013829 where device_id = 326 and person_id = 1145665335953719299 order by last_update_time desc limit 1 +select device_id, person_id, count(*) from ten_person_sync_836271798248013829 group by device_id, person_id having count(*) > 1 +select * from ten_person where person_id = 1144346910165827586 + */ + @Test + public void syncTest() { + List allSysTenUser = sysUserService.findAllSysTenUser(); + for (SysUserEntity sysTenUser : allSysTenUser) { + System.out.println("处理运营商:"+sysTenUser.getUsername()+" tenantId:"+sysTenUser.getTenantId()); + List towList = tenPersonSyncService.findTwo(sysTenUser.getTenantId()); + for(TenPersonSyncEntity personEntity: towList){ + List haveTwo = tenPersonSyncService.findByDeviceIdAndPersonIdList(personEntity.getDeviceId(),personEntity.getPersonId(),sysTenUser.getTenantId()); + if(haveTwo.size()>1){ + TenPersonSyncEntity entity = haveTwo.get(0); + tenPersonSyncService.removeByPersonSyncId(entity.getPersonSyncId(),entity.getTenantId()); + System.out.println("删除同步信息:"+entity.getPersonSyncId()); + } + } + } + System.out.println("所有数据转换完成。。。。。。。。。。。。"); + } +}