From d896676d46d2a5e03023cc21b62a8c5d87c1f8a4 Mon Sep 17 00:00:00 2001 From: louwenzhi Date: Mon, 5 Jul 2021 17:47:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=AE=E6=A3=80=E9=80=BB=E8=BE=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qm/implments/DefectRecord.service.impl.go | 61 +++++++++++++------ 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/services/qm/implments/DefectRecord.service.impl.go b/services/qm/implments/DefectRecord.service.impl.go index c22b4b5..e34e07c 100644 --- a/services/qm/implments/DefectRecord.service.impl.go +++ b/services/qm/implments/DefectRecord.service.impl.go @@ -246,10 +246,9 @@ func (impl *DefectRecordServiceImplement) Insert(user *models.Usertab, entities if err != nil { return grmi.NewBusinessError("序列订单查询错误!") } - if OrderInfo != nil { + if OrderInfo != nil && OrderInfo.Status == common.CHECK_STATUS_CLOSED{ return grmi.NewBusinessError("该序列订单已经检测!") } - orderId := entities.SerialorderId bdal := basedal.NewLabelParserHeadDAO(session, user.Pid, user.Userid) @@ -273,15 +272,37 @@ func (impl *DefectRecordServiceImplement) Insert(user *models.Usertab, entities artID := codeInfos["artId"] if count <= 0 { - /*******无提交记录,即为正常订单********/ - entities.Status = common.CHECK_STATUS_CLOSED - entities.IsPack = 0 - entities.ArtId = artID - err = sdao.InsertOne(&entities) - if err != nil { - return grmi.NewBusinessError("提交记录失败!") + //判断是否是修复 + if OrderInfo.Status == common.CHECK_STATUS_RUNNING{ + //判断是否修复 + recordDAO := dal.NewDefectRecordDAO(session, user.Pid, user.Userid) + records, err := recordDAO.Select([]grmi.Predicate{meta.DefectRecord_SerialOrderId.NewPredicate(grmi.Equal, orderId),meta.DefectRecord_Status.NewPredicate(grmi.LessThen, common.ORDER_STATUS_CLOSED)}, nil) + if err != nil { + return err + } + if records != nil && len(records) > 0 { + return grmi.NewBusinessError("该序列工单返工未完成!") + } + //更新状态 + entities.Status = common.CHECK_STATUS_CLOSED + entities.IsPack = 0 + entities.ArtId = artID + err = sdao.UpdateOne(&entities) + if err != nil { + return grmi.NewBusinessError("更新记录失败!") + } + return nil + }else { + /*******无提交记录,即为正常订单********/ + entities.Status = common.CHECK_STATUS_CLOSED + entities.IsPack = 0 + entities.ArtId = artID + err = sdao.InsertOne(&entities) + if err != nil { + return grmi.NewBusinessError("提交记录失败!") + } + return nil } - return nil } dao := dal.NewDefectRecordDAO(session, user.Pid, user.Userid) @@ -511,16 +532,16 @@ func (impl *DefectRecordServiceImplement) Rework(user *models.Usertab, recNr int return grmi.NewBusinessError("状态错误!") } - sdao := dal.NewSerialOrderRutingDAO(session, user.Pid, user.Userid) - OrderInfo, err := sdao.SelectOne(record.SerialOrderId) - if err != nil { - return grmi.NewBusinessError("序列订单查询错误!") - } - OrderInfo.Status = common.CHECK_STATUS_CLOSED - err = sdao.UpdateOne(OrderInfo) - if err != nil { - return grmi.NewBusinessError("序列订单查询错误!") - } + //sdao := dal.NewSerialOrderRutingDAO(session, user.Pid, user.Userid) + //OrderInfo, err := sdao.SelectOne(record.SerialOrderId) + //if err != nil { + // return grmi.NewBusinessError("序列订单查询错误!") + //} + //OrderInfo.Status = common.CHECK_STATUS_CLOSED + //err = sdao.UpdateOne(OrderInfo) + //if err != nil { + // return grmi.NewBusinessError("序列订单查询错误!") + //} record.Status = strconv.Itoa(common.ORDER_STATUS_CLOSED) record.InspectTime = grmi.DateTime(time.Now()) record.Inspector = user.Userid