2
3

suppliercertsub.go 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/goodsaptitudeclass"
  4. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  5. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  6. "dashoo.cn/backend/api/business/oilsupplier/supplierpausereason"
  7. "dashoo.cn/backend/api/business/organize"
  8. "dashoo.cn/business2/parameter"
  9. "encoding/json"
  10. //"fmt"
  11. "strconv"
  12. "strings"
  13. "time"
  14. "dashoo.cn/backend/api/business/baseUser"
  15. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  16. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  17. // "dashoo.cn/backend/api/business/oilsupplier/technologyservice"
  18. . "dashoo.cn/backend/api/controllers"
  19. "dashoo.cn/business2/userRole"
  20. "dashoo.cn/utils"
  21. )
  22. type OilSupplierCertSubController struct {
  23. BaseController
  24. }
  25. // @Title 获取列表
  26. // @Description get user by token
  27. // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
  28. // @router /list [get]
  29. func (this *OilSupplierCertSubController) GetEntityList() {
  30. //获取分页信息
  31. page := this.GetPageInfoForm()
  32. where := " 1=1 "
  33. orderby := "Id"
  34. asc := false
  35. Order := this.GetString("Order")
  36. Prop := this.GetString("Prop")
  37. if Order != "" && Prop != "" {
  38. orderby = Prop
  39. if Order == "asc" {
  40. asc = true
  41. }
  42. }
  43. Id := this.GetString("Id")
  44. SupplierId := this.GetString("SupplierId")
  45. SupplierCertId := this.GetString("SupplierCertId")
  46. SupplierTypeCode := this.GetString("SupplierTypeCode")
  47. Code := this.GetString("Code")
  48. Name := this.GetString("Name")
  49. Remark := this.GetString("Remark")
  50. IsDelete := this.GetString("IsDelete")
  51. CreateOn := this.GetString("CreateOn")
  52. CreateUserId := this.GetString("CreateUserId")
  53. CreateBy := this.GetString("CreateBy")
  54. ModifiedOn := this.GetString("ModifiedOn")
  55. ModifiedUserId := this.GetString("ModifiedUserId")
  56. ModifiedBy := this.GetString("ModifiedBy")
  57. if Id != "" {
  58. where = where + " and Id like '%" + Id + "%'"
  59. }
  60. if SupplierId != "" {
  61. where = where + " and SupplierId like '%" + SupplierId + "%'"
  62. }
  63. if SupplierCertId != "" {
  64. where = where + " and SupplierCertId = '" + SupplierCertId + "'"
  65. }
  66. if SupplierTypeCode != "" {
  67. where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'"
  68. }
  69. if Code != "" {
  70. where = where + " and Code like '%" + Code + "%'"
  71. }
  72. if Name != "" {
  73. where = where + " and Name like '%" + Name + "%'"
  74. }
  75. if Remark != "" {
  76. where = where + " and Remark like '%" + Remark + "%'"
  77. }
  78. if IsDelete != "" {
  79. where = where + " and IsDelete like '%" + IsDelete + "%'"
  80. }
  81. if CreateUserId != "" {
  82. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  83. }
  84. if CreateBy != "" {
  85. where = where + " and CreateBy like '%" + CreateBy + "%'"
  86. }
  87. if ModifiedOn != "" {
  88. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  89. }
  90. if ModifiedUserId != "" {
  91. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  92. }
  93. if ModifiedBy != "" {
  94. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  95. }
  96. if CreateOn != "" {
  97. dates := strings.Split(CreateOn, ",")
  98. if len(dates) == 2 {
  99. minDate := dates[0]
  100. maxDate := dates[1]
  101. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  102. }
  103. }
  104. where = where + " and Type in (1, 3)"
  105. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  106. var list []suppliercertsub.OilSupplierCertSub
  107. total := svc.GetPagingEntitiesWithoutAccCode(page.CurrentPage, page.Size, orderby, asc, &list, where)
  108. var datainfo DataInfo
  109. datainfo.Items = list
  110. datainfo.CurrentItemCount = total
  111. datainfo.PageIndex = page.CurrentPage
  112. datainfo.ItemsPerPage = page.Size
  113. this.Data["json"] = &datainfo
  114. this.ServeJSON()
  115. }
  116. // @Title 获取列表
  117. // @Description
  118. // @Success 200 {object}
  119. // @router /listCert2019 [get]
  120. func (this *OilSupplierCertSubController) ListCert2019() {
  121. //获取分页信息
  122. page := this.GetPageInfoForm()
  123. where := " 1=1 "
  124. orderby := "Id"
  125. asc := true
  126. Order := this.GetString("Order")
  127. Prop := this.GetString("Prop")
  128. if Order != "" && Prop != "" {
  129. orderby = Prop
  130. if Order == "asc" {
  131. asc = true
  132. }
  133. }
  134. Name := this.GetString("Name")
  135. if Name != "" {
  136. where = where + " and (Name like '%" + Name + "%' or Code like '%" + Name + "%')"
  137. }
  138. where = where + " and Edition = '2'"
  139. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  140. var list []goodsaptitudeclass.OilGoodsAptitudeClass
  141. total := svc.GetPagingEntitiesWithoutAccCode(page.CurrentPage, page.Size, orderby, asc, &list, where)
  142. var datainfo DataInfo
  143. datainfo.Items = list
  144. datainfo.CurrentItemCount = total
  145. this.Data["json"] = &datainfo
  146. this.ServeJSON()
  147. }
  148. // @Title 获取字典列表
  149. // @Description get user by token
  150. // @Success 200 {object} map[string]interface{}
  151. // @router /dictlist [get]
  152. func (this *OilSupplierCertSubController) GetDictList() {
  153. dictList := make(map[string]interface{})
  154. //dictSvc := items.GetItemsService(utils.DBE)
  155. userSvc := baseUser.GetBaseUserService(utils.DBE)
  156. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  157. //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", this.User.AccCode)
  158. var userEntity userRole.Base_User
  159. userSvc.GetEntityById(this.User.Id, &userEntity)
  160. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  161. //var dictCustomer []svccustomer.Customer
  162. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  163. //dictList["EntrustCorp"] = &dictCustomer
  164. var datainfo DataInfo
  165. datainfo.Items = dictList
  166. this.Data["json"] = &datainfo
  167. this.ServeJSON()
  168. }
  169. // @Title 获取实体
  170. // @Description 获取实体
  171. // @Success 200 {object} suppliercertsub.OilSupplierCertSub
  172. // @router /get/:id [get]
  173. func (this *OilSupplierCertSubController) GetEntity() {
  174. Id := this.Ctx.Input.Param(":id")
  175. var model suppliercertsub.OilSupplierCertSub
  176. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  177. svc.GetEntityByIdBytbl(OilSupplierCertSubName, Id, &model)
  178. this.Data["json"] = &model
  179. this.ServeJSON()
  180. }
  181. // @Title 添加
  182. // @Description 新增
  183. // @Success 200 {object} controllers.Request
  184. // @router /add [post]
  185. func (this *OilSupplierCertSubController) AddEntity() {
  186. var model suppliercertsub.OilSupplierCertSub
  187. var jsonBlob = this.Ctx.Input.RequestBody
  188. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  189. json.Unmarshal(jsonBlob, &model)
  190. model.CreateOn = time.Now()
  191. model.CreateBy = this.User.Realname
  192. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  193. //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  194. _, err := svc.InsertEntityBytbl(OilSupplierCertSubName, &model)
  195. var errinfo ErrorDataInfo
  196. if err == nil {
  197. //新增
  198. errinfo.Message = "添加成功!"
  199. errinfo.Code = 0
  200. errinfo.Item = model.Id
  201. this.Data["json"] = &errinfo
  202. this.ServeJSON()
  203. } else {
  204. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  205. errinfo.Code = -1
  206. this.Data["json"] = &errinfo
  207. this.ServeJSON()
  208. }
  209. }
  210. // @Title 修改实体
  211. // @Description 修改实体
  212. // @Success 200 {object} controllers.Request
  213. // @router /update/:id [post]
  214. func (this *OilSupplierCertSubController) UpdateEntity() {
  215. id := this.Ctx.Input.Param(":id")
  216. var errinfo ErrorInfo
  217. if id == "" {
  218. errinfo.Message = "操作失败!请求信息不完整"
  219. errinfo.Code = -2
  220. this.Data["json"] = &errinfo
  221. this.ServeJSON()
  222. return
  223. }
  224. var model suppliercertsub.OilSupplierCertSub
  225. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  226. var jsonBlob = this.Ctx.Input.RequestBody
  227. json.Unmarshal(jsonBlob, &model)
  228. model.ModifiedOn = time.Now()
  229. model.ModifiedBy = this.User.Realname
  230. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  231. cols := []string{
  232. "Id",
  233. "SupplierId",
  234. "SupplierCertId",
  235. "SubClassId",
  236. "Code",
  237. "Name",
  238. "Remark",
  239. "IsDelete",
  240. "CreateOn",
  241. "CreateUserId",
  242. "CreateBy",
  243. "ModifiedOn",
  244. "ModifiedUserId",
  245. "ModifiedBy",
  246. }
  247. err := svc.UpdateEntityBytbl(OilSupplierCertSubName, id, &model, cols)
  248. if err == nil {
  249. errinfo.Message = "修改成功!"
  250. errinfo.Code = 0
  251. this.Data["json"] = &errinfo
  252. this.ServeJSON()
  253. } else {
  254. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  255. errinfo.Code = -1
  256. this.Data["json"] = &errinfo
  257. this.ServeJSON()
  258. }
  259. }
  260. // @Title 删除单条信息
  261. // @Description
  262. // @Success 200 {object} ErrorInfo
  263. // @Failure 403 :id 为空
  264. // @router /delete/:Id [delete]
  265. func (this *OilSupplierCertSubController) DeleteEntity() {
  266. Id := this.Ctx.Input.Param(":Id")
  267. var errinfo ErrorInfo
  268. if Id == "" {
  269. errinfo.Message = "操作失败!请求信息不完整"
  270. errinfo.Code = -2
  271. this.Data["json"] = &errinfo
  272. this.ServeJSON()
  273. return
  274. }
  275. var model suppliercertsub.OilSupplierCertSub
  276. var entityempty suppliercertsub.OilSupplierCertSub
  277. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  278. opdesc := "删除-" + Id
  279. err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierCertSubName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
  280. if err == nil {
  281. errinfo.Message = "删除成功"
  282. errinfo.Code = 0
  283. this.Data["json"] = &errinfo
  284. this.ServeJSON()
  285. } else {
  286. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  287. errinfo.Code = -1
  288. this.Data["json"] = &errinfo
  289. this.ServeJSON()
  290. }
  291. }
  292. // @Title 批量添加准入范围--物资类
  293. // @Description 批量添加准入范围
  294. // @Success 200 {object} business.device.DeviceChannels
  295. // @router /addgoodsbus [post]
  296. func (this *OilSupplierCertSubController) AddGoodsBus() {
  297. var jsonblob = this.Ctx.Input.RequestBody
  298. var datamain suppliercertsub.OilSupplierCertSub
  299. var dataother suppliercertsub.SupplierCertSubModel
  300. json.Unmarshal(jsonblob, &datamain)
  301. json.Unmarshal(jsonblob, &dataother)
  302. var supplierCertModel suppliercert.OilSupplierCert
  303. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  304. svcCert.GetEntityById(datamain.SupplierCertId, &supplierCertModel)
  305. var supplierModel supplier.OilSupplier
  306. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  307. svcSupplier.GetEntityById(datamain.SupplierId, &supplierModel)
  308. for n := 0; n < len(dataother.CheckList); n++ {
  309. where_sub := "SupplierTypeCode = 01 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  310. where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
  311. where_sub += " and SubClassId = '" + dataother.CheckList[n].Id + "'"
  312. var model suppliercertsub.OilSupplierCertSub
  313. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  314. has := svc.GetEntityByWhere(OilSupplierCertSubName, where_sub, &model)
  315. if !has {
  316. datamain.SubClassId, _ = utils.StrTo(dataother.CheckList[n].Id).Int()
  317. datamain.Code = dataother.CheckList[n].Code
  318. datamain.Name = dataother.CheckList[n].Name
  319. datamain.GoodsLevel = dataother.CheckList[n].GoodsLevel
  320. datamain.Remark = dataother.Remark
  321. datamain.IsDelete = 0
  322. datamain.CreateBy = this.User.Realname
  323. datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  324. unitsvc := organize.GetOrganizeService(utils.DBE)
  325. unitid := unitsvc.GetMyUnitDepartmentId(this.User.DepartmentId)
  326. if unitid == "100000095" {
  327. datamain.CertSubStatus = "1"
  328. }
  329. svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
  330. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  331. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  332. needList := filesvc.GetGoodsNeedFileList(dataother.CheckList[n].Id, "2")
  333. if supplierCertModel.InStyle == "4" {
  334. var needFile supplierfile.FileList
  335. //战略合作协议扫描件
  336. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  337. needList = append(needList, needFile)
  338. }
  339. var list []supplierfile.OilSupplierFile
  340. where := "SupplierTypeCode in (01,000) and IsManuf in ('0','2') and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  341. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  342. //三证合一或五证合一不需要的字段
  343. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  344. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  345. mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  346. for i := 0; i < len(needList); i++ {
  347. var entity supplierfile.OilSupplierFile
  348. entity.SupplierId = dataother.SupplierId
  349. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  350. continue
  351. }
  352. //加入对应表OilSupplierCert2File
  353. var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
  354. cert2File.SupplierId = dataother.SupplierId
  355. cert2File.SupplierCertId = dataother.SupplierCertId
  356. cert2File.SupplierTypeCode = dataother.SupplierTypeCode
  357. cert2File.IsManuf = "2"
  358. cert2File.SubClassId, _ = utils.StrTo(dataother.CheckList[n].Id).Int()
  359. cert2File.Code = dataother.CheckList[n].Code
  360. cert2File.Name = dataother.CheckList[n].Name
  361. cert2File.NeedFileType = needList[i].FileName
  362. svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
  363. if strings.Contains(mustField, needList[i].FileName+",") {
  364. entity.SupplierTypeCode = "000"
  365. entity.IsManuf = "0"
  366. } else {
  367. entity.SupplierTypeCode = dataother.SupplierTypeCode
  368. entity.IsManuf = "2"
  369. }
  370. entity.NeedFileType = needList[i].FileName
  371. entity.FileType = 1
  372. entity.EffectDate = time.Now()
  373. entity.CreateBy = this.User.Realname
  374. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  375. entity.SupType = 1
  376. isRepeat := false
  377. for j := 0; j < len(list); j++ {
  378. if list[j].NeedFileType == needList[i].FileName {
  379. isRepeat = true
  380. break
  381. }
  382. }
  383. if isRepeat == true {
  384. continue
  385. }
  386. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  387. }
  388. }
  389. }
  390. var errinfo ErrorDataInfo
  391. errinfo.Message = "操作成功!"
  392. errinfo.Code = 0
  393. this.Data["json"] = &errinfo
  394. this.ServeJSON()
  395. }
  396. // @Title 批量添加准入范围--技术服务类
  397. // @Description 批量添加准入范围
  398. // @Success 200 {object} business.device.DeviceChannels
  399. // @router /addtechbus [post]
  400. func (this *OilSupplierCertSubController) AddTechBus() {
  401. var jsonblob = this.Ctx.Input.RequestBody
  402. var datamain suppliercertsub.OilSupplierCertSub
  403. var dataother suppliercertsub.TechnologySubModel
  404. json.Unmarshal(jsonblob, &datamain)
  405. json.Unmarshal(jsonblob, &dataother)
  406. var supplierCertModel suppliercert.OilSupplierCert
  407. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  408. svcCert.GetEntityById(datamain.SupplierCertId, &supplierCertModel)
  409. var supplierModel supplier.OilSupplier
  410. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  411. svcSupplier.GetEntityById(datamain.SupplierId, &supplierModel)
  412. for n := 0; n < len(dataother.CheckList); n++ {
  413. where_sub := "SupplierTypeCode = 03 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  414. where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
  415. where_sub += " and SubClassId = '" + strconv.Itoa(dataother.CheckList[n].Id) + "'"
  416. var model suppliercertsub.OilSupplierCertSub
  417. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  418. has := svc.GetEntityByWhere(OilSupplierCertSubName, where_sub, &model)
  419. if !has {
  420. datamain.SubClassId = dataother.CheckList[n].Id
  421. datamain.Code = dataother.CheckList[n].Code
  422. datamain.Name = dataother.CheckList[n].Name
  423. datamain.Remark = dataother.Remark
  424. datamain.IsDelete = 0
  425. datamain.CreateBy = this.User.Realname
  426. datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  427. unitsvc := organize.GetOrganizeService(utils.DBE)
  428. unitid := unitsvc.GetMyUnitDepartmentId(this.User.DepartmentId)
  429. if unitid == "100000095" {
  430. datamain.CertSubStatus = "1"
  431. }
  432. svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
  433. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  434. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  435. needList := filesvc.GetTechNeedFileList(strconv.Itoa(dataother.CheckList[n].Id))
  436. if supplierCertModel.InStyle == "4" {
  437. var needFile supplierfile.FileList
  438. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  439. needList = append(needList, needFile)
  440. }
  441. var list []supplierfile.OilSupplierFile
  442. where := "SupplierTypeCode in (03,000) and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  443. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  444. //三证合一或五证合一不需要的字段
  445. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  446. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  447. mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  448. for i := 0; i < len(needList); i++ {
  449. var entity supplierfile.OilSupplierFile
  450. entity.SupplierId = dataother.SupplierId
  451. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  452. continue
  453. }
  454. //加入对应表OilSupplierCert2File
  455. var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
  456. cert2File.SupplierId = dataother.SupplierId
  457. cert2File.SupplierCertId = dataother.SupplierCertId
  458. cert2File.SupplierTypeCode = dataother.SupplierTypeCode
  459. cert2File.SubClassId = dataother.CheckList[n].Id
  460. cert2File.Code = dataother.CheckList[n].Code
  461. cert2File.Name = dataother.CheckList[n].Name
  462. cert2File.NeedFileType = needList[i].FileName
  463. svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
  464. if strings.Contains(mustField, needList[i].FileName+",") {
  465. entity.SupplierTypeCode = "000"
  466. } else {
  467. entity.SupplierTypeCode = dataother.SupplierTypeCode
  468. }
  469. entity.NeedFileType = needList[i].FileName
  470. entity.FileType = 1
  471. entity.EffectDate = time.Now()
  472. entity.CreateBy = this.User.Realname
  473. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  474. entity.SupType = 1
  475. isRepeat := false
  476. for j := 0; j < len(list); j++ {
  477. if list[j].NeedFileType == needList[i].FileName {
  478. isRepeat = true
  479. break
  480. }
  481. }
  482. if isRepeat == true {
  483. continue
  484. }
  485. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  486. }
  487. }
  488. }
  489. var errinfo ErrorDataInfo
  490. errinfo.Message = "操作成功!"
  491. errinfo.Code = 0
  492. this.Data["json"] = &errinfo
  493. this.ServeJSON()
  494. }
  495. // @Title 新增准入范围
  496. // @Description 新增准入范围
  497. // @Success 200 {object} controllers.Request
  498. // @router /addbusiness [post]
  499. func (this *OilSupplierCertSubController) AddBusiness() {
  500. var model suppliercertsub.OilSupplierCertSub
  501. var err error
  502. var jsonblob = this.Ctx.Input.RequestBody
  503. json.Unmarshal(jsonblob, &model)
  504. model.CreateBy = this.User.Realname
  505. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  506. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  507. var submodel suppliercertsub.OilSupplierCertSub
  508. where_certsub := " SupplierCertId = " + utils.ToStr(model.SupplierCertId) + " and SupplierTypeCode = 02"
  509. where_certsub += " and SubClassId = '" + utils.ToStr(model.SubClassId) + "'"
  510. has := svc.GetEntityByWhere(OilSupplierCertSubName, where_certsub, &submodel)
  511. unitsvc := organize.GetOrganizeService(utils.DBE)
  512. unitid := unitsvc.GetMyUnitDepartmentId(this.User.DepartmentId)
  513. if !has {
  514. //添加到准入分类表中
  515. if unitid == "100000095" {
  516. model.CertSubStatus = "1"
  517. }
  518. _, err = svc.InsertEntityBytbl(OilSupplierCertSubName, &model)
  519. } else {
  520. model.Id = submodel.Id
  521. }
  522. var supplierCertModel suppliercert.OilSupplierCert
  523. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  524. svcCert.GetEntityById(model.SupplierCertId, &supplierCertModel)
  525. var supplierModel supplier.OilSupplier
  526. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  527. svcSupplier.GetEntityById(model.SupplierId, &supplierModel)
  528. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  529. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  530. var needList []supplierfile.FileList
  531. if model.SupplierTypeCode == "01" {
  532. // needList = filesvc.GetGoodsNeedFileList(model.SubClassId)
  533. } else if model.SupplierTypeCode == "02" {
  534. needList = filesvc.GetBasicNeedFileList(strconv.Itoa(model.SubClassId))
  535. } else {
  536. // needList = filesvc.GetTechNeedFileList(model.SubClassId)
  537. }
  538. if supplierCertModel.InStyle == "4" {
  539. var needFile supplierfile.FileList
  540. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  541. needList = append(needList, needFile)
  542. }
  543. if err == nil {
  544. var list []supplierfile.OilSupplierFile
  545. where := "SupplierTypeCode in (02,000) and SupplierId = '" + strconv.Itoa(model.SupplierId) + "'"
  546. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  547. //三证合一或五证合一不需要的字段
  548. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  549. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  550. mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  551. for i := 0; i < len(needList); i++ {
  552. var entity supplierfile.OilSupplierFile
  553. entity.SupplierId = model.SupplierId
  554. //加入对应表OilSupplierCert2File
  555. var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
  556. cert2File.SupplierId = model.SupplierId
  557. cert2File.SupplierCertId = model.SupplierCertId
  558. cert2File.SupplierTypeCode = model.SupplierTypeCode
  559. cert2File.SubClassId = model.SubClassId
  560. cert2File.Code = model.Code
  561. cert2File.Name = model.Name
  562. cert2File.NeedFileType = needList[i].FileName
  563. svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
  564. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  565. continue
  566. }
  567. if strings.Contains(mustField, needList[i].FileName+",") {
  568. entity.SupplierTypeCode = "000"
  569. } else {
  570. entity.SupplierTypeCode = model.SupplierTypeCode
  571. }
  572. entity.NeedFileType = needList[i].FileName
  573. entity.FileType = 1
  574. entity.EffectDate = time.Now()
  575. entity.CreateBy = this.User.Realname
  576. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  577. entity.SupType = 1
  578. isRepeat := false
  579. for j := 0; j < len(list); j++ {
  580. if list[j].NeedFileType == needList[i].FileName {
  581. isRepeat = true
  582. break
  583. }
  584. }
  585. if isRepeat == true {
  586. continue
  587. }
  588. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  589. }
  590. }
  591. var errinfo ErrorDataInfo
  592. if err == nil {
  593. errinfo.Message = "操作成功!"
  594. errinfo.Code = 0
  595. errinfo.Item = model.Id
  596. this.Data["json"] = &errinfo
  597. this.ServeJSON()
  598. } else {
  599. errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
  600. errinfo.Code = -1
  601. this.Data["json"] = &errinfo
  602. this.ServeJSON()
  603. }
  604. }
  605. // @Title 删除准入范围
  606. // @Description
  607. // @Success 200 {object} ErrorInfo
  608. // @Failure 403 :id 为空
  609. // @router /businessdelete/:Id [delete]
  610. func (this *OilSupplierCertSubController) BusinessDelete() {
  611. Id := this.Ctx.Input.Param(":Id")
  612. //SupplierCertId := this.GetString("SupplierCertId")
  613. SupplierId := this.GetString("SupplierId")
  614. SupplierTypeCode := this.GetString("SupplierTypeCode")
  615. var IsManufacturer string
  616. var errinfo ErrorInfo
  617. if Id == "" {
  618. errinfo.Message = "操作失败!请求信息不完整"
  619. errinfo.Code = -2
  620. this.Data["json"] = &errinfo
  621. this.ServeJSON()
  622. return
  623. }
  624. Ids := strings.Split(Id, ",")
  625. //根据Id查出OilSupplierCertSub的SubClassId
  626. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE) //获得数据库引擎
  627. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  628. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  629. //
  630. var CertSublList []suppliercertsub.OilSupplierCertSub
  631. where := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode // 没有删除的准入范围
  632. svc.GetEntities(&CertSublList, where)
  633. SubClassIds := ""
  634. for _, CertSub := range CertSublList {
  635. SubClassIds += strconv.Itoa(CertSub.SubClassId) + ","
  636. }
  637. var SurplusList []supplierfile.FileList
  638. SubClassIds = strings.Trim(SubClassIds, ",")
  639. if SubClassIds != "" {
  640. if SupplierTypeCode == "01" {
  641. //SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds, IsManufacturer)
  642. } else if SupplierTypeCode == "02" {
  643. SurplusList = filesvc.GetBasicNeedFileList(SubClassIds)
  644. } else if SupplierTypeCode == "03" {
  645. SurplusList = filesvc.GetTechNeedFileList(SubClassIds)
  646. }
  647. }
  648. fileNames := ""
  649. for _, CertSub := range SurplusList {
  650. fileNames += CertSub.FileName + ","
  651. }
  652. for i := 0; i < len(Ids); i++ {
  653. IsManufacturer = filesvc.CheckIsManuf(Ids[i])
  654. if SubClassIds != "" {
  655. if SupplierTypeCode == "01" {
  656. var CertSublList2 []suppliercertsub.OilSupplierCertSub
  657. wheregood := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode + " and IsManufacturer =" + IsManufacturer // 没有删除的准入范围
  658. svc.GetEntities(&CertSublList2, wheregood)
  659. SubClassIds2 := ""
  660. for _, CertSub := range CertSublList2 {
  661. SubClassIds2 += strconv.Itoa(CertSub.SubClassId) + ","
  662. }
  663. SubClassIds2 = strings.Trim(SubClassIds2, ",")
  664. SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds2, IsManufacturer)
  665. }
  666. }
  667. if fileNames == "" {
  668. for _, CertSub := range SurplusList {
  669. fileNames += CertSub.FileName + ","
  670. }
  671. }
  672. var datamain suppliercertsub.OilSupplierCertSub //创建OilSupplierCertSub结构体(映射用)
  673. var datamain2 []suppliercertsub.OilSupplierCertSub //空的查询用
  674. where := " Id= " + Ids[i]
  675. svc.GetEntity(&datamain, where) //根据Id查找,映射结构体
  676. //再根据企业id查找这个企业有几个准入范围(如果只有一个准入范围了,基本资质也删除)
  677. supplierId := datamain.SupplierId
  678. where = "SupplierId=" + strconv.Itoa(supplierId)
  679. svc.GetEntities(&datamain2, where)
  680. flag := 0
  681. if len(datamain2) == 1 {
  682. flag = 1
  683. }
  684. subClassId := datamain.SubClassId //4.拿到结构体中的准入范围SubClassId
  685. //根据SubClassId查出此准入范围所拥有的资质名称
  686. var needList []supplierfile.FileList //定义存储所拥有资质名称的数组
  687. if datamain.SupplierTypeCode == "01" {
  688. needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), IsManufacturer) //通过准入范围Id获得资质名称并填充数组
  689. } else if datamain.SupplierTypeCode == "02" {
  690. needList = filesvc.GetBasicNeedFileList(strconv.Itoa(subClassId))
  691. } else {
  692. needList = filesvc.GetTechNeedFileList(strconv.Itoa(subClassId))
  693. }
  694. var mustField string
  695. mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName") //必需的资质
  696. //根据企业ID(SupplierId)和此准入范围所拥有的资质名称删除OilSupplierFile表中对应的资质
  697. for j := 0; j < len(needList); j++ { //循环遍历资质名称数组,逐条删除
  698. if flag == 0 && strings.Contains(mustField, needList[j].FileName+",") {
  699. continue
  700. }
  701. if flag == 0 && strings.Contains(fileNames, needList[j].FileName+",") {
  702. continue
  703. }
  704. if datamain.SupplierTypeCode == "01" {
  705. where = " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and IsManuf='" + IsManufacturer + "' and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
  706. } else {
  707. where = " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
  708. }
  709. err := svc.DeleteEntityBytbl(OilSupplierFileName, where) //删除第j条资质数据
  710. if err == nil {
  711. errinfo.Message = "删除成功"
  712. errinfo.Code = 0
  713. this.Data["json"] = &errinfo
  714. this.ServeJSON()
  715. } else {
  716. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  717. errinfo.Code = -1
  718. this.Data["json"] = &errinfo
  719. this.ServeJSON()
  720. }
  721. }
  722. where = " SupplierId=" + strconv.Itoa(datamain.SupplierId) + " and SupplierTypeCode =" + SupplierTypeCode + " and SubClassId=" + strconv.Itoa(subClassId)
  723. err1 := svc.DeleteEntityBytbl(OilSupplierCert2FileName, where)
  724. if err1 == nil {
  725. errinfo.Message = "删除成功"
  726. errinfo.Code = 0
  727. this.Data["json"] = &errinfo
  728. this.ServeJSON()
  729. } else {
  730. errinfo.Message = "删除失败!" + utils.AlertProcess(err1.Error())
  731. errinfo.Code = -1
  732. this.Data["json"] = &errinfo
  733. this.ServeJSON()
  734. }
  735. where = " Id= " + Ids[i] + " and SupplierTypeCode =" + SupplierTypeCode
  736. err2 := svc.DeleteEntityBytbl(OilSupplierCertSubName, where) //删除OilSupplierCertSub单条准入范围
  737. if err2 == nil {
  738. errinfo.Message = "删除成功"
  739. errinfo.Code = 0
  740. this.Data["json"] = &errinfo
  741. this.ServeJSON()
  742. } else {
  743. errinfo.Message = "删除失败!" + utils.AlertProcess(err2.Error())
  744. errinfo.Code = -1
  745. this.Data["json"] = &errinfo
  746. this.ServeJSON()
  747. }
  748. }
  749. }
  750. // @Title 获取待审核业务列表
  751. // @Description get user by token
  752. // @Success 200 {object} models.Userblood
  753. // @router /auditbuslist [get]
  754. func (this *OilSupplierCertSubController) AuditbusList() {
  755. var list []suppliercertsub.OilSupplierCertSub
  756. //获取分页信息
  757. page := this.GetPageInfoForm()
  758. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  759. orderby := "CreateOn desc"
  760. Order := this.GetString("Order")
  761. Prop := this.GetString("Prop")
  762. if Order != "" && Prop != "" {
  763. orderby = Prop + " " + Order
  764. }
  765. where := "1 = 1"
  766. SupplierCertId := this.GetString("SupplierCertId")
  767. if SupplierCertId != "" {
  768. where = where + " and a.SupplierCertId = '" + SupplierCertId + "'"
  769. }
  770. total, list := svc.GetWaitAuditBusinesslist(page.CurrentPage, page.Size, orderby, OilSupplierCertSubName, OilClassOrgSettingName, where)
  771. var datainfo DataInfo
  772. datainfo.Items = list
  773. datainfo.CurrentItemCount = total
  774. this.Data["json"] = &datainfo
  775. this.ServeJSON()
  776. }
  777. // @Title 获取审核意见列表
  778. // @Description 获取审核意见列表
  779. // @Success 200 {object} controllers.Request
  780. // @router /opinionlist [get]
  781. func (this *OilSupplierCertSubController) OpinionList() {
  782. SupplierCertSubId := this.GetString("SupplierCertSubId")
  783. var list []suppliercertsub.OilSupplierOpinion
  784. where := " 1 = 1 "
  785. if SupplierCertSubId != "" {
  786. where = where + " and SupplierCertSubId = '" + SupplierCertSubId + "'"
  787. }
  788. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  789. svc.GetEntitysByWhere(OilSupplierOpinionName, where, &list)
  790. var datainfo DataInfo
  791. datainfo.Items = list
  792. this.Data["json"] = &datainfo
  793. this.ServeJSON()
  794. }
  795. // @Title 新增审核意见
  796. // @Description 新增审核意见
  797. // @Success 200 {object} controllers.Request
  798. // @router /addopinion [post]
  799. func (this *OilSupplierCertSubController) AddOpinion() {
  800. var model suppliercertsub.OilSupplierOpinion
  801. var jsonblob = this.Ctx.Input.RequestBody
  802. json.Unmarshal(jsonblob, &model)
  803. model.AuditorName = this.User.Realname
  804. model.AuditorId, _ = utils.StrTo(this.User.Id).Int()
  805. model.CreateBy = this.User.Realname
  806. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  807. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  808. //where := "SupplierCertSubId=" + strconv.Itoa(model.SupplierCertSubId) + " and AuditorId= " + strconv.Itoa(model.AuditorId) + " and Status = '" + model.Status + "'"
  809. //svc.DeleteEntityBytbl(OilSupplierOpinionName, where)
  810. _, err := svc.InsertEntityBytbl(OilSupplierOpinionName, &model)
  811. var errinfo ErrorDataInfo
  812. if err == nil {
  813. errinfo.Message = "操作成功!"
  814. errinfo.Code = 0
  815. errinfo.Item = model.Id
  816. this.Data["json"] = &errinfo
  817. this.ServeJSON()
  818. } else {
  819. errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
  820. errinfo.Code = -1
  821. this.Data["json"] = &errinfo
  822. this.ServeJSON()
  823. }
  824. }
  825. // @Title 更新准入项状态
  826. // @Description
  827. // @router /updatestatus/:Id/:Status [get]
  828. func (this *OilSupplierCertSubController) UpdateStatus() {
  829. Id := this.Ctx.Input.Param(":Id")
  830. Status := this.Ctx.Input.Param(":Status")
  831. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  832. var error error
  833. if Status == "1" {
  834. _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set CertSubStatus='2' where Id=" + Id + "")
  835. } else {
  836. _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set CertSubStatus='1' where Id=" + Id + "")
  837. }
  838. var errinfo ErrorDataInfo
  839. if error == nil {
  840. errinfo.Message = "操作成功!"
  841. errinfo.Code = 0
  842. this.Data["json"] = &errinfo
  843. this.ServeJSON()
  844. } else {
  845. errinfo.Message = "操作失败!"
  846. errinfo.Code = -1
  847. this.Data["json"] = &errinfo
  848. this.ServeJSON()
  849. }
  850. }
  851. // @Title 修改是否为供应商
  852. // @Description
  853. // @router /updatemanufacturer/:Id/:SupplierId/:IsManufacturer [get]
  854. func (this *OilSupplierCertSubController) UpdateManufacturer() {
  855. Id := this.Ctx.Input.Param(":Id")
  856. IsManufacturer := this.Ctx.Input.Param(":IsManufacturer")
  857. SupplierId := this.Ctx.Input.Param(":SupplierId")
  858. SupplierTypeCode := "01"
  859. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  860. var CertSublList []suppliercertsub.OilSupplierCertSub
  861. where := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode ='" + SupplierTypeCode + "'" // 没有删除的准入范围
  862. svc.GetEntities(&CertSublList, where)
  863. var SupplierCertId int
  864. for _, CertSub := range CertSublList {
  865. SupplierCertId = CertSub.SupplierCertId
  866. }
  867. var supplierCertModel suppliercert.OilSupplierCert
  868. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  869. svcCert.GetEntityById(SupplierCertId, &supplierCertModel)
  870. var supplierModel supplier.OilSupplier
  871. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  872. svcSupplier.GetEntityById(SupplierId, &supplierModel)
  873. var error error
  874. if IsManufacturer == "2" {
  875. var errinfo ErrorInfo
  876. //根据Id查出OilSupplierCertSub的SubClassId
  877. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  878. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  879. SubClassIds := ""
  880. for _, CertSub := range CertSublList {
  881. SubClassIds += strconv.Itoa(CertSub.SubClassId) + ","
  882. }
  883. var SurplusList []supplierfile.FileList
  884. SubClassIds = strings.Trim(SubClassIds, ",")
  885. if SubClassIds != "" {
  886. if SupplierTypeCode == "01" {
  887. var CertSublList2 []suppliercertsub.OilSupplierCertSub
  888. wheregood := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode + " and IsManufacturer =" + IsManufacturer // 没有删除的准入范围
  889. svc.GetEntities(&CertSublList2, wheregood)
  890. SubClassIds2 := ""
  891. for _, CertSub := range CertSublList2 {
  892. SubClassIds2 += strconv.Itoa(CertSub.SubClassId) + ","
  893. }
  894. SubClassIds2 = strings.Trim(SubClassIds2, ",")
  895. SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds2, IsManufacturer)
  896. }
  897. }
  898. fileNames := ""
  899. for _, CertSub := range SurplusList {
  900. fileNames += CertSub.FileName + ","
  901. }
  902. var datamain suppliercertsub.OilSupplierCertSub //创建OilSupplierCertSub结构体(映射用)
  903. var datamain2 []suppliercertsub.OilSupplierCertSub //空的查询用
  904. where = " Id= " + Id
  905. svc.GetEntity(&datamain, where) //根据Id查找,映射结构体
  906. //再根据企业id查找这个企业有几个准入范围(如果只有一个准入范围了,基本资质也删除)
  907. supplierId := datamain.SupplierId
  908. where = "SupplierId=" + strconv.Itoa(supplierId)
  909. svc.GetEntities(&datamain2, where)
  910. flag := 0
  911. if len(datamain2) == 1 {
  912. flag = 1
  913. }
  914. subClassId := datamain.SubClassId //4.拿到结构体中的准入范围SubClassId
  915. //根据SubClassId查出此准入范围所拥有的资质名称
  916. var needList []supplierfile.FileList //定义存储所拥有资质名称的数组
  917. needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), IsManufacturer) //通过准入范围Id获得资质名称并填充数组
  918. var mustField string
  919. mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName") //必需的资质
  920. //根据企业ID(SupplierId)和此准入范围所拥有的资质名称删除OilSupplierFile表中对应的资质
  921. for j := 0; j < len(needList); j++ { //循环遍历资质名称数组,逐条删除
  922. if flag == 0 && strings.Contains(mustField, needList[j].FileName+",") {
  923. continue
  924. }
  925. if flag == 0 && strings.Contains(fileNames, needList[j].FileName+",") {
  926. continue
  927. }
  928. where := " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and IsManuf='" + IsManufacturer + "' and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
  929. err := svc.DeleteEntityBytbl(OilSupplierFileName, where) //删除第j条资质数据
  930. if err == nil {
  931. errinfo.Message = "删除成功"
  932. errinfo.Code = 0
  933. this.Data["json"] = &errinfo
  934. this.ServeJSON()
  935. } else {
  936. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  937. errinfo.Code = -1
  938. this.Data["json"] = &errinfo
  939. this.ServeJSON()
  940. }
  941. }
  942. needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), "1")
  943. if supplierCertModel.InStyle == "4" {
  944. var needFile supplierfile.FileList
  945. //战略合作协议扫描件
  946. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  947. needList = append(needList, needFile)
  948. }
  949. var list []supplierfile.OilSupplierFile
  950. where := "SupplierTypeCode in (01,000) and IsManuf in ('0','1') and SupplierId =" + strconv.Itoa(supplierId)
  951. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  952. //三证合一或五证合一不需要的字段
  953. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  954. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  955. mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  956. for i := 0; i < len(needList); i++ {
  957. var entity supplierfile.OilSupplierFile
  958. entity.SupplierId = supplierId
  959. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  960. continue
  961. }
  962. //加入对应表OilSupplierCertFile
  963. if strings.Contains(mustField, needList[i].FileName+",") {
  964. entity.SupplierTypeCode = "000"
  965. entity.IsManuf = "0"
  966. } else {
  967. entity.SupplierTypeCode = "01"
  968. entity.IsManuf = "1"
  969. }
  970. entity.NeedFileType = needList[i].FileName
  971. entity.FileType = 1
  972. entity.EffectDate = time.Now()
  973. entity.CreateBy = this.User.Realname
  974. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  975. entity.SupType = 1
  976. isRepeat := false
  977. for j := 0; j < len(list); j++ {
  978. if list[j].NeedFileType == needList[i].FileName {
  979. isRepeat = true
  980. break
  981. }
  982. }
  983. if isRepeat == true {
  984. continue
  985. }
  986. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  987. }
  988. _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set IsManufacturer =1 where Id=" + Id + "")
  989. } else if IsManufacturer == "1" {
  990. var errinfo ErrorInfo
  991. //根据Id查出OilSupplierCertSub的SubClassId
  992. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  993. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  994. SubClassIds := ""
  995. for _, CertSub := range CertSublList {
  996. SubClassIds += strconv.Itoa(CertSub.SubClassId) + ","
  997. }
  998. var SurplusList []supplierfile.FileList
  999. SubClassIds = strings.Trim(SubClassIds, ",")
  1000. if SubClassIds != "" {
  1001. if SupplierTypeCode == "01" {
  1002. var CertSublList2 []suppliercertsub.OilSupplierCertSub
  1003. wheregood := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode + " and IsManufacturer =" + IsManufacturer // 没有删除的准入范围
  1004. svc.GetEntities(&CertSublList2, wheregood)
  1005. SubClassIds2 := ""
  1006. for _, CertSub := range CertSublList2 {
  1007. SubClassIds2 += strconv.Itoa(CertSub.SubClassId) + ","
  1008. }
  1009. SubClassIds2 = strings.Trim(SubClassIds2, ",")
  1010. SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds2, IsManufacturer)
  1011. }
  1012. }
  1013. fileNames := ""
  1014. for _, CertSub := range SurplusList {
  1015. fileNames += CertSub.FileName + ","
  1016. }
  1017. var datamain suppliercertsub.OilSupplierCertSub //创建OilSupplierCertSub结构体(映射用)
  1018. var datamain2 []suppliercertsub.OilSupplierCertSub //空的查询用
  1019. where = " Id= " + Id
  1020. svc.GetEntity(&datamain, where) //根据Id查找,映射结构体
  1021. //再根据企业id查找这个企业有几个准入范围(如果只有一个准入范围了,基本资质也删除)
  1022. supplierId := datamain.SupplierId
  1023. where = "SupplierId=" + strconv.Itoa(supplierId)
  1024. svc.GetEntities(&datamain2, where)
  1025. flag := 0
  1026. if len(datamain2) == 1 {
  1027. flag = 1
  1028. }
  1029. subClassId := datamain.SubClassId //4.拿到结构体中的准入范围SubClassId
  1030. //根据SubClassId查出此准入范围所拥有的资质名称
  1031. var needList []supplierfile.FileList //定义存储所拥有资质名称的数组
  1032. needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), IsManufacturer) //通过准入范围Id获得资质名称并填充数组
  1033. var mustField string
  1034. mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName") //必需的资质
  1035. //根据企业ID(SupplierId)和此准入范围所拥有的资质名称删除OilSupplierFile表中对应的资质
  1036. for j := 0; j < len(needList); j++ { //循环遍历资质名称数组,逐条删除
  1037. if flag == 0 && strings.Contains(mustField, needList[j].FileName+",") {
  1038. continue
  1039. }
  1040. if flag == 0 && strings.Contains(fileNames, needList[j].FileName+",") {
  1041. continue
  1042. }
  1043. where := " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and IsManuf='" + IsManufacturer + "' and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
  1044. err := svc.DeleteEntityBytbl(OilSupplierFileName, where) //删除第j条资质数据
  1045. if err == nil {
  1046. errinfo.Message = "删除成功"
  1047. errinfo.Code = 0
  1048. this.Data["json"] = &errinfo
  1049. this.ServeJSON()
  1050. } else {
  1051. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  1052. errinfo.Code = -1
  1053. this.Data["json"] = &errinfo
  1054. this.ServeJSON()
  1055. }
  1056. }
  1057. needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), "2")
  1058. if supplierCertModel.InStyle == "4" {
  1059. var needFile supplierfile.FileList
  1060. //战略合作协议扫描件
  1061. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  1062. needList = append(needList, needFile)
  1063. }
  1064. var list []supplierfile.OilSupplierFile
  1065. where := "SupplierTypeCode in (01,000) and IsManuf in ('0','2') and SupplierId =" + strconv.Itoa(supplierId)
  1066. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  1067. //三证合一或五证合一不需要的字段
  1068. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  1069. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  1070. mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  1071. for i := 0; i < len(needList); i++ {
  1072. var entity supplierfile.OilSupplierFile
  1073. entity.SupplierId = supplierId
  1074. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  1075. continue
  1076. }
  1077. //加入对应表OilSupplierCertFile
  1078. if strings.Contains(mustField, needList[i].FileName+",") {
  1079. entity.SupplierTypeCode = "000"
  1080. entity.IsManuf = "0"
  1081. } else {
  1082. entity.SupplierTypeCode = "01"
  1083. entity.IsManuf = "2"
  1084. }
  1085. entity.NeedFileType = needList[i].FileName
  1086. entity.FileType = 1
  1087. entity.EffectDate = time.Now()
  1088. entity.CreateBy = this.User.Realname
  1089. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1090. entity.SupType = 1
  1091. isRepeat := false
  1092. for j := 0; j < len(list); j++ {
  1093. if list[j].NeedFileType == needList[i].FileName {
  1094. isRepeat = true
  1095. break
  1096. }
  1097. }
  1098. if isRepeat == true {
  1099. continue
  1100. }
  1101. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  1102. }
  1103. _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set IsManufacturer=2 where Id=" + Id + "")
  1104. }
  1105. var errinfo ErrorDataInfo
  1106. if error == nil {
  1107. errinfo.Message = "修改成功!"
  1108. errinfo.Code = 0
  1109. this.Data["json"] = &errinfo
  1110. this.ServeJSON()
  1111. } else {
  1112. errinfo.Message = "修改失败!"
  1113. errinfo.Code = -1
  1114. this.Data["json"] = &errinfo
  1115. this.ServeJSON()
  1116. }
  1117. }
  1118. // @Title 修改是否为供应商
  1119. // @Description
  1120. // @router /updatemanufacturers/:SupplierId/:IsManufacturer [get]
  1121. func (this *OilSupplierCertSubController) UpdateManufacturers() {
  1122. //Id := this.Ctx.Input.Param(":Id")
  1123. IsManufacturer := this.Ctx.Input.Param(":IsManufacturer")
  1124. SupplierId := this.Ctx.Input.Param(":SupplierId")
  1125. SupplierTypeCode := "01"
  1126. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  1127. var CertSublListAll []suppliercertsub.OilSupplierCertSub
  1128. wherea := "SupplierId=" + SupplierId + " and SupplierTypeCode='" + SupplierTypeCode + "' and IsManufacturer='1'"
  1129. svc.GetEntities(&CertSublListAll, wherea)
  1130. var error error
  1131. for _, item := range CertSublListAll {
  1132. Id := strconv.Itoa(item.Id)
  1133. var CertSublList []suppliercertsub.OilSupplierCertSub
  1134. where := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode ='" + SupplierTypeCode + "'" // 没有删除的准入范围
  1135. svc.GetEntities(&CertSublList, where)
  1136. var SupplierCertId int
  1137. for _, CertSub := range CertSublList {
  1138. SupplierCertId = CertSub.SupplierCertId
  1139. }
  1140. var supplierCertModel suppliercert.OilSupplierCert
  1141. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  1142. svcCert.GetEntityById(SupplierCertId, &supplierCertModel)
  1143. var supplierModel supplier.OilSupplier
  1144. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  1145. svcSupplier.GetEntityById(SupplierId, &supplierModel)
  1146. var errinfo ErrorInfo
  1147. //根据Id查出OilSupplierCertSub的SubClassId
  1148. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  1149. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1150. SubClassIds := ""
  1151. for _, CertSub := range CertSublList {
  1152. SubClassIds += strconv.Itoa(CertSub.SubClassId) + ","
  1153. }
  1154. var SurplusList []supplierfile.FileList
  1155. SubClassIds = strings.Trim(SubClassIds, ",")
  1156. if SubClassIds != "" {
  1157. if SupplierTypeCode == "01" {
  1158. var CertSublList2 []suppliercertsub.OilSupplierCertSub
  1159. wheregood := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode + " and IsManufacturer =" + IsManufacturer // 没有删除的准入范围
  1160. svc.GetEntities(&CertSublList2, wheregood)
  1161. SubClassIds2 := ""
  1162. for _, CertSub := range CertSublList2 {
  1163. SubClassIds2 += strconv.Itoa(CertSub.SubClassId) + ","
  1164. }
  1165. SubClassIds2 = strings.Trim(SubClassIds2, ",")
  1166. SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds2, IsManufacturer)
  1167. }
  1168. }
  1169. fileNames := ""
  1170. for _, CertSub := range SurplusList {
  1171. fileNames += CertSub.FileName + ","
  1172. }
  1173. var datamain suppliercertsub.OilSupplierCertSub //创建OilSupplierCertSub结构体(映射用)
  1174. var datamain2 []suppliercertsub.OilSupplierCertSub //空的查询用
  1175. where = " Id= " + Id
  1176. svc.GetEntity(&datamain, where) //根据Id查找,映射结构体
  1177. //再根据企业id查找这个企业有几个准入范围(如果只有一个准入范围了,基本资质也删除)
  1178. supplierId := datamain.SupplierId
  1179. where = "SupplierId=" + strconv.Itoa(supplierId)
  1180. svc.GetEntities(&datamain2, where)
  1181. flag := 0
  1182. if len(datamain2) == 1 {
  1183. flag = 1
  1184. }
  1185. subClassId := datamain.SubClassId //4.拿到结构体中的准入范围SubClassId
  1186. //根据SubClassId查出此准入范围所拥有的资质名称
  1187. var needList []supplierfile.FileList //定义存储所拥有资质名称的数组
  1188. needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), IsManufacturer) //通过准入范围Id获得资质名称并填充数组
  1189. var mustField string
  1190. mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName") //必需的资质
  1191. //根据企业ID(SupplierId)和此准入范围所拥有的资质名称删除OilSupplierFile表中对应的资质
  1192. for j := 0; j < len(needList); j++ { //循环遍历资质名称数组,逐条删除
  1193. if flag == 0 && strings.Contains(mustField, needList[j].FileName+",") {
  1194. continue
  1195. }
  1196. if flag == 0 && strings.Contains(fileNames, needList[j].FileName+",") {
  1197. continue
  1198. }
  1199. where := " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and IsManuf='" + IsManufacturer + "' and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
  1200. err := svc.DeleteEntityBytbl(OilSupplierFileName, where) //删除第j条资质数据
  1201. if err == nil {
  1202. errinfo.Message = "删除成功"
  1203. errinfo.Code = 0
  1204. this.Data["json"] = &errinfo
  1205. this.ServeJSON()
  1206. } else {
  1207. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  1208. errinfo.Code = -1
  1209. this.Data["json"] = &errinfo
  1210. this.ServeJSON()
  1211. }
  1212. }
  1213. needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), "2")
  1214. if supplierCertModel.InStyle == "4" {
  1215. var needFile supplierfile.FileList
  1216. //战略合作协议扫描件
  1217. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  1218. needList = append(needList, needFile)
  1219. }
  1220. var list []supplierfile.OilSupplierFile
  1221. where1 := "SupplierTypeCode in (01,000) and IsManuf in ('0','2') and SupplierId =" + strconv.Itoa(supplierId)
  1222. svc.GetEntitysByWhere(OilSupplierFileName, where1, &list)
  1223. //三证合一或五证合一不需要的字段
  1224. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  1225. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  1226. mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  1227. for i := 0; i < len(needList); i++ {
  1228. var entity supplierfile.OilSupplierFile
  1229. entity.SupplierId = supplierId
  1230. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  1231. continue
  1232. }
  1233. //加入对应表OilSupplierCertFile
  1234. if strings.Contains(mustField, needList[i].FileName+",") {
  1235. entity.SupplierTypeCode = "000"
  1236. entity.IsManuf = "0"
  1237. } else {
  1238. entity.SupplierTypeCode = "01"
  1239. entity.IsManuf = "2"
  1240. }
  1241. entity.NeedFileType = needList[i].FileName
  1242. entity.FileType = 1
  1243. entity.EffectDate = time.Now()
  1244. entity.CreateBy = this.User.Realname
  1245. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1246. entity.SupType = 1
  1247. isRepeat := false
  1248. for j := 0; j < len(list); j++ {
  1249. if list[j].NeedFileType == needList[i].FileName {
  1250. isRepeat = true
  1251. break
  1252. }
  1253. }
  1254. if isRepeat == true {
  1255. continue
  1256. }
  1257. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  1258. }
  1259. _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set IsManufacturer=2 where Id=" + Id + "")
  1260. }
  1261. var errinfo ErrorDataInfo
  1262. if error == nil {
  1263. errinfo.Message = "修改成功!"
  1264. errinfo.Code = 0
  1265. this.Data["json"] = &errinfo
  1266. this.ServeJSON()
  1267. } else {
  1268. errinfo.Message = "修改失败!"
  1269. errinfo.Code = -1
  1270. this.Data["json"] = &errinfo
  1271. this.ServeJSON()
  1272. }
  1273. }
  1274. type OilSupplierCert2File struct {
  1275. Id int `json:"not null pk autoincr INT(10)"`
  1276. certSubId int `json:"not null default 0 comment('供方基本信息表主键') INT(10)"`
  1277. certSubStatus int `json:"not null default 0 comment('供方准入证书信息表主键') INT(10)"`
  1278. stopReason string `json:"not null default '0' comment('准入类别代码(1 物资类,2 基建类,3 技术服务类)') VARCHAR(5)"`
  1279. }
  1280. // @Title 记录准入项状态更改日志
  1281. // @Description
  1282. // @router /updatestatuswithlog/:Id [post]
  1283. func (this *OilSupplierCertSubController) UpdateStatusWithLog() {
  1284. Id := this.Ctx.Input.Param(":Id")
  1285. reasonSvc := supplierpausereason.GetOilSupplierPauseReasonService(utils.DBE)
  1286. var pauseModel supplierpausereason.OilSupplierPauseReason
  1287. var jsonblob = this.Ctx.Input.RequestBody
  1288. json.Unmarshal(jsonblob, &pauseModel)
  1289. Status := pauseModel.CertSubStatus
  1290. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  1291. var error error
  1292. if Status == "1" {
  1293. _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set CertSubStatus='2' where Id=" + Id + "")
  1294. pauseModel.CertSubStatus = "2"
  1295. } else {
  1296. _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set CertSubStatus='1' where Id=" + Id + "")
  1297. pauseModel.CertSubStatus = "1"
  1298. }
  1299. pauseModel.CreateOn = time.Now()
  1300. pauseModel.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1301. pauseModel.CreateBy = this.User.Realname
  1302. reasonSvc.InsertEntity(pauseModel)
  1303. var errinfo ErrorDataInfo
  1304. if error == nil {
  1305. errinfo.Message = "操作成功!"
  1306. errinfo.Code = 0
  1307. this.Data["json"] = &errinfo
  1308. this.ServeJSON()
  1309. } else {
  1310. errinfo.Message = "操作失败!"
  1311. errinfo.Code = -1
  1312. this.Data["json"] = &errinfo
  1313. this.ServeJSON()
  1314. }
  1315. }