Ver código fonte

提交代码

陈少旭 2 semanas atrás
pai
commit
a29f82fdcc
1 arquivos alterados com 21 adições e 4 exclusões
  1. 21 4
      service/statistis_qc_service.go

+ 21 - 4
service/statistis_qc_service.go Ver arquivo

@@ -951,11 +951,28 @@ type QualityControlStandard struct {
951 951
 }
952 952
 
953 953
 func getQualityControlStandards(org_id int64) ([]QualityControlStandard, error) {
954
-	var standards []QualityControlStandard
955
-	if err := readDb.Model(&models.XtQualityControlStandard{}).Select("re.project_name as project_name,re.item_name as item_name,xt_quality_control_standard.inspection_major as inspection_major,xt_quality_control_standard.inspection_minor as inspection_minor").Joins("join xt_inspection_reference re on re.project_id = xt_quality_control_standard.inspection_major and re.item_id = xt_quality_control_standard.inspection_minor and re.org_id = ?", org_id).Where("xt_quality_control_standard.user_org_id = ? and xt_quality_control_standard.status = 1", org_id).Scan(&standards).Error; err != nil {
956
-		return nil, err
954
+	db := XTReadDB()
955
+	var count int64
956
+	err = db.Model(&models.InspectionReference{}).Where("status = 1 AND org_id = ?", org_id).Count(&count).Error
957
+
958
+	//count, _ := FindOrgInspectionCount(org_id)
959
+
960
+	if count == 0 {
961
+
962
+		var standards []QualityControlStandard
963
+		if err := readDb.Model(&models.XtQualityControlStandard{}).Select("re.project_name as project_name,re.item_name as item_name,xt_quality_control_standard.inspection_major as inspection_major,xt_quality_control_standard.inspection_minor as inspection_minor").Joins("join xt_inspection_reference re on re.project_id = xt_quality_control_standard.inspection_major and re.id = xt_quality_control_standard.inspection_minor and re.org_id = 0").Where("xt_quality_control_standard.user_org_id = ? and xt_quality_control_standard.status = 1", org_id).Scan(&standards).Error; err != nil {
964
+			return nil, err
965
+		}
966
+		return standards, nil
967
+	} else {
968
+		var standards []QualityControlStandard
969
+		if err := readDb.Model(&models.XtQualityControlStandard{}).Select("re.project_name as project_name,re.item_name as item_name,xt_quality_control_standard.inspection_major as inspection_major,xt_quality_control_standard.inspection_minor as inspection_minor").Joins("join xt_inspection_reference re on re.project_id = xt_quality_control_standard.inspection_major and re.item_id = xt_quality_control_standard.inspection_minor and re.org_id = ?", org_id).Where("xt_quality_control_standard.user_org_id = ? and xt_quality_control_standard.status = 1", org_id).Scan(&standards).Error; err != nil {
970
+			return nil, err
971
+		}
972
+		return standards, nil
973
+
957 974
 	}
958
-	return standards, nil
975
+
959 976
 }
960 977
 
961 978
 type DialysisQualityStat struct {