Browse Source

Merge pull request '客户管理变成分页' (#138) from feature_search into develop

Reviewed-on: http://101.201.121.115:3000/leo/LAPP_CHEERSSON_BACKEND/pulls/138
pull/139/head
yehongyang 3 years ago
parent
commit
4ad1a4f4db
7 changed files with 190 additions and 23 deletions
  1. +22
    -1
      dao/ap/CustDemandVerHead.dao.go
  2. +121
    -3
      dao/ap/implments/CustDemandVerHead.dao.impl.go
  3. +17
    -0
      models/ap/CustDemandVerHead.model.go
  4. +1
    -1
      services/ap/CustDemandVerHead.service.go
  5. +21
    -11
      services/ap/implments/CustDemandVerHead.service.impl.go
  6. +1
    -1
      task/createVersion/createVersion.go
  7. +7
    -6
      web/controllers/ap/CustDemandVerHead.rest.go

+ 22
- 1
dao/ap/CustDemandVerHead.dao.go View File

@ -186,7 +186,28 @@ type CustDemandVerHeadDAO interface {
* @Date : 2021-08-20 11:11:05
*
******************************************************************************/
SelectData(customerId string, versionId string, artId string, Valid bool) ([]model.CustDemandVerHead, error)
SelectData(*grmi.Paging, string, string, string, bool) (grmi.PagingResult, error)
/******************************************************************************
*
* @Function Name : SelectDataCount
*-----------------------------------------------------------------------------
*
* @Description : 按条件查询CustDemandVerHead
*
* @Function Parameters : 查询条件
*
* @Function Parameters : 排序字段
*
* @Return Value : 查询结果
*
* @Return Value : 执行时发生的错误
*
* @Author : 代码生成器创建
*
* @Date : 2021-08-20 11:11:05
*
******************************************************************************/
SelectDataCount(customerId string, versionId string, artId string, Valid bool) (int64, error)
/******************************************************************************
*
* @Function Name : SelectUnique


+ 121
- 3
dao/ap/implments/CustDemandVerHead.dao.impl.go View File

@ -8,6 +8,7 @@ import (
"leit.com/LAPP_CHEERSSON_BACKEND/grmi"
meta "leit.com/LAPP_CHEERSSON_BACKEND/meta/ap"
model "leit.com/LAPP_CHEERSSON_BACKEND/models/ap"
baseModel "leit.com/LAPP_CHEERSSON_BACKEND/models/base"
"xorm.io/core"
)
@ -345,7 +346,7 @@ func (impl *CustDemandVerHeadDAOImplement) IssueVersion(entity *model.CustDemand
func (impl *CustDemandVerHeadDAOImplement) IssueGlobalVersion(entity *model.CustDemandVerHead) error {
entity.PlantNr = impl.plantNr
entity.LastUser = impl.userid
_, err := impl.session.Table(impl.meta.TableName).Cols("GlobalPublish,PublishId,PublishNumber").ID(entity.GetKey()).Update(entity)
_, err := impl.session.Table(impl.meta.TableName).Cols("GlobalPublish,PublishId,PublishNumber").Join("INNER","AP_UserCustlst","AP_UserCustlst.PlantNr = AP_CustDemandVerHead.PlantNr and AP_UserCustlst.CustomerId = AP_CustDemandVerHead.CustomerId").Where("AP_CustDemandVerHead.Status = ? and AP_UserCustlst.UserId = ?",baseModel.STATUS_YES,impl.userid).Update(entity)
if err != nil {
return grmi.NewDataBaseError(err)
}
@ -354,10 +355,127 @@ func (impl *CustDemandVerHeadDAOImplement) IssueGlobalVersion(entity *model.Cust
/******************************************************************************
*
* @Reference leit.com/LAPP_CHEERSSON_BACKEND/dao/ap/CustDemandHeadDAO.SelectData
* @Reference leit.com/LAPP_CHEERSSON_BACKEND/dao/ap/CustDemandVerHeadDAO.SelectData
*
******************************************************************************/
func (impl *CustDemandVerHeadDAOImplement) SelectData(customerId string, versionId string, artId string, Valid bool) ([]model.CustDemandVerHead, error) {
func (impl *CustDemandVerHeadDAOImplement) SelectData(paging *grmi.Paging, customerId string, versionId string, artId string, Valid bool) (grmi.PagingResult, error) {
if Valid {
//查询有效的版本
session := impl.session.Table("AP_CustDemandVerHead").Select("AP_CustDemandVerHead.*").Distinct("AP_CustDemandVerHead.VersionId")
session = session.Join("INNER", "AP_CustDemandHead", "AP_CustDemandHead.PlantNr = AP_CustDemandVerHead.PlantNr And AP_CustDemandHead.CustomerId = AP_CustDemandVerHead.CustomerId And AP_CustDemandHead.VersionId = AP_CustDemandVerHead.VersionId")
session = session.Join("INNER", "AP_UserCustlst", "AP_CustDemandVerHead.PlantNr = AP_UserCustlst.PlantNr And AP_CustDemandVerHead.CustomerId = AP_UserCustlst.CustomerId").Where("AP_CustDemandVerHead.PlantNr = ? and AP_UserCustlst.UserId = ?", impl.plantNr, impl.userid)
if customerId != "" {
session = session.And("AP_CustDemandVerHead.CustomerId = ?", customerId)
}
if versionId != "" {
session = session.And("AP_CustDemandVerHead.VersionId = ?", versionId)
}
if artId != "" {
session = session.Join("INNER", meta.CustDemandVerDetail.TableName, "AP_CustDemandVerHead.PlantNr = AP_CustDemandVerDetail.PlantNr And AP_CustDemandVerHead.CustomerId = AP_CustDemandVerDetail.CustomerId And AP_CustDemandVerHead.VersionId = AP_CustDemandVerDetail.VersionId")
session = session.And("AP_CustDemandVerDetail.ArtId like concat('%%', ?, '%%')", artId)
}
session = session.OrderBy("AP_CustDemandVerHead.VersionId")
data := make([]model.CustDemandVerHead, 0, 10)
err := session.Limit(int(paging.Size), int(paging.Offset())).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
} else {
session := impl.session.Table(impl.meta.TableName).Select("AP_CustDemandVerHead.*").Distinct("AP_CustDemandVerHead.VersionId")
session = session.Join("INNER", "AP_UserCustlst", "AP_CustDemandVerHead.PlantNr = AP_UserCustlst.PlantNr And AP_CustDemandVerHead.CustomerId = AP_UserCustlst.CustomerId").Where("AP_CustDemandVerHead.PlantNr = ? and AP_UserCustlst.UserId = ?", impl.plantNr, impl.userid)
if customerId != "" {
session = session.And("AP_CustDemandVerHead.CustomerId = ?", customerId)
}
if versionId != "" {
session = session.And("AP_CustDemandVerHead.VersionId = ?", versionId)
}
if artId != "" {
session = session.Join("INNER", meta.CustDemandVerDetail.TableName, "AP_CustDemandVerHead.PlantNr = AP_CustDemandVerDetail.PlantNr And AP_CustDemandVerHead.CustomerId = AP_CustDemandVerDetail.CustomerId And AP_CustDemandVerHead.VersionId = AP_CustDemandVerDetail.VersionId")
session = session.And("AP_CustDemandVerDetail.ArtId like concat('%%', ?, '%%')", artId)
}
session = session.OrderBy("AP_CustDemandVerHead.VersionId")
data := make([]model.CustDemandVerHead, 0, 10)
err := session.Limit(int(paging.Size), int(paging.Offset())).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
}
}
/******************************************************************************
*
* @Reference leit.com/LAPP_CHEERSSON_BACKEND/dao/ap/CustDemandVerHeadDAO.SelectData
*
******************************************************************************/
func (impl *CustDemandVerHeadDAOImplement) SelectDataCount(customerId string, versionId string, artId string, Valid bool) (int64, error) {
if Valid {
//查询有效的版本
session := impl.session.Table("AP_CustDemandVerHead").Select("count(AP_CustDemandVerHead.VersionId) as countNum")
session = session.Join("INNER", "AP_CustDemandHead", "AP_CustDemandHead.PlantNr = AP_CustDemandVerHead.PlantNr And AP_CustDemandHead.CustomerId = AP_CustDemandVerHead.CustomerId And AP_CustDemandHead.VersionId = AP_CustDemandVerHead.VersionId")
session = session.Join("INNER", "AP_UserCustlst", "AP_CustDemandVerHead.PlantNr = AP_UserCustlst.PlantNr And AP_CustDemandVerHead.CustomerId = AP_UserCustlst.CustomerId").Where("AP_CustDemandVerHead.PlantNr = ? and AP_UserCustlst.UserId = ?", impl.plantNr, impl.userid)
if customerId != "" {
session = session.And("AP_CustDemandVerHead.CustomerId = ?", customerId)
}
if versionId != "" {
session = session.And("AP_CustDemandVerHead.VersionId = ?", versionId)
}
if artId != "" {
session = session.Join("INNER", meta.CustDemandVerDetail.TableName, "AP_CustDemandVerHead.PlantNr = AP_CustDemandVerDetail.PlantNr And AP_CustDemandVerHead.CustomerId = AP_CustDemandVerDetail.CustomerId And AP_CustDemandVerHead.VersionId = AP_CustDemandVerDetail.VersionId")
session = session.And("AP_CustDemandVerDetail.ArtId like concat('%%', ?, '%%')", artId)
}
data := new(model.CustomerCount)
count,err := session.Count(data)
if err != nil {
return 0, grmi.NewDataBaseError(err)
}
return count, nil
} else {
session := impl.session.Table(impl.meta.TableName).Select("count(AP_CustDemandVerHead.VersionId) as countNum")
session = session.Join("INNER", "AP_UserCustlst", "AP_CustDemandVerHead.PlantNr = AP_UserCustlst.PlantNr And AP_CustDemandVerHead.CustomerId = AP_UserCustlst.CustomerId").Where("AP_CustDemandVerHead.PlantNr = ? and AP_UserCustlst.UserId = ?", impl.plantNr, impl.userid)
if customerId != "" {
session = session.And("AP_CustDemandVerHead.CustomerId = ?", customerId)
}
if versionId != "" {
session = session.And("AP_CustDemandVerHead.VersionId = ?", versionId)
}
if artId != "" {
session = session.Join("INNER", meta.CustDemandVerDetail.TableName, "AP_CustDemandVerHead.PlantNr = AP_CustDemandVerDetail.PlantNr And AP_CustDemandVerHead.CustomerId = AP_CustDemandVerDetail.CustomerId And AP_CustDemandVerHead.VersionId = AP_CustDemandVerDetail.VersionId")
session = session.And("AP_CustDemandVerDetail.ArtId like concat('%%', ?, '%%')", artId)
}
data := new(model.CustomerCount)
count,err := session.Count(data)
if err != nil {
return 0, grmi.NewDataBaseError(err)
}
return count, nil
}
}
/******************************************************************************
*
* @Reference leit.com/LAPP_CHEERSSON_BACKEND/dao/ap/CustDemandHeadDAO.SelectDataTest
*
******************************************************************************/
func (impl *CustDemandVerHeadDAOImplement) SelectDataTest(customerId string, versionId string, artId string, Valid bool) ([]model.CustDemandVerHead, error) {
if Valid {
session := impl.session.Table("AP_CustDemandVerHead").Select("AP_CustDemandVerHead.*").Distinct("AP_CustDemandVerHead.VersionId")


+ 17
- 0
models/ap/CustDemandVerHead.model.go View File

@ -90,3 +90,20 @@ type CustomerItem struct {
SortKeys []string `json:"SortKeys" xorm:"-"`
CustDemandVerDetail map[string]CustDemandVerDetail `json:"CustDemandVerDetail" xorm:"-"`
}
/******************************************************************************
*
* @Struct Name : CustomerItem
*-----------------------------------------------------------------------------
*
* @Description : 数据项
*
* @Author : 娄文智
*
* @Date : 2021-09-08
*
******************************************************************************/
type CustomerCount struct {
CountNum int64 `json:"countNum" xorm:"-"`
}

+ 1
- 1
services/ap/CustDemandVerHead.service.go View File

@ -492,7 +492,7 @@ type CustDemandVerHeadService interface {
* @Date : 2021-08-20 11:11:05
*
******************************************************************************/
SelectData(*global.User, string, string,string,bool) ([]model.CustDemandVerHead, error)
SelectData(*global.User,map[string]string, string, string,string,bool) (grmi.PagingResult, error)
/******************************************************************************
*
* @Function Name : SelectData


+ 21
- 11
services/ap/implments/CustDemandVerHead.service.impl.go View File

@ -746,42 +746,52 @@ func (impl *CustDemandVerHeadServiceImplement) Select(user *global.User, urlPara
* @Reference leit.com/LAPP_CHEERSSON_BACKEND/services/ap/CustDemandVerHeadService.SelectData
*
******************************************************************************/
func (impl *CustDemandVerHeadServiceImplement) SelectData(user *global.User, customerId string, versionId string, artId string, Valid bool) ([]model.CustDemandVerHead, error) {
func (impl *CustDemandVerHeadServiceImplement) SelectData(user *global.User, urlParameters map[string]string, customerId string, versionId string, artId string, Valid bool) (grmi.PagingResult, error) {
grmi.Log(user, "/services/ap/implments/CustDemandVerHead.service.impl.go", "SelectCustDemandVerHead", "查询CustDemandVerHead")
engine := db.Eloquent.Master()
session := engine.NewSession()
defer session.Close()
engine.ShowSQL(true)
dao := dal.NewCustDemandVerHeadDAO(session, user.PlantNr, user.UserId)
globalDao := dal.NewCustDemandHeadDAO(session, user.PlantNr, user.UserId)
result, err := dao.SelectData(customerId, versionId, artId, Valid)
condition := DefaultConditionOfCustDemandVerHeadAndPaging
condition.Fill(urlParameters)
result, err := dao.SelectData(condition.Paging, customerId, versionId, artId, Valid)
if err != nil {
return nil, err
return grmi.EmptyPagingResult, err
}
result.Count,err = dao.SelectDataCount(customerId, versionId, artId, Valid)
if err != nil {
return grmi.EmptyPagingResult, err
}
list, err := globalDao.Select([]grmi.Predicate{
meta.CustDemandHead_CustomerId.NewPredicate(grmi.Equal, customerId),
}, nil)
if err != nil {
return nil, err
return grmi.EmptyPagingResult, err
}
if len(list) > 0 {
var versionId string
for _, v := range list {
versionId = v.VersionId
}
for k, v := range result {
if versionId == v.VersionId {
result[k].Valid = true
}
resultInfo,ok := result.Records.([]model.CustDemandVerHead)
if ok{
for k, v := range resultInfo {
if versionId == v.VersionId {
resultInfo[k].Valid = true
}
}
result.Records = resultInfo
}
}
return result, nil
}
/******************************************************************************
*
* @Reference leit.com/LAPP_CHEERSSON_BACKEND/services/ap/CustDemandVerHeadService.SelectUnique


+ 1
- 1
task/createVersion/createVersion.go View File

@ -57,7 +57,7 @@ func doTaskVersion(ctx context.Context) {
user.UserId = "auto"
err := serviceOfCustVerHead.SelectOneByCustTask(user, task)
if err != nil {
glog.InfoExtln("创建错误记录","err:",err)
glog.InfoExtln("创建错误记录", "err:", err)
continue
}
}


+ 7
- 6
web/controllers/ap/CustDemandVerHead.rest.go View File

@ -1342,7 +1342,7 @@ func RegisterRemoveIssueOneCustDemandVerHead(party router.Party, httpMethod stri
* @Date : 2021-08-20 11:11:05
*
******************************************************************************/
func RegisterSearchCustDemandVerHead(party router.Party, path string, method func(*global.User, string, string, string, bool) ([]model.CustDemandVerHead, error)) {
func RegisterSearchCustDemandVerHead(party router.Party, path string, method func(*global.User, map[string]string, string, string, string, bool) (grmi.PagingResult, error)) {
party.Get(path, func(ctx iris.Context) {
user, ok := jwts.ParseToken(ctx)
@ -1354,15 +1354,16 @@ func RegisterSearchCustDemandVerHead(party router.Party, path string, method fun
artId := ctx.URLParam("artId")
versionId := ctx.URLParam("versionId")
valid, _ := ctx.URLParamBool("valid")
result, err := method(user, customerId, versionId, artId, valid)
urlParameters := make(map[string]string)
urlParameters["pageNumber"] = ctx.URLParam("pageNumber")
urlParameters["pageSize"] = ctx.URLParam("pageSize")
result, err := method(user, urlParameters, customerId, versionId, artId, valid)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
if result == nil {
supports.Error(ctx, iris.StatusNotFound, supports.NotFound, nil)
return
}
supports.Ok(ctx, supports.OptionSuccess, result)
})
}

Loading…
Cancel
Save