technologyservice.go 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  4. "dashoo.cn/backend/api/business/oilsupplier/supplierdataentry"
  5. "dashoo.cn/backend/api/business/oilsupplier/tableheader"
  6. "dashoo.cn/backend/api/business/oilsupplier/technologyserviceclass"
  7. "dashoo.cn/backend/api/business/workflow"
  8. "encoding/json"
  9. "fmt"
  10. "github.com/tealeg/xlsx"
  11. "log"
  12. "os"
  13. "reflect"
  14. "strconv"
  15. "strings"
  16. "time"
  17. "dashoo.cn/backend/api/business/items"
  18. "dashoo.cn/backend/api/business/baseUser"
  19. "dashoo.cn/business2/userRole"
  20. "dashoo.cn/backend/api/business/oilsupplier/goodsaptitude"
  21. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  22. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  23. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  24. //"dashoo.cn/backend/api/business/items"
  25. "dashoo.cn/backend/api/business/oilsupplier/technologyservice"
  26. . "dashoo.cn/backend/api/controllers"
  27. "dashoo.cn/business2/parameter"
  28. "dashoo.cn/utils"
  29. . "github.com/linxGnu/goseaweedfs"
  30. )
  31. type OilTechnologyServiceController struct {
  32. BaseController
  33. }
  34. // @Title 获取列表
  35. // @Description get user by token
  36. // @Success 200 {object} []technologyservice.OilTechnologyService
  37. // @router /list [get]
  38. func (this *OilTechnologyServiceController) GetEntityList() {
  39. //获取分页信息
  40. page := this.GetPageInfoForm()
  41. where := " 1=1 "
  42. orderby := "Code"
  43. asc := true
  44. Order := this.GetString("Order")
  45. Prop := this.GetString("Prop")
  46. if Order != "" && Prop != "" {
  47. orderby = Prop
  48. if Order == "asc" {
  49. asc = true
  50. }else {
  51. asc = false
  52. }
  53. }
  54. CreateOn := this.GetString("CreateOn")
  55. Code := this.GetString("Code")
  56. Name := this.GetString("Name")
  57. Code1 := this.GetString("Code1")
  58. Name1 := this.GetString("Name1")
  59. Code2 := this.GetString("Code2")
  60. Name2 := this.GetString("Name2")
  61. Code3 := this.GetString("Code3")
  62. Name3 := this.GetString("Name3")
  63. Code4 := this.GetString("Code4")
  64. Name4 := this.GetString("Name4")
  65. if Code != "" {
  66. where = where + " and Code like '%" + Code + "%'"
  67. }
  68. if Name != "" {
  69. where = where + " and Name like '%" + Name + "%'"
  70. }
  71. if Code1 != "" {
  72. where = where + " and Code1 like '%" + Code1 + "%'"
  73. }
  74. if Name1 != "" {
  75. where = where + " and Name1 like '%" + Name1 + "%'"
  76. }
  77. if Code2 != "" {
  78. where = where + " and Code2 like '%" + Code2 + "%'"
  79. }
  80. if Name2 != "" {
  81. where = where + " and Name2 like '%" + Name2 + "%'"
  82. }
  83. if Code3 != "" {
  84. where = where + " and Code3 like '%" + Code3 + "%'"
  85. }
  86. if Name3 != "" {
  87. where = where + " and Name3 like '%" + Name3 + "%'"
  88. }
  89. if Code4 != "" {
  90. where = where + " and Code4 like '%" + Code4 + "%'"
  91. }
  92. if Name4 != "" {
  93. where = where + " and Name4 like '%" + Name4 + "%'"
  94. }
  95. if CreateOn != "" {
  96. dates := strings.Split(CreateOn, ",")
  97. if len(dates) == 2 {
  98. minDate := dates[0]
  99. maxDate := dates[1]
  100. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  101. }
  102. }
  103. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  104. var list []technologyservice.OilTechnologyServiceView
  105. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilTechsrvDetailViewName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  106. var datainfo DataInfo
  107. datainfo.Items = list
  108. datainfo.CurrentItemCount = total
  109. datainfo.PageIndex = page.CurrentPage
  110. datainfo.ItemsPerPage = page.Size
  111. this.Data["json"] = &datainfo
  112. this.ServeJSON()
  113. }
  114. // @Title 获取字典列表
  115. // @Description get user by token
  116. // @Success 200 {object} map[string]interface{}
  117. // @router /dictlist [get]
  118. func (this *OilTechnologyServiceController) GetDictList() {
  119. dictList := make(map[string]interface{})
  120. dictSvc := items.GetItemsService(utils.DBE)
  121. userSvc := baseUser.GetBaseUserService(utils.DBE)
  122. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  123. //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", "")
  124. var userEntity userRole.Base_User
  125. userSvc.GetEntityById(this.User.Id, &userEntity)
  126. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId("", userEntity.Departmentid)
  127. dictList["AuditStep"] = dictSvc.GetKeyValueItems("AuditStep", this.User.AccCode)
  128. //var dictCustomer []svccustomer.Customer
  129. //customerSvc.GetEntitysByWhere("" + CustomerName, "", &dictCustomer)
  130. //dictList["EntrustCorp"] = &dictCustomer
  131. var datainfo DataInfo
  132. datainfo.Items = dictList
  133. this.Data["json"] = &datainfo
  134. this.ServeJSON()
  135. }
  136. // @Title 获取实体
  137. // @Description 获取实体
  138. // @Success 200 {object} technologyservice.OilTechnologyService
  139. // @router /get/:id [get]
  140. func (this *OilTechnologyServiceController) GetEntity() {
  141. Id := this.Ctx.Input.Param(":id")
  142. var model technologyservice.OilTechnologyServiceView
  143. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  144. //svc.GetEntityByIdBytbl(""+OilTechnologyServiceName, Id, &model)
  145. where := " Id ="+ Id
  146. svc.GetEntityByWhere(OilTechsrvDetailViewName, where, &model)
  147. this.Data["json"] = &model
  148. this.ServeJSON()
  149. }
  150. // @Title 添加
  151. // @Description 新增
  152. // @Success 200 {object} controllers.Request
  153. // @router /add [post]
  154. func (this *OilTechnologyServiceController) AddEntity() {
  155. //classId := this.Ctx.Input.Param(":id")
  156. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  157. var model technologyserviceclass.OilTechnologyServiceClass
  158. var classmodel technologyserviceclass.OilTechnologyServiceClass
  159. var parentedId technologyserviceclass.ParentedId
  160. var jsonBlob = this.Ctx.Input.RequestBody
  161. json.Unmarshal(jsonBlob, &parentedId)
  162. json.Unmarshal(jsonBlob, &model)
  163. var errinfo ErrorDataInfo
  164. where := " Code = " + model.Code
  165. code := svc.GetEntityByWhere(OilTechnologyServiceClassName, where, &classmodel)
  166. if code {
  167. errinfo.Message = "编码不能重复!"
  168. errinfo.Code = -1
  169. this.Data["json"] = &errinfo
  170. this.ServeJSON()
  171. return
  172. }
  173. //where1 := " Name = " + model.Name
  174. //name := svc.GetEntityByWhere(OilGoodsAptitudeClassName, where1, &classmodel)
  175. //if name {
  176. // errinfo.Message = "名称不能重复!"
  177. // errinfo.Code = -1
  178. // this.Data["json"] = &errinfo
  179. // this.ServeJSON()
  180. // return
  181. //}
  182. model.ParentId = parentedId.ParentId
  183. model.CreateOn = time.Now()
  184. model.CreateBy = this.User.Realname
  185. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  186. _, err := svc.InsertEntityBytbl(""+OilTechnologyServiceClassName, &model)
  187. var model2 technologyservice.OilTechnologyService
  188. json.Unmarshal(jsonBlob, &model2)
  189. model2.ClassId = model.Id
  190. model2.CreateOn = time.Now()
  191. model2.CreateBy = this.User.Realname
  192. model2.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  193. _, err = svc.InsertEntityBytbl(""+OilTechnologyServiceName, &model2)
  194. if err == nil {
  195. //新增
  196. errinfo.Message = "添加成功!"
  197. errinfo.Code = 0
  198. errinfo.Item = model2.Id
  199. this.Data["json"] = &errinfo
  200. this.ServeJSON()
  201. } else {
  202. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  203. errinfo.Code = -1
  204. this.Data["json"] = &errinfo
  205. this.ServeJSON()
  206. }
  207. }
  208. // @Title 修改实体
  209. // @Description 修改实体
  210. // @Success 200 {object} controllers.Request
  211. // @router /update/:id [post]
  212. func (this *OilTechnologyServiceController) UpdateEntity() {
  213. id := this.Ctx.Input.Param(":id")
  214. var errinfo ErrorInfo
  215. if id == "" {
  216. errinfo.Message = "操作失败!请求信息不完整"
  217. errinfo.Code = -2
  218. this.Data["json"] = &errinfo
  219. this.ServeJSON()
  220. return
  221. }
  222. var model technologyservice.OilTechnologyService
  223. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  224. var jsonBlob = this.Ctx.Input.RequestBody
  225. json.Unmarshal(jsonBlob, &model)
  226. model.ModifiedOn = time.Now()
  227. model.ModifiedBy = this.User.Realname
  228. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  229. cols := []string{
  230. "Id",
  231. "Code",
  232. "Name",
  233. "Code1",
  234. "Name1",
  235. "Code2",
  236. "Name2",
  237. "Code3",
  238. "Name3",
  239. "Code4",
  240. "Name4",
  241. "OrgId",
  242. "OrgName",
  243. "F01",
  244. "F02",
  245. "F03",
  246. "F04",
  247. "F05",
  248. "F06",
  249. "F07",
  250. "F08",
  251. "F09",
  252. "F10",
  253. "F11",
  254. "F12",
  255. "F13",
  256. "F14",
  257. "F15",
  258. "F16",
  259. "F17",
  260. "F18",
  261. "F19",
  262. "F20",
  263. "F21",
  264. "F22",
  265. "F23",
  266. "F24",
  267. "F25",
  268. "F26",
  269. "F27",
  270. "F28",
  271. "F29",
  272. "F30",
  273. "F31",
  274. "F32",
  275. "F33",
  276. "F34",
  277. "F35",
  278. "F36",
  279. "F37",
  280. "F38",
  281. "F39",
  282. "F40",
  283. "F41",
  284. "F42",
  285. "F43",
  286. "F44",
  287. "F45",
  288. "F46",
  289. "F47",
  290. "F48",
  291. "F49",
  292. "F50",
  293. "F51",
  294. "F52",
  295. "Remark",
  296. "DeletionStateCode",
  297. "CreateOn",
  298. "CreateUserId",
  299. "CreateBy",
  300. "ModifiedOn",
  301. "ModifiedUserId",
  302. "ModifiedBy",
  303. }
  304. err := svc.UpdateEntityBytbl(""+OilTechnologyServiceName, id, &model, cols)
  305. if err == nil {
  306. errinfo.Message = "修改成功!"
  307. errinfo.Code = 0
  308. this.Data["json"] = &errinfo
  309. this.ServeJSON()
  310. } else {
  311. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  312. errinfo.Code = -1
  313. this.Data["json"] = &errinfo
  314. this.ServeJSON()
  315. }
  316. }
  317. // @Title 修改实体
  318. // @Description 修改实体
  319. // @Success 200 {object} controllers.Request
  320. // @router /updatecode/:id [post]
  321. func (this *OilTechnologyServiceController) UpdateCodeEntity() {
  322. var errinfo ErrorInfo
  323. var err error
  324. id := this.Ctx.Input.Param(":id")
  325. if id == "" {
  326. errinfo.Message = "操作失败!请求信息不完整"
  327. errinfo.Code = -2
  328. this.Data["json"] = &errinfo
  329. this.ServeJSON()
  330. return
  331. }
  332. var classall technologyservice.OilTechnologyClassServiceView
  333. var model technologyserviceclass.OilTechnologyServiceClass
  334. var classmodel []technologyserviceclass.OilTechnologyServiceClass
  335. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  336. var jsonBlob = this.Ctx.Input.RequestBody
  337. json.Unmarshal(jsonBlob, &classall)
  338. model.ModifiedOn = time.Now()
  339. model.ModifiedBy = this.User.Realname
  340. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  341. colsName := []string{"Name"}
  342. colsCode := []string{"Code"}
  343. //svc.GetEntityById(id, &model)
  344. if classall.Name1 != ""{
  345. where := " Name = '" + classall.Name1 +"' and Id <> "+utils.ToStr(classall.Id1)
  346. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  347. if len(classmodel) > 0 {
  348. errinfo.Message = "一级名称已存在,请重新添加!"
  349. errinfo.Code = -1
  350. this.Data["json"] = &errinfo
  351. this.ServeJSON()
  352. return
  353. }else {
  354. model.Name = classall.Name1
  355. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id1, &model, colsName)
  356. }
  357. }
  358. if classall.Name2 != ""{
  359. where := " Name = '" + classall.Name2 +"' and Id <> "+utils.ToStr(classall.Id2)
  360. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  361. if len(classmodel) > 0 {
  362. errinfo.Message = "二级名称已存在,请重新添加!"
  363. errinfo.Code = -1
  364. this.Data["json"] = &errinfo
  365. this.ServeJSON()
  366. return
  367. }else {
  368. model.Name = classall.Name2
  369. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id2, &model, colsName)
  370. }
  371. }
  372. if classall.Name3 != ""{
  373. where := " Name = '" + classall.Name3 +"' and Id <> "+utils.ToStr(classall.Id3)
  374. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  375. if len(classmodel) > 0 {
  376. errinfo.Message = "三级名称已存在,请重新添加!"
  377. errinfo.Code = -1
  378. this.Data["json"] = &errinfo
  379. this.ServeJSON()
  380. return
  381. }else {
  382. model.Name = classall.Name3
  383. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id3, &model, colsName)
  384. }
  385. }
  386. if classall.Name4 != ""{
  387. where := " Name = '" + classall.Name4 + "' and Id <> "+utils.ToStr(classall.Id4)
  388. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  389. if len(classmodel) > 0 {
  390. errinfo.Message = "四级名称已存在,请重新添加!"
  391. errinfo.Code = -1
  392. this.Data["json"] = &errinfo
  393. this.ServeJSON()
  394. return
  395. }else {
  396. model.Name = classall.Name4
  397. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id4, &model, colsName)
  398. }
  399. }
  400. if classall.Code1 != ""{
  401. where := " Code = " + classall.Code1 +" and Id <> "+utils.ToStr(classall.Id1)
  402. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  403. if len(classmodel) > 0 {
  404. errinfo.Message = "一级编码已存在,请重新添加!"
  405. errinfo.Code = -1
  406. this.Data["json"] = &errinfo
  407. this.ServeJSON()
  408. return
  409. }else {
  410. model.Code = classall.Code1
  411. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id1, &model, colsCode)
  412. }
  413. }
  414. if classall.Code2 != ""{
  415. where := " Code = " + classall.Code2 +" and Id <> "+utils.ToStr(classall.Id2)
  416. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  417. if len(classmodel) > 0 {
  418. errinfo.Message = "二级编码已存在,请重新添加!"
  419. errinfo.Code = -1
  420. this.Data["json"] = &errinfo
  421. this.ServeJSON()
  422. return
  423. }else {
  424. model.Code = classall.Code2
  425. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id2, &model, colsCode)
  426. }
  427. }
  428. if classall.Code3 != ""{
  429. where := " Code = " + classall.Code3 +" and Id <> "+utils.ToStr(classall.Id3)
  430. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  431. if len(classmodel) > 0 {
  432. errinfo.Message = "三级编码已存在,请重新添加!"
  433. errinfo.Code = -1
  434. this.Data["json"] = &errinfo
  435. this.ServeJSON()
  436. return
  437. }else {
  438. model.Code = classall.Code3
  439. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id3, &model, colsCode)
  440. }
  441. }
  442. if classall.Code4 != ""{
  443. where := " Code = " + classall.Code4 +" and Id <> "+utils.ToStr(classall.Id4)
  444. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  445. if len(classmodel) > 0 {
  446. errinfo.Message = "四级编码已存在,请重新添加!"
  447. errinfo.Code = -1
  448. this.Data["json"] = &errinfo
  449. this.ServeJSON()
  450. return
  451. }else {
  452. model.Code = classall.Code4
  453. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id4, &model, colsCode)
  454. }
  455. }
  456. if err == nil {
  457. errinfo.Message = "修改成功!"
  458. errinfo.Code = 0
  459. this.Data["json"] = &errinfo
  460. this.ServeJSON()
  461. } else {
  462. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  463. errinfo.Code = -1
  464. this.Data["json"] = &errinfo
  465. this.ServeJSON()
  466. }
  467. }
  468. // @Title 删除单条信息
  469. // @Description
  470. // @Success 200 {object} ErrorInfo
  471. // @Failure 403 :id 为空
  472. // @router /delete/:Id [delete]
  473. func (this *OilTechnologyServiceController) DeleteEntity() {
  474. Id := this.Ctx.Input.Param(":Id")
  475. var errinfo ErrorInfo
  476. if Id == "" {
  477. errinfo.Message = "操作失败!请求信息不完整"
  478. errinfo.Code = -2
  479. this.Data["json"] = &errinfo
  480. this.ServeJSON()
  481. return
  482. }
  483. var model technologyservice.OilTechnologyService
  484. var entityempty technologyservice.OilTechnologyService
  485. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  486. svc.GetEntityById(Id, &model)
  487. opdesc := "删除-" + Id
  488. err := svc.DeleteOperationAndWriteLogBytbl(""+OilTechnologyServiceName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "服务类准入范围子表删除")
  489. var model1 technologyserviceclass.OilTechnologyServiceClass
  490. var entityempty1 technologyserviceclass.OilTechnologyServiceClass
  491. svc1 := technologyserviceclass.GetOilTechnologyServiceClassService(utils.DBE)
  492. opdesc1 := "删除-" + strconv.Itoa(model.ClassId)
  493. err1 := svc1.DeleteOperationAndWriteLogBytbl(""+OilTechnologyServiceClassName, BaseOperationLogName, strconv.Itoa(model.ClassId), &model1, &entityempty1, utils.ToStr(this.User.Id), this.User.Username, opdesc1, "", "服务类准入范围删除")
  494. if err == nil && err1 == nil {
  495. errinfo.Message = "删除成功"
  496. errinfo.Code = 0
  497. this.Data["json"] = &errinfo
  498. this.ServeJSON()
  499. } else {
  500. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  501. errinfo.Code = -1
  502. this.Data["json"] = &errinfo
  503. this.ServeJSON()
  504. }
  505. }
  506. // @Title get 业务列表
  507. // @Description get SampleType by token
  508. // @Success 200 {object} sampletype.SampleType
  509. // @router /techbuslist [get]
  510. func (this *OilTechnologyServiceController) TechbusList() {
  511. keyword := this.GetString("keyword")
  512. where := " 1 = 1 "
  513. if keyword != "" {
  514. where = where + " and Code like '%" + keyword + "%' or Name like '%" + keyword + "%'"
  515. }
  516. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  517. var list []technologyservice.TechnologyBusiness
  518. //获取技术服务类资质分类层级信息
  519. list = svc.GetTechList(OilTechnologyServiceClassName, where)
  520. var datainfo DataInfo
  521. datainfo.Items = list
  522. this.Data["json"] = &datainfo
  523. this.ServeJSON()
  524. }
  525. //// @Title get 业务列表
  526. //// @Description get SampleType by token
  527. //// @Success 200 {object} sampletype.SampleType
  528. //// @router /needfilelist [get]
  529. //func (this *OilTechnologyServiceController) NeedFileList() {
  530. // svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  531. // where := " 1 = 1 "
  532. // ClassId := this.GetString("ClassId")
  533. // if ClassId != "" {
  534. // where = where + " and ClassId ='" + ClassId + "' "
  535. // }
  536. // var model technologyservice.OilTechnologyService
  537. // svc.GetEntityByWhere(OilTechnologyServiceName, where, &model)
  538. // var datainfo DataInfo
  539. // datainfo.Items = model
  540. // this.Data["json"] = &datainfo
  541. // this.ServeJSON()
  542. //}
  543. // @Title 获取Code
  544. // @Description 根据Id获取Code
  545. // @Success 200 {object} technologyservice.TechnologyBusiness
  546. // @router /getcode/:id [get]
  547. func (this *OilTechnologyServiceController) GetCodeById() {
  548. Id := this.Ctx.Input.Param(":id")
  549. where := " 1 = 1 "
  550. if Id != "" {
  551. where = where + " and Id = " + Id
  552. }
  553. var list []technologyservice.TechnologyBusiness
  554. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  555. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &list)
  556. var datainfo DataInfo
  557. datainfo.Items = list
  558. this.Data["json"] = &datainfo
  559. this.ServeJSON()
  560. }
  561. // @Title get 导出ex
  562. // @Description get SampleType by token
  563. // @Success 200 {object} sampletype.SampleType
  564. // @router /exportexcelall [get]
  565. func (this *OilTechnologyServiceController) ExportExcelAll() {
  566. //获取分页信息
  567. where := " 1=1 "
  568. orderby := "Code"
  569. asc := true
  570. Order := this.GetString("Order")
  571. Prop := this.GetString("Prop")
  572. if Order != "" && Prop != "" {
  573. orderby = Prop
  574. if Order == "asc" {
  575. asc = true
  576. } else {
  577. asc = false
  578. }
  579. }
  580. t := time.Now()
  581. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  582. var list []technologyservice.OilTechnologyServiceView
  583. svc.GetMyPagingEntitiesWithOrderBytbl(OilTechsrvDetailViewName, 0, 0, orderby, asc, &list, where)
  584. var title []string
  585. filetitle := "服务类"
  586. //自定义显示列
  587. showcolumnarr := this.GetString("showcolumnarr")
  588. showcolumnnamearr := this.GetString("showcolumnnamearr")
  589. titlestring := showcolumnnamearr
  590. title = strings.Split(titlestring, ",")
  591. f := xlsx.NewFile()
  592. sheet, _ := f.AddSheet(filetitle)
  593. cellname := strings.Split(showcolumnarr, ",")
  594. row := sheet.AddRow()
  595. row.WriteSlice(&cellname, -1)
  596. for _, item := range list {
  597. var enumModel technologyservice.OilTechnologyServiceView
  598. tmpModel := &item
  599. enumModel = *tmpModel
  600. immumodel := reflect.ValueOf(&enumModel)
  601. elem := immumodel.Elem()
  602. row := sheet.AddRow()
  603. for _, name := range title {
  604. cell := row.AddCell()
  605. if strings.HasPrefix(name, "F") {
  606. var val = elem.FieldByName(name).String()
  607. if val == "1" {
  608. cell.Value = "是"
  609. } else {
  610. cell.Value = ""
  611. }
  612. } else {
  613. cell.Value = elem.FieldByName(name).String()
  614. }
  615. }
  616. }
  617. for c, cl := 0, len(sheet.Cols); c < cl; c++ {
  618. sheet.Cols[c].Width = 20
  619. }
  620. dir := "static/file/excel/report/" + this.GetAccode()
  621. SaveDirectory(dir)
  622. path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
  623. f.Save(path)
  624. var sw *Seaweed
  625. var filer []string
  626. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  627. filer = []string{_filer}
  628. }
  629. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  630. _, _, fID, _ := sw.UploadFile(path, "", "")
  631. retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  632. os.Remove(path)
  633. fmt.Println("==retDocWatermarkUrl==", retDocUrl)
  634. this.Data["json"] = retDocUrl
  635. this.ServeJSON()
  636. elapsed := time.Since(t)
  637. fmt.Println(elapsed)
  638. }
  639. // @Title 获取所有
  640. // @Description
  641. // @Success 200 {object}
  642. // @router /getcompanylist [post]
  643. func (this *OilTechnologyServiceController) GetTList() {
  644. var model supplier.OilSupplierSelect
  645. var model1 supplier.RegCapitalRange //注册资金范围
  646. //var model2 supplier.NeedFileTypeStruct //资质结构体
  647. var jsonBlob = this.Ctx.Input.RequestBody
  648. json.Unmarshal(jsonBlob, &model)
  649. json.Unmarshal(jsonBlob, &model1)
  650. //json.Unmarshal(jsonBlob, &model2)
  651. // //获取分页信息
  652. page := this.GetPageInfoForm()
  653. where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' and b.SupplierTypeCode = '03' AND t.SupplierId IS NOT NULL "
  654. orderby := "a.Id"
  655. asc := true
  656. Order := this.GetString("Order")
  657. Prop := this.GetString("Prop")
  658. CheckUId := this.GetString("CheckUId")
  659. FullId := this.GetString("FullId")
  660. if Order != "" && Prop != "" {
  661. orderby = Prop
  662. if Order == "desc" {
  663. asc = false
  664. }
  665. }
  666. leftjoin := ""
  667. //准入证号
  668. if model.AccessCardNo != "" {
  669. where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
  670. }
  671. //企业名称
  672. if model.SupplierName != "" {
  673. where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
  674. }
  675. if model.OldSupplierName != "" {
  676. where = where + " and OldSupplierName like '%" + model.OldSupplierName + "%'"
  677. }
  678. if FullId != "" {
  679. where = where + " and f.Id = '" + FullId + "'"
  680. }
  681. if CheckUId != "" {
  682. where = where + " and g.CheckUnitId = '" + CheckUId + "'"
  683. }
  684. //准入标识 1 准入 2 暂停 3取消
  685. if model.InFlag != "" {
  686. where = where + " and b.InFlag = '" + model.InFlag + "'"
  687. }
  688. //法人
  689. if model.LegalPerson != "" {
  690. where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
  691. }
  692. //联系人
  693. if model.ContactName != "" {
  694. where = where + " and a.ContactName like '%" + model.ContactName + "%'"
  695. }
  696. //统一社会信用代码
  697. if model.CommercialNo != "" {
  698. where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
  699. }
  700. //开户银行
  701. if model.DepositBank != "" {
  702. where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
  703. }
  704. //HSE审查
  705. if model.HseTraining != "" {
  706. where = where + " and a.HseTraining = '" + model.HseTraining + "'"
  707. }
  708. //公司类型
  709. if model.CompanyType != "" {
  710. where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
  711. }
  712. //成立时间
  713. SetupTime := this.GetString("SetupTime")
  714. if SetupTime != "" {
  715. where = where + " and a.SetupTime ='" + SetupTime + "'"
  716. }
  717. //注册资金范围
  718. if model1.RegCapital1 != "" {
  719. where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
  720. }
  721. if model1.RegCapital2 != "" {
  722. where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
  723. }
  724. //注册省份
  725. if model.Province != "" {
  726. where = where + " and a.Province = '" + model.Province + "'"
  727. }
  728. //注册市
  729. if model.City != "" {
  730. where = where + " and a.City = '" + model.City + "'"
  731. }
  732. //注册区
  733. if model.Street != "" {
  734. where = where + " and a.Street = '" + model.Street + "'"
  735. }
  736. //注册详细地址
  737. if model.Address != "" {
  738. where = where + " and a.Address like '%" + model.Address + "%'"
  739. }
  740. if model.LinkProvince != "" {
  741. where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
  742. }
  743. if model.LinkCity != "" {
  744. where = where + " and a.LinkCity = '" + model.LinkCity + "'"
  745. }
  746. if model.LinkStreet != "" {
  747. where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
  748. }
  749. if model.LinkAddress != "" {
  750. where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
  751. }
  752. //营业范围
  753. if model.BusinessScope != "" {
  754. where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
  755. }
  756. CreateOn := this.GetString("CreateOn")
  757. if CreateOn != "" {
  758. dates := strings.Split(CreateOn, ",")
  759. if len(dates) == 2 {
  760. minDate := dates[0]
  761. maxDate := dates[1]
  762. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  763. }
  764. }
  765. a := model.InStyle
  766. fmt.Println(a)
  767. //准入方式
  768. if model.InStyle != "" {
  769. if model.InStyle == "0"{
  770. where = where + " and b.InStyle in ('2','3','4','5')"
  771. }else{
  772. where = where + " and b.InStyle ='" + model.InStyle + "'"
  773. }
  774. }
  775. having:=""
  776. //准入范围
  777. if model.CerSubName!="" {
  778. having = " having CerSubName like '%"+model.CerSubName+"%' "
  779. leftjoin = "left join "+ OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  780. }
  781. //资质
  782. if model.NeedFileType!="" {
  783. having = " having NeedFileType like '%"+model.NeedFileType+"%' "
  784. }
  785. if model.CerSubName!=""&& model.NeedFileType!=""{
  786. having = " having CerSubName like '%"+model.CerSubName+"%' and NeedFileType like '%"+model.NeedFileType+"%' "
  787. leftjoin = "left join "+ OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  788. }
  789. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  790. var list []supplier.OilSupplierSelect
  791. total := svc.GetMyPagingDelEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName,OilCorporateInfoName,OilSupplierCertSubName,
  792. OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where,having, leftjoin)
  793. var datainfo DataInfo
  794. datainfo.Items = list
  795. datainfo.CurrentItemCount = total
  796. datainfo.PageIndex = page.CurrentPage
  797. datainfo.ItemsPerPage = page.Size
  798. this.Data["json"] = &datainfo
  799. this.ServeJSON()
  800. }
  801. // @Title 删除不符合的的准入项
  802. // @Description get user by token
  803. // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
  804. // @router /deltmpsuppliercertsub [get]
  805. func (this *OilTechnologyServiceController) DelTmpSupplierCertSub() {
  806. var err error
  807. session := utils.DBE.NewSession()
  808. session.Begin()
  809. defer session.Close()
  810. supplierId := this.GetString("SupplierId")
  811. id := this.GetString("Id")
  812. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  813. var supplierCertSubList []suppliercertsub.Tmp_OilSupplierCertSub
  814. wheredel := "1=1 and SupplierTypeCode = '03'"
  815. if supplierId != "" {
  816. wheredel += " and SupplierId=" + supplierId
  817. }
  818. if id != "" {
  819. wheredel += " and Id=" + id
  820. }
  821. svc.GetEntitysByWhere(TmpOilSupplierCertSubName, wheredel, &supplierCertSubList)
  822. var errinfo ErrorInfo
  823. for _,item := range supplierCertSubList {
  824. where := "Id = " + strconv.Itoa(item.Id)
  825. err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
  826. if err != nil {
  827. session.Rollback()
  828. errinfo.Code = -1
  829. errinfo.Message = "删除失败!"
  830. this.Data["json"] = &errinfo
  831. this.ServeJSON()
  832. }
  833. }
  834. for _,item := range supplierCertSubList {
  835. where := "Id = " + strconv.Itoa(item.Id)
  836. err = svc.DeleteEntityBytbl(TmpOilSupplierCertSubName, where)
  837. }
  838. if err == nil {
  839. session.Commit()
  840. errinfo.Code = 0
  841. errinfo.Message = "删除成功!"
  842. this.Data["json"] = &errinfo
  843. this.ServeJSON()
  844. } else {
  845. session.Rollback()
  846. errinfo.Code = -1
  847. errinfo.Message = "删除失败!"
  848. this.Data["json"] = &errinfo
  849. this.ServeJSON()
  850. }
  851. }
  852. // @Title 修改资质后找出不符合的准入
  853. // @Description 修改实体
  854. // @Success 200 {object} controllers.Request
  855. // @router /findinconformity [post]
  856. func (this *OilTechnologyServiceController) FindInconformity() {
  857. var errinfo ErrorInfo
  858. var err error
  859. var model technologyservice.OilTechnologyServiceAndCode
  860. var companygoodslist []suppliercertsub.OilSupplierCertSub
  861. var companygood suppliercertsub.OilSupplierCertSub
  862. var SurplusList []supplierfile.FileList
  863. var supfilemodel []supplierfile.OilSupplierFile
  864. var supfilemodel01 []supplierfile.OilSupplierFile
  865. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  866. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  867. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  868. var jsonBlob = this.Ctx.Input.RequestBody
  869. json.Unmarshal(jsonBlob, &model)
  870. Code := model.Code
  871. where := " Code ='"+Code+"' and Type in ('1','3') and SupplierTypeCode = '03'"
  872. svc.FindGoodsByCode("OilSupplierCertSub",where,&companygoodslist)
  873. SurplusList = filesvc.GetBasicNeedFileList(strconv.Itoa(model.Id))
  874. for _, CertSub := range companygoodslist {
  875. companygood = CertSub
  876. wherecompany := " SupplierId ="+strconv.Itoa(CertSub.SupplierId)
  877. svc.FindFileByCompany("OilSupplierFile",wherecompany,&supfilemodel)
  878. if len(supfilemodel)<1 {
  879. _,err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  880. }else {
  881. var tmplist1 []suppliercertsub.Tmp_OilSupplierCertSub
  882. wherecompany = " Id ="+strconv.Itoa(CertSub.Id)
  883. svc.FindFileByCompany("tmp_OilSupplierCertSub",wherecompany,&tmplist1)
  884. if len(tmplist1)<1{
  885. wherecompany = " SupplierId ='" + strconv.Itoa(CertSub.SupplierId) + "'"
  886. svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel01)
  887. var File01 string
  888. for _, Filesub := range supfilemodel01 {
  889. File01 = File01 + Filesub.NeedFileType + ","
  890. }
  891. for _, Filesub := range SurplusList {
  892. var supplierModel supplier.OilSupplier
  893. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  894. svcSupplier.GetEntityById(strconv.Itoa(CertSub.SupplierId), &supplierModel)
  895. //三证合一或五证合一不需要的字段
  896. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  897. File01 = mergerCertSkipField + File01
  898. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(File01, Filesub.FileName+",") { //三证合一或五证合一了
  899. continue
  900. }
  901. if strings.Contains(File01, Filesub.FileName+",") {
  902. continue
  903. }
  904. _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  905. break
  906. }
  907. }
  908. }
  909. }
  910. if err == nil {
  911. errinfo.Message = "已拉取缺失资质列表!"
  912. errinfo.Code = 0
  913. this.Data["json"] = &errinfo
  914. this.ServeJSON()
  915. } else {
  916. errinfo.Message = "拉取列表失败!" + utils.AlertProcess(err.Error())
  917. errinfo.Code = -1
  918. this.Data["json"] = &errinfo
  919. this.ServeJSON()
  920. }
  921. }
  922. // @Title get 导入excel
  923. // @Description get SampleType by token
  924. // @Success 200 {object} sampletype.SampleType
  925. // @router /importexcel [get]
  926. func (this *OilTechnologyServiceController) ImportExcel() {
  927. url := this.GetString("ExcelUrl")
  928. var errorinfo ErrorInfo
  929. if url == "" {
  930. errorinfo.Code = -2
  931. errorinfo.Message = "导入失败!"
  932. this.Data["json"] = &errorinfo
  933. this.ServeJSON()
  934. }
  935. session := utils.DBE.NewSession()
  936. err := session.Begin()
  937. svc := technologyservice.GetOilTechnologySession(session)
  938. err = svc.TruncateTable(Tmp_TechnologyName)
  939. if err != nil {
  940. session.Rollback()
  941. errorinfo.Code = -2
  942. errorinfo.Message = "导入失败!"
  943. this.Data["json"] = &errorinfo
  944. this.ServeJSON()
  945. }
  946. err = svc.TruncateTable(Tmp_TechnologyClassName)
  947. if err != nil {
  948. session.Rollback()
  949. errorinfo.Code = -2
  950. errorinfo.Message = "导入失败!"
  951. this.Data["json"] = &errorinfo
  952. this.ServeJSON()
  953. }
  954. _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
  955. filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
  956. utils.DownloadFile(url, filename, _dir)
  957. t := time.Now()
  958. filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
  959. xlFile, err := xlsx.OpenFile(filePath)
  960. var errLineNum string
  961. //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
  962. if err != nil {
  963. fmt.Printf("open failed: %s\n", err)
  964. }
  965. var sheet = xlFile.Sheets[0]
  966. Fstrs := svc.GetFCode()
  967. Fstrs = "ClassId, OrgName," + Fstrs
  968. columnArr := strings.Split(Fstrs, ",")
  969. defer func() {
  970. session.Close()
  971. }()
  972. codemap := make(map[string]int)
  973. arrLength := len(sheet.Rows[1].Cells)
  974. for i := 1; i < len(sheet.Rows); i++ {
  975. lineNo := strconv.Itoa(i + 1)
  976. this.OperationCell(svc, lineNo, columnArr, codemap, sheet.Rows[i].Cells, &errLineNum, arrLength)
  977. }
  978. os.Remove(filePath)
  979. if errLineNum != "" {
  980. session.Rollback()
  981. errorinfo.Code = -1
  982. errorinfo.Message = "导入失败!错误行号:" + errLineNum
  983. this.Data["json"] = &errorinfo
  984. this.ServeJSON()
  985. } else {
  986. session.Commit()
  987. elapsed := time.Since(t)
  988. log.Println(elapsed)
  989. errorinfo.Code = 0
  990. errorinfo.Message = "导入成功!"
  991. this.Data["json"] = &errorinfo
  992. this.ServeJSON()
  993. }
  994. }
  995. func (this *OilTechnologyServiceController) OperationCell(svc *technologyservice.OilTechnologySession, lineNo string, columnArr []string, codemap map[string]int, cellsArr []*xlsx.Cell, errLineNum *string, arrLength int) {
  996. defer func() {
  997. if err := recover(); err != nil {
  998. log.Println("err"+lineNo, err)
  999. *errLineNum += lineNo + ","
  1000. }
  1001. }()
  1002. parentId := 0
  1003. classId := 0
  1004. //cellsArrLen := len(cellsArr)
  1005. cellsArrLen := arrLength
  1006. var valstr = ""
  1007. for i := 0; i < cellsArrLen; {
  1008. if i < 8 {
  1009. var entity technologyserviceclass.Tmp_OilTechnologyServiceClass
  1010. cellval := strings.TrimSpace(cellsArr[i].String())
  1011. fmt.Println(cellval)
  1012. if cellval != "" {
  1013. _, has := codemap[cellval]
  1014. if !has {
  1015. if i > 2 {
  1016. upcode := cellsArr[i-2].String()
  1017. parentId = codemap[upcode]
  1018. } else {
  1019. upcode := cellsArr[0].String()
  1020. parentId = codemap[upcode]
  1021. }
  1022. entity.Code = cellval
  1023. entity.Name = strings.TrimSpace(cellsArr[i+1].String())
  1024. entity.ParentId = parentId
  1025. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1026. entity.CreateBy = this.User.Realname
  1027. entity.CreateOn = time.Now()
  1028. _, err := svc.InsertEntityBytbl(Tmp_TechnologyClassName, &entity)
  1029. if err != nil {
  1030. panic(err)
  1031. break
  1032. }
  1033. classId = entity.Id
  1034. if i <= 6 {
  1035. codemap[cellval] = entity.Id
  1036. }
  1037. }
  1038. }
  1039. }
  1040. if i >= 8 {
  1041. valstr += "'" + strings.TrimLeft(cellsArr[i].String(), " ") + "',"
  1042. i++
  1043. } else {
  1044. i += 2
  1045. }
  1046. }
  1047. valstr = strings.Trim(valstr, ",")
  1048. valstr = strings.Replace(valstr, "是", "1", -1)
  1049. log.Println(cellsArr[0].String() + "==" + valstr)
  1050. var columnstr = ""
  1051. for l := 0; l < cellsArrLen-7; l++ {
  1052. columnstr += columnArr[l] + ","
  1053. }
  1054. columnstr = strings.Trim(columnstr, ",")
  1055. valstr = strconv.Itoa(classId) + "," + valstr
  1056. var err error
  1057. if classId > 0 {
  1058. err = svc.InsertTmpTechnology(columnstr, valstr)
  1059. }
  1060. if err != nil {
  1061. panic(err)
  1062. }
  1063. }
  1064. // @Title 获取列表新导入的列表
  1065. // @Description get user by token
  1066. // @Success 200 {object} []
  1067. // @router /importlist [get]
  1068. func (this *OilTechnologyServiceController) GetImportEntityList() {
  1069. //获取分页信息
  1070. page := this.GetPageInfoForm()
  1071. where := " 1=1 "
  1072. orderby := "Code"
  1073. asc := true
  1074. Order := this.GetString("Order")
  1075. Prop := this.GetString("Prop")
  1076. if Order != "" && Prop != "" {
  1077. orderby = Prop
  1078. if Order == "asc" {
  1079. asc = true
  1080. }else {
  1081. asc = false
  1082. }
  1083. }
  1084. CreateOn := this.GetString("CreateOn")
  1085. Code := this.GetString("Code")
  1086. Name := this.GetString("Name")
  1087. Code1 := this.GetString("Code1")
  1088. Name1 := this.GetString("Name1")
  1089. Code2 := this.GetString("Code2")
  1090. Name2 := this.GetString("Name2")
  1091. Code3 := this.GetString("Code3")
  1092. Name3 := this.GetString("Name3")
  1093. Code4 := this.GetString("Code4")
  1094. Name4 := this.GetString("Name4")
  1095. if Code != "" {
  1096. where = where + " and Code like '%" + Code + "%'"
  1097. }
  1098. if Name != "" {
  1099. where = where + " and Name like '%" + Name + "%'"
  1100. }
  1101. if Code1 != "" {
  1102. where = where + " and Code1 like '%" + Code1 + "%'"
  1103. }
  1104. if Name1 != "" {
  1105. where = where + " and Name1 like '%" + Name1 + "%'"
  1106. }
  1107. if Code2 != "" {
  1108. where = where + " and Code2 like '%" + Code2 + "%'"
  1109. }
  1110. if Name2 != "" {
  1111. where = where + " and Name2 like '%" + Name2 + "%'"
  1112. }
  1113. if Code3 != "" {
  1114. where = where + " and Code3 like '%" + Code3 + "%'"
  1115. }
  1116. if Name3 != "" {
  1117. where = where + " and Name3 like '%" + Name3 + "%'"
  1118. }
  1119. if Code4 != "" {
  1120. where = where + " and Code4 like '%" + Code4 + "%'"
  1121. }
  1122. if Name4 != "" {
  1123. where = where + " and Name4 like '%" + Name4 + "%'"
  1124. }
  1125. if CreateOn != "" {
  1126. dates := strings.Split(CreateOn, ",")
  1127. if len(dates) == 2 {
  1128. minDate := dates[0]
  1129. maxDate := dates[1]
  1130. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  1131. }
  1132. }
  1133. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1134. var list []technologyservice.OilTechnologyServiceView
  1135. total := svc.GetMyPagingEntitiesWithOrderBytbl(ImportTechsrvDetailViewName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  1136. var datainfo DataInfo
  1137. datainfo.Items = list
  1138. datainfo.CurrentItemCount = total
  1139. datainfo.PageIndex = page.CurrentPage
  1140. datainfo.ItemsPerPage = page.Size
  1141. this.Data["json"] = &datainfo
  1142. this.ServeJSON()
  1143. }
  1144. // @Title 将导入的数据 导入到正式表
  1145. // @Description get SampleType by token
  1146. // @Success 200 {object} sampletype.SampleType
  1147. // @router /insertTechnology [get]
  1148. func (this *OilTechnologyServiceController) InsertTechnology() {
  1149. session := utils.DBE.NewSession()
  1150. err := session.Begin()
  1151. defer session.Close()
  1152. svc := technologyservice.GetOilTechnologySession(session)
  1153. var errinfo ErrorInfo
  1154. err = svc.TruncateTable(OilTechnologyServiceName)
  1155. if err != nil {
  1156. session.Rollback()
  1157. errinfo.Code = -1
  1158. errinfo.Message = "更新失败!"
  1159. this.Data["json"] = &errinfo
  1160. this.ServeJSON()
  1161. }
  1162. err = svc.TruncateTable(OilTechnologyServiceClassName)
  1163. if err != nil {
  1164. session.Rollback()
  1165. errinfo.Code = -1
  1166. errinfo.Message = "更新失败!"
  1167. this.Data["json"] = &errinfo
  1168. this.ServeJSON()
  1169. }
  1170. err = svc.InsertTechnology(Tmp_TechnologyName, OilTechnologyServiceName)
  1171. if err != nil {
  1172. session.Rollback()
  1173. errinfo.Code = -1
  1174. errinfo.Message = "更新失败!"
  1175. this.Data["json"] = &errinfo
  1176. this.ServeJSON()
  1177. }
  1178. err = svc.InsertTechnology(Tmp_TechnologyClassName, OilTechnologyServiceClassName)
  1179. if err != nil {
  1180. session.Rollback()
  1181. errinfo.Code = -1
  1182. errinfo.Message = "更新失败!"
  1183. this.Data["json"] = &errinfo
  1184. this.ServeJSON()
  1185. }
  1186. session.Commit()
  1187. errinfo.Code = 0
  1188. errinfo.Message = "更新成功,即将操作企业准入范围!"
  1189. this.Data["json"] = &errinfo
  1190. this.ServeJSON()
  1191. }
  1192. // @Title 更新企业的准入项及资质
  1193. // @Description get SampleType by token
  1194. // @Success 200 {object} sampletype.SampleType
  1195. // @router /updatasuppiercertsub [get]
  1196. func (this *OilTechnologyServiceController) UpdataSuppierCertSub() {
  1197. t := time.Now()
  1198. technologysvc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1199. technologysvc.DeleteTable(TmpOilSupplierCertSubName, "SupplierTypeCode='03'")
  1200. supsvc := supplier.GetOilSupplierService(utils.DBE)
  1201. var suppliercertList []suppliercert.OilSupplierCert
  1202. where := "SupplierTypeCode='03' AND OutsideFlog = '' AND (InFlag IN ('1','2')) "
  1203. supsvc.GetEntities(&suppliercertList, where)
  1204. var technologyClassList []technologyserviceclass.OilTechnologyServiceClass
  1205. supsvc.GetEntities(&technologyClassList, "")
  1206. var colsname = []string{"Name"}
  1207. for _, suppliercert := range suppliercertList {
  1208. var supplier supplier.OilSupplier
  1209. wheres := " Id=" + strconv.Itoa(suppliercert.SupplierId)
  1210. supsvc.GetEntity(&supplier, wheres)
  1211. log.Println(suppliercert.SupplierId)
  1212. var supplierCertSubList []suppliercertsub.OilSupplierCertSub
  1213. wheresup := "SupplierId = " + strconv.Itoa(suppliercert.SupplierId) + " and SupplierTypeCode='03' AND Type IN ('1', '3')"
  1214. supsvc.GetEntities(&supplierCertSubList, wheresup)
  1215. fmt.Println(len(supplierCertSubList))
  1216. mergerCertSkipField := ""
  1217. if supplier.CredentialFlag == "1" || supplier.CredentialFlag == "2" {
  1218. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1219. //三证合一或五证合一不需要的字段
  1220. mergerCertSkipField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  1221. }
  1222. for idx := 0; idx < len(supplierCertSubList); idx++ {
  1223. supplierCertSub := supplierCertSubList[idx]
  1224. decCode := supplierCertSub.Code
  1225. // 物资类的准入编码
  1226. for _, technologyClass := range technologyClassList {
  1227. // 如果编码相同的后 判断有没有改名 然后查询准入项需要哪些资质 去查资质表里有没有这些资质 没有就删除这个准入项
  1228. if supplierCertSub.Code == technologyClass.Code {
  1229. decCode = ""
  1230. technologyNameArr := this.GetTechnologyName(strconv.Itoa(technologyClass.Id))
  1231. for _, val := range technologyNameArr {
  1232. if strings.Contains(mergerCertSkipField, val) {
  1233. break
  1234. }
  1235. var supplierFile supplierfile.OilSupplierFile
  1236. where := "SupplierId=" + strconv.Itoa(suppliercert.SupplierId) + " and NeedFileType='" + val + "'" + " and SupplierTypeCode IN ('000', '03')"
  1237. has := supsvc.GetEntityByWhere(OilSupplierFileName, where, &supplierFile)
  1238. if !has {
  1239. log.Println(supplierCertSub.Code + "====" + val)
  1240. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  1241. break
  1242. }
  1243. if supplierCertSub.Name != technologyClass.Name {
  1244. var entity suppliercertsub.OilSupplierCertSub
  1245. entity.Name = technologyClass.Name
  1246. where := "Id = " + strconv.Itoa(supplierCertSub.Id)
  1247. supsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &entity, colsname, where)
  1248. }
  1249. }
  1250. break
  1251. }
  1252. }
  1253. if decCode != "" {
  1254. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  1255. }
  1256. }
  1257. }
  1258. elapsed := time.Since(t)
  1259. log.Println(elapsed)
  1260. var errinfo ErrorInfo
  1261. errinfo.Code = 0
  1262. errinfo.Message = "更新完成!"
  1263. this.Data["json"] = &errinfo
  1264. this.ServeJSON()
  1265. //xlFile.Save(excelFileName)
  1266. }
  1267. func (this *OilTechnologyServiceController) GetTechnologyName(classId string) []string {
  1268. var goodsAptitudeName string
  1269. var technologyFList []technologyservice.OilTechnologyF
  1270. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1271. where := "ClassId=" + classId
  1272. svc.GetOilTechnologyF(&technologyFList, where)
  1273. for _, goodsAptitude := range technologyFList {
  1274. t := reflect.TypeOf(goodsAptitude)
  1275. v := reflect.ValueOf(goodsAptitude)
  1276. for k := 0; k < t.NumField(); k++ {
  1277. if v.Field(k).Interface() == "1" {
  1278. var tableHeader tableheader.BaseTableheader
  1279. where := "Code='" + t.Field(k).Name + "' and CategoryCode = '03'"
  1280. has := svc.GetEntityByWhere(BaseTableHeader, where, &tableHeader)
  1281. if has {
  1282. goodsAptitudeName += tableHeader.Name + ","
  1283. }
  1284. }
  1285. }
  1286. }
  1287. goodsAptitudeName = strings.Trim(goodsAptitudeName, ",")
  1288. return strings.Split(goodsAptitudeName, ",")
  1289. }
  1290. // @Title 导出数据到word,作为导出pdf的中间步骤
  1291. // @Description 数据存入word
  1292. // @Success 200 {object} controllers.Request
  1293. // @router /exportpdf/:tbid/:typecode [post]
  1294. func (this *OilTechnologyServiceController) PdfExport() {
  1295. Id := this.Ctx.Input.Param(":tbid")
  1296. SupplierTypeCode := this.Ctx.Input.Param(":typecode")
  1297. var Url string
  1298. var fileName string
  1299. var model1 supplierdataentry.SupplierDataEntry
  1300. var model2 supplierdataentry.SupplierCertDataEntry
  1301. svc := supplierdataentry.GetSupplierDataEntryService(utils.DBE)
  1302. where1 := "1=1"
  1303. where1 += " AND Id = '" + Id + "'"
  1304. where2 := "SupplierId = '" + Id + "' and SupplierTypecode='"+ SupplierTypeCode +"'"
  1305. svc.GetEntityByWhere(OilSupplierName, where1, &model1)
  1306. svc.GetEntityByWhere(OilSupplierCertName, where2, &model2)
  1307. var tabledata []supplierdataentry.SupplierCertSubEntry
  1308. where3:="SupplierId = '" + Id + "' and SupplierTypecode='"+ SupplierTypeCode +"' and Type in ('1','3')"//准入状态的准入项
  1309. svc.GetEntitysByOrderbyWhere(TmpOilSupplierCertSubName, where3, "1", &tabledata)
  1310. datamap := structToMapDemo(model1.OilSupplier)
  1311. if model2.SupplierTypeCode == "01" {
  1312. Url = utils.Cfg.MustValue("workflow", "goodsPdfHost")
  1313. fileName = "待删除物资类准入范围.docx"
  1314. } else if model2.SupplierTypeCode == "02" {
  1315. Url = utils.Cfg.MustValue("workflow", "basisPdfHost")
  1316. fileName = "待删除基建类准入范围.docx"
  1317. datamap["TJInNotify"] = model1.TJInNotify
  1318. } else {
  1319. Url = utils.Cfg.MustValue("workflow", "techPdfHost")
  1320. fileName = "待删除服务类准入范围.docx"
  1321. }
  1322. //model1
  1323. datamap["SetupTime"] = model1.SetupTime.Format("2006年01月02日")
  1324. datamap["QualifCert"] = model1.QualifCert
  1325. datamap["QualifCertLevel"] = model1.QualifCertLevel
  1326. datamap["SpecIndustryCert"] = model1.SpecIndustryCert
  1327. datamap["MaunLicense"] = model1.MaunLicense
  1328. if model1.HseTraining == "1" {
  1329. datamap["HseTraining"] = "是"
  1330. } else {
  1331. datamap["HseTraining"] = "否"
  1332. }
  1333. if model1.OperType != "" {
  1334. if model1.OperType == "1" || model1.OperType == "制造商"{
  1335. datamap["OperType"] = "√制造商 □代理商 □贸易商"
  1336. }else if model1.OperType == "2" || model1.OperType == "代理商"{
  1337. datamap["OperType"] = "□制造商 √代理商 □贸易商"
  1338. }else if model1.OperType == "3" || model1.OperType == "代理商"{
  1339. datamap["OperType"] = "□制造商 □代理商 √贸易商"
  1340. }else {
  1341. datamap["OperType"] = "□制造商 □代理商 □贸易商"
  1342. }
  1343. }
  1344. if model1.SpecTypeCode != "" {
  1345. if model1.SpecTypeCode == "1"{
  1346. datamap["SpecTypeCode"] = "√一般外部 □多元企业"
  1347. }else if model1.SpecTypeCode == "2"{
  1348. datamap["SpecTypeCode"] = "□一般外部 √多元企业"
  1349. }else {
  1350. datamap["SpecTypeCode"] = "□一般外部 □多元企业"
  1351. }
  1352. }
  1353. if model1.Grade == "1"{
  1354. datamap["Grade"] = "一级"
  1355. }else if model1.SpecTypeCode == "2"{
  1356. datamap["Grade"] = "二级"
  1357. }
  1358. datamap["Fax"] = model1.Fax
  1359. datamap["CompanyTel"] = model1.CompanyTel
  1360. datamap["SupplierName"] = model1.SupplierName
  1361. datamap["Country"] = model1.Country
  1362. datamap["MaunAgent"] = model1.MaunAgent
  1363. datamap["SupplierCertificate"] = model1.SupplierCertificate
  1364. datamap["MgrUnit"] = model1.MgrUnit
  1365. datamap["CommercialNo"] = model1.CommercialNo
  1366. datamap["CountryTaxNo"] = model1.CountryTaxNo
  1367. datamap["OrganCode"] = model1.OrganCode
  1368. datamap["Address"] = model1.Address
  1369. datamap["ZipCode"] = model1.ZipCode
  1370. datamap["LinkAddress"] = model1.LinkAddress
  1371. datamap["LinkZipCode"] = model1.LinkZipCode
  1372. datamap["QualitySystemCert"] = model1.QualitySystemCert
  1373. datamap["ProductQualityCert"] = model1.ProductQualityCert
  1374. datamap["MaunLicense"] = model1.MaunLicense
  1375. datamap["LegalPerson"] = model1.LegalPerson
  1376. datamap["CompanyType"] = model1.CompanyType
  1377. datamap["ContactName"] = model1.ContactName
  1378. datamap["RegCapital"] = strconv.FormatFloat(model1.RegCapital,'f',2,64)+"万元"+model1.Currency
  1379. datamap["DepositBank"] = model1.DepositBank
  1380. datamap["BankAccount"] = model1.BankAccount
  1381. datamap["Mobile"] = model1.Mobile
  1382. datamap["EMail"] = model1.EMail
  1383. datamap["BankCreditRating"] = model1.BankCreditRating
  1384. datamap["BusinessScope"] = model1.BusinessScope
  1385. datamap["Telphone"] = model1.Telphone
  1386. datamap["AccessCardNo"] = model2.AccessCardNo
  1387. datamap["PrintYear"] = time.Now().Year()
  1388. datamap["PrintMonth"] = time.Now().Month()
  1389. datamap["PrintDay"] = time.Now().Day()
  1390. datamap["Name"] = ""
  1391. if len(tabledata) != 0 {
  1392. var Name string
  1393. Name = "\n待删除准入范围:"+ tabledata[0].Code
  1394. Name = Name + " " + tabledata[0].Name
  1395. var i int
  1396. for i = 1; i < len(tabledata); i++ {
  1397. Name += ";"
  1398. Name += tabledata[i].Code
  1399. Name = Name + " " + tabledata[i].Name
  1400. }
  1401. //if i == 100 {
  1402. // Name += "(准入范围未完全显示,请到系统查看详情)"
  1403. //}
  1404. datamap["Name"] =datamap["Name"].(string) + Name
  1405. } else {
  1406. datamap["Name"] =datamap["Name"].(string)
  1407. }
  1408. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1409. retDocUrl := svcActiviti.FillWordTemplate(datamap, Url, fileName)
  1410. var datainfo ErrorDataInfo
  1411. datainfo.Code = 0
  1412. datainfo.Item = retDocUrl
  1413. datainfo.Message = "准备导出"
  1414. this.Data["json"] = &datainfo
  1415. this.ServeJSON()
  1416. }
  1417. // @Title get 清空导入的信息
  1418. // @Description get SampleType by token
  1419. // @Success 200 {object} sampletype.SampleType
  1420. // @router /truncateimport [get]
  1421. func (this *OilTechnologyServiceController) TruncateImport() {
  1422. session := utils.DBE.NewSession()
  1423. err := session.Begin()
  1424. defer session.Close()
  1425. svc := technologyservice.GetOilTechnologySession(session)
  1426. err = svc.TruncateTable(Tmp_TechnologyName)
  1427. var errorinfo ErrorInfo
  1428. if err != nil {
  1429. session.Rollback()
  1430. errorinfo.Code = -1
  1431. errorinfo.Message = "删除失败!"
  1432. this.Data["json"] = &errorinfo
  1433. this.ServeJSON()
  1434. }
  1435. err = svc.TruncateTable(Tmp_TechnologyClassName)
  1436. if err != nil {
  1437. session.Rollback()
  1438. errorinfo.Code = -1
  1439. errorinfo.Message = "删除失败!"
  1440. this.Data["json"] = &errorinfo
  1441. this.ServeJSON()
  1442. }
  1443. session.Commit()
  1444. errorinfo.Code = 0
  1445. errorinfo.Message = "删除成功!"
  1446. this.Data["json"] = &errorinfo
  1447. this.ServeJSON()
  1448. }
  1449. // @Title 导出到execl
  1450. // @Description 导出到execl
  1451. // @Success 200 {object} controllers.Request
  1452. // @router /exportexecl [post]
  1453. func (this *OilTechnologyServiceController) ExeclExport() {
  1454. // 填物资类信息表首页信息
  1455. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1456. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1457. var list2 []supplier.OilSupplierContrast
  1458. where := " 1=1"
  1459. svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierTecContrast", 0,0, "Id", false, &list2, where)
  1460. fileName := "资质导入对比表.xlsx"
  1461. Url := utils.Cfg.MustValue("workflow", "ContrastExcel")
  1462. var datamap = make(map[string]interface{})
  1463. datamap["data"] = list2
  1464. retDocUrl := svcActiviti.ContrastExcel(datamap, Url, fileName)
  1465. var datainfo ErrorDataInfo
  1466. datainfo.Code = 0
  1467. datainfo.Item = retDocUrl
  1468. datainfo.Message = "打印成功"
  1469. this.Data["json"] = &datainfo
  1470. this.ServeJSON()
  1471. }
  1472. // @Title 新导入资质后,比对不合格的准入用户
  1473. // @Description 对比列表
  1474. // @Success 200 {object} []supplier.OilSupplierSelect
  1475. // @router /get-compare-tmp-supplier [get]
  1476. func (this *OilTechnologyServiceController) GetCompareTmpSupplier() {
  1477. //获取分页信息
  1478. page := this.GetPageInfoForm()
  1479. where := " 1=1 "
  1480. orderby := "Id"
  1481. asc := false
  1482. Order := this.GetString("Order")
  1483. Prop := this.GetString("Prop")
  1484. if Order != "" && Prop != "" {
  1485. orderby = Prop
  1486. if Order == "asc" {
  1487. asc = true
  1488. }
  1489. }
  1490. Id := this.GetString("Id")
  1491. SupplierName := this.GetString("SupplierName")
  1492. AccessCardNo := this.GetString("AccessCardNo")
  1493. SupplierTypeCode := this.GetString("SupplierTypeCode")
  1494. Code := this.GetString("Code")
  1495. Name := this.GetString("Name")
  1496. Conditions := this.GetString("Conditions")
  1497. IsDelete := this.GetString("IsDelete")
  1498. CreateOn := this.GetString("CreateOn")
  1499. CreateUserId := this.GetString("CreateUserId")
  1500. CreateBy := this.GetString("CreateBy")
  1501. ModifiedOn := this.GetString("ModifiedOn")
  1502. ModifiedUserId := this.GetString("ModifiedUserId")
  1503. ModifiedBy := this.GetString("ModifiedBy")
  1504. if Id != "" {
  1505. where = where + " and Id like '%" + Id + "%'"
  1506. }
  1507. if SupplierName != "" {
  1508. where = where + " and SupplierName like '%" + SupplierName + "%'"
  1509. }
  1510. if AccessCardNo != "" {
  1511. where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
  1512. }
  1513. if SupplierTypeCode != "" {
  1514. where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'"
  1515. }
  1516. if Code != "" {
  1517. where = where + " and Code like '%" + Code + "%'"
  1518. }
  1519. if Name != "" {
  1520. where = where + " and Name like '%" + Name + "%'"
  1521. }
  1522. if Conditions == "2"{
  1523. where = where + " and MinClassId = '0'"
  1524. } else if Conditions == "3"{
  1525. where = where + " and Checked = '0'"
  1526. } else if Conditions == "4"{
  1527. where = where + " and Checked = '1"
  1528. }
  1529. if IsDelete != "" {
  1530. where = where + " and IsDelete like '%" + IsDelete + "%'"
  1531. }
  1532. if CreateUserId != "" {
  1533. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  1534. }
  1535. if CreateBy != "" {
  1536. where = where + " and CreateBy like '%" + CreateBy + "%'"
  1537. }
  1538. if ModifiedOn != "" {
  1539. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  1540. }
  1541. if ModifiedUserId != "" {
  1542. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  1543. }
  1544. if ModifiedBy != "" {
  1545. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  1546. }
  1547. if CreateOn != "" {
  1548. dates := strings.Split(CreateOn, ",")
  1549. if len(dates) == 2 {
  1550. minDate := dates[0]
  1551. maxDate := dates[1]
  1552. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  1553. }
  1554. }
  1555. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1556. var list2 []supplier.OilSupplierContrast
  1557. total := svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierTecContrast", page.CurrentPage, page.Size, orderby, asc, &list2, where)
  1558. var datainfo DataInfo
  1559. datainfo.Items = list2
  1560. datainfo.CurrentItemCount = total
  1561. datainfo.PageIndex = page.CurrentPage
  1562. datainfo.ItemsPerPage = page.Size
  1563. this.Data["json"] = &datainfo
  1564. this.ServeJSON()
  1565. }
  1566. // @Title 获取列表
  1567. // @Description get user by token
  1568. // @Success 200 {object} []goodsaptitude.OilGoodsAptitude
  1569. // @router /comparelist [get]
  1570. func (this *OilTechnologyServiceController) GetCompareList() {
  1571. //获取分页信息
  1572. page := this.GetPageInfoForm()
  1573. where := " 1=1 "
  1574. orderby := "Code"
  1575. asc := true
  1576. Order := this.GetString("Order")
  1577. Prop := this.GetString("Prop")
  1578. Conditions := this.GetString("Conditions")
  1579. if Conditions == "1" {
  1580. // 匹配上
  1581. where += " and b.Name = tmpb.Name"
  1582. } else if Conditions == "4" {
  1583. // 旧表有新表没
  1584. where += " and tmpb.Name is null"
  1585. } else if Conditions == "5" {
  1586. // 新表有,旧表没
  1587. where += " and tmpb.Name is null"
  1588. } else if Conditions == "6" {
  1589. // 资质+级别匹配
  1590. where += " and b.Name = tmpb.Name and (a.F01 = tmpa.F01 or (tmpa.F01 = '' && a.F01 is null)) and (a.F02 = tmpa.F02 or (tmpa.F02 = '' && a.F02 is null)) and (a.F03 = tmpa.F03 or (tmpa.F03 = '' && a.F03 is null)) and (a.F04 = tmpa.F04 or (tmpa.F04 = '' && a.F04 is null)) and (a.F05 = tmpa.F05 or (tmpa.F05 = '' && a.F05 is null)) and (a.F06 = tmpa.F06 or (tmpa.F06 = '' && a.F06 is null)) and (a.F07 = tmpa.F07 or (tmpa.F07 = '' && a.F07 is null)) and (a.F08 = tmpa.F08 or (tmpa.F08 = '' && a.F08 is null)) and (a.F09 = tmpa.F09 or (tmpa.F09 = '' && a.F09 is null)) and (a.F10 = tmpa.F10 or (tmpa.F10 = '' && a.F10 is null))" +
  1591. " and (a.F11 = tmpa.F11 or (tmpa.F11 = '' && a.F11 is null)) and (a.F12 = tmpa.F12 or (tmpa.F12 = '' && a.F12 is null)) and (a.F13 = tmpa.F13 or (tmpa.F13 = '' && a.F13 is null)) and (a.F14 = tmpa.F14 or (tmpa.F14 = '' && a.F14 is null)) and (a.F15 = tmpa.F15 or (tmpa.F15 = '' && a.F15 is null)) and (a.F16 = tmpa.F16 or (tmpa.F16 = '' && a.F16 is null)) and (a.F17 = tmpa.F17 or (tmpa.F17 = '' && a.F17 is null)) and (a.F18 = tmpa.F18 or (tmpa.F18 = '' && a.F18 is null)) and (a.F19 = tmpa.F19 or (tmpa.F19 = '' && a.F19 is null)) and (a.F20 = tmpa.F20 or (tmpa.F20 = '' && a.F20 is null))" +
  1592. " and (a.F21 = tmpa.F21 or (tmpa.F21 = '' && a.F21 is null)) and (a.F22 = tmpa.F22 or (tmpa.F22 = '' && a.F22 is null)) and (a.F23 = tmpa.F23 or (tmpa.F23 = '' && a.F23 is null)) and (a.F24 = tmpa.F24 or (tmpa.F24 = '' && a.F24 is null)) and (a.F25 = tmpa.F25 or (tmpa.F25 = '' && a.F25 is null)) and (a.F26 = tmpa.F26 or (tmpa.F26 = '' && a.F26 is null)) and (a.F27 = tmpa.F27 or (tmpa.F27 = '' && a.F27 is null)) and (a.F28 = tmpa.F28 or (tmpa.F28 = '' && a.F28 is null)) and (a.F29 = tmpa.F29 or (tmpa.F29 = '' && a.F29 is null)) and (a.F30 = tmpa.F30 or (tmpa.F30 = '' && a.F30 is null))" +
  1593. " and (a.F31 = tmpa.F31 or (tmpa.F31 = '' && a.F31 is null)) and (a.F32 = tmpa.F32 or (tmpa.F32 = '' && a.F32 is null)) and (a.F33 = tmpa.F33 or (tmpa.F33 = '' && a.F33 is null)) and (a.F34 = tmpa.F34 or (tmpa.F34 = '' && a.F34 is null)) and (a.F35 = tmpa.F35 or (tmpa.F35 = '' && a.F35 is null)) and (a.F36 = tmpa.F36 or (tmpa.F36 = '' && a.F36 is null)) and (a.F37 = tmpa.F37 or (tmpa.F37 = '' && a.F37 is null)) and (a.F38 = tmpa.F38 or (tmpa.F38 = '' && a.F38 is null)) and (a.F39 = tmpa.F39 or (tmpa.F39 = '' && a.F39 is null)) and (a.F40 = tmpa.F40 or (tmpa.F40 = '' && a.F40 is null))" +
  1594. " and (a.F41 = tmpa.F41 or (tmpa.F41 = '' && a.F41 is null)) and (a.F42 = tmpa.F42 or (tmpa.F42 = '' && a.F42 is null)) and (a.F43 = tmpa.F43 or (tmpa.F43 = '' && a.F43 is null)) and (a.F44 = tmpa.F44 or (tmpa.F44 = '' && a.F44 is null)) and (a.F45 = tmpa.F45 or (tmpa.F45 = '' && a.F45 is null)) and (a.F46 = tmpa.F46 or (tmpa.F46 = '' && a.F46 is null)) and (a.F47 = tmpa.F47 or (tmpa.F47 = '' && a.F47 is null)) and (a.F48 = tmpa.F48 or (tmpa.F48 = '' && a.F48 is null)) and (a.F49 = tmpa.F49 or (tmpa.F49 = '' && a.F49 is null)) and (a.F50 = tmpa.F50 or (tmpa.F50 = '' && a.F50 is null))" +
  1595. " and (a.F51 = tmpa.F51 or (tmpa.F51 = '' && a.F51 is null)) and (a.F52 = tmpa.F52 or (tmpa.F52 = '' && a.F52 is null))"
  1596. }
  1597. if Order != "" && Prop != "" {
  1598. orderby = Prop
  1599. if Order == "asc" {
  1600. asc = true
  1601. } else {
  1602. asc = false
  1603. }
  1604. }
  1605. CreateOn := this.GetString("CreateOn")
  1606. Code := this.GetString("Code")
  1607. Name := this.GetString("Name")
  1608. BigClassName := this.GetString("BigClassName")
  1609. BigClassCode := this.GetString("BigClassCode")
  1610. MiddleClassName := this.GetString("MiddleClassName")
  1611. SmallClassName := this.GetString("SmallClassName")
  1612. GoodsName := this.GetString("GoodsName")
  1613. GoodsLevel := this.GetString("GoodsLevel")
  1614. GoodsDesc := this.GetString("GoodsDesc")
  1615. Standard := this.GetString("Standard")
  1616. CompanyType := this.GetString("CompanyType")
  1617. if Code != "" {
  1618. where = where + " and b.Code like '%" + Code + "%'"
  1619. }
  1620. if Name != "" {
  1621. where = where + " and b.Name like '%" + Name + "%'"
  1622. }
  1623. if BigClassName != "" {
  1624. where = where + " and Name1 like '%" + BigClassName + "%'"
  1625. }
  1626. if BigClassCode != "" {
  1627. where = where + " and Code1 like '%" + BigClassCode + "%'"
  1628. }
  1629. if MiddleClassName != "" {
  1630. where = where + " and Name2 like '%" + MiddleClassName + "%'"
  1631. }
  1632. if SmallClassName != "" {
  1633. where = where + " and Name3 like '%" + SmallClassName + "%'"
  1634. }
  1635. if GoodsName != "" {
  1636. where = where + " and Name4 like '%" + GoodsName + "%'"
  1637. }
  1638. if GoodsLevel != "" {
  1639. where = where + " and GoodsLevel like '%" + GoodsLevel + "%'"
  1640. }
  1641. if GoodsDesc != "" {
  1642. where = where + " and GoodsDesc like '%" + GoodsDesc + "%'"
  1643. }
  1644. if Standard != "" {
  1645. where = where + " and Standard '%" + Standard + "%'"
  1646. }
  1647. if CompanyType != "" {
  1648. where = where + " and CompanyType '%" + CompanyType + "%'"
  1649. }
  1650. if CreateOn != "" {
  1651. dates := strings.Split(CreateOn, ",")
  1652. if len(dates) == 2 {
  1653. minDate := dates[0]
  1654. maxDate := dates[1]
  1655. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  1656. }
  1657. }
  1658. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1659. var list []technologyservice.OilTechnologyServiceTmp
  1660. total := svc.GetPClassEntities(page.CurrentPage, page.Size, orderby, asc, &list, where, Conditions)
  1661. var datainfo DataInfo
  1662. datainfo.Items = list
  1663. datainfo.CurrentItemCount = total
  1664. datainfo.PageIndex = page.CurrentPage
  1665. datainfo.ItemsPerPage = page.Size
  1666. this.Data["json"] = &datainfo
  1667. this.ServeJSON()
  1668. }
  1669. // @Title get 生成对比列表
  1670. // @Description get SampleType by token
  1671. // @Success 200 {object} sampletype.SampleType
  1672. // @router /create-contrast [get]
  1673. func (this *OilTechnologyServiceController) CreateContrast() {
  1674. go func() {
  1675. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1676. svc.TruncateTable("OilSupplierTecContrast")
  1677. // 插入对比列表
  1678. var list1 []supplier.OilSupplier
  1679. svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, 0, 0, "Id", false, &list1, " 1=1")
  1680. svc.DBE.Query("SET unique_checks=0;")
  1681. svc.DBE.Query("SET autocommit=0;")
  1682. for _, item := range list1 {
  1683. var list []supplier.OilSupplierContrast
  1684. where := " b.SupplierTypeCode='03' and a.Id = " + strconv.Itoa(item.Id)
  1685. svc.GetPagingTmpCheckedEntities(&list, where)
  1686. if list != nil {
  1687. var supplierCertSubList []suppliercertsub.OilSupplierCertSub
  1688. total := svc.GetTableTotal(" SupplierTypeCode='03' AND SupplierId = "+strconv.Itoa(item.Id), &supplierCertSubList)
  1689. total1 := svc.GetNoSubCntTotal("a.SupplierTypeCode = '03' and c.ClassId is null and a.SupplierId = " + strconv.Itoa(item.Id))
  1690. list[0].SubCnt = int(total)
  1691. //list[0].MinClassId = "0"
  1692. list[0].NoSubCnt = int(total1)
  1693. //for _, sub := range supplierCertSubList {
  1694. // var technologyClassList technologyserviceclass.OilTechnologyServiceClass
  1695. // where2 := "Name = '"+ sub.Name + "'"
  1696. // svc.GetEntityByWhere(Tmp_TechnologyClassName, where2, &technologyClassList)
  1697. // if technologyClassList.Id > 0{
  1698. // list[0].MinClassId = strconv.Itoa(technologyClassList.Id)
  1699. // } else {
  1700. // list[0].MinClassId = "0"
  1701. // break
  1702. // }
  1703. //}
  1704. list[0].SetupTime = time.Now()
  1705. svc.InsertEntityBytbl("OilSupplierTecContrast", list[0])
  1706. svc.DBE.Query("commit;")
  1707. }
  1708. }
  1709. svc.DBE.Query("SET unique_checks=1;")
  1710. svc.DBE.Query("SET autocommit=1;")
  1711. }()
  1712. var errorinfo ErrorInfo
  1713. errorinfo.Code = 0
  1714. errorinfo.Message = "成功!"
  1715. this.Data["json"] = &errorinfo
  1716. this.ServeJSON()
  1717. }
  1718. // @Title 查看对比列表的准入范围 2020-12-18
  1719. // @Description get user by token
  1720. // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
  1721. // @router /delcertsublist [get]
  1722. func (this *OilTechnologyServiceController) GetDelCertSubList() {
  1723. //获取分页信息
  1724. page := this.GetPageInfoForm()
  1725. where := " 1=1 "
  1726. orderby := "a.Id"
  1727. asc := false
  1728. Order := this.GetString("Order")
  1729. Prop := this.GetString("Prop")
  1730. if Order != "" && Prop != "" {
  1731. orderby = Prop
  1732. if Order == "asc" {
  1733. asc = true
  1734. }
  1735. }
  1736. Id := this.GetString("Id")
  1737. SupplierId := this.GetString("SupplierId")
  1738. SupplierCertId := this.GetString("SupplierCertId")
  1739. SupplierTypeCode := this.GetString("SupplierTypeCode")
  1740. Code := this.GetString("Code")
  1741. Name := this.GetString("Name")
  1742. Remark := this.GetString("Remark")
  1743. IsDelete := this.GetString("IsDelete")
  1744. CreateOn := this.GetString("CreateOn")
  1745. CreateUserId := this.GetString("CreateUserId")
  1746. CreateBy := this.GetString("CreateBy")
  1747. ModifiedOn := this.GetString("ModifiedOn")
  1748. ModifiedUserId := this.GetString("ModifiedUserId")
  1749. ModifiedBy := this.GetString("ModifiedBy")
  1750. if Id != "" {
  1751. where = where + " and a.Id like '%" + Id + "%'"
  1752. }
  1753. if SupplierId != "" {
  1754. where = where + " and a.SupplierId like '%" + SupplierId + "%'"
  1755. }
  1756. if SupplierCertId != "" {
  1757. where = where + " and a.SupplierCertId = '" + SupplierCertId + "'"
  1758. }
  1759. if SupplierTypeCode != "" {
  1760. where = where + " and a.SupplierTypeCode = '" + SupplierTypeCode + "'"
  1761. }
  1762. if Code != "" {
  1763. where = where + " and a.Code like '%" + Code + "%'"
  1764. }
  1765. if Name != "" {
  1766. where = where + " and a.Name like '%" + Name + "%'"
  1767. }
  1768. if Remark != "" {
  1769. where = where + " and a.Remark like '%" + Remark + "%'"
  1770. }
  1771. if IsDelete != "" {
  1772. where = where + " and a.IsDelete like '%" + IsDelete + "%'"
  1773. }
  1774. if CreateUserId != "" {
  1775. where = where + " and a.CreateUserId like '%" + CreateUserId + "%'"
  1776. }
  1777. if CreateBy != "" {
  1778. where = where + " and a.CreateBy like '%" + CreateBy + "%'"
  1779. }
  1780. if ModifiedOn != "" {
  1781. where = where + " and a.ModifiedOn like '%" + ModifiedOn + "%'"
  1782. }
  1783. if ModifiedUserId != "" {
  1784. where = where + " and a.ModifiedUserId like '%" + ModifiedUserId + "%'"
  1785. }
  1786. if ModifiedBy != "" {
  1787. where = where + " and a.ModifiedBy like '%" + ModifiedBy + "%'"
  1788. }
  1789. if CreateOn != "" {
  1790. dates := strings.Split(CreateOn, ",")
  1791. if len(dates) == 2 {
  1792. minDate := dates[0]
  1793. maxDate := dates[1]
  1794. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  1795. }
  1796. }
  1797. where = where + " and a.Type in (1, 3)"
  1798. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1799. var list []suppliercertsub.OilSupplierCertSub1
  1800. var co supplier.OilSupplierContrast
  1801. svc.GetEntityById(SupplierId, &co)
  1802. if co.IsDelete == 1 {
  1803. where += " and a.IsQuestion = 1"
  1804. }
  1805. total := svc.GetPagingTmpSubEntities(page.CurrentPage, page.Size, orderby, asc, &list, where)
  1806. a := 0
  1807. for _, item := range list {
  1808. sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25),IF(ifnull(F26, '') = '', '', F26),IF(ifnull(F27, '') = '', '', F27),IF(ifnull(F28, '') = '', '', F28),IF(ifnull(F29, '') = '', '', F29),IF(ifnull(F30, '') = '', '', F30),IF(ifnull(F31, '') = '', '', F31),IF(ifnull(F32, '') = '', '', F32),IF(ifnull(F33, '') = '', '', F33),IF(ifnull(F34, '') = '', '', F34),IF(ifnull(F35, '') = '', '', F35),IF(ifnull(F36, '') = '', '', F36),IF(ifnull(F37, '') = '', '', F37),IF(ifnull(F38, '') = '', '', F38),IF(ifnull(F39, '') = '', '', F39),IF(ifnull(F40, '') = '', '', F40),IF(ifnull(F41, '') = '', '', F41),IF(ifnull(F42, '') = '', '', F42),IF(ifnull(F43, '') = '', '', F43),IF(ifnull(F44, '') = '', '', F44),IF(ifnull(F45, '') = '', '', F45),IF(ifnull(F46, '') = '', '', F46),IF(ifnull(F47, '') = '', '', F47),IF(ifnull(F48, '') = '', '', F48),IF(ifnull(F49, '') = '', '', F49),IF(ifnull(F50, '') = '', '', F50),IF(ifnull(F51, '') = '', '', F51),IF(ifnull(F52, '') = '', '', F52)) AS Codes FROM Tmp_OilTechnologyService a LEFT JOIN Tmp_OilTechnologyServiceClass class ON a.ClassId = class.Id"
  1809. sql += " where class.Name = '"+ item.Name + "'"
  1810. model, _ := svc.DBE.QueryString(sql)
  1811. if model != nil {
  1812. code := strings.Split(model[0]["Codes"], ",")
  1813. i := 1
  1814. for _, value := range code {
  1815. if i == 41 || i == 42 || i == 1 {
  1816. if (code[0] == "1" && strings.Index(item.HeaderCodes, "F01") < 0) && (code[40] == "1" && strings.Index(item.HeaderCodes, "F41") < 0) && (code[41] == "1" && strings.Index(item.HeaderCodes, "F42") < 0) {
  1817. list[a].Checked = 1
  1818. sql1 := "select Name from Base_TableHeader where Code = 'F01' and CategoryCode = '03'"
  1819. model1, _ := svc.DBE.QueryString(sql1)
  1820. if strings.Index(list[a].HeaderName, model1[0]["Name"]) == -1 {
  1821. list[a].HeaderName += model1[0]["Name"] + " "
  1822. }
  1823. }
  1824. } else if i > 10 {
  1825. if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
  1826. list[a].Checked = 1
  1827. sql1 := "select Name from Base_TableHeader where Code = 'F"+strconv.Itoa(i)+"' and CategoryCode = '03'"
  1828. model1, _ := svc.DBE.QueryString(sql1)
  1829. list[a].HeaderName += model1[0]["Name"]+ " "
  1830. }
  1831. } else {
  1832. if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
  1833. list[a].Checked = 1
  1834. sql1 := "select Name from Base_TableHeader where Code = 'F0"+strconv.Itoa(i)+"' and CategoryCode = '03'"
  1835. model1, _ := svc.DBE.QueryString(sql1)
  1836. list[a].HeaderName += model1[0]["Name"]+ " "
  1837. }
  1838. }
  1839. i += 1
  1840. }
  1841. } else {
  1842. list[a].MinClassId = "0"
  1843. }
  1844. a += 1
  1845. }
  1846. var datainfo DataInfo
  1847. datainfo.Items = list
  1848. datainfo.CurrentItemCount = total
  1849. datainfo.PageIndex = page.CurrentPage
  1850. datainfo.ItemsPerPage = page.Size
  1851. this.Data["json"] = &datainfo
  1852. this.ServeJSON()
  1853. }
  1854. // @Title 确认更新后的删除/暂停企业准入范围 2020-12-18
  1855. // @Description 修改实体
  1856. // @Success 200 {object} controllers.Request
  1857. // @router /delete-suspend [post]
  1858. func (this *OilTechnologyServiceController) DeleteSuspend() {
  1859. var errinfo ErrorInfo
  1860. var err error
  1861. var list []supplier.OilSupplierContrast
  1862. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1863. //svc.GetEntitysByWhere("OilSupplierContrast", "TwoOneCount = 0", &list)
  1864. svc.GetEntitysByWhere("OilSupplierTecContrast", "1=1", &list)
  1865. go func() {
  1866. for _,item := range list{
  1867. var sub []suppliercertsub.OilSupplierCertSub
  1868. svc.GetEntitysByWhere("OilSupplierCertSub", "SupplierTypeCode = '03' and SupplierId = " + strconv.Itoa(item.Id), &sub)
  1869. for _, itemSub := range sub {
  1870. //sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25),IF(ifnull(F26, '') = '', '', F26),IF(ifnull(F27, '') = '', '', F27),IF(ifnull(F28, '') = '', '', F28),IF(ifnull(F29, '') = '', '', F29),IF(ifnull(F30, '') = '', '', F30),IF(ifnull(F31, '') = '', '', F31),IF(ifnull(F32, '') = '', '', F32),IF(ifnull(F33, '') = '', '', F33),IF(ifnull(F34, '') = '', '', F34),IF(ifnull(F35, '') = '', '', F35),IF(ifnull(F36, '') = '', '', F36),IF(ifnull(F37, '') = '', '', F37),IF(ifnull(F38, '') = '', '', F38),IF(ifnull(F39, '') = '', '', F39),IF(ifnull(F40, '') = '', '', F40),IF(ifnull(F41, '') = '', '', F41),IF(ifnull(F42, '') = '', '', F42),IF(ifnull(F43, '') = '', '', F43),IF(ifnull(F44, '') = '', '', F44),IF(ifnull(F45, '') = '', '', F45),IF(ifnull(F46, '') = '', '', F46),IF(ifnull(F47, '') = '', '', F47),IF(ifnull(F48, '') = '', '', F48),IF(ifnull(F49, '') = '', '', F49),IF(ifnull(F50, '') = '', '', F50),IF(ifnull(F51, '') = '', '', F51),IF(ifnull(F52, '') = '', '', F52)) AS Codes,Code FROM Tmp_OilTechnologyService a LEFT JOIN Tmp_OilTechnologyServiceClass class ON a.ClassId = class.Id"
  1871. sql := "SELECT Code FROM Tmp_OilTechnologyService a LEFT JOIN Tmp_OilTechnologyServiceClass class ON a.ClassId = class.Id"
  1872. sql += " where class.Name = '"+ itemSub.Name + "'"
  1873. model, _ := svc.DBE.QueryString(sql)
  1874. var subDelete suppliercertsub.OilSupplierCertSub
  1875. if model != nil {
  1876. //code := strings.Split(model[0]["Codes"], ",")
  1877. cols := []string{"Code"}
  1878. subDelete.Code = model[0]["Code"]
  1879. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id))
  1880. //cols = append(cols, "DueTime")
  1881. //cols = append(cols, "CertSubStatus")
  1882. //subDelete.CertSubStatus = "2"
  1883. //paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1884. //DueTimeStr := paramSvc.GetBaseparameterMessage("GFZT", "paramset", "Suspend")
  1885. //currentTime := time.Now()
  1886. //days,_ := strconv.Atoi(DueTimeStr)
  1887. //subDelete.DueTime = currentTime.AddDate(0, 0, days)
  1888. //i := 1
  1889. ////暂停
  1890. //for _, value := range code {
  1891. // if i == 41 || i == 42 || i == 1 {
  1892. // if (code[0] == "1" && strings.Index(item.HeaderCodes, "F01") < 0) && (code[40] == "1" && strings.Index(item.HeaderCodes, "F41") < 0) && (code[41] == "1" && strings.Index(item.HeaderCodes, "F42") < 0) {
  1893. // err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
  1894. // var model1 supplierpausereason.OilSupplierPauseReason
  1895. // model1.SupplierId = item.Id
  1896. // model1.CertSubId = itemSub.Id
  1897. // model1.CertSubStatus = "2"
  1898. // model1.SupplierCertId = itemSub.SupplierCertId
  1899. // model1.BackReason = "老数据导入缺资质"
  1900. // model1.CreateOn = time.Now()
  1901. // model1.CreateBy = this.User.Realname
  1902. // model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1903. // svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
  1904. // break
  1905. // }
  1906. // } else if i > 10 {
  1907. // if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
  1908. // err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
  1909. // var model1 supplierpausereason.OilSupplierPauseReason
  1910. // model1.SupplierId = item.Id
  1911. // model1.CertSubId = itemSub.Id
  1912. // model1.CertSubStatus = "2"
  1913. // model1.SupplierCertId = itemSub.SupplierCertId
  1914. // model1.BackReason = "老数据导入缺资质"
  1915. // model1.CreateOn = time.Now()
  1916. // model1.CreateBy = this.User.Realname
  1917. // model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1918. // svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
  1919. // break
  1920. // }
  1921. // } else {
  1922. // if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
  1923. // err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
  1924. // var model1 supplierpausereason.OilSupplierPauseReason
  1925. // model1.SupplierId = item.Id
  1926. // model1.CertSubId = itemSub.Id
  1927. // model1.CertSubStatus = "2"
  1928. // model1.SupplierCertId = itemSub.SupplierCertId
  1929. // model1.BackReason = "老数据导入缺资质"
  1930. // model1.CreateOn = time.Now()
  1931. // model1.CreateBy = this.User.Realname
  1932. // model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1933. // svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
  1934. // break
  1935. // }
  1936. // }
  1937. // i += 1
  1938. //}
  1939. } else {
  1940. // 删除
  1941. //err = svc.DeleteEntityById(itemSub.Id, &subDelete)
  1942. }
  1943. }
  1944. //err = svc.DeleteTable("OilSupplierTecContrast", "Id = " + strconv.Itoa(item.Id))
  1945. }
  1946. this.CreateContrast()
  1947. }()
  1948. errinfo.Message = "更新中,请勿重复更新!"
  1949. errinfo.Code = 0
  1950. this.Data["json"] = &errinfo
  1951. this.ServeJSON()
  1952. }