架构修改

This commit is contained in:
张博 2024-11-12 13:05:13 +08:00
parent 2d69472a04
commit b921b3ce8a
6 changed files with 59 additions and 18 deletions

View File

@ -2,6 +2,7 @@ package net.shapelight.modules.ten.dao;
import net.shapelight.modules.ten.entity.TenPersonSyncEntity; import net.shapelight.modules.ten.entity.TenPersonSyncEntity;
import net.shapelight.modules.vo.TenPersonIdUpdateAllVo; import net.shapelight.modules.vo.TenPersonIdUpdateAllVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -29,8 +30,12 @@ public interface TenPersonSyncDao {
List<TenPersonSyncEntity> findByPersonId(@Param("personId")Long personId, @Param("cellId")Long cellId); List<TenPersonSyncEntity> findByPersonId(@Param("personId")Long personId, @Param("cellId")Long cellId);
@MapKey("deviceSn")
List<Map<String,String>> findGroupDevicePersons(@Param("personIds")List<Long> personIds, @Param("cellId")Long cellId); List<Map<String,String>> findGroupDevicePersons(@Param("personIds")List<Long> personIds, @Param("cellId")Long cellId);
@MapKey("deviceSn")
Map<String,String> findGroupDevicePerson(@Param("personId")Long personId, @Param("cellId")Long cellId);
List<TenPersonSyncEntity> findDeviceAllDeletePersons(@Param("deviceId")Long deviceId,@Param("cellId")Long cellId); List<TenPersonSyncEntity> findDeviceAllDeletePersons(@Param("deviceId")Long deviceId,@Param("cellId")Long cellId);
List<TenPersonSyncEntity> findDeviceAllAddPersons(@Param("deviceId")Long deviceId,@Param("cellId")Long cellId); List<TenPersonSyncEntity> findDeviceAllAddPersons(@Param("deviceId")Long deviceId,@Param("cellId")Long cellId);

View File

@ -34,6 +34,8 @@ public interface TenPersonSyncService {
List<Map<String,String>> findGroupDevicePersons(List<Long> personIds, Long tenantId); List<Map<String,String>> findGroupDevicePersons(List<Long> personIds, Long tenantId);
Map<String,String> findGroupDevicePerson(Long personId, Long tenantId);
List<TenPersonSyncEntity> findDeviceAllDeletePersons(Long deviceId, Long cellId); List<TenPersonSyncEntity> findDeviceAllDeletePersons(Long deviceId, Long cellId);
List<TenPersonSyncEntity> findDeviceAllAddPersons(Long deviceId, Long tenantId); List<TenPersonSyncEntity> findDeviceAllAddPersons(Long deviceId, Long tenantId);

View File

@ -891,7 +891,7 @@ public class TenPersonServiceImpl implements TenPersonService {
//记录所有人员id //记录所有人员id
/*Map<String,Object> personParams = new HashMap<>(); /* Map<String,Object> personParams = new HashMap<>();
personParams.put("operation","delUserData"); personParams.put("operation","delUserData");
personParams.put("accountNumber",globalValue.accountNumber); personParams.put("accountNumber",globalValue.accountNumber);
personParams.put("passKey", KeysEntity.passKey); personParams.put("passKey", KeysEntity.passKey);
@ -909,14 +909,35 @@ public class TenPersonServiceImpl implements TenPersonService {
personIds.add(personId); personIds.add(personId);
} }
}*/ }*/
personIds.add(personId);
tenPersonDao.logicDeleteById(personId, cellId); tenPersonDao.logicDeleteById(personId, cellId);
tenRelationMapper.delete(new LambdaQueryWrapper<TenRelation>().eq(TenRelation::getStudentId,personId)); tenRelationMapper.delete(new LambdaQueryWrapper<TenRelation>().eq(TenRelation::getStudentId,personId));
Map<String, String> snPersons = tenPersonSyncService.findGroupDevicePerson(personId,cellId);
String sn = snPersons.get("deviceSn");
TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
if(deviceEntity==null){
continue;
}
String[] persons = snPersons.get("plist").split(",");
List<TenPersonOperationVo> list = new ArrayList<>();
for (String personStr : persons) {
String[] personInfoStr = personStr.split("_");
Long personCode = Long.parseLong(personInfoStr[0]);
Date lastUpdateTime = DateUtils.stringToDate(personInfoStr[1], DateUtils.DATE_TIME_PATTERN);
TenPersonSyncEntity syncEntity = tenPersonSyncService.findByDeviceIdAndPersonId(deviceEntity.getDeviceId(), personCode, cellId);
syncEntity.setLastUpdateTime(lastUpdateTime);
syncEntity.setState(Constant.PERSON_SYNC_DELETE);
tenPersonSyncService.updateById(syncEntity);
}
} }
//配置同步信息并推送 //配置同步信息并推送
List<Map<String, String>> snPersonsList = tenPersonSyncService.findGroupDevicePersons(personIds, cellId); /*List<Map<String, String>> snPersonsList = tenPersonSyncService.findGroupDevicePersons(personIds, cellId);
for (Map<String, String> snPersons : snPersonsList) { for (Map<String, String> snPersons : snPersonsList) {
String sn = snPersons.get("deviceSn"); String sn = snPersons.get("deviceSn");
TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn); TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
@ -935,7 +956,7 @@ public class TenPersonServiceImpl implements TenPersonService {
syncEntity.setState(Constant.PERSON_SYNC_DELETE); syncEntity.setState(Constant.PERSON_SYNC_DELETE);
tenPersonSyncService.updateById(syncEntity); tenPersonSyncService.updateById(syncEntity);
} }
/*//下发通知 //下发通知
List<TenPersonSyncEntity> allDelete = tenPersonSyncService.findDeviceAllDeletePersons(deviceEntity.getDeviceId(), deviceEntity.getTenantId()); List<TenPersonSyncEntity> allDelete = tenPersonSyncService.findDeviceAllDeletePersons(deviceEntity.getDeviceId(), deviceEntity.getTenantId());
for (TenPersonSyncEntity syncEntity : allDelete) { for (TenPersonSyncEntity syncEntity : allDelete) {
TenPersonOperationVo vo = new TenPersonOperationVo(); TenPersonOperationVo vo = new TenPersonOperationVo();
@ -943,13 +964,13 @@ public class TenPersonServiceImpl implements TenPersonService {
vo.setOperation(Constant.PERSON_SYNC_DELETE); vo.setOperation(Constant.PERSON_SYNC_DELETE);
vo.setLast_update_stamp(syncEntity.getLastUpdateTime()); vo.setLast_update_stamp(syncEntity.getLastUpdateTime());
list.add(vo); list.add(vo);
}*/ }
//int flag = serverApiService.personOperation(sn, list); int flag = serverApiService.personOperation(sn, list);
//下发成功删除状态为删除的同步人员 //下发成功删除状态为删除的同步人员
tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(), cellId); tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(), cellId);
} }*/
return true; return true;
} }

