technologyservice.go 78 KB

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