supplier.go 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. package oilsupplier
  2. import (
  3. "encoding/json"
  4. "strconv"
  5. "strings"
  6. "time"
  7. "dashoo.cn/backend/api/business/baseUser"
  8. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  9. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  10. . "dashoo.cn/backend/api/controllers"
  11. "dashoo.cn/business/userRole"
  12. "dashoo.cn/utils"
  13. "github.com/go-xorm/xorm"
  14. )
  15. type OilSupplierController struct {
  16. BaseController
  17. }
  18. // @Title 获取列表
  19. // @Description get user by token
  20. // @Success 200 {object} []supplier.OilSupplier
  21. // @router /list [get]
  22. func (this *OilSupplierController) GetEntityList() {
  23. //获取分页信息
  24. page := this.GetPageInfoForm()
  25. where := " 1=1 "
  26. orderby := "Id"
  27. asc := false
  28. Order := this.GetString("Order")
  29. Prop := this.GetString("Prop")
  30. if Order != "" && Prop != "" {
  31. orderby = Prop
  32. if Order == "asc" {
  33. asc = true
  34. }
  35. }
  36. Id := this.GetString("Id")
  37. SupplierName := this.GetString("SupplierName")
  38. OilCertificateNo := this.GetString("OilCertificateNo")
  39. Grade := this.GetString("Grade")
  40. MgrUnit := this.GetString("MgrUnit")
  41. OperType := this.GetString("OperType")
  42. Country := this.GetString("Country")
  43. MaunAgent := this.GetString("MaunAgent")
  44. ConstructTeam := this.GetString("ConstructTeam")
  45. CommercialNo := this.GetString("CommercialNo")
  46. OrganCode := this.GetString("OrganCode")
  47. CountryTaxNo := this.GetString("CountryTaxNo")
  48. LocalTaxNo := this.GetString("LocalTaxNo")
  49. Address := this.GetString("Address")
  50. Province := this.GetString("Province")
  51. City := this.GetString("City")
  52. Street := this.GetString("Street")
  53. HouseNo := this.GetString("HouseNo")
  54. ZipCode := this.GetString("ZipCode")
  55. QualitySystemCert := this.GetString("QualitySystemCert")
  56. ProductQualityCert := this.GetString("ProductQualityCert")
  57. MaunLicense := this.GetString("MaunLicense")
  58. QualifCert := this.GetString("QualifCert")
  59. QualifCertLevel := this.GetString("QualifCertLevel")
  60. SafetyLicense := this.GetString("SafetyLicense")
  61. TechServiceLic := this.GetString("TechServiceLic")
  62. TJInNotify := this.GetString("TJInNotify")
  63. SpecIndustryCert := this.GetString("SpecIndustryCert")
  64. LegalPerson := this.GetString("LegalPerson")
  65. CategoryCode := this.GetString("CategoryCode")
  66. CategoryName := this.GetString("CategoryName")
  67. RegCapital := this.GetString("RegCapital")
  68. Currency := this.GetString("Currency")
  69. ContactName := this.GetString("ContactName")
  70. CompanyType := this.GetString("CompanyType")
  71. SetupTime := this.GetString("SetupTime")
  72. DepositBank := this.GetString("DepositBank")
  73. BankAccount := this.GetString("BankAccount")
  74. EMail := this.GetString("EMail")
  75. BankCreditRating := this.GetString("BankCreditRating")
  76. Mobile := this.GetString("Mobile")
  77. Telphone := this.GetString("Telphone")
  78. Fax := this.GetString("Fax")
  79. CompanyTel := this.GetString("CompanyTel")
  80. QQ := this.GetString("QQ")
  81. CompanyUrl := this.GetString("CompanyUrl")
  82. SpecSupplier := this.GetString("SpecSupplier")
  83. SpecTypeCode := this.GetString("SpecTypeCode")
  84. SpecTypeName := this.GetString("SpecTypeName")
  85. Remark := this.GetString("Remark")
  86. IsDelete := this.GetString("IsDelete")
  87. CreateOn := this.GetString("CreateOn")
  88. CreateUserId := this.GetString("CreateUserId")
  89. CreateBy := this.GetString("CreateBy")
  90. ModifiedOn := this.GetString("ModifiedOn")
  91. ModifiedUserId := this.GetString("ModifiedUserId")
  92. ModifiedBy := this.GetString("ModifiedBy")
  93. if Id != "" {
  94. where = where + " and Id like '%" + Id + "%'"
  95. }
  96. if SupplierName != "" {
  97. where = where + " and SupplierName like '%" + SupplierName + "%'"
  98. }
  99. if OilCertificateNo != "" {
  100. where = where + " and OilCertificateNo like '%" + OilCertificateNo + "%'"
  101. }
  102. if Grade != "" {
  103. where = where + " and Grade like '%" + Grade + "%'"
  104. }
  105. if MgrUnit != "" {
  106. where = where + " and MgrUnit like '%" + MgrUnit + "%'"
  107. }
  108. if OperType != "" {
  109. where = where + " and OperType like '%" + OperType + "%'"
  110. }
  111. if Country != "" {
  112. where = where + " and Country like '%" + Country + "%'"
  113. }
  114. if MaunAgent != "" {
  115. where = where + " and MaunAgent like '%" + MaunAgent + "%'"
  116. }
  117. if ConstructTeam != "" {
  118. where = where + " and ConstructTeam like '%" + ConstructTeam + "%'"
  119. }
  120. if CommercialNo != "" {
  121. where = where + " and CommercialNo like '%" + CommercialNo + "%'"
  122. }
  123. if OrganCode != "" {
  124. where = where + " and OrganCode like '%" + OrganCode + "%'"
  125. }
  126. if CountryTaxNo != "" {
  127. where = where + " and CountryTaxNo like '%" + CountryTaxNo + "%'"
  128. }
  129. if LocalTaxNo != "" {
  130. where = where + " and LocalTaxNo like '%" + LocalTaxNo + "%'"
  131. }
  132. if Address != "" {
  133. where = where + " and Address like '%" + Address + "%'"
  134. }
  135. if Province != "" {
  136. where = where + " and Province like '%" + Province + "%'"
  137. }
  138. if City != "" {
  139. where = where + " and City like '%" + City + "%'"
  140. }
  141. if Street != "" {
  142. where = where + " and Street like '%" + Street + "%'"
  143. }
  144. if HouseNo != "" {
  145. where = where + " and HouseNo like '%" + HouseNo + "%'"
  146. }
  147. if ZipCode != "" {
  148. where = where + " and ZipCode like '%" + ZipCode + "%'"
  149. }
  150. if QualitySystemCert != "" {
  151. where = where + " and QualitySystemCert like '%" + QualitySystemCert + "%'"
  152. }
  153. if ProductQualityCert != "" {
  154. where = where + " and ProductQualityCert like '%" + ProductQualityCert + "%'"
  155. }
  156. if MaunLicense != "" {
  157. where = where + " and MaunLicense like '%" + MaunLicense + "%'"
  158. }
  159. if QualifCert != "" {
  160. where = where + " and QualifCert like '%" + QualifCert + "%'"
  161. }
  162. if QualifCertLevel != "" {
  163. where = where + " and QualifCertLevel like '%" + QualifCertLevel + "%'"
  164. }
  165. if SafetyLicense != "" {
  166. where = where + " and SafetyLicense like '%" + SafetyLicense + "%'"
  167. }
  168. if TechServiceLic != "" {
  169. where = where + " and TechServiceLic like '%" + TechServiceLic + "%'"
  170. }
  171. if TJInNotify != "" {
  172. where = where + " and TJInNotify like '%" + TJInNotify + "%'"
  173. }
  174. if SpecIndustryCert != "" {
  175. where = where + " and SpecIndustryCert like '%" + SpecIndustryCert + "%'"
  176. }
  177. if LegalPerson != "" {
  178. where = where + " and LegalPerson like '%" + LegalPerson + "%'"
  179. }
  180. if CategoryCode != "" {
  181. where = where + " and CategoryCode like '%" + CategoryCode + "%'"
  182. }
  183. if CategoryName != "" {
  184. where = where + " and CategoryName like '%" + CategoryName + "%'"
  185. }
  186. if RegCapital != "" {
  187. where = where + " and RegCapital like '%" + RegCapital + "%'"
  188. }
  189. if Currency != "" {
  190. where = where + " and Currency like '%" + Currency + "%'"
  191. }
  192. if ContactName != "" {
  193. where = where + " and ContactName like '%" + ContactName + "%'"
  194. }
  195. if CompanyType != "" {
  196. where = where + " and CompanyType like '%" + CompanyType + "%'"
  197. }
  198. if SetupTime != "" {
  199. where = where + " and SetupTime like '%" + SetupTime + "%'"
  200. }
  201. if DepositBank != "" {
  202. where = where + " and DepositBank like '%" + DepositBank + "%'"
  203. }
  204. if BankAccount != "" {
  205. where = where + " and BankAccount like '%" + BankAccount + "%'"
  206. }
  207. if EMail != "" {
  208. where = where + " and EMail like '%" + EMail + "%'"
  209. }
  210. if BankCreditRating != "" {
  211. where = where + " and BankCreditRating like '%" + BankCreditRating + "%'"
  212. }
  213. if Mobile != "" {
  214. where = where + " and Mobile like '%" + Mobile + "%'"
  215. }
  216. if Telphone != "" {
  217. where = where + " and Telphone like '%" + Telphone + "%'"
  218. }
  219. if Fax != "" {
  220. where = where + " and Fax like '%" + Fax + "%'"
  221. }
  222. if CompanyTel != "" {
  223. where = where + " and CompanyTel like '%" + CompanyTel + "%'"
  224. }
  225. if QQ != "" {
  226. where = where + " and QQ like '%" + QQ + "%'"
  227. }
  228. if CompanyUrl != "" {
  229. where = where + " and CompanyUrl like '%" + CompanyUrl + "%'"
  230. }
  231. if SpecSupplier != "" {
  232. where = where + " and SpecSupplier like '%" + SpecSupplier + "%'"
  233. }
  234. if SpecTypeCode != "" {
  235. where = where + " and SpecTypeCode like '%" + SpecTypeCode + "%'"
  236. }
  237. if SpecTypeName != "" {
  238. where = where + " and SpecTypeName like '%" + SpecTypeName + "%'"
  239. }
  240. if Remark != "" {
  241. where = where + " and Remark like '%" + Remark + "%'"
  242. }
  243. if IsDelete != "" {
  244. where = where + " and IsDelete like '%" + IsDelete + "%'"
  245. }
  246. if CreateUserId != "" {
  247. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  248. }
  249. if CreateBy != "" {
  250. where = where + " and CreateBy like '%" + CreateBy + "%'"
  251. }
  252. if ModifiedOn != "" {
  253. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  254. }
  255. if ModifiedUserId != "" {
  256. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  257. }
  258. if ModifiedBy != "" {
  259. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  260. }
  261. if CreateOn != "" {
  262. dates := strings.Split(CreateOn, ",")
  263. if len(dates) == 2 {
  264. minDate := dates[0]
  265. maxDate := dates[1]
  266. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  267. }
  268. }
  269. svc := supplier.GetOilSupplierService(utils.DBE)
  270. var list []supplier.OilSupplier
  271. total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  272. var datainfo DataInfo
  273. datainfo.Items = list
  274. datainfo.CurrentItemCount = total
  275. datainfo.PageIndex = page.CurrentPage
  276. datainfo.ItemsPerPage = page.Size
  277. this.Data["json"] = &datainfo
  278. this.ServeJSON()
  279. }
  280. // @Title 获取列表
  281. // @Description get user by token
  282. // @Success 200 {object} []supplier.OilSupplier
  283. // @router /certlist [get]
  284. func (this *OilSupplierController) GetJoinCertEntityList() {
  285. //获取分页信息
  286. page := this.GetPageInfoForm()
  287. where := " 1=1 "
  288. orderby := "Id"
  289. asc := false
  290. Order := this.GetString("Order")
  291. Prop := this.GetString("Prop")
  292. if Order != "" && Prop != "" {
  293. orderby = Prop
  294. if Order == "asc" {
  295. asc = true
  296. }
  297. }
  298. Id := this.GetString("Id")
  299. SupplierName := this.GetString("SupplierName")
  300. OilCertificateNo := this.GetString("OilCertificateNo")
  301. Grade := this.GetString("Grade")
  302. MgrUnit := this.GetString("MgrUnit")
  303. OperType := this.GetString("OperType")
  304. Country := this.GetString("Country")
  305. MaunAgent := this.GetString("MaunAgent")
  306. ConstructTeam := this.GetString("ConstructTeam")
  307. CommercialNo := this.GetString("CommercialNo")
  308. OrganCode := this.GetString("OrganCode")
  309. CountryTaxNo := this.GetString("CountryTaxNo")
  310. LocalTaxNo := this.GetString("LocalTaxNo")
  311. Address := this.GetString("Address")
  312. Province := this.GetString("Province")
  313. City := this.GetString("City")
  314. Street := this.GetString("Street")
  315. HouseNo := this.GetString("HouseNo")
  316. ZipCode := this.GetString("ZipCode")
  317. QualitySystemCert := this.GetString("QualitySystemCert")
  318. ProductQualityCert := this.GetString("ProductQualityCert")
  319. MaunLicense := this.GetString("MaunLicense")
  320. QualifCert := this.GetString("QualifCert")
  321. QualifCertLevel := this.GetString("QualifCertLevel")
  322. SafetyLicense := this.GetString("SafetyLicense")
  323. TechServiceLic := this.GetString("TechServiceLic")
  324. TJInNotify := this.GetString("TJInNotify")
  325. SpecIndustryCert := this.GetString("SpecIndustryCert")
  326. LegalPerson := this.GetString("LegalPerson")
  327. CategoryCode := this.GetString("CategoryCode")
  328. CategoryName := this.GetString("CategoryName")
  329. RegCapital := this.GetString("RegCapital")
  330. Currency := this.GetString("Currency")
  331. ContactName := this.GetString("ContactName")
  332. CompanyType := this.GetString("CompanyType")
  333. SetupTime := this.GetString("SetupTime")
  334. DepositBank := this.GetString("DepositBank")
  335. BankAccount := this.GetString("BankAccount")
  336. EMail := this.GetString("EMail")
  337. BankCreditRating := this.GetString("BankCreditRating")
  338. Mobile := this.GetString("Mobile")
  339. Telphone := this.GetString("Telphone")
  340. Fax := this.GetString("Fax")
  341. CompanyTel := this.GetString("CompanyTel")
  342. QQ := this.GetString("QQ")
  343. CompanyUrl := this.GetString("CompanyUrl")
  344. SpecSupplier := this.GetString("SpecSupplier")
  345. SpecTypeCode := this.GetString("SpecTypeCode")
  346. SpecTypeName := this.GetString("SpecTypeName")
  347. Remark := this.GetString("Remark")
  348. CreateOn := this.GetString("CreateOn")
  349. SupplierTypeCode := this.GetString("SupplierTypeCode")
  350. if Id != "" {
  351. where = where + " and a.Id like '%" + Id + "%'"
  352. }
  353. if SupplierName != "" {
  354. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  355. }
  356. if OilCertificateNo != "" {
  357. where = where + " and a.OilCertificateNo like '%" + OilCertificateNo + "%'"
  358. }
  359. if Grade != "" {
  360. where = where + " and a.Grade like '%" + Grade + "%'"
  361. }
  362. if MgrUnit != "" {
  363. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  364. }
  365. if OperType != "" {
  366. where = where + " and a.OperType like '%" + OperType + "%'"
  367. }
  368. if Country != "" {
  369. where = where + " and a.Country like '%" + Country + "%'"
  370. }
  371. if MaunAgent != "" {
  372. where = where + " and a.MaunAgent like '%" + MaunAgent + "%'"
  373. }
  374. if ConstructTeam != "" {
  375. where = where + " and a.ConstructTeam like '%" + ConstructTeam + "%'"
  376. }
  377. if CommercialNo != "" {
  378. where = where + " and a.CommercialNo like '%" + CommercialNo + "%'"
  379. }
  380. if OrganCode != "" {
  381. where = where + " and a.OrganCode like '%" + OrganCode + "%'"
  382. }
  383. if CountryTaxNo != "" {
  384. where = where + " and a.CountryTaxNo like '%" + CountryTaxNo + "%'"
  385. }
  386. if LocalTaxNo != "" {
  387. where = where + " and a.LocalTaxNo like '%" + LocalTaxNo + "%'"
  388. }
  389. if Address != "" {
  390. where = where + " and a.Address like '%" + Address + "%'"
  391. }
  392. if Province != "" {
  393. where = where + " and a.Province like '%" + Province + "%'"
  394. }
  395. if City != "" {
  396. where = where + " and a.City like '%" + City + "%'"
  397. }
  398. if Street != "" {
  399. where = where + " and a.Street like '%" + Street + "%'"
  400. }
  401. if HouseNo != "" {
  402. where = where + " and a.HouseNo like '%" + HouseNo + "%'"
  403. }
  404. if ZipCode != "" {
  405. where = where + " and a.ZipCode like '%" + ZipCode + "%'"
  406. }
  407. if QualitySystemCert != "" {
  408. where = where + " and a.QualitySystemCert like '%" + QualitySystemCert + "%'"
  409. }
  410. if ProductQualityCert != "" {
  411. where = where + " and a.ProductQualityCert like '%" + ProductQualityCert + "%'"
  412. }
  413. if MaunLicense != "" {
  414. where = where + " and a.MaunLicense like '%" + MaunLicense + "%'"
  415. }
  416. if QualifCert != "" {
  417. where = where + " and a.QualifCert like '%" + QualifCert + "%'"
  418. }
  419. if QualifCertLevel != "" {
  420. where = where + " and a.QualifCertLevel like '%" + QualifCertLevel + "%'"
  421. }
  422. if SafetyLicense != "" {
  423. where = where + " and a.SafetyLicense like '%" + SafetyLicense + "%'"
  424. }
  425. if TechServiceLic != "" {
  426. where = where + " and a.TechServiceLic like '%" + TechServiceLic + "%'"
  427. }
  428. if TJInNotify != "" {
  429. where = where + " and a.TJInNotify like '%" + TJInNotify + "%'"
  430. }
  431. if SpecIndustryCert != "" {
  432. where = where + " and a.SpecIndustryCert like '%" + SpecIndustryCert + "%'"
  433. }
  434. if LegalPerson != "" {
  435. where = where + " and a.LegalPerson like '%" + LegalPerson + "%'"
  436. }
  437. if CategoryCode != "" {
  438. where = where + " and a.CategoryCode like '%" + CategoryCode + "%'"
  439. }
  440. if CategoryName != "" {
  441. where = where + " and a.CategoryName like '%" + CategoryName + "%'"
  442. }
  443. if RegCapital != "" {
  444. where = where + " and a.RegCapital like '%" + RegCapital + "%'"
  445. }
  446. if Currency != "" {
  447. where = where + " and a.Currency like '%" + Currency + "%'"
  448. }
  449. if ContactName != "" {
  450. where = where + " and a.ContactName like '%" + ContactName + "%'"
  451. }
  452. if CompanyType != "" {
  453. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  454. }
  455. if SetupTime != "" {
  456. where = where + " and a.SetupTime like '%" + SetupTime + "%'"
  457. }
  458. if DepositBank != "" {
  459. where = where + " and a.DepositBank like '%" + DepositBank + "%'"
  460. }
  461. if BankAccount != "" {
  462. where = where + " and a.BankAccount like '%" + BankAccount + "%'"
  463. }
  464. if EMail != "" {
  465. where = where + " and a.EMail like '%" + EMail + "%'"
  466. }
  467. if BankCreditRating != "" {
  468. where = where + " and a.BankCreditRating like '%" + BankCreditRating + "%'"
  469. }
  470. if Mobile != "" {
  471. where = where + " and a.Mobile like '%" + Mobile + "%'"
  472. }
  473. if Telphone != "" {
  474. where = where + " and a.Telphone like '%" + Telphone + "%'"
  475. }
  476. if Fax != "" {
  477. where = where + " and a.Fax like '%" + Fax + "%'"
  478. }
  479. if CompanyTel != "" {
  480. where = where + " and a.CompanyTel like '%" + CompanyTel + "%'"
  481. }
  482. if QQ != "" {
  483. where = where + " and a.QQ like '%" + QQ + "%'"
  484. }
  485. if CompanyUrl != "" {
  486. where = where + " and a.CompanyUrl like '%" + CompanyUrl + "%'"
  487. }
  488. if SpecSupplier != "" {
  489. where = where + " and a.SpecSupplier like '%" + SpecSupplier + "%'"
  490. }
  491. if SpecTypeCode != "" {
  492. where = where + " and a.SpecTypeCode like '%" + SpecTypeCode + "%'"
  493. }
  494. if SpecTypeName != "" {
  495. where = where + " and a.SpecTypeName like '%" + SpecTypeName + "%'"
  496. }
  497. if Remark != "" {
  498. where = where + " and a.Remark like '%" + Remark + "%'"
  499. }
  500. if CreateOn != "" {
  501. dates := strings.Split(CreateOn, ",")
  502. if len(dates) == 2 {
  503. minDate := dates[0]
  504. maxDate := dates[1]
  505. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  506. }
  507. }
  508. if SupplierTypeCode != "" {
  509. where = where + " and b.SupplierTypeCode = '" + SupplierTypeCode + "'"
  510. }
  511. svc := supplier.GetOilSupplierService(utils.DBE)
  512. var list []supplier.OilSupplierView
  513. var total int64
  514. if where == "" {
  515. where = " 1=1 "
  516. }
  517. //获取总记录数
  518. sqlCount := `select count(*) from ` + OilSupplierName + ` a `
  519. sqlCount += ` left join ` + OilSupplierCertName + " b on b.SupplierId = a.Id"
  520. sqlCount += ` where ` + where
  521. var sql string
  522. sql = `select a.*, b.Id as CertId, b.AccessCardNo, b.SupplierTypeCode, b.SupplierTypeName from ` + OilSupplierName + ` a `
  523. sql += ` left join ` + OilSupplierCertName + " b on b.SupplierId = a.Id"
  524. sql += ` where ` + where
  525. if asc {
  526. sql += ` order by ` + orderby + ` ASC `
  527. } else {
  528. sql += ` order by ` + orderby + ` DESC `
  529. }
  530. sql += ` limit ` + utils.ToStr((page.CurrentPage-1)*page.Size) + "," + utils.ToStr(page.Size)
  531. utils.DBE.SQL(sql).Find(&list)
  532. resultsSlice, _ := svc.DBE.Query(sqlCount)
  533. if len(resultsSlice) > 0 {
  534. results := resultsSlice[0]
  535. for _, value := range results {
  536. total, _ = strconv.ParseInt(string(value), 10, 64)
  537. break
  538. }
  539. }
  540. var datainfo DataInfo
  541. datainfo.Items = list
  542. datainfo.CurrentItemCount = total
  543. datainfo.PageIndex = page.CurrentPage
  544. datainfo.ItemsPerPage = page.Size
  545. this.Data["json"] = &datainfo
  546. this.ServeJSON()
  547. }
  548. // @Title 获取字典列表
  549. // @Description get user by token
  550. // @Success 200 {object} map[string]interface{}
  551. // @router /dictlist [get]
  552. func (this *OilSupplierController) GetDictList() {
  553. dictList := make(map[string]interface{})
  554. //dictSvc := items.GetItemsService(utils.DBE)
  555. userSvc := baseUser.GetBaseUserService(utils.DBE)
  556. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  557. //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", this.User.AccCode)
  558. var userEntity userRole.Base_User
  559. userSvc.GetEntityById(this.User.Id, &userEntity)
  560. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  561. //var dictCustomer []svccustomer.Customer
  562. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  563. //dictList["EntrustCorp"] = &dictCustomer
  564. var datainfo DataInfo
  565. datainfo.Items = dictList
  566. this.Data["json"] = &datainfo
  567. this.ServeJSON()
  568. }
  569. // @Title 获取实体
  570. // @Description 获取实体
  571. // @Success 200 {object} supplier.OilSupplier
  572. // @router /get/:id [get]
  573. func (this *OilSupplierController) GetEntity() {
  574. Id := this.Ctx.Input.Param(":id")
  575. var model supplier.OilSupplier
  576. svc := supplier.GetOilSupplierService(utils.DBE)
  577. svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  578. this.Data["json"] = &model
  579. this.ServeJSON()
  580. }
  581. // @Title 获取实体
  582. // @Description 获取实体
  583. // @Success 200 {object} supplier.OilSupplier
  584. // @router /getandcert/:certId [get]
  585. func (this *OilSupplierController) GetEntityAndCert() {
  586. Id := this.Ctx.Input.Param(":certId")
  587. var model supplier.OilSupplierView
  588. svc := supplier.GetOilSupplierService(utils.DBE)
  589. svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  590. var sql string
  591. sql = `select a.*, b.Id as CertId, b.AccessCardNo, b.SupplierTypeCode, b.SupplierTypeName, b.Step, b.WorkerTotal, b.ContractNum, b.UniversityNum, b.TechnicalNum, b.AboveProfNum, b.MiddleProfNum, b.NationalRegNum, b.NationalCertTotal, b.DesignerTotal, b.SkillerTotal from ` + OilSupplierName + ` a `
  592. sql += ` left join ` + OilSupplierCertName + " b on b.SupplierId = a.Id"
  593. sql += ` where b.Id ='` + Id + `'`
  594. utils.DBE.SQL(sql).Get(&model)
  595. this.Data["json"] = &model
  596. this.ServeJSON()
  597. }
  598. // @Title 添加
  599. // @Description 新增
  600. // @Param body body supplier.OilSupplier
  601. // @Success 200 {object} controllers.Request
  602. // @router /add [post]
  603. func (this *OilSupplierController) AddEntity() {
  604. var model supplier.OilSupplier
  605. var modelCert suppliercert.OilSupplierCert
  606. var modelCertVM suppliercert.OilSupplierVM
  607. var jsonBlob = this.Ctx.Input.RequestBody
  608. var session *xorm.Session
  609. session = utils.DBE.NewSession()
  610. svc := supplier.GetOilSupplierSession(session)
  611. svcCert := suppliercert.GetOilSupplierCertSession(session)
  612. json.Unmarshal(jsonBlob, &model)
  613. model.CreateOn = time.Now()
  614. model.CreateBy = this.User.Realname
  615. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  616. //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  617. defer session.Close()
  618. err := session.Begin()
  619. _, err = svc.InsertEntityBytbl(OilSupplierName, &model)
  620. if err != nil {
  621. session.Rollback()
  622. }
  623. modelCert.SupplierId = model.Id
  624. json.Unmarshal(jsonBlob, &modelCertVM)
  625. modelCert.SupplierTypeCode = modelCertVM.SupplierTypeCode
  626. modelCert.SupplierTypeName = modelCertVM.SupplierTypeName
  627. modelCert.Step = 1 //企业信息保存完成
  628. modelCert.CreateOn = time.Now()
  629. modelCert.CreateBy = this.User.Realname
  630. modelCert.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  631. _, err = svcCert.InsertEntityBytbl(OilSupplierCertName, &modelCert)
  632. if err != nil {
  633. session.Rollback()
  634. }
  635. // add Commit() after all actions
  636. err = session.Commit()
  637. var errinfo ErrorDataInfo
  638. if err == nil {
  639. //新增
  640. errinfo.Message = "添加成功!"
  641. errinfo.Code = 0
  642. errinfo.Item = strconv.Itoa(model.Id) + "_" + strconv.Itoa(modelCert.Id)
  643. this.Data["json"] = &errinfo
  644. this.ServeJSON()
  645. } else {
  646. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  647. errinfo.Code = -1
  648. this.Data["json"] = &errinfo
  649. this.ServeJSON()
  650. }
  651. }
  652. // @Title 修改实体
  653. // @Description 修改实体
  654. // @Param body body supplier.OilSupplier
  655. // @Success 200 {object} controllers.Request
  656. // @router /update/:id [post]
  657. func (this *OilSupplierController) UpdateEntity() {
  658. id := this.Ctx.Input.Param(":id")
  659. var errinfo ErrorInfo
  660. if id == "" {
  661. errinfo.Message = "操作失败!请求信息不完整"
  662. errinfo.Code = -2
  663. this.Data["json"] = &errinfo
  664. this.ServeJSON()
  665. return
  666. }
  667. var model supplier.OilSupplier
  668. svc := supplier.GetOilSupplierService(utils.DBE)
  669. var jsonBlob = this.Ctx.Input.RequestBody
  670. json.Unmarshal(jsonBlob, &model)
  671. model.ModifiedOn = time.Now()
  672. model.ModifiedBy = this.User.Realname
  673. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  674. cols := []string{
  675. "Id",
  676. "SupplierName",
  677. "OilCertificateNo",
  678. "Grade",
  679. "MgrUnit",
  680. "OperType",
  681. "Country",
  682. "MaunAgent",
  683. "ConstructTeam",
  684. "CommercialNo",
  685. "OrganCode",
  686. "CountryTaxNo",
  687. "LocalTaxNo",
  688. "Address",
  689. "Province",
  690. "City",
  691. "Street",
  692. "HouseNo",
  693. "ZipCode",
  694. "QualitySystemCert",
  695. "ProductQualityCert",
  696. "MaunLicense",
  697. "QualifCert",
  698. "QualifCertLevel",
  699. "SafetyLicense",
  700. "TechServiceLic",
  701. "TJInNotify",
  702. "SpecIndustryCert",
  703. "LegalPerson",
  704. "CategoryCode",
  705. "CategoryName",
  706. "RegCapital",
  707. "Currency",
  708. "ContactName",
  709. "CompanyType",
  710. "SetupTime",
  711. "DepositBank",
  712. "BankAccount",
  713. "EMail",
  714. "BankCreditRating",
  715. "Mobile",
  716. "Telphone",
  717. "Fax",
  718. "CompanyTel",
  719. "QQ",
  720. "CompanyUrl",
  721. "SpecSupplier",
  722. "SpecTypeCode",
  723. "SpecTypeName",
  724. "WorkerTotal",
  725. "ContractNum ",
  726. "UniversityNum",
  727. "TechnicalNum",
  728. "AboveProfNum",
  729. "MiddleProfNum",
  730. "NationalRegNum",
  731. "NationalCertTotal",
  732. "DesignerTotal",
  733. "SkillerTotal",
  734. "Remark",
  735. "IsDelete",
  736. "CreateOn",
  737. "CreateUserId",
  738. "CreateBy",
  739. "ModifiedOn",
  740. "ModifiedUserId",
  741. "ModifiedBy",
  742. }
  743. err := svc.UpdateEntityBytbl(OilSupplierName, id, &model, cols)
  744. if err == nil {
  745. errinfo.Message = "修改成功!"
  746. errinfo.Code = 0
  747. this.Data["json"] = &errinfo
  748. this.ServeJSON()
  749. } else {
  750. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  751. errinfo.Code = -1
  752. this.Data["json"] = &errinfo
  753. this.ServeJSON()
  754. }
  755. }
  756. // @Title 修改企业人员情况实体
  757. // @Description 修改实体
  758. // @Param body body supplier.OilSupplier
  759. // @Success 200 {object} controllers.Request
  760. // @router /updatenumber/:id [post]
  761. func (this *OilSupplierController) UpdateNumberEntity() {
  762. idGroup := this.Ctx.Input.Param(":id")
  763. //id := strings.Split(idGroup, "_")[0]
  764. certId := strings.Split(idGroup, "_")[1]
  765. var errinfo ErrorInfo
  766. if certId == "" {
  767. errinfo.Message = "操作失败!请求信息不完整"
  768. errinfo.Code = -2
  769. this.Data["json"] = &errinfo
  770. this.ServeJSON()
  771. return
  772. }
  773. var modelCert suppliercert.OilSupplierCert
  774. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  775. var jsonBlob = this.Ctx.Input.RequestBody
  776. json.Unmarshal(jsonBlob, &modelCert)
  777. modelCert.ModifiedOn = time.Now()
  778. modelCert.ModifiedBy = this.User.Realname
  779. modelCert.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  780. colcerts := []string{
  781. "Id",
  782. "WorkerTotal",
  783. "ContractNum ",
  784. "UniversityNum",
  785. "TechnicalNum",
  786. "AboveProfNum",
  787. "MiddleProfNum",
  788. "NationalRegNum",
  789. "NationalCertTotal",
  790. "DesignerTotal",
  791. "SkillerTotal",
  792. "ModifiedOn",
  793. "ModifiedUserId",
  794. "ModifiedBy",
  795. }
  796. if modelCert.Step <= 2 {
  797. modelCert.Step = 2 //完成企业基本信息
  798. colcerts = append(colcerts, "Step")
  799. }
  800. err := svcCert.UpdateEntityBytbl(OilSupplierCertName, certId, &modelCert, colcerts)
  801. if err == nil {
  802. errinfo.Message = "保存成功!"
  803. errinfo.Code = 0
  804. this.Data["json"] = &errinfo
  805. this.ServeJSON()
  806. } else {
  807. errinfo.Message = "保存失败!" + utils.AlertProcess(err.Error())
  808. errinfo.Code = -1
  809. this.Data["json"] = &errinfo
  810. this.ServeJSON()
  811. }
  812. }
  813. // @Title 删除单条信息
  814. // @Description
  815. // @Success 200 {object} ErrorInfo
  816. // @Failure 403 :id 为空
  817. // @router /delete/:Id [delete]
  818. func (this *OilSupplierController) DeleteEntity() {
  819. Id := this.Ctx.Input.Param(":Id")
  820. var errinfo ErrorInfo
  821. if Id == "" {
  822. errinfo.Message = "操作失败!请求信息不完整"
  823. errinfo.Code = -2
  824. this.Data["json"] = &errinfo
  825. this.ServeJSON()
  826. return
  827. }
  828. var model supplier.OilSupplier
  829. var entityempty supplier.OilSupplier
  830. svc := supplier.GetOilSupplierService(utils.DBE)
  831. opdesc := "删除-" + Id
  832. err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
  833. if err == nil {
  834. errinfo.Message = "删除成功"
  835. errinfo.Code = 0
  836. this.Data["json"] = &errinfo
  837. this.ServeJSON()
  838. } else {
  839. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  840. errinfo.Code = -1
  841. this.Data["json"] = &errinfo
  842. this.ServeJSON()
  843. }
  844. }
  845. // @Title 启动工作流
  846. // @Description 启动工作流
  847. // @Param body body supplier.OilSupplier
  848. // @Success 200 {object} controllers.Request
  849. // @router /workflow/:id [post]
  850. func (this *OilSupplierController) StartAudit() {
  851. //测试多实例工作流
  852. svcFlow := supplier.GetOilSupplierService(utils.DBE)
  853. svcFlow.StartAudit()
  854. }