View File

@ -85,6 +85,11 @@ public class TenPersonSyncServiceImpl implements TenPersonSyncService {
return tenPersonSyncDao.findGroupDevicePersons(personIds, cellId); return tenPersonSyncDao.findGroupDevicePersons(personIds, cellId);
} }
@Override
public Map<String, String> findGroupDevicePerson(Long personId, Long cellId) {
return tenPersonSyncDao.findGroupDevicePerson(personId, cellId);
}
@Override @Override
public List<TenPersonSyncEntity> findDeviceAllDeletePersons(Long deviceId, Long cellId) { public List<TenPersonSyncEntity> findDeviceAllDeletePersons(Long deviceId, Long cellId) {
return tenPersonSyncDao.findDeviceAllDeletePersons(deviceId,cellId); return tenPersonSyncDao.findDeviceAllDeletePersons(deviceId,cellId);

View File

@ -83,20 +83,20 @@ global:
db_password: root db_password: root
db_host: localhost db_host: localhost
db_port: 3306 db_port: 3306
# minio:
# endpoint: http://192.168.10.20:9000
# port: 9000
# accessKey: admin
# secretKey: admin@C501
# bucketName: cell
# path: /root/minio/data/cell
minio: minio:
endpoint: https://c.xitu3d.com:19000 endpoint: http://192.168.10.20:9000
port: 19000 port: 9000
accessKey: 7885444af42e4b30c518c5be17c8850b accessKey: admin
secretKey: 0fad3477fb9f60c7be75561db967e8d7 secretKey: admin@C501
bucketName: school bucketName: cell
path: /root/minio/data/cell path: /root/minio/data/cell
# minio:
# endpoint: https://c.xitu3d.com:19000
# port: 19000
# accessKey: 7885444af42e4b30c518c5be17c8850b
# secretKey: 0fad3477fb9f60c7be75561db967e8d7
# bucketName: school
# path: /root/minio/data/cell
device: device:
appId: 8e9b941923abd appId: 8e9b941923abd
appSecret: Mjk0ODIxOTcwMTQ0NjkwNzA1NDE0MzcyNjgxMTQ0MDc0MjE appSecret: Mjk0ODIxOTcwMTQ0NjkwNzA1NDE0MzcyNjgxMTQ0MDc0MjE

View File

@ -172,6 +172,14 @@
GROUP BY device_sn GROUP BY device_sn
</select> </select>
<select id="findGroupDevicePerson" resultType="map">
select device_sn as deviceSn,group_concat(person_id,"_",last_update_time separator ",") as plist
from ten_person_sync_${cellId} where 1= 1
<if test="personIds != null">
and person_id = #{personId}
</if>
</select>
<select id="findDeviceAllDeletePersons" resultType="net.shapelight.modules.ten.entity.TenPersonSyncEntity"> <select id="findDeviceAllDeletePersons" resultType="net.shapelight.modules.ten.entity.TenPersonSyncEntity">
select * from ten_person_sync_${cellId} select * from ten_person_sync_${cellId}
where device_id = #{deviceId} where device_id = #{deviceId}