_,err:=engine.Table("pln_workorder").Cols("status").Where("finr = ? and workordernr = ? and status <= ?",finr,workordernr,status).Update(&map[string]interface{}{"status":40})
_,err:=session.Table("pln_workorder").Cols("status").Where("finr = ? and workordernr = ? and status <= ?",finr,workordernr,status).Update(&map[string]interface{}{"status":40})
iferr!=nil{
session.Rollback()
session.Close()
etcd.G_jobLock.UnLock()
returnerr
}
//查询生产订单对应的客户订单是否有小于80状态的订单
varplnmodels.Pln_workorder
_,err=engine.Table("pln_workorder").Where("finr = ? and workordernr = ?",finr,workordernr).Get(&pln)
_,err=session.Table("pln_workorder").Where("finr = ? and workordernr = ?",finr,workordernr).Get(&pln)
iferr!=nil{
session.Rollback()
session.Close()
etcd.G_jobLock.UnLock()
returnerr
}
//更新客户订单
_,err=engine.Table("pln_custorder").Cols("status").Where("finr = ? and custordernr = ? and status <= ?",finr,pln.Custordernr,status).Update(&map[string]interface{}{"status":40})
_,err=session.Table("pln_custorder").Cols("status").Where("finr = ? and custordernr = ? and status <= ?",finr,pln.Custordernr,status).Update(&map[string]interface{}{"status":40})
iferr!=nil{
session.Rollback()
session.Close()
etcd.G_jobLock.UnLock()
returnerr
}
case80:
//更新生产订单表
_,err:=engine.Table("pln_workorder").Cols("status").Where("finr = ? and workordernr = ? and status <= ?",finr,workordernr,status).Update(&map[string]interface{}{"status":80})
_,err:=session.Table("pln_workorder").Cols("status").Where("finr = ? and workordernr = ? and status <= ?",finr,workordernr,status).Update(&map[string]interface{}{"status":80})
iferr!=nil{
session.Rollback()
session.Close()
etcd.G_jobLock.UnLock()
returnerr
}
//查询生产订单对应的客户订单是否有小于80状态的订单
varplnmodels.Pln_workorder
_,err=engine.Table("pln_workorder").Where("finr = ? and workordernr = ?",finr,workordernr).Get(&pln)
_,err=session.Table("pln_workorder").Where("finr = ? and workordernr = ?",finr,workordernr).Get(&pln)
iferr!=nil{
session.Rollback()
session.Close()
etcd.G_jobLock.UnLock()
returnerr
}
varplcmodels.Pln_workorder
ok,err:=engine.Table("pln_workorder").Where("finr = ? and custordernr = ? and status < ?",finr,pln.Custordernr,status).Get(&plc)
ok,err:=session.Table("pln_workorder").Where("finr = ? and custordernr = ? and status < ?",finr,pln.Custordernr,status).Get(&plc)
iferr!=nil{
session.Rollback()
session.Close()
etcd.G_jobLock.UnLock()
returnerr
}
if!ok{
//生产订单不存在小于80的状态,更新生产订单
_,err:=engine.Table("pln_custorder").Cols("status").Where("finr = ? and custordernr = ?",finr,pln.Custordernr).Update(&map[string]interface{}{"status":80})
_,err:=session.Table("pln_custorder").Cols("status").Where("finr = ? and custordernr = ?",finr,pln.Custordernr).Update(&map[string]interface{}{"status":80})