|
|
@@ -13,7 +13,6 @@ import com.sptg.common.core.beans.PageBean;
|
|
|
import com.sptg.common.core.beans.ResultBean;
|
|
|
import com.sptg.common.core.beans.ResultEnum;
|
|
|
import com.sptg.common.core.constant.OperationConstant;
|
|
|
-import com.sptg.common.core.constant.UserFlagConstant;
|
|
|
import com.sptg.common.core.entity.DispatchTask;
|
|
|
import com.sptg.common.core.enums.Instruct;
|
|
|
import com.sptg.common.core.enums.InstructDH;
|
|
|
@@ -67,8 +66,6 @@ public class DeviceController implements DeviceFeign {
|
|
|
private final DeviceServiceInterface deviceServiceInterface;
|
|
|
private final ResidentialFeign residentialFeign;
|
|
|
private final DeviceAddProduceInterface deviceAddProduceInterface;
|
|
|
- private final AccessCardPushRecordsFeign accessCardPushRecordsFeign;
|
|
|
- private final AccessFacePushRecordsFeign accessFacePushRecordsFeign;
|
|
|
private final ConfFeign confFeign;
|
|
|
private final RedisTemplate<String, String> redisTemplate;
|
|
|
|
|
|
@@ -807,41 +804,13 @@ public class DeviceController implements DeviceFeign {
|
|
|
map.put("imgSrc",null);
|
|
|
}
|
|
|
if(operType.equals(OperationConstant.ONE)){
|
|
|
- // 获取设备列表
|
|
|
-// deviceList = this.deviceServiceInterface.getListByPathUse(task.getXqId(), task.getUnitId(), DeviceConstants.DEVICE_ACCESS_TYPE_UNIVERSAL);
|
|
|
// 新增下发
|
|
|
map.put("isAdd", "true");
|
|
|
this.msgPublishService.batchPushInstruct(task.getData(),deviceList,Instruct.add_user_face,map);
|
|
|
- }else if(operType.equals(OperationConstant.TWO)){ //更新人脸,只更新已经下发过的设备
|
|
|
- String id = userInfoDto.getId();
|
|
|
- Long userId = Long.parseLong(id.substring(OperationConstant.TWO));
|
|
|
- Integer accessUserType = OperationConstant.ZERO;
|
|
|
- if(id.startsWith(UserFlagConstant.SERVER_USER_NUMBER_FLAG)){
|
|
|
- accessUserType = OperationConstant.FOUR;
|
|
|
- }else if(id.startsWith(UserFlagConstant.USER_NUMBER_FLAG)){
|
|
|
-
|
|
|
- }
|
|
|
- ResultBean<AccessFacePushRecords> resultBean = this.accessFacePushRecordsFeign.getListByUserId(userId, accessUserType, OperationConstant.TWO);
|
|
|
- List<AccessFacePushRecords> pushRecords = resultBean.getList();
|
|
|
- if(pushRecords != null && pushRecords.size() > 0){
|
|
|
- List<Long> deviceIdList = new ArrayList<>();
|
|
|
- pushRecords.forEach(push -> {
|
|
|
- deviceIdList.add(push.getDeviceId());
|
|
|
- });
|
|
|
- Wrapper<Device> wrapper = new EntityWrapper<>();
|
|
|
- wrapper.in("l_id", deviceIdList);
|
|
|
- List<Device> specialDeviceList = this.deviceServiceInterface.selectList(wrapper);
|
|
|
- deviceList.addAll(specialDeviceList);
|
|
|
- }
|
|
|
- map.put("isAdd", "false");
|
|
|
- this.msgPublishService.batchPushInstruct(task.getData(),deviceList,Instruct.add_user_face,map);
|
|
|
+ }else if(operType.equals(OperationConstant.TWO)){
|
|
|
+ //更新人脸
|
|
|
+ this.msgPublishService.batchPushInstruct(task.getData(),deviceList,Instruct.update_user_face,map);
|
|
|
}
|
|
|
-
|
|
|
- /*--------------------------------------------------记录用户人脸授权下发设备记录------------------------------------------*/
|
|
|
- //获取用户
|
|
|
-// User user = this.userFeign.findUserById(Long.parseLong(userInfoDto.getId().substring(OperationConstant.TWO)));
|
|
|
-// this.editAccessFacePushRecords(userInfoDto, operType, deviceList,user.getFaceBeginDate(),user.getFaceEndDate());
|
|
|
- /*---------------------------------------------------------------------------------------------------------------------*/
|
|
|
return new ResultBean<>(ResultEnum.SUCCESS,true);
|
|
|
}
|
|
|
|
|
|
@@ -880,36 +849,7 @@ public class DeviceController implements DeviceFeign {
|
|
|
}else {
|
|
|
map.put("imgSrc",null);
|
|
|
}
|
|
|
-
|
|
|
- String id = userInfoDto.getId();
|
|
|
- Long userId = Long.parseLong(id.substring(OperationConstant.TWO));
|
|
|
- Integer accessUserType = OperationConstant.ZERO;
|
|
|
- if(id.startsWith(UserFlagConstant.SERVER_USER_FLAG)){
|
|
|
- accessUserType = OperationConstant.FOUR;
|
|
|
- }else if(id.startsWith(UserFlagConstant.USER_FLAG)){
|
|
|
-
|
|
|
- }
|
|
|
- ResultBean<AccessFacePushRecords> resultBean = this.accessFacePushRecordsFeign.getListByUserId(userId, accessUserType, OperationConstant.TWO);
|
|
|
- List<AccessFacePushRecords> pushRecords = resultBean.getList();
|
|
|
- if(pushRecords != null && pushRecords.size() > 0){
|
|
|
- List<Long> deviceIdList = new ArrayList<>();
|
|
|
- pushRecords.forEach(push -> {
|
|
|
- deviceIdList.add(push.getDeviceId());
|
|
|
- });
|
|
|
- Wrapper<Device> wrapper = new EntityWrapper<>();
|
|
|
- wrapper.in("l_id", deviceIdList);
|
|
|
- List<Device> specialDeviceList = this.deviceServiceInterface.selectList(wrapper);
|
|
|
- deviceList.addAll(specialDeviceList);
|
|
|
- this.msgPublishService.batchPushInstruct(task.getData(), deviceList, Instruct.delete_user_face,map);
|
|
|
- }else{
|
|
|
- this.msgPublishService.batchPushInstruct(task.getData(), deviceList, Instruct.delete_user_face,map);
|
|
|
- }
|
|
|
-
|
|
|
- /*--------------------------------------------------记录用户人脸授权下发设备记录------------------------------------------*/
|
|
|
- //获取用户
|
|
|
-// User user = this.userFeign.findUserById(Long.parseLong(userInfoDto.getId().substring(OperationConstant.TWO)));
|
|
|
-// this.editAccessFacePushRecords(userInfoDto, operType, deviceList,user.getFaceBeginDate(),user.getFaceEndDate());
|
|
|
- /*---------------------------------------------------------------------------------------------------------------------*/
|
|
|
+ this.msgPublishService.batchPushInstruct(task.getData(), deviceList, Instruct.delete_user_face,map);
|
|
|
return new ResultBean<>(ResultEnum.SUCCESS,true);
|
|
|
}
|
|
|
|
|
|
@@ -933,87 +873,9 @@ public class DeviceController implements DeviceFeign {
|
|
|
}else{
|
|
|
this.msgPublishService.batchPushInstruct(task.getData(),deviceList,Instruct.add_user_face,map);
|
|
|
}
|
|
|
- /*--------------------------------------------------记录用户人脸授权下发设备记录------------------------------------------*/
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
- UserInfoDto userInfoDto = objectMapper.convertValue(task.getData(), UserInfoDto.class);
|
|
|
- if(task.getOperType() != null){
|
|
|
- this.editAccessFacePushRecords(userInfoDto, task.getOperType(), deviceList, task.getBeginDate(), task.getEndDate());
|
|
|
- }
|
|
|
- /*---------------------------------------------------------------------------------------------------------------------*/
|
|
|
return new ResultBean<>(ResultEnum.SUCCESS,true);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 编辑用户人脸下发到特殊设备记录
|
|
|
- * @param dto
|
|
|
- * @param operType
|
|
|
- * @param deviceList
|
|
|
- */
|
|
|
- private void editAccessFacePushRecords(UserInfoDto dto, Integer operType, List<Device> deviceList, Date beginDate, Date endDate){
|
|
|
- String id = dto.getId(); //u_120000,s_12000等,表示用户ID,前缀表示用户类型
|
|
|
- AccessFacePushRecordsDto recordsDto = new AccessFacePushRecordsDto();
|
|
|
- Long userId = Long.parseLong(id.substring(OperationConstant.TWO));
|
|
|
- recordsDto.setUserId(Long.parseLong(id.substring(OperationConstant.TWO)));
|
|
|
- //设置人脸有效期 如果是禁用,则不改变有效时间
|
|
|
- recordsDto.setBeginDate(beginDate);
|
|
|
- recordsDto.setEndDate(endDate);
|
|
|
-
|
|
|
- Map<String, Object> face = null;
|
|
|
- if(!operType.equals(OperationConstant.THREE)){
|
|
|
- face = dto.getFaceCodeList().get(0);
|
|
|
- recordsDto.setFaceUri((String)face.get("imgSrc"));
|
|
|
- }
|
|
|
- Integer accessUserType = OperationConstant.ZERO;
|
|
|
- if(id.startsWith(UserFlagConstant.SERVER_USER_FLAG)){
|
|
|
- recordsDto.setAccessUserType(OperationConstant.FOUR); //服务人员
|
|
|
- accessUserType = OperationConstant.FOUR;
|
|
|
- }else if(id.startsWith(UserFlagConstant.USER_FLAG)){
|
|
|
- recordsDto.setAccessUserType(OperationConstant.ZERO); //住户
|
|
|
- }
|
|
|
- if(operType.equals(OperationConstant.ONE)){ //新增门禁卡到设备
|
|
|
- List<Long> deviceIdList = new ArrayList<>();
|
|
|
- deviceList.forEach(device -> {
|
|
|
- deviceIdList.add(device.getId());
|
|
|
- });
|
|
|
- recordsDto.setDeviceIdList(deviceIdList);
|
|
|
- recordsDto.setEnable(OperationConstant.ONE);
|
|
|
- recordsDto.setSendDeviceType(OperationConstant.TWO);
|
|
|
- this.accessFacePushRecordsFeign.addAccessFacePushRecordsByDevices(recordsDto);
|
|
|
- }else if(operType.equals(OperationConstant.TWO)){ //更新门禁卡到设备
|
|
|
-// List<Long> addDeviceIdList = new ArrayList<>();
|
|
|
-// ResultBean<AccessFacePushRecords> resultBean = accessFacePushRecordsFeign.getListByUserId(userId, accessUserType, null);
|
|
|
-// List<AccessFacePushRecords> pushRecords = resultBean.getList();
|
|
|
-// if(pushRecords != null && pushRecords.size() > 0){
|
|
|
-//
|
|
|
-// }
|
|
|
-// List<Long> hadPushDeviceIdList = new ArrayList<>();
|
|
|
-// resultBean.getList().forEach(push -> {
|
|
|
-// hadPushDeviceIdList.add(push.getDeviceId());
|
|
|
-// });
|
|
|
-// List<Long> deviceIdList = new ArrayList<>();
|
|
|
-// deviceList.forEach(device -> {
|
|
|
-// deviceIdList.add(device.getId());
|
|
|
-// });
|
|
|
-// deviceIdList.forEach(deviceId ->{
|
|
|
-// if(hadPushDeviceIdList.contains(deviceId)){
|
|
|
-//
|
|
|
-// }else{
|
|
|
-// addDeviceIdList.add(deviceId);
|
|
|
-// }
|
|
|
-// } );
|
|
|
-// recordsDto.setEnable(OperationConstant.ONE);
|
|
|
-// this.accessFacePushRecordsFeign.updateAccessFacePushRecords(recordsDto);
|
|
|
-// if(addDeviceIdList.size() > 0){
|
|
|
-// recordsDto.setDeviceIdList(addDeviceIdList);
|
|
|
-// this.accessFacePushRecordsFeign.addAccessFacePushRecordsByDevices(recordsDto);
|
|
|
-// }
|
|
|
- }else if(operType.equals(OperationConstant.THREE)){ //删除或者禁用了
|
|
|
-// recordsDto.setEnable(OperationConstant.TWO);
|
|
|
- this.accessFacePushRecordsFeign.deleteAccessFacePushRecords(recordsDto);
|
|
|
-// this.accessFacePushRecordsFeign.updateAccessFacePushRecords(recordsDto);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
@PostMapping(value = "/device/manualPushUserCardToDevices")
|
|
|
public ResultBean<Boolean> manualPushUserCardToDevices(@RequestBody ManualPushDevicesTask task) {
|
|
|
@@ -1029,13 +891,6 @@ public class DeviceController implements DeviceFeign {
|
|
|
}else{
|
|
|
this.msgPublishService.batchPushInstruct(task.getData(),deviceList,Instruct.del_open_door_card,map);
|
|
|
}
|
|
|
- /*--------------------------------------------------记录用户门禁卡授权下发设备记录------------------------------------------*/
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
- AccessCardDto accessCardDto = objectMapper.convertValue(task.getData(), AccessCardDto.class);
|
|
|
- if(task.getOperType() != null){
|
|
|
- this.editAccessCardPushRecords(accessCardDto, task.getOperType(), deviceList,task.getBeginDate(),task.getEndDate());
|
|
|
- }
|
|
|
- /*---------------------------------------------------------------------------------------------------------------------*/
|
|
|
return new ResultBean<>(ResultEnum.SUCCESS,true);
|
|
|
}
|
|
|
|
|
|
@@ -1238,30 +1093,9 @@ public class DeviceController implements DeviceFeign {
|
|
|
}
|
|
|
if(operType.equals(OperationConstant.ONE)){ //新增下发门禁卡到通用设备
|
|
|
this.msgPublishService.batchPushInstruct(task.getData(),deviceList,Instruct.add_open_door_card,map);
|
|
|
- }else if(operType.equals(OperationConstant.TWO)){ //更新下发门禁卡到以下发过的设备
|
|
|
- //是否有下发过特殊设备
|
|
|
- ResultBean<AccessCardPushRecords> resultBean = this.accessCardPushRecordsFeign.getListByUserId(Long.parseLong(accessCardDto.getUserId()), accessCardDto.getType(), OperationConstant.TWO);
|
|
|
- List<AccessCardPushRecords> pushRecords = resultBean.getList();
|
|
|
- if(pushRecords != null && pushRecords.size() > 0){
|
|
|
- List<Long> deviceIdList = new ArrayList<>();
|
|
|
- pushRecords.forEach(push -> {
|
|
|
- deviceIdList.add(push.getDeviceId());
|
|
|
- });
|
|
|
- Wrapper<Device> wrapper = new EntityWrapper<>();
|
|
|
- wrapper.in("l_id", deviceIdList);
|
|
|
- List<Device> specialDeviceList = this.deviceServiceInterface.selectList(wrapper);
|
|
|
- //如果有特殊设备则增加特殊设备
|
|
|
- if (specialDeviceList != null && specialDeviceList.size() >0){
|
|
|
- deviceList.addAll(specialDeviceList);
|
|
|
- }
|
|
|
- }
|
|
|
+ }else if(operType.equals(OperationConstant.TWO)){ //更新下发门禁卡到通用设备
|
|
|
this.msgPublishService.batchPushInstruct(task.getData(),deviceList,Instruct.add_open_door_card,map);
|
|
|
}
|
|
|
- /*--------------------------------------------------记录用户门禁卡授权下发设备记录------------------------------------------*/
|
|
|
- /*if(StringUtils.hasText(accessCardDto.getUserId())){ //如果是不记名门禁卡下发,就不记录用户下发门禁卡记录了
|
|
|
- this.editAccessCardPushRecords(accessCardDto, operType, deviceList,accessCardDto.getBeginDate(),accessCardDto.getEndDate());
|
|
|
- }*/
|
|
|
- /*---------------------------------------------------------------------------------------------------------------------*/
|
|
|
return new ResultBean<>(ResultEnum.SUCCESS,true);
|
|
|
}
|
|
|
|
|
|
@@ -1277,59 +1111,6 @@ public class DeviceController implements DeviceFeign {
|
|
|
return resultBean;
|
|
|
}
|
|
|
|
|
|
- private void editAccessCardPushRecords(AccessCardDto accessCardDto, Integer operType, List<Device> deviceList,Date beginDate, Date endDate){
|
|
|
- AccessCardPushRecordsDto recordsDto = new AccessCardPushRecordsDto();
|
|
|
- Long userId = Long.parseLong(accessCardDto.getUserId());
|
|
|
- recordsDto.setUserId(userId);
|
|
|
- recordsDto.setCardNo(accessCardDto.getCardNo());
|
|
|
- recordsDto.setBeginDate(beginDate);
|
|
|
- recordsDto.setEndDate(endDate);
|
|
|
- Integer accessUserType = OperationConstant.ZERO;
|
|
|
- if(accessCardDto.getType().equals(OperationConstant.FOUR)){
|
|
|
- recordsDto.setAccessUserType(OperationConstant.FOUR); //服务人员
|
|
|
- accessUserType = OperationConstant.FOUR;
|
|
|
- }else if(accessCardDto.getType().equals(OperationConstant.ZERO)){
|
|
|
- recordsDto.setAccessUserType(OperationConstant.ZERO); //住户
|
|
|
- }
|
|
|
- if(operType.equals(OperationConstant.ONE)){ //新增门禁卡到设备
|
|
|
- List<Long> deviceIdList = new ArrayList<>();
|
|
|
- deviceList.forEach(device -> {
|
|
|
- deviceIdList.add(device.getId());
|
|
|
- });
|
|
|
- recordsDto.setDeviceIdList(deviceIdList);
|
|
|
- recordsDto.setEnable(OperationConstant.ONE);
|
|
|
- recordsDto.setSendDeviceType(OperationConstant.TWO);
|
|
|
- this.accessCardPushRecordsFeign.addAccessCardPushRecordsByDevices(recordsDto);
|
|
|
- }else if(operType.equals(OperationConstant.TWO)){ //更新门禁卡到设备
|
|
|
-// List<Long> addDeviceIdList = new ArrayList<>();
|
|
|
-// ResultBean<AccessCardPushRecords> resultBean = accessCardPushRecordsFeign.getListByUserId(userId, accessUserType, null);
|
|
|
-// List<Long> hadPushDeviceIdList = new ArrayList<>();
|
|
|
-// resultBean.getList().forEach(push -> {
|
|
|
-// hadPushDeviceIdList.add(push.getDeviceId());
|
|
|
-// });
|
|
|
-// List<Long> deviceIdList = new ArrayList<>();
|
|
|
-// deviceList.forEach(device -> {
|
|
|
-// deviceIdList.add(device.getId());
|
|
|
-// });
|
|
|
-// deviceIdList.forEach(deviceId ->{
|
|
|
-// if(hadPushDeviceIdList.contains(deviceId)){
|
|
|
-//
|
|
|
-// }else{
|
|
|
-// addDeviceIdList.add(deviceId);
|
|
|
-// }
|
|
|
-// } );
|
|
|
-// recordsDto.setEnable(OperationConstant.ONE);
|
|
|
-// this.accessCardPushRecordsFeign.updateAccessCardPushRecords(recordsDto);
|
|
|
-// if(addDeviceIdList.size() > 0){
|
|
|
-// recordsDto.setDeviceIdList(addDeviceIdList);
|
|
|
-// this.accessCardPushRecordsFeign.addAccessCardPushRecordsByDevices(recordsDto);
|
|
|
-// }
|
|
|
- }else if(operType.equals(OperationConstant.THREE)){ //删除或者禁用门禁卡了,仅设置禁用状态
|
|
|
-// recordsDto.setEnable(OperationConstant.TWO);
|
|
|
- this.accessCardPushRecordsFeign.deleteAccessCardPushRecords(recordsDto);
|
|
|
-// this.accessCardPushRecordsFeign.updateAccessCardPushRecords(recordsDto);
|
|
|
- }
|
|
|
- }
|
|
|
@Override
|
|
|
@PostMapping(value = "/device/removeCard")
|
|
|
public ResultBean<Boolean> removeCard(@RequestBody DispatchTask task) {
|
|
|
@@ -1396,28 +1177,8 @@ public class DeviceController implements DeviceFeign {
|
|
|
map.put("endTime",null);
|
|
|
}
|
|
|
if(accessCardDto.getUserId() != null){
|
|
|
- ResultBean<AccessCardPushRecords> pushResult = this.accessCardPushRecordsFeign.getListByUserId(Long.parseLong(accessCardDto.getUserId()), accessCardDto.getType(), null);
|
|
|
- List<AccessCardPushRecords> list = pushResult.getList();
|
|
|
- List<Device> hadPushDevices = null;
|
|
|
- if(list != null && list.size() > 0){ //如果有下发记录,就按照下发的记录进行删除或者禁用
|
|
|
- List<Long> deviceIdList = new ArrayList<>();
|
|
|
- list.forEach(push -> {
|
|
|
- deviceIdList.add(push.getDeviceId());
|
|
|
- });
|
|
|
- hadPushDevices = this.deviceServiceInterface.selectBatchIds(deviceIdList);
|
|
|
- if(hadPushDevices != null && hadPushDevices.size() > 0){
|
|
|
- deviceList.addAll(hadPushDevices);
|
|
|
- }
|
|
|
- this.msgPublishService.batchPushInstruct(task.getData(),deviceList,Instruct.del_open_door_card,map);
|
|
|
- AccessCardPushRecordsDto recordsDto = new AccessCardPushRecordsDto();
|
|
|
- recordsDto.setUserId(Long.parseLong(accessCardDto.getUserId()));
|
|
|
- recordsDto.setAccessUserType(accessCardDto.getType());
|
|
|
- this.accessCardPushRecordsFeign.deleteAccessCardPushRecords(recordsDto);
|
|
|
- return new ResultBean<>(ResultEnum.SUCCESS,true);
|
|
|
- }else{ //否则全部删除或者禁用
|
|
|
- this.msgPublishService.batchPushInstruct(task.getData(),deviceList,Instruct.del_open_door_card,map);
|
|
|
- return new ResultBean<>(ResultEnum.SUCCESS,true);
|
|
|
- }
|
|
|
+ this.msgPublishService.batchPushInstruct(task.getData(),deviceList,Instruct.del_open_door_card,map);
|
|
|
+ return new ResultBean<>(ResultEnum.SUCCESS,true);
|
|
|
}else{
|
|
|
this.msgPublishService.batchPushInstruct(task.getData(),deviceList,Instruct.del_open_door_card,map);
|
|
|
return new ResultBean<>(ResultEnum.SUCCESS,true);
|