2
3

suppliercertappendsub.go 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/goodsaptitude"
  4. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  5. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  6. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  7. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  8. "dashoo.cn/business2/parameter"
  9. "encoding/json"
  10. "fmt"
  11. "log"
  12. "reflect"
  13. "strconv"
  14. "strings"
  15. "time"
  16. "dashoo.cn/backend/api/business/oilsupplier/suppliercertappendsub"
  17. . "dashoo.cn/backend/api/controllers"
  18. "dashoo.cn/utils"
  19. )
  20. type OilSupplierCertAppendSubController struct {
  21. BaseController
  22. }
  23. type AppendChangeItemsAll struct {
  24. InfochangeForm []appenditems
  25. SupplierId string
  26. MInfoId string
  27. }
  28. type appenditems struct {
  29. SelectItem string
  30. SelectItemName string
  31. BeChangeInfo string
  32. ChangeInfo string
  33. }
  34. // @Title 获取列表
  35. // @Description 获取列表
  36. // @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
  37. // @router /getList [get]
  38. func (this *OilSupplierCertAppendSubController) GetList() {
  39. //获取分页信息
  40. page := this.GetPageInfoForm()
  41. //where := " 1=1 "
  42. //orderby := "Id"
  43. //asc := false
  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. // }
  51. //}
  52. //SupplierCertAppendId := this.GetString("SupplierCertAppendId")
  53. //if SupplierCertAppendId != "" {
  54. // where = where + " and SupplierCertAppendId = " + SupplierCertAppendId
  55. //}
  56. SupplierCertId := this.GetString("SupCertId")
  57. SupplierTypeCode := this.GetString("SupTypeCode")
  58. suwhere := " SupplierCertId = " + SupplierCertId + " and SupplierTypeCode = " + SupplierTypeCode
  59. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  60. var list []suppliercertsub.OilSupplierCertSub
  61. //svc.GetEntitysByWhere(OilSupplierCertAppendSubName, where, &list)
  62. //svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere, "CreateOn asc", &list)
  63. total := svc.GetPagingEntitiesWithOrder(page.CurrentPage, page.Size, "CreateOn", false, &list, suwhere)
  64. var dataInfo DataInfo
  65. dataInfo.CurrentItemCount = total
  66. dataInfo.PageIndex = page.CurrentPage
  67. dataInfo.ItemsPerPage = page.Size
  68. dataInfo.Items = list
  69. this.Data["json"] = &dataInfo
  70. this.ServeJSON()
  71. }
  72. // @Title 获取列表
  73. // @Description 获取列表
  74. // @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
  75. // @router /getListInandApp [get]
  76. func (this *OilSupplierCertAppendSubController) GetListInAndApp() {
  77. //获取分页信息
  78. page := this.GetPageInfoForm()
  79. //where := " 1=1 "
  80. //orderby := "Id"
  81. //asc := false
  82. //Order := this.GetString("Order")
  83. //Prop := this.GetString("Prop")
  84. //if Order != "" && Prop != "" {
  85. // orderby = Prop
  86. // if Order == "asc" {
  87. // asc = true
  88. // }
  89. //}
  90. //SupplierCertAppendId := this.GetString("SupplierCertAppendId")
  91. //if SupplierCertAppendId != "" {
  92. // where = where + " and SupplierCertAppendId = " + SupplierCertAppendId
  93. //}
  94. SupplierCertId := this.GetString("SupCertId")
  95. SupplierTypeCode := this.GetString("SupTypeCode")
  96. SupplierCertAppendId := this.GetString("SupplierCertAppendId")
  97. searchCode := this.GetString("searchCode")
  98. where := `((SupplierCertId = ` + SupplierCertId + ` AND SupplierTypeCode = '` + SupplierTypeCode + `' AND TYPE IN ('1', '3'))
  99. OR (SupplierCertId = ` + SupplierCertId + ` AND SupplierTypeCode = '` + SupplierTypeCode + `' AND SupplierCertAppendId = ` + SupplierCertAppendId + `)) `
  100. //" SupplierCertId = "+ SupplierCertId+ " and SupplierTypeCode = "+ SupplierTypeCode
  101. if searchCode != "" {
  102. where += " and (Code like '" + strings.Trim(searchCode, " ") + "%' or Name like '%" + strings.Trim(searchCode, " ") + "%')"
  103. }
  104. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  105. var list []suppliercertsub.OilSupplierCertSub
  106. //svc.GetEntitysByWhere(OilSupplierCertAppendSubName, where, &list)
  107. //svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere, "CreateOn asc", &list)
  108. total := svc.GetPagingEntitiesWithOrder(page.CurrentPage, page.Size, "CreateOn", false, &list, where)
  109. var dataInfo DataInfo
  110. if list == nil {
  111. dataInfo.Items = []suppliercertsub.OilSupplierCertSub{}
  112. } else {
  113. dataInfo.Items = list
  114. }
  115. dataInfo.CurrentItemCount = total
  116. dataInfo.PageIndex = page.CurrentPage
  117. dataInfo.ItemsPerPage = page.Size
  118. this.Data["json"] = &dataInfo
  119. this.ServeJSON()
  120. }
  121. // @Title 获取列表
  122. // @Description 获取列表
  123. // @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
  124. // @router /getMyList [get]
  125. func (this *OilSupplierCertAppendSubController) GetMyList() {
  126. //获取分页信息
  127. page := this.GetPageInfoForm()
  128. SupplierCertId := this.GetString("SupCertId")
  129. SupplierTypeCode := this.GetString("SupTypeCode")
  130. SuppAppendId := this.GetString("SupplierCertAppendId")
  131. searchCode := this.GetString("searchCode")
  132. where := " SupplierCertId = " + SupplierCertId + " and SupplierTypeCode = '" + SupplierTypeCode + "' and SupplierCertAppendId = " + SuppAppendId
  133. if searchCode != "" {
  134. where += " and (Code like '" + strings.Trim(searchCode, " ") + "%' or Name like '%" + strings.Trim(searchCode, " ") + "%')"
  135. }
  136. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  137. var list []suppliercertsub.OilSupplierCertSub
  138. //svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere, "CreateOn asc", &list)
  139. total := svc.GetPagingEntitiesWithOrder(page.CurrentPage, page.Size, "CreateOn", false, &list, where)
  140. var dataInfo DataInfo
  141. if list == nil {
  142. dataInfo.Items = []suppliercertsub.OilSupplierCertSub{}
  143. } else {
  144. dataInfo.Items = list
  145. }
  146. dataInfo.CurrentItemCount = total
  147. dataInfo.PageIndex = page.CurrentPage
  148. dataInfo.ItemsPerPage = page.Size
  149. this.Data["json"] = &dataInfo
  150. this.ServeJSON()
  151. }
  152. // @Title 获取列表
  153. // @Description 获取列表
  154. // @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
  155. // @router /getListappend [get]
  156. func (this *OilSupplierCertAppendSubController) GetListAppend() {
  157. //获取分页信息
  158. page := this.GetPageInfoForm()
  159. //where := " 1=1 "
  160. //orderby := "Id"
  161. //asc := false
  162. //Order := this.GetString("Order")
  163. //Prop := this.GetString("Prop")
  164. //if Order != "" && Prop != "" {
  165. // orderby = Prop
  166. // if Order == "asc" {
  167. // asc = true
  168. // }
  169. //}
  170. //SupplierCertAppendId := this.GetString("SupplierCertAppendId")
  171. //if SupplierCertAppendId != "" {
  172. // where = where + " and SupplierCertAppendId = " + SupplierCertAppendId
  173. //}
  174. SupplierCertAppendId := this.GetString("SupplierCertAppendId")
  175. SupplierCertId := this.GetString("SupCertId")
  176. SupplierTypeCode := this.GetString("SupTypeCode")
  177. searchCode := this.GetString("searchCode")
  178. where := " SupplierCertId = " + SupplierCertId + " and SupplierCertAppendId= " + SupplierCertAppendId + " and SupplierTypeCode = '" + SupplierTypeCode + "' and Type in(2,3) "
  179. if searchCode != "" {
  180. where += " and (Code like '" + strings.Trim(searchCode, " ") + "%' or Name like '%" + strings.Trim(searchCode, " ") + "%')"
  181. }
  182. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  183. var list []suppliercertsub.OilSupplierCertSub
  184. //svc.GetEntitysByWhere(OilSupplierCertAppendSubName, where, &list)
  185. //svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere, "CreateOn asc", &list)
  186. total := svc.GetPagingEntitiesWithOrder(page.CurrentPage, page.Size, "CreateOn", false, &list, where)
  187. var dataInfo DataInfo
  188. if list == nil {
  189. dataInfo.Items = []suppliercertsub.OilSupplierCertSub{}
  190. } else {
  191. dataInfo.Items = list
  192. }
  193. dataInfo.CurrentItemCount = total
  194. dataInfo.PageIndex = page.CurrentPage
  195. dataInfo.ItemsPerPage = page.Size
  196. this.Data["json"] = &dataInfo
  197. this.ServeJSON()
  198. }
  199. // @Title 添加
  200. // @Description 添加增项分类信息基建类
  201. // @Success 200 {object} controllers.Request
  202. // @router /addappendsub [post]
  203. func (this *OilSupplierCertAppendSubController) AddAppendSub() {
  204. var model suppliercertsub.OilSupplierCertSub
  205. var err error
  206. var jsonblob = this.Ctx.Input.RequestBody
  207. json.Unmarshal(jsonblob, &model)
  208. model.CreateBy = this.User.Realname
  209. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  210. model.CertSubStatus = "-1"
  211. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  212. var submodel suppliercertsub.OilSupplierCertSub
  213. where_certsub := " SupplierCertId = " + utils.ToStr(model.SupplierCertId) + " and SupplierTypeCode = 02"
  214. where_certsub += " and SubClassId = '" + utils.ToStr(model.SubClassId) + "'"
  215. has := svc.GetEntityByWhere(OilSupplierCertSubName, where_certsub, &submodel)
  216. if !has {
  217. //添加到准入分类表中
  218. _, err = svc.InsertEntityBytbl(OilSupplierCertSubName, &model)
  219. // TODO: 删除准入范围和资质对应关系表
  220. /*var supplierCertModel suppliercert.OilSupplierCert
  221. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  222. svcCert.GetEntityById(model.SupplierCertId, &supplierCertModel)
  223. var supplierModel supplier.OilSupplier
  224. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  225. svcSupplier.GetEntityById(model.SupplierId, &supplierModel)
  226. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  227. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  228. var needList []supplierfile.FileList
  229. if model.SupplierTypeCode == "01" {
  230. // needList = filesvc.GetGoodsNeedFileList(model.SubClassId)
  231. } else if model.SupplierTypeCode == "02" {
  232. needList = filesvc.GetBasicNeedFileList(strconv.Itoa(model.SubClassId))
  233. } else {
  234. // needList = filesvc.GetTechNeedFileList(model.SubClassId)
  235. }
  236. if supplierCertModel.InStyle == "4" {
  237. var needFile supplierfile.FileList
  238. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  239. needList = append(needList, needFile)
  240. }
  241. if err == nil {
  242. var list []supplierfile.OilSupplierFile
  243. where := "SupplierTypeCode in (02,000) and SupplierId = '" + strconv.Itoa(model.SupplierId) + "'"
  244. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  245. //三证合一或五证合一不需要的字段
  246. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  247. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  248. // mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  249. for i := 0; i < len(needList); i++ {
  250. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  251. continue
  252. }
  253. var entity supplierfile.OilSupplierFile
  254. entity.SupplierId = model.SupplierId
  255. //加入对应表OilSupplierCert2File
  256. var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
  257. cert2File.SupplierId = model.SupplierId
  258. cert2File.SupplierCertId = model.SupplierCertId
  259. cert2File.SupplierCertSubId = model.Id
  260. cert2File.SupplierTypeCode = model.SupplierTypeCode
  261. cert2File.SubClassId = model.SubClassId
  262. cert2File.Code = model.Code
  263. cert2File.Name = model.Name
  264. cert2File.NeedFileType = needList[i].FileName
  265. svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
  266. }
  267. }*/
  268. }
  269. var errinfo ErrorDataInfo
  270. if err == nil {
  271. errinfo.Message = "操作成功!"
  272. errinfo.Code = 0
  273. errinfo.Item = model.Id
  274. this.Data["json"] = &errinfo
  275. this.ServeJSON()
  276. } else {
  277. errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
  278. errinfo.Code = -1
  279. this.Data["json"] = &errinfo
  280. this.ServeJSON()
  281. }
  282. }
  283. // @Title 批量添加增项准入范围--技术服务类
  284. // @Description 批量添加准入范围
  285. // @Success 200 {object} business.device.DeviceChannels
  286. // @router /addtechbus [post]
  287. func (this *OilSupplierCertAppendSubController) AddTechBus() {
  288. var jsonblob = this.Ctx.Input.RequestBody
  289. var datamain suppliercertsub.OilSupplierCertSub
  290. var dataother suppliercertsub.TechnologySubModel
  291. json.Unmarshal(jsonblob, &datamain)
  292. json.Unmarshal(jsonblob, &dataother)
  293. var supplierCertModel suppliercert.OilSupplierCert
  294. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  295. svcCert.GetEntityById(datamain.SupplierCertId, &supplierCertModel)
  296. var supplierModel supplier.OilSupplier
  297. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  298. svcSupplier.GetEntityById(datamain.SupplierId, &supplierModel)
  299. for n := 0; n < len(dataother.CheckList); n++ {
  300. where_sub := "SupplierTypeCode = 03 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  301. where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
  302. where_sub += " and SubClassId = '" + strconv.Itoa(dataother.CheckList[n].Id) + "'"
  303. var model suppliercertsub.OilSupplierCertSub
  304. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  305. has := svc.GetEntityByWhere(OilSupplierCertSubName, where_sub, &model)
  306. if !has {
  307. // TODO: 不存在的准入范围直接就新增了,因为前台已经调用了checkLost检查过是否缺少资质,有时间可以在些方法补充验证
  308. datamain.SubClassId = dataother.CheckList[n].Id
  309. datamain.Code = dataother.CheckList[n].Code
  310. datamain.Name = dataother.CheckList[n].Name
  311. datamain.Remark = dataother.Remark
  312. datamain.CertSubStatus = "-1"
  313. datamain.IsDelete = 0
  314. datamain.CreateBy = this.User.Realname
  315. datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  316. datamain.Id = 0
  317. svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
  318. // TODO: 删除准入范围和资质对应关系表
  319. /*paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  320. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  321. needList := filesvc.GetTechNeedFileList(strconv.Itoa(dataother.CheckList[n].Id))
  322. if supplierCertModel.InStyle == "4" {
  323. var needFile supplierfile.FileList
  324. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  325. needList = append(needList, needFile)
  326. }
  327. var list []supplierfile.OilSupplierFile
  328. where := "SupplierTypeCode in (03,000) and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  329. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  330. //三证合一或五证合一不需要的字段
  331. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  332. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  333. // mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  334. for i := 0; i < len(needList); i++ {
  335. var entity supplierfile.OilSupplierFile
  336. entity.SupplierId = dataother.SupplierId
  337. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  338. continue
  339. }
  340. //加入对应表OilSupplierCert2File
  341. var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
  342. cert2File.SupplierId = dataother.SupplierId
  343. cert2File.SupplierCertId = dataother.SupplierCertId
  344. cert2File.SupplierCertSubId = datamain.Id
  345. cert2File.SupplierTypeCode = dataother.SupplierTypeCode
  346. cert2File.SubClassId= dataother.CheckList[n].Id
  347. cert2File.Code = dataother.CheckList[n].Code
  348. cert2File.Name = dataother.CheckList[n].Name
  349. cert2File.NeedFileType = needList[i].FileName
  350. svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
  351. }*/
  352. }
  353. }
  354. var errinfo ErrorDataInfo
  355. errinfo.Message = "操作成功!"
  356. errinfo.Code = 0
  357. this.Data["json"] = &errinfo
  358. this.ServeJSON()
  359. }
  360. // @Title 批量添加增项准入范围--物资类
  361. // @Description 批量添加增项准入范围
  362. // @Success 200 {object} business.device.DeviceChannels
  363. // @router /addgoodsbus [post]
  364. func (this *OilSupplierCertAppendSubController) AddGoodsBus() {
  365. var jsonblob = this.Ctx.Input.RequestBody
  366. var datamain suppliercertsub.OilSupplierCertSub
  367. var dataother suppliercertsub.SupplierCertSubModel
  368. json.Unmarshal(jsonblob, &datamain)
  369. json.Unmarshal(jsonblob, &dataother)
  370. var supplierCertModel suppliercert.OilSupplierCert
  371. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  372. svcCert.GetEntityById(datamain.SupplierCertId, &supplierCertModel)
  373. var supplierModel supplier.OilSupplier
  374. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  375. svcSupplier.GetEntityById(datamain.SupplierId, &supplierModel)
  376. var goods goodsaptitude.GoodsBusiness1
  377. svcGoods := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  378. for n := 0; n < len(dataother.CheckList); n++ {
  379. svcGoods.GetEntityJoin2(OilGoodsAptitudeName, OilGoodsAptitudeClassName, &goods, "Code = '"+dataother.CheckList[n].Code+"'")
  380. where_sub := "SupplierTypeCode = 01 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  381. where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
  382. where_sub += " and SubClassId = '" + strconv.Itoa(goods.Id) + "'"
  383. var model suppliercertsub.OilSupplierCertSub
  384. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  385. has := svc.GetEntityByWhere(OilSupplierCertSubName, where_sub, &model)
  386. if !has {
  387. // TODO: 不存在的准入范围直接就新增了,因为前台已经调用了checkLost检查过是否缺少资质,有时间可以在些方法补充验证
  388. datamain.SubClassId = goods.Id
  389. datamain.Code = dataother.CheckList[n].Code
  390. datamain.Name = dataother.CheckList[n].Name
  391. datamain.GoodsLevel = goods.GoodsLevel
  392. datamain.CertSubStatus = "-1"
  393. datamain.Remark = dataother.Remark
  394. datamain.IsDelete = 0
  395. datamain.CreateBy = this.User.Realname
  396. datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  397. datamain.Id = 0
  398. log.Print("增项【可】添加不存在的准入范围,SupplierId: " + strconv.Itoa(datamain.SupplierId) + "AppendId: " + strconv.Itoa(datamain.SupplierCertAppendId) + "Code: " + datamain.Code)
  399. svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
  400. log.Println("添加成功")
  401. // TODO: 删除准入范围和资质对应关系表
  402. /*paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  403. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  404. needList := filesvc.GetGoodsNeedFileList(dataother.CheckList[n].Id,"2")
  405. if supplierCertModel.InStyle == "4" {
  406. var needFile supplierfile.FileList
  407. //战略合作协议扫描件
  408. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  409. needList = append(needList, needFile)
  410. }
  411. var list []supplierfile.OilSupplierFile
  412. where := "SupplierTypeCode in (01,000) and IsManuf in ('0','2') and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  413. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  414. //三证合一或五证合一不需要的字段
  415. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  416. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  417. // mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  418. for i := 0; i < len(needList); i++ {
  419. var entity supplierfile.OilSupplierFile
  420. entity.SupplierId = dataother.SupplierId
  421. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  422. continue
  423. }
  424. //加入对应表OilSupplierCert2File
  425. var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
  426. cert2File.SupplierId = dataother.SupplierId
  427. cert2File.SupplierCertId = dataother.SupplierCertId
  428. cert2File.SupplierCertSubId = datamain.Id
  429. cert2File.SupplierTypeCode = dataother.SupplierTypeCode
  430. cert2File.SubClassId, _ = utils.StrTo(dataother.CheckList[n].Id).Int()
  431. cert2File.IsManuf = "2"
  432. cert2File.Code = dataother.CheckList[n].Code
  433. cert2File.Name = dataother.CheckList[n].Name
  434. cert2File.NeedFileType = needList[i].FileName
  435. svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
  436. }*/
  437. } else {
  438. log.Print("增项【不可】再次添加已添加过的准入范围,SupplierId: " + strconv.Itoa(datamain.SupplierId) + "AppendId: " + strconv.Itoa(datamain.SupplierCertAppendId) + "Code: " + datamain.Code)
  439. }
  440. }
  441. var errinfo ErrorDataInfo
  442. errinfo.Message = "操作成功!"
  443. errinfo.Code = 0
  444. this.Data["json"] = &errinfo
  445. this.ServeJSON()
  446. }
  447. // @Title 修改实体
  448. // @Description 修改实体
  449. // @Success 200 {object} controllers.Request
  450. // @router /update/:id [post]
  451. func (this *OilSupplierCertAppendSubController) UpdateEntity() {
  452. var errinfo ErrorInfo
  453. var model suppliercertappendsub.OilSupplierCertAppendSub
  454. id := this.Ctx.Input.Param(":id")
  455. if id == "" {
  456. errinfo.Message = "操作失败!请求信息不完整"
  457. errinfo.Code = -2
  458. this.Data["json"] = &errinfo
  459. this.ServeJSON()
  460. return
  461. }
  462. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  463. var jsonBlob = this.Ctx.Input.RequestBody
  464. json.Unmarshal(jsonBlob, &model)
  465. model.ModifiedOn = time.Now()
  466. model.ModifiedBy = this.User.Realname
  467. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  468. cols := []string{
  469. "SortFlag",
  470. "Code",
  471. "Name",
  472. "Remark",
  473. "ModifiedOn",
  474. "ModifiedUserId",
  475. "ModifiedBy",
  476. }
  477. err := svc.UpdateEntityBytbl(OilSupplierCertAppendSubName, id, &model, cols)
  478. if err == nil {
  479. errinfo.Message = "修改成功!"
  480. errinfo.Code = 0
  481. this.Data["json"] = &errinfo
  482. this.ServeJSON()
  483. } else {
  484. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  485. errinfo.Code = -1
  486. this.Data["json"] = &errinfo
  487. this.ServeJSON()
  488. }
  489. }
  490. // @Title 删除
  491. // @Description 删除信息
  492. // @Success 200 {object} ErrorInfo
  493. // @Failure 403 :id 为空
  494. // @router /delete/:Id [delete]
  495. func (this *OilSupplierCertAppendSubController) DeleteEntity() {
  496. Id := this.Ctx.Input.Param(":Id")
  497. var errinfo ErrorInfo
  498. if Id == "" {
  499. errinfo.Message = "操作失败!请求信息不完整"
  500. errinfo.Code = -2
  501. this.Data["json"] = &errinfo
  502. this.ServeJSON()
  503. return
  504. }
  505. var model suppliercertappendsub.OilSupplierCertAppendSub
  506. var entityempty suppliercertappendsub.OilSupplierCertAppendSub
  507. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  508. opdesc := "删除-" + Id
  509. err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierCertAppendSubName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "增项分类")
  510. if err == nil {
  511. errinfo.Message = "删除成功"
  512. errinfo.Code = 0
  513. this.Data["json"] = &errinfo
  514. this.ServeJSON()
  515. } else {
  516. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  517. errinfo.Code = -1
  518. this.Data["json"] = &errinfo
  519. this.ServeJSON()
  520. }
  521. }
  522. // @Title 修改是否为供应商
  523. // @Description
  524. // @router /updatemanufacturerappend/:Id/:SupplierId/:IsManufacturer [get]
  525. func (this *OilSupplierCertAppendSubController) UpdateManufacturerAppend() {
  526. Id := this.Ctx.Input.Param(":Id")
  527. IsManufacturer := this.Ctx.Input.Param(":IsManufacturer")
  528. SupplierId := this.Ctx.Input.Param(":SupplierId")
  529. SupplierTypeCode := "01"
  530. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  531. var CertSublList []suppliercertsub.OilSupplierCertSub
  532. where := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode ='" + SupplierTypeCode + "'" // 没有删除的准入范围
  533. svc.GetEntities(&CertSublList, where)
  534. var SupplierCertId int
  535. for _, CertSub := range CertSublList {
  536. SupplierCertId = CertSub.SupplierCertId
  537. }
  538. var supplierCertModel suppliercert.OilSupplierCert
  539. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  540. svcCert.GetEntityById(SupplierCertId, &supplierCertModel)
  541. var supplierModel supplier.OilSupplier
  542. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  543. svcSupplier.GetEntityById(SupplierId, &supplierModel)
  544. var error error
  545. if IsManufacturer == "2" {
  546. var errinfo ErrorInfo
  547. //根据Id查出OilSupplierCertSub的SubClassId
  548. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  549. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  550. SubClassIds := ""
  551. for _, CertSub := range CertSublList {
  552. SubClassIds += strconv.Itoa(CertSub.SubClassId) + ","
  553. }
  554. var SurplusList []supplierfile.FileList
  555. SubClassIds = strings.Trim(SubClassIds, ",")
  556. if SubClassIds != "" {
  557. if SupplierTypeCode == "01" {
  558. var CertSublList2 []suppliercertsub.OilSupplierCertSub
  559. wheregood := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode + " and IsManufacturer =" + IsManufacturer // 没有删除的准入范围
  560. svc.GetEntities(&CertSublList2, wheregood)
  561. SubClassIds2 := ""
  562. for _, CertSub := range CertSublList2 {
  563. SubClassIds2 += strconv.Itoa(CertSub.SubClassId) + ","
  564. }
  565. SubClassIds2 = strings.Trim(SubClassIds2, ",")
  566. SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds2, IsManufacturer)
  567. }
  568. }
  569. fileNames := ""
  570. for _, CertSub := range SurplusList {
  571. fileNames += CertSub.FileName + ","
  572. }
  573. var datamain suppliercertsub.OilSupplierCertSub //创建OilSupplierCertSub结构体(映射用)
  574. var datamain2 []suppliercertsub.OilSupplierCertSub //空的查询用
  575. where = " Id= " + Id
  576. svc.GetEntity(&datamain, where) //根据Id查找,映射结构体
  577. //再根据企业id查找这个企业有几个准入范围(如果只有一个准入范围了,基本资质也删除)
  578. supplierId := datamain.SupplierId
  579. where = "SupplierId=" + strconv.Itoa(supplierId)
  580. svc.GetEntities(&datamain2, where)
  581. flag := 0
  582. if len(datamain2) == 1 {
  583. flag = 1
  584. }
  585. subClassId := datamain.SubClassId //4.拿到结构体中的准入范围SubClassId
  586. //根据SubClassId查出此准入范围所拥有的资质名称
  587. var needList []supplierfile.FileList //定义存储所拥有资质名称的数组
  588. needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), IsManufacturer) //通过准入范围Id获得资质名称并填充数组
  589. var mustField string
  590. mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName") //必需的资质
  591. //根据企业ID(SupplierId)和此准入范围所拥有的资质名称删除OilSupplierFile表中对应的资质
  592. for j := 0; j < len(needList); j++ { //循环遍历资质名称数组,逐条删除
  593. if flag == 0 && strings.Contains(mustField, needList[j].FileName+",") {
  594. continue
  595. }
  596. if flag == 0 && strings.Contains(fileNames, needList[j].FileName+",") {
  597. continue
  598. }
  599. where := " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and IsManuf='" + IsManufacturer + "' and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
  600. err := svc.DeleteEntityBytbl(OilSupplierFileName, where) //删除第j条资质数据
  601. if err == nil {
  602. errinfo.Message = "删除成功"
  603. errinfo.Code = 0
  604. this.Data["json"] = &errinfo
  605. this.ServeJSON()
  606. } else {
  607. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  608. errinfo.Code = -1
  609. this.Data["json"] = &errinfo
  610. this.ServeJSON()
  611. }
  612. }
  613. needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), "1")
  614. //if supplierCertModel.InStyle == "4" {
  615. // var needFile supplierfile.FileList
  616. // //战略合作协议扫描件
  617. // needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  618. // needList = append(needList, needFile)
  619. //}
  620. var list []supplierfile.OilSupplierFile
  621. where := "SupplierTypeCode in (01,000) and IsManuf in ('0','1') and SupplierId =" + strconv.Itoa(supplierId)
  622. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  623. //三证合一或五证合一不需要的字段
  624. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  625. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  626. mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  627. for i := 0; i < len(needList); i++ {
  628. var entity supplierfile.OilSupplierFile
  629. entity.SupplierId = supplierId
  630. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  631. continue
  632. }
  633. //加入对应表OilSupplierCertFile
  634. if strings.Contains(mustField, needList[i].FileName+",") {
  635. entity.SupplierTypeCode = "000"
  636. entity.IsManuf = "0"
  637. } else {
  638. entity.SupplierTypeCode = "01"
  639. entity.IsManuf = "1"
  640. }
  641. entity.NeedFileType = needList[i].FileName
  642. entity.FileType = 1
  643. //entity.EffectDate = time.Now()
  644. entity.CreateBy = this.User.Realname
  645. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  646. entity.SupType = 2
  647. entity.SupplierCertSubId = datamain.SupplierCertAppendId
  648. isRepeat := false
  649. for j := 0; j < len(list); j++ {
  650. if list[j].NeedFileType == needList[i].FileName {
  651. isRepeat = true
  652. break
  653. }
  654. }
  655. if isRepeat == true {
  656. continue
  657. }
  658. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  659. }
  660. _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set IsManufacturer =1 where Id=" + Id + "")
  661. } else if IsManufacturer == "1" {
  662. var errinfo ErrorInfo
  663. //根据Id查出OilSupplierCertSub的SubClassId
  664. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  665. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  666. SubClassIds := ""
  667. for _, CertSub := range CertSublList {
  668. SubClassIds += strconv.Itoa(CertSub.SubClassId) + ","
  669. }
  670. var SurplusList []supplierfile.FileList
  671. SubClassIds = strings.Trim(SubClassIds, ",")
  672. if SubClassIds != "" {
  673. if SupplierTypeCode == "01" {
  674. var CertSublList2 []suppliercertsub.OilSupplierCertSub
  675. wheregood := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode + " and IsManufacturer =" + IsManufacturer // 没有删除的准入范围
  676. svc.GetEntities(&CertSublList2, wheregood)
  677. SubClassIds2 := ""
  678. for _, CertSub := range CertSublList2 {
  679. SubClassIds2 += strconv.Itoa(CertSub.SubClassId) + ","
  680. }
  681. SubClassIds2 = strings.Trim(SubClassIds2, ",")
  682. SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds2, IsManufacturer)
  683. }
  684. }
  685. fileNames := ""
  686. for _, CertSub := range SurplusList {
  687. fileNames += CertSub.FileName + ","
  688. }
  689. var datamain suppliercertsub.OilSupplierCertSub //创建OilSupplierCertSub结构体(映射用)
  690. var datamain2 []suppliercertsub.OilSupplierCertSub //空的查询用
  691. where = " Id= " + Id
  692. svc.GetEntity(&datamain, where) //根据Id查找,映射结构体
  693. //再根据企业id查找这个企业有几个准入范围(如果只有一个准入范围了,基本资质也删除)
  694. supplierId := datamain.SupplierId
  695. where = "SupplierId=" + strconv.Itoa(supplierId)
  696. svc.GetEntities(&datamain2, where)
  697. flag := 0
  698. if len(datamain2) == 1 {
  699. flag = 1
  700. }
  701. subClassId := datamain.SubClassId //4.拿到结构体中的准入范围SubClassId
  702. //根据SubClassId查出此准入范围所拥有的资质名称
  703. var needList []supplierfile.FileList //定义存储所拥有资质名称的数组
  704. needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), IsManufacturer) //通过准入范围Id获得资质名称并填充数组
  705. var mustField string
  706. mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName") //必需的资质
  707. //根据企业ID(SupplierId)和此准入范围所拥有的资质名称删除OilSupplierFile表中对应的资质
  708. for j := 0; j < len(needList); j++ { //循环遍历资质名称数组,逐条删除
  709. if flag == 0 && strings.Contains(mustField, needList[j].FileName+",") {
  710. continue
  711. }
  712. if flag == 0 && strings.Contains(fileNames, needList[j].FileName+",") {
  713. continue
  714. }
  715. where := " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and IsManuf='" + IsManufacturer + "' and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
  716. err := svc.DeleteEntityBytbl(OilSupplierFileName, where) //删除第j条资质数据
  717. if err == nil {
  718. errinfo.Message = "删除成功"
  719. errinfo.Code = 0
  720. this.Data["json"] = &errinfo
  721. this.ServeJSON()
  722. } else {
  723. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  724. errinfo.Code = -1
  725. this.Data["json"] = &errinfo
  726. this.ServeJSON()
  727. }
  728. }
  729. needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), "2")
  730. //if supplierCertModel.InStyle == "4" {
  731. // var needFile supplierfile.FileList
  732. // //战略合作协议扫描件
  733. // needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  734. // needList = append(needList, needFile)
  735. //}
  736. var list []supplierfile.OilSupplierFile
  737. where := "SupplierTypeCode in (01,000) and IsManuf in ('0','2') and SupplierId =" + strconv.Itoa(supplierId)
  738. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  739. //三证合一或五证合一不需要的字段
  740. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  741. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  742. mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  743. for i := 0; i < len(needList); i++ {
  744. var entity supplierfile.OilSupplierFile
  745. entity.SupplierId = supplierId
  746. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  747. continue
  748. }
  749. //加入对应表OilSupplierCertFile
  750. if strings.Contains(mustField, needList[i].FileName+",") {
  751. entity.SupplierTypeCode = "000"
  752. entity.IsManuf = "0"
  753. } else {
  754. entity.SupplierTypeCode = "01"
  755. entity.IsManuf = "2"
  756. }
  757. entity.NeedFileType = needList[i].FileName
  758. entity.FileType = 1
  759. //entity.EffectDate = time.Now()
  760. entity.CreateBy = this.User.Realname
  761. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  762. entity.SupType = 2
  763. entity.SupplierCertSubId = datamain.SupplierCertAppendId
  764. isRepeat := false
  765. for j := 0; j < len(list); j++ {
  766. if list[j].NeedFileType == needList[i].FileName {
  767. isRepeat = true
  768. break
  769. }
  770. }
  771. if isRepeat == true {
  772. continue
  773. }
  774. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  775. }
  776. _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set IsManufacturer=2 where Id=" + Id + "")
  777. }
  778. var errinfo ErrorDataInfo
  779. if error == nil {
  780. errinfo.Message = "修改成功!"
  781. errinfo.Code = 0
  782. this.Data["json"] = &errinfo
  783. this.ServeJSON()
  784. } else {
  785. errinfo.Message = "修改失败!"
  786. errinfo.Code = -1
  787. this.Data["json"] = &errinfo
  788. this.ServeJSON()
  789. }
  790. }
  791. // @Title 获取实体
  792. // @Description 获取实体
  793. // @Success 200 {object} supplier.OilSupplier
  794. // @router /getchangelist/:id [get]
  795. func (this *OilSupplierCertAppendSubController) GetChangeEntity() {
  796. Id := this.Ctx.Input.Param(":id")
  797. InfoId := this.GetString("InfomainId")
  798. var models [2]supplier.OilSupplier
  799. var model supplier.OilSupplier
  800. var enumModel supplier.OilSupplier
  801. svc := supplier.GetOilSupplierService(utils.DBE)
  802. svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  803. models[0] = model
  804. var infoitems []suppliercertappendsub.OilAppendChangeItem
  805. where := " SupplierId = " + Id + " and InfoId =" + InfoId
  806. where = where + " and ChangeStatus = 0"
  807. svc.GetEntitysByWhere(OilAppendChangeItemName, where, &infoitems)
  808. tmpModel := &model
  809. enumModel = *tmpModel
  810. immumodel := reflect.ValueOf(&enumModel)
  811. elem := immumodel.Elem()
  812. if len(infoitems) == 0 {
  813. models[1] = enumModel
  814. this.Data["json"] = &models
  815. this.ServeJSON()
  816. return
  817. } else {
  818. for _, info := range infoitems {
  819. fmt.Println(info.SelectItem)
  820. fmt.Println(";;;;;;;;;", elem.FieldByName(info.SelectItem).Type().String())
  821. if elem.FieldByName(info.SelectItem).Type().String() == "int64" {
  822. intchangeinfo, _ := strconv.ParseInt(info.ChangeInfo, 10, 64)
  823. elem.FieldByName(info.SelectItem).SetInt(intchangeinfo)
  824. } else if elem.FieldByName(info.SelectItem).Type().String() == "float64" {
  825. floatchangeinfo, _ := strconv.ParseFloat(info.ChangeInfo, 64)
  826. elem.FieldByName(info.SelectItem).SetFloat(floatchangeinfo)
  827. } else if elem.FieldByName(info.SelectItem).Type().String() == "time.Time" {
  828. t, _ := time.Parse("2006-01-02", info.ChangeInfo[0:10])
  829. elem.FieldByName(info.SelectItem).Set(reflect.ValueOf(t))
  830. } else {
  831. elem.FieldByName(info.SelectItem).SetString(info.ChangeInfo)
  832. }
  833. }
  834. models[1] = enumModel
  835. this.Data["json"] = &models
  836. this.ServeJSON()
  837. }
  838. }
  839. // @Title 获取实体
  840. // @Description 获取实体
  841. // @Success 200 {object} annualaudit.OilAnnualAudit
  842. // @router /auditget/:id [get]
  843. func (this *OilSupplierCertAppendSubController) GetEntityThen() {
  844. InfoId := this.Ctx.Input.Param(":id")
  845. var model []suppliercertappendsub.OilAppendChangeItem
  846. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  847. where := " InfoId = " + InfoId
  848. svc.GetEntitysByWhere(OilAppendChangeItemName, where, &model)
  849. var datainfo DataInfo
  850. datainfo.Items = model
  851. this.Data["json"] = &datainfo
  852. this.ServeJSON()
  853. }
  854. // @Title 添加
  855. // @Description 新增
  856. // @Success 200 {object} controllers.Request
  857. // @router /addinfochangeitemch [post]
  858. func (this *OilSupplierCertAppendSubController) AddInfoChangeItemCh() {
  859. var model AppendChangeItemsAll
  860. var jsonBlob = this.Ctx.Input.RequestBody
  861. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  862. json.Unmarshal(jsonBlob, &model)
  863. var err error
  864. where := " SupplierId = " + model.SupplierId
  865. where = where + " and InfoId = " + model.MInfoId
  866. var deleteEntity suppliercertappendsub.OilAppendChangeItem
  867. delMainId, _ := strconv.Atoi(model.MInfoId)
  868. deleteEntity.InfoId = delMainId
  869. svc.DBE.Delete(deleteEntity)
  870. var infoitementitys []suppliercertappendsub.OilAppendChangeItem
  871. for i := 0; i < len(model.InfochangeForm); i++ {
  872. var infoitementity suppliercertappendsub.OilAppendChangeItem
  873. infoitementity.SelectItem = model.InfochangeForm[i].SelectItem
  874. infoitementity.SelectItemName = model.InfochangeForm[i].SelectItemName
  875. infoitementity.ChangeInfo = model.InfochangeForm[i].ChangeInfo
  876. infoitementity.BeChangeInfo = model.InfochangeForm[i].BeChangeInfo
  877. infoitementity.ChangeStatus = 0
  878. infoitementity.SupplierId, _ = strconv.Atoi(model.SupplierId)
  879. infoitementity.InfoId, _ = strconv.Atoi(model.MInfoId)
  880. infoitementity.CreateOn = time.Now()
  881. infoitementity.CreateBy = this.User.Realname
  882. infoitementity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  883. infoitementitys = append(infoitementitys, infoitementity)
  884. }
  885. _, err = svc.InsertEntityBytbl(""+OilAppendChangeItemName, &infoitementitys)
  886. var errinfo ErrorDataInfo
  887. if err == nil {
  888. //新增
  889. errinfo.Message = "添加成功!"
  890. errinfo.Code = 0
  891. //errinfo.Item = model.Id
  892. this.Data["json"] = &errinfo
  893. this.ServeJSON()
  894. } else {
  895. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  896. errinfo.Code = -1
  897. this.Data["json"] = &errinfo
  898. this.ServeJSON()
  899. }
  900. }
  901. // @Title 资质文件
  902. // @Description get user by token
  903. // @Success 200 {object} models.Userblood
  904. // @router /filelist [get]
  905. func (this *OilSupplierCertAppendSubController) FileList() {
  906. page := this.GetPageInfoForm()
  907. var list []suppliercertappendsub.OilAppendChangeDetail1
  908. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  909. where := " 1=1"
  910. orderby := "a.SupplierTypeCode"
  911. asc := true
  912. Order := this.GetString("Order")
  913. Prop := this.GetString("Prop")
  914. if Order != "" && Prop != "" {
  915. orderby = Prop
  916. if Order == "asc" {
  917. asc = true
  918. }
  919. }
  920. SupplierId := this.GetString("SupplierId")
  921. MInfoId := this.GetString("MInfoId")
  922. if SupplierId != "" {
  923. where = where + " and a.SupplierId = '" + SupplierId + "'"
  924. }
  925. SupplierTypeCode := this.GetString("SupplierTypeCode")
  926. if SupplierTypeCode != "" {
  927. where = where + " and a.SupplierTypeCode in ( '000', '" + SupplierTypeCode + "')"
  928. }
  929. total := svc.GetQualPagingEntities(OilSupplierFileName, OilAppendChangeDetailName, page.CurrentPage, page.Size, orderby, asc, &list, where, MInfoId)
  930. var datainfo DataInfo
  931. datainfo.Items = list
  932. datainfo.CurrentItemCount = total
  933. this.Data["json"] = &datainfo
  934. this.ServeJSON()
  935. }
  936. // @Title 资质文件变更上传
  937. // @Description 更新文件上传
  938. // @Param id path string true
  939. // @Success 200 {object}
  940. // @router /editqualchange/:id [put]
  941. func (this *OilSupplierCertAppendSubController) EditQualChange() {
  942. id := this.Ctx.Input.Param(":id")
  943. var errinfo ErrorInfo
  944. if id == "" {
  945. errinfo.Message = "操作失败!请求信息不完整"
  946. errinfo.Code = -2
  947. this.Data["json"] = &errinfo
  948. this.ServeJSON()
  949. return
  950. }
  951. var model suppliercertappendsub.OilAppendChangeDetail
  952. var jsonblob = this.Ctx.Input.RequestBody
  953. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  954. json.Unmarshal(jsonblob, &model)
  955. model.FileUrl = strings.Trim(model.FileUrl, "$")
  956. model.FileName = strings.Trim(model.FileName, "$")
  957. model.OldFileUrl = strings.Trim(model.OldFileUrl, "$")
  958. model.OldFileName = strings.Trim(model.OldFileName, "$")
  959. var supplierfile supplierfile.OilSupplierFile
  960. svc.GetEntityByIdBytbl(OilSupplierFileName, model.Id, &supplierfile)
  961. if supplierfile.FileUrl == "" {
  962. //区别 更新前和更新后文件
  963. supplierfile.FileUrl = strings.Trim(model.FileUrl, "$")
  964. supplierfile.FileName = strings.Trim(model.FileName, "$")
  965. supplierfile.EffectDate = model.EffectDate
  966. }
  967. supplierfile.ModifiedOn = time.Now()
  968. supplierfile.ModifiedUserId, _ = strconv.Atoi(this.User.Id)
  969. supplierfile.ModifiedBy = this.User.Realname
  970. supplierfile.OtherRemark = model.Remark
  971. svc.UpdateEntityBywheretbl(OilSupplierFileName, &supplierfile, []string{"EffectDate", "FileUrl", "FileName", "ModifiedOn", "ModifiedUserId", "ModifiedBy", "OtherRemark"}, "Id = " + strconv.Itoa(model.Id))
  972. var err error
  973. var entity suppliercertappendsub.OilAppendChangeDetail
  974. var qualdetaimodel []suppliercertappendsub.OilAppendChangeDetail
  975. qdwhere := " SupplierId = " + utils.ToStr(model.SupplierId) + " and FileId = " + utils.ToStr(model.Id) + " and ParentId=" + id
  976. svc.GetEntitysByWhere(OilAppendChangeDetailName, qdwhere, &qualdetaimodel)
  977. entity = model
  978. entity.Id = 0
  979. entity.ParentId, _ = strconv.Atoi(id)
  980. entity.SupplierCertId = model.SupplierCertId
  981. entity.FileId = model.Id
  982. if len(qualdetaimodel) == 0 {
  983. entity.CreateOn = time.Now()
  984. entity.CreateBy = this.User.Realname
  985. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  986. _, err = svc.InsertEntityBytbl(OilAppendChangeDetailName, &entity)
  987. } else {
  988. err = svc.UpdateEntityBywheretbl(OilAppendChangeDetailName, &entity, []string{"EffectDate", "FileUrl", "FileName", "OtherRemark"}, qdwhere)
  989. }
  990. if err == nil {
  991. errinfo.Message = "操作成功!"
  992. errinfo.Code = 0
  993. this.Data["json"] = &errinfo
  994. this.ServeJSON()
  995. } else {
  996. errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
  997. errinfo.Code = -1
  998. this.Data["json"] = &errinfo
  999. this.ServeJSON()
  1000. }
  1001. }
  1002. // @Title 删除新上传的资质
  1003. // @Description
  1004. // @Success 200 {object} ErrorInfo
  1005. // @Failure 403 :id 为空
  1006. // @router /deletenewfile/:Id [delete]
  1007. func (this *OilSupplierCertAppendSubController) DeleteNewFile() {
  1008. Id := this.Ctx.Input.Param(":Id")
  1009. var errinfo ErrorInfo
  1010. if Id == "" {
  1011. errinfo.Message = "操作失败!请求信息不完整"
  1012. errinfo.Code = -2
  1013. this.Data["json"] = &errinfo
  1014. this.ServeJSON()
  1015. return
  1016. }
  1017. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  1018. where := "FileId=" + Id
  1019. err := svc.DeleteEntityBytbl(OilAppendChangeDetailName, where)
  1020. if err == nil {
  1021. errinfo.Message = "删除成功"
  1022. errinfo.Code = 0
  1023. this.Data["json"] = &errinfo
  1024. this.ServeJSON()
  1025. } else {
  1026. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  1027. errinfo.Code = -1
  1028. this.Data["json"] = &errinfo
  1029. this.ServeJSON()
  1030. }
  1031. }