2
3

supplier.go 37 KB

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