diff --git a/common/Const.go b/common/Const.go index b447837..e6692f6 100644 --- a/common/Const.go +++ b/common/Const.go @@ -8,6 +8,7 @@ const ( EDI_CALLOFF = "CALLOFF" EDI_PARSE_YES = 1 + EDI_PARSE_TWO = 2 EDI_PARSE_NO = 0 EDI_PARSE_ERROR = 9 diff --git a/db/Pln_custorder_ver.go b/db/Pln_custorder_ver.go index edc9d70..bc3eb79 100644 --- a/db/Pln_custorder_ver.go +++ b/db/Pln_custorder_ver.go @@ -139,12 +139,11 @@ func (t *Pln_custorder_ver) SelectInfo() bool { // 获取指定项目的未解析且客户订单处理状态!=ER的客户订单版本数据 func (t *Pln_custorder_ver) GetProjectUnparsedTOD(projnr string) (vcovlst []VCustorderVer, err error) { var i int - e := G_DbEngine if err = e.Table("pln_custorder").Alias("co").Join("INNER", []string{"pln_custorder_ver", "cov"}, - "co.finr = cov.finr and co.custordernr = cov.custordernr").Where("co.finr = ? and co.projnr = ? and co.handlestatus != ? and cov.parsed = ? and cov.edifiletype = ?", - G_FINR, projnr, common.CO_PARSE_STATUS_ERROR, common.EDI_PARSE_NO, common.EDI_TOD).Asc("cov.version", "cov.custordernr").Find(&vcovlst); err != nil { + "co.finr = cov.finr and co.custordernr = cov.custordernr").In("cov.parsed", common.EDI_PARSE_NO, common.EDI_PARSE_TWO).Where("co.finr = ? and co.projnr = ? and co.handlestatus != ? and cov.edifiletype = ?", + G_FINR, projnr, common.CO_PARSE_STATUS_ERROR, common.EDI_TOD).Asc("cov.version", "cov.custordernr").Find(&vcovlst); err != nil { return } diff --git a/tod/Todtask.go b/tod/Todtask.go index c4c4de1..b0ee33d 100644 --- a/tod/Todtask.go +++ b/tod/Todtask.go @@ -192,35 +192,32 @@ func ParseTodCustorderNew() { // 加载客户订单进行校验 for j, _ = range vcovlst { - if bl_co.SeqType == 1 { - //判断是否存在前一个版本, - //如果存在前一个版本,判断是否解析 - if vcovlst[j].Pln_custorder_ver.Version > 1 { - perInfo := new(db.Pln_custorder_ver) - perInfo.Finr = vcovlst[j].Pln_custorder_ver.Finr - perInfo.Custordernr = vcovlst[j].Pln_custorder_ver.Custordernr - perInfo.Version = vcovlst[j].Pln_custorder_ver.Version - res := perInfo.SelectInfo() - glog.InfoExtln("tod","Custordernr", vcovlst[j].Pln_custorder_ver.Custordernr) - glog.InfoExtln("tod","Version",vcovlst[j].Pln_custorder_ver.Version) - glog.InfoExtln("tod","上一版本Version",perInfo.Version) - glog.InfoExtln("tod","result",res) - if err != nil { - glog.InfoExtln("TOD解析创建生产订单", "err is:", err) - return - } - if res { - //添加邮件预警 - mailsubject = "客户订单上一版本没有解析" - mailbody = "项目号: " + todProj.Projectid + "\r\n客户订单号: " + bl_co.Oemordernr + "\r\nErrorinfo : 客户订单上一版本没有解析!" - if err = SendTodErrorEmail(projtablst[i], mailsubject, mailbody); err != nil { - glog.InfoExtln("发送邮件", "err is :", err) - } - glog.InfoExtln("tod","result:",mailsubject) - continue + //判断是否存在前一个版本, + //如果存在前一个版本,判断是否解析 + if vcovlst[j].Pln_custorder_ver.Version > 1 { + perInfo := new(db.Pln_custorder_ver) + perInfo.Finr = vcovlst[j].Pln_custorder_ver.Finr + perInfo.Custordernr = vcovlst[j].Pln_custorder_ver.Custordernr + perInfo.Version = vcovlst[j].Pln_custorder_ver.Version + res := perInfo.SelectInfo() + glog.InfoExtln("tod","Custordernr", vcovlst[j].Pln_custorder_ver.Custordernr) + glog.InfoExtln("tod","Version",vcovlst[j].Pln_custorder_ver.Version) + glog.InfoExtln("tod","上一版本Version",perInfo.Version) + glog.InfoExtln("tod","result",res) + if err != nil { + glog.InfoExtln("TOD解析创建生产订单", "err is:", err) + return + } + if res { + //添加邮件预警 + mailsubject = "客户订单上一版本没有解析" + mailbody = "项目号: " + todProj.Projectid + "\r\n客户订单号: " + bl_co.Oemordernr + "\r\nErrorinfo : 客户订单上一版本没有解析!" + if err = SendTodErrorEmail(projtablst[i], mailsubject, mailbody); err != nil { + glog.InfoExtln("发送邮件", "err is :", err) } + glog.InfoExtln("tod","result:",mailsubject) + continue } - } /* 获取锁 */