diesel.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. package service
  2. import (
  3. "fmt"
  4. "github.com/360EntSecGroup-Skylar/excelize"
  5. "github.com/astaxie/beego/logs"
  6. "github.com/gin-gonic/gin"
  7. "github.com/goccy/go-json"
  8. "github.com/k0kubun/pp/v3"
  9. "github.com/pkg/errors"
  10. log "github.com/sirupsen/logrus"
  11. "gorm.io/gorm"
  12. "kpt.xdmy/apiserver/model"
  13. "kpt.xdmy/apiserver/model/http"
  14. "kpt.xdmy/pkg/util"
  15. "strconv"
  16. "strings"
  17. "time"
  18. )
  19. func (s *Service) InsertDieselData(req *http.DieselReq) error {
  20. code := new(model.CreateCodeN)
  21. s.d.DB.Raw(`call createCodeN(?,?)`, req.PastureId, "CY").First(code)
  22. return s.d.DB.Transaction(func(tx *gorm.DB) error {
  23. diesel := &model.Diesel{
  24. PastureId: req.PastureId,
  25. DeptId: req.DepartmentId,
  26. EqId: req.EqId,
  27. EqCode: req.EqCode,
  28. OilcardId: req.OilcardId,
  29. CardNumber: req.CardNumber,
  30. OilClass: req.OilClass,
  31. OilAmount: req.OilAmount,
  32. NowPrice: req.NowPrice,
  33. Price: req.Price,
  34. EmpId: req.EmpId,
  35. InputId: req.InputId,
  36. SelTime: req.SelTime,
  37. Note: req.Note,
  38. OilName: req.OilName,
  39. OilType: req.OilType,
  40. DieselCode: code.OrderCode,
  41. }
  42. resp := tx.Create(diesel)
  43. if resp.Error != nil {
  44. logs.Error("DieseUseProof0: ", resp.Error)
  45. return resp.Error
  46. }
  47. req.Id = diesel.Id
  48. err := tx.Exec(`update oilcard set lastcardAmount=cardAmount,cardAmount =cardAmount -? where id =?`, req.Id, req.NowPrice).Error
  49. if err != nil {
  50. logs.Error(err)
  51. return err
  52. }
  53. dieselList := make([]*model.Diesel, 0)
  54. dieselList = append(dieselList, diesel)
  55. err = s.DieseUseProof(dieselList, tx, strconv.FormatInt(req.PastureId, 10), code.OrderCode, req.SelTime)
  56. if err != nil {
  57. logs.Error("DieseUseProof2: ", err)
  58. return err
  59. }
  60. return nil
  61. })
  62. }
  63. func (s *Service) ImportExcel(c *gin.Context) (map[string]interface{}, error) {
  64. inputdata := ""
  65. if err := c.Request.ParseForm(); err != nil {
  66. return nil, err
  67. }
  68. params := c.Request.Form
  69. // file, _, err := c.Request.FormFile("file")
  70. fileHeader, err := c.FormFile("file")
  71. file, err := fileHeader.Open()
  72. if err != nil {
  73. return nil, err
  74. }
  75. if err != nil {
  76. return nil, err
  77. }
  78. pastureId := params.Get("pastureId")
  79. sqlnamestr := params.Get("name")
  80. sheetname := params.Get("sheetname")
  81. importParams := params.Get("importParams")
  82. //sql, _ := restful.GetSqlByNameDB(sqlnamestr)
  83. // 备件编号,备件名称,规格型号,计量单位,品牌,计划量,单价,备注,jwt_username
  84. paramslist := strings.Split(importParams, ",")
  85. if sqlnamestr != "importGasoline" && sqlnamestr != "importCoal" && sqlnamestr != "importBiomass" && sqlnamestr != "importEnergy" {
  86. paramslist = append(paramslist, "jwt_username")
  87. }
  88. queryData := make([]interface{}, 0)
  89. xlsx1, err := excelize.OpenReader(file)
  90. if err != nil {
  91. return nil, err
  92. }
  93. ok := 0
  94. error := 0
  95. rows := xlsx1.GetRows(sheetname)
  96. if len(rows) > 10000 {
  97. rows = rows[:10000]
  98. }
  99. dieselList := make([]*model.Diesel, 0)
  100. errBool := false
  101. var selTime string
  102. code := new(model.CreateCodeN)
  103. s.d.DB.Raw(`call createCodeN(?,?)`, pastureId, "CY").First(&code)
  104. if code.OrderCode == "" {
  105. s.d.DB.Raw(`call createCodeN(?,?)`, pastureId, "CY").First(&code)
  106. if code.OrderCode == "" {
  107. outentry := make(map[string]interface{})
  108. outentry["error_msg"] = "上传失败,请重新导入"
  109. error++
  110. queryData = append(queryData, outentry)
  111. data := make(map[string]interface{})
  112. data["result"] = queryData
  113. //data["success"] = ok
  114. data["err_count"] = 1
  115. return data, nil
  116. }
  117. }
  118. tx := s.d.DB.Begin()
  119. var dateList []string
  120. for i, row := range rows {
  121. if i > 0 {
  122. if len(paramslist) > 0 {
  123. s_params := make([]interface{}, 0)
  124. entry := make(map[string]string)
  125. outentry := make(map[string]interface{})
  126. inputdata = ""
  127. for _, value := range paramslist {
  128. if strings.ToLower(strings.Trim(value, " ")) == "jwt_username" {
  129. if tempv, exists := c.Get("jwt_username"); exists {
  130. s_params = append(s_params, tempv.(string))
  131. } else {
  132. s_params = append(s_params, "")
  133. }
  134. } else {
  135. for j, colCell := range rows[0] {
  136. if strings.Trim(value, " ") == colCell {
  137. for k, colCell1 := range row {
  138. if j == k {
  139. outentry[colCell] = colCell1
  140. entry[colCell] = colCell1
  141. //inputdata = inputdata + colCell + ":" + colCell1 + ";"
  142. }
  143. }
  144. }
  145. }
  146. s_params = append(s_params, entry[strings.Trim(value, " ")])
  147. }
  148. }
  149. outentry["input"] = inputdata
  150. diesel := new(model.Diesel)
  151. fmt.Println(entry)
  152. //牧场,油卡编号,设备名称,设备编号,加油日期,加油量(升),单价,录入人,加油人,加油工班,备注,柴油类型,jwt_username
  153. if _, ok := entry["加油量(升)"]; ok {
  154. diesel.OilAmount = entry["加油量(升)"]
  155. }
  156. if _, ok := entry["单价"]; ok {
  157. diesel.Price = entry["单价"]
  158. }
  159. if _, ok := entry["单价"]; ok {
  160. diesel.Price = entry["单价"]
  161. }
  162. if diesel.OilAmount == "" {
  163. outentry["error_msg"] = "加油量必须输入"
  164. error++
  165. queryData = append(queryData, outentry)
  166. errBool = true
  167. continue
  168. }
  169. if diesel.Price == "" {
  170. outentry["error_msg"] = "单价不能为空"
  171. error++
  172. queryData = append(queryData, outentry)
  173. errBool = true
  174. continue
  175. }
  176. if _, ok := entry["牧场"]; !ok {
  177. outentry["error_msg"] = "牧场不能为空"
  178. error++
  179. queryData = append(queryData, outentry)
  180. errBool = true
  181. continue
  182. }
  183. if _, ok := entry["油卡编号"]; !ok {
  184. outentry["error_msg"] = "油卡编号不能为空"
  185. error++
  186. queryData = append(queryData, outentry)
  187. errBool = true
  188. continue
  189. }
  190. jyTime, err := time.Parse("2006-01-02", entry["加油日期"])
  191. if err != nil {
  192. outentry["error_msg"] = err.Error()
  193. error++
  194. queryData = append(queryData, outentry)
  195. errBool = true
  196. continue
  197. }
  198. if len(dateList) == 0 {
  199. dateList = append(dateList, jyTime.Format("2006-01-02"))
  200. } else {
  201. exist := false
  202. for _, date := range dateList {
  203. if date == jyTime.Format("2006-01-02") {
  204. exist = true
  205. break
  206. }
  207. }
  208. if !exist {
  209. dateList = append(dateList, jyTime.Format("2006-01-02"))
  210. }
  211. }
  212. now, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
  213. if jyTime.Unix() > now.Unix() {
  214. outentry["error_msg"] = "本次抄表日期不可大于当前日期"
  215. error++
  216. queryData = append(queryData, outentry)
  217. errBool = true
  218. continue
  219. }
  220. pasture := new(model.Pasture)
  221. tx.Where("name = ?", entry["牧场"]).First(pasture)
  222. if pasture.ID == 0 {
  223. outentry["error_msg"] = "牧场不存在"
  224. error++
  225. queryData = append(queryData, outentry)
  226. errBool = true
  227. continue
  228. }
  229. diesel.CardNumber = entry["油卡编号"]
  230. diesel.SelTime = entry["加油日期"]
  231. oilcard := new(model.Oilcard)
  232. tx.Where("cardCode = ? and pastureId = ? ", entry["油卡编号"], pasture.ID).First(oilcard)
  233. if oilcard.Id == "" {
  234. outentry["error_msg"] = entry["油卡编号"] + "油卡不存在"
  235. error++
  236. queryData = append(queryData, outentry)
  237. errBool = true
  238. continue
  239. }
  240. if oilcard.CardType != "外部" {
  241. equipment := new(model.Equipment)
  242. tx.Debug().Where("eqCode = ? and pastureId =? ", entry["设备编号"], pasture.ID).First(equipment)
  243. diesel.EqCode = equipment.EqCode
  244. diesel.EqId = int64(equipment.Id)
  245. deptId, _ := strconv.ParseInt(equipment.DepartmentId, 10, 64)
  246. diesel.DeptId = deptId
  247. if equipment.EqCode == "" {
  248. outentry["error_msg"] = entry["设备编号"] + "资产不存在或不在本牧场"
  249. error++
  250. queryData = append(queryData, outentry)
  251. errBool = true
  252. continue
  253. }
  254. }
  255. if _, ok := entry["录入人"]; ok {
  256. emp := new(model.Emp)
  257. tx.Where("empname = ? and pastureId = ?", entry["录入人"], pasture.ID).First(emp)
  258. diesel.InputId = emp.Id
  259. }
  260. diesel.PastureId = int64(pasture.ID)
  261. price, _ := strconv.ParseFloat(diesel.Price, 64)
  262. oilAmount, _ := strconv.ParseFloat(diesel.OilAmount, 64)
  263. diesel.NowPrice = price * oilAmount
  264. if _, ok := entry["备注"]; ok {
  265. diesel.Note = entry["备注"]
  266. }
  267. if _, ok := entry["录入人"]; ok {
  268. emp := new(model.Emp)
  269. tx.Where("empname = ? and pastureId = ?", entry["录入人"], pasture.ID).First(emp)
  270. diesel.EmpId = emp.Empname
  271. }
  272. if _, ok := entry["加油工班"]; ok {
  273. diesel.OilClass = entry["加油工班"]
  274. }
  275. if diesel.DeptId == 0 {
  276. deptId, _ := strconv.ParseInt(oilcard.DepartmentId, 10, 64)
  277. diesel.DeptId = deptId
  278. }
  279. oilcardId, _ := strconv.ParseInt(oilcard.Id, 10, 64)
  280. diesel.OilcardId = oilcardId
  281. //WHEN '0#' THEN
  282. //1
  283. //WHEN '-10#' THEN
  284. //2
  285. //WHEN '-20#' THEN
  286. //3
  287. //WHEN '-30#' THEN
  288. //4
  289. //WHEN '-35#' THEN
  290. if _, ok := entry["柴油类型"]; ok {
  291. if entry["柴油类型"] == "" {
  292. outentry["error_msg"] = "柴油类型不能为空"
  293. error++
  294. queryData = append(queryData, outentry)
  295. //tx.Rollback()
  296. errBool = true
  297. continue
  298. }
  299. diesel.OilName = entry["柴油类型"]
  300. if entry["柴油类型"] == "0号" {
  301. diesel.OilType = 1
  302. } else if entry["柴油类型"] == "10号" {
  303. //diesel.OilName = "-10#"
  304. diesel.OilType = 2
  305. } else if entry["柴油类型"] == "20号" {
  306. //diesel.OilName = "-20#"
  307. diesel.OilType = 3
  308. } else if entry["柴油类型"] == "30号" {
  309. //diesel.OilName = "-30#"
  310. diesel.OilType = 4
  311. } else if entry["柴油类型"] == "35号" {
  312. //diesel.OilName = "-35#"
  313. diesel.OilType = 5
  314. }
  315. } else {
  316. outentry["error_msg"] = "柴油类型不能为空"
  317. error++
  318. queryData = append(queryData, outentry)
  319. //tx.Rollback()
  320. errBool = true
  321. continue
  322. }
  323. diesel.DieselCode = code.OrderCode
  324. err = tx.Create(diesel).Error
  325. if err != nil {
  326. outentry["error_msg"] = err.Error()
  327. error++
  328. queryData = append(queryData, outentry)
  329. //tx.Rollback()
  330. logs.Error("DieseUseProof0: ", err)
  331. errBool = true
  332. continue
  333. }
  334. err = tx.Exec(` UPDATE
  335. oilcard
  336. SET
  337. lastcardAmount = cardAmount,
  338. cardAmount = cardAmount-CAST( ?*? as decimal(10,2))
  339. WHERE id = ?;`, oilAmount, price, oilcard.Id).Error
  340. if err != nil {
  341. outentry["error_msg"] = err.Error()
  342. error++
  343. queryData = append(queryData, outentry)
  344. //tx.Rollback()
  345. errBool = true
  346. continue
  347. }
  348. selTime = diesel.SelTime
  349. dieselList = append(dieselList, diesel)
  350. ok++
  351. }
  352. }
  353. }
  354. if len(dateList) > 1 {
  355. tx.Rollback()
  356. data := make(map[string]interface{})
  357. outentry := make(map[string]interface{})
  358. outentry["error_msg"] = "请勿上传多个日期数据!"
  359. error++
  360. queryData = append(queryData, outentry)
  361. data["result"] = queryData
  362. data["result"] = queryData
  363. //data["success"] = ok
  364. data["err_count"] = 1
  365. return data, nil
  366. }
  367. if errBool {
  368. tx.Rollback()
  369. data := make(map[string]interface{})
  370. data["result"] = queryData
  371. //data["success"] = ok
  372. data["err_count"] = 1
  373. return data, nil
  374. }
  375. err = s.DieseUseProof(dieselList, tx, pastureId, code.OrderCode, selTime)
  376. if err != nil {
  377. outentry := make(map[string]interface{})
  378. outentry["error_msg"] = err.Error()
  379. error++
  380. queryData = append(queryData, outentry)
  381. data := make(map[string]interface{})
  382. data["result"] = queryData
  383. //data["success"] = ok
  384. data["err_count"] = 1
  385. tx.Rollback()
  386. return data, nil
  387. }
  388. err = tx.Commit().Error
  389. if err != nil {
  390. outentry := make(map[string]interface{})
  391. outentry["error_msg"] = "上传失败"
  392. error++
  393. queryData = append(queryData, outentry)
  394. data := make(map[string]interface{})
  395. data["result"] = queryData
  396. //data["success"] = ok
  397. data["err_count"] = 1
  398. tx.Rollback()
  399. return data, nil
  400. }
  401. data := make(map[string]interface{})
  402. data["result"] = queryData
  403. data["success"] = len(dieselList)
  404. //data["err_count"] = error
  405. return data, nil
  406. }
  407. func (s *Service) DieseUseProof(reqList []*model.Diesel, tx *gorm.DB, pastureId, dieselCode, selTime string) error {
  408. //pr := new(http.ProofPartReq)
  409. r := new(http.ProofReq)
  410. rp := new(http.ProofResp)
  411. //parts := make([]*model.PartUseStr, 0)
  412. //bp := new(model.BigPartUse)
  413. pa := new(model.Pasture)
  414. if e := tx.Where("id = ? ", pastureId).First(pa).Error; e != nil {
  415. log.Error(e)
  416. return errors.New(fmt.Sprintf("查询牧场信息 errors:%v", e))
  417. }
  418. proofDest(r)
  419. //{"DEST":{"DEST_ID":"EQMAN","BUSS_TP":"MM001","MESS_ID":"","STATUS":"","MESS_TEXT":"","STATUS_OS":"",
  420. // "Url":"http://192.168.61.117/SAPP0/Common/MM001/ModifyMblnr"},"DATA":{"BLDAT":"20221105",
  421. // "BUDAT":"20221101","FRBNR":"CK03221105003","MSEG":[{"ZEILE":"1","MATNR":"14.02.15.06.000091",
  422. // "WERKS":"M003","LGORT":"1004","MENGE":"1.000000","MEINS":"桶","EBELN":"","EBPLP":"",
  423. // "BWART":"201","SOBKZ":"K","KOSTL":"1002030505","ANLN1":"50300000007","ANLN2":"","LIFNR":"100869"}]}}
  424. //b, _ := json.Marshal(pr)
  425. //restful.Dbs.DB.Exec(` insert into equipmentlingshi(text)values(?)`, string(b))
  426. r.Dest.MESSIDOS = dieselCode
  427. r.Dest.BUSSDOCOS = dieselCode
  428. r.Data.EqNumber = dieselCode
  429. r.Data.CreateTime = time.Now().Format("20060102")
  430. if t, e := util.ParseDate(selTime[:10]); e != nil {
  431. log.Error(e, selTime)
  432. } else {
  433. r.Data.PostDate = t.Format("20060102")
  434. }
  435. diesePartMap := map[string]string{
  436. "0号": "20.04.01.01.000001",
  437. "10号": "20.04.01.01.000002",
  438. "20号": "20.04.01.01.000003",
  439. "30号": "20.04.01.01.000004",
  440. "35号": "20.04.01.01.000005",
  441. }
  442. //for i, v := range parts {
  443. //bc := new(model.BigContract)
  444. //c := new(model.Contract)
  445. //w := new(model.Warehouse)
  446. //pv := new(model.Provider)
  447. //contractID, _ := strconv.Atoi(v.ContractID.(string))
  448. //if e := s.d.DB.First(storage, model.PartRepertory{ContractID: contractID}).Error; e != nil {
  449. // log.Errorln(e, v.ContractID)
  450. // return errors.New(fmt.Sprintf("查询库存信息出错 errors:%v", e))
  451. //}
  452. //if e := s.d.DB.First(pv, model.Provider{ID: storage.ProviderID}).Error; e != nil {
  453. // log.Errorln(e, storage.ProviderID)
  454. // return errors.New(fmt.Sprintf("查询供应商信息出错 errors:%v", e))
  455. //}
  456. //dict := new(model.Dictlist)
  457. //tx.First(dict, model.Dictlist{Pid: 21, Value: "物耗"})
  458. //if e := s.d.DB.First(w, model.Warehouse{ID: v.LocationID}).Error; e != nil {
  459. // log.Errorln(e, v.LocationID)
  460. // return errors.New(fmt.Sprintf("errors:%v", e))
  461. //}
  462. for i, req := range reqList {
  463. eq := new(model.Equipment)
  464. dp := new(model.Department)
  465. if e := tx.Where("id = ? ", req.DeptId).First(dp).Error; e != nil {
  466. log.Error(e)
  467. return errors.New(fmt.Sprintf("查询部门信息出错 errors:%v", e))
  468. }
  469. sdetail := http.ProofDetail{}
  470. if req.EqCode != "" {
  471. if e := tx.Where("id = ? and pastureid = ? ", req.EqId, req.PastureId).First(eq).Error; e != nil {
  472. return errors.New(fmt.Sprintf("errors:%v", e))
  473. }
  474. sdetail.AssetCode = eq.SapCode
  475. sdetail.AssetSon = eq.SonCode
  476. }
  477. sdetail.EXT01 = "6601011703"
  478. sdetail.MoveType = "201"
  479. sdetail.CostCenter = dp.CostCenterCode
  480. sdetail.Factory = pa.FactoryCode
  481. if sdetail.Factory == "M005" && strings.Contains(dp.Name, "二期") {
  482. sdetail.Factory = "M017"
  483. }
  484. sdetail.RowNumber = fmt.Sprintf("%d", i+1)
  485. sdetail.Quantity = fmt.Sprintf("%s", req.OilAmount)
  486. sdetail.Code = diesePartMap[req.OilName]
  487. sdetail.Location = "1005"
  488. r.Data.Detail = append(r.Data.Detail, sdetail)
  489. tx.Exec(` update diesel set sort = ? where id = ? `, sdetail.RowNumber, req.Id)
  490. }
  491. //_, err = tx.Exec(` update partuse set rowNumber = ? where id = ? `, sdetail.RowNumber, v.ID)
  492. //if err != nil {
  493. // return err
  494. //}
  495. //}
  496. //}
  497. ///*
  498. pp.Print(r)
  499. //log.Infof("bp.pastureId:%d,pa.name:%s,pa.companycode:%s", bp.PastureID, pa.Name, pa.CompanyCode)
  500. rbyte, _ := json.Marshal(r)
  501. fmt.Println(string(rbyte))
  502. if e := s.SyncSap(r, rp, rbyte); e != nil {
  503. log.Errorf("laid proof error:%v", e)
  504. return errors.New(fmt.Sprintf("errors:%s", r.MessText))
  505. } else {
  506. if rp.Dest.Status == "S" {
  507. log.Printf("use proof success:eqcode=%s,sapcode=%s", rp.Data.EqNumber, rp.Data.SapNumber)
  508. //if e := s.d.DB.Model(&model.BigPartUse{}).Where("useform = ?", rp.Data.EqNumber).Update("ProofCode", rp.Data.SapNumber).Error; e != nil {
  509. // log.Errorln(e)
  510. //}
  511. err := tx.Exec(` update diesel set ProofCode = ? where dieselCode = ? `, rp.Data.SapNumber, dieselCode).Error
  512. if err != nil {
  513. log.Printf("%s", err.Error())
  514. }
  515. } else {
  516. log.Warnf(" use proof :%s", rp.Dest.MessText)
  517. return errors.New(fmt.Sprintf("errors:%s", rp.Dest.MessText))
  518. }
  519. }
  520. return nil
  521. }
  522. func (s *Service) zdDieselData(pastureId, date, code string) error {
  523. //code := new(model.CreateCodeN)
  524. //s.d.DB.Raw(`call createCodeN(?,?)`, pastureId, "CY").First(code)
  525. return s.d.DB.Transaction(func(tx *gorm.DB) error {
  526. deselOffList := make([]*model.Diesel, 0)
  527. tx.Debug().Where("pastureId = ?", pastureId).Where("selTime = ?", date).Where(" dieselCode = ? ", code).Find(&deselOffList)
  528. //fmt.Println(err)
  529. //if err != nil {
  530. // //logs.Error(err)
  531. // return err
  532. //}
  533. //if len(deselOffList) == 0 {
  534. // return nil
  535. //}
  536. //dieselList := make([]*model.Diesel, 0)
  537. //for _, item := range deselOffList {
  538. //fmt.Println(item)
  539. //var targetTime = ""
  540. //t, err := time.Parse("2006-01-02 15:04:05", item.SelTime)
  541. //if err != nil {
  542. // fmt.Println("解析错误:", err)
  543. // targetTime = item.SelTime
  544. //} else {
  545. // targetTime = t.Format("2006-01-02 15:04:05")
  546. //}
  547. //
  548. //// 转换为指定格式的时间字符串
  549. //fmt.Println(targetTime)
  550. //diesel := &model.Diesel{
  551. // Id: item.Id,
  552. // PastureId: item.PastureId,
  553. // DeptId: item.DeptId,
  554. // EqId: item.EqId,
  555. // EqCode: item.EqCode,
  556. // OilcardId: item.OilcardId,
  557. // CardNumber: item.CardNumber,
  558. // OilClass: item.OilClass,
  559. // OilAmount: item.OilAmount,
  560. // NowPrice: item.NowPrice,
  561. // Price: item.Price,
  562. // EmpId: item.EmpId,
  563. // InputId: item.InputId,
  564. // SelTime: targetTime,
  565. // Note: item.Note,
  566. // OilName: item.OilName,
  567. // OilType: item.OilType,
  568. // DieselCode: item.DieselCode,
  569. //}
  570. //tx.Create(diesel)
  571. //dieselList = append(dieselList, diesel)
  572. //tx.Exec(`delete from diesel_off where id = ?`, item.Id)
  573. //}
  574. err := s.DieseUseProof(deselOffList, tx, pastureId, code, date)
  575. if err != nil {
  576. logs.Error(err)
  577. return err
  578. }
  579. return nil
  580. })
  581. }