Browse Source

配置零件增加零件数量 零件配置

增加启动可以设置项目目录 -p 优化所有项目在goland debug模式下访问同一个配置文件
pull/39/head
yehongyang 3 years ago
parent
commit
fef2512d60
12 changed files with 38 additions and 4 deletions
  1. +3
    -1
      dao/me/implments/Product.dao.impl.go
  2. +4
    -1
      dao/me/implments/ProductFamily.dao.impl.go
  3. +1
    -0
      main.go
  4. +2
    -0
      meta/me/ProductFamilyRelate.meta.go
  5. +2
    -1
      models/me/Product.model.go
  6. +1
    -0
      models/me/ProductFamily.model.go
  7. +1
    -0
      models/me/ProductFamilyRelate.model.go
  8. +16
    -0
      services/me/implments/Product.service.impl.go
  9. +3
    -1
      services/me/implments/ProductFamily.service.impl.go
  10. +1
    -0
      services/me/implments/ProductFamilyRelate.service.impl.go
  11. +3
    -0
      utils/file.go
  12. +1
    -0
      utils/sysconf.go

+ 3
- 1
dao/me/implments/Product.dao.impl.go View File

@ -100,9 +100,11 @@ func (impl *ProductDAOImplement) SelectOne(productId string) (*model.Product, er
impl.session.Table(meta.ProductFamilyRelate.TableName).Where("ProductId=?", data.ProductId).Find(&relate) impl.session.Table(meta.ProductFamilyRelate.TableName).Where("ProductId=?", data.ProductId).Find(&relate)
var projectId []string var projectId []string
var familyId []string var familyId []string
familyCount := make(map[string]int)
for _, v := range relate { for _, v := range relate {
projectId = append(projectId, v.ProjectId) projectId = append(projectId, v.ProjectId)
familyId = append(familyId, v.ProductFamilyId) familyId = append(familyId, v.ProductFamilyId)
familyCount[v.ProductFamilyId] = v.Count
} }
//查询车型 //查询车型
var project []model.Project var project []model.Project
@ -113,6 +115,7 @@ func (impl *ProductDAOImplement) SelectOne(productId string) (*model.Product, er
//配置map //配置map
familyMap := make(map[string][]model.ProductFamily) familyMap := make(map[string][]model.ProductFamily)
for _, v := range family { for _, v := range family {
v.Count = familyCount[v.ProductFamilyId]
familyMap[v.ProjectId] = append(familyMap[v.ProjectId], v) familyMap[v.ProjectId] = append(familyMap[v.ProjectId], v)
} }
//将配置导入车型 //将配置导入车型
@ -333,4 +336,3 @@ func (impl *ProductDAOImplement) UpdateWhere(predicates []grmi.Predicate, entity
} }
return nil return nil
} }

+ 4
- 1
dao/me/implments/ProductFamily.dao.impl.go View File

