package canal import ( "fmt" "github.com/go-mysql-org/go-mysql/canal" "proxy/logger" . "proxy/MsgDef" "strconv" ) func getAcctInfoColumns(c *RecordChange, bB bool, bA bool, beC []interface{}, afC []interface{}, e *canal.RowsEvent) { var chg ChgAcctInfo var str string if bB { //beC := rowData.GetBeforeColumns() for index, column := range e.Table.Columns { switch column.Name { case "PRD_INST_STAS_ID": str = fmt.Sprintf("%v", beC[index]) chg.OldPrdInstStasId = str case "PRD_INST_ID": str = fmt.Sprintf("%v", beC[index]) chg.PrdInstId, _ = strconv.Atoi(str) case "SERVICE_NBR": chg.ServiceNbr = fmt.Sprintf("%v", beC[index]) case "IF_PREPAY": chg.IfPrepaid = fmt.Sprintf("%v", beC[index]) } } } if bA { //afC := rowData.GetAfterColumns() for index, column := range e.Table.Columns { switch column.Name { case "PRD_INST_STAS_ID": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldPrdInstStasId { chg.BUpdate = true } chg.NewPrdInstStasId = str case "PRD_INST_ID": str = fmt.Sprintf("%v", afC[index]) chg.PrdInstId, _ = strconv.Atoi(str) case "SERVICE_NBR": chg.ServiceNbr = fmt.Sprintf("%v", afC[index]) case "IF_PREPAY": chg.IfPrepaid = fmt.Sprintf("%v", afC[index]) } } } switch c.EventType { case canal.InsertAction: if chg.IfPrepaid != "1" || chg.NewPrdInstStasId != "1001" { } else { c.ChgAcctInfo = append(c.ChgAcctInfo, chg) logger.CanalLog.Infof("insert into prd_prd_inst_551: [%#v]", chg) } case canal.DeleteAction: if chg.IfPrepaid != "1" || chg.OldPrdInstStasId != "1001" { } else { c.ChgAcctInfo = append(c.ChgAcctInfo, chg) logger.CanalLog.Infof("delete from prd_prd_inst_551: [%#v]", chg) } default: if chg.IfPrepaid != "1" || !chg.BUpdate { } else { if chg.OldPrdInstStasId == "1001" && chg.NewPrdInstStasId != "1001" { c.EventType = canal.DeleteAction } else if chg.OldPrdInstStasId != "1001" && chg.NewPrdInstStasId == "1001" { c.EventType = canal.InsertAction } c.ChgAcctInfo = append(c.ChgAcctInfo, chg) logger.CanalLog.Infof("modify prd_prd_inst_551: [%#v]", chg) } } } func getOfrDetailColumns(c *RecordChange, bB bool, bA bool, beC []interface{}, afC []interface{}, e *canal.RowsEvent) { var chg ChgOfrDetail var str string if bB { //beC := rowData.GetBeforeColumns() for index, column := range e.Table.Columns { switch column.Name { case "OFR_DETAIL_TYPE_ID": str = fmt.Sprintf("%v", beC[index]) chg.OfrDetailTypeId = str case "OFR_DETAIL_INST_ID": str = fmt.Sprintf("%v", beC[index]) chg.OfrDetailInstId, _ = strconv.Atoi(str) case "EFF_DATE": str = fmt.Sprintf("%v", beC[index]) chg.OldEffDate = str case "EXP_DATE": str = fmt.Sprintf("%v", beC[index]) chg.OldExpDate = str /*case "CALC_PRIORITY": chg.ChgOfrDetail.OldCalcPriority = column.Value*/ } } } if bA { //afC := rowData.GetAfterColumns() for index, column := range e.Table.Columns { switch column.Name { case "OFR_DETAIL_TYPE_ID": str = fmt.Sprintf("%v", afC[index]) chg.OfrDetailTypeId = str case "OFR_DETAIL_INST_ID": str = fmt.Sprintf("%v", afC[index]) chg.OfrDetailInstId, _ = strconv.Atoi(str) case "EFF_DATE": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldEffDate { chg.BUpdate = true } chg.NewEffDate = str case "EXP_DATE": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldExpDate { chg.BUpdate = true } chg.NewExpDate = str /*case "CALC_PRIORITY": if column.Updated { chg.ChgOfrDetail.BUpdate = true } chg.ChgOfrDetail.NewCalcPriority = column.Value*/ } } } switch c.EventType { case canal.InsertAction: if chg.OfrDetailTypeId != "A1" { } else { c.ChgOfrDetail = append(c.ChgOfrDetail, chg) logger.CanalLog.Infof("insert into prd_ofr_detail_inst_551: [%#v]", chg) } case canal.DeleteAction: if chg.OfrDetailTypeId != "A1" { } else { c.ChgOfrDetail = append(c.ChgOfrDetail, chg) logger.CanalLog.Infof("delete from prd_ofr_detail_inst_551: [%#v]", chg) } default: if !chg.BUpdate || chg.OfrDetailTypeId != "A1" { } else { c.ChgOfrDetail = append(c.ChgOfrDetail, chg) logger.CanalLog.Infof("modify prd_ofr_detail_inst_551: [%#v]", chg) } } //c.ChgOfrDetail = append(c.ChgOfrDetail, chg) } func getTariffColumns(c *RecordChange, bB bool, bA bool, beC []interface{}, afC []interface{}, e *canal.RowsEvent) { var chg ChgTariff var str string if bB { //beC := rowData.GetBeforeColumns() for index, column := range e.Table.Columns { switch column.Name { case "TARIFF_ID": str = fmt.Sprintf("%v", beC[index]) chg.TariffId, _ = strconv.Atoi(str) } } } if bA { //afC := rowData.GetAfterColumns() for index, column := range e.Table.Columns { switch column.Name { case "TARIFF_ID": str = fmt.Sprintf("%v", afC[index]) chg.TariffId, _ = strconv.Atoi(str) } } } c.ChgTariff = append(c.ChgTariff, chg) logger.CanalLog.Infof("update tb_tariff: [%#v], type[%s]", chg, c.EventType) } func getOfrInfoColumns(c *RecordChange, bB bool, bA bool, beC []interface{}, afC []interface{}, e *canal.RowsEvent) { var chg ChgOfrInfo var str string if bB { //beC := rowData.GetBeforeColumns() for index, column := range e.Table.Columns { switch column.Name { case "OFR_TYPE_ID": str = fmt.Sprintf("%v", beC[index]) chg.OfrTypeId = str case "OFR_ID": str = fmt.Sprintf("%v", beC[index]) chg.OfrId, _ = strconv.Atoi(str) case "IF_PREPAY": str = fmt.Sprintf("%v", beC[index]) chg.IfPrepaid = str case "OFR_STATE": str = fmt.Sprintf("%v", beC[index]) chg.OldOfrState = str case "CALC_PRIORITY": str = fmt.Sprintf("%v", beC[index]) chg.OldCalcPriority = str } } } if bA { //afC := rowData.GetAfterColumns() for index, column := range e.Table.Columns { switch column.Name { case "OFR_TYPE_ID": str = fmt.Sprintf("%v", afC[index]) chg.OfrTypeId = str case "OFR_ID": str = fmt.Sprintf("%v", afC[index]) chg.OfrId, _ = strconv.Atoi(str) case "IF_PREPAY": str = fmt.Sprintf("%v", afC[index]) chg.IfPrepaid = str case "OFR_STATE": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldOfrState { chg.BUpdate = true } chg.NewOfrState = str case "CALC_PRIORITY": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldCalcPriority { chg.BUpdate = true } chg.NewCalcPriority = str } } } switch c.EventType { case canal.InsertAction: if chg.IfPrepaid != "1" || chg.OfrTypeId != "1" || chg.NewOfrState != "2" { } else { c.ChgOfrInfo = append(c.ChgOfrInfo, chg) logger.CanalLog.Infof("insert into tb_ofr: [%#v]", chg) } case canal.DeleteAction: if chg.IfPrepaid != "1" || chg.OfrTypeId != "1" || chg.OldOfrState != "2" { } else { c.ChgOfrInfo = append(c.ChgOfrInfo, chg) logger.CanalLog.Infof("delete from tb_ofr: [%#v]", chg) } default: if chg.IfPrepaid != "1" || chg.OfrTypeId != "1" || !chg.BUpdate { } else { if chg.OldOfrState == "2" && chg.NewOfrState != "2" { c.EventType = canal.DeleteAction } else if chg.OldOfrState != "2" && chg.NewOfrState == "2" { c.EventType = canal.InsertAction } c.ChgOfrInfo = append(c.ChgOfrInfo, chg) logger.CanalLog.Infof("modify tb_ofr: [%#v]", chg) } } } func getPricingStrategyColumns(c *RecordChange, bB bool, bA bool, beC []interface{}, afC []interface{}, e *canal.RowsEvent) { var chg ChgPricingStrategy var str string if bB { //beC := rowData.GetBeforeColumns() for index, column := range e.Table.Columns { switch column.Name { case "EVENT_PRICING_STRATEGY_ID": str = fmt.Sprintf("%v", beC[index]) chg.EventPricingStrategyId, _ = strconv.Atoi(str) case "EVENT_PRIORITY": str = fmt.Sprintf("%v", beC[index]) chg.OldEventPriority = str case "CALL_TYPE": str = fmt.Sprintf("%v", beC[index]) chg.OldCallType = str } } } if bA { //afC := rowData.GetAfterColumns() for index, column := range e.Table.Columns { switch column.Name { case "EVENT_PRICING_STRATEGY_ID": str = fmt.Sprintf("%v", afC[index]) chg.EventPricingStrategyId, _ = strconv.Atoi(str) case "EVENT_PRIORITY": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldEventPriority { chg.BUpdate = true } chg.NewEventPriority = str case "CALL_TYPE": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldCallType { chg.BUpdate = true } chg.NewCallType = str } } } switch c.EventType { case canal.InsertAction: c.ChgPricingStrategy = append(c.ChgPricingStrategy, chg) logger.CanalLog.Infof("insert into tb_pricing_strategy: [%#v]", chg) case canal.DeleteAction: c.ChgPricingStrategy = append(c.ChgPricingStrategy, chg) logger.CanalLog.Infof("delete from tb_pricing_strategy: [%#v]", chg) default: if !chg.BUpdate { } else { c.ChgPricingStrategy = append(c.ChgPricingStrategy, chg) logger.CanalLog.Infof("modify tb_pricing_strategy: [%#v]", chg) } } } func getConfigAreaColumns(c *RecordChange, bB bool, bA bool, beC []interface{}, afC []interface{}, e *canal.RowsEvent) { var chg ChgConfigArea var str string if bB { //beC := rowData.GetBeforeColumns() for index, column := range e.Table.Columns { switch column.Name { case "area_id": str = fmt.Sprintf("%v", beC[index]) chg.AreaId, _ = strconv.Atoi(str) case "area_code": str = fmt.Sprintf("%v", beC[index]) chg.OldAreaCode = str case "state": str = fmt.Sprintf("%v", beC[index]) chg.OldState = str } } } if bA { //afC := rowData.GetAfterColumns() for index, column := range e.Table.Columns { switch column.Name { case "area_id": str = fmt.Sprintf("%v", afC[index]) chg.AreaId, _ = strconv.Atoi(str) case "area_code": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldAreaCode { chg.BUpdate = true } chg.NewAreaCode = str case "state": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldState { chg.BUpdate = true } chg.NewState = str } } } switch c.EventType { case canal.InsertAction: if chg.NewState != "1" { } else { c.ChgConfigArea = append(c.ChgConfigArea, chg) logger.CanalLog.Infof("insert into tb_config_area: [%#v]", chg) } case canal.DeleteAction: if chg.OldState != "1" { } else { c.ChgConfigArea = append(c.ChgConfigArea, chg) logger.CanalLog.Infof("delete from tb_config_area: [%#v]", chg) } default: if !chg.BUpdate { } else { if chg.OldState != "1" && chg.NewState == "1" { c.EventType = canal.InsertAction } else if chg.OldState == "1" && chg.NewState != "1" { c.EventType = canal.DeleteAction } c.ChgConfigArea = append(c.ChgConfigArea, chg) logger.CanalLog.Infof("modify tb_config_area: [%#v]", chg) } } } func getPricingAreaColumns(c *RecordChange, bB bool, bA bool, beC []interface{}, afC []interface{}, e *canal.RowsEvent) { var chg ChgPricingArea var str string if bB { //beC := rowData.GetBeforeColumns() for index, column := range e.Table.Columns { switch column.Name { case "STRATEGY_ID": str = fmt.Sprintf("%v", beC[index]) chg.OldStrategyId, _ = strconv.Atoi(str) case "area_id": str = fmt.Sprintf("%v", beC[index]) chg.OldAreaId, _ = strconv.Atoi(str) } } } if bA { //afC := rowData.GetAfterColumns() for index, column := range e.Table.Columns { switch column.Name { case "STRATEGY_ID": str = fmt.Sprintf("%v", afC[index]) chg.NewStrategyId, _ = strconv.Atoi(str) if bB && chg.NewStrategyId != chg.OldStrategyId { chg.BUpdate = true } case "area_id": str = fmt.Sprintf("%v", afC[index]) chg.NewAreaId, _ = strconv.Atoi(str) if bB && chg.NewStrategyId != chg.OldAreaId { chg.BUpdate = true } } } } c.ChgPricingArea = append(c.ChgPricingArea, chg) logger.CanalLog.Infof("update tb_pricing_area: [%#v], type[%s]", chg, c.EventType) } func getRrColumns(c *RecordChange, bB bool, bA bool, beC []interface{}, afC []interface{}, e *canal.RowsEvent) { var chg ChgRr //c.ChgRr = make([]ChgRr, 0, 1) var str string if bB { //beC := rowData.GetBeforeColumns() for index, column := range e.Table.Columns { switch column.Name { case "ID": str = fmt.Sprintf("%v", beC[index]) chg.Id, _ = strconv.ParseInt(str, 10, 64) case "END_TIME": str = fmt.Sprintf("%v", beC[index]) chg.OldEndTime = str case "BEGIN_TIME": str = fmt.Sprintf("%v", beC[index]) chg.OldBeginTime = str case "FREE_VALUE": str = fmt.Sprintf("%v", beC[index]) chg.OldFreeValue, _ = strconv.ParseInt(str, 10, 64) case "VALUE": str = fmt.Sprintf("%v", beC[index]) chg.OldValue, _ = strconv.ParseInt(str, 10, 64) case "PRICING_SUB_SECTION_ID": str = fmt.Sprintf("%v", beC[index]) chg.OldPricingSubSectionId = str case "OFR_INST_ID": str = fmt.Sprintf("%v", beC[index]) chg.OldOfrInstId = str case "OWNER_ID": str = fmt.Sprintf("%v", beC[index]) chg.OldOwnId = str } } } if bA { //afC := rowData.GetAfterColumns() for index, column := range e.Table.Columns { switch column.Name { case "ID": str = fmt.Sprintf("%v", afC[index]) chg.Id, _ = strconv.ParseInt(str, 10, 64) case "END_TIME": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldEndTime { chg.BUpdate = true } chg.NewEndTime = str case "BEGIN_TIME": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldBeginTime { chg.BUpdate = true } chg.NewBeginTime = str case "FREE_VALUE": str = fmt.Sprintf("%v", afC[index]) chg.NewFreeValue, _ = strconv.ParseInt(str, 10, 64) if bB && chg.NewFreeValue != chg.OldFreeValue { chg.BUpdate = true } case "VALUE": str = fmt.Sprintf("%v", afC[index]) chg.NewValue, _ = strconv.ParseInt(str, 10, 64) if bB && chg.NewValue != chg.OldValue { chg.BUpdate = true } case "PRICING_SUB_SECTION_ID": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldPricingSubSectionId { chg.BUpdate = true } chg.NewPricingSubSectionId = str case "OFR_INST_ID": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldOfrInstId { chg.BUpdate = true } chg.NewOfrInstId = str case "OWNER_ID": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldOwnId { chg.BUpdate = true } chg.NewOwnId = str } } } switch c.EventType { case canal.InsertAction: c.ChgRr = append(c.ChgRr, chg) logger.CanalLog.Infof("insert into rr: [%#v]", chg) case canal.DeleteAction: c.ChgRr = append(c.ChgRr, chg) logger.CanalLog.Infof("delete from rr: [%#v]", chg) default: if !chg.BUpdate { } else { //if chg.NewValue >= chg.NewFreeValue {// may refund late, should not delete // c.EventType = canal.DeleteAction //} if chg.OldValue >= chg.OldFreeValue && chg.NewValue < chg.NewFreeValue { c.EventType = canal.InsertAction } c.ChgRr = append(c.ChgRr, chg) logger.CanalLog.Infof("modify rr: [%#v]", chg) } } } func getHolidayColumns(c *RecordChange, bB bool, bA bool, beC []interface{}, afC []interface{}, e *canal.RowsEvent) { var chg ChgHoliday var str string if bB { //beC := rowData.GetBeforeColumns() for index, column := range e.Table.Columns { switch column.Name { case "state": str = fmt.Sprintf("%v", beC[index]) chg.OldState = str case "tariff_id": str = fmt.Sprintf("%v", beC[index]) chg.OldTariffId, _ = strconv.Atoi(str) case "tariff_seq": str = fmt.Sprintf("%v", beC[index]) chg.OldTariffSeq, _ = strconv.Atoi(str) } } } if bA { //afC := rowData.GetAfterColumns() for index, column := range e.Table.Columns { switch column.Name { case "state": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldState { chg.BUpdate = true } chg.NewState = str case "tariff_id": str = fmt.Sprintf("%v", afC[index]) chg.NewTariffId, _ = strconv.Atoi(str) if bB && chg.NewTariffId != chg.OldTariffId { chg.BUpdate = true } case "tariff_seq": str = fmt.Sprintf("%v", afC[index]) chg.NewTariffSeq, _ = strconv.Atoi(str) if bB && chg.NewTariffSeq != chg.OldTariffSeq { chg.BUpdate = true } } } } switch c.EventType { case canal.InsertAction: if chg.NewState != "1" { } else { c.ChgHoliday = append(c.ChgHoliday, chg) logger.CanalLog.Infof("insert into tb_holiday: [%#v]", chg) } case canal.DeleteAction: if chg.OldState != "1" { } else { c.ChgHoliday = append(c.ChgHoliday, chg) logger.CanalLog.Infof("delete from tb_holiday: [%#v]", chg) } default: if chg.OldState != "1" && chg.NewState != "1" { } else { if chg.OldState != "1" && chg.NewState == "1" { c.EventType = canal.InsertAction } else if chg.OldState == "1" && chg.NewState != "1" { c.EventType = canal.DeleteAction } c.ChgHoliday = append(c.ChgHoliday, chg) logger.CanalLog.Infof("modify tb_holiday: [%#v]", chg) } } } func getBilHolidayColumns(c *RecordChange, bB bool, bA bool, beC []interface{}, afC []interface{}, e *canal.RowsEvent) { var chg ChgBilHoliday var str string if bB { //beC := rowData.GetBeforeColumns() for index, column := range e.Table.Columns { switch column.Name { case "HOLIDAY_ID": str = fmt.Sprintf("%v", beC[index]) chg.HolidayId, _ = strconv.Atoi(str) case "STATE": str = fmt.Sprintf("%v", beC[index]) chg.OldState = str } } } if bA { //afC := rowData.GetAfterColumns() for index, column := range e.Table.Columns { switch column.Name { case "HOLIDAY_ID": str = fmt.Sprintf("%v", afC[index]) chg.HolidayId, _ = strconv.Atoi(str) case "STATE": str = fmt.Sprintf("%v", afC[index]) if bB && str != chg.OldState { chg.BUpdate = true } chg.NewState = str } } } switch c.EventType { case canal.InsertAction: if chg.NewState != "L0R" { } else { c.ChgBilHoliday = append(c.ChgBilHoliday, chg) logger.CanalLog.Infof("insert into tb_bil_holiday: [%#v]", chg) } case canal.DeleteAction: if chg.OldState != "L0R" { } else { c.ChgBilHoliday = append(c.ChgBilHoliday, chg) logger.CanalLog.Infof("delete from tb_bil_holiday: [%#v]", chg) } default: if chg.OldState != "L0R" && chg.NewState != "L0R" { } else { if chg.OldState != "L0R" && chg.NewState == "L0R" { c.EventType = canal.InsertAction } else if chg.OldState == "L0R" && chg.NewState != "L0R" { c.EventType = canal.DeleteAction } c.ChgBilHoliday = append(c.ChgBilHoliday, chg) logger.CanalLog.Infof("modify tb_bil_holiday: [%#v]", chg) } } } func getSmsInfoColumns(c *RecordChange, bB bool, bA bool, beC []interface{}, afC []interface{}, e *canal.RowsEvent) { var chg ChgAlertSms var str string if bB { //beC := rowData.GetBeforeColumns() for index, column := range e.Table.Columns { switch column.Name { case "sms_alert_id": str = fmt.Sprintf("%v", beC[index]) chg.AlertId, _ = strconv.Atoi(str) case "sms_called_number": chg.ServiceNbr = fmt.Sprintf("%v", beC[index]) case "sms_content": chg.SmsContent = fmt.Sprintf("%v", beC[index]) case "sms_state": str = fmt.Sprintf("%v", beC[index]) chg.OldState, _ = strconv.Atoi(str) } } } if bA { //afC := rowData.GetAfterColumns() for index, column := range e.Table.Columns { switch column.Name { case "sms_alert_id": str = fmt.Sprintf("%v", afC[index]) chg.AlertId, _ = strconv.Atoi(str) case "sms_called_number": chg.ServiceNbr = fmt.Sprintf("%v", afC[index]) case "sms_content": chg.SmsContent = fmt.Sprintf("%v", afC[index]) case "sms_state": str = fmt.Sprintf("%v", afC[index]) chg.NewState, _ = strconv.Atoi(str) } } } switch c.EventType { case canal.InsertAction: if chg.NewState == 1 { c.ChgAlertSms = append(c.ChgAlertSms, chg) logger.CanalLog.Infof("insert into tb_sms_info: [%#v]", chg) } case canal.UpdateAction: if chg.OldState != 1 && chg.NewState != 1 { c.ChgAlertSms = append(c.ChgAlertSms, chg) logger.CanalLog.Infof("modify tb_sms_info: [%#v]", chg) } } } func getSyncMobileColumns(c *RecordChange, bB bool, bA bool, beC []interface{}, afC []interface{}, e *canal.RowsEvent) { var chg ChgSyncMobile var str string if bB { //beC := rowData.GetBeforeColumns() for index, column := range e.Table.Columns { switch column.Name { case "STATE": str = fmt.Sprintf("%v", beC[index]) chg.OldState, _ = strconv.Atoi(str) } } } if bA { //afC := rowData.GetAfterColumns() for index, column := range e.Table.Columns { switch column.Name { case "PRE_ID": str = fmt.Sprintf("%v", afC[index]) chg.PreId, _ = strconv.Atoi(str) case "OPER_TYPE": str = fmt.Sprintf("%v", afC[index]) chg.OperType, _ = strconv.Atoi(str) case "STATE": str = fmt.Sprintf("%v", afC[index]) chg.State, _ = strconv.Atoi(str) case "MOBILE_TYPE": str = fmt.Sprintf("%v", afC[index]) chg.MobileType, _ = strconv.Atoi(str) case "SERVICE_NBR": chg.ServiceNbr = fmt.Sprintf("%v", afC[index]) case "CUST_ID": str = fmt.Sprintf("%v", afC[index]) chg.CustId, _ = strconv.Atoi(str) case "ACCT_ID": str = fmt.Sprintf("%v", afC[index]) chg.AcctId, _ = strconv.Atoi(str) case "PRD_INST_ID": str = fmt.Sprintf("%v", afC[index]) chg.PrdInstId, _ = strconv.Atoi(str) case "OFR_ID": str = fmt.Sprintf("%v", afC[index]) chg.OfrId, _ = strconv.Atoi(str) case "BALANCE": str = fmt.Sprintf("%v", afC[index]) chg.Balance, _ = strconv.Atoi(str) case "BIRTH_DATE": chg.BirthDate = fmt.Sprintf("%v", afC[index]) case "BALANCE_EXP_DATE": chg.BalanceExpDate = fmt.Sprintf("%v", afC[index]) case "IMSI": chg.Imsi = fmt.Sprintf("%v", afC[index]) case "KI": chg.Ki = fmt.Sprintf("%v", afC[index]) case "OPC": chg.Opc = fmt.Sprintf("%v", afC[index]) case "EXP_DATE": chg.ExpDate = fmt.Sprintf("%v", afC[index]) case "VMS_FLAG": str = fmt.Sprintf("%v", afC[index]) chg.VmsFlag, _ = strconv.Atoi(str) case "CUG_ID": str = fmt.Sprintf("%v", afC[index]) chg.CugId, _ = strconv.Atoi(str) } } } switch c.EventType { case canal.InsertAction: if chg.State == 1 && chg.OperType == 1 && chg.MobileType == 1 { c.ChgSyncMobile = append(c.ChgSyncMobile, chg) logger.CanalLog.Infof("insert into tb_sync_mobile: [%#v]", chg) } case canal.UpdateAction: if chg.OldState != 1 && chg.State == 1 { c.ChgSyncMobile = append(c.ChgSyncMobile, chg) logger.CanalLog.Infof("modify tb_sync_mobile: [%#v]", chg) } } } func ParseAndFilterBinLog(e *canal.RowsEvent) *RecordChange { var chg = RecordChange{EventType: e.Action, TableName: e.Table.Name} var num int=0 if chg.EventType == canal.InsertAction || chg.EventType == canal.DeleteAction { num = len(e.Rows) } else { num = len(e.Rows)/2 } for i:=0; i