diff --git a/archive/archive.go b/archive/archive.go index 31d137a..d4b566f 100644 --- a/archive/archive.go +++ b/archive/archive.go @@ -15,7 +15,8 @@ import ( type CustOrders struct { Projnr string //项目号 Custordernr string //客户订单号 - Oemordernr string //oem订单号 + Oemordernr string //Oemordernr订单号 + Oemseq string //oem订单号 Finr int //工厂编号 } @@ -64,6 +65,7 @@ func CustProduct(conf *config.EnvConfig) { //查询缓存记录表 cust, err := archive.SelectAll() if err != nil { + glog.InfoExtln("调度生成终止", "cust is error:", err) glog.InfoExtln("调度生成终止", "cust is error!") return } @@ -72,7 +74,8 @@ func CustProduct(conf *config.EnvConfig) { } e := db.G_DbEngine data := make([]CustOrders, 0) - oemdata := make([]CustOrders, 0) + oemdataG38 := make([]CustOrders, 0) + oemdataG18 := make([]CustOrders, 0) oemdata1 := make([]CustOrders, 0) //获取七天前的字符串 if common.ValueIsEmpty(conf.Day) { @@ -87,26 +90,35 @@ func CustProduct(conf *config.EnvConfig) { num = conf.Num } oneWeekStr := common.TimeFormat(oneWeek, "yyyyMMddHHmmss") - //第一步:查询最近一千条的oemordernr - err = e.Table("pln_custorder").Join("INNER","pln_calloffdata_landing","pln_calloffdata_landing.finr = pln_custorder.finr and pln_calloffdata_landing.calloffnr = pln_custorder.calloffnr").Select("pln_custorder.oemordernr").Where("pln_custorder.finr = ? and pln_custorder.status = ? and pln_calloffdata_landing.parsed = ?", db.G_FINR, common.CO_STATUS_CLOSED,1).Asc("pln_custorder.credatuz").Limit(num).Find(&oemdata) + //第一步:查询最近一千条的oemseq;预留G38 + err = e.Table("pln_custorder").Distinct("pln_custorder.oemseq").Join("INNER", "pln_calloffdata_landing", "pln_calloffdata_landing.finr = pln_custorder.finr and pln_calloffdata_landing.calloffnr = pln_custorder.calloffnr").Select("pln_custorder.oemseq").Where("pln_custorder.finr = ? and pln_custorder.status = ? and pln_calloffdata_landing.parsed = ? and pln_custorder.projnr = ?", db.G_FINR, common.CO_STATUS_CLOSED, 1,"G38").Asc("pln_custorder.oemseq").Limit(num).Find(&oemdataG38) if err != nil { glog.InfoExtln("调度生成终止", "err : ", err) return } - for _, v := range oemdata { - oemorders = append(oemorders, v.Oemordernr) + for _, v := range oemdataG38 { + oemorders = append(oemorders, v.Oemseq) } - //第二步:查询出小于80状态的oemordernr集合 - err = e.Table("pln_custorder").Join("INNER","pln_calloffdata_landing","pln_calloffdata_landing.finr = pln_custorder.finr and pln_calloffdata_landing.calloffnr = pln_custorder.calloffnr").Select("pln_custorder.oemordernr").Where("pln_custorder.finr = ? and pln_custorder.status < ? and pln_calloffdata_landing.parsed = ?", db.G_FINR, common.CO_STATUS_CLOSED,1).Asc("pln_custorder.credatuz").Find(&oemdata1) + //第一步:查询最近一千条的oemseq;预留G18 + err = e.Table("pln_custorder").Distinct("pln_custorder.oemseq").Join("INNER", "pln_calloffdata_landing", "pln_calloffdata_landing.finr = pln_custorder.finr and pln_calloffdata_landing.calloffnr = pln_custorder.calloffnr").Select("pln_custorder.oemseq").Where("pln_custorder.finr = ? and pln_custorder.status = ? and pln_calloffdata_landing.parsed = ? and pln_custorder.projnr = ?", db.G_FINR, common.CO_STATUS_CLOSED, 1,"G18").Asc("pln_custorder.oemseq").Limit(num).Find(&oemdataG18) + if err != nil { + glog.InfoExtln("调度生成终止", "err : ", err) + return + } + for _, v := range oemdataG18 { + oemorders = append(oemorders, v.Oemseq) + } + //第二步:查询出小于80状态的oemordernr集合(因为oemseq是一对多,有80的也有20的) + err = e.Table("pln_custorder").Distinct("pln_custorder.oemseq").Join("INNER", "pln_calloffdata_landing", "pln_calloffdata_landing.finr = pln_custorder.finr and pln_calloffdata_landing.calloffnr = pln_custorder.calloffnr").Select("pln_custorder.oemseq").Where("pln_custorder.finr = ? and pln_custorder.status < ? and pln_calloffdata_landing.parsed = ?", db.G_FINR, common.CO_STATUS_CLOSED, 1).Asc("pln_custorder.oemseq").Find(&oemdata1) if err != nil { glog.InfoExtln("调度生成终止", "err : ", err) return } for _, v := range oemdata1 { - oemorders = append(oemorders, v.Oemordernr) + oemorders = append(oemorders, v.Oemseq) } - //状态必须都是80,时间是14天以前的客户订单(并且预留1000个oemorder订单) - err = e.Table("pln_custorder").Join("INNER","pln_calloffdata_landing","pln_calloffdata_landing.finr = pln_custorder.finr and pln_calloffdata_landing.calloffnr = pln_custorder.calloffnr").NotIn("pln_custorder.oemordernr", oemorders).NotIn("pln_custorder.custordernr", custorders).Where("pln_custorder.status = ? and pln_custorder.credatuz <= ? and pln_calloffdata_landing.parsed = ?", common.CO_STATUS_CLOSED, oneWeekStr,1).Desc("pln_custorder.credatuz").Limit(10).Find(&data) + //状态必须都是80,时间是14天以前的客户订单(并且预留1000个oemseq订单) + err = e.Table("pln_custorder").Join("INNER", "pln_calloffdata_landing", "pln_calloffdata_landing.finr = pln_custorder.finr and pln_calloffdata_landing.calloffnr = pln_custorder.calloffnr").NotIn("pln_custorder.oemordernr", oemorders).NotIn("pln_custorder.custordernr", custorders).Where("pln_custorder.status = ? and pln_custorder.credatuz <= ? and pln_calloffdata_landing.parsed = ?", common.CO_STATUS_CLOSED, oneWeekStr, 1).Desc("pln_custorder.oemseq").Limit(10).Find(&data) if err != nil { glog.InfoExtln("调度生成终止", "err : ", err) return diff --git a/seq/Seq_test.go b/seq/Seq_test.go index d84569d..87a6367 100644 --- a/seq/Seq_test.go +++ b/seq/Seq_test.go @@ -176,11 +176,11 @@ func TestParseSeqOrder(t *testing.T) { t.Errorf("Failed to get full data for custorder %s due to: %v", bl_co.Custordernr, err) return } - // 验证客户订单状态是否满足更新条件 if bl_co.Custordertab.Handlestatus != common.CO_PARSE_STATUS_OK { continue } + // 判断订单状态,如果是>=26,则跳出循环 if bl_co.Custordertab.Status >= common.CO_STATUS_RELEASED { // 客户订单状态不允许更新,设置解析状态为9 seqlandtablst[j].Parsed = common.EDI_PARSE_ERROR @@ -189,6 +189,7 @@ func TestParseSeqOrder(t *testing.T) { if err = seqlandtablst[j].UpdateFieldsWithoutSession(fields); err != nil { return } + continue } // 校验客户订单的OEMSEQ是否连续(基于零件族获取最大的已计划的客户订单的SEQ) diff --git a/seq/Seqtask.go b/seq/Seqtask.go index 1d37fa2..01a7147 100644 --- a/seq/Seqtask.go +++ b/seq/Seqtask.go @@ -178,6 +178,7 @@ func ParseSeqOrder() { etcd.G_jobLock.UnLock() continue } + // 判断订单状态,如果是>=26,则跳出循环 if bl_co.Custordertab.Status >= common.CO_STATUS_RELEASED { // 客户订单状态不允许更新,设置解析状态为9 seqlandtablst[j].Parsed = common.EDI_PARSE_ERROR @@ -187,6 +188,7 @@ func ParseSeqOrder() { etcd.G_jobLock.UnLock() return } + continue } // 校验客户订单的OEMSEQ是否连续(基于零件族获取最大的已计划的客户订单的SEQ) diff --git a/service/Custorder.go b/service/Custorder.go index 5313d37..a30e5bc 100644 --- a/service/Custorder.go +++ b/service/Custorder.go @@ -361,7 +361,7 @@ func (bl_co *BL_CustOrder) AssignPartsToShippableSG(tp *TodProject) (err error) // 遍历零件进行分配 for _, sgpt = range bl_cosg.Bl_sgpartDict { for _, me_sgasntab = range bl_sg.SgAssigndict { - bl_asnsg, ok = bl_co.Bl_usgdict[me_sgasntab.Fsupplygroupid]; + bl_asnsg, ok = bl_co.Bl_usgdict[me_sgasntab.Fsupplygroupid] // 对于SEQ+1通用件分配的供应组可能因为工单取消而不存在 if bl_co.SeqType == 3 && !ok { // SupplyGroup不存在 @@ -1348,7 +1348,7 @@ func (bl_co *BL_CustOrder) UpdateSEQData(seqlandtab db.Pln_seqdata_landing) (err bl_wo.Workordertab.Status = common.WO_STATUS_PLANNED } bl_wo.Workordertab.Lastmodif = common.Date(time.Now().Unix(), "YYYYMMDDHHmmss") - if err = bl_wo.Workordertab.Update("oemseq, preschedseq, schedseq, status, swet, lastmodif"); err != nil { + if err = bl_wo.Workordertab.Update("oemseq, preschedseq, status, swet, lastmodif"); err != nil { glog.InfoExtln("seq更新", "bl_wo.Workordertab..Oemseq", bl_wo.Workordertab.Oemseq) glog.InfoExtln("seq更新", "bl_wo.Workordertab.Preschedseq", bl_wo.Workordertab.Preschedseq) glog.InfoExtln("seq更新", "bl_wo.Workordertab.Swet", seqlandtab.Swet) @@ -1360,7 +1360,7 @@ func (bl_co *BL_CustOrder) UpdateSEQData(seqlandtab db.Pln_seqdata_landing) (err } // UpdateSEQData: 基于解析的SEQ数据更新客户订单和它的生产订单 -func (bl_co *BL_CustOrder) UpdateSEQDataSession(session *xorm.Session,seqlandtab db.Pln_seqdata_landing) (err error) { +func (bl_co *BL_CustOrder) UpdateSEQDataSession(session *xorm.Session, seqlandtab db.Pln_seqdata_landing) (err error) { var ( bl_wo BL_WorkOrder ) @@ -1379,7 +1379,7 @@ func (bl_co *BL_CustOrder) UpdateSEQDataSession(session *xorm.Session,seqlandtab } bl_co.Custordertab.Seqswet = seqlandtab.Swet bl_co.Custordertab.Lastmodif = common.Date(time.Now().Unix(), "YYYYMMDDHHmmss") - if err = bl_co.Custordertab.UpdateFields(session,"oemseq, unloadingpoint, vin, status, seqswet, orderinfo, lastmodif"); err != nil { + if err = bl_co.Custordertab.UpdateFields(session, "oemseq, unloadingpoint, vin, status, seqswet, orderinfo, lastmodif"); err != nil { glog.InfoExtln("seq更新", "seqlandtab.Oemseq", seqlandtab.Oemseq) glog.InfoExtln("seq更新", "seqlandtab.Unloadingpoint", seqlandtab.Unloadingpoint) glog.InfoExtln("seq更新", "seqlandtab.Vin", seqlandtab.Vin) @@ -1398,7 +1398,7 @@ func (bl_co *BL_CustOrder) UpdateSEQDataSession(session *xorm.Session,seqlandtab bl_wo.Workordertab.Status = common.WO_STATUS_PLANNED } bl_wo.Workordertab.Lastmodif = common.Date(time.Now().Unix(), "YYYYMMDDHHmmss") - if err = bl_wo.Workordertab.Update("oemseq, preschedseq, schedseq, status, swet, lastmodif"); err != nil { + if err = bl_wo.Workordertab.Update("oemseq, preschedseq, status, swet, lastmodif"); err != nil { glog.InfoExtln("seq更新", "bl_wo.Workordertab..Oemseq", bl_wo.Workordertab.Oemseq) glog.InfoExtln("seq更新", "bl_wo.Workordertab.Preschedseq", bl_wo.Workordertab.Preschedseq) glog.InfoExtln("seq更新", "bl_wo.Workordertab.Swet", seqlandtab.Swet) diff --git a/tod/Tod_test.go b/tod/Tod_test.go index 6e383b0..fc75aff 100644 --- a/tod/Tod_test.go +++ b/tod/Tod_test.go @@ -493,4 +493,4 @@ func TestReadTodXlsx(t *testing.T) { os.Rename(edi_file, todProj.Projecttab.Tod_folder+"/outxlsx"+"/"+fi.Name()) } } -} +} \ No newline at end of file