diff --git a/dao/ap/CustDemandVerHead.dao.go b/dao/ap/CustDemandVerHead.dao.go index a50edaf..64ffc43 100644 --- a/dao/ap/CustDemandVerHead.dao.go +++ b/dao/ap/CustDemandVerHead.dao.go @@ -166,6 +166,27 @@ type CustDemandVerHeadDAO interface { * ******************************************************************************/ Select([]grmi.Predicate, []grmi.Field) ([]model.CustDemandVerHead, error) + /****************************************************************************** + * + * @Function Name : SelectData + *----------------------------------------------------------------------------- + * + * @Description : 按条件查询CustDemandVerHead + * + * @Function Parameters : 查询条件 + * + * @Function Parameters : 排序字段 + * + * @Return Value : 查询结果 + * + * @Return Value : 执行时发生的错误 + * + * @Author : 代码生成器创建 + * + * @Date : 2021-08-20 11:11:05 + * + ******************************************************************************/ + SelectData(customerId string,artId string,Valid bool) ([]model.CustDemandVerHead, error) /****************************************************************************** * * @Function Name : SelectUnique diff --git a/dao/ap/implments/CustDemandVerHead.dao.impl.go b/dao/ap/implments/CustDemandVerHead.dao.impl.go index 7405360..77f5d48 100644 --- a/dao/ap/implments/CustDemandVerHead.dao.impl.go +++ b/dao/ap/implments/CustDemandVerHead.dao.impl.go @@ -351,3 +351,46 @@ func (impl *CustDemandVerHeadDAOImplement) IssueGlobalVersion(entity *model.Cust } return nil } + +/****************************************************************************** + * + * @Reference leit.com/LAPP_CHEERSSON_BACKEND/dao/ap/CustDemandHeadDAO.SelectData + * + ******************************************************************************/ +func (impl *CustDemandVerHeadDAOImplement) SelectData(customerId string, artId string, Valid bool) ([]model.CustDemandVerHead, error) { + + if Valid { + session := impl.session.Table("AP_CustDemandVerHead").Select("AP_CustDemandVerHead.*").Distinct("AP_CustDemandVerHead.VersionId").Join("LEFT", "AP_CustDemandHead", "AP_CustDemandHead.PlantNr = AP_CustDemandVerHead.PlantNr And AP_CustDemandHead.CustomerId = AP_CustDemandVerHead.CustomerId And AP_CustDemandHead.VersionId = AP_CustDemandVerHead.VersionId").Join("LEFT", meta.CustDemandVerDetail.TableName, "AP_CustDemandVerHead.PlantNr = AP_CustDemandVerDetail.PlantNr And AP_CustDemandVerHead.CustomerId = AP_CustDemandVerDetail.CustomerId And AP_CustDemandVerHead.VersionId = AP_CustDemandVerDetail.VersionId").Where("AP_CustDemandVerHead.PlantNr = ?", impl.plantNr) + if customerId != "" { + session = session.And("AP_CustDemandVerHead.CustomerId = ?", customerId) + } + if artId != "" { + session = session.And("AP_CustDemandVerDetail.ArtId like concat('%%', ?, '%%')", artId) + } + session = session.OrderBy("AP_CustDemandVerHead.VersionId") + + data := make([]model.CustDemandVerHead, 0) + err := session.Find(&data) + if err != nil { + return nil, grmi.NewDataBaseError(err) + } + return data, nil + } else { + session := impl.session.Table(impl.meta.TableName).Select("AP_CustDemandVerHead.*").Distinct("AP_CustDemandVerHead.VersionId").Join("LEFT", meta.CustDemandVerDetail.TableName, "AP_CustDemandVerHead.PlantNr = AP_CustDemandVerDetail.PlantNr And AP_CustDemandVerHead.CustomerId = AP_CustDemandVerDetail.CustomerId And AP_CustDemandVerHead.VersionId = AP_CustDemandVerDetail.VersionId").Where("AP_CustDemandVerHead.PlantNr = ?", impl.plantNr) + if customerId != "" { + session = session.And("AP_CustDemandVerHead.CustomerId = ?", customerId) + } + if artId != "" { + session = session.And("AP_CustDemandVerDetail.ArtId like concat('%%', ?, '%%')", artId) + } + session = session.OrderBy("AP_CustDemandVerHead.VersionId") + + data := make([]model.CustDemandVerHead, 0, 10) + err := session.Find(&data) + if err != nil { + return nil, grmi.NewDataBaseError(err) + } + return data, nil + } + +} diff --git a/models/ap/CustDemandVerHead.model.go b/models/ap/CustDemandVerHead.model.go index 7d59aae..65123d5 100644 --- a/models/ap/CustDemandVerHead.model.go +++ b/models/ap/CustDemandVerHead.model.go @@ -20,33 +20,34 @@ import ( * ******************************************************************************/ type CustDemandVerHead struct { - PlantNr int `xorm:"pk int 'PlantNr'" json:"AP_CustDemandVerHead-PlantNr"` - CustomerId string `xorm:"pk nvarchar(40) 'CustomerId'" json:"AP_CustDemandVerHead-CustomerId"` - VersionId string `xorm:"pk nvarchar(40) 'VersionId'" json:"AP_CustDemandVerHead-VersionId"` - Descr string `xorm:"nvarchar(100) 'Descr' not null" json:"AP_CustDemandVerHead-Descr"` - Status string `xorm:"nvarchar(1) 'Status' not null" json:"AP_CustDemandVerHead-Status"` - GlobalPublish int `xorm:"int 'GlobalPublish' not null" json:"AP_CustDemandVerHead-GlobalPublish"` - PlanReleaseTime grmi.DateTime `xorm:"datetime 'PlanReleaseTime'" json:"AP_CustDemandVerHead-PlanReleaseTime"` - ActualReleaseTime grmi.DateTime `xorm:"datetime 'ActualReleaseTime'" json:"AP_CustDemandVerHead-ActualReleaseTime"` - CreateMode string `xorm:"nvarchar(40) 'CreateMode' not null" json:"AP_CustDemandVerHead-CreateMode"` - CreateUser string `xorm:"nvarchar(40) 'CreateUser' not null" json:"AP_CustDemandVerHead-CreateUser"` - CtrlPara1 int `xorm:"int 'CtrlPara1' not null" json:"AP_CustDemandVerHead-CtrlPara1"` - CtrlPara2 int `xorm:"int 'CtrlPara2' not null" json:"AP_CustDemandVerHead-CtrlPara2"` - CtrlStr1 string `xorm:"nvarchar(255) 'CtrlStr1' not null" json:"AP_CustDemandVerHead-CtrlStr1"` - CtrlStr2 string `xorm:"nvarchar(255) 'CtrlStr2' not null" json:"AP_CustDemandVerHead-CtrlStr2"` - CtrlTime1 grmi.DateTime `xorm:"datetime 'CtrlTime1' not null created" json:"AP_CustDemandVerHead-CtrlTime1"` - CtrlTime2 grmi.DateTime `xorm:"datetime 'CtrlTime2' not null created" json:"AP_CustDemandVerHead-CtrlTime2"` - LastModify grmi.DateTime `xorm:"datetime 'LastModify' not null updated" json:"AP_CustDemandVerHead-LastModify"` - LastUser string `xorm:"nvarchar(20) 'LastUser' not null" json:"AP_CustDemandVerHead-LastUser"` - CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null created" json:"AP_CustDemandVerHead-CreateTime"` - CustomerItem []CustomerItem `xorm:"-" json:"AP_CustDemandVerHead-CustomerItem"` - CreateYear int `xorm:"int 'CreateYear'" json:"AP_CustDemandVerHead-CreateYear"` - CreateWeek int `xorm:"int 'CreateWeek'" json:"AP_CustDemandVerHead-CreateWeek"` - CreateModeDescr string `xorm:"-" json:"AP_CustDemandVerHead-CreateModeDescr"` - Valid bool `xorm:"-" json:"AP_CustDemandVerHead-Valid"` - PublishId int `xorm:"int 'PublishId'" json:"AP_CustDemandVerHead-PublishId"` - PublishNumber string `xorm:"nvarchar(255) 'PublishNumber'" json:"AP_CustDemandVerHead-PublishNumber"` - PublishStatus int `xorm:"int 'PublishStatus'" json:"AP_CustDemandVerHead-PublishStatus"` + PlantNr int `xorm:"pk int 'PlantNr'" json:"AP_CustDemandVerHead-PlantNr"` + CustomerId string `xorm:"pk nvarchar(40) 'CustomerId'" json:"AP_CustDemandVerHead-CustomerId"` + VersionId string `xorm:"pk nvarchar(40) 'VersionId'" json:"AP_CustDemandVerHead-VersionId"` + Descr string `xorm:"nvarchar(100) 'Descr' not null" json:"AP_CustDemandVerHead-Descr"` + Status string `xorm:"nvarchar(1) 'Status' not null" json:"AP_CustDemandVerHead-Status"` + GlobalPublish int `xorm:"int 'GlobalPublish' not null" json:"AP_CustDemandVerHead-GlobalPublish"` + PlanReleaseTime grmi.DateTime `xorm:"datetime 'PlanReleaseTime'" json:"AP_CustDemandVerHead-PlanReleaseTime"` + ActualReleaseTime grmi.DateTime `xorm:"datetime 'ActualReleaseTime'" json:"AP_CustDemandVerHead-ActualReleaseTime"` + CreateMode string `xorm:"nvarchar(40) 'CreateMode' not null" json:"AP_CustDemandVerHead-CreateMode"` + CreateUser string `xorm:"nvarchar(40) 'CreateUser' not null" json:"AP_CustDemandVerHead-CreateUser"` + CtrlPara1 int `xorm:"int 'CtrlPara1' not null" json:"AP_CustDemandVerHead-CtrlPara1"` + CtrlPara2 int `xorm:"int 'CtrlPara2' not null" json:"AP_CustDemandVerHead-CtrlPara2"` + CtrlStr1 string `xorm:"nvarchar(255) 'CtrlStr1' not null" json:"AP_CustDemandVerHead-CtrlStr1"` + CtrlStr2 string `xorm:"nvarchar(255) 'CtrlStr2' not null" json:"AP_CustDemandVerHead-CtrlStr2"` + CtrlTime1 grmi.DateTime `xorm:"datetime 'CtrlTime1' not null created" json:"AP_CustDemandVerHead-CtrlTime1"` + CtrlTime2 grmi.DateTime `xorm:"datetime 'CtrlTime2' not null created" json:"AP_CustDemandVerHead-CtrlTime2"` + LastModify grmi.DateTime `xorm:"datetime 'LastModify' not null updated" json:"AP_CustDemandVerHead-LastModify"` + LastUser string `xorm:"nvarchar(20) 'LastUser' not null" json:"AP_CustDemandVerHead-LastUser"` + CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null created" json:"AP_CustDemandVerHead-CreateTime"` + CustomerItem []CustomerItem `xorm:"-" json:"AP_CustDemandVerHead-CustomerItem"` + CustDemandVerDetail map[string]CustDemandVerDetail `json:"CustDemandVerDetail" xorm:"-"` + CreateYear int `xorm:"int 'CreateYear'" json:"AP_CustDemandVerHead-CreateYear"` + CreateWeek int `xorm:"int 'CreateWeek'" json:"AP_CustDemandVerHead-CreateWeek"` + CreateModeDescr string `xorm:"-" json:"AP_CustDemandVerHead-CreateModeDescr"` + Valid bool `xorm:"-" json:"AP_CustDemandVerHead-Valid"` + PublishId int `xorm:"int '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/services/ap/CustDemandVerHead.service.go b/services/ap/CustDemandVerHead.service.go index e5784ad..715384d 100644 --- a/services/ap/CustDemandVerHead.service.go +++ b/services/ap/CustDemandVerHead.service.go @@ -379,7 +379,7 @@ type CustDemandVerHeadService interface { * @Date : 2021-08-20 11:11:05 * ******************************************************************************/ - CompareVersionInfoByArtcle(user *global.User, versions string, artcle string,opotionId string) (*commonModel.CustomerDeviationDetailItemBomLst, error) + CompareVersionInfoByArtcle(user *global.User, versions string, artcle string, opotionId string) (*commonModel.CustomerDeviationDetailItemBomLst, error) /****************************************************************************** * * @Function Name : ExportCompareVersionInfoByArtcle @@ -394,7 +394,7 @@ type CustDemandVerHeadService interface { * @Date : 2021-08-20 11:11:05 * ******************************************************************************/ - ExportCompareVersionInfoByArtcle(user *global.User, versions string, artcle string,opotionId string) (interface{}, error) + ExportCompareVersionInfoByArtcle(user *global.User, versions string, artcle string, opotionId string) (interface{}, error) /****************************************************************************** * * @Function Name : ExportCompareVersion @@ -471,6 +471,27 @@ type CustDemandVerHeadService interface { * ******************************************************************************/ RemoveIssueVersion(user *global.User, entity *model.CustDemandVerHead) error + /****************************************************************************** + * + * @Function Name : SelectData + *----------------------------------------------------------------------------- + * + * @Description : 查询CustDemandVerHead + * + * @Function Parameters : 当前访问人员信息 + * + * @Function Parameters : 查询参数 + * + * @Return Value : 查询结果 + * + * @Return Value : 执行时发生的错误 + * + * @Author : 代码生成器创建 + * + * @Date : 2021-08-20 11:11:05 + * + ******************************************************************************/ + SelectData(*global.User, string, string,bool) ([]model.CustDemandVerHead, error) } /****************************************************************************** diff --git a/services/ap/implments/CustDemandVerHead.service.impl.go b/services/ap/implments/CustDemandVerHead.service.impl.go index f7a47e3..6db8ecc 100644 --- a/services/ap/implments/CustDemandVerHead.service.impl.go +++ b/services/ap/implments/CustDemandVerHead.service.impl.go @@ -341,6 +341,7 @@ func (impl *CustDemandVerHeadServiceImplement) SelectOne(user *global.User, cust //排序 sort.Strings(sortArtKeys) temData := make([]model.CustomerItem, 0) + detail := make(map[string]model.CustDemandVerDetail) var SortKeys []string //第二步根据模型分类处理 if mInfo.DemandStartDateMode == "D" { @@ -353,7 +354,6 @@ func (impl *CustDemandVerHeadServiceImplement) SelectOne(user *global.User, cust one.CustomerId = result.CustomerId one.Version = result.VersionId item := make(map[string]int) - detail := make(map[string]model.CustDemandVerDetail) for _, vv := range artInfo { dateTime := vv.DemandDate.Restore() key := utils.TimeFormat(dateTime, "yyyy-MM-dd") @@ -377,7 +377,6 @@ func (impl *CustDemandVerHeadServiceImplement) SelectOne(user *global.User, cust one.CustomerId = result.CustomerId one.Version = result.VersionId item := make(map[string]int) - detail := make(map[string]model.CustDemandVerDetail) for _, vv := range artInfo { key := utils.ValueToString(vv.DemandYear, "") + "." + utils.ValueToString(vv.DemandWeek, "") item[key] = utils.ValueToInt(vv.DemandQty, 0) @@ -401,7 +400,6 @@ func (impl *CustDemandVerHeadServiceImplement) SelectOne(user *global.User, cust one.CustomerId = result.CustomerId one.Version = result.VersionId item := make(map[string]int) - detail := make(map[string]model.CustDemandVerDetail) for _, vv := range artInfo { key := utils.ValueToString(vv.DemandYear, "") + "." + utils.ValueToString(vv.DemandMonth, "") item[key] = utils.ValueToInt(vv.DemandQty, 0) @@ -419,6 +417,7 @@ func (impl *CustDemandVerHeadServiceImplement) SelectOne(user *global.User, cust return nil, err } //第三步:构建数组 + result.CustDemandVerDetail = detail result.CustomerItem = temData return result, nil } @@ -663,6 +662,47 @@ func (impl *CustDemandVerHeadServiceImplement) Select(user *global.User, urlPara return result, nil } +/****************************************************************************** + * + * @Reference leit.com/LAPP_CHEERSSON_BACKEND/services/ap/CustDemandVerHeadService.SelectData + * + ******************************************************************************/ +func (impl *CustDemandVerHeadServiceImplement) SelectData(user *global.User, customerId string, artId string, Valid bool) ([]model.CustDemandVerHead, 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, artId, Valid) + if err != nil { + return nil, err + } + + list, err := globalDao.Select([]grmi.Predicate{ + meta.CustDemandHead_CustomerId.NewPredicate(grmi.Equal, customerId), + }, nil) + if err != nil { + return nil, 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 + } + + } + } + return result, nil +} + /****************************************************************************** * * @Reference leit.com/LAPP_CHEERSSON_BACKEND/services/ap/CustDemandVerHeadService.SelectUnique @@ -2680,6 +2720,7 @@ func (impl *CustDemandVerHeadServiceImplement) SelectOneByCust(user *global.User temData = append(temData, one) } //第三步:构建数组 + result.CustDemandVerDetail = detail result.CustomerItem = temData return result, nil } diff --git a/web/controllers/ap/CustDemandVerHead.rest.go b/web/controllers/ap/CustDemandVerHead.rest.go index b7903e7..a354021 100644 --- a/web/controllers/ap/CustDemandVerHead.rest.go +++ b/web/controllers/ap/CustDemandVerHead.rest.go @@ -554,7 +554,6 @@ func RegisterIssueOneCustDemandVerHead(party router.Party, httpMethod string, pa }) } - /****************************************************************************** * * @Function Name : RegisterIssueUpdateOneCustDemandVerHead @@ -1036,8 +1035,6 @@ func RegisterCompareVersionCustDemandVerHead(party router.Party, path string, me }) } - - /****************************************************************************** * * @Function Name : RegisterSelectOneByCust @@ -1079,7 +1076,6 @@ func RegisterSelectOneByCust(party router.Party, path string, method func(*globa }) } - /****************************************************************************** * * @Function Name : RegisterDeviationAnalysisCustDemandVerHead @@ -1327,3 +1323,45 @@ func RegisterRemoveIssueOneCustDemandVerHead(party router.Party, httpMethod stri supports.Ok(ctx, supports.OptionSuccess, nil) }) } + +/****************************************************************************** + * + * @Function Name : RegisterCompareVersionCustDemandVerDetail + *----------------------------------------------------------------------------- + * + * @Description : 为一个查找单条CustDemandVerDetail的方法注册路由 + * + * @Function Parameters : 路由分组 + * + * @Function Parameters : 路径 + * + * @Function Parameters : 实际处理请求的方法 + * + * @Author : 代码生成器创建 + * + * @Date : 2021-08-20 11:11:05 + * + ******************************************************************************/ +func RegisterSearchCustDemandVerHead(party router.Party, path string, method func(*global.User, string, string, bool) ([]model.CustDemandVerHead, error)) { + + party.Get(path, func(ctx iris.Context) { + user, ok := jwts.ParseToken(ctx) + if !ok { + supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil) + return + } + customerId := ctx.URLParam("customerId") + artId := ctx.URLParam("artId") + valid, _ := ctx.URLParamBool("valid") + result, err := method(user, customerId, 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) + }) +} diff --git a/web/controllers/ap/ap.go b/web/controllers/ap/ap.go index e18bf41..e4c4c7a 100644 --- a/web/controllers/ap/ap.go +++ b/web/controllers/ap/ap.go @@ -112,6 +112,8 @@ func RegisterRoutes() { // RegisterDeleteCustDemandVerHead(custdemandverhead, "/delete", serviceOfCustDemandVerHead.Delete) // CustDemandVerHead查询多条 RegisterSelectCustDemandVerHead(custdemandverhead, "/selectlist", serviceOfCustDemandVerHead.Select) + //CustDemandVerHead查询多条(支持模糊查询物料) + RegisterSearchCustDemandVerHead(custdemandverhead, "/selectdata", serviceOfCustDemandVerHead.SelectData) // CustDemandVerHead查询多条 RegisterSelectUniqueCustDemandVerHead(custdemandverhead, "/selectuinquelist", serviceOfCustDemandVerHead.SelectUnique) // CustDemandVerHead查询多条并分页