infochange.go 54 KB

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