2
3

basisbuild.go 57 KB

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