supplier.go 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505
  1. package oilsupplier
  2. import (
  3. "encoding/json"
  4. "strconv"
  5. "strings"
  6. "time"
  7. "dashoo.cn/backend/api/business/auditsetting"
  8. "dashoo.cn/backend/api/business/organize"
  9. "dashoo.cn/business2/permission"
  10. "dashoo.cn/backend/api/business/workflow"
  11. "dashoo.cn/business2/areajson"
  12. "dashoo.cn/business2/items"
  13. "dashoo.cn/backend/api/business/baseUser"
  14. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  15. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  16. . "dashoo.cn/backend/api/controllers"
  17. "dashoo.cn/business2/userRole"
  18. "dashoo.cn/utils"
  19. "github.com/go-xorm/xorm"
  20. )
  21. type OilSupplierController struct {
  22. BaseController
  23. }
  24. // @Title 获取列表
  25. // @Description get user by token
  26. // @Success 200 {object} []supplier.OilSupplier
  27. // @router /list [get]
  28. func (this *OilSupplierController) GetEntityList() {
  29. //获取分页信息
  30. page := this.GetPageInfoForm()
  31. where := " 1=1 "
  32. orderby := "Id"
  33. asc := false
  34. Order := this.GetString("Order")
  35. Prop := this.GetString("Prop")
  36. if Order != "" && Prop != "" {
  37. orderby = Prop
  38. if Order == "asc" {
  39. asc = true
  40. }
  41. }
  42. Id := this.GetString("Id")
  43. SupplierName := this.GetString("SupplierName")
  44. OilCertificateNo := this.GetString("OilCertificateNo")
  45. Grade := this.GetString("Grade")
  46. MgrUnit := this.GetString("MgrUnit")
  47. OperType := this.GetString("OperType")
  48. Country := this.GetString("Country")
  49. MaunAgent := this.GetString("MaunAgent")
  50. ConstructTeam := this.GetString("ConstructTeam")
  51. CommercialNo := this.GetString("CommercialNo")
  52. OrganCode := this.GetString("OrganCode")
  53. CountryTaxNo := this.GetString("CountryTaxNo")
  54. LocalTaxNo := this.GetString("LocalTaxNo")
  55. Address := this.GetString("Address")
  56. Province := this.GetString("Province")
  57. City := this.GetString("City")
  58. Street := this.GetString("Street")
  59. HouseNo := this.GetString("HouseNo")
  60. ZipCode := this.GetString("ZipCode")
  61. QualitySystemCert := this.GetString("QualitySystemCert")
  62. ProductQualityCert := this.GetString("ProductQualityCert")
  63. MaunLicense := this.GetString("MaunLicense")
  64. QualifCert := this.GetString("QualifCert")
  65. QualifCertLevel := this.GetString("QualifCertLevel")
  66. SafetyLicense := this.GetString("SafetyLicense")
  67. TechServiceLic := this.GetString("TechServiceLic")
  68. TJInNotify := this.GetString("TJInNotify")
  69. SpecIndustryCert := this.GetString("SpecIndustryCert")
  70. LegalPerson := this.GetString("LegalPerson")
  71. CategoryCode := this.GetString("CategoryCode")
  72. CategoryName := this.GetString("CategoryName")
  73. RegCapital := this.GetString("RegCapital")
  74. Currency := this.GetString("Currency")
  75. ContactName := this.GetString("ContactName")
  76. CompanyType := this.GetString("CompanyType")
  77. SetupTime := this.GetString("SetupTime")
  78. DepositBank := this.GetString("DepositBank")
  79. BankAccount := this.GetString("BankAccount")
  80. EMail := this.GetString("EMail")
  81. BankCreditRating := this.GetString("BankCreditRating")
  82. Mobile := this.GetString("Mobile")
  83. Telphone := this.GetString("Telphone")
  84. Fax := this.GetString("Fax")
  85. CompanyTel := this.GetString("CompanyTel")
  86. QQ := this.GetString("QQ")
  87. CompanyUrl := this.GetString("CompanyUrl")
  88. SpecSupplier := this.GetString("SpecSupplier")
  89. SpecTypeCode := this.GetString("SpecTypeCode")
  90. SpecTypeName := this.GetString("SpecTypeName")
  91. Remark := this.GetString("Remark")
  92. IsDelete := this.GetString("IsDelete")
  93. CreateOn := this.GetString("CreateOn")
  94. CreateUserId := this.GetString("CreateUserId")
  95. CreateBy := this.GetString("CreateBy")
  96. ModifiedOn := this.GetString("ModifiedOn")
  97. ModifiedUserId := this.GetString("ModifiedUserId")
  98. ModifiedBy := this.GetString("ModifiedBy")
  99. if Id != "" {
  100. where = where + " and Id like '%" + Id + "%'"
  101. }
  102. if SupplierName != "" {
  103. where = where + " and SupplierName like '%" + SupplierName + "%'"
  104. }
  105. if OilCertificateNo != "" {
  106. where = where + " and OilCertificateNo like '%" + OilCertificateNo + "%'"
  107. }
  108. if Grade != "" {
  109. where = where + " and Grade like '%" + Grade + "%'"
  110. }
  111. if MgrUnit != "" {
  112. where = where + " and MgrUnit like '%" + MgrUnit + "%'"
  113. }
  114. if OperType != "" {
  115. where = where + " and OperType like '%" + OperType + "%'"
  116. }
  117. if Country != "" {
  118. where = where + " and Country like '%" + Country + "%'"
  119. }
  120. if MaunAgent != "" {
  121. where = where + " and MaunAgent like '%" + MaunAgent + "%'"
  122. }
  123. if ConstructTeam != "" {
  124. where = where + " and ConstructTeam like '%" + ConstructTeam + "%'"
  125. }
  126. if CommercialNo != "" {
  127. where = where + " and CommercialNo like '%" + CommercialNo + "%'"
  128. }
  129. if OrganCode != "" {
  130. where = where + " and OrganCode like '%" + OrganCode + "%'"
  131. }
  132. if CountryTaxNo != "" {
  133. where = where + " and CountryTaxNo like '%" + CountryTaxNo + "%'"
  134. }
  135. if LocalTaxNo != "" {
  136. where = where + " and LocalTaxNo like '%" + LocalTaxNo + "%'"
  137. }
  138. if Address != "" {
  139. where = where + " and Address like '%" + Address + "%'"
  140. }
  141. if Province != "" {
  142. where = where + " and Province like '%" + Province + "%'"
  143. }
  144. if City != "" {
  145. where = where + " and City like '%" + City + "%'"
  146. }
  147. if Street != "" {
  148. where = where + " and Street like '%" + Street + "%'"
  149. }
  150. if HouseNo != "" {
  151. where = where + " and HouseNo like '%" + HouseNo + "%'"
  152. }
  153. if ZipCode != "" {
  154. where = where + " and ZipCode like '%" + ZipCode + "%'"
  155. }
  156. if QualitySystemCert != "" {
  157. where = where + " and QualitySystemCert like '%" + QualitySystemCert + "%'"
  158. }
  159. if ProductQualityCert != "" {
  160. where = where + " and ProductQualityCert like '%" + ProductQualityCert + "%'"
  161. }
  162. if MaunLicense != "" {
  163. where = where + " and MaunLicense like '%" + MaunLicense + "%'"
  164. }
  165. if QualifCert != "" {
  166. where = where + " and QualifCert like '%" + QualifCert + "%'"
  167. }
  168. if QualifCertLevel != "" {
  169. where = where + " and QualifCertLevel like '%" + QualifCertLevel + "%'"
  170. }
  171. if SafetyLicense != "" {
  172. where = where + " and SafetyLicense like '%" + SafetyLicense + "%'"
  173. }
  174. if TechServiceLic != "" {
  175. where = where + " and TechServiceLic like '%" + TechServiceLic + "%'"
  176. }
  177. if TJInNotify != "" {
  178. where = where + " and TJInNotify like '%" + TJInNotify + "%'"
  179. }
  180. if SpecIndustryCert != "" {
  181. where = where + " and SpecIndustryCert like '%" + SpecIndustryCert + "%'"
  182. }
  183. if LegalPerson != "" {
  184. where = where + " and LegalPerson like '%" + LegalPerson + "%'"
  185. }
  186. if CategoryCode != "" {
  187. where = where + " and CategoryCode like '%" + CategoryCode + "%'"
  188. }
  189. if CategoryName != "" {
  190. where = where + " and CategoryName like '%" + CategoryName + "%'"
  191. }
  192. if RegCapital != "" {
  193. where = where + " and RegCapital like '%" + RegCapital + "%'"
  194. }
  195. if Currency != "" {
  196. where = where + " and Currency like '%" + Currency + "%'"
  197. }
  198. if ContactName != "" {
  199. where = where + " and ContactName like '%" + ContactName + "%'"
  200. }
  201. if CompanyType != "" {
  202. where = where + " and CompanyType like '%" + CompanyType + "%'"
  203. }
  204. if SetupTime != "" {
  205. where = where + " and SetupTime like '%" + SetupTime + "%'"
  206. }
  207. if DepositBank != "" {
  208. where = where + " and DepositBank like '%" + DepositBank + "%'"
  209. }
  210. if BankAccount != "" {
  211. where = where + " and BankAccount like '%" + BankAccount + "%'"
  212. }
  213. if EMail != "" {
  214. where = where + " and EMail like '%" + EMail + "%'"
  215. }
  216. if BankCreditRating != "" {
  217. where = where + " and BankCreditRating like '%" + BankCreditRating + "%'"
  218. }
  219. if Mobile != "" {
  220. where = where + " and Mobile like '%" + Mobile + "%'"
  221. }
  222. if Telphone != "" {
  223. where = where + " and Telphone like '%" + Telphone + "%'"
  224. }
  225. if Fax != "" {
  226. where = where + " and Fax like '%" + Fax + "%'"
  227. }
  228. if CompanyTel != "" {
  229. where = where + " and CompanyTel like '%" + CompanyTel + "%'"
  230. }
  231. if QQ != "" {
  232. where = where + " and QQ like '%" + QQ + "%'"
  233. }
  234. if CompanyUrl != "" {
  235. where = where + " and CompanyUrl like '%" + CompanyUrl + "%'"
  236. }
  237. if SpecSupplier != "" {
  238. where = where + " and SpecSupplier like '%" + SpecSupplier + "%'"
  239. }
  240. if SpecTypeCode != "" {
  241. where = where + " and SpecTypeCode like '%" + SpecTypeCode + "%'"
  242. }
  243. if SpecTypeName != "" {
  244. where = where + " and SpecTypeName like '%" + SpecTypeName + "%'"
  245. }
  246. if Remark != "" {
  247. where = where + " and Remark like '%" + Remark + "%'"
  248. }
  249. if IsDelete != "" {
  250. where = where + " and IsDelete like '%" + IsDelete + "%'"
  251. }
  252. if CreateUserId != "" {
  253. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  254. }
  255. if CreateBy != "" {
  256. where = where + " and CreateBy like '%" + CreateBy + "%'"
  257. }
  258. if ModifiedOn != "" {
  259. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  260. }
  261. if ModifiedUserId != "" {
  262. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  263. }
  264. if ModifiedBy != "" {
  265. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  266. }
  267. if CreateOn != "" {
  268. dates := strings.Split(CreateOn, ",")
  269. if len(dates) == 2 {
  270. minDate := dates[0]
  271. maxDate := dates[1]
  272. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  273. }
  274. }
  275. //企业用户必须加创建人条件
  276. if this.User.IsCompanyUser == 1 {
  277. where = where + " and CreateUserId = '" + this.User.Id + "'"
  278. } else {
  279. //超级管理员和有查看所有数据权限的用户不加条件
  280. svcPerm := permission.GetPermissionService(utils.DBE)
  281. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  282. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  283. where = where + " and CreateUserId = '" + this.User.Id + "'"
  284. }
  285. }
  286. svc := supplier.GetOilSupplierService(utils.DBE)
  287. var list []supplier.OilSupplier
  288. total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  289. var datainfo DataInfo
  290. datainfo.Items = list
  291. datainfo.CurrentItemCount = total
  292. datainfo.PageIndex = page.CurrentPage
  293. datainfo.ItemsPerPage = page.Size
  294. this.Data["json"] = &datainfo
  295. this.ServeJSON()
  296. }
  297. // @Title 获取列表
  298. // @Description get user by token
  299. // @Success 200 {object} []supplier.OilSupplier
  300. // @router /certlist [get]
  301. func (this *OilSupplierController) GetJoinCertEntityList() {
  302. //获取分页信息
  303. page := this.GetPageInfoForm()
  304. where := " 1=1 "
  305. orderby := "Id"
  306. asc := false
  307. Order := this.GetString("Order")
  308. Prop := this.GetString("Prop")
  309. if Order != "" && Prop != "" {
  310. orderby = Prop
  311. if Order == "asc" {
  312. asc = true
  313. }
  314. }
  315. Id := this.GetString("Id")
  316. SupplierName := this.GetString("SupplierName")
  317. OilCertificateNo := this.GetString("OilCertificateNo")
  318. Grade := this.GetString("Grade")
  319. MgrUnit := this.GetString("MgrUnit")
  320. OperType := this.GetString("OperType")
  321. Country := this.GetString("Country")
  322. MaunAgent := this.GetString("MaunAgent")
  323. ConstructTeam := this.GetString("ConstructTeam")
  324. CommercialNo := this.GetString("CommercialNo")
  325. OrganCode := this.GetString("OrganCode")
  326. CountryTaxNo := this.GetString("CountryTaxNo")
  327. LocalTaxNo := this.GetString("LocalTaxNo")
  328. Address := this.GetString("Address")
  329. Province := this.GetString("Province")
  330. City := this.GetString("City")
  331. Street := this.GetString("Street")
  332. HouseNo := this.GetString("HouseNo")
  333. ZipCode := this.GetString("ZipCode")
  334. QualitySystemCert := this.GetString("QualitySystemCert")
  335. ProductQualityCert := this.GetString("ProductQualityCert")
  336. MaunLicense := this.GetString("MaunLicense")
  337. QualifCert := this.GetString("QualifCert")
  338. QualifCertLevel := this.GetString("QualifCertLevel")
  339. SafetyLicense := this.GetString("SafetyLicense")
  340. TechServiceLic := this.GetString("TechServiceLic")
  341. TJInNotify := this.GetString("TJInNotify")
  342. SpecIndustryCert := this.GetString("SpecIndustryCert")
  343. LegalPerson := this.GetString("LegalPerson")
  344. CategoryCode := this.GetString("CategoryCode")
  345. CategoryName := this.GetString("CategoryName")
  346. RegCapital := this.GetString("RegCapital")
  347. Currency := this.GetString("Currency")
  348. ContactName := this.GetString("ContactName")
  349. CompanyType := this.GetString("CompanyType")
  350. SetupTime := this.GetString("SetupTime")
  351. DepositBank := this.GetString("DepositBank")
  352. BankAccount := this.GetString("BankAccount")
  353. EMail := this.GetString("EMail")
  354. BankCreditRating := this.GetString("BankCreditRating")
  355. Mobile := this.GetString("Mobile")
  356. Telphone := this.GetString("Telphone")
  357. Fax := this.GetString("Fax")
  358. CompanyTel := this.GetString("CompanyTel")
  359. QQ := this.GetString("QQ")
  360. CompanyUrl := this.GetString("CompanyUrl")
  361. SpecSupplier := this.GetString("SpecSupplier")
  362. SpecTypeCode := this.GetString("SpecTypeCode")
  363. SpecTypeName := this.GetString("SpecTypeName")
  364. Remark := this.GetString("Remark")
  365. CreateOn := this.GetString("CreateOn")
  366. SupplierTypeCode := this.GetString("SupplierTypeCode")
  367. if Id != "" {
  368. where = where + " and a.Id like '%" + Id + "%'"
  369. }
  370. if SupplierName != "" {
  371. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  372. }
  373. if OilCertificateNo != "" {
  374. where = where + " and a.OilCertificateNo like '%" + OilCertificateNo + "%'"
  375. }
  376. if Grade != "" {
  377. where = where + " and a.Grade like '%" + Grade + "%'"
  378. }
  379. if MgrUnit != "" {
  380. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  381. }
  382. if OperType != "" {
  383. where = where + " and a.OperType like '%" + OperType + "%'"
  384. }
  385. if Country != "" {
  386. where = where + " and a.Country like '%" + Country + "%'"
  387. }
  388. if MaunAgent != "" {
  389. where = where + " and a.MaunAgent like '%" + MaunAgent + "%'"
  390. }
  391. if ConstructTeam != "" {
  392. where = where + " and a.ConstructTeam like '%" + ConstructTeam + "%'"
  393. }
  394. if CommercialNo != "" {
  395. where = where + " and a.CommercialNo like '%" + CommercialNo + "%'"
  396. }
  397. if OrganCode != "" {
  398. where = where + " and a.OrganCode like '%" + OrganCode + "%'"
  399. }
  400. if CountryTaxNo != "" {
  401. where = where + " and a.CountryTaxNo like '%" + CountryTaxNo + "%'"
  402. }
  403. if LocalTaxNo != "" {
  404. where = where + " and a.LocalTaxNo like '%" + LocalTaxNo + "%'"
  405. }
  406. if Address != "" {
  407. where = where + " and a.Address like '%" + Address + "%'"
  408. }
  409. if Province != "" {
  410. where = where + " and a.Province like '%" + Province + "%'"
  411. }
  412. if City != "" {
  413. where = where + " and a.City like '%" + City + "%'"
  414. }
  415. if Street != "" {
  416. where = where + " and a.Street like '%" + Street + "%'"
  417. }
  418. if HouseNo != "" {
  419. where = where + " and a.HouseNo like '%" + HouseNo + "%'"
  420. }
  421. if ZipCode != "" {
  422. where = where + " and a.ZipCode like '%" + ZipCode + "%'"
  423. }
  424. if QualitySystemCert != "" {
  425. where = where + " and a.QualitySystemCert like '%" + QualitySystemCert + "%'"
  426. }
  427. if ProductQualityCert != "" {
  428. where = where + " and a.ProductQualityCert like '%" + ProductQualityCert + "%'"
  429. }
  430. if MaunLicense != "" {
  431. where = where + " and a.MaunLicense like '%" + MaunLicense + "%'"
  432. }
  433. if QualifCert != "" {
  434. where = where + " and a.QualifCert like '%" + QualifCert + "%'"
  435. }
  436. if QualifCertLevel != "" {
  437. where = where + " and a.QualifCertLevel like '%" + QualifCertLevel + "%'"
  438. }
  439. if SafetyLicense != "" {
  440. where = where + " and a.SafetyLicense like '%" + SafetyLicense + "%'"
  441. }
  442. if TechServiceLic != "" {
  443. where = where + " and a.TechServiceLic like '%" + TechServiceLic + "%'"
  444. }
  445. if TJInNotify != "" {
  446. where = where + " and a.TJInNotify like '%" + TJInNotify + "%'"
  447. }
  448. if SpecIndustryCert != "" {
  449. where = where + " and a.SpecIndustryCert like '%" + SpecIndustryCert + "%'"
  450. }
  451. if LegalPerson != "" {
  452. where = where + " and a.LegalPerson like '%" + LegalPerson + "%'"
  453. }
  454. if CategoryCode != "" {
  455. where = where + " and a.CategoryCode like '%" + CategoryCode + "%'"
  456. }
  457. if CategoryName != "" {
  458. where = where + " and a.CategoryName like '%" + CategoryName + "%'"
  459. }
  460. if RegCapital != "" {
  461. where = where + " and a.RegCapital like '%" + RegCapital + "%'"
  462. }
  463. if Currency != "" {
  464. where = where + " and a.Currency like '%" + Currency + "%'"
  465. }
  466. if ContactName != "" {
  467. where = where + " and a.ContactName like '%" + ContactName + "%'"
  468. }
  469. if CompanyType != "" {
  470. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  471. }
  472. if SetupTime != "" {
  473. where = where + " and a.SetupTime like '%" + SetupTime + "%'"
  474. }
  475. if DepositBank != "" {
  476. where = where + " and a.DepositBank like '%" + DepositBank + "%'"
  477. }
  478. if BankAccount != "" {
  479. where = where + " and a.BankAccount like '%" + BankAccount + "%'"
  480. }
  481. if EMail != "" {
  482. where = where + " and a.EMail like '%" + EMail + "%'"
  483. }
  484. if BankCreditRating != "" {
  485. where = where + " and a.BankCreditRating like '%" + BankCreditRating + "%'"
  486. }
  487. if Mobile != "" {
  488. where = where + " and a.Mobile like '%" + Mobile + "%'"
  489. }
  490. if Telphone != "" {
  491. where = where + " and a.Telphone like '%" + Telphone + "%'"
  492. }
  493. if Fax != "" {
  494. where = where + " and a.Fax like '%" + Fax + "%'"
  495. }
  496. if CompanyTel != "" {
  497. where = where + " and a.CompanyTel like '%" + CompanyTel + "%'"
  498. }
  499. if QQ != "" {
  500. where = where + " and a.QQ like '%" + QQ + "%'"
  501. }
  502. if CompanyUrl != "" {
  503. where = where + " and a.CompanyUrl like '%" + CompanyUrl + "%'"
  504. }
  505. if SpecSupplier != "" {
  506. where = where + " and a.SpecSupplier like '%" + SpecSupplier + "%'"
  507. }
  508. if SpecTypeCode != "" {
  509. where = where + " and a.SpecTypeCode like '%" + SpecTypeCode + "%'"
  510. }
  511. if SpecTypeName != "" {
  512. where = where + " and a.SpecTypeName like '%" + SpecTypeName + "%'"
  513. }
  514. if Remark != "" {
  515. where = where + " and a.Remark like '%" + Remark + "%'"
  516. }
  517. if CreateOn != "" {
  518. dates := strings.Split(CreateOn, ",")
  519. if len(dates) == 2 {
  520. minDate := dates[0]
  521. maxDate := dates[1]
  522. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  523. }
  524. }
  525. if SupplierTypeCode != "" {
  526. where = where + " and b.SupplierTypeCode = '" + SupplierTypeCode + "'"
  527. }
  528. //企业用户只看自己的数据记录
  529. /*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
  530. extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
  531. if extOrganizeId == this.User.DepartmentId {
  532. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  533. }*/
  534. //企业用户必须加创建人条件
  535. if this.User.IsCompanyUser == 1 {
  536. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  537. } else {
  538. //超级管理员和有查看所有数据权限的用户不加条件
  539. svcPerm := permission.GetPermissionService(utils.DBE)
  540. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  541. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  542. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  543. }
  544. }
  545. svc := supplier.GetOilSupplierService(utils.DBE)
  546. var list []supplier.OilSupplierView
  547. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  548. var datainfo DataInfo
  549. datainfo.Items = list
  550. datainfo.CurrentItemCount = total
  551. datainfo.PageIndex = page.CurrentPage
  552. datainfo.ItemsPerPage = page.Size
  553. this.Data["json"] = &datainfo
  554. this.ServeJSON()
  555. }
  556. // @Title 获取列表
  557. // @Description get user by token
  558. // @Success 200 {object} []supplier.OilSupplierView
  559. // @router /mytasks [get]
  560. func (this *OilSupplierController) GetMyTaskEntityList() {
  561. //获取分页信息
  562. page := this.GetPageInfoForm()
  563. where := " 1=1 "
  564. orderby := "Id"
  565. asc := false
  566. Order := this.GetString("Order")
  567. //Statustype := this.GetString("Statustype")
  568. //if Statustype != "" {
  569. // where = " 1=1 and b.Status =" + Statustype
  570. //}
  571. where = where + " and b.Status>0"
  572. Prop := this.GetString("Prop")
  573. if Order != "" && Prop != "" {
  574. orderby = Prop
  575. if Order == "asc" {
  576. asc = true
  577. }
  578. }
  579. Id := this.GetString("Id")
  580. SupplierName := this.GetString("SupplierName")
  581. OilCertificateNo := this.GetString("OilCertificateNo")
  582. Grade := this.GetString("Grade")
  583. MgrUnit := this.GetString("MgrUnit")
  584. OperType := this.GetString("OperType")
  585. Country := this.GetString("Country")
  586. MaunAgent := this.GetString("MaunAgent")
  587. ConstructTeam := this.GetString("ConstructTeam")
  588. CommercialNo := this.GetString("CommercialNo")
  589. OrganCode := this.GetString("OrganCode")
  590. CountryTaxNo := this.GetString("CountryTaxNo")
  591. LocalTaxNo := this.GetString("LocalTaxNo")
  592. Address := this.GetString("Address")
  593. Province := this.GetString("Province")
  594. City := this.GetString("City")
  595. Street := this.GetString("Street")
  596. HouseNo := this.GetString("HouseNo")
  597. ZipCode := this.GetString("ZipCode")
  598. QualitySystemCert := this.GetString("QualitySystemCert")
  599. ProductQualityCert := this.GetString("ProductQualityCert")
  600. MaunLicense := this.GetString("MaunLicense")
  601. QualifCert := this.GetString("QualifCert")
  602. QualifCertLevel := this.GetString("QualifCertLevel")
  603. SafetyLicense := this.GetString("SafetyLicense")
  604. TechServiceLic := this.GetString("TechServiceLic")
  605. TJInNotify := this.GetString("TJInNotify")
  606. SpecIndustryCert := this.GetString("SpecIndustryCert")
  607. LegalPerson := this.GetString("LegalPerson")
  608. CategoryCode := this.GetString("CategoryCode")
  609. CategoryName := this.GetString("CategoryName")
  610. RegCapital := this.GetString("RegCapital")
  611. Currency := this.GetString("Currency")
  612. ContactName := this.GetString("ContactName")
  613. CompanyType := this.GetString("CompanyType")
  614. SetupTime := this.GetString("SetupTime")
  615. DepositBank := this.GetString("DepositBank")
  616. BankAccount := this.GetString("BankAccount")
  617. EMail := this.GetString("EMail")
  618. BankCreditRating := this.GetString("BankCreditRating")
  619. Mobile := this.GetString("Mobile")
  620. Telphone := this.GetString("Telphone")
  621. Fax := this.GetString("Fax")
  622. CompanyTel := this.GetString("CompanyTel")
  623. QQ := this.GetString("QQ")
  624. CompanyUrl := this.GetString("CompanyUrl")
  625. SpecSupplier := this.GetString("SpecSupplier")
  626. SpecTypeCode := this.GetString("SpecTypeCode")
  627. SpecTypeName := this.GetString("SpecTypeName")
  628. Remark := this.GetString("Remark")
  629. CreateOn := this.GetString("CreateOn")
  630. SupplierTypeCode := this.GetString("SupplierTypeCode")
  631. if Id != "" {
  632. where = where + " and a.Id like '%" + Id + "%'"
  633. }
  634. if SupplierName != "" {
  635. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  636. }
  637. if OilCertificateNo != "" {
  638. where = where + " and a.OilCertificateNo like '%" + OilCertificateNo + "%'"
  639. }
  640. if Grade != "" {
  641. where = where + " and a.Grade like '%" + Grade + "%'"
  642. }
  643. if MgrUnit != "" {
  644. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  645. }
  646. if OperType != "" {
  647. where = where + " and a.OperType like '%" + OperType + "%'"
  648. }
  649. if Country != "" {
  650. where = where + " and a.Country like '%" + Country + "%'"
  651. }
  652. if MaunAgent != "" {
  653. where = where + " and a.MaunAgent like '%" + MaunAgent + "%'"
  654. }
  655. if ConstructTeam != "" {
  656. where = where + " and a.ConstructTeam like '%" + ConstructTeam + "%'"
  657. }
  658. if CommercialNo != "" {
  659. where = where + " and a.CommercialNo like '%" + CommercialNo + "%'"
  660. }
  661. if OrganCode != "" {
  662. where = where + " and a.OrganCode like '%" + OrganCode + "%'"
  663. }
  664. if CountryTaxNo != "" {
  665. where = where + " and a.CountryTaxNo like '%" + CountryTaxNo + "%'"
  666. }
  667. if LocalTaxNo != "" {
  668. where = where + " and a.LocalTaxNo like '%" + LocalTaxNo + "%'"
  669. }
  670. if Address != "" {
  671. where = where + " and a.Address like '%" + Address + "%'"
  672. }
  673. if Province != "" {
  674. where = where + " and a.Province like '%" + Province + "%'"
  675. }
  676. if City != "" {
  677. where = where + " and a.City like '%" + City + "%'"
  678. }
  679. if Street != "" {
  680. where = where + " and a.Street like '%" + Street + "%'"
  681. }
  682. if HouseNo != "" {
  683. where = where + " and a.HouseNo like '%" + HouseNo + "%'"
  684. }
  685. if ZipCode != "" {
  686. where = where + " and a.ZipCode like '%" + ZipCode + "%'"
  687. }
  688. if QualitySystemCert != "" {
  689. where = where + " and a.QualitySystemCert like '%" + QualitySystemCert + "%'"
  690. }
  691. if ProductQualityCert != "" {
  692. where = where + " and a.ProductQualityCert like '%" + ProductQualityCert + "%'"
  693. }
  694. if MaunLicense != "" {
  695. where = where + " and a.MaunLicense like '%" + MaunLicense + "%'"
  696. }
  697. if QualifCert != "" {
  698. where = where + " and a.QualifCert like '%" + QualifCert + "%'"
  699. }
  700. if QualifCertLevel != "" {
  701. where = where + " and a.QualifCertLevel like '%" + QualifCertLevel + "%'"
  702. }
  703. if SafetyLicense != "" {
  704. where = where + " and a.SafetyLicense like '%" + SafetyLicense + "%'"
  705. }
  706. if TechServiceLic != "" {
  707. where = where + " and a.TechServiceLic like '%" + TechServiceLic + "%'"
  708. }
  709. if TJInNotify != "" {
  710. where = where + " and a.TJInNotify like '%" + TJInNotify + "%'"
  711. }
  712. if SpecIndustryCert != "" {
  713. where = where + " and a.SpecIndustryCert like '%" + SpecIndustryCert + "%'"
  714. }
  715. if LegalPerson != "" {
  716. where = where + " and a.LegalPerson like '%" + LegalPerson + "%'"
  717. }
  718. if CategoryCode != "" {
  719. where = where + " and a.CategoryCode like '%" + CategoryCode + "%'"
  720. }
  721. if CategoryName != "" {
  722. where = where + " and a.CategoryName like '%" + CategoryName + "%'"
  723. }
  724. if RegCapital != "" {
  725. where = where + " and a.RegCapital like '%" + RegCapital + "%'"
  726. }
  727. if Currency != "" {
  728. where = where + " and a.Currency like '%" + Currency + "%'"
  729. }
  730. if ContactName != "" {
  731. where = where + " and a.ContactName like '%" + ContactName + "%'"
  732. }
  733. if CompanyType != "" {
  734. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  735. }
  736. if SetupTime != "" {
  737. where = where + " and a.SetupTime like '%" + SetupTime + "%'"
  738. }
  739. if DepositBank != "" {
  740. where = where + " and a.DepositBank like '%" + DepositBank + "%'"
  741. }
  742. if BankAccount != "" {
  743. where = where + " and a.BankAccount like '%" + BankAccount + "%'"
  744. }
  745. if EMail != "" {
  746. where = where + " and a.EMail like '%" + EMail + "%'"
  747. }
  748. if BankCreditRating != "" {
  749. where = where + " and a.BankCreditRating like '%" + BankCreditRating + "%'"
  750. }
  751. if Mobile != "" {
  752. where = where + " and a.Mobile like '%" + Mobile + "%'"
  753. }
  754. if Telphone != "" {
  755. where = where + " and a.Telphone like '%" + Telphone + "%'"
  756. }
  757. if Fax != "" {
  758. where = where + " and a.Fax like '%" + Fax + "%'"
  759. }
  760. if CompanyTel != "" {
  761. where = where + " and a.CompanyTel like '%" + CompanyTel + "%'"
  762. }
  763. if QQ != "" {
  764. where = where + " and a.QQ like '%" + QQ + "%'"
  765. }
  766. if CompanyUrl != "" {
  767. where = where + " and a.CompanyUrl like '%" + CompanyUrl + "%'"
  768. }
  769. if SpecSupplier != "" {
  770. where = where + " and a.SpecSupplier like '%" + SpecSupplier + "%'"
  771. }
  772. if SpecTypeCode != "" {
  773. where = where + " and a.SpecTypeCode like '%" + SpecTypeCode + "%'"
  774. }
  775. if SpecTypeName != "" {
  776. where = where + " and a.SpecTypeName like '%" + SpecTypeName + "%'"
  777. }
  778. if Remark != "" {
  779. where = where + " and a.Remark like '%" + Remark + "%'"
  780. }
  781. if CreateOn != "" {
  782. dates := strings.Split(CreateOn, ",")
  783. if len(dates) == 2 {
  784. minDate := dates[0]
  785. maxDate := dates[1]
  786. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  787. }
  788. }
  789. if SupplierTypeCode != "" {
  790. where = where + " and b.SupplierTypeCode = '" + SupplierTypeCode + "'"
  791. }
  792. //找出待办任务
  793. actisvc := workflow.GetActivitiService(utils.DBE)
  794. certIdList := actisvc.GetMyTasks(workflow.OIL_SUPPLIER_APPLY, this.User.Id)
  795. where += " and b.Id in (" + certIdList + ")"
  796. //根据部门查询待办任务
  797. svc := supplier.GetOilSupplierService(utils.DBE)
  798. var list []supplier.OilSupplierView
  799. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  800. var datainfo DataInfo
  801. datainfo.Items = list
  802. datainfo.CurrentItemCount = total
  803. datainfo.PageIndex = page.CurrentPage
  804. datainfo.ItemsPerPage = page.Size
  805. this.Data["json"] = &datainfo
  806. this.ServeJSON()
  807. }
  808. // @Title 获取字典列表
  809. // @Description get user by token
  810. // @Success 200 {object} map[string]interface{}
  811. // @router /dictlist [get]
  812. func (this *OilSupplierController) GetDictList() {
  813. dictList := make(map[string]interface{})
  814. dictSvc := items.GetItemsService(utils.DBE)
  815. userSvc := baseUser.GetBaseUserService(utils.DBE)
  816. areaJsonSvc := areajson.GetAreaJsonService(utils.DBE)
  817. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  818. dictList["UnitRelation"] = dictSvc.GetKeyValueItems("UnitRelation")
  819. dictList["CompanyType"] = dictSvc.GetKeyValueItems("CompanyType")
  820. var userEntity userRole.Base_User
  821. userSvc.GetEntityById(this.User.Id, &userEntity)
  822. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  823. dictList["GaodeMapChinaAreas"] = areaJsonSvc.GetGaodeMapChinaAreas()
  824. dictList["CountryList"] = areaJsonSvc.GetCountryList()
  825. //获取我创建的所有公司
  826. var list []supplier.OilSupplier
  827. if this.User.IsCompanyUser == 1 {
  828. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  829. supplierWhere := " CreateUserId = '" + this.User.Id + "'"
  830. svcSupplier.GetEntitysByWhere(OilSupplierName, supplierWhere, &list)
  831. dictList["CompanyNames"] = list
  832. } else { //二级单位不用获取
  833. dictList["CompanyNames"] = list
  834. }
  835. // 部门
  836. orgsvc := organize.GetOrganizeService(utils.DBE)
  837. dictList["Organizes"] = orgsvc.GetCollectionDetailviewlist("'" + this.User.AccCode + "'")
  838. //var dictCustomer []svccustomer.Customer
  839. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  840. //dictList["EntrustCorp"] = &dictCustomer
  841. //获得有审核权限的人员
  842. var users []userRole.Base_RoleList
  843. var auditWorkflow auditsetting.Base_OilAuditSetting
  844. rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  845. rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
  846. users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
  847. dictList["Auditer"] = users
  848. var datainfo DataInfo
  849. datainfo.Items = dictList
  850. this.Data["json"] = &datainfo
  851. this.ServeJSON()
  852. }
  853. // @Title 获取字典列表By Status
  854. // @Description get user by token
  855. // @Success 200 {object} map[string]interface{}
  856. // @router /dictlistbystatus/ [get]
  857. func (this *OilSupplierController) GetDictListByStatus() {
  858. //status := this.Ctx.Input.Param(":status")
  859. status := this.GetString("status")
  860. majorAduit := this.GetString("majorAduit")
  861. dictList := make(map[string]interface{})
  862. dictSvc := items.GetItemsService(utils.DBE)
  863. userSvc := baseUser.GetBaseUserService(utils.DBE)
  864. areaJsonSvc := areajson.GetAreaJsonService(utils.DBE)
  865. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  866. dictList["UnitRelation"] = dictSvc.GetKeyValueItems("UnitRelation")
  867. dictList["CompanyType"] = dictSvc.GetKeyValueItems("CompanyType")
  868. var userEntity userRole.Base_User
  869. userSvc.GetEntityById(this.User.Id, &userEntity)
  870. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  871. dictList["GaodeMapChinaAreas"] = areaJsonSvc.GetGaodeMapChinaAreas()
  872. dictList["CountryList"] = areaJsonSvc.GetCountryList()
  873. //获取我创建的所有公司
  874. var list []supplier.OilSupplier
  875. if this.User.IsCompanyUser == 1 {
  876. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  877. supplierWhere := " CreateUserId = '" + this.User.Id + "'"
  878. svcSupplier.GetEntitysByWhere(OilSupplierName, supplierWhere, &list)
  879. dictList["CompanyNames"] = list
  880. } else { //二级单位不用获取
  881. dictList["CompanyNames"] = list
  882. }
  883. // 部门
  884. orgsvc := organize.GetOrganizeService(utils.DBE)
  885. dictList["Organizes"] = orgsvc.GetCollectionDetailviewlist("'" + this.User.AccCode + "'")
  886. //var dictCustomer []svccustomer.Customer
  887. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  888. //dictList["EntrustCorp"] = &dictCustomer
  889. //获得有审核权限的人员
  890. //var users []suppliercert.UserList
  891. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  892. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  893. var users []userRole.Base_RoleList
  894. if status == suppliercert.FIRST_TRIAL_STATUS {
  895. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
  896. //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
  897. //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + workflow.SECOND_TRIAL + "'"
  898. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  899. certSrv.GetAuditUser(this.User.DepartmentId, workflow.SECOND_TRIAL, &users)
  900. dictList["Auditer"] = users
  901. } else if status == suppliercert.SECOND_TRIAL_STATUS {
  902. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
  903. } else if status == suppliercert.THIRD_TRIAL_STATUS {
  904. //where := "OrganizeId=" + majorAduit + " and AuditStepCode='" + workflow.SECOND_TRIAL + "'"
  905. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  906. certSrv.GetAuditUser(majorAduit, workflow.SECOND_TRIAL, &users)
  907. dictList["Auditer"] = users
  908. } else if status == suppliercert.PROF_AUDIT_STATUS {
  909. //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + workflow.PROF_AUDIT + "'"
  910. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  911. certSrv.GetAuditUser(this.User.DepartmentId, workflow.PROF_AUDIT, &users)
  912. dictList["Auditer"] = users
  913. } else if status == suppliercert.CENT_AUDIT_STATUS {
  914. }
  915. // 获取当
  916. var datainfo DataInfo
  917. datainfo.Items = dictList
  918. this.Data["json"] = &datainfo
  919. this.ServeJSON()
  920. }
  921. // @Title 获取实体
  922. // @Description 获取实体
  923. // @Success 200 {object} supplier.OilSupplier
  924. // @router /get/:id [get]
  925. func (this *OilSupplierController) GetEntity() {
  926. Id := this.Ctx.Input.Param(":id")
  927. var model supplier.OilSupplier
  928. svc := supplier.GetOilSupplierService(utils.DBE)
  929. svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  930. this.Data["json"] = &model
  931. this.ServeJSON()
  932. }
  933. // @Title 获取实体
  934. // @Description 获取实体
  935. // @Success 200 {object} supplier.OilSupplier
  936. // @router /getandcert/:certId [get]
  937. func (this *OilSupplierController) GetEntityAndCert() {
  938. Id := this.Ctx.Input.Param(":certId")
  939. var model supplier.OilSupplierView
  940. svc := supplier.GetOilSupplierService(utils.DBE)
  941. svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  942. var sql string
  943. 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,
  944. b.MiddleProfNum, b.NationalRegNum, b.NationalCertTotal, b.DesignerTotal, b.SkillerTotal, b.WorkflowId, b.Status, b.ThirdAudit from ` + OilSupplierName + ` a `
  945. sql += ` left join ` + OilSupplierCertName + " b on b.SupplierId = a.Id"
  946. sql += ` where b.Id ='` + Id + `'`
  947. utils.DBE.SQL(sql).Get(&model)
  948. this.Data["json"] = &model
  949. this.ServeJSON()
  950. }
  951. // @Title 获取实体
  952. // @Description 获取实体
  953. // @Success 200 {object} supplier.OilSupplier
  954. // @router /getbyname/:name [get]
  955. func (this *OilSupplierController) GetEntityByName() {
  956. name := this.Ctx.Input.Param(":name")
  957. var model supplier.OilSupplier
  958. svc := supplier.GetOilSupplierService(utils.DBE)
  959. where := "SupplierName='" + name + "'"
  960. svc.GetEntityByWhere(OilSupplierName, where, &model)
  961. this.Data["json"] = &model
  962. this.ServeJSON()
  963. }
  964. // @Title 添加
  965. // @Description 新增
  966. // @Success 200 {object} controllers.Request
  967. // @router /add [post]
  968. func (this *OilSupplierController) AddEntity() {
  969. var model supplier.OilSupplier
  970. var modelCert suppliercert.OilSupplierCert
  971. var modelCertVM suppliercert.OilSupplierVM
  972. var jsonBlob = this.Ctx.Input.RequestBody
  973. json.Unmarshal(jsonBlob, &model)
  974. json.Unmarshal(jsonBlob, &modelCertVM)
  975. serviceCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  976. canApply := serviceCert.IsCanApplyByExtOrganizeUser(modelCertVM.SupplierTypeCode, this.User.DepartmentId, this.User.Id, this.User.IsCompanyUser)
  977. var errinfo ErrorDataInfo
  978. if !canApply {
  979. errinfo.Message = "添加失败!供方用户只能申请一次"
  980. errinfo.Code = -1
  981. this.Data["json"] = &errinfo
  982. this.ServeJSON()
  983. return
  984. }
  985. var list []supplier.OilSupplierView
  986. service := supplier.GetOilSupplierService(utils.DBE)
  987. if model.Id <= 0 {
  988. service.CheckRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  989. if len(list) > 0 {
  990. errinfo.Message = "添加失败! 已存在相关企业的信息,不能重复申请"
  991. errinfo.Code = -1
  992. this.Data["json"] = &errinfo
  993. this.ServeJSON()
  994. return
  995. }
  996. } else {
  997. service.CheckUpdateRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, strconv.Itoa(model.Id), model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  998. if len(list) > 0 {
  999. errinfo.Message = "添加失败! 已存在相关企业的信息,或与其他企业信息重复"
  1000. errinfo.Code = -1
  1001. this.Data["json"] = &errinfo
  1002. this.ServeJSON()
  1003. return
  1004. }
  1005. }
  1006. var session *xorm.Session
  1007. session = utils.DBE.NewSession()
  1008. svc := supplier.GetOilSupplierSession(session)
  1009. svcCert := suppliercert.GetOilSupplierCertSession(session)
  1010. model.CreateOn = time.Now()
  1011. model.CreateBy = this.User.Realname
  1012. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1013. //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  1014. defer session.Close()
  1015. err := session.Begin()
  1016. if model.Id <= 0 {
  1017. _, err = svc.InsertEntityBytbl(OilSupplierName, &model)
  1018. } else {
  1019. //判断基本信息是否可修改
  1020. updateCols := svc.GetUpdateCols(OilSupplierCertName, modelCertVM.SupplierTypeCode, model.Id)
  1021. err = svc.UpdateEntityBytbl(OilSupplierName, model.Id, &model, updateCols)
  1022. }
  1023. if err != nil {
  1024. session.Rollback()
  1025. }
  1026. modelCert.SupplierId = model.Id
  1027. modelCert.SupplierTypeCode = modelCertVM.SupplierTypeCode
  1028. modelCert.SupplierTypeName = modelCertVM.SupplierTypeName
  1029. modelCert.Step = 1 //企业信息保存完成
  1030. modelCert.CreateOn = time.Now()
  1031. modelCert.CreateBy = this.User.Realname
  1032. modelCert.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1033. _, err = svcCert.InsertEntityBytbl(OilSupplierCertName, &modelCert)
  1034. if err != nil {
  1035. session.Rollback()
  1036. }
  1037. // add Commit() after all actions
  1038. err = session.Commit()
  1039. if err == nil {
  1040. //新增
  1041. errinfo.Message = "添加成功!"
  1042. errinfo.Code = 0
  1043. errinfo.Item = strconv.Itoa(model.Id) + "_" + strconv.Itoa(modelCert.Id)
  1044. this.Data["json"] = &errinfo
  1045. this.ServeJSON()
  1046. } else {
  1047. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  1048. errinfo.Code = -1
  1049. this.Data["json"] = &errinfo
  1050. this.ServeJSON()
  1051. }
  1052. }
  1053. // @Title 修改实体
  1054. // @Description 修改实体
  1055. // @Success 200 {object} controllers.Request
  1056. // @router /update/:id/:type [post]
  1057. func (this *OilSupplierController) UpdateEntity() {
  1058. id := this.Ctx.Input.Param(":id")
  1059. typeCode := this.Ctx.Input.Param(":type")
  1060. var errinfo ErrorInfo
  1061. if id == "" {
  1062. errinfo.Message = "操作失败!请求信息不完整"
  1063. errinfo.Code = -2
  1064. this.Data["json"] = &errinfo
  1065. this.ServeJSON()
  1066. return
  1067. }
  1068. var model supplier.OilSupplier
  1069. var jsonBlob = this.Ctx.Input.RequestBody
  1070. json.Unmarshal(jsonBlob, &model)
  1071. var list []supplier.OilSupplierView
  1072. service := supplier.GetOilSupplierService(utils.DBE)
  1073. service.CheckUpdateRepeatApplyInfo(OilSupplierName, OilSupplierCertName, typeCode, strconv.Itoa(model.Id), model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1074. if len(list) > 0 {
  1075. errinfo.Message = "修改失败! 已存在相关企业的信息,或与其他企业信息重复"
  1076. errinfo.Code = -1
  1077. this.Data["json"] = &errinfo
  1078. this.ServeJSON()
  1079. return
  1080. }
  1081. svc := supplier.GetOilSupplierService(utils.DBE)
  1082. model.ModifiedOn = time.Now()
  1083. model.ModifiedBy = this.User.Realname
  1084. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  1085. //判断基本信息是否可修改
  1086. updateCols := svc.GetUpdateCols(OilSupplierCertName, typeCode, model.Id)
  1087. err := svc.UpdateEntityBytbl(OilSupplierName, id, &model, updateCols)
  1088. if err == nil {
  1089. errinfo.Message = "修改成功!"
  1090. errinfo.Code = 0
  1091. this.Data["json"] = &errinfo
  1092. this.ServeJSON()
  1093. } else {
  1094. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  1095. errinfo.Code = -1
  1096. this.Data["json"] = &errinfo
  1097. this.ServeJSON()
  1098. }
  1099. }
  1100. // @Title 修改企业人员情况实体
  1101. // @Description 修改实体
  1102. // @Success 200 {object} controllers.Request
  1103. // @router /updatenumber/:id [post]
  1104. func (this *OilSupplierController) UpdateNumberEntity() {
  1105. idGroup := this.Ctx.Input.Param(":id")
  1106. //id := strings.Split(idGroup, "_")[0]
  1107. certId := strings.Split(idGroup, "_")[1]
  1108. var errinfo ErrorInfo
  1109. if certId == "" {
  1110. errinfo.Message = "操作失败!请求信息不完整"
  1111. errinfo.Code = -2
  1112. this.Data["json"] = &errinfo
  1113. this.ServeJSON()
  1114. return
  1115. }
  1116. var modelCert suppliercert.OilSupplierCert
  1117. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  1118. var jsonBlob = this.Ctx.Input.RequestBody
  1119. json.Unmarshal(jsonBlob, &modelCert)
  1120. modelCert.ModifiedOn = time.Now()
  1121. modelCert.ModifiedBy = this.User.Realname
  1122. modelCert.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  1123. colcerts := []string{
  1124. "Id",
  1125. "WorkerTotal",
  1126. "ContractNum ",
  1127. "UniversityNum",
  1128. "TechnicalNum",
  1129. "AboveProfNum",
  1130. "MiddleProfNum",
  1131. "NationalRegNum",
  1132. "NationalCertTotal",
  1133. "DesignerTotal",
  1134. "SkillerTotal",
  1135. "ModifiedOn",
  1136. "ModifiedUserId",
  1137. "ModifiedBy",
  1138. }
  1139. // if modelCert.Step <= 2 {
  1140. // modelCert.Step = 2 //完成企业基本信息
  1141. // colcerts = append(colcerts, "Step")
  1142. // }
  1143. err := svcCert.UpdateEntityBytbl(OilSupplierCertName, certId, &modelCert, colcerts)
  1144. if err == nil {
  1145. errinfo.Message = "保存成功!"
  1146. errinfo.Code = 0
  1147. this.Data["json"] = &errinfo
  1148. this.ServeJSON()
  1149. } else {
  1150. errinfo.Message = "保存失败!" + utils.AlertProcess(err.Error())
  1151. errinfo.Code = -1
  1152. this.Data["json"] = &errinfo
  1153. this.ServeJSON()
  1154. }
  1155. }
  1156. // @Title 删除单条信息
  1157. // @Description
  1158. // @Success 200 {object} ErrorInfo
  1159. // @Failure 403 :id 为空
  1160. // @router /delete/:Id [delete]
  1161. func (this *OilSupplierController) DeleteEntity() {
  1162. Id := this.Ctx.Input.Param(":Id")
  1163. var errinfo ErrorInfo
  1164. if Id == "" {
  1165. errinfo.Message = "操作失败!请求信息不完整"
  1166. errinfo.Code = -2
  1167. this.Data["json"] = &errinfo
  1168. this.ServeJSON()
  1169. return
  1170. }
  1171. var model supplier.OilSupplier
  1172. var entityempty supplier.OilSupplier
  1173. svc := supplier.GetOilSupplierService(utils.DBE)
  1174. opdesc := "删除-" + Id
  1175. err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
  1176. if err == nil {
  1177. errinfo.Message = "删除成功"
  1178. errinfo.Code = 0
  1179. this.Data["json"] = &errinfo
  1180. this.ServeJSON()
  1181. } else {
  1182. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  1183. errinfo.Code = -1
  1184. this.Data["json"] = &errinfo
  1185. this.ServeJSON()
  1186. }
  1187. }
  1188. // @Title 判断是否可以申请准入
  1189. // @Description
  1190. // @Success 200 {string} Count
  1191. // @Failure 403 :id 为空
  1192. // @router /iscanapply/:type [get]
  1193. func (this *OilSupplierController) IsCanApply() {
  1194. Type := this.Ctx.Input.Param(":type")
  1195. var errinfo ErrorInfo
  1196. if Type == "" {
  1197. errinfo.Message = "操作失败!请求信息不完整"
  1198. errinfo.Code = -2
  1199. this.Data["json"] = &errinfo
  1200. this.ServeJSON()
  1201. return
  1202. }
  1203. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  1204. canApply := svc.IsCanApplyByExtOrganizeUser(Type, this.User.DepartmentId, this.User.Id, this.User.IsCompanyUser)
  1205. if canApply {
  1206. errinfo.Message = "无申请记录,可以申请"
  1207. errinfo.Code = 0
  1208. this.Data["json"] = &errinfo
  1209. this.ServeJSON()
  1210. } else {
  1211. errinfo.Message = "供方用户只能申请一次"
  1212. errinfo.Code = -1
  1213. this.Data["json"] = &errinfo
  1214. this.ServeJSON()
  1215. }
  1216. }
  1217. // @Title 判断是否可以修改供方企业信息
  1218. // @Description
  1219. // @Success 200 {string} Count
  1220. // @Failure 403 :id 为空
  1221. // @router /iscanupdatesupplier/:supplierid [get]
  1222. func (this *OilSupplierController) CanUpdateSupplier() {
  1223. supplierId := this.Ctx.Input.Param(":supplierid")
  1224. var errinfo ErrorInfo
  1225. if supplierId == "" {
  1226. errinfo.Message = "操作失败!请求信息不完整"
  1227. errinfo.Code = -2
  1228. this.Data["json"] = &errinfo
  1229. this.ServeJSON()
  1230. return
  1231. }
  1232. Id, _ := strconv.Atoi(supplierId)
  1233. svc := supplier.GetOilSupplierService(utils.DBE)
  1234. canUpdate := svc.CanUpdateSupplier(OilSupplierCertName, Id)
  1235. if canUpdate {
  1236. errinfo.Message = "可以修改"
  1237. errinfo.Code = 0
  1238. this.Data["json"] = &errinfo
  1239. this.ServeJSON()
  1240. } else {
  1241. errinfo.Message = "此供方已经提交准入申请,不可修改"
  1242. errinfo.Code = -1
  1243. this.Data["json"] = &errinfo
  1244. this.ServeJSON()
  1245. }
  1246. }
  1247. // @Title 获取二级初审人员
  1248. // @Description 获取二级初审人员
  1249. // @router /getauditerbydept/:deptId [get]
  1250. func (this *OilSupplierController) GetAuditerByDept() {
  1251. Id := this.Ctx.Input.Param(":deptId")
  1252. auditstepcode := this.GetString("auditstepcode")
  1253. //var auditWorkflow []auditsetting.Base_OilAuditSetting
  1254. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  1255. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, Id, workflow.FIRST_TRIAL, &auditWorkflow)
  1256. //var auditset []auditsetting.Base_OilAuditSetting
  1257. //where := "OrganizeId=" + Id + " and AuditStepCode='" + auditstepcode + "'"
  1258. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &auditset)
  1259. //var users []userRole.Base_RoleList
  1260. //if auditset != nil {
  1261. // svc := auditsetting.GetOilAuditSettingService(utils.DBE)
  1262. // svc.GetAuditUserList(strconv.Itoa(auditset[0].Id), &users)
  1263. //}
  1264. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1265. var users []userRole.Base_RoleList
  1266. certSrv.GetAuditUser(Id, auditstepcode, &users)
  1267. var datainfo ErrorDataInfo
  1268. datainfo.Item = users
  1269. this.Data["json"] = &datainfo
  1270. this.ServeJSON()
  1271. }