contract.go 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  1. package oilcontract
  2. import (
  3. "dashoo.cn/backend/api/business/auditsetting"
  4. "dashoo.cn/backend/api/business/oilcontract/contractReview"
  5. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  6. "dashoo.cn/backend/api/business/organize"
  7. "dashoo.cn/backend/api/business/workflow"
  8. "encoding/json"
  9. "fmt"
  10. "github.com/tealeg/xlsx"
  11. "log"
  12. "os"
  13. "reflect"
  14. "strconv"
  15. "strings"
  16. "time"
  17. "dashoo.cn/backend/api/business/baseUser"
  18. "dashoo.cn/backend/api/business/oilcontract/contract"
  19. . "dashoo.cn/backend/api/controllers"
  20. "dashoo.cn/business2/items"
  21. "dashoo.cn/business2/userRole"
  22. "dashoo.cn/utils"
  23. )
  24. type OilContractController struct {
  25. BaseController
  26. }
  27. // @Title 获取列表
  28. // @Description get user by token
  29. // @Success 200 {object} []oilcontract.OilContract
  30. // @router /list [get]
  31. func (this *OilContractController) GetEntityList() {
  32. //获取分页信息
  33. page := this.GetPageInfoForm()
  34. where := " 1=1 "
  35. orderby := "Id"
  36. asc := false
  37. Order := this.GetString("Order")
  38. Prop := this.GetString("Prop")
  39. if Order != "" && Prop != "" {
  40. orderby = Prop
  41. if Order == "asc" {
  42. asc = true
  43. }
  44. }
  45. Id := this.GetString("Id")
  46. SupplierId := this.GetString("SupplierId")
  47. SupplierName := this.GetString("SupplierName")
  48. Status := this.GetString("Status")
  49. SettleStatus := this.GetString("SettleStatus")
  50. ProjectName := this.GetString("ProjectName")
  51. ContractNo := this.GetString("ContractNo")
  52. ProjectPlace := this.GetString("ProjectPlace")
  53. ProjectOwner := this.GetString("ProjectOwner")
  54. Telephone := this.GetString("Telephone")
  55. ProjectType := this.GetString("ProjectType")
  56. ContractMode := this.GetString("ContractMode")
  57. Amount := this.GetString("Amount")
  58. ContractPeriod := this.GetString("ContractPeriod")
  59. OpenDate := this.GetString("OpenDate")
  60. PlanFinishDate := this.GetString("PlanFinishDate")
  61. ConstructionUnit := this.GetString("ConstructionUnit")
  62. ConstructionOwner := this.GetString("ConstructionOwner")
  63. ConstructionTelphone := this.GetString("ConstructionTelphone")
  64. BuildUnit := this.GetString("BuildUnit")
  65. BuildOwner := this.GetString("BuildOwner")
  66. BuildTelphone := this.GetString("BuildTelphone")
  67. SuperviseUnit := this.GetString("SuperviseUnit")
  68. SuperviseOwner := this.GetString("SuperviseOwner")
  69. SuperviseTelphone := this.GetString("SuperviseTelphone")
  70. QualityUnit := this.GetString("QualityUnit")
  71. QualityOwner := this.GetString("QualityOwner")
  72. QualityTelphone := this.GetString("QualityTelphone")
  73. Remark := this.GetString("Remark")
  74. IsDelete := this.GetString("IsDelete")
  75. CreateOn := this.GetString("CreateOn")
  76. CreateUserId := this.GetString("CreateUserId")
  77. CreateBy := this.GetString("CreateBy")
  78. ModifiedOn := this.GetString("ModifiedOn")
  79. ModifiedUserId := this.GetString("ModifiedUserId")
  80. ModifiedBy := this.GetString("ModifiedBy")
  81. ContractName := this.GetString("ContractName")
  82. ContractSonClass := this.GetString("ContractSonClass")
  83. SmallClass := this.GetString("SmallClass")
  84. SignedDate := this.GetString("SignedDate")
  85. People := this.GetString("People")
  86. Number := this.GetString("Number")
  87. ChooseWay := this.GetString("ChooseWay")
  88. ContractMark := this.GetString("ContractMark")
  89. Currency := this.GetString("Currency")
  90. BudgetAmount := this.GetString("BudgetAmount")
  91. PerformAmount := this.GetString("PerformAmount")
  92. IsInternal := this.GetString("IsInternal")
  93. IsForeign := this.GetString("IsForeign")
  94. IsDeal := this.GetString("IsDeal")
  95. MoneyFlows := this.GetString("MoneyFlows")
  96. MoneyChannel := this.GetString("MoneyChannel")
  97. MoneyChannelSon := this.GetString("MoneyChannelSon")
  98. MoneyChannelSmall := this.GetString("MoneyChannelSmall")
  99. SingUnit := this.GetString("SingUnit")
  100. Place := this.GetString("Place")
  101. DisputeResolution := this.GetString("DisputeResolution")
  102. SubmitDate := this.GetString("SubmitDate")
  103. SealName := this.GetString("SealName")
  104. PoNumber := this.GetString("PoNumber")
  105. SubPackage := this.GetString("SubPackage")
  106. ImportStatus := this.GetString("ImportStatus")
  107. if Id != "" {
  108. where = where + " and Id like '%" + Id + "%'"
  109. }
  110. if SupplierId != "" {
  111. where = where + " and SupplierId like '%" + SupplierId + "%'"
  112. }
  113. if SupplierName != "" {
  114. where = where + " and SupplierName like '%" + SupplierName + "%'"
  115. }
  116. if Status != "" {
  117. where = where + " and Status=" + Status + " "
  118. }
  119. if SettleStatus != "" {
  120. where = where + " and SettleStatus='" + SettleStatus + "' "
  121. }
  122. if ProjectName != "" {
  123. where = where + " and ProjectName like '%" + ProjectName + "%'"
  124. }
  125. if ContractNo != "" {
  126. where = where + " and ContractNo like '%" + ContractNo + "%'"
  127. }
  128. if ProjectPlace != "" {
  129. where = where + " and ProjectPlace like '%" + ProjectPlace + "%'"
  130. }
  131. if ProjectOwner != "" {
  132. where = where + " and ProjectOwner like '%" + ProjectOwner + "%'"
  133. }
  134. if Telephone != "" {
  135. where = where + " and Telephone like '%" + Telephone + "%'"
  136. }
  137. if ProjectType != "" {
  138. where = where + " and ProjectType like '%" + ProjectType + "%'"
  139. }
  140. if ContractMode != "" {
  141. where = where + " and ContractMode like '%" + ContractMode + "%'"
  142. }
  143. if Amount != "" {
  144. where = where + " and Amount like '%" + Amount + "%'"
  145. }
  146. if ContractPeriod != "" {
  147. where = where + " and ContractPeriod like '%" + ContractPeriod + "%'"
  148. }
  149. if OpenDate != "" {
  150. where = where + " and OpenDate like '%" + OpenDate + "%'"
  151. }
  152. if PlanFinishDate != "" {
  153. where = where + " and PlanFinishDate like '%" + PlanFinishDate + "%'"
  154. }
  155. if ConstructionUnit != "" {
  156. where = where + " and ConstructionUnit like '%" + ConstructionUnit + "%'"
  157. }
  158. if ConstructionOwner != "" {
  159. where = where + " and ConstructionOwner like '%" + ConstructionOwner + "%'"
  160. }
  161. if ConstructionTelphone != "" {
  162. where = where + " and ConstructionTelphone like '%" + ConstructionTelphone + "%'"
  163. }
  164. if BuildUnit != "" {
  165. where = where + " and BuildUnit like '%" + BuildUnit + "%'"
  166. }
  167. if BuildOwner != "" {
  168. where = where + " and BuildOwner like '%" + BuildOwner + "%'"
  169. }
  170. if BuildTelphone != "" {
  171. where = where + " and BuildTelphone like '%" + BuildTelphone + "%'"
  172. }
  173. if SuperviseUnit != "" {
  174. where = where + " and SuperviseUnit like '%" + SuperviseUnit + "%'"
  175. }
  176. if SuperviseOwner != "" {
  177. where = where + " and SuperviseOwner like '%" + SuperviseOwner + "%'"
  178. }
  179. if SuperviseTelphone != "" {
  180. where = where + " and SuperviseTelphone like '%" + SuperviseTelphone + "%'"
  181. }
  182. if QualityUnit != "" {
  183. where = where + " and QualityUnit like '%" + QualityUnit + "%'"
  184. }
  185. if QualityOwner != "" {
  186. where = where + " and QualityOwner like '%" + QualityOwner + "%'"
  187. }
  188. if QualityTelphone != "" {
  189. where = where + " and QualityTelphone like '%" + QualityTelphone + "%'"
  190. }
  191. if Remark != "" {
  192. where = where + " and Remark like '%" + Remark + "%'"
  193. }
  194. if IsDelete != "" {
  195. where = where + " and IsDelete like '%" + IsDelete + "%'"
  196. }
  197. //if CreateOn != "" {
  198. // where = where + " and CreateOn like '%" + CreateOn + "%'"
  199. //}
  200. if CreateUserId != "" {
  201. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  202. }
  203. if CreateBy != "" {
  204. where = where + " and CreateBy like '%" + CreateBy + "%'"
  205. }
  206. if ModifiedOn != "" {
  207. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  208. }
  209. if ModifiedUserId != "" {
  210. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  211. }
  212. if ModifiedBy != "" {
  213. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  214. }
  215. if CreateOn != "" {
  216. dates := strings.Split(CreateOn, ",")
  217. if len(dates) == 2 {
  218. minDate := dates[0]
  219. maxDate := dates[1]
  220. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  221. }
  222. }
  223. if SubPackage != "" {
  224. where = where + " and SubPackage like '%" + SubPackage + "%'"
  225. }
  226. if ContractName != "" {
  227. where = where + " and ContractName like '%" + ContractName + "%'"
  228. }
  229. if ContractSonClass != "" {
  230. where = where + " and ContractSonClass like '%" + ContractSonClass + "%'"
  231. }
  232. if SmallClass != "" {
  233. where = where + " and SmallClass like '%" + SmallClass + "%'"
  234. }
  235. if People != "" {
  236. where = where + " and People like '%" + People + "%'"
  237. }
  238. if Number != "" {
  239. where = where + " and Number like '%" + Number + "%'"
  240. }
  241. if ChooseWay != "" {
  242. where = where + " and ChooseWay like '%" + ChooseWay + "%'"
  243. }
  244. if ContractMark != "" {
  245. where = where + " and ContractMark like '%" + ContractMark + "%'"
  246. }
  247. if Currency != "" {
  248. where = where + " and Currency like '%" + Currency + "%'"
  249. }
  250. if BudgetAmount != "" {
  251. where = where + " and BudgetAmount like '%" + BudgetAmount + "%'"
  252. }
  253. if PerformAmount != "" {
  254. where = where + " and PerformAmount like '%" + PerformAmount + "%'"
  255. }
  256. if IsInternal != "" {
  257. where = where + " and IsInternal like '%" + IsInternal + "%'"
  258. }
  259. if IsForeign != "" {
  260. where = where + " and IsForeign like '%" + IsForeign + "%'"
  261. }
  262. if IsDeal != "" {
  263. where = where + " and IsDeal like '%" + IsDeal + "%'"
  264. }
  265. if MoneyFlows != "" {
  266. where = where + " and MoneyFlows like '%" + MoneyFlows + "%'"
  267. }
  268. if MoneyChannel != "" {
  269. where = where + " and MoneyChannel like '%" + MoneyChannel + "%'"
  270. }
  271. if MoneyChannelSon != "" {
  272. where = where + " and MoneyChannelSon like '%" + MoneyChannelSon + "%'"
  273. }
  274. if MoneyChannelSmall != "" {
  275. where = where + " and MoneyChannelSmall like '%" + MoneyChannelSmall + "%'"
  276. }
  277. if SingUnit != "" {
  278. where = where + " and SingUnit like '%" + SingUnit + "%'"
  279. }
  280. if Place != "" {
  281. where = where + " and Place like '%" + Place + "%'"
  282. }
  283. if DisputeResolution != "" {
  284. where = where + " and DisputeResolution like '%" + DisputeResolution + "%'"
  285. }
  286. if SubmitDate != "" {
  287. where = where + " and SubmitDate like '%" + SubmitDate + "%'"
  288. }
  289. if SealName != "" {
  290. where = where + " and SealName like '%" + SealName + "%'"
  291. }
  292. if PoNumber != "" {
  293. where = where + " and PoNumber like '%" + PoNumber + "%'"
  294. }
  295. if SignedDate != "" {
  296. where = where + " and PoNumber like '%" + SignedDate + "%'"
  297. }
  298. if ImportStatus != "" {
  299. where = where + " and ImportStatus = " + ImportStatus
  300. } else {
  301. where = where + " and ImportStatus != 0"
  302. }
  303. // 企管法规处可看所有合同, 获取企管法规处人员
  304. var setting auditsetting.Base_OilAuditSetting
  305. orgSvc := organize.GetOrganizeService(utils.DBE)
  306. whereAudit := "AuditStepCode='PROF_REGULATION'"
  307. orgSvc.GetEntity(&setting, whereAudit)
  308. res := orgSvc.UserInRoleById(this.User.Id, strconv.Itoa(setting.RoleId))
  309. if !res {
  310. where = where + " and SecondUnit= " + strconv.Itoa(this.User.UnitId)
  311. }
  312. svc := contract.GetOilContractService(utils.DBE)
  313. var list []contract.OilContract
  314. total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  315. var datainfo DataInfo
  316. datainfo.Items = list
  317. datainfo.CurrentItemCount = total
  318. datainfo.PageIndex = page.CurrentPage
  319. datainfo.ItemsPerPage = page.Size
  320. this.Data["json"] = &datainfo
  321. this.ServeJSON()
  322. }
  323. // @Title 获取字典列表
  324. // @Description get user by token
  325. // @Success 200 {object} map[string]interface{}
  326. // @router /dictlist [get]
  327. func (this *OilContractController) GetDictList() {
  328. dictList := make(map[string]interface{})
  329. dictSvc := items.GetItemsService(utils.DBE)
  330. userSvc := baseUser.GetBaseUserService(utils.DBE)
  331. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  332. //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", "")
  333. var userEntity userRole.Base_User
  334. userSvc.GetEntityById(this.User.Id, &userEntity)
  335. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId("", userEntity.Departmentid)
  336. dictList["ContractClass"] = dictSvc.GetKeyValueItems("ContractClass")
  337. dictList["ProjectType"] = dictSvc.GetKeyValueItems("ProjectType")
  338. dictList["ContractMode"] = dictSvc.GetKeyValueItems("ContractMode")
  339. dictList["CurrencyType"] = dictSvc.GetKeyValueItems("CurrencyType")
  340. //var dictCustomer []svccustomer.Customer
  341. //customerSvc.GetEntitysByWhere("" + CustomerName, "", &dictCustomer)
  342. //dictList["EntrustCorp"] = &dictCustomer
  343. var datainfo DataInfo
  344. datainfo.Items = dictList
  345. this.Data["json"] = &datainfo
  346. this.ServeJSON()
  347. }
  348. // @Title 完成合同
  349. // @Description get user by token
  350. // @Success 200 {object} map[string]interface{}
  351. // @router /finish/:id [get]
  352. //func (this *OilContractController) Finish(){
  353. // id := this.Ctx.Input.Param(":id")
  354. // var errinfo ErrorInfo
  355. // if id == "" {
  356. // errinfo.Message = "操作失败!请求信息不完整"
  357. // errinfo.Code = -2
  358. // this.Data["json"] = &errinfo
  359. // this.ServeJSON()
  360. // return
  361. // }
  362. // var model contract.OilContract
  363. // svc := contract.GetOilContractService(utils.DBE)
  364. // model.Status = 2
  365. // cols := []string{
  366. // "Status",
  367. // }
  368. // err := svc.UpdateEntityBytbl(OilContractName, id, &model, cols)
  369. // if err == nil {
  370. // errinfo.Message = "修改成功!"
  371. // errinfo.Code = 0
  372. // this.Data["json"] = &errinfo
  373. // this.ServeJSON()
  374. // } else {
  375. // errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  376. // errinfo.Code = -1
  377. // this.Data["json"] = &errinfo
  378. // this.ServeJSON()
  379. // }
  380. //}
  381. // @Title 获取实体
  382. // @Description 获取实体
  383. // @Success 200 {object} oilcontract.OilContract
  384. // @router /get/:id [get]
  385. func (this *OilContractController) GetEntity() {
  386. Id := this.Ctx.Input.Param(":id")
  387. var model contract.OilContract
  388. svc := contract.GetOilContractService(utils.DBE)
  389. svc.GetEntityByIdBytbl(OilContractName, Id, &model)
  390. this.Data["json"] = &model
  391. this.ServeJSON()
  392. }
  393. // @Title get 导入excel
  394. // @Description 导入excel
  395. // @Success 200 {object} controllers.Request
  396. // @router /importexcel [get]
  397. func (this *OilContractController) ImportExcel() {
  398. go func() {
  399. url := this.GetString("ExcelUrl")
  400. //var errLineNum string
  401. if url == "" {
  402. fmt.Println("文件不能为空!")
  403. }
  404. _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
  405. filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
  406. utils.DownloadFile(url, filename, _dir)
  407. t := time.Now()
  408. filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
  409. xlFile, err := xlsx.OpenFile(filePath)
  410. //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
  411. if err != nil {
  412. fmt.Printf("open failed: %s\n", err)
  413. }
  414. var sheet = xlFile.Sheets[0]
  415. // 插入字段
  416. //Fstrs := "ContractNo,ContractName,Amount,ContractType,ContractSonClass,SmallClass,SignedDate,Number,ChooseWay,ContractMark,Currency,BudgetAmount,PerformAmount,IsInternal,IsForeign,IsDeal,MoneyFlows,MoneyChannel,MoneyChannelSon,MoneyChannelSmall,SingUnit,Place,StartDate,EndDate,DisputeResolution,Remark,ProjectOwner,SubmitDate,SealName,PoNumber"
  417. //columnArr := strings.Split(Fstrs, ",")
  418. //timeTemplate1 := "2006/01/02 15:04:05" //常规类型
  419. svc := contract.GetOilContractService(utils.DBE)
  420. for i := 1; i < len(sheet.Rows); i++ {
  421. var con contract.OilContract
  422. var con1 contract.OilContract
  423. lineNo := strconv.Itoa(i + 1)
  424. fmt.Println(lineNo)
  425. svc.GetEntityByWhere(OilContractName, "ContractNo = '"+sheet.Rows[i].Cells[0].String()+"'", &con1)
  426. if con1.Id > 0 {
  427. con1.ContractName = sheet.Rows[i].Cells[1].String()
  428. con1.Amount = sheet.Rows[i].Cells[2].String()
  429. con1.ClassName = sheet.Rows[i].Cells[3].String()
  430. con1.ContractSonClass = sheet.Rows[i].Cells[4].String()
  431. con1.SmallClass = sheet.Rows[i].Cells[5].String()
  432. con1.SignedDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[6].Value), time.Local)
  433. con1.Number = sheet.Rows[i].Cells[9].String()
  434. con1.ChooseWay = sheet.Rows[i].Cells[10].String()
  435. con1.ContractMark = sheet.Rows[i].Cells[11].String()
  436. con1.Currency = sheet.Rows[i].Cells[12].String()
  437. con1.BudgetAmount = sheet.Rows[i].Cells[13].String()
  438. con1.PerformAmount = sheet.Rows[i].Cells[14].String()
  439. con1.IsYearMoney = con1.PerformAmount
  440. con1.IsInternal = 0
  441. if sheet.Rows[i].Cells[15].String() == "是" {
  442. con1.IsInternal = 1
  443. }
  444. con1.IsForeign = 0
  445. if sheet.Rows[i].Cells[16].String() == "是" {
  446. con1.IsForeign = 1
  447. }
  448. con1.IsDeal = 0
  449. if sheet.Rows[i].Cells[17].String() == "是" {
  450. con1.IsDeal = 1
  451. }
  452. con1.MoneyFlows = sheet.Rows[i].Cells[18].String()
  453. con1.MoneyChannel = sheet.Rows[i].Cells[19].String()
  454. con1.MoneyChannelSon = sheet.Rows[i].Cells[20].String()
  455. con1.MoneyChannelSmall = sheet.Rows[i].Cells[21].String()
  456. con1.SingUnit = sheet.Rows[i].Cells[22].String()
  457. con1.Place = sheet.Rows[i].Cells[23].String()
  458. con1.StartDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[24].Value), time.Local)
  459. con1.EndDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[25].Value), time.Local)
  460. con1.DisputeResolution = sheet.Rows[i].Cells[26].String()
  461. con1.Remark = sheet.Rows[i].Cells[27].String()
  462. if con1.ProjectOwner != sheet.Rows[i].Cells[28].String() {
  463. con1.ProjectOwner = con1.ProjectOwner + "," + sheet.Rows[i].Cells[28].String()
  464. }
  465. con1.SubmitDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[29].Value), time.Local)
  466. con1.SealName = sheet.Rows[i].Cells[30].String()
  467. con1.PoNumber = sheet.Rows[i].Cells[31].String()
  468. con1.ImportStatus = 0
  469. svc.UpdateEntityById(con1.Id, &con1)
  470. continue
  471. }
  472. con.ContractNo = sheet.Rows[i].Cells[0].String()
  473. con.ContractName = sheet.Rows[i].Cells[1].String()
  474. con.Amount = sheet.Rows[i].Cells[2].String()
  475. con.ClassName = sheet.Rows[i].Cells[3].String()
  476. con.ContractSonClass = sheet.Rows[i].Cells[4].String()
  477. con.SmallClass = sheet.Rows[i].Cells[5].String()
  478. //con.SignedDate = convertToFormatDay(sheet.Rows[i].Cells[6].Value)
  479. con.SignedDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[6].Value), time.Local)
  480. con.ImportSecondUnit = sheet.Rows[i].Cells[7].String()
  481. con.ImportSupplierName = sheet.Rows[i].Cells[8].String()
  482. var supp supplier.OilSupplier
  483. svc.GetEntityByWhere(OilSupplierName, "SupplierName = '"+con.ImportSupplierName+"'", &supp)
  484. if supp.Id > 0 {
  485. con.SupplierId = supp.Id
  486. }
  487. var org organize.Base_Organize
  488. svc.GetEntityByWhere("Base_Organize", "FullName = '"+sheet.Rows[i].Cells[7].String()+"'", &org)
  489. if org.Id > 0 {
  490. con.SecondUnit = org.Id
  491. con.SecondUnitName = org.Fullname
  492. }
  493. con.Number = sheet.Rows[i].Cells[9].String()
  494. con.ChooseWay = sheet.Rows[i].Cells[10].String()
  495. con.ContractMark = sheet.Rows[i].Cells[11].String()
  496. con.Currency = sheet.Rows[i].Cells[12].String()
  497. con.BudgetAmount = sheet.Rows[i].Cells[13].String()
  498. con.PerformAmount = sheet.Rows[i].Cells[14].String()
  499. con.IsYearMoney = con.PerformAmount
  500. con.IsInternal = 0
  501. if sheet.Rows[i].Cells[15].String() == "是" {
  502. con.IsInternal = 1
  503. }
  504. con.IsForeign = 0
  505. if sheet.Rows[i].Cells[16].String() == "是" {
  506. con.IsForeign = 1
  507. }
  508. con.IsDeal = 0
  509. if sheet.Rows[i].Cells[17].String() == "是" {
  510. con.IsDeal = 1
  511. }
  512. con.MoneyFlows = sheet.Rows[i].Cells[18].String()
  513. con.MoneyChannel = sheet.Rows[i].Cells[19].String()
  514. con.MoneyChannelSon = sheet.Rows[i].Cells[20].String()
  515. con.MoneyChannelSmall = sheet.Rows[i].Cells[21].String()
  516. con.SingUnit = sheet.Rows[i].Cells[22].String()
  517. con.Place = sheet.Rows[i].Cells[23].String()
  518. con.StartDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[24].Value), time.Local)
  519. con.EndDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[25].Value), time.Local)
  520. con.DisputeResolution = sheet.Rows[i].Cells[26].String()
  521. con.Remark = sheet.Rows[i].Cells[27].String()
  522. con.ProjectOwner = sheet.Rows[i].Cells[28].String()
  523. con.SubmitDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[29].Value), time.Local)
  524. con.SealName = sheet.Rows[i].Cells[30].String()
  525. con.PoNumber = sheet.Rows[i].Cells[31].String()
  526. con.ImportStatus = 0
  527. con.Status = 1
  528. con.SettleStatus = "1"
  529. _, err = svc.InsertEntityBytbl(OilContractName, &con)
  530. if err != nil {
  531. fmt.Println(err)
  532. }
  533. }
  534. os.Remove(filePath)
  535. elapsed := time.Since(t)
  536. log.Println(elapsed)
  537. }()
  538. var errorinfo ErrorDataInfo
  539. errorinfo.Code = 0
  540. errorinfo.Message = "导入中,请稍后!"
  541. this.Data["json"] = &errorinfo
  542. this.ServeJSON()
  543. }
  544. // @Title 从数据录入数据导出到word文档
  545. // @Description 数据存入word
  546. // @Success 200 {object} controllers.Request
  547. // @router /exportword/:id [get]
  548. func (this *OilContractController) DocExport() {
  549. // 填物资类信息表首页信息
  550. Id := this.Ctx.Input.Param(":id")
  551. var Url string
  552. var fileName string
  553. svcActiviti := workflow.GetActivitiService(utils.DBE)
  554. var model contract.OilContract
  555. svc := contract.GetOilContractService(utils.DBE)
  556. where := "1=1"
  557. where += " AND Id = '" + Id + "'"
  558. svc.GetEntityByWhere(OilContractName, where, &model)
  559. Url = utils.Cfg.MustValue("workflow", "contractUrl")
  560. fileName = "合同导出模板.docx"
  561. datamap := structToMapDemo(model)
  562. //datamap["TableComment"] = []string{"MajorEquipments", "ThreeYears", "Patent", "Winning"}
  563. retDocUrl := svcActiviti.FillWordTemplate(datamap, Url, fileName)
  564. //retDocUrl := svcActiviti.FillWordWatermarkTemplate(datamap, Url, fileName, model.SupplierName)
  565. var datainfo ErrorDataInfo
  566. datainfo.Code = 0
  567. datainfo.Item = retDocUrl
  568. datainfo.Message = "导出成功"
  569. this.Data["json"] = &datainfo
  570. this.ServeJSON()
  571. }
  572. // @Title get 导入批量保存
  573. // @Description 数据存入
  574. // @Success 200 {object} controllers.Request
  575. // @router /importbatchsave [post]
  576. func (this *OilContractController) ImportBatchSave() {
  577. sql := "update OilContract set ImportStatus = 1 where SupplierId != 0 and ContractClass != '' and SecondUnit != 0"
  578. _, err := utils.DBE.Query(sql)
  579. var errinfo ErrorInfo
  580. if err == nil {
  581. errinfo.Message = "确认成功!"
  582. errinfo.Code = 0
  583. this.Data["json"] = &errinfo
  584. this.ServeJSON()
  585. } else {
  586. errinfo.Message = "确认失败!" + utils.AlertProcess(err.Error())
  587. errinfo.Code = -1
  588. this.Data["json"] = &errinfo
  589. this.ServeJSON()
  590. }
  591. }
  592. // @Title get 批量修改字段
  593. // @Description 批量修改字段
  594. // @Success 200 {object} controllers.Request
  595. // @router /importUpdate [get]
  596. func (this *OilContractController) ImportUpdate() {
  597. Class := this.GetString("Class")
  598. Value := this.GetString("Value")
  599. Column := this.GetString("Column")
  600. Id := this.GetString("Id")
  601. SupplierId := this.GetString("SupplierId")
  602. var supp supplier.OilSupplier
  603. svc := supplier.GetOilSupplierService(utils.DBE)
  604. svc.GetEntityById(SupplierId, &supp)
  605. sql := ""
  606. var err error
  607. where := "1=1"
  608. if Column == "ContractClass" {
  609. if Id != "" {
  610. where += " and Id = " + Id + " and ImportStatus = 0 and ClassName = '" + Class + "'"
  611. sql = "update OilContract set SupplierName = '" + supp.SupplierName + "', " + Column + " = '" + Value + "' where " + where
  612. } else {
  613. where += " and ImportStatus = 0 and ClassName = '" + Class + "' and " + Column + " = ''"
  614. sql = "update OilContract set " + Column + " = '" + Value + "' where " + where
  615. }
  616. _, err = utils.DBE.Query(sql)
  617. }
  618. if Column == "SupplierId" {
  619. if Id != "" {
  620. where += " and Id = " + Id + " and ImportStatus = 0 and ImportSupplierName = '" + Class + "'"
  621. } else {
  622. where += " and ImportStatus = 0 and ImportSupplierName = '" + Class + "' and " + Column + " = 0"
  623. }
  624. sql := "update OilContract set SupplierName = '" + supp.SupplierName + "', " + Column + " = " + Value + " where " + where
  625. _, err = utils.DBE.Query(sql)
  626. }
  627. if Column == "SecondUnit" {
  628. var org organize.Base_Organize
  629. svc.GetEntityByWhere("Base_Organize", "Id = " + Value, &org)
  630. if Id != "" {
  631. where += " and Id = " + Id + " and ImportStatus = 0 and ImportSecondUnit = '" + Class + "'"
  632. sql = "update OilContract set SecondUnitName = '" + org.Fullname + "',SupplierName = '" + supp.SupplierName + "', " + Column + " = " + Value + " where " + where
  633. } else {
  634. where += " and ImportStatus = 0 and ImportSecondUnit = '" + Class + "' and " + Column + " = 0"
  635. sql = "update OilContract set SecondUnitName = '" + org.Fullname + "'," + Column + " = " + Value + " where " + where
  636. }
  637. _, err = utils.DBE.Query(sql)
  638. }
  639. if Column == "Status" {
  640. where += " and Id = " + Id + " and ImportStatus = 0"
  641. sql := "update OilContract set SupplierName = '" + supp.SupplierName + "', " + Column + " = " + Value + " where " + where
  642. _, err = utils.DBE.Query(sql)
  643. }
  644. if Column == "SettleStatus" {
  645. where += " and Id = " + Id + " and ImportStatus = 0"
  646. sql := "update OilContract set SupplierName = '" + supp.SupplierName + "', " + Column + " = '" + Value + "' where " + where
  647. _, err = utils.DBE.Query(sql)
  648. }
  649. var errinfo ErrorInfo
  650. if err == nil {
  651. errinfo.Message = "修改成功!"
  652. errinfo.Code = 0
  653. this.Data["json"] = &errinfo
  654. this.ServeJSON()
  655. } else {
  656. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  657. errinfo.Code = -1
  658. this.Data["json"] = &errinfo
  659. this.ServeJSON()
  660. }
  661. }
  662. // excel日期字段格式化 yyyy-mm-dd
  663. func convertToFormatDay(excelDaysString string) string {
  664. // 2006-01-02 距离 1900-01-01的天数
  665. baseDiffDay := int64(38719) //在网上工具计算的天数需要加2天,什么原因没弄清楚
  666. curDiffDay := excelDaysString
  667. comma := strings.Index(curDiffDay, ".")
  668. if comma != -1 {
  669. curDiffDay = curDiffDay[0:comma]
  670. }
  671. b, _ := strconv.ParseInt(curDiffDay, 10, 64) //strconv.Atoi(curDiffDay)
  672. // 获取excel的日期距离2006-01-02的天数
  673. realDiffDay := b - baseDiffDay
  674. //fmt.Println("realDiffDay:",realDiffDay)
  675. // 距离2006-01-02 秒数
  676. realDiffSecond := realDiffDay * 24 * 3600
  677. //fmt.Println("realDiffSecond:",realDiffSecond)
  678. // 2006-01-02 15:04:05距离1970-01-01 08:00:00的秒数 网上工具可查出
  679. baseOriginSecond := int64(1136185445)
  680. resultTime := time.Unix((baseOriginSecond + realDiffSecond), 0).Format("2006-01-02")
  681. return resultTime
  682. }
  683. func (this *OilContractController) OperationCell(svc *contract.OilContractSession, lineNo string, columnArr []string, cellsArr []*xlsx.Cell, errLineNum *string) {
  684. defer func() {
  685. if err := recover(); err != nil {
  686. log.Println("err"+lineNo, err)
  687. *errLineNum += lineNo + ","
  688. }
  689. }()
  690. cellsArrLen := len(cellsArr)
  691. var valstr = ""
  692. for i := 0; i < cellsArrLen; i++ {
  693. valstr += "'" + cellsArr[i].String() + "',"
  694. }
  695. valstr = strings.Trim(valstr, ",")
  696. valstr = strings.Replace(valstr, "是", "1", -1)
  697. log.Println(cellsArr[6].String() + "==" + valstr)
  698. var columnstr = ""
  699. for l := 0; l < cellsArrLen; l++ {
  700. columnstr += columnArr[l] + ","
  701. }
  702. columnstr = strings.Trim(columnstr, ",")
  703. //err := svc.InsertTmpOilBasisBuild(columnstr, valstr)
  704. //if err != nil {
  705. // panic(err)
  706. //}
  707. }
  708. func structToMapDemo(obj interface{}) map[string]interface{} {
  709. obj1 := reflect.TypeOf(obj)
  710. obj2 := reflect.ValueOf(obj)
  711. var data = make(map[string]interface{})
  712. for i := 0; i < obj1.NumField(); i++ {
  713. data[obj1.Field(i).Name] = obj2.Field(i).Interface()
  714. }
  715. return data
  716. }
  717. // @Title 添加
  718. // @Description 新增
  719. // @Param body body oilcontract.OilContract
  720. // @Success 200 {object} controllers.Request
  721. // @router /add [post]
  722. func (this *OilContractController) AddEntity() {
  723. var errinfo ErrorDataInfo
  724. var model contract.OilContract
  725. var jsonBlob = this.Ctx.Input.RequestBody
  726. svc := contract.GetOilContractService(utils.DBE)
  727. json.Unmarshal(jsonBlob, &model)
  728. if model.IsYear == 1 && model.IsYearMoney == "" {
  729. errinfo.Message = "跨年当年结算金额必填"
  730. errinfo.Code = -2
  731. this.Data["json"] = &errinfo
  732. this.ServeJSON()
  733. return
  734. }
  735. if model.IsYearMoney == "" {
  736. model.IsYearMoney = model.PerformAmount
  737. }
  738. model.ImportStatus = 2
  739. model.CreateOn = time.Now()
  740. model.CreateBy = this.User.Realname
  741. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  742. model.SecondUnit = this.User.UnitId
  743. var model1 contract.OilContractMoney
  744. var contract contract.OilContract
  745. tempCount, _ := svc.GetCount(&contract, "ContractNo='"+model.ContractNo+"' ")
  746. if tempCount > 0 {
  747. errinfo.Message = "合同编号已存在!"
  748. errinfo.Code = -1
  749. this.Data["json"] = &errinfo
  750. this.ServeJSON()
  751. return
  752. }
  753. _, err := svc.InsertEntityBytbl(OilContractName, &model)
  754. if err == nil {
  755. if model.IsYear == 1 {
  756. svc.GetEntityByWhere(OilContractName, "ContractNo = '"+model.ContractNo+"'", &model)
  757. svc.GetEntityByWhere("OilContractMoney", "Year = '"+time.Now().Format("2006")+"' and ContractId = "+strconv.Itoa(model.Id), &model1)
  758. model1.ContractId = model.Id
  759. model1.Money = model.IsYearMoney
  760. model1.Year = time.Now().Format("2006")
  761. model1.CreateOn = time.Now()
  762. model1.CreateBy = this.User.Realname
  763. model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  764. svc.InsertEntityBytbl("OilContractMoney", &model1)
  765. }
  766. //新增
  767. errinfo.Message = "添加成功!"
  768. errinfo.Code = 0
  769. errinfo.Item = model.Id
  770. this.Data["json"] = &errinfo
  771. this.ServeJSON()
  772. } else {
  773. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  774. errinfo.Code = -1
  775. this.Data["json"] = &errinfo
  776. this.ServeJSON()
  777. }
  778. }
  779. // @Title 修改实体
  780. // @Description 修改实体
  781. // @Param body body oilcontract.OilContract
  782. // @Success 200 {object} controllers.Request
  783. // @router /update/:id [post]
  784. func (this *OilContractController) UpdateEntity() {
  785. id := this.Ctx.Input.Param(":id")
  786. var errinfo ErrorInfo
  787. if id == "" {
  788. errinfo.Message = "操作失败!请求信息不完整"
  789. errinfo.Code = -2
  790. this.Data["json"] = &errinfo
  791. this.ServeJSON()
  792. return
  793. }
  794. var model contract.OilContract
  795. var model1 contract.OilContractMoney
  796. svc := contract.GetOilContractService(utils.DBE)
  797. var jsonBlob = this.Ctx.Input.RequestBody
  798. json.Unmarshal(jsonBlob, &model)
  799. if model.IsYear == 1 && model.IsYearMoney == "" {
  800. errinfo.Message = "跨年当年结算金额必填"
  801. errinfo.Code = -2
  802. this.Data["json"] = &errinfo
  803. this.ServeJSON()
  804. return
  805. }
  806. if model.IsYearMoney == "" {
  807. model.IsYearMoney = model.PerformAmount
  808. }
  809. model.ModifiedOn = time.Now()
  810. model.ModifiedBy = this.User.Realname
  811. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  812. cols := []string{
  813. "Id",
  814. "SupplierId",
  815. "SupplierName",
  816. "Status",
  817. "SettleStatus",
  818. "ProjectName",
  819. "ContractNo",
  820. "ProjectPlace",
  821. "ProjectOwner",
  822. "Telephone",
  823. "ProjectType",
  824. "ContractMode",
  825. "Amount",
  826. "ContractPeriod",
  827. "OpenDate",
  828. "PlanFinishDate",
  829. "ConstructionUnit",
  830. "ConstructionOwner",
  831. "ConstructionTelphone",
  832. "BuildUnit",
  833. "BuildOwner",
  834. "BuildTelphone",
  835. "SuperviseUnit",
  836. "SuperviseOwner",
  837. "SuperviseTelphone",
  838. "QualityUnit",
  839. "QualityOwner",
  840. "QualityTelphone",
  841. "Remark",
  842. "IsDelete",
  843. "CreateOn",
  844. "CreateUserId",
  845. "CreateBy",
  846. "ModifiedOn",
  847. "ModifiedUserId",
  848. "ModifiedBy",
  849. "SubPackage",
  850. "ContractName",
  851. "ContractSonClass",
  852. "SmallClass",
  853. "SignedDate",
  854. "People",
  855. "Number",
  856. "ChooseWay",
  857. "ContractMark",
  858. "Currency",
  859. "BudgetAmount",
  860. "PerformAmount",
  861. "IsInternal",
  862. "IsForeign",
  863. "IsDeal",
  864. "MoneyFlows",
  865. "MoneyChannelSon",
  866. "MoneyChannelSmall",
  867. "SingUnit",
  868. "Place",
  869. "DisputeResolution",
  870. "SubmitDate",
  871. "SealName",
  872. "PoNumber",
  873. "IsYearMoney",
  874. "IsYear",
  875. }
  876. var contract contract.OilContract
  877. tempCount, _ := svc.GetCount(&contract, "ContractNo='"+model.ContractNo+"' and id <> "+id)
  878. if tempCount > 0 {
  879. errinfo.Message = "合同编号已存在!"
  880. errinfo.Code = -1
  881. this.Data["json"] = &errinfo
  882. this.ServeJSON()
  883. return
  884. }
  885. err := svc.UpdateEntityBytbl(OilContractName, id, &model, cols)
  886. if err == nil {
  887. if model.IsYear == 1 && model.IsYearMoney != "" {
  888. svc.GetEntityByWhere("OilContractMoney", "Year = '"+time.Now().Format("2006")+"' and ContractId = "+id, &model1)
  889. if model1.Id > 0 {
  890. model1.Money = model.IsYearMoney
  891. model1.ModifiedOn = time.Now()
  892. model1.ModifiedBy = this.User.Realname
  893. model1.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  894. svc.UpdateEntityBytbl("OilContractMoney", model1.Id, &model1, []string{"Money"})
  895. } else {
  896. model1.ContractId, _ = strconv.Atoi(id)
  897. model1.Money = model.IsYearMoney
  898. model1.Year = time.Now().Format("2006")
  899. model1.CreateOn = time.Now()
  900. model1.CreateBy = this.User.Realname
  901. model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  902. svc.InsertEntityBytbl("OilContractMoney", &model1)
  903. }
  904. }
  905. errinfo.Message = "修改成功!"
  906. errinfo.Code = 0
  907. this.Data["json"] = &errinfo
  908. this.ServeJSON()
  909. } else {
  910. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  911. errinfo.Code = -1
  912. this.Data["json"] = &errinfo
  913. this.ServeJSON()
  914. }
  915. }
  916. // @Title 删除单条信息
  917. // @Description
  918. // @Success 200 {object} ErrorInfo
  919. // @Failure 403 :id 为空
  920. // @router /delete/:Id [delete]
  921. func (this *OilContractController) DeleteEntity() {
  922. Id := this.Ctx.Input.Param(":Id")
  923. var errinfo ErrorInfo
  924. if Id == "" {
  925. errinfo.Message = "操作失败!请求信息不完整"
  926. errinfo.Code = -2
  927. this.Data["json"] = &errinfo
  928. this.ServeJSON()
  929. return
  930. }
  931. // 有没有待审核的评价
  932. itemsSvc := contractReview.GetOilContractReviewService(utils.DBE)
  933. var review contractReview.OilContractReview
  934. //tempCount,_:=itemsSvc.GetCount(&review,"ContractId='" + Id +"' and status > 0 and status < 8 ")
  935. tempCount, _ := itemsSvc.GetCount(&review, "ContractId='"+Id+"' ")
  936. if tempCount > 0 {
  937. errinfo.Message = "该合同存在评价不能删除!"
  938. errinfo.Code = -1
  939. this.Data["json"] = &errinfo
  940. this.ServeJSON()
  941. return
  942. }
  943. var model contract.OilContract
  944. var entityempty contract.OilContract
  945. svc := contract.GetOilContractService(utils.DBE)
  946. opdesc := "删除-" + Id
  947. err := svc.DeleteOperationAndWriteLogBytbl(OilContractName, BaseOperationLogName, Id, &model, &entityempty,
  948. utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "合同表")
  949. if err == nil {
  950. errinfo.Message = "删除成功"
  951. errinfo.Code = 0
  952. this.Data["json"] = &errinfo
  953. this.ServeJSON()
  954. } else {
  955. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  956. errinfo.Code = -1
  957. this.Data["json"] = &errinfo
  958. this.ServeJSON()
  959. }
  960. }
  961. // @Title 获取合同结算金额总数
  962. // @Description
  963. // @Success 200 {object} ErrorInfo
  964. // @Failure 403 :id 为空
  965. // @router /countMoney/:Id [get]
  966. func (this *OilContractController) CountMoney() {
  967. Id := this.Ctx.Input.Param(":Id")
  968. var errinfo ErrorInfo
  969. if Id == "" {
  970. errinfo.Message = "操作失败!请求信息不完整"
  971. errinfo.Code = -2
  972. this.Data["json"] = &errinfo
  973. this.ServeJSON()
  974. return
  975. }
  976. var model contract.OilContractMoney
  977. svc := contract.GetOilContractService(utils.DBE)
  978. svc.GetSum(&model, "Year != '"+time.Now().Format("2006")+"'")
  979. this.Data["json"] = &model
  980. this.ServeJSON()
  981. }
  982. // @Title 获取列表
  983. // @Description get user by token
  984. // @Success 200 {object} []oilcontract.OilContract
  985. // @router /need-eva-list [get]
  986. func (this *OilContractController) GetNeedEvaList() {
  987. var list []contract.OilContract
  988. sql := ` select a.* from OilContract a left join OilContractReview b on b.ContractId=a.Id where a.SecondUnit=` + strconv.Itoa(this.User.UnitId) + ` and (b.Status=0 or b.Status=NULL) `
  989. utils.DBE.Sql(sql).Find(&list)
  990. var dataInfo DataInfo
  991. dataInfo.Items = list
  992. dataInfo.CurrentItemCount = int64(len(list))
  993. this.Data["json"] = &dataInfo
  994. this.ServeJSON()
  995. }