@@ -1748,8 +1748,21 @@ func CentralKitchenForSchoolClassList(c *gin.Context) { | |||||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | ||||
return | 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 { | if err != nil { | ||||
e.OutErr(c, e.ERR, err.Error()) | e.OutErr(c, e.ERR, err.Error()) | ||||
return | return | ||||
@@ -611,7 +611,20 @@ func SelfSupportForSchoolClassList(c *gin.Context) { | |||||
return | 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 { | if err != nil { | ||||
e.OutErr(c, e.ERR, err.Error()) | e.OutErr(c, e.ERR, err.Error()) | ||||
return | return | ||||
@@ -2564,6 +2564,21 @@ func CentralKitchenForSchoolPeriodList(req md.CentralKitchenForSchoolPeriodListR | |||||
} | } | ||||
func CentralKitchenForSchoolClassList(req md.CentralKitchenForSchoolClassListReq) (m []*model.Class, count int64, err error) { | 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) | sess := db.Db.Where("enterprise_id =?", req.EnterpriseId) | ||||
if req.Name != "" { | if req.Name != "" { | ||||
sess.And("name like ?", "%"+req.Name+"%") | sess.And("name like ?", "%"+req.Name+"%") | ||||
@@ -579,7 +579,7 @@ func SelfSupportForSchoolPeriodList(req md.SelfSupportForSchoolPeriodListReq) (m | |||||
return | 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) | sess := db.Db.Where("enterprise_id =?", req.EnterpriseId) | ||||
if req.Name != "" { | if req.Name != "" { | ||||
sess.And("name like ?", "%"+req.Name+"%") | sess.And("name like ?", "%"+req.Name+"%") | ||||
@@ -594,6 +594,21 @@ func SelfSupportForSchoolClassList(req md.SelfSupportForSchoolClassListReq) (m [ | |||||
return | 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) { | func SelfSupportForSchoolOrdList(req md.SelfSupportForSchoolOrdListReq) (resp []md.SelfSupportForSchoolOrdListResp, count int64, err error) { | ||||
var classWithUserIdentityIdsOne []int | var classWithUserIdentityIdsOne []int | ||||
var classWithUserIdentityIdsTwo []int | var classWithUserIdentityIdsTwo []int | ||||
@@ -1280,12 +1280,25 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD | |||||
var sumTotal = map[string]int64{} | var sumTotal = map[string]int64{} | ||||
tmpClassDb := db.ClassDb{} | tmpClassDb := db.ClassDb{} | ||||
tmpClassDb.Set(0) | 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 _, class := range *classList { | ||||
for k2, v2 := range v1 { | for k2, v2 := range v1 { | ||||
if k2 == "" { | if k2 == "" { | ||||
@@ -1527,11 +1540,22 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD | |||||
} | } | ||||
tmpClassDb := db.ClassDb{} | tmpClassDb := db.ClassDb{} | ||||
tmpClassDb.Set(0) | 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 _, class := range *classList { | ||||
for k2, v2 := range v1 { | for k2, v2 := range v1 { | ||||
@@ -2646,11 +2670,22 @@ func CentralKitchenForSchoolDataStatisticsContrast(req md.CentralKitchenForSchoo | |||||
} | } | ||||
tmpClassDb := db.ClassDb{} | tmpClassDb := db.ClassDb{} | ||||
tmpClassDb.Set(0) | 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() | xlsx := excelize.NewFile() | ||||
@@ -40,6 +40,14 @@ func (classDb *ClassDb) FindClassByEnterprise(enterpriseId interface{}) (*[]mode | |||||
} | } | ||||
func (classDb *ClassDb) FindClassAscByEnterprise(enterpriseId interface{}) (*[]model.Class, error) { | 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 | var m []model.Class | ||||
if err := classDb.Db.Asc("sort").Where("enterprise_id =?", enterpriseId).Find(&m); err != nil { | if err := classDb.Db.Asc("sort").Where("enterprise_id =?", enterpriseId).Find(&m); err != nil { | ||||
return nil, logx.Error(err) | return nil, logx.Error(err) | ||||