suppliercertappendsub.go 43 KB

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