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"` }