target

package
v0.0.0-...-1aeafd4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2023 License: MIT Imports: 25 Imported by: 0

README

(可选操作)如果远程服务器在插入数据的过程中,屡次出现主键冲突的问题,则需要对本地爬虫服务器和远程数据库服务器做同步操作

第一步、从远程数据库服务器查询所有历史记录,保存到自己电脑,IDE默认另存为t_dmaa_base_target_value.csv

SELECT TARGET_CODE, REGION_CODE, ACCT_YEAR, ACCT_QUARTOR, ACCT_MONTH, ACCT_DATE FROM t_dmaa_base_target_value;

第二步、计算每一条记录的md5值,代码参考target/pkg/synchronous/synchronous.go

Documentation

Index

Constants

View Source
const (
	SheetName  = "Sheet1"
	ConfigFile = "诚通指标配置.xlsx"
)
View Source
const RunInterval = time.Minute * 30

RunInterval 默认每隔半小时跑一次

View Source
const WebService = "http://106.37.165.121/inf/chengtong/py/sy/baseTargetValue/saveRequest"

WebService 远程数据库服务器接口

Variables

This section is empty.

Functions

func Generator

func Generator(ec ExcelConfig, responses []model.Response, targetValueCut bool) (data []model.DataBase)

Generator 数据生成器,将配置文件数据和爬虫数据组合在一起 ec:每个指标的配置 responses:每个指标爬取的数据 targetValueCut:指标值是否要切分 - 如汇率、股票等数据,因为指标值包含最高、最低、开盘、收盘、涨幅等多个值,故多个值以逗号分隔当作一体发送给Java服务器 - 如GDP、CPI等数据,因为指标值只包含一个值

func NewTarget

func NewTarget()

NewTarget 新建指标爬虫任务

func NewTargetSelenium

func NewTargetSelenium()

NewTargetSelenium 新建指标爬虫任务

func RunTarget

func RunTarget()

func RunTargetSelenium

func RunTargetSelenium()

Types

type ExcelConfig

type ExcelConfig struct {
	Enable                 bool   // 是否启用
	TargetCode             string // 指标编码
	TargetName             string // 指标名称
	TargetNameSpider       string // 指标名称_爬虫程序
	TargetNameEn           string // 指标名称英文
	DataSourceCode         string // 数据源代码
	DataSourceName         string // 数据源名称
	SourceTargetCodeSpider string // 来源系统指标编号_爬虫程序
	SourceTargetCode       string // 来源系统指标编号
	IsQuantity             string // 是否定量
	UnitType               string // 计量单位类型
	UnitName               string // 计量单位名称
	PeriodType             string // 指标期间类型
	PeriodName             string // 指标期间名称
	SpiderTime             string // 爬虫时间
	Adapter                string // 适配
}

ExcelConfig Excel配置

func ExcelSetUp

func ExcelSetUp() []ExcelConfig

ExcelSetUp Excel初始化

type RemoteServerResponse

type RemoteServerResponse struct {
	Flag     bool   `json:"flag"`
	Status   bool   `json:"status"`
	TipsCode string `json:"tipsCode"`
	Msg      string `json:"msg"`
	PkID     string `json:"pkId"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL