jaryhe 1 jaar geleden
bovenliggende
commit
5325073636
7 gewijzigde bestanden met toevoegingen van 128 en 67 verwijderingen
  1. 5 64
      impl/v1/query/A02.go
  2. 86 0
      impl/v1/query/F01.go
  3. 1 0
      impl/v1/query/U01.go
  4. 29 0
      impl/v1/query/U02.go
  5. 1 0
      impl/v1/query/V01.go
  6. 2 1
      impl/v1/query/V02.go
  7. 4 2
      impl/v1/query/center.go

+ 5 - 64
impl/v1/query/A02.go

@@ -19,65 +19,6 @@ type a02Req struct {
 	PlateType string `json:"plate_type"`
 }
 
-type a02Response struct {
-	PlateNo                     string `json:"plate_no"`
-	PlateType                   string `json:"plate_type"`
-	Vin                         string `json:"vin"`                       //
-	EngineNo                    string `json:"engine_no"`                 //
-	EngineType                  string `json:"engine_type"`               //
-	ModelNo                     string `json:"model_no"`                  //
-	BrandName                   string `json:"brand_name"`                //
-	InitialRegistrationDate     string `json:"initial_registration_date"` //16
-	VehicleType                 string `json:"vehicle_type"`              //18
-	VehicleTypeDetail           string `json:"vehicle_type_detail"`       //18
-	UseProperty                 string `json:"use_property"`              //16
-	UsePropertyDetail           string `json:"use_property_detail"`       //15
-	VehicleBodyColor            string `json:"vehicle_body_color"`        //16
-	VehicleBodyColorDetail      string `json:"vehicle_body_color_detail"` //
-	ApprovedLoad                string `json:"approved_load"`             //
-	ApprovedNumber              string `json:"approved_number"`           //
-	AxleNumber                  string `json:"axle_number"`               //
-	AxleWeight                  string `json:"axle_weight"`               //
-	Displacement                string `json:"displacement"`              //
-	DisplacementL               string `json:"displacement_l"`
-	FrontWheelDistance          string `json:"front_wheel_distance"` //
-	BackWheelDistance           string `json:"back_wheel_distance"`  //
-	FuelType                    string `json:"fuel_type"`            //16
-	FuelTypeDetail              string `json:"fuel_type_detail"`     //
-	GrossMass                   string `json:"gross_mass"`           //
-	RatedPower                  string `json:"rated_power"`          //
-	ReleaseDate                 string `json:"release_date"`         //
-	UnladenMass                 string `json:"unladen_mass"`         //
-	EmissionStandard            string `json:"emission_standard"`    //
-	High                        string `json:"high"`                 //
-	Long                        string `json:"long"`                 //
-	Wide                        string `json:"wide"`                 //
-	OilWear                     string `json:"oil_wear"`             //
-	TractionMass                string `json:"traction_mass"`        //
-	TyreSize                    string `json:"tyre_size"`            //
-	TyreNumber                  string `json:"tyre_number"`          //
-	WheelBase                   string `json:"wheel_base"`           //
-	CompulsoryScrapTo           string `json:"compulsory_scrap_to"`
-	InspectionResultEffectiveTo string `json:"inspection_result_effective_to"`
-
-	//CertificateNumber                  string `json:"certificate_number"`                      //
-	//CertificateDate                    string `json:"certificate_date"`                        //
-	//VehicleManufacturer                string `json:"vehicle_manufacturer"`                    //
-	//ChassisModel                       string `json:"chassis_model"`                           //
-	//ChassisId                          string `json:"chassis_id"`                              //
-	//ChassisCertificateNumber           string `json:"chassis_certificate_number"`              //
-	//DisplacementL                      string `json:"displacement_l"`                          //
-	//CargoLong                          string `json:"cargo_long"`                              //
-	//CargoWide                          string `json:"cargo_wide"`                              //
-	//CargoHigh                          string `json:"cargo_high"`                              //
-	//NumberOfLeafSprings                string `json:"number_of_leaf_springs"`                  //
-	//SteeringMode                       string `json:"steering_mode"`                           //
-	//LoadMassCoefficient                string `json:"load_mass_coefficient"`                   //
-	//SemitrailerSaddleMaxAllowGrossMass string `json:"semitrailer_saddle_max_allow_gross_mass"` //
-	//NumberOfPassengers                 string `json:"number_of_passengers"`                    //
-	//TopSpeed                           string `json:"top_speed"`                               //
-}
-
 // vin查车辆信息
 func A02(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
 	reply = &apis.QueryResponse{}
@@ -90,7 +31,7 @@ func A02(ctx context.Context, params string) (reply *apis.QueryResponse, err err
 
 	db := database.DB()
 
-	var res a02Response
+	var res a04Response
 
 	sql := "select * from v_gadm_vin where vin = ? "
 
@@ -125,12 +66,12 @@ func A02(ctx context.Context, params string) (reply *apis.QueryResponse, err err
 		res.PlateType = req.PlateType
 	}
 
-	a02Str, _ := jsoniter.MarshalToString(res)
-	a02Map := make(map[string]interface{})
-	jsoniter.Unmarshal([]byte(a02Str), &a02Map)
+	a04Str, _ := jsoniter.MarshalToString(res)
+	a04Map := make(map[string]interface{})
+	jsoniter.Unmarshal([]byte(a04Str), &a04Map)
 	//formatData(a02Map)
 
-	reply.Data, _ = jsoniter.MarshalToString(a02Map)
+	reply.Data, _ = jsoniter.MarshalToString(a04Map)
 
 	return reply, nil
 

+ 86 - 0
impl/v1/query/F01.go

@@ -0,0 +1,86 @@
+package query
+
+import (
+	"context"
+	"encoding/json"
+	"gd_adm_data/apis"
+	"gd_adm_data/errors"
+	"gd_adm_data/utils"
+	"strings"
+	"time"
+
+	jsoniter "github.com/json-iterator/go"
+)
+
+// 计算最后投保日期
+func calcLatestInsuredate(reqMap map[string]interface{}) {
+	retLen := utils.MonthLen
+	firstInsuranceDate := ""
+	lastCompulsoryInsuranceDate := ""
+
+	if v, ok := reqMap["first_insurance_date"]; ok {
+		firstInsuranceDate = v.(string)
+	}
+
+	if v, ok := reqMap["last_compulsory_insurance_date"]; ok {
+		lastCompulsoryInsuranceDate = v.(string)
+	}
+
+	if firstInsuranceDate == "" && lastCompulsoryInsuranceDate == "" {
+		return
+	}
+
+	latestInsuranceDateStart := ""
+
+	lastCompulsoryInsuranceDate = strings.TrimSpace(lastCompulsoryInsuranceDate)
+	firstInsuranceDate = strings.TrimSpace(firstInsuranceDate)
+
+	if lastCompulsoryInsuranceDate == "" {
+		return
+	} else if firstInsuranceDate == "" {
+		latestInsuranceDateStart = lastCompulsoryInsuranceDate
+	} else if len(lastCompulsoryInsuranceDate) < utils.MonthLen ||
+		len(firstInsuranceDate) < utils.MonthLen {
+		return
+	} else if lastCompulsoryInsuranceDate[utils.MonthLen-2:utils.MonthLen] == firstInsuranceDate[utils.MonthLen-2:utils.MonthLen] {
+		if len(firstInsuranceDate) == utils.DataLen {
+			latestInsuranceDateStart = lastCompulsoryInsuranceDate + firstInsuranceDate[7:]
+			retLen = utils.DataLen
+		} else {
+			latestInsuranceDateStart = lastCompulsoryInsuranceDate
+		}
+
+	} else {
+		latestInsuranceDateStart = lastCompulsoryInsuranceDate
+	}
+
+	latestInsuranceDateStart = strings.TrimSpace(latestInsuranceDateStart)
+	if len(latestInsuranceDateStart) > utils.DataLen {
+		latestInsuranceDateStart = latestInsuranceDateStart[:utils.DataLen]
+	} else if len(latestInsuranceDateStart) == utils.MonthLen {
+		latestInsuranceDateStart = latestInsuranceDateStart + "-01"
+	}
+
+	latestInsuranceDateStartTime, _ := time.Parse(utils.DayLayout, latestInsuranceDateStart)
+	latestInsuranceDateEnd := latestInsuranceDateStartTime.AddDate(1, 0, 0).String()[:retLen]
+	reqMap["latest_insurance_date_end"] = latestInsuranceDateEnd
+	reqMap["latest_nsurance_date_start"] = latestInsuranceDateStart
+}
+
+// 格式化数据
+func F01(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
+	reply = &apis.QueryResponse{}
+
+	reply.Data = params
+	reqMap := make(map[string]interface{})
+	err = json.Unmarshal([]byte(params), &reqMap)
+	if err != nil {
+		return reply, errors.ParamsError
+	}
+	// 格式化数据
+	formatData(reqMap)
+
+	reply.Data, _ = jsoniter.MarshalToString(reqMap)
+
+	return reply, nil
+}

+ 1 - 0
impl/v1/query/U01.go

@@ -624,6 +624,7 @@ func formatData(reqMap map[string]interface{}) {
 	formatDate(reqMap, "insurance_first_date")
 	formatDate(reqMap, "compulsory_scrap_to")
 	formatYearMonth(reqMap, "last_compulsory_insurance_date")
+	calcLatestInsuredate(reqMap)
 
 	// 格式化数据编码
 	formatDataCode(reqMap, "use_property", "use_property_detail", utils.ParseProperty)

+ 29 - 0
impl/v1/query/U02.go

@@ -0,0 +1,29 @@
+package query
+
+import (
+	"context"
+	"encoding/json"
+	"gd_adm_data/apis"
+	"gd_adm_data/errors"
+
+	jsoniter "github.com/json-iterator/go"
+)
+
+// 补充车辆数据
+func U02(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
+	reply = &apis.QueryResponse{}
+
+	reply.Data = params
+	reqMap := make(map[string]interface{})
+	err = json.Unmarshal([]byte(params), &reqMap)
+	if err != nil {
+		return reply, errors.ParamsError
+	}
+
+	// 补充车辆数据
+	supplementData(reqMap)
+
+	reply.Data, _ = jsoniter.MarshalToString(reqMap)
+
+	return reply, nil
+}

+ 1 - 0
impl/v1/query/V01.go

@@ -28,6 +28,7 @@ type ads3Response struct {
 	UpdatedAt int64  `json:"updated_at"`
 }
 
+// 所有人验证
 func V01(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
 	reply = &apis.QueryResponse{}
 

+ 2 - 1
impl/v1/query/V02.go

@@ -27,6 +27,7 @@ type ads20Response struct {
 	UpdatedAt int64  `json:"updated_at"`
 }
 
+// 人名身份证验证
 func V02(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
 	reply = &apis.QueryResponse{}
 
@@ -41,7 +42,7 @@ func V02(ctx context.Context, params string) (reply *apis.QueryResponse, err err
 	//var name string
 	//var updatedAt int64
 	db := database.DB()
-	err = db.Raw("select name,updated_at from t_adm_ads20 where id_card = ?", req.IdCard).Find(&ads20).Error
+	err = db.Raw("select name,updated_at from t_adm_dws15 where id_card = ?", req.IdCard).Find(&ads20).Error
 	if err != nil {
 		if err == gorm.ErrRecordNotFound {
 			return reply, errors.DataNotExistError

+ 4 - 2
impl/v1/query/center.go

@@ -27,9 +27,11 @@ func Query(ctx context.Context, req *apis.QueryRequest, reply *apis.QueryRespons
 		"IS01": IS01,
 		"V02":  V02,
 		"U01":  U01,
+		"U02":  U02,
 		"A04":  A04,
 		"A05":  A05,
 		"P11":  P11,
+		"F01":  F01,
 	}
 
 	code := strings.ToUpper(req.Code)
@@ -40,14 +42,14 @@ func Query(ctx context.Context, req *apis.QueryRequest, reply *apis.QueryRespons
 		}
 
 		reply.Data = vreply.Data
-		if code == "U01" {
+		/*if code == "U01" {
 			return nil
 		}
 
 		uReply, uerr := U01(ctx, reply.Data)
 		if uerr == nil {
 			reply.Data = uReply.Data
-		}
+		}*/
 		return nil
 	}