select.go 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. package oilsupplier
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. // "fmt"
  6. "dashoo.cn/backend/api/business/oilsupplier/selectbusiness"
  7. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  8. . "dashoo.cn/backend/api/controllers"
  9. "dashoo.cn/utils"
  10. )
  11. type SelectController struct {
  12. BaseController
  13. }
  14. type RegCapitalRange struct {
  15. RegCapital1 string
  16. RegCapital2 string
  17. }
  18. type UpSearch struct {
  19. SupplierName string
  20. }
  21. type UpInfoSearch struct {
  22. SupplierName string
  23. SupplierTypeCode string
  24. SupplierTypeName string
  25. AllUpNum int
  26. HeGeNum int
  27. UnHeGeNum int
  28. Reason string
  29. }
  30. type NeedFileTypeStruct struct {
  31. NeedFileType []string
  32. }
  33. // @Title 获取所有
  34. // @Description
  35. // @Success 200 {object}
  36. // @router /getcompanylist [post]
  37. func (this *SelectController) GetTList() {
  38. var model supplier.OilSupplierView
  39. var model1 RegCapitalRange
  40. var model2 NeedFileTypeStruct
  41. var jsonBlob = this.Ctx.Input.RequestBody
  42. json.Unmarshal(jsonBlob, &model)
  43. json.Unmarshal(jsonBlob, &model1)
  44. json.Unmarshal(jsonBlob, &model2)
  45. // //获取分页信息
  46. page := this.GetPageInfoForm()
  47. where := " 1=1"
  48. orderby := "a.Id"
  49. asc := false
  50. Order := this.GetString("Order")
  51. Prop := this.GetString("Prop")
  52. fmt.Println(Prop)
  53. if Order != "" && Prop != "" {
  54. orderby = Prop
  55. if Order == "asc" {
  56. asc = true
  57. }
  58. }
  59. if model.AccessCardNo != "" {
  60. where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
  61. }
  62. if model.SupplierName != "" {
  63. where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
  64. }
  65. if model.SupplierTypeCode != "" {
  66. where = where + " and b.SupplierTypeCode = '" + model.SupplierTypeCode + "'"
  67. }
  68. if model.InFlag != "" {
  69. where = where + " and b.InFlag = '" + model.InFlag + "'"
  70. }
  71. if model.LegalPerson != "" {
  72. where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
  73. }
  74. if model.ContactName != "" {
  75. where = where + " and a.ContactName like '%" + model.ContactName + "%'"
  76. }
  77. if model.CommercialNo != "" {
  78. where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
  79. }
  80. if model.CompanyType != "" {
  81. where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
  82. }
  83. HseTraining := this.GetString("HseTraining")
  84. if HseTraining != "" {
  85. where = where + " and a.HseTraining = '" + HseTraining + "'"
  86. }
  87. BusinessScope := this.GetString("BusinessScope")
  88. if BusinessScope != "" {
  89. where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
  90. }
  91. OldSupplierName := this.GetString("OldSupplierName")
  92. if OldSupplierName != "" {
  93. where = where + " and c.OldSupplierName like '%" + OldSupplierName + "%'"
  94. }
  95. Province := this.GetString("Province")
  96. if Province != "" {
  97. where = where + " and a.Province = '" + Province + "'"
  98. }
  99. City := this.GetString("City")
  100. if City != "" {
  101. where = where + " and a.City = '" + City + "'"
  102. }
  103. Street := this.GetString("Street")
  104. if Street != "" {
  105. where = where + " and a.Street = '" + Street + "'"
  106. }
  107. Address := this.GetString("Address")
  108. if Address != "" {
  109. where = where + " and a.Address like '%" + Address + "%'"
  110. }
  111. LinkProvince := this.GetString("LinkProvince")
  112. if LinkProvince != "" {
  113. where = where + " and a.LinkProvince = '" + LinkProvince + "'"
  114. }
  115. LinkCity := this.GetString("LinkCity")
  116. if LinkCity != "" {
  117. where = where + " and a.LinkCity = '" + LinkCity + "'"
  118. }
  119. LinkStreet := this.GetString("LinkStreet")
  120. if LinkStreet != "" {
  121. where = where + " and a.LinkStreet = '" + LinkStreet + "'"
  122. }
  123. LinkAddress := this.GetString("LinkAddress")
  124. if LinkAddress != "" {
  125. where = where + " and a.LinkAddress like '%" + LinkAddress + "%'"
  126. }
  127. DepositBank := this.GetString("DepositBank")
  128. if DepositBank != "" {
  129. where = where + " and a.DepositBank like '%" + DepositBank + "%'"
  130. }
  131. SetupTime := this.GetString("SetupTime")
  132. if SetupTime != "" {
  133. where = where + " and a.SetupTime ='" + SetupTime + "'"
  134. }
  135. if model1.RegCapital1 != "" {
  136. where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
  137. }
  138. if model1.RegCapital2 != "" {
  139. where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
  140. }
  141. if model2.NeedFileType != nil && len(model2.NeedFileType) > 0 {
  142. pararm := ""
  143. for i := 0; i < len(model2.NeedFileType); i++ {
  144. pararm = pararm + "'" + model2.NeedFileType[i] + "',"
  145. }
  146. fmt.Println(pararm[0 : len(pararm)-1])
  147. where = where + " and d.NeedFileType in (" + pararm[0:len(pararm)-1] + ")"
  148. }
  149. svc := selectbusiness.GetSelectService(utils.DBE)
  150. var list []supplier.OilSupplierView
  151. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName, OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  152. var datainfo DataInfo
  153. datainfo.Items = list
  154. datainfo.CurrentItemCount = total
  155. datainfo.PageIndex = page.CurrentPage
  156. datainfo.ItemsPerPage = page.Size
  157. this.Data["json"] = &datainfo
  158. this.ServeJSON()
  159. }
  160. // @Title 获取所有
  161. // @Description
  162. // @Success 200 {object}
  163. // @router /up [post]
  164. func (this *SelectController) Up() {
  165. var model UpSearch
  166. var jsonBlob = this.Ctx.Input.RequestBody
  167. json.Unmarshal(jsonBlob, &model)
  168. // //获取分页信息
  169. page := this.GetPageInfoForm()
  170. where := " 1=1"
  171. asc := false
  172. Order := this.GetString("Order")
  173. Prop := this.GetString("Prop")
  174. if Order != "" && Prop != "" {
  175. if Order == "asc" {
  176. asc = true
  177. }
  178. }
  179. if model.SupplierName != "" {
  180. where = where + " and SupplierName like '%" + model.SupplierName + "%'"
  181. }
  182. svc := selectbusiness.GetSelectService(utils.DBE)
  183. var list []UpInfoSearch
  184. total := svc.GetUp(OilSupplierName, OilSupplierCertName, OilSupplierCertSubName, page.CurrentPage, page.Size, Prop, asc, &list, where)
  185. var datainfo DataInfo
  186. datainfo.Items = list
  187. datainfo.CurrentItemCount = total
  188. datainfo.PageIndex = page.CurrentPage
  189. datainfo.ItemsPerPage = page.Size
  190. this.Data["json"] = &datainfo
  191. this.ServeJSON()
  192. }
  193. // @Title 获取所有资质名称
  194. // @Description
  195. // @Success 200 {object}
  196. // @router /getnftoptions [post]
  197. func (this *SelectController) GetNFTOptions() {
  198. svc := selectbusiness.GetSelectService(utils.DBE)
  199. var list []map[string]string
  200. sql := "select distinct(Name) from " + BaseTableHeader + ""
  201. list, _ = svc.DBE.QueryString(sql)
  202. var datainfo DataInfo
  203. datainfo.Items = list
  204. this.Data["json"] = &datainfo
  205. this.ServeJSON()
  206. }