12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package entity
- import (
- "log"
- . "online_datasync/config"
- . "online_datasync/db"
- . "app.yhyue.com/moapp/jybase/common"
- )
- var (
- Raw_product *raw_product
- )
- type raw_product struct {
- }
- func (r *raw_product) TableName() string {
- return "raw_product"
- }
- //
- func (r *raw_product) SaveFields() []string {
- return []string{"id", "product_name", "product_code", "parent_code", "level", "product_cost_type"}
- }
- //
- func (r *raw_product) Run(start_unix, end_unix int64, start_layout, end_layout string) {
- log.Println("开始同步", r.TableName(), "表。。。")
- index := 0
- array := []interface{}{}
- Mysql_From_Jyactivities.SelectByBath(Config.SelectBathSize, func(l *[]map[string]interface{}) {
- for _, v := range *l {
- index++
- TimeTask.Raw_product_id = Int64All(v["id"])
- array = append(array, v["id"], v["productName"], v["productCode"], v["parentCode"], 1, 1)
- if index%Config.InsertBathSize == 0 {
- log.Println("同步", r.TableName(), "表", index)
- Mysql_Main.InsertIgnoreBatch(r.TableName(), r.SaveFields(), array)
- array = []interface{}{}
- }
- }
- }, `select id,productName,productCode,parentCode from product where id>? order by id`, TimeTask.Raw_product_id)
- if len(array) > 0 {
- Mysql_Main.InsertIgnoreBatch(r.TableName(), r.SaveFields(), array)
- array = []interface{}{}
- }
- log.Println("同步", r.TableName(), "表结束。。。", index)
- }
|