2
3

goodsaptitude.go 83 KB

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