| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375 |
- 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/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/workflow"
- "dashoo.cn/backend/api/business/baseUser"
- "dashoo.cn/backend/api/business/oilsupplier/goodsaptitude"
- . "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 获取列表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/:id [post]
- func (this *OilGoodsAptitudeController) AddEntity() {
- classId := this.Ctx.Input.Param(":id")
- var model goodsaptitude.OilGoodsAptitude
- var jsonBlob = this.Ctx.Input.RequestBody
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- json.Unmarshal(jsonBlob, &model)
- model.CreateOn = time.Now()
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- model.ClassId, _ = strconv.Atoi(classId)
- //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
- _, err := svc.InsertEntityBytbl(""+OilGoodsAptitudeName, &model)
- var errinfo ErrorDataInfo
- if err == nil {
- //新增
- errinfo.Message = "添加成功!"
- errinfo.Code = 0
- errinfo.Item = model.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
- 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)
- var errinfo ErrorDataInfo
- 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)
- opdesc := "删除-" + Id
- err := svc.DeleteOperationAndWriteLogBytbl(""+OilGoodsAptitudeName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "钻井日报")
- 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()
- }
- session := utils.DBE.NewSession()
- err := session.Begin()
- svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
- err = svc.TruncateTable(Tmp_OilGoodsAptitudeName)
- if err != nil {
- session.Rollback()
- errorinfo.Code = -2
- errorinfo.Message = "导入失败!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- err = svc.TruncateTable(Tmp_OilGoodsAptitudeClassName)
- if err != nil {
- session.Rollback()
- errorinfo.Code = -2
- errorinfo.Message = "导入失败!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- _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, ",")
- defer func() {
- session.Close()
- }()
- codemap := make(map[string]int)
- for i := 2; i < len(sheet.Rows); i++ {
- lineNo := strconv.Itoa(i + 1)
- this.OperationCell(svc, lineNo, columnArr, codemap, sheet.Rows[i].Cells, &errLineNum)
- }
- os.Remove(filePath)
- if errLineNum != "" {
- session.Rollback()
- errorinfo.Code = -1
- errorinfo.Message = "导入失败!错误行号:" + errLineNum
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- } else {
- session.Commit()
- elapsed := time.Since(t)
- log.Println(elapsed)
- errorinfo.Code = 0
- errorinfo.Message = "导入成功!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- }
- func (this *OilGoodsAptitudeController) OperationCell(svc *goodsaptitude.OilGoodsAptitudeSession, 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 + ","
- }
- }()
- 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 将导入的数据 导入到正式表
- // @Description get SampleType by token
- // @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()
- }
- 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 获取删除的准入项
- // @Description get user by token
- // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
- // @router /delcertsublist [get]
- func (this *OilGoodsAptitudeController) GetDelCertSubList() {
- //获取分页信息
- 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 + "'"
- }
- }
- where = where + " and Type in (1, 3)"
- svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- var list []suppliercertsub.Tmp_OilSupplierCertSub
- total := svc.GetMyPagingEntitiesWithOrderBytbl(TmpOilSupplierCertSubName, 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} []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)
- var supplierCertSubList []suppliercertsub.Tmp_OilSupplierCertSub
- wheredel := "1=1 and SupplierTypeCode = '01'"
- if supplierId != "" {
- wheredel += " and SupplierId=" + supplierId
- }
- if id != "" {
- wheredel += " and Id=" + id
- }
- svc.GetEntitysByWhere(TmpOilSupplierCertSubName, wheredel, &supplierCertSubList)
- var errinfo ErrorInfo
- for _, item := range supplierCertSubList {
- 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()
- }
- }
- for _, item := range supplierCertSubList {
- where := "Id = " + strconv.Itoa(item.Id)
- err = svc.DeleteEntityBytbl(TmpOilSupplierCertSubName, where)
- }
- 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} 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()
- }
|