2
3

basisbuild.go 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730
  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/supplier"
  23. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  24. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  25. . "dashoo.cn/backend/api/controllers"
  26. "dashoo.cn/business2/parameter"
  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 model1 basisbuild.OilBasisBuild
  122. var jsonBlob = this.Ctx.Input.RequestBody
  123. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  124. var errinfo ErrorDataInfo
  125. json.Unmarshal(jsonBlob, &model)
  126. where := " Code = " + model.Code
  127. code := svc.GetEntityByWhere(OilBasisBuildName, where, &model1)
  128. if code {
  129. errinfo.Message = "编码不能重复!"
  130. errinfo.Code = -1
  131. this.Data["json"] = &errinfo
  132. this.ServeJSON()
  133. return
  134. }
  135. where1 := " Name = " + model.Name
  136. name := svc.GetEntityByWhere(OilBasisBuildName, where1, &model1)
  137. if name {
  138. errinfo.Message = "名称不能重复!"
  139. errinfo.Code = -1
  140. this.Data["json"] = &errinfo
  141. this.ServeJSON()
  142. return
  143. }
  144. model.CreateOn = time.Now()
  145. model.CreateBy = this.User.Realname
  146. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  147. //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  148. _, err := svc.InsertEntityBytbl(""+OilBasisBuildName, &model)
  149. if err == nil {
  150. //新增
  151. errinfo.Message = "添加成功!"
  152. errinfo.Code = 0
  153. errinfo.Item = model.Id
  154. this.Data["json"] = &errinfo
  155. this.ServeJSON()
  156. } else {
  157. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  158. errinfo.Code = -1
  159. this.Data["json"] = &errinfo
  160. this.ServeJSON()
  161. }
  162. }
  163. // @Title 修改实体
  164. // @Description 修改实体
  165. // @Success 200 {object} controllers.Request
  166. // @router /update/:id [post]
  167. func (this *OilBasisBuildController) UpdateEntity() {
  168. id := this.Ctx.Input.Param(":id")
  169. var errinfo ErrorInfo
  170. if id == "" {
  171. errinfo.Message = "操作失败!请求信息不完整"
  172. errinfo.Code = -2
  173. this.Data["json"] = &errinfo
  174. this.ServeJSON()
  175. return
  176. }
  177. var model basisbuild.OilBasisBuild
  178. var basmodel []basisbuild.OilBasisBuild
  179. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  180. var jsonBlob = this.Ctx.Input.RequestBody
  181. json.Unmarshal(jsonBlob, &model)
  182. if model.Name != "" {
  183. where := " Name = '" + model.Name +"' and Id not in ('"+id+"')"
  184. svc.GetEntitysByWhere(OilBasisBuildName, where, &basmodel)
  185. if len(basmodel) > 0 {
  186. errinfo.Message = "名称已存在,请重新添加!"
  187. errinfo.Code = -1
  188. this.Data["json"] = &errinfo
  189. this.ServeJSON()
  190. return
  191. }
  192. }
  193. if model.Code != "" {
  194. cowhere := " Code = '" + model.Code+"' and Id not in ('"+id+"')"
  195. svc.GetEntitysByWhere(OilBasisBuildName, cowhere, &basmodel)
  196. if len(basmodel) > 0 {
  197. errinfo.Message = "编码已存在,请重新添加!"
  198. errinfo.Code = -1
  199. this.Data["json"] = &errinfo
  200. this.ServeJSON()
  201. return
  202. }
  203. }
  204. model.ModifiedOn = time.Now()
  205. model.ModifiedBy = this.User.Realname
  206. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  207. cols := []string{
  208. "Id",
  209. "Code",
  210. "Name",
  211. "F01",
  212. "F02",
  213. "F03",
  214. "F04",
  215. "F05",
  216. "F06",
  217. "F07",
  218. "F08",
  219. "F09",
  220. "F10",
  221. "F11",
  222. "F12",
  223. "F13",
  224. "F14",
  225. "F15",
  226. "F16",
  227. "F17",
  228. "F18",
  229. "F19",
  230. "F20",
  231. "F21",
  232. "F22",
  233. "F23",
  234. "F24",
  235. "F25",
  236. "Remark",
  237. "DeletionStateCode",
  238. "CreateOn",
  239. "CreateUserId",
  240. "CreateBy",
  241. "ModifiedOn",
  242. "ModifiedUserId",
  243. "ModifiedBy",
  244. }
  245. err := svc.UpdateEntityBytbl(""+OilBasisBuildName, id, &model, cols)
  246. if err == nil {
  247. errinfo.Message = "修改成功!"
  248. errinfo.Code = 0
  249. this.Data["json"] = &errinfo
  250. this.ServeJSON()
  251. } else {
  252. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  253. errinfo.Code = -1
  254. this.Data["json"] = &errinfo
  255. this.ServeJSON()
  256. }
  257. }
  258. // @Title 删除单条信息
  259. // @Description
  260. // @Success 200 {object} ErrorInfo
  261. // @Failure 403 :id 为空
  262. // @router /delete/:Id [delete]
  263. func (this *OilBasisBuildController) DeleteEntity() {
  264. Id := this.Ctx.Input.Param(":Id")
  265. var errinfo ErrorInfo
  266. if Id == "" {
  267. errinfo.Message = "操作失败!请求信息不完整"
  268. errinfo.Code = -2
  269. this.Data["json"] = &errinfo
  270. this.ServeJSON()
  271. return
  272. }
  273. var model basisbuild.OilBasisBuild
  274. var entityempty basisbuild.OilBasisBuild
  275. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  276. opdesc := "删除-" + Id
  277. err := svc.DeleteOperationAndWriteLogBytbl(""+OilBasisBuildName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "钻井日报")
  278. if err == nil {
  279. errinfo.Message = "删除成功"
  280. errinfo.Code = 0
  281. this.Data["json"] = &errinfo
  282. this.ServeJSON()
  283. } else {
  284. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  285. errinfo.Code = -1
  286. this.Data["json"] = &errinfo
  287. this.ServeJSON()
  288. }
  289. }
  290. // @Title 基建类业务
  291. // @Description get user by token
  292. // @Success 200 {object} models.Userblood
  293. // @router /basiclist [get]
  294. func (this *OilBasisBuildController) BasicList() {
  295. page := this.GetPageInfoForm()
  296. var list []basisbuild.OilBasisBuild
  297. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  298. where := " 1=1"
  299. orderby := "Id"
  300. asc := true
  301. Order := this.GetString("Order")
  302. Prop := this.GetString("Prop")
  303. if Order != "" && Prop != "" {
  304. orderby = Prop
  305. if Order == "asc" {
  306. asc = true
  307. }
  308. }
  309. keyword := this.GetString("keyword")
  310. if keyword != "" {
  311. where = where + " and Name like '%" + keyword + "%' or Code like '%" + keyword + "%'"
  312. }
  313. total := svc.GetPagingEntitiesWithoutAccCode(page.CurrentPage, page.Size, orderby, asc, &list, where)
  314. var datainfo DataInfo
  315. datainfo.Items = list
  316. datainfo.CurrentItemCount = total
  317. this.Data["json"] = &datainfo
  318. this.ServeJSON()
  319. }
  320. // @Title get 导出ex
  321. // @Description get SampleType by token
  322. // @Success 200 {object} sampletype.SampleType
  323. // @router /exportexcelall [get]
  324. func (this *OilBasisBuildController) ExportExcelAll() {
  325. //获取分页信息
  326. where := " 1=1 "
  327. orderby := "Code"
  328. asc := true
  329. Order := this.GetString("Order")
  330. Prop := this.GetString("Prop")
  331. if Order != "" && Prop != "" {
  332. orderby = Prop
  333. if Order == "asc" {
  334. asc = true
  335. } else {
  336. asc = false
  337. }
  338. }
  339. t := time.Now()
  340. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  341. var list []basisbuild.OilBasisBuild
  342. svc.GetPagingEntitiesWithOrderBytbl("", 0, 0, orderby, asc, &list, where)
  343. var title []string
  344. filetitle := "基建类"
  345. //自定义显示列
  346. showcolumnarr := this.GetString("showcolumnarr")
  347. showcolumnnamearr := this.GetString("showcolumnnamearr")
  348. titlestring := showcolumnnamearr
  349. title = strings.Split(titlestring, ",")
  350. f := xlsx.NewFile()
  351. sheet, _ := f.AddSheet(filetitle)
  352. cellname := strings.Split(showcolumnarr, ",")
  353. row := sheet.AddRow()
  354. row.WriteSlice(&cellname, -1)
  355. for _, item := range list {
  356. var enumModel basisbuild.OilBasisBuild
  357. tmpModel := &item
  358. enumModel = *tmpModel
  359. immumodel := reflect.ValueOf(&enumModel)
  360. elem := immumodel.Elem()
  361. row := sheet.AddRow()
  362. for _, name := range title {
  363. cell := row.AddCell()
  364. if strings.HasPrefix(name, "F") {
  365. var val = elem.FieldByName(name).String()
  366. if val == "1" {
  367. cell.Value = "是"
  368. } else {
  369. cell.Value = ""
  370. }
  371. } else {
  372. cell.Value = elem.FieldByName(name).String()
  373. }
  374. }
  375. }
  376. for c, cl := 0, len(sheet.Cols); c < cl; c++ {
  377. sheet.Cols[c].Width = 20
  378. }
  379. dir := "static/file/excel/report/" + this.GetAccode()
  380. SaveDirectory(dir)
  381. path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
  382. f.Save(path)
  383. var sw *Seaweed
  384. var filer []string
  385. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  386. filer = []string{_filer}
  387. }
  388. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  389. _, _, fID, _ := sw.UploadFile(path, "", "")
  390. retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  391. os.Remove(path)
  392. fmt.Println("==retDocWatermarkUrl==", retDocUrl)
  393. this.Data["json"] = retDocUrl
  394. this.ServeJSON()
  395. elapsed := time.Since(t)
  396. fmt.Println(elapsed)
  397. }
  398. // @Title 获取所有
  399. // @Description
  400. // @Success 200 {object}
  401. // @router /getcompanylist [post]
  402. func (this *OilBasisBuildController) GetTList() {
  403. var model supplier.OilSupplierSelect
  404. var model1 supplier.RegCapitalRange //注册资金范围
  405. //var model2 supplier.NeedFileTypeStruct //资质结构体
  406. var jsonBlob = this.Ctx.Input.RequestBody
  407. json.Unmarshal(jsonBlob, &model)
  408. json.Unmarshal(jsonBlob, &model1)
  409. //json.Unmarshal(jsonBlob, &model2)
  410. // //获取分页信息
  411. page := this.GetPageInfoForm()
  412. where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' and b.SupplierTypeCode = '02' AND t.SupplierId IS NOT NULL "
  413. orderby := "a.Id"
  414. asc := true
  415. Order := this.GetString("Order")
  416. Prop := this.GetString("Prop")
  417. CheckUId := this.GetString("CheckUId")
  418. FullId := this.GetString("FullId")
  419. if Order != "" && Prop != "" {
  420. orderby = Prop
  421. if Order == "desc" {
  422. asc = false
  423. }
  424. }
  425. leftjoin := ""
  426. //准入证号
  427. if model.AccessCardNo != "" {
  428. where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
  429. }
  430. //企业名称
  431. if model.SupplierName != "" {
  432. where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
  433. }
  434. if model.OldSupplierName != "" {
  435. where = where + " and OldSupplierName like '%" + model.OldSupplierName + "%'"
  436. }
  437. if FullId != "" {
  438. where = where + " and f.Id = '" + FullId + "'"
  439. }
  440. if CheckUId != "" {
  441. where = where + " and g.CheckUnitId = '" + CheckUId + "'"
  442. }
  443. //准入标识 1 准入 2 暂停 3取消
  444. if model.InFlag != "" {
  445. where = where + " and b.InFlag = '" + model.InFlag + "'"
  446. }
  447. //法人
  448. if model.LegalPerson != "" {
  449. where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
  450. }
  451. //联系人
  452. if model.ContactName != "" {
  453. where = where + " and a.ContactName like '%" + model.ContactName + "%'"
  454. }
  455. //统一社会信用代码
  456. if model.CommercialNo != "" {
  457. where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
  458. }
  459. //开户银行
  460. if model.DepositBank != "" {
  461. where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
  462. }
  463. //HSE审查
  464. if model.HseTraining != "" {
  465. where = where + " and a.HseTraining = '" + model.HseTraining + "'"
  466. }
  467. //公司类型
  468. if model.CompanyType != "" {
  469. where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
  470. }
  471. //成立时间
  472. SetupTime := this.GetString("SetupTime")
  473. if SetupTime != "" {
  474. where = where + " and a.SetupTime ='" + SetupTime + "'"
  475. }
  476. //注册资金范围
  477. if model1.RegCapital1 != "" {
  478. where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
  479. }
  480. if model1.RegCapital2 != "" {
  481. where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
  482. }
  483. //注册省份
  484. if model.Province != "" {
  485. where = where + " and a.Province = '" + model.Province + "'"
  486. }
  487. //注册市
  488. if model.City != "" {
  489. where = where + " and a.City = '" + model.City + "'"
  490. }
  491. //注册区
  492. if model.Street != "" {
  493. where = where + " and a.Street = '" + model.Street + "'"
  494. }
  495. //注册详细地址
  496. if model.Address != "" {
  497. where = where + " and a.Address like '%" + model.Address + "%'"
  498. }
  499. if model.LinkProvince != "" {
  500. where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
  501. }
  502. if model.LinkCity != "" {
  503. where = where + " and a.LinkCity = '" + model.LinkCity + "'"
  504. }
  505. if model.LinkStreet != "" {
  506. where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
  507. }
  508. if model.LinkAddress != "" {
  509. where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
  510. }
  511. //营业范围
  512. if model.BusinessScope != "" {
  513. where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
  514. }
  515. CreateOn := this.GetString("CreateOn")
  516. if CreateOn != "" {
  517. dates := strings.Split(CreateOn, ",")
  518. if len(dates) == 2 {
  519. minDate := dates[0]
  520. maxDate := dates[1]
  521. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  522. }
  523. }
  524. a := model.InStyle
  525. fmt.Println(a)
  526. //准入方式
  527. if model.InStyle != "" {
  528. if model.InStyle == "0"{
  529. where = where + " and b.InStyle in ('2','3','4','5')"
  530. }else{
  531. where = where + " and b.InStyle ='" + model.InStyle + "'"
  532. }
  533. }
  534. having:=""
  535. //准入范围
  536. if model.CerSubName!="" {
  537. having = " having CerSubName like '%"+model.CerSubName+"%' "
  538. leftjoin = "left join "+ OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  539. }
  540. //资质
  541. if model.NeedFileType!="" {
  542. having = " having NeedFileType like '%"+model.NeedFileType+"%' "
  543. }
  544. if model.CerSubName!=""&& model.NeedFileType!=""{
  545. having = " having CerSubName like '%"+model.CerSubName+"%' and NeedFileType like '%"+model.NeedFileType+"%' "
  546. leftjoin = "left join "+ OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  547. }
  548. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  549. var list []supplier.OilSupplierSelect
  550. total := svc.GetMyPagingDelEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName,OilCorporateInfoName,OilSupplierCertSubName,
  551. OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where,having, leftjoin)
  552. var datainfo DataInfo
  553. datainfo.Items = list
  554. datainfo.CurrentItemCount = total
  555. datainfo.PageIndex = page.CurrentPage
  556. datainfo.ItemsPerPage = page.Size
  557. this.Data["json"] = &datainfo
  558. this.ServeJSON()
  559. }
  560. // @Title 删除不符合的的准入项
  561. // @Description get user by token
  562. // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
  563. // @router /deltmpsuppliercertsub [get]
  564. func (this *OilBasisBuildController) DelTmpSupplierCertSub() {
  565. var err error
  566. session := utils.DBE.NewSession()
  567. session.Begin()
  568. defer session.Close()
  569. supplierId := this.GetString("SupplierId")
  570. id := this.GetString("Id")
  571. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  572. var supplierCertSubList []suppliercertsub.Tmp_OilSupplierCertSub
  573. wheredel := "1=1 and SupplierTypeCode = '02'"
  574. if supplierId != "" {
  575. wheredel += " and SupplierId=" + supplierId
  576. }
  577. if id != "" {
  578. wheredel += " and Id=" + id
  579. }
  580. svc.GetEntitysByWhere(TmpOilSupplierCertSubName, wheredel, &supplierCertSubList)
  581. var errinfo ErrorInfo
  582. for _,item := range supplierCertSubList {
  583. where := "Id = " + strconv.Itoa(item.Id)
  584. err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
  585. if err != nil {
  586. session.Rollback()
  587. errinfo.Code = -1
  588. errinfo.Message = "删除失败!"
  589. this.Data["json"] = &errinfo
  590. this.ServeJSON()
  591. }
  592. }
  593. for _,item := range supplierCertSubList {
  594. where := "Id = " + strconv.Itoa(item.Id)
  595. err = svc.DeleteEntityBytbl(TmpOilSupplierCertSubName, where)
  596. }
  597. if err == nil {
  598. session.Commit()
  599. errinfo.Code = 0
  600. errinfo.Message = "删除成功!"
  601. this.Data["json"] = &errinfo
  602. this.ServeJSON()
  603. } else {
  604. session.Rollback()
  605. errinfo.Code = -1
  606. errinfo.Message = "删除失败!"
  607. this.Data["json"] = &errinfo
  608. this.ServeJSON()
  609. }
  610. }
  611. // @Title 修改资质后找出不符合的准入
  612. // @Description 修改实体
  613. // @Success 200 {object} controllers.Request
  614. // @router /findinconformity [post]
  615. func (this *OilBasisBuildController) FindInconformity() {
  616. var errinfo ErrorInfo
  617. var err error
  618. var model basisbuild.OilBasisBuild
  619. var companygoodslist []suppliercertsub.OilSupplierCertSub
  620. var companygood suppliercertsub.OilSupplierCertSub
  621. var SurplusList []supplierfile.FileList
  622. var supfilemodel []supplierfile.OilSupplierFile
  623. var supfilemodel01 []supplierfile.OilSupplierFile
  624. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  625. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  626. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  627. var jsonBlob = this.Ctx.Input.RequestBody
  628. json.Unmarshal(jsonBlob, &model)
  629. Code := model.Code
  630. where := " Code ='"+Code+"' and Type in ('1','3') and SupplierTypeCode = '02'"
  631. svc.FindGoodsByCode("OilSupplierCertSub",where,&companygoodslist)
  632. SurplusList = filesvc.GetBasicNeedFileList(strconv.Itoa(model.Id))
  633. for _, CertSub := range companygoodslist {
  634. companygood = CertSub
  635. wherecompany := " SupplierId ="+strconv.Itoa(CertSub.SupplierId)
  636. svc.FindFileByCompany("OilSupplierFile",wherecompany,&supfilemodel)
  637. if len(supfilemodel)<1 {
  638. _,err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  639. }else {
  640. var tmplist1 []suppliercertsub.Tmp_OilSupplierCertSub
  641. wherecompany = " Id ="+strconv.Itoa(CertSub.Id)
  642. svc.FindFileByCompany("tmp_OilSupplierCertSub",wherecompany,&tmplist1)
  643. if len(tmplist1)<1{
  644. wherecompany = " SupplierId ='" + strconv.Itoa(CertSub.SupplierId) + "'"
  645. svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel01)
  646. var File01 string
  647. for _, Filesub := range supfilemodel01 {
  648. File01 = File01 + Filesub.NeedFileType + ","
  649. }
  650. for _, Filesub := range SurplusList {
  651. var supplierModel supplier.OilSupplier
  652. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  653. svcSupplier.GetEntityById(strconv.Itoa(CertSub.SupplierId), &supplierModel)
  654. //三证合一或五证合一不需要的字段
  655. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  656. File01 = mergerCertSkipField + File01
  657. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(File01, Filesub.FileName+",") { //三证合一或五证合一了
  658. continue
  659. }
  660. if strings.Contains(File01, Filesub.FileName+",") {
  661. continue
  662. }
  663. _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  664. break
  665. }
  666. }
  667. }
  668. }
  669. if err == nil {
  670. errinfo.Message = "已拉取缺失资质列表!"
  671. errinfo.Code = 0
  672. this.Data["json"] = &errinfo
  673. this.ServeJSON()
  674. } else {
  675. errinfo.Message = "拉取列表失败!" + utils.AlertProcess(err.Error())
  676. errinfo.Code = -1
  677. this.Data["json"] = &errinfo
  678. this.ServeJSON()
  679. }
  680. }
  681. // @Title 获取列表新导入的列表
  682. // @Description get user by token
  683. // @Success 200 {object} []goodsaptitude.OilGoodsAptitude
  684. // @router /importlist [get]
  685. func (this *OilBasisBuildController) GetImportEntityList() {
  686. //获取分页信息
  687. page := this.GetPageInfoForm()
  688. where := " 1=1 "
  689. orderby := "Code"
  690. asc := true
  691. Order := this.GetString("Order")
  692. Prop := this.GetString("Prop")
  693. if Order != "" && Prop != "" {
  694. orderby = Prop
  695. if Order == "asc" {
  696. asc = true
  697. } else {
  698. asc = false
  699. }
  700. }
  701. Code := this.GetString("Code")
  702. Name := this.GetString("Name")
  703. if Code != "" {
  704. where = where + " and Code like '%" + Code + "%'"
  705. }
  706. if Name != "" {
  707. where = where + " and Name like '%" + Name + "%'"
  708. }
  709. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  710. var list []basisbuild.OilBasisBuild
  711. total := svc.GetMyPagingEntitiesWithOrderBytbl(TmpOilBasisBuildName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  712. var datainfo DataInfo
  713. datainfo.Items = list
  714. datainfo.CurrentItemCount = total
  715. datainfo.PageIndex = page.CurrentPage
  716. datainfo.ItemsPerPage = page.Size
  717. this.Data["json"] = &datainfo
  718. this.ServeJSON()
  719. }
  720. // @Title get 导入excel
  721. // @Description get SampleType by token
  722. // @Success 200 {object} sampletype.SampleType
  723. // @router /importexcel [get]
  724. func (this *OilBasisBuildController) ImportExcel() {
  725. url := this.GetString("ExcelUrl")
  726. var errorinfo ErrorInfo
  727. if url == "" {
  728. errorinfo.Code = -2
  729. errorinfo.Message = "导入失败!"
  730. this.Data["json"] = &errorinfo
  731. this.ServeJSON()
  732. }
  733. session := utils.DBE.NewSession()
  734. err := session.Begin()
  735. svc := basisbuild.GetOilBasisbuildSession(session)
  736. err = svc.TruncateTable(TmpOilBasisBuildName)
  737. if err != nil {
  738. session.Rollback()
  739. errorinfo.Code = -2
  740. errorinfo.Message = "导入失败!"
  741. this.Data["json"] = &errorinfo
  742. this.ServeJSON()
  743. }
  744. _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
  745. filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
  746. utils.DownloadFile(url, filename, _dir)
  747. t := time.Now()
  748. filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
  749. xlFile, err := xlsx.OpenFile(filePath)
  750. var errLineNum string
  751. //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
  752. if err != nil {
  753. fmt.Printf("open failed: %s\n", err)
  754. }
  755. var sheet = xlFile.Sheets[0]
  756. // 插入字段
  757. Fstrs := svc.GetFCode()
  758. Fstrs = "Code,Name," + Fstrs
  759. columnArr := strings.Split(Fstrs, ",")
  760. defer func() {
  761. session.Close()
  762. }()
  763. codemap := make(map[string]int)
  764. for i := 1; i < len(sheet.Rows); i++ {
  765. lineNo := strconv.Itoa(i + 1)
  766. fmt.Println(lineNo)
  767. this.OperationCell(svc, lineNo, columnArr, codemap, sheet.Rows[i].Cells, &errLineNum)
  768. }
  769. os.Remove(filePath)
  770. if errLineNum != "" {
  771. session.Rollback()
  772. errorinfo.Code = -1
  773. errorinfo.Message = "导入失败!错误行号:" + errLineNum
  774. this.Data["json"] = &errorinfo
  775. this.ServeJSON()
  776. } else {
  777. session.Commit()
  778. elapsed := time.Since(t)
  779. log.Println(elapsed)
  780. errorinfo.Code = 0
  781. errorinfo.Message = "导入成功!"
  782. this.Data["json"] = &errorinfo
  783. this.ServeJSON()
  784. }
  785. }
  786. func (this *OilBasisBuildController) OperationCell(svc *basisbuild.OilBasisbuildSession, lineNo string, columnArr []string, codemap map[string]int, cellsArr []*xlsx.Cell, errLineNum *string) {
  787. defer func() {
  788. if err := recover(); err != nil {
  789. log.Println("err"+lineNo, err)
  790. *errLineNum += lineNo + ","
  791. }
  792. }()
  793. cellsArrLen := len(cellsArr)
  794. var valstr = ""
  795. for i := 0; i < cellsArrLen;i++ {
  796. valstr += "'" + cellsArr[i].String() + "',"
  797. }
  798. valstr = strings.Trim(valstr, ",")
  799. valstr = strings.Replace(valstr, "是", "1", -1)
  800. log.Println(cellsArr[6].String() + "==" + valstr)
  801. var columnstr= ""
  802. for l := 0; l < cellsArrLen; l++ {
  803. columnstr += columnArr[l] + ","
  804. }
  805. columnstr = strings.Trim(columnstr, ",")
  806. err := svc.InsertTmpOilBasisBuild(columnstr, valstr)
  807. if err != nil {
  808. panic(err)
  809. }
  810. }
  811. // @Title get 清空导入的信息
  812. // @Description get SampleType by token
  813. // @Success 200 {object} sampletype.SampleType
  814. // @router /truncateimport [get]
  815. func (this *OilBasisBuildController) TruncateImport() {
  816. session := utils.DBE.NewSession()
  817. err := session.Begin()
  818. defer session.Close()
  819. svc := basisbuild.GetOilBasisbuildSession(session)
  820. err = svc.TruncateTable(TmpOilBasisBuildName)
  821. var errorinfo ErrorInfo
  822. if err != nil {
  823. session.Rollback()
  824. errorinfo.Code = -1
  825. errorinfo.Message = "删除失败!"
  826. this.Data["json"] = &errorinfo
  827. this.ServeJSON()
  828. }
  829. session.Commit()
  830. errorinfo.Code = 0
  831. errorinfo.Message = "删除成功!"
  832. this.Data["json"] = &errorinfo
  833. this.ServeJSON()
  834. }
  835. // @Title 将导入的数据 导入到正式表
  836. // @Description get SampleType by token
  837. // @Success 200 {object} sampletype.SampleType
  838. // @router /insertbasisbuild [get]
  839. func (this *OilBasisBuildController) InsertBasisbuild() {
  840. session := utils.DBE.NewSession()
  841. err := session.Begin()
  842. defer session.Close()
  843. svc := basisbuild.GetOilBasisbuildSession(session)
  844. var errinfo ErrorInfo
  845. err = svc.TruncateTable(OilBasisBuildName)
  846. if err != nil {
  847. session.Rollback()
  848. errinfo.Code = -1
  849. errinfo.Message = "更新失败!"
  850. this.Data["json"] = &errinfo
  851. this.ServeJSON()
  852. }
  853. err = svc.InsertBasisBuild(TmpOilBasisBuildName, OilBasisBuildName)
  854. if err != nil {
  855. session.Rollback()
  856. errinfo.Code = -1
  857. errinfo.Message = "更新失败!"
  858. this.Data["json"] = &errinfo
  859. this.ServeJSON()
  860. }
  861. session.Commit()
  862. errinfo.Code = 0
  863. errinfo.Message = "更新成功!"
  864. this.Data["json"] = &errinfo
  865. this.ServeJSON()
  866. }
  867. // @Title 更新企业的准入项及资质
  868. // @Description get SampleType by token
  869. // @Success 200 {object} sampletype.SampleType
  870. // @router /updatasuppiercertsub [get]
  871. func (this *OilBasisBuildController) UpdataSuppierCertSub() {
  872. t := time.Now()
  873. goodsvc := basisbuild.GetOilBasisBuildService(utils.DBE)
  874. goodsvc.DeleteTable(TmpOilSupplierCertSubName, "SupplierTypeCode='02'")
  875. supsvc := supplier.GetOilSupplierService(utils.DBE)
  876. // 所有基建类供应商
  877. var suppliercertList []suppliercert.OilSupplierCert
  878. where := "SupplierTypeCode='02' AND OutsideFlog = '' AND (InFlag IN ('1','2')) "
  879. supsvc.GetEntities(&suppliercertList, where)
  880. var basisbuildList []basisbuild.OilBasisBuild
  881. supsvc.GetEntities(&basisbuildList, "")
  882. var colsname = []string{"Name"}
  883. for _, suppliercert := range suppliercertList {
  884. var supplier supplier.OilSupplier
  885. wheres := " Id=" + strconv.Itoa(suppliercert.SupplierId)
  886. supsvc.GetEntity(&supplier, wheres)
  887. log.Println(suppliercert.SupplierId)
  888. // 供应商的准入范围
  889. var supplierCertSubList []suppliercertsub.OilSupplierCertSub
  890. wheresup := "SupplierId = " + strconv.Itoa(suppliercert.SupplierId) + " and SupplierTypeCode='02' AND Type IN ('1', '3')"
  891. supsvc.GetEntities(&supplierCertSubList, wheresup)
  892. fmt.Println(len(supplierCertSubList))
  893. mergerCertSkipField := ""
  894. if supplier.CredentialFlag == "1" || supplier.CredentialFlag == "2" {
  895. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  896. //三证合一或五证合一不需要的字段
  897. mergerCertSkipField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  898. }
  899. for idx := 0; idx < len(supplierCertSubList); idx++ {
  900. supplierCertSub := supplierCertSubList[idx]
  901. decCode := supplierCertSub.Code
  902. // 基建类的准入编码 basisbuildList基建类准入编码
  903. for _, goodsaptitudeClass := range basisbuildList {
  904. // 如果编码相同的后 判断有没有改名 然后查询准入项需要哪些资质 去查资质表里有没有这些资质 没有就删除这个准入项
  905. if supplierCertSub.Code == goodsaptitudeClass.Code {
  906. decCode = ""
  907. // F01 F02...对应的名称
  908. goodsAptitudeNameArr := this.GetBasisBuildName(strconv.Itoa(goodsaptitudeClass.Id))
  909. for _, val := range goodsAptitudeNameArr {
  910. if strings.Contains(mergerCertSkipField, val) {
  911. break
  912. }
  913. var supplierFile supplierfile.OilSupplierFile
  914. where := "SupplierId=" + strconv.Itoa(suppliercert.SupplierId) + " and NeedFileType='" + val + "'" + " and SupplierTypeCode IN ('000', '02')"
  915. has := supsvc.GetEntityByWhere(OilSupplierFileName, where, &supplierFile)
  916. if !has {
  917. log.Println(supplierCertSub.Code + "====" + val)
  918. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  919. break
  920. }
  921. if supplierCertSub.Name != goodsaptitudeClass.Name {
  922. var entity suppliercertsub.OilSupplierCertSub
  923. entity.Name = goodsaptitudeClass.Name
  924. where := "Id = " + strconv.Itoa(supplierCertSub.Id)
  925. supsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &entity, colsname, where)
  926. }
  927. }
  928. break
  929. }
  930. }
  931. if decCode != "" {
  932. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  933. }
  934. }
  935. }
  936. elapsed := time.Since(t)
  937. log.Println(elapsed)
  938. var errinfo ErrorInfo
  939. errinfo.Code = 0
  940. errinfo.Message = "更新完成!"
  941. this.Data["json"] = &errinfo
  942. this.ServeJSON()
  943. //xlFile.Save(excelFileName)
  944. }
  945. func (this *OilBasisBuildController) GetBasisBuildName(classId string) []string {
  946. var goodsAptitudeName string
  947. var goodsAptitudeList []basisbuild.OilBasisBuildF
  948. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  949. where := "Id=" + classId
  950. svc.GetBasisBuildServiceF(&goodsAptitudeList, where)
  951. for _, goodsAptitude := range goodsAptitudeList {
  952. t := reflect.TypeOf(goodsAptitude)
  953. v := reflect.ValueOf(goodsAptitude)
  954. for k := 0; k < t.NumField(); k++ {
  955. if v.Field(k).Interface() == "1" {
  956. var tableHeader tableheader.BaseTableheader
  957. where := "Code='" + t.Field(k).Name + "' and CategoryCode = '02'"
  958. has := svc.GetEntityByWhere(BaseTableHeader, where, &tableHeader)
  959. if has {
  960. goodsAptitudeName += tableHeader.Name + ","
  961. }
  962. }
  963. }
  964. }
  965. goodsAptitudeName = strings.Trim(goodsAptitudeName, ",")
  966. return strings.Split(goodsAptitudeName, ",")
  967. }
  968. // @Title 导出数据到word,作为导出pdf的中间步骤
  969. // @Description 数据存入word
  970. // @Success 200 {object} controllers.Request
  971. // @router /exportpdf/:tbid/:typecode [post]
  972. func (this *OilBasisBuildController) PdfExport() {
  973. Id := this.Ctx.Input.Param(":tbid")
  974. SupplierTypeCode := this.Ctx.Input.Param(":typecode")
  975. var Url string
  976. var fileName string
  977. var model1 supplierdataentry.SupplierDataEntry
  978. var model2 supplierdataentry.SupplierCertDataEntry
  979. svc := supplierdataentry.GetSupplierDataEntryService(utils.DBE)
  980. where1 := "1=1"
  981. where1 += " AND Id = '" + Id + "'"
  982. where2 := "SupplierId = '" + Id + "' and SupplierTypecode='"+ SupplierTypeCode +"'"
  983. svc.GetEntityByWhere(OilSupplierName, where1, &model1)
  984. svc.GetEntityByWhere(OilSupplierCertName, where2, &model2)
  985. var tabledata []supplierdataentry.SupplierCertSubEntry
  986. where3:="SupplierId = '" + Id + "' and SupplierTypecode='"+ SupplierTypeCode +"' and Type in ('1','3')"//准入状态的准入项
  987. svc.GetEntitysByOrderbyWhere(TmpOilSupplierCertSubName, where3, "1", &tabledata)
  988. datamap := structToMapDemo(model1.OilSupplier)
  989. if model2.SupplierTypeCode == "01" {
  990. Url = utils.Cfg.MustValue("workflow", "goodsPdfHost")
  991. fileName = "待删除物资类准入范围.docx"
  992. } else if model2.SupplierTypeCode == "02" {
  993. Url = utils.Cfg.MustValue("workflow", "basisPdfHost")
  994. fileName = "待删除基建类准入范围.docx"
  995. datamap["TJInNotify"] = model1.TJInNotify
  996. } else {
  997. Url = utils.Cfg.MustValue("workflow", "techPdfHost")
  998. fileName = "待删除服务类准入范围.docx"
  999. }
  1000. //model1
  1001. datamap["SetupTime"] = model1.SetupTime.Format("2006年01月02日")
  1002. datamap["QualifCert"] = model1.QualifCert
  1003. datamap["QualifCertLevel"] = model1.QualifCertLevel
  1004. datamap["SpecIndustryCert"] = model1.SpecIndustryCert
  1005. datamap["MaunLicense"] = model1.MaunLicense
  1006. if model1.HseTraining == "1" {
  1007. datamap["HseTraining"] = "是"
  1008. } else {
  1009. datamap["HseTraining"] = "否"
  1010. }
  1011. if model1.OperType != "" {
  1012. if model1.OperType == "1" || model1.OperType == "制造商"{
  1013. datamap["OperType"] = "√制造商 □代理商 □贸易商"
  1014. }else if model1.OperType == "2" || model1.OperType == "代理商"{
  1015. datamap["OperType"] = "□制造商 √代理商 □贸易商"
  1016. }else if model1.OperType == "3" || model1.OperType == "代理商"{
  1017. datamap["OperType"] = "□制造商 □代理商 √贸易商"
  1018. }else {
  1019. datamap["OperType"] = "□制造商 □代理商 □贸易商"
  1020. }
  1021. }
  1022. if model1.SpecTypeCode != "" {
  1023. if model1.SpecTypeCode == "1"{
  1024. datamap["SpecTypeCode"] = "√一般外部 □多元企业"
  1025. }else if model1.SpecTypeCode == "2"{
  1026. datamap["SpecTypeCode"] = "□一般外部 √多元企业"
  1027. }else {
  1028. datamap["SpecTypeCode"] = "□一般外部 □多元企业"
  1029. }
  1030. }
  1031. if model1.Grade == "1"{
  1032. datamap["Grade"] = "一级"
  1033. }else if model1.SpecTypeCode == "2"{
  1034. datamap["Grade"] = "二级"
  1035. }
  1036. datamap["Fax"] = model1.Fax
  1037. datamap["CompanyTel"] = model1.CompanyTel
  1038. datamap["SupplierName"] = model1.SupplierName
  1039. datamap["Country"] = model1.Country
  1040. datamap["MaunAgent"] = model1.MaunAgent
  1041. datamap["SupplierCertificate"] = model1.SupplierCertificate
  1042. datamap["MgrUnit"] = model1.MgrUnit
  1043. datamap["CommercialNo"] = model1.CommercialNo
  1044. datamap["CountryTaxNo"] = model1.CountryTaxNo
  1045. datamap["OrganCode"] = model1.OrganCode
  1046. datamap["Address"] = model1.Address
  1047. datamap["ZipCode"] = model1.ZipCode
  1048. datamap["LinkAddress"] = model1.LinkAddress
  1049. datamap["LinkZipCode"] = model1.LinkZipCode
  1050. datamap["QualitySystemCert"] = model1.QualitySystemCert
  1051. datamap["ProductQualityCert"] = model1.ProductQualityCert
  1052. datamap["MaunLicense"] = model1.MaunLicense
  1053. datamap["LegalPerson"] = model1.LegalPerson
  1054. datamap["CompanyType"] = model1.CompanyType
  1055. datamap["ContactName"] = model1.ContactName
  1056. datamap["RegCapital"] = strconv.FormatFloat(model1.RegCapital,'f',2,64)+"万元"+model1.Currency
  1057. datamap["DepositBank"] = model1.DepositBank
  1058. datamap["BankAccount"] = model1.BankAccount
  1059. datamap["Mobile"] = model1.Mobile
  1060. datamap["EMail"] = model1.EMail
  1061. datamap["BankCreditRating"] = model1.BankCreditRating
  1062. datamap["BusinessScope"] = model1.BusinessScope
  1063. datamap["Telphone"] = model1.Telphone
  1064. datamap["AccessCardNo"] = model2.AccessCardNo
  1065. datamap["PrintYear"] = time.Now().Year()
  1066. datamap["PrintMonth"] = time.Now().Month()
  1067. datamap["PrintDay"] = time.Now().Day()
  1068. datamap["Name"] = ""
  1069. if len(tabledata) != 0 {
  1070. var Name string
  1071. Name = "\n待删除准入范围:"+ tabledata[0].Code
  1072. Name = Name + " " + tabledata[0].Name
  1073. var i int
  1074. for i = 1; i < len(tabledata); i++ {
  1075. Name += ";"
  1076. Name += tabledata[i].Code
  1077. Name = Name + " " + tabledata[i].Name
  1078. }
  1079. //if i == 100 {
  1080. // Name += "(准入范围未完全显示,请到系统查看详情)"
  1081. //}
  1082. datamap["Name"] =datamap["Name"].(string) + Name
  1083. } else {
  1084. datamap["Name"] =datamap["Name"].(string)
  1085. }
  1086. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1087. retDocUrl := svcActiviti.FillWordTemplate(datamap, Url, fileName)
  1088. var datainfo ErrorDataInfo
  1089. datainfo.Code = 0
  1090. datainfo.Item = retDocUrl
  1091. datainfo.Message = "准备导出"
  1092. this.Data["json"] = &datainfo
  1093. this.ServeJSON()
  1094. }
  1095. // @Title 导出到execl
  1096. // @Description 导出到execl
  1097. // @Success 200 {object} controllers.Request
  1098. // @router /exportexecl [post]
  1099. func (this *OilBasisBuildController) ExeclExport() {
  1100. // 填物资类信息表首页信息
  1101. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1102. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  1103. var list2 []supplier.OilSupplierContrast
  1104. where := " 1=1"
  1105. svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierBasContrast", 0,0, "Id", false, &list2, where)
  1106. fileName := "资质导入对比表.xlsx"
  1107. Url := utils.Cfg.MustValue("workflow", "ContrastExcel")
  1108. var datamap = make(map[string]interface{})
  1109. datamap["data"] = list2
  1110. retDocUrl := svcActiviti.ContrastExcel(datamap, Url, fileName)
  1111. var datainfo ErrorDataInfo
  1112. datainfo.Code = 0
  1113. datainfo.Item = retDocUrl
  1114. datainfo.Message = "打印成功"
  1115. this.Data["json"] = &datainfo
  1116. this.ServeJSON()
  1117. }
  1118. // @Title 新导入资质后,比对不合格的准入用户
  1119. // @Description 对比列表
  1120. // @Success 200 {object} []supplier.OilSupplierSelect
  1121. // @router /get-compare-tmp-supplier [get]
  1122. func (this *OilBasisBuildController) GetCompareTmpSupplier() {
  1123. //获取分页信息
  1124. page := this.GetPageInfoForm()
  1125. where := " 1=1 "
  1126. orderby := "Id"
  1127. asc := false
  1128. Order := this.GetString("Order")
  1129. Prop := this.GetString("Prop")
  1130. if Order != "" && Prop != "" {
  1131. orderby = Prop
  1132. if Order == "asc" {
  1133. asc = true
  1134. }
  1135. }
  1136. Id := this.GetString("Id")
  1137. SupplierName := this.GetString("SupplierName")
  1138. AccessCardNo := this.GetString("AccessCardNo")
  1139. SupplierTypeCode := this.GetString("SupplierTypeCode")
  1140. Code := this.GetString("Code")
  1141. Name := this.GetString("Name")
  1142. Conditions := this.GetString("Conditions")
  1143. IsDelete := this.GetString("IsDelete")
  1144. CreateOn := this.GetString("CreateOn")
  1145. CreateUserId := this.GetString("CreateUserId")
  1146. CreateBy := this.GetString("CreateBy")
  1147. ModifiedOn := this.GetString("ModifiedOn")
  1148. ModifiedUserId := this.GetString("ModifiedUserId")
  1149. ModifiedBy := this.GetString("ModifiedBy")
  1150. if Id != "" {
  1151. where = where + " and Id like '%" + Id + "%'"
  1152. }
  1153. if SupplierName != "" {
  1154. where = where + " and SupplierName like '%" + SupplierName + "%'"
  1155. }
  1156. if AccessCardNo != "" {
  1157. where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
  1158. }
  1159. if SupplierTypeCode != "" {
  1160. where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'"
  1161. }
  1162. if Code != "" {
  1163. where = where + " and Code like '%" + Code + "%'"
  1164. }
  1165. if Name != "" {
  1166. where = where + " and Name like '%" + Name + "%'"
  1167. }
  1168. if Conditions == "2"{
  1169. where = where + " and MinClassId = '0'"
  1170. } else if Conditions == "3"{
  1171. where = where + " and Checked = '0'"
  1172. } else if Conditions == "4"{
  1173. where = where + " and Checked = '1"
  1174. }
  1175. if IsDelete != "" {
  1176. where = where + " and IsDelete like '%" + IsDelete + "%'"
  1177. }
  1178. if CreateUserId != "" {
  1179. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  1180. }
  1181. if CreateBy != "" {
  1182. where = where + " and CreateBy like '%" + CreateBy + "%'"
  1183. }
  1184. if ModifiedOn != "" {
  1185. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  1186. }
  1187. if ModifiedUserId != "" {
  1188. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  1189. }
  1190. if ModifiedBy != "" {
  1191. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  1192. }
  1193. if CreateOn != "" {
  1194. dates := strings.Split(CreateOn, ",")
  1195. if len(dates) == 2 {
  1196. minDate := dates[0]
  1197. maxDate := dates[1]
  1198. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  1199. }
  1200. }
  1201. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  1202. var list2 []supplier.OilSupplierContrast
  1203. total := svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierBasContrast", page.CurrentPage, page.Size, orderby, asc, &list2, where)
  1204. var datainfo DataInfo
  1205. datainfo.Items = list2
  1206. datainfo.CurrentItemCount = total
  1207. datainfo.PageIndex = page.CurrentPage
  1208. datainfo.ItemsPerPage = page.Size
  1209. this.Data["json"] = &datainfo
  1210. this.ServeJSON()
  1211. }
  1212. // @Title 获取列表
  1213. // @Description get user by token
  1214. // @Success 200 {object} []goodsaptitude.OilGoodsAptitude
  1215. // @router /comparelist [get]
  1216. func (this *OilBasisBuildController) GetCompareList() {
  1217. //获取分页信息
  1218. page := this.GetPageInfoForm()
  1219. where := " 1=1 "
  1220. orderby := "Code"
  1221. asc := true
  1222. Order := this.GetString("Order")
  1223. Prop := this.GetString("Prop")
  1224. Conditions := this.GetString("Conditions")
  1225. if Conditions == "1" {
  1226. // 匹配上
  1227. where += " and a.Name = tmpa.Name"
  1228. } else if Conditions == "4" {
  1229. // 旧表有新表没
  1230. where += " and tmpa.Name is null"
  1231. } else if Conditions == "5" {
  1232. // 新表有,旧表没
  1233. where += " and tmpa.Name is null"
  1234. } else if Conditions == "6" {
  1235. // 资质+级别匹配
  1236. where += " and a.Name = tmpa.Name and (a.F01 = tmpa.F01 or (tmpa.F01 = '' && a.F01 is null)) and (a.F02 = tmpa.F02 or (tmpa.F02 = '' && a.F02 is null)) and (a.F03 = tmpa.F03 or (tmpa.F03 = '' && a.F03 is null)) and (a.F04 = tmpa.F04 or (tmpa.F04 = '' && a.F04 is null)) and (a.F05 = tmpa.F05 or (tmpa.F05 = '' && a.F05 is null)) and (a.F06 = tmpa.F06 or (tmpa.F06 = '' && a.F06 is null)) and (a.F07 = tmpa.F07 or (tmpa.F07 = '' && a.F07 is null)) and (a.F08 = tmpa.F08 or (tmpa.F08 = '' && a.F08 is null)) and (a.F09 = tmpa.F09 or (tmpa.F09 = '' && a.F09 is null)) and (a.F10 = tmpa.F10 or (tmpa.F10 = '' && a.F10 is null))" +
  1237. " and (a.F11 = tmpa.F11 or (tmpa.F11 = '' && a.F11 is null)) and (a.F12 = tmpa.F12 or (tmpa.F12 = '' && a.F12 is null)) and (a.F13 = tmpa.F13 or (tmpa.F13 = '' && a.F13 is null)) and (a.F14 = tmpa.F14 or (tmpa.F14 = '' && a.F14 is null)) and (a.F15 = tmpa.F15 or (tmpa.F15 = '' && a.F15 is null)) and (a.F16 = tmpa.F16 or (tmpa.F16 = '' && a.F16 is null)) and (a.F17 = tmpa.F17 or (tmpa.F17 = '' && a.F17 is null)) and (a.F18 = tmpa.F18 or (tmpa.F18 = '' && a.F18 is null)) and (a.F19 = tmpa.F19 or (tmpa.F19 = '' && a.F19 is null)) and (a.F20 = tmpa.F20 or (tmpa.F20 = '' && a.F20 is null))" +
  1238. " and (a.F21 = tmpa.F21 or (tmpa.F21 = '' && a.F21 is null)) and (a.F22 = tmpa.F22 or (tmpa.F22 = '' && a.F22 is null)) and (a.F23 = tmpa.F23 or (tmpa.F23 = '' && a.F23 is null)) and (a.F24 = tmpa.F24 or (tmpa.F24 = '' && a.F24 is null)) and (a.F25 = tmpa.F25 or (tmpa.F25 = '' && a.F25 is null))"
  1239. }
  1240. if Order != "" && Prop != "" {
  1241. orderby = Prop
  1242. if Order == "asc" {
  1243. asc = true
  1244. } else {
  1245. asc = false
  1246. }
  1247. }
  1248. CreateOn := this.GetString("CreateOn")
  1249. Code := this.GetString("Code")
  1250. Name := this.GetString("Name")
  1251. BigClassName := this.GetString("BigClassName")
  1252. BigClassCode := this.GetString("BigClassCode")
  1253. MiddleClassName := this.GetString("MiddleClassName")
  1254. SmallClassName := this.GetString("SmallClassName")
  1255. GoodsName := this.GetString("GoodsName")
  1256. GoodsLevel := this.GetString("GoodsLevel")
  1257. GoodsDesc := this.GetString("GoodsDesc")
  1258. Standard := this.GetString("Standard")
  1259. CompanyType := this.GetString("CompanyType")
  1260. if Code != "" {
  1261. where = where + " and b.Code like '%" + Code + "%'"
  1262. }
  1263. if Name != "" {
  1264. where = where + " and b.Name like '%" + Name + "%'"
  1265. }
  1266. if BigClassName != "" {
  1267. where = where + " and Name1 like '%" + BigClassName + "%'"
  1268. }
  1269. if BigClassCode != "" {
  1270. where = where + " and Code1 like '%" + BigClassCode + "%'"
  1271. }
  1272. if MiddleClassName != "" {
  1273. where = where + " and Name2 like '%" + MiddleClassName + "%'"
  1274. }
  1275. if SmallClassName != "" {
  1276. where = where + " and Name3 like '%" + SmallClassName + "%'"
  1277. }
  1278. if GoodsName != "" {
  1279. where = where + " and Name4 like '%" + GoodsName + "%'"
  1280. }
  1281. if GoodsLevel != "" {
  1282. where = where + " and GoodsLevel like '%" + GoodsLevel + "%'"
  1283. }
  1284. if GoodsDesc != "" {
  1285. where = where + " and GoodsDesc like '%" + GoodsDesc + "%'"
  1286. }
  1287. if Standard != "" {
  1288. where = where + " and Standard '%" + Standard + "%'"
  1289. }
  1290. if CompanyType != "" {
  1291. where = where + " and CompanyType '%" + CompanyType + "%'"
  1292. }
  1293. if CreateOn != "" {
  1294. dates := strings.Split(CreateOn, ",")
  1295. if len(dates) == 2 {
  1296. minDate := dates[0]
  1297. maxDate := dates[1]
  1298. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  1299. }
  1300. }
  1301. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  1302. var list []basisbuild.OilBasisBuildTmp
  1303. total := svc.GetPClassEntities(page.CurrentPage, page.Size, orderby, asc, &list, where, Conditions)
  1304. var datainfo DataInfo
  1305. datainfo.Items = list
  1306. datainfo.CurrentItemCount = total
  1307. datainfo.PageIndex = page.CurrentPage
  1308. datainfo.ItemsPerPage = page.Size
  1309. this.Data["json"] = &datainfo
  1310. this.ServeJSON()
  1311. }
  1312. // @Title get 生成对比列表
  1313. // @Description get SampleType by token
  1314. // @Success 200 {object} sampletype.SampleType
  1315. // @router /create-contrast [get]
  1316. func (this *OilBasisBuildController) CreateContrast() {
  1317. go func() {
  1318. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  1319. svc.TruncateTable("OilSupplierBasContrast")
  1320. // 插入对比列表
  1321. var list1 []supplier.OilSupplier
  1322. svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, 0, 0, "Id", false, &list1, " 1=1")
  1323. svc.DBE.Query("SET unique_checks=0;")
  1324. svc.DBE.Query("SET autocommit=0;")
  1325. for _, item := range list1 {
  1326. var list []supplier.OilSupplierContrast
  1327. where := " b.SupplierTypeCode='02' and a.Id = " + strconv.Itoa(item.Id)
  1328. svc.GetPagingTmpCheckedEntities(&list, where)
  1329. if list != nil {
  1330. var supplierCertSubList []suppliercertsub.OilSupplierCertSub
  1331. total := svc.GetTableTotal(" SupplierTypeCode='02' AND SupplierId = "+strconv.Itoa(item.Id), &supplierCertSubList)
  1332. total1 := svc.GetNoSubCntTotal("a.SupplierTypeCode = '02' and c.ClassId is null and a.SupplierId = " + strconv.Itoa(item.Id))
  1333. list[0].SubCnt = int(total)
  1334. list[0].NoSubCnt = int(total1)
  1335. list[0].SetupTime = time.Now()
  1336. svc.InsertEntityBytbl("OilSupplierBasContrast", list[0])
  1337. svc.DBE.Query("commit;")
  1338. }
  1339. }
  1340. svc.DBE.Query("SET unique_checks=1;")
  1341. svc.DBE.Query("SET autocommit=1;")
  1342. }()
  1343. var errorinfo ErrorInfo
  1344. errorinfo.Code = 0
  1345. errorinfo.Message = "成功!"
  1346. this.Data["json"] = &errorinfo
  1347. this.ServeJSON()
  1348. }
  1349. // @Title 查看对比列表的准入范围 2020-12-18
  1350. // @Description get user by token
  1351. // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
  1352. // @router /delcertsublist [get]
  1353. func (this *OilBasisBuildController) GetDelCertSubList() {
  1354. //获取分页信息
  1355. page := this.GetPageInfoForm()
  1356. where := " 1=1 "
  1357. orderby := "a.Id"
  1358. asc := false
  1359. Order := this.GetString("Order")
  1360. Prop := this.GetString("Prop")
  1361. if Order != "" && Prop != "" {
  1362. orderby = Prop
  1363. if Order == "asc" {
  1364. asc = true
  1365. }
  1366. }
  1367. Id := this.GetString("Id")
  1368. SupplierId := this.GetString("SupplierId")
  1369. SupplierCertId := this.GetString("SupplierCertId")
  1370. SupplierTypeCode := this.GetString("SupplierTypeCode")
  1371. Code := this.GetString("Code")
  1372. Name := this.GetString("Name")
  1373. Remark := this.GetString("Remark")
  1374. IsDelete := this.GetString("IsDelete")
  1375. CreateOn := this.GetString("CreateOn")
  1376. CreateUserId := this.GetString("CreateUserId")
  1377. CreateBy := this.GetString("CreateBy")
  1378. ModifiedOn := this.GetString("ModifiedOn")
  1379. ModifiedUserId := this.GetString("ModifiedUserId")
  1380. ModifiedBy := this.GetString("ModifiedBy")
  1381. if Id != "" {
  1382. where = where + " and a.Id like '%" + Id + "%'"
  1383. }
  1384. if SupplierId != "" {
  1385. where = where + " and a.SupplierId like '%" + SupplierId + "%'"
  1386. }
  1387. if SupplierCertId != "" {
  1388. where = where + " and a.SupplierCertId = '" + SupplierCertId + "'"
  1389. }
  1390. if SupplierTypeCode != "" {
  1391. where = where + " and a.SupplierTypeCode = '" + SupplierTypeCode + "'"
  1392. }
  1393. if Code != "" {
  1394. where = where + " and a.Code like '%" + Code + "%'"
  1395. }
  1396. if Name != "" {
  1397. where = where + " and a.Name like '%" + Name + "%'"
  1398. }
  1399. if Remark != "" {
  1400. where = where + " and a.Remark like '%" + Remark + "%'"
  1401. }
  1402. if IsDelete != "" {
  1403. where = where + " and a.IsDelete like '%" + IsDelete + "%'"
  1404. }
  1405. if CreateUserId != "" {
  1406. where = where + " and a.CreateUserId like '%" + CreateUserId + "%'"
  1407. }
  1408. if CreateBy != "" {
  1409. where = where + " and a.CreateBy like '%" + CreateBy + "%'"
  1410. }
  1411. if ModifiedOn != "" {
  1412. where = where + " and a.ModifiedOn like '%" + ModifiedOn + "%'"
  1413. }
  1414. if ModifiedUserId != "" {
  1415. where = where + " and a.ModifiedUserId like '%" + ModifiedUserId + "%'"
  1416. }
  1417. if ModifiedBy != "" {
  1418. where = where + " and a.ModifiedBy like '%" + ModifiedBy + "%'"
  1419. }
  1420. if CreateOn != "" {
  1421. dates := strings.Split(CreateOn, ",")
  1422. if len(dates) == 2 {
  1423. minDate := dates[0]
  1424. maxDate := dates[1]
  1425. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  1426. }
  1427. }
  1428. where = where + " and a.Type in (1, 3)"
  1429. svc := basisbuild.GetOilBasisBuildService(utils.DBE)
  1430. var list []suppliercertsub.OilSupplierCertSub1
  1431. var co supplier.OilSupplierContrast
  1432. svc.GetEntityById(SupplierId, &co)
  1433. if co.IsDelete == 1 {
  1434. where += " and a.IsQuestion = 1"
  1435. }
  1436. total := svc.GetPagingTmpSubEntities(page.CurrentPage, page.Size, orderby, asc, &list, where)
  1437. a := 0
  1438. for _, item := range list {
  1439. sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25)) AS Codes FROM Tmp_OilBasisBuild"
  1440. sql += " where Name = '"+ item.Name + "'"
  1441. model, _ := svc.DBE.QueryString(sql)
  1442. if model != nil {
  1443. code := strings.Split(model[0]["Codes"], ",")
  1444. i := 1
  1445. for _, value := range code {
  1446. if i == 41 || i == 42 || i == 1 {
  1447. if (code[0] == "1" && strings.Index(item.HeaderCodes, "F01") < 0) && (code[40] == "1" && strings.Index(item.HeaderCodes, "F41") < 0) && (code[41] == "1" && strings.Index(item.HeaderCodes, "F42") < 0) {
  1448. list[a].Checked = 1
  1449. sql1 := "select Name from Base_TableHeader where Code = 'F01' and CategoryCode = '02'"
  1450. model1, _ := svc.DBE.QueryString(sql1)
  1451. if strings.Index(list[a].HeaderName, model1[0]["Name"]) == -1 {
  1452. list[a].HeaderName += model1[0]["Name"] + " "
  1453. }
  1454. }
  1455. } else if i > 10 {
  1456. if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
  1457. list[a].Checked = 1
  1458. sql1 := "select Name from Base_TableHeader where Code = 'F"+strconv.Itoa(i)+"' and CategoryCode = '02'"
  1459. model1, _ := svc.DBE.QueryString(sql1)
  1460. list[a].HeaderName += model1[0]["Name"]+ " "
  1461. }
  1462. } else {
  1463. if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
  1464. list[a].Checked = 1
  1465. sql1 := "select Name from Base_TableHeader where Code = 'F0"+strconv.Itoa(i)+"' and CategoryCode = '02'"
  1466. model1, _ := svc.DBE.QueryString(sql1)
  1467. list[a].HeaderName += model1[0]["Name"]+ " "
  1468. }
  1469. }
  1470. i += 1
  1471. }
  1472. } else {
  1473. list[a].MinClassId = "0"
  1474. }
  1475. a += 1
  1476. }
  1477. var datainfo DataInfo
  1478. datainfo.Items = list
  1479. datainfo.CurrentItemCount = total
  1480. datainfo.PageIndex = page.CurrentPage
  1481. datainfo.ItemsPerPage = page.Size
  1482. this.Data["json"] = &datainfo
  1483. this.ServeJSON()
  1484. }
  1485. // @Title 确认更新后的删除/暂停企业准入范围 2020-12-18
  1486. // @Description 修改实体
  1487. // @Success 200 {object} controllers.Request
  1488. // @router /delete-suspend [post]
  1489. func (this *OilBasisBuildController) DeleteSuspend() {
  1490. var errinfo ErrorInfo
  1491. var err error
  1492. var list []supplier.OilSupplierContrast
  1493. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  1494. //svc.GetEntitysByWhere("OilSupplierContrast", "TwoOneCount = 0", &list)
  1495. svc.GetEntitysByWhere("OilSupplierBasContrast", "1=1", &list)
  1496. go func() {
  1497. for _,item := range list{
  1498. var sub []suppliercertsub.OilSupplierCertSub
  1499. svc.GetEntitysByWhere("OilSupplierCertSub", "SupplierTypeCode = '02' and SupplierId = " + strconv.Itoa(item.Id), &sub)
  1500. for _, itemSub := range sub {
  1501. //sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25)) AS Codes,Code FROM Tmp_OilBasisBuild"
  1502. sql := "SELECT Code FROM Tmp_OilBasisBuild"
  1503. sql += " where Name = '"+ itemSub.Name + "'"
  1504. model, _ := svc.DBE.QueryString(sql)
  1505. var subDelete suppliercertsub.OilSupplierCertSub
  1506. if model != nil {
  1507. //code := strings.Split(model[0]["Codes"], ",")
  1508. cols := []string{"Code"}
  1509. subDelete.Code = model[0]["Code"]
  1510. // 修改
  1511. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id))
  1512. } else {
  1513. // 删除
  1514. err = svc.DeleteEntityById(itemSub.Id, &subDelete)
  1515. }
  1516. }
  1517. err = svc.DeleteTable("OilSupplierBasContrast", "Id = " + strconv.Itoa(item.Id))
  1518. }
  1519. this.CreateContrast()
  1520. }()
  1521. errinfo.Message = "更新中,请勿重复更新!"
  1522. errinfo.Code = 0
  1523. this.Data["json"] = &errinfo
  1524. this.ServeJSON()
  1525. }