suppliercertappendsub.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  4. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  5. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  6. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  7. "dashoo.cn/business2/parameter"
  8. "encoding/json"
  9. "strconv"
  10. "strings"
  11. "time"
  12. "dashoo.cn/backend/api/business/oilsupplier/suppliercertappendsub"
  13. . "dashoo.cn/backend/api/controllers"
  14. "dashoo.cn/utils"
  15. )
  16. type OilSupplierCertAppendSubController struct {
  17. BaseController
  18. }
  19. // @Title 获取列表
  20. // @Description 获取列表
  21. // @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
  22. // @router /getList [get]
  23. func (this *OilSupplierCertAppendSubController) GetList() {
  24. //获取分页信息
  25. //page := this.GetPageInfoForm()
  26. //where := " 1=1 "
  27. //orderby := "Id"
  28. //asc := false
  29. //Order := this.GetString("Order")
  30. //Prop := this.GetString("Prop")
  31. //if Order != "" && Prop != "" {
  32. // orderby = Prop
  33. // if Order == "asc" {
  34. // asc = true
  35. // }
  36. //}
  37. //SupplierCertAppendId := this.GetString("SupplierCertAppendId")
  38. //if SupplierCertAppendId != "" {
  39. // where = where + " and SupplierCertAppendId = " + SupplierCertAppendId
  40. //}
  41. SupplierCertId := this.GetString("SupCertId")
  42. SupplierTypeCode := this.GetString("SupTypeCode")
  43. suwhere := " SupplierCertId = "+ SupplierCertId+ " and SupplierTypeCode = "+ SupplierTypeCode
  44. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  45. var list []suppliercertsub.OilSupplierCertSub
  46. //svc.GetEntitysByWhere(OilSupplierCertAppendSubName, where, &list)
  47. svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere,"CreateOn asc", &list)
  48. var datainfo ErrorDataInfo
  49. datainfo.Item = list
  50. this.Data["json"] = &datainfo
  51. this.ServeJSON()
  52. }
  53. // @Title 获取列表
  54. // @Description 获取列表
  55. // @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
  56. // @router /getMyList [get]
  57. func (this *OilSupplierCertAppendSubController) GetMyList() {
  58. SupplierCertId := this.GetString("SupCertId")
  59. SupplierTypeCode := this.GetString("SupTypeCode")
  60. SuppAppendId := this.GetString("SupplierCertAppendId")
  61. suwhere := " SupplierCertId = "+ SupplierCertId+ " and SupplierTypeCode = '"+ SupplierTypeCode +"' and SupplierCertAppendId = "+ SuppAppendId
  62. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  63. var list []suppliercertsub.OilSupplierCertSub
  64. svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere,"CreateOn asc", &list)
  65. var datainfo ErrorDataInfo
  66. datainfo.Item = list
  67. this.Data["json"] = &datainfo
  68. this.ServeJSON()
  69. }
  70. // @Title 获取列表
  71. // @Description 获取列表
  72. // @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
  73. // @router /getListappend [get]
  74. func (this *OilSupplierCertAppendSubController) GetListAppend() {
  75. //获取分页信息
  76. //page := this.GetPageInfoForm()
  77. //where := " 1=1 "
  78. //orderby := "Id"
  79. //asc := false
  80. //Order := this.GetString("Order")
  81. //Prop := this.GetString("Prop")
  82. //if Order != "" && Prop != "" {
  83. // orderby = Prop
  84. // if Order == "asc" {
  85. // asc = true
  86. // }
  87. //}
  88. //SupplierCertAppendId := this.GetString("SupplierCertAppendId")
  89. //if SupplierCertAppendId != "" {
  90. // where = where + " and SupplierCertAppendId = " + SupplierCertAppendId
  91. //}
  92. SupplierCertId := this.GetString("SupCertId")
  93. SupplierTypeCode := this.GetString("SupTypeCode")
  94. suwhere := " SupplierCertId = "+ SupplierCertId+ " and SupplierTypeCode = "+ SupplierTypeCode +" and Type = 2"
  95. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  96. var list []suppliercertsub.OilSupplierCertSub
  97. //svc.GetEntitysByWhere(OilSupplierCertAppendSubName, where, &list)
  98. svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere,"CreateOn asc", &list)
  99. var datainfo ErrorDataInfo
  100. datainfo.Item = list
  101. this.Data["json"] = &datainfo
  102. this.ServeJSON()
  103. }
  104. // @Title 添加
  105. // @Description 添加增项分类信息基建类
  106. // @Success 200 {object} controllers.Request
  107. // @router /addappendsub [post]
  108. func (this *OilSupplierCertAppendSubController) AddAppendSub() {
  109. var model suppliercertsub.OilSupplierCertSub
  110. var jsonblob = this.Ctx.Input.RequestBody
  111. var errinfo ErrorDataInfo
  112. var err error
  113. json.Unmarshal(jsonblob, &model)
  114. model.Type = "2"
  115. model.CreateOn = time.Now()
  116. model.CreateBy = this.User.Realname
  117. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  118. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  119. var submodel suppliercertsub.OilSupplierCertSub
  120. where_certsub := " SupplierCertId = "+ utils.ToStr(model.SupplierCertId) + " and SupplierTypeCode = 02"
  121. where_certsub += " and SubClassId = '" + utils.ToStr(model.SubClassId) + "'"
  122. has := svc.GetEntityByWhere(OilSupplierCertSubName, where_certsub, &submodel)
  123. if !has{
  124. //添加到准入分类表中
  125. _, err = svc.InsertEntityBytbl(OilSupplierCertSubName, &model)
  126. }else{
  127. model.Id = submodel.Id
  128. }
  129. var supplierCertModel suppliercert.OilSupplierCert
  130. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  131. svcCert.GetEntityById(model.SupplierCertId, &supplierCertModel)
  132. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  133. var needList []supplierfile.FileList
  134. if model.SupplierTypeCode == "01" {
  135. // needList = filesvc.GetGoodsNeedFileList(model.SubClassId)
  136. } else if model.SupplierTypeCode == "02" {
  137. needList = filesvc.GetBasicNeedFileList(model.SubClassId)
  138. } else {
  139. // needList = filesvc.GetTechNeedFileList(model.SubClassId)
  140. }
  141. if supplierCertModel.InStyle == "4" {
  142. var needFile supplierfile.FileList
  143. needFile.FileName = "战略合作协议扫描件"
  144. needList = append(needList, needFile)
  145. }
  146. if err == nil {
  147. var list []supplierfile.OilSupplierFile
  148. where := "SupplierId = '" + strconv.Itoa(model.SupplierId) + "'"
  149. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  150. hasField := ""
  151. for i := 0; i < len(list); i++ {
  152. hasField += list[i].NeedFileType + ","
  153. }
  154. mustField := "营业执照,组织代码,税务登记,开户许可,银行开户许可证,承诺书,企业信息系统截图,战略合作协议扫描件,"
  155. for i := 0; i < len(needList); i++ {
  156. var entity supplierfile.OilSupplierFile
  157. entity.SupplierId = model.SupplierId
  158. if strings.Contains(mustField, needList[i].FileName+",") {
  159. entity.SupplierTypeCode = "000"
  160. } else {
  161. entity.SupplierTypeCode = model.SupplierTypeCode
  162. }
  163. entity.NeedFileType = needList[i].FileName
  164. entity.FileType = 1
  165. entity.EffectDate = time.Now()
  166. entity.CreateBy = this.User.Realname
  167. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  168. isRepeat := false
  169. for j := 0; j < len(list); j++ {
  170. if list[j].NeedFileType == needList[i].FileName{
  171. isRepeat = true
  172. break
  173. }
  174. }
  175. if isRepeat == true {
  176. continue
  177. }
  178. entity.SupType = 2
  179. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  180. }
  181. }
  182. if err == nil {
  183. errinfo.Message = "操作成功!"
  184. errinfo.Code = 0
  185. errinfo.Item = model.Id
  186. this.Data["json"] = &errinfo
  187. this.ServeJSON()
  188. } else {
  189. errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
  190. errinfo.Code = -1
  191. this.Data["json"] = &errinfo
  192. this.ServeJSON()
  193. }
  194. }
  195. // @Title 批量添加增项准入范围--技术服务类
  196. // @Description 批量添加准入范围
  197. // @Success 200 {object} business.device.DeviceChannels
  198. // @router /addtechbus [post]
  199. func (this *OilSupplierCertAppendSubController) AddTechBus() {
  200. var jsonblob = this.Ctx.Input.RequestBody
  201. var datamain suppliercertsub.OilSupplierCertSub
  202. var dataother suppliercertsub.TechnologySubModel
  203. json.Unmarshal(jsonblob, &datamain)
  204. json.Unmarshal(jsonblob, &dataother)
  205. var supplierCertModel suppliercert.OilSupplierCert
  206. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  207. svcCert.GetEntityById(datamain.SupplierCertId, &supplierCertModel)
  208. for n := 0; n < len(dataother.CheckList); n++ {
  209. where_sub := "SupplierTypeCode = 03 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  210. where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
  211. where_sub += " and SubClassId = '" + strconv.Itoa(dataother.CheckList[n].Id) + "'"
  212. var model suppliercertsub.OilSupplierCertSub
  213. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  214. has := svc.GetEntityByWhere(OilSupplierCertSubName, where_sub, &model)
  215. if !has {
  216. datamain.Type = "2"
  217. datamain.SubClassId = dataother.CheckList[n].Id
  218. datamain.Code = dataother.CheckList[n].Code
  219. datamain.Name = dataother.CheckList[n].Name
  220. datamain.Remark = dataother.Remark
  221. datamain.IsDelete = 0
  222. datamain.CreateBy = this.User.Realname
  223. datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  224. svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
  225. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  226. needList := filesvc.GetTechNeedFileList(dataother.CheckList[n].Id)
  227. if supplierCertModel.InStyle == "4" {
  228. var needFile supplierfile.FileList
  229. needFile.FileName = "战略合作协议扫描件"
  230. needList = append(needList, needFile)
  231. }
  232. var list []supplierfile.OilSupplierFile
  233. where := "SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  234. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  235. hasField := ""
  236. for i := 0; i < len(list); i++ {
  237. hasField += list[i].NeedFileType + ","
  238. }
  239. mustField := "营业执照,组织代码,税务登记,开户许可,银行开户许可证,承诺书,企业信息系统截图,战略合作协议扫描件,"
  240. for i := 0; i < len(needList); i++ {
  241. var entity supplierfile.OilSupplierFile
  242. entity.SupplierId = dataother.SupplierId
  243. if strings.Contains(mustField, needList[i].FileName+",") {
  244. entity.SupplierTypeCode = "000"
  245. } else {
  246. entity.SupplierTypeCode = dataother.SupplierTypeCode
  247. }
  248. entity.NeedFileType = needList[i].FileName
  249. entity.SupType = 2
  250. entity.FileType = 1
  251. entity.EffectDate = time.Now()
  252. entity.CreateBy = this.User.Realname
  253. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  254. isRepeat := false
  255. for j := 0; j < len(list); j++ {
  256. if list[j].NeedFileType == needList[i].FileName{
  257. isRepeat = true
  258. break
  259. }
  260. }
  261. if isRepeat == true {
  262. continue
  263. }
  264. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  265. }
  266. }
  267. }
  268. var errinfo ErrorDataInfo
  269. errinfo.Message = "操作成功!"
  270. errinfo.Code = 0
  271. this.Data["json"] = &errinfo
  272. this.ServeJSON()
  273. }
  274. // @Title 批量添加增项准入范围--物资类
  275. // @Description 批量添加增项准入范围
  276. // @Success 200 {object} business.device.DeviceChannels
  277. // @router /addgoodsbus [post]
  278. func (this *OilSupplierCertAppendSubController) AddGoodsBus() {
  279. var jsonblob = this.Ctx.Input.RequestBody
  280. var datamain suppliercertsub.OilSupplierCertSub
  281. var dataother suppliercertsub.SupplierCertSubModel
  282. json.Unmarshal(jsonblob, &datamain)
  283. json.Unmarshal(jsonblob, &dataother)
  284. var supplierCertModel suppliercert.OilSupplierCert
  285. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  286. svcCert.GetEntityById(datamain.SupplierCertId, &supplierCertModel)
  287. var supplierModel supplier.OilSupplier
  288. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  289. svcSupplier.GetEntityById(datamain.SupplierCertId, &supplierModel)
  290. for n := 0; n < len(dataother.CheckList); n++ {
  291. where_sub := "SupplierTypeCode = 01 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  292. where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
  293. where_sub += " and SubClassId = '" + dataother.CheckList[n].Id + "'"
  294. var model suppliercertsub.OilSupplierCertSub
  295. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  296. has := svc.GetEntityByWhere(OilSupplierCertSubName, where_sub, &model)
  297. if !has {
  298. datamain.Type = "2"
  299. datamain.SubClassId, _ = utils.StrTo(dataother.CheckList[n].Id).Int()
  300. datamain.Code = dataother.CheckList[n].Code
  301. datamain.Name = dataother.CheckList[n].Name
  302. datamain.Remark = dataother.Remark
  303. datamain.IsDelete = 0
  304. datamain.CreateBy = this.User.Realname
  305. datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  306. svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
  307. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  308. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  309. needList := filesvc.GetGoodsNeedFileList(dataother.CheckList[n].Id)
  310. if supplierCertModel.InStyle == "4" {
  311. var needFile supplierfile.FileList
  312. //战略合作协议扫描件
  313. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  314. needList = append(needList, needFile)
  315. }
  316. var list []supplierfile.OilSupplierFile
  317. where := "SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  318. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  319. hasField := ""
  320. for i := 0; i < len(list); i++ {
  321. hasField += list[i].NeedFileType + ","
  322. }
  323. //三证合一或五证合一不需要的字段
  324. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  325. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  326. mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  327. for i := 0; i < len(needList); i++ {
  328. var entity supplierfile.OilSupplierFile
  329. entity.SupplierId = dataother.SupplierId
  330. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  331. continue
  332. }
  333. if strings.Contains(mustField, needList[i].FileName+",") {
  334. entity.SupplierTypeCode = "000"
  335. } else {
  336. entity.SupplierTypeCode = dataother.SupplierTypeCode
  337. }
  338. entity.NeedFileType = needList[i].FileName
  339. entity.FileType = 1
  340. entity.SupType = 2
  341. entity.EffectDate = time.Now()
  342. entity.CreateBy = this.User.Realname
  343. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  344. isRepeat := false
  345. for j := 0; j < len(list); j++ {
  346. if list[j].NeedFileType == needList[i].FileName{
  347. isRepeat = true
  348. break
  349. }
  350. }
  351. if isRepeat == true {
  352. continue
  353. }
  354. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  355. }
  356. }
  357. }
  358. var errinfo ErrorDataInfo
  359. errinfo.Message = "操作成功!"
  360. errinfo.Code = 0
  361. this.Data["json"] = &errinfo
  362. this.ServeJSON()
  363. }
  364. // @Title 修改实体
  365. // @Description 修改实体
  366. // @Success 200 {object} controllers.Request
  367. // @router /update/:id [post]
  368. func (this *OilSupplierCertAppendSubController) UpdateEntity() {
  369. var errinfo ErrorInfo
  370. var model suppliercertappendsub.OilSupplierCertAppendSub
  371. id := this.Ctx.Input.Param(":id")
  372. if id == "" {
  373. errinfo.Message = "操作失败!请求信息不完整"
  374. errinfo.Code = -2
  375. this.Data["json"] = &errinfo
  376. this.ServeJSON()
  377. return
  378. }
  379. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  380. var jsonBlob = this.Ctx.Input.RequestBody
  381. json.Unmarshal(jsonBlob, &model)
  382. model.ModifiedOn = time.Now()
  383. model.ModifiedBy = this.User.Realname
  384. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  385. cols := []string{
  386. "SortFlag",
  387. "Code",
  388. "Name",
  389. "Remark",
  390. "ModifiedOn",
  391. "ModifiedUserId",
  392. "ModifiedBy",
  393. }
  394. err := svc.UpdateEntityBytbl(OilSupplierCertAppendSubName, id, &model, cols)
  395. if err == nil {
  396. errinfo.Message = "修改成功!"
  397. errinfo.Code = 0
  398. this.Data["json"] = &errinfo
  399. this.ServeJSON()
  400. } else {
  401. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  402. errinfo.Code = -1
  403. this.Data["json"] = &errinfo
  404. this.ServeJSON()
  405. }
  406. }
  407. // @Title 删除
  408. // @Description 删除信息
  409. // @Success 200 {object} ErrorInfo
  410. // @Failure 403 :id 为空
  411. // @router /delete/:Id [delete]
  412. func (this *OilSupplierCertAppendSubController) DeleteEntity() {
  413. Id := this.Ctx.Input.Param(":Id")
  414. var errinfo ErrorInfo
  415. if Id == "" {
  416. errinfo.Message = "操作失败!请求信息不完整"
  417. errinfo.Code = -2
  418. this.Data["json"] = &errinfo
  419. this.ServeJSON()
  420. return
  421. }
  422. var model suppliercertappendsub.OilSupplierCertAppendSub
  423. var entityempty suppliercertappendsub.OilSupplierCertAppendSub
  424. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  425. opdesc := "删除-" + Id
  426. err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierCertAppendSubName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "增项分类")
  427. if err == nil {
  428. errinfo.Message = "删除成功"
  429. errinfo.Code = 0
  430. this.Data["json"] = &errinfo
  431. this.ServeJSON()
  432. } else {
  433. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  434. errinfo.Code = -1
  435. this.Data["json"] = &errinfo
  436. this.ServeJSON()
  437. }
  438. }