| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163 |
- package oilsupplier
- import (
- "dashoo.cn/backend/api/business/oilsupplier/supplier"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
- "dashoo.cn/backend/api/business/oilsupplier/supplierdataentry"
- "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
- "dashoo.cn/backend/api/business/oilsupplier/supplierpausereason"
- "dashoo.cn/backend/api/business/oilsupplier/tableheader"
- "encoding/json"
- "fmt"
- "github.com/tealeg/xlsx"
- "log"
- "os"
- "reflect"
- "strconv"
- "strings"
- "time"
- "dashoo.cn/backend/api/business/oilsupplier/goodsaptitudeclass"
- "dashoo.cn/backend/api/business/items"
- "dashoo.cn/backend/api/business/baseUser"
- "dashoo.cn/backend/api/business/oilsupplier/goodsaptitude"
- "dashoo.cn/backend/api/business/workflow"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/business2/parameter"
- "dashoo.cn/business2/userRole"
- "dashoo.cn/utils"
- . "github.com/linxGnu/goseaweedfs"
- )
- type OilGoodsAptitudeController struct {
- BaseController
- }
- func structToMapDemo(obj interface{}) map[string]interface{} {
- obj1 := reflect.TypeOf(obj)
- obj2 := reflect.ValueOf(obj)
- var data = make(map[string]interface{})
- for i := 0; i < obj1.NumField(); i++ {
- data[obj1.Field(i).Name] = obj2.Field(i).Interface()
- }
- return data
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []goodsaptitude.OilGoodsAptitude
- // @router /list [get]
- func (this *OilGoodsAptitudeController) GetEntityList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Code"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- } else {
- asc = false
- }
- }
- Edition := this.GetString("Edition")
- CreateOn := this.GetString("CreateOn")
- Code := this.GetString("Code")
- Name := this.GetString("Name")
- BigClassName := this.GetString("BigClassName")
- BigClassCode := this.GetString("BigClassCode")
- MiddleClassName := this.GetString("MiddleClassName")
- SmallClassName := this.GetString("SmallClassName")
- GoodsName := this.GetString("GoodsName")
- GoodsLevel := this.GetString("GoodsLevel")
- GoodsDesc := this.GetString("GoodsDesc")
- Standard := this.GetString("Standard")
- CompanyType := this.GetString("CompanyType")
- if Edition != "" {
- where = where + " and Edition = '" + Edition + "'"
- }
- if Code != "" {
- where = where + " and Code like '%" + Code + "%'"
- }
- if Name != "" {
- where = where + " and Name like '%" + Name + "%'"
- }
- if BigClassName != "" {
- where = where + " and Name1 like '%" + BigClassName + "%'"
- }
- if BigClassCode != "" {
- where = where + " and Code1 like '%" + BigClassCode + "%'"
- }
- if MiddleClassName != "" {
- where = where + " and Name2 like '%" + MiddleClassName + "%'"
- }
- if SmallClassName != "" {
- where = where + " and Name3 like '%" + SmallClassName + "%'"
- }
- if GoodsName != "" {
- where = where + " and Name4 like '%" + GoodsName + "%'"
- }
- if GoodsLevel != "" {
- where = where + " and GoodsLevel like '%" + GoodsLevel + "%'"
- }
- if GoodsDesc != "" {
- where = where + " and GoodsDesc like '%" + GoodsDesc + "%'"
- }
- if Standard != "" {
- where = where + " and Standard '%" + Standard + "%'"
- }
- if CompanyType != "" {
- where = where + " and CompanyType '%" + CompanyType + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
- }
- }
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list []goodsaptitude.OilGoodsAptitudeView
- total := svc.GetMyPagingEntitiesWithOrderBytbl(OilGoodsAptDetailViewName, page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取列表新导入的列表
- // @Description get user by token
- // @Success 200 {object} []goodsaptitude.OilGoodsAptitude
- // @router /importlist [get]
- func (this *OilGoodsAptitudeController) GetImportEntityList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Code"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- } else {
- asc = false
- }
- }
- Edition := this.GetString("Edition")
- CreateOn := this.GetString("CreateOn")
- Code := this.GetString("Code")
- Name := this.GetString("Name")
- BigClassName := this.GetString("BigClassName")
- BigClassCode := this.GetString("BigClassCode")
- MiddleClassName := this.GetString("MiddleClassName")
- SmallClassName := this.GetString("SmallClassName")
- GoodsName := this.GetString("GoodsName")
- GoodsLevel := this.GetString("GoodsLevel")
- GoodsDesc := this.GetString("GoodsDesc")
- Standard := this.GetString("Standard")
- CompanyType := this.GetString("CompanyType")
- if Edition != "" {
- where = where + " and Edition = '" + Edition + "'"
- }
- if Code != "" {
- where = where + " and Code like '%" + Code + "%'"
- }
- if Name != "" {
- where = where + " and Name like '%" + Name + "%'"
- }
- if BigClassName != "" {
- where = where + " and Name1 like '%" + BigClassName + "%'"
- }
- if BigClassCode != "" {
- where = where + " and Code1 like '%" + BigClassCode + "%'"
- }
- if MiddleClassName != "" {
- where = where + " and Name2 like '%" + MiddleClassName + "%'"
- }
- if SmallClassName != "" {
- where = where + " and Name3 like '%" + SmallClassName + "%'"
- }
- if GoodsName != "" {
- where = where + " and Name4 like '%" + GoodsName + "%'"
- }
- if GoodsLevel != "" {
- where = where + " and GoodsLevel like '%" + GoodsLevel + "%'"
- }
- if GoodsDesc != "" {
- where = where + " and GoodsDesc like '%" + GoodsDesc + "%'"
- }
- if Standard != "" {
- where = where + " and Standard '%" + Standard + "%'"
- }
- if CompanyType != "" {
- where = where + " and CompanyType '%" + CompanyType + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
- }
- }
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list []goodsaptitude.OilGoodsAptitudeView
- total := svc.GetMyPagingEntitiesWithOrderBytbl(ImportOilGoodsAptDetailViewName, page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []goodsaptitude.OilGoodsAptitude
- // @router /comparelist [get]
- func (this *OilGoodsAptitudeController) GetCompareList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Code"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- Conditions := this.GetString("Conditions")
- if Conditions == "1" {
- // 匹配上
- where += " and a.GoodsLevel = tmpa.GoodsLevel"
- } else if Conditions == "2" {
- // 1变2
- where += " and a.GoodsLevel < tmpa.GoodsLevel"
- } else if Conditions == "3" {
- // 2变1
- where += " and a.GoodsLevel > tmpa.GoodsLevel"
- } else if Conditions == "4" {
- // 旧表有新表没
- where += " and tmpb.Code is null"
- } else if Conditions == "5" {
- // 新表有,旧表没
- where += " and tmpb.Code is null"
- } else if Conditions == "6" {
- // code+资质+级别匹配
- 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))" +
- " 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))" +
- " 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))" +
- " 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))" +
- " 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))"
- }
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- } else {
- asc = false
- }
- }
- Edition := this.GetString("Edition")
- CreateOn := this.GetString("CreateOn")
- Code := this.GetString("Code")
- Name := this.GetString("Name")
- BigClassName := this.GetString("BigClassName")
- BigClassCode := this.GetString("BigClassCode")
- MiddleClassName := this.GetString("MiddleClassName")
- SmallClassName := this.GetString("SmallClassName")
- GoodsName := this.GetString("GoodsName")
- GoodsLevel := this.GetString("GoodsLevel")
- GoodsDesc := this.GetString("GoodsDesc")
- Standard := this.GetString("Standard")
- CompanyType := this.GetString("CompanyType")
- if Edition != "" {
- where = where + " and b.Edition = '" + Edition + "'"
- }
- if Code != "" {
- where = where + " and b.Code like '%" + Code + "%'"
- }
- if Name != "" {
- where = where + " and b.Name like '%" + Name + "%'"
- }
- if BigClassName != "" {
- where = where + " and Name1 like '%" + BigClassName + "%'"
- }
- if BigClassCode != "" {
- where = where + " and Code1 like '%" + BigClassCode + "%'"
- }
- if MiddleClassName != "" {
- where = where + " and Name2 like '%" + MiddleClassName + "%'"
- }
- if SmallClassName != "" {
- where = where + " and Name3 like '%" + SmallClassName + "%'"
- }
- if GoodsName != "" {
- where = where + " and Name4 like '%" + GoodsName + "%'"
- }
- if GoodsLevel != "" {
- where = where + " and GoodsLevel like '%" + GoodsLevel + "%'"
- }
- if GoodsDesc != "" {
- where = where + " and GoodsDesc like '%" + GoodsDesc + "%'"
- }
- if Standard != "" {
- where = where + " and Standard '%" + Standard + "%'"
- }
- if CompanyType != "" {
- where = where + " and CompanyType '%" + CompanyType + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
- }
- }
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list []goodsaptitude.OilGoodsAptitudeTmp
- total := svc.GetPClassEntities(page.CurrentPage, page.Size, orderby, asc, &list, where, Conditions)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取列表2019版本
- // @Description
- // @Success 200 {object}
- // @router /list_2019 [get]
- func (this *OilGoodsAptitudeController) GetEntityList_2019() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Code"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- } else {
- asc = false
- }
- }
- Edition := this.GetString("Edition")
- Code := this.GetString("Code")
- Name := this.GetString("Name")
- if Edition != "" {
- where = where + " and a.Edition = '" + Edition + "'"
- }
- if Code != "" {
- where = where + " and b.Code like '%" + Code + "%'"
- }
- if Name != "" {
- where = where + " and b.Name like '%" + Name + "%'"
- }
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list []goodsaptitude.OilGoodsAptitude_2
- total := svc.GetList_2019(OilGoodsAptitudeName, OilGoodsAptitudeClassName, page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取字典列表
- // @Description get user by token
- // @Success 200 {object} map[string]interface{}
- // @router /dictlist [get]
- func (this *OilGoodsAptitudeController) GetDictList() {
- dictList := make(map[string]interface{})
- dictSvc := items.GetItemsService(utils.DBE)
- userSvc := baseUser.GetBaseUserService(utils.DBE)
- //customerSvc := svccustomer.GetCustomerService(utils.DBE)
- //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", "")
- var userEntity userRole.Base_User
- userSvc.GetEntityById(this.User.Id, &userEntity)
- dictList["Supervisers"] = userSvc.GetUserListByDepartmentId("", userEntity.Departmentid)
- dictList["AuditStep"] = dictSvc.GetKeyValueItems("AuditStep", this.User.AccCode)
- //var dictCustomer []svccustomer.Customer
- //customerSvc.GetEntitysByWhere("" + CustomerName, "", &dictCustomer)
- //dictList["EntrustCorp"] = &dictCustomer
- var datainfo DataInfo
- datainfo.Items = dictList
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} goodsaptitude.OilGoodsAptitude
- // @router /get/:id [get]
- func (this *OilGoodsAptitudeController) GetEntity() {
- Id := this.Ctx.Input.Param(":id")
- var model goodsaptitude.OilGoodsAptitudeView
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- //svc.GetEntityByIdBytbl(""+OilGoodsAptitudeName, Id, &model)
- where := " Id =" + Id
- svc.GetEntityByWhere(OilGoodsAptDetailViewName, where, &model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object}
- // @router /get_2019/:id [get]
- func (this *OilGoodsAptitudeController) GetEntity_2019() {
- Id := this.Ctx.Input.Param(":id")
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var tempMap []map[string]string
- 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,
- a.F11,a.F12,a.F13,a.F14,a.F15,a.F16,a.F17,a.F18,a.F19,a.F20,
- a.F21,a.F22,a.F23,a.F24,a.F25,a.F26,a.F27,a.F28,a.F29,a.F30,
- a.F31,a.F32,a.F33,a.F34,a.F35,a.F36,a.F37,a.F38,a.F39,a.F40,
- a.F41,a.F42,a.F43,a.F44,a.F45,a.F46,b.Code, b.Name `
- sql += ` from ` + OilGoodsAptitudeName + ` a `
- sql += ` left join ` + OilGoodsAptitudeClassName + " b on b.Id = a.ClassId"
- sql += ` where a.Id='` + Id + `'`
- tempMap, _ = svc.DBE.QueryString(sql)
- this.Data["json"] = &tempMap
- this.ServeJSON()
- }
- // @Title 添加
- // @Description 新增
- // @Success 200 {object} controllers.Request
- // @router /add [post]
- func (this *OilGoodsAptitudeController) AddEntity() {
- //ParentId := this.Ctx.Input.Param(":id")
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var model goodsaptitudeclass.OilGoodsAptitudeClass
- var classmodel goodsaptitudeclass.OilGoodsAptitudeClass
- var parentedId goodsaptitudeclass.ParentedId
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &parentedId)
- json.Unmarshal(jsonBlob, &model)
- var errinfo ErrorDataInfo
- where := " Code = " + model.Code
- code := svc.GetEntityByWhere(OilGoodsAptitudeClassName, where, &classmodel)
- if code {
- errinfo.Message = "编码不能重复!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- //where1 := " Name = " + model.Name
- //name := svc.GetEntityByWhere(OilGoodsAptitudeClassName, where1, &classmodel)
- //if name {
- // errinfo.Message = "名称不能重复!"
- // errinfo.Code = -1
- // this.Data["json"] = &errinfo
- // this.ServeJSON()
- // return
- //}
- model.ParentId = parentedId.ParentId
- model.Edition = "1"
- model.CreateOn = time.Now()
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- _, err := svc.InsertEntityBytbl(""+OilGoodsAptitudeClassName, &model)
- var model2 goodsaptitude.OilGoodsAptitude
- json.Unmarshal(jsonBlob, &model2)
- model2.ClassId = model.Id
- model2.Edition = "1"
- model2.CreateOn = time.Now()
- model2.CreateBy = this.User.Realname
- model2.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- _, err = svc.InsertEntityBytbl(""+OilGoodsAptitudeName, &model2)
- if err == nil {
- //新增
- errinfo.Message = "添加成功!"
- errinfo.Code = 0
- errinfo.Item = model2.Id
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 添加
- // @Description 新增
- // @Success 200 {object} controllers.Request
- // @router /add_2019 [post]
- func (this *OilGoodsAptitudeController) AddEntity_2019() {
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var model goodsaptitudeclass.OilGoodsAptitudeClass
- var jsonBlob = this.Ctx.Input.RequestBody
- var errinfo ErrorDataInfo
- json.Unmarshal(jsonBlob, &model)
- model.ParentId = -1
- model.Edition = "2"
- model.CreateOn = time.Now()
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- _, err := svc.InsertEntityBytbl(""+OilGoodsAptitudeClassName, &model)
- var model2 goodsaptitude.OilGoodsAptitude
- json.Unmarshal(jsonBlob, &model2)
- model2.ClassId = model.Id
- model2.Edition = "2"
- model2.CreateOn = time.Now()
- model2.CreateBy = this.User.Realname
- model2.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- _, err = svc.InsertEntityBytbl(""+OilGoodsAptitudeName, &model2)
- if err == nil {
- //新增
- errinfo.Message = "添加成功!"
- errinfo.Code = 0
- errinfo.Item = model2.Id
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 修改实体
- // @Description 修改实体
- // @Success 200 {object} controllers.Request
- // @router /update/:id [post]
- func (this *OilGoodsAptitudeController) UpdateEntity() {
- id := this.Ctx.Input.Param(":id")
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model goodsaptitude.OilGoodsAptitude
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &model)
- model.ModifiedOn = time.Now()
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- cols := []string{
- "Id",
- "Code",
- "Name",
- "BigClassName",
- "MiddleClassName",
- "SmallClassName",
- "GoodsName",
- "GoodsLevel",
- "GoodsDesc",
- "Standard",
- "CompanyType",
- "F01",
- "F02",
- "F03",
- "F04",
- "F05",
- "F06",
- "F07",
- "F08",
- "F09",
- "F10",
- "F11",
- "F12",
- "F13",
- "F14",
- "F15",
- "F16",
- "F17",
- "F18",
- "F19",
- "F20",
- "F21",
- "F22",
- "F23",
- "F24",
- "F25",
- "F26",
- "F27",
- "F28",
- "F29",
- "F30",
- "F31",
- "F32",
- "F33",
- "F34",
- "F35",
- "F36",
- "F37",
- "F38",
- "F39",
- "F40",
- "F41",
- "F42",
- "F43",
- "F44",
- "F45",
- "F46",
- "Remark",
- "DeletionStateCode",
- "CreateOn",
- "CreateUserId",
- "CreateBy",
- "ModifiedOn",
- "ModifiedUserId",
- "ModifiedBy",
- }
- err := svc.UpdateEntityBytbl(""+OilGoodsAptitudeName, id, &model, cols)
- if err == nil {
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 修改实体
- // @Description 修改实体
- // @Success 200 {object} controllers.Request
- // @router /update_2019/:id [post]
- func (this *OilGoodsAptitudeController) UpdateEntity_2019() {
- id := this.Ctx.Input.Param(":id")
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model goodsaptitude.OilGoodsAptitude
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &model)
- model.ModifiedOn = time.Now()
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- cols := []string{
- "F01",
- "F02",
- "F03",
- "F04",
- "F05",
- "F06",
- "F07",
- "F08",
- "F09",
- "F10",
- "F11",
- "F12",
- "F13",
- "F14",
- "F15",
- "F16",
- "F17",
- "F18",
- "F19",
- "F20",
- "F21",
- "F22",
- "F23",
- "F24",
- "F25",
- "F26",
- "F27",
- "F28",
- "F29",
- "F30",
- "F31",
- "F32",
- "F33",
- "F34",
- "F35",
- "F36",
- "F37",
- "F38",
- "F39",
- "F40",
- "F41",
- "F42",
- "F43",
- "F44",
- "F45",
- "F46",
- "ModifiedOn",
- "ModifiedUserId",
- "ModifiedBy",
- }
- err := svc.UpdateEntityBytbl(""+OilGoodsAptitudeName, id, &model, cols)
- var model2 goodsaptitudeclass.OilGoodsAptitudeClass
- json.Unmarshal(jsonBlob, &model2)
- model2.ModifiedOn = time.Now()
- model2.ModifiedBy = this.User.Realname
- model2.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- cols2 := []string{
- "Code",
- "Name",
- "ModifiedOn",
- "ModifiedUserId",
- "ModifiedBy",
- }
- err = svc.UpdateEntityBytbl(""+OilGoodsAptitudeClassName, model.ClassId, &model2, cols2)
- if err == nil {
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 修改实体
- // @Description 修改实体
- // @Success 200 {object} controllers.Request
- // @router /updatecode/:id [post]
- func (this *OilGoodsAptitudeController) UpdateCodeEntity() {
- var errinfo ErrorInfo
- var err error
- id := this.Ctx.Input.Param(":id")
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var classall goodsaptitude.OilGoodsAptitudeClassView
- var model goodsaptitudeclass.OilGoodsAptitudeClass
- var classmodel []goodsaptitudeclass.OilGoodsAptitudeClass
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &classall)
- model.ModifiedOn = time.Now()
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- colsName := []string{"Name"}
- colsCode := []string{"Code"}
- //svc.GetEntityById(id, &model)
- if classall.Name1 != "" {
- where := " Name = '" + classall.Name1 + "' and Id <> " + utils.ToStr(classall.Id1)
- svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
- if len(classmodel) > 0 {
- errinfo.Message = "大类名称已存在,请重新添加!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- } else {
- model.Name = classall.Name1
- err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id1, &model, colsName)
- }
- }
- if classall.Name2 != "" {
- where := " Name = '" + classall.Name2 + "' and Id <> " + utils.ToStr(classall.Id2)
- svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
- if len(classmodel) > 0 {
- errinfo.Message = "中类名称已存在,请重新添加!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- } else {
- model.Name = classall.Name2
- err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id2, &model, colsName)
- }
- }
- if classall.Name3 != "" {
- where := " Name = '" + classall.Name3 + "' and Id <> " + utils.ToStr(classall.Id3)
- svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
- if len(classmodel) > 0 {
- errinfo.Message = "小类名称已存在,请重新添加!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- } else {
- model.Name = classall.Name3
- err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id3, &model, colsName)
- }
- }
- if classall.Name4 != "" {
- where := " Name = '" + classall.Name4 + "' and Id <> " + utils.ToStr(classall.Id4)
- svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
- if len(classmodel) > 0 {
- errinfo.Message = "品名已存在,请重新添加!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- } else {
- model.Name = classall.Name4
- err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id4, &model, colsName)
- }
- }
- if classall.Code1 != "" {
- where := " Code = " + classall.Code1 + " and Id <> " + utils.ToStr(classall.Id1)
- svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
- if len(classmodel) > 0 {
- errinfo.Message = "大类编码已存在,请重新添加!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- } else {
- model.Code = classall.Code1
- err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id1, &model, colsCode)
- }
- }
- if classall.Code2 != "" {
- where := " Code = " + classall.Code2 + " and Id <> " + utils.ToStr(classall.Id2)
- svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
- if len(classmodel) > 0 {
- errinfo.Message = "中类编码已存在,请重新添加!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- } else {
- model.Code = classall.Code2
- err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id2, &model, colsCode)
- }
- }
- if classall.Code3 != "" {
- where := " Code = " + classall.Code3 + " and Id <> " + utils.ToStr(classall.Id3)
- svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
- if len(classmodel) > 0 {
- errinfo.Message = "小类编码已存在,请重新添加!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- } else {
- model.Code = classall.Code3
- err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id3, &model, colsCode)
- }
- }
- if classall.Code4 != "" {
- where := " Code = " + classall.Code4 + " and Id <> " + utils.ToStr(classall.Id4)
- svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
- if len(classmodel) > 0 {
- errinfo.Message = "品名编码已存在,请重新添加!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- } else {
- model.Code = classall.Code4
- err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id4, &model, colsCode)
- }
- }
- if err == nil {
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 删除单条信息
- // @Description
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /delete/:Id [delete]
- func (this *OilGoodsAptitudeController) DeleteEntity() {
- Id := this.Ctx.Input.Param(":Id")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model goodsaptitude.OilGoodsAptitude
- var entityempty goodsaptitude.OilGoodsAptitude
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- svc.GetEntityById(Id, &model)
- opdesc := "删除-" + Id
- err := svc.DeleteOperationAndWriteLogBytbl(""+OilGoodsAptitudeName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "物资类准入范围子表删除")
- var model1 goodsaptitudeclass.OilGoodsAptitudeClass
- var entityempty1 goodsaptitudeclass.OilGoodsAptitudeClass
- svc1 := goodsaptitudeclass.GetOilGoodsAptitudeClassService(utils.DBE)
- opdesc1 := "删除-" + strconv.Itoa(model.ClassId)
- err1 := svc1.DeleteOperationAndWriteLogBytbl(""+OilGoodsAptitudeClassName, BaseOperationLogName, strconv.Itoa(model.ClassId), &model1, &entityempty1, utils.ToStr(this.User.Id), this.User.Username, opdesc1, "", "物资类准入范围删除")
- if err == nil && err1 == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 删除企业的准入范围
- // @Description
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /deletelist/:Id [delete]
- func (this *OilGoodsAptitudeController) DeleteList() {
- Ids := this.Ctx.Input.Param(":Id")
- //Ids := this.GetString("deleteString")
- var errinfo ErrorInfo
- if Ids == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- idArr := strings.Split(Ids, ",")
- for _, id := range idArr {
- err := svc.DeleteEntityBytbl("OilSupplierCertSub", " SubClassId = " + id)
- if err == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- }
- // @Title 暂停企业的准入范围
- // @Description
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /changelist/:Id [get]
- func (this *OilGoodsAptitudeController) Changelist() {
- Ids := this.Ctx.Input.Param(":Id")
- //Ids := this.GetString("deleteString")
- var errinfo ErrorInfo
- if Ids == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model suppliercertsub.OilSupplierCertSub
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- idArr := strings.Split(Ids, ",")
- cols := []string{"CertSubStatus"}
- model.CertSubStatus = "2"
- for _, id := range idArr {
- err := svc.UpdateEntityBywheretbl("OilSupplierCertSub", &model, cols, " SubClassId = " + id)
- if err == nil {
- errinfo.Message = "变更成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "变更失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- }
- // @Title get 查询
- // @Description get SampleType by token
- // @Success 200 {object} sampletype.SampleType
- // @router /goodsparentlist/:name [get]
- func (this *OilGoodsAptitudeController) GoodsParentList() {
- Name := this.Ctx.Input.Param(":name")
- if Name != "" {
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- where1 := "1=1"
- where1 += " AND Name LIKE '%" + Name + "%' OR Code LIKE '" + Name + "%' "
- sqlStr := "SELECT Id, Code, Name, concat(Code, ' ', Name) as CodeName, ParentId FROM OilGoodsAptitudeClass " +
- "WHERE " + where1 + " AND Edition='1' AND DeletionStateCode = 0 ORDER BY Code"
- list, _ := svc.DBE.QueryString(sqlStr)
- /*
- sql := "SELECT Id, Code, Name, concat(Code, ' ', Name) as CodeName, ParentId FROM OilGoodsAptitudeClass " +
- "WHERE DeletionStateCode = 0 AND " + where1 + " OR Id = (" + sqlStr + ")" +" ORDER BY Code"
- list, _ := svc.DBE.QueryString(sql)*/
- var datainfo DataInfo
- datainfo.Items = list
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- }
- // @Title get 获取子类
- // @Description get SampleType by token
- // @Success 200 {object} sampletype.SampleType
- // @router /goodschildlist/:id [get]
- func (this *OilGoodsAptitudeController) GoodsChildList() {
- ParentId := this.Ctx.Input.Param(":id")
- 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"
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- list, _ := svc.DBE.QueryString(sqlStr)
- var datainfo DataInfo
- datainfo.Items = list
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title get 获取子类
- // @Description get SampleType by token
- // @Success 200 {object} sampletype.SampleType
- // @router /goodschildlistbypid/:parentid [get]
- func (this *OilGoodsAptitudeController) GoodsChildLisByParentId() {
- ParentId := this.Ctx.Input.Param(":parentid")
- GoodsLevel := this.GetString("GoodsLevel")
- sqlStr := "SELECT o.Id, o.`Code`, o.`Name`, concat(o.Code, ' ', o.Name) as CodeName, o.ParentId, g.GoodsLevel," +
- " (CASE WHEN length(Code)>=8 THEN '1' ELSE '0' END) as Leaf FROM OilGoodsAptitudeClass o " +
- " LEFT JOIN `OilGoodsAptitude` g ON (g.ClassId = o.Id)" +
- " 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"
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- list, _ := svc.DBE.QueryString(sqlStr)
- var datainfo DataInfo
- datainfo.Items = list
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title get 导出ex
- // @Description get SampleType by token
- // @Success 200 {object} sampletype.SampleType
- // @router /exportexcelall [get]
- func (this *OilGoodsAptitudeController) ExportExcelAll() {
- //获取分页信息
- //page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Code"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- } else {
- asc = false
- }
- }
- Edition := this.GetString("Edition")
- if Edition != "" {
- where = where + " and Edition = '" + Edition + "'"
- }
- t := time.Now()
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list []goodsaptitude.OilGoodsAptitudeView
- svc.GetMyPagingEntitiesWithOrderBytbl(OilGoodsAptDetailViewName, 0, 0, orderby, asc, &list, where)
- var title []string
- filetitle := "物资类"
- //自定义显示列
- showcolumnarr := this.GetString("showcolumnarr")
- showcolumnnamearr := this.GetString("showcolumnnamearr")
- titlestring := showcolumnnamearr
- title = strings.Split(titlestring, ",")
- f := xlsx.NewFile()
- sheet, _ := f.AddSheet(filetitle)
- //rowhead := sheet.AddRow()
- //rowhead.WriteSlice(&title, -1)
- cellname := strings.Split(showcolumnarr, ",")
- row := sheet.AddRow()
- row2 := sheet.AddRow()
- row.WriteSlice(&cellname, -1)
- row2.WriteSlice(&cellname, -1)
- //doublename := "制造商,贸易商"
- //doubleslice := strings.Split(doublename, ",")
- //rowhead := sheet.AddRow()
- //rowhead.WriteSlice(&doubleslice, -1)
- intsix := svc.GetNumOfPass("0")
- intStr := strconv.FormatInt(intsix, 10)
- alluse ,_ := strconv.Atoi(intStr)
- for i := 0; i < alluse+12; i++ {
- row.Cells[i].Merge(0, 1)
- }
- intsix1 := svc.GetNumOfPass("2")
- intStr1 := strconv.FormatInt(intsix1, 10)
- traker ,_ := strconv.Atoi(intStr1)
- row.Cells[alluse+12].Merge(traker-1,0)
- row.Cells[alluse+12].Value = "贸易产品"
- intsix2 := svc.GetNumOfPass("1")
- intStr2 := strconv.FormatInt(intsix2, 10)
- maker ,_ := strconv.Atoi(intStr2)
- row.Cells[alluse+12+traker].Merge(maker-1,0)
- row.Cells[alluse+12+traker].Value = "制造产品"
- for _, item := range list {
- var enumModel goodsaptitude.OilGoodsAptitudeView
- tmpModel := &item
- enumModel = *tmpModel
- immumodel := reflect.ValueOf(&enumModel)
- elem := immumodel.Elem()
- row := sheet.AddRow()
- for _, name := range title {
- cell := row.AddCell()
- if strings.HasPrefix(name, "F") {
- var val = elem.FieldByName(name).String()
- if val == "1" {
- cell.Value = "是"
- } else {
- cell.Value = ""
- }
- } else {
- cell.Value = elem.FieldByName(name).String()
- }
- }
- }
- for c, cl := 0, len(sheet.Cols); c < cl; c++ {
- sheet.Cols[c].Width = 20
- }
- //this.SaveSampleXlsx(filetitle, title, showcolumnarr, list, f)
- dir := "static/file/excel/report/" + this.GetAccode()
- SaveDirectory(dir)
- path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
- f.Save(path)
- var sw *Seaweed
- var filer []string
- if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
- filer = []string{_filer}
- }
- sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
- _, _, fID, _ := sw.UploadFile(path, "", "")
- retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
- os.Remove(path)
- fmt.Println("==retDocWatermarkUrl==", retDocUrl)
- this.Data["json"] = retDocUrl
- this.ServeJSON()
- elapsed := time.Since(t)
- fmt.Println(elapsed)
- }
- // @Title get 导出ex
- // @Description get SampleType by token
- // @Success 200 {object} sampletype.SampleType
- // @router /exportexcelall2019 [get]
- func (this *OilGoodsAptitudeController) ExportExcelAll2019() {
- //获取分页信息
- //page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Code"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- } else {
- asc = false
- }
- }
- Edition := this.GetString("Edition")
- if Edition != "" {
- where = where + " and a.Edition = '" + Edition + "'"
- }
- t := time.Now()
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list []goodsaptitude.OilGoodsAptitude_2
- svc.GetList_2019(OilGoodsAptitudeName, OilGoodsAptitudeClassName, 0, 0, orderby, asc, &list, where)
- var title []string
- filetitle := "物资类(顶级)"
- //自定义显示列
- showcolumnarr := this.GetString("showcolumnarr")
- showcolumnnamearr := this.GetString("showcolumnnamearr")
- titlestring := showcolumnnamearr
- title = strings.Split(titlestring, ",")
- f := xlsx.NewFile()
- sheet, _ := f.AddSheet(filetitle)
- cellname := strings.Split(showcolumnarr, ",")
- row := sheet.AddRow()
- row.WriteSlice(&cellname, -1)
- for _, item := range list {
- var enumModel goodsaptitude.OilGoodsAptitude_2
- tmpModel := &item
- enumModel = *tmpModel
- immumodel := reflect.ValueOf(&enumModel)
- elem := immumodel.Elem()
- row := sheet.AddRow()
- for _, name := range title {
- cell := row.AddCell()
- if strings.HasPrefix(name, "F") {
- var val = elem.FieldByName(name).String()
- if val == "1" {
- cell.Value = "是"
- } else {
- cell.Value = ""
- }
- } else {
- cell.Value = elem.FieldByName(name).String()
- }
- }
- }
- for c, cl := 0, len(sheet.Cols); c < cl; c++ {
- sheet.Cols[c].Width = 20
- }
- dir := "static/file/excel/report/" + this.GetAccode()
- SaveDirectory(dir)
- path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
- f.Save(path)
- var sw *Seaweed
- var filer []string
- if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
- filer = []string{_filer}
- }
- sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
- _, _, fID, _ := sw.UploadFile(path, "", "")
- retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
- os.Remove(path)
- fmt.Println("==retDocWatermarkUrl==", retDocUrl)
- this.Data["json"] = retDocUrl
- this.ServeJSON()
- elapsed := time.Since(t)
- fmt.Println(elapsed)
- }
- // @Title get 导入excel
- // @Description get SampleType by token
- // @Success 200 {object} sampletype.SampleType
- // @router /importexcel [get]
- func (this *OilGoodsAptitudeController) ImportExcel() {
- url := this.GetString("ExcelUrl")
- var errorinfo ErrorInfo
- if url == "" {
- errorinfo.Code = -2
- errorinfo.Message = "导入失败!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- err := svc.TruncateTable(Tmp_OilGoodsAptitudeName)
- if err != nil {
- errorinfo.Code = -2
- errorinfo.Message = "导入失败!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- err = svc.TruncateTable(Tmp_OilGoodsAptitudeClassName)
- if err != nil {
- errorinfo.Code = -2
- errorinfo.Message = "导入失败!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- // 外网不用 go func()
- go func() {
- _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
- filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
- utils.DownloadFile(url, filename, _dir)
- t := time.Now()
- filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
- xlFile, err := xlsx.OpenFile(filePath)
- var errLineNum string
- //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
- if err != nil {
- fmt.Printf("open failed: %s\n", err)
- }
- var sheet = xlFile.Sheets[0]
- Fstrs := svc.GetFCode()
- Fstrs = "GoodsLevel,GoodsDesc,Standard,CompanyType," + Fstrs
- columnArr := strings.Split(Fstrs, ",")
- codemap := make(map[string]int)
- for i := 2; i < len(sheet.Rows); i++ {
- lineNo := strconv.Itoa(i + 1)
- this.OperationCell(lineNo, columnArr, codemap, sheet.Rows[i].Cells, &errLineNum)
- }
- os.Remove(filePath)
- if errLineNum != "" {
- log.Println("导入失败!错误行号:" + errLineNum)
- } else {
- elapsed := time.Since(t)
- log.Println(elapsed)
- this.CreateContrast()
- }
- }()
- errorinfo.Code = 0
- errorinfo.Message = "导入中,请等待!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- func (this *OilGoodsAptitudeController) OperationCell(lineNo string, columnArr []string, codemap map[string]int, cellsArr []*xlsx.Cell, errLineNum *string) {
- defer func() {
- if err := recover(); err != nil {
- log.Println("err"+lineNo, err)
- *errLineNum += lineNo + ","
- }
- }()
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- parentId := 0
- classId := 0
- cellsArrLen := len(cellsArr)
- cellD := strings.TrimSpace(cellsArr[6].String())
- var valstr = ""
- for i := 0; i < cellsArrLen; {
- if i < 8 {
- var entity goodsaptitudeclass.Tmp_OilGoodsAptitudeClass
- cellval := strings.TrimSpace(cellsArr[i].String())
- fmt.Println(cellval)
- _, has := codemap[cellval]
- if !has {
- if i != 0 {
- upcode := cellsArr[i-2].String()
- parentId = codemap[upcode]
- }
- entity.Code = cellval
- entity.Name = strings.TrimSpace(cellsArr[i+1].String())
- entity.Edition = "1"
- entity.ParentId = parentId
- entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- entity.CreateBy = this.User.Realname
- entity.CreateOn = time.Now()
- _, err := svc.InsertEntityBytbl(Tmp_OilGoodsAptitudeClassName, &entity)
- if err != nil {
- panic(err)
- break
- }
- classId = entity.Id
- if i <= 6 {
- codemap[cellval] = entity.Id
- }
- }
- }
- if i >= 8 {
- valstr += "'" + cellsArr[i].String() + "',"
- i++
- } else {
- i += 2
- }
- }
- //for idx, cell := range cellsArr {
- // if idx < 4 {
- // cellstr := cell.String()
- // //fmt.Printf("%s\n", cellstr)
- // if strings.TrimSpace(cellstr) == "" {
- // break
- // }
- // cellArr := strings.Fields(cellstr)
- //
- // //id := sessionsvc.SelectGoodsAptitudeClassCode(cellArr[0])
- //
- // var entity goodsaptitudeclass.Tmp_OilGoodsAptitudeClass
- // _, has := codemap[cellArr[0]]
- // if !has {
- // if idx != 0 {
- // upcellstr := cellsArr[idx-1].String()
- // upcellArr := strings.Fields(upcellstr)
- // parentId = codemap[upcellArr[0]]
- // }
- // entity.Code = cellArr[0]
- // entity.Name = cellArr[1]
- // entity.Edition = "1"
- // entity.ParentId = parentId
- // entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- // entity.CreateBy = this.User.Realname
- // entity.CreateOn = time.Now()
- //
- // _, err := svc.InsertEntityBytbl(Tmp_OilGoodsAptitudeClassName, &entity)
- // if err != nil {
- // panic(err)
- // break
- // }
- // classId = entity.Id
- // if idx != 3 {
- // codemap[cellArr[0]] = entity.Id
- // }
- // }
- // }
- // if idx >= 4 {
- // valstr += "'" + cellsArr[idx].String() + "',"
- // }
- //}
- if cellD != "" {
- valstr = strings.Trim(valstr, ",")
- valstr = strings.Replace(valstr, "是", "1", -1)
- log.Println(cellsArr[6].String() + "==" + valstr)
- var columnstr = ""
- for l := 0; l < cellsArrLen-8; l++ {
- columnstr += columnArr[l] + ","
- }
- columnstr = strings.Trim(columnstr, ",")
- err := svc.InsertTmpGoodsAptitude(strconv.Itoa(classId), columnstr, valstr)
- if err != nil {
- panic(err)
- }
- }
- }
- // @Title get 清空导入的信息
- // @Description get SampleType by token
- // @Success 200 {object} sampletype.SampleType
- // @router /truncateimport [get]
- func (this *OilGoodsAptitudeController) TruncateImport() {
- session := utils.DBE.NewSession()
- err := session.Begin()
- defer session.Close()
- svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
- err = svc.TruncateTable(Tmp_OilGoodsAptitudeName)
- var errorinfo ErrorInfo
- if err != nil {
- session.Rollback()
- errorinfo.Code = -1
- errorinfo.Message = "删除失败!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- err = svc.TruncateTable(Tmp_OilGoodsAptitudeClassName)
- if err != nil {
- session.Rollback()
- errorinfo.Code = -1
- errorinfo.Message = "删除失败!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- session.Commit()
- errorinfo.Code = 0
- errorinfo.Message = "删除成功!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- // @Title get 生成对比列表
- // @Description get SampleType by token
- // @Success 200 {object} sampletype.SampleType
- // @router /create-contrast [get]
- func (this *OilGoodsAptitudeController) CreateContrast() {
- go func() {
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- svc.TruncateTable("OilSupplierContrast")
- // 插入对比列表
- var list1 []supplier.OilSupplier
- svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, 0, 0, "Id", false, &list1, " 1=1")
- svc.DBE.Query("SET unique_checks=0;")
- svc.DBE.Query("SET autocommit=0;")
- for _, item := range list1 {
- var list []supplier.OilSupplierContrast
- where := " b.SupplierTypeCode='01' and a.Id = " + strconv.Itoa(item.Id)
- svc.GetPagingTmpCheckedEntities(&list, where)
- if list != nil {
- var supplierCertSubList []suppliercertsub.OilSupplierCertSub
- total := svc.GetTableTotal(" SupplierTypeCode = '01' AND SupplierId = "+strconv.Itoa(item.Id), &supplierCertSubList)
- total1 := svc.GetNoSubCntTotal("a.SupplierTypeCode = '01' and b.`Name` is null and a.SupplierId = " + strconv.Itoa(item.Id))
- list[0].SubCnt = int(total)
- //list[0].MinClassId = "0"
- list[0].NoSubCnt = int(total1)
- //for _, sub := range supplierCertSubList {
- // var goodsList goodsaptitudeclass.OilGoodsAptitudeClass
- // where2 := "Code = '"+ sub.Code + "'"
- // svc.GetEntityByWhere(Tmp_OilGoodsAptitudeClassName, where2, &goodsList)
- // if goodsList.Id > 0{
- // list[0].MinClassId = strconv.Itoa(goodsList.Id)
- // } else {
- // list[0].MinClassId = "0"
- // break
- // }
- //}
- list[0].SetupTime = time.Now()
- var oneTwo supplier.OilSupplierContrast
- svc.GetEntityByCode("SupplierTypeCode = '01' and SupplierId = "+strconv.Itoa(list[0].Id), &oneTwo)
- list[0].OneTwoCount = oneTwo.OneTwoCount
- list[0].TwoOneCount = oneTwo.TwoOneCount
- svc.InsertEntityBytbl("OilSupplierContrast", list[0])
- svc.DBE.Query("commit;")
- }
- }
- svc.DBE.Query("SET unique_checks=1;")
- svc.DBE.Query("SET autocommit=1;")
- }()
- var errorinfo ErrorInfo
- errorinfo.Code = 0
- errorinfo.Message = "成功!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- // @Title 将导入的数据 导入到正式表
- // @Description 确认更新
- // @Success 200 {object} sampletype.SampleType
- // @router /insertgoodsaptitude [get]
- func (this *OilGoodsAptitudeController) InsertGoodsAptitude() {
- session := utils.DBE.NewSession()
- err := session.Begin()
- defer session.Close()
- svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
- var errinfo ErrorInfo
- err = svc.TruncateTable(OilGoodsAptitudeName)
- if err != nil {
- session.Rollback()
- errinfo.Code = -1
- errinfo.Message = "更新失败!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- err = svc.TruncateTable(OilGoodsAptitudeClassName)
- if err != nil {
- session.Rollback()
- errinfo.Code = -1
- errinfo.Message = "更新失败!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- err = svc.InsertGoodsAptitude(Tmp_OilGoodsAptitudeName, OilGoodsAptitudeName)
- if err != nil {
- session.Rollback()
- errinfo.Code = -1
- errinfo.Message = "更新失败!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- err = svc.InsertGoodsAptitude(Tmp_OilGoodsAptitudeClassName, OilGoodsAptitudeClassName)
- if err != nil {
- session.Rollback()
- errinfo.Code = -1
- errinfo.Message = "更新失败!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- // TODO 更新certsub表的subclassid
- svc1 := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list2 []supplier.OilSupplierContrast
- where := " (Checked = '0' or MinClassId = '0') and SupplierTypeCode = '01'"
- svc1.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrast", 0, 0, "Id", false, &list2, where)
- err = svc.TruncateTable("OilSupplierContrastNew")
- if err != nil {
- session.Rollback()
- errinfo.Code = -1
- errinfo.Message = "更新失败!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- for _, item := range list2 {
- _, err := svc.InsertEntityBytbl("OilSupplierContrastNew", item)
- if err != nil {
- session.Rollback()
- errinfo.Code = -1
- errinfo.Message = "更新失败!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- session.Commit()
- errinfo.Code = 0
- errinfo.Message = "更新成功,即将操作企业准入范围!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- // @Title 更新企业的准入项及资质
- // @Description get SampleType by token
- // @Success 200 {object} sampletype.SampleType
- // @router /updatasuppiercertsub [get]
- func (this *OilGoodsAptitudeController) UpdataSuppierCertSub() {
- //excelFileName := "F:/ssa.xlsx"
- //xlFile, _ := xlsx.OpenFile(excelFileName)
- //var sheet = xlFile.Sheets[0]
- t := time.Now()
- goodsvc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- goodsvc.DeleteTable(TmpOilSupplierCertSubName, "SupplierTypeCode='01'")
- supsvc := supplier.GetOilSupplierService(utils.DBE)
- var suppliercertList []suppliercert.OilSupplierCert
- where := "SupplierTypeCode='01' AND OutsideFlog = '' AND (InFlag IN ('1','2')) "
- supsvc.GetEntities(&suppliercertList, where)
- var goodsaptitudeClassList []goodsaptitudeclass.OilGoodsAptitudeClass
- whereclass := "LENGTH(CODE) = 8 "
- supsvc.GetEntities(&goodsaptitudeClassList, whereclass)
- var colsname = []string{"Name"}
- var colsLevel = []string{"GoodsLevel"}
- for _, suppliercert := range suppliercertList {
- //row := sheet.AddRow()
- //cell := row.AddCell()
- //cell.Value = strconv.Itoa(suppliercert.SupplierId)
- var supplier supplier.OilSupplier
- wheres := " Id=" + strconv.Itoa(suppliercert.SupplierId)
- supsvc.GetEntity(&supplier, wheres)
- log.Println(suppliercert.SupplierId)
- var supplierCertSubList []suppliercertsub.OilSupplierCertSub
- wheresup := "SupplierId = " + strconv.Itoa(suppliercert.SupplierId) + " and SupplierTypeCode='01' AND Type IN ('1', '3')"
- supsvc.GetEntities(&supplierCertSubList, wheresup)
- fmt.Println(len(supplierCertSubList))
- mergerCertSkipField := ""
- if supplier.CredentialFlag == "1" || supplier.CredentialFlag == "2" {
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- //三证合一或五证合一不需要的字段
- mergerCertSkipField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
- }
- // 准入项
- //for idx, supplierCertSub := range supplierCertSubList {
- for idx := 0; idx < len(supplierCertSubList); idx++ {
- //row := sheet.AddRow()
- //cell := row.AddCell()
- //cell.Value = "删除"
- supplierCertSub := supplierCertSubList[idx]
- decCode := supplierCertSub.Code
- // 物资类的准入编码
- for _, goodsaptitudeClass := range goodsaptitudeClassList {
- // 如果编码相同的后 判断有没有改名 然后查询准入项需要哪些资质 去查资质表里有没有这些资质 没有就删除这个准入项
- if supplierCertSub.Code == goodsaptitudeClass.Code {
- decCode = ""
- goodsAptitudeNameArr := this.GetGoodsAptitudeName(strconv.Itoa(goodsaptitudeClass.Id), strconv.Itoa(supplierCertSub.IsManufacturer))
- for _, val := range goodsAptitudeNameArr {
- if strings.Contains(mergerCertSkipField, val) {
- break
- }
- var supplierFile supplierfile.OilSupplierFile
- where := "SupplierId=" + strconv.Itoa(suppliercert.SupplierId) + " and NeedFileType='" + val + "'" + " and SupplierTypeCode IN ('000', '01')"
- has := supsvc.GetEntityByWhere(OilSupplierFileName, where, &supplierFile)
- if !has {
- //cell := row.AddCell()
- //cell.Value = supplierCertSub.Code + " " + supplierCertSub.Name
- log.Println(supplierCertSub.Code + "====" + val)
- //wheredel := "Id = " + strconv.Itoa(supplierCertSub.Id)
- //supsvc.DeleteEntityBytbl(OilSupplierCertSubName, wheredel)
- supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
- break
- }
- if supplierCertSub.Name != goodsaptitudeClass.Name {
- //row := sheet.AddRow()
- //cell := row.AddCell()
- //cell.Value = supplierCertSub.Code + ":" + supplierCertSub.Name + "==" + goodsaptitudeClass.Name
- var entity suppliercertsub.OilSupplierCertSub
- entity.Name = goodsaptitudeClass.Name
- where := "Id = " + strconv.Itoa(supplierCertSub.Id)
- supsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &entity, colsname, where)
- }
- var goodsAptitude goodsaptitude.OilGoodsAptitude
- whereg := "ClassId = " + strconv.Itoa(goodsaptitudeClass.Id)
- supsvc.GetEntity(&goodsAptitude, whereg)
- if goodsAptitude.GoodsLevel != supplierCertSub.GoodsLevel {
- if goodsAptitude.GoodsLevel == "1" && supplier.Grade == "2" {
- supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
- } else {
- var entity suppliercertsub.OilSupplierCertSub
- entity.GoodsLevel = goodsAptitude.GoodsLevel
- where := "Id = " + strconv.Itoa(supplierCertSub.Id)
- supsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &entity, colsLevel, where)
- }
- }
- }
- break
- }
- }
- if decCode != "" {
- //wheredel := "Code = '" + decCode + "'"
- //supsvc.DeleteEntityBytbl(OilSupplierCertSubName, wheredel)
- supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
- }
- //cell1 := row.AddCell()
- //cell1.Value = decCode
- }
- }
- elapsed := time.Since(t)
- log.Println(elapsed)
- var errinfo ErrorInfo
- errinfo.Code = 0
- errinfo.Message = "更新完成!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- //xlFile.Save(excelFileName)
- }
- func (this *OilGoodsAptitudeController) GetGoodsAptitudeName(classId, IsManuf string) []string {
- var goodsAptitudeName string
- var goodsAptitudeList []goodsaptitude.OilGoodsAptitudeF
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- where := "ClassId=" + classId
- svc.GetGoodsAptitudeF(&goodsAptitudeList, where)
- for _, goodsAptitude := range goodsAptitudeList {
- t := reflect.TypeOf(goodsAptitude)
- v := reflect.ValueOf(goodsAptitude)
- for k := 0; k < t.NumField(); k++ {
- if v.Field(k).Interface() == "1" {
- var tableHeader tableheader.BaseTableheader
- where := "Code='" + t.Field(k).Name + "' and IsManuf in ('0','" + IsManuf + "')"
- has := svc.GetEntityByWhere(BaseTableHeader, where, &tableHeader)
- if has {
- goodsAptitudeName += tableHeader.Name + ","
- }
- }
- }
- }
- return strings.Split(goodsAptitudeName, ",")
- }
- // @Title 获取所有
- // @Description
- // @Success 200 {object}
- // @router /getcompanylist [post]
- func (this *OilGoodsAptitudeController) GetTList() {
- var model supplier.OilSupplierSelect
- var model1 supplier.RegCapitalRange //注册资金范围
- //var model2 supplier.NeedFileTypeStruct //资质结构体
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &model)
- json.Unmarshal(jsonBlob, &model1)
- //json.Unmarshal(jsonBlob, &model2)
- // //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' and b.SupplierTypeCode = '01' AND t.SupplierId IS NOT NULL "
- orderby := "a.Id"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- CheckUId := this.GetString("CheckUId")
- FullId := this.GetString("FullId")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "desc" {
- asc = false
- }
- }
- leftjoin := ""
- //准入证号
- if model.AccessCardNo != "" {
- where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
- }
- //企业名称
- if model.SupplierName != "" {
- where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
- }
- if model.OldSupplierName != "" {
- where = where + " and OldSupplierName like '%" + model.OldSupplierName + "%'"
- }
- if FullId != "" {
- where = where + " and f.Id = '" + FullId + "'"
- }
- if CheckUId != "" {
- where = where + " and g.CheckUnitId = '" + CheckUId + "'"
- }
- //准入标识 1 准入 2 暂停 3取消
- if model.InFlag != "" {
- where = where + " and b.InFlag = '" + model.InFlag + "'"
- }
- //法人
- if model.LegalPerson != "" {
- where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
- }
- //联系人
- if model.ContactName != "" {
- where = where + " and a.ContactName like '%" + model.ContactName + "%'"
- }
- //统一社会信用代码
- if model.CommercialNo != "" {
- where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
- }
- //开户银行
- if model.DepositBank != "" {
- where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
- }
- //HSE审查
- if model.HseTraining != "" {
- where = where + " and a.HseTraining = '" + model.HseTraining + "'"
- }
- //公司类型
- if model.CompanyType != "" {
- where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
- }
- //成立时间
- SetupTime := this.GetString("SetupTime")
- if SetupTime != "" {
- where = where + " and a.SetupTime ='" + SetupTime + "'"
- }
- //注册资金范围
- if model1.RegCapital1 != "" {
- where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
- }
- if model1.RegCapital2 != "" {
- where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
- }
- //注册省份
- if model.Province != "" {
- where = where + " and a.Province = '" + model.Province + "'"
- }
- //注册市
- if model.City != "" {
- where = where + " and a.City = '" + model.City + "'"
- }
- //注册区
- if model.Street != "" {
- where = where + " and a.Street = '" + model.Street + "'"
- }
- //注册详细地址
- if model.Address != "" {
- where = where + " and a.Address like '%" + model.Address + "%'"
- }
- if model.LinkProvince != "" {
- where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
- }
- if model.LinkCity != "" {
- where = where + " and a.LinkCity = '" + model.LinkCity + "'"
- }
- if model.LinkStreet != "" {
- where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
- }
- if model.LinkAddress != "" {
- where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
- }
- //营业范围
- if model.BusinessScope != "" {
- where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
- }
- CreateOn := this.GetString("CreateOn")
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
- }
- }
- a := model.InStyle
- fmt.Println(a)
- //准入方式
- if model.InStyle != "" {
- if model.InStyle == "0" {
- where = where + " and b.InStyle in ('2','3','4','5')"
- } else {
- where = where + " and b.InStyle ='" + model.InStyle + "'"
- }
- }
- having := ""
- //准入范围
- if model.CerSubName != "" {
- having = " having CerSubName like '%" + model.CerSubName + "%' "
- leftjoin = "left join " + OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
- }
- //资质
- if model.NeedFileType != "" {
- having = " having NeedFileType like '%" + model.NeedFileType + "%' "
- }
- if model.CerSubName != "" && model.NeedFileType != "" {
- having = " having CerSubName like '%" + model.CerSubName + "%' and NeedFileType like '%" + model.NeedFileType + "%' "
- leftjoin = "left join " + OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
- }
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list []supplier.OilSupplierSelect
- total := svc.GetMyPagingDelEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
- OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where, having, leftjoin)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 查看对比列表的准入范围 2020-12-18
- // @Description get user by token
- // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
- // @router /delcertsublist [get]
- func (this *OilGoodsAptitudeController) GetDelCertSubList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "a.Id"
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- Id := this.GetString("Id")
- SupplierId := this.GetString("SupplierId")
- SupplierCertId := this.GetString("SupplierCertId")
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- Code := this.GetString("Code")
- Name := this.GetString("Name")
- Remark := this.GetString("Remark")
- IsDelete := this.GetString("IsDelete")
- CreateOn := this.GetString("CreateOn")
- CreateUserId := this.GetString("CreateUserId")
- CreateBy := this.GetString("CreateBy")
- ModifiedOn := this.GetString("ModifiedOn")
- ModifiedUserId := this.GetString("ModifiedUserId")
- ModifiedBy := this.GetString("ModifiedBy")
- if Id != "" {
- where = where + " and a.Id like '%" + Id + "%'"
- }
- if SupplierId != "" {
- where = where + " and a.SupplierId like '%" + SupplierId + "%'"
- }
- if SupplierCertId != "" {
- where = where + " and a.SupplierCertId = '" + SupplierCertId + "'"
- }
- if SupplierTypeCode != "" {
- where = where + " and a.SupplierTypeCode = '" + SupplierTypeCode + "'"
- }
- if Code != "" {
- where = where + " and a.Code like '%" + Code + "%'"
- }
- if Name != "" {
- where = where + " and a.Name like '%" + Name + "%'"
- }
- if Remark != "" {
- where = where + " and a.Remark like '%" + Remark + "%'"
- }
- if IsDelete != "" {
- where = where + " and a.IsDelete like '%" + IsDelete + "%'"
- }
- if CreateUserId != "" {
- where = where + " and a.CreateUserId like '%" + CreateUserId + "%'"
- }
- if CreateBy != "" {
- where = where + " and a.CreateBy like '%" + CreateBy + "%'"
- }
- if ModifiedOn != "" {
- where = where + " and a.ModifiedOn like '%" + ModifiedOn + "%'"
- }
- if ModifiedUserId != "" {
- where = where + " and a.ModifiedUserId like '%" + ModifiedUserId + "%'"
- }
- if ModifiedBy != "" {
- where = where + " and a.ModifiedBy like '%" + ModifiedBy + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
- }
- }
- where = where + " and a.Type in (1, 3)"
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list []suppliercertsub.OilSupplierCertSub1
- var co supplier.OilSupplierContrast
- svc.GetEntityById(SupplierId, &co)
- //total := svc.GetMyPagingEntitiesWithOrderBytbl(TmpOilSupplierCertSubName, page.CurrentPage, page.Size, orderby, asc, &list, where)
- //total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierCertSubName, page.CurrentPage, page.Size, orderby, asc, &list, where)
- if co.IsDelete == 1 {
- where += " and a.IsQuestion = 1"
- }
- total := svc.GetPagingTmpSubEntities(page.CurrentPage, page.Size, orderby, asc, &list, where)
- a := 0
- for _, item := range list {
- 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"
- sql += " where class.Code = '"+ item.Code + "'"
- model, _ := svc.DBE.QueryString(sql)
- if model != nil {
- code := strings.Split(model[0]["Codes"], ",")
- i := 1
- for _, value := range code {
- if i == 36 || i == 37 || i == 1 {
- 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) {
- list[a].Checked = 1
- sql1 := "select Name from Base_TableHeader where Code = 'F01' and CategoryCode = '01'"
- model1, _ := svc.DBE.QueryString(sql1)
- if strings.Index(list[a].HeaderName, model1[0]["Name"]) == -1 {
- list[a].HeaderName += model1[0]["Name"] + " "
- }
- }
- } else if i > 10 {
- if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
- list[a].Checked = 1
- sql1 := "select Name from Base_TableHeader where Code = 'F"+strconv.Itoa(i)+"' and CategoryCode = '01'"
- model1, _ := svc.DBE.QueryString(sql1)
- list[a].HeaderName += model1[0]["Name"]+ " "
- }
- } else {
- if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
- list[a].Checked = 1
- sql1 := "select Name from Base_TableHeader where Code = 'F0"+strconv.Itoa(i)+"' and CategoryCode = '01'"
- model1, _ := svc.DBE.QueryString(sql1)
- list[a].HeaderName += model1[0]["Name"]+ " "
- }
- }
- i += 1
- }
- } else {
- list[a].MinClassId = "0"
- }
- a += 1
- }
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 删除不符合的的准入项
- // @Description get user by token
- // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
- // @router /deltmpsuppliercertsub [get]
- func (this *OilGoodsAptitudeController) DelTmpSupplierCertSub() {
- var err error
- session := utils.DBE.NewSession()
- session.Begin()
- defer session.Close()
- supplierId := this.GetString("SupplierId")
- id := this.GetString("Id")
- svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
- wheredel := "1=1 and SupplierTypeCode = '01'"
- if supplierId != "" {
- wheredel += " and Id=" + supplierId
- }
- if id != "" {
- wheredel += " and Id=" + id
- }
- svc1 := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- //svc.GetEntitysByWhere(TmpOilSupplierCertSubName, wheredel, &supplierCertSubList)
- //svc.GetEntitysByWhere(OilSupplierCertSubName, wheredel, &supplierCertSubList)
- //svc1.GetPagingSubEntities(0, 0, "Id", false, &supplierCertSubList, wheredel)
- var list2 []supplier.OilSupplierContrast
- svc1.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrastNew", 0, 0, "Id", false, &list2, wheredel)
- a := 0
- var errinfo ErrorInfo
- for _, item2 := range list2 {
- var supplierCertSubList []suppliercertsub.OilSupplierCertSub
- where := " SupplierId = " + strconv.Itoa(item2.Id)
- svc1.GetEntitysByWhere(OilSupplierCertSubName, where, &supplierCertSubList)
- for _, item := range supplierCertSubList {
- 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"
- sql += " where class.Code = '"+ item.Code + "'"
- model, err := svc1.DBE.QueryString(sql)
- if len(model) == 0 {
- where := "Id = " + strconv.Itoa(item.Id)
- err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
- if err != nil {
- session.Rollback()
- errinfo.Code = -1
- errinfo.Message = "删除失败!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- continue
- }
- }
- code := strings.Split(model[0]["Codes"], ",")
- i := 1
- for _, value := range code {
- if i == 36 || i == 37 || i == 1 {
- 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) {
- where := "Id = " + strconv.Itoa(item.Id)
- err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
- if err != nil {
- session.Rollback()
- errinfo.Code = -1
- errinfo.Message = "删除失败!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- break
- }
- }
- } else if i > 10 {
- if value == "1" && strings.Index(item2.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
- where := "Id = " + strconv.Itoa(item.Id)
- err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
- if err != nil {
- session.Rollback()
- errinfo.Code = -1
- errinfo.Message = "删除失败!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- break
- }
- }
- } else {
- if value == "1" && strings.Index(item2.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
- where := "Id = " + strconv.Itoa(item.Id)
- err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
- if err != nil {
- session.Rollback()
- errinfo.Code = -1
- errinfo.Message = "删除失败!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- break
- }
- }
- }
- i += 1
- }
- a += 1
- }
- where1 := "Id = " + strconv.Itoa(item2.Id)
- err = svc.DeleteEntityBytbl("OilSupplierContrastNew", where1)
- }
- if err == nil {
- session.Commit()
- errinfo.Code = 0
- errinfo.Message = "删除成功!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- session.Rollback()
- errinfo.Code = -1
- errinfo.Message = "删除失败!"
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 新导入资质后,比对不合格的准入用户
- // @Description 对比列表
- // @Success 200 {object} []supplier.OilSupplierSelect
- // @router /get-compare-tmp-supplier [get]
- func (this *OilGoodsAptitudeController) GetCompareTmpSupplier() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Id"
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- Id := this.GetString("Id")
- SupplierName := this.GetString("SupplierName")
- AccessCardNo := this.GetString("AccessCardNo")
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- Code := this.GetString("Code")
- Name := this.GetString("Name")
- Conditions := this.GetString("Conditions")
- IsDelete := this.GetString("IsDelete")
- CreateOn := this.GetString("CreateOn")
- CreateUserId := this.GetString("CreateUserId")
- CreateBy := this.GetString("CreateBy")
- ModifiedOn := this.GetString("ModifiedOn")
- ModifiedUserId := this.GetString("ModifiedUserId")
- ModifiedBy := this.GetString("ModifiedBy")
- if Id != "" {
- where = where + " and Id like '%" + Id + "%'"
- }
- if SupplierName != "" {
- where = where + " and SupplierName like '%" + SupplierName + "%'"
- }
- if AccessCardNo != "" {
- where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
- }
- if SupplierTypeCode != "" {
- where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'"
- }
- if Code != "" {
- where = where + " and Code like '%" + Code + "%'"
- }
- if Name != "" {
- where = where + " and Name like '%" + Name + "%'"
- }
- if Conditions == "2"{
- where = where + " and MinClassId = '0'"
- } else if Conditions == "3"{
- where = where + " and Checked = '0'"
- } else if Conditions == "4"{
- where = where + " and Checked = '1"
- }
- if IsDelete != "" {
- where = where + " and IsDelete like '%" + IsDelete + "%'"
- }
- if CreateUserId != "" {
- where = where + " and CreateUserId like '%" + CreateUserId + "%'"
- }
- if CreateBy != "" {
- where = where + " and CreateBy like '%" + CreateBy + "%'"
- }
- if ModifiedOn != "" {
- where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
- }
- if ModifiedUserId != "" {
- where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
- }
- if ModifiedBy != "" {
- where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
- }
- }
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list2 []supplier.OilSupplierContrast
- total := svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrast", page.CurrentPage, page.Size, orderby, asc, &list2, where)
- var datainfo DataInfo
- datainfo.Items = list2
- datainfo.CurrentItemCount = total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 确认更新后的待删除准入范围列表
- // @Description get compare tmp supplier
- // @Success 200 {object} []supplier.OilSupplierSelect
- // @router /get-delete-supplier [get]
- func (this *OilGoodsAptitudeController) GetDeleteSupplier() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Id"
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- Id := this.GetString("Id")
- SupplierId := this.GetString("SupplierId")
- SupplierCertId := this.GetString("SupplierCertId")
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- Code := this.GetString("Code")
- Name := this.GetString("Name")
- Remark := this.GetString("Remark")
- IsDelete := this.GetString("IsDelete")
- CreateOn := this.GetString("CreateOn")
- CreateUserId := this.GetString("CreateUserId")
- CreateBy := this.GetString("CreateBy")
- ModifiedOn := this.GetString("ModifiedOn")
- ModifiedUserId := this.GetString("ModifiedUserId")
- ModifiedBy := this.GetString("ModifiedBy")
- if Id != "" {
- where = where + " and Id like '%" + Id + "%'"
- }
- if SupplierId != "" {
- where = where + " and SupplierId like '%" + SupplierId + "%'"
- }
- if SupplierCertId != "" {
- where = where + " and SupplierCertId = '" + SupplierCertId + "'"
- }
- if SupplierTypeCode != "" {
- where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'"
- }
- if Code != "" {
- where = where + " and Code like '%" + Code + "%'"
- }
- if Name != "" {
- where = where + " and Name like '%" + Name + "%'"
- }
- if Remark != "" {
- where = where + " and Remark like '%" + Remark + "%'"
- }
- if IsDelete != "" {
- where = where + " and IsDelete like '%" + IsDelete + "%'"
- }
- if CreateUserId != "" {
- where = where + " and CreateUserId like '%" + CreateUserId + "%'"
- }
- if CreateBy != "" {
- where = where + " and CreateBy like '%" + CreateBy + "%'"
- }
- if ModifiedOn != "" {
- where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
- }
- if ModifiedUserId != "" {
- where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
- }
- if ModifiedBy != "" {
- where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
- }
- }
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list2 []supplier.OilSupplierContrast
- total := svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrastNew", page.CurrentPage, page.Size, orderby, asc, &list2, where)
- var datainfo DataInfo
- datainfo.Items = list2
- datainfo.CurrentItemCount = total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 导出到execl
- // @Description 导出到execl
- // @Success 200 {object} controllers.Request
- // @router /exportexecl [post]
- func (this *OilGoodsAptitudeController) ExeclExport() {
- // 填物资类信息表首页信息
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list2 []supplier.OilSupplierContrast
- where := " 1=1"
- svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrast", 0,0, "Id", false, &list2, where)
- fileName := "资质导入对比表.xlsx"
- Url := utils.Cfg.MustValue("workflow", "ContrastExcel")
- var datamap = make(map[string]interface{})
- datamap["data"] = list2
- retDocUrl := svcActiviti.ContrastExcel(datamap, Url, fileName)
- var datainfo ErrorDataInfo
- datainfo.Code = 0
- datainfo.Item = retDocUrl
- datainfo.Message = "打印成功"
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 修改资质后找出不符合的准入
- // @Description 修改实体
- // @Success 200 {object} controllers.Request
- // @router /findinconformity [post]
- func (this *OilGoodsAptitudeController) FindInconformity() {
- var errinfo ErrorInfo
- var err error
- var model goodsaptitude.OilGoodsAptitude_2
- var companygoodslist []suppliercertsub.OilSupplierCertSub
- var companygood suppliercertsub.OilSupplierCertSub
- var SurplusList1 []supplierfile.FileList
- var SurplusList2 []supplierfile.FileList
- var supfilemodel []supplierfile.OilSupplierFile
- var supfilemodel01 []supplierfile.OilSupplierFile
- var supfilemodel02 []supplierfile.OilSupplierFile
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- filesvc := supplierfile.GetSupplierfileService(utils.DBE)
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &model)
- Code := model.Code
- where := " Code ='" + Code + "' and Type in ('1','3') and SupplierTypeCode = '01'"
- svc.FindGoodsByCode("OilSupplierCertSub", where, &companygoodslist)
- SurplusList1 = filesvc.GetGoodsNeedFileList(strconv.Itoa(model.ClassId), "1")
- SurplusList2 = filesvc.GetGoodsNeedFileList(strconv.Itoa(model.ClassId), "2")
- for _, CertSub := range companygoodslist {
- companygood = CertSub
- wherecompany := " SupplierId =" + strconv.Itoa(CertSub.SupplierId)
- svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel)
- if len(supfilemodel) < 1 {
- _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
- } else {
- var tmplist1 []suppliercertsub.Tmp_OilSupplierCertSub
- wherecompany = " Id =" + strconv.Itoa(CertSub.Id)
- svc.FindFileByCompany("tmp_OilSupplierCertSub", wherecompany, &tmplist1)
- if len(tmplist1) < 1 {
- wherecompany = " SupplierId ='" + strconv.Itoa(CertSub.SupplierId) + "' and IsManuf in ('0','1')"
- svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel01)
- var File01 string
- for _, Filesub := range supfilemodel01 {
- File01 = File01 + Filesub.NeedFileType + ","
- }
- for _, Filesub := range SurplusList1 {
- var supplierModel supplier.OilSupplier
- svcSupplier := supplier.GetOilSupplierService(utils.DBE)
- svcSupplier.GetEntityById(strconv.Itoa(CertSub.SupplierId), &supplierModel)
- //三证合一或五证合一不需要的字段
- mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
- File01 = mergerCertSkipField + File01
- if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(File01, Filesub.FileName+",") { //三证合一或五证合一了
- continue
- }
- if strings.Contains(File01, Filesub.FileName+",") {
- continue
- }
- _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
- break
- }
- }
- var tmplist2 []suppliercertsub.Tmp_OilSupplierCertSub
- wherecompany = " Id =" + strconv.Itoa(CertSub.Id)
- svc.FindFileByCompany("tmp_OilSupplierCertSub", wherecompany, &tmplist2)
- if len(tmplist2) < 1 {
- wherecompany = " SupplierId ='" + strconv.Itoa(CertSub.SupplierId) + "' and IsManuf in ('0','2')"
- svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel02)
- var File02 string
- for _, Filesub := range supfilemodel02 {
- File02 = File02 + Filesub.NeedFileType + ","
- }
- for _, Filesub := range SurplusList2 {
- var supplierModel supplier.OilSupplier
- svcSupplier := supplier.GetOilSupplierService(utils.DBE)
- svcSupplier.GetEntityById(strconv.Itoa(CertSub.SupplierId), &supplierModel)
- //三证合一或五证合一不需要的字段
- mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
- File02 = mergerCertSkipField + File02
- if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(File02, Filesub.FileName+",") { //三证合一或五证合一了
- continue
- }
- if strings.Contains(File02, Filesub.FileName+",") {
- continue
- }
- _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
- break
- }
- }
- }
- var entity supplier.OilSupplier
- wherec := "Id=" + strconv.Itoa(CertSub.SupplierId)
- svc.GetEntity(&entity, wherec)
- if model.GoodsLevel == "1" && entity.Grade == "2" {
- svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
- } else {
- var certsub suppliercertsub.OilSupplierCertSub
- certsub.GoodsLevel = model.GoodsLevel
- cols := []string{"GoodsLevel"}
- where := "Id=" + strconv.Itoa(CertSub.Id)
- svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &certsub, cols, where)
- }
- }
- if err == nil {
- errinfo.Message = "已拉取缺失资质列表!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "拉取列表失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title get 导入excel对比差异
- // @Description get SampleType by token
- // @Success 200 {object} sampletype.SampleType
- // @router /oilcompare [get]
- func (this *OilGoodsAptitudeController) OilCompare() {
- url := this.GetString("ExcelUrl")
- inputcode := this.GetString("Code")
- inputname := this.GetString("CompanyName")
- session := utils.DBE.NewSession()
- err := session.Begin()
- svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
- timeUnixNano := strconv.FormatInt(int64(time.Now().UnixNano()), 10)
- _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
- utils.DownloadFile(url, timeUnixNano+".xlsx", _dir)
- filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + timeUnixNano + ".xlsx"
- xlFile, err := xlsx.OpenFile(filePath)
- //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
- if err != nil {
- fmt.Printf("open failed: %s\n", err)
- }
- var sheet = xlFile.Sheets[0]
- defer func() {
- session.Close()
- }()
- var Comparelist []suppliercertsub.OilCompare
- var Comparelistnow []suppliercertsub.OilCompare
- var Compare suppliercertsub.OilCompare
- var CompanyName string
- for i := 2; i < len(sheet.Rows); i++ {
- if inputcode != "" && inputcode != sheet.Rows[i].Cells[0].Value{
- continue
- }
- if inputname !="" && inputname != sheet.Rows[i].Cells[4].Value {
- continue
- }
- var List []supplier.OilSupplier
- CompanyName = sheet.Rows[i].Cells[4].Value
- where := "SupplierName = '" + CompanyName + "'"
- svc.GetEntitysByWhere(OilSupplierName, where, &List)
- Compare.SortCoding = sheet.Rows[i].Cells[0].Value
- Compare.SortName = sheet.Rows[i].Cells[1].Value
- Compare.Level = sheet.Rows[i].Cells[2].Value
- //Compare.SupplierCode = sheet.Rows[i].Cells[3].Value
- Compare.SupplierName = sheet.Rows[i].Cells[4].Value
- //Compare.SurplusCount = sheet.Rows[i].Cells[5].Value
- Compare.ManagementUnitType = sheet.Rows[i].Cells[6].Value
- //Compare.EliminationCause = sheet.Rows[i].Cells[7].Value
- //Compare.AccessList = sheet.Rows[i].Cells[8].Value
- //Compare.SupplierSubTime = sheet.Rows[i].Cells[9].Value
- //Compare.ProductType = sheet.Rows[i].Cells[10].Value
- //Compare.Editor = sheet.Rows[i].Cells[11].Value
- //Compare.EditingTime = sheet.Rows[i].Cells[12].Value
- //Compare.FlowState = sheet.Rows[i].Cells[13].Value
- //Compare.ProcessNotes = sheet.Rows[i].Cells[14].Value
- //Compare.Reviewime = sheet.Rows[i].Cells[15].Value
- //Compare.Brand = sheet.Rows[i].Cells[16].Value
- //Compare.WorkCode = sheet.Rows[i].Cells[17].Value
- //Compare.WorkType = sheet.Rows[i].Cells[18].Value
- //Compare.ProductScope = sheet.Rows[i].Cells[19].Value
- //Compare.IsBid = sheet.Rows[i].Cells[20].Value
- //Compare.MoreInfo = sheet.Rows[i].Cells[21].Value
- //Compare.ManufacturerCode = sheet.Rows[i].Cells[22].Value
- //Compare.ManufacturerName = sheet.Rows[i].Cells[23].Value
- Compare.Diff = "0"
- if len(List) < 1 {
- Compare.Diff = "1"
- Comparelist = append(Comparelist, Compare)
- }
- if len(List) > 0 {
- var certsublist2 []suppliercertsub.OilSupplierCertSub
- namewhere := "SupplierId = '" + strconv.Itoa(List[0].Id) + "' and Code ='" + Compare.SortCoding + "' and SupplierTypeCode ='01'"
- svc.GetEntitysByWhere(OilSupplierCertSubName, namewhere, &certsublist2)
- if len(certsublist2) < 1 {
- Compare.Diff = "1"
- Comparelist = append(Comparelist, Compare)
- }
- }
- if Compare.Diff == "0" {
- Comparelistnow = append(Comparelistnow,Compare)
- }
- }
- for _,nowlist := range Comparelistnow {
- Comparelist = append(Comparelist,nowlist)
- }
- os.Remove(filePath)
- var datainfo DataInfo
- datainfo.Items = Comparelist
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 导出数据到word,作为导出pdf的中间步骤
- // @Description 数据存入word
- // @Success 200 {object} controllers.Request
- // @router /exportpdf/:tbid/:typecode [post]
- func (this *OilGoodsAptitudeController) PdfExport() {
- Id := this.Ctx.Input.Param(":tbid")
- SupplierTypeCode := this.Ctx.Input.Param(":typecode")
- var Url string
- var fileName string
- var model1 supplierdataentry.SupplierDataEntry
- var model2 supplierdataentry.SupplierCertDataEntry
- svc := supplierdataentry.GetSupplierDataEntryService(utils.DBE)
- where1 := "1=1"
- where1 += " AND Id = '" + Id + "'"
- where2 := "SupplierId = '" + Id + "' and SupplierTypecode='"+ SupplierTypeCode +"'"
- svc.GetEntityByWhere(OilSupplierName, where1, &model1)
- svc.GetEntityByWhere(OilSupplierCertName, where2, &model2)
- var tabledata []supplierdataentry.SupplierCertSubEntry
- where3:="SupplierId = '" + Id + "' and SupplierTypecode='"+ SupplierTypeCode +"' and Type in ('1','3')"//准入状态的准入项
- svc.GetEntitysByOrderbyWhere(TmpOilSupplierCertSubName, where3, "1", &tabledata)
- datamap := structToMapDemo(model1.OilSupplier)
- if model2.SupplierTypeCode == "01" {
- Url = utils.Cfg.MustValue("workflow", "goodsPdfHost")
- fileName = "待删除物资类准入范围.docx"
- } else if model2.SupplierTypeCode == "02" {
- Url = utils.Cfg.MustValue("workflow", "basisPdfHost")
- fileName = "待删除基建类准入范围.docx"
- datamap["TJInNotify"] = model1.TJInNotify
- } else {
- Url = utils.Cfg.MustValue("workflow", "techPdfHost")
- fileName = "待删除服务类准入范围.docx"
- }
- //model1
- datamap["SetupTime"] = model1.SetupTime.Format("2006年01月02日")
- datamap["QualifCert"] = model1.QualifCert
- datamap["QualifCertLevel"] = model1.QualifCertLevel
- datamap["SpecIndustryCert"] = model1.SpecIndustryCert
- datamap["MaunLicense"] = model1.MaunLicense
- if model1.HseTraining == "1" {
- datamap["HseTraining"] = "是"
- } else {
- datamap["HseTraining"] = "否"
- }
- if model1.OperType != "" {
- if model1.OperType == "1" || model1.OperType == "制造商"{
- datamap["OperType"] = "√制造商 □代理商 □贸易商"
- }else if model1.OperType == "2" || model1.OperType == "代理商"{
- datamap["OperType"] = "□制造商 √代理商 □贸易商"
- }else if model1.OperType == "3" || model1.OperType == "代理商"{
- datamap["OperType"] = "□制造商 □代理商 √贸易商"
- }else {
- datamap["OperType"] = "□制造商 □代理商 □贸易商"
- }
- }
- if model1.SpecTypeCode != "" {
- if model1.SpecTypeCode == "1"{
- datamap["SpecTypeCode"] = "√一般外部 □多元企业"
- }else if model1.SpecTypeCode == "2"{
- datamap["SpecTypeCode"] = "□一般外部 √多元企业"
- }else {
- datamap["SpecTypeCode"] = "□一般外部 □多元企业"
- }
- }
- if model1.Grade == "1"{
- datamap["Grade"] = "一级"
- }else if model1.SpecTypeCode == "2"{
- datamap["Grade"] = "二级"
- }
- datamap["Fax"] = model1.Fax
- datamap["CompanyTel"] = model1.CompanyTel
- datamap["SupplierName"] = model1.SupplierName
- datamap["Country"] = model1.Country
- datamap["MaunAgent"] = model1.MaunAgent
- datamap["SupplierCertificate"] = model1.SupplierCertificate
- datamap["MgrUnit"] = model1.MgrUnit
- datamap["CommercialNo"] = model1.CommercialNo
- datamap["CountryTaxNo"] = model1.CountryTaxNo
- datamap["OrganCode"] = model1.OrganCode
- datamap["Address"] = model1.Address
- datamap["ZipCode"] = model1.ZipCode
- datamap["LinkAddress"] = model1.LinkAddress
- datamap["LinkZipCode"] = model1.LinkZipCode
- datamap["QualitySystemCert"] = model1.QualitySystemCert
- datamap["ProductQualityCert"] = model1.ProductQualityCert
- datamap["MaunLicense"] = model1.MaunLicense
- datamap["LegalPerson"] = model1.LegalPerson
- datamap["CompanyType"] = model1.CompanyType
- datamap["ContactName"] = model1.ContactName
- datamap["RegCapital"] = strconv.FormatFloat(model1.RegCapital,'f',2,64)+"万元"+model1.Currency
- datamap["DepositBank"] = model1.DepositBank
- datamap["BankAccount"] = model1.BankAccount
- datamap["Mobile"] = model1.Mobile
- datamap["EMail"] = model1.EMail
- datamap["BankCreditRating"] = model1.BankCreditRating
- datamap["BusinessScope"] = model1.BusinessScope
- datamap["Telphone"] = model1.Telphone
- datamap["AccessCardNo"] = model2.AccessCardNo
- datamap["PrintYear"] = time.Now().Year()
- datamap["PrintMonth"] = time.Now().Month()
- datamap["PrintDay"] = time.Now().Day()
- datamap["Name"] = ""
- if len(tabledata) != 0 {
- var Name string
- Name = "\n待删除准入范围:"+ tabledata[0].Code
- Name = Name + " " + tabledata[0].Name
- var i int
- for i = 1; i < len(tabledata); i++ {
- Name += ";"
- Name += tabledata[i].Code
- Name = Name + " " + tabledata[i].Name
- }
- //if i == 100 {
- // Name += "(准入范围未完全显示,请到系统查看详情)"
- //}
- datamap["Name"] =datamap["Name"].(string) + Name
- } else {
- datamap["Name"] =datamap["Name"].(string)
- }
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- retDocUrl := svcActiviti.FillWordTemplate(datamap, Url, fileName)
- var datainfo ErrorDataInfo
- datainfo.Code = 0
- datainfo.Item = retDocUrl
- datainfo.Message = "准备导出"
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 确认更新后的删除/暂停企业准入范围 2020-12-18
- // @Description 修改实体
- // @Success 200 {object} controllers.Request
- // @router /delete-suspend [post]
- func (this *OilGoodsAptitudeController) DeleteSuspend() {
- var errinfo ErrorInfo
- var err error
- var list []supplier.OilSupplierContrast
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- //svc.GetEntitysByWhere("OilSupplierContrast", "TwoOneCount = 0", &list)
- svc.GetEntitysByWhere("OilSupplierContrast", "1=1", &list)
- for _,item := range list{
- var sub []suppliercertsub.OilSupplierCertSub
- svc.GetEntitysByWhere("OilSupplierCertSub", "SupplierTypeCode = '01' and SupplierId = " + strconv.Itoa(item.Id), &sub)
- for _, itemSub := range sub {
- 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"
- sql += " where class.Code = '"+ itemSub.Code + "'"
- model, _ := svc.DBE.QueryString(sql)
- var subDelete suppliercertsub.OilSupplierCertSub1
- if model != nil {
- code := strings.Split(model[0]["Codes"], ",")
- cols := []string{"GoodsLevel", "Name"}
- subDelete.GoodsLevel = model[0]["GoodsLevel"]
- subDelete.Name = model[0]["Name"]
- //2升1不变
- if model[0]["GoodsLevel"] == "1" && itemSub.GoodsLevel == "2" {
- colsC := []string{"IsDelete"}
- colsS := []string{"IsQuestion"}
- item.IsDelete = 1
- itemSub.IsQuestion = 1
- svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &itemSub, colsS, "Id = "+strconv.Itoa(itemSub.Id))
- svc.UpdateEntityBywheretbl("OilSupplierContrast", &item, colsC, "Id = "+strconv.Itoa(item.Id))
- continue
- }
- // 1降2修改
- if item.OneTwoCount > 0 {
- err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id))
- }
- cols = append(cols, "DueTime")
- cols = append(cols, "CertSubStatus")
- subDelete.CertSubStatus = "2"
- //subDelete.DueTime = "2021-06-06 00:00:00"
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- DueTimeStr := paramSvc.GetBaseparameterMessage("GFZT", "paramset", "Suspend")
- //fmt.Println("返回的时间", DueTimeStr)
- //local, _ := time.LoadLocation("Local")
- //theTime, _ := time.ParseInLocation("2006-01-02", DueTimeStr, local)
- currentTime := time.Now()
- days,_ := strconv.Atoi(DueTimeStr)
- subDelete.DueTime = currentTime.AddDate(0, 0, days)
- i := 1
- //暂停
- for _, value := range code {
- if i == 36 || i == 37 || i == 1 {
- 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) {
- err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
- var model1 supplierpausereason.OilSupplierPauseReason
- model1.SupplierId = item.Id
- model1.CertSubId = itemSub.Id
- model1.CertSubStatus = "2"
- model1.SupplierCertId = itemSub.SupplierCertId
- model1.BackReason = "老数据导入缺资质"
- model1.CreateOn = time.Now()
- model1.CreateBy = this.User.Realname
- model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
- break
- }
- } else if i > 10 {
- if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
- err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
- var model1 supplierpausereason.OilSupplierPauseReason
- model1.SupplierId = item.Id
- model1.CertSubId = itemSub.Id
- model1.CertSubStatus = "2"
- model1.SupplierCertId = itemSub.SupplierCertId
- model1.BackReason = "老数据导入缺资质"
- model1.CreateOn = time.Now()
- model1.CreateBy = this.User.Realname
- model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
- break
- }
- } else {
- if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
- err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = " + strconv.Itoa(itemSub.Id))
- var model1 supplierpausereason.OilSupplierPauseReason
- model1.SupplierId = item.Id
- model1.CertSubId = itemSub.Id
- model1.CertSubStatus = "2"
- model1.SupplierCertId = itemSub.SupplierCertId
- model1.BackReason = "老数据导入缺资质"
- model1.CreateOn = time.Now()
- model1.CreateBy = this.User.Realname
- model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
- break
- }
- }
- i += 1
- }
- } else {
- // 删除
- err = svc.DeleteEntityById(itemSub.Id, &subDelete)
- }
- }
- if item.TwoOneCount == 0 {
- err = svc.DeleteTable("OilSupplierContrast", "Id = " + strconv.Itoa(item.Id))
- }
- }
- if err == nil {
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "修改失败!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
|