fabu renwu

This commit is contained in:
苏尹岚
2020-10-13 18:09:28 +08:00
parent 602f088dba
commit 8f746dcfea

View File

@@ -26,7 +26,7 @@ func PublishJob(ctx *jxcontext.Context, job *model.Job) (err error) {
if job.Count <= 0 { if job.Count <= 0 {
return fmt.Errorf("任务数量不能为0") return fmt.Errorf("任务数量不能为0")
} }
if job.Address != "" { if job.Address != "" && (job.Lng == 0 || job.Lat == 0) {
lng, lat, err := api.AutonaviAPI.GetCoordinateFromAddressByPage(job.Address) lng, lat, err := api.AutonaviAPI.GetCoordinateFromAddressByPage(job.Address)
if err != nil { if err != nil {
return err return err
@@ -45,6 +45,11 @@ func PublishJob(ctx *jxcontext.Context, job *model.Job) (err error) {
} }
}() }()
err = dao.CreateEntity(db, job) err = dao.CreateEntity(db, job)
for _, v := range job.JobSteps {
dao.WrapAddIDCULEntity(v, ctx.GetUserName())
v.JobID = job.ID
err = dao.CreateEntity(db, v)
}
if err != nil { if err != nil {
dao.Rollback(db) dao.Rollback(db)
} }