123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- package supply_analysis
- import (
- "eta_gn/eta_index_lib/global"
- "time"
- )
- // VarietyPlant variety_plant 品种装置表
- type VarietyPlant struct {
- VarietyPlantId int `gorm:"primaryKey;autoIncrement;column:variety_plant_id" description:"品种装置ID"`
- VarietyId int `gorm:"column:variety_id" description:"品种id"`
- Province string `gorm:"column:province" description:"所属省份"`
- City string `gorm:"column:city" description:"所属城市"`
- FactoryName string `gorm:"column:factory_name" description:"工厂名称"`
- PlantName string `gorm:"column:plant_name" description:"装置/产线名称"`
- MaintenanceDate time.Time `gorm:"column:maintenance_date" description:"检修日期"`
- ResumptionDate time.Time `gorm:"column:resumption_date" description:"复产日期"`
- AnnualCapacity float64 `gorm:"column:annual_capacity" description:"年产能"`
- Coefficient float64 `gorm:"column:coefficient" description:"降负系数"`
- AverageDailyCapacityReduction float64 `gorm:"column:average_daily_capacity_reduction" description:"日均产量减量"`
- IsStop int `gorm:"column:is_stop" description:"是否停产,0:未停产;1:停产;默认未停产"`
- Sort int `gorm:"column:sort" description:"排序字段,越小越靠前"`
- SysUserId int `gorm:"column:sys_user_id" description:"添加人id"`
- SysUserRealName string `gorm:"column:sys_user_real_name" description:"添加人真实姓名"`
- ModifyTime time.Time `gorm:"column:modify_time" description:"最近一次更新时间"`
- CreateTime time.Time `gorm:"column:create_time" description:"添加时间"`
- }
- // GetAllVarietyPlantByVarietyId 根据品种id获取所有的装置
- func GetAllVarietyPlantByVarietyId(varietyId int) (items []*VarietyPlant, err error) {
- sql := `SELECT * FROM variety_plant a WHERE variety_id = ? ORDER BY variety_plant_id desc `
- err = global.DEFAULT_DmSQL.Raw(sql, varietyId).Scan(&items).Error
- return
- }
- // AddVarietyPlant 添加future_good_chart分类
- func AddVarietyPlant(item *VarietyPlant) (err error) {
- err = global.DEFAULT_DmSQL.Create(item).Error
- return
- }
- // Update 更新基础信息
- func (varietyPlant *VarietyPlant) Update(cols []string) (err error) {
- //_, err = o.Update(varietyPlant, cols...)
- err = global.DEFAULT_DmSQL.Model(varietyPlant).Select(cols).Updates(varietyPlant).Error
- return
- }
- // GetVarietyPlantById 根据品种装置id获取品种装置详情
- func GetVarietyPlantById(id int) (item *VarietyPlant, err error) {
- sql := `SELECT * FROM variety_plant WHERE variety_plant_id = ?`
- err = global.DEFAULT_DmSQL.Raw(sql, id).First(&item).Error
- return
- }
- // VarietyPlantItem 品种装置数据(展示使用)
- type VarietyPlantItem struct {
- VarietyPlantId int `gorm:"primaryKey;autoIncrement;column:variety_plant_id"`
- VarietyId int `description:"品种id"`
- Province string `description:"所属省份"`
- City string `description:"所属城市"`
- FactoryName string `description:"工厂名称"`
- PlantName string `description:"装置/产线名称"`
- MaintenanceDate string `description:"检修日期"`
- ResumptionDate string `description:"复产日期"`
- AnnualCapacity float64 `description:"年产能"`
- Coefficient float64 `description:"降负系数"`
- AverageDailyCapacityReduction float64 `description:"日均产量减量"`
- IsStop int `description:"是否停产,0:未停产;1:停产;默认未停产"`
- Sort int `description:"排序字段,越小越靠前"`
- SysUserId int `description:"添加人id"`
- SysUserRealName string `description:"添加人真实姓名"`
- ModifyTime string `description:"最近一次更新时间"`
- CreateTime string `description:"添加时间"`
- Button VarietyPlantButton `description:"操作按钮权限"`
- }
- type VarietyPlantButton struct {
- Edit bool `description:"操作权限"`
- Delete bool `description:"删除权限"`
- }
- // GetAllVarietyPlantItemByVarietyId 根据品种id获取所有的装置
- func GetAllVarietyPlantItemByVarietyId(varietyId int) (items []*VarietyPlantItem, err error) {
- sql := `SELECT * FROM variety_plant a WHERE variety_id = ? ORDER BY variety_plant_id desc `
- err = global.DEFAULT_DmSQL.Raw(sql, varietyId).Scan(&items).Error
- return
- }
- // GetCountVarietyPlantByVarietyId 根据品种id获取所有的装置数量
- func GetCountVarietyPlantByVarietyId(varietyId int) (total int, err error) {
- sql := `SELECT count(1) total FROM variety_plant a WHERE variety_id = ? `
- err = global.DEFAULT_DmSQL.Raw(sql, varietyId).Scan(&total).Error
- return
- }
- // DeleteVarietyPlantById 根据装置id删除
- func DeleteVarietyPlantById(id int) (err error) {
- sql := `DELETE FROM variety_plant WHERE variety_plant_id = ?`
- err = global.DEFAULT_DmSQL.Exec(sql, id).Error
- return
- }
|