feat(): 添加二级人/车日志记录功能
parent
2b6aeb7685
commit
dd39782668
|
|
@ -23,6 +23,7 @@ import com.zcloud.primeport.plan.mjDevice.dto.OneLevelCarSaveDto;
|
||||||
import com.zcloud.primeport.plan.mjDevice.dto.TwoLevelCar;
|
import com.zcloud.primeport.plan.mjDevice.dto.TwoLevelCar;
|
||||||
import com.zcloud.primeport.plan.mjDevice.dto.TwoLevelUser;
|
import com.zcloud.primeport.plan.mjDevice.dto.TwoLevelUser;
|
||||||
import jodd.util.Base64;
|
import jodd.util.Base64;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -35,6 +36,7 @@ import java.util.stream.Collectors;
|
||||||
* 一级人员门禁对接 前缀
|
* 一级人员门禁对接 前缀
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class TwoCarUtil {
|
public class TwoCarUtil {
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -54,8 +56,11 @@ public class TwoCarUtil {
|
||||||
* */
|
* */
|
||||||
public void scheduledCarCompany() {
|
public void scheduledCarCompany() {
|
||||||
if (!dockFlag.equals(1)) return;
|
if (!dockFlag.equals(1)) return;
|
||||||
|
log.info("定时任务-开始车辆同步");
|
||||||
// 所有今日有效的分公司/相关方二级口门车(car_belong_type IN 1,2,3,5)
|
// 所有今日有效的分公司/相关方二级口门车(car_belong_type IN 1,2,3,5)
|
||||||
List<TwoLevelCar> fgsCarList = closedAreaCarApplyRepository.getFgsCarToDay(null);
|
List<TwoLevelCar> fgsCarList = closedAreaCarApplyRepository.getFgsCarToDay(null);
|
||||||
|
log.info("定时任务-分公司/相关方车辆数:{}", fgsCarList.size());
|
||||||
|
int fgsSuccess = 0, fgsFail = 0;
|
||||||
for (TwoLevelCar twoLevelCar : fgsCarList) {
|
for (TwoLevelCar twoLevelCar : fgsCarList) {
|
||||||
try {
|
try {
|
||||||
HKDeviceUtil.saveOrUpdCar(twoLevelCar.getLicenceNo(), 0);
|
HKDeviceUtil.saveOrUpdCar(twoLevelCar.getLicenceNo(), 0);
|
||||||
|
|
@ -63,12 +68,18 @@ public class TwoCarUtil {
|
||||||
twoLevelCar.getHkIndexCode(), twoLevelCar.getKhParkSysCode(),
|
twoLevelCar.getHkIndexCode(), twoLevelCar.getKhParkSysCode(),
|
||||||
DateUtil.date2Str(new Date(), "yyyy-MM-dd"),
|
DateUtil.date2Str(new Date(), "yyyy-MM-dd"),
|
||||||
DateUtil.date2Str(new Date(), "yyyy-MM-dd"));
|
DateUtil.date2Str(new Date(), "yyyy-MM-dd"));
|
||||||
|
fgsSuccess++;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("二级门禁分公司车辆同步失败, licenceNo=" + twoLevelCar.getLicenceNo() + ", 原因: " + e.getMessage());
|
fgsFail++;
|
||||||
|
log.error("定时任务-分公司车辆同步失败, licenceNo:{}, hkIndexCode:{}, 原因:{}",
|
||||||
|
twoLevelCar.getLicenceNo(), twoLevelCar.getHkIndexCode(), e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.info("定时任务-分公司车辆同步结果, 成功:{}, 失败:{}, 总数:{}", fgsSuccess, fgsFail, fgsCarList.size());
|
||||||
// 所有今日有效的临时二级口门车(car_belong_type = 4)
|
// 所有今日有效的临时二级口门车(car_belong_type = 4)
|
||||||
List<TwoLevelCar> tmpCarList = closedAreaCarApplyRepository.dockTmpCarLevelTwo(null);
|
List<TwoLevelCar> tmpCarList = closedAreaCarApplyRepository.dockTmpCarLevelTwo(null);
|
||||||
|
log.info("定时任务-临时车辆数:{}", tmpCarList.size());
|
||||||
|
int tmpSuccess = 0, tmpFail = 0;
|
||||||
for (TwoLevelCar twoLevelCar : tmpCarList) {
|
for (TwoLevelCar twoLevelCar : tmpCarList) {
|
||||||
try {
|
try {
|
||||||
HKDeviceUtil.saveOrUpdCar(twoLevelCar.getLicenceNo(), 0);
|
HKDeviceUtil.saveOrUpdCar(twoLevelCar.getLicenceNo(), 0);
|
||||||
|
|
@ -76,10 +87,15 @@ public class TwoCarUtil {
|
||||||
twoLevelCar.getHkIndexCode(), twoLevelCar.getKhParkSysCode(),
|
twoLevelCar.getHkIndexCode(), twoLevelCar.getKhParkSysCode(),
|
||||||
DateUtil.date2Str(new Date(), "yyyy-MM-dd"),
|
DateUtil.date2Str(new Date(), "yyyy-MM-dd"),
|
||||||
DateUtil.date2Str(new Date(), "yyyy-MM-dd"));
|
DateUtil.date2Str(new Date(), "yyyy-MM-dd"));
|
||||||
|
tmpSuccess++;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("二级门禁临时车辆同步失败, licenceNo=" + twoLevelCar.getLicenceNo() + ", 原因: " + e.getMessage());
|
tmpFail++;
|
||||||
|
log.error("定时任务-临时车辆同步失败, licenceNo:{}, hkIndexCode:{}, 原因:{}",
|
||||||
|
twoLevelCar.getLicenceNo(), twoLevelCar.getHkIndexCode(), e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.info("定时任务-临时车辆同步结果, 成功:{}, 失败:{}, 总数:{}", tmpSuccess, tmpFail, tmpCarList.size());
|
||||||
|
log.info("定时任务-车辆同步完成, 总计-分公司:{}/{}, 临时:{}/{}", fgsSuccess, fgsFail, tmpSuccess, tmpFail);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
@ -92,16 +108,23 @@ public class TwoCarUtil {
|
||||||
*/
|
*/
|
||||||
public void levelTwoCarCompanyByApplyId(Long applyId) {
|
public void levelTwoCarCompanyByApplyId(Long applyId) {
|
||||||
if (!dockFlag.equals(1)) return;
|
if (!dockFlag.equals(1)) return;
|
||||||
|
log.info("开始审批通过后车辆同步, applyId:{}", applyId);
|
||||||
ClosedAreaCarApplyDO byId = closedAreaCarApplyRepository.getById(applyId);
|
ClosedAreaCarApplyDO byId = closedAreaCarApplyRepository.getById(applyId);
|
||||||
Integer carBelongType = byId.getCarBelongType();
|
Integer carBelongType = byId.getCarBelongType();
|
||||||
|
log.info("车辆同步-车辆信息, applyId:{}, 车牌号:{}, 车辆归属类型:{}, 车辆类型:{}",
|
||||||
|
applyId, byId.getLicenceNo(), carBelongType, byId.getVehicleType());
|
||||||
// 二级门禁(海康)同步 — 所有类型都需要
|
// 二级门禁(海康)同步 — 所有类型都需要
|
||||||
if (carBelongType.equals(4)) {
|
if (carBelongType.equals(4)) {
|
||||||
|
log.info("车辆同步-临时车辆, 开始对接二级门禁(海康), 车牌号:{}", byId.getLicenceNo());
|
||||||
dockTmpCarLevelTwo(byId.getLicenceNo());
|
dockTmpCarLevelTwo(byId.getLicenceNo());
|
||||||
} else {
|
} else {
|
||||||
|
log.info("车辆同步-非临时车辆(carBelongType={}), 开始对接二级门禁(海康), 车牌号:{}",
|
||||||
|
carBelongType, byId.getLicenceNo());
|
||||||
dockFgsCarLevelTwo(byId.getLicenceNo());
|
dockFgsCarLevelTwo(byId.getLicenceNo());
|
||||||
}
|
}
|
||||||
// 一级门禁(车行系统)同步 — 先查vehicle_apply表该车是否有有效权限,没有再新增
|
// 一级门禁(车行系统)同步 — 先查vehicle_apply表该车是否有有效权限,没有再新增
|
||||||
dockOneLevelCar(byId, carBelongType);
|
dockOneLevelCar(byId, carBelongType);
|
||||||
|
log.info("审批通过后车辆同步完成, applyId:{}, 车牌号:{}", applyId, byId.getLicenceNo());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -122,10 +145,12 @@ public class TwoCarUtil {
|
||||||
|
|
||||||
if (!vehicleApplyRepository.list(queryWrapper).isEmpty()) {
|
if (!vehicleApplyRepository.list(queryWrapper).isEmpty()) {
|
||||||
// vehicle_apply已有有效权限 → 不覆盖
|
// vehicle_apply已有有效权限 → 不覆盖
|
||||||
|
log.info("车辆同步-一级门禁(车行)已有有效权限,跳过, 车牌号:{}", byId.getLicenceNo());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 无有效权限 → 走新增逻辑
|
// 无有效权限 → 走新增逻辑
|
||||||
|
log.info("车辆同步-一级门禁(车行)无有效权限,开始新增, 车牌号:{}, carBelongType:{}", byId.getLicenceNo(), carBelongType);
|
||||||
OneLevelCarSaveDto saveDto = new OneLevelCarSaveDto();
|
OneLevelCarSaveDto saveDto = new OneLevelCarSaveDto();
|
||||||
saveDto.setTruckNo(byId.getLicenceNo());
|
saveDto.setTruckNo(byId.getLicenceNo());
|
||||||
saveDto.setTruckCardColor(byId.getLicenceType());
|
saveDto.setTruckCardColor(byId.getLicenceType());
|
||||||
|
|
@ -161,7 +186,10 @@ public class TwoCarUtil {
|
||||||
public void dockFgsCarLevelTwo(String licence_no) {
|
public void dockFgsCarLevelTwo(String licence_no) {
|
||||||
if (!dockFlag.equals(1)) return;
|
if (!dockFlag.equals(1)) return;
|
||||||
List<TwoLevelCar> carList = closedAreaCarApplyRepository.getFgsCarToDay(licence_no);
|
List<TwoLevelCar> carList = closedAreaCarApplyRepository.getFgsCarToDay(licence_no);
|
||||||
|
log.info("车辆同步-分公司车辆, 车牌号:{}, 查询到记录数:{}", licence_no, carList.size());
|
||||||
for (TwoLevelCar twoLevelCar : carList) {
|
for (TwoLevelCar twoLevelCar : carList) {
|
||||||
|
log.info("车辆同步-保存/更新分公司车辆到海康, 车牌号:{}, hkIndexCode:{}, parkSysCode:{}",
|
||||||
|
twoLevelCar.getLicenceNo(), twoLevelCar.getHkIndexCode(), twoLevelCar.getKhParkSysCode());
|
||||||
// todo 车牌号转一下类型
|
// todo 车牌号转一下类型
|
||||||
HKDeviceUtil.saveOrUpdCar(twoLevelCar.getLicenceNo(), 0);
|
HKDeviceUtil.saveOrUpdCar(twoLevelCar.getLicenceNo(), 0);
|
||||||
HKDeviceUtil.vehicleTopUp(twoLevelCar.getLicenceNo(), 0, twoLevelCar.getHkIndexCode(), twoLevelCar.getKhParkSysCode(), DateUtil.date2Str(new Date(), "yyyy-MM-dd"), DateUtil.date2Str(new Date(), "yyyy-MM-dd"));
|
HKDeviceUtil.vehicleTopUp(twoLevelCar.getLicenceNo(), 0, twoLevelCar.getHkIndexCode(), twoLevelCar.getKhParkSysCode(), DateUtil.date2Str(new Date(), "yyyy-MM-dd"), DateUtil.date2Str(new Date(), "yyyy-MM-dd"));
|
||||||
|
|
@ -175,7 +203,10 @@ public class TwoCarUtil {
|
||||||
public void dockTmpCarLevelTwo(String licence_no) {
|
public void dockTmpCarLevelTwo(String licence_no) {
|
||||||
if (!dockFlag.equals(1)) return;
|
if (!dockFlag.equals(1)) return;
|
||||||
List<TwoLevelCar> carList = closedAreaCarApplyRepository.dockTmpCarLevelTwo(licence_no);
|
List<TwoLevelCar> carList = closedAreaCarApplyRepository.dockTmpCarLevelTwo(licence_no);
|
||||||
|
log.info("车辆同步-临时车辆, 车牌号:{}, 查询到记录数:{}", licence_no, carList.size());
|
||||||
for (TwoLevelCar twoLevelCar : carList) {
|
for (TwoLevelCar twoLevelCar : carList) {
|
||||||
|
log.info("车辆同步-保存/更新临时车辆到海康, 车牌号:{}, hkIndexCode:{}, parkSysCode:{}",
|
||||||
|
twoLevelCar.getLicenceNo(), twoLevelCar.getHkIndexCode(), twoLevelCar.getKhParkSysCode());
|
||||||
// todo 车牌号转一下类型
|
// todo 车牌号转一下类型
|
||||||
HKDeviceUtil.saveOrUpdCar(twoLevelCar.getLicenceNo(), 0);
|
HKDeviceUtil.saveOrUpdCar(twoLevelCar.getLicenceNo(), 0);
|
||||||
HKDeviceUtil.vehicleTopUp(twoLevelCar.getLicenceNo(), 0, twoLevelCar.getHkIndexCode(), twoLevelCar.getKhParkSysCode(), DateUtil.date2Str(new Date(), "yyyy-MM-dd"), DateUtil.date2Str(new Date(), "yyyy-MM-dd"));
|
HKDeviceUtil.vehicleTopUp(twoLevelCar.getLicenceNo(), 0, twoLevelCar.getHkIndexCode(), twoLevelCar.getKhParkSysCode(), DateUtil.date2Str(new Date(), "yyyy-MM-dd"), DateUtil.date2Str(new Date(), "yyyy-MM-dd"));
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import com.zcloud.primeport.persistence.repository.XgfApplyPersonRepository;
|
||||||
import com.zcloud.primeport.plan.mjDevice.dto.TwoLevelUser;
|
import com.zcloud.primeport.plan.mjDevice.dto.TwoLevelUser;
|
||||||
import jodd.util.Base64;
|
import jodd.util.Base64;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
@ -31,6 +32,7 @@ import java.util.stream.Collectors;
|
||||||
* 一级人员门禁对接 前缀
|
* 一级人员门禁对接 前缀
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class TwoPersonUtil {
|
public class TwoPersonUtil {
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -56,16 +58,18 @@ public class TwoPersonUtil {
|
||||||
* */
|
* */
|
||||||
public void levelTwoPeopleCompanyByApplyId(Long applyId) {
|
public void levelTwoPeopleCompanyByApplyId(Long applyId) {
|
||||||
if (!dockFlag.equals(1)) return;
|
if (!dockFlag.equals(1)) return;
|
||||||
|
log.info("开始审批通过后人员同步, applyId:{}", applyId);
|
||||||
List<TwoLevelUser> userList = new ArrayList<>();
|
List<TwoLevelUser> userList = new ArrayList<>();
|
||||||
ClosedAreaPersonApplyDO byId = closedAreaPersonApplyRepository.getById(applyId);
|
ClosedAreaPersonApplyDO byId = closedAreaPersonApplyRepository.getById(applyId);
|
||||||
// 查询出来要对接的人
|
// 查询出来要对接的人
|
||||||
if (byId.getPersonBelongType().equals(4)) {
|
if (byId.getPersonBelongType().equals(4)) {
|
||||||
// 临时人员
|
// 临时人员
|
||||||
userList = closedAreaPersonApplyRepository.getDockAuthTmpInfoById(applyId);
|
userList = closedAreaPersonApplyRepository.getDockAuthTmpInfoById(applyId);
|
||||||
|
log.info("查询临时人员列表, applyId:{}, 人数:{}", applyId, userList.size());
|
||||||
} else {
|
} else {
|
||||||
// 非临时人员
|
// 非临时人员
|
||||||
userList = closedAreaPersonApplyRepository.getDockAuthInfoById(applyId);
|
userList = closedAreaPersonApplyRepository.getDockAuthInfoById(applyId);
|
||||||
|
log.info("查询非临时人员列表, applyId:{}, 人数:{}", applyId, userList.size());
|
||||||
}
|
}
|
||||||
dockUserReal(userList);
|
dockUserReal(userList);
|
||||||
// 同步一级门禁(大华) — 先查大华系统是否有已有权限,不覆盖原有权限
|
// 同步一级门禁(大华) — 先查大华系统是否有已有权限,不覆盖原有权限
|
||||||
|
|
@ -73,10 +77,12 @@ public class TwoPersonUtil {
|
||||||
try {
|
try {
|
||||||
dockOneLevelPerson(item.getUserCard(), item.getUserFaceImages(), item.getUserUid(), item.getUserName());
|
dockOneLevelPerson(item.getUserCard(), item.getUserFaceImages(), item.getUserUid(), item.getUserName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error("一级门禁(大华)同步失败, applyId:{}, userCard:{}, userName:{}", applyId,
|
||||||
|
item.getUserCard(), item.getUserName(), e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.info("审批通过后人员同步完成, applyId:{}, 同步人数:{}", applyId, userList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -87,22 +93,35 @@ public class TwoPersonUtil {
|
||||||
if (!dockFlag.equals(1)) return;
|
if (!dockFlag.equals(1)) return;
|
||||||
List<TwoLevelUser> userList = closedAreaPersonApplyRepository.getDockAuthTmpInfoById(null);
|
List<TwoLevelUser> userList = closedAreaPersonApplyRepository.getDockAuthTmpInfoById(null);
|
||||||
userList.addAll(closedAreaPersonApplyRepository.getDockAuthInfoById(null));
|
userList.addAll(closedAreaPersonApplyRepository.getDockAuthInfoById(null));
|
||||||
|
log.info("定时任务-开始人员同步, 总人数:{}", userList.size());
|
||||||
// 二级门禁同步 — 逐个处理,单个失败继续下一个
|
// 二级门禁同步 — 逐个处理,单个失败继续下一个
|
||||||
|
int successCount = 0;
|
||||||
|
int failCount = 0;
|
||||||
for (TwoLevelUser user : userList) {
|
for (TwoLevelUser user : userList) {
|
||||||
try {
|
try {
|
||||||
dockUserReal(Collections.singletonList(user));
|
dockUserReal(Collections.singletonList(user));
|
||||||
|
successCount++;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("二级门禁人员同步失败, userCard=" + user.getUserCard() + ", 原因: " + e.getMessage());
|
failCount++;
|
||||||
|
log.error("定时任务-二级门禁人员同步失败, userCard:{}, userName:{}, 原因:{}",
|
||||||
|
user.getUserCard(), user.getUserName(), e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.info("定时任务-二级门禁人员同步结果, 成功:{}, 失败:{}, 总数:{}", successCount, failCount, userList.size());
|
||||||
// 一级门禁(大华)同步 — 逐个处理,单个失败继续下一个
|
// 一级门禁(大华)同步 — 逐个处理,单个失败继续下一个
|
||||||
|
int dahuaSuccess = 0;
|
||||||
|
int dahuaFail = 0;
|
||||||
for (TwoLevelUser item : userList) {
|
for (TwoLevelUser item : userList) {
|
||||||
try {
|
try {
|
||||||
dockOneLevelPerson(item.getUserCard(), item.getUserFaceImages(), item.getUserUid(), item.getUserName());
|
dockOneLevelPerson(item.getUserCard(), item.getUserFaceImages(), item.getUserUid(), item.getUserName());
|
||||||
|
dahuaSuccess++;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("一级门禁人员同步失败, userCard=" + item.getUserCard() + ", 原因: " + e.getMessage());
|
dahuaFail++;
|
||||||
|
log.error("定时任务-一级门禁人员同步失败, userCard:{}, userName:{}, 原因:{}",
|
||||||
|
item.getUserCard(), item.getUserName(), e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.info("定时任务-一级门禁人员同步结果, 成功:{}, 失败:{}, 总数:{}", dahuaSuccess, dahuaFail, userList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
@ -177,6 +196,7 @@ public class TwoPersonUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void dockUserReal(List<TwoLevelUser> userList) {
|
protected void dockUserReal(List<TwoLevelUser> userList) {
|
||||||
|
log.info("开始二级门禁(海康)人员同步, 总人数:{}", userList.size());
|
||||||
userList.forEach(item -> {
|
userList.forEach(item -> {
|
||||||
List<TwoLevelUser> u = new ArrayList<>();
|
List<TwoLevelUser> u = new ArrayList<>();
|
||||||
List<String> faceUrl = new ArrayList<>();
|
List<String> faceUrl = new ArrayList<>();
|
||||||
|
|
@ -203,15 +223,21 @@ public class TwoPersonUtil {
|
||||||
validUsers.add(itemUser);
|
validUsers.add(itemUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.info("人员同步-人脸数据获取完成, 主用户:{}, 有效用户数(含随行人员):{}/{}, hkIndexCode:{}",
|
||||||
|
item.getUserName(), validUsers.size(), u.size(), item.getHkIndexCode());
|
||||||
|
|
||||||
// 把人同步过去,如存在不做任何操作。
|
// 把人同步过去,如存在不做任何操作。
|
||||||
validUsers.forEach(this::dockLongTermUserAuthLevelTwo);
|
validUsers.forEach(this::dockLongTermUserAuthLevelTwo);
|
||||||
|
|
||||||
// 只有当有有效用户时才进行权限授权
|
// 只有当有有效用户时才进行权限授权
|
||||||
if (!validUsers.isEmpty()) {
|
if (!validUsers.isEmpty()) {
|
||||||
|
log.info("开始人员门禁授权, 人数:{}, 门禁点:{}", validUsers.size(), item.getHkIndexCode());
|
||||||
dockLongAuthTwo(validUsers, Arrays.asList(item.getHkIndexCode().split(",")), DateUtil.date2Str(new Date(), "yyyy-MM-dd"));
|
dockLongAuthTwo(validUsers, Arrays.asList(item.getHkIndexCode().split(",")), DateUtil.date2Str(new Date(), "yyyy-MM-dd"));
|
||||||
|
} else {
|
||||||
|
log.warn("有效用户数为0,跳过门禁授权, 主用户:{}", item.getUserName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
log.info("二级门禁(海康)人员同步完成, 总人数:{}", userList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<TwoLevelUser> getEntourageList(List<String> faceUrl, JSONArray entries, String hkindecodes) {
|
protected List<TwoLevelUser> getEntourageList(List<String> faceUrl, JSONArray entries, String hkindecodes) {
|
||||||
|
|
@ -252,19 +278,26 @@ public class TwoPersonUtil {
|
||||||
*/
|
*/
|
||||||
public void dockLongTermUserAuthLevelTwo(TwoLevelUser towUser) {
|
public void dockLongTermUserAuthLevelTwo(TwoLevelUser towUser) {
|
||||||
if (!dockFlag.equals(1)) return;
|
if (!dockFlag.equals(1)) return;
|
||||||
|
log.info("人员同步-检查海康是否存在, 姓名:{}, 手机号:{}, 身份证:{}", towUser.getUserName(),
|
||||||
|
towUser.getUserPhone(), towUser.getUserCard());
|
||||||
// 按手机号查询
|
// 按手机号查询
|
||||||
JSONObject phoneResult = HKDeviceUtil.getUserListByPhone(Collections.singletonList(towUser.getUserPhone()));
|
JSONObject phoneResult = HKDeviceUtil.getUserListByPhone(Collections.singletonList(towUser.getUserPhone()));
|
||||||
if (!phoneResult.getJSONObject("data").getJSONArray("list").isEmpty()) {
|
if (!phoneResult.getJSONObject("data").getJSONArray("list").isEmpty()) {
|
||||||
// 手机号查到,用户已存在,无需新增
|
// 手机号查到,用户已存在,无需新增
|
||||||
|
log.info("人员同步-手机号查到,用户已存在,跳过新增, 姓名:{}, 手机号:{}", towUser.getUserName(), towUser.getUserPhone());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 手机号查不到,尝试用身份证号(手机号可能变更了,但身份证号不变)
|
// 手机号查不到,尝试用身份证号(手机号可能变更了,但身份证号不变)
|
||||||
JSONObject idCardResult = HKDeviceUtil.getUserListByUserCard(towUser.getUserCard());
|
JSONObject idCardResult = HKDeviceUtil.getUserListByUserCard(towUser.getUserCard());
|
||||||
if (!idCardResult.getJSONObject("data").getJSONArray("list").isEmpty()) {
|
if (!idCardResult.getJSONObject("data").getJSONArray("list").isEmpty()) {
|
||||||
// 身份证查到 -> 用户存在,只是手机号变了,无需新增
|
// 身份证查到 -> 用户存在,只是手机号变了,无需新增
|
||||||
|
log.info("人员同步-身份证查到,用户已存在(手机号可能变更),跳过新增, 姓名:{}, 身份证:{}", towUser.getUserName(), towUser.getUserCard());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 手机号和身份证都查不到 -> 海康无此用户,新增
|
// 手机号和身份证都查不到 -> 海康无此用户,新增
|
||||||
|
log.info("人员同步-海康无此用户,开始新增, 姓名:{}, 手机号:{}, 身份证:{}, 人脸长度:{}",
|
||||||
|
towUser.getUserName(), towUser.getUserPhone(), towUser.getUserCard(),
|
||||||
|
towUser.getUserFaceImagesBase64() != null ? towUser.getUserFaceImagesBase64().length() : 0);
|
||||||
HKDeviceUtil.saveUser(towUser.getUserName(), towUser.getUserCard(), towUser.getUserFaceImagesBase64(), towUser.getUserPhone());
|
HKDeviceUtil.saveUser(towUser.getUserName(), towUser.getUserCard(), towUser.getUserFaceImagesBase64(), towUser.getUserPhone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -282,6 +315,8 @@ public class TwoPersonUtil {
|
||||||
* */
|
* */
|
||||||
public void dockLongAuthTwo(List<TwoLevelUser> userIdList, List<String> resourceInfos, String time) {
|
public void dockLongAuthTwo(List<TwoLevelUser> userIdList, List<String> resourceInfos, String time) {
|
||||||
if (!dockFlag.equals(1)) return;
|
if (!dockFlag.equals(1)) return;
|
||||||
|
log.info("门禁授权-开始, 待授权用户数:{}, 门禁点数:{}, 日期:{}", userIdList.size(),
|
||||||
|
resourceInfos.size(), time);
|
||||||
JSONArray userJsonArray = new JSONArray();
|
JSONArray userJsonArray = new JSONArray();
|
||||||
List<String> phoneList = userIdList.stream().map(TwoLevelUser::getUserPhone).collect(Collectors.toList());
|
List<String> phoneList = userIdList.stream().map(TwoLevelUser::getUserPhone).collect(Collectors.toList());
|
||||||
List<List<String>> partitions = partition(phoneList, 20);
|
List<List<String>> partitions = partition(phoneList, 20);
|
||||||
|
|
@ -297,15 +332,20 @@ public class TwoPersonUtil {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 手机号查不到的用户,用身份证号查(手机号变更后海康仍存旧号,但身份证号不变)
|
// 手机号查不到的用户,用身份证号查(手机号变更后海康仍存旧号,但身份证号不变)
|
||||||
|
int idCardQueryCount = 0;
|
||||||
for (TwoLevelUser user : userIdList) {
|
for (TwoLevelUser user : userIdList) {
|
||||||
if (!foundPhones.contains(user.getUserPhone())) {
|
if (!foundPhones.contains(user.getUserPhone())) {
|
||||||
|
log.info("门禁授权-手机号未查到,用身份证查询, 姓名:{}, 身份证:{}", user.getUserName(), user.getUserCard());
|
||||||
JSONObject result = HKDeviceUtil.getUserListByUserCard(user.getUserCard());
|
JSONObject result = HKDeviceUtil.getUserListByUserCard(user.getUserCard());
|
||||||
JSONArray list = result.getJSONObject("data").getJSONArray("list");
|
JSONArray list = result.getJSONObject("data").getJSONArray("list");
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
userJsonArray.add(list.getJSONObject(i));
|
userJsonArray.add(list.getJSONObject(i));
|
||||||
}
|
}
|
||||||
|
idCardQueryCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.info("门禁授权-用户查询完成, 手机号查到:{}, 身份证补查:{}, 总查到personId数:{}",
|
||||||
|
foundPhones.size(), idCardQueryCount, userJsonArray.size());
|
||||||
ArrayList<JSONObject> objects = new ArrayList<>();
|
ArrayList<JSONObject> objects = new ArrayList<>();
|
||||||
resourceInfos.forEach(item -> {
|
resourceInfos.forEach(item -> {
|
||||||
JSONObject entries = new JSONObject();
|
JSONObject entries = new JSONObject();
|
||||||
|
|
@ -320,9 +360,11 @@ public class TwoPersonUtil {
|
||||||
userIds.add(jsonObject.getStr("personId"));
|
userIds.add(jsonObject.getStr("personId"));
|
||||||
}
|
}
|
||||||
List<List<String>> partitionUserIds = partition(userIds, 1000);
|
List<List<String>> partitionUserIds = partition(userIds, 1000);
|
||||||
|
log.info("门禁授权-分批调用海康授权接口, 批次数:{}", partitionUserIds.size());
|
||||||
partitionUserIds.forEach(itemUserPhones -> {
|
partitionUserIds.forEach(itemUserPhones -> {
|
||||||
HKDeviceUtil.authPersonArea(itemUserPhones, objects, time + "T00:00:00+08:00", time + "T23:59:59+08:00");
|
HKDeviceUtil.authPersonArea(itemUserPhones, objects, time + "T00:00:00+08:00", time + "T23:59:59+08:00");
|
||||||
});
|
});
|
||||||
|
log.info("门禁授权-完成, 授权personId数:{}, 门禁点数:{}", userIds.size(), resourceInfos.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DaHuaDeviceCommon getDaHuaDeviceCommon() {
|
protected DaHuaDeviceCommon getDaHuaDeviceCommon() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue