diff --git a/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go b/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go index aea7c61..65ae53c 100644 --- a/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go +++ b/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go @@ -1748,8 +1748,21 @@ func CentralKitchenForSchoolClassList(c *gin.Context) { e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") return } + //TODO::判断单位类型 + if enterprise.Kind == enum.EnterpriseKindByCentralKitchenForSchool { + resp, total, err := svc2.CentralKitchenForSchoolClassList(req) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + e.OutSuc(c, map[string]interface{}{ + "list": resp, + "total": total, + }, nil) + return + } - resp, total, err := svc2.CentralKitchenForSchoolClassList(req) + resp, total, err := svc2.CentralKitchenForSchoolClassListBySort(req) if err != nil { e.OutErr(c, e.ERR, err.Error()) return diff --git a/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go b/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go index af604a5..65a53ab 100644 --- a/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go +++ b/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go @@ -611,7 +611,20 @@ func SelfSupportForSchoolClassList(c *gin.Context) { return } - resp, total, err := svc2.SelfSupportForSchoolClassList(req) + //TODO::判断单位类型 + if enterprise.Kind == enum.EnterpriseKindByCentralKitchenForSchool { + resp, total, err := svc2.SelfSupportForSchoolClassList(req) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + e.OutSuc(c, map[string]interface{}{ + "list": resp, + "total": total, + }, nil) + return + } + resp, total, err := svc2.SelfSupportForSchoolClassListBySort(req) if err != nil { e.OutErr(c, e.ERR, err.Error()) return diff --git a/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go b/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go index 4aef5be..a4d5899 100644 --- a/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go +++ b/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go @@ -2564,6 +2564,21 @@ func CentralKitchenForSchoolPeriodList(req md.CentralKitchenForSchoolPeriodListR } func CentralKitchenForSchoolClassList(req md.CentralKitchenForSchoolClassListReq) (m []*model.Class, count int64, err error) { + sess := db.Db.Where("enterprise_id =?", req.EnterpriseId) + if req.Name != "" { + sess.And("name like ?", "%"+req.Name+"%") + } + if req.GradeId != 0 { + sess.And("grade_id = ?", req.GradeId) + } + count, err = sess.Asc("id").Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m) + if err != nil { + return nil, 0, err + } + return +} + +func CentralKitchenForSchoolClassListBySort(req md.CentralKitchenForSchoolClassListReq) (m []*model.Class, count int64, err error) { sess := db.Db.Where("enterprise_id =?", req.EnterpriseId) if req.Name != "" { sess.And("name like ?", "%"+req.Name+"%") diff --git a/app/admin/svc/enterprise_manage/svc_self_support_for_school.go b/app/admin/svc/enterprise_manage/svc_self_support_for_school.go index 3045c34..3fc4f1a 100644 --- a/app/admin/svc/enterprise_manage/svc_self_support_for_school.go +++ b/app/admin/svc/enterprise_manage/svc_self_support_for_school.go @@ -579,7 +579,7 @@ func SelfSupportForSchoolPeriodList(req md.SelfSupportForSchoolPeriodListReq) (m return } -func SelfSupportForSchoolClassList(req md.SelfSupportForSchoolClassListReq) (m []*model.Class, count int64, err error) { +func SelfSupportForSchoolClassListBySort(req md.SelfSupportForSchoolClassListReq) (m []*model.Class, count int64, err error) { sess := db.Db.Where("enterprise_id =?", req.EnterpriseId) if req.Name != "" { sess.And("name like ?", "%"+req.Name+"%") @@ -594,6 +594,21 @@ func SelfSupportForSchoolClassList(req md.SelfSupportForSchoolClassListReq) (m [ return } +func SelfSupportForSchoolClassList(req md.SelfSupportForSchoolClassListReq) (m []*model.Class, count int64, err error) { + sess := db.Db.Where("enterprise_id =?", req.EnterpriseId) + if req.Name != "" { + sess.And("name like ?", "%"+req.Name+"%") + } + if req.GradeId != 0 { + sess.And("grade_id = ?", req.GradeId) + } + count, err = sess.Asc("id").Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m) + if err != nil { + return nil, 0, err + } + return +} + func SelfSupportForSchoolOrdList(req md.SelfSupportForSchoolOrdListReq) (resp []md.SelfSupportForSchoolOrdListResp, count int64, err error) { var classWithUserIdentityIdsOne []int var classWithUserIdentityIdsTwo []int diff --git a/app/admin/svc/svc_data_statisstics.go b/app/admin/svc/svc_data_statisstics.go index 10c3e9b..24af2ae 100644 --- a/app/admin/svc/svc_data_statisstics.go +++ b/app/admin/svc/svc_data_statisstics.go @@ -1280,12 +1280,25 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD var sumTotal = map[string]int64{} tmpClassDb := db.ClassDb{} tmpClassDb.Set(0) - classList, err := tmpClassDb.FindClassAscByEnterprise(tmpEnterprise.Id) - if err != nil { - logx.Error(err) - println("<<<>>>>Error:::", err.Error()) - panic(err) + + var classList *[]model.Class + //TODO::判断单位类型 + if tmpEnterprise.Kind == enum.EnterpriseKindByCentralKitchenForSchool { + classList, err = tmpClassDb.FindClassAscByEnterprise(tmpEnterprise.Id) + if err != nil { + logx.Error(err) + println("<<<>>>>Error:::", err.Error()) + panic(err) + } + } else { + classList, err = tmpClassDb.FindClassSortAscByEnterprise(tmpEnterprise.Id) + if err != nil { + logx.Error(err) + println("<<<>>>>Error:::", err.Error()) + panic(err) + } } + for _, class := range *classList { for k2, v2 := range v1 { if k2 == "" { @@ -1527,11 +1540,22 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD } tmpClassDb := db.ClassDb{} tmpClassDb.Set(0) - classList, err := tmpClassDb.FindClassAscByEnterprise(tmpEnterprise.Id) - if err != nil { - logx.Error(err) - println("<<<>>>>Error:::", err.Error()) - panic(err) + var classList *[]model.Class + //TODO::判断单位类型 + if tmpEnterprise.Kind == enum.EnterpriseKindByCentralKitchenForSchool { + classList, err = tmpClassDb.FindClassAscByEnterprise(tmpEnterprise.Id) + if err != nil { + logx.Error(err) + println("<<<>>>>Error:::", err.Error()) + panic(err) + } + } else { + classList, err = tmpClassDb.FindClassSortAscByEnterprise(tmpEnterprise.Id) + if err != nil { + logx.Error(err) + println("<<<>>>>Error:::", err.Error()) + panic(err) + } } for _, class := range *classList { for k2, v2 := range v1 { @@ -2646,11 +2670,22 @@ func CentralKitchenForSchoolDataStatisticsContrast(req md.CentralKitchenForSchoo } tmpClassDb := db.ClassDb{} tmpClassDb.Set(0) - classList, err := tmpClassDb.FindClassAscByEnterprise(tmpEnterprise.Id) - if err != nil { - logx.Error(err) - println("<<<>>>>Error:::", err.Error()) - panic(err) + var classList *[]model.Class + //TODO::判断单位类型 + if tmpEnterprise.Kind == enum.EnterpriseKindByCentralKitchenForSchool { + classList, err = tmpClassDb.FindClassAscByEnterprise(tmpEnterprise.Id) + if err != nil { + logx.Error(err) + println("<<<>>>>Error:::", err.Error()) + panic(err) + } + } else { + classList, err = tmpClassDb.FindClassSortAscByEnterprise(tmpEnterprise.Id) + if err != nil { + logx.Error(err) + println("<<<>>>>Error:::", err.Error()) + panic(err) + } } xlsx := excelize.NewFile() diff --git a/app/db/db_class.go b/app/db/db_class.go index e0cbef6..8619b25 100644 --- a/app/db/db_class.go +++ b/app/db/db_class.go @@ -40,6 +40,14 @@ func (classDb *ClassDb) FindClassByEnterprise(enterpriseId interface{}) (*[]mode } func (classDb *ClassDb) FindClassAscByEnterprise(enterpriseId interface{}) (*[]model.Class, error) { + var m []model.Class + if err := classDb.Db.Asc("id").Where("enterprise_id =?", enterpriseId).Find(&m); err != nil { + return nil, logx.Error(err) + } + return &m, nil +} + +func (classDb *ClassDb) FindClassSortAscByEnterprise(enterpriseId interface{}) (*[]model.Class, error) { var m []model.Class if err := classDb.Db.Asc("sort").Where("enterprise_id =?", enterpriseId).Find(&m); err != nil { return nil, logx.Error(err)