|
@@ -10,51 +10,6 @@ import (
|
|
|
"unicode/utf8"
|
|
|
)
|
|
|
|
|
|
-type Info struct {
|
|
|
- Contact map[string]*Contact
|
|
|
-}
|
|
|
-type Contact struct {
|
|
|
- Per string
|
|
|
- Tel string
|
|
|
- Buyer bool
|
|
|
- Agency bool
|
|
|
- Winner bool
|
|
|
- Owner bool
|
|
|
-}
|
|
|
-
|
|
|
-// 处理地域代码
|
|
|
-func CalculateRegionCode(area string, city string, district string) (area_code string, city_code string, district_code string) {
|
|
|
- area_code, city_code, district_code = "000000", "", ""
|
|
|
- if district != "" {
|
|
|
- key := area + "~" + city + "~" + district + "~"
|
|
|
- code := RegionCodeData[key]
|
|
|
- if code != "" {
|
|
|
- district_code = code
|
|
|
- city_code = code[:4] + "00"
|
|
|
- area_code = code[:2] + "0000"
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- if city != "" {
|
|
|
- key := area + "~" + city + "~" + "" + "~"
|
|
|
- code := RegionCodeData[key]
|
|
|
- if code != "" {
|
|
|
- city_code = code
|
|
|
- area_code = city_code[:2] + "0000"
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- if area != "" {
|
|
|
- key := area + "~" + "" + "~" + "" + "~"
|
|
|
- code := RegionCodeData[key]
|
|
|
- if code != "" {
|
|
|
- area_code = code
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
// 单位分割~去重 中标单位
|
|
|
func SegmentationEntName(name_1 string, name_2 string) ([]string, []bool) {
|
|
|
new_arr := []string{}
|
|
@@ -94,47 +49,6 @@ func SegmentationEntName(name_1 string, name_2 string) ([]string, []bool) {
|
|
|
return new_arr, new_bool
|
|
|
}
|
|
|
|
|
|
-// 转二进制
|
|
|
-func Str2DEC(s string) (num int) {
|
|
|
- l := len(s)
|
|
|
- for i := l - 1; i >= 0; i-- {
|
|
|
- num += (int(s[l-i-1]) & 0xf) << uint8(i)
|
|
|
- }
|
|
|
- return
|
|
|
-}
|
|
|
-func ConvertToBin(num int) string {
|
|
|
- s := ""
|
|
|
- if num == 0 {
|
|
|
- return "0"
|
|
|
- }
|
|
|
- for ; num > 0; num /= 2 {
|
|
|
- lsb := num % 2
|
|
|
- s = strconv.Itoa(lsb) + s
|
|
|
- }
|
|
|
- return s
|
|
|
-}
|
|
|
-
|
|
|
-func toMegaBytes(bytes uint64) float64 {
|
|
|
- return float64(bytes) / 1024 / 1024
|
|
|
-}
|
|
|
-func traceMemStats() {
|
|
|
- var ms runtime.MemStats
|
|
|
- runtime.ReadMemStats(&ms)
|
|
|
- var result = make([]float64, 7)
|
|
|
- result[0] = float64(ms.HeapObjects)
|
|
|
- result[1] = toMegaBytes(ms.HeapAlloc)
|
|
|
- result[2] = toMegaBytes(ms.TotalAlloc)
|
|
|
- result[3] = toMegaBytes(ms.HeapSys)
|
|
|
- result[4] = toMegaBytes(ms.HeapIdle)
|
|
|
- result[5] = toMegaBytes(ms.HeapReleased)
|
|
|
- result[6] = toMegaBytes(ms.HeapIdle - ms.HeapReleased)
|
|
|
-
|
|
|
- for _, v := range result {
|
|
|
- fmt.Printf("%.2f\t", v)
|
|
|
- }
|
|
|
- fmt.Printf("\n")
|
|
|
-}
|
|
|
-
|
|
|
func IsMarkInterfaceArr(t interface{}) []string {
|
|
|
sub_list := []string{}
|
|
|
if list_3, ok_3 := t.([]string); ok_3 {
|
|
@@ -151,6 +65,22 @@ func IsMarkInterfaceArr(t interface{}) []string {
|
|
|
return sub_list
|
|
|
}
|
|
|
|
|
|
+func IsMarkInterfaceMap(t interface{}) []map[string]interface{} {
|
|
|
+ p_list := []map[string]interface{}{}
|
|
|
+ if yl_list_1, ok_3 := t.([]map[string]interface{}); ok_3 {
|
|
|
+ p_list = yl_list_1
|
|
|
+ return p_list
|
|
|
+ }
|
|
|
+ if yl_list_1, ok_1 := t.(primitive.A); ok_1 {
|
|
|
+ p_list = qu.ObjArrToMapArr(yl_list_1)
|
|
|
+ } else {
|
|
|
+ if yl_list_2, ok_2 := t.([]interface{}); ok_2 {
|
|
|
+ p_list = qu.ObjArrToMapArr(yl_list_2)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return p_list
|
|
|
+}
|
|
|
+
|
|
|
// 获取最优企业
|
|
|
func GetOneBaseCompany(arr []map[string]interface{}) int {
|
|
|
index := 0
|
|
@@ -172,6 +102,24 @@ func GetOneBaseCompany(arr []map[string]interface{}) int {
|
|
|
return index
|
|
|
}
|
|
|
|
|
|
+// 创建企业信息
|
|
|
+func GetOneQyxyInfo(name string) map[string]interface{} {
|
|
|
+ qyxy_info := map[string]interface{}{}
|
|
|
+ dataArr, _ := QyxyMgo.Find("qyxy_std", map[string]interface{}{"company_name": name}, map[string]interface{}{"updatetime": -1}, nil)
|
|
|
+ if len(dataArr) > 0 {
|
|
|
+ qyxy_info = dataArr[0] //补充企业信息
|
|
|
+ } else {
|
|
|
+ data := SpiMgo.FindOne("company_history_name", map[string]interface{}{
|
|
|
+ "history_name": name,
|
|
|
+ })
|
|
|
+ if len(data) > 0 {
|
|
|
+ company_id := qu.ObjToString(data["company_id"])
|
|
|
+ qyxy_info = QyxyMgo.FindOne("qyxy_std", map[string]interface{}{"_id": company_id})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return qyxy_info
|
|
|
+}
|
|
|
+
|
|
|
// 清洗日期~
|
|
|
func cleanErrDateTime(datetime string) bool {
|
|
|
arr := strings.Split(datetime, "-")
|
|
@@ -183,3 +131,44 @@ func cleanErrDateTime(datetime string) bool {
|
|
|
}
|
|
|
return false
|
|
|
}
|
|
|
+
|
|
|
+// 转二进制 用不到......
|
|
|
+func Str2DEC(s string) (num int) {
|
|
|
+ l := len(s)
|
|
|
+ for i := l - 1; i >= 0; i-- {
|
|
|
+ num += (int(s[l-i-1]) & 0xf) << uint8(i)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+func ConvertToBin(num int) string {
|
|
|
+ s := ""
|
|
|
+ if num == 0 {
|
|
|
+ return "0"
|
|
|
+ }
|
|
|
+ for ; num > 0; num /= 2 {
|
|
|
+ lsb := num % 2
|
|
|
+ s = strconv.Itoa(lsb) + s
|
|
|
+ }
|
|
|
+ return s
|
|
|
+}
|
|
|
+
|
|
|
+func toMegaBytes(bytes uint64) float64 {
|
|
|
+ return float64(bytes) / 1024 / 1024
|
|
|
+}
|
|
|
+func traceMemStats() {
|
|
|
+ var ms runtime.MemStats
|
|
|
+ runtime.ReadMemStats(&ms)
|
|
|
+ var result = make([]float64, 7)
|
|
|
+ result[0] = float64(ms.HeapObjects)
|
|
|
+ result[1] = toMegaBytes(ms.HeapAlloc)
|
|
|
+ result[2] = toMegaBytes(ms.TotalAlloc)
|
|
|
+ result[3] = toMegaBytes(ms.HeapSys)
|
|
|
+ result[4] = toMegaBytes(ms.HeapIdle)
|
|
|
+ result[5] = toMegaBytes(ms.HeapReleased)
|
|
|
+ result[6] = toMegaBytes(ms.HeapIdle - ms.HeapReleased)
|
|
|
+
|
|
|
+ for _, v := range result {
|
|
|
+ fmt.Printf("%.2f\t", v)
|
|
|
+ }
|
|
|
+ fmt.Printf("\n")
|
|
|
+}
|