|
|
@ -357,13 +357,19 @@ func (impl *CustDemandVerHeadDAOImplement) IssueGlobalVersion(entity *model.Cust |
|
|
|
* @Reference leit.com/LAPP_CHEERSSON_BACKEND/dao/ap/CustDemandHeadDAO.SelectData |
|
|
|
* |
|
|
|
******************************************************************************/ |
|
|
|
func (impl *CustDemandVerHeadDAOImplement) SelectData(customerId string, artId string, Valid bool) ([]model.CustDemandVerHead, error) { |
|
|
|
func (impl *CustDemandVerHeadDAOImplement) SelectData(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").Join("INNER", "AP_CustDemandHead", "AP_CustDemandHead.PlantNr = AP_CustDemandVerHead.PlantNr And AP_CustDemandHead.CustomerId = AP_CustDemandVerHead.CustomerId And AP_CustDemandHead.VersionId = AP_CustDemandVerHead.VersionId").Where("AP_CustDemandVerHead.PlantNr = ?", impl.plantNr) |
|
|
|
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) |
|
|
@ -377,10 +383,15 @@ func (impl *CustDemandVerHeadDAOImplement) SelectData(customerId string, artId s |
|
|
|
} |
|
|
|
return data, nil |
|
|
|
} else { |
|
|
|
session := impl.session.Table(impl.meta.TableName).Select("AP_CustDemandVerHead.*").Distinct("AP_CustDemandVerHead.VersionId").Where("AP_CustDemandVerHead.PlantNr = ?", impl.plantNr) |
|
|
|
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) |
|
|
|