@@ -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 | |||
@@ -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 | |||
@@ -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+"%") | |||
@@ -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 | |||
@@ -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("<<<<CentralKitchenForSchoolDataStatisticsExport4>>>>>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("<<<<CentralKitchenForSchoolDataStatisticsExport4>>>>>Error:::", err.Error()) | |||
panic(err) | |||
} | |||
} else { | |||
classList, err = tmpClassDb.FindClassSortAscByEnterprise(tmpEnterprise.Id) | |||
if err != nil { | |||
logx.Error(err) | |||
println("<<<<CentralKitchenForSchoolDataStatisticsExport4>>>>>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("<<<<CentralKitchenForSchoolDataStatisticsExport4>>>>>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("<<<<CentralKitchenForSchoolDataStatisticsExport4>>>>>Error:::", err.Error()) | |||
panic(err) | |||
} | |||
} else { | |||
classList, err = tmpClassDb.FindClassSortAscByEnterprise(tmpEnterprise.Id) | |||
if err != nil { | |||
logx.Error(err) | |||
println("<<<<CentralKitchenForSchoolDataStatisticsExport4>>>>>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("<<<<CentralKitchenForSchoolDataStatisticsExport4>>>>>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("<<<<CentralKitchenForSchoolDataStatisticsExport4>>>>>Error:::", err.Error()) | |||
panic(err) | |||
} | |||
} else { | |||
classList, err = tmpClassDb.FindClassSortAscByEnterprise(tmpEnterprise.Id) | |||
if err != nil { | |||
logx.Error(err) | |||
println("<<<<CentralKitchenForSchoolDataStatisticsExport4>>>>>Error:::", err.Error()) | |||
panic(err) | |||
} | |||
} | |||
xlsx := excelize.NewFile() | |||
@@ -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) | |||