|
@@ -1096,7 +1096,8 @@ func GetLzSurveyProductData(cont context.Context) (err error) {
|
|
|
existList, err := data_manage.GetLzSurveyDataExistByTradeCode(v.SurveyProductId)
|
|
|
existMap := make(map[string]*data_manage.LongzhongSurveyData)
|
|
|
for _, v := range existList {
|
|
|
- existMap[v.DataTime] = v
|
|
|
+ key := strconv.Itoa(int(v.QuotaSampleId)) + v.DataTime
|
|
|
+ existMap[key] = v
|
|
|
}
|
|
|
fmt.Println(existMap)
|
|
|
pageIndex := 1
|
|
@@ -1156,12 +1157,14 @@ func GetLzSurveyProductData(cont context.Context) (err error) {
|
|
|
shouldDateTimeStr := shouldDateTime.Format(utils.FormatDate)
|
|
|
|
|
|
//fmt.Println("QuotaSampleID:", n.QuotaSampleID, "taskActualFinishTime:", dateTimeStr, "taskShouldFinishTime:", shouldDateTimeStr)
|
|
|
- //count, err := models.GetLzSurveyDataCount(v.SurveyProductId, int(v.QuotaSampleId), shouldDateTimeStr)
|
|
|
- //if err != nil {
|
|
|
- // msg = "获取隆众调研指标数据失败:err " + err.Error()
|
|
|
- // return err
|
|
|
- //}
|
|
|
- if findItem, ok := existMap[shouldDateTimeStr]; !ok && n.InputValue != "0" {
|
|
|
+ count, err := models.GetLzSurveyDataCount(v.SurveyProductId, int(v.QuotaSampleId), shouldDateTimeStr)
|
|
|
+ if err != nil {
|
|
|
+ msg = "获取隆众调研指标数据失败:err " + err.Error()
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ key := strconv.Itoa(int(v.QuotaSampleId)) + shouldDateTimeStr
|
|
|
+ if count <= 0 {
|
|
|
+ fmt.Println("not exist:" + key)
|
|
|
item := new(models.LongzhongSurveyData)
|
|
|
item.SurveyProductId = v.SurveyProductId
|
|
|
item.ProjectQuotaId = n.ProjectQuotaID
|
|
@@ -1199,11 +1202,58 @@ func GetLzSurveyProductData(cont context.Context) (err error) {
|
|
|
return err
|
|
|
}
|
|
|
} else {
|
|
|
- if findItem != nil && findItem.InputValue != n.InputValue && n.InputValue != "0" {
|
|
|
- models.ModifyLzSurveyData(n.InputValue, findItem.SurveyDataId)
|
|
|
+ fmt.Println("exist:" + key)
|
|
|
+ err = models.ModifyLzSurveyDataV1(n.InputValue, int(n.QuotaSampleID), shouldDateTimeStr)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("ModifyLzSurveyDataV1 Err:" + err.Error())
|
|
|
}
|
|
|
- fmt.Println("exist:", shouldDateTimeStr)
|
|
|
}
|
|
|
+ //key:=strconv.Itoa(int(v.QuotaSampleId))+shouldDateTimeStr
|
|
|
+ //if findItem, ok := existMap[key]; !ok && n.InputValue != "0" {
|
|
|
+ // fmt.Println("not exist:"+key)
|
|
|
+ // item := new(models.LongzhongSurveyData)
|
|
|
+ // item.SurveyProductId = v.SurveyProductId
|
|
|
+ // item.ProjectQuotaId = n.ProjectQuotaID
|
|
|
+ // item.BreedId = n.BreedID
|
|
|
+ // item.BreedName = n.BreedName
|
|
|
+ // item.QuotaId = n.QuotaID
|
|
|
+ // item.QuotaName = n.QuotaName
|
|
|
+ // item.UnitId = n.UnitID
|
|
|
+ // item.UnitName = n.UnitName
|
|
|
+ // item.SampleType = n.SampleType
|
|
|
+ // item.SampleId = n.SampleID
|
|
|
+ // item.SampleName = n.SampleName
|
|
|
+ // item.DeviceId = n.DeviceID
|
|
|
+ // item.Device = n.Device
|
|
|
+ // item.ProductCraftId = n.ProductCraftID
|
|
|
+ // item.ProductCraft = n.ProductCraft
|
|
|
+ // item.ProductLine = n.ProductLine
|
|
|
+ // item.InputMode = n.InputMode
|
|
|
+ // item.Frequency = n.Frequency
|
|
|
+ // item.InputValue = n.InputValue
|
|
|
+ // item.TaskShouldFinishTime = n.TaskShouldFinishTime
|
|
|
+ // item.CustomId = n.CustomID
|
|
|
+ // item.CustomType = n.CustomType
|
|
|
+ // item.Custom = n.Custom
|
|
|
+ // item.QuotaSampleId = n.QuotaSampleID
|
|
|
+ // item.TaskActualFinishTime = n.TaskActualFinishTime
|
|
|
+ // //item.AreaName = n.AreaName.(string)
|
|
|
+ // //item.ProvinceName = n.ProvinceName.(string)
|
|
|
+ // item.ResearchStartData = n.ResearchStartDate
|
|
|
+ // item.ResearchStopData = n.ResearchStopDate
|
|
|
+ // item.DataTime = shouldDateTimeStr
|
|
|
+ // err = models.AddLongzhongSurveyData(item)
|
|
|
+ // if err != nil {
|
|
|
+ // msg = "新增调研指标数据失败:err " + err.Error()
|
|
|
+ // return err
|
|
|
+ // }
|
|
|
+ //} else {
|
|
|
+ // fmt.Println("exist:"+key)
|
|
|
+ // if findItem != nil && findItem.InputValue != n.InputValue && n.InputValue != "0" {
|
|
|
+ // models.ModifyLzSurveyData(n.InputValue, findItem.SurveyDataId)
|
|
|
+ // }
|
|
|
+ // fmt.Println("exist:", shouldDateTimeStr)
|
|
|
+ //}
|
|
|
}
|
|
|
pageIndex = pageIndex + 1
|
|
|
totalPage := utils.PageCount(int(dataList.Response.Total), 100)
|