select.go 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/annualaudit"
  4. "dashoo.cn/backend/api/business/oilsupplier/infochange"
  5. "dashoo.cn/backend/api/business/oilsupplier/qualchange"
  6. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  7. "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
  8. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  9. "dashoo.cn/backend/api/business/register"
  10. "encoding/json"
  11. "fmt"
  12. "sort"
  13. "strconv"
  14. "strings"
  15. "time"
  16. // "fmt"
  17. "dashoo.cn/backend/api/business/oilsupplier/selectbusiness"
  18. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  19. . "dashoo.cn/backend/api/controllers"
  20. "dashoo.cn/utils"
  21. )
  22. type SelectController struct {
  23. BaseController
  24. }
  25. type UpSearch struct {
  26. FullName string
  27. }
  28. type UpInfoSearch struct {
  29. FullName string
  30. SupplierTypeName string
  31. HeGe int
  32. BuHeGe int
  33. ZongShu int
  34. Reason string
  35. }
  36. type Processinfo struct {
  37. Id int
  38. AccessCardNo string
  39. WorkflowId string
  40. ProcessKey string
  41. SupplierName string
  42. SupplierTypeCode string
  43. Status string
  44. Type string
  45. CreateOn time.Time
  46. AddinTime time.Time
  47. RecUnitName string
  48. ContactName string
  49. Mobile string
  50. }
  51. // @Title 获取所有
  52. // @Description
  53. // @Success 200 {object}
  54. // @router /getcompanylist [post]
  55. func (this *SelectController) GetTList() {
  56. var model supplier.OilSupplierSelect
  57. var model1 supplier.RegCapitalRange //注册资金范围
  58. //var model2 supplier.NeedFileTypeStruct //资质结构体
  59. var jsonBlob = this.Ctx.Input.RequestBody
  60. json.Unmarshal(jsonBlob, &model)
  61. json.Unmarshal(jsonBlob, &model1)
  62. //json.Unmarshal(jsonBlob, &model2)
  63. // //获取分页信息
  64. page := this.GetPageInfoForm()
  65. where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' "
  66. orderby := "a.Id"
  67. asc := true
  68. Order := this.GetString("Order")
  69. Prop := this.GetString("Prop")
  70. if Order != "" && Prop != "" {
  71. orderby = Prop
  72. if Order == "desc" {
  73. asc = false
  74. }
  75. }
  76. leftjoin := ""
  77. //准入证号
  78. if model.AccessCardNo != "" {
  79. where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
  80. }
  81. //企业名称
  82. if model.SupplierName != "" {
  83. where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
  84. }
  85. if model.OldSupplierName != "" {
  86. where = where + " and OldSupplierName like '%" + model.OldSupplierName + "%'"
  87. }
  88. if model.FullName != "" {
  89. where = where + " and f.FullName like '%" + model.FullName + "%'"
  90. }
  91. if model.CheckUnitName != "" {
  92. where = where + " and g.CheckUnitName like '%" + model.CheckUnitName + "%'"
  93. }
  94. //准入类别(基建,物资,技术服务)
  95. if model.SupplierTypeCode != "" {
  96. where = where + " and b.SupplierTypeCode = '" + model.SupplierTypeCode + "'"
  97. }
  98. //准入标识 1 准入 2 暂停 3取消
  99. if model.InFlag != "" {
  100. where = where + " and b.InFlag = '" + model.InFlag + "'"
  101. }
  102. //法人
  103. if model.LegalPerson != "" {
  104. where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
  105. }
  106. //联系人
  107. if model.ContactName != "" {
  108. where = where + " and a.ContactName like '%" + model.ContactName + "%'"
  109. }
  110. //统一社会信用代码
  111. if model.CommercialNo != "" {
  112. where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
  113. }
  114. //开户银行
  115. if model.DepositBank != "" {
  116. where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
  117. }
  118. //HSE审查
  119. if model.HseTraining != "" {
  120. where = where + " and a.HseTraining = '" + model.HseTraining + "'"
  121. }
  122. //公司类型
  123. if model.CompanyType != "" {
  124. where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
  125. }
  126. //成立时间
  127. SetupTime := this.GetString("SetupTime")
  128. if SetupTime != "" {
  129. where = where + " and a.SetupTime ='" + SetupTime + "'"
  130. }
  131. //注册资金范围
  132. if model1.RegCapital1 != "" {
  133. where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
  134. }
  135. if model1.RegCapital2 != "" {
  136. where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
  137. }
  138. //注册省份
  139. if model.Province != "" {
  140. where = where + " and a.Province = '" + model.Province + "'"
  141. }
  142. //注册市
  143. if model.City != "" {
  144. where = where + " and a.City = '" + model.City + "'"
  145. }
  146. //注册区
  147. if model.Street != "" {
  148. where = where + " and a.Street = '" + model.Street + "'"
  149. }
  150. //注册详细地址
  151. if model.Address != "" {
  152. where = where + " and a.Address like '%" + model.Address + "%'"
  153. }
  154. if model.LinkProvince != "" {
  155. where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
  156. }
  157. if model.LinkCity != "" {
  158. where = where + " and a.LinkCity = '" + model.LinkCity + "'"
  159. }
  160. if model.LinkStreet != "" {
  161. where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
  162. }
  163. if model.LinkAddress != "" {
  164. where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
  165. }
  166. //营业范围
  167. if model.BusinessScope != "" {
  168. where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
  169. }
  170. CreateOn := this.GetString("CreateOn")
  171. if CreateOn != "" {
  172. dates := strings.Split(CreateOn, ",")
  173. if len(dates) == 2 {
  174. minDate := dates[0]
  175. maxDate := dates[1]
  176. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  177. }
  178. }
  179. a := model.InStyle
  180. fmt.Println(a)
  181. //准入方式
  182. if model.InStyle != "" {
  183. if model.InStyle == "0"{
  184. where = where + " and b.InStyle in ('2','3','4','5')"
  185. }else{
  186. where = where + " and b.InStyle ='" + model.InStyle + "'"
  187. }
  188. }
  189. //包含资质
  190. //if model2.NeedFileType != nil && len(model2.NeedFileType) > 0 {
  191. // pararm := ""
  192. // for i := 0; i < len(model2.NeedFileType); i++ {
  193. //
  194. // pararm = pararm + "'" + model2.NeedFileType[i] + "',"
  195. //
  196. // }
  197. // fmt.Println(pararm[0 : len(pararm)-1])
  198. // where = where + " and d.NeedFileType in (" + pararm[0:len(pararm)-1] + ")"
  199. //}
  200. having:=""
  201. //准入范围
  202. if model.CerSubName!="" {
  203. having = " having CerSubName like '%"+model.CerSubName+"%' "
  204. leftjoin = "left join "+ OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  205. }
  206. //资质
  207. if model.NeedFileType!="" {
  208. having = " having NeedFileType like '%"+model.NeedFileType+"%' "
  209. }
  210. if model.CerSubName!=""&& model.NeedFileType!=""{
  211. having = " having CerSubName like '%"+model.CerSubName+"%' and NeedFileType like '%"+model.NeedFileType+"%' "
  212. leftjoin = "left join "+ OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  213. }
  214. svc := selectbusiness.GetSelectService(utils.DBE)
  215. var list []supplier.OilSupplierSelect
  216. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName,OilCorporateInfoName,OilSupplierCertSubName,
  217. OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where,having, leftjoin)
  218. var datainfo DataInfo
  219. datainfo.Items = list
  220. datainfo.CurrentItemCount = total
  221. datainfo.PageIndex = page.CurrentPage
  222. datainfo.ItemsPerPage = page.Size
  223. this.Data["json"] = &datainfo
  224. this.ServeJSON()
  225. }
  226. // @Title 获取所有
  227. // @Description
  228. // @Success 200 {object}
  229. // @router /getbaseinfo [post]
  230. func (this *SelectController) GetBaseInfo() {
  231. Spesearch := this.GetString("Spesearch")
  232. spesearchs := strings.Split(Spesearch, ",")
  233. svc := selectbusiness.GetSelectService(utils.DBE)
  234. var infoIntelist []supplier.OilSupplierInte
  235. for _,item := range spesearchs {
  236. //var supplierinfo supplier.SupplierInfoInte
  237. var infoInte supplier.OilSupplierInte
  238. where := " where 1 = 1 AND a.SupplierName = '" + item + "'"
  239. svc.GetInfoByCompId(where,&infoInte.SupplierInfo)
  240. //var suplliersup []supplier.OilSupplierCertSubInte
  241. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='01'"
  242. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.WZsub)
  243. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='02'"
  244. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JSsub)
  245. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='03'"
  246. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JFsub)
  247. infoIntelist = append(infoIntelist, infoInte)
  248. }
  249. var datainfo DataInfo
  250. datainfo.Items = infoIntelist
  251. this.Data["json"] = &datainfo
  252. this.ServeJSON()
  253. }
  254. // @Title 获取所有
  255. // @Description
  256. // @Success 200 {object}
  257. // @router /up [post]
  258. func (this *SelectController) Up() {
  259. var model UpSearch
  260. var jsonBlob = this.Ctx.Input.RequestBody
  261. json.Unmarshal(jsonBlob, &model)
  262. // //获取分页信息
  263. page := this.GetPageInfoForm()
  264. where := ""
  265. asc := false
  266. Order := this.GetString("Order")
  267. Prop := this.GetString("Prop")
  268. CreateOn := this.GetString("CreateOn")
  269. if Order != "" && Prop != "" {
  270. if Order == "asc" {
  271. asc = true
  272. }
  273. }
  274. if CreateOn != "" {
  275. dates := strings.Split(CreateOn, ",")
  276. if len(dates) == 2 {
  277. minDate := dates[0]
  278. maxDate := dates[1]
  279. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  280. }
  281. }
  282. if model.FullName != "" {
  283. where = where + " and (select FullName from Base_Organize where Id = a.CommitComId) like '%" + model.FullName + "%'"
  284. }
  285. svc := selectbusiness.GetSelectService(utils.DBE)
  286. var list []UpInfoSearch
  287. total := svc.GetUp( OilSupplierCertName , page.CurrentPage, page.Size, Prop, asc, &list, where)
  288. var datainfo DataInfo
  289. datainfo.Items = list
  290. datainfo.CurrentItemCount = total
  291. datainfo.PageIndex = page.CurrentPage
  292. datainfo.ItemsPerPage = page.Size
  293. this.Data["json"] = &datainfo
  294. this.ServeJSON()
  295. }
  296. // @Title 获取所有资质名称
  297. // @Description
  298. // @Success 200 {object}
  299. // @router /getnftoptions [post]
  300. func (this *SelectController) GetNFTOptions() {
  301. svc := selectbusiness.GetSelectService(utils.DBE)
  302. var list []map[string]string
  303. sql := "select distinct(Name) from " + BaseTableHeader + ""
  304. list, _ = svc.DBE.QueryString(sql)
  305. var datainfo DataInfo
  306. datainfo.Items = list
  307. this.Data["json"] = &datainfo
  308. this.ServeJSON()
  309. }
  310. // @Title 流程查询准入
  311. // @Description
  312. // @Success 200 {object}
  313. // @router /getprocessauditlist [get]
  314. func (this *SelectController) GetProcessAuditList() {
  315. //获取分页信息
  316. page := this.GetPageInfoForm()
  317. where := " 1=1 "
  318. orderby := "Id"
  319. asc := false
  320. Order := this.GetString("Order")
  321. Prop := this.GetString("Prop")
  322. if Order != "" && Prop != "" {
  323. orderby = Prop
  324. if Order == "asc" {
  325. asc = true
  326. }
  327. }
  328. svc := supplier.GetOilSupplierService(utils.DBE)
  329. tabinx := this.GetString("tabinx")
  330. supplierTypeCode := this.GetString("SupplierTypeCode")
  331. supplierName := this.GetString("SupplierName")
  332. CreateOn := this.GetString("CreateOn")
  333. //企业用户必须加创建人条件
  334. var registerUser register.OilCorporateInfo
  335. sql := " UserName='" + this.User.Username + "'"
  336. svc.GetEntity(&registerUser,sql)
  337. var processinfolist []Processinfo
  338. if this.User.IsCompanyUser == 1 {
  339. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='"+registerUser.CommercialNo+"')"
  340. }
  341. if supplierTypeCode != "" {
  342. where = where + " and b.SupplierTypeCode like '%" + supplierTypeCode + "%'"
  343. }
  344. if supplierName != "" {
  345. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  346. }
  347. var total int64 = 0
  348. var datainfo DataInfo
  349. if tabinx == "1" || tabinx == "0" {
  350. var list []Processinfo //[]supplier.OilSupplierView
  351. if CreateOn != "" {
  352. dates := strings.Split(CreateOn, ",")
  353. if len(dates) == 2 {
  354. minDate := dates[0]
  355. maxDate := dates[1]
  356. where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
  357. }
  358. }
  359. total = total + svc.GetProcessInfoWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, "b.Id", asc, &list, where)
  360. processinfolist = append(processinfolist, list...)
  361. //datainfo.Items = processinfolist
  362. }
  363. if tabinx == "2" || tabinx == "0" {
  364. whereapp := "1=1"
  365. //企业用户必须加创建人条件
  366. if this.User.IsCompanyUser == 1 {
  367. whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'"
  368. }
  369. if supplierTypeCode != "" {
  370. whereapp = whereapp + " and a.AppendType like '%" + supplierTypeCode + "%'"
  371. }
  372. if supplierName != "" {
  373. whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'"
  374. }
  375. if CreateOn != "" {
  376. dates := strings.Split(CreateOn, ",")
  377. if len(dates) == 2 {
  378. minDate := dates[0]
  379. maxDate := dates[1]
  380. whereapp = whereapp + " a.and CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  381. }
  382. }
  383. var list []Processinfo//[]suppliercertappend.OilSupplierCertAppend
  384. svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  385. total = total + svc.GetProcessInfoWithOrderBytbl(OilSupplierCertAppendName, page.CurrentPage, page.Size, "a.Id", asc, &list, whereapp)
  386. processinfolist = append(processinfolist, list...)
  387. //datainfo.Items = processinfolist
  388. }
  389. if tabinx == "3" || tabinx == "0" {
  390. whereapp := "1=1"
  391. //企业用户必须加创建人条件
  392. if this.User.IsCompanyUser == 1 {
  393. whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'"
  394. }
  395. if supplierTypeCode != "" {
  396. whereapp = whereapp + " and a.SupplierTypeName like '%" + supplierTypeCode + "%'"
  397. }
  398. if supplierName != "" {
  399. whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'"
  400. }
  401. if CreateOn != "" {
  402. dates := strings.Split(CreateOn, ",")
  403. if len(dates) == 2 {
  404. minDate := dates[0]
  405. maxDate := dates[1]
  406. whereapp = whereapp + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  407. }
  408. }
  409. var list []Processinfo//[]annualaudit.OilAnnualAudit
  410. svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  411. total = total + svc.GetProcessInfoWithOrderBytbl(OilAnnualAuditName, page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  412. processinfolist = append(processinfolist, list...)
  413. //datainfo.Items = processinfolist
  414. }
  415. if tabinx == "4" || tabinx == "0" {
  416. whereapp := "1=1"
  417. //企业用户必须加创建人条件
  418. if this.User.IsCompanyUser == 1 {
  419. whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'"
  420. }
  421. if supplierName != "" {
  422. whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'"
  423. }
  424. if CreateOn != "" {
  425. dates := strings.Split(CreateOn, ",")
  426. if len(dates) == 2 {
  427. minDate := dates[0]
  428. maxDate := dates[1]
  429. whereapp = whereapp + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  430. }
  431. }
  432. var list []Processinfo//[]infochange.OilInfoChange
  433. svc := infochange.GetInfoChangeService(utils.DBE)
  434. total = total + svc.GetProcessInfoWithOrderBytbl(OilInfoChangeName, page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  435. processinfolist = append(processinfolist, list...)
  436. //datainfo.Items = processinfolist
  437. }
  438. if tabinx == "5" {
  439. whereapp := "1=1"
  440. //企业用户必须加创建人条件
  441. if this.User.IsCompanyUser == 1 {
  442. whereapp = whereapp + " and CreateUserId = '" + this.User.Id + "'"
  443. }
  444. if supplierName != "" {
  445. whereapp = whereapp + " and SupplierName like '%" + supplierName + "%'"
  446. }
  447. if CreateOn != "" {
  448. dates := strings.Split(CreateOn, ",")
  449. if len(dates) == 2 {
  450. minDate := dates[0]
  451. maxDate := dates[1]
  452. whereapp = whereapp + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  453. }
  454. }
  455. svc := qualchange.GetQualChangeService(utils.DBE)
  456. var list []qualchange.OilQualChangeMain
  457. total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  458. datainfo.Items = list
  459. }
  460. sort.Slice(processinfolist, func(i, j int) bool {
  461. return processinfolist[i].CreateOn.Unix() > processinfolist[j].CreateOn.Unix()
  462. })
  463. datainfo.Items = processinfolist
  464. datainfo.CurrentItemCount = total
  465. datainfo.PageIndex = page.CurrentPage
  466. datainfo.ItemsPerPage = page.Size
  467. this.Data["json"] = &datainfo
  468. this.ServeJSON()
  469. }
  470. // @Title 准入范围查询
  471. // @Description
  472. // @Success 200 {object}
  473. // @router /zrfwselect [get]
  474. func (this *SelectController) ZrfwSelect() {
  475. //获取分页信息
  476. page := this.GetPageInfoForm()
  477. limitCurrent:=(page.CurrentPage-1)*page.Size
  478. svc := selectbusiness.GetSelectService(utils.DBE)
  479. supplierTypeCode := this.GetString("SupplierTypeCode")
  480. certsub := this.GetString("certsub")
  481. //企业用户必须加创建人条件
  482. var registerUser register.OilCorporateInfo
  483. var company supplier.OilSupplier
  484. sql := " UserName='" + this.User.Username + "'"
  485. svc.GetEntity(&registerUser,sql)
  486. if this.User.IsCompanyUser == 1 {
  487. sql1:= " CreateUserId = '" + this.User.Id + "' or CommercialNo='"+registerUser.CommercialNo+"'"
  488. svc.GetEntity(&company,sql1)
  489. }
  490. where := ""
  491. if certsub != "" {
  492. where = " and (Code like '%" + certsub + "%' or Name like '%" + certsub + "%')"
  493. }
  494. if company.SupplierName!=""{
  495. sql2:="select distinct(Code),Name,SupplierId,CertSubStatus from OilSupplierCertSub where SupplierId='"+strconv.Itoa(company.Id)+"' and SupplierTypeCode='"+supplierTypeCode+"' " + where + " order by CertSubStatus desc,Code asc limit "+strconv.FormatInt(limitCurrent,10)+","+strconv.FormatInt(page.Size,10)+""
  496. result,_:=svc.DBE.QueryString(sql2)
  497. sql3:="select count(distinct(Code)) total from OilSupplierCertSub where SupplierId='"+strconv.Itoa(company.Id)+"' and SupplierTypeCode='"+supplierTypeCode+"'" + where
  498. result1,_:=svc.DBE.QueryString(sql3)
  499. total,_:= strconv.ParseInt(result1[0]["total"], 10, 64)
  500. var datainfo DataInfo
  501. datainfo.Items = result
  502. datainfo.CurrentItemCount = total
  503. datainfo.PageIndex = page.CurrentPage
  504. datainfo.ItemsPerPage = page.Size
  505. this.Data["json"] = &datainfo
  506. this.ServeJSON()
  507. }else{
  508. var datainfo DataInfo
  509. datainfo.Items = ""
  510. datainfo.PageIndex = page.CurrentPage
  511. datainfo.ItemsPerPage = page.Size
  512. this.Data["json"] = &datainfo
  513. this.ServeJSON()
  514. }
  515. }
  516. // @Title 获取所有
  517. // @Description
  518. // @Success 200 {object}
  519. // @router /getallbusinesslist [post]
  520. func (this *SelectController) GetAllBusinesList() {
  521. perject := this.GetString("Perject")
  522. accessCardNo := this.GetString("AccessCardNo")
  523. supplierTypeCode := this.GetString("SupplierTypeCode")
  524. supplierName := this.GetString("SupplierName")
  525. var list []selectbusiness.SelectBusiness
  526. // 准入
  527. if perject == "1" || perject == "" {
  528. where := "1=1 "
  529. if accessCardNo != "" {
  530. where = where + " and b.AccessCardNo='" + accessCardNo + "'"
  531. }
  532. if supplierTypeCode != "" {
  533. where = where + " and b.SupplierTypeCode='" + supplierTypeCode + "'"
  534. }
  535. if supplierName != "" {
  536. where =where + " and a.SupplierName like '%" + supplierName + "%'"
  537. }
  538. var zrlist []supplier.OilSupplierView
  539. zrsvc := supplier.GetOilSupplierService(utils.DBE)
  540. if this.User.IsCompanyUser == 1 {
  541. var registerUser register.OilCorporateInfo
  542. sql := " UserName='" + this.User.Username + "'"
  543. zrsvc.GetEntity(&registerUser,sql)
  544. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  545. }
  546. zrwhere := where + " and b.Status='" + suppliercert.STORE_STATUS + "'"
  547. zrsvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 1, 100, "b.Id", false , &zrlist, zrwhere)
  548. for _, item := range zrlist {
  549. var sele selectbusiness.SelectBusiness
  550. sele.SupplierName = item.SupplierName
  551. sele.CreateOn = item.CreateOn
  552. sele.AccessCardNo = item.AccessCardNo
  553. sele.TypeCode = item.SupplierTypeCode
  554. sele.TypeName = item.SupplierTypeName
  555. sele.Preject = "1"
  556. list = append(list, sele)
  557. }
  558. }
  559. // 增项
  560. if perject == "2" || perject == "" {
  561. where := "1=1 "
  562. if accessCardNo != "" {
  563. where = where + " and b.AccessCardNo='" + accessCardNo + "'"
  564. }
  565. if supplierTypeCode != "" {
  566. where = where + " and b.AppendType='" + supplierTypeCode + "'"
  567. }
  568. if supplierName != "" {
  569. where =where + " and a.SupplierName like '%" + supplierName + "%'"
  570. }
  571. var zxlist []suppliercertappend.OilSupplierCertAppend
  572. zxsvc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  573. if this.User.IsCompanyUser == 1 {
  574. var registerUser register.OilCorporateInfo
  575. sql := " UserName='" + this.User.Username + "'"
  576. zxsvc.GetEntity(&registerUser,sql)
  577. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  578. }
  579. zxwhere := where + " and b.Status='" + suppliercert.STORE_STATUS + "'"
  580. zxsvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertAppendName, 1, 100, "b.Id", false, &zxlist, zxwhere)
  581. for _, item := range zxlist {
  582. var sele selectbusiness.SelectBusiness
  583. sele.SupplierName = item.SupplierName
  584. sele.CreateOn = item.CreateOn
  585. sele.AccessCardNo = item.AccessCardNo
  586. sele.TypeCode = item.AppendType
  587. sele.TypeName = ""
  588. sele.Preject = "2"
  589. list = append(list, sele)
  590. }
  591. }
  592. // 年审
  593. if perject == "3" || perject == "" {
  594. where := "1=1 "
  595. if accessCardNo != "" {
  596. where = where + " and b.AccessCardNo='" + accessCardNo + "'"
  597. }
  598. if supplierTypeCode != "" {
  599. where = where + " and b.SupplierTypeName='" + supplierTypeCode + "'"
  600. }
  601. if supplierName != "" {
  602. where =where + " and a.SupplierName like '%" + supplierName + "%'"
  603. }
  604. var nslist []annualaudit.OilAnnualAudit
  605. nssvc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  606. if this.User.IsCompanyUser == 1 {
  607. var registerUser register.OilCorporateInfo
  608. sql := " UserName='" + this.User.Username + "'"
  609. nssvc.GetEntity(&registerUser,sql)
  610. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  611. }
  612. zswhere := where + " and b.Status='" + suppliercert.DRAFT_STATUS + "'"
  613. nssvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilAnnualAuditName,1, 100, "b.Id", false, &nslist, zswhere)
  614. for _, item := range nslist {
  615. var sele selectbusiness.SelectBusiness
  616. sele.SupplierName = item.SupplierName
  617. sele.CreateOn = item.CreateOn
  618. sele.AccessCardNo = item.AccessCardNo
  619. sele.TypeCode = item.SupplierTypeName
  620. sele.TypeName = ""
  621. sele.Preject = "3"
  622. list = append(list, sele)
  623. }
  624. }
  625. // 变更申请
  626. if perject == "4" || perject == "" {
  627. where := "1=1 "
  628. if accessCardNo != "" {
  629. where = where + " and b.AccessCardNo='" + accessCardNo + "'"
  630. }
  631. if supplierTypeCode != "" {
  632. where = where + " and b.SupplierTypeCode='" + supplierTypeCode + "'"
  633. }
  634. if supplierName != "" {
  635. where =where + " and a.SupplierName like '%" + supplierName + "%'"
  636. }
  637. var bglist []infochange.SuppModelInfo
  638. bgsvc := infochange.GetInfoChangeService(utils.DBE)
  639. if this.User.IsCompanyUser == 1 {
  640. var registerUser register.OilCorporateInfo
  641. sql := " UserName='" + this.User.Username + "'"
  642. bgsvc.GetEntity(&registerUser,sql)
  643. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  644. }
  645. bgwhere := where + " and b.Status='" + suppliercert.DRAFT_STATUS + "'"
  646. bgsvc.GetSuppPagingEntitiesWithOrderBytbl(OilSupplierName, OilInfoChangeName, 1, 100, "b.Id", false, &bglist, bgwhere)
  647. for _, item := range bglist {
  648. var sele selectbusiness.SelectBusiness
  649. sele.SupplierName = item.SupplierName
  650. sele.CreateOn = item.CreateOn
  651. sele.AccessCardNo = ""
  652. sele.TypeCode = item.SupplierTypeCode
  653. sele.TypeName = item.SupplierTypeName
  654. sele.Preject = "4"
  655. list = append(list, sele)
  656. }
  657. }
  658. var datainfo DataInfo
  659. datainfo.Items = list
  660. this.Data["json"] = &datainfo
  661. this.ServeJSON()
  662. }
  663. // @Title 文件上传
  664. // @Description get user by tokenaddsubfile
  665. // @Success 200 {object} models.Userblood
  666. // @router /filelist [get]
  667. func (this *SelectController) FileList() {
  668. page := this.GetPageInfoForm()
  669. var list []supplierfile.OilSupplierFile
  670. svc := supplierfile.GetSupplierfileService(utils.DBE)
  671. where := " 1=1"
  672. orderby := "Id"
  673. asc := true
  674. Order := this.GetString("Order")
  675. Prop := this.GetString("Prop")
  676. subfilename := this.GetString("subfileName")
  677. supplierId := this.GetString("SupplierId")
  678. createOn := this.GetString("CreateOn")
  679. if Order != "" && Prop != "" {
  680. orderby = Prop
  681. if Order == "asc" {
  682. asc = true
  683. }
  684. }
  685. //企业用户必须加创建人条件
  686. var registerUser register.OilCorporateInfo
  687. var company supplier.OilSupplier
  688. sql := " UserName='" + this.User.Username + "'"
  689. svc.GetEntity(&registerUser,sql)
  690. sql1:= " CreateUserId = '" + this.User.Id + "' or CommercialNo='"+registerUser.CommercialNo+"'"
  691. svc.GetEntity(&company,sql1)
  692. if supplierId != "0" {
  693. where = where + " and SupplierId=" + supplierId
  694. } else {
  695. where = where + " and SupplierId=" + strconv.Itoa(company.Id)
  696. }
  697. if subfilename != "" {
  698. where = where + " and NeedFileType like '%" + subfilename + "%'"
  699. }
  700. if createOn != "" {
  701. dates := strings.Split(createOn, ",")
  702. if len(dates) == 2 {
  703. minDate := dates[0]
  704. maxDate := dates[1]
  705. where = where + " and EffectDate>='" + minDate + "' and EffectDate<='" + maxDate + "'"
  706. }
  707. }
  708. total := svc.GetPagingEntitiesWithoutAccCode(page.CurrentPage, page.Size, orderby, asc, &list, where)
  709. var datainfo DataInfo
  710. datainfo.Items = list
  711. datainfo.CurrentItemCount = total
  712. this.Data["json"] = &datainfo
  713. this.ServeJSON()
  714. }
  715. // @Title 获取列表
  716. // @Description
  717. // @Success 200 {object}
  718. // @router /totallist [get]
  719. func (this *SelectController) GetTotalList() {
  720. //获取分页信息
  721. page := this.GetPageInfoForm()
  722. where := "0"
  723. orderby := "Id"
  724. asc := false
  725. Order := this.GetString("Order")
  726. Prop := this.GetString("Prop")
  727. if Order != "" && Prop != "" {
  728. orderby = Prop
  729. if Order == "asc" {
  730. asc = true
  731. }
  732. }
  733. Years := this.GetString("Years")
  734. if Years != "" {
  735. where = Years
  736. }
  737. //CreateOn := this.GetString("CreateOn")
  738. //
  739. //if CreateOn != "" {
  740. // dates := strings.Split(CreateOn, ",")
  741. // if len(dates) == 2 {
  742. // minDate := dates[0]
  743. // maxDate := dates[1]
  744. // where = where + " and ValidityTo>='" + minDate + "' and ValidityTo<='" + maxDate + "'"
  745. // }
  746. //}
  747. svc := selectbusiness.GetSelectService(utils.DBE)
  748. var list []selectbusiness.TotalCount
  749. svc.GetTotalInMonth(orderby, asc, &list, where)
  750. var datainfo DataInfo
  751. datainfo.Items = list
  752. datainfo.PageIndex = page.CurrentPage
  753. datainfo.ItemsPerPage = page.Size
  754. this.Data["json"] = &datainfo
  755. this.ServeJSON()
  756. }