|
@@ -13,6 +13,8 @@ import com.usky.sas.domain.SasVillage;
|
|
|
import com.usky.sas.domain.SasEquip;
|
|
import com.usky.sas.domain.SasEquip;
|
|
|
import com.usky.sas.domain.SasEquipCode;
|
|
import com.usky.sas.domain.SasEquipCode;
|
|
|
import com.usky.sas.domain.SasEntrance;
|
|
import com.usky.sas.domain.SasEntrance;
|
|
|
|
|
+import com.usky.sas.domain.SasCredentialTypeCode;
|
|
|
|
|
+import com.usky.sas.domain.SasSystemConfig;
|
|
|
import com.usky.sas.mapper.SasBuildingMapper;
|
|
import com.usky.sas.mapper.SasBuildingMapper;
|
|
|
import com.usky.sas.mapper.SasHouseMapper;
|
|
import com.usky.sas.mapper.SasHouseMapper;
|
|
|
import com.usky.sas.mapper.SasPersonMapper;
|
|
import com.usky.sas.mapper.SasPersonMapper;
|
|
@@ -23,6 +25,8 @@ import com.usky.sas.mapper.SasEquipMapper;
|
|
|
import com.usky.sas.mapper.SasEquipCodeMapper;
|
|
import com.usky.sas.mapper.SasEquipCodeMapper;
|
|
|
import com.usky.sas.mapper.SasEntranceMapper;
|
|
import com.usky.sas.mapper.SasEntranceMapper;
|
|
|
import com.usky.sas.mapper.SasGisMapper;
|
|
import com.usky.sas.mapper.SasGisMapper;
|
|
|
|
|
+import com.usky.sas.mapper.SasCredentialTypeCodeMapper;
|
|
|
|
|
+import com.usky.sas.mapper.SasSystemConfigMapper;
|
|
|
import com.usky.sas.domain.SasGis;
|
|
import com.usky.sas.domain.SasGis;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@@ -38,6 +42,7 @@ import com.usky.sas.service.dto.agbox.BuildingVO;
|
|
|
import com.usky.sas.service.dto.agbox.HouseVo;
|
|
import com.usky.sas.service.dto.agbox.HouseVo;
|
|
|
import com.usky.sas.service.vo.*;
|
|
import com.usky.sas.service.vo.*;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
|
+import cn.hutool.core.util.IdcardUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -91,21 +96,66 @@ public class SasOneStandardSixRealitiesServiceImpl implements SasOneStandardSixR
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SasEntranceMapper sasEntranceMapper;
|
|
private SasEntranceMapper sasEntranceMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SasCredentialTypeCodeMapper sasCredentialTypeCodeMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SasSystemConfigMapper sasSystemConfigMapper;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public CommonPage<PowerListItem> powerPage(OneStandardSixRealitiesPageRequest request) {
|
|
public CommonPage<PowerListItem> powerPage(OneStandardSixRealitiesPageRequest request) {
|
|
|
- IPage<SasPerson> page = new Page<>(request.getCurrent(), request.getSize());
|
|
|
|
|
- LambdaQueryWrapper<SasPerson> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- // 这里简单按 power_code 是否非空作为实有力量筛选,占位实现
|
|
|
|
|
- wrapper.isNotNull(SasPerson::getPowerCode);
|
|
|
|
|
- page = sasPersonMapper.selectPage(page, wrapper);
|
|
|
|
|
- List<SasPerson> records = page.getRecords();
|
|
|
|
|
- if (records == null) {
|
|
|
|
|
- records = Collections.emptyList();
|
|
|
|
|
|
|
+ // 先尝试从 AG 获取实有力量分页,失败或未配置时回退到本地人员表
|
|
|
|
|
+ com.usky.sas.domain.SasConfig config = sasConfigService.getConfig();
|
|
|
|
|
+ if (config == null || config.getKeyds() == null || config.getHost() == null) {
|
|
|
|
|
+ log.debug("实有力量分页:未配置 AG,走本地人员表");
|
|
|
|
|
+ return localPowerPage(request);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String villageCode = request.getVillageCode();
|
|
|
|
|
+ if (villageCode == null || villageCode.isEmpty()) {
|
|
|
|
|
+ villageCode = getVillageCodeForSync();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (villageCode == null || villageCode.isEmpty()) {
|
|
|
|
|
+ log.debug("实有力量分页:无可用地块编码,走本地人员表");
|
|
|
|
|
+ return localPowerPage(request);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int pageNo = request.getCurrent() != null ? request.getCurrent() : 1;
|
|
|
|
|
+ int pageSize = request.getSize() != null ? request.getSize() : 10;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ String baseUrl = buildAgboxBaseUrl(config.getHost(), null);
|
|
|
|
|
+ String villageUrl = baseUrl + AGBOX_VILLAGE_PATH;
|
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
|
+ params.put("page", pageNo);
|
|
|
|
|
+ params.put("pageSize", pageSize);
|
|
|
|
|
+ params.put("code", villageCode);
|
|
|
|
|
+ JsonRpcRequest getPowerJson = new JsonRpcRequest("getPower", params, null);
|
|
|
|
|
+ Map<String, Object> requestBody = new HashMap<>();
|
|
|
|
|
+ requestBody.put("key", config.getKeyds());
|
|
|
|
|
+ requestBody.put("json", JSONUtil.toJsonStr(getPowerJson));
|
|
|
|
|
+ log.info("请求AG实有力量分页(getPower):page={}, pageSize={}, code={}", pageNo, pageSize, villageCode);
|
|
|
|
|
+
|
|
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
+ String resultStr = postWithRetry(villageUrl, requestBody);
|
|
|
|
|
+ PowerVo powerVo = mapper.readValue(resultStr, PowerVo.class);
|
|
|
|
|
+ PowerVo.PowerResult result = powerVo != null ? powerVo.getResult() : null;
|
|
|
|
|
+ List<PowerVo.Power> powerList = (result != null && result.getPowerList() != null)
|
|
|
|
|
+ ? result.getPowerList() : Collections.emptyList();
|
|
|
|
|
+
|
|
|
|
|
+ SasSystemConfig systemConfig = sasSystemConfigMapper.selectOne(new LambdaQueryWrapper<SasSystemConfig>().last("limit 1"));
|
|
|
|
|
+ boolean maskIdCard = systemConfig != null && Boolean.TRUE.equals(systemConfig.getMaskIdCardNo());
|
|
|
|
|
+
|
|
|
|
|
+ List<PowerListItem> list = powerList.stream()
|
|
|
|
|
+ .map(p -> fromPowerToListItem(p, maskIdCard))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ long total = (result != null && result.getCount() != null) ? result.getCount() : 0L;
|
|
|
|
|
+ return new CommonPage<>(list, total, (long) pageNo, (long) pageSize);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("实有力量分页请求 AG 失败,回退本地人员表:{}", e.getMessage());
|
|
|
|
|
+ return localPowerPage(request);
|
|
|
}
|
|
}
|
|
|
- List<PowerListItem> list = records.stream()
|
|
|
|
|
- .map(this::fromPersonToPower)
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
- return new CommonPage<>(list, page.getTotal(), page.getCurrent(), page.getSize());
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1049,6 +1099,11 @@ public class SasOneStandardSixRealitiesServiceImpl implements SasOneStandardSixR
|
|
|
PowerListItem item = new PowerListItem();
|
|
PowerListItem item = new PowerListItem();
|
|
|
item.setPersonCode(p.getPersonCode());
|
|
item.setPersonCode(p.getPersonCode());
|
|
|
item.setName(p.getName());
|
|
item.setName(p.getName());
|
|
|
|
|
+ item.setCredentialType(p.getCredentialType());
|
|
|
|
|
+ item.setCredentialNo(p.getCredentialNo());
|
|
|
|
|
+ item.setPhone1(p.getPhone1());
|
|
|
|
|
+ item.setPhone2(p.getPhone2());
|
|
|
|
|
+ item.setPhone3(p.getPhone3());
|
|
|
item.setPowerCode(p.getPowerCode());
|
|
item.setPowerCode(p.getPowerCode());
|
|
|
item.setPowerName(null);
|
|
item.setPowerName(null);
|
|
|
item.setSecurityCardNo(p.getSecurityCardNo());
|
|
item.setSecurityCardNo(p.getSecurityCardNo());
|
|
@@ -1057,6 +1112,69 @@ public class SasOneStandardSixRealitiesServiceImpl implements SasOneStandardSixR
|
|
|
return item;
|
|
return item;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * AG Power 数据转列表项
|
|
|
|
|
+ */
|
|
|
|
|
+ private PowerListItem fromPowerToListItem(PowerVo.Power power, boolean maskIdCard) {
|
|
|
|
|
+ PowerListItem item = new PowerListItem();
|
|
|
|
|
+ item.setPersonCode(power.getPersonCode());
|
|
|
|
|
+ item.setName(power.getName());
|
|
|
|
|
+ item.setCredentialType(power.getCredentialType());
|
|
|
|
|
+ if (power.getCredentialType() != null) {
|
|
|
|
|
+ SasCredentialTypeCode ct = sasCredentialTypeCodeMapper.selectById(power.getCredentialType());
|
|
|
|
|
+ if (ct != null) {
|
|
|
|
|
+ item.setCredentialTypeName(ct.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (power.getCredentialNo() != null) {
|
|
|
|
|
+ String no = power.getCredentialNo();
|
|
|
|
|
+ if (maskIdCard && no.length() > 8) {
|
|
|
|
|
+ item.setCredentialNo(IdcardUtil.hide(no, 4, no.length() - 4));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ item.setCredentialNo(no);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 电话列表拆分到 phone1/2/3
|
|
|
|
|
+ if (power.getPhone() != null && !power.getPhone().isEmpty()) {
|
|
|
|
|
+ if (power.getPhone().size() >= 1) item.setPhone1(power.getPhone().get(0));
|
|
|
|
|
+ if (power.getPhone().size() >= 2) item.setPhone2(power.getPhone().get(1));
|
|
|
|
|
+ if (power.getPhone().size() >= 3) item.setPhone3(power.getPhone().get(2));
|
|
|
|
|
+ }
|
|
|
|
|
+ item.setPowerCode(power.getPowerCode());
|
|
|
|
|
+ item.setPowerName(null);
|
|
|
|
|
+ item.setSecurityCardNo(power.getSecurityCardNo());
|
|
|
|
|
+ item.setSecurityDutiesCode(power.getSecurityDutiesCode() == null ? null : String.valueOf(power.getSecurityDutiesCode()));
|
|
|
|
|
+ if (power.getUpdateTime() != null && !power.getUpdateTime().isEmpty()) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ item.setUpdateTime(LocalDateTime.parse(
|
|
|
|
|
+ power.getUpdateTime(),
|
|
|
|
|
+ java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
|
+ } catch (Exception ignored) {
|
|
|
|
|
+ // ignore parse error, keep null
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return item;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 本地人员表分页作为回退策略
|
|
|
|
|
+ */
|
|
|
|
|
+ private CommonPage<PowerListItem> localPowerPage(OneStandardSixRealitiesPageRequest request) {
|
|
|
|
|
+ IPage<SasPerson> page = new Page<>(request.getCurrent(), request.getSize());
|
|
|
|
|
+ LambdaQueryWrapper<SasPerson> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ // 这里简单按 power_code 是否非空作为实有力量筛选
|
|
|
|
|
+ wrapper.isNotNull(SasPerson::getPowerCode);
|
|
|
|
|
+ page = sasPersonMapper.selectPage(page, wrapper);
|
|
|
|
|
+ List<SasPerson> records = page.getRecords();
|
|
|
|
|
+ if (records == null) {
|
|
|
|
|
+ records = Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<PowerListItem> list = records.stream()
|
|
|
|
|
+ .map(this::fromPersonToPower)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ return new CommonPage<>(list, page.getTotal(), page.getCurrent(), page.getSize());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private AreaListItem fromBuildingToArea(SasBuilding b) {
|
|
private AreaListItem fromBuildingToArea(SasBuilding b) {
|
|
|
AreaListItem item = new AreaListItem();
|
|
AreaListItem item = new AreaListItem();
|
|
|
item.setBuildingCode(b.getBuildingCode());
|
|
item.setBuildingCode(b.getBuildingCode());
|