2
3

infochange.go 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/audithistory"
  4. "dashoo.cn/backend/api/business/auditsetting"
  5. "dashoo.cn/backend/api/business/oilsupplier/infochange"
  6. "dashoo.cn/backend/api/business/oilsupplier/qualchange"
  7. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  8. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  9. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  10. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  11. "dashoo.cn/backend/api/business/paymentinfo"
  12. "dashoo.cn/backend/api/business/register"
  13. "dashoo.cn/business2/parameter"
  14. "dashoo.cn/business2/permission"
  15. "dashoo.cn/business2/userRole"
  16. "encoding/json"
  17. "fmt"
  18. "log"
  19. "reflect"
  20. "strconv"
  21. "strings"
  22. "time"
  23. "dashoo.cn/backend/api/business/oilsupplier/annualaudit"
  24. "dashoo.cn/backend/api/business/workflow"
  25. . "dashoo.cn/backend/api/controllers"
  26. "dashoo.cn/utils"
  27. )
  28. type InfoChangeController struct {
  29. BaseController
  30. }
  31. type InfoShenHeModel struct {
  32. FirstAudit int
  33. SecondAudit int
  34. InfoId int
  35. SuccessStatus int
  36. AuditorRemark string
  37. SuppId int
  38. }
  39. type InfoChangeItemsAll struct {
  40. InfochangeForm []infoitems
  41. SupplierId string
  42. MInfoId string
  43. }
  44. type infoitems struct {
  45. SelectItem string
  46. SelectItemName string
  47. BeChangeInfo string
  48. ChangeInfo string
  49. }
  50. // @Title 获取实体
  51. // @Description 获取实体
  52. // @Success 200 {object} annualaudit.OilAnnualAudit
  53. // @router /get/:id [get]
  54. func (this *InfoChangeController) GetEntity() {
  55. CertId := this.Ctx.Input.Param(":id")
  56. var model []infochange.OilInfoChangeItem
  57. svc := infochange.GetInfoChangeService(utils.DBE)
  58. where := " SupplierId = " + CertId
  59. svc.GetEntitysByWhere(OilInfoChangeItemName, where, &model)
  60. var datainfo DataInfo
  61. datainfo.Items = model
  62. this.Data["json"] = &datainfo
  63. this.ServeJSON()
  64. }
  65. // @Title 获取实体
  66. // @Description 获取实体
  67. // @Success 200 {object} annualaudit.OilAnnualAudit
  68. // @router /getmain/:id [get]
  69. func (this *InfoChangeController) GetMainEntity() {
  70. Id := this.Ctx.Input.Param(":id")
  71. var model []infochange.OilInfoChange
  72. svc := infochange.GetInfoChangeService(utils.DBE)
  73. where := " Id = " + Id
  74. svc.GetEntitysByWhere(OilInfoChangeName, where, &model)
  75. var datainfo DataInfo
  76. datainfo.Items = model
  77. this.Data["json"] = &datainfo
  78. this.ServeJSON()
  79. }
  80. // @Title 获取实体
  81. // @Description 获取实体
  82. // @Success 200 {object} annualaudit.OilAnnualAudit
  83. // @router /getAccessCardNo/:id [get]
  84. func (this *InfoChangeController) GetAccessCardNo() {
  85. SuppId := this.Ctx.Input.Param(":id")
  86. var model []suppliercert.OilSupplierCert
  87. svc := infochange.GetInfoChangeService(utils.DBE)
  88. where := " SupplierId = " + SuppId
  89. svc.GetEntitysByOrderbyWhere(OilSupplierCertName, where, "SupplierTypeCode asc", &model)
  90. var datainfo DataInfo
  91. datainfo.Items = model
  92. this.Data["json"] = &datainfo
  93. this.ServeJSON()
  94. }
  95. // @Title 获取实体
  96. // @Description 获取实体
  97. // @Success 200 {object} annualaudit.OilAnnualAudit
  98. // @router /auditget/:id [get]
  99. func (this *InfoChangeController) GetEntityThen() {
  100. InfoId := this.Ctx.Input.Param(":id")
  101. var model []infochange.OilInfoChangeItem
  102. svc := infochange.GetInfoChangeService(utils.DBE)
  103. where := " InfoId = " + InfoId
  104. svc.GetEntitysByWhere(OilInfoChangeItemName, where, &model)
  105. var datainfo DataInfo
  106. datainfo.Items = model
  107. this.Data["json"] = &datainfo
  108. this.ServeJSON()
  109. }
  110. // @Title 获取列表
  111. // @Description get user by token
  112. // @Success 200 {object} []supplier.OilSupplier
  113. // @router /supplist [get]
  114. func (this *InfoChangeController) GetSuppList() {
  115. //获取分页信息
  116. page := this.GetPageInfoForm()
  117. where := " b.Id is not null "
  118. orderby := "b.Id"
  119. asc := false
  120. Order := this.GetString("Order")
  121. Prop := this.GetString("Prop")
  122. if Order != "" && Prop != "" {
  123. orderby = Prop
  124. if Order == "asc" {
  125. asc = true
  126. }
  127. }
  128. SupplierName := this.GetString("SupplierName")
  129. OilCertificateNo := this.GetString("OilCertificateNo")
  130. Grade := this.GetString("Grade")
  131. MgrUnit := this.GetString("MgrUnit")
  132. OperType := this.GetString("OperType")
  133. Country := this.GetString("Country")
  134. MaunAgent := this.GetString("MaunAgent")
  135. ConstructTeam := this.GetString("ConstructTeam")
  136. CommercialNo := this.GetString("CommercialNo")
  137. OrganCode := this.GetString("OrganCode")
  138. CountryTaxNo := this.GetString("CountryTaxNo")
  139. LocalTaxNo := this.GetString("LocalTaxNo")
  140. Address := this.GetString("Address")
  141. Province := this.GetString("Province")
  142. City := this.GetString("City")
  143. Street := this.GetString("Street")
  144. HouseNo := this.GetString("HouseNo")
  145. ZipCode := this.GetString("ZipCode")
  146. QualitySystemCert := this.GetString("QualitySystemCert")
  147. ProductQualityCert := this.GetString("ProductQualityCert")
  148. MaunLicense := this.GetString("MaunLicense")
  149. QualifCert := this.GetString("QualifCert")
  150. QualifCertLevel := this.GetString("QualifCertLevel")
  151. SafetyLicense := this.GetString("SafetyLicense")
  152. TechServiceLic := this.GetString("TechServiceLic")
  153. TJInNotify := this.GetString("TJInNotify")
  154. SpecIndustryCert := this.GetString("SpecIndustryCert")
  155. LegalPerson := this.GetString("LegalPerson")
  156. CategoryCode := this.GetString("CategoryCode")
  157. CategoryName := this.GetString("CategoryName")
  158. RegCapital := this.GetString("RegCapital")
  159. Currency := this.GetString("Currency")
  160. ContactName := this.GetString("ContactName")
  161. CompanyType := this.GetString("CompanyType")
  162. SetupTime := this.GetString("SetupTime")
  163. DepositBank := this.GetString("DepositBank")
  164. BankAccount := this.GetString("BankAccount")
  165. EMail := this.GetString("EMail")
  166. BankCreditRating := this.GetString("BankCreditRating")
  167. Mobile := this.GetString("Mobile")
  168. Telphone := this.GetString("Telphone")
  169. Fax := this.GetString("Fax")
  170. CompanyTel := this.GetString("CompanyTel")
  171. QQ := this.GetString("QQ")
  172. CompanyUrl := this.GetString("CompanyUrl")
  173. SpecSupplier := this.GetString("SpecSupplier")
  174. SpecTypeCode := this.GetString("SpecTypeCode")
  175. SpecTypeName := this.GetString("SpecTypeName")
  176. Remark := this.GetString("Remark")
  177. CreateOn := this.GetString("CreateOn")
  178. if SupplierName != "" {
  179. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  180. }
  181. if OilCertificateNo != "" {
  182. where = where + " and a.OilCertificateNo like '%" + OilCertificateNo + "%'"
  183. }
  184. if Grade != "" {
  185. where = where + " and a.Grade like '%" + Grade + "%'"
  186. }
  187. if MgrUnit != "" {
  188. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  189. }
  190. if OperType != "" {
  191. where = where + " and a.OperType like '%" + OperType + "%'"
  192. }
  193. if Country != "" {
  194. where = where + " and a.Country like '%" + Country + "%'"
  195. }
  196. if MaunAgent != "" {
  197. where = where + " and a.MaunAgent like '%" + MaunAgent + "%'"
  198. }
  199. if ConstructTeam != "" {
  200. where = where + " and a.ConstructTeam like '%" + ConstructTeam + "%'"
  201. }
  202. if CommercialNo != "" {
  203. where = where + " and a.CommercialNo like '%" + CommercialNo + "%'"
  204. }
  205. if OrganCode != "" {
  206. where = where + " and a.OrganCode like '%" + OrganCode + "%'"
  207. }
  208. if CountryTaxNo != "" {
  209. where = where + " and a.CountryTaxNo like '%" + CountryTaxNo + "%'"
  210. }
  211. if LocalTaxNo != "" {
  212. where = where + " and a.LocalTaxNo like '%" + LocalTaxNo + "%'"
  213. }
  214. if Address != "" {
  215. where = where + " and a.Address like '%" + Address + "%'"
  216. }
  217. if Province != "" {
  218. where = where + " and a.Province like '%" + Province + "%'"
  219. }
  220. if City != "" {
  221. where = where + " and a.City like '%" + City + "%'"
  222. }
  223. if Street != "" {
  224. where = where + " and a.Street like '%" + Street + "%'"
  225. }
  226. if HouseNo != "" {
  227. where = where + " and a.HouseNo like '%" + HouseNo + "%'"
  228. }
  229. if ZipCode != "" {
  230. where = where + " and a.ZipCode like '%" + ZipCode + "%'"
  231. }
  232. if QualitySystemCert != "" {
  233. where = where + " and a.QualitySystemCert like '%" + QualitySystemCert + "%'"
  234. }
  235. if ProductQualityCert != "" {
  236. where = where + " and a.ProductQualityCert like '%" + ProductQualityCert + "%'"
  237. }
  238. if MaunLicense != "" {
  239. where = where + " and a.MaunLicense like '%" + MaunLicense + "%'"
  240. }
  241. if QualifCert != "" {
  242. where = where + " and a.QualifCert like '%" + QualifCert + "%'"
  243. }
  244. if QualifCertLevel != "" {
  245. where = where + " and a.QualifCertLevel like '%" + QualifCertLevel + "%'"
  246. }
  247. if SafetyLicense != "" {
  248. where = where + " and a.SafetyLicense like '%" + SafetyLicense + "%'"
  249. }
  250. if TechServiceLic != "" {
  251. where = where + " and a.TechServiceLic like '%" + TechServiceLic + "%'"
  252. }
  253. if TJInNotify != "" {
  254. where = where + " and a.TJInNotify like '%" + TJInNotify + "%'"
  255. }
  256. if SpecIndustryCert != "" {
  257. where = where + " and a.SpecIndustryCert like '%" + SpecIndustryCert + "%'"
  258. }
  259. if LegalPerson != "" {
  260. where = where + " and a.LegalPerson like '%" + LegalPerson + "%'"
  261. }
  262. if CategoryCode != "" {
  263. where = where + " and a.CategoryCode like '%" + CategoryCode + "%'"
  264. }
  265. if CategoryName != "" {
  266. where = where + " and a.CategoryName like '%" + CategoryName + "%'"
  267. }
  268. if RegCapital != "" {
  269. where = where + " and a.RegCapital like '%" + RegCapital + "%'"
  270. }
  271. if Currency != "" {
  272. where = where + " and a.Currency like '%" + Currency + "%'"
  273. }
  274. if ContactName != "" {
  275. where = where + " and a.ContactName like '%" + ContactName + "%'"
  276. }
  277. if CompanyType != "" {
  278. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  279. }
  280. if SetupTime != "" {
  281. where = where + " and a.SetupTime like '%" + SetupTime + "%'"
  282. }
  283. if DepositBank != "" {
  284. where = where + " and a.DepositBank like '%" + DepositBank + "%'"
  285. }
  286. if BankAccount != "" {
  287. where = where + " and a.BankAccount like '%" + BankAccount + "%'"
  288. }
  289. if EMail != "" {
  290. where = where + " and a.EMail like '%" + EMail + "%'"
  291. }
  292. if BankCreditRating != "" {
  293. where = where + " and a.BankCreditRating like '%" + BankCreditRating + "%'"
  294. }
  295. if Mobile != "" {
  296. where = where + " and a.Mobile like '%" + Mobile + "%'"
  297. }
  298. if Telphone != "" {
  299. where = where + " and a.Telphone like '%" + Telphone + "%'"
  300. }
  301. if Fax != "" {
  302. where = where + " and a.Fax like '%" + Fax + "%'"
  303. }
  304. if CompanyTel != "" {
  305. where = where + " and a.CompanyTel like '%" + CompanyTel + "%'"
  306. }
  307. if QQ != "" {
  308. where = where + " and a.QQ like '%" + QQ + "%'"
  309. }
  310. if CompanyUrl != "" {
  311. where = where + " and a.CompanyUrl like '%" + CompanyUrl + "%'"
  312. }
  313. if SpecSupplier != "" {
  314. where = where + " and a.SpecSupplier like '%" + SpecSupplier + "%'"
  315. }
  316. if SpecTypeCode != "" {
  317. where = where + " and a.SpecTypeCode like '%" + SpecTypeCode + "%'"
  318. }
  319. if SpecTypeName != "" {
  320. where = where + " and a.SpecTypeName like '%" + SpecTypeName + "%'"
  321. }
  322. if Remark != "" {
  323. where = where + " and a.Remark like '%" + Remark + "%'"
  324. }
  325. if CreateOn != "" {
  326. dates := strings.Split(CreateOn, ",")
  327. if len(dates) == 2 {
  328. minDate := dates[0]
  329. maxDate := dates[1]
  330. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  331. }
  332. }
  333. svc := infochange.GetInfoChangeService(utils.DBE)
  334. var registerUser register.OilCorporateInfo
  335. sql := " UserName='" + this.User.Username + "'"
  336. svc.GetEntity(&registerUser, sql)
  337. //企业用户必须加创建人条件
  338. if this.User.IsCompanyUser == 1 {
  339. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  340. } else {
  341. //超级管理员和有查看所有数据权限的用户不加条件
  342. svcPerm := permission.GetPermissionService(utils.DBE)
  343. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_system.infochange.AllRecord")
  344. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  345. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  346. }
  347. }
  348. var list []infochange.SuppModelInfo
  349. total := svc.GetSuppPagingEntitiesWithOrderBytbl(OilSupplierName, OilInfoChangeName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  350. //total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  351. var datainfo DataInfo
  352. datainfo.Items = list
  353. datainfo.CurrentItemCount = total
  354. datainfo.PageIndex = page.CurrentPage
  355. datainfo.ItemsPerPage = page.Size
  356. this.Data["json"] = &datainfo
  357. this.ServeJSON()
  358. }
  359. // @Title 获取列表
  360. // @Description get user by token
  361. // @Success 200 {object} []infochange.OilInfoChange
  362. // @router /alllist [get]
  363. func (this *InfoChangeController) GetAllEntityList() {
  364. //获取分页信息
  365. page := this.GetPageInfoForm()
  366. where := " 1=1"
  367. orderby := "Id"
  368. asc := false
  369. Order := this.GetString("Order")
  370. Prop := this.GetString("Prop")
  371. SupplierId := this.GetString("SupplierId")
  372. if Order != "" && Prop != "" {
  373. orderby = Prop
  374. if Order == "asc" {
  375. asc = true
  376. }
  377. }
  378. SupplierName := this.GetString("SupplierName")
  379. //if SupplierId != "" {
  380. // var model supplier.OilSupplier
  381. // sv := supplier.GetOilSupplierService(utils.DBE)
  382. // sv.GetEntityByIdBytbl(OilSupplierName, SupplierId, &model)
  383. // SupplierName = model.SupplierName
  384. //}
  385. CreateOn := this.GetString("CreateOn")
  386. if SupplierName != "" {
  387. where = where + " and Name like '%" + SupplierName + "%'"
  388. }
  389. if SupplierId != "" {
  390. where = where + " and SupplierId = '" + SupplierId + "'"
  391. }
  392. if CreateOn != "" {
  393. dates := strings.Split(CreateOn, ",")
  394. if len(dates) == 2 {
  395. minDate := dates[0]
  396. maxDate := dates[1]
  397. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  398. }
  399. }
  400. svc := infochange.GetInfoChangeService(utils.DBE)
  401. var list []infochange.OilUsedName
  402. //total := svc.GetUsedNameWithOrderBytbl(OilSupplierName, OilInfoChangeItemName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  403. total := svc.GetOldNameWithOrderBytbl(page.CurrentPage, page.Size, orderby, asc, &list, where)
  404. var datainfo DataInfo
  405. datainfo.Items = list
  406. datainfo.CurrentItemCount = total
  407. this.Data["json"] = &datainfo
  408. this.ServeJSON()
  409. }
  410. // @Title 获取列表
  411. // @Description get user by token
  412. // @Success 200 {object} []infochange.OilInfoChange
  413. // @router /list [get]
  414. func (this *InfoChangeController) GetEntityList() {
  415. //获取分页信息
  416. page := this.GetPageInfoForm()
  417. where := " 1=1 "
  418. orderby := "Id"
  419. asc := false
  420. Order := this.GetString("Order")
  421. Prop := this.GetString("Prop")
  422. if Order != "" && Prop != "" {
  423. orderby = Prop
  424. if Order == "asc" {
  425. asc = true
  426. }
  427. }
  428. SupplierTypeName := this.GetString("SupplierTypeName")
  429. RecUnitId := this.GetString("RecUnitId")
  430. AccessCardNo := this.GetString("AccessCardNo")
  431. SupplierName := this.GetString("SupplierName")
  432. CreateOn := this.GetString("CreateOn")
  433. if SupplierTypeName != "" {
  434. where = where + " and SupplierTypeName like '%" + SupplierTypeName + "%'"
  435. }
  436. if RecUnitId != "" {
  437. where = where + " and RecUnitId like '%" + RecUnitId + "%'"
  438. }
  439. if AccessCardNo != "" {
  440. where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
  441. }
  442. if SupplierName != "" {
  443. where = where + " and SupplierName like '%" + SupplierName + "%'"
  444. }
  445. if CreateOn != "" {
  446. dates := strings.Split(CreateOn, ",")
  447. if len(dates) == 2 {
  448. minDate := dates[0]
  449. maxDate := dates[1]
  450. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  451. }
  452. }
  453. //找出待办任务
  454. actisvc := workflow.GetActivitiService(utils.DBE)
  455. certIdList := actisvc.GetMyTasks(workflow.OIL_INFO_CHANGE, this.User.Id)
  456. appendIdarr := strings.Split(certIdList, ",")
  457. for i, item := range appendIdarr {
  458. idx := strings.Index(item, "-")
  459. if idx >= 0 {
  460. appendIdarr[i] = strings.Split(item, "-")[0]
  461. }
  462. }
  463. certIdList = strings.Join(appendIdarr, ",")
  464. svc := infochange.GetInfoChangeService(utils.DBE)
  465. var list []infochange.OilInfoChange
  466. var total int64 = 0
  467. if certIdList != "" {
  468. where += " and Id in (" + certIdList + ")"
  469. total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  470. }
  471. var datainfo DataInfo
  472. datainfo.Items = list
  473. datainfo.CurrentItemCount = total
  474. datainfo.PageIndex = page.CurrentPage
  475. datainfo.ItemsPerPage = page.Size
  476. this.Data["json"] = &datainfo
  477. this.ServeJSON()
  478. }
  479. // @Title 获取实体
  480. // @Description 获取实体
  481. // @Success 200 {object} annualaudit.OilAnnualAudit
  482. // @router /getinfoforitem [get]
  483. func (this *InfoChangeController) GetInfoForItem() {
  484. certId := this.GetString("certId")
  485. selctitem := this.GetString("selctitem")
  486. svc := infochange.GetInfoChangeService(utils.DBE)
  487. where := "Id =" + utils.ToStr(certId)
  488. var selecteditem = svc.GetInfoforItem(""+OilSupplierName, selctitem, where)
  489. this.Data["json"] = &selecteditem
  490. this.ServeJSON()
  491. }
  492. // @Title 获取实体
  493. // @Description 获取实体
  494. // @Success 200 {object} supplier.OilSupplier
  495. // @router /getchangelist/:id [get]
  496. func (this *InfoChangeController) GetChangeEntity() {
  497. Id := this.Ctx.Input.Param(":id")
  498. InfoId := this.GetString("InfomainId")
  499. var models [2]supplier.OilSupplier
  500. var model supplier.OilSupplier
  501. var enumModel supplier.OilSupplier
  502. svc := supplier.GetOilSupplierService(utils.DBE)
  503. svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  504. models[0] = model
  505. var infoitems []infochange.OilInfoChangeItem
  506. where := " SupplierId = " + Id + " and InfoId =" + InfoId
  507. where = where + " and ChangeStatus = 0"
  508. svc.GetEntitysByWhere(OilInfoChangeItemName, where, &infoitems)
  509. tmpModel := &model
  510. enumModel = *tmpModel
  511. immumodel := reflect.ValueOf(&enumModel)
  512. elem := immumodel.Elem()
  513. if len(infoitems) == 0 {
  514. models[1] = enumModel
  515. this.Data["json"] = &models
  516. this.ServeJSON()
  517. return
  518. } else {
  519. for _, info := range infoitems {
  520. fmt.Println(info.SelectItem)
  521. fmt.Println(";;;;;;;;;", elem.FieldByName(info.SelectItem).Type().String())
  522. if elem.FieldByName(info.SelectItem).Type().String() == "int64" {
  523. intchangeinfo, _ := strconv.ParseInt(info.ChangeInfo, 10, 64)
  524. elem.FieldByName(info.SelectItem).SetInt(intchangeinfo)
  525. } else if elem.FieldByName(info.SelectItem).Type().String() == "float64" {
  526. floatchangeinfo, _ := strconv.ParseFloat(info.ChangeInfo, 64)
  527. elem.FieldByName(info.SelectItem).SetFloat(floatchangeinfo)
  528. } else if elem.FieldByName(info.SelectItem).Type().String() == "time.Time" {
  529. t, _ := time.Parse("2006-01-02", info.ChangeInfo[0:10])
  530. elem.FieldByName(info.SelectItem).Set(reflect.ValueOf(t))
  531. } else {
  532. elem.FieldByName(info.SelectItem).SetString(info.ChangeInfo)
  533. }
  534. }
  535. models[1] = enumModel
  536. this.Data["json"] = &models
  537. this.ServeJSON()
  538. }
  539. }
  540. // @Title 获取列表
  541. // @Description get user by token
  542. // @Success 200 {object} []annualaudit.OilAnnualAudit
  543. // @router /mytasks [get]
  544. func (this *InfoChangeController) GetMyTaskEntityList() {
  545. //获取分页信息
  546. page := this.GetPageInfoForm()
  547. where := " 1=1 "
  548. orderby := "Id"
  549. asc := false
  550. Order := this.GetString("Order")
  551. Prop := this.GetString("Prop")
  552. if Order != "" && Prop != "" {
  553. orderby = Prop
  554. if Order == "asc" {
  555. asc = true
  556. }
  557. }
  558. SupplierTypeName := this.GetString("SupplierTypeName")
  559. RecUnitId := this.GetString("RecUnitId")
  560. AccessCardNo := this.GetString("AccessCardNo")
  561. SupplierName := this.GetString("SupplierName")
  562. CreateOn := this.GetString("CreateOn")
  563. if SupplierTypeName != "" {
  564. where = where + " and SupplierTypeName like '%" + SupplierTypeName + "%'"
  565. }
  566. if RecUnitId != "" {
  567. where = where + " and RecUnitId like '%" + RecUnitId + "%'"
  568. }
  569. if AccessCardNo != "" {
  570. where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
  571. }
  572. if SupplierName != "" {
  573. where = where + " and SupplierName like '%" + SupplierName + "%'"
  574. }
  575. if CreateOn != "" {
  576. dates := strings.Split(CreateOn, ",")
  577. if len(dates) == 2 {
  578. minDate := dates[0]
  579. maxDate := dates[1]
  580. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  581. }
  582. }
  583. svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  584. var list []annualaudit.OilAnnualAudit
  585. //找出待办任务
  586. actisvc := workflow.GetActivitiService(utils.DBE)
  587. certIdList := actisvc.GetMyTasks(workflow.OIL_AUDIT_APPLY, this.User.Id)
  588. where += " and Id in (" + certIdList + ")"
  589. where += " and Status != -2 "
  590. //根据部门查询待办任务
  591. total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  592. //total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  593. var datainfo DataInfo
  594. datainfo.Items = list
  595. datainfo.CurrentItemCount = total
  596. datainfo.PageIndex = page.CurrentPage
  597. datainfo.ItemsPerPage = page.Size
  598. this.Data["json"] = &datainfo
  599. this.ServeJSON()
  600. }
  601. // @Title 删除单条信息
  602. // @Description
  603. // @Success 200 {object} ErrorInfo
  604. // @Failure 403 :id 为空
  605. // @router /delete/:Id [delete]
  606. func (this *InfoChangeController) DeleteEntity() {
  607. Id := this.Ctx.Input.Param(":Id")
  608. var errinfo ErrorInfo
  609. if Id == "" {
  610. errinfo.Message = "操作失败!请求信息不完整"
  611. errinfo.Code = -2
  612. this.Data["json"] = &errinfo
  613. this.ServeJSON()
  614. return
  615. }
  616. var model infochange.OilInfoChangeItem
  617. var entityempty infochange.OilInfoChangeItem
  618. svc := infochange.GetInfoChangeService(utils.DBE)
  619. opdesc := "删除-" + Id
  620. err := svc.DeleteOperationAndWriteLogBytbl(""+OilInfoChangeItemName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "信息变更")
  621. if err == nil {
  622. errinfo.Message = "删除成功"
  623. errinfo.Code = 0
  624. this.Data["json"] = &errinfo
  625. this.ServeJSON()
  626. } else {
  627. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  628. errinfo.Code = -1
  629. this.Data["json"] = &errinfo
  630. this.ServeJSON()
  631. }
  632. }
  633. // @Title 删除信息变更
  634. // @Description
  635. // @Success 200 {object} ErrorInfo
  636. // @Failure 403 :id 为空
  637. // @router /delinfochangech/:Id [delete]
  638. func (this *InfoChangeController) DelInfoChangech() {
  639. Id := this.Ctx.Input.Param(":Id")
  640. var errinfo ErrorInfo
  641. if Id == "" {
  642. errinfo.Message = "操作失败!请求信息不完整"
  643. errinfo.Code = -2
  644. this.Data["json"] = &errinfo
  645. this.ServeJSON()
  646. return
  647. }
  648. svc := infochange.GetInfoChangeService(utils.DBE)
  649. var infoChange infochange.OilInfoChange
  650. where := "Id=" + Id + " and Status <= '0'"
  651. has1 := svc.GetEntity(&infoChange, where)
  652. if !has1 {
  653. errinfo.Message = "删除失败"
  654. errinfo.Code = -1
  655. this.Data["json"] = &errinfo
  656. this.ServeJSON()
  657. return
  658. }
  659. where = "ParentId=" + Id
  660. svc.DeleteEntityBytbl(OilQualChangeDetailName, where)
  661. where = "InfoId=" + Id
  662. svc.DeleteEntityBytbl(OilInfoChangeItemName, where)
  663. where = "Id=" + Id
  664. err := svc.DeleteEntityBytbl(OilInfoChangeName, where)
  665. where = "SupplierId=" + strconv.Itoa(infoChange.SupplierId) + " and FileName=''"
  666. err = svc.DeleteEntityBytbl(OilSupplierFileName, where)
  667. if err == nil {
  668. errinfo.Message = "删除成功"
  669. errinfo.Code = 0
  670. this.Data["json"] = &errinfo
  671. this.ServeJSON()
  672. } else {
  673. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  674. errinfo.Code = -1
  675. this.Data["json"] = &errinfo
  676. this.ServeJSON()
  677. }
  678. }
  679. // @Title 删除资质
  680. // @Description
  681. // @Success 200 {object} ErrorInfo
  682. // @Failure 403 :id 为空
  683. // @router /delfile/:Id [delete]
  684. func (this *InfoChangeController) DelFile() {
  685. Id := this.Ctx.Input.Param(":Id")
  686. var errinfo ErrorInfo
  687. if Id == "" {
  688. errinfo.Message = "操作失败!请求信息不完整"
  689. errinfo.Code = -2
  690. this.Data["json"] = &errinfo
  691. this.ServeJSON()
  692. return
  693. }
  694. svc := infochange.GetInfoChangeService(utils.DBE)
  695. var file supplierfile.OilSupplierFile
  696. where := "Id=" + Id
  697. has1 := svc.GetEntity(&file, where)
  698. if !has1 {
  699. errinfo.Message = "删除失败"
  700. errinfo.Code = -1
  701. this.Data["json"] = &errinfo
  702. this.ServeJSON()
  703. return
  704. }
  705. // 之前的资质改状态, 新增资质删除
  706. var err error
  707. if file.FileUrl != "" {
  708. cols := []string{"IsDelete"}
  709. file.IsDelete = 1
  710. _, err = svc.UpdateEntityByIdCols(Id, &file, cols)
  711. } else {
  712. where := "FileId=" + Id
  713. err = svc.DeleteEntityBytbl(OilQualChangeDetailName, where)
  714. err = svc.DeleteEntityById(Id, &file)
  715. }
  716. if err == nil {
  717. errinfo.Message = "删除成功"
  718. errinfo.Code = 0
  719. this.Data["json"] = &errinfo
  720. this.ServeJSON()
  721. } else {
  722. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  723. errinfo.Code = -1
  724. this.Data["json"] = &errinfo
  725. this.ServeJSON()
  726. }
  727. }
  728. // @Title 删除新上传的资质
  729. // @Description
  730. // @Success 200 {object} ErrorInfo
  731. // @Failure 403 :id 为空
  732. // @router /deletenewfile/:Id [delete]
  733. func (this *InfoChangeController) DeleteNewFile() {
  734. Id := this.Ctx.Input.Param(":Id")
  735. var errinfo ErrorInfo
  736. if Id == "" {
  737. errinfo.Message = "操作失败!请求信息不完整"
  738. errinfo.Code = -2
  739. this.Data["json"] = &errinfo
  740. this.ServeJSON()
  741. return
  742. }
  743. svc := infochange.GetInfoChangeService(utils.DBE)
  744. where := "FileId=" + Id
  745. err := svc.DeleteEntityBytbl(OilQualChangeDetailName, where)
  746. if err == nil {
  747. errinfo.Message = "删除成功"
  748. errinfo.Code = 0
  749. this.Data["json"] = &errinfo
  750. this.ServeJSON()
  751. } else {
  752. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  753. errinfo.Code = -1
  754. this.Data["json"] = &errinfo
  755. this.ServeJSON()
  756. }
  757. }
  758. // @Title 删除资质撤销
  759. // @Description
  760. // @Success 200 {object} ErrorInfo
  761. // @Failure 403 :id 为空
  762. // @router /recall [post]
  763. func (this *InfoChangeController) Recall() {
  764. SupplierId := this.GetString("SupplierId")
  765. SupplierTypeCode := this.GetString("SupplierTypeCode")
  766. var errinfo ErrorInfo
  767. svc := infochange.GetInfoChangeService(utils.DBE)
  768. var file supplierfile.OilSupplierFile
  769. where := "SupplierId=" + SupplierId + " and SupplierTypeCode in ('000', '" + SupplierTypeCode + "')" + " and IsDelete=1"
  770. cols := []string{"IsDelete"}
  771. file.IsDelete = 0
  772. err := svc.UpdateEntityBywheretbl(OilSupplierFileName, &file, cols, where)
  773. if err == nil {
  774. errinfo.Message = "撤销成功"
  775. errinfo.Code = 0
  776. this.Data["json"] = &errinfo
  777. this.ServeJSON()
  778. } else {
  779. errinfo.Message = "撤销失败!" + utils.AlertProcess(err.Error())
  780. errinfo.Code = -1
  781. this.Data["json"] = &errinfo
  782. this.ServeJSON()
  783. }
  784. }
  785. // @Title 添加
  786. // @Description 新增
  787. // @Success 200 {object} controllers.Request
  788. // @router /addinfochangeitem [post]
  789. func (this *InfoChangeController) AddInfoChangeItem() {
  790. var model infochange.OilInfoChangeItem
  791. var jsonBlob = this.Ctx.Input.RequestBody
  792. svc := infochange.GetInfoChangeService(utils.DBE)
  793. json.Unmarshal(jsonBlob, &model)
  794. model.CreateOn = time.Now()
  795. model.CreateBy = this.User.Realname
  796. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  797. _, err := svc.InsertEntityBytbl(""+OilInfoChangeItemName, &model)
  798. var errinfo ErrorDataInfo
  799. if err == nil {
  800. //新增
  801. errinfo.Message = "添加成功!"
  802. errinfo.Code = 0
  803. errinfo.Item = model.Id
  804. this.Data["json"] = &errinfo
  805. this.ServeJSON()
  806. } else {
  807. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  808. errinfo.Code = -1
  809. this.Data["json"] = &errinfo
  810. this.ServeJSON()
  811. }
  812. }
  813. // @Title 添加
  814. // @Description 新增
  815. // @Success 200 {object} controllers.Request
  816. // @router /addinfochangeitemch [post]
  817. func (this *InfoChangeController) AddInfoChangeItemCh() {
  818. var model InfoChangeItemsAll
  819. var jsonBlob = this.Ctx.Input.RequestBody
  820. svc := infochange.GetInfoChangeService(utils.DBE)
  821. json.Unmarshal(jsonBlob, &model)
  822. var err error
  823. where := " SupplierId = " + model.SupplierId
  824. where = where + " and InfoId = " + model.MInfoId
  825. var deleteEntity infochange.OilInfoChangeItem
  826. delMainId, _ := strconv.Atoi(model.MInfoId)
  827. deleteEntity.InfoId = delMainId
  828. svc.DBE.Delete(deleteEntity)
  829. var infoitementitys []infochange.OilInfoChangeItem
  830. for i := 0; i < len(model.InfochangeForm); i++ {
  831. var infoitementity infochange.OilInfoChangeItem
  832. infoitementity.SelectItem = model.InfochangeForm[i].SelectItem
  833. infoitementity.SelectItemName = model.InfochangeForm[i].SelectItemName
  834. infoitementity.ChangeInfo = model.InfochangeForm[i].ChangeInfo
  835. infoitementity.BeChangeInfo = model.InfochangeForm[i].BeChangeInfo
  836. infoitementity.ChangeStatus = 0
  837. infoitementity.SupplierId, _ = strconv.Atoi(model.SupplierId)
  838. infoitementity.InfoId, _ = strconv.Atoi(model.MInfoId)
  839. infoitementity.CreateOn = time.Now()
  840. infoitementity.CreateBy = this.User.Realname
  841. infoitementity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  842. infoitementitys = append(infoitementitys, infoitementity)
  843. }
  844. _, err = svc.InsertEntityBytbl(""+OilInfoChangeItemName, &infoitementitys)
  845. var errinfo ErrorDataInfo
  846. if err == nil {
  847. //新增
  848. errinfo.Message = "添加成功!"
  849. errinfo.Code = 0
  850. //errinfo.Item = model.Id
  851. this.Data["json"] = &errinfo
  852. this.ServeJSON()
  853. } else {
  854. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  855. errinfo.Code = -1
  856. this.Data["json"] = &errinfo
  857. this.ServeJSON()
  858. }
  859. }
  860. // @Title 获取二级初审人员
  861. // @Description 获取二级初审人员
  862. // @router /getauditerbydept/:deptId [get]
  863. func (this *InfoChangeController) GetAuditerByDept() {
  864. Id := this.Ctx.Input.Param(":deptId")
  865. //var auditWorkflow auditsetting.Base_OilAuditSetting
  866. rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  867. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, Id, workflow.FIRST_TRIAL, &auditWorkflow)
  868. var userlist []userRole.Base_User
  869. where := " CompanyId = " + Id
  870. rsvc.GetEntities(&userlist, where)
  871. var datainfo ErrorDataInfo
  872. datainfo.Item = userlist
  873. this.Data["json"] = &datainfo
  874. this.ServeJSON()
  875. }
  876. // @Title 获取企业法规处人员
  877. // @Description 获取企业法规处人员
  878. // @router /getauditer [get]
  879. func (this *InfoChangeController) GetAuditer() {
  880. //svc := infochange.GetInfoChangeService(utils.DBE)
  881. //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  882. var userlist []userRole.Base_User
  883. var setting auditsetting.Base_OilAuditSetting
  884. svc := userRole.GetUserService(utils.DBE)
  885. where := "AuditStepCode='" + workflow.PROF_REGULATION + "'"
  886. svc.GetEntity(&setting, where)
  887. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  888. topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT")
  889. ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  890. tempstr := strings.Join(ids, ",")
  891. userIds := strings.Replace(tempstr, "uid_", "", -1)
  892. userIds = strings.Trim(userIds, ",")
  893. if userIds != "" {
  894. where := "Id in (" + userIds + ")" + "and UnitId=" + topid
  895. svc.GetEntities(&userlist, where)
  896. }
  897. //var users []userRole.Base_RoleList
  898. //certSrv.GetAuditUser("100000178", workflow.PROF_REGULATION, &users)
  899. //var users []suppliercert.UserList
  900. // where := "OrganizeId=100000178 and AuditStepCode='" + workflow.PROF_REGULATION + "'"
  901. //svc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  902. var datainfo ErrorDataInfo
  903. datainfo.Item = userlist
  904. this.Data["json"] = &datainfo
  905. this.ServeJSON()
  906. }
  907. // @Title 添加
  908. // @Description 新增信息变更
  909. // @Success 200 {object} controllers.Request
  910. // @router /addinfomain [post]
  911. func (this *InfoChangeController) AddInfoMain() {
  912. SupplierId := this.GetString("SupplierId")
  913. Remark := this.GetString("Remark")
  914. var infochmain infochange.OilInfoChange
  915. var infochm []infochange.OilInfoChange
  916. var suppliermodel supplier.OilSupplier
  917. var errinfo ErrorDataInfo
  918. svc := infochange.GetInfoChangeService(utils.DBE)
  919. where := " SupplierId = " + SupplierId + " and Status < 11 and Status != 8"
  920. svc.GetEntitysByWhere(OilInfoChangeName, where, &infochm)
  921. if len(infochm) > 0 {
  922. errinfo.Message = "有已提交在申请中的信息变更,请审批完成后再提交!"
  923. errinfo.Code = -1
  924. this.Data["json"] = &errinfo
  925. this.ServeJSON()
  926. return
  927. }
  928. svc.GetEntityById(SupplierId, &suppliermodel)
  929. infochmain.Status = "0"
  930. infochmain.SupplierName = suppliermodel.SupplierName
  931. infochmain.OldSupplierName = suppliermodel.SupplierName
  932. infochmain.PACNumber = suppliermodel.PACNumber
  933. infochmain.SupplierCertificate = suppliermodel.SupplierCertificate
  934. infochmain.MgrUnit = suppliermodel.MgrUnit
  935. infochmain.OilCertificateNo = suppliermodel.OilCertificateNo
  936. infochmain.OperType = suppliermodel.OperType
  937. infochmain.Country = suppliermodel.Country
  938. infochmain.MaunAgent = suppliermodel.MaunAgent
  939. infochmain.CommercialNo = suppliermodel.CommercialNo
  940. infochmain.OrganCode = suppliermodel.OrganCode
  941. infochmain.SupplierId, _ = strconv.Atoi(SupplierId)
  942. infochmain.Remark = Remark
  943. infochmain.CreateOn = time.Now()
  944. infochmain.CreateBy = this.User.Realname
  945. infochmain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  946. _, err := svc.InsertEntityBytbl(OilInfoChangeName, &infochmain)
  947. if err == nil {
  948. errinfo.Message = "添加成功!"
  949. errinfo.Code = 0
  950. errinfo.Item = infochmain.Id
  951. this.Data["json"] = &errinfo
  952. this.ServeJSON()
  953. } else {
  954. errinfo.Message = "添加失败!"
  955. errinfo.Code = -1
  956. this.Data["json"] = &errinfo
  957. this.ServeJSON()
  958. }
  959. }
  960. // @Title 获取信息变更企业名称
  961. // @Description 获取实体
  962. // @Success 200 {object}
  963. // @router /addsupplierlist [get]
  964. func (this *InfoChangeController) GetAddSupplierList() {
  965. svc := infochange.GetInfoChangeService(utils.DBE)
  966. var supplierlist []annualaudit.Suppliername
  967. where := "1=1"
  968. //企业用户必须加创建人条件
  969. if this.User.IsCompanyUser == 1 {
  970. where = where + " and CreateUserId = '" + this.User.Id + "'"
  971. }
  972. //else { // 二级单位可以为所有企业提交信息变更 2020-03-12
  973. // //超级管理员和有查看所有数据权限的用户不加条件
  974. // svcPerm := permission.GetPermissionService(utils.DBE)
  975. // isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  976. // if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  977. // where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  978. // }
  979. //}
  980. //supplierlist = svc.GetSupplierList(""+OilSupplierName, where)
  981. svc.GetEntitysByWhere(OilSupplierName, where, &supplierlist)
  982. var datainfo DataInfo
  983. datainfo.Items = supplierlist
  984. this.Data["json"] = &datainfo
  985. this.ServeJSON()
  986. }
  987. // @Title 提交审批
  988. // @Description 提交审批
  989. // @Success 200 {object} controllers.Request
  990. // @router /commitaudit/:id [post]
  991. func (this *InfoChangeController) CommitAuditEntity() {
  992. //suppId := this.Ctx.Input.Param(":id")
  993. firstAudit := this.GetString("auditer")
  994. fushenauditer := this.GetString("fushenauditer")
  995. Remark := this.GetString("Remark")
  996. InfoId := this.GetString("MInfoId")
  997. var setting auditsetting.Base_OilAuditSetting
  998. var userlist []userRole.Base_User
  999. usvc := userRole.GetUserService(utils.DBE)
  1000. where := ""
  1001. if this.User.IsCompanyUser == 1 {
  1002. where = "AuditStepCode='" + workflow.SUB_OFFICE_BG + "'"
  1003. usvc.GetEntity(&setting, where)
  1004. ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  1005. tempstr := strings.Join(ids, ",")
  1006. uids := strings.Replace(tempstr, "uid_", "", -1)
  1007. uids = strings.Trim(uids, ",")
  1008. if uids != "" {
  1009. where := "Id in (" + uids + ")" + " and UnitId=" + firstAudit
  1010. usvc.GetEntities(&userlist, where)
  1011. }
  1012. userIds := ""
  1013. for _, tmpUser := range userlist {
  1014. userIds += strconv.Itoa(tmpUser.Id) + ","
  1015. }
  1016. firstAudit = strings.Trim(userIds, ",")
  1017. }
  1018. //取出审批列表
  1019. svc := infochange.GetInfoChangeService(utils.DBE)
  1020. var infochangeentity infochange.OilInfoChange
  1021. infwhere := " Id = " + InfoId
  1022. svc.GetEntity(&infochangeentity, infwhere)
  1023. var errinfo ErrorDataInfo
  1024. defer func() { //finally处理失败的异常
  1025. if err := recover(); err != nil {
  1026. errinfo.Message = "提交失败," + err.(string)
  1027. errinfo.Code = -1
  1028. this.Data["json"] = &errinfo
  1029. this.ServeJSON()
  1030. } else {
  1031. //返回正确结果
  1032. errinfo.Message = "审核提交成功"
  1033. errinfo.Code = 0
  1034. this.Data["json"] = &errinfo
  1035. this.ServeJSON()
  1036. }
  1037. }()
  1038. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1039. processInstanceId := ""
  1040. businessKey := ""
  1041. businessKey = InfoId + "-" + strconv.Itoa(infochangeentity.AuditIndex)
  1042. result := strconv.Itoa(this.User.IsCompanyUser)
  1043. processInstanceId = svcActiviti.StartProcess2(workflow.OIL_INFO_CHANGE, businessKey, this.User.Id, result, infochangeentity.SupplierTypeCode, infochangeentity.SupplierName)
  1044. var ActiComplete workflow.ActiCompleteVM
  1045. ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
  1046. ActiComplete.BusinessKey = businessKey
  1047. ActiComplete.UserNames = firstAudit
  1048. ActiComplete.UserId = this.User.Id
  1049. ActiComplete.Result = result
  1050. ActiComplete.Remarks = Remark
  1051. ActiComplete.CallbackUrl = ""
  1052. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1053. if receiveVal == "true" {
  1054. errinfo.Message = "提交成功!"
  1055. errinfo.Code = 0
  1056. this.Data["json"] = &errinfo
  1057. this.ServeJSON()
  1058. } else {
  1059. errinfo.Message = "工作流异常,请联系管理员!"
  1060. errinfo.Code = -1
  1061. this.Data["json"] = &errinfo
  1062. this.ServeJSON()
  1063. return
  1064. }
  1065. //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
  1066. if this.User.IsCompanyUser == 1 {
  1067. infochangeentity.Status = suppliercert.FEN_TRIAL_STATUS
  1068. } else {
  1069. infochangeentity.Status = suppliercert.FIRST_TRIAL_STATUS
  1070. }
  1071. infochangeentity.WorkFlowId = processInstanceId
  1072. infochangeentity.FenbanAudit, _ = strconv.Atoi(firstAudit)
  1073. infochangeentity.FirstAudit, _ = strconv.Atoi(firstAudit)
  1074. infochangeentity.SecondAudit, _ = strconv.Atoi(fushenauditer)
  1075. infochangeentity.AuditIndex = infochangeentity.AuditIndex + 1
  1076. infochangeentity.BusinessKey = ActiComplete.BusinessKey
  1077. infochangeentity.CreateOn = time.Now()
  1078. infochangeentity.CreateBy = this.User.Realname
  1079. infochangeentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1080. cols := []string{
  1081. "Id",
  1082. "WorkflowId",
  1083. "Status",
  1084. "Step",
  1085. "FenbanAudit",
  1086. "FirstAudit",
  1087. "SecondAudit",
  1088. "AuditIndex",
  1089. "BusinessKey",
  1090. "CreateOn",
  1091. "CreateBy",
  1092. "CreateUserId",
  1093. }
  1094. svc.UpdateEntityByIdCols(InfoId, infochangeentity, cols)
  1095. }
  1096. // @Title 提交审批
  1097. // @Description 提交审批
  1098. // @Success 200 {object} controllers.Request
  1099. // @router /audit/:id [post]
  1100. func (this *InfoChangeController) AuditEntity() {
  1101. suppId := this.Ctx.Input.Param(":id")
  1102. firstAudit := this.GetString("auditer")
  1103. Remark := this.GetString("Remark")
  1104. InfoId := this.GetString("MInfoId")
  1105. //取出审批列表
  1106. svc := infochange.GetInfoChangeService(utils.DBE)
  1107. var infoitems []infochange.OilInfoChangeItem
  1108. where := " SupplierId = " + suppId
  1109. svc.GetEntities(&infoitems, where)
  1110. var infochangeentity infochange.OilInfoChange
  1111. infwhere := " Id = " + InfoId
  1112. svc.GetEntity(&infochangeentity, infwhere)
  1113. var infomodel infochange.OilInfoChangeItem
  1114. var errinfo ErrorDataInfo
  1115. defer func() { //finally处理失败的异常
  1116. if err := recover(); err != nil {
  1117. errinfo.Message = "提交失败," + err.(string)
  1118. errinfo.Code = -1
  1119. this.Data["json"] = &errinfo
  1120. this.ServeJSON()
  1121. } else {
  1122. //返回正确结果
  1123. errinfo.Message = "审核提交成功"
  1124. errinfo.Code = 0
  1125. this.Data["json"] = &errinfo
  1126. this.ServeJSON()
  1127. }
  1128. }()
  1129. var items string
  1130. for i := 0; i < len(infoitems); i++ {
  1131. items = fmt.Sprintf("%s %s %s %s", items, infoitems[i].SelectItem, ","+infoitems[i].BeChangeInfo, ","+infoitems[i].ChangeInfo+";")
  1132. }
  1133. items = strings.Trim(items, ";")
  1134. infowhere := " Id = " + InfoId
  1135. svc.Updateentityinfo(OilInfoChangeName, items, infowhere)
  1136. //修改从表infoid
  1137. for i := 0; i < len(infoitems); i++ {
  1138. infomodel.InfoId, _ = strconv.Atoi(InfoId)
  1139. err := svc.UpdateEntityBytbl(OilInfoChangeItemName, infoitems[i].Id, &infomodel, []string{"InfoId"})
  1140. fmt.Println(err)
  1141. }
  1142. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1143. processInstanceId := ""
  1144. businessKey := ""
  1145. if infochangeentity.WorkFlowId == "0" || len(infochangeentity.WorkFlowId) <= 0 {
  1146. //启动工作流
  1147. businessKey = InfoId + "-" + strconv.Itoa(infochangeentity.AuditIndex)
  1148. processInstanceId = svcActiviti.StartProcess(workflow.OIL_INFO_CHANGE, businessKey, this.User.Id)
  1149. }
  1150. var ActiComplete workflow.ActiCompleteVM
  1151. ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
  1152. ActiComplete.BusinessKey = businessKey
  1153. ActiComplete.UserNames = firstAudit
  1154. ActiComplete.UserId = this.User.Id
  1155. ActiComplete.Result = "1"
  1156. ActiComplete.Remarks = Remark
  1157. ActiComplete.CallbackUrl = ""
  1158. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1159. if receiveVal == "true" {
  1160. errinfo.Message = "提交成功!"
  1161. errinfo.Code = 0
  1162. this.Data["json"] = &errinfo
  1163. this.ServeJSON()
  1164. } else {
  1165. errinfo.Message = "工作流异常,请联系管理员!"
  1166. errinfo.Code = -1
  1167. this.Data["json"] = &errinfo
  1168. this.ServeJSON()
  1169. return
  1170. }
  1171. //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
  1172. infochangeentity.WorkFlowId = processInstanceId
  1173. infochangeentity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
  1174. infochangeentity.AuditIndex = infochangeentity.AuditIndex + 1
  1175. infochangeentity.BusinessKey = ActiComplete.BusinessKey
  1176. infochangeentity.CreateOn = time.Now()
  1177. infochangeentity.CreateBy = this.User.Realname
  1178. infochangeentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1179. cols := []string{
  1180. "Id",
  1181. "WorkflowId",
  1182. "Status",
  1183. "Step",
  1184. "FirstAudit",
  1185. "AuditIndex",
  1186. "BusinessKey",
  1187. "CreateOn",
  1188. "CreateBy",
  1189. "CreateUserId",
  1190. }
  1191. svc.UpdateEntityByIdCols(InfoId, infochangeentity, cols)
  1192. }
  1193. // @Title 审批
  1194. // @Description 审批
  1195. // @Success 200 {object} controllers.Request
  1196. // @router /infoaudit [post]
  1197. func (this *InfoChangeController) InfoAudit() {
  1198. t := time.Now()
  1199. svc := infochange.GetInfoChangeService(utils.DBE)
  1200. var jsonblob = this.Ctx.Input.RequestBody
  1201. var dataother InfoShenHeModel
  1202. json.Unmarshal(jsonblob, &dataother)
  1203. //取出审批列表
  1204. var infoid = dataother.InfoId
  1205. var infomodel infochange.OilInfoChange
  1206. svc.GetEntityById(utils.ToStr(dataother.InfoId), &infomodel)
  1207. var infoitems []infochange.OilInfoChangeItem
  1208. where := "SupplierId = " + utils.ToStr(dataother.SuppId) + " and InfoId = " + utils.ToStr(dataother.InfoId)
  1209. svc.GetEntities(&infoitems, where)
  1210. var errinfo ErrorDataInfo
  1211. defer func() { //finally处理失败的异常
  1212. if err := recover(); err != nil {
  1213. errinfo.Message = "提交失败," + err.(string)
  1214. errinfo.Code = -1
  1215. this.Data["json"] = &errinfo
  1216. this.ServeJSON()
  1217. } else {
  1218. //返回正确结果
  1219. errinfo.Message = "审核提交成功"
  1220. errinfo.Code = 0
  1221. this.Data["json"] = &errinfo
  1222. this.ServeJSON()
  1223. }
  1224. }()
  1225. //审核状态判断进行的操作
  1226. step := 2
  1227. status := ""
  1228. backstatus := "0"
  1229. var userIds string
  1230. if infomodel.Status == suppliercert.FEN_TRIAL_STATUS {
  1231. userIds = utils.ToStr(dataother.FirstAudit)
  1232. status = suppliercert.FIRST_TRIAL_STATUS
  1233. step = 2
  1234. backstatus = suppliercert.NO_FEN_TRIAL_STATUS
  1235. if dataother.SuccessStatus == 1 {
  1236. infomodel.FirstAudit = dataother.FirstAudit
  1237. infomodel.SecondAudit = dataother.SecondAudit
  1238. cols := []string{
  1239. "FirstAudit",
  1240. "SecondAudit",
  1241. }
  1242. svc.UpdateEntityByIdCols(infoid, infomodel, cols)
  1243. }
  1244. }
  1245. if infomodel.Status == suppliercert.FIRST_TRIAL_STATUS {
  1246. userIds = utils.ToStr(infomodel.SecondAudit)
  1247. status = suppliercert.SECOND_TRIAL_STATUS
  1248. step = 2
  1249. backstatus = suppliercert.NOPASS_STATUS
  1250. } else if infomodel.Status == suppliercert.SECOND_TRIAL_STATUS {
  1251. status = suppliercert.CENT_AUDIT_STATUS
  1252. backstatus = suppliercert.NO_SECOND_TRIAL_STATUS
  1253. step = 2
  1254. //dictSvc := items.GetItemsService(utils.DBE)
  1255. //deptIds := dictSvc.GetKeyValueItems("CENT_AUDIT")
  1256. //var users []userRole.Base_RoleList
  1257. //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1258. //for _, dept := range deptIds {
  1259. // certSrv.GetAuditUser(dept.Value, workflow.PROF_REGULATION, &users)
  1260. // for _, tmpUser := range users {
  1261. // userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
  1262. // }
  1263. //}
  1264. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1265. topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT")
  1266. var userlist []userRole.Base_User
  1267. var setting auditsetting.Base_OilAuditSetting
  1268. usvc := userRole.GetUserService(utils.DBE)
  1269. where := "AuditStepCode='" + workflow.PROF_REGULATION + "'"
  1270. svc.GetEntity(&setting, where)
  1271. ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  1272. tempstr := strings.Join(ids, ",")
  1273. uids := strings.Replace(tempstr, "uid_", "", -1)
  1274. uids = strings.Trim(uids, ",")
  1275. if uids != "" {
  1276. where := "Id in (" + uids + ")" + " and UnitId=" + topid
  1277. svc.GetEntities(&userlist, where)
  1278. }
  1279. for _, tmpUser := range userlist {
  1280. userIds += strconv.Itoa(tmpUser.Id) + ","
  1281. }
  1282. userIds = strings.Trim(userIds, ",")
  1283. } else if infomodel.Status == suppliercert.CENT_AUDIT_STATUS {
  1284. status = suppliercert.ALL_PASE_STATUS
  1285. step = 3
  1286. backstatus = suppliercert.NO_CENT_AUDIT_STATUS
  1287. }
  1288. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1289. var ActiComplete workflow.ActiCompleteVM
  1290. ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
  1291. ActiComplete.BusinessKey = infomodel.BusinessKey
  1292. ActiComplete.UserNames = userIds
  1293. ActiComplete.UserId = this.User.Id
  1294. ActiComplete.Remarks = dataother.AuditorRemark
  1295. ActiComplete.CallbackUrl = ""
  1296. var myerr error
  1297. if dataother.SuccessStatus == 1 {
  1298. ActiComplete.Result = "1"
  1299. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1300. if infomodel.Status == suppliercert.CENT_AUDIT_STATUS {
  1301. //信息更新
  1302. var infochangeitemmodel infochange.OilInfoChangeItem
  1303. var supmodel supplier.OilSupplier
  1304. infochangeitemmodel.ChangeStatus = 1
  1305. infomodel.Status = status
  1306. itemswhere := "InfoId = " + utils.ToStr(infoid)
  1307. myerr = svc.UpdateEntityBywheretbl(OilInfoChangeItemName, &infochangeitemmodel, []string{"ChangeStatus"}, itemswhere)
  1308. myerr = this.updatesupplier(OilSupplierName, dataother.SuppId, infoitems, supmodel)
  1309. //资质更新
  1310. //where := "SupplierId = " + utils.ToStr(dataother.SuppId) + " and SupType = 2"
  1311. //var supfilemodel supplierfile.OilSupplierFile
  1312. //supfilemodel.SupType = 3
  1313. //svc.UpdateEntityBywheretbl(OilSupplierFileName, &supfilemodel, []string{"SupType"}, where)
  1314. // 级别 一级变二级 删除不符合的准入项和资质
  1315. for _, item := range infoitems {
  1316. if item.SelectItem == "Grade" && (item.BeChangeInfo == "1" && item.ChangeInfo == "2") {
  1317. this.BusinessDelete(utils.ToStr(dataother.SuppId))
  1318. }
  1319. }
  1320. // 删除资质及准入项
  1321. this.FileDelete(strconv.Itoa(dataother.SuppId))
  1322. s := time.Since(t)
  1323. log.Println(s, "============================")
  1324. var qualdetail []qualchange.OilQualChangeDetail
  1325. where1 := "SupplierId = " + utils.ToStr(dataother.SuppId) + " and ParentId=" + strconv.Itoa(infoid)
  1326. svc.GetEntities(&qualdetail, where1)
  1327. if len(qualdetail) > 0 {
  1328. for i := 0; i < len(qualdetail); i++ {
  1329. var supfilemodel supplierfile.OilSupplierFile
  1330. supfilemodel.FileName = qualdetail[i].FileName
  1331. supfilemodel.FileUrl = qualdetail[i].FileUrl
  1332. supfilemodel.EffectDate = qualdetail[i].EffectDate
  1333. svc.UpdateEntityBytbl(OilSupplierFileName, qualdetail[i].FileId, &supfilemodel, []string{"FileName", "FileUrl", "EffectDate"})
  1334. }
  1335. }
  1336. }
  1337. infomodel.Status = status
  1338. infomodel.Step = step
  1339. if receiveVal == "true" {
  1340. cols := []string{
  1341. "Id",
  1342. "Status",
  1343. "Step",
  1344. }
  1345. _, myerr = svc.UpdateEntityByIdCols(infoid, infomodel, cols)
  1346. if myerr == nil {
  1347. errinfo.Message = "提交成功!"
  1348. errinfo.Code = 0
  1349. this.Data["json"] = &errinfo
  1350. this.ServeJSON()
  1351. } else {
  1352. errinfo.Message = "提交失败!"
  1353. errinfo.Code = -1
  1354. this.Data["json"] = &errinfo
  1355. this.ServeJSON()
  1356. }
  1357. } else {
  1358. errinfo.Message = "工作流异常,请联系管理员!"
  1359. errinfo.Code = -1
  1360. this.Data["json"] = &errinfo
  1361. this.ServeJSON()
  1362. return
  1363. }
  1364. } else {
  1365. ActiComplete.Result = "0"
  1366. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1367. if receiveVal == "true" {
  1368. if infomodel.Status == suppliercert.CENT_AUDIT_STATUS {
  1369. infomodel.Status = backstatus
  1370. } else {
  1371. infomodel.Status = backstatus
  1372. // 审批历史
  1373. var audithistoryentity audithistory.Base_AuditHistory
  1374. audithistoryentity.EntityId = infoid
  1375. audithistoryentity.WorkflowId = infomodel.WorkFlowId
  1376. audithistoryentity.Process = ActiComplete.ProcessKey
  1377. audithistoryentity.BusinessKey = ActiComplete.BusinessKey
  1378. audithistoryentity.Type = "04"
  1379. audithistoryentity.BackStep = infomodel.Status
  1380. audithistoryentity.Index = infomodel.AuditIndex
  1381. audithistoryentity.CreateOn = time.Now()
  1382. audithistoryentity.CreateBy = this.User.Realname
  1383. audithistoryentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1384. _, myerr = svc.InsertEntity(audithistoryentity)
  1385. infomodel.WorkFlowId = ""
  1386. }
  1387. infomodel.Step = 1
  1388. cols := []string{
  1389. "Status",
  1390. "Step",
  1391. "WorkFlowId",
  1392. }
  1393. _, myerr := svc.UpdateEntityByIdCols(infoid, infomodel, cols)
  1394. if myerr == nil {
  1395. errinfo.Message = "提交成功!"
  1396. errinfo.Code = 0
  1397. this.Data["json"] = &errinfo
  1398. this.ServeJSON()
  1399. } else {
  1400. errinfo.Message = "提交失败!"
  1401. errinfo.Code = -1
  1402. this.Data["json"] = &errinfo
  1403. this.ServeJSON()
  1404. }
  1405. } else {
  1406. errinfo.Message = "工作流异常,请联系管理员!"
  1407. errinfo.Code = -1
  1408. this.Data["json"] = &errinfo
  1409. this.ServeJSON()
  1410. return
  1411. }
  1412. }
  1413. }
  1414. // @Title 企业用户提交按钮 --启动工作流
  1415. // @Description 企业用户提交按钮
  1416. // @Success 200 {object} controllers.Request
  1417. // @router /company-audit/:id [post]
  1418. func (this *InfoChangeController) CompanyAuditEntity() {
  1419. infoId := this.Ctx.Input.Param(":id")
  1420. unitId := this.GetString("unitId")
  1421. AuditRemark := this.GetString("AuditRemark")
  1422. var errinfo ErrorDataInfo
  1423. defer func() { //finally处理失败的异常
  1424. if err := recover(); err != nil {
  1425. errinfo.Message = err.(string)
  1426. errinfo.Code = -1
  1427. this.Data["json"] = &errinfo
  1428. this.ServeJSON()
  1429. } else {
  1430. //返回正确结果
  1431. errinfo.Message = "提交成功"
  1432. errinfo.Code = 0
  1433. this.Data["json"] = &errinfo
  1434. this.ServeJSON()
  1435. }
  1436. }()
  1437. if this.User.IsCompanyUser == 0 {
  1438. // 0二级单位; 1企业用户
  1439. panic("非企业用户,请用分办功能提交!")
  1440. }
  1441. //取出准入申请表
  1442. infoSrv := infochange.GetInfoChangeService(utils.DBE)
  1443. var infoChangeEntity infochange.OilInfoChange
  1444. infoSrv.GetEntityById(infoId, &infoChangeEntity)
  1445. // TODO 检查是否可以提交
  1446. //infoSrv.IsSupplierCertCanSubmit(strconv.Itoa(supplierCertEntity.Id), certId)
  1447. //取出企业主表
  1448. supplierSvc := supplier.GetOilSupplierService(utils.DBE)
  1449. var supplierEntity supplier.OilSupplier
  1450. //检查是否可提交
  1451. supplierSvc.GetEntityById(infoChangeEntity.SupplierId, &supplierEntity)
  1452. status, _ := strconv.Atoi(infoChangeEntity.Status)
  1453. if status > 0 {
  1454. panic("工作流已经启动,请刷新重试!")
  1455. }
  1456. stepCode := workflow.SUB_OFFICE_BG
  1457. auditSettingService := auditsetting.GetOilAuditSettingService(utils.DBE)
  1458. approverIds := auditSettingService.GetApproverIdsByStepCodeAndUnitId(stepCode, unitId)
  1459. if approverIds == "" {
  1460. panic("该分办单位未配置审批人")
  1461. }
  1462. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1463. //启动工作流
  1464. businessKey := infoChangeEntity.BusinessKey
  1465. processInstanceId := infoChangeEntity.WorkFlowId
  1466. // 如果被驳回,不再新启工作流
  1467. if processInstanceId == "" {
  1468. businessKey = infoId + "-" + strconv.Itoa(infoChangeEntity.AuditIndex)
  1469. processInstanceId = svcActiviti.StartProcess2(workflow.OIL_INFO_CHANGE, businessKey, this.User.Id, "1", infoChangeEntity.SupplierTypeCode, supplierEntity.SupplierName)
  1470. if len(processInstanceId) <= 0 {
  1471. panic("工作流启动失败!")
  1472. }
  1473. infoChangeEntity.AuditIndex += 1
  1474. }
  1475. // 将启动和工作流,选择的分办单位id记录下来
  1476. cols := []string{
  1477. "Id",
  1478. "WorkflowId",
  1479. "BusinessKey",
  1480. "ProcessKey",
  1481. "CommitComId",
  1482. "AuditIndex",
  1483. }
  1484. infoChangeEntity.ProcessKey = workflow.OIL_INFO_CHANGE
  1485. infoChangeEntity.BusinessKey = businessKey
  1486. infoChangeEntity.WorkFlowId = processInstanceId
  1487. infoChangeEntity.CommitComId = unitId
  1488. infoSrv.UpdateEntityByIdCols(infoId, infoChangeEntity, cols)
  1489. var ActiComplete workflow.ActiCompleteVM
  1490. ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
  1491. ActiComplete.BusinessKey = businessKey
  1492. ActiComplete.UserId = this.User.Id
  1493. ActiComplete.Result = "1" //提交给二级单位分办
  1494. ActiComplete.Remarks = AuditRemark
  1495. ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
  1496. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1497. if receiveVal != "true" {
  1498. panic("工作流异常,请联系管理员!" + receiveVal)
  1499. }
  1500. }
  1501. // @Title 二级单位提交审批 --启动工作流
  1502. // @Description 二级单位提交审批
  1503. // @Success 200 {object} controllers.Request
  1504. // @router /unit-audit/:id [post]
  1505. func (this *InfoChangeController) UnitAuditEntity() {
  1506. infoId := this.Ctx.Input.Param(":id")
  1507. firstAudit := this.GetString("FirstAudit")
  1508. secondAudit := this.GetString("SecondAudit")
  1509. AuditRemark := this.GetString("AuditRemark")
  1510. userId := this.User.Id
  1511. var baseUserInfo userRole.Base_User
  1512. userService := userRole.GetUserService(utils.DBE)
  1513. userService.GetEntityById(userId, &baseUserInfo)
  1514. unitId := baseUserInfo.UnitId
  1515. var errinfo ErrorDataInfo
  1516. defer func() { //finally处理失败的异常
  1517. if err := recover(); err != nil {
  1518. errinfo.Message = err.(string)
  1519. errinfo.Code = -1
  1520. this.Data["json"] = &errinfo
  1521. this.ServeJSON()
  1522. } else {
  1523. //返回正确结果
  1524. errinfo.Message = "审核提交成功"
  1525. errinfo.Code = 0
  1526. this.Data["json"] = &errinfo
  1527. this.ServeJSON()
  1528. }
  1529. }()
  1530. //取出准入表信息
  1531. svc := infochange.GetInfoChangeService(utils.DBE)
  1532. var infoChangeEntity infochange.OilInfoChange
  1533. svc.GetEntityById(infoId, &infoChangeEntity)
  1534. // TODO 检查是否可提交
  1535. //svc.IsSupplierCertCanSubmit(strconv.Itoa(supplierCertEntity.Id), certId)
  1536. //取出企业主表
  1537. supplierSvc := supplier.GetOilSupplierService(utils.DBE)
  1538. var supplierEntity supplier.OilSupplier
  1539. supplierSvc.GetEntityById(infoChangeEntity.SupplierId, &supplierEntity)
  1540. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1541. //启动工作流
  1542. businessKey := infoChangeEntity.BusinessKey
  1543. processInstanceId := infoChangeEntity.WorkFlowId
  1544. // 如果被驳回,不再新启工作流
  1545. if processInstanceId == "" {
  1546. businessKey = infoId + "-" + strconv.Itoa(infoChangeEntity.AuditIndex)
  1547. processInstanceId = svcActiviti.StartProcess2(workflow.OIL_INFO_CHANGE, businessKey, this.User.Id, "1", infoChangeEntity.SupplierTypeCode, supplierEntity.SupplierName)
  1548. if len(processInstanceId) <= 0 {
  1549. panic("工作流启动失败!")
  1550. }
  1551. infoChangeEntity.AuditIndex += 1
  1552. }
  1553. // 将启动和工作流,选择的初审和复审人员保存下来
  1554. cols := []string{
  1555. "Id",
  1556. "FirstAudit",
  1557. "SecondAudit",
  1558. "WorkflowId",
  1559. "BusinessKey",
  1560. "ProcessKey",
  1561. "CommitComId",
  1562. "AuditIndex",
  1563. }
  1564. infoChangeEntity.ProcessKey = workflow.OIL_INFO_CHANGE
  1565. infoChangeEntity.BusinessKey = businessKey
  1566. infoChangeEntity.WorkFlowId = processInstanceId
  1567. infoChangeEntity.FirstAudit, _ = strconv.Atoi(firstAudit)
  1568. infoChangeEntity.SecondAudit, _ = strconv.Atoi(secondAudit)
  1569. infoChangeEntity.CommitComId = strconv.Itoa(unitId)
  1570. svc.UpdateEntityByIdCols(infoId, infoChangeEntity, cols)
  1571. var ActiComplete workflow.ActiCompleteVM
  1572. ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
  1573. ActiComplete.BusinessKey = infoChangeEntity.BusinessKey
  1574. ActiComplete.UserId = this.User.Id // 当前审批操作人员
  1575. //ActiComplete.UserNames = secondAudit // 当前审批操作人员
  1576. ActiComplete.Result = "2" //分办提交给二级单位初审
  1577. ActiComplete.Remarks = AuditRemark
  1578. ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
  1579. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1580. if receiveVal != "true" {
  1581. panic("工作流异常,请联系管理员!" + receiveVal)
  1582. }
  1583. }
  1584. // @Title 二级单位分办 --审批
  1585. // @Description 二级分办
  1586. // @Success 200 {object} controllers.Request
  1587. // @router /separate-audit/:id [post]
  1588. func (this *InfoChangeController) SeparateAuditEntity() {
  1589. infoId := this.Ctx.Input.Param(":id")
  1590. //SuppId := this.GetString("SuppId")
  1591. Result := this.GetString("Result")
  1592. firstAudit := this.GetString("FirstAudit")
  1593. secondAudit := this.GetString("SecondAudit")
  1594. AuditRemark := this.GetString("AuditRemark")
  1595. var errinfo ErrorDataInfo
  1596. defer func() { //finally处理失败的异常
  1597. if err := recover(); err != nil {
  1598. errinfo.Message = err.(string)
  1599. errinfo.Code = -1
  1600. this.Data["json"] = &errinfo
  1601. this.ServeJSON()
  1602. } else {
  1603. //返回正确结果
  1604. errinfo.Message = "审核提交成功"
  1605. errinfo.Code = 0
  1606. this.Data["json"] = &errinfo
  1607. this.ServeJSON()
  1608. }
  1609. }()
  1610. // 取出准入表信息
  1611. infoSrv := infochange.GetInfoChangeService(utils.DBE)
  1612. var infoChangeEntity infochange.OilInfoChange
  1613. infoSrv.GetEntityById(infoId, &infoChangeEntity)
  1614. if Result == "1" {
  1615. // 将选择的初审和复审人员保存下来
  1616. cols := []string{
  1617. "FirstAudit",
  1618. "SecondAudit",
  1619. }
  1620. infoChangeEntity.FirstAudit, _ = strconv.Atoi(firstAudit)
  1621. infoChangeEntity.SecondAudit, _ = strconv.Atoi(secondAudit)
  1622. infoSrv.UpdateEntityByIdCols(infoId, infoChangeEntity, cols)
  1623. }
  1624. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1625. var ActiComplete workflow.ActiCompleteVM
  1626. ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
  1627. ActiComplete.BusinessKey = infoChangeEntity.BusinessKey
  1628. ActiComplete.UserId = this.User.Id // 审批人员
  1629. // ActiComplete.UserNames = secondAudit // 初审人员
  1630. ActiComplete.Result = Result //分办完成后只向前走
  1631. ActiComplete.Remarks = AuditRemark
  1632. ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
  1633. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1634. if receiveVal != "true" {
  1635. panic("工作流异常,请联系管理员!" + receiveVal)
  1636. }
  1637. }
  1638. // @Title 分办之后的各级审批 --审批 包含:二级单位初审、复审, 企管法规处评审
  1639. // @Description 分办之后的各级审批
  1640. // @Success 200 {object} controllers.Request
  1641. // @router /common-audit/:id [post]
  1642. func (this *InfoChangeController) CommonAuditEntity() {
  1643. infoId := this.Ctx.Input.Param(":id")
  1644. result := this.GetString("result")
  1645. AuditRemark := this.GetString("AuditRemark")
  1646. var errinfo ErrorDataInfo
  1647. defer func() { //finally处理失败的异常
  1648. if err := recover(); err != nil {
  1649. errinfo.Message = err.(string)
  1650. errinfo.Code = -1
  1651. this.Data["json"] = &errinfo
  1652. this.ServeJSON()
  1653. } else {
  1654. //返回正确结果
  1655. errinfo.Message = "审核提交成功"
  1656. errinfo.Code = 0
  1657. this.Data["json"] = &errinfo
  1658. this.ServeJSON()
  1659. }
  1660. }()
  1661. //取出变更表信息
  1662. infoSrv := infochange.GetInfoChangeService(utils.DBE)
  1663. var infoChangeEntity infochange.OilInfoChange
  1664. infoSrv.GetEntityById(infoId, &infoChangeEntity)
  1665. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1666. var ActiComplete workflow.ActiCompleteVM
  1667. ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
  1668. ActiComplete.BusinessKey = infoChangeEntity.BusinessKey
  1669. ActiComplete.UserId = this.User.Id //审批人员
  1670. ActiComplete.Result = result //前台审批[同意、不同意]
  1671. ActiComplete.Remarks = AuditRemark
  1672. ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
  1673. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1674. if receiveVal != "true" {
  1675. panic("工作流异常,请联系管理员!" + receiveVal)
  1676. }
  1677. var infoChangeEntityAfterUpdate infochange.OilInfoChange
  1678. infoSrv.GetEntityById(infoId, &infoChangeEntityAfterUpdate)
  1679. if infoChangeEntityAfterUpdate.Status == suppliercert.STORE_STATUS {
  1680. fmt.Println("资质变更入库完成, 开始实际变更信息: supplierId" + strconv.Itoa(infoChangeEntityAfterUpdate.SupplierId) + "变更信息表ID: " + infoId)
  1681. var oilSupplier supplier.OilSupplier
  1682. var oldName supplier.OilSupplierOldName
  1683. var info infochange.OilInfoChangeItem
  1684. svc := supplier.GetOilSupplierService(utils.DBE)
  1685. svc.GetEntityByWhere(OilInfoChangeItemName, "SelectItem = 'SupplierName' and InfoId = " + infoId, &info)
  1686. // 曾用名存到主表
  1687. oilSupplier.OldSupplierName = info.BeChangeInfo
  1688. svc.UpdateEntityBywheretbl(OilSupplierName, &oilSupplier, []string{"OldSupplierName"}, "Id = " + strconv.Itoa(infoChangeEntityAfterUpdate.SupplierId))
  1689. oldName.OldName = info.BeChangeInfo
  1690. oldName.Name = info.ChangeInfo
  1691. oldName.SupplierId = infoChangeEntityAfterUpdate.SupplierId
  1692. oldName.GfId = 0
  1693. oldName.CreateOn = info.CreateOn
  1694. oldName.CreateBy = info.CreateBy
  1695. oldName.CreateUserId = info.CreateUserId
  1696. // 曾用名存到子表
  1697. svc.InsertEntityBytbl("OilSupplierOldName", &oldName)
  1698. this.updateChangeInfo(infoChangeEntityAfterUpdate.SupplierId, infoId)
  1699. }
  1700. }
  1701. // @Title 交费用户确认交费
  1702. // @Description 交费用户确认交费
  1703. // @Success 200 {object} controllers.Request
  1704. // @router /update-pay-status/:id [post]
  1705. func (this *InfoChangeController) UpdatePayStatus() {
  1706. infoId := this.Ctx.Input.Param(":id")
  1707. var errinfo ErrorInfo
  1708. if infoId == "" {
  1709. errinfo.Message = "操作失败!请求信息不完整"
  1710. errinfo.Code = -2
  1711. this.Data["json"] = &errinfo
  1712. this.ServeJSON()
  1713. return
  1714. }
  1715. infoSrv := infochange.GetInfoChangeService(utils.DBE)
  1716. var infoChangeEntity infochange.OilInfoChange
  1717. infoSrv.GetEntityById(infoId, &infoChangeEntity)
  1718. paySrv := paymentinfo.GetPaymentService(utils.DBE)
  1719. var paymentInfoEntities []paymentinfo.OilPaymentInfo
  1720. err := paySrv.GetPaymentInfoBySrcId(infoId, "1", &paymentInfoEntities)
  1721. if err != nil {
  1722. errinfo.Message = "未知错误,请稍后再试!"
  1723. errinfo.Code = -1
  1724. this.Data["json"] = &errinfo
  1725. this.ServeJSON()
  1726. }
  1727. if len(paymentInfoEntities) == 1 {
  1728. for _, item := range paymentInfoEntities {
  1729. if item.IsPay == "1" {
  1730. errinfo.Message = "已确认交费!请耐心等待"
  1731. errinfo.Code = -1
  1732. this.Data["json"] = &errinfo
  1733. this.ServeJSON()
  1734. }
  1735. if item.IsPay == "2" {
  1736. errinfo.Message = "已交费!请勿重复操作!"
  1737. errinfo.Code = -1
  1738. this.Data["json"] = &errinfo
  1739. this.ServeJSON()
  1740. }
  1741. }
  1742. }
  1743. sql := "UPDATE OilPaymentInfo SET IsPay ='1' where SrcId=" + infoId + " and PayType='1'"
  1744. paySrv.DBE.Exec(sql)
  1745. errinfo.Message = "确认交费成功!"
  1746. errinfo.Code = 0
  1747. this.Data["json"] = &errinfo
  1748. this.ServeJSON()
  1749. }
  1750. //更新供方信息表
  1751. func (this *InfoChangeController) updatesupplier(supname string, suppid int, infoitems []infochange.OilInfoChangeItem, supmodel supplier.OilSupplier) error {
  1752. svc := infochange.GetInfoChangeService(utils.DBE)
  1753. var err error
  1754. if len(infoitems) > 0 {
  1755. for i := 0; i < len(infoitems); i++ {
  1756. //var cols []string
  1757. //cols = append(cols, infoitems[i].SelectItem)
  1758. where := " Id = " + utils.ToStr(suppid)
  1759. var sql string
  1760. if infoitems[i].SelectItem == "SetupTime" {
  1761. sql = `UPDATE ` + supname + ` set ` + infoitems[i].SelectItem + ` = '` + infoitems[i].ChangeInfo[0:10] + `' where ` + where
  1762. } else {
  1763. sql = `UPDATE ` + supname + ` set ` + infoitems[i].SelectItem + ` = '` + infoitems[i].ChangeInfo + `' where ` + where
  1764. }
  1765. _, err = svc.DBE.Exec(sql)
  1766. //err = svc.UpdateEntityBytbl(OilSupplierName, suppid, &supmodel, cols)
  1767. }
  1768. }
  1769. return err
  1770. }
  1771. func (this *InfoChangeController) BusinessDelete(SupplierId string) {
  1772. //SupplierTypeCode := "01"
  1773. //var IsManufacturer string
  1774. //根据Id查出OilSupplierCertSub的SubClassId
  1775. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE) //获得数据库引擎
  1776. //filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  1777. //paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1778. //var DelCertSublList []suppliercertsub.OilSupplierCertSub
  1779. // 级别 一级变二级 把物资类一级的删掉
  1780. whereDel := "SupplierId=" + SupplierId + " and SupplierTypeCode='01' and GoodsLevel='1'"
  1781. //svc.GetEntities(&DelCertSublList, whereDel)
  1782. svc.DeleteEntityBytbl(OilSupplierCertSubName, whereDel)
  1783. //Id := ""
  1784. //for _, item := range DelCertSublList {
  1785. // Id = Id + "," + strconv.Itoa(item.Id)
  1786. //}
  1787. //Id = strings.Trim(Id, ",")
  1788. //if Id != "" {
  1789. // Ids := strings.Split(Id, ",")
  1790. //
  1791. // //
  1792. // var CertSublList []suppliercertsub.OilSupplierCertSub
  1793. // where := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode // 没有删除的准入范围
  1794. // svc.GetEntities(&CertSublList, where)
  1795. // SubClassIds := ""
  1796. // for _, CertSub := range CertSublList {
  1797. //
  1798. // SubClassIds += strconv.Itoa(CertSub.SubClassId) + ","
  1799. // }
  1800. // var SurplusList []supplierfile.FileList
  1801. // SubClassIds = strings.Trim(SubClassIds, ",")
  1802. // if SubClassIds != "" {
  1803. // if SupplierTypeCode == "01" {
  1804. // //SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds, IsManufacturer)
  1805. // } else if SupplierTypeCode == "02" {
  1806. // SurplusList = filesvc.GetBasicNeedFileList(SubClassIds)
  1807. // } else if SupplierTypeCode == "03" {
  1808. // SurplusList = filesvc.GetTechNeedFileList(SubClassIds)
  1809. // }
  1810. // }
  1811. // fileNames := ""
  1812. // for _, CertSub := range SurplusList {
  1813. // fileNames += CertSub.FileName + ","
  1814. // }
  1815. //
  1816. // for i := 0; i < len(Ids); i++ {
  1817. // IsManufacturer = filesvc.CheckIsManuf(Ids[i])
  1818. // if SubClassIds != "" {
  1819. // if SupplierTypeCode == "01" {
  1820. // var CertSublList2 []suppliercertsub.OilSupplierCertSub
  1821. // wheregood := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode + " and IsManufacturer =" + IsManufacturer // 没有删除的准入范围
  1822. // svc.GetEntities(&CertSublList2, wheregood)
  1823. // SubClassIds2 := ""
  1824. // for _, CertSub := range CertSublList2 {
  1825. // SubClassIds2 += strconv.Itoa(CertSub.SubClassId) + ","
  1826. // }
  1827. // SubClassIds2 = strings.Trim(SubClassIds2, ",")
  1828. // SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds2, IsManufacturer)
  1829. // }
  1830. // }
  1831. // if fileNames == "" {
  1832. // for _, CertSub := range SurplusList {
  1833. // fileNames += CertSub.FileName + ","
  1834. // }
  1835. // }
  1836. // var datamain suppliercertsub.OilSupplierCertSub //创建OilSupplierCertSub结构体(映射用)
  1837. // var datamain2 []suppliercertsub.OilSupplierCertSub //空的查询用
  1838. //
  1839. // where := " Id= " + Ids[i]
  1840. // svc.GetEntity(&datamain, where) //根据Id查找,映射结构体
  1841. //
  1842. // //再根据企业id查找这个企业有几个准入范围(如果只有一个准入范围了,基本资质也删除)
  1843. //
  1844. // supplierId := datamain.SupplierId
  1845. // where = "SupplierId=" + strconv.Itoa(supplierId)
  1846. // svc.GetEntities(&datamain2, where)
  1847. // flag := 0
  1848. // if len(datamain2) == 1 {
  1849. // flag = 1
  1850. // }
  1851. // subClassId := datamain.SubClassId //4.拿到结构体中的准入范围SubClassId
  1852. // //根据SubClassId查出此准入范围所拥有的资质名称
  1853. // var needList []supplierfile.FileList //定义存储所拥有资质名称的数组
  1854. // if datamain.SupplierTypeCode == "01" {
  1855. // needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), IsManufacturer) //通过准入范围Id获得资质名称并填充数组
  1856. // } else if datamain.SupplierTypeCode == "02" {
  1857. // needList = filesvc.GetBasicNeedFileList(strconv.Itoa(subClassId))
  1858. // } else {
  1859. // needList = filesvc.GetTechNeedFileList(strconv.Itoa(subClassId))
  1860. // }
  1861. //
  1862. // var mustField string
  1863. // mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName") //必需的资质
  1864. //
  1865. // //根据企业ID(SupplierId)和此准入范围所拥有的资质名称删除OilSupplierFile表中对应的资质
  1866. // for j := 0; j < len(needList); j++ { //循环遍历资质名称数组,逐条删除
  1867. //
  1868. // if flag == 0 && strings.Contains(mustField, needList[j].FileName+",") {
  1869. // continue
  1870. // }
  1871. // if flag == 0 && strings.Contains(fileNames, needList[j].FileName+",") {
  1872. // continue
  1873. // }
  1874. // if datamain.SupplierTypeCode == "01" {
  1875. // where = " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and IsManuf='" + IsManufacturer + "' and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
  1876. // } else {
  1877. // where = " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
  1878. // }
  1879. // svc.DeleteEntityBytbl(OilSupplierFileName, where) //删除第j条资质数据
  1880. //
  1881. // }
  1882. //
  1883. // // TODO: 删除准入范围和资质对应关系表
  1884. // /*where = " SupplierId=" + strconv.Itoa(datamain.SupplierId) + " and SupplierTypeCode =" + SupplierTypeCode + " and SubClassId=" + strconv.Itoa(subClassId)
  1885. // svc.DeleteEntityBytbl(OilSupplierCert2FileName, where)*/
  1886. //
  1887. // where = " Id= " + Ids[i] + " and SupplierTypeCode =" + SupplierTypeCode
  1888. // svc.DeleteEntityBytbl(OilSupplierCertSubName, where) //删除OilSupplierCertSub单条准入范围
  1889. //
  1890. // }
  1891. //}
  1892. }
  1893. func (this *InfoChangeController) FileDelete(supplierId string) {
  1894. s := time.Now()
  1895. where := "SupplierId=" + supplierId + " and IsDelete=1"
  1896. svc := infochange.GetInfoChangeService(utils.DBE)
  1897. var delfiles []supplierfile.OilSupplierFile
  1898. svc.GetEntities(&delfiles, where)
  1899. delfilenames := ""
  1900. for _, delfile := range delfiles {
  1901. delfilenames += delfile.NeedFileType + ","
  1902. }
  1903. fmt.Println("del==" + delfilenames)
  1904. var sub []suppliercertsub.OilSupplierCertSub
  1905. weresup := "SupplierId=" + supplierId
  1906. svc.GetEntitysByWhere(OilSupplierCertSubName, weresup, &sub)
  1907. for _, item := range sub {
  1908. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  1909. needList := filesvc.GetGoodsNeedFileList(strconv.Itoa(item.SubClassId))
  1910. for _, needfile := range needList {
  1911. if strings.Index(delfilenames, needfile.FileName) > -1 {
  1912. where := "Id=" + strconv.Itoa(item.Id)
  1913. svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
  1914. break
  1915. }
  1916. }
  1917. }
  1918. svc.DeleteEntityBytbl(OilSupplierFileName, where)
  1919. sp := time.Since(s)
  1920. log.Println(sp, "++++++++++++++++++++")
  1921. }
  1922. func (this *InfoChangeController) updateChangeInfo(supplierId int, infoId string) {
  1923. var infoItems []infochange.OilInfoChangeItem
  1924. where := " SupplierId = " + strconv.Itoa(supplierId) + " and InfoId =" + infoId
  1925. where = where + " and ChangeStatus = 0"
  1926. var supModel supplier.OilSupplier
  1927. svc := supplier.GetOilSupplierService(utils.DBE)
  1928. svc.GetEntitysByWhere(OilInfoChangeItemName, where, &infoItems)
  1929. //修改主表信息
  1930. this.updatesupplier(OilSupplierName, supplierId, infoItems, supModel)
  1931. // 级别 一级变二级 删除不符合的准入项
  1932. for _, item := range infoItems {
  1933. if item.SelectItem == "Grade" {
  1934. if item.BeChangeInfo == "1" && item.ChangeInfo == "2" {
  1935. this.BusinessDelete(utils.ToStr(supplierId))
  1936. }
  1937. }
  1938. }
  1939. this.FileDelete(strconv.Itoa(supplierId))
  1940. t := time.Now()
  1941. s := time.Since(t)
  1942. log.Println(s, "============================")
  1943. var qualDetail []qualchange.OilQualChangeDetail
  1944. where1 := "SupplierId = " + utils.ToStr(supplierId) + " and ParentId=" + infoId
  1945. svc1 := infochange.GetInfoChangeService(utils.DBE)
  1946. svc1.GetEntities(&qualDetail, where1)
  1947. //更新 变更的资质
  1948. if len(qualDetail) > 0 {
  1949. for i := 0; i < len(qualDetail); i++ {
  1950. var supFileModel supplierfile.OilSupplierFile
  1951. supFileModel.FileName = qualDetail[i].FileName
  1952. supFileModel.FileUrl = qualDetail[i].FileUrl
  1953. supFileModel.EffectDate = qualDetail[i].EffectDate
  1954. svc.UpdateEntityBytbl(OilSupplierFileName, qualDetail[i].FileId, &supFileModel, []string{"FileName", "FileUrl", "EffectDate"})
  1955. }
  1956. }
  1957. }