select.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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/suppliercertappend"
  7. "encoding/json"
  8. // "fmt"
  9. "dashoo.cn/backend/api/business/oilsupplier/selectbusiness"
  10. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  11. . "dashoo.cn/backend/api/controllers"
  12. "dashoo.cn/utils"
  13. )
  14. type SelectController struct {
  15. BaseController
  16. }
  17. type UpSearch struct {
  18. FullName string
  19. }
  20. type UpInfoSearch struct {
  21. FullName string
  22. SupplierTypeName string
  23. HeGe int
  24. BuHeGe int
  25. ZongShu int
  26. Reason string
  27. }
  28. // @Title 获取所有
  29. // @Description
  30. // @Success 200 {object}
  31. // @router /getcompanylist [post]
  32. func (this *SelectController) GetTList() {
  33. var model supplier.OilSupplierSelect
  34. var model1 supplier.RegCapitalRange //注册资金范围
  35. //var model2 supplier.NeedFileTypeStruct //资质结构体
  36. var jsonBlob = this.Ctx.Input.RequestBody
  37. json.Unmarshal(jsonBlob, &model)
  38. json.Unmarshal(jsonBlob, &model1)
  39. //json.Unmarshal(jsonBlob, &model2)
  40. // //获取分页信息
  41. page := this.GetPageInfoForm()
  42. where := " 1=1 "
  43. orderby := "a.Id"
  44. asc := true
  45. Order := this.GetString("Order")
  46. Prop := this.GetString("Prop")
  47. if Order != "" && Prop != "" {
  48. orderby = Prop
  49. if Order == "desc" {
  50. asc = false
  51. }
  52. }
  53. //准入证号
  54. if model.AccessCardNo != "" {
  55. where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
  56. }
  57. //企业名称
  58. if model.SupplierName != "" {
  59. where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
  60. }
  61. if model.OldSupplierName != "" {
  62. where = where + " and OldSupplierName like '%" + model.OldSupplierName + "%'"
  63. }
  64. //准入类别(基建,物资,技术服务)
  65. if model.SupplierTypeCode != "" {
  66. where = where + " and b.SupplierTypeCode = '" + model.SupplierTypeCode + "'"
  67. }
  68. //准入标识 1 准入 2 暂停 3取消
  69. if model.InFlag != "" {
  70. where = where + " and b.InFlag = '" + model.InFlag + "'"
  71. }
  72. //法人
  73. if model.LegalPerson != "" {
  74. where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
  75. }
  76. //联系人
  77. if model.ContactName != "" {
  78. where = where + " and a.ContactName like '%" + model.ContactName + "%'"
  79. }
  80. //统一社会信用代码
  81. if model.CommercialNo != "" {
  82. where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
  83. }
  84. //开户银行
  85. if model.DepositBank != "" {
  86. where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
  87. }
  88. //HSE审查
  89. if model.HseTraining != "" {
  90. where = where + " and a.HseTraining = '" + model.HseTraining + "'"
  91. }
  92. //公司类型
  93. if model.CompanyType != "" {
  94. where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
  95. }
  96. //成立时间
  97. SetupTime := this.GetString("SetupTime")
  98. if SetupTime != "" {
  99. where = where + " and a.SetupTime ='" + SetupTime + "'"
  100. }
  101. //注册资金范围
  102. if model1.RegCapital1 != "" {
  103. where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
  104. }
  105. if model1.RegCapital2 != "" {
  106. where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
  107. }
  108. //注册省份
  109. if model.Province != "" {
  110. where = where + " and a.Province = '" + model.Province + "'"
  111. }
  112. //注册市
  113. if model.City != "" {
  114. where = where + " and a.City = '" + model.City + "'"
  115. }
  116. //注册区
  117. if model.Street != "" {
  118. where = where + " and a.Street = '" + model.Street + "'"
  119. }
  120. //注册详细地址
  121. if model.Address != "" {
  122. where = where + " and a.Address like '%" + model.Address + "%'"
  123. }
  124. if model.LinkProvince != "" {
  125. where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
  126. }
  127. if model.LinkCity != "" {
  128. where = where + " and a.LinkCity = '" + model.LinkCity + "'"
  129. }
  130. if model.LinkStreet != "" {
  131. where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
  132. }
  133. if model.LinkAddress != "" {
  134. where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
  135. }
  136. //营业范围
  137. if model.BusinessScope != "" {
  138. where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
  139. }
  140. //包含资质
  141. //if model2.NeedFileType != nil && len(model2.NeedFileType) > 0 {
  142. // pararm := ""
  143. // for i := 0; i < len(model2.NeedFileType); i++ {
  144. //
  145. // pararm = pararm + "'" + model2.NeedFileType[i] + "',"
  146. //
  147. // }
  148. // fmt.Println(pararm[0 : len(pararm)-1])
  149. // where = where + " and d.NeedFileType in (" + pararm[0:len(pararm)-1] + ")"
  150. //}
  151. having:=""
  152. //准入范围
  153. if model.CerSubName!="" {
  154. having = " having CerSubName like '%"+model.CerSubName+"%' "
  155. }
  156. //资质
  157. if model.NeedFileType!="" {
  158. having = " having NeedFileType like '%"+model.NeedFileType+"%' "
  159. }
  160. if model.CerSubName!=""&& model.NeedFileType!=""{
  161. having = " having CerSubName like '%"+model.CerSubName+"%' and NeedFileType like '%"+model.NeedFileType+"%' "
  162. }
  163. svc := selectbusiness.GetSelectService(utils.DBE)
  164. var list []supplier.OilSupplierSelect
  165. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName,OilSupplierCert2FileName , page.CurrentPage, page.Size, orderby, asc, &list, where,having)
  166. var datainfo DataInfo
  167. datainfo.Items = list
  168. datainfo.CurrentItemCount = total
  169. datainfo.PageIndex = page.CurrentPage
  170. datainfo.ItemsPerPage = page.Size
  171. this.Data["json"] = &datainfo
  172. this.ServeJSON()
  173. }
  174. // @Title 获取所有
  175. // @Description
  176. // @Success 200 {object}
  177. // @router /up [post]
  178. func (this *SelectController) Up() {
  179. var model UpSearch
  180. var jsonBlob = this.Ctx.Input.RequestBody
  181. json.Unmarshal(jsonBlob, &model)
  182. // //获取分页信息
  183. page := this.GetPageInfoForm()
  184. where := ""
  185. asc := false
  186. Order := this.GetString("Order")
  187. Prop := this.GetString("Prop")
  188. if Order != "" && Prop != "" {
  189. if Order == "asc" {
  190. asc = true
  191. }
  192. }
  193. if model.FullName != "" {
  194. where = where + " and (select FullName from Base_Organize where Id = a.CommitComId) like '%" + model.FullName + "%'"
  195. }
  196. svc := selectbusiness.GetSelectService(utils.DBE)
  197. var list []UpInfoSearch
  198. total := svc.GetUp( OilSupplierCertName , page.CurrentPage, page.Size, Prop, asc, &list, where)
  199. var datainfo DataInfo
  200. datainfo.Items = list
  201. datainfo.CurrentItemCount = total
  202. datainfo.PageIndex = page.CurrentPage
  203. datainfo.ItemsPerPage = page.Size
  204. this.Data["json"] = &datainfo
  205. this.ServeJSON()
  206. }
  207. // @Title 获取所有资质名称
  208. // @Description
  209. // @Success 200 {object}
  210. // @router /getnftoptions [post]
  211. func (this *SelectController) GetNFTOptions() {
  212. svc := selectbusiness.GetSelectService(utils.DBE)
  213. var list []map[string]string
  214. sql := "select distinct(Name) from " + BaseTableHeader + ""
  215. list, _ = svc.DBE.QueryString(sql)
  216. var datainfo DataInfo
  217. datainfo.Items = list
  218. this.Data["json"] = &datainfo
  219. this.ServeJSON()
  220. }
  221. // @Title 流程查询准入
  222. // @Description
  223. // @Success 200 {object}
  224. // @router /getprocessauditlist [get]
  225. func (this *SelectController) GetProcessAuditList() {
  226. //获取分页信息
  227. page := this.GetPageInfoForm()
  228. where := " 1=1 "
  229. orderby := "Id"
  230. asc := false
  231. Order := this.GetString("Order")
  232. Prop := this.GetString("Prop")
  233. if Order != "" && Prop != "" {
  234. orderby = Prop
  235. if Order == "asc" {
  236. asc = true
  237. }
  238. }
  239. tabinx := this.GetString("tabinx")
  240. supplierTypeCode := this.GetString("SupplierTypeCode")
  241. supplierName := this.GetString("SupplierName")
  242. //企业用户必须加创建人条件
  243. if this.User.IsCompanyUser == 1 {
  244. where = where + " and b.CreateUserId = '" + this.User.Id + "'"
  245. }
  246. if supplierTypeCode != "" {
  247. where = where + " and b.SupplierTypeCode like '%" + supplierTypeCode + "%'"
  248. }
  249. if supplierName != "" {
  250. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  251. }
  252. var total int64 = 0
  253. var datainfo DataInfo
  254. if tabinx == "0" {
  255. var list []supplier.OilSupplierView
  256. svc := supplier.GetOilSupplierService(utils.DBE)
  257. total = svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  258. datainfo.Items = list
  259. } else if tabinx == "1" {
  260. whereapp := "1=1"
  261. //企业用户必须加创建人条件
  262. if this.User.IsCompanyUser == 1 {
  263. whereapp = whereapp + " and CreateUserId = '" + this.User.Id + "'"
  264. }
  265. if supplierTypeCode != "" {
  266. whereapp = whereapp + " and AppendType like '%" + supplierTypeCode + "%'"
  267. }
  268. if supplierName != "" {
  269. whereapp = whereapp + " and SupplierName like '%" + supplierName + "%'"
  270. }
  271. var list []suppliercertappend.OilSupplierCertAppend
  272. svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  273. total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  274. datainfo.Items = list
  275. } else if tabinx == "2" {
  276. whereapp := "1=1"
  277. //企业用户必须加创建人条件
  278. if this.User.IsCompanyUser == 1 {
  279. whereapp = whereapp + " and CreateUserId = '" + this.User.Id + "'"
  280. }
  281. if supplierTypeCode != "" {
  282. whereapp = whereapp + " and SupplierTypeName like '%" + supplierTypeCode + "%'"
  283. }
  284. if supplierName != "" {
  285. whereapp = whereapp + " and SupplierName like '%" + supplierName + "%'"
  286. }
  287. var list []annualaudit.OilAnnualAudit
  288. svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  289. total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  290. datainfo.Items = list
  291. } else if tabinx == "3" {
  292. whereapp := "1=1"
  293. //企业用户必须加创建人条件
  294. if this.User.IsCompanyUser == 1 {
  295. whereapp = whereapp + " and CreateUserId = '" + this.User.Id + "'"
  296. }
  297. if supplierName != "" {
  298. whereapp = whereapp + " and SupplierName like '%" + supplierName + "%'"
  299. }
  300. var list []infochange.OilInfoChange
  301. svc := infochange.GetInfoChangeService(utils.DBE)
  302. total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  303. datainfo.Items = list
  304. } else if tabinx == "4" {
  305. whereapp := "1=1"
  306. //企业用户必须加创建人条件
  307. if this.User.IsCompanyUser == 1 {
  308. whereapp = whereapp + " and CreateUserId = '" + this.User.Id + "'"
  309. }
  310. if supplierName != "" {
  311. whereapp = whereapp + " and SupplierName like '%" + supplierName + "%'"
  312. }
  313. svc := qualchange.GetQualChangeService(utils.DBE)
  314. var list []qualchange.OilQualChangeMain
  315. total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  316. datainfo.Items = list
  317. }
  318. datainfo.CurrentItemCount = total
  319. datainfo.PageIndex = page.CurrentPage
  320. datainfo.ItemsPerPage = page.Size
  321. this.Data["json"] = &datainfo
  322. this.ServeJSON()
  323. }