123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- package models
- import (
- "rdluck_tools/orm"
- "time"
- )
- type Longzhongdata struct {
- LongzhongdataId int `orm:"column(longzhongdata_id);pk"`
- LongzhonginfoId int
- TradeCode string
- Dt string
- Close float64
- CreateTime time.Time
- ModifyTime time.Time
- UnitDesc string
- UpdTime string
- }
- type Longzhonginfo struct {
- LongzhonginfoId int `orm:"column(longzhonginfo_id);pk"`
- TradeCode string
- SecName string
- Frequency string
- ClassifyId int
- ClassifyName string
- Unit string
- CreateTime time.Time
- Remark string
- IsNormal string
- LastModifyDate string
- Unitid int64
- TempId int64
- TempName string
- ModifyTime time.Time
- }
- func GetLongzhonginfoBySecName(secName string) (item *Longzhongdata, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := `SELECT * FROM longzhonginfo WHERE sec_name=? `
- err = o.Raw(sql, secName).QueryRow(&item)
- return
- }
- //判断指标数据是否已经录入
- func GetLongzhongdataCount(longzhonginfoId int, dt string) (count int, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := `SELECT COUNT(1) AS count FROM longzhongdata WHERE longzhonginfo_id=? AND dt=? `
- err = o.Raw(sql, longzhonginfoId, dt).QueryRow(&count)
- return
- }
- func AddLongzhongdata(item *Longzhongdata) (err error) {
- o := orm.NewOrm()
- o.Using("edb")
- _, err = o.Insert(item)
- return
- }
- func ModifyLongzhongdata(item *Longzhongdata) (err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := ` UPDATE longzhongdata
- SET
- close = ?,
- modify_time= NOW(),
- unit_desc= ?,
- upd_time = ?
- WHERE longzhonginfo_id = ? AND dt=?
- `
- _, err = o.Raw(sql, item.Close, item.UnitDesc, item.UpdTime, item.LongzhonginfoId, item.Dt).Exec()
- return
- }
- func AddLongzhonginfo(item *Longzhonginfo) (newId int64, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- newId, err = o.Insert(item)
- return
- }
- func ModifyLongzhonginfo(item *Longzhonginfo) (err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := `UPDATE longzhonginfo
- SET
- sec_name = ?,
- unit = ?,
- frequency = ?,
- classify_id = ?,
- classify_name = ?,
- remark = ?,
- last_modify_date = ?,
- temp_id = ?,
- temp_name = ?,
- is_normal = ?,
- modify_time=NOW()
- WHERE unitid = ? `
- _, err = o.Raw(sql, item.SecName, item.Unit, item.Frequency, item.ClassifyId, item.ClassifyName, item.Remark, item.LastModifyDate, item.TempId, item.TempName, item.IsNormal, item.Unitid).Exec()
- return
- }
- //判断指标数据是否已经录入
- func GetLongzhonginfoCount(classifyId int, unitid int64) (count int, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := `SELECT COUNT(1) AS count FROM longzhonginfo WHERE classify_id=? AND unitid=? `
- err = o.Raw(sql, classifyId, unitid).QueryRow(&count)
- return
- }
- type LzProductInfoResp struct {
- Msg string `json:"msg"`
- Code string `json:"code"`
- Data []*LzProductInfo `json:"data"`
- }
- type LzProductInfo struct {
- Unitid int64 `json:"unitid"`
- ProUnitName string `json:"proUnitName"`
- Tempid int64 `json:"tempid"`
- TempName string `json:"tempName"`
- Proid int `json:"proid"`
- ProName string `json:"proName"`
- Unit string `json:"unit"`
- LzType string `json:"type"`
- Maxdate string `json:"maxdate"`
- IsNormal string `json:"isNormal"`
- }
- func GetLongzhonginfoMaxId() (count int, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := `SELECT MAX(longzhonginfo_id) AS count FROM longzhonginfo`
- err = o.Raw(sql).QueryRow(&count)
- return
- }
- type LzProductInfoDetail struct {
- UnitId int64 `json:"unit_id"`
- UnitName string `json:"unit_name"`
- TempId int `json:"temp_id"`
- TempName string `json:"temp_name"`
- TempUnit string `json:"temp_unit"`
- ProId int `json:"pro_id"`
- ProCnName string `json:"pro_cn_name"`
- UnitValue float64 `json:"unit_value"`
- UnitDesc string `json:"unit_desc"`
- DataTime string `json:"data_time"`
- UpdTime string `json:"upd_time"`
- }
- type LzProductInfoDetailResp struct {
- Msg string `json:"msg"`
- Code string `json:"code"`
- Data []*LzProductInfoDetail `json:"data"`
- Pagesize int `json:"pagesize"`
- Page int `json:"page"`
- }
- func GetLongzhonginfoByUnitId(classifyName string, unitId int64) (item *Longzhongdata, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := `SELECT * FROM longzhonginfo WHERE unitid=? AND classify_name=?`
- err = o.Raw(sql, unitId, classifyName).QueryRow(&item)
- return
- }
- func GetLongzhongDataById(lzInfoId int) (items []*Longzhongdata, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := `SELECT * FROM longzhongdata WHERE longzhonginfo_id=? ORDER BY dt DESC `
- _, err = o.Raw(sql, lzInfoId).QueryRows(&items)
- return
- }
- func GetLongzhongDataMaxCount(classifyId int) (count int, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := `SELECT MAX(t.num) AS count FROM (
- SELECT COUNT(1) AS num FROM longzhonginfo AS a
- INNER JOIN longzhongdata AS b ON a.longzhonginfo_id=b.longzhonginfo_id
- WHERE a.classify_id=?
- GROUP BY a.longzhonginfo_id
- )AS t `
- err = o.Raw(sql, classifyId).QueryRow(&count)
- return
- }
- type LongzhonginfoList struct {
- LongzhonginfoId int `orm:"column(longzhonginfo_id);pk"`
- TradeCode string
- SecName string
- Frequency string
- ClassifyId int
- ClassifyName string
- Unit string
- IsNormal string
- LastModifyDate string
- Unitid int
- }
- func GetLongzhonginfoList() (items []*LongzhonginfoList, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := ` SELECT * FROM longzhonginfo WHERE is_normal=1 `
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- func ModifyLongzhonginfoIsNormal(longzhonginfoId int) (err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := ` UPDATE longzhonginfo SET is_normal=0 WHERE longzhonginfo_id=? `
- _, err = o.Raw(sql, longzhonginfoId).Exec()
- return
- }
- type LzPriceInfo struct {
- Standard string `json:"standard"`
- ModelName string `json:"modelName"`
- Unit string `json:"unit"`
- AreaName string `json:"areaName"`
- PriceType string `json:"priceType"`
- Memo string `json:"memo"`
- Id string `json:"id"`
- ProductName string `json:"productName"`
- }
- type LzPriceInfoResp struct {
- Msg string `json:"msg"`
- Code int `json:"code"`
- Data []*LzPriceInfo `json:"data"`
- }
- type Longzhongpriceinfo struct {
- LongzhongpriceinfoId int `orm:"column(longzhongpriceinfo_id);pk"`
- Standard string
- ModelName string
- Unit string
- AreaName string
- PriceType string
- Memo string
- PriceId string
- ProductName string
- InfoType string
- InfoTypeRemark string
- }
- func AddLongzhongpriceinfo(item *Longzhongpriceinfo) (newId int64, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- newId, err = o.Insert(item)
- return
- }
- //判断指标数据是否已经录入
- func GetLongzhongpriceinfoCount(unitid string) (count int, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := `SELECT COUNT(1) AS count FROM longzhongpriceinfo WHERE price_id=? `
- err = o.Raw(sql, unitid).QueryRow(&count)
- return
- }
- //判断指标数据是否已经录入
- func GetLongzhongpriceinfo() (items []*Longzhongpriceinfo, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := `SELECT * FROM longzhongpriceinfo `
- _,err = o.Raw(sql).QueryRows(&items)
- return
- }
- type Longzhongpricedata struct {
- LongzhongpricedataId int `orm:"column(longzhongpricedata_id);pk"`
- LongzhongpriceinfoId int
- PriceDate string
- Memo string
- Price string
- CnyPrice string
- ZsyPrice string
- ZshPrice string
- LowPrice string
- HighPrice string
- RisePrice string
- TonPrice string
- PriceType string
- UpdateDate string
- }
- func AddLongzhongpricedata(item *Longzhongpricedata) (newId int64, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- newId, err = o.Insert(item)
- return
- }
- //判断指标数据是否已经录入
- func GetLongzhongpricedataCount(unitid, priceDate string) (count int, err error) {
- o := orm.NewOrm()
- o.Using("edb")
- sql := `SELECT COUNT(1) AS count FROM longzhongpricedata WHERE longzhongpriceinfo_id=? AND price_date=? `
- err = o.Raw(sql, unitid, priceDate).QueryRow(&count)
- return
- }
- type LzPriceData struct {
- Id string `json:"id"`
- PriceDate string `json:"priceDate"`
- Memo string `json:"memo"`
- Price string `json:"price"`
- CnyPrice string `json:"cnyPrice"`
- ZsyPrice string `json:"zsyPrice"`
- ZshPrice string `json:"zshPrice"`
- LowPrice string `json:"lowPrice"`
- HighPrice string `json:"highPrice"`
- RisePrice string `json:"risePrice"`
- TonPrice string `json:"tonPrice"`
- PriceType string `json:"priceType"`
- UpdateDate string `json:"updateDate"`
- }
- type LzPriceDataResp struct {
- Msg string `json:"msg"`
- Code int `json:"code"`
- Data []*LzPriceData `json:"data"`
- }
|