2
3

goodsaptitude.go 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375
  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/workflow"
  21. "dashoo.cn/backend/api/business/baseUser"
  22. "dashoo.cn/backend/api/business/oilsupplier/goodsaptitude"
  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/:id [post]
  320. func (this *OilGoodsAptitudeController) AddEntity() {
  321. classId := this.Ctx.Input.Param(":id")
  322. var model goodsaptitude.OilGoodsAptitude
  323. var jsonBlob = this.Ctx.Input.RequestBody
  324. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  325. json.Unmarshal(jsonBlob, &model)
  326. model.CreateOn = time.Now()
  327. model.CreateBy = this.User.Realname
  328. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  329. model.ClassId, _ = strconv.Atoi(classId)
  330. //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  331. _, err := svc.InsertEntityBytbl(""+OilGoodsAptitudeName, &model)
  332. var errinfo ErrorDataInfo
  333. if err == nil {
  334. //新增
  335. errinfo.Message = "添加成功!"
  336. errinfo.Code = 0
  337. errinfo.Item = model.Id
  338. this.Data["json"] = &errinfo
  339. this.ServeJSON()
  340. } else {
  341. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  342. errinfo.Code = -1
  343. this.Data["json"] = &errinfo
  344. this.ServeJSON()
  345. }
  346. }
  347. // @Title 添加
  348. // @Description 新增
  349. // @Success 200 {object} controllers.Request
  350. // @router /add_2019 [post]
  351. func (this *OilGoodsAptitudeController) AddEntity_2019() {
  352. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  353. var model goodsaptitudeclass.OilGoodsAptitudeClass
  354. var jsonBlob = this.Ctx.Input.RequestBody
  355. json.Unmarshal(jsonBlob, &model)
  356. model.ParentId = -1
  357. model.Edition = "2"
  358. model.CreateOn = time.Now()
  359. model.CreateBy = this.User.Realname
  360. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  361. _, err := svc.InsertEntityBytbl(""+OilGoodsAptitudeClassName, &model)
  362. var model2 goodsaptitude.OilGoodsAptitude
  363. json.Unmarshal(jsonBlob, &model2)
  364. model2.ClassId = model.Id
  365. model2.Edition = "2"
  366. model2.CreateOn = time.Now()
  367. model2.CreateBy = this.User.Realname
  368. model2.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  369. _, err = svc.InsertEntityBytbl(""+OilGoodsAptitudeName, &model2)
  370. var errinfo ErrorDataInfo
  371. if err == nil {
  372. //新增
  373. errinfo.Message = "添加成功!"
  374. errinfo.Code = 0
  375. errinfo.Item = model2.Id
  376. this.Data["json"] = &errinfo
  377. this.ServeJSON()
  378. } else {
  379. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  380. errinfo.Code = -1
  381. this.Data["json"] = &errinfo
  382. this.ServeJSON()
  383. }
  384. }
  385. // @Title 修改实体
  386. // @Description 修改实体
  387. // @Success 200 {object} controllers.Request
  388. // @router /update/:id [post]
  389. func (this *OilGoodsAptitudeController) UpdateEntity() {
  390. id := this.Ctx.Input.Param(":id")
  391. var errinfo ErrorInfo
  392. if id == "" {
  393. errinfo.Message = "操作失败!请求信息不完整"
  394. errinfo.Code = -2
  395. this.Data["json"] = &errinfo
  396. this.ServeJSON()
  397. return
  398. }
  399. var model goodsaptitude.OilGoodsAptitude
  400. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  401. var jsonBlob = this.Ctx.Input.RequestBody
  402. json.Unmarshal(jsonBlob, &model)
  403. model.ModifiedOn = time.Now()
  404. model.ModifiedBy = this.User.Realname
  405. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  406. cols := []string{
  407. "Id",
  408. "Code",
  409. "Name",
  410. "BigClassName",
  411. "MiddleClassName",
  412. "SmallClassName",
  413. "GoodsName",
  414. "GoodsLevel",
  415. "GoodsDesc",
  416. "Standard",
  417. "CompanyType",
  418. "F01",
  419. "F02",
  420. "F03",
  421. "F04",
  422. "F05",
  423. "F06",
  424. "F07",
  425. "F08",
  426. "F09",
  427. "F10",
  428. "F11",
  429. "F12",
  430. "F13",
  431. "F14",
  432. "F15",
  433. "F16",
  434. "F17",
  435. "F18",
  436. "F19",
  437. "F20",
  438. "F21",
  439. "F22",
  440. "F23",
  441. "F24",
  442. "F25",
  443. "F26",
  444. "F27",
  445. "F28",
  446. "F29",
  447. "F30",
  448. "F31",
  449. "F32",
  450. "F33",
  451. "F34",
  452. "F35",
  453. "F36",
  454. "F37",
  455. "F38",
  456. "F39",
  457. "F40",
  458. "F41",
  459. "F42",
  460. "F43",
  461. "F44",
  462. "F45",
  463. "F46",
  464. "Remark",
  465. "DeletionStateCode",
  466. "CreateOn",
  467. "CreateUserId",
  468. "CreateBy",
  469. "ModifiedOn",
  470. "ModifiedUserId",
  471. "ModifiedBy",
  472. }
  473. err := svc.UpdateEntityBytbl(""+OilGoodsAptitudeName, id, &model, cols)
  474. if err == nil {
  475. errinfo.Message = "修改成功!"
  476. errinfo.Code = 0
  477. this.Data["json"] = &errinfo
  478. this.ServeJSON()
  479. } else {
  480. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  481. errinfo.Code = -1
  482. this.Data["json"] = &errinfo
  483. this.ServeJSON()
  484. }
  485. }
  486. // @Title 修改实体
  487. // @Description 修改实体
  488. // @Success 200 {object} controllers.Request
  489. // @router /update_2019/:id [post]
  490. func (this *OilGoodsAptitudeController) UpdateEntity_2019() {
  491. id := this.Ctx.Input.Param(":id")
  492. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  493. var errinfo ErrorInfo
  494. if id == "" {
  495. errinfo.Message = "操作失败!请求信息不完整"
  496. errinfo.Code = -2
  497. this.Data["json"] = &errinfo
  498. this.ServeJSON()
  499. return
  500. }
  501. var model goodsaptitude.OilGoodsAptitude
  502. var jsonBlob = this.Ctx.Input.RequestBody
  503. json.Unmarshal(jsonBlob, &model)
  504. model.ModifiedOn = time.Now()
  505. model.ModifiedBy = this.User.Realname
  506. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  507. cols := []string{
  508. "F01",
  509. "F02",
  510. "F03",
  511. "F04",
  512. "F05",
  513. "F06",
  514. "F07",
  515. "F08",
  516. "F09",
  517. "F10",
  518. "F11",
  519. "F12",
  520. "F13",
  521. "F14",
  522. "F15",
  523. "F16",
  524. "F17",
  525. "F18",
  526. "F19",
  527. "F20",
  528. "F21",
  529. "F22",
  530. "F23",
  531. "F24",
  532. "F25",
  533. "F26",
  534. "F27",
  535. "F28",
  536. "F29",
  537. "F30",
  538. "F31",
  539. "F32",
  540. "F33",
  541. "F34",
  542. "F35",
  543. "F36",
  544. "F37",
  545. "F38",
  546. "F39",
  547. "F40",
  548. "F41",
  549. "F42",
  550. "F43",
  551. "F44",
  552. "F45",
  553. "F46",
  554. "ModifiedOn",
  555. "ModifiedUserId",
  556. "ModifiedBy",
  557. }
  558. err := svc.UpdateEntityBytbl(""+OilGoodsAptitudeName, id, &model, cols)
  559. var model2 goodsaptitudeclass.OilGoodsAptitudeClass
  560. json.Unmarshal(jsonBlob, &model2)
  561. model2.ModifiedOn = time.Now()
  562. model2.ModifiedBy = this.User.Realname
  563. model2.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  564. cols2 := []string{
  565. "Code",
  566. "Name",
  567. "ModifiedOn",
  568. "ModifiedUserId",
  569. "ModifiedBy",
  570. }
  571. err = svc.UpdateEntityBytbl(""+OilGoodsAptitudeClassName, model.ClassId, &model2, cols2)
  572. if err == nil {
  573. errinfo.Message = "修改成功!"
  574. errinfo.Code = 0
  575. this.Data["json"] = &errinfo
  576. this.ServeJSON()
  577. } else {
  578. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  579. errinfo.Code = -1
  580. this.Data["json"] = &errinfo
  581. this.ServeJSON()
  582. }
  583. }
  584. // @Title 修改实体
  585. // @Description 修改实体
  586. // @Success 200 {object} controllers.Request
  587. // @router /updatecode/:id [post]
  588. func (this *OilGoodsAptitudeController) UpdateCodeEntity() {
  589. var errinfo ErrorInfo
  590. var err error
  591. id := this.Ctx.Input.Param(":id")
  592. if id == "" {
  593. errinfo.Message = "操作失败!请求信息不完整"
  594. errinfo.Code = -2
  595. this.Data["json"] = &errinfo
  596. this.ServeJSON()
  597. return
  598. }
  599. var classall goodsaptitude.OilGoodsAptitudeClassView
  600. var model goodsaptitudeclass.OilGoodsAptitudeClass
  601. var classmodel []goodsaptitudeclass.OilGoodsAptitudeClass
  602. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  603. var jsonBlob = this.Ctx.Input.RequestBody
  604. json.Unmarshal(jsonBlob, &classall)
  605. model.ModifiedOn = time.Now()
  606. model.ModifiedBy = this.User.Realname
  607. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  608. colsName := []string{"Name"}
  609. colsCode := []string{"Code"}
  610. //svc.GetEntityById(id, &model)
  611. if classall.Name1 != "" {
  612. where := " Name = '" + classall.Name1 + "' and Id <> " + utils.ToStr(classall.Id1)
  613. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  614. if len(classmodel) > 0 {
  615. errinfo.Message = "大类名称已存在,请重新添加!"
  616. errinfo.Code = -1
  617. this.Data["json"] = &errinfo
  618. this.ServeJSON()
  619. return
  620. } else {
  621. model.Name = classall.Name1
  622. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id1, &model, colsName)
  623. }
  624. }
  625. if classall.Name2 != "" {
  626. where := " Name = '" + classall.Name2 + "' and Id <> " + utils.ToStr(classall.Id2)
  627. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  628. if len(classmodel) > 0 {
  629. errinfo.Message = "中类名称已存在,请重新添加!"
  630. errinfo.Code = -1
  631. this.Data["json"] = &errinfo
  632. this.ServeJSON()
  633. return
  634. } else {
  635. model.Name = classall.Name2
  636. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id2, &model, colsName)
  637. }
  638. }
  639. if classall.Name3 != "" {
  640. where := " Name = '" + classall.Name3 + "' and Id <> " + utils.ToStr(classall.Id3)
  641. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  642. if len(classmodel) > 0 {
  643. errinfo.Message = "小类名称已存在,请重新添加!"
  644. errinfo.Code = -1
  645. this.Data["json"] = &errinfo
  646. this.ServeJSON()
  647. return
  648. } else {
  649. model.Name = classall.Name3
  650. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id3, &model, colsName)
  651. }
  652. }
  653. if classall.Name4 != "" {
  654. where := " Name = '" + classall.Name4 + "' and Id <> " + utils.ToStr(classall.Id4)
  655. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  656. if len(classmodel) > 0 {
  657. errinfo.Message = "品名已存在,请重新添加!"
  658. errinfo.Code = -1
  659. this.Data["json"] = &errinfo
  660. this.ServeJSON()
  661. return
  662. } else {
  663. model.Name = classall.Name4
  664. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id4, &model, colsName)
  665. }
  666. }
  667. if classall.Code1 != "" {
  668. where := " Code = " + classall.Code1 + " and Id <> " + utils.ToStr(classall.Id1)
  669. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  670. if len(classmodel) > 0 {
  671. errinfo.Message = "大类编码已存在,请重新添加!"
  672. errinfo.Code = -1
  673. this.Data["json"] = &errinfo
  674. this.ServeJSON()
  675. return
  676. } else {
  677. model.Code = classall.Code1
  678. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id1, &model, colsCode)
  679. }
  680. }
  681. if classall.Code2 != "" {
  682. where := " Code = " + classall.Code2 + " and Id <> " + utils.ToStr(classall.Id2)
  683. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  684. if len(classmodel) > 0 {
  685. errinfo.Message = "中类编码已存在,请重新添加!"
  686. errinfo.Code = -1
  687. this.Data["json"] = &errinfo
  688. this.ServeJSON()
  689. return
  690. } else {
  691. model.Code = classall.Code2
  692. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id2, &model, colsCode)
  693. }
  694. }
  695. if classall.Code3 != "" {
  696. where := " Code = " + classall.Code3 + " and Id <> " + utils.ToStr(classall.Id3)
  697. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  698. if len(classmodel) > 0 {
  699. errinfo.Message = "小类编码已存在,请重新添加!"
  700. errinfo.Code = -1
  701. this.Data["json"] = &errinfo
  702. this.ServeJSON()
  703. return
  704. } else {
  705. model.Code = classall.Code3
  706. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id3, &model, colsCode)
  707. }
  708. }
  709. if classall.Code4 != "" {
  710. where := " Code = " + classall.Code4 + " and Id <> " + utils.ToStr(classall.Id4)
  711. svc.GetEntitysByWhere(OilGoodsAptitudeClassName, where, &classmodel)
  712. if len(classmodel) > 0 {
  713. errinfo.Message = "品名编码已存在,请重新添加!"
  714. errinfo.Code = -1
  715. this.Data["json"] = &errinfo
  716. this.ServeJSON()
  717. return
  718. } else {
  719. model.Code = classall.Code4
  720. err = svc.UpdateEntityBytbl(OilGoodsAptitudeClassName, classall.Id4, &model, colsCode)
  721. }
  722. }
  723. if err == nil {
  724. errinfo.Message = "修改成功!"
  725. errinfo.Code = 0
  726. this.Data["json"] = &errinfo
  727. this.ServeJSON()
  728. } else {
  729. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  730. errinfo.Code = -1
  731. this.Data["json"] = &errinfo
  732. this.ServeJSON()
  733. }
  734. }
  735. // @Title 删除单条信息
  736. // @Description
  737. // @Success 200 {object} ErrorInfo
  738. // @Failure 403 :id 为空
  739. // @router /delete/:Id [delete]
  740. func (this *OilGoodsAptitudeController) DeleteEntity() {
  741. Id := this.Ctx.Input.Param(":Id")
  742. var errinfo ErrorInfo
  743. if Id == "" {
  744. errinfo.Message = "操作失败!请求信息不完整"
  745. errinfo.Code = -2
  746. this.Data["json"] = &errinfo
  747. this.ServeJSON()
  748. return
  749. }
  750. var model goodsaptitude.OilGoodsAptitude
  751. var entityempty goodsaptitude.OilGoodsAptitude
  752. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  753. opdesc := "删除-" + Id
  754. err := svc.DeleteOperationAndWriteLogBytbl(""+OilGoodsAptitudeName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "钻井日报")
  755. if err == nil {
  756. errinfo.Message = "删除成功"
  757. errinfo.Code = 0
  758. this.Data["json"] = &errinfo
  759. this.ServeJSON()
  760. } else {
  761. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  762. errinfo.Code = -1
  763. this.Data["json"] = &errinfo
  764. this.ServeJSON()
  765. }
  766. }
  767. // @Title get 查询
  768. // @Description get SampleType by token
  769. // @Success 200 {object} sampletype.SampleType
  770. // @router /goodsparentlist/:name [get]
  771. func (this *OilGoodsAptitudeController) GoodsParentList() {
  772. Name := this.Ctx.Input.Param(":name")
  773. if Name != "" {
  774. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  775. where1 := "1=1"
  776. where1 += " AND Name LIKE '%" + Name + "%' OR Code LIKE '" + Name + "%' "
  777. sqlStr := "SELECT Id, Code, Name, concat(Code, ' ', Name) as CodeName, ParentId FROM OilGoodsAptitudeClass " +
  778. "WHERE " + where1 + " AND Edition='1' AND DeletionStateCode = 0 ORDER BY Code"
  779. list, _ := svc.DBE.QueryString(sqlStr)
  780. /*
  781. sql := "SELECT Id, Code, Name, concat(Code, ' ', Name) as CodeName, ParentId FROM OilGoodsAptitudeClass " +
  782. "WHERE DeletionStateCode = 0 AND " + where1 + " OR Id = (" + sqlStr + ")" +" ORDER BY Code"
  783. list, _ := svc.DBE.QueryString(sql)*/
  784. var datainfo DataInfo
  785. datainfo.Items = list
  786. this.Data["json"] = &datainfo
  787. this.ServeJSON()
  788. }
  789. }
  790. // @Title get 获取子类
  791. // @Description get SampleType by token
  792. // @Success 200 {object} sampletype.SampleType
  793. // @router /goodschildlist/:id [get]
  794. func (this *OilGoodsAptitudeController) GoodsChildList() {
  795. ParentId := this.Ctx.Input.Param(":id")
  796. 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"
  797. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  798. list, _ := svc.DBE.QueryString(sqlStr)
  799. var datainfo DataInfo
  800. datainfo.Items = list
  801. this.Data["json"] = &datainfo
  802. this.ServeJSON()
  803. }
  804. // @Title get 获取子类
  805. // @Description get SampleType by token
  806. // @Success 200 {object} sampletype.SampleType
  807. // @router /goodschildlistbypid/:parentid [get]
  808. func (this *OilGoodsAptitudeController) GoodsChildLisByParentId() {
  809. ParentId := this.Ctx.Input.Param(":parentid")
  810. GoodsLevel := this.GetString("GoodsLevel")
  811. sqlStr := "SELECT o.Id, o.`Code`, o.`Name`, concat(o.Code, ' ', o.Name) as CodeName, o.ParentId, g.GoodsLevel," +
  812. " (CASE WHEN length(Code)>=8 THEN '1' ELSE '0' END) as Leaf FROM OilGoodsAptitudeClass o " +
  813. " LEFT JOIN `OilGoodsAptitude` g ON (g.ClassId = o.Id)" +
  814. " 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"
  815. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  816. list, _ := svc.DBE.QueryString(sqlStr)
  817. var datainfo DataInfo
  818. datainfo.Items = list
  819. this.Data["json"] = &datainfo
  820. this.ServeJSON()
  821. }
  822. // @Title get 导出ex
  823. // @Description get SampleType by token
  824. // @Success 200 {object} sampletype.SampleType
  825. // @router /exportexcelall [get]
  826. func (this *OilGoodsAptitudeController) ExportExcelAll() {
  827. //获取分页信息
  828. //page := this.GetPageInfoForm()
  829. where := " 1=1 "
  830. orderby := "Code"
  831. asc := true
  832. Order := this.GetString("Order")
  833. Prop := this.GetString("Prop")
  834. if Order != "" && Prop != "" {
  835. orderby = Prop
  836. if Order == "asc" {
  837. asc = true
  838. } else {
  839. asc = false
  840. }
  841. }
  842. Edition := this.GetString("Edition")
  843. if Edition != "" {
  844. where = where + " and Edition = '" + Edition + "'"
  845. }
  846. t := time.Now()
  847. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  848. var list []goodsaptitude.OilGoodsAptitudeView
  849. svc.GetMyPagingEntitiesWithOrderBytbl(OilGoodsAptDetailViewName, 0, 0, orderby, asc, &list, where)
  850. var title []string
  851. filetitle := "物资类"
  852. //自定义显示列
  853. showcolumnarr := this.GetString("showcolumnarr")
  854. showcolumnnamearr := this.GetString("showcolumnnamearr")
  855. titlestring := showcolumnnamearr
  856. title = strings.Split(titlestring, ",")
  857. f := xlsx.NewFile()
  858. sheet, _ := f.AddSheet(filetitle)
  859. //rowhead := sheet.AddRow()
  860. //rowhead.WriteSlice(&title, -1)
  861. cellname := strings.Split(showcolumnarr, ",")
  862. row := sheet.AddRow()
  863. row2 := sheet.AddRow()
  864. row.WriteSlice(&cellname, -1)
  865. row2.WriteSlice(&cellname, -1)
  866. //doublename := "制造商,贸易商"
  867. //doubleslice := strings.Split(doublename, ",")
  868. //rowhead := sheet.AddRow()
  869. //rowhead.WriteSlice(&doubleslice, -1)
  870. intsix := svc.GetNumOfPass("0")
  871. intStr := strconv.FormatInt(intsix, 10)
  872. alluse ,_ := strconv.Atoi(intStr)
  873. for i := 0; i < alluse+12; i++ {
  874. row.Cells[i].Merge(0, 1)
  875. }
  876. intsix1 := svc.GetNumOfPass("2")
  877. intStr1 := strconv.FormatInt(intsix1, 10)
  878. traker ,_ := strconv.Atoi(intStr1)
  879. row.Cells[alluse+12].Merge(traker-1,0)
  880. row.Cells[alluse+12].Value = "贸易产品"
  881. intsix2 := svc.GetNumOfPass("1")
  882. intStr2 := strconv.FormatInt(intsix2, 10)
  883. maker ,_ := strconv.Atoi(intStr2)
  884. row.Cells[alluse+12+traker].Merge(maker-1,0)
  885. row.Cells[alluse+12+traker].Value = "制造产品"
  886. for _, item := range list {
  887. var enumModel goodsaptitude.OilGoodsAptitudeView
  888. tmpModel := &item
  889. enumModel = *tmpModel
  890. immumodel := reflect.ValueOf(&enumModel)
  891. elem := immumodel.Elem()
  892. row := sheet.AddRow()
  893. for _, name := range title {
  894. cell := row.AddCell()
  895. if strings.HasPrefix(name, "F") {
  896. var val = elem.FieldByName(name).String()
  897. if val == "1" {
  898. cell.Value = "是"
  899. } else {
  900. cell.Value = ""
  901. }
  902. } else {
  903. cell.Value = elem.FieldByName(name).String()
  904. }
  905. }
  906. }
  907. for c, cl := 0, len(sheet.Cols); c < cl; c++ {
  908. sheet.Cols[c].Width = 20
  909. }
  910. //this.SaveSampleXlsx(filetitle, title, showcolumnarr, list, f)
  911. dir := "static/file/excel/report/" + this.GetAccode()
  912. SaveDirectory(dir)
  913. path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
  914. f.Save(path)
  915. var sw *Seaweed
  916. var filer []string
  917. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  918. filer = []string{_filer}
  919. }
  920. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  921. _, _, fID, _ := sw.UploadFile(path, "", "")
  922. retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  923. os.Remove(path)
  924. fmt.Println("==retDocWatermarkUrl==", retDocUrl)
  925. this.Data["json"] = retDocUrl
  926. this.ServeJSON()
  927. elapsed := time.Since(t)
  928. fmt.Println(elapsed)
  929. }
  930. // @Title get 导出ex
  931. // @Description get SampleType by token
  932. // @Success 200 {object} sampletype.SampleType
  933. // @router /exportexcelall2019 [get]
  934. func (this *OilGoodsAptitudeController) ExportExcelAll2019() {
  935. //获取分页信息
  936. //page := this.GetPageInfoForm()
  937. where := " 1=1 "
  938. orderby := "Code"
  939. asc := true
  940. Order := this.GetString("Order")
  941. Prop := this.GetString("Prop")
  942. if Order != "" && Prop != "" {
  943. orderby = Prop
  944. if Order == "asc" {
  945. asc = true
  946. } else {
  947. asc = false
  948. }
  949. }
  950. Edition := this.GetString("Edition")
  951. if Edition != "" {
  952. where = where + " and a.Edition = '" + Edition + "'"
  953. }
  954. t := time.Now()
  955. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  956. var list []goodsaptitude.OilGoodsAptitude_2
  957. svc.GetList_2019(OilGoodsAptitudeName, OilGoodsAptitudeClassName, 0, 0, orderby, asc, &list, where)
  958. var title []string
  959. filetitle := "物资类(顶级)"
  960. //自定义显示列
  961. showcolumnarr := this.GetString("showcolumnarr")
  962. showcolumnnamearr := this.GetString("showcolumnnamearr")
  963. titlestring := showcolumnnamearr
  964. title = strings.Split(titlestring, ",")
  965. f := xlsx.NewFile()
  966. sheet, _ := f.AddSheet(filetitle)
  967. cellname := strings.Split(showcolumnarr, ",")
  968. row := sheet.AddRow()
  969. row.WriteSlice(&cellname, -1)
  970. for _, item := range list {
  971. var enumModel goodsaptitude.OilGoodsAptitude_2
  972. tmpModel := &item
  973. enumModel = *tmpModel
  974. immumodel := reflect.ValueOf(&enumModel)
  975. elem := immumodel.Elem()
  976. row := sheet.AddRow()
  977. for _, name := range title {
  978. cell := row.AddCell()
  979. if strings.HasPrefix(name, "F") {
  980. var val = elem.FieldByName(name).String()
  981. if val == "1" {
  982. cell.Value = "是"
  983. } else {
  984. cell.Value = ""
  985. }
  986. } else {
  987. cell.Value = elem.FieldByName(name).String()
  988. }
  989. }
  990. }
  991. for c, cl := 0, len(sheet.Cols); c < cl; c++ {
  992. sheet.Cols[c].Width = 20
  993. }
  994. dir := "static/file/excel/report/" + this.GetAccode()
  995. SaveDirectory(dir)
  996. path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
  997. f.Save(path)
  998. var sw *Seaweed
  999. var filer []string
  1000. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  1001. filer = []string{_filer}
  1002. }
  1003. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  1004. _, _, fID, _ := sw.UploadFile(path, "", "")
  1005. retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  1006. os.Remove(path)
  1007. fmt.Println("==retDocWatermarkUrl==", retDocUrl)
  1008. this.Data["json"] = retDocUrl
  1009. this.ServeJSON()
  1010. elapsed := time.Since(t)
  1011. fmt.Println(elapsed)
  1012. }
  1013. // @Title get 导入excel
  1014. // @Description get SampleType by token
  1015. // @Success 200 {object} sampletype.SampleType
  1016. // @router /importexcel [get]
  1017. func (this *OilGoodsAptitudeController) ImportExcel() {
  1018. url := this.GetString("ExcelUrl")
  1019. var errorinfo ErrorInfo
  1020. if url == "" {
  1021. errorinfo.Code = -2
  1022. errorinfo.Message = "导入失败!"
  1023. this.Data["json"] = &errorinfo
  1024. this.ServeJSON()
  1025. }
  1026. session := utils.DBE.NewSession()
  1027. err := session.Begin()
  1028. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  1029. err = svc.TruncateTable(Tmp_OilGoodsAptitudeName)
  1030. if err != nil {
  1031. session.Rollback()
  1032. errorinfo.Code = -2
  1033. errorinfo.Message = "导入失败!"
  1034. this.Data["json"] = &errorinfo
  1035. this.ServeJSON()
  1036. }
  1037. err = svc.TruncateTable(Tmp_OilGoodsAptitudeClassName)
  1038. if err != nil {
  1039. session.Rollback()
  1040. errorinfo.Code = -2
  1041. errorinfo.Message = "导入失败!"
  1042. this.Data["json"] = &errorinfo
  1043. this.ServeJSON()
  1044. }
  1045. _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
  1046. filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
  1047. utils.DownloadFile(url, filename, _dir)
  1048. t := time.Now()
  1049. filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
  1050. xlFile, err := xlsx.OpenFile(filePath)
  1051. var errLineNum string
  1052. //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
  1053. if err != nil {
  1054. fmt.Printf("open failed: %s\n", err)
  1055. }
  1056. var sheet = xlFile.Sheets[0]
  1057. Fstrs := svc.GetFCode()
  1058. Fstrs = "GoodsLevel,GoodsDesc,Standard,CompanyType," + Fstrs
  1059. columnArr := strings.Split(Fstrs, ",")
  1060. defer func() {
  1061. session.Close()
  1062. }()
  1063. codemap := make(map[string]int)
  1064. for i := 2; i < len(sheet.Rows); i++ {
  1065. lineNo := strconv.Itoa(i + 1)
  1066. this.OperationCell(svc, lineNo, columnArr, codemap, sheet.Rows[i].Cells, &errLineNum)
  1067. }
  1068. os.Remove(filePath)
  1069. if errLineNum != "" {
  1070. session.Rollback()
  1071. errorinfo.Code = -1
  1072. errorinfo.Message = "导入失败!错误行号:" + errLineNum
  1073. this.Data["json"] = &errorinfo
  1074. this.ServeJSON()
  1075. } else {
  1076. session.Commit()
  1077. elapsed := time.Since(t)
  1078. log.Println(elapsed)
  1079. errorinfo.Code = 0
  1080. errorinfo.Message = "导入成功!"
  1081. this.Data["json"] = &errorinfo
  1082. this.ServeJSON()
  1083. }
  1084. }
  1085. func (this *OilGoodsAptitudeController) OperationCell(svc *goodsaptitude.OilGoodsAptitudeSession, lineNo string, columnArr []string, codemap map[string]int, cellsArr []*xlsx.Cell, errLineNum *string) {
  1086. defer func() {
  1087. if err := recover(); err != nil {
  1088. log.Println("err"+lineNo, err)
  1089. *errLineNum += lineNo + ","
  1090. }
  1091. }()
  1092. parentId := 0
  1093. classId := 0
  1094. cellsArrLen := len(cellsArr)
  1095. cellD := strings.TrimSpace(cellsArr[6].String())
  1096. var valstr = ""
  1097. for i := 0; i < cellsArrLen; {
  1098. if i < 8 {
  1099. var entity goodsaptitudeclass.Tmp_OilGoodsAptitudeClass
  1100. cellval := strings.TrimSpace(cellsArr[i].String())
  1101. fmt.Println(cellval)
  1102. _, has := codemap[cellval]
  1103. if !has {
  1104. if i != 0 {
  1105. upcode := cellsArr[i-2].String()
  1106. parentId = codemap[upcode]
  1107. }
  1108. entity.Code = cellval
  1109. entity.Name = strings.TrimSpace(cellsArr[i+1].String())
  1110. entity.Edition = "1"
  1111. entity.ParentId = parentId
  1112. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1113. entity.CreateBy = this.User.Realname
  1114. entity.CreateOn = time.Now()
  1115. _, err := svc.InsertEntityBytbl(Tmp_OilGoodsAptitudeClassName, &entity)
  1116. if err != nil {
  1117. panic(err)
  1118. break
  1119. }
  1120. classId = entity.Id
  1121. if i <= 6 {
  1122. codemap[cellval] = entity.Id
  1123. }
  1124. }
  1125. }
  1126. if i >= 8 {
  1127. valstr += "'" + cellsArr[i].String() + "',"
  1128. i++
  1129. } else {
  1130. i += 2
  1131. }
  1132. }
  1133. //for idx, cell := range cellsArr {
  1134. // if idx < 4 {
  1135. // cellstr := cell.String()
  1136. // //fmt.Printf("%s\n", cellstr)
  1137. // if strings.TrimSpace(cellstr) == "" {
  1138. // break
  1139. // }
  1140. // cellArr := strings.Fields(cellstr)
  1141. //
  1142. // //id := sessionsvc.SelectGoodsAptitudeClassCode(cellArr[0])
  1143. //
  1144. // var entity goodsaptitudeclass.Tmp_OilGoodsAptitudeClass
  1145. // _, has := codemap[cellArr[0]]
  1146. // if !has {
  1147. // if idx != 0 {
  1148. // upcellstr := cellsArr[idx-1].String()
  1149. // upcellArr := strings.Fields(upcellstr)
  1150. // parentId = codemap[upcellArr[0]]
  1151. // }
  1152. // entity.Code = cellArr[0]
  1153. // entity.Name = cellArr[1]
  1154. // entity.Edition = "1"
  1155. // entity.ParentId = parentId
  1156. // entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1157. // entity.CreateBy = this.User.Realname
  1158. // entity.CreateOn = time.Now()
  1159. //
  1160. // _, err := svc.InsertEntityBytbl(Tmp_OilGoodsAptitudeClassName, &entity)
  1161. // if err != nil {
  1162. // panic(err)
  1163. // break
  1164. // }
  1165. // classId = entity.Id
  1166. // if idx != 3 {
  1167. // codemap[cellArr[0]] = entity.Id
  1168. // }
  1169. // }
  1170. // }
  1171. // if idx >= 4 {
  1172. // valstr += "'" + cellsArr[idx].String() + "',"
  1173. // }
  1174. //}
  1175. if cellD != "" {
  1176. valstr = strings.Trim(valstr, ",")
  1177. valstr = strings.Replace(valstr, "是", "1", -1)
  1178. log.Println(cellsArr[6].String() + "==" + valstr)
  1179. var columnstr = ""
  1180. for l := 0; l < cellsArrLen-8; l++ {
  1181. columnstr += columnArr[l] + ","
  1182. }
  1183. columnstr = strings.Trim(columnstr, ",")
  1184. err := svc.InsertTmpGoodsAptitude(strconv.Itoa(classId), columnstr, valstr)
  1185. if err != nil {
  1186. panic(err)
  1187. }
  1188. }
  1189. }
  1190. // @Title get 清空导入的信息
  1191. // @Description get SampleType by token
  1192. // @Success 200 {object} sampletype.SampleType
  1193. // @router /truncateimport [get]
  1194. func (this *OilGoodsAptitudeController) TruncateImport() {
  1195. session := utils.DBE.NewSession()
  1196. err := session.Begin()
  1197. defer session.Close()
  1198. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  1199. err = svc.TruncateTable(Tmp_OilGoodsAptitudeName)
  1200. var errorinfo ErrorInfo
  1201. if err != nil {
  1202. session.Rollback()
  1203. errorinfo.Code = -1
  1204. errorinfo.Message = "删除失败!"
  1205. this.Data["json"] = &errorinfo
  1206. this.ServeJSON()
  1207. }
  1208. err = svc.TruncateTable(Tmp_OilGoodsAptitudeClassName)
  1209. if err != nil {
  1210. session.Rollback()
  1211. errorinfo.Code = -1
  1212. errorinfo.Message = "删除失败!"
  1213. this.Data["json"] = &errorinfo
  1214. this.ServeJSON()
  1215. }
  1216. session.Commit()
  1217. errorinfo.Code = 0
  1218. errorinfo.Message = "删除成功!"
  1219. this.Data["json"] = &errorinfo
  1220. this.ServeJSON()
  1221. }
  1222. // @Title 将导入的数据 导入到正式表
  1223. // @Description get SampleType by token
  1224. // @Success 200 {object} sampletype.SampleType
  1225. // @router /insertgoodsaptitude [get]
  1226. func (this *OilGoodsAptitudeController) InsertGoodsAptitude() {
  1227. session := utils.DBE.NewSession()
  1228. err := session.Begin()
  1229. defer session.Close()
  1230. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  1231. var errinfo ErrorInfo
  1232. err = svc.TruncateTable(OilGoodsAptitudeName)
  1233. if err != nil {
  1234. session.Rollback()
  1235. errinfo.Code = -1
  1236. errinfo.Message = "跟新失败!"
  1237. this.Data["json"] = &errinfo
  1238. this.ServeJSON()
  1239. }
  1240. err = svc.TruncateTable(OilGoodsAptitudeClassName)
  1241. if err != nil {
  1242. session.Rollback()
  1243. errinfo.Code = -1
  1244. errinfo.Message = "跟新失败!"
  1245. this.Data["json"] = &errinfo
  1246. this.ServeJSON()
  1247. }
  1248. err = svc.InsertGoodsAptitude(Tmp_OilGoodsAptitudeName, OilGoodsAptitudeName)
  1249. if err != nil {
  1250. session.Rollback()
  1251. errinfo.Code = -1
  1252. errinfo.Message = "跟新失败!"
  1253. this.Data["json"] = &errinfo
  1254. this.ServeJSON()
  1255. }
  1256. err = svc.InsertGoodsAptitude(Tmp_OilGoodsAptitudeClassName, OilGoodsAptitudeClassName)
  1257. if err != nil {
  1258. session.Rollback()
  1259. errinfo.Code = -1
  1260. errinfo.Message = "跟新失败!"
  1261. this.Data["json"] = &errinfo
  1262. this.ServeJSON()
  1263. }
  1264. session.Commit()
  1265. errinfo.Code = 0
  1266. errinfo.Message = "跟新成功!"
  1267. this.Data["json"] = &errinfo
  1268. this.ServeJSON()
  1269. }
  1270. // @Title 更新企业的准入项及资质
  1271. // @Description get SampleType by token
  1272. // @Success 200 {object} sampletype.SampleType
  1273. // @router /updatasuppiercertsub [get]
  1274. func (this *OilGoodsAptitudeController) UpdataSuppierCertSub() {
  1275. //excelFileName := "F:/ssa.xlsx"
  1276. //xlFile, _ := xlsx.OpenFile(excelFileName)
  1277. //var sheet = xlFile.Sheets[0]
  1278. t := time.Now()
  1279. goodsvc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1280. goodsvc.DeleteTable(TmpOilSupplierCertSubName, "SupplierTypeCode='01'")
  1281. supsvc := supplier.GetOilSupplierService(utils.DBE)
  1282. var suppliercertList []suppliercert.OilSupplierCert
  1283. where := "SupplierTypeCode='01' AND OutsideFlog = '' AND (InFlag IN ('1','2')) "
  1284. supsvc.GetEntities(&suppliercertList, where)
  1285. var goodsaptitudeClassList []goodsaptitudeclass.OilGoodsAptitudeClass
  1286. whereclass := "LENGTH(CODE) = 8 "
  1287. supsvc.GetEntities(&goodsaptitudeClassList, whereclass)
  1288. var colsname = []string{"Name"}
  1289. var colsLevel = []string{"GoodsLevel"}
  1290. for _, suppliercert := range suppliercertList {
  1291. //row := sheet.AddRow()
  1292. //cell := row.AddCell()
  1293. //cell.Value = strconv.Itoa(suppliercert.SupplierId)
  1294. var supplier supplier.OilSupplier
  1295. wheres := " Id=" + strconv.Itoa(suppliercert.SupplierId)
  1296. supsvc.GetEntity(&supplier, wheres)
  1297. log.Println(suppliercert.SupplierId)
  1298. var supplierCertSubList []suppliercertsub.OilSupplierCertSub
  1299. wheresup := "SupplierId = " + strconv.Itoa(suppliercert.SupplierId) + " and SupplierTypeCode='01' AND Type IN ('1', '3')"
  1300. supsvc.GetEntities(&supplierCertSubList, wheresup)
  1301. fmt.Println(len(supplierCertSubList))
  1302. mergerCertSkipField := ""
  1303. if supplier.CredentialFlag == "1" || supplier.CredentialFlag == "2" {
  1304. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1305. //三证合一或五证合一不需要的字段
  1306. mergerCertSkipField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  1307. }
  1308. // 准入项
  1309. //for idx, supplierCertSub := range supplierCertSubList {
  1310. for idx := 0; idx < len(supplierCertSubList); idx++ {
  1311. //row := sheet.AddRow()
  1312. //cell := row.AddCell()
  1313. //cell.Value = "删除"
  1314. supplierCertSub := supplierCertSubList[idx]
  1315. decCode := supplierCertSub.Code
  1316. // 物资类的准入编码
  1317. for _, goodsaptitudeClass := range goodsaptitudeClassList {
  1318. // 如果编码相同的后 判断有没有改名 然后查询准入项需要哪些资质 去查资质表里有没有这些资质 没有就删除这个准入项
  1319. if supplierCertSub.Code == goodsaptitudeClass.Code {
  1320. decCode = ""
  1321. goodsAptitudeNameArr := this.GetGoodsAptitudeName(strconv.Itoa(goodsaptitudeClass.Id), strconv.Itoa(supplierCertSub.IsManufacturer))
  1322. for _, val := range goodsAptitudeNameArr {
  1323. if strings.Contains(mergerCertSkipField, val) {
  1324. break
  1325. }
  1326. var supplierFile supplierfile.OilSupplierFile
  1327. where := "SupplierId=" + strconv.Itoa(suppliercert.SupplierId) + " and NeedFileType='" + val + "'" + " and SupplierTypeCode IN ('000', '01')"
  1328. has := supsvc.GetEntityByWhere(OilSupplierFileName, where, &supplierFile)
  1329. if !has {
  1330. //cell := row.AddCell()
  1331. //cell.Value = supplierCertSub.Code + " " + supplierCertSub.Name
  1332. log.Println(supplierCertSub.Code + "====" + val)
  1333. //wheredel := "Id = " + strconv.Itoa(supplierCertSub.Id)
  1334. //supsvc.DeleteEntityBytbl(OilSupplierCertSubName, wheredel)
  1335. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  1336. break
  1337. }
  1338. if supplierCertSub.Name != goodsaptitudeClass.Name {
  1339. //row := sheet.AddRow()
  1340. //cell := row.AddCell()
  1341. //cell.Value = supplierCertSub.Code + ":" + supplierCertSub.Name + "==" + goodsaptitudeClass.Name
  1342. var entity suppliercertsub.OilSupplierCertSub
  1343. entity.Name = goodsaptitudeClass.Name
  1344. where := "Id = " + strconv.Itoa(supplierCertSub.Id)
  1345. supsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &entity, colsname, where)
  1346. }
  1347. var goodsAptitude goodsaptitude.OilGoodsAptitude
  1348. whereg := "ClassId = " + strconv.Itoa(goodsaptitudeClass.Id)
  1349. supsvc.GetEntity(&goodsAptitude, whereg)
  1350. if goodsAptitude.GoodsLevel != supplierCertSub.GoodsLevel {
  1351. if goodsAptitude.GoodsLevel == "1" && supplier.Grade == "2" {
  1352. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  1353. } else {
  1354. var entity suppliercertsub.OilSupplierCertSub
  1355. entity.GoodsLevel = goodsAptitude.GoodsLevel
  1356. where := "Id = " + strconv.Itoa(supplierCertSub.Id)
  1357. supsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &entity, colsLevel, where)
  1358. }
  1359. }
  1360. }
  1361. break
  1362. }
  1363. }
  1364. if decCode != "" {
  1365. //wheredel := "Code = '" + decCode + "'"
  1366. //supsvc.DeleteEntityBytbl(OilSupplierCertSubName, wheredel)
  1367. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  1368. }
  1369. //cell1 := row.AddCell()
  1370. //cell1.Value = decCode
  1371. }
  1372. }
  1373. elapsed := time.Since(t)
  1374. log.Println(elapsed)
  1375. var errinfo ErrorInfo
  1376. errinfo.Code = 0
  1377. errinfo.Message = "更新完成!"
  1378. this.Data["json"] = &errinfo
  1379. this.ServeJSON()
  1380. //xlFile.Save(excelFileName)
  1381. }
  1382. func (this *OilGoodsAptitudeController) GetGoodsAptitudeName(classId, IsManuf string) []string {
  1383. var goodsAptitudeName string
  1384. var goodsAptitudeList []goodsaptitude.OilGoodsAptitudeF
  1385. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1386. where := "ClassId=" + classId
  1387. svc.GetGoodsAptitudeF(&goodsAptitudeList, where)
  1388. for _, goodsAptitude := range goodsAptitudeList {
  1389. t := reflect.TypeOf(goodsAptitude)
  1390. v := reflect.ValueOf(goodsAptitude)
  1391. for k := 0; k < t.NumField(); k++ {
  1392. if v.Field(k).Interface() == "1" {
  1393. var tableHeader tableheader.BaseTableheader
  1394. where := "Code='" + t.Field(k).Name + "' and IsManuf in ('0','" + IsManuf + "')"
  1395. has := svc.GetEntityByWhere(BaseTableHeader, where, &tableHeader)
  1396. if has {
  1397. goodsAptitudeName += tableHeader.Name + ","
  1398. }
  1399. }
  1400. }
  1401. }
  1402. return strings.Split(goodsAptitudeName, ",")
  1403. }
  1404. // @Title 获取所有
  1405. // @Description
  1406. // @Success 200 {object}
  1407. // @router /getcompanylist [post]
  1408. func (this *OilGoodsAptitudeController) GetTList() {
  1409. var model supplier.OilSupplierSelect
  1410. var model1 supplier.RegCapitalRange //注册资金范围
  1411. //var model2 supplier.NeedFileTypeStruct //资质结构体
  1412. var jsonBlob = this.Ctx.Input.RequestBody
  1413. json.Unmarshal(jsonBlob, &model)
  1414. json.Unmarshal(jsonBlob, &model1)
  1415. //json.Unmarshal(jsonBlob, &model2)
  1416. // //获取分页信息
  1417. page := this.GetPageInfoForm()
  1418. where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' and b.SupplierTypeCode = '01' AND t.SupplierId IS NOT NULL "
  1419. orderby := "a.Id"
  1420. asc := true
  1421. Order := this.GetString("Order")
  1422. Prop := this.GetString("Prop")
  1423. CheckUId := this.GetString("CheckUId")
  1424. FullId := this.GetString("FullId")
  1425. if Order != "" && Prop != "" {
  1426. orderby = Prop
  1427. if Order == "desc" {
  1428. asc = false
  1429. }
  1430. }
  1431. leftjoin := ""
  1432. //准入证号
  1433. if model.AccessCardNo != "" {
  1434. where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
  1435. }
  1436. //企业名称
  1437. if model.SupplierName != "" {
  1438. where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
  1439. }
  1440. if model.OldSupplierName != "" {
  1441. where = where + " and OldSupplierName like '%" + model.OldSupplierName + "%'"
  1442. }
  1443. if FullId != "" {
  1444. where = where + " and f.Id = '" + FullId + "'"
  1445. }
  1446. if CheckUId != "" {
  1447. where = where + " and g.CheckUnitId = '" + CheckUId + "'"
  1448. }
  1449. //准入标识 1 准入 2 暂停 3取消
  1450. if model.InFlag != "" {
  1451. where = where + " and b.InFlag = '" + model.InFlag + "'"
  1452. }
  1453. //法人
  1454. if model.LegalPerson != "" {
  1455. where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
  1456. }
  1457. //联系人
  1458. if model.ContactName != "" {
  1459. where = where + " and a.ContactName like '%" + model.ContactName + "%'"
  1460. }
  1461. //统一社会信用代码
  1462. if model.CommercialNo != "" {
  1463. where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
  1464. }
  1465. //开户银行
  1466. if model.DepositBank != "" {
  1467. where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
  1468. }
  1469. //HSE审查
  1470. if model.HseTraining != "" {
  1471. where = where + " and a.HseTraining = '" + model.HseTraining + "'"
  1472. }
  1473. //公司类型
  1474. if model.CompanyType != "" {
  1475. where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
  1476. }
  1477. //成立时间
  1478. SetupTime := this.GetString("SetupTime")
  1479. if SetupTime != "" {
  1480. where = where + " and a.SetupTime ='" + SetupTime + "'"
  1481. }
  1482. //注册资金范围
  1483. if model1.RegCapital1 != "" {
  1484. where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
  1485. }
  1486. if model1.RegCapital2 != "" {
  1487. where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
  1488. }
  1489. //注册省份
  1490. if model.Province != "" {
  1491. where = where + " and a.Province = '" + model.Province + "'"
  1492. }
  1493. //注册市
  1494. if model.City != "" {
  1495. where = where + " and a.City = '" + model.City + "'"
  1496. }
  1497. //注册区
  1498. if model.Street != "" {
  1499. where = where + " and a.Street = '" + model.Street + "'"
  1500. }
  1501. //注册详细地址
  1502. if model.Address != "" {
  1503. where = where + " and a.Address like '%" + model.Address + "%'"
  1504. }
  1505. if model.LinkProvince != "" {
  1506. where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
  1507. }
  1508. if model.LinkCity != "" {
  1509. where = where + " and a.LinkCity = '" + model.LinkCity + "'"
  1510. }
  1511. if model.LinkStreet != "" {
  1512. where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
  1513. }
  1514. if model.LinkAddress != "" {
  1515. where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
  1516. }
  1517. //营业范围
  1518. if model.BusinessScope != "" {
  1519. where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
  1520. }
  1521. CreateOn := this.GetString("CreateOn")
  1522. if CreateOn != "" {
  1523. dates := strings.Split(CreateOn, ",")
  1524. if len(dates) == 2 {
  1525. minDate := dates[0]
  1526. maxDate := dates[1]
  1527. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  1528. }
  1529. }
  1530. a := model.InStyle
  1531. fmt.Println(a)
  1532. //准入方式
  1533. if model.InStyle != "" {
  1534. if model.InStyle == "0" {
  1535. where = where + " and b.InStyle in ('2','3','4','5')"
  1536. } else {
  1537. where = where + " and b.InStyle ='" + model.InStyle + "'"
  1538. }
  1539. }
  1540. having := ""
  1541. //准入范围
  1542. if model.CerSubName != "" {
  1543. having = " having CerSubName like '%" + model.CerSubName + "%' "
  1544. leftjoin = "left join " + OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  1545. }
  1546. //资质
  1547. if model.NeedFileType != "" {
  1548. having = " having NeedFileType like '%" + model.NeedFileType + "%' "
  1549. }
  1550. if model.CerSubName != "" && model.NeedFileType != "" {
  1551. having = " having CerSubName like '%" + model.CerSubName + "%' and NeedFileType like '%" + model.NeedFileType + "%' "
  1552. leftjoin = "left join " + OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  1553. }
  1554. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1555. var list []supplier.OilSupplierSelect
  1556. total := svc.GetMyPagingDelEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
  1557. OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where, having, leftjoin)
  1558. var datainfo DataInfo
  1559. datainfo.Items = list
  1560. datainfo.CurrentItemCount = total
  1561. datainfo.PageIndex = page.CurrentPage
  1562. datainfo.ItemsPerPage = page.Size
  1563. this.Data["json"] = &datainfo
  1564. this.ServeJSON()
  1565. }
  1566. // @Title 获取删除的准入项
  1567. // @Description get user by token
  1568. // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
  1569. // @router /delcertsublist [get]
  1570. func (this *OilGoodsAptitudeController) GetDelCertSubList() {
  1571. //获取分页信息
  1572. page := this.GetPageInfoForm()
  1573. where := " 1=1 "
  1574. orderby := "Id"
  1575. asc := false
  1576. Order := this.GetString("Order")
  1577. Prop := this.GetString("Prop")
  1578. if Order != "" && Prop != "" {
  1579. orderby = Prop
  1580. if Order == "asc" {
  1581. asc = true
  1582. }
  1583. }
  1584. Id := this.GetString("Id")
  1585. SupplierId := this.GetString("SupplierId")
  1586. SupplierCertId := this.GetString("SupplierCertId")
  1587. SupplierTypeCode := this.GetString("SupplierTypeCode")
  1588. Code := this.GetString("Code")
  1589. Name := this.GetString("Name")
  1590. Remark := this.GetString("Remark")
  1591. IsDelete := this.GetString("IsDelete")
  1592. CreateOn := this.GetString("CreateOn")
  1593. CreateUserId := this.GetString("CreateUserId")
  1594. CreateBy := this.GetString("CreateBy")
  1595. ModifiedOn := this.GetString("ModifiedOn")
  1596. ModifiedUserId := this.GetString("ModifiedUserId")
  1597. ModifiedBy := this.GetString("ModifiedBy")
  1598. if Id != "" {
  1599. where = where + " and Id like '%" + Id + "%'"
  1600. }
  1601. if SupplierId != "" {
  1602. where = where + " and SupplierId like '%" + SupplierId + "%'"
  1603. }
  1604. if SupplierCertId != "" {
  1605. where = where + " and SupplierCertId = '" + SupplierCertId + "'"
  1606. }
  1607. if SupplierTypeCode != "" {
  1608. where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'"
  1609. }
  1610. if Code != "" {
  1611. where = where + " and Code like '%" + Code + "%'"
  1612. }
  1613. if Name != "" {
  1614. where = where + " and Name like '%" + Name + "%'"
  1615. }
  1616. if Remark != "" {
  1617. where = where + " and Remark like '%" + Remark + "%'"
  1618. }
  1619. if IsDelete != "" {
  1620. where = where + " and IsDelete like '%" + IsDelete + "%'"
  1621. }
  1622. if CreateUserId != "" {
  1623. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  1624. }
  1625. if CreateBy != "" {
  1626. where = where + " and CreateBy like '%" + CreateBy + "%'"
  1627. }
  1628. if ModifiedOn != "" {
  1629. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  1630. }
  1631. if ModifiedUserId != "" {
  1632. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  1633. }
  1634. if ModifiedBy != "" {
  1635. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  1636. }
  1637. if CreateOn != "" {
  1638. dates := strings.Split(CreateOn, ",")
  1639. if len(dates) == 2 {
  1640. minDate := dates[0]
  1641. maxDate := dates[1]
  1642. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  1643. }
  1644. }
  1645. where = where + " and Type in (1, 3)"
  1646. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1647. var list []suppliercertsub.Tmp_OilSupplierCertSub
  1648. total := svc.GetMyPagingEntitiesWithOrderBytbl(TmpOilSupplierCertSubName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  1649. var datainfo DataInfo
  1650. datainfo.Items = list
  1651. datainfo.CurrentItemCount = total
  1652. datainfo.PageIndex = page.CurrentPage
  1653. datainfo.ItemsPerPage = page.Size
  1654. this.Data["json"] = &datainfo
  1655. this.ServeJSON()
  1656. }
  1657. // @Title 删除不符合的的准入项
  1658. // @Description get user by token
  1659. // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
  1660. // @router /deltmpsuppliercertsub [get]
  1661. func (this *OilGoodsAptitudeController) DelTmpSupplierCertSub() {
  1662. var err error
  1663. session := utils.DBE.NewSession()
  1664. session.Begin()
  1665. defer session.Close()
  1666. supplierId := this.GetString("SupplierId")
  1667. id := this.GetString("Id")
  1668. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  1669. var supplierCertSubList []suppliercertsub.Tmp_OilSupplierCertSub
  1670. wheredel := "1=1 and SupplierTypeCode = '01'"
  1671. if supplierId != "" {
  1672. wheredel += " and SupplierId=" + supplierId
  1673. }
  1674. if id != "" {
  1675. wheredel += " and Id=" + id
  1676. }
  1677. svc.GetEntitysByWhere(TmpOilSupplierCertSubName, wheredel, &supplierCertSubList)
  1678. var errinfo ErrorInfo
  1679. for _, item := range supplierCertSubList {
  1680. where := "Id = " + strconv.Itoa(item.Id)
  1681. err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
  1682. if err != nil {
  1683. session.Rollback()
  1684. errinfo.Code = -1
  1685. errinfo.Message = "删除失败!"
  1686. this.Data["json"] = &errinfo
  1687. this.ServeJSON()
  1688. }
  1689. }
  1690. for _, item := range supplierCertSubList {
  1691. where := "Id = " + strconv.Itoa(item.Id)
  1692. err = svc.DeleteEntityBytbl(TmpOilSupplierCertSubName, where)
  1693. }
  1694. if err == nil {
  1695. session.Commit()
  1696. errinfo.Code = 0
  1697. errinfo.Message = "删除成功!"
  1698. this.Data["json"] = &errinfo
  1699. this.ServeJSON()
  1700. } else {
  1701. session.Rollback()
  1702. errinfo.Code = -1
  1703. errinfo.Message = "删除失败!"
  1704. this.Data["json"] = &errinfo
  1705. this.ServeJSON()
  1706. }
  1707. }
  1708. // @Title 修改资质后找出不符合的准入
  1709. // @Description 修改实体
  1710. // @Success 200 {object} controllers.Request
  1711. // @router /findinconformity [post]
  1712. func (this *OilGoodsAptitudeController) FindInconformity() {
  1713. var errinfo ErrorInfo
  1714. var err error
  1715. var model goodsaptitude.OilGoodsAptitude_2
  1716. var companygoodslist []suppliercertsub.OilSupplierCertSub
  1717. var companygood suppliercertsub.OilSupplierCertSub
  1718. var SurplusList1 []supplierfile.FileList
  1719. var SurplusList2 []supplierfile.FileList
  1720. var supfilemodel []supplierfile.OilSupplierFile
  1721. var supfilemodel01 []supplierfile.OilSupplierFile
  1722. var supfilemodel02 []supplierfile.OilSupplierFile
  1723. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1724. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  1725. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1726. var jsonBlob = this.Ctx.Input.RequestBody
  1727. json.Unmarshal(jsonBlob, &model)
  1728. Code := model.Code
  1729. where := " Code ='" + Code + "' and Type in ('1','3') and SupplierTypeCode = '01'"
  1730. svc.FindGoodsByCode("OilSupplierCertSub", where, &companygoodslist)
  1731. SurplusList1 = filesvc.GetGoodsNeedFileList(strconv.Itoa(model.ClassId), "1")
  1732. SurplusList2 = filesvc.GetGoodsNeedFileList(strconv.Itoa(model.ClassId), "2")
  1733. for _, CertSub := range companygoodslist {
  1734. companygood = CertSub
  1735. wherecompany := " SupplierId =" + strconv.Itoa(CertSub.SupplierId)
  1736. svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel)
  1737. if len(supfilemodel) < 1 {
  1738. _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  1739. } else {
  1740. var tmplist1 []suppliercertsub.Tmp_OilSupplierCertSub
  1741. wherecompany = " Id =" + strconv.Itoa(CertSub.Id)
  1742. svc.FindFileByCompany("tmp_OilSupplierCertSub", wherecompany, &tmplist1)
  1743. if len(tmplist1) < 1 {
  1744. wherecompany = " SupplierId ='" + strconv.Itoa(CertSub.SupplierId) + "' and IsManuf in ('0','1')"
  1745. svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel01)
  1746. var File01 string
  1747. for _, Filesub := range supfilemodel01 {
  1748. File01 = File01 + Filesub.NeedFileType + ","
  1749. }
  1750. for _, Filesub := range SurplusList1 {
  1751. var supplierModel supplier.OilSupplier
  1752. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  1753. svcSupplier.GetEntityById(strconv.Itoa(CertSub.SupplierId), &supplierModel)
  1754. //三证合一或五证合一不需要的字段
  1755. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  1756. File01 = mergerCertSkipField + File01
  1757. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(File01, Filesub.FileName+",") { //三证合一或五证合一了
  1758. continue
  1759. }
  1760. if strings.Contains(File01, Filesub.FileName+",") {
  1761. continue
  1762. }
  1763. _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  1764. break
  1765. }
  1766. }
  1767. var tmplist2 []suppliercertsub.Tmp_OilSupplierCertSub
  1768. wherecompany = " Id =" + strconv.Itoa(CertSub.Id)
  1769. svc.FindFileByCompany("tmp_OilSupplierCertSub", wherecompany, &tmplist2)
  1770. if len(tmplist2) < 1 {
  1771. wherecompany = " SupplierId ='" + strconv.Itoa(CertSub.SupplierId) + "' and IsManuf in ('0','2')"
  1772. svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel02)
  1773. var File02 string
  1774. for _, Filesub := range supfilemodel02 {
  1775. File02 = File02 + Filesub.NeedFileType + ","
  1776. }
  1777. for _, Filesub := range SurplusList2 {
  1778. var supplierModel supplier.OilSupplier
  1779. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  1780. svcSupplier.GetEntityById(strconv.Itoa(CertSub.SupplierId), &supplierModel)
  1781. //三证合一或五证合一不需要的字段
  1782. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  1783. File02 = mergerCertSkipField + File02
  1784. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(File02, Filesub.FileName+",") { //三证合一或五证合一了
  1785. continue
  1786. }
  1787. if strings.Contains(File02, Filesub.FileName+",") {
  1788. continue
  1789. }
  1790. _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  1791. break
  1792. }
  1793. }
  1794. }
  1795. var entity supplier.OilSupplier
  1796. wherec := "Id=" + strconv.Itoa(CertSub.SupplierId)
  1797. svc.GetEntity(&entity, wherec)
  1798. if model.GoodsLevel == "1" && entity.Grade == "2" {
  1799. svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  1800. } else {
  1801. var certsub suppliercertsub.OilSupplierCertSub
  1802. certsub.GoodsLevel = model.GoodsLevel
  1803. cols := []string{"GoodsLevel"}
  1804. where := "Id=" + strconv.Itoa(CertSub.Id)
  1805. svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &certsub, cols, where)
  1806. }
  1807. }
  1808. if err == nil {
  1809. errinfo.Message = "已拉取缺失资质列表!"
  1810. errinfo.Code = 0
  1811. this.Data["json"] = &errinfo
  1812. this.ServeJSON()
  1813. } else {
  1814. errinfo.Message = "拉取列表失败!" + utils.AlertProcess(err.Error())
  1815. errinfo.Code = -1
  1816. this.Data["json"] = &errinfo
  1817. this.ServeJSON()
  1818. }
  1819. }
  1820. // @Title get 导入excel对比差异
  1821. // @Description get SampleType by token
  1822. // @Success 200 {object} sampletype.SampleType
  1823. // @router /oilcompare [get]
  1824. func (this *OilGoodsAptitudeController) OilCompare() {
  1825. url := this.GetString("ExcelUrl")
  1826. inputcode := this.GetString("Code")
  1827. inputname := this.GetString("CompanyName")
  1828. session := utils.DBE.NewSession()
  1829. err := session.Begin()
  1830. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  1831. timeUnixNano := strconv.FormatInt(int64(time.Now().UnixNano()), 10)
  1832. _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
  1833. utils.DownloadFile(url, timeUnixNano+".xlsx", _dir)
  1834. filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + timeUnixNano + ".xlsx"
  1835. xlFile, err := xlsx.OpenFile(filePath)
  1836. //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
  1837. if err != nil {
  1838. fmt.Printf("open failed: %s\n", err)
  1839. }
  1840. var sheet = xlFile.Sheets[0]
  1841. defer func() {
  1842. session.Close()
  1843. }()
  1844. var Comparelist []suppliercertsub.OilCompare
  1845. var Comparelistnow []suppliercertsub.OilCompare
  1846. var Compare suppliercertsub.OilCompare
  1847. var CompanyName string
  1848. for i := 2; i < len(sheet.Rows); i++ {
  1849. if inputcode != "" && inputcode != sheet.Rows[i].Cells[0].Value{
  1850. continue
  1851. }
  1852. if inputname !="" && inputname != sheet.Rows[i].Cells[4].Value {
  1853. continue
  1854. }
  1855. var List []supplier.OilSupplier
  1856. CompanyName = sheet.Rows[i].Cells[4].Value
  1857. where := "SupplierName = '" + CompanyName + "'"
  1858. svc.GetEntitysByWhere(OilSupplierName, where, &List)
  1859. Compare.SortCoding = sheet.Rows[i].Cells[0].Value
  1860. Compare.SortName = sheet.Rows[i].Cells[1].Value
  1861. Compare.Level = sheet.Rows[i].Cells[2].Value
  1862. //Compare.SupplierCode = sheet.Rows[i].Cells[3].Value
  1863. Compare.SupplierName = sheet.Rows[i].Cells[4].Value
  1864. //Compare.SurplusCount = sheet.Rows[i].Cells[5].Value
  1865. Compare.ManagementUnitType = sheet.Rows[i].Cells[6].Value
  1866. //Compare.EliminationCause = sheet.Rows[i].Cells[7].Value
  1867. //Compare.AccessList = sheet.Rows[i].Cells[8].Value
  1868. //Compare.SupplierSubTime = sheet.Rows[i].Cells[9].Value
  1869. //Compare.ProductType = sheet.Rows[i].Cells[10].Value
  1870. //Compare.Editor = sheet.Rows[i].Cells[11].Value
  1871. //Compare.EditingTime = sheet.Rows[i].Cells[12].Value
  1872. //Compare.FlowState = sheet.Rows[i].Cells[13].Value
  1873. //Compare.ProcessNotes = sheet.Rows[i].Cells[14].Value
  1874. //Compare.Reviewime = sheet.Rows[i].Cells[15].Value
  1875. //Compare.Brand = sheet.Rows[i].Cells[16].Value
  1876. //Compare.WorkCode = sheet.Rows[i].Cells[17].Value
  1877. //Compare.WorkType = sheet.Rows[i].Cells[18].Value
  1878. //Compare.ProductScope = sheet.Rows[i].Cells[19].Value
  1879. //Compare.IsBid = sheet.Rows[i].Cells[20].Value
  1880. //Compare.MoreInfo = sheet.Rows[i].Cells[21].Value
  1881. //Compare.ManufacturerCode = sheet.Rows[i].Cells[22].Value
  1882. //Compare.ManufacturerName = sheet.Rows[i].Cells[23].Value
  1883. Compare.Diff = "0"
  1884. if len(List) < 1 {
  1885. Compare.Diff = "1"
  1886. Comparelist = append(Comparelist, Compare)
  1887. }
  1888. if len(List) > 0 {
  1889. var certsublist2 []suppliercertsub.OilSupplierCertSub
  1890. namewhere := "SupplierId = '" + strconv.Itoa(List[0].Id) + "' and Code ='" + Compare.SortCoding + "' and SupplierTypeCode ='01'"
  1891. svc.GetEntitysByWhere(OilSupplierCertSubName, namewhere, &certsublist2)
  1892. if len(certsublist2) < 1 {
  1893. Compare.Diff = "1"
  1894. Comparelist = append(Comparelist, Compare)
  1895. }
  1896. }
  1897. if Compare.Diff == "0" {
  1898. Comparelistnow = append(Comparelistnow,Compare)
  1899. }
  1900. }
  1901. for _,nowlist := range Comparelistnow {
  1902. Comparelist = append(Comparelist,nowlist)
  1903. }
  1904. os.Remove(filePath)
  1905. var datainfo DataInfo
  1906. datainfo.Items = Comparelist
  1907. this.Data["json"] = &datainfo
  1908. this.ServeJSON()
  1909. }
  1910. // @Title 导出数据到word,作为导出pdf的中间步骤
  1911. // @Description 数据存入word
  1912. // @Success 200 {object} controllers.Request
  1913. // @router /exportpdf/:tbid/:typecode [post]
  1914. func (this *OilGoodsAptitudeController) PdfExport() {
  1915. Id := this.Ctx.Input.Param(":tbid")
  1916. SupplierTypeCode := this.Ctx.Input.Param(":typecode")
  1917. var Url string
  1918. var fileName string
  1919. var model1 supplierdataentry.SupplierDataEntry
  1920. var model2 supplierdataentry.SupplierCertDataEntry
  1921. svc := supplierdataentry.GetSupplierDataEntryService(utils.DBE)
  1922. where1 := "1=1"
  1923. where1 += " AND Id = '" + Id + "'"
  1924. where2 := "SupplierId = '" + Id + "' and SupplierTypecode='"+ SupplierTypeCode +"'"
  1925. svc.GetEntityByWhere(OilSupplierName, where1, &model1)
  1926. svc.GetEntityByWhere(OilSupplierCertName, where2, &model2)
  1927. var tabledata []supplierdataentry.SupplierCertSubEntry
  1928. where3:="SupplierId = '" + Id + "' and SupplierTypecode='"+ SupplierTypeCode +"' and Type in ('1','3')"//准入状态的准入项
  1929. svc.GetEntitysByOrderbyWhere(TmpOilSupplierCertSubName, where3, "1", &tabledata)
  1930. datamap := structToMapDemo(model1.OilSupplier)
  1931. if model2.SupplierTypeCode == "01" {
  1932. Url = utils.Cfg.MustValue("workflow", "goodsPdfHost")
  1933. fileName = "待删除物资类准入范围.docx"
  1934. } else if model2.SupplierTypeCode == "02" {
  1935. Url = utils.Cfg.MustValue("workflow", "basisPdfHost")
  1936. fileName = "待删除基建类准入范围.docx"
  1937. datamap["TJInNotify"] = model1.TJInNotify
  1938. } else {
  1939. Url = utils.Cfg.MustValue("workflow", "techPdfHost")
  1940. fileName = "待删除服务类准入范围.docx"
  1941. }
  1942. //model1
  1943. datamap["SetupTime"] = model1.SetupTime.Format("2006年01月02日")
  1944. datamap["QualifCert"] = model1.QualifCert
  1945. datamap["QualifCertLevel"] = model1.QualifCertLevel
  1946. datamap["SpecIndustryCert"] = model1.SpecIndustryCert
  1947. datamap["MaunLicense"] = model1.MaunLicense
  1948. if model1.HseTraining == "1" {
  1949. datamap["HseTraining"] = "是"
  1950. } else {
  1951. datamap["HseTraining"] = "否"
  1952. }
  1953. if model1.OperType != "" {
  1954. if model1.OperType == "1" || model1.OperType == "制造商"{
  1955. datamap["OperType"] = "√制造商 □代理商 □贸易商"
  1956. }else if model1.OperType == "2" || model1.OperType == "代理商"{
  1957. datamap["OperType"] = "□制造商 √代理商 □贸易商"
  1958. }else if model1.OperType == "3" || model1.OperType == "代理商"{
  1959. datamap["OperType"] = "□制造商 □代理商 √贸易商"
  1960. }else {
  1961. datamap["OperType"] = "□制造商 □代理商 □贸易商"
  1962. }
  1963. }
  1964. if model1.SpecTypeCode != "" {
  1965. if model1.SpecTypeCode == "1"{
  1966. datamap["SpecTypeCode"] = "√一般外部 □多元企业"
  1967. }else if model1.SpecTypeCode == "2"{
  1968. datamap["SpecTypeCode"] = "□一般外部 √多元企业"
  1969. }else {
  1970. datamap["SpecTypeCode"] = "□一般外部 □多元企业"
  1971. }
  1972. }
  1973. if model1.Grade == "1"{
  1974. datamap["Grade"] = "一级"
  1975. }else if model1.SpecTypeCode == "2"{
  1976. datamap["Grade"] = "二级"
  1977. }
  1978. datamap["Fax"] = model1.Fax
  1979. datamap["CompanyTel"] = model1.CompanyTel
  1980. datamap["SupplierName"] = model1.SupplierName
  1981. datamap["Country"] = model1.Country
  1982. datamap["MaunAgent"] = model1.MaunAgent
  1983. datamap["SupplierCertificate"] = model1.SupplierCertificate
  1984. datamap["MgrUnit"] = model1.MgrUnit
  1985. datamap["CommercialNo"] = model1.CommercialNo
  1986. datamap["CountryTaxNo"] = model1.CountryTaxNo
  1987. datamap["OrganCode"] = model1.OrganCode
  1988. datamap["Address"] = model1.Address
  1989. datamap["ZipCode"] = model1.ZipCode
  1990. datamap["LinkAddress"] = model1.LinkAddress
  1991. datamap["LinkZipCode"] = model1.LinkZipCode
  1992. datamap["QualitySystemCert"] = model1.QualitySystemCert
  1993. datamap["ProductQualityCert"] = model1.ProductQualityCert
  1994. datamap["MaunLicense"] = model1.MaunLicense
  1995. datamap["LegalPerson"] = model1.LegalPerson
  1996. datamap["CompanyType"] = model1.CompanyType
  1997. datamap["ContactName"] = model1.ContactName
  1998. datamap["RegCapital"] = strconv.FormatFloat(model1.RegCapital,'f',2,64)+"万元"+model1.Currency
  1999. datamap["DepositBank"] = model1.DepositBank
  2000. datamap["BankAccount"] = model1.BankAccount
  2001. datamap["Mobile"] = model1.Mobile
  2002. datamap["EMail"] = model1.EMail
  2003. datamap["BankCreditRating"] = model1.BankCreditRating
  2004. datamap["BusinessScope"] = model1.BusinessScope
  2005. datamap["Telphone"] = model1.Telphone
  2006. datamap["AccessCardNo"] = model2.AccessCardNo
  2007. datamap["PrintYear"] = time.Now().Year()
  2008. datamap["PrintMonth"] = time.Now().Month()
  2009. datamap["PrintDay"] = time.Now().Day()
  2010. datamap["Name"] = ""
  2011. if len(tabledata) != 0 {
  2012. var Name string
  2013. Name = "\n待删除准入范围:"+ tabledata[0].Code
  2014. Name = Name + " " + tabledata[0].Name
  2015. var i int
  2016. for i = 1; i < len(tabledata); i++ {
  2017. Name += ";"
  2018. Name += tabledata[i].Code
  2019. Name = Name + " " + tabledata[i].Name
  2020. }
  2021. //if i == 100 {
  2022. // Name += "(准入范围未完全显示,请到系统查看详情)"
  2023. //}
  2024. datamap["Name"] =datamap["Name"].(string) + Name
  2025. } else {
  2026. datamap["Name"] =datamap["Name"].(string)
  2027. }
  2028. svcActiviti := workflow.GetActivitiService(utils.DBE)
  2029. retDocUrl := svcActiviti.FillWordTemplate(datamap, Url, fileName)
  2030. var datainfo ErrorDataInfo
  2031. datainfo.Code = 0
  2032. datainfo.Item = retDocUrl
  2033. datainfo.Message = "准备导出"
  2034. this.Data["json"] = &datainfo
  2035. this.ServeJSON()
  2036. }