supplier.go 39 KB

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