jaryhe 1 rok pred
rodič
commit
a17adedcfc
4 zmenil súbory, kde vykonal 46 pridanie a 49 odobranie
  1. 1 0
      consts/common.go
  2. 41 47
      impl/analysis/ods7.go
  3. 2 1
      impl/handle/common.go
  4. 2 1
      model/ods7.go

+ 1 - 0
consts/common.go

@@ -42,6 +42,7 @@ const (
 	ZRTWOELEMENTVERIFYNATIONAL = "103-002"
 	DYXL                       = "104-002"
 	DYXW                       = "104-001"
+	DYXLALL                       = "104-003"
 
 	//ZCRKENGINENO                 = "141-003"
 	//ZCRKBYVIN                = "141-004"

+ 41 - 47
impl/analysis/ods7.go

@@ -4,68 +4,66 @@
 package analysis
 
 import (
+	"fmt"
 	"gadm-ods/apis"
 	"gadm-ods/common.in/clinit"
-	"gadm-ods/consts"
 	"gadm-ods/model"
-	"fmt"
 	"github.com/tidwall/gjson"
+	"go.uber.org/zap"
 	"strings"
 )
 
-// spy 过户车记录查询128-010
+// dybd 学历(DYXL                       = "104-003")
 func ParasOds7(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()
+	idCard := gjson.Get(requestParams, "cardNo").String()
+	name := gjson.Get(requestParams, "name").String()
 
-	if vin == "" {
-		return nil, fmt.Errorf("数据异常,车牌姓名不匹配")
+	if idCard == "" || 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("数据异常,没有数据")
 	}
-	lastTransTime := int64(0)
-	lastPlate := ""
 
-	respData := gjson.Get(responseParams, "data").Array()
-	for _, v := range respData {
-		dataMap := make(map[string]string)
-		//record.TransferNumber = v.Get("transTime").Int()
-		//record.TransferAge = v.Get("carYear").String()
-		//record.NewPlateNo = v.Get("newCp").String()
-		transTime := v.Get("transTime").Int()
-		dataMap["vin"] = vin
-		dataMap["plate_no"] = v.Get("oldCp").String()
-		if transTime > lastTransTime {
-			lastPlate = v.Get("newCp").String()
-			lastTransTime = transTime
-		}
-		insuranceDate := v.Get("changeMonth").String()
-		if len(insuranceDate) >= 6 {
-			insuranceDate = insuranceDate[0:4] + "-" + insuranceDate[4:]
-		}
+	arr := gjson.Get(responseParams, "data").Array()
 
-		dataMap["insurance_date"] = insuranceDate
-		dataMap["is_expire"] = consts.EXPIREDATA
 
-		//record.TransferDate = v.Get("changeMonth").String()
-		//record.TransferAgeMonth = v.Get("carMonth").String()
-		ret = append(ret, dataMap)
+	for _, v := range arr {
+		respMap := make(map[string]string)
+		respMap["name"] = name
+		respMap["is_double_first_class_university"] = v.Get("isDoubleFirstClassUniversity").String() // 是否为双一流学校
+		respMap["is_two_one_one_university"] = v.Get("isTwoOneOneUniversity").String() // 是否为211学校
+		respMap["end_date"] = v.Get("endDate").String()   // 毕业日期
+		respMap["type_name"] = v.Get("typeName").String() // 研究类型
+		respMap["edu_code"] = v.Get("eduCode").String()  // 学校代码
+		respMap["qualification_code"] = v.Get( "qualificationCode").String()  // 教育类别代码
+		respMap["major_category"] = v.Get( "majorCategory").String()  // 专业名称
+		respMap["edu_name"] = v.Get( "eduName").String() // 学校名
+		respMap["qualification_name"] = v.Get( "qualificationName").String() // 教育类别
+		respMap["type_code"] = v.Get( "typeCode").String() // 研究类型代码
+		respMap["secondary_category"] = v.Get( "secondaryCategory").String() // 二级学科名称
+		respMap["begin_date"] = v.Get( "beginDate").String() // 注册日期
+		respMap["major_code"] = v.Get( "majorCode").String() // 专业代码
+		respMap["is_nine_eight_five_university"] = v.Get( "isNineEightFiveUniversity").String() // 是否为985学校
+		respMap["id_card"] = idCard
+		ret = append(ret, respMap)
 	}
 
-	if lastPlate != "" {
-		dataMap := make(map[string]string)
-		dataMap["vin"] = vin
-		dataMap["plate_no"] = lastPlate
-		dataMap["is_expire"] = consts.NORMALDATA
-		ret = append(ret, dataMap)
+	if len(ret) == 0 {
+		l.Error("func",
+			zap.String("call", "ParasOds7"),
+			zap.String("args", content),
+			zap.String("error", "数据异常,无法解析"))
+		return nil, fmt.Errorf("数据异常")
+	} else {
+		return ret, nil
 	}
 
-	return ret, nil
 }
 
 func HandleOnlineOds7(msg *apis.OdsMessage) (dataMapList []map[string]string, err error) {
@@ -78,16 +76,18 @@ func HandleOnlineOds7(msg *apis.OdsMessage) (dataMapList []map[string]string, er
 	if len(dataMapList) == 0 {
 		return nil, nil
 	}
+
 	// 入本地库
 	ods7 := &model.Ods7{}
-	ods7.Vin = dataMapList[0]["vin"]
+	ods7.IdCard = dataMapList[0]["id_card"]
+	ods7.Name = dataMapList[0]["name"]
 	ods7.Content = msg.Content
 	err = ods7.Insert(clinit.DB())
 	if err != nil {
 		if !strings.Contains(err.Error(), "Duplicate") {
 			return nil, err
 		} else {
-			where := map[string]interface{}{"vin": ods7.Vin}
+			where := map[string]interface{}{"id_card": ods7.IdCard,"name":ods7.Name}
 			oldOds7 := &model.Ods7{}
 			err = oldOds7.Query(clinit.DB(), where)
 			if err == nil {
@@ -100,11 +100,5 @@ func HandleOnlineOds7(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
 }

+ 2 - 1
impl/handle/common.go

@@ -36,6 +36,7 @@ var OdsOnlineTaskMap = map[string]ProviderLogTask{
 	consts.SOURCEODS4:  {analysis.HandleOnlineOds4, analysis.ParasOds4},
 	consts.SOURCEODS5:  {analysis.HandleOnlineOds5, analysis.ParasOds5},
 	consts.SOURCEODS6:  {analysis.HandleOnlineOds6, analysis.ParasOds6},
+	consts.SOURCEODS7:  {analysis.HandleOnlineOds7, analysis.ParasOds7},
 	/*consts.SOURCEODS16: {analysis.HandleOnlineOds16, analysis.ParasOds16},
 	consts.SOURCEODS17: {analysis.HandleOnlineOds17, analysis.ParasOds12},
 	consts.SOURCEODS18: {analysis.HandleOnlineOds18, analysis.ParasOds18},
@@ -67,7 +68,7 @@ var ProviderApiCodeToSoucreCodeMap = map[string]string{
 	consts.ZRTWOELEMENTVERIFY: consts.SOURCEODS4,
 	consts.DYXW: consts.SOURCEODS5,
 	consts.DYXL: consts.SOURCEODS6,
-
+	consts.DYXLALL: consts.SOURCEODS7,
 	/*consts.ZCRKENGINENO:             consts.SOURCEODS18,
 	consts.ZCRKBYVIN: consts.SOURCEODS19,*/
 }

+ 2 - 1
model/ods7.go

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