@ -99,16 +99,19 @@ func (impl *ProductFamilyDAOImplement) SelectOne(productFamilyId string) (*model
var relate []model.ProductFamilyRelate var relate []model.ProductFamilyRelate
err = impl.session.Table(meta.ProductFamilyRelate.TableName).Where("ProductFamilyId = ? and ProjectId=?", data.ProductFamilyId, data.ProjectId).Find(&relate) err = impl.session.Table(meta.ProductFamilyRelate.TableName).Where("ProductFamilyId = ? and ProjectId=?", data.ProductFamilyId, data.ProjectId).Find(&relate)
var productId []string var productId []string
productCount := make(map[string]int)
for _, v := range relate { for _, v := range relate {
productId = append(productId, v.ProductId) productId = append(productId, v.ProductId)
productCount[v.ProductId] = v.Count
} }
//查询车型配置零件 //查询车型配置零件
var product []model.Product var product []model.Product
err = impl.session.Table(meta.Product.TableName).In("ProductId", productId).Find(&product) err = impl.session.Table(meta.Product.TableName).In("ProductId", productId).Find(&product)
if err == nil { if err == nil {
for k, _ := range product {
for k, v := range product {
product[k].ProductFamilyId = data.ProductFamilyId product[k].ProductFamilyId = data.ProductFamilyId
product[k].ProjectId = data.ProjectId product[k].ProjectId = data.ProjectId
product[k].Count = productCount[v.ProductId]
} }
data.Product = product data.Product = product
} }


+ 1
- 0
main.go View File

@ -81,6 +81,7 @@ func imain() {
//初始化日志开始 //初始化日志开始
baseDir := "" baseDir := ""
flag.StringVar(&baseDir, "dir", "log", "running in a directory") flag.StringVar(&baseDir, "dir", "log", "running in a directory")
flag.StringVar(&utils.SysPath, "p", "", "root Path")
flag.Parse() flag.Parse()
defer glog.Flush() defer glog.Flush()


+ 2
- 0
meta/me/ProductFamilyRelate.meta.go View File

@ -22,6 +22,7 @@ var ProductFamilyRelate_ProjectId = grmi.NewField("ProjectId", "[ME_ProductFamil
var ProductFamilyRelate_ProductId = grmi.NewField("ProductId", "[ME_ProductFamilyRelate].ProductId", "productid", grmi.TypeString) var ProductFamilyRelate_ProductId = grmi.NewField("ProductId", "[ME_ProductFamilyRelate].ProductId", "productid", grmi.TypeString)
var ProductFamilyRelate_ProductDescr = grmi.NewField("ProductDescr", "[ME_ProductFamilyRelate].ProductDescr", "productdescr", grmi.TypeString) var ProductFamilyRelate_ProductDescr = grmi.NewField("ProductDescr", "[ME_ProductFamilyRelate].ProductDescr", "productdescr", grmi.TypeString)
var ProductFamilyRelate_Pos = grmi.NewField("Pos", "[ME_ProductFamilyRelate].Pos", "pos", grmi.TypeInt) var ProductFamilyRelate_Pos = grmi.NewField("Pos", "[ME_ProductFamilyRelate].Pos", "pos", grmi.TypeInt)
var ProductFamilyRelate_Count = grmi.NewField("Count", "[ME_ProductFamilyRelate].Count", "count", grmi.TypeInt)
var ProductFamilyRelate_LastModify = grmi.NewField("LastModify", "[ME_ProductFamilyRelate].LastModify", "lastmodify", grmi.TypeDateTime) var ProductFamilyRelate_LastModify = grmi.NewField("LastModify", "[ME_ProductFamilyRelate].LastModify", "lastmodify", grmi.TypeDateTime)
var ProductFamilyRelate_LastUser = grmi.NewField("LastUser", "[ME_ProductFamilyRelate].LastUser", "lastuser", grmi.TypeString) var ProductFamilyRelate_LastUser = grmi.NewField("LastUser", "[ME_ProductFamilyRelate].LastUser", "lastuser", grmi.TypeString)
var ProductFamilyRelate_CreateTime = grmi.NewField("CreateTime", "[ME_ProductFamilyRelate].CreateTime", "createtime", grmi.TypeDateTime) var ProductFamilyRelate_CreateTime = grmi.NewField("CreateTime", "[ME_ProductFamilyRelate].CreateTime", "createtime", grmi.TypeDateTime)
@ -45,6 +46,7 @@ var ProductFamilyRelate = grmi.NewEntity(
ProductFamilyRelate_ProductId.Name: ProductFamilyRelate_ProductId, ProductFamilyRelate_ProductId.Name: ProductFamilyRelate_ProductId,
ProductFamilyRelate_ProductDescr.Name: ProductFamilyRelate_ProductDescr, ProductFamilyRelate_ProductDescr.Name: ProductFamilyRelate_ProductDescr,
ProductFamilyRelate_Pos.Name: ProductFamilyRelate_Pos, ProductFamilyRelate_Pos.Name: ProductFamilyRelate_Pos,
ProductFamilyRelate_Count.Name: ProductFamilyRelate_Count,
ProductFamilyRelate_LastModify.Name: ProductFamilyRelate_LastModify, ProductFamilyRelate_LastModify.Name: ProductFamilyRelate_LastModify,
ProductFamilyRelate_LastUser.Name: ProductFamilyRelate_LastUser, ProductFamilyRelate_LastUser.Name: ProductFamilyRelate_LastUser,
ProductFamilyRelate_CreateTime.Name: ProductFamilyRelate_CreateTime, ProductFamilyRelate_CreateTime.Name: ProductFamilyRelate_CreateTime,


+ 2
- 1
models/me/Product.model.go View File

@ -24,7 +24,7 @@ type Product struct {
ProductId string `xorm:"pk nvarchar(40) 'ProductId'" json:"ME_Product-ProductId"` ProductId string `xorm:"pk nvarchar(40) 'ProductId'" json:"ME_Product-ProductId"`
Descr string `xorm:"nvarchar(40) 'Descr' not null" json:"ME_Product-Descr"` Descr string `xorm:"nvarchar(40) 'Descr' not null" json:"ME_Product-Descr"`
ProductFamilyId string `xorm:"-" json:"ME_Product-ProductFamilyId"` ProductFamilyId string `xorm:"-" json:"ME_Product-ProductFamilyId"`
ProjectId string `xorm:"-" json:"ME_Product-ProjectId"`
ProjectId string `xorm:"nvarchar(40) 'ProjectId'" json:"ME_Product-ProjectId"`
DefaultWorkLineId string `xorm:"nvarchar(40) 'DefaultWorkLineId'" json:"ME_Product-DefaultWorkLineId"` DefaultWorkLineId string `xorm:"nvarchar(40) 'DefaultWorkLineId'" json:"ME_Product-DefaultWorkLineId"`
MultiWorkLineToggle bool `xorm:"bit 'MultiWorkLineToggle' not null" json:"ME_Product-MultiWorkLineToggle"` MultiWorkLineToggle bool `xorm:"bit 'MultiWorkLineToggle' not null" json:"ME_Product-MultiWorkLineToggle"`
Descr1 string `xorm:"nvarchar(40) 'Descr1' not null" json:"ME_Product-Descr1"` Descr1 string `xorm:"nvarchar(40) 'Descr1' not null" json:"ME_Product-Descr1"`
@ -62,6 +62,7 @@ type Product struct {
CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null created" json:"ME_Product-CreateTime"` CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null created" json:"ME_Product-CreateTime"`
Project []Project `xorm:"-" json:"-"` Project []Project `xorm:"-" json:"-"`
ProductFamily []ProductFamily `xorm:"-" json:"ME_Product-ProductFamily"` ProductFamily []ProductFamily `xorm:"-" json:"ME_Product-ProductFamily"`
Count int `xorm:"-" json:"ME_Product-Count"`
} }
/****************************************************************************** /******************************************************************************


+ 1
- 0
models/me/ProductFamily.model.go View File

@ -44,6 +44,7 @@ type ProductFamily struct {
Product []Product `xorm:"-" json:"ME_ProductFamily-Product"` Product []Product `xorm:"-" json:"ME_ProductFamily-Product"`
Relate []ProductFamilyRelate `xorm:"-" json:"-"` Relate []ProductFamilyRelate `xorm:"-" json:"-"`
Project Project `xorm:"-" json:"-"` Project Project `xorm:"-" json:"-"`
Count int `xorm:"-" json:"ME_ProductFamily-Count"`
} }
/****************************************************************************** /******************************************************************************


+ 1
- 0
models/me/ProductFamilyRelate.model.go View File

@ -26,6 +26,7 @@ type ProductFamilyRelate struct {
ProductId string `xorm:"pk nvarchar(40) 'ProductId'" json:"ME_ProductFamilyRelate-ProductId"` ProductId string `xorm:"pk nvarchar(40) 'ProductId'" json:"ME_ProductFamilyRelate-ProductId"`
ProductDescr string `xorm:"nvarchar(40) 'ProductDescr' not null" json:"ME_ProductFamilyRelate-ProductDescr"` ProductDescr string `xorm:"nvarchar(40) 'ProductDescr' not null" json:"ME_ProductFamilyRelate-ProductDescr"`
Pos int `xorm:"int 'Pos' not null" json:"ME_ProductFamilyRelate-Pos"` Pos int `xorm:"int 'Pos' not null" json:"ME_ProductFamilyRelate-Pos"`
Count int `xorm:"int 'Count' not null" json:"ME_ProductFamilyRelate-Count"`
LastModify grmi.DateTime `xorm:"datetime 'LastModify' not null updated" json:"ME_ProductFamilyRelate-LastModify"` LastModify grmi.DateTime `xorm:"datetime 'LastModify' not null updated" json:"ME_ProductFamilyRelate-LastModify"`
LastUser string `xorm:"nvarchar(20) 'LastUser' not null" json:"ME_ProductFamilyRelate-LastUser"` LastUser string `xorm:"nvarchar(20) 'LastUser' not null" json:"ME_ProductFamilyRelate-LastUser"`
CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null created" json:"ME_ProductFamilyRelate-CreateTime"` CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null created" json:"ME_ProductFamilyRelate-CreateTime"`


+ 16
- 0
services/me/implments/Product.service.impl.go View File

@ -133,6 +133,9 @@ func (impl *ProductServiceImplement) InsertOne(user *global.User, entity *model.
if record != nil { if record != nil {
return grmi.NewBusinessError("已经存在相同主键的记录!") return grmi.NewBusinessError("已经存在相同主键的记录!")
} }
if !(entity.Count > 0) {
return grmi.NewBusinessError("请填写数量!")
}
//查询配置 //查询配置
relateL, err := relateDao.SelectOne(entity.ProductFamilyId, entity.ProjectId, entity.ProductId) relateL, err := relateDao.SelectOne(entity.ProductFamilyId, entity.ProjectId, entity.ProductId)
if err != nil { if err != nil {
@ -148,6 +151,7 @@ func (impl *ProductServiceImplement) InsertOne(user *global.User, entity *model.
ProductDescr: entity.Descr, ProductDescr: entity.Descr,
ProjectId: entity.ProjectId, ProjectId: entity.ProjectId,
ProductId: entity.ProductId, ProductId: entity.ProductId,
Count: entity.Count,
} }
err = relateDao.InsertOne(&relateData) err = relateDao.InsertOne(&relateData)
if err != nil { if err != nil {
@ -293,6 +297,18 @@ func (impl *ProductServiceImplement) UpdateOne(user *global.User, entity *model.
return grmi.NewBusinessError("不存在指定记录!") return grmi.NewBusinessError("不存在指定记录!")
} }
err = dao.UpdateOne(entity) err = dao.UpdateOne(entity)
//如过count大于0修改对应配置数量
if entity.Count > 0 {
rateDao := dal.NewProductFamilyRelateDAO(session, user.PlantNr, user.UserId)
//修改数量
rate := model.ProductFamilyRelate{
Count: entity.Count,
ProjectId: entity.ProjectId,
ProductFamilyId: entity.ProductFamilyId,
ProductId: entity.ProductId,
}
rateDao.UpdateOne(&rate)
}
if err != nil { if err != nil {
return err return err
} }


+ 3
- 1
services/me/implments/ProductFamily.service.impl.go View File

@ -153,12 +153,14 @@ func (impl *ProductFamilyServiceImplement) Association(user *global.User, entity
} }
//添加配置 //添加配置
var relateData []model.ProductFamilyRelate var relateData []model.ProductFamilyRelate
for _, v := range entity.Product {
for k, v := range entity.Product {
relateData = append(relateData, model.ProductFamilyRelate{ relateData = append(relateData, model.ProductFamilyRelate{
ProductId: v.ProductId, ProductId: v.ProductId,
ProductFamilyId: record.ProductFamilyId, ProductFamilyId: record.ProductFamilyId,
ProjectId: record.ProjectId, ProjectId: record.ProjectId,
ProductDescr: v.Descr, ProductDescr: v.Descr,
Count: v.Count,
Pos: k,
}) })
} }
if len(relateData) == 0 { if len(relateData) == 0 {


+ 1
- 0
services/me/implments/ProductFamilyRelate.service.impl.go View File

@ -30,6 +30,7 @@ var DefaultConditionOfProductFamilyRelate = grmi.NewCondition(
meta.ProductFamilyRelate_LastModify.UrlParameterName: grmi.NewConditionItem(meta.ProductFamilyRelate_LastModify, grmi.Approximate, false), meta.ProductFamilyRelate_LastModify.UrlParameterName: grmi.NewConditionItem(meta.ProductFamilyRelate_LastModify, grmi.Approximate, false),
meta.ProductFamilyRelate_LastUser.UrlParameterName: grmi.NewConditionItem(meta.ProductFamilyRelate_LastUser, grmi.Equal, false), meta.ProductFamilyRelate_LastUser.UrlParameterName: grmi.NewConditionItem(meta.ProductFamilyRelate_LastUser, grmi.Equal, false),
meta.ProductFamilyRelate_CreateTime.UrlParameterName: grmi.NewConditionItem(meta.ProductFamilyRelate_CreateTime, grmi.Approximate, false), meta.ProductFamilyRelate_CreateTime.UrlParameterName: grmi.NewConditionItem(meta.ProductFamilyRelate_CreateTime, grmi.Approximate, false),
meta.ProductFamilyRelate_Count.UrlParameterName: grmi.NewConditionItem(meta.ProductFamilyRelate_Count, grmi.Equal, false),
}, },
nil, nil,
) )


+ 3
- 0
utils/file.go View File

@ -117,6 +117,9 @@ func IsExists(path string) bool {
* *
******************************************************************************/ ******************************************************************************/
func GetCurrentPath(dir string) (string, error) { func GetCurrentPath(dir string) (string, error) {
if SysPath != "" {
return SysPath + dir, nil
}
file, err := exec.LookPath(os.Args[0]) file, err := exec.LookPath(os.Args[0])
if err != nil { if err != nil {
return "", err return "", err


+ 1
- 0
utils/sysconf.go View File

@ -28,3 +28,4 @@ const (
// 中国时区 // 中国时区
var SysTimeLocation, _ = time.LoadLocation("Asia/Chongqing") var SysTimeLocation, _ = time.LoadLocation("Asia/Chongqing")
var SysPath string

Loading…
Cancel
Save