From 1c84d09e201ed1765f05e0b5d8fbc14528bf56e9 Mon Sep 17 00:00:00 2001 From: louwenzhi Date: Sun, 2 Jan 2022 21:37:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=88=86=E9=A1=B5=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../implments/CustDemandVerHead.dao.impl.go | 33 ++++++++++++------- models/ap/CustDemandVerHead.model.go | 1 + models/common/common.go | 15 ++++++++- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/dao/ap/implments/CustDemandVerHead.dao.impl.go b/dao/ap/implments/CustDemandVerHead.dao.impl.go index 15ee713..0146066 100644 --- a/dao/ap/implments/CustDemandVerHead.dao.impl.go +++ b/dao/ap/implments/CustDemandVerHead.dao.impl.go @@ -9,6 +9,7 @@ import ( meta "leit.com/LAPP_CHEERSSON_BACKEND/meta/ap" model "leit.com/LAPP_CHEERSSON_BACKEND/models/ap" baseModel "leit.com/LAPP_CHEERSSON_BACKEND/models/base" + "leit.com/LAPP_CHEERSSON_BACKEND/models/common" "leit.com/LAPP_CHEERSSON_BACKEND/utils" "xorm.io/core" ) @@ -434,7 +435,7 @@ func (impl *CustDemandVerHeadDAOImplement) SelectData(paging *grmi.Paging, group //查询有效的版本 where := fmt.Sprintf("AP_CustDemandVerHead.PlantNr = %d", impl.plantNr) - joinstr := " INNER JOIN AP_UserCustlst ON AP_CustDemandVerHead.PlantNr = AP_UserCustlst.PlantNr AND AP_CustDemandVerHead.CustomerId = AP_UserCustlst.CustomerId INNER JOIN AP_CustDemandHead ON AP_CustDemandVerHead.PlantNr = AP_CustDemandHead.PlantNr AND AP_CustDemandVerHead.CustomerId = AP_CustDemandHead.CustomerId AND AP_CustDemandVerHead.VersionId = AP_CustDemandHead.VersionId " + joinstr := " INNER JOIN AP_UserCustlst ON AP_CustDemandVerHead.PlantNr = AP_UserCustlst.PlantNr AND AP_CustDemandVerHead.CustomerId = AP_UserCustlst.CustomerId INNER JOIN AP_CustDemandHead ON AP_CustDemandVerHead.PlantNr = AP_CustDemandHead.PlantNr AND AP_CustDemandVerHead.CustomerId = AP_CustDemandHead.CustomerId AND AP_CustDemandVerHead.VersionId = AP_CustDemandHead.VersionId INNER JOIN Customer ON AP_CustDemandVerHead.PlantNr = Customer.PlantNr And AP_CustDemandVerHead.CustomerId = Customer.CustomerId " where += fmt.Sprintf(" AND AP_UserCustlst.UserId = '%s'", impl.userid) @@ -454,23 +455,29 @@ func (impl *CustDemandVerHeadDAOImplement) SelectData(paging *grmi.Paging, group where += fmt.Sprintf(" and AP_CustDemandVerDetail.ArtId like concat('%%', '%s', '%%')", artId) } if grouptype != "" { - joinstr += " INNER JOIN Customer ON AP_CustDemandVerHead.PlantNr = Customer.PlantNr And AP_CustDemandVerHead.CustomerId = Customer.CustomerId " where += fmt.Sprintf(" AND Customer.CustomerType = '%s'", grouptype) } orderBy := " order by " + " AP_CustDemandVerHead.VersionId " where = " where " + where - data := make([]model.CustDemandVerHead, 0, 10) - err := impl.session.Table(impl.meta.TableName).SQL("select DISTINCT AP_CustDemandVerHead.* from AP_CustDemandVerHead " + joinstr + where + orderBy + " offset " + utils.ValueToString(paging.Offset(), "") + " row fetch next " + utils.ValueToString(paging.Size, "") + " row only").Find(&data) + data := make([]common.CustOrderData, 0) + + err := impl.session.Table(impl.meta.TableName).SQL("select * from AP_CustDemandVerHead " + joinstr + where + orderBy + " offset " + utils.ValueToString(paging.Offset(), "") + " row fetch next " + utils.ValueToString(paging.Size, "") + " row only").Find(&data) if err != nil { return grmi.EmptyPagingResult, grmi.NewDataBaseError(err) } - return grmi.PagingResult{Records: data, Count: paging.Size, PageNumber: paging.Number, PageSize: paging.Size}, nil + datalst := make([]model.CustDemandVerHead, 0) + for _, item := range data { + custHead := item.CustDemandVerHead + custHead.CustomerName = item.Customer.Name1 + datalst = append(datalst, custHead) + } + return grmi.PagingResult{Records: datalst, Count: paging.Size, PageNumber: paging.Number, PageSize: paging.Size}, nil } else { //查询有效的版本 where := fmt.Sprintf("AP_CustDemandVerHead.PlantNr = %d", impl.plantNr) - joinstr := " INNER JOIN AP_UserCustlst ON AP_CustDemandVerHead.PlantNr = AP_UserCustlst.PlantNr AND AP_CustDemandVerHead.CustomerId = AP_UserCustlst.CustomerId " + joinstr := " INNER JOIN AP_UserCustlst ON AP_CustDemandVerHead.PlantNr = AP_UserCustlst.PlantNr AND AP_CustDemandVerHead.CustomerId = AP_UserCustlst.CustomerId INNER JOIN Customer ON AP_CustDemandVerHead.PlantNr = Customer.PlantNr And AP_CustDemandVerHead.CustomerId = Customer.CustomerId " where += fmt.Sprintf(" AND AP_UserCustlst.UserId = '%s'", impl.userid) if customerId != "" { where += fmt.Sprintf(" AND AP_CustDemandVerHead.CustomerId = '%s'", customerId) @@ -488,19 +495,23 @@ func (impl *CustDemandVerHeadDAOImplement) SelectData(paging *grmi.Paging, group where += fmt.Sprintf(" and AP_CustDemandVerDetail.ArtId like concat('%%', '%s', '%%')", artId) } if grouptype != "" { - joinstr += " INNER JOIN Customer ON AP_CustDemandVerHead.PlantNr = Customer.PlantNr And AP_CustDemandVerHead.CustomerId = Customer.CustomerId " where += fmt.Sprintf(" AND Customer.CustomerType = '%s'", grouptype) } orderBy := " order by " + " AP_CustDemandVerHead.VersionId " where = " where " + where - data := make([]model.CustDemandVerHead, 0, 10) - err := impl.session.Table(impl.meta.TableName).SQL("select DISTINCT AP_CustDemandVerHead.* from AP_CustDemandVerHead " + joinstr + where + orderBy + " offset " + utils.ValueToString(paging.Offset(), "") + " row fetch next " + utils.ValueToString(paging.Size, "") + " row only").Find(&data) + data := make([]common.CustOrderData, 0) + err := impl.session.Table(impl.meta.TableName).SQL("select * from AP_CustDemandVerHead " + joinstr + where + orderBy + " offset " + utils.ValueToString(paging.Offset(), "") + " row fetch next " + utils.ValueToString(paging.Size, "") + " row only").Find(&data) if err != nil { return grmi.EmptyPagingResult, grmi.NewDataBaseError(err) } - - return grmi.PagingResult{Records: data, Count: paging.Size, PageNumber: paging.Number, PageSize: paging.Size}, nil + datalst := make([]model.CustDemandVerHead, 0) + for _, item := range data { + custHead := item.CustDemandVerHead + custHead.CustomerName = item.Customer.Name1 + datalst = append(datalst, custHead) + } + return grmi.PagingResult{Records: datalst, Count: paging.Size, PageNumber: paging.Number, PageSize: paging.Size}, nil } } diff --git a/models/ap/CustDemandVerHead.model.go b/models/ap/CustDemandVerHead.model.go index a6ffa57..4ef14ab 100644 --- a/models/ap/CustDemandVerHead.model.go +++ b/models/ap/CustDemandVerHead.model.go @@ -45,6 +45,7 @@ type CustDemandVerHead struct { CreateWeek int `xorm:"int 'CreateWeek'" json:"AP_CustDemandVerHead-CreateWeek"` CreateModeDescr string `xorm:"-" json:"AP_CustDemandVerHead-CreateModeDescr"` Valid bool `xorm:"-" json:"AP_CustDemandVerHead-Valid"` + CustomerName string `xorm:"-" json:"AP_CustDemandVerHead-CustomerName"` PublishId string `xorm:"string 'PublishId'" json:"AP_CustDemandVerHead-PublishId"` PublishNumber string `xorm:"nvarchar(255) 'PublishNumber'" json:"AP_CustDemandVerHead-PublishNumber"` PublishStatus int `xorm:"int 'PublishStatus'" json:"AP_CustDemandVerHead-PublishStatus"` diff --git a/models/common/common.go b/models/common/common.go index 67dec2b..a1283d0 100644 --- a/models/common/common.go +++ b/models/common/common.go @@ -8,5 +8,18 @@ import ( type CustomerDeviationDetailItemBomLst struct { PerCustomerDeviationDetailItem []ap.PerCustomerDeviationDetailItem `json:"PerCustomerDeviationDetailItem" xorm:"-"` CustomerDeviationDetailItem []ap.CustomerDeviationDetailItem `json:"CustomerDeviationDetailItem" xorm:"-"` - Article base.Article `json:"Article" xorm:"-"` + Article base.Article `json:"Article" xorm:"-"` +} + +// CustOrderData 客户订单和状态、数量的联查 +type CustOrderData struct { + CustDemandVerHead ap.CustDemandVerHead `xorm:"extends"` + Customer base.Customer `xorm:"extends"` +} + +// CustOrderData 客户订单和状态、数量的联查 +type ArticleStockData struct { + ArticleResource ap.ArticleResource `xorm:"extends"` + Resource ap.Resource `xorm:"extends"` + ArticleStockLevel ap.ArticleStockLevel `xorm:"extends"` }