v8:批处理程序

This commit is contained in:
gaoben 2023-10-07 14:30:48 +08:00
parent 9f88bd089c
commit 7ae14cac37
2 changed files with 75 additions and 0 deletions

View File

@ -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

View File

@ -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<SysUserEntity> allSysTenUser = sysUserService.findAllSysTenUser();
for (SysUserEntity sysTenUser : allSysTenUser) {
System.out.println("处理运营商:"+sysTenUser.getUsername()+" tenantId:"+sysTenUser.getTenantId());
List<TenPersonSyncEntity> towList = tenPersonSyncService.findTwo(sysTenUser.getTenantId());
for(TenPersonSyncEntity personEntity: towList){
List<TenPersonSyncEntity> 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("所有数据转换完成。。。。。。。。。。。。");
}
}