承接 nicholasricci/anagrafiche-anpr-istat 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nicholasricci/anagrafiche-anpr-istat

Composer 安装命令:

composer require nicholasricci/anagrafiche-anpr-istat

包简介

Serialized data of ANPRR and ISTAT

README 文档

README

Official Italian Belfiore code list (cadastral code) which represents a comune.

Update

To update the database, you have to clone the project and install the dev-dependencies. Then, the console will be available to download and dump the normalized datasets:

composer install
php -d memory_limit=-1 bin/console update

and you are golden.

Usage

Installation

PHP

composer require nicholasricci/anagrafiche-anpr-istat

Serialized data

You can get the up to date serialized database of comunes and foreign regions in CSV, JSON, XML and YAML inside the dist/ folder in any language.

API

PHP

There is a nicholasricci\AnagraficheANPRISTAT\Collection\ComuneCollection and a nicholasricci\AnagraficheANPRISTAT\BelfioreCode\Collection\RegionCollection to get an ArrayCollection filled with both databases. This enables you to directly iterate through them like an array, or even perform queries of columns.

Querying

You can fetch a comune by its registry_code (also know as cadastral code or belfiore code).

<?php

use nicholasricci\AnagraficheANPRISTAT\Collection\ComuneCollection;
use nicholasricci\AnagraficheANPRISTAT\Collections\Criteria;
use Doctrine\Common\Collections\Expr\Comparison;

$comunes = new ComuneCollection();

$criteria = new Criteria();
$criteria
    ->where(new Comparison('registry_code', Comparison::IS, 'A001'))
;

var_dump($comunes->matching($criteria)));

This would get you a new collection with the matching registry codes. As you can see there is a comune called "ABANO" discontinued in 1924-11-13, and an active comune called "ABANO TERME":

object(nicholasricci\AnagraficheANPRISTAT\Collection\ComuneCollection)#49 (1) {
  ["elements":"Doctrine\Common\Collections\ArrayCollection":private]=>
  array(2) {
    [0]=>
    array(18) {
      ["id"]=>
      string(5) "12560"
      ["institution_date"]=>
      string(10) "1866-11-19"
      ["end_date"]=>
      string(10) "1924-11-13"
      ["istat_id"]=>
      string(6) "028001"
      ["registry_code"]=>
      string(4) "A001"
      ["name_it"]=>
      string(5) "ABANO"
      ["name_transliterated"]=>
      string(5) "ABANO"
      ["alternative_name"]=>
      string(0) ""
      ["alternative_name_transliterated"]=>
      string(0) ""
      ["anpr_id"]=>
      string(2) "28"
      ["istat_province_id"]=>
      string(3) "028"
      ["istat_region_id"]=>
      string(2) "05"
      ["istat_prefecture_id"]=>
      string(0) ""
      ["status"]=>
      string(12) "discontinued"
      ["provincial_code"]=>
      string(2) "PD"
      ["source"]=>
      string(0) ""
      ["last_update"]=>
      string(10) "2016-06-17"
      ["istat_discontinued_code"]=>
      string(6) "028500"
    }
    [1]=>
    array(18) {
      ["id"]=>
      string(1) "1"
      ["institution_date"]=>
      string(10) "1924-11-14"
      ["end_date"]=>
      string(10) "9999-12-31"
      ["istat_id"]=>
      string(6) "028001"
      ["registry_code"]=>
      string(4) "A001"
      ["name_it"]=>
      string(11) "ABANO TERME"
      ["name_transliterated"]=>
      string(11) "ABANO TERME"
      ["alternative_name"]=>
      string(0) ""
      ["alternative_name_transliterated"]=>
      string(0) ""
      ["anpr_id"]=>
      string(2) "28"
      ["istat_province_id"]=>
      string(3) "028"
      ["istat_region_id"]=>
      string(2) "05"
      ["istat_prefecture_id"]=>
      string(2) "PD"
      ["status"]=>
      string(6) "active"
      ["provincial_code"]=>
      string(2) "PD"
      ["source"]=>
      string(0) ""
      ["last_update"]=>
      string(10) "2016-06-17"
      ["istat_discontinued_code"]=>
      string(0) ""
    }
  }
}

You may want to find an active comune by his registry_code. To archieve this, just play with the Doctrine Collections docs

<?php

use nicholasricci\AnagraficheANPRISTAT\Collection\ComuneCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Expr\Comparison;

$comunes = new ComuneCollection();

$criteria = new Criteria();
$criteria
    ->where(new Comparison('registry_code', Comparison::IS, 'A001'))
    ->andWhere(new Comparison('status', Comparison::IS, 'active'))
;

var_dump($comunes->matching($criteria)));

and it will grab for you your desired criteria:

object(nicholasricci\AnagraficheANPRISTAT\Collection\ComuneCollection)#55 (1) {
  ["elements":"Doctrine\Common\Collections\ArrayCollection":private]=>
  array(1) {
    [1]=>
    array(18) {
      ["id"]=>
      string(1) "1"
      ["institution_date"]=>
      string(10) "1924-11-14"
      ["end_date"]=>
      string(10) "9999-12-31"
      ["istat_id"]=>
      string(6) "028001"
      ["registry_code"]=>
      string(4) "A001"
      ["name_it"]=>
      string(11) "ABANO TERME"
      ["name_transliterated"]=>
      string(11) "ABANO TERME"
      ["alternative_name"]=>
      string(0) ""
      ["alternative_name_transliterated"]=>
      string(0) ""
      ["anpr_id"]=>
      string(2) "28"
      ["istat_province_id"]=>
      string(3) "028"
      ["istat_region_id"]=>
      string(2) "05"
      ["istat_prefecture_id"]=>
      string(2) "PD"
      ["status"]=>
      string(6) "active"
      ["provincial_code"]=>
      string(2) "PD"
      ["source"]=>
      string(0) ""
      ["last_update"]=>
      string(10) "2016-06-17"
      ["istat_discontinued_code"]=>
      string(0) ""
    }
  }
}

Ordering

Ordering can be done too through Doctrine Collections. Please refer to their docs to see the available API:

<?php

use nicholasricci\AnagraficheANPRISTAT\Collection\ComuneCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Expr\Comparison;

$comunes = new ComuneCollection();

$criteria = new Criteria();
$criteria->orderBy(['last_update' => Criteria::ASC]);

var_dump($comunes->matching($criteria)));

Attribution

Forked by devnix/belfiore-code,

nicholasricci/anagrafiche-anpr-istat 适用场景与选型建议

nicholasricci/anagrafiche-anpr-istat 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 387 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 08 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nicholasricci/anagrafiche-anpr-istat 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nicholasricci/anagrafiche-anpr-istat 我们能提供哪些服务?
定制开发 / 二次开发

基于 nicholasricci/anagrafiche-anpr-istat 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 387
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 27
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: CC-BY-4.0
  • 更新时间: 2024-08-07