data_source_longzhong.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type Longzhongdata struct {
  7. LongzhongdataId int `orm:"column(longzhongdata_id);pk"`
  8. LongzhonginfoId int
  9. TradeCode string
  10. Dt string
  11. Close float64
  12. CreateTime time.Time
  13. ModifyTime time.Time
  14. UnitDesc string
  15. UpdTime string
  16. AddTime string
  17. DisplayTime string
  18. }
  19. type Longzhonginfo struct {
  20. LongzhonginfoId int `orm:"column(longzhonginfo_id);pk"`
  21. TradeCode string
  22. SecName string
  23. Frequency string
  24. ClassifyId int
  25. ClassifyName string
  26. Unit string
  27. CreateTime time.Time
  28. Remark string
  29. IsNormal string
  30. LastModifyDate string
  31. Unitid int64
  32. TempId int64
  33. TempName string
  34. ModifyTime time.Time
  35. }
  36. func GetLongzhonginfoBySecName(secName string) (item *Longzhongdata, err error) {
  37. o := orm.NewOrmUsingDB("edb")
  38. sql := `SELECT * FROM longzhonginfo WHERE sec_name=? `
  39. err = o.Raw(sql, secName).QueryRow(&item)
  40. return
  41. }
  42. //判断指标数据是否已经录入
  43. func GetLongzhongdataCount(longzhonginfoId int, dt string) (count int, err error) {
  44. o := orm.NewOrmUsingDB("edb")
  45. sql := `SELECT COUNT(1) AS count FROM longzhongdata WHERE longzhonginfo_id=? AND dt=? `
  46. err = o.Raw(sql, longzhonginfoId, dt).QueryRow(&count)
  47. return
  48. }
  49. func AddLongzhongdata(item *Longzhongdata) (err error) {
  50. o := orm.NewOrmUsingDB("edb")
  51. _, err = o.Insert(item)
  52. return
  53. }
  54. func ModifyLongzhongdata(item *Longzhongdata) (err error) {
  55. o := orm.NewOrmUsingDB("edb")
  56. sql := ` UPDATE longzhongdata
  57. SET
  58. close = ?,
  59. modify_time= NOW(),
  60. unit_desc= ?,
  61. upd_time = ?,
  62. add_time=?,
  63. display_time=?
  64. WHERE longzhonginfo_id = ? AND dt=?
  65. `
  66. _, err = o.Raw(sql, item.Close, item.UnitDesc, item.UpdTime, item.AddTime, item.DisplayTime, item.LongzhonginfoId, item.Dt).Exec()
  67. return
  68. }
  69. func AddLongzhonginfo(item *Longzhonginfo) (newId int64, err error) {
  70. o := orm.NewOrmUsingDB("edb")
  71. newId, err = o.Insert(item)
  72. return
  73. }
  74. func ModifyLongzhonginfo(item *Longzhonginfo) (err error) {
  75. o := orm.NewOrmUsingDB("edb")
  76. sql := `UPDATE longzhonginfo
  77. SET
  78. sec_name = ?,
  79. unit = ?,
  80. frequency = ?,
  81. classify_id = ?,
  82. classify_name = ?,
  83. remark = ?,
  84. last_modify_date = ?,
  85. temp_name = ?,
  86. is_normal = ?,
  87. modify_time=NOW()
  88. WHERE unitid = ? AND temp_id = ? `
  89. _, err = o.Raw(sql, item.SecName, item.Unit, item.Frequency, item.ClassifyId, item.ClassifyName, item.Remark, item.LastModifyDate, item.TempName, item.IsNormal, item.Unitid, item.TempId).Exec()
  90. return
  91. }
  92. //判断指标数据是否已经录入
  93. func GetLongzhonginfoCount(classifyId int, unitid int64) (count int, err error) {
  94. o := orm.NewOrmUsingDB("edb")
  95. sql := `SELECT COUNT(1) AS count FROM longzhonginfo WHERE classify_id=? AND unitid=? `
  96. err = o.Raw(sql, classifyId, unitid).QueryRow(&count)
  97. return
  98. }
  99. //判断指标数据是否已经录入
  100. func GetLongzhonginfoBySecNameCount(secName string) (count int, err error) {
  101. o := orm.NewOrmUsingDB("edb")
  102. sql := `SELECT COUNT(1) AS count FROM longzhonginfo WHERE sec_name=? `
  103. err = o.Raw(sql, secName).QueryRow(&count)
  104. return
  105. }
  106. type LzProductInfoResp struct {
  107. Msg string `json:"msg"`
  108. Code string `json:"code"`
  109. Data []*LzProductInfo `json:"data"`
  110. }
  111. type LzProductInfo struct {
  112. Unitid int64 `json:"unitid"`
  113. ProUnitName string `json:"proUnitName"`
  114. Tempid int64 `json:"tempid"`
  115. TempName string `json:"tempName"`
  116. Proid int `json:"proid"`
  117. ProName string `json:"proName"`
  118. Unit string `json:"unit"`
  119. LzType string `json:"type"`
  120. Maxdate string `json:"maxdate"`
  121. IsNormal string `json:"isNormal"`
  122. }
  123. func GetLongzhonginfoMaxId() (count int, err error) {
  124. o := orm.NewOrmUsingDB("edb")
  125. sql := `SELECT MAX(longzhonginfo_id) AS count FROM longzhonginfo`
  126. err = o.Raw(sql).QueryRow(&count)
  127. return
  128. }
  129. type LzProductInfoDetail struct {
  130. UnitId int64 `json:"unit_id"`
  131. UnitName string `json:"unit_name"`
  132. TempId int `json:"temp_id"`
  133. TempName string `json:"temp_name"`
  134. TempUnit string `json:"temp_unit"`
  135. ProId int `json:"pro_id"`
  136. ProCnName string `json:"pro_cn_name"`
  137. UnitValue float64 `json:"unit_value"`
  138. UnitDesc string `json:"unit_desc"`
  139. DataTime string `json:"data_time"`
  140. UpdTime string `json:"upd_time"`
  141. AddTime string `json:"add_time"`
  142. DisplayTime string `json:"display_time"`
  143. }
  144. type LzProductInfoDetailResp struct {
  145. Msg string `json:"msg"`
  146. Code string `json:"code"`
  147. Data []*LzProductInfoDetail `json:"data"`
  148. Pagesize int `json:"pagesize"`
  149. Page int `json:"page"`
  150. }
  151. func GetLongzhonginfoByUnitId(classifyName string, unitId int64) (item *Longzhonginfo, err error) {
  152. o := orm.NewOrmUsingDB("edb")
  153. sql := `SELECT * FROM longzhonginfo WHERE unitid=? AND classify_name=?`
  154. err = o.Raw(sql, unitId, classifyName).QueryRow(&item)
  155. return
  156. }
  157. func GetLongzhongDataById(lzInfoId int) (items []*Longzhongdata, err error) {
  158. o := orm.NewOrmUsingDB("edb")
  159. sql := `SELECT * FROM longzhongdata WHERE longzhonginfo_id=? ORDER BY dt DESC `
  160. _, err = o.Raw(sql, lzInfoId).QueryRows(&items)
  161. return
  162. }
  163. func GetLongzhongDataMaxCount(classifyId int) (count int, err error) {
  164. o := orm.NewOrmUsingDB("edb")
  165. sql := `SELECT MAX(t.num) AS count FROM (
  166. SELECT COUNT(1) AS num FROM longzhonginfo AS a
  167. INNER JOIN longzhongdata AS b ON a.longzhonginfo_id=b.longzhonginfo_id
  168. WHERE a.classify_id=?
  169. GROUP BY a.longzhonginfo_id
  170. )AS t `
  171. err = o.Raw(sql, classifyId).QueryRow(&count)
  172. return
  173. }
  174. type LongzhonginfoList struct {
  175. LongzhonginfoId int `orm:"column(longzhonginfo_id);pk"`
  176. TradeCode string
  177. SecName string
  178. Frequency string
  179. ClassifyId int
  180. ClassifyName string
  181. Unit string
  182. IsNormal string
  183. LastModifyDate string
  184. Unitid int
  185. }
  186. func GetLongzhonginfoList() (items []*LongzhonginfoList, err error) {
  187. o := orm.NewOrmUsingDB("edb")
  188. sql := ` SELECT * FROM longzhonginfo AS a `
  189. _, err = o.Raw(sql).QueryRows(&items)
  190. return
  191. }
  192. func ModifyLongzhonginfoIsNormal(longzhonginfoId int) (err error) {
  193. o := orm.NewOrmUsingDB("edb")
  194. sql := ` UPDATE longzhonginfo SET is_normal=0 WHERE longzhonginfo_id=? `
  195. _, err = o.Raw(sql, longzhonginfoId).Exec()
  196. return
  197. }
  198. type LzPriceInfo struct {
  199. Standard string `json:"standard"`
  200. ModelName string `json:"modelName"`
  201. Unit string `json:"unit"`
  202. AreaName string `json:"areaName"`
  203. PriceType string `json:"priceType"`
  204. Memo string `json:"memo"`
  205. Id string `json:"id"`
  206. ProductName string `json:"productName"`
  207. MarketName string `json:"marketName"`
  208. ManufactureName string `json:"manufactureName"`
  209. }
  210. type LzPriceInfoResp struct {
  211. Msg string `json:"msg"`
  212. Code int `json:"code"`
  213. Data []*LzPriceInfo `json:"data"`
  214. }
  215. type Longzhongpriceinfo struct {
  216. LongzhongpriceinfoId int `orm:"column(longzhongpriceinfo_id);pk"`
  217. Standard string
  218. ModelName string
  219. Unit string
  220. AreaName string
  221. PriceType string
  222. Memo string
  223. PriceId string
  224. ProductName string
  225. InfoType string
  226. InfoTypeRemark string
  227. MarketName string
  228. ManufactureName string
  229. }
  230. func AddLongzhongpriceinfo(item *Longzhongpriceinfo) (newId int64, err error) {
  231. o := orm.NewOrmUsingDB("edb")
  232. newId, err = o.Insert(item)
  233. return
  234. }
  235. //判断指标数据是否已经录入
  236. func GetLongzhongpriceinfoCount(unitid string) (count int, err error) {
  237. o := orm.NewOrmUsingDB("edb")
  238. sql := `SELECT COUNT(1) AS count FROM longzhongpriceinfo WHERE price_id=? `
  239. err = o.Raw(sql, unitid).QueryRow(&count)
  240. return
  241. }
  242. //判断指标数据是否已经录入
  243. func GetLongzhongpriceinfo() (items []*Longzhongpriceinfo, err error) {
  244. o := orm.NewOrmUsingDB("edb")
  245. sql := `SELECT * FROM longzhongpriceinfo `
  246. _, err = o.Raw(sql).QueryRows(&items)
  247. return
  248. }
  249. type Longzhongpricedata struct {
  250. LongzhongpricedataId int `orm:"column(longzhongpricedata_id);pk"`
  251. LongzhongpriceinfoId int
  252. PriceDate string
  253. Memo string
  254. Price string
  255. CnyPrice string
  256. ZsyPrice string
  257. ZshPrice string
  258. LowPrice string
  259. HighPrice string
  260. RisePrice string
  261. TonPrice string
  262. PriceType string
  263. UpdateDate string
  264. }
  265. func AddLongzhongpricedata(item *Longzhongpricedata) (newId int64, err error) {
  266. o := orm.NewOrmUsingDB("edb")
  267. newId, err = o.Insert(item)
  268. return
  269. }
  270. //判断指标数据是否已经录入
  271. func GetLongzhongpricedataCount(longzhongpriceinfoId int, priceDate string) (count int, err error) {
  272. o := orm.NewOrmUsingDB("edb")
  273. sql := `SELECT COUNT(1) AS count FROM longzhongpricedata WHERE longzhongpriceinfo_id=? AND price_date=? `
  274. err = o.Raw(sql, longzhongpriceinfoId, priceDate).QueryRow(&count)
  275. return
  276. }
  277. type LzPriceData struct {
  278. Id string `json:"id"`
  279. PriceDate string `json:"priceDate"`
  280. Memo string `json:"memo"`
  281. Price string `json:"price"`
  282. CnyPrice string `json:"cnyPrice"`
  283. ZsyPrice string `json:"zsyPrice"`
  284. ZshPrice string `json:"zshPrice"`
  285. LowPrice string `json:"lowPrice"`
  286. HighPrice string `json:"highPrice"`
  287. RisePrice string `json:"risePrice"`
  288. TonPrice string `json:"tonPrice"`
  289. PriceType string `json:"priceType"`
  290. UpdateDate string `json:"updateDate"`
  291. }
  292. type LzPriceDataResp struct {
  293. Msg string `json:"msg"`
  294. Code int `json:"code"`
  295. Data []*LzPriceData `json:"data"`
  296. }
  297. func GetLongzhongPriceDataMaxCount(productName string) (count int, err error) {
  298. o := orm.NewOrmUsingDB("edb")
  299. sql := `SELECT MAX(t.num) AS count FROM (
  300. SELECT COUNT(1) AS num FROM longzhongpriceinfo AS a
  301. INNER JOIN longzhongpricedata AS b ON a.longzhongpriceinfo_id=b.longzhongpriceinfo_id
  302. WHERE a.product_name=?
  303. GROUP BY a.product_name
  304. )AS t `
  305. err = o.Raw(sql, productName).QueryRow(&count)
  306. return
  307. }
  308. type LongzhongpricedataItems struct {
  309. LongzhongpricedataId int `orm:"column(longzhongpricedata_id);pk"`
  310. LongzhongpriceinfoId int
  311. PriceDate string
  312. Memo string
  313. Price float64
  314. CnyPrice float64
  315. ZsyPrice float64
  316. ZshPrice float64
  317. LowPrice float64
  318. HighPrice float64
  319. RisePrice float64
  320. TonPrice float64
  321. PriceType string
  322. UpdateDate string
  323. }
  324. func GetLongzhongPriceDataById(lzPriceInfoId int) (items []*LongzhongpricedataItems, err error) {
  325. o := orm.NewOrmUsingDB("edb")
  326. sql := `SELECT * FROM longzhongpricedata WHERE longzhongpriceinfo_id=? ORDER BY price_date DESC `
  327. _, err = o.Raw(sql, lzPriceInfoId).QueryRows(&items)
  328. return
  329. }
  330. func ModifyLongzhongpriceinfo(item *Longzhongpriceinfo) (err error) {
  331. o := orm.NewOrmUsingDB("edb")
  332. sql := `UPDATE longzhongpriceinfo
  333. SET
  334. standard = ?,
  335. model_name = ?,
  336. unit= ?,
  337. area_name=?,
  338. price_type = ?,
  339. memo = ?,
  340. market_name = ?,
  341. manufacture_name = ?
  342. WHERE price_id = ? `
  343. _, err = o.Raw(sql, item.Standard, item.ModelName, item.Unit, item.AreaName, item.PriceType, item.Memo, item.MarketName, item.ManufactureName, item.PriceId).Exec()
  344. return
  345. }
  346. func GetDisplayTime(longzhonginfoId int) (display_time string, err error) {
  347. o := orm.NewOrmUsingDB("edb")
  348. sql := ` SELECT max(a.display_time) AS display_time FROM longzhongdata AS a WHERE a.longzhonginfo_id=? `
  349. err = o.Raw(sql, longzhonginfoId).QueryRow(&display_time)
  350. return
  351. }
  352. type SurveyProduct struct {
  353. Message string `json:"message"`
  354. Response struct {
  355. List []struct {
  356. AreaName interface{} `json:"areaName"`
  357. BreedID string `json:"breedId"`
  358. BreedName string `json:"breedName"`
  359. Custom string `json:"custom"`
  360. CustomID string `json:"customId"`
  361. CustomType int64 `json:"customType"`
  362. Device string `json:"device"`
  363. DeviceID string `json:"deviceId"`
  364. Frequency int64 `json:"frequency"`
  365. InputMode int64 `json:"inputMode"`
  366. InputValue interface{} `json:"inputValue"`
  367. Labels interface{} `json:"labels"`
  368. ProductCraft string `json:"productCraft"`
  369. ProductCraftID string `json:"productCraftId"`
  370. ProductLine string `json:"productLine"`
  371. ProjectQuotaID int64 `json:"projectQuotaId"`
  372. ProvinceName interface{} `json:"provinceName"`
  373. QuotaID string `json:"quotaId"`
  374. QuotaName string `json:"quotaName"`
  375. QuotaSampleID int64 `json:"quotaSampleId"`
  376. ResearchStartDate interface{} `json:"researchStartDate"`
  377. ResearchStopDate interface{} `json:"researchStopDate"`
  378. SampleID string `json:"sampleId"`
  379. SampleName string `json:"sampleName"`
  380. SampleType int64 `json:"sampleType"`
  381. TaskActualFinishTime interface{} `json:"taskActualFinishTime"`
  382. TaskShouldFinishTime interface{} `json:"taskShouldFinishTime"`
  383. UnitID string `json:"unitId"`
  384. UnitName string `json:"unitName"`
  385. } `json:"list"`
  386. PageNum int64 `json:"pageNum"`
  387. PageSize int64 `json:"pageSize"`
  388. Pages int64 `json:"pages"`
  389. Total int64 `json:"total"`
  390. } `json:"response"`
  391. Status string `json:"status"`
  392. }
  393. type LongzhongSurveyProduct struct {
  394. SurveyProductId int `orm:"column(survey_product_id);pk"`
  395. ProjectQuotaId int64
  396. BreedId string
  397. BreedName string
  398. QuotaId string
  399. QuotaName string
  400. UnitId string
  401. UnitName string
  402. SampleType int64
  403. SampleId string
  404. SampleName string
  405. DeviceId string
  406. Device string
  407. ProductCraftId string
  408. ProductCraft string
  409. ProductLine string
  410. InputMode int64
  411. Frequency int64
  412. InputValue string
  413. TaskShouldFinishTime int
  414. CustomId string
  415. CustomType int64
  416. Custom string
  417. QuotaSampleId int64
  418. StartDate string
  419. EndDate string
  420. ModifyTime time.Time
  421. LzCode string
  422. }
  423. //判断指标数据是否已经录入
  424. func GetLongzhongSurveyProductCount(quotaSampleId int64) (count int, err error) {
  425. o := orm.NewOrmUsingDB("edb")
  426. sql := `SELECT COUNT(1) AS count FROM longzhong_survey_product WHERE quota_sample_id=? `
  427. err = o.Raw(sql, quotaSampleId).QueryRow(&count)
  428. return
  429. }
  430. func AddLongzhongSurveyProduct(item *LongzhongSurveyProduct) (lastId int64, err error) {
  431. o := orm.NewOrmUsingDB("edb")
  432. lastId, err = o.Insert(item)
  433. return
  434. }
  435. func ModifLongzhongSurveyProduct(item *LongzhongSurveyProduct) (err error) {
  436. o := orm.NewOrmUsingDB("edb")
  437. sql := `UPDATE longzhong_survey_product
  438. SET
  439. breed_id = ?,
  440. breed_name = ?,
  441. quota_id= ?,
  442. quota_name=?,
  443. unit_id = ?,
  444. unit_name = ?,
  445. project_quota_id = ?
  446. WHERE quota_sample_id = ? `
  447. _, err = o.Raw(sql, item.BreedId, item.BreedName, item.QuotaId, item.QuotaName, item.UnitId, item.UnitName, item.ProjectQuotaId, item.QuotaSampleId).Exec()
  448. return
  449. }
  450. //判断指标数据是否已经录入
  451. func GetLongzhongSurveyList() (items []*LongzhongSurveyProduct, err error) {
  452. o := orm.NewOrmUsingDB("edb")
  453. sql := `SELECT * FROM longzhong_survey_product ORDER BY survey_product_id ASC`
  454. _, err = o.Raw(sql).QueryRows(&items)
  455. return
  456. }
  457. type LongzhongSurveyData struct {
  458. SurveyDataId int `orm:"column(survey_data_id);pk"`
  459. SurveyProductId int
  460. ProjectQuotaId int64
  461. BreedId string
  462. BreedName string
  463. QuotaId string
  464. QuotaName string
  465. UnitId string
  466. UnitName string
  467. SampleType int64
  468. SampleId string
  469. SampleName string
  470. DeviceId string
  471. Device string
  472. ProductCraftId string
  473. ProductCraft string
  474. ProductLine string
  475. InputMode int64
  476. Frequency int64
  477. InputValue string
  478. TaskShouldFinishTime int64
  479. CustomId string
  480. CustomType int64
  481. Custom string
  482. QuotaSampleId int64
  483. TaskActualFinishTime int64
  484. AreaName string
  485. ProvinceName string
  486. ResearchStartData int64
  487. ResearchStopData int64
  488. DataTime string
  489. }
  490. func AddLongzhongSurveyData(item *LongzhongSurveyData) (err error) {
  491. o := orm.NewOrmUsingDB("edb")
  492. _, err = o.Insert(item)
  493. return
  494. }
  495. type LzSurveyData struct {
  496. Message string `json:"message"`
  497. Response struct {
  498. List []struct {
  499. AreaName interface{} `json:"areaName"`
  500. BreedID string `json:"breedId"`
  501. BreedName string `json:"breedName"`
  502. Custom string `json:"custom"`
  503. CustomID string `json:"customId"`
  504. CustomType int64 `json:"customType"`
  505. Device string `json:"device"`
  506. DeviceID string `json:"deviceId"`
  507. Frequency int64 `json:"frequency"`
  508. InputMode int64 `json:"inputMode"`
  509. InputValue string `json:"inputValue"`
  510. Labels interface{} `json:"labels"`
  511. ProductCraft string `json:"productCraft"`
  512. ProductCraftID string `json:"productCraftId"`
  513. ProductLine string `json:"productLine"`
  514. ProjectQuotaID int64 `json:"projectQuotaId"`
  515. ProvinceName interface{} `json:"provinceName"`
  516. QuotaID string `json:"quotaId"`
  517. QuotaName string `json:"quotaName"`
  518. QuotaSampleID int64 `json:"quotaSampleId"`
  519. ResearchStartDate int64 `json:"researchStartDate"`
  520. ResearchStopDate int64 `json:"researchStopDate"`
  521. SampleID string `json:"sampleId"`
  522. SampleName string `json:"sampleName"`
  523. SampleType int64 `json:"sampleType"`
  524. TaskActualFinishTime int64 `json:"taskActualFinishTime"`
  525. TaskShouldFinishTime int64 `json:"taskShouldFinishTime"`
  526. UnitID string `json:"unitId"`
  527. UnitName string `json:"unitName"`
  528. } `json:"list"`
  529. PageNum int64 `json:"pageNum"`
  530. PageSize int64 `json:"pageSize"`
  531. Pages int64 `json:"pages"`
  532. Total int64 `json:"total"`
  533. } `json:"response"`
  534. Status string `json:"status"`
  535. }
  536. //判断指标数据是否已经录入
  537. func GetLzSurveyDataCount(surveyProductId, quotaSampleId int, dataTime string) (count int, err error) {
  538. o := orm.NewOrmUsingDB("edb")
  539. sql := `SELECT COUNT(1) AS count FROM longzhong_survey_data WHERE survey_product_id=? AND quota_sample_id=? AND data_time=? `
  540. err = o.Raw(sql, surveyProductId, quotaSampleId, dataTime).QueryRow(&count)
  541. return
  542. }
  543. type LzSurveyMaxAndMinInfo struct {
  544. MinDate string `description:"最小日期"`
  545. MaxDate string `description:"最大日期"`
  546. MinValue float64 `description:"最小值"`
  547. MaxValue float64 `description:"最大值"`
  548. }
  549. func GetLzSurveyMaxAndMinInfo(surveyProductId, quotaSampleId int) (item *LzSurveyMaxAndMinInfo, err error) {
  550. o := orm.NewOrmUsingDB("edb")
  551. sql := ``
  552. sql = ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date,MIN(input_value) AS min_value,MAX(input_value) AS max_value
  553. FROM longzhong_survey_data WHERE survey_product_id=? AND quota_sample_id=? `
  554. err = o.Raw(sql, surveyProductId, quotaSampleId).QueryRow(&item)
  555. return
  556. }
  557. func ModifyLzSurveyMaxAndMinInfo(item *LzSurveyMaxAndMinInfo, surveyProductId int) (err error) {
  558. o := orm.NewOrmUsingDB("edb")
  559. sql := ` UPDATE longzhong_survey_product SET start_date=?,end_date=?,min_value=?,max_value=? WHERE survey_product_id=? `
  560. _, err = o.Raw(sql, item.MinDate, item.MaxDate, item.MinValue, item.MaxValue, surveyProductId).Exec()
  561. return
  562. }
  563. func ModifLongzhongSurveyProductCode(lzCode string, surveyProductId int) (err error) {
  564. o := orm.NewOrmUsingDB("edb")
  565. sql := `UPDATE longzhong_survey_product
  566. SET lz_code= ?,modify_time=NOW()
  567. WHERE survey_product_id = ? `
  568. _, err = o.Raw(sql, lzCode, surveyProductId).Exec()
  569. return
  570. }
  571. //判断指标数据是否已经录入
  572. func GetLongzhongSurveyProductItem(quotaSampleId int64) (item *LongzhongSurveyProduct, err error) {
  573. o := orm.NewOrmUsingDB("edb")
  574. sql := `SELECT * FROM longzhong_survey_product WHERE quota_sample_id=? `
  575. err = o.Raw(sql, quotaSampleId).QueryRow(&item)
  576. return
  577. }
  578. func ModifyLzSurveyData(inputValue string, surveyDataId int) (err error) {
  579. o := orm.NewOrmUsingDB("edb")
  580. sql := ` UPDATE longzhong_survey_data SET input_value=? WHERE survey_data_id=? `
  581. _, err = o.Raw(sql, inputValue, surveyDataId).Exec()
  582. return
  583. }
  584. func ModifyLzSurveyDataV1(inputValue string, quotaSampleId int,shouldDateTimeStr string) (err error) {
  585. o := orm.NewOrmUsingDB("edb")
  586. sql := ` UPDATE longzhong_survey_data SET input_value=? WHERE quota_sample_id=? AND data_time=? `
  587. _, err = o.Raw(sql, inputValue, quotaSampleId,shouldDateTimeStr).Exec()
  588. return
  589. }