Browse Source

Merge branch 'master' into feature/v1.0.4

lianbingjie 1 năm trước cách đây
mục cha
commit
a490aa84f5
1 tập tin đã thay đổi với 80 bổ sung21 xóa
  1. 80 21
      api/internal/service/employService.go

+ 80 - 21
api/internal/service/employService.go

@@ -670,19 +670,19 @@ func employInfoPerson(table, employKey, findKey string, in *types.InfoEmployinfo
 	wuyeData1 := &[]map[string]interface{}{}
 	wuyeData2 := &[]map[string]interface{}{}
 	if len(infoId1Arr) > 0 {
-		infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select   %s, is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ", employKey, table, employKey, strings.Join(infoId1Arr, "','"), employKey), in.PositionId)
+		infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select   %s, is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ,type  order  by type", employKey, table, employKey, strings.Join(infoId1Arr, "','"), employKey), in.PositionId)
 	}
 	if len(infoId2Arr) > 0 {
-		infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,  is_ignore,status,id,type from  %s   where position_id =? and  %s in '%s')    GROUP BY %s ", employKey, table, employKey, strings.Join(infoId2Arr, "','"), employKey), in.PositionId)
+		infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,  is_ignore,status,id,type from  %s   where position_id =? and  %s in '%s')    GROUP BY %s ,type order  by type ", employKey, table, employKey, strings.Join(infoId2Arr, "','"), employKey), in.PositionId)
 	}
 	if len(niJianIdArr) > 0 {
-		niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,   is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ", employKey, table, employKey, strings.Join(niJianIdArr, "','"), employKey), in.PositionId)
+		niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,   is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s  ,type order  by type", employKey, table, employKey, strings.Join(niJianIdArr, "','"), employKey), in.PositionId)
 	}
 	if len(wuye1Arr) > 0 {
-		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,  is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')  GROUP BY %s ", employKey, table, employKey, strings.Join(wuye1Arr, "','"), employKey), in.PositionId)
+		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,  is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')  GROUP BY %s  ,type order  by type", employKey, table, employKey, strings.Join(wuye1Arr, "','"), employKey), in.PositionId)
 	}
 	if len(wuye2Arr) > 0 {
-		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select   %s, is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ", employKey, table, employKey, strings.Join(wuye2Arr, "','"), employKey), in.PositionId)
+		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select   %s, is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ,type order  by type ", employKey, table, employKey, strings.Join(wuye2Arr, "','"), employKey), in.PositionId)
 	}
 	for _, v := range *infoData1 {
 		valueMap := map[string]interface{}{
@@ -695,7 +695,12 @@ func employInfoPerson(table, employKey, findKey string, in *types.InfoEmployinfo
 			"type":        1,
 		}
 		sourceId := gconv.String(v[employKey])
-		data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+		if _, ok := data[sourceId]; ok {
+			data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+		} else {
+			data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		}
 	}
 	for _, v := range *infoData2 {
 		valueMap := map[string]interface{}{
@@ -708,7 +713,13 @@ func employInfoPerson(table, employKey, findKey string, in *types.InfoEmployinfo
 			"type":        1,
 		}
 		sourceId := gconv.String(v[employKey])
-		data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+		if _, ok := data[sourceId]; ok {
+			data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		} else {
+			data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		}
 	}
 	for _, v := range *niJianData {
 		valueMap := map[string]interface{}{
@@ -721,7 +732,13 @@ func employInfoPerson(table, employKey, findKey string, in *types.InfoEmployinfo
 			"type":        1,
 		}
 		sourceId := gconv.String(v[employKey])
-		data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+		if _, ok := data[sourceId]; ok {
+			data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		} else {
+			data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		}
 	}
 	for _, v := range *wuyeData1 {
 		valueMap := map[string]interface{}{
@@ -734,7 +751,13 @@ func employInfoPerson(table, employKey, findKey string, in *types.InfoEmployinfo
 			"type":        1,
 		}
 		sourceId := gconv.String(v[employKey])
-		data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+		if _, ok := data[sourceId]; ok {
+			data[sourceId] = EmployHandle(data[sourceId], v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		} else {
+			data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		}
 	}
 	for _, v := range *wuyeData2 {
 		valueMap := map[string]interface{}{
@@ -747,7 +770,13 @@ func employInfoPerson(table, employKey, findKey string, in *types.InfoEmployinfo
 			"type":        1,
 		}
 		sourceId := gconv.String(v[employKey])
-		data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+		if _, ok := data[sourceId]; ok {
+			data[sourceId] = EmployHandle(data[sourceId], v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		} else {
+			data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		}
 	}
 	return data
 }
@@ -761,19 +790,19 @@ func employInfoEnt(table, employKey, findKey, depIDArr string, in *types.InfoEmp
 	wuyeData1 := &[]map[string]interface{}{}
 	wuyeData2 := &[]map[string]interface{}{}
 	if len(infoId1Arr) > 0 {
-		infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s in ('%s') and  source=? and    ent_dept_id in  (%s) GROUP BY %s ", employKey, table, employKey, strings.Join(infoId1Arr, "','"), depIDArr, employKey), 1)
+		infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s in ('%s') and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,type order  by type", employKey, table, employKey, strings.Join(infoId1Arr, "','"), depIDArr, employKey), 1)
 	}
 	if len(infoId2Arr) > 0 {
-		infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s in ('%s') and  source=? and    ent_dept_id in  (%s)  GROUP BY %s ", employKey, table, employKey, strings.Join(infoId2Arr, "','"), depIDArr, employKey), 2)
+		infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s in ('%s') and  source=? and    ent_dept_id in  (%s)  GROUP BY %s ,type order  by type", employKey, table, employKey, strings.Join(infoId2Arr, "','"), depIDArr, employKey), 2)
 	}
 	if len(niJianIdArr) > 0 {
-		niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s  in ('%s') and  source=? and    ent_dept_id in  (%s) GROUP BY %s ", employKey, table, employKey, strings.Join(niJianIdArr, "','"), depIDArr, employKey), 2)
+		niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s  in ('%s') and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,type order  by type", employKey, table, employKey, strings.Join(niJianIdArr, "','"), depIDArr, employKey), 2)
 	}
 	if len(wuye1Arr) > 0 {
-		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,  id,is_ignore,status ,type  from  %s   where %s in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s)  GROUP BY %s  ", employKey, table, employKey, strings.Join(wuye1Arr, "','"), depIDArr, employKey), 1)
+		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,  id,is_ignore,status ,type  from  %s   where %s in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s)  GROUP BY %s  ,type order  by type", employKey, table, employKey, strings.Join(wuye1Arr, "','"), depIDArr, employKey), 1)
 	}
 	if len(wuye2Arr) > 0 {
-		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s id,is_ignore,status ,type  from  %s   where %s  in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s) GROUP BY %s ", employKey, table, employKey, strings.Join(wuye2Arr, "','"), depIDArr, employKey), 2)
+		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s id,is_ignore,status ,type  from  %s   where %s  in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,type order  by type", employKey, table, employKey, strings.Join(wuye2Arr, "','"), depIDArr, employKey), 2)
 	}
 	for _, v := range *infoData1 {
 		valueMap := map[string]interface{}{
@@ -786,7 +815,13 @@ func employInfoEnt(table, employKey, findKey, depIDArr string, in *types.InfoEmp
 			"type":        1,
 		}
 		sourceId := gconv.String(v[employKey])
-		data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+		if _, ok := data[sourceId]; ok {
+			data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		} else {
+			data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		}
 	}
 	for _, v := range *infoData2 {
 		valueMap := map[string]interface{}{
@@ -799,7 +834,13 @@ func employInfoEnt(table, employKey, findKey, depIDArr string, in *types.InfoEmp
 			"type":        1,
 		}
 		sourceId := gconv.String(v[employKey])
-		data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+		if _, ok := data[sourceId]; ok {
+			data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		} else {
+			data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		}
 	}
 	for _, v := range *niJianData {
 		valueMap := map[string]interface{}{
@@ -812,7 +853,13 @@ func employInfoEnt(table, employKey, findKey, depIDArr string, in *types.InfoEmp
 			"type":        1,
 		}
 		sourceId := gconv.String(v[employKey])
-		data[sourceId] = EmployHandle(valueMap, v, version, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+		if _, ok := data[sourceId]; ok {
+			data[sourceId] = EmployHandle(data[sourceId], v, version, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		} else {
+			data[sourceId] = EmployHandle(valueMap, v, version, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		}
 	}
 	for _, v := range *wuyeData1 {
 		valueMap := map[string]interface{}{
@@ -825,7 +872,13 @@ func employInfoEnt(table, employKey, findKey, depIDArr string, in *types.InfoEmp
 			"type":        1,
 		}
 		sourceId := gconv.String(v[employKey])
-		data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+		if _, ok := data[sourceId]; ok {
+			data[sourceId] = EmployHandle(data[sourceId], v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		} else {
+			data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		}
 	}
 	for _, v := range *wuyeData2 {
 		valueMap := map[string]interface{}{
@@ -838,7 +891,13 @@ func employInfoEnt(table, employKey, findKey, depIDArr string, in *types.InfoEmp
 			"type":        1,
 		}
 		sourceId := gconv.String(v[employKey])
-		data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+		if _, ok := data[sourceId]; ok {
+			data[sourceId] = EmployHandle(data[sourceId], v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		} else {
+			data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
+
+		}
 	}
 	return data
 }
@@ -863,7 +922,7 @@ func EmployHandle(valueMap map[string]interface{}, employData map[string]interfa
 			}
 		case 3:
 			if valueMap["employ2"] != nil {
-				employ3 = gconv.Bool(valueMap["employ2"])
+				employ2 = gconv.Bool(valueMap["employ2"])
 			}
 			if employStatus == 1 {
 				employ3 = true