2
3

goodsaptitude.go 100 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  4. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  5. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  6. "dashoo.cn/backend/api/business/oilsupplier/supplierdataentry"
  7. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  8. "dashoo.cn/backend/api/business/oilsupplier/supplierpausereason"
  9. "dashoo.cn/backend/api/business/oilsupplier/tableheader"
  10. "encoding/json"
  11. "fmt"
  12. "github.com/tealeg/xlsx"
  13. "log"
  14. "os"
  15. "reflect"
  16. "strconv"
  17. "strings"
  18. "time"
  19. "dashoo.cn/backend/api/business/oilsupplier/goodsaptitudeclass"
  20. "dashoo.cn/backend/api/business/items"
  21. "dashoo.cn/backend/api/business/baseUser"
  22. "dashoo.cn/backend/api/business/oilsupplier/goodsaptitude"
  23. "dashoo.cn/backend/api/business/workflow"
  24. . "dashoo.cn/backend/api/controllers"
  25. "dashoo.cn/business2/parameter"
  26. "dashoo.cn/business2/userRole"
  27. "dashoo.cn/utils"
  28. . "github.com/linxGnu/goseaweedfs"
  29. )
  30. type OilGoodsAptitudeController struct {
  31. BaseController
  32. }
  33. func structToMapDemo(obj interface{}) map[string]interface{} {
  34. obj1 := reflect.TypeOf(obj)
  35. obj2 := reflect.ValueOf(obj)
  36. var data = make(map[string]interface{})
  37. for i := 0; i < obj1.NumField(); i++ {
  38. data[obj1.Field(i).Name] = obj2.Field(i).Interface()
  39. }
  40. return data
  41. }
  42. // @Title 获取列表
  43. // @Description get user by token
  44. // @Success 200 {object} []goodsaptitude.OilGoodsAptitude
  45. // @router /list [get]
  46. func (this *OilGoodsAptitudeController) GetEntityList() {
  47. //获取分页信息
  48. page := this.GetPageInfoForm()
  49. where := " 1=1 "
  50. orderby := "Code"
  51. asc := true
  52. Order := this.GetString("Order")
  53. Prop := this.GetString("Prop")
  54. if Order != "" && Prop != "" {
  55. orderby = Prop
  56. if Order == "asc" {
  57. asc = true
  58. } else {
  59. asc = false
  60. }
  61. }
  62. Edition := this.GetString("Edition")
  63. CreateOn := this.GetString("CreateOn")
  64. Code := this.GetString("Code")
  65. Name := this.GetString("Name")
  66. BigClassName := this.GetString("BigClassName")
  67. BigClassCode := this.GetString("BigClassCode")
  68. MiddleClassName := this.GetString("MiddleClassName")
  69. SmallClassName := this.GetString("SmallClassName")
  70. GoodsName := this.GetString("GoodsName")
  71. GoodsLevel := this.GetString("GoodsLevel")
  72. GoodsDesc := this.GetString("GoodsDesc")
  73. Standard := this.GetString("Standard")
  74. CompanyType := this.GetString("CompanyType")
  75. if Edition != "" {
  76. where = where + " and Edition = '" + Edition + "'"
  77. }
  78. if Code != "" {
  79. where = where + " and Code like '%" + Code + "%'"
  80. }
  81. if Name != "" {
  82. where = where + " and Name like '%" + Name + "%'"
  83. }
  84. if BigClassName != "" {
  85. where = where + " and Name1 like '%" + BigClassName + "%'"
  86. }
  87. if BigClassCode != "" {
  88. where = where + " and Code1 like '%" + BigClassCode + "%'"
  89. }
  90. if MiddleClassName != "" {
  91. where = where + " and Name2 like '%" + MiddleClassName + "%'"
  92. }
  93. if SmallClassName != "" {
  94. where = where + " and Name3 like '%" + SmallClassName + "%'"
  95. }
  96. if GoodsName != "" {
  97. where = where + " and Name4 like '%" + GoodsName + "%'"
  98. }
  99. if GoodsLevel != "" {
  100. where = where + " and GoodsLevel like '%" + GoodsLevel + "%'"
  101. }
  102. if GoodsDesc != "" {
  103. where = where + " and GoodsDesc like '%" + GoodsDesc + "%'"
  104. }
  105. if Standard != "" {
  106. where = where + " and Standard '%" + Standard + "%'"
  107. }
  108. if CompanyType != "" {
  109. where = where + " and CompanyType '%" + CompanyType + "%'"
  110. }
  111. if CreateOn != "" {
  112. dates := strings.Split(CreateOn, ",")
  113. if len(dates) == 2 {
  114. minDate := dates[0]
  115. maxDate := dates[1]
  116. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  117. }
  118. }
  119. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  120. var list []goodsaptitude.OilGoodsAptitudeView
  121. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilGoodsAptDetailViewName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  122. var datainfo DataInfo
  123. datainfo.Items = list
  124. datainfo.CurrentItemCount = total
  125. datainfo.PageIndex = page.CurrentPage
  126. datainfo.ItemsPerPage = page.Size
  127. this.Data["json"] = &datainfo
  128. this.ServeJSON()
  129. }
  130. // @Title 获取列表新导入的列表
  131. // @Description get user by token
  132. // @Success 200 {object} []goodsaptitude.OilGoodsAptitude
  133. // @router /importlist [get]
  134. func (this *OilGoodsAptitudeController) GetImportEntityList() {
  135. //获取分页信息
  136. page := this.GetPageInfoForm()
  137. where := " 1=1 "
  138. orderby := "Code"
  139. asc := true
  140. Order := this.GetString("Order")
  141. Prop := this.GetString("Prop")
  142. if Order != "" && Prop != "" {
  143. orderby = Prop
  144. if Order == "asc" {
  145. asc = true
  146. } else {
  147. asc = false
  148. }
  149. }
  150. Edition := this.GetString("Edition")
  151. CreateOn := this.GetString("CreateOn")
  152. Code := this.GetString("Code")
  153. Name := this.GetString("Name")
  154. BigClassName := this.GetString("BigClassName")
  155. BigClassCode := this.GetString("BigClassCode")
  156. MiddleClassName := this.GetString("MiddleClassName")
  157. SmallClassName := this.GetString("SmallClassName")
  158. GoodsName := this.GetString("GoodsName")
  159. GoodsLevel := this.GetString("GoodsLevel")
  160. GoodsDesc := this.GetString("GoodsDesc")
  161. Standard := this.GetString("Standard")
  162. CompanyType := this.GetString("CompanyType")
  163. if Edition != "" {
  164. where = where + " and Edition = '" + Edition + "'"
  165. }
  166. if Code != "" {
  167. where = where + " and Code like '%" + Code + "%'"
  168. }
  169. if Name != "" {
  170. where = where + " and Name like '%" + Name + "%'"
  171. }
  172. if BigClassName != "" {
  173. where = where + " and Name1 like '%" + BigClassName + "%'"
  174. }
  175. if BigClassCode != "" {
  176. where = where + " and Code1 like '%" + BigClassCode + "%'"
  177. }
  178. if MiddleClassName != "" {
  179. where = where + " and Name2 like '%" + MiddleClassName + "%'"
  180. }
  181. if SmallClassName != "" {
  182. where = where + " and Name3 like '%" + SmallClassName + "%'"
  183. }
  184. if GoodsName != "" {
  185. where = where + " and Name4 like '%" + GoodsName + "%'"
  186. }
  187. if GoodsLevel != "" {
  188. where = where + " and GoodsLevel like '%" + GoodsLevel + "%'"
  189. }
  190. if GoodsDesc != "" {
  191. where = where + " and GoodsDesc like '%" + GoodsDesc + "%'"
  192. }
  193. if Standard != "" {
  194. where = where + " and Standard '%" + Standard + "%'"
  195. }
  196. if CompanyType != "" {
  197. where = where + " and CompanyType '%" + CompanyType + "%'"
  198. }
  199. if CreateOn != "" {
  200. dates := strings.Split(CreateOn, ",")
  201. if len(dates) == 2 {
  202. minDate := dates[0]
  203. maxDate := dates[1]
  204. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  205. }
  206. }
  207. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  208. var list []goodsaptitude.OilGoodsAptitudeView
  209. total := svc.GetMyPagingEntitiesWithOrderBytbl(ImportOilGoodsAptDetailViewName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  210. var datainfo DataInfo
  211. datainfo.Items = list
  212. datainfo.CurrentItemCount = total
  213. datainfo.PageIndex = page.CurrentPage
  214. datainfo.ItemsPerPage = page.Size
  215. this.Data["json"] = &datainfo
  216. this.ServeJSON()
  217. }
  218. // @Title 获取列表
  219. // @Description get user by token
  220. // @Success 200 {object} []goodsaptitude.OilGoodsAptitude
  221. // @router /comparelist [get]
  222. func (this *OilGoodsAptitudeController) GetCompareList() {
  223. //获取分页信息
  224. page := this.GetPageInfoForm()
  225. where := " 1=1 "
  226. orderby := "Code"
  227. asc := true
  228. Order := this.GetString("Order")
  229. Prop := this.GetString("Prop")
  230. Conditions := this.GetString("Conditions")
  231. if Conditions == "1" {
  232. // 匹配上
  233. where += " and a.GoodsLevel = tmpa.GoodsLevel"
  234. } else if Conditions == "2" {
  235. // 1变2
  236. where += " and a.GoodsLevel < tmpa.GoodsLevel"
  237. } else if Conditions == "3" {
  238. // 2变1
  239. where += " and a.GoodsLevel > tmpa.GoodsLevel"
  240. } else if Conditions == "4" {
  241. // 旧表有新表没
  242. where += " and tmpb.Code is null"
  243. } else if Conditions == "5" {
  244. // 新表有,旧表没
  245. where += " and tmpb.Code is null"
  246. } else if Conditions == "6" {
  247. // code+资质+级别匹配
  248. where += " and a.GoodsLevel = tmpa.GoodsLevel 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))" +
  249. " 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))" +
  250. " 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))" +
  251. " 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))" +
  252. " 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))"
  253. }
  254. if Order != "" && Prop != "" {
  255. orderby = Prop
  256. if Order == "asc" {
  257. asc = true
  258. } else {
  259. asc = false
  260. }
  261. }
  262. Edition := this.GetString("Edition")
  263. CreateOn := this.GetString("CreateOn")
  264. Code := this.GetString("Code")
  265. Name := this.GetString("Name")
  266. BigClassName := this.GetString("BigClassName")
  267. BigClassCode := this.GetString("BigClassCode")
  268. MiddleClassName := this.GetString("MiddleClassName")
  269. SmallClassName := this.GetString("SmallClassName")
  270. GoodsName := this.GetString("GoodsName")
  271. GoodsLevel := this.GetString("GoodsLevel")
  272. GoodsDesc := this.GetString("GoodsDesc")
  273. Standard := this.GetString("Standard")
  274. CompanyType := this.GetString("CompanyType")
  275. if Edition != "" {
  276. where = where + " and b.Edition = '" + Edition + "'"
  277. }
  278. if Code != "" {
  279. where = where + " and b.Code like '%" + Code + "%'"
  280. }
  281. if Name != "" {
  282. where = where + " and b.Name like '%" + Name + "%'"
  283. }
  284. if BigClassName != "" {
  285. where = where + " and Name1 like '%" + BigClassName + "%'"
  286. }
  287. if BigClassCode != "" {
  288. where = where + " and Code1 like '%" + BigClassCode + "%'"
  289. }
  290. if MiddleClassName != "" {
  291. where = where + " and Name2 like '%" + MiddleClassName + "%'"
  292. }
  293. if SmallClassName != "" {
  294. where = where + " and Name3 like '%" + SmallClassName + "%'"
  295. }
  296. if GoodsName != "" {
  297. where = where + " and Name4 like '%" + GoodsName + "%'"
  298. }
  299. if GoodsLevel != "" {
  300. where = where + " and GoodsLevel like '%" + GoodsLevel + "%'"
  301. }
  302. if GoodsDesc != "" {
  303. where = where + " and GoodsDesc like '%" + GoodsDesc + "%'"
  304. }
  305. if Standard != "" {
  306. where = where + " and Standard '%" + Standard + "%'"
  307. }
  308. if CompanyType != "" {
  309. where = where + " and CompanyType '%" + CompanyType + "%'"
  310. }
  311. if CreateOn != "" {
  312. dates := strings.Split(CreateOn, ",")
  313. if len(dates) == 2 {
  314. minDate := dates[0]
  315. maxDate := dates[1]
  316. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  317. }
  318. }
  319. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  320. var list []goodsaptitude.OilGoodsAptitudeTmp
  321. total := svc.GetPClassEntities(page.CurrentPage, page.Size, orderby, asc, &list, where, Conditions)
  322. var datainfo DataInfo
  323. datainfo.Items = list
  324. datainfo.CurrentItemCount = total
  325. datainfo.PageIndex = page.CurrentPage
  326. datainfo.ItemsPerPage = page.Size
  327. this.Data["json"] = &datainfo
  328. this.ServeJSON()
  329. }
  330. // @Title 获取列表2019版本
  331. // @Description
  332. // @Success 200 {object}
  333. // @router /list_2019 [get]
  334. func (this *OilGoodsAptitudeController) GetEntityList_2019() {
  335. //获取分页信息
  336. page := this.GetPageInfoForm()
  337. where := " 1=1 "
  338. orderby := "Code"
  339. asc := true
  340. Order := this.GetString("Order")
  341. Prop := this.GetString("Prop")
  342. if Order != "" && Prop != "" {
  343. orderby = Prop
  344. if Order == "asc" {
  345. asc = true
  346. } else {
  347. asc = false
  348. }
  349. }
  350. Edition := this.GetString("Edition")
  351. Code := this.GetString("Code")
  352. Name := this.GetString("Name")
  353. if Edition != "" {
  354. where = where + " and a.Edition = '" + Edition + "'"
  355. }
  356. if Code != "" {
  357. where = where + " and b.Code like '%" + Code + "%'"
  358. }
  359. if Name != "" {
  360. where = where + " and b.Name like '%" + Name + "%'"
  361. }
  362. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  363. var list []goodsaptitude.OilGoodsAptitude_2
  364. total := svc.GetList_2019(OilGoodsAptitudeName, OilGoodsAptitudeClassName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  365. var datainfo DataInfo
  366. datainfo.Items = list
  367. datainfo.CurrentItemCount = total
  368. datainfo.PageIndex = page.CurrentPage
  369. datainfo.ItemsPerPage = page.Size
  370. this.Data["json"] = &datainfo
  371. this.ServeJSON()
  372. }
  373. // @Title 获取字典列表
  374. // @Description get user by token
  375. // @Success 200 {object} map[string]interface{}
  376. // @router /dictlist [get]
  377. func (this *OilGoodsAptitudeController) GetDictList() {
  378. dictList := make(map[string]interface{})
  379. dictSvc := items.GetItemsService(utils.DBE)
  380. userSvc := baseUser.GetBaseUserService(utils.DBE)
  381. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  382. //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", "")
  383. var userEntity userRole.Base_User
  384. userSvc.GetEntityById(this.User.Id, &userEntity)
  385. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId("", userEntity.Departmentid)
  386. dictList["AuditStep"] = dictSvc.GetKeyValueItems("AuditStep", this.User.AccCode)
  387. //var dictCustomer []svccustomer.Customer
  388. //customerSvc.GetEntitysByWhere("" + CustomerName, "", &dictCustomer)
  389. //dictList["EntrustCorp"] = &dictCustomer
  390. var datainfo DataInfo
  391. datainfo.Items = dictList
  392. this.Data["json"] = &datainfo
  393. this.ServeJSON()
  394. }
  395. // @Title 获取实体
  396. // @Description 获取实体
  397. // @Success 200 {object} goodsaptitude.OilGoodsAptitude
  398. // @router /get/:id [get]
  399. func (this *OilGoodsAptitudeController) GetEntity() {
  400. Id := this.Ctx.Input.Param(":id")
  401. var model goodsaptitude.OilGoodsAptitudeView
  402. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  403. //svc.GetEntityByIdBytbl(""+OilGoodsAptitudeName, Id, &model)
  404. where := " Id =" + Id
  405. svc.GetEntityByWhere(OilGoodsAptDetailViewName, where, &model)
  406. this.Data["json"] = &model
  407. this.ServeJSON()
  408. }
  409. // @Title 获取实体
  410. // @Description 获取实体
  411. // @Success 200 {object}
  412. // @router /get_2019/:id [get]
  413. func (this *OilGoodsAptitudeController) GetEntity_2019() {
  414. Id := this.Ctx.Input.Param(":id")
  415. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  416. var tempMap []map[string]string
  417. sql := `select a.Id,a.ClassId,a.F01,a.F02,a.F03,a.F04,a.F05,a.F06,a.F07,a.F08,a.F09,a.F10,
  418. a.F11,a.F12,a.F13,a.F14,a.F15,a.F16,a.F17,a.F18,a.F19,a.F20,
  419. a.F21,a.F22,a.F23,a.F24,a.F25,a.F26,a.F27,a.F28,a.F29,a.F30,
  420. a.F31,a.F32,a.F33,a.F34,a.F35,a.F36,a.F37,a.F38,a.F39,a.F40,
  421. a.F41,a.F42,a.F43,a.F44,a.F45,a.F46,b.Code, b.Name `
  422. sql += ` from ` + OilGoodsAptitudeName + ` a `
  423. sql += ` left join ` + OilGoodsAptitudeClassName + " b on b.Id = a.ClassId"
  424. sql += ` where a.Id='` + Id + `'`
  425. tempMap, _ = svc.DBE.QueryString(sql)
  426. this.Data["json"] = &tempMap
  427. this.ServeJSON()
  428. }
  429. // @Title 添加
  430. // @Description 新增
  431. // @Success 200 {object} controllers.Request
  432. // @router /add [post]
  433. func (this *OilGoodsAptitudeController) AddEntity() {
  434. //ParentId := this.Ctx.Input.Param(":id")
  435. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  436. var model goodsaptitudeclass.OilGoodsAptitudeClass
  437. var classmodel goodsaptitudeclass.OilGoodsAptitudeClass
  438. var parentedId goodsaptitudeclass.ParentedId
  439. var jsonBlob = this.Ctx.Input.RequestBody
  440. json.Unmarshal(jsonBlob, &parentedId)
  441. json.Unmarshal(jsonBlob, &model)
  442. var errinfo ErrorDataInfo
  443. where := " Code = " + model.Code
  444. code := svc.GetEntityByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  445. if code {
  446. errinfo.Message = "编码不能重复!"
  447. errinfo.Code = -1
  448. this.Data["json"] = &errinfo
  449. this.ServeJSON()
  450. return
  451. }
  452. //where1 := " Name = " + model.Name
  453. //name := svc.GetEntityByWhere(OilGoodsAptitudeClassName, where1, &classmodel)
  454. //if name {
  455. // errinfo.Message = "名称不能重复!"
  456. // errinfo.Code = -1
  457. // this.Data["json"] = &errinfo
  458. // this.ServeJSON()
  459. // return
  460. //}
  461. model.ParentId = parentedId.ParentId
  462. model.Edition = "1"
  463. model.CreateOn = time.Now()
  464. model.CreateBy = this.User.Realname
  465. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  466. _, err := svc.InsertEntityBytbl(""+OilGoodsAptitudeClassName, &model)
  467. var model2 goodsaptitude.OilGoodsAptitude
  468. json.Unmarshal(jsonBlob, &model2)
  469. model2.ClassId = model.Id
  470. model2.Edition = "1"
  471. model2.CreateOn = time.Now()
  472. model2.CreateBy = this.User.Realname
  473. model2.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  474. _, err = svc.InsertEntityBytbl(""+OilGoodsAptitudeName, &model2)
  475. if err == nil {
  476. //新增
  477. errinfo.Message = "添加成功!"
  478. errinfo.Code = 0
  479. errinfo.Item = model2.Id
  480. this.Data["json"] = &errinfo
  481. this.ServeJSON()
  482. } else {
  483. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  484. errinfo.Code = -1
  485. this.Data["json"] = &errinfo
  486. this.ServeJSON()
  487. }
  488. }
  489. // @Title 添加
  490. // @Description 新增
  491. // @Success 200 {object} controllers.Request
  492. // @router /add_2019 [post]
  493. func (this *OilGoodsAptitudeController) AddEntity_2019() {
  494. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  495. var model goodsaptitudeclass.OilGoodsAptitudeClass
  496. var jsonBlob = this.Ctx.Input.RequestBody
  497. var errinfo ErrorDataInfo
  498. json.Unmarshal(jsonBlob, &model)
  499. model.ParentId = -1
  500. model.Edition = "2"
  501. model.CreateOn = time.Now()
  502. model.CreateBy = this.User.Realname
  503. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  504. _, err := svc.InsertEntityBytbl(""+OilGoodsAptitudeClassName, &model)
  505. var model2 goodsaptitude.OilGoodsAptitude
  506. json.Unmarshal(jsonBlob, &model2)
  507. model2.ClassId = model.Id
  508. model2.Edition = "2"
  509. model2.CreateOn = time.Now()
  510. model2.CreateBy = this.User.Realname
  511. model2.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  512. _, err = svc.InsertEntityBytbl(""+OilGoodsAptitudeName, &model2)
  513. if err == nil {
  514. //新增
  515. errinfo.Message = "添加成功!"
  516. errinfo.Code = 0
  517. errinfo.Item = model2.Id
  518. this.Data["json"] = &errinfo
  519. this.ServeJSON()
  520. } else {
  521. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  522. errinfo.Code = -1
  523. this.Data["json"] = &errinfo
  524. this.ServeJSON()
  525. }
  526. }
  527. // @Title 修改实体
  528. // @Description 修改实体
  529. // @Success 200 {object} controllers.Request
  530. // @router /update/:id [post]
  531. func (this *OilGoodsAptitudeController) UpdateEntity() {
  532. id := this.Ctx.Input.Param(":id")
  533. var errinfo ErrorInfo
  534. if id == "" {
  535. errinfo.Message = "操作失败!请求信息不完整"
  536. errinfo.Code = -2
  537. this.Data["json"] = &errinfo
  538. this.ServeJSON()
  539. return
  540. }
  541. var model goodsaptitude.OilGoodsAptitude
  542. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  543. var jsonBlob = this.Ctx.Input.RequestBody
  544. json.Unmarshal(jsonBlob, &model)
  545. model.ModifiedOn = time.Now()
  546. model.ModifiedBy = this.User.Realname
  547. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  548. cols := []string{
  549. "Id",
  550. "Code",
  551. "Name",
  552. "BigClassName",
  553. "MiddleClassName",
  554. "SmallClassName",
  555. "GoodsName",
  556. "GoodsLevel",
  557. "GoodsDesc",
  558. "Standard",
  559. "CompanyType",
  560. "F01",
  561. "F02",
  562. "F03",
  563. "F04",
  564. "F05",
  565. "F06",
  566. "F07",
  567. "F08",
  568. "F09",
  569. "F10",
  570. "F11",
  571. "F12",
  572. "F13",
  573. "F14",
  574. "F15",
  575. "F16",
  576. "F17",
  577. "F18",
  578. "F19",
  579. "F20",
  580. "F21",
  581. "F22",
  582. "F23",
  583. "F24",
  584. "F25",
  585. "F26",
  586. "F27",
  587. "F28",
  588. "F29",
  589. "F30",
  590. "F31",
  591. "F32",
  592. "F33",
  593. "F34",
  594. "F35",
  595. "F36",
  596. "F37",
  597. "F38",
  598. "F39",
  599. "F40",
  600. "F41",
  601. "F42",
  602. "F43",
  603. "F44",
  604. "F45",
  605. "F46",
  606. "Remark",
  607. "DeletionStateCode",
  608. "CreateOn",
  609. "CreateUserId",
  610. "CreateBy",
  611. "ModifiedOn",
  612. "ModifiedUserId",
  613. "ModifiedBy",
  614. }
  615. err := svc.UpdateEntityBytbl(""+OilGoodsAptitudeName, id, &model, cols)
  616. if err == nil {
  617. errinfo.Message = "修改成功!"
  618. errinfo.Code = 0
  619. this.Data["json"] = &errinfo
  620. this.ServeJSON()
  621. } else {
  622. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  623. errinfo.Code = -1
  624. this.Data["json"] = &errinfo
  625. this.ServeJSON()
  626. }
  627. }
  628. // @Title 修改实体
  629. // @Description 修改实体
  630. // @Success 200 {object} controllers.Request
  631. // @router /update_2019/:id [post]
  632. func (this *OilGoodsAptitudeController) UpdateEntity_2019() {
  633. id := this.Ctx.Input.Param(":id")
  634. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  635. var errinfo ErrorInfo
  636. if id == "" {
  637. errinfo.Message = "操作失败!请求信息不完整"
  638. errinfo.Code = -2
  639. this.Data["json"] = &errinfo
  640. this.ServeJSON()
  641. return
  642. }
  643. var model goodsaptitude.OilGoodsAptitude
  644. var jsonBlob = this.Ctx.Input.RequestBody
  645. json.Unmarshal(jsonBlob, &model)
  646. model.ModifiedOn = time.Now()
  647. model.ModifiedBy = this.User.Realname
  648. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  649. cols := []string{
  650. "F01",
  651. "F02",
  652. "F03",
  653. "F04",
  654. "F05",
  655. "F06",
  656. "F07",
  657. "F08",
  658. "F09",
  659. "F10",
  660. "F11",
  661. "F12",
  662. "F13",
  663. "F14",
  664. "F15",
  665. "F16",
  666. "F17",
  667. "F18",
  668. "F19",
  669. "F20",
  670. "F21",
  671. "F22",
  672. "F23",
  673. "F24",
  674. "F25",
  675. "F26",
  676. "F27",
  677. "F28",
  678. "F29",
  679. "F30",
  680. "F31",
  681. "F32",
  682. "F33",
  683. "F34",
  684. "F35",
  685. "F36",
  686. "F37",
  687. "F38",
  688. "F39",
  689. "F40",
  690. "F41",
  691. "F42",
  692. "F43",
  693. "F44",
  694. "F45",
  695. "F46",
  696. "ModifiedOn",
  697. "ModifiedUserId",
  698. "ModifiedBy",
  699. }
  700. err := svc.UpdateEntityBytbl(""+OilGoodsAptitudeName, id, &model, cols)
  701. var model2 goodsaptitudeclass.OilGoodsAptitudeClass
  702. json.Unmarshal(jsonBlob, &model2)
  703. model2.ModifiedOn = time.Now()
  704. model2.ModifiedBy = this.User.Realname
  705. model2.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  706. cols2 := []string{
  707. "Code",
  708. "Name",
  709. "ModifiedOn",
  710. "ModifiedUserId",
  711. "ModifiedBy",
  712. }
  713. err = svc.UpdateEntityBytbl(""+OilGoodsAptitudeClassName, model.ClassId, &model2, cols2)
  714. if err == nil {
  715. errinfo.Message = "修改成功!"
  716. errinfo.Code = 0
  717. this.Data["json"] = &errinfo
  718. this.ServeJSON()
  719. } else {
  720. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  721. errinfo.Code = -1
  722. this.Data["json"] = &errinfo
  723. this.ServeJSON()
  724. }
  725. }
  726. // @Title 修改实体
  727. // @Description 修改实体
  728. // @Success 200 {object} controllers.Request
  729. // @router /updatecode/:id [post]
  730. func (this *OilGoodsAptitudeController) UpdateCodeEntity() {
  731. var errinfo ErrorInfo
  732. var err error
  733. id := this.Ctx.Input.Param(":id")
  734. if id == "" {
  735. errinfo.Message = "操作失败!请求信息不完整"
  736. errinfo.Code = -2
  737. this.Data["json"] = &errinfo
  738. this.ServeJSON()
  739. return
  740. }
  741. var classall goodsaptitude.OilGoodsAptitudeClassView
  742. var model goodsaptitudeclass.OilGoodsAptitudeClass
  743. var classmodel []goodsaptitudeclass.OilGoodsAptitudeClass
  744. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  745. var jsonBlob = this.Ctx.Input.RequestBody
  746. json.Unmarshal(jsonBlob, &classall)
  747. model.ModifiedOn = time.Now()
  748. model.ModifiedBy = this.User.Realname
  749. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  750. colsName := []string{"Name"}
  751. colsCode := []string{"Code"}
  752. //svc.GetEntityById(id, &model)
  753. if classall.Name1 != "" {
  754. where := " Name = '" + classall.Name1 + "' and Id <> " + utils.ToStr(classall.Id1)
  755. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  756. if len(classmodel) > 0 {
  757. errinfo.Message = "大类名称已存在,请重新添加!"
  758. errinfo.Code = -1
  759. this.Data["json"] = &errinfo
  760. this.ServeJSON()
  761. return
  762. } else {
  763. model.Name = classall.Name1
  764. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id1, &model, colsName)
  765. }
  766. }
  767. if classall.Name2 != "" {
  768. where := " Name = '" + classall.Name2 + "' and Id <> " + utils.ToStr(classall.Id2)
  769. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  770. if len(classmodel) > 0 {
  771. errinfo.Message = "中类名称已存在,请重新添加!"
  772. errinfo.Code = -1
  773. this.Data["json"] = &errinfo
  774. this.ServeJSON()
  775. return
  776. } else {
  777. model.Name = classall.Name2
  778. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id2, &model, colsName)
  779. }
  780. }
  781. if classall.Name3 != "" {
  782. where := " Name = '" + classall.Name3 + "' and Id <> " + utils.ToStr(classall.Id3)
  783. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  784. if len(classmodel) > 0 {
  785. errinfo.Message = "小类名称已存在,请重新添加!"
  786. errinfo.Code = -1
  787. this.Data["json"] = &errinfo
  788. this.ServeJSON()
  789. return
  790. } else {
  791. model.Name = classall.Name3
  792. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id3, &model, colsName)
  793. }
  794. }
  795. if classall.Name4 != "" {
  796. where := " Name = '" + classall.Name4 + "' and Id <> " + utils.ToStr(classall.Id4)
  797. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  798. if len(classmodel) > 0 {
  799. errinfo.Message = "品名已存在,请重新添加!"
  800. errinfo.Code = -1
  801. this.Data["json"] = &errinfo
  802. this.ServeJSON()
  803. return
  804. } else {
  805. model.Name = classall.Name4
  806. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id4, &model, colsName)
  807. }
  808. }
  809. if classall.Code1 != "" {
  810. where := " Code = " + classall.Code1 + " and Id <> " + utils.ToStr(classall.Id1)
  811. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  812. if len(classmodel) > 0 {
  813. errinfo.Message = "大类编码已存在,请重新添加!"
  814. errinfo.Code = -1
  815. this.Data["json"] = &errinfo
  816. this.ServeJSON()
  817. return
  818. } else {
  819. model.Code = classall.Code1
  820. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id1, &model, colsCode)
  821. }
  822. }
  823. if classall.Code2 != "" {
  824. where := " Code = " + classall.Code2 + " and Id <> " + utils.ToStr(classall.Id2)
  825. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  826. if len(classmodel) > 0 {
  827. errinfo.Message = "中类编码已存在,请重新添加!"
  828. errinfo.Code = -1
  829. this.Data["json"] = &errinfo
  830. this.ServeJSON()
  831. return
  832. } else {
  833. model.Code = classall.Code2
  834. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id2, &model, colsCode)
  835. }
  836. }
  837. if classall.Code3 != "" {
  838. where := " Code = " + classall.Code3 + " and Id <> " + utils.ToStr(classall.Id3)
  839. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  840. if len(classmodel) > 0 {
  841. errinfo.Message = "小类编码已存在,请重新添加!"
  842. errinfo.Code = -1
  843. this.Data["json"] = &errinfo
  844. this.ServeJSON()
  845. return
  846. } else {
  847. model.Code = classall.Code3
  848. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id3, &model, colsCode)
  849. }
  850. }
  851. if classall.Code4 != "" {
  852. where := " Code = " + classall.Code4 + " and Id <> " + utils.ToStr(classall.Id4)
  853. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  854. if len(classmodel) > 0 {
  855. errinfo.Message = "品名编码已存在,请重新添加!"
  856. errinfo.Code = -1
  857. this.Data["json"] = &errinfo
  858. this.ServeJSON()
  859. return
  860. } else {
  861. model.Code = classall.Code4
  862. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id4, &model, colsCode)
  863. }
  864. }
  865. if err == nil {
  866. errinfo.Message = "修改成功!"
  867. errinfo.Code = 0
  868. this.Data["json"] = &errinfo
  869. this.ServeJSON()
  870. } else {
  871. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  872. errinfo.Code = -1
  873. this.Data["json"] = &errinfo
  874. this.ServeJSON()
  875. }
  876. }
  877. // @Title 删除单条信息
  878. // @Description
  879. // @Success 200 {object} ErrorInfo
  880. // @Failure 403 :id 为空
  881. // @router /delete/:Id [delete]
  882. func (this *OilGoodsAptitudeController) DeleteEntity() {
  883. Id := this.Ctx.Input.Param(":Id")
  884. var errinfo ErrorInfo
  885. if Id == "" {
  886. errinfo.Message = "操作失败!请求信息不完整"
  887. errinfo.Code = -2
  888. this.Data["json"] = &errinfo
  889. this.ServeJSON()
  890. return
  891. }
  892. var model goodsaptitude.OilGoodsAptitude
  893. var entityempty goodsaptitude.OilGoodsAptitude
  894. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  895. svc.GetEntityById(Id, &model)
  896. opdesc := "删除-" + Id
  897. err := svc.DeleteOperationAndWriteLogBytbl(""+OilGoodsAptitudeName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "物资类准入范围子表删除")
  898. var model1 goodsaptitudeclass.OilGoodsAptitudeClass
  899. var entityempty1 goodsaptitudeclass.OilGoodsAptitudeClass
  900. svc1 := goodsaptitudeclass.GetOilGoodsAptitudeClassService(utils.DBE)
  901. opdesc1 := "删除-" + strconv.Itoa(model.ClassId)
  902. err1 := svc1.DeleteOperationAndWriteLogBytbl(""+OilGoodsAptitudeClassName, BaseOperationLogName, strconv.Itoa(model.ClassId), &model1, &entityempty1, utils.ToStr(this.User.Id), this.User.Username, opdesc1, "", "物资类准入范围删除")
  903. if err == nil && err1 == nil {
  904. errinfo.Message = "删除成功"
  905. errinfo.Code = 0
  906. this.Data["json"] = &errinfo
  907. this.ServeJSON()
  908. } else {
  909. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  910. errinfo.Code = -1
  911. this.Data["json"] = &errinfo
  912. this.ServeJSON()
  913. }
  914. }
  915. // @Title 删除企业的准入范围
  916. // @Description
  917. // @Success 200 {object} ErrorInfo
  918. // @Failure 403 :id 为空
  919. // @router /deletelist/:Id [delete]
  920. func (this *OilGoodsAptitudeController) DeleteList() {
  921. Ids := this.Ctx.Input.Param(":Id")
  922. //Ids := this.GetString("deleteString")
  923. var errinfo ErrorInfo
  924. if Ids == "" {
  925. errinfo.Message = "操作失败!请求信息不完整"
  926. errinfo.Code = -2
  927. this.Data["json"] = &errinfo
  928. this.ServeJSON()
  929. return
  930. }
  931. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  932. idArr := strings.Split(Ids, ",")
  933. for _, id := range idArr {
  934. err := svc.DeleteEntityBytbl("OilSupplierCertSub", " SubClassId = " + id)
  935. if err == nil {
  936. errinfo.Message = "删除成功"
  937. errinfo.Code = 0
  938. this.Data["json"] = &errinfo
  939. this.ServeJSON()
  940. } else {
  941. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  942. errinfo.Code = -1
  943. this.Data["json"] = &errinfo
  944. this.ServeJSON()
  945. }
  946. }
  947. }
  948. // @Title 暂停企业的准入范围
  949. // @Description
  950. // @Success 200 {object} ErrorInfo
  951. // @Failure 403 :id 为空
  952. // @router /changelist/:Id [get]
  953. func (this *OilGoodsAptitudeController) Changelist() {
  954. Ids := this.Ctx.Input.Param(":Id")
  955. //Ids := this.GetString("deleteString")
  956. var errinfo ErrorInfo
  957. if Ids == "" {
  958. errinfo.Message = "操作失败!请求信息不完整"
  959. errinfo.Code = -2
  960. this.Data["json"] = &errinfo
  961. this.ServeJSON()
  962. return
  963. }
  964. var model suppliercertsub.OilSupplierCertSub
  965. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  966. idArr := strings.Split(Ids, ",")
  967. cols := []string{"CertSubStatus"}
  968. model.CertSubStatus = "2"
  969. for _, id := range idArr {
  970. err := svc.UpdateEntityBywheretbl("OilSupplierCertSub", &model, cols, " SubClassId = " + id)
  971. if err == nil {
  972. errinfo.Message = "变更成功"
  973. errinfo.Code = 0
  974. this.Data["json"] = &errinfo
  975. this.ServeJSON()
  976. } else {
  977. errinfo.Message = "变更失败!" + utils.AlertProcess(err.Error())
  978. errinfo.Code = -1
  979. this.Data["json"] = &errinfo
  980. this.ServeJSON()
  981. }
  982. }
  983. }
  984. // @Title get 查询
  985. // @Description get SampleType by token
  986. // @Success 200 {object} sampletype.SampleType
  987. // @router /goodsparentlist/:name [get]
  988. func (this *OilGoodsAptitudeController) GoodsParentList() {
  989. Name := this.Ctx.Input.Param(":name")
  990. if Name != "" {
  991. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  992. where1 := "1=1"
  993. where1 += " AND Name LIKE '%" + Name + "%' OR Code LIKE '" + Name + "%' "
  994. sqlStr := "SELECT Id, Code, Name, concat(Code, ' ', Name) as CodeName, ParentId FROM OilGoodsAptitudeClass " +
  995. "WHERE " + where1 + " AND Edition='1' AND DeletionStateCode = 0 ORDER BY Code"
  996. list, _ := svc.DBE.QueryString(sqlStr)
  997. /*
  998. sql := "SELECT Id, Code, Name, concat(Code, ' ', Name) as CodeName, ParentId FROM OilGoodsAptitudeClass " +
  999. "WHERE DeletionStateCode = 0 AND " + where1 + " OR Id = (" + sqlStr + ")" +" ORDER BY Code"
  1000. list, _ := svc.DBE.QueryString(sql)*/
  1001. var datainfo DataInfo
  1002. datainfo.Items = list
  1003. this.Data["json"] = &datainfo
  1004. this.ServeJSON()
  1005. }
  1006. }
  1007. // @Title get 获取子类
  1008. // @Description get SampleType by token
  1009. // @Success 200 {object} sampletype.SampleType
  1010. // @router /goodschildlist/:id [get]
  1011. func (this *OilGoodsAptitudeController) GoodsChildList() {
  1012. ParentId := this.Ctx.Input.Param(":id")
  1013. sqlStr := "SELECT Id, `Code`, `Name`, concat(Code, ' ', Name) as CodeName, ParentId FROM OilGoodsAptitudeClass WHERE FIND_IN_SET(ParentId, fun_getOilGoodsAptitudeClasschildlist(" + ParentId + ")) AND DeletionStateCode = 0 order by Code"
  1014. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1015. list, _ := svc.DBE.QueryString(sqlStr)
  1016. var datainfo DataInfo
  1017. datainfo.Items = list
  1018. this.Data["json"] = &datainfo
  1019. this.ServeJSON()
  1020. }
  1021. // @Title get 获取子类
  1022. // @Description get SampleType by token
  1023. // @Success 200 {object} sampletype.SampleType
  1024. // @router /goodschildlistbypid/:parentid [get]
  1025. func (this *OilGoodsAptitudeController) GoodsChildLisByParentId() {
  1026. ParentId := this.Ctx.Input.Param(":parentid")
  1027. GoodsLevel := this.GetString("GoodsLevel")
  1028. sqlStr := "SELECT o.Id, o.`Code`, o.`Name`, concat(o.Code, ' ', o.Name) as CodeName, o.ParentId, g.GoodsLevel," +
  1029. " (CASE WHEN length(Code)>=8 THEN '1' ELSE '0' END) as Leaf FROM OilGoodsAptitudeClass o " +
  1030. " LEFT JOIN `OilGoodsAptitude` g ON (g.ClassId = o.Id)" +
  1031. " WHERE IF ((LENGTH(CODE)=8 and '" + GoodsLevel + "' = 2 ) , g.GoodsLevel = '2', 1=1 ) and o.ParentId = " + ParentId + " AND o.Edition='1' AND o.DeletionStateCode = 0 order by o.Code"
  1032. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1033. list, _ := svc.DBE.QueryString(sqlStr)
  1034. var datainfo DataInfo
  1035. datainfo.Items = list
  1036. this.Data["json"] = &datainfo
  1037. this.ServeJSON()
  1038. }
  1039. // @Title get 导出ex
  1040. // @Description get SampleType by token
  1041. // @Success 200 {object} sampletype.SampleType
  1042. // @router /exportexcelall [get]
  1043. func (this *OilGoodsAptitudeController) ExportExcelAll() {
  1044. //获取分页信息
  1045. //page := this.GetPageInfoForm()
  1046. where := " 1=1 "
  1047. orderby := "Code"
  1048. asc := true
  1049. Order := this.GetString("Order")
  1050. Prop := this.GetString("Prop")
  1051. if Order != "" && Prop != "" {
  1052. orderby = Prop
  1053. if Order == "asc" {
  1054. asc = true
  1055. } else {
  1056. asc = false
  1057. }
  1058. }
  1059. Edition := this.GetString("Edition")
  1060. if Edition != "" {
  1061. where = where + " and Edition = '" + Edition + "'"
  1062. }
  1063. t := time.Now()
  1064. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1065. var list []goodsaptitude.OilGoodsAptitudeView
  1066. svc.GetMyPagingEntitiesWithOrderBytbl(OilGoodsAptDetailViewName, 0, 0, orderby, asc, &list, where)
  1067. var title []string
  1068. filetitle := "物资类"
  1069. //自定义显示列
  1070. showcolumnarr := this.GetString("showcolumnarr")
  1071. showcolumnnamearr := this.GetString("showcolumnnamearr")
  1072. titlestring := showcolumnnamearr
  1073. title = strings.Split(titlestring, ",")
  1074. f := xlsx.NewFile()
  1075. sheet, _ := f.AddSheet(filetitle)
  1076. //rowhead := sheet.AddRow()
  1077. //rowhead.WriteSlice(&title, -1)
  1078. cellname := strings.Split(showcolumnarr, ",")
  1079. row := sheet.AddRow()
  1080. row2 := sheet.AddRow()
  1081. row.WriteSlice(&cellname, -1)
  1082. row2.WriteSlice(&cellname, -1)
  1083. //doublename := "制造商,贸易商"
  1084. //doubleslice := strings.Split(doublename, ",")
  1085. //rowhead := sheet.AddRow()
  1086. //rowhead.WriteSlice(&doubleslice, -1)
  1087. intsix := svc.GetNumOfPass("0")
  1088. intStr := strconv.FormatInt(intsix, 10)
  1089. alluse ,_ := strconv.Atoi(intStr)
  1090. for i := 0; i < alluse+12; i++ {
  1091. row.Cells[i].Merge(0, 1)
  1092. }
  1093. intsix1 := svc.GetNumOfPass("2")
  1094. intStr1 := strconv.FormatInt(intsix1, 10)
  1095. traker ,_ := strconv.Atoi(intStr1)
  1096. row.Cells[alluse+12].Merge(traker-1,0)
  1097. row.Cells[alluse+12].Value = "贸易产品"
  1098. intsix2 := svc.GetNumOfPass("1")
  1099. intStr2 := strconv.FormatInt(intsix2, 10)
  1100. maker ,_ := strconv.Atoi(intStr2)
  1101. row.Cells[alluse+12+traker].Merge(maker-1,0)
  1102. row.Cells[alluse+12+traker].Value = "制造产品"
  1103. for _, item := range list {
  1104. var enumModel goodsaptitude.OilGoodsAptitudeView
  1105. tmpModel := &item
  1106. enumModel = *tmpModel
  1107. immumodel := reflect.ValueOf(&enumModel)
  1108. elem := immumodel.Elem()
  1109. row := sheet.AddRow()
  1110. for _, name := range title {
  1111. cell := row.AddCell()
  1112. if strings.HasPrefix(name, "F") {
  1113. var val = elem.FieldByName(name).String()
  1114. if val == "1" {
  1115. cell.Value = "是"
  1116. } else {
  1117. cell.Value = ""
  1118. }
  1119. } else {
  1120. cell.Value = elem.FieldByName(name).String()
  1121. }
  1122. }
  1123. }
  1124. for c, cl := 0, len(sheet.Cols); c < cl; c++ {
  1125. sheet.Cols[c].Width = 20
  1126. }
  1127. //this.SaveSampleXlsx(filetitle, title, showcolumnarr, list, f)
  1128. dir := "static/file/excel/report/" + this.GetAccode()
  1129. SaveDirectory(dir)
  1130. path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
  1131. f.Save(path)
  1132. var sw *Seaweed
  1133. var filer []string
  1134. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  1135. filer = []string{_filer}
  1136. }
  1137. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  1138. _, _, fID, _ := sw.UploadFile(path, "", "")
  1139. retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  1140. os.Remove(path)
  1141. fmt.Println("==retDocWatermarkUrl==", retDocUrl)
  1142. this.Data["json"] = retDocUrl
  1143. this.ServeJSON()
  1144. elapsed := time.Since(t)
  1145. fmt.Println(elapsed)
  1146. }
  1147. // @Title get 导出ex
  1148. // @Description get SampleType by token
  1149. // @Success 200 {object} sampletype.SampleType
  1150. // @router /exportexcelall2019 [get]
  1151. func (this *OilGoodsAptitudeController) ExportExcelAll2019() {
  1152. //获取分页信息
  1153. //page := this.GetPageInfoForm()
  1154. where := " 1=1 "
  1155. orderby := "Code"
  1156. asc := true
  1157. Order := this.GetString("Order")
  1158. Prop := this.GetString("Prop")
  1159. if Order != "" && Prop != "" {
  1160. orderby = Prop
  1161. if Order == "asc" {
  1162. asc = true
  1163. } else {
  1164. asc = false
  1165. }
  1166. }
  1167. Edition := this.GetString("Edition")
  1168. if Edition != "" {
  1169. where = where + " and a.Edition = '" + Edition + "'"
  1170. }
  1171. t := time.Now()
  1172. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1173. var list []goodsaptitude.OilGoodsAptitude_2
  1174. svc.GetList_2019(OilGoodsAptitudeName, OilGoodsAptitudeClassName, 0, 0, orderby, asc, &list, where)
  1175. var title []string
  1176. filetitle := "物资类(顶级)"
  1177. //自定义显示列
  1178. showcolumnarr := this.GetString("showcolumnarr")
  1179. showcolumnnamearr := this.GetString("showcolumnnamearr")
  1180. titlestring := showcolumnnamearr
  1181. title = strings.Split(titlestring, ",")
  1182. f := xlsx.NewFile()
  1183. sheet, _ := f.AddSheet(filetitle)
  1184. cellname := strings.Split(showcolumnarr, ",")
  1185. row := sheet.AddRow()
  1186. row.WriteSlice(&cellname, -1)
  1187. for _, item := range list {
  1188. var enumModel goodsaptitude.OilGoodsAptitude_2
  1189. tmpModel := &item
  1190. enumModel = *tmpModel
  1191. immumodel := reflect.ValueOf(&enumModel)
  1192. elem := immumodel.Elem()
  1193. row := sheet.AddRow()
  1194. for _, name := range title {
  1195. cell := row.AddCell()
  1196. if strings.HasPrefix(name, "F") {
  1197. var val = elem.FieldByName(name).String()
  1198. if val == "1" {
  1199. cell.Value = "是"
  1200. } else {
  1201. cell.Value = ""
  1202. }
  1203. } else {
  1204. cell.Value = elem.FieldByName(name).String()
  1205. }
  1206. }
  1207. }
  1208. for c, cl := 0, len(sheet.Cols); c < cl; c++ {
  1209. sheet.Cols[c].Width = 20
  1210. }
  1211. dir := "static/file/excel/report/" + this.GetAccode()
  1212. SaveDirectory(dir)
  1213. path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
  1214. f.Save(path)
  1215. var sw *Seaweed
  1216. var filer []string
  1217. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  1218. filer = []string{_filer}
  1219. }
  1220. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  1221. _, _, fID, _ := sw.UploadFile(path, "", "")
  1222. retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  1223. os.Remove(path)
  1224. fmt.Println("==retDocWatermarkUrl==", retDocUrl)
  1225. this.Data["json"] = retDocUrl
  1226. this.ServeJSON()
  1227. elapsed := time.Since(t)
  1228. fmt.Println(elapsed)
  1229. }
  1230. // @Title get 导入excel
  1231. // @Description get SampleType by token
  1232. // @Success 200 {object} sampletype.SampleType
  1233. // @router /importexcel [get]
  1234. func (this *OilGoodsAptitudeController) ImportExcel() {
  1235. url := this.GetString("ExcelUrl")
  1236. var errorinfo ErrorInfo
  1237. if url == "" {
  1238. errorinfo.Code = -2
  1239. errorinfo.Message = "导入失败!"
  1240. this.Data["json"] = &errorinfo
  1241. this.ServeJSON()
  1242. }
  1243. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1244. err := svc.TruncateTable(Tmp_OilGoodsAptitudeName)
  1245. if err != nil {
  1246. errorinfo.Code = -2
  1247. errorinfo.Message = "导入失败!"
  1248. this.Data["json"] = &errorinfo
  1249. this.ServeJSON()
  1250. }
  1251. err = svc.TruncateTable(Tmp_OilGoodsAptitudeClassName)
  1252. if err != nil {
  1253. errorinfo.Code = -2
  1254. errorinfo.Message = "导入失败!"
  1255. this.Data["json"] = &errorinfo
  1256. this.ServeJSON()
  1257. }
  1258. // 外网不用 go func()
  1259. go func() {
  1260. _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
  1261. filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
  1262. utils.DownloadFile(url, filename, _dir)
  1263. t := time.Now()
  1264. filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
  1265. xlFile, err := xlsx.OpenFile(filePath)
  1266. var errLineNum string
  1267. //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
  1268. if err != nil {
  1269. fmt.Printf("open failed: %s\n", err)
  1270. }
  1271. var sheet = xlFile.Sheets[0]
  1272. Fstrs := svc.GetFCode()
  1273. Fstrs = "GoodsLevel,GoodsDesc,Standard,CompanyType," + Fstrs
  1274. columnArr := strings.Split(Fstrs, ",")
  1275. codemap := make(map[string]int)
  1276. for i := 2; i < len(sheet.Rows); i++ {
  1277. lineNo := strconv.Itoa(i + 1)
  1278. this.OperationCell(lineNo, columnArr, codemap, sheet.Rows[i].Cells, &errLineNum)
  1279. }
  1280. os.Remove(filePath)
  1281. if errLineNum != "" {
  1282. log.Println("导入失败!错误行号:" + errLineNum)
  1283. } else {
  1284. elapsed := time.Since(t)
  1285. log.Println(elapsed)
  1286. this.CreateContrast()
  1287. }
  1288. }()
  1289. errorinfo.Code = 0
  1290. errorinfo.Message = "导入中,请等待!"
  1291. this.Data["json"] = &errorinfo
  1292. this.ServeJSON()
  1293. }
  1294. func (this *OilGoodsAptitudeController) OperationCell(lineNo string, columnArr []string, codemap map[string]int, cellsArr []*xlsx.Cell, errLineNum *string) {
  1295. defer func() {
  1296. if err := recover(); err != nil {
  1297. log.Println("err"+lineNo, err)
  1298. *errLineNum += lineNo + ","
  1299. }
  1300. }()
  1301. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1302. parentId := 0
  1303. classId := 0
  1304. cellsArrLen := len(cellsArr)
  1305. cellD := strings.TrimSpace(cellsArr[6].String())
  1306. var valstr = ""
  1307. for i := 0; i < cellsArrLen; {
  1308. if i < 8 {
  1309. var entity goodsaptitudeclass.Tmp_OilGoodsAptitudeClass
  1310. cellval := strings.TrimSpace(cellsArr[i].String())
  1311. fmt.Println(cellval)
  1312. _, has := codemap[cellval]
  1313. if !has {
  1314. if i != 0 {
  1315. upcode := cellsArr[i-2].String()
  1316. parentId = codemap[upcode]
  1317. }
  1318. entity.Code = cellval
  1319. entity.Name = strings.TrimSpace(cellsArr[i+1].String())
  1320. entity.Edition = "1"
  1321. entity.ParentId = parentId
  1322. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1323. entity.CreateBy = this.User.Realname
  1324. entity.CreateOn = time.Now()
  1325. _, err := svc.InsertEntityBytbl(Tmp_OilGoodsAptitudeClassName, &entity)
  1326. if err != nil {
  1327. panic(err)
  1328. break
  1329. }
  1330. classId = entity.Id
  1331. if i <= 6 {
  1332. codemap[cellval] = entity.Id
  1333. }
  1334. }
  1335. }
  1336. if i >= 8 {
  1337. valstr += "'" + cellsArr[i].String() + "',"
  1338. i++
  1339. } else {
  1340. i += 2
  1341. }
  1342. }
  1343. //for idx, cell := range cellsArr {
  1344. // if idx < 4 {
  1345. // cellstr := cell.String()
  1346. // //fmt.Printf("%s\n", cellstr)
  1347. // if strings.TrimSpace(cellstr) == "" {
  1348. // break
  1349. // }
  1350. // cellArr := strings.Fields(cellstr)
  1351. //
  1352. // //id := sessionsvc.SelectGoodsAptitudeClassCode(cellArr[0])
  1353. //
  1354. // var entity goodsaptitudeclass.Tmp_OilGoodsAptitudeClass
  1355. // _, has := codemap[cellArr[0]]
  1356. // if !has {
  1357. // if idx != 0 {
  1358. // upcellstr := cellsArr[idx-1].String()
  1359. // upcellArr := strings.Fields(upcellstr)
  1360. // parentId = codemap[upcellArr[0]]
  1361. // }
  1362. // entity.Code = cellArr[0]
  1363. // entity.Name = cellArr[1]
  1364. // entity.Edition = "1"
  1365. // entity.ParentId = parentId
  1366. // entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1367. // entity.CreateBy = this.User.Realname
  1368. // entity.CreateOn = time.Now()
  1369. //
  1370. // _, err := svc.InsertEntityBytbl(Tmp_OilGoodsAptitudeClassName, &entity)
  1371. // if err != nil {
  1372. // panic(err)
  1373. // break
  1374. // }
  1375. // classId = entity.Id
  1376. // if idx != 3 {
  1377. // codemap[cellArr[0]] = entity.Id
  1378. // }
  1379. // }
  1380. // }
  1381. // if idx >= 4 {
  1382. // valstr += "'" + cellsArr[idx].String() + "',"
  1383. // }
  1384. //}
  1385. if cellD != "" {
  1386. valstr = strings.Trim(valstr, ",")
  1387. valstr = strings.Replace(valstr, "是", "1", -1)
  1388. log.Println(cellsArr[6].String() + "==" + valstr)
  1389. var columnstr = ""
  1390. for l := 0; l < cellsArrLen-8; l++ {
  1391. columnstr += columnArr[l] + ","
  1392. }
  1393. columnstr = strings.Trim(columnstr, ",")
  1394. err := svc.InsertTmpGoodsAptitude(strconv.Itoa(classId), columnstr, valstr)
  1395. if err != nil {
  1396. panic(err)
  1397. }
  1398. }
  1399. }
  1400. // @Title get 清空导入的信息
  1401. // @Description get SampleType by token
  1402. // @Success 200 {object} sampletype.SampleType
  1403. // @router /truncateimport [get]
  1404. func (this *OilGoodsAptitudeController) TruncateImport() {
  1405. session := utils.DBE.NewSession()
  1406. err := session.Begin()
  1407. defer session.Close()
  1408. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  1409. err = svc.TruncateTable(Tmp_OilGoodsAptitudeName)
  1410. var errorinfo ErrorInfo
  1411. if err != nil {
  1412. session.Rollback()
  1413. errorinfo.Code = -1
  1414. errorinfo.Message = "删除失败!"
  1415. this.Data["json"] = &errorinfo
  1416. this.ServeJSON()
  1417. }
  1418. err = svc.TruncateTable(Tmp_OilGoodsAptitudeClassName)
  1419. if err != nil {
  1420. session.Rollback()
  1421. errorinfo.Code = -1
  1422. errorinfo.Message = "删除失败!"
  1423. this.Data["json"] = &errorinfo
  1424. this.ServeJSON()
  1425. }
  1426. session.Commit()
  1427. errorinfo.Code = 0
  1428. errorinfo.Message = "删除成功!"
  1429. this.Data["json"] = &errorinfo
  1430. this.ServeJSON()
  1431. }
  1432. // @Title get 生成对比列表
  1433. // @Description get SampleType by token
  1434. // @Success 200 {object} sampletype.SampleType
  1435. // @router /create-contrast [get]
  1436. func (this *OilGoodsAptitudeController) CreateContrast() {
  1437. go func() {
  1438. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1439. svc.TruncateTable("OilSupplierContrast")
  1440. // 插入对比列表
  1441. var list1 []supplier.OilSupplier
  1442. svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, 0, 0, "Id", false, &list1, " 1=1")
  1443. svc.DBE.Query("SET unique_checks=0;")
  1444. svc.DBE.Query("SET autocommit=0;")
  1445. for _, item := range list1 {
  1446. var list []supplier.OilSupplierContrast
  1447. where := " b.SupplierTypeCode='01' and a.Id = " + strconv.Itoa(item.Id)
  1448. svc.GetPagingTmpCheckedEntities(&list, where)
  1449. if list != nil {
  1450. var supplierCertSubList []suppliercertsub.OilSupplierCertSub
  1451. total := svc.GetTableTotal(" SupplierTypeCode = '01' AND SupplierId = "+strconv.Itoa(item.Id), &supplierCertSubList)
  1452. total1 := svc.GetNoSubCntTotal("a.SupplierTypeCode = '01' and b.`Name` is null and a.SupplierId = " + strconv.Itoa(item.Id))
  1453. list[0].SubCnt = int(total)
  1454. //list[0].MinClassId = "0"
  1455. list[0].NoSubCnt = int(total1)
  1456. //for _, sub := range supplierCertSubList {
  1457. // var goodsList goodsaptitudeclass.OilGoodsAptitudeClass
  1458. // where2 := "Code = '"+ sub.Code + "'"
  1459. // svc.GetEntityByWhere(Tmp_OilGoodsAptitudeClassName, where2, &goodsList)
  1460. // if goodsList.Id > 0{
  1461. // list[0].MinClassId = strconv.Itoa(goodsList.Id)
  1462. // } else {
  1463. // list[0].MinClassId = "0"
  1464. // break
  1465. // }
  1466. //}
  1467. list[0].SetupTime = time.Now()
  1468. var oneTwo supplier.OilSupplierContrast
  1469. svc.GetEntityByCode("SupplierTypeCode = '01' and SupplierId = "+strconv.Itoa(list[0].Id), &oneTwo)
  1470. list[0].OneTwoCount = oneTwo.OneTwoCount
  1471. list[0].TwoOneCount = oneTwo.TwoOneCount
  1472. svc.InsertEntityBytbl("OilSupplierContrast", list[0])
  1473. svc.DBE.Query("commit;")
  1474. }
  1475. }
  1476. svc.DBE.Query("SET unique_checks=1;")
  1477. svc.DBE.Query("SET autocommit=1;")
  1478. }()
  1479. var errorinfo ErrorInfo
  1480. errorinfo.Code = 0
  1481. errorinfo.Message = "成功!"
  1482. this.Data["json"] = &errorinfo
  1483. this.ServeJSON()
  1484. }
  1485. // @Title 将导入的数据 导入到正式表
  1486. // @Description 确认更新
  1487. // @Success 200 {object} sampletype.SampleType
  1488. // @router /insertgoodsaptitude [get]
  1489. func (this *OilGoodsAptitudeController) InsertGoodsAptitude() {
  1490. session := utils.DBE.NewSession()
  1491. err := session.Begin()
  1492. defer session.Close()
  1493. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  1494. var errinfo ErrorInfo
  1495. err = svc.TruncateTable(OilGoodsAptitudeName)
  1496. if err != nil {
  1497. session.Rollback()
  1498. errinfo.Code = -1
  1499. errinfo.Message = "更新失败!"
  1500. this.Data["json"] = &errinfo
  1501. this.ServeJSON()
  1502. }
  1503. err = svc.TruncateTable(OilGoodsAptitudeClassName)
  1504. if err != nil {
  1505. session.Rollback()
  1506. errinfo.Code = -1
  1507. errinfo.Message = "更新失败!"
  1508. this.Data["json"] = &errinfo
  1509. this.ServeJSON()
  1510. }
  1511. err = svc.InsertGoodsAptitude(Tmp_OilGoodsAptitudeName, OilGoodsAptitudeName)
  1512. if err != nil {
  1513. session.Rollback()
  1514. errinfo.Code = -1
  1515. errinfo.Message = "更新失败!"
  1516. this.Data["json"] = &errinfo
  1517. this.ServeJSON()
  1518. }
  1519. err = svc.InsertGoodsAptitude(Tmp_OilGoodsAptitudeClassName, OilGoodsAptitudeClassName)
  1520. if err != nil {
  1521. session.Rollback()
  1522. errinfo.Code = -1
  1523. errinfo.Message = "更新失败!"
  1524. this.Data["json"] = &errinfo
  1525. this.ServeJSON()
  1526. }
  1527. // TODO 更新certsub表的subclassid
  1528. svc1 := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1529. var list2 []supplier.OilSupplierContrast
  1530. where := " (Checked = '0' or MinClassId = '0') and SupplierTypeCode = '01'"
  1531. svc1.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrast", 0, 0, "Id", false, &list2, where)
  1532. err = svc.TruncateTable("OilSupplierContrastNew")
  1533. if err != nil {
  1534. session.Rollback()
  1535. errinfo.Code = -1
  1536. errinfo.Message = "更新失败!"
  1537. this.Data["json"] = &errinfo
  1538. this.ServeJSON()
  1539. }
  1540. for _, item := range list2 {
  1541. _, err := svc.InsertEntityBytbl("OilSupplierContrastNew", item)
  1542. if err != nil {
  1543. session.Rollback()
  1544. errinfo.Code = -1
  1545. errinfo.Message = "更新失败!"
  1546. this.Data["json"] = &errinfo
  1547. this.ServeJSON()
  1548. }
  1549. }
  1550. session.Commit()
  1551. errinfo.Code = 0
  1552. errinfo.Message = "更新成功,即将操作企业准入范围!"
  1553. this.Data["json"] = &errinfo
  1554. this.ServeJSON()
  1555. }
  1556. // @Title 更新企业的准入项及资质
  1557. // @Description get SampleType by token
  1558. // @Success 200 {object} sampletype.SampleType
  1559. // @router /updatasuppiercertsub [get]
  1560. func (this *OilGoodsAptitudeController) UpdataSuppierCertSub() {
  1561. //excelFileName := "F:/ssa.xlsx"
  1562. //xlFile, _ := xlsx.OpenFile(excelFileName)
  1563. //var sheet = xlFile.Sheets[0]
  1564. t := time.Now()
  1565. goodsvc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1566. goodsvc.DeleteTable(TmpOilSupplierCertSubName, "SupplierTypeCode='01'")
  1567. supsvc := supplier.GetOilSupplierService(utils.DBE)
  1568. var suppliercertList []suppliercert.OilSupplierCert
  1569. where := "SupplierTypeCode='01' AND OutsideFlog = '' AND (InFlag IN ('1','2')) "
  1570. supsvc.GetEntities(&suppliercertList, where)
  1571. var goodsaptitudeClassList []goodsaptitudeclass.OilGoodsAptitudeClass
  1572. whereclass := "LENGTH(CODE) = 8 "
  1573. supsvc.GetEntities(&goodsaptitudeClassList, whereclass)
  1574. var colsname = []string{"Name"}
  1575. var colsLevel = []string{"GoodsLevel"}
  1576. for _, suppliercert := range suppliercertList {
  1577. //row := sheet.AddRow()
  1578. //cell := row.AddCell()
  1579. //cell.Value = strconv.Itoa(suppliercert.SupplierId)
  1580. var supplier supplier.OilSupplier
  1581. wheres := " Id=" + strconv.Itoa(suppliercert.SupplierId)
  1582. supsvc.GetEntity(&supplier, wheres)
  1583. log.Println(suppliercert.SupplierId)
  1584. var supplierCertSubList []suppliercertsub.OilSupplierCertSub
  1585. wheresup := "SupplierId = " + strconv.Itoa(suppliercert.SupplierId) + " and SupplierTypeCode='01' AND Type IN ('1', '3')"
  1586. supsvc.GetEntities(&supplierCertSubList, wheresup)
  1587. fmt.Println(len(supplierCertSubList))
  1588. mergerCertSkipField := ""
  1589. if supplier.CredentialFlag == "1" || supplier.CredentialFlag == "2" {
  1590. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1591. //三证合一或五证合一不需要的字段
  1592. mergerCertSkipField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  1593. }
  1594. // 准入项
  1595. //for idx, supplierCertSub := range supplierCertSubList {
  1596. for idx := 0; idx < len(supplierCertSubList); idx++ {
  1597. //row := sheet.AddRow()
  1598. //cell := row.AddCell()
  1599. //cell.Value = "删除"
  1600. supplierCertSub := supplierCertSubList[idx]
  1601. decCode := supplierCertSub.Code
  1602. // 物资类的准入编码
  1603. for _, goodsaptitudeClass := range goodsaptitudeClassList {
  1604. // 如果编码相同的后 判断有没有改名 然后查询准入项需要哪些资质 去查资质表里有没有这些资质 没有就删除这个准入项
  1605. if supplierCertSub.Code == goodsaptitudeClass.Code {
  1606. decCode = ""
  1607. goodsAptitudeNameArr := this.GetGoodsAptitudeName(strconv.Itoa(goodsaptitudeClass.Id), strconv.Itoa(supplierCertSub.IsManufacturer))
  1608. for _, val := range goodsAptitudeNameArr {
  1609. if strings.Contains(mergerCertSkipField, val) {
  1610. break
  1611. }
  1612. var supplierFile supplierfile.OilSupplierFile
  1613. where := "SupplierId=" + strconv.Itoa(suppliercert.SupplierId) + " and NeedFileType='" + val + "'" + " and SupplierTypeCode IN ('000', '01')"
  1614. has := supsvc.GetEntityByWhere(OilSupplierFileName, where, &supplierFile)
  1615. if !has {
  1616. //cell := row.AddCell()
  1617. //cell.Value = supplierCertSub.Code + " " + supplierCertSub.Name
  1618. log.Println(supplierCertSub.Code + "====" + val)
  1619. //wheredel := "Id = " + strconv.Itoa(supplierCertSub.Id)
  1620. //supsvc.DeleteEntityBytbl(OilSupplierCertSubName, wheredel)
  1621. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  1622. break
  1623. }
  1624. if supplierCertSub.Name != goodsaptitudeClass.Name {
  1625. //row := sheet.AddRow()
  1626. //cell := row.AddCell()
  1627. //cell.Value = supplierCertSub.Code + ":" + supplierCertSub.Name + "==" + goodsaptitudeClass.Name
  1628. var entity suppliercertsub.OilSupplierCertSub
  1629. entity.Name = goodsaptitudeClass.Name
  1630. where := "Id = " + strconv.Itoa(supplierCertSub.Id)
  1631. supsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &entity, colsname, where)
  1632. }
  1633. var goodsAptitude goodsaptitude.OilGoodsAptitude
  1634. whereg := "ClassId = " + strconv.Itoa(goodsaptitudeClass.Id)
  1635. supsvc.GetEntity(&goodsAptitude, whereg)
  1636. if goodsAptitude.GoodsLevel != supplierCertSub.GoodsLevel {
  1637. if goodsAptitude.GoodsLevel == "1" && supplier.Grade == "2" {
  1638. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  1639. } else {
  1640. var entity suppliercertsub.OilSupplierCertSub
  1641. entity.GoodsLevel = goodsAptitude.GoodsLevel
  1642. where := "Id = " + strconv.Itoa(supplierCertSub.Id)
  1643. supsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &entity, colsLevel, where)
  1644. }
  1645. }
  1646. }
  1647. break
  1648. }
  1649. }
  1650. if decCode != "" {
  1651. //wheredel := "Code = '" + decCode + "'"
  1652. //supsvc.DeleteEntityBytbl(OilSupplierCertSubName, wheredel)
  1653. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  1654. }
  1655. //cell1 := row.AddCell()
  1656. //cell1.Value = decCode
  1657. }
  1658. }
  1659. elapsed := time.Since(t)
  1660. log.Println(elapsed)
  1661. var errinfo ErrorInfo
  1662. errinfo.Code = 0
  1663. errinfo.Message = "更新完成!"
  1664. this.Data["json"] = &errinfo
  1665. this.ServeJSON()
  1666. //xlFile.Save(excelFileName)
  1667. }
  1668. func (this *OilGoodsAptitudeController) GetGoodsAptitudeName(classId, IsManuf string) []string {
  1669. var goodsAptitudeName string
  1670. var goodsAptitudeList []goodsaptitude.OilGoodsAptitudeF
  1671. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1672. where := "ClassId=" + classId
  1673. svc.GetGoodsAptitudeF(&goodsAptitudeList, where)
  1674. for _, goodsAptitude := range goodsAptitudeList {
  1675. t := reflect.TypeOf(goodsAptitude)
  1676. v := reflect.ValueOf(goodsAptitude)
  1677. for k := 0; k < t.NumField(); k++ {
  1678. if v.Field(k).Interface() == "1" {
  1679. var tableHeader tableheader.BaseTableheader
  1680. where := "Code='" + t.Field(k).Name + "' and IsManuf in ('0','" + IsManuf + "')"
  1681. has := svc.GetEntityByWhere(BaseTableHeader, where, &tableHeader)
  1682. if has {
  1683. goodsAptitudeName += tableHeader.Name + ","
  1684. }
  1685. }
  1686. }
  1687. }
  1688. return strings.Split(goodsAptitudeName, ",")
  1689. }
  1690. // @Title 获取所有
  1691. // @Description
  1692. // @Success 200 {object}
  1693. // @router /getcompanylist [post]
  1694. func (this *OilGoodsAptitudeController) GetTList() {
  1695. var model supplier.OilSupplierSelect
  1696. var model1 supplier.RegCapitalRange //注册资金范围
  1697. //var model2 supplier.NeedFileTypeStruct //资质结构体
  1698. var jsonBlob = this.Ctx.Input.RequestBody
  1699. json.Unmarshal(jsonBlob, &model)
  1700. json.Unmarshal(jsonBlob, &model1)
  1701. //json.Unmarshal(jsonBlob, &model2)
  1702. // //获取分页信息
  1703. page := this.GetPageInfoForm()
  1704. where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' and b.SupplierTypeCode = '01' AND t.SupplierId IS NOT NULL "
  1705. orderby := "a.Id"
  1706. asc := true
  1707. Order := this.GetString("Order")
  1708. Prop := this.GetString("Prop")
  1709. CheckUId := this.GetString("CheckUId")
  1710. FullId := this.GetString("FullId")
  1711. if Order != "" && Prop != "" {
  1712. orderby = Prop
  1713. if Order == "desc" {
  1714. asc = false
  1715. }
  1716. }
  1717. leftjoin := ""
  1718. //准入证号
  1719. if model.AccessCardNo != "" {
  1720. where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
  1721. }
  1722. //企业名称
  1723. if model.SupplierName != "" {
  1724. where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
  1725. }
  1726. if model.OldSupplierName != "" {
  1727. where = where + " and OldSupplierName like '%" + model.OldSupplierName + "%'"
  1728. }
  1729. if FullId != "" {
  1730. where = where + " and f.Id = '" + FullId + "'"
  1731. }
  1732. if CheckUId != "" {
  1733. where = where + " and g.CheckUnitId = '" + CheckUId + "'"
  1734. }
  1735. //准入标识 1 准入 2 暂停 3取消
  1736. if model.InFlag != "" {
  1737. where = where + " and b.InFlag = '" + model.InFlag + "'"
  1738. }
  1739. //法人
  1740. if model.LegalPerson != "" {
  1741. where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
  1742. }
  1743. //联系人
  1744. if model.ContactName != "" {
  1745. where = where + " and a.ContactName like '%" + model.ContactName + "%'"
  1746. }
  1747. //统一社会信用代码
  1748. if model.CommercialNo != "" {
  1749. where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
  1750. }
  1751. //开户银行
  1752. if model.DepositBank != "" {
  1753. where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
  1754. }
  1755. //HSE审查
  1756. if model.HseTraining != "" {
  1757. where = where + " and a.HseTraining = '" + model.HseTraining + "'"
  1758. }
  1759. //公司类型
  1760. if model.CompanyType != "" {
  1761. where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
  1762. }
  1763. //成立时间
  1764. SetupTime := this.GetString("SetupTime")
  1765. if SetupTime != "" {
  1766. where = where + " and a.SetupTime ='" + SetupTime + "'"
  1767. }
  1768. //注册资金范围
  1769. if model1.RegCapital1 != "" {
  1770. where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
  1771. }
  1772. if model1.RegCapital2 != "" {
  1773. where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
  1774. }
  1775. //注册省份
  1776. if model.Province != "" {
  1777. where = where + " and a.Province = '" + model.Province + "'"
  1778. }
  1779. //注册市
  1780. if model.City != "" {
  1781. where = where + " and a.City = '" + model.City + "'"
  1782. }
  1783. //注册区
  1784. if model.Street != "" {
  1785. where = where + " and a.Street = '" + model.Street + "'"
  1786. }
  1787. //注册详细地址
  1788. if model.Address != "" {
  1789. where = where + " and a.Address like '%" + model.Address + "%'"
  1790. }
  1791. if model.LinkProvince != "" {
  1792. where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
  1793. }
  1794. if model.LinkCity != "" {
  1795. where = where + " and a.LinkCity = '" + model.LinkCity + "'"
  1796. }
  1797. if model.LinkStreet != "" {
  1798. where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
  1799. }
  1800. if model.LinkAddress != "" {
  1801. where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
  1802. }
  1803. //营业范围
  1804. if model.BusinessScope != "" {
  1805. where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
  1806. }
  1807. CreateOn := this.GetString("CreateOn")
  1808. if CreateOn != "" {
  1809. dates := strings.Split(CreateOn, ",")
  1810. if len(dates) == 2 {
  1811. minDate := dates[0]
  1812. maxDate := dates[1]
  1813. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  1814. }
  1815. }
  1816. a := model.InStyle
  1817. fmt.Println(a)
  1818. //准入方式
  1819. if model.InStyle != "" {
  1820. if model.InStyle == "0" {
  1821. where = where + " and b.InStyle in ('2','3','4','5')"
  1822. } else {
  1823. where = where + " and b.InStyle ='" + model.InStyle + "'"
  1824. }
  1825. }
  1826. having := ""
  1827. //准入范围
  1828. if model.CerSubName != "" {
  1829. having = " having CerSubName like '%" + model.CerSubName + "%' "
  1830. leftjoin = "left join " + OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  1831. }
  1832. //资质
  1833. if model.NeedFileType != "" {
  1834. having = " having NeedFileType like '%" + model.NeedFileType + "%' "
  1835. }
  1836. if model.CerSubName != "" && model.NeedFileType != "" {
  1837. having = " having CerSubName like '%" + model.CerSubName + "%' and NeedFileType like '%" + model.NeedFileType + "%' "
  1838. leftjoin = "left join " + OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  1839. }
  1840. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1841. var list []supplier.OilSupplierSelect
  1842. total := svc.GetMyPagingDelEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
  1843. OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where, having, leftjoin)
  1844. var datainfo DataInfo
  1845. datainfo.Items = list
  1846. datainfo.CurrentItemCount = total
  1847. datainfo.PageIndex = page.CurrentPage
  1848. datainfo.ItemsPerPage = page.Size
  1849. this.Data["json"] = &datainfo
  1850. this.ServeJSON()
  1851. }
  1852. // @Title 查看对比列表的准入范围 2020-12-18
  1853. // @Description get user by token
  1854. // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
  1855. // @router /delcertsublist [get]
  1856. func (this *OilGoodsAptitudeController) GetDelCertSubList() {
  1857. //获取分页信息
  1858. page := this.GetPageInfoForm()
  1859. where := " 1=1 "
  1860. orderby := "a.Id"
  1861. asc := false
  1862. Order := this.GetString("Order")
  1863. Prop := this.GetString("Prop")
  1864. if Order != "" && Prop != "" {
  1865. orderby = Prop
  1866. if Order == "asc" {
  1867. asc = true
  1868. }
  1869. }
  1870. Id := this.GetString("Id")
  1871. SupplierId := this.GetString("SupplierId")
  1872. SupplierCertId := this.GetString("SupplierCertId")
  1873. SupplierTypeCode := this.GetString("SupplierTypeCode")
  1874. Code := this.GetString("Code")
  1875. Name := this.GetString("Name")
  1876. Remark := this.GetString("Remark")
  1877. IsDelete := this.GetString("IsDelete")
  1878. CreateOn := this.GetString("CreateOn")
  1879. CreateUserId := this.GetString("CreateUserId")
  1880. CreateBy := this.GetString("CreateBy")
  1881. ModifiedOn := this.GetString("ModifiedOn")
  1882. ModifiedUserId := this.GetString("ModifiedUserId")
  1883. ModifiedBy := this.GetString("ModifiedBy")
  1884. if Id != "" {
  1885. where = where + " and a.Id like '%" + Id + "%'"
  1886. }
  1887. if SupplierId != "" {
  1888. where = where + " and a.SupplierId like '%" + SupplierId + "%'"
  1889. }
  1890. if SupplierCertId != "" {
  1891. where = where + " and a.SupplierCertId = '" + SupplierCertId + "'"
  1892. }
  1893. if SupplierTypeCode != "" {
  1894. where = where + " and a.SupplierTypeCode = '" + SupplierTypeCode + "'"
  1895. }
  1896. if Code != "" {
  1897. where = where + " and a.Code like '%" + Code + "%'"
  1898. }
  1899. if Name != "" {
  1900. where = where + " and a.Name like '%" + Name + "%'"
  1901. }
  1902. if Remark != "" {
  1903. where = where + " and a.Remark like '%" + Remark + "%'"
  1904. }
  1905. if IsDelete != "" {
  1906. where = where + " and a.IsDelete like '%" + IsDelete + "%'"
  1907. }
  1908. if CreateUserId != "" {
  1909. where = where + " and a.CreateUserId like '%" + CreateUserId + "%'"
  1910. }
  1911. if CreateBy != "" {
  1912. where = where + " and a.CreateBy like '%" + CreateBy + "%'"
  1913. }
  1914. if ModifiedOn != "" {
  1915. where = where + " and a.ModifiedOn like '%" + ModifiedOn + "%'"
  1916. }
  1917. if ModifiedUserId != "" {
  1918. where = where + " and a.ModifiedUserId like '%" + ModifiedUserId + "%'"
  1919. }
  1920. if ModifiedBy != "" {
  1921. where = where + " and a.ModifiedBy like '%" + ModifiedBy + "%'"
  1922. }
  1923. if CreateOn != "" {
  1924. dates := strings.Split(CreateOn, ",")
  1925. if len(dates) == 2 {
  1926. minDate := dates[0]
  1927. maxDate := dates[1]
  1928. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  1929. }
  1930. }
  1931. where = where + " and a.Type in (1, 3)"
  1932. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1933. var list []suppliercertsub.OilSupplierCertSub1
  1934. var co supplier.OilSupplierContrast
  1935. svc.GetEntityById(SupplierId, &co)
  1936. //total := svc.GetMyPagingEntitiesWithOrderBytbl(TmpOilSupplierCertSubName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  1937. //total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierCertSubName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  1938. if co.IsDelete == 1 {
  1939. where += " and a.IsQuestion = 1"
  1940. }
  1941. total := svc.GetPagingTmpSubEntities(page.CurrentPage, page.Size, orderby, asc, &list, where)
  1942. a := 0
  1943. for _, item := range list {
  1944. 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)) AS Codes FROM tmp_OilGoodsAptitude a LEFT JOIN tmp_OilGoodsAptitudeClass class ON a.ClassId = class.Id"
  1945. sql += " where class.Code = '"+ item.Code + "'"
  1946. model, _ := svc.DBE.QueryString(sql)
  1947. if model != nil {
  1948. code := strings.Split(model[0]["Codes"], ",")
  1949. i := 1
  1950. for _, value := range code {
  1951. if i == 36 || i == 37 || i == 1 {
  1952. if (code[0] == "1" && strings.Index(item.HeaderCodes, "F01") < 0) && (code[35] == "1" && strings.Index(item.HeaderCodes, "F36") < 0) && (code[36] == "1" && strings.Index(item.HeaderCodes, "F37") < 0) {
  1953. list[a].Checked = 1
  1954. sql1 := "select Name from Base_TableHeader where Code = 'F01' and CategoryCode = '01'"
  1955. model1, _ := svc.DBE.QueryString(sql1)
  1956. if strings.Index(list[a].HeaderName, model1[0]["Name"]) == -1 {
  1957. list[a].HeaderName += model1[0]["Name"] + " "
  1958. }
  1959. }
  1960. } else if i > 10 {
  1961. if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
  1962. list[a].Checked = 1
  1963. sql1 := "select Name from Base_TableHeader where Code = 'F"+strconv.Itoa(i)+"' and CategoryCode = '01'"
  1964. model1, _ := svc.DBE.QueryString(sql1)
  1965. list[a].HeaderName += model1[0]["Name"]+ " "
  1966. }
  1967. } else {
  1968. if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
  1969. list[a].Checked = 1
  1970. sql1 := "select Name from Base_TableHeader where Code = 'F0"+strconv.Itoa(i)+"' and CategoryCode = '01'"
  1971. model1, _ := svc.DBE.QueryString(sql1)
  1972. list[a].HeaderName += model1[0]["Name"]+ " "
  1973. }
  1974. }
  1975. i += 1
  1976. }
  1977. } else {
  1978. list[a].MinClassId = "0"
  1979. }
  1980. a += 1
  1981. }
  1982. var datainfo DataInfo
  1983. datainfo.Items = list
  1984. datainfo.CurrentItemCount = total
  1985. datainfo.PageIndex = page.CurrentPage
  1986. datainfo.ItemsPerPage = page.Size
  1987. this.Data["json"] = &datainfo
  1988. this.ServeJSON()
  1989. }
  1990. // @Title 删除不符合的的准入项
  1991. // @Description get user by token
  1992. // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
  1993. // @router /deltmpsuppliercertsub [get]
  1994. func (this *OilGoodsAptitudeController) DelTmpSupplierCertSub() {
  1995. var err error
  1996. session := utils.DBE.NewSession()
  1997. session.Begin()
  1998. defer session.Close()
  1999. supplierId := this.GetString("SupplierId")
  2000. id := this.GetString("Id")
  2001. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  2002. wheredel := "1=1 and SupplierTypeCode = '01'"
  2003. if supplierId != "" {
  2004. wheredel += " and Id=" + supplierId
  2005. }
  2006. if id != "" {
  2007. wheredel += " and Id=" + id
  2008. }
  2009. svc1 := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  2010. //svc.GetEntitysByWhere(TmpOilSupplierCertSubName, wheredel, &supplierCertSubList)
  2011. //svc.GetEntitysByWhere(OilSupplierCertSubName, wheredel, &supplierCertSubList)
  2012. //svc1.GetPagingSubEntities(0, 0, "Id", false, &supplierCertSubList, wheredel)
  2013. var list2 []supplier.OilSupplierContrast
  2014. svc1.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrastNew", 0, 0, "Id", false, &list2, wheredel)
  2015. a := 0
  2016. var errinfo ErrorInfo
  2017. for _, item2 := range list2 {
  2018. var supplierCertSubList []suppliercertsub.OilSupplierCertSub
  2019. where := " SupplierId = " + strconv.Itoa(item2.Id)
  2020. svc1.GetEntitysByWhere(OilSupplierCertSubName, where, &supplierCertSubList)
  2021. for _, item := range supplierCertSubList {
  2022. 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)) AS Codes FROM OilGoodsAptitude a LEFT JOIN OilGoodsAptitudeClass class ON a.ClassId = class.Id"
  2023. sql += " where class.Code = '"+ item.Code + "'"
  2024. model, err := svc1.DBE.QueryString(sql)
  2025. if len(model) == 0 {
  2026. where := "Id = " + strconv.Itoa(item.Id)
  2027. err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
  2028. if err != nil {
  2029. session.Rollback()
  2030. errinfo.Code = -1
  2031. errinfo.Message = "删除失败!"
  2032. this.Data["json"] = &errinfo
  2033. this.ServeJSON()
  2034. } else {
  2035. continue
  2036. }
  2037. }
  2038. code := strings.Split(model[0]["Codes"], ",")
  2039. i := 1
  2040. for _, value := range code {
  2041. if i == 36 || i == 37 || i == 1 {
  2042. if (code[0] == "1" && strings.Index(item2.HeaderCodes, "F01") < 0) && (code[35] == "1" && strings.Index(item2.HeaderCodes, "F36") < 0) && (code[36] == "1" && strings.Index(item2.HeaderCodes, "F37") < 0) {
  2043. where := "Id = " + strconv.Itoa(item.Id)
  2044. err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
  2045. if err != nil {
  2046. session.Rollback()
  2047. errinfo.Code = -1
  2048. errinfo.Message = "删除失败!"
  2049. this.Data["json"] = &errinfo
  2050. this.ServeJSON()
  2051. } else {
  2052. break
  2053. }
  2054. }
  2055. } else if i > 10 {
  2056. if value == "1" && strings.Index(item2.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
  2057. where := "Id = " + strconv.Itoa(item.Id)
  2058. err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
  2059. if err != nil {
  2060. session.Rollback()
  2061. errinfo.Code = -1
  2062. errinfo.Message = "删除失败!"
  2063. this.Data["json"] = &errinfo
  2064. this.ServeJSON()
  2065. } else {
  2066. break
  2067. }
  2068. }
  2069. } else {
  2070. if value == "1" && strings.Index(item2.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
  2071. where := "Id = " + strconv.Itoa(item.Id)
  2072. err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
  2073. if err != nil {
  2074. session.Rollback()
  2075. errinfo.Code = -1
  2076. errinfo.Message = "删除失败!"
  2077. this.Data["json"] = &errinfo
  2078. this.ServeJSON()
  2079. } else {
  2080. break
  2081. }
  2082. }
  2083. }
  2084. i += 1
  2085. }
  2086. a += 1
  2087. }
  2088. where1 := "Id = " + strconv.Itoa(item2.Id)
  2089. err = svc.DeleteEntityBytbl("OilSupplierContrastNew", where1)
  2090. }
  2091. if err == nil {
  2092. session.Commit()
  2093. errinfo.Code = 0
  2094. errinfo.Message = "删除成功!"
  2095. this.Data["json"] = &errinfo
  2096. this.ServeJSON()
  2097. } else {
  2098. session.Rollback()
  2099. errinfo.Code = -1
  2100. errinfo.Message = "删除失败!"
  2101. this.Data["json"] = &errinfo
  2102. this.ServeJSON()
  2103. }
  2104. }
  2105. // @Title 新导入资质后,比对不合格的准入用户
  2106. // @Description 对比列表
  2107. // @Success 200 {object} []supplier.OilSupplierSelect
  2108. // @router /get-compare-tmp-supplier [get]
  2109. func (this *OilGoodsAptitudeController) GetCompareTmpSupplier() {
  2110. //获取分页信息
  2111. page := this.GetPageInfoForm()
  2112. where := " 1=1 "
  2113. orderby := "Id"
  2114. asc := false
  2115. Order := this.GetString("Order")
  2116. Prop := this.GetString("Prop")
  2117. if Order != "" && Prop != "" {
  2118. orderby = Prop
  2119. if Order == "asc" {
  2120. asc = true
  2121. }
  2122. }
  2123. Id := this.GetString("Id")
  2124. SupplierName := this.GetString("SupplierName")
  2125. AccessCardNo := this.GetString("AccessCardNo")
  2126. SupplierTypeCode := this.GetString("SupplierTypeCode")
  2127. Code := this.GetString("Code")
  2128. Name := this.GetString("Name")
  2129. Conditions := this.GetString("Conditions")
  2130. IsDelete := this.GetString("IsDelete")
  2131. CreateOn := this.GetString("CreateOn")
  2132. CreateUserId := this.GetString("CreateUserId")
  2133. CreateBy := this.GetString("CreateBy")
  2134. ModifiedOn := this.GetString("ModifiedOn")
  2135. ModifiedUserId := this.GetString("ModifiedUserId")
  2136. ModifiedBy := this.GetString("ModifiedBy")
  2137. if Id != "" {
  2138. where = where + " and Id like '%" + Id + "%'"
  2139. }
  2140. if SupplierName != "" {
  2141. where = where + " and SupplierName like '%" + SupplierName + "%'"
  2142. }
  2143. if AccessCardNo != "" {
  2144. where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
  2145. }
  2146. if SupplierTypeCode != "" {
  2147. where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'"
  2148. }
  2149. if Code != "" {
  2150. where = where + " and Code like '%" + Code + "%'"
  2151. }
  2152. if Name != "" {
  2153. where = where + " and Name like '%" + Name + "%'"
  2154. }
  2155. if Conditions == "2"{
  2156. where = where + " and MinClassId = '0'"
  2157. } else if Conditions == "3"{
  2158. where = where + " and Checked = '0'"
  2159. } else if Conditions == "4"{
  2160. where = where + " and Checked = '1"
  2161. }
  2162. if IsDelete != "" {
  2163. where = where + " and IsDelete like '%" + IsDelete + "%'"
  2164. }
  2165. if CreateUserId != "" {
  2166. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  2167. }
  2168. if CreateBy != "" {
  2169. where = where + " and CreateBy like '%" + CreateBy + "%'"
  2170. }
  2171. if ModifiedOn != "" {
  2172. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  2173. }
  2174. if ModifiedUserId != "" {
  2175. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  2176. }
  2177. if ModifiedBy != "" {
  2178. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  2179. }
  2180. if CreateOn != "" {
  2181. dates := strings.Split(CreateOn, ",")
  2182. if len(dates) == 2 {
  2183. minDate := dates[0]
  2184. maxDate := dates[1]
  2185. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  2186. }
  2187. }
  2188. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  2189. var list2 []supplier.OilSupplierContrast
  2190. total := svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrast", page.CurrentPage, page.Size, orderby, asc, &list2, where)
  2191. var datainfo DataInfo
  2192. datainfo.Items = list2
  2193. datainfo.CurrentItemCount = total
  2194. datainfo.PageIndex = page.CurrentPage
  2195. datainfo.ItemsPerPage = page.Size
  2196. this.Data["json"] = &datainfo
  2197. this.ServeJSON()
  2198. }
  2199. // @Title 确认更新后的待删除准入范围列表
  2200. // @Description get compare tmp supplier
  2201. // @Success 200 {object} []supplier.OilSupplierSelect
  2202. // @router /get-delete-supplier [get]
  2203. func (this *OilGoodsAptitudeController) GetDeleteSupplier() {
  2204. //获取分页信息
  2205. page := this.GetPageInfoForm()
  2206. where := " 1=1 "
  2207. orderby := "Id"
  2208. asc := false
  2209. Order := this.GetString("Order")
  2210. Prop := this.GetString("Prop")
  2211. if Order != "" && Prop != "" {
  2212. orderby = Prop
  2213. if Order == "asc" {
  2214. asc = true
  2215. }
  2216. }
  2217. Id := this.GetString("Id")
  2218. SupplierId := this.GetString("SupplierId")
  2219. SupplierCertId := this.GetString("SupplierCertId")
  2220. SupplierTypeCode := this.GetString("SupplierTypeCode")
  2221. Code := this.GetString("Code")
  2222. Name := this.GetString("Name")
  2223. Remark := this.GetString("Remark")
  2224. IsDelete := this.GetString("IsDelete")
  2225. CreateOn := this.GetString("CreateOn")
  2226. CreateUserId := this.GetString("CreateUserId")
  2227. CreateBy := this.GetString("CreateBy")
  2228. ModifiedOn := this.GetString("ModifiedOn")
  2229. ModifiedUserId := this.GetString("ModifiedUserId")
  2230. ModifiedBy := this.GetString("ModifiedBy")
  2231. if Id != "" {
  2232. where = where + " and Id like '%" + Id + "%'"
  2233. }
  2234. if SupplierId != "" {
  2235. where = where + " and SupplierId like '%" + SupplierId + "%'"
  2236. }
  2237. if SupplierCertId != "" {
  2238. where = where + " and SupplierCertId = '" + SupplierCertId + "'"
  2239. }
  2240. if SupplierTypeCode != "" {
  2241. where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'"
  2242. }
  2243. if Code != "" {
  2244. where = where + " and Code like '%" + Code + "%'"
  2245. }
  2246. if Name != "" {
  2247. where = where + " and Name like '%" + Name + "%'"
  2248. }
  2249. if Remark != "" {
  2250. where = where + " and Remark like '%" + Remark + "%'"
  2251. }
  2252. if IsDelete != "" {
  2253. where = where + " and IsDelete like '%" + IsDelete + "%'"
  2254. }
  2255. if CreateUserId != "" {
  2256. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  2257. }
  2258. if CreateBy != "" {
  2259. where = where + " and CreateBy like '%" + CreateBy + "%'"
  2260. }
  2261. if ModifiedOn != "" {
  2262. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  2263. }
  2264. if ModifiedUserId != "" {
  2265. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  2266. }
  2267. if ModifiedBy != "" {
  2268. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  2269. }
  2270. if CreateOn != "" {
  2271. dates := strings.Split(CreateOn, ",")
  2272. if len(dates) == 2 {
  2273. minDate := dates[0]
  2274. maxDate := dates[1]
  2275. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  2276. }
  2277. }
  2278. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  2279. var list2 []supplier.OilSupplierContrast
  2280. total := svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrastNew", page.CurrentPage, page.Size, orderby, asc, &list2, where)
  2281. var datainfo DataInfo
  2282. datainfo.Items = list2
  2283. datainfo.CurrentItemCount = total
  2284. datainfo.PageIndex = page.CurrentPage
  2285. datainfo.ItemsPerPage = page.Size
  2286. this.Data["json"] = &datainfo
  2287. this.ServeJSON()
  2288. }
  2289. // @Title 导出到execl
  2290. // @Description 导出到execl
  2291. // @Success 200 {object} controllers.Request
  2292. // @router /exportexecl [post]
  2293. func (this *OilGoodsAptitudeController) ExeclExport() {
  2294. // 填物资类信息表首页信息
  2295. svcActiviti := workflow.GetActivitiService(utils.DBE)
  2296. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  2297. var list2 []supplier.OilSupplierContrast
  2298. where := " 1=1"
  2299. svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrast", 0,0, "Id", false, &list2, where)
  2300. fileName := "资质导入对比表.xlsx"
  2301. Url := utils.Cfg.MustValue("workflow", "ContrastExcel")
  2302. var datamap = make(map[string]interface{})
  2303. datamap["data"] = list2
  2304. retDocUrl := svcActiviti.ContrastExcel(datamap, Url, fileName)
  2305. var datainfo ErrorDataInfo
  2306. datainfo.Code = 0
  2307. datainfo.Item = retDocUrl
  2308. datainfo.Message = "打印成功"
  2309. this.Data["json"] = &datainfo
  2310. this.ServeJSON()
  2311. }
  2312. // @Title 修改资质后找出不符合的准入
  2313. // @Description 修改实体
  2314. // @Success 200 {object} controllers.Request
  2315. // @router /findinconformity [post]
  2316. func (this *OilGoodsAptitudeController) FindInconformity() {
  2317. var errinfo ErrorInfo
  2318. var err error
  2319. var model goodsaptitude.OilGoodsAptitude_2
  2320. var companygoodslist []suppliercertsub.OilSupplierCertSub
  2321. var companygood suppliercertsub.OilSupplierCertSub
  2322. var SurplusList1 []supplierfile.FileList
  2323. var SurplusList2 []supplierfile.FileList
  2324. var supfilemodel []supplierfile.OilSupplierFile
  2325. var supfilemodel01 []supplierfile.OilSupplierFile
  2326. var supfilemodel02 []supplierfile.OilSupplierFile
  2327. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  2328. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  2329. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  2330. var jsonBlob = this.Ctx.Input.RequestBody
  2331. json.Unmarshal(jsonBlob, &model)
  2332. Code := model.Code
  2333. where := " Code ='" + Code + "' and Type in ('1','3') and SupplierTypeCode = '01'"
  2334. svc.FindGoodsByCode("OilSupplierCertSub", where, &companygoodslist)
  2335. SurplusList1 = filesvc.GetGoodsNeedFileList(strconv.Itoa(model.ClassId), "1")
  2336. SurplusList2 = filesvc.GetGoodsNeedFileList(strconv.Itoa(model.ClassId), "2")
  2337. for _, CertSub := range companygoodslist {
  2338. companygood = CertSub
  2339. wherecompany := " SupplierId =" + strconv.Itoa(CertSub.SupplierId)
  2340. svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel)
  2341. if len(supfilemodel) < 1 {
  2342. _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  2343. } else {
  2344. var tmplist1 []suppliercertsub.Tmp_OilSupplierCertSub
  2345. wherecompany = " Id =" + strconv.Itoa(CertSub.Id)
  2346. svc.FindFileByCompany("tmp_OilSupplierCertSub", wherecompany, &tmplist1)
  2347. if len(tmplist1) < 1 {
  2348. wherecompany = " SupplierId ='" + strconv.Itoa(CertSub.SupplierId) + "' and IsManuf in ('0','1')"
  2349. svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel01)
  2350. var File01 string
  2351. for _, Filesub := range supfilemodel01 {
  2352. File01 = File01 + Filesub.NeedFileType + ","
  2353. }
  2354. for _, Filesub := range SurplusList1 {
  2355. var supplierModel supplier.OilSupplier
  2356. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  2357. svcSupplier.GetEntityById(strconv.Itoa(CertSub.SupplierId), &supplierModel)
  2358. //三证合一或五证合一不需要的字段
  2359. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  2360. File01 = mergerCertSkipField + File01
  2361. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(File01, Filesub.FileName+",") { //三证合一或五证合一了
  2362. continue
  2363. }
  2364. if strings.Contains(File01, Filesub.FileName+",") {
  2365. continue
  2366. }
  2367. _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  2368. break
  2369. }
  2370. }
  2371. var tmplist2 []suppliercertsub.Tmp_OilSupplierCertSub
  2372. wherecompany = " Id =" + strconv.Itoa(CertSub.Id)
  2373. svc.FindFileByCompany("tmp_OilSupplierCertSub", wherecompany, &tmplist2)
  2374. if len(tmplist2) < 1 {
  2375. wherecompany = " SupplierId ='" + strconv.Itoa(CertSub.SupplierId) + "' and IsManuf in ('0','2')"
  2376. svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel02)
  2377. var File02 string
  2378. for _, Filesub := range supfilemodel02 {
  2379. File02 = File02 + Filesub.NeedFileType + ","
  2380. }
  2381. for _, Filesub := range SurplusList2 {
  2382. var supplierModel supplier.OilSupplier
  2383. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  2384. svcSupplier.GetEntityById(strconv.Itoa(CertSub.SupplierId), &supplierModel)
  2385. //三证合一或五证合一不需要的字段
  2386. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  2387. File02 = mergerCertSkipField + File02
  2388. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(File02, Filesub.FileName+",") { //三证合一或五证合一了
  2389. continue
  2390. }
  2391. if strings.Contains(File02, Filesub.FileName+",") {
  2392. continue
  2393. }
  2394. _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  2395. break
  2396. }
  2397. }
  2398. }
  2399. var entity supplier.OilSupplier
  2400. wherec := "Id=" + strconv.Itoa(CertSub.SupplierId)
  2401. svc.GetEntity(&entity, wherec)
  2402. if model.GoodsLevel == "1" && entity.Grade == "2" {
  2403. svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  2404. } else {
  2405. var certsub suppliercertsub.OilSupplierCertSub
  2406. certsub.GoodsLevel = model.GoodsLevel
  2407. cols := []string{"GoodsLevel"}
  2408. where := "Id=" + strconv.Itoa(CertSub.Id)
  2409. svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &certsub, cols, where)
  2410. }
  2411. }
  2412. if err == nil {
  2413. errinfo.Message = "已拉取缺失资质列表!"
  2414. errinfo.Code = 0
  2415. this.Data["json"] = &errinfo
  2416. this.ServeJSON()
  2417. } else {
  2418. errinfo.Message = "拉取列表失败!" + utils.AlertProcess(err.Error())
  2419. errinfo.Code = -1
  2420. this.Data["json"] = &errinfo
  2421. this.ServeJSON()
  2422. }
  2423. }
  2424. // @Title get 导入excel对比差异
  2425. // @Description get SampleType by token
  2426. // @Success 200 {object} sampletype.SampleType
  2427. // @router /oilcompare [get]
  2428. func (this *OilGoodsAptitudeController) OilCompare() {
  2429. url := this.GetString("ExcelUrl")
  2430. inputcode := this.GetString("Code")
  2431. inputname := this.GetString("CompanyName")
  2432. session := utils.DBE.NewSession()
  2433. err := session.Begin()
  2434. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  2435. timeUnixNano := strconv.FormatInt(int64(time.Now().UnixNano()), 10)
  2436. _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
  2437. utils.DownloadFile(url, timeUnixNano+".xlsx", _dir)
  2438. filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + timeUnixNano + ".xlsx"
  2439. xlFile, err := xlsx.OpenFile(filePath)
  2440. //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
  2441. if err != nil {
  2442. fmt.Printf("open failed: %s\n", err)
  2443. }
  2444. var sheet = xlFile.Sheets[0]
  2445. defer func() {
  2446. session.Close()
  2447. }()
  2448. var Comparelist []suppliercertsub.OilCompare
  2449. var Comparelistnow []suppliercertsub.OilCompare
  2450. var Compare suppliercertsub.OilCompare
  2451. var CompanyName string
  2452. for i := 2; i < len(sheet.Rows); i++ {
  2453. if inputcode != "" && inputcode != sheet.Rows[i].Cells[0].Value{
  2454. continue
  2455. }
  2456. if inputname !="" && inputname != sheet.Rows[i].Cells[4].Value {
  2457. continue
  2458. }
  2459. var List []supplier.OilSupplier
  2460. CompanyName = sheet.Rows[i].Cells[4].Value
  2461. where := "SupplierName = '" + CompanyName + "'"
  2462. svc.GetEntitysByWhere(OilSupplierName, where, &List)
  2463. Compare.SortCoding = sheet.Rows[i].Cells[0].Value
  2464. Compare.SortName = sheet.Rows[i].Cells[1].Value
  2465. Compare.Level = sheet.Rows[i].Cells[2].Value
  2466. //Compare.SupplierCode = sheet.Rows[i].Cells[3].Value
  2467. Compare.SupplierName = sheet.Rows[i].Cells[4].Value
  2468. //Compare.SurplusCount = sheet.Rows[i].Cells[5].Value
  2469. Compare.ManagementUnitType = sheet.Rows[i].Cells[6].Value
  2470. //Compare.EliminationCause = sheet.Rows[i].Cells[7].Value
  2471. //Compare.AccessList = sheet.Rows[i].Cells[8].Value
  2472. //Compare.SupplierSubTime = sheet.Rows[i].Cells[9].Value
  2473. //Compare.ProductType = sheet.Rows[i].Cells[10].Value
  2474. //Compare.Editor = sheet.Rows[i].Cells[11].Value
  2475. //Compare.EditingTime = sheet.Rows[i].Cells[12].Value
  2476. //Compare.FlowState = sheet.Rows[i].Cells[13].Value
  2477. //Compare.ProcessNotes = sheet.Rows[i].Cells[14].Value
  2478. //Compare.Reviewime = sheet.Rows[i].Cells[15].Value
  2479. //Compare.Brand = sheet.Rows[i].Cells[16].Value
  2480. //Compare.WorkCode = sheet.Rows[i].Cells[17].Value
  2481. //Compare.WorkType = sheet.Rows[i].Cells[18].Value
  2482. //Compare.ProductScope = sheet.Rows[i].Cells[19].Value
  2483. //Compare.IsBid = sheet.Rows[i].Cells[20].Value
  2484. //Compare.MoreInfo = sheet.Rows[i].Cells[21].Value
  2485. //Compare.ManufacturerCode = sheet.Rows[i].Cells[22].Value
  2486. //Compare.ManufacturerName = sheet.Rows[i].Cells[23].Value
  2487. Compare.Diff = "0"
  2488. if len(List) < 1 {
  2489. Compare.Diff = "1"
  2490. Comparelist = append(Comparelist, Compare)
  2491. }
  2492. if len(List) > 0 {
  2493. var certsublist2 []suppliercertsub.OilSupplierCertSub
  2494. namewhere := "SupplierId = '" + strconv.Itoa(List[0].Id) + "' and Code ='" + Compare.SortCoding + "' and SupplierTypeCode ='01'"
  2495. svc.GetEntitysByWhere(OilSupplierCertSubName, namewhere, &certsublist2)
  2496. if len(certsublist2) < 1 {
  2497. Compare.Diff = "1"
  2498. Comparelist = append(Comparelist, Compare)
  2499. }
  2500. }
  2501. if Compare.Diff == "0" {
  2502. Comparelistnow = append(Comparelistnow,Compare)
  2503. }
  2504. }
  2505. for _,nowlist := range Comparelistnow {
  2506. Comparelist = append(Comparelist,nowlist)
  2507. }
  2508. os.Remove(filePath)
  2509. var datainfo DataInfo
  2510. datainfo.Items = Comparelist
  2511. this.Data["json"] = &datainfo
  2512. this.ServeJSON()
  2513. }
  2514. // @Title 导出数据到word,作为导出pdf的中间步骤
  2515. // @Description 数据存入word
  2516. // @Success 200 {object} controllers.Request
  2517. // @router /exportpdf/:tbid/:typecode [post]
  2518. func (this *OilGoodsAptitudeController) PdfExport() {
  2519. Id := this.Ctx.Input.Param(":tbid")
  2520. SupplierTypeCode := this.Ctx.Input.Param(":typecode")
  2521. var Url string
  2522. var fileName string
  2523. var model1 supplierdataentry.SupplierDataEntry
  2524. var model2 supplierdataentry.SupplierCertDataEntry
  2525. svc := supplierdataentry.GetSupplierDataEntryService(utils.DBE)
  2526. where1 := "1=1"
  2527. where1 += " AND Id = '" + Id + "'"
  2528. where2 := "SupplierId = '" + Id + "' and SupplierTypecode='"+ SupplierTypeCode +"'"
  2529. svc.GetEntityByWhere(OilSupplierName, where1, &model1)
  2530. svc.GetEntityByWhere(OilSupplierCertName, where2, &model2)
  2531. var tabledata []supplierdataentry.SupplierCertSubEntry
  2532. where3:="SupplierId = '" + Id + "' and SupplierTypecode='"+ SupplierTypeCode +"' and Type in ('1','3')"//准入状态的准入项
  2533. svc.GetEntitysByOrderbyWhere(TmpOilSupplierCertSubName, where3, "1", &tabledata)
  2534. datamap := structToMapDemo(model1.OilSupplier)
  2535. if model2.SupplierTypeCode == "01" {
  2536. Url = utils.Cfg.MustValue("workflow", "goodsPdfHost")
  2537. fileName = "待删除物资类准入范围.docx"
  2538. } else if model2.SupplierTypeCode == "02" {
  2539. Url = utils.Cfg.MustValue("workflow", "basisPdfHost")
  2540. fileName = "待删除基建类准入范围.docx"
  2541. datamap["TJInNotify"] = model1.TJInNotify
  2542. } else {
  2543. Url = utils.Cfg.MustValue("workflow", "techPdfHost")
  2544. fileName = "待删除服务类准入范围.docx"
  2545. }
  2546. //model1
  2547. datamap["SetupTime"] = model1.SetupTime.Format("2006年01月02日")
  2548. datamap["QualifCert"] = model1.QualifCert
  2549. datamap["QualifCertLevel"] = model1.QualifCertLevel
  2550. datamap["SpecIndustryCert"] = model1.SpecIndustryCert
  2551. datamap["MaunLicense"] = model1.MaunLicense
  2552. if model1.HseTraining == "1" {
  2553. datamap["HseTraining"] = "是"
  2554. } else {
  2555. datamap["HseTraining"] = "否"
  2556. }
  2557. if model1.OperType != "" {
  2558. if model1.OperType == "1" || model1.OperType == "制造商"{
  2559. datamap["OperType"] = "√制造商 □代理商 □贸易商"
  2560. }else if model1.OperType == "2" || model1.OperType == "代理商"{
  2561. datamap["OperType"] = "□制造商 √代理商 □贸易商"
  2562. }else if model1.OperType == "3" || model1.OperType == "代理商"{
  2563. datamap["OperType"] = "□制造商 □代理商 √贸易商"
  2564. }else {
  2565. datamap["OperType"] = "□制造商 □代理商 □贸易商"
  2566. }
  2567. }
  2568. if model1.SpecTypeCode != "" {
  2569. if model1.SpecTypeCode == "1"{
  2570. datamap["SpecTypeCode"] = "√一般外部 □多元企业"
  2571. }else if model1.SpecTypeCode == "2"{
  2572. datamap["SpecTypeCode"] = "□一般外部 √多元企业"
  2573. }else {
  2574. datamap["SpecTypeCode"] = "□一般外部 □多元企业"
  2575. }
  2576. }
  2577. if model1.Grade == "1"{
  2578. datamap["Grade"] = "一级"
  2579. }else if model1.SpecTypeCode == "2"{
  2580. datamap["Grade"] = "二级"
  2581. }
  2582. datamap["Fax"] = model1.Fax
  2583. datamap["CompanyTel"] = model1.CompanyTel
  2584. datamap["SupplierName"] = model1.SupplierName
  2585. datamap["Country"] = model1.Country
  2586. datamap["MaunAgent"] = model1.MaunAgent
  2587. datamap["SupplierCertificate"] = model1.SupplierCertificate
  2588. datamap["MgrUnit"] = model1.MgrUnit
  2589. datamap["CommercialNo"] = model1.CommercialNo
  2590. datamap["CountryTaxNo"] = model1.CountryTaxNo
  2591. datamap["OrganCode"] = model1.OrganCode
  2592. datamap["Address"] = model1.Address
  2593. datamap["ZipCode"] = model1.ZipCode
  2594. datamap["LinkAddress"] = model1.LinkAddress
  2595. datamap["LinkZipCode"] = model1.LinkZipCode
  2596. datamap["QualitySystemCert"] = model1.QualitySystemCert
  2597. datamap["ProductQualityCert"] = model1.ProductQualityCert
  2598. datamap["MaunLicense"] = model1.MaunLicense
  2599. datamap["LegalPerson"] = model1.LegalPerson
  2600. datamap["CompanyType"] = model1.CompanyType
  2601. datamap["ContactName"] = model1.ContactName
  2602. datamap["RegCapital"] = strconv.FormatFloat(model1.RegCapital,'f',2,64)+"万元"+model1.Currency
  2603. datamap["DepositBank"] = model1.DepositBank
  2604. datamap["BankAccount"] = model1.BankAccount
  2605. datamap["Mobile"] = model1.Mobile
  2606. datamap["EMail"] = model1.EMail
  2607. datamap["BankCreditRating"] = model1.BankCreditRating
  2608. datamap["BusinessScope"] = model1.BusinessScope
  2609. datamap["Telphone"] = model1.Telphone
  2610. datamap["AccessCardNo"] = model2.AccessCardNo
  2611. datamap["PrintYear"] = time.Now().Year()
  2612. datamap["PrintMonth"] = time.Now().Month()
  2613. datamap["PrintDay"] = time.Now().Day()
  2614. datamap["Name"] = ""
  2615. if len(tabledata) != 0 {
  2616. var Name string
  2617. Name = "\n待删除准入范围:"+ tabledata[0].Code
  2618. Name = Name + " " + tabledata[0].Name
  2619. var i int
  2620. for i = 1; i < len(tabledata); i++ {
  2621. Name += ";"
  2622. Name += tabledata[i].Code
  2623. Name = Name + " " + tabledata[i].Name
  2624. }
  2625. //if i == 100 {
  2626. // Name += "(准入范围未完全显示,请到系统查看详情)"
  2627. //}
  2628. datamap["Name"] =datamap["Name"].(string) + Name
  2629. } else {
  2630. datamap["Name"] =datamap["Name"].(string)
  2631. }
  2632. svcActiviti := workflow.GetActivitiService(utils.DBE)
  2633. retDocUrl := svcActiviti.FillWordTemplate(datamap, Url, fileName)
  2634. var datainfo ErrorDataInfo
  2635. datainfo.Code = 0
  2636. datainfo.Item = retDocUrl
  2637. datainfo.Message = "准备导出"
  2638. this.Data["json"] = &datainfo
  2639. this.ServeJSON()
  2640. }
  2641. // @Title 确认更新后的删除/暂停企业准入范围 2020-12-18
  2642. // @Description 修改实体
  2643. // @Success 200 {object} controllers.Request
  2644. // @router /delete-suspend [post]
  2645. func (this *OilGoodsAptitudeController) DeleteSuspend() {
  2646. var errinfo ErrorInfo
  2647. var err error
  2648. var list []supplier.OilSupplierContrast
  2649. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  2650. //svc.GetEntitysByWhere("OilSupplierContrast", "TwoOneCount = 0", &list)
  2651. svc.GetEntitysByWhere("OilSupplierContrast", "1=1", &list)
  2652. for _,item := range list{
  2653. var sub []suppliercertsub.OilSupplierCertSub
  2654. svc.GetEntitysByWhere("OilSupplierCertSub", "SupplierTypeCode = '01' and SupplierId = " + strconv.Itoa(item.Id), &sub)
  2655. for _, itemSub := range sub {
  2656. 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)) AS Codes,a.GoodsLevel,class.Name FROM OilGoodsAptitude a LEFT JOIN OilGoodsAptitudeClass class ON a.ClassId = class.Id"
  2657. sql += " where class.Code = '"+ itemSub.Code + "'"
  2658. model, _ := svc.DBE.QueryString(sql)
  2659. var subDelete suppliercertsub.OilSupplierCertSub1
  2660. if model != nil {
  2661. code := strings.Split(model[0]["Codes"], ",")
  2662. cols := []string{"GoodsLevel", "Name"}
  2663. subDelete.GoodsLevel = model[0]["GoodsLevel"]
  2664. subDelete.Name = model[0]["Name"]
  2665. //2升1不变
  2666. if model[0]["GoodsLevel"] == "1" && itemSub.GoodsLevel == "2" {
  2667. colsC := []string{"IsDelete"}
  2668. colsS := []string{"IsQuestion"}
  2669. item.IsDelete = 1
  2670. itemSub.IsQuestion = 1
  2671. svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &itemSub, colsS, "Id = "+strconv.Itoa(itemSub.Id))
  2672. svc.UpdateEntityBywheretbl("OilSupplierContrast", &item, colsC, "Id = "+strconv.Itoa(item.Id))
  2673. continue
  2674. }
  2675. // 1降2修改
  2676. if item.OneTwoCount > 0 {
  2677. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id))
  2678. }
  2679. cols = append(cols, "DueTime")
  2680. cols = append(cols, "CertSubStatus")
  2681. subDelete.CertSubStatus = "2"
  2682. //subDelete.DueTime = "2021-06-06 00:00:00"
  2683. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  2684. DueTimeStr := paramSvc.GetBaseparameterMessage("GFZT", "paramset", "Suspend")
  2685. //fmt.Println("返回的时间", DueTimeStr)
  2686. //local, _ := time.LoadLocation("Local")
  2687. //theTime, _ := time.ParseInLocation("2006-01-02", DueTimeStr, local)
  2688. currentTime := time.Now()
  2689. days,_ := strconv.Atoi(DueTimeStr)
  2690. subDelete.DueTime = currentTime.AddDate(0, 0, days)
  2691. i := 1
  2692. //暂停
  2693. for _, value := range code {
  2694. if i == 36 || i == 37 || i == 1 {
  2695. if (code[0] == "1" && strings.Index(item.HeaderCodes, "F01") < 0) && (code[35] == "1" && strings.Index(item.HeaderCodes, "F36") < 0) && (code[36] == "1" && strings.Index(item.HeaderCodes, "F37") < 0) {
  2696. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
  2697. var model1 supplierpausereason.OilSupplierPauseReason
  2698. model1.SupplierId = item.Id
  2699. model1.CertSubId = itemSub.Id
  2700. model1.CertSubStatus = "2"
  2701. model1.SupplierCertId = itemSub.SupplierCertId
  2702. model1.BackReason = "老数据导入缺资质"
  2703. model1.CreateOn = time.Now()
  2704. model1.CreateBy = this.User.Realname
  2705. model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  2706. svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
  2707. break
  2708. }
  2709. } else if i > 10 {
  2710. if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
  2711. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
  2712. var model1 supplierpausereason.OilSupplierPauseReason
  2713. model1.SupplierId = item.Id
  2714. model1.CertSubId = itemSub.Id
  2715. model1.CertSubStatus = "2"
  2716. model1.SupplierCertId = itemSub.SupplierCertId
  2717. model1.BackReason = "老数据导入缺资质"
  2718. model1.CreateOn = time.Now()
  2719. model1.CreateBy = this.User.Realname
  2720. model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  2721. svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
  2722. break
  2723. }
  2724. } else {
  2725. if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
  2726. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
  2727. var model1 supplierpausereason.OilSupplierPauseReason
  2728. model1.SupplierId = item.Id
  2729. model1.CertSubId = itemSub.Id
  2730. model1.CertSubStatus = "2"
  2731. model1.SupplierCertId = itemSub.SupplierCertId
  2732. model1.BackReason = "老数据导入缺资质"
  2733. model1.CreateOn = time.Now()
  2734. model1.CreateBy = this.User.Realname
  2735. model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  2736. svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
  2737. break
  2738. }
  2739. }
  2740. i += 1
  2741. }
  2742. } else {
  2743. // 删除
  2744. err = svc.DeleteEntityById(itemSub.Id, &subDelete)
  2745. }
  2746. }
  2747. if item.TwoOneCount == 0 {
  2748. err = svc.DeleteTable("OilSupplierContrast", "Id = " + strconv.Itoa(item.Id))
  2749. }
  2750. }
  2751. if err == nil {
  2752. errinfo.Message = "修改成功!"
  2753. errinfo.Code = 0
  2754. this.Data["json"] = &errinfo
  2755. this.ServeJSON()
  2756. } else {
  2757. errinfo.Message = "修改失败!"
  2758. errinfo.Code = -1
  2759. this.Data["json"] = &errinfo
  2760. this.ServeJSON()
  2761. }
  2762. }