basisbuild.go 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  4. "dashoo.cn/backend/api/business/oilsupplier/supplierdataentry"
  5. "dashoo.cn/backend/api/business/oilsupplier/tableheader"
  6. "dashoo.cn/backend/api/business/workflow"
  7. "encoding/json"
  8. "fmt"
  9. "github.com/tealeg/xlsx"
  10. "log"
  11. "os"
  12. "reflect"
  13. "strconv"
  14. "strings"
  15. "time"
  16. "dashoo.cn/backend/api/business/items"
  17. "dashoo.cn/backend/api/business/baseUser"
  18. "dashoo.cn/business2/userRole"
  19. //"dashoo.cn/backend/api/business/items"
  20. "dashoo.cn/backend/api/business/oilsupplier/basisbuild"
  21. "dashoo.cn/backend/api/business/oilsupplier/goodsaptitude"
  22. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  23. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  24. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  25. "dashoo.cn/business2/parameter"
  26. . "dashoo.cn/backend/api/controllers"
  27. "dashoo.cn/utils"
  28. . "github.com/linxGnu/goseaweedfs"
  29. )
  30. type OilBasisBuildController struct {
  31. BaseController
  32. }
  33. // @Title 获取列表
  34. // @Description get user by token
  35. // @Success 200 {object} []basisbuild.OilBasisBuild
  36. // @router /list [get]
  37. func (this *OilBasisBuildController) GetEntityList() {
  38. //获取分页信息
  39. page := this.GetPageInfoForm()
  40. where := " 1=1 "
  41. orderby := "Code"
  42. asc := true
  43. Order := this.GetString("Order")
  44. Prop := this.GetString("Prop")
  45. if Order != "" && Prop != "" {
  46. orderby = Prop
  47. if Order == "asc" {
  48. asc = true
  49. }else {
  50. asc = false
  51. }
  52. }
  53. CreateOn := this.GetString("CreateOn")
  54. Code := this.GetString("Code")
  55. Name := this.GetString("Name")
  56. if Code != "" {
  57. where = where + " and Code like '%" + Code + "%'"
  58. }
  59. if Name != "" {
  60. where = where + " and Name like '%" + Name + "%'"
  61. }
  62. if CreateOn != "" {
  63. dates := strings.Split(CreateOn, ",")
  64. if len(dates) == 2 {
  65. minDate := dates[0]
  66. maxDate := dates[1]
  67. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  68. }
  69. }
  70. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  71. var list []basisbuild.OilBasisBuild
  72. total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  73. var datainfo DataInfo
  74. datainfo.Items = list
  75. datainfo.CurrentItemCount = total
  76. datainfo.PageIndex = page.CurrentPage
  77. datainfo.ItemsPerPage = page.Size
  78. this.Data["json"] = &datainfo
  79. this.ServeJSON()
  80. }
  81. // @Title 获取字典列表
  82. // @Description get user by token
  83. // @Success 200 {object} map[string]interface{}
  84. // @router /dictlist [get]
  85. func (this *OilBasisBuildController) GetDictList() {
  86. dictList := make(map[string]interface{})
  87. dictSvc := items.GetItemsService(utils.DBE)
  88. userSvc := baseUser.GetBaseUserService(utils.DBE)
  89. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  90. //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", "")
  91. var userEntity userRole.Base_User
  92. userSvc.GetEntityById(this.User.Id, &userEntity)
  93. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId("", userEntity.Departmentid)
  94. dictList["AuditStep"] = dictSvc.GetKeyValueItems("AuditStep", this.User.AccCode)
  95. //var dictCustomer []svccustomer.Customer
  96. //customerSvc.GetEntitysByWhere("" + CustomerName, "", &dictCustomer)
  97. //dictList["EntrustCorp"] = &dictCustomer
  98. var datainfo DataInfo
  99. datainfo.Items = dictList
  100. this.Data["json"] = &datainfo
  101. this.ServeJSON()
  102. }
  103. // @Title 获取实体
  104. // @Description 获取实体
  105. // @Success 200 {object} basisbuild.OilBasisBuild
  106. // @router /get/:id [get]
  107. func (this *OilBasisBuildController) GetEntity() {
  108. Id := this.Ctx.Input.Param(":id")
  109. var model basisbuild.OilBasisBuild
  110. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  111. svc.GetEntityByIdBytbl(""+OilBasisBuildName, Id, &model)
  112. this.Data["json"] = &model
  113. this.ServeJSON()
  114. }
  115. // @Title 添加
  116. // @Description 新增
  117. // @Success 200 {object} controllers.Request
  118. // @router /add [post]
  119. func (this *OilBasisBuildController) AddEntity() {
  120. var model basisbuild.OilBasisBuild
  121. var jsonBlob = this.Ctx.Input.RequestBody
  122. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  123. json.Unmarshal(jsonBlob, &model)
  124. model.CreateOn = time.Now()
  125. model.CreateBy = this.User.Realname
  126. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  127. //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  128. _, err := svc.InsertEntityBytbl(""+OilBasisBuildName, &model)
  129. var errinfo ErrorDataInfo
  130. if err == nil {
  131. //新增
  132. errinfo.Message = "添加成功!"
  133. errinfo.Code = 0
  134. errinfo.Item = model.Id
  135. this.Data["json"] = &errinfo
  136. this.ServeJSON()
  137. } else {
  138. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  139. errinfo.Code = -1
  140. this.Data["json"] = &errinfo
  141. this.ServeJSON()
  142. }
  143. }
  144. // @Title 修改实体
  145. // @Description 修改实体
  146. // @Success 200 {object} controllers.Request
  147. // @router /update/:id [post]
  148. func (this *OilBasisBuildController) UpdateEntity() {
  149. id := this.Ctx.Input.Param(":id")
  150. var errinfo ErrorInfo
  151. if id == "" {
  152. errinfo.Message = "操作失败!请求信息不完整"
  153. errinfo.Code = -2
  154. this.Data["json"] = &errinfo
  155. this.ServeJSON()
  156. return
  157. }
  158. var model basisbuild.OilBasisBuild
  159. var basmodel []basisbuild.OilBasisBuild
  160. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  161. var jsonBlob = this.Ctx.Input.RequestBody
  162. json.Unmarshal(jsonBlob, &model)
  163. if model.Name != "" {
  164. where := " Name = '" + model.Name +"' and Id not in ('"+id+"')"
  165. svc.GetEntitysByWhere(OilBasisBuildName, where, &basmodel)
  166. if len(basmodel) > 0 {
  167. errinfo.Message = "名称已存在,请重新添加!"
  168. errinfo.Code = -1
  169. this.Data["json"] = &errinfo
  170. this.ServeJSON()
  171. return
  172. }
  173. }
  174. if model.Code != "" {
  175. cowhere := " Code = '" + model.Code+"' and Id not in ('"+id+"')"
  176. svc.GetEntitysByWhere(OilBasisBuildName, cowhere, &basmodel)
  177. if len(basmodel) > 0 {
  178. errinfo.Message = "编码已存在,请重新添加!"
  179. errinfo.Code = -1
  180. this.Data["json"] = &errinfo
  181. this.ServeJSON()
  182. return
  183. }
  184. }
  185. model.ModifiedOn = time.Now()
  186. model.ModifiedBy = this.User.Realname
  187. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  188. cols := []string{
  189. "Id",
  190. "Code",
  191. "Name",
  192. "F01",
  193. "F02",
  194. "F03",
  195. "F04",
  196. "F05",
  197. "F06",
  198. "F07",
  199. "F08",
  200. "F09",
  201. "F10",
  202. "F11",
  203. "F12",
  204. "F13",
  205. "F14",
  206. "F15",
  207. "F16",
  208. "F17",
  209. "F18",
  210. "F19",
  211. "F20",
  212. "F21",
  213. "F22",
  214. "F23",
  215. "F24",
  216. "F25",
  217. "Remark",
  218. "DeletionStateCode",
  219. "CreateOn",
  220. "CreateUserId",
  221. "CreateBy",
  222. "ModifiedOn",
  223. "ModifiedUserId",
  224. "ModifiedBy",
  225. }
  226. err := svc.UpdateEntityBytbl(""+OilBasisBuildName, id, &model, cols)
  227. if err == nil {
  228. errinfo.Message = "修改成功!"
  229. errinfo.Code = 0
  230. this.Data["json"] = &errinfo
  231. this.ServeJSON()
  232. } else {
  233. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  234. errinfo.Code = -1
  235. this.Data["json"] = &errinfo
  236. this.ServeJSON()
  237. }
  238. }
  239. // @Title 删除单条信息
  240. // @Description
  241. // @Success 200 {object} ErrorInfo
  242. // @Failure 403 :id 为空
  243. // @router /delete/:Id [delete]
  244. func (this *OilBasisBuildController) DeleteEntity() {
  245. Id := this.Ctx.Input.Param(":Id")
  246. var errinfo ErrorInfo
  247. if Id == "" {
  248. errinfo.Message = "操作失败!请求信息不完整"
  249. errinfo.Code = -2
  250. this.Data["json"] = &errinfo
  251. this.ServeJSON()
  252. return
  253. }
  254. var model basisbuild.OilBasisBuild
  255. var entityempty basisbuild.OilBasisBuild
  256. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  257. opdesc := "删除-" + Id
  258. err := svc.DeleteOperationAndWriteLogBytbl(""+OilBasisBuildName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "钻井日报")
  259. if err == nil {
  260. errinfo.Message = "删除成功"
  261. errinfo.Code = 0
  262. this.Data["json"] = &errinfo
  263. this.ServeJSON()
  264. } else {
  265. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  266. errinfo.Code = -1
  267. this.Data["json"] = &errinfo
  268. this.ServeJSON()
  269. }
  270. }
  271. // @Title 基建类业务
  272. // @Description get user by token
  273. // @Success 200 {object} models.Userblood
  274. // @router /basiclist [get]
  275. func (this *OilBasisBuildController) BasicList() {
  276. page := this.GetPageInfoForm()
  277. var list []basisbuild.OilBasisBuild
  278. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  279. where := " 1=1"
  280. orderby := "Id"
  281. asc := true
  282. Order := this.GetString("Order")
  283. Prop := this.GetString("Prop")
  284. if Order != "" && Prop != "" {
  285. orderby = Prop
  286. if Order == "asc" {
  287. asc = true
  288. }
  289. }
  290. keyword := this.GetString("keyword")
  291. if keyword != "" {
  292. where = where + " and Name like '%" + keyword + "%' or Code like '%" + keyword + "%'"
  293. }
  294. total := svc.GetPagingEntitiesWithoutAccCode(page.CurrentPage, page.Size, orderby, asc, &list, where)
  295. var datainfo DataInfo
  296. datainfo.Items = list
  297. datainfo.CurrentItemCount = total
  298. this.Data["json"] = &datainfo
  299. this.ServeJSON()
  300. }
  301. // @Title get 导出ex
  302. // @Description get SampleType by token
  303. // @Success 200 {object} sampletype.SampleType
  304. // @router /exportexcelall [get]
  305. func (this *OilBasisBuildController) ExportExcelAll() {
  306. //获取分页信息
  307. where := " 1=1 "
  308. orderby := "Code"
  309. asc := true
  310. Order := this.GetString("Order")
  311. Prop := this.GetString("Prop")
  312. if Order != "" && Prop != "" {
  313. orderby = Prop
  314. if Order == "asc" {
  315. asc = true
  316. } else {
  317. asc = false
  318. }
  319. }
  320. t := time.Now()
  321. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  322. var list []basisbuild.OilBasisBuild
  323. svc.GetPagingEntitiesWithOrderBytbl("", 0, 0, orderby, asc, &list, where)
  324. var title []string
  325. filetitle := "基建类"
  326. //自定义显示列
  327. showcolumnarr := this.GetString("showcolumnarr")
  328. showcolumnnamearr := this.GetString("showcolumnnamearr")
  329. titlestring := showcolumnnamearr
  330. title = strings.Split(titlestring, ",")
  331. f := xlsx.NewFile()
  332. sheet, _ := f.AddSheet(filetitle)
  333. cellname := strings.Split(showcolumnarr, ",")
  334. row := sheet.AddRow()
  335. row.WriteSlice(&cellname, -1)
  336. for _, item := range list {
  337. var enumModel basisbuild.OilBasisBuild
  338. tmpModel := &item
  339. enumModel = *tmpModel
  340. immumodel := reflect.ValueOf(&enumModel)
  341. elem := immumodel.Elem()
  342. row := sheet.AddRow()
  343. for _, name := range title {
  344. cell := row.AddCell()
  345. if strings.HasPrefix(name, "F") {
  346. var val = elem.FieldByName(name).String()
  347. if val == "1" {
  348. cell.Value = "是"
  349. } else {
  350. cell.Value = ""
  351. }
  352. } else {
  353. cell.Value = elem.FieldByName(name).String()
  354. }
  355. }
  356. }
  357. for c, cl := 0, len(sheet.Cols); c < cl; c++ {
  358. sheet.Cols[c].Width = 20
  359. }
  360. dir := "static/file/excel/report/" + this.GetAccode()
  361. SaveDirectory(dir)
  362. path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
  363. f.Save(path)
  364. var sw *Seaweed
  365. var filer []string
  366. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  367. filer = []string{_filer}
  368. }
  369. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  370. _, _, fID, _ := sw.UploadFile(path, "", "")
  371. retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  372. os.Remove(path)
  373. fmt.Println("==retDocWatermarkUrl==", retDocUrl)
  374. this.Data["json"] = retDocUrl
  375. this.ServeJSON()
  376. elapsed := time.Since(t)
  377. fmt.Println(elapsed)
  378. }
  379. // @Title 获取所有
  380. // @Description
  381. // @Success 200 {object}
  382. // @router /getcompanylist [post]
  383. func (this *OilBasisBuildController) GetTList() {
  384. var model supplier.OilSupplierSelect
  385. var model1 supplier.RegCapitalRange //注册资金范围
  386. //var model2 supplier.NeedFileTypeStruct //资质结构体
  387. var jsonBlob = this.Ctx.Input.RequestBody
  388. json.Unmarshal(jsonBlob, &model)
  389. json.Unmarshal(jsonBlob, &model1)
  390. //json.Unmarshal(jsonBlob, &model2)
  391. // //获取分页信息
  392. page := this.GetPageInfoForm()
  393. where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' and b.SupplierTypeCode = '02' AND t.SupplierId IS NOT NULL "
  394. orderby := "a.Id"
  395. asc := true
  396. Order := this.GetString("Order")
  397. Prop := this.GetString("Prop")
  398. CheckUId := this.GetString("CheckUId")
  399. FullId := this.GetString("FullId")
  400. if Order != "" && Prop != "" {
  401. orderby = Prop
  402. if Order == "desc" {
  403. asc = false
  404. }
  405. }
  406. leftjoin := ""
  407. //准入证号
  408. if model.AccessCardNo != "" {
  409. where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
  410. }
  411. //企业名称
  412. if model.SupplierName != "" {
  413. where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
  414. }
  415. if model.OldSupplierName != "" {
  416. where = where + " and OldSupplierName like '%" + model.OldSupplierName + "%'"
  417. }
  418. if FullId != "" {
  419. where = where + " and f.Id = '" + FullId + "'"
  420. }
  421. if CheckUId != "" {
  422. where = where + " and g.CheckUnitId = '" + CheckUId + "'"
  423. }
  424. //准入标识 1 准入 2 暂停 3取消
  425. if model.InFlag != "" {
  426. where = where + " and b.InFlag = '" + model.InFlag + "'"
  427. }
  428. //法人
  429. if model.LegalPerson != "" {
  430. where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
  431. }
  432. //联系人
  433. if model.ContactName != "" {
  434. where = where + " and a.ContactName like '%" + model.ContactName + "%'"
  435. }
  436. //统一社会信用代码
  437. if model.CommercialNo != "" {
  438. where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
  439. }
  440. //开户银行
  441. if model.DepositBank != "" {
  442. where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
  443. }
  444. //HSE审查
  445. if model.HseTraining != "" {
  446. where = where + " and a.HseTraining = '" + model.HseTraining + "'"
  447. }
  448. //公司类型
  449. if model.CompanyType != "" {
  450. where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
  451. }
  452. //成立时间
  453. SetupTime := this.GetString("SetupTime")
  454. if SetupTime != "" {
  455. where = where + " and a.SetupTime ='" + SetupTime + "'"
  456. }
  457. //注册资金范围
  458. if model1.RegCapital1 != "" {
  459. where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
  460. }
  461. if model1.RegCapital2 != "" {
  462. where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
  463. }
  464. //注册省份
  465. if model.Province != "" {
  466. where = where + " and a.Province = '" + model.Province + "'"
  467. }
  468. //注册市
  469. if model.City != "" {
  470. where = where + " and a.City = '" + model.City + "'"
  471. }
  472. //注册区
  473. if model.Street != "" {
  474. where = where + " and a.Street = '" + model.Street + "'"
  475. }
  476. //注册详细地址
  477. if model.Address != "" {
  478. where = where + " and a.Address like '%" + model.Address + "%'"
  479. }
  480. if model.LinkProvince != "" {
  481. where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
  482. }
  483. if model.LinkCity != "" {
  484. where = where + " and a.LinkCity = '" + model.LinkCity + "'"
  485. }
  486. if model.LinkStreet != "" {
  487. where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
  488. }
  489. if model.LinkAddress != "" {
  490. where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
  491. }
  492. //营业范围
  493. if model.BusinessScope != "" {
  494. where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
  495. }
  496. CreateOn := this.GetString("CreateOn")
  497. if CreateOn != "" {
  498. dates := strings.Split(CreateOn, ",")
  499. if len(dates) == 2 {
  500. minDate := dates[0]
  501. maxDate := dates[1]
  502. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  503. }
  504. }
  505. a := model.InStyle
  506. fmt.Println(a)
  507. //准入方式
  508. if model.InStyle != "" {
  509. if model.InStyle == "0"{
  510. where = where + " and b.InStyle in ('2','3','4','5')"
  511. }else{
  512. where = where + " and b.InStyle ='" + model.InStyle + "'"
  513. }
  514. }
  515. having:=""
  516. //准入范围
  517. if model.CerSubName!="" {
  518. having = " having CerSubName like '%"+model.CerSubName+"%' "
  519. leftjoin = "left join "+ OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  520. }
  521. //资质
  522. if model.NeedFileType!="" {
  523. having = " having NeedFileType like '%"+model.NeedFileType+"%' "
  524. }
  525. if model.CerSubName!=""&& model.NeedFileType!=""{
  526. having = " having CerSubName like '%"+model.CerSubName+"%' and NeedFileType like '%"+model.NeedFileType+"%' "
  527. leftjoin = "left join "+ OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  528. }
  529. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  530. var list []supplier.OilSupplierSelect
  531. total := svc.GetMyPagingDelEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName,OilCorporateInfoName,OilSupplierCertSubName,
  532. OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where,having, leftjoin)
  533. var datainfo DataInfo
  534. datainfo.Items = list
  535. datainfo.CurrentItemCount = total
  536. datainfo.PageIndex = page.CurrentPage
  537. datainfo.ItemsPerPage = page.Size
  538. this.Data["json"] = &datainfo
  539. this.ServeJSON()
  540. }
  541. // @Title 删除不符合的的准入项
  542. // @Description get user by token
  543. // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
  544. // @router /deltmpsuppliercertsub [get]
  545. func (this *OilBasisBuildController) DelTmpSupplierCertSub() {
  546. var err error
  547. session := utils.DBE.NewSession()
  548. session.Begin()
  549. defer session.Close()
  550. supplierId := this.GetString("SupplierId")
  551. id := this.GetString("Id")
  552. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  553. var supplierCertSubList []suppliercertsub.Tmp_OilSupplierCertSub
  554. wheredel := "1=1 and SupplierTypeCode = '02'"
  555. if supplierId != "" {
  556. wheredel += " and SupplierId=" + supplierId
  557. }
  558. if id != "" {
  559. wheredel += " and Id=" + id
  560. }
  561. svc.GetEntitysByWhere(TmpOilSupplierCertSubName, wheredel, &supplierCertSubList)
  562. var errinfo ErrorInfo
  563. for _,item := range supplierCertSubList {
  564. where := "Id = " + strconv.Itoa(item.Id)
  565. err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
  566. if err != nil {
  567. session.Rollback()
  568. errinfo.Code = -1
  569. errinfo.Message = "删除失败!"
  570. this.Data["json"] = &errinfo
  571. this.ServeJSON()
  572. }
  573. }
  574. for _,item := range supplierCertSubList {
  575. where := "Id = " + strconv.Itoa(item.Id)
  576. err = svc.DeleteEntityBytbl(TmpOilSupplierCertSubName, where)
  577. }
  578. if err == nil {
  579. session.Commit()
  580. errinfo.Code = 0
  581. errinfo.Message = "删除成功!"
  582. this.Data["json"] = &errinfo
  583. this.ServeJSON()
  584. } else {
  585. session.Rollback()
  586. errinfo.Code = -1
  587. errinfo.Message = "删除失败!"
  588. this.Data["json"] = &errinfo
  589. this.ServeJSON()
  590. }
  591. }
  592. // @Title 修改资质后找出不符合的准入
  593. // @Description 修改实体
  594. // @Success 200 {object} controllers.Request
  595. // @router /findinconformity [post]
  596. func (this *OilBasisBuildController) FindInconformity() {
  597. var errinfo ErrorInfo
  598. var err error
  599. var model basisbuild.OilBasisBuild
  600. var companygoodslist []suppliercertsub.OilSupplierCertSub
  601. var companygood suppliercertsub.OilSupplierCertSub
  602. var SurplusList []supplierfile.FileList
  603. var supfilemodel []supplierfile.OilSupplierFile
  604. var supfilemodel01 []supplierfile.OilSupplierFile
  605. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  606. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  607. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  608. var jsonBlob = this.Ctx.Input.RequestBody
  609. json.Unmarshal(jsonBlob, &model)
  610. Code := model.Code
  611. where := " Code ='"+Code+"' and Type in ('1','3') and SupplierTypeCode = '02'"
  612. svc.FindGoodsByCode("OilSupplierCertSub",where,&companygoodslist)
  613. SurplusList = filesvc.GetBasicNeedFileList(strconv.Itoa(model.Id))
  614. for _, CertSub := range companygoodslist {
  615. companygood = CertSub
  616. wherecompany := " SupplierId ="+strconv.Itoa(CertSub.SupplierId)
  617. svc.FindFileByCompany("OilSupplierFile",wherecompany,&supfilemodel)
  618. if len(supfilemodel)<1 {
  619. _,err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  620. }else {
  621. var tmplist1 []suppliercertsub.Tmp_OilSupplierCertSub
  622. wherecompany = " Id ="+strconv.Itoa(CertSub.Id)
  623. svc.FindFileByCompany("tmp_OilSupplierCertSub",wherecompany,&tmplist1)
  624. if len(tmplist1)<1{
  625. wherecompany = " SupplierId ='" + strconv.Itoa(CertSub.SupplierId) + "'"
  626. svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel01)
  627. var File01 string
  628. for _, Filesub := range supfilemodel01 {
  629. File01 = File01 + Filesub.NeedFileType + ","
  630. }
  631. for _, Filesub := range SurplusList {
  632. var supplierModel supplier.OilSupplier
  633. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  634. svcSupplier.GetEntityById(strconv.Itoa(CertSub.SupplierId), &supplierModel)
  635. //三证合一或五证合一不需要的字段
  636. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  637. File01 = mergerCertSkipField + File01
  638. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(File01, Filesub.FileName+",") { //三证合一或五证合一了
  639. continue
  640. }
  641. if strings.Contains(File01, Filesub.FileName+",") {
  642. continue
  643. }
  644. _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  645. break
  646. }
  647. }
  648. }
  649. }
  650. if err == nil {
  651. errinfo.Message = "已拉取缺失资质列表!"
  652. errinfo.Code = 0
  653. this.Data["json"] = &errinfo
  654. this.ServeJSON()
  655. } else {
  656. errinfo.Message = "拉取列表失败!" + utils.AlertProcess(err.Error())
  657. errinfo.Code = -1
  658. this.Data["json"] = &errinfo
  659. this.ServeJSON()
  660. }
  661. }
  662. // @Title 获取列表新导入的列表
  663. // @Description get user by token
  664. // @Success 200 {object} []goodsaptitude.OilGoodsAptitude
  665. // @router /importlist [get]
  666. func (this *OilBasisBuildController) GetImportEntityList() {
  667. //获取分页信息
  668. page := this.GetPageInfoForm()
  669. where := " 1=1 "
  670. orderby := "Code"
  671. asc := true
  672. Order := this.GetString("Order")
  673. Prop := this.GetString("Prop")
  674. if Order != "" && Prop != "" {
  675. orderby = Prop
  676. if Order == "asc" {
  677. asc = true
  678. } else {
  679. asc = false
  680. }
  681. }
  682. Code := this.GetString("Code")
  683. Name := this.GetString("Name")
  684. if Code != "" {
  685. where = where + " and Code like '%" + Code + "%'"
  686. }
  687. if Name != "" {
  688. where = where + " and Name like '%" + Name + "%'"
  689. }
  690. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  691. var list []basisbuild.OilBasisBuild
  692. total := svc.GetMyPagingEntitiesWithOrderBytbl(TmpOilBasisBuildName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  693. var datainfo DataInfo
  694. datainfo.Items = list
  695. datainfo.CurrentItemCount = total
  696. datainfo.PageIndex = page.CurrentPage
  697. datainfo.ItemsPerPage = page.Size
  698. this.Data["json"] = &datainfo
  699. this.ServeJSON()
  700. }
  701. // @Title get 导入excel
  702. // @Description get SampleType by token
  703. // @Success 200 {object} sampletype.SampleType
  704. // @router /importexcel [get]
  705. func (this *OilBasisBuildController) ImportExcel() {
  706. url := this.GetString("ExcelUrl")
  707. var errorinfo ErrorInfo
  708. if url == "" {
  709. errorinfo.Code = -2
  710. errorinfo.Message = "导入失败!"
  711. this.Data["json"] = &errorinfo
  712. this.ServeJSON()
  713. }
  714. session := utils.DBE.NewSession()
  715. err := session.Begin()
  716. svc := basisbuild.GetOilBasisbuildSession(session)
  717. err = svc.TruncateTable(TmpOilBasisBuildName)
  718. if err != nil {
  719. session.Rollback()
  720. errorinfo.Code = -2
  721. errorinfo.Message = "导入失败!"
  722. this.Data["json"] = &errorinfo
  723. this.ServeJSON()
  724. }
  725. _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
  726. filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
  727. utils.DownloadFile(url, filename, _dir)
  728. t := time.Now()
  729. filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
  730. xlFile, err := xlsx.OpenFile(filePath)
  731. var errLineNum string
  732. //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
  733. if err != nil {
  734. fmt.Printf("open failed: %s\n", err)
  735. }
  736. var sheet = xlFile.Sheets[0]
  737. // 插入字段
  738. Fstrs := svc.GetFCode()
  739. Fstrs = "Code,Name," + Fstrs
  740. columnArr := strings.Split(Fstrs, ",")
  741. defer func() {
  742. session.Close()
  743. }()
  744. codemap := make(map[string]int)
  745. for i := 1; i < len(sheet.Rows); i++ {
  746. lineNo := strconv.Itoa(i + 1)
  747. fmt.Println(lineNo)
  748. this.OperationCell(svc, lineNo, columnArr, codemap, sheet.Rows[i].Cells, &errLineNum)
  749. }
  750. os.Remove(filePath)
  751. if errLineNum != "" {
  752. session.Rollback()
  753. errorinfo.Code = -1
  754. errorinfo.Message = "导入失败!错误行号:" + errLineNum
  755. this.Data["json"] = &errorinfo
  756. this.ServeJSON()
  757. } else {
  758. session.Commit()
  759. elapsed := time.Since(t)
  760. log.Println(elapsed)
  761. errorinfo.Code = 0
  762. errorinfo.Message = "导入成功!"
  763. this.Data["json"] = &errorinfo
  764. this.ServeJSON()
  765. }
  766. }
  767. func (this *OilBasisBuildController) OperationCell(svc *basisbuild.OilBasisbuildSession, lineNo string, columnArr []string, codemap map[string]int, cellsArr []*xlsx.Cell, errLineNum *string) {
  768. defer func() {
  769. if err := recover(); err != nil {
  770. log.Println("err"+lineNo, err)
  771. *errLineNum += lineNo + ","
  772. }
  773. }()
  774. cellsArrLen := len(cellsArr)
  775. var valstr = ""
  776. for i := 0; i < cellsArrLen;i++ {
  777. valstr += "'" + cellsArr[i].String() + "',"
  778. }
  779. valstr = strings.Trim(valstr, ",")
  780. valstr = strings.Replace(valstr, "是", "1", -1)
  781. log.Println(cellsArr[6].String() + "==" + valstr)
  782. var columnstr= ""
  783. for l := 0; l < cellsArrLen; l++ {
  784. columnstr += columnArr[l] + ","
  785. }
  786. columnstr = strings.Trim(columnstr, ",")
  787. err := svc.InsertTmpOilBasisBuild(columnstr, valstr)
  788. if err != nil {
  789. panic(err)
  790. }
  791. }
  792. // @Title get 清空导入的信息
  793. // @Description get SampleType by token
  794. // @Success 200 {object} sampletype.SampleType
  795. // @router /truncateimport [get]
  796. func (this *OilBasisBuildController) TruncateImport() {
  797. session := utils.DBE.NewSession()
  798. err := session.Begin()
  799. defer session.Close()
  800. svc := basisbuild.GetOilBasisbuildSession(session)
  801. err = svc.TruncateTable(TmpOilBasisBuildName)
  802. var errorinfo ErrorInfo
  803. if err != nil {
  804. session.Rollback()
  805. errorinfo.Code = -1
  806. errorinfo.Message = "删除失败!"
  807. this.Data["json"] = &errorinfo
  808. this.ServeJSON()
  809. }
  810. session.Commit()
  811. errorinfo.Code = 0
  812. errorinfo.Message = "删除成功!"
  813. this.Data["json"] = &errorinfo
  814. this.ServeJSON()
  815. }
  816. // @Title 将导入的数据 导入到正式表
  817. // @Description get SampleType by token
  818. // @Success 200 {object} sampletype.SampleType
  819. // @router /insertbasisbuild [get]
  820. func (this *OilBasisBuildController) InsertBasisbuild() {
  821. session := utils.DBE.NewSession()
  822. err := session.Begin()
  823. defer session.Close()
  824. svc := basisbuild.GetOilBasisbuildSession(session)
  825. var errinfo ErrorInfo
  826. err = svc.TruncateTable(OilBasisBuildName)
  827. if err != nil {
  828. session.Rollback()
  829. errinfo.Code = -1
  830. errinfo.Message = "跟新失败!"
  831. this.Data["json"] = &errinfo
  832. this.ServeJSON()
  833. }
  834. err = svc.InsertBasisBuild(TmpOilBasisBuildName, OilBasisBuildName)
  835. if err != nil {
  836. session.Rollback()
  837. errinfo.Code = -1
  838. errinfo.Message = "跟新失败!"
  839. this.Data["json"] = &errinfo
  840. this.ServeJSON()
  841. }
  842. session.Commit()
  843. errinfo.Code = 0
  844. errinfo.Message = "跟新成功!"
  845. this.Data["json"] = &errinfo
  846. this.ServeJSON()
  847. }
  848. // @Title 更新企业的准入项及资质
  849. // @Description get SampleType by token
  850. // @Success 200 {object} sampletype.SampleType
  851. // @router /updatasuppiercertsub [get]
  852. func (this *OilBasisBuildController) UpdataSuppierCertSub() {
  853. t := time.Now()
  854. goodsvc := basisbuild.GetOilBasisBuildService(utils.DBE)
  855. goodsvc.DeleteTable(TmpOilSupplierCertSubName, "SupplierTypeCode='02'")
  856. supsvc := supplier.GetOilSupplierService(utils.DBE)
  857. // 所有基建类供应商
  858. var suppliercertList []suppliercert.OilSupplierCert
  859. where := "SupplierTypeCode='02' AND OutsideFlog = '' AND (InFlag IN ('1','2')) "
  860. supsvc.GetEntities(&suppliercertList, where)
  861. var basisbuildList []basisbuild.OilBasisBuild
  862. supsvc.GetEntities(&basisbuildList, "")
  863. var colsname = []string{"Name"}
  864. for _, suppliercert := range suppliercertList {
  865. var supplier supplier.OilSupplier
  866. wheres := " Id=" + strconv.Itoa(suppliercert.SupplierId)
  867. supsvc.GetEntity(&supplier, wheres)
  868. log.Println(suppliercert.SupplierId)
  869. // 供应商的准入范围
  870. var supplierCertSubList []suppliercertsub.OilSupplierCertSub
  871. wheresup := "SupplierId = " + strconv.Itoa(suppliercert.SupplierId) + " and SupplierTypeCode='02' AND Type IN ('1', '3')"
  872. supsvc.GetEntities(&supplierCertSubList, wheresup)
  873. fmt.Println(len(supplierCertSubList))
  874. mergerCertSkipField := ""
  875. if supplier.CredentialFlag == "1" || supplier.CredentialFlag == "2" {
  876. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  877. //三证合一或五证合一不需要的字段
  878. mergerCertSkipField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  879. }
  880. for idx := 0; idx < len(supplierCertSubList); idx++ {
  881. supplierCertSub := supplierCertSubList[idx]
  882. decCode := supplierCertSub.Code
  883. // 基建类的准入编码 basisbuildList基建类准入编码
  884. for _, goodsaptitudeClass := range basisbuildList {
  885. // 如果编码相同的后 判断有没有改名 然后查询准入项需要哪些资质 去查资质表里有没有这些资质 没有就删除这个准入项
  886. if supplierCertSub.Code == goodsaptitudeClass.Code {
  887. decCode = ""
  888. // F01 F02...对应的名称
  889. goodsAptitudeNameArr := this.GetBasisBuildName(strconv.Itoa(goodsaptitudeClass.Id))
  890. for _, val := range goodsAptitudeNameArr {
  891. if strings.Contains(mergerCertSkipField, val) {
  892. break
  893. }
  894. var supplierFile supplierfile.OilSupplierFile
  895. where := "SupplierId=" + strconv.Itoa(suppliercert.SupplierId) + " and NeedFileType='" + val + "'" + " and SupplierTypeCode IN ('000', '02')"
  896. has := supsvc.GetEntityByWhere(OilSupplierFileName, where, &supplierFile)
  897. if !has {
  898. log.Println(supplierCertSub.Code + "====" + val)
  899. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  900. break
  901. }
  902. if supplierCertSub.Name != goodsaptitudeClass.Name {
  903. var entity suppliercertsub.OilSupplierCertSub
  904. entity.Name = goodsaptitudeClass.Name
  905. where := "Id = " + strconv.Itoa(supplierCertSub.Id)
  906. supsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &entity, colsname, where)
  907. }
  908. }
  909. break
  910. }
  911. }
  912. if decCode != "" {
  913. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  914. }
  915. }
  916. }
  917. elapsed := time.Since(t)
  918. log.Println(elapsed)
  919. var errinfo ErrorInfo
  920. errinfo.Code = 0
  921. errinfo.Message = "更新完成!"
  922. this.Data["json"] = &errinfo
  923. this.ServeJSON()
  924. //xlFile.Save(excelFileName)
  925. }
  926. func (this *OilBasisBuildController) GetBasisBuildName(classId string) []string {
  927. var goodsAptitudeName string
  928. var goodsAptitudeList []basisbuild.OilBasisBuildF
  929. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  930. where := "Id=" + classId
  931. svc.GetBasisBuildServiceF(&goodsAptitudeList, where)
  932. for _, goodsAptitude := range goodsAptitudeList {
  933. t := reflect.TypeOf(goodsAptitude)
  934. v := reflect.ValueOf(goodsAptitude)
  935. for k := 0; k < t.NumField(); k++ {
  936. if v.Field(k).Interface() == "1" {
  937. var tableHeader tableheader.BaseTableheader
  938. where := "Code='" + t.Field(k).Name + "' and CategoryCode = '02'"
  939. has := svc.GetEntityByWhere(BaseTableHeader, where, &tableHeader)
  940. if has {
  941. goodsAptitudeName += tableHeader.Name + ","
  942. }
  943. }
  944. }
  945. }
  946. goodsAptitudeName = strings.Trim(goodsAptitudeName, ",")
  947. return strings.Split(goodsAptitudeName, ",")
  948. }
  949. // @Title 导出数据到word,作为导出pdf的中间步骤
  950. // @Description 数据存入word
  951. // @Success 200 {object} controllers.Request
  952. // @router /exportpdf/:tbid/:typecode [post]
  953. func (this *OilBasisBuildController) PdfExport() {
  954. Id := this.Ctx.Input.Param(":tbid")
  955. SupplierTypeCode := this.Ctx.Input.Param(":typecode")
  956. var Url string
  957. var fileName string
  958. var model1 supplierdataentry.SupplierDataEntry
  959. var model2 supplierdataentry.SupplierCertDataEntry
  960. svc := supplierdataentry.GetSupplierDataEntryService(utils.DBE)
  961. where1 := "1=1"
  962. where1 += " AND Id = '" + Id + "'"
  963. where2 := "SupplierId = '" + Id + "' and SupplierTypecode='"+ SupplierTypeCode +"'"
  964. svc.GetEntityByWhere(OilSupplierName, where1, &model1)
  965. svc.GetEntityByWhere(OilSupplierCertName, where2, &model2)
  966. var tabledata []supplierdataentry.SupplierCertSubEntry
  967. where3:="SupplierId = '" + Id + "' and SupplierTypecode='"+ SupplierTypeCode +"' and Type in ('1','3')"//准入状态的准入项
  968. svc.GetEntitysByOrderbyWhere(TmpOilSupplierCertSubName, where3, "1", &tabledata)
  969. datamap := structToMapDemo(model1.OilSupplier)
  970. if model2.SupplierTypeCode == "01" {
  971. Url = utils.Cfg.MustValue("workflow", "goodsPdfHost")
  972. fileName = "待删除物资类准入范围.docx"
  973. } else if model2.SupplierTypeCode == "02" {
  974. Url = utils.Cfg.MustValue("workflow", "basisPdfHost")
  975. fileName = "待删除基建类准入范围.docx"
  976. datamap["TJInNotify"] = model1.TJInNotify
  977. } else {
  978. Url = utils.Cfg.MustValue("workflow", "techPdfHost")
  979. fileName = "待删除服务类准入范围.docx"
  980. }
  981. //model1
  982. datamap["SetupTime"] = model1.SetupTime.Format("2006年01月02日")
  983. datamap["QualifCert"] = model1.QualifCert
  984. datamap["QualifCertLevel"] = model1.QualifCertLevel
  985. datamap["SpecIndustryCert"] = model1.SpecIndustryCert
  986. datamap["MaunLicense"] = model1.MaunLicense
  987. if model1.HseTraining == "1" {
  988. datamap["HseTraining"] = "是"
  989. } else {
  990. datamap["HseTraining"] = "否"
  991. }
  992. if model1.OperType != "" {
  993. if model1.OperType == "1" || model1.OperType == "制造商"{
  994. datamap["OperType"] = "√制造商 □代理商 □贸易商"
  995. }else if model1.OperType == "2" || model1.OperType == "代理商"{
  996. datamap["OperType"] = "□制造商 √代理商 □贸易商"
  997. }else if model1.OperType == "3" || model1.OperType == "代理商"{
  998. datamap["OperType"] = "□制造商 □代理商 √贸易商"
  999. }else {
  1000. datamap["OperType"] = "□制造商 □代理商 □贸易商"
  1001. }
  1002. }
  1003. if model1.SpecTypeCode != "" {
  1004. if model1.SpecTypeCode == "1"{
  1005. datamap["SpecTypeCode"] = "√一般外部 □多元企业"
  1006. }else if model1.SpecTypeCode == "2"{
  1007. datamap["SpecTypeCode"] = "□一般外部 √多元企业"
  1008. }else {
  1009. datamap["SpecTypeCode"] = "□一般外部 □多元企业"
  1010. }
  1011. }
  1012. if model1.Grade == "1"{
  1013. datamap["Grade"] = "一级"
  1014. }else if model1.SpecTypeCode == "2"{
  1015. datamap["Grade"] = "二级"
  1016. }
  1017. datamap["Fax"] = model1.Fax
  1018. datamap["CompanyTel"] = model1.CompanyTel
  1019. datamap["SupplierName"] = model1.SupplierName
  1020. datamap["Country"] = model1.Country
  1021. datamap["MaunAgent"] = model1.MaunAgent
  1022. datamap["SupplierCertificate"] = model1.SupplierCertificate
  1023. datamap["MgrUnit"] = model1.MgrUnit
  1024. datamap["CommercialNo"] = model1.CommercialNo
  1025. datamap["CountryTaxNo"] = model1.CountryTaxNo
  1026. datamap["OrganCode"] = model1.OrganCode
  1027. datamap["Address"] = model1.Address
  1028. datamap["ZipCode"] = model1.ZipCode
  1029. datamap["LinkAddress"] = model1.LinkAddress
  1030. datamap["LinkZipCode"] = model1.LinkZipCode
  1031. datamap["QualitySystemCert"] = model1.QualitySystemCert
  1032. datamap["ProductQualityCert"] = model1.ProductQualityCert
  1033. datamap["MaunLicense"] = model1.MaunLicense
  1034. datamap["LegalPerson"] = model1.LegalPerson
  1035. datamap["CompanyType"] = model1.CompanyType
  1036. datamap["ContactName"] = model1.ContactName
  1037. datamap["RegCapital"] = strconv.FormatFloat(model1.RegCapital,'f',2,64)+"万元"+model1.Currency
  1038. datamap["DepositBank"] = model1.DepositBank
  1039. datamap["BankAccount"] = model1.BankAccount
  1040. datamap["Mobile"] = model1.Mobile
  1041. datamap["EMail"] = model1.EMail
  1042. datamap["BankCreditRating"] = model1.BankCreditRating
  1043. datamap["BusinessScope"] = model1.BusinessScope
  1044. datamap["Telphone"] = model1.Telphone
  1045. datamap["AccessCardNo"] = model2.AccessCardNo
  1046. datamap["PrintYear"] = time.Now().Year()
  1047. datamap["PrintMonth"] = time.Now().Month()
  1048. datamap["PrintDay"] = time.Now().Day()
  1049. datamap["Name"] = ""
  1050. if len(tabledata) != 0 {
  1051. var Name string
  1052. Name = "\n待删除准入范围:"+ tabledata[0].Code
  1053. Name = Name + " " + tabledata[0].Name
  1054. var i int
  1055. for i = 1; i < len(tabledata); i++ {
  1056. Name += ";"
  1057. Name += tabledata[i].Code
  1058. Name = Name + " " + tabledata[i].Name
  1059. }
  1060. //if i == 100 {
  1061. // Name += "(准入范围未完全显示,请到系统查看详情)"
  1062. //}
  1063. datamap["Name"] =datamap["Name"].(string) + Name
  1064. } else {
  1065. datamap["Name"] =datamap["Name"].(string)
  1066. }
  1067. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1068. retDocUrl := svcActiviti.FillWordTemplate(datamap, Url, fileName)
  1069. var datainfo ErrorDataInfo
  1070. datainfo.Code = 0
  1071. datainfo.Item = retDocUrl
  1072. datainfo.Message = "准备导出"
  1073. this.Data["json"] = &datainfo
  1074. this.ServeJSON()
  1075. }