jaryhe 1 yıl önce
ebeveyn
işleme
4ca1f1ddac
6 değiştirilmiş dosya ile 76 ekleme ve 272 silme
  1. 3 0
      consts/common.go
  2. 27 221
      impl/analysis/ods5.go
  3. 37 49
      impl/analysis/ods6.go
  4. 5 0
      impl/handle/common.go
  5. 2 1
      model/ods5.go
  6. 2 1
      model/ods6.go

+ 3 - 0
consts/common.go

@@ -40,6 +40,9 @@ const (
 	CDBDTWOELEMENTVERIFY = "101-001"
 	ZRTWOELEMENTVERIFY = "103-001"
 	ZRTWOELEMENTVERIFYNATIONAL = "103-002"
+	DYXL                       = "104-002"
+	DYXW                       = "104-001"
+
 	//ZCRKENGINENO                 = "141-003"
 	//ZCRKBYVIN                = "141-004"
 )

+ 27 - 221
impl/analysis/ods5.go

@@ -4,237 +4,48 @@
 package analysis
 
 import (
+	"fmt"
 	"gadm-ods/apis"
 	"gadm-ods/common.in/clinit"
 	"gadm-ods/model"
-	"fmt"
 	"github.com/tidwall/gjson"
 	"go.uber.org/zap"
 	"strings"
-	"time"
 )
 
-// spy 	VIN查询车型信息128-001
+// dybd 学位(DYXW                       = "104-001")
 func ParasOds5(content string) (ret []map[string]string, err error) {
 	data := gjson.Parse(content)
 	requestParams := data.Get("request_params").String()
 	responseParams := data.Get("response_params").String()
-	vin := gjson.Get(requestParams, "vin").String()
-	if vin == "" {
+	degreeId := gjson.Get(requestParams, "xwzsbh").String()
+	name := gjson.Get(requestParams, "xm").String()
+	
+	if degreeId == "" || name == ""{
 		return nil, fmt.Errorf("数据异常,车牌姓名不匹配")
 	}
 
-	code := gjson.Get(responseParams, "respCode").String()
-	if code != "0" {
+	code := gjson.Get(responseParams, "code").String()
+	if code != "200" {
 		return nil, fmt.Errorf("数据异常,没有数据")
 	}
-
-	stateCode := gjson.Get(responseParams, "data.stateCode").String()
-	if stateCode == "0" {
-		return nil, fmt.Errorf("数据异常,没有数据")
+	
+	arr := gjson.Get(responseParams, "data").Array()
+	
+	
+	for _, v := range arr {
+		dataMap := make(map[string]string)
+		dataMap["birth_date"] = v.Get("csrq").String()   // 出生日期
+		dataMap["gender"] = v.Get("xb").String()   // 性别
+		dataMap["major"] = v.Get("xkzy").String()   // 学科专业
+		dataMap["degree_name"] = v.Get("xwlb").String()   // 获学位名称
+		dataMap["award_name"] = v.Get( "xwsydw").String()   // 学位授予单位
+		dataMap["name"] = v.Get( "xm").String()  //  姓名
+		dataMap["award_date"] = v.Get( "hxwrq").String()  // 获学位日期
+		dataMap["degree_id"] = degreeId
+		ret = append(ret, dataMap)
 	}
-	respData := gjson.Get(responseParams, "data").String()
-	if stateCode == "1" {
-		arr := gjson.Get(respData, "vecStdVOS").Array()
-		for _, v := range arr {
-			dataMap := make(map[string]string)
-			dataMap["vin"] = vin
-			dataMap["approved_load"] = v.Get("approvedLoad").String()
-			dataMap["release_date"] = time.Unix(v.Get("vinTime").Int()/1000, 0).Format("2006-01-02")
-			dataMap["long"] = v.Get("wkc").String()
-			dataMap["oil_wear"] = v.Get("yh").String()
-			dataMap["engine_type"] = v.Get("fdjxh").String()
-			dataMap["high"] = v.Get("wkg").String()
-			dataMap["wide"] = v.Get("wkk").String()
-			dataMap["vehicle_body_color_detail"] = v.Get("csys").String()
-			dataMap["gross_mass"] = v.Get("zzl").String()
-			dataMap["front_wheel_distance"] = v.Get("qlj").String()
-			dataMap["axle_weight"] = v.Get("zh").String()
-			dataMap["wheel_base"] = v.Get("zj").String()
-			dataMap["model_no"] = v.Get("clxh").String()
-			dataMap["axle_number"] = v.Get("zs").String()
-			dataMap["approved_number"] = v.Get("edzk").String()
-			plL := v.Get("plL").String()
-			engineMod := v.Get("engineMod").String()
-			plLMod := ""
-			tmp := strings.Split(engineMod, " ")
-			if len(tmp) > 0 {
-				plLMod = tmp[0]
-			}
-			if plL != "" {
-				tmp := strings.Replace(plL, "L", "", -1)
-				tmp = strings.Replace(tmp, "T", "", -1)
-				dataMap["displacement_l"] = tmp
-				if strings.HasSuffix(plL, "L") {
-					dataMap["air_intak_form"] = "L"
-				} else if strings.HasSuffix(plL, "T") {
-					dataMap["air_intak_form"] = "T"
-				}
-
-			} else if engineMod != "" {
-				if plLMod != "" {
-					pl := strings.Replace(plLMod, "L", "", -1)
-					pl = strings.Replace(pl, "T", "", -1)
-					dataMap["displacement_l"] = pl
-				}
-			}
-			if dataMap["air_intak_form"] == "" {
-				if plLMod != "" {
-					if strings.HasSuffix(plLMod, "L") {
-						dataMap["air_intak_form"] = "L"
-					} else if strings.HasSuffix(plLMod, "T") {
-						dataMap["air_intak_form"] = "T"
-					}
-				}
-			}
-
-			dataMap["engine_no"] = v.Get("fdjh").String()
-
-			// TODO 拆分为前后轮胎规格
-			dataMap["tyre_size"] = v.Get("ltgg").String()
-			//dataMap["front_wheel_specification"] = dataMap["tyre_size"]
-			//dataMap["back_wheel_specification"] = dataMap["tyre_size"]
-			dataMap["fuel_type_detail"] = v.Get("oilWay").String()
-			dataMap["use_property_detail"] = v.Get("syxz").String()
-			dataMap["unladen_mass"] = v.Get("zbzl").String()
-			dataMap["rated_power"] = v.Get("gl").String()
-			dataMap["back_wheel_distance"] = v.Get("hlj").String()
-			dataMap["vehicle_type_detail"] = v.Get("vecModType").String()
-			dataMap["tyre_number"] = v.Get("lts").String()
-			dataMap["traction_mass"] = v.Get("quasiTraction").String()
-			dataMap["emission_standard"] = v.Get("pfbz").String()
-			dataMap["brand_name"] = v.Get("automarkerInfo").String()
-
-			dataMap["price"] = v.Get("autoPrice").String()
-			dataMap["vehicle_structure"] = v.Get("bodyStruct").String()
-			dataMap["model_year"] = v.Get("modelYear").String()
-			//dataMap["axle_number"] = v.Get("wheelSum").String()
-			dataMap["drive_type"] = v.Get("driveWay").String()
-			dataMap["chassis_model"] = v.Get("chassisModel").String()
-			if v.Get("cxid").String() != ""{
-				dataMap["third_style_id"] = v.Get("cxid").String()
-				dataMap["source"] = "1"
-			}else{
-				qczjId := v.Get("qczjId").String()
-				if qczjId != "" {
-					dataMap["third_style_id"] = qczjId
-					dataMap["source"] = "2"
-				}
-			}
-
-			dataMap["series_source"] = "1"
-			/*if v.Get("catarcCode").Exists() {
-				dataMap["third_style_id"] = v.Get("catarcCode").String()
-			} else {
-				dataMap["third_style_id"] = v.Get("cxid").String()
-			}*/
-
-			dataMap["third_series_id"] = v.Get("ccs5").String()
-			dataMap["third_series_name"] = v.Get("vecMod").String()
-			dataMap["third_style_name"] = v.Get("vecName").String()
-			ret = append(ret, dataMap)
-		}
-	} else if stateCode == "2" {
-		arr := gjson.Get(respData, "vinSycVO").Array()
-		for _, v := range arr {
-			dataMap := make(map[string]string)
-			dataMap["vin"] = vin
-			dataMap["approved_load"] = v.Get("ratedLoadMass").String()
-			if v.Get("createTime").Int() != 0 {
-				dataMap["release_date"] = time.Unix(v.Get("createTime").Int()/1000, 0).Format("2006-01-02")
-			} else {
-				dataMap["release_date"] = ""
-			}
-
-			dataMap["long"] = v.Get("length").String()
-			dataMap["oil_wear"] = v.Get("oilLoss").String()
-			dataMap["engine_type"] = v.Get("engineType").String()
-			dataMap["high"] = v.Get("height").String()
-			dataMap["wide"] = v.Get("wide").String()
-			dataMap["gross_mass"] = v.Get("totalQuality").String()
-			dataMap["front_wheel_distance"] = v.Get("frontGauge").String()
-			dataMap["axle_weight"] = v.Get("axleLoad").String()
-			dataMap["wheel_base"] = v.Get("wheelBase").String()
-			dataMap["model_no"] = v.Get("vehicleNumber").String()
-			dataMap["axle_number"] = v.Get("numberOfShaft").String()
-			dataMap["approved_number"] = v.Get("ratedPassenger").String()
-			dataMap["displacement"] = v.Get("displacement").String()
-			dataMap["engine_no"] = v.Get("fdjh").String()
-			dataMap["tyre_size"] = v.Get("tireSize").String()
-			dataMap["fuel_type_detail"] = v.Get("fuelType").String()
-			dataMap["unladen_mass"] = v.Get("curbWeight").String()
-			dataMap["rated_power"] = v.Get("power").String()
-			dataMap["back_wheel_distance"] = v.Get("trackRear").String()
-			dataMap["vehicle_type_detail"] = v.Get("vehicleCategory").String() + v.Get("vehicleName").String()
-			dataMap["tyre_number"] = v.Get("numberOfTires").String()
-			dataMap["emission_standard"] = v.Get("emissionStandard").String()
-			dataMap["brand_name"] = v.Get("brand").String()
-			if v.Get("brand").String() == "" {
-				dataMap["brand_name"] = v.Get("vehicleBrand").String()
-			}
-			dataMap["traction_mass"] = v.Get("totalMassOfQuasiTraction").String()
-			dataMap["cargo_high"] = v.Get("cargoVanHeight").String()
-			dataMap["cargo_long"] = v.Get("cargoVanLong").String()
-			dataMap["cargo_wide"] = v.Get("cargoVanWide").String()
-			dataMap["chassis_model"] = v.Get("chassisModel").String()
-			//dataMap["drive_type"] = v.Get("drivingForm").String()
-			//dataMap["vehicle_type_detail"] = v.Get("vehicleType").String()
-			dataMap["number_of_leaf_springs"] = v.Get("numberOfLeafSprings").String()
-			dataMap["number_of_passengers"] = v.Get("numberOfPassengers").String()
-			ret = append(ret, dataMap)
-		}
-	} else if stateCode == "3" {
-		arr := gjson.Get(respData, "vinMotoVO").Array()
-		for _, v := range arr {
-			dataMap := make(map[string]string)
-			dataMap["vin"] = vin
-			if v.Get("createTime").Int() != 0 {
-				dataMap["release_date"] = time.Unix(v.Get("createTime").Int()/1000, 0).Format("2006-01-02")
-			} else {
-				dataMap["release_date"] = ""
-			}
-			dataMap["brand_name"] = v.Get("brand").String()
-			if v.Get("brand").String() == "" {
-				dataMap["brand_name"] = v.Get("vehicleBrand").String()
-			}
-			dataMap["front_wheel_distance"] = v.Get("frontGauge").String()
-			dataMap["back_wheel_distance"] = v.Get("trackRear").String()
-			dataMap["tyre_number"] = v.Get("numberOfTires").String()
-			dataMap["tyre_size"] = v.Get("tireSize").String()
-			dataMap["number_of_leaf_springs"] = v.Get("numberOfLeafSprings").String()
-			dataMap["wheel_base"] = v.Get("wheelBase").String()
-			dataMap["axle_weight"] = v.Get("axleLoad").String()
-			dataMap["axle_number"] = v.Get("numberOfShaft").String()
-			dataMap["long"] = v.Get("length").String()
-			dataMap["wide"] = v.Get("wide").String()
-			dataMap["high"] = v.Get("height").String()
-			dataMap["cargo_long"] = v.Get("cargoVanLong").String()
-			dataMap["cargo_wide"] = v.Get("cargoVanWide").String()
-			dataMap["cargo_high"] = v.Get("cargoVanHeight").String()
-			dataMap["gross_mass"] = v.Get("totalQuality").String()
-			dataMap["approved_load"] = v.Get("ratedLoadMass").String()
-			dataMap["unladen_mass"] = v.Get("curbWeight").String()
-			dataMap["traction_mass"] = v.Get("totalMassOfQuasiTraction").String()
-			dataMap["number_of_passengers"] = v.Get("numberOfPassengers").String()
-			dataMap["approved_number"] = v.Get("ratedPassenger").String()
-			dataMap["top_speed"] = v.Get("topSpeed").String()
-			dataMap["model_no"] = v.Get("vehicleNumber").String()
-			//vehicleCategory
-			dataMap["vehicle_type_detail"] = v.Get("vehicleName").String()
-			dataMap["emission_standard"] = v.Get("emissionStandard").String()
-			dataMap["displacement"] = v.Get("displacement").String()
-			dataMap["rated_power"] = v.Get("power").String()
-			dataMap["engine_type"] = v.Get("engineType").String()
-			dataMap["fuel_type_detail"] = v.Get("fuelType").String()
-			// enterpriseName
-			dataMap["engine_no"] = v.Get("fdjh").String()
-			dataMap["vehicle_body_color_detail"] = v.Get("bodyColor").String()
-			dataMap["steering_mode"] = v.Get("steeringMode").String()
-			dataMap["is_moto"] = "1"
-			ret = append(ret, dataMap)
-		}
-	}
-
+	
 	if len(ret) == 0 {
 		l.Error("func",
 			zap.String("call", "ParasOds5"),
@@ -260,14 +71,15 @@ func HandleOnlineOds5(msg *apis.OdsMessage) (dataMapList []map[string]string, er
 
 	// 入本地库
 	ods5 := &model.Ods5{}
-	ods5.Vin = dataMapList[0]["vin"]
+	ods5.DegreeId = dataMapList[0]["degree_id"]
+	ods5.Name = dataMapList[0]["name"]
 	ods5.Content = msg.Content
 	err = ods5.Insert(clinit.DB())
 	if err != nil {
 		if !strings.Contains(err.Error(), "Duplicate") {
 			return nil, err
 		} else {
-			where := map[string]interface{}{"vin": ods5.Vin}
+			where := map[string]interface{}{"degree_id": ods5.DegreeId,"name":ods5.Name}
 			oldOds5 := &model.Ods5{}
 			err = oldOds5.Query(clinit.DB(), where)
 			if err == nil {
@@ -280,11 +92,5 @@ func HandleOnlineOds5(msg *apis.OdsMessage) (dataMapList []map[string]string, er
 		}
 	}
 
-	/*for _, dataMap := range dataMapList {
-		dwsMsg := dutils.NewDwsMessage(msg)
-		dwsMsg.Content = utils.MarshalJsonString(dataMap)
-		ret = append(ret, dwsMsg)
-	}*/
-
 	return dataMapList, nil
 }

+ 37 - 49
impl/analysis/ods6.go

@@ -4,60 +4,58 @@
 package analysis
 
 import (
-	"gadm-ods/apis"
-	"gadm-ods/model"
 	"fmt"
-	"strings"
-
+	"gadm-ods/apis"
 	"gadm-ods/common.in/clinit"
+	"gadm-ods/model"
 	"github.com/tidwall/gjson"
+	"go.uber.org/zap"
+	"strings"
 )
 
-// spy 两日期查询128-004,128-006
+// dybd 学历(DYXL                       = "104-002")
 func ParasOds6(content string) (ret []map[string]string, err error) {
 	data := gjson.Parse(content)
 	requestParams := data.Get("request_params").String()
 	responseParams := data.Get("response_params").String()
-	cp := gjson.Get(requestParams, "cp").String()
-	if cp == "" {
+	educationId := gjson.Get(requestParams, "certificateid").String()
+	name := gjson.Get(requestParams, "name").String()
+
+	if educationId == "" || name == ""{
 		return nil, fmt.Errorf("数据异常,车牌姓名不匹配")
 	}
-	code := gjson.Get(responseParams, "respCode").String()
-	if code != "0" {
-		return nil, fmt.Errorf("数据异常,没有数据")
-	}
 
-	stateCode := gjson.Get(responseParams, "data.stateCode").String()
-	if stateCode == "0" {
+	code := gjson.Get(responseParams, "code").String()
+	if code != "200" {
 		return nil, fmt.Errorf("数据异常,没有数据")
 	}
 
-	dataArray := gjson.Get(responseParams, "data").Array()
-	if len(dataArray) == 0 {
+	arr := gjson.Get(responseParams, "data").Array()
+
+
+	for _, v := range arr {
 		dataMap := make(map[string]string)
-		dataMap["cp"] = cp
-		respData := gjson.Get(responseParams, "data").String()
-		dataMap["plate_no"] = gjson.Get(respData, "cp").String()
-		dataMap["vin"] = gjson.Get(respData, "vin").String()
-		dataMap["last_compulsory_insurance_date"] = gjson.Get(respData, "insuranceMonth").String()
-		dataMap["insurance_first_date"] = gjson.Get(respData, "registerDate").String()
-		dataMap["use_property_detail"] = gjson.Get(respData, "usage").String()
+		dataMap["name"] = v.Get("xm").String()
+		dataMap["level"] = v.Get("cc").String()   // 层次   专科,本科
+		dataMap["major"] = v.Get("zymc").String() //专业名称
+		dataMap["university"] = v.Get("yxmc").String()  //毕业学校名称
+		dataMap["end_year"] = v.Get( "byrq").String()  //毕业日期
+		dataMap["start_year"] = v.Get( "rxrq").String()  //入学日期
+		dataMap["form"] = v.Get( "xxxs").String() //学习形式 普通全日制
+		dataMap["education_id"] = educationId
 		ret = append(ret, dataMap)
-	}else{
-		for _,v := range dataArray{
-			dataMap := make(map[string]string)
-			dataMap["cp"] = cp
-			dataMap["plate_no"] = v.Get("cp").String()
-			dataMap["vin"] = v.Get("vin").String()
-			dataMap["last_compulsory_insurance_date"] = v.Get("insuranceMonth").String()
-			dataMap["insurance_first_date"] = v.Get("registerDate").String()
-			dataMap["use_property_detail"] = v.Get("usage").String()
-			dataMap["city"] = v.Get( "city").String()
-			dataMap["province"] = v.Get( "province").String()
-			ret = append(ret, dataMap)
-		}
 	}
-	return ret, nil
+
+	if len(ret) == 0 {
+		l.Error("func",
+			zap.String("call", "ParasOds6"),
+			zap.String("args", content),
+			zap.String("error", "数据异常,无法解析"))
+		return nil, fmt.Errorf("数据异常")
+	} else {
+		return ret, nil
+	}
+
 }
 
 func HandleOnlineOds6(msg *apis.OdsMessage) (dataMapList []map[string]string, err error) {
@@ -73,18 +71,15 @@ func HandleOnlineOds6(msg *apis.OdsMessage) (dataMapList []map[string]string, er
 
 	// 入本地库
 	ods6 := &model.Ods6{}
-	ods6.Code = dataMapList[0]["cp"]
-	if ods6.Code == "" {
-		fmt.Println("主键值为空")
-		return nil, nil
-	}
+	ods6.EducationId = dataMapList[0]["education_id"]
+	ods6.Name = dataMapList[0]["name"]
 	ods6.Content = msg.Content
 	err = ods6.Insert(clinit.DB())
 	if err != nil {
 		if !strings.Contains(err.Error(), "Duplicate") {
 			return nil, err
 		} else {
-			where := map[string]interface{}{"code": ods6.Code}
+			where := map[string]interface{}{"education_id": ods6.EducationId,"name":ods6.Name}
 			oldOds6 := &model.Ods6{}
 			err = oldOds6.Query(clinit.DB(), where)
 			if err == nil {
@@ -97,12 +92,5 @@ func HandleOnlineOds6(msg *apis.OdsMessage) (dataMapList []map[string]string, er
 		}
 	}
 
-	for _, dataMap := range dataMapList {
-		delete(dataMap, "cp")
-		//dwsMsg := dutils.NewDwsMessage(msg)
-		//dwsMsg.Content = utils.MarshalJsonString(dataMap)
-		//ret = append(ret, dwsMsg)
-	}
-
 	return dataMapList, nil
 }

+ 5 - 0
impl/handle/common.go

@@ -34,6 +34,8 @@ var OdsOnlineTaskMap = map[string]ProviderLogTask{
 	consts.SOURCEODS2:  {analysis.HandleOnlineOds2, analysis.ParasOds2},
 	consts.SOURCEODS3:  {analysis.HandleOnlineOds3, analysis.ParasOds3},
 	consts.SOURCEODS4:  {analysis.HandleOnlineOds4, analysis.ParasOds4},
+	consts.SOURCEODS5:  {analysis.HandleOnlineOds5, analysis.ParasOds5},
+	consts.SOURCEODS6:  {analysis.HandleOnlineOds6, analysis.ParasOds6},
 	/*consts.SOURCEODS16: {analysis.HandleOnlineOds16, analysis.ParasOds16},
 	consts.SOURCEODS17: {analysis.HandleOnlineOds17, analysis.ParasOds12},
 	consts.SOURCEODS18: {analysis.HandleOnlineOds18, analysis.ParasOds18},
@@ -63,6 +65,9 @@ var ProviderApiCodeToSoucreCodeMap = map[string]string{
 	consts.CDBDTWOELEMENTVERIFY: consts.SOURCEODS2,
 	consts.ZRTWOELEMENTVERIFYNATIONAL:           consts.SOURCEODS3,
 	consts.ZRTWOELEMENTVERIFY: consts.SOURCEODS4,
+	consts.DYXW: consts.SOURCEODS5,
+	consts.DYXL: consts.SOURCEODS6,
+
 	/*consts.ZCRKENGINENO:             consts.SOURCEODS18,
 	consts.ZCRKBYVIN: consts.SOURCEODS19,*/
 }

+ 2 - 1
model/ods5.go

@@ -12,7 +12,8 @@ import (
 
 type Ods5 struct {
 	ID        int64  `gorm:"primary_key"`
-	Vin       string `json:"vin"`
+	DegreeId string `json:"degree_id"`
+	Name string `json:"name"`
 	Content   string `json:"content"`
 	CreatedAt int64  `json:"created_at"`
 	UpdatedAt int64  `json:"updated_at"`

+ 2 - 1
model/ods6.go

@@ -12,7 +12,8 @@ import (
 
 type Ods6 struct {
 	ID        int64  `gorm:"primary_key"`
-	Code      string `json:"code"`
+	EducationId string `json:"education_id"`
+	Name string `json:"name"`
 	Content   string `json:"content"`
 	CreatedAt int64  `json:"created_at"`
 	UpdatedAt int64  `json:"updated_at"`