|
|
@ -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") |
|
|
|