technologyservice.go 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  4. "dashoo.cn/backend/api/business/oilsupplier/supplierdataentry"
  5. "dashoo.cn/backend/api/business/oilsupplier/supplierpausereason"
  6. "dashoo.cn/backend/api/business/oilsupplier/tableheader"
  7. "dashoo.cn/backend/api/business/oilsupplier/technologyserviceclass"
  8. "dashoo.cn/backend/api/business/workflow"
  9. "encoding/json"
  10. "fmt"
  11. "github.com/tealeg/xlsx"
  12. "log"
  13. "os"
  14. "reflect"
  15. "strconv"
  16. "strings"
  17. "time"
  18. "dashoo.cn/backend/api/business/items"
  19. "dashoo.cn/backend/api/business/baseUser"
  20. "dashoo.cn/business2/userRole"
  21. "dashoo.cn/backend/api/business/oilsupplier/goodsaptitude"
  22. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  23. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  24. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  25. //"dashoo.cn/backend/api/business/items"
  26. "dashoo.cn/backend/api/business/oilsupplier/technologyservice"
  27. . "dashoo.cn/backend/api/controllers"
  28. "dashoo.cn/business2/parameter"
  29. "dashoo.cn/utils"
  30. . "github.com/linxGnu/goseaweedfs"
  31. )
  32. type OilTechnologyServiceController struct {
  33. BaseController
  34. }
  35. // @Title 获取列表
  36. // @Description get user by token
  37. // @Success 200 {object} []technologyservice.OilTechnologyService
  38. // @router /list [get]
  39. func (this *OilTechnologyServiceController) GetEntityList() {
  40. //获取分页信息
  41. page := this.GetPageInfoForm()
  42. where := " 1=1 "
  43. orderby := "Code"
  44. asc := true
  45. Order := this.GetString("Order")
  46. Prop := this.GetString("Prop")
  47. if Order != "" && Prop != "" {
  48. orderby = Prop
  49. if Order == "asc" {
  50. asc = true
  51. } else {
  52. asc = false
  53. }
  54. }
  55. CreateOn := this.GetString("CreateOn")
  56. Code := this.GetString("Code")
  57. Name := this.GetString("Name")
  58. Code1 := this.GetString("Code1")
  59. Name1 := this.GetString("Name1")
  60. Code2 := this.GetString("Code2")
  61. Name2 := this.GetString("Name2")
  62. Code3 := this.GetString("Code3")
  63. Name3 := this.GetString("Name3")
  64. Code4 := this.GetString("Code4")
  65. Name4 := this.GetString("Name4")
  66. if Code != "" {
  67. where = where + " and Code like '" + strings.Trim(Code, " ") + "%'"
  68. }
  69. if Name != "" {
  70. where = where + " and Name like '%" + strings.Trim(Name, " ") + "%'"
  71. }
  72. if Code1 != "" {
  73. where = where + " and Code1 like '%" + Code1 + "%'"
  74. }
  75. if Name1 != "" {
  76. where = where + " and Name1 like '%" + Name1 + "%'"
  77. }
  78. if Code2 != "" {
  79. where = where + " and Code2 like '%" + Code2 + "%'"
  80. }
  81. if Name2 != "" {
  82. where = where + " and Name2 like '%" + Name2 + "%'"
  83. }
  84. if Code3 != "" {
  85. where = where + " and Code3 like '%" + Code3 + "%'"
  86. }
  87. if Name3 != "" {
  88. where = where + " and Name3 like '%" + Name3 + "%'"
  89. }
  90. if Code4 != "" {
  91. where = where + " and Code4 like '%" + Code4 + "%'"
  92. }
  93. if Name4 != "" {
  94. where = where + " and Name4 like '%" + Name4 + "%'"
  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. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  105. var list []technologyservice.OilTechnologyServiceView
  106. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilTechsrvDetailViewName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  107. var datainfo DataInfo
  108. datainfo.Items = list
  109. datainfo.CurrentItemCount = total
  110. datainfo.PageIndex = page.CurrentPage
  111. datainfo.ItemsPerPage = page.Size
  112. this.Data["json"] = &datainfo
  113. this.ServeJSON()
  114. }
  115. // @Title 获取字典列表
  116. // @Description get user by token
  117. // @Success 200 {object} map[string]interface{}
  118. // @router /dictlist [get]
  119. func (this *OilTechnologyServiceController) GetDictList() {
  120. dictList := make(map[string]interface{})
  121. dictSvc := items.GetItemsService(utils.DBE)
  122. userSvc := baseUser.GetBaseUserService(utils.DBE)
  123. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  124. //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", "")
  125. var userEntity userRole.Base_User
  126. userSvc.GetEntityById(this.User.Id, &userEntity)
  127. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId("", userEntity.Departmentid)
  128. dictList["AuditStep"] = dictSvc.GetKeyValueItems("AuditStep", this.User.AccCode)
  129. //var dictCustomer []svccustomer.Customer
  130. //customerSvc.GetEntitysByWhere("" + CustomerName, "", &dictCustomer)
  131. //dictList["EntrustCorp"] = &dictCustomer
  132. var datainfo DataInfo
  133. datainfo.Items = dictList
  134. this.Data["json"] = &datainfo
  135. this.ServeJSON()
  136. }
  137. // @Title 获取实体
  138. // @Description 获取实体
  139. // @Success 200 {object} technologyservice.OilTechnologyService
  140. // @router /get/:id [get]
  141. func (this *OilTechnologyServiceController) GetEntity() {
  142. Id := this.Ctx.Input.Param(":id")
  143. var model technologyservice.OilTechnologyServiceView
  144. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  145. //svc.GetEntityByIdBytbl(""+OilTechnologyServiceName, Id, &model)
  146. where := " Id =" + Id
  147. svc.GetEntityByWhere(OilTechsrvDetailViewName, where, &model)
  148. this.Data["json"] = &model
  149. this.ServeJSON()
  150. }
  151. // @Title 添加
  152. // @Description 新增
  153. // @Success 200 {object} controllers.Request
  154. // @router /add [post]
  155. func (this *OilTechnologyServiceController) AddEntity() {
  156. //classId := this.Ctx.Input.Param(":id")
  157. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  158. var model technologyserviceclass.OilTechnologyServiceClass
  159. var classmodel technologyserviceclass.OilTechnologyServiceClass
  160. var parentedId technologyserviceclass.ParentedId
  161. var jsonBlob = this.Ctx.Input.RequestBody
  162. json.Unmarshal(jsonBlob, &parentedId)
  163. json.Unmarshal(jsonBlob, &model)
  164. var errinfo ErrorDataInfo
  165. where := " Code = " + model.Code
  166. code := svc.GetEntityByWhere(OilTechnologyServiceClassName, where, &classmodel)
  167. if code {
  168. errinfo.Message = "编码不能重复!"
  169. errinfo.Code = -1
  170. this.Data["json"] = &errinfo
  171. this.ServeJSON()
  172. return
  173. }
  174. if parentedId.ParentId == 0 {
  175. where1 := " Code = " + Substr(model.Code, 0, 2)
  176. code1 := svc.GetEntityByWhere(OilTechnologyServiceClassName, where1, &classmodel)
  177. if code1 {
  178. errinfo.Message = "请选择父节点!"
  179. errinfo.Code = -1
  180. this.Data["json"] = &errinfo
  181. this.ServeJSON()
  182. return
  183. } else {
  184. model.Code = Substr(model.Code, 0, 2)
  185. }
  186. }
  187. //where1 := " Name = " + model.Name
  188. //name := svc.GetEntityByWhere(OilGoodsAptitudeClassName, where1, &classmodel)
  189. //if name {
  190. // errinfo.Message = "名称不能重复!"
  191. // errinfo.Code = -1
  192. // this.Data["json"] = &errinfo
  193. // this.ServeJSON()
  194. // return
  195. //}
  196. model.ParentId = parentedId.ParentId
  197. model.CreateOn = time.Now()
  198. model.CreateBy = this.User.Realname
  199. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  200. _, err := svc.InsertEntityBytbl(""+OilTechnologyServiceClassName, &model)
  201. var model2 technologyservice.OilTechnologyService
  202. json.Unmarshal(jsonBlob, &model2)
  203. model2.ClassId = model.Id
  204. model2.CreateOn = time.Now()
  205. model2.CreateBy = this.User.Realname
  206. model2.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  207. _, err = svc.InsertEntityBytbl(""+OilTechnologyServiceName, &model2)
  208. if err == nil {
  209. //新增
  210. errinfo.Message = "添加成功!"
  211. errinfo.Code = 0
  212. errinfo.Item = model2.Id
  213. this.Data["json"] = &errinfo
  214. this.ServeJSON()
  215. } else {
  216. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  217. errinfo.Code = -1
  218. this.Data["json"] = &errinfo
  219. this.ServeJSON()
  220. }
  221. }
  222. // @Title 修改实体
  223. // @Description 修改实体
  224. // @Success 200 {object} controllers.Request
  225. // @router /update/:id [post]
  226. func (this *OilTechnologyServiceController) UpdateEntity() {
  227. id := this.Ctx.Input.Param(":id")
  228. var errinfo ErrorInfo
  229. if id == "" {
  230. errinfo.Message = "操作失败!请求信息不完整"
  231. errinfo.Code = -2
  232. this.Data["json"] = &errinfo
  233. this.ServeJSON()
  234. return
  235. }
  236. var model technologyservice.OilTechnologyService
  237. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  238. var jsonBlob = this.Ctx.Input.RequestBody
  239. json.Unmarshal(jsonBlob, &model)
  240. model.ModifiedOn = time.Now()
  241. model.ModifiedBy = this.User.Realname
  242. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  243. cols := []string{
  244. "Id",
  245. "Code",
  246. "Name",
  247. "Code1",
  248. "Name1",
  249. "Code2",
  250. "Name2",
  251. "Code3",
  252. "Name3",
  253. "Code4",
  254. "Name4",
  255. "OrgId",
  256. "OrgName",
  257. "F01",
  258. "F02",
  259. "F03",
  260. "F04",
  261. "F05",
  262. "F06",
  263. "F07",
  264. "F08",
  265. "F09",
  266. "F10",
  267. "F11",
  268. "F12",
  269. "F13",
  270. "F14",
  271. "F15",
  272. "F16",
  273. "F17",
  274. "F18",
  275. "F19",
  276. "F20",
  277. "F21",
  278. "F22",
  279. "F23",
  280. "F24",
  281. "F25",
  282. "F26",
  283. "F27",
  284. "F28",
  285. "F29",
  286. "F30",
  287. "F31",
  288. "F32",
  289. "F33",
  290. "F34",
  291. "F35",
  292. "F36",
  293. "F37",
  294. "F38",
  295. "F39",
  296. "F40",
  297. "F41",
  298. "F42",
  299. "F43",
  300. "F44",
  301. "F45",
  302. "F46",
  303. "F47",
  304. "F48",
  305. "F49",
  306. "F50",
  307. "F51",
  308. "F52",
  309. "F53",
  310. "F54",
  311. "F55",
  312. "F56",
  313. "F57",
  314. "F58",
  315. "F59",
  316. "F60",
  317. "F61",
  318. "F62",
  319. "Remark",
  320. "DeletionStateCode",
  321. "CreateOn",
  322. "CreateUserId",
  323. "CreateBy",
  324. "ModifiedOn",
  325. "ModifiedUserId",
  326. "ModifiedBy",
  327. }
  328. err := svc.UpdateEntityBytbl(""+OilTechnologyServiceName, id, &model, cols)
  329. if err == nil {
  330. errinfo.Message = "修改成功!"
  331. errinfo.Code = 0
  332. this.Data["json"] = &errinfo
  333. this.ServeJSON()
  334. } else {
  335. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  336. errinfo.Code = -1
  337. this.Data["json"] = &errinfo
  338. this.ServeJSON()
  339. }
  340. }
  341. // @Title 修改实体
  342. // @Description 修改实体
  343. // @Success 200 {object} controllers.Request
  344. // @router /updatecode/:id [post]
  345. func (this *OilTechnologyServiceController) UpdateCodeEntity() {
  346. var errinfo ErrorInfo
  347. var err error
  348. id := this.Ctx.Input.Param(":id")
  349. if id == "" {
  350. errinfo.Message = "操作失败!请求信息不完整"
  351. errinfo.Code = -2
  352. this.Data["json"] = &errinfo
  353. this.ServeJSON()
  354. return
  355. }
  356. var classall technologyservice.OilTechnologyClassServiceView
  357. var model technologyserviceclass.OilTechnologyServiceClass
  358. var classmodel []technologyserviceclass.OilTechnologyServiceClass
  359. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  360. var jsonBlob = this.Ctx.Input.RequestBody
  361. json.Unmarshal(jsonBlob, &classall)
  362. model.ModifiedOn = time.Now()
  363. model.ModifiedBy = this.User.Realname
  364. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  365. colsName := []string{"Name"}
  366. colsCode := []string{"Code"}
  367. //svc.GetEntityById(id, &model)
  368. var model2 technologyserviceclass.OilTechnologyServiceClass
  369. svc.GetEntityByWhere(OilTechnologyServiceClassName, "Id = "+id, &model2)
  370. if classall.Name1 != "" {
  371. where := " Name = '" + classall.Name1 + "' and Id <> " + utils.ToStr(classall.Id1)
  372. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  373. if len(classmodel) > 0 {
  374. errinfo.Message = "一级名称已存在,请重新添加!"
  375. errinfo.Code = -1
  376. this.Data["json"] = &errinfo
  377. this.ServeJSON()
  378. return
  379. } else {
  380. model.Name = classall.Name1
  381. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id1, &model, colsName)
  382. }
  383. }
  384. if classall.Name2 != "" {
  385. where := " Name = '" + classall.Name2 + "' and Id <> " + utils.ToStr(classall.Id2)
  386. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  387. if len(classmodel) > 0 {
  388. errinfo.Message = "二级名称已存在,请重新添加!"
  389. errinfo.Code = -1
  390. this.Data["json"] = &errinfo
  391. this.ServeJSON()
  392. return
  393. } else {
  394. model.Name = classall.Name2
  395. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id2, &model, colsName)
  396. if model2.Name != model.Name && classall.Name3 == "" && classall.Name4 == "" {
  397. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &model, []string{"Name"}, "SubClassId = "+id+" and SupplierTypeCode = '03' and Name = '"+model2.Name+"'")
  398. }
  399. }
  400. }
  401. if classall.Name3 != "" {
  402. where := " Name = '" + classall.Name3 + "' and Id <> " + utils.ToStr(classall.Id3)
  403. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  404. if len(classmodel) > 0 {
  405. errinfo.Message = "三级名称已存在,请重新添加!"
  406. errinfo.Code = -1
  407. this.Data["json"] = &errinfo
  408. this.ServeJSON()
  409. return
  410. } else {
  411. model.Name = classall.Name3
  412. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id3, &model, colsName)
  413. if model2.Name != model.Name && classall.Name4 == "" {
  414. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &model, []string{"Name"}, "SubClassId = "+id+" and SupplierTypeCode = '03' and Name = '"+model2.Name+"'")
  415. }
  416. }
  417. }
  418. if classall.Name4 != "" {
  419. where := " Name = '" + classall.Name4 + "' and Id <> " + utils.ToStr(classall.Id4)
  420. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  421. if len(classmodel) > 0 {
  422. errinfo.Message = "四级名称已存在,请重新添加!"
  423. errinfo.Code = -1
  424. this.Data["json"] = &errinfo
  425. this.ServeJSON()
  426. return
  427. } else {
  428. model.Name = classall.Name4
  429. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id4, &model, colsName)
  430. if model2.Name != model.Name {
  431. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &model, []string{"Name"}, "SubClassId = "+id+" and SupplierTypeCode = '03' and Name = '"+model2.Name+"'")
  432. }
  433. }
  434. }
  435. if classall.Code1 != "" {
  436. where := " Code = " + classall.Code1 + " and Id <> " + utils.ToStr(classall.Id1)
  437. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  438. if len(classmodel) > 0 {
  439. errinfo.Message = "一级编码已存在,请重新添加!"
  440. errinfo.Code = -1
  441. this.Data["json"] = &errinfo
  442. this.ServeJSON()
  443. return
  444. } else {
  445. model.Code = classall.Code1
  446. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id1, &model, colsCode)
  447. }
  448. }
  449. if classall.Code2 != "" {
  450. where := " Code = " + classall.Code2 + " and Id <> " + utils.ToStr(classall.Id2)
  451. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  452. if len(classmodel) > 0 {
  453. errinfo.Message = "二级编码已存在,请重新添加!"
  454. errinfo.Code = -1
  455. this.Data["json"] = &errinfo
  456. this.ServeJSON()
  457. return
  458. } else {
  459. model.Code = classall.Code2
  460. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id2, &model, colsCode)
  461. }
  462. }
  463. if classall.Code3 != "" {
  464. where := " Code = " + classall.Code3 + " and Id <> " + utils.ToStr(classall.Id3)
  465. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  466. if len(classmodel) > 0 {
  467. errinfo.Message = "三级编码已存在,请重新添加!"
  468. errinfo.Code = -1
  469. this.Data["json"] = &errinfo
  470. this.ServeJSON()
  471. return
  472. } else {
  473. model.Code = classall.Code3
  474. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id3, &model, colsCode)
  475. }
  476. }
  477. if classall.Code4 != "" {
  478. where := " Code = " + classall.Code4 + " and Id <> " + utils.ToStr(classall.Id4)
  479. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel)
  480. if len(classmodel) > 0 {
  481. errinfo.Message = "四级编码已存在,请重新添加!"
  482. errinfo.Code = -1
  483. this.Data["json"] = &errinfo
  484. this.ServeJSON()
  485. return
  486. } else {
  487. model.Code = classall.Code4
  488. err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id4, &model, colsCode)
  489. }
  490. }
  491. if err == nil {
  492. errinfo.Message = "修改成功!"
  493. errinfo.Code = 0
  494. this.Data["json"] = &errinfo
  495. this.ServeJSON()
  496. } else {
  497. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  498. errinfo.Code = -1
  499. this.Data["json"] = &errinfo
  500. this.ServeJSON()
  501. }
  502. }
  503. // @Title 删除单条信息
  504. // @Description
  505. // @Success 200 {object} ErrorInfo
  506. // @Failure 403 :id 为空
  507. // @router /delete/:Id [delete]
  508. func (this *OilTechnologyServiceController) DeleteEntity() {
  509. Id := this.Ctx.Input.Param(":Id")
  510. var errinfo ErrorInfo
  511. if Id == "" {
  512. errinfo.Message = "操作失败!请求信息不完整"
  513. errinfo.Code = -2
  514. this.Data["json"] = &errinfo
  515. this.ServeJSON()
  516. return
  517. }
  518. var model technologyservice.OilTechnologyService
  519. var entityempty technologyservice.OilTechnologyService
  520. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  521. svc.GetEntityById(Id, &model)
  522. opdesc := "删除-" + Id
  523. err := svc.DeleteOperationAndWriteLogBytbl(""+OilTechnologyServiceName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "服务类准入范围子表删除")
  524. var model1 technologyserviceclass.OilTechnologyServiceClass
  525. var entityempty1 technologyserviceclass.OilTechnologyServiceClass
  526. svc1 := technologyserviceclass.GetOilTechnologyServiceClassService(utils.DBE)
  527. opdesc1 := "删除-" + strconv.Itoa(model.ClassId)
  528. err1 := svc1.DeleteOperationAndWriteLogBytbl(""+OilTechnologyServiceClassName, BaseOperationLogName, strconv.Itoa(model.ClassId), &model1, &entityempty1, utils.ToStr(this.User.Id), this.User.Username, opdesc1, "", "服务类准入范围删除")
  529. if err == nil && err1 == nil {
  530. errinfo.Message = "删除成功"
  531. errinfo.Code = 0
  532. this.Data["json"] = &errinfo
  533. this.ServeJSON()
  534. } else {
  535. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  536. errinfo.Code = -1
  537. this.Data["json"] = &errinfo
  538. this.ServeJSON()
  539. }
  540. }
  541. // @Title get 业务列表
  542. // @Description get SampleType by token
  543. // @Success 200 {object} sampletype.SampleType
  544. // @router /techbuslist [get]
  545. func (this *OilTechnologyServiceController) TechbusList() {
  546. keyword := this.GetString("keyword")
  547. where := " 1 = 1 "
  548. if keyword != "" {
  549. where = where + " and Code like '%" + keyword + "%' or Name like '%" + keyword + "%'"
  550. }
  551. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  552. var list []technologyservice.TechnologyBusiness
  553. //获取技术服务类资质分类层级信息
  554. list = svc.GetTechList(OilTechnologyServiceClassName, where)
  555. var datainfo DataInfo
  556. datainfo.Items = list
  557. this.Data["json"] = &datainfo
  558. this.ServeJSON()
  559. }
  560. //// @Title get 业务列表
  561. //// @Description get SampleType by token
  562. //// @Success 200 {object} sampletype.SampleType
  563. //// @router /needfilelist [get]
  564. //func (this *OilTechnologyServiceController) NeedFileList() {
  565. // svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  566. // where := " 1 = 1 "
  567. // ClassId := this.GetString("ClassId")
  568. // if ClassId != "" {
  569. // where = where + " and ClassId ='" + ClassId + "' "
  570. // }
  571. // var model technologyservice.OilTechnologyService
  572. // svc.GetEntityByWhere(OilTechnologyServiceName, where, &model)
  573. // var datainfo DataInfo
  574. // datainfo.Items = model
  575. // this.Data["json"] = &datainfo
  576. // this.ServeJSON()
  577. //}
  578. // @Title 获取Code
  579. // @Description 根据Id获取Code
  580. // @Success 200 {object} technologyservice.TechnologyBusiness
  581. // @router /getcode/:id [get]
  582. func (this *OilTechnologyServiceController) GetCodeById() {
  583. Id := this.Ctx.Input.Param(":id")
  584. where := " 1 = 1 "
  585. if Id != "" {
  586. where = where + " and Id = " + Id
  587. }
  588. var list []technologyservice.TechnologyBusiness
  589. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  590. svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &list)
  591. var datainfo DataInfo
  592. datainfo.Items = list
  593. this.Data["json"] = &datainfo
  594. this.ServeJSON()
  595. }
  596. // @Title get 导出ex
  597. // @Description get SampleType by token
  598. // @Success 200 {object} sampletype.SampleType
  599. // @router /exportexcelall [get]
  600. func (this *OilTechnologyServiceController) ExportExcelAll() {
  601. //获取分页信息
  602. where := " 1=1 "
  603. orderby := "Code"
  604. asc := true
  605. Order := this.GetString("Order")
  606. Prop := this.GetString("Prop")
  607. if Order != "" && Prop != "" {
  608. orderby = Prop
  609. if Order == "asc" {
  610. asc = true
  611. } else {
  612. asc = false
  613. }
  614. }
  615. t := time.Now()
  616. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  617. var list []technologyservice.OilTechnologyServiceView
  618. svc.GetMyPagingEntitiesWithOrderBytbl(OilTechsrvDetailViewName, 0, 0, orderby, asc, &list, where)
  619. var title []string
  620. filetitle := "服务类"
  621. //自定义显示列
  622. showcolumnarr := this.GetString("showcolumnarr")
  623. showcolumnnamearr := this.GetString("showcolumnnamearr")
  624. titlestring := showcolumnnamearr
  625. title = strings.Split(titlestring, ",")
  626. f := xlsx.NewFile()
  627. sheet, _ := f.AddSheet(filetitle)
  628. cellname := strings.Split(showcolumnarr, ",")
  629. row := sheet.AddRow()
  630. row.WriteSlice(&cellname, -1)
  631. for _, item := range list {
  632. var enumModel technologyservice.OilTechnologyServiceView
  633. tmpModel := &item
  634. enumModel = *tmpModel
  635. immumodel := reflect.ValueOf(&enumModel)
  636. elem := immumodel.Elem()
  637. row := sheet.AddRow()
  638. for _, name := range title {
  639. cell := row.AddCell()
  640. if strings.HasPrefix(name, "F") {
  641. var val = elem.FieldByName(name).String()
  642. if val == "1" {
  643. cell.Value = "是"
  644. } else {
  645. cell.Value = ""
  646. }
  647. } else {
  648. cell.Value = elem.FieldByName(name).String()
  649. }
  650. }
  651. }
  652. for c, cl := 0, len(sheet.Cols); c < cl; c++ {
  653. sheet.Cols[c].Width = 20
  654. }
  655. dir := "static/file/excel/report/" + this.GetAccode()
  656. SaveDirectory(dir)
  657. path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
  658. f.Save(path)
  659. var sw *Seaweed
  660. var filer []string
  661. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  662. filer = []string{_filer}
  663. }
  664. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  665. _, _, fID, _ := sw.UploadFile(path, "", "")
  666. retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  667. os.Remove(path)
  668. fmt.Println("==retDocWatermarkUrl==", retDocUrl)
  669. this.Data["json"] = retDocUrl
  670. this.ServeJSON()
  671. elapsed := time.Since(t)
  672. fmt.Println(elapsed)
  673. }
  674. // @Title get 导出ex
  675. // @Description get SampleType by token
  676. // @Success 200 {object} sampletype.SampleType
  677. // @router /export-new [get]
  678. func (this *OilTechnologyServiceController) ExportAptitudeExcelByJava() {
  679. //获取分页信息
  680. where := " 1=1 "
  681. orderby := "Code"
  682. asc := true
  683. Order := this.GetString("Order")
  684. Prop := this.GetString("Prop")
  685. if Order != "" && Prop != "" {
  686. orderby = Prop
  687. if Order == "asc" {
  688. asc = true
  689. } else {
  690. asc = false
  691. }
  692. }
  693. var titleCode []string
  694. //自定义显示列
  695. showColumnArr := this.GetString("showcolumnarr")
  696. titleName := strings.Split(showColumnArr, ",")
  697. showColumnNameArr := this.GetString("showcolumnnamearr")
  698. titleString := showColumnNameArr
  699. titleCode = strings.Split(titleString, ",")
  700. //t := time.Now()
  701. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  702. var list []technologyservice.OilTechnologyServiceView
  703. svc.GetMyPagingEntitiesWithOrderBytbl(OilTechsrvDetailViewName, 0, 0, orderby, asc, &list, where)
  704. var listRes []technologyservice.OilTechnologyServiceViewVM
  705. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  706. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  707. mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  708. for _, item := range list {
  709. var enumModel technologyservice.OilTechnologyServiceView
  710. var itemTmp technologyservice.OilTechnologyServiceViewVM
  711. tmpModel := &item
  712. enumModel = *tmpModel
  713. immuModel := reflect.ValueOf(&enumModel)
  714. elem := immuModel.Elem()
  715. allNeedAptitude := ""
  716. for i := 0; i < len(titleCode); i++ {
  717. code := titleCode[i]
  718. name := titleName[i]
  719. if !strings.Contains(mustField, name) {
  720. if strings.HasPrefix(code, "F") {
  721. var val = elem.FieldByName(code).String()
  722. if val == "1" {
  723. if allNeedAptitude == "" {
  724. allNeedAptitude = titleName[i]
  725. } else {
  726. allNeedAptitude = allNeedAptitude + "," + titleName[i]
  727. }
  728. }
  729. } else {
  730. fmt.Println("没了")
  731. }
  732. }
  733. }
  734. itemTmp.Code1 = item.Code1
  735. itemTmp.Name1 = item.Name1
  736. itemTmp.Code2 = item.Code2
  737. itemTmp.Name2 = item.Name2
  738. itemTmp.Code3 = item.Code3
  739. itemTmp.Name3 = item.Name3
  740. itemTmp.Code4 = item.Code4
  741. itemTmp.Name4 = item.Name4
  742. itemTmp.OrgName = item.OrgName
  743. itemTmp.AllNeedApName = allNeedAptitude
  744. listRes = append(listRes, itemTmp)
  745. }
  746. fileName := "服务类资质配置导出表.xlsx"
  747. Url := utils.Cfg.MustValue("workflow", "AptitudeExcel")
  748. var dataMap = make(map[string]interface{})
  749. dataMap["data"] = listRes
  750. svcActiviti := workflow.GetActivitiService(utils.DBE)
  751. retDocUrl := svcActiviti.ExportAptitudeExcel(dataMap, "2", Url, fileName)
  752. var dataInfo ErrorDataInfo
  753. dataInfo.Code = 0
  754. dataInfo.Item = retDocUrl
  755. dataInfo.Message = "导出成功"
  756. this.Data["json"] = &dataInfo
  757. this.ServeJSON()
  758. }
  759. // @Title 获取所有
  760. // @Description
  761. // @Success 200 {object}
  762. // @router /getcompanylist [post]
  763. func (this *OilTechnologyServiceController) GetTList() {
  764. var model supplier.OilSupplierSelect
  765. var model1 supplier.RegCapitalRange //注册资金范围
  766. //var model2 supplier.NeedFileTypeStruct //资质结构体
  767. var jsonBlob = this.Ctx.Input.RequestBody
  768. json.Unmarshal(jsonBlob, &model)
  769. json.Unmarshal(jsonBlob, &model1)
  770. //json.Unmarshal(jsonBlob, &model2)
  771. // //获取分页信息
  772. page := this.GetPageInfoForm()
  773. where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' and b.SupplierTypeCode = '03' AND t.SupplierId IS NOT NULL "
  774. orderby := "a.Id"
  775. asc := true
  776. Order := this.GetString("Order")
  777. Prop := this.GetString("Prop")
  778. CheckUId := this.GetString("CheckUId")
  779. FullId := this.GetString("FullId")
  780. if Order != "" && Prop != "" {
  781. orderby = Prop
  782. if Order == "desc" {
  783. asc = false
  784. }
  785. }
  786. leftjoin := ""
  787. //准入证号
  788. if model.AccessCardNo != "" {
  789. where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
  790. }
  791. //企业名称
  792. if model.SupplierName != "" {
  793. where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
  794. }
  795. if model.OldSupplierName != "" {
  796. where = where + " and OldSupplierName like '%" + model.OldSupplierName + "%'"
  797. }
  798. if FullId != "" {
  799. where = where + " and f.Id = '" + FullId + "'"
  800. }
  801. if CheckUId != "" {
  802. where = where + " and g.CheckUnitId = '" + CheckUId + "'"
  803. }
  804. //准入标识 1 准入 2 暂停 3取消
  805. if model.InFlag != "" {
  806. where = where + " and b.InFlag = '" + model.InFlag + "'"
  807. }
  808. //法人
  809. if model.LegalPerson != "" {
  810. where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
  811. }
  812. //联系人
  813. if model.ContactName != "" {
  814. where = where + " and a.ContactName like '%" + model.ContactName + "%'"
  815. }
  816. //统一社会信用代码
  817. if model.CommercialNo != "" {
  818. where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
  819. }
  820. //开户银行
  821. if model.DepositBank != "" {
  822. where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
  823. }
  824. //HSE审查
  825. if model.HseTraining != "" {
  826. where = where + " and a.HseTraining = '" + model.HseTraining + "'"
  827. }
  828. //公司类型
  829. if model.CompanyType != "" {
  830. where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
  831. }
  832. //成立时间
  833. SetupTime := this.GetString("SetupTime")
  834. if SetupTime != "" {
  835. where = where + " and a.SetupTime ='" + SetupTime + "'"
  836. }
  837. //注册资金范围
  838. if model1.RegCapital1 != "" {
  839. where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
  840. }
  841. if model1.RegCapital2 != "" {
  842. where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
  843. }
  844. //注册省份
  845. if model.Province != "" {
  846. where = where + " and a.Province = '" + model.Province + "'"
  847. }
  848. //注册市
  849. if model.City != "" {
  850. where = where + " and a.City = '" + model.City + "'"
  851. }
  852. //注册区
  853. if model.Street != "" {
  854. where = where + " and a.Street = '" + model.Street + "'"
  855. }
  856. //注册详细地址
  857. if model.Address != "" {
  858. where = where + " and a.Address like '%" + model.Address + "%'"
  859. }
  860. if model.LinkProvince != "" {
  861. where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
  862. }
  863. if model.LinkCity != "" {
  864. where = where + " and a.LinkCity = '" + model.LinkCity + "'"
  865. }
  866. if model.LinkStreet != "" {
  867. where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
  868. }
  869. if model.LinkAddress != "" {
  870. where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
  871. }
  872. //营业范围
  873. if model.BusinessScope != "" {
  874. where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
  875. }
  876. CreateOn := this.GetString("CreateOn")
  877. if CreateOn != "" {
  878. dates := strings.Split(CreateOn, ",")
  879. if len(dates) == 2 {
  880. minDate := dates[0]
  881. maxDate := dates[1]
  882. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  883. }
  884. }
  885. a := model.InStyle
  886. fmt.Println(a)
  887. //准入方式
  888. if model.InStyle != "" {
  889. if model.InStyle == "0" {
  890. where = where + " and b.InStyle in ('2','3','4','5')"
  891. } else {
  892. where = where + " and b.InStyle ='" + model.InStyle + "'"
  893. }
  894. }
  895. having := ""
  896. //准入范围
  897. if model.CerSubName != "" {
  898. having = " having CerSubName like '%" + model.CerSubName + "%' "
  899. leftjoin = "left join " + OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  900. }
  901. //资质
  902. if model.NeedFileType != "" {
  903. having = " having NeedFileType like '%" + model.NeedFileType + "%' "
  904. }
  905. if model.CerSubName != "" && model.NeedFileType != "" {
  906. having = " having CerSubName like '%" + model.CerSubName + "%' and NeedFileType like '%" + model.NeedFileType + "%' "
  907. leftjoin = "left join " + OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
  908. }
  909. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  910. var list []supplier.OilSupplierSelect
  911. total := svc.GetMyPagingDelEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
  912. OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where, having, leftjoin)
  913. var datainfo DataInfo
  914. datainfo.Items = list
  915. datainfo.CurrentItemCount = total
  916. datainfo.PageIndex = page.CurrentPage
  917. datainfo.ItemsPerPage = page.Size
  918. this.Data["json"] = &datainfo
  919. this.ServeJSON()
  920. }
  921. // @Title 删除不符合的的准入项
  922. // @Description get user by token
  923. // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
  924. // @router /deltmpsuppliercertsub [get]
  925. func (this *OilTechnologyServiceController) DelTmpSupplierCertSub() {
  926. var err error
  927. session := utils.DBE.NewSession()
  928. session.Begin()
  929. defer session.Close()
  930. supplierId := this.GetString("SupplierId")
  931. id := this.GetString("Id")
  932. svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
  933. var supplierCertSubList []suppliercertsub.Tmp_OilSupplierCertSub
  934. wheredel := "1=1 and SupplierTypeCode = '03'"
  935. if supplierId != "" {
  936. wheredel += " and SupplierId=" + supplierId
  937. }
  938. if id != "" {
  939. wheredel += " and Id=" + id
  940. }
  941. svc.GetEntitysByWhere(TmpOilSupplierCertSubName, wheredel, &supplierCertSubList)
  942. var errinfo ErrorInfo
  943. for _, item := range supplierCertSubList {
  944. where := "Id = " + strconv.Itoa(item.Id)
  945. err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
  946. if err != nil {
  947. session.Rollback()
  948. errinfo.Code = -1
  949. errinfo.Message = "删除失败!"
  950. this.Data["json"] = &errinfo
  951. this.ServeJSON()
  952. }
  953. }
  954. for _, item := range supplierCertSubList {
  955. where := "Id = " + strconv.Itoa(item.Id)
  956. err = svc.DeleteEntityBytbl(TmpOilSupplierCertSubName, where)
  957. }
  958. if err == nil {
  959. session.Commit()
  960. errinfo.Code = 0
  961. errinfo.Message = "删除成功!"
  962. this.Data["json"] = &errinfo
  963. this.ServeJSON()
  964. } else {
  965. session.Rollback()
  966. errinfo.Code = -1
  967. errinfo.Message = "删除失败!"
  968. this.Data["json"] = &errinfo
  969. this.ServeJSON()
  970. }
  971. }
  972. // @Title 修改资质后找出不符合的准入
  973. // @Description 修改实体
  974. // @Success 200 {object} controllers.Request
  975. // @router /findinconformity [post]
  976. func (this *OilTechnologyServiceController) FindInconformity() {
  977. var errinfo ErrorInfo
  978. var err error
  979. var model technologyservice.OilTechnologyServiceAndCode
  980. var companygoodslist []suppliercertsub.OilSupplierCertSub
  981. var companygood suppliercertsub.OilSupplierCertSub
  982. var SurplusList []supplierfile.FileList
  983. var supfilemodel []supplierfile.OilSupplierFile
  984. var supfilemodel01 []supplierfile.OilSupplierFile
  985. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  986. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  987. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  988. var jsonBlob = this.Ctx.Input.RequestBody
  989. json.Unmarshal(jsonBlob, &model)
  990. Code := model.Code
  991. where := " Code ='" + Code + "' and Type in ('1','3') and SupplierTypeCode = '03'"
  992. svc.FindGoodsByCode("OilSupplierCertSub", where, &companygoodslist)
  993. SurplusList = filesvc.GetBasicNeedFileList(strconv.Itoa(model.Id))
  994. for _, CertSub := range companygoodslist {
  995. companygood = CertSub
  996. wherecompany := " SupplierId =" + strconv.Itoa(CertSub.SupplierId)
  997. svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel)
  998. if len(supfilemodel) < 1 {
  999. _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  1000. } else {
  1001. var tmplist1 []suppliercertsub.Tmp_OilSupplierCertSub
  1002. wherecompany = " Id =" + strconv.Itoa(CertSub.Id)
  1003. svc.FindFileByCompany("tmp_OilSupplierCertSub", wherecompany, &tmplist1)
  1004. if len(tmplist1) < 1 {
  1005. wherecompany = " SupplierId ='" + strconv.Itoa(CertSub.SupplierId) + "'"
  1006. svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel01)
  1007. var File01 string
  1008. for _, Filesub := range supfilemodel01 {
  1009. File01 = File01 + Filesub.NeedFileType + ","
  1010. }
  1011. for _, Filesub := range SurplusList {
  1012. var supplierModel supplier.OilSupplier
  1013. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  1014. svcSupplier.GetEntityById(strconv.Itoa(CertSub.SupplierId), &supplierModel)
  1015. //三证合一或五证合一不需要的字段
  1016. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  1017. File01 = mergerCertSkipField + File01
  1018. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(File01, Filesub.FileName+",") { //三证合一或五证合一了
  1019. continue
  1020. }
  1021. if strings.Contains(File01, Filesub.FileName+",") {
  1022. continue
  1023. }
  1024. _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood)
  1025. break
  1026. }
  1027. }
  1028. }
  1029. }
  1030. if err == nil {
  1031. errinfo.Message = "已拉取缺失资质列表!"
  1032. errinfo.Code = 0
  1033. this.Data["json"] = &errinfo
  1034. this.ServeJSON()
  1035. } else {
  1036. errinfo.Message = "拉取列表失败!" + utils.AlertProcess(err.Error())
  1037. errinfo.Code = -1
  1038. this.Data["json"] = &errinfo
  1039. this.ServeJSON()
  1040. }
  1041. }
  1042. // @Title get 导入excel
  1043. // @Description get SampleType by token
  1044. // @Success 200 {object} sampletype.SampleType
  1045. // @router /importexcel [get]
  1046. func (this *OilTechnologyServiceController) ImportExcel() {
  1047. url := this.GetString("ExcelUrl")
  1048. var errorinfo ErrorInfo
  1049. if url == "" {
  1050. errorinfo.Code = -2
  1051. errorinfo.Message = "导入失败!"
  1052. this.Data["json"] = &errorinfo
  1053. this.ServeJSON()
  1054. }
  1055. session := utils.DBE.NewSession()
  1056. err := session.Begin()
  1057. svc := technologyservice.GetOilTechnologySession(session)
  1058. err = svc.TruncateTable(Tmp_TechnologyName)
  1059. if err != nil {
  1060. session.Rollback()
  1061. errorinfo.Code = -2
  1062. errorinfo.Message = "导入失败!"
  1063. this.Data["json"] = &errorinfo
  1064. this.ServeJSON()
  1065. }
  1066. err = svc.TruncateTable(Tmp_TechnologyClassName)
  1067. if err != nil {
  1068. session.Rollback()
  1069. errorinfo.Code = -2
  1070. errorinfo.Message = "导入失败!"
  1071. this.Data["json"] = &errorinfo
  1072. this.ServeJSON()
  1073. }
  1074. _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
  1075. filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
  1076. url = strings.Replace(url, "60.30.245.229", "10.76.248.23", -1)
  1077. utils.DownloadFile(url, filename, _dir)
  1078. t := time.Now()
  1079. filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
  1080. xlFile, err := xlsx.OpenFile(filePath)
  1081. var errLineNum string
  1082. //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
  1083. if err != nil {
  1084. fmt.Printf("open failed: %s\n", err)
  1085. }
  1086. var sheet = xlFile.Sheets[0]
  1087. Fstrs := svc.GetFCode()
  1088. Fstrs = "ClassId, OrgName," + Fstrs
  1089. columnArr := strings.Split(Fstrs, ",")
  1090. defer func() {
  1091. session.Close()
  1092. }()
  1093. codemap := make(map[string]int)
  1094. arrLength := len(sheet.Rows[1].Cells)
  1095. for i := 1; i < len(sheet.Rows); i++ {
  1096. lineNo := strconv.Itoa(i + 1)
  1097. this.OperationCell(svc, lineNo, columnArr, codemap, sheet.Rows[i].Cells, &errLineNum, arrLength)
  1098. }
  1099. os.Remove(filePath)
  1100. if errLineNum != "" {
  1101. session.Rollback()
  1102. errorinfo.Code = -1
  1103. errorinfo.Message = "导入失败!错误行号:" + errLineNum
  1104. this.Data["json"] = &errorinfo
  1105. this.ServeJSON()
  1106. } else {
  1107. session.Commit()
  1108. elapsed := time.Since(t)
  1109. log.Println(elapsed)
  1110. errorinfo.Code = 0
  1111. errorinfo.Message = "导入成功!"
  1112. this.Data["json"] = &errorinfo
  1113. this.ServeJSON()
  1114. }
  1115. }
  1116. func (this *OilTechnologyServiceController) OperationCell(svc *technologyservice.OilTechnologySession, lineNo string, columnArr []string, codemap map[string]int, cellsArr []*xlsx.Cell, errLineNum *string, arrLength int) {
  1117. defer func() {
  1118. if err := recover(); err != nil {
  1119. log.Println("err"+lineNo, err)
  1120. *errLineNum += lineNo + ","
  1121. }
  1122. }()
  1123. parentId := 0
  1124. classId := 0
  1125. //cellsArrLen := len(cellsArr)
  1126. cellsArrLen := arrLength
  1127. var valstr = ""
  1128. for i := 0; i < cellsArrLen; {
  1129. if i < 8 {
  1130. var entity technologyserviceclass.Tmp_OilTechnologyServiceClass
  1131. cellval := strings.TrimSpace(cellsArr[i].String())
  1132. fmt.Println(cellval)
  1133. if cellval != "" {
  1134. _, has := codemap[cellval]
  1135. if !has {
  1136. if i > 2 {
  1137. upcode := cellsArr[i-2].String()
  1138. parentId = codemap[upcode]
  1139. } else {
  1140. upcode := cellsArr[0].String()
  1141. parentId = codemap[upcode]
  1142. }
  1143. entity.Code = cellval
  1144. entity.Name = strings.TrimSpace(cellsArr[i+1].String())
  1145. entity.ParentId = parentId
  1146. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1147. entity.CreateBy = this.User.Realname
  1148. entity.CreateOn = time.Now()
  1149. _, err := svc.InsertEntityBytbl(Tmp_TechnologyClassName, &entity)
  1150. if err != nil {
  1151. panic(err)
  1152. break
  1153. }
  1154. classId = entity.Id
  1155. if i <= 6 {
  1156. codemap[cellval] = entity.Id
  1157. }
  1158. }
  1159. }
  1160. }
  1161. if i >= 8 {
  1162. valstr += "'" + strings.TrimLeft(cellsArr[i].String(), " ") + "',"
  1163. i++
  1164. } else {
  1165. i += 2
  1166. }
  1167. }
  1168. valstr = strings.Trim(valstr, ",")
  1169. valstr = strings.Replace(valstr, "是", "1", -1)
  1170. log.Println(cellsArr[0].String() + "==" + valstr)
  1171. var columnstr = ""
  1172. for l := 0; l < cellsArrLen-7; l++ {
  1173. columnstr += columnArr[l] + ","
  1174. }
  1175. columnstr = strings.Trim(columnstr, ",")
  1176. valstr = strconv.Itoa(classId) + "," + valstr
  1177. var err error
  1178. if classId > 0 {
  1179. err = svc.InsertTmpTechnology(columnstr, valstr)
  1180. }
  1181. if err != nil {
  1182. panic(err)
  1183. }
  1184. }
  1185. // @Title 获取列表新导入的列表
  1186. // @Description get user by token
  1187. // @Success 200 {object} []
  1188. // @router /importlist [get]
  1189. func (this *OilTechnologyServiceController) GetImportEntityList() {
  1190. //获取分页信息
  1191. page := this.GetPageInfoForm()
  1192. where := " 1=1 "
  1193. orderby := "Code"
  1194. asc := true
  1195. Order := this.GetString("Order")
  1196. Prop := this.GetString("Prop")
  1197. if Order != "" && Prop != "" {
  1198. orderby = Prop
  1199. if Order == "asc" {
  1200. asc = true
  1201. } else {
  1202. asc = false
  1203. }
  1204. }
  1205. CreateOn := this.GetString("CreateOn")
  1206. Code := this.GetString("Code")
  1207. Name := this.GetString("Name")
  1208. Code1 := this.GetString("Code1")
  1209. Name1 := this.GetString("Name1")
  1210. Code2 := this.GetString("Code2")
  1211. Name2 := this.GetString("Name2")
  1212. Code3 := this.GetString("Code3")
  1213. Name3 := this.GetString("Name3")
  1214. Code4 := this.GetString("Code4")
  1215. Name4 := this.GetString("Name4")
  1216. if Code != "" {
  1217. where = where + " and Code like '%" + Code + "%'"
  1218. }
  1219. if Name != "" {
  1220. where = where + " and Name like '%" + Name + "%'"
  1221. }
  1222. if Code1 != "" {
  1223. where = where + " and Code1 like '%" + Code1 + "%'"
  1224. }
  1225. if Name1 != "" {
  1226. where = where + " and Name1 like '%" + Name1 + "%'"
  1227. }
  1228. if Code2 != "" {
  1229. where = where + " and Code2 like '%" + Code2 + "%'"
  1230. }
  1231. if Name2 != "" {
  1232. where = where + " and Name2 like '%" + Name2 + "%'"
  1233. }
  1234. if Code3 != "" {
  1235. where = where + " and Code3 like '%" + Code3 + "%'"
  1236. }
  1237. if Name3 != "" {
  1238. where = where + " and Name3 like '%" + Name3 + "%'"
  1239. }
  1240. if Code4 != "" {
  1241. where = where + " and Code4 like '%" + Code4 + "%'"
  1242. }
  1243. if Name4 != "" {
  1244. where = where + " and Name4 like '%" + Name4 + "%'"
  1245. }
  1246. if CreateOn != "" {
  1247. dates := strings.Split(CreateOn, ",")
  1248. if len(dates) == 2 {
  1249. minDate := dates[0]
  1250. maxDate := dates[1]
  1251. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  1252. }
  1253. }
  1254. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1255. var list []technologyservice.OilTechnologyServiceView
  1256. total := svc.GetMyPagingEntitiesWithOrderBytbl(ImportTechsrvDetailViewName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  1257. var datainfo DataInfo
  1258. datainfo.Items = list
  1259. datainfo.CurrentItemCount = total
  1260. datainfo.PageIndex = page.CurrentPage
  1261. datainfo.ItemsPerPage = page.Size
  1262. this.Data["json"] = &datainfo
  1263. this.ServeJSON()
  1264. }
  1265. // @Title 将导入的数据 导入到正式表
  1266. // @Description get SampleType by token
  1267. // @Success 200 {object} sampletype.SampleType
  1268. // @router /insertTechnology [get]
  1269. func (this *OilTechnologyServiceController) InsertTechnology() {
  1270. session := utils.DBE.NewSession()
  1271. err := session.Begin()
  1272. defer session.Close()
  1273. svc := technologyservice.GetOilTechnologySession(session)
  1274. var errinfo ErrorInfo
  1275. err = svc.TruncateTable(OilTechnologyServiceName)
  1276. if err != nil {
  1277. session.Rollback()
  1278. errinfo.Code = -1
  1279. errinfo.Message = "更新失败!"
  1280. this.Data["json"] = &errinfo
  1281. this.ServeJSON()
  1282. }
  1283. err = svc.TruncateTable(OilTechnologyServiceClassName)
  1284. if err != nil {
  1285. session.Rollback()
  1286. errinfo.Code = -1
  1287. errinfo.Message = "更新失败!"
  1288. this.Data["json"] = &errinfo
  1289. this.ServeJSON()
  1290. }
  1291. err = svc.InsertTechnology(Tmp_TechnologyName, OilTechnologyServiceName)
  1292. if err != nil {
  1293. session.Rollback()
  1294. errinfo.Code = -1
  1295. errinfo.Message = "更新失败!"
  1296. this.Data["json"] = &errinfo
  1297. this.ServeJSON()
  1298. }
  1299. err = svc.InsertTechnology(Tmp_TechnologyClassName, OilTechnologyServiceClassName)
  1300. if err != nil {
  1301. session.Rollback()
  1302. errinfo.Code = -1
  1303. errinfo.Message = "更新失败!"
  1304. this.Data["json"] = &errinfo
  1305. this.ServeJSON()
  1306. }
  1307. session.Commit()
  1308. errinfo.Code = 0
  1309. errinfo.Message = "更新成功,即将操作企业准入范围!"
  1310. this.Data["json"] = &errinfo
  1311. this.ServeJSON()
  1312. }
  1313. // @Title 更新企业的准入项及资质
  1314. // @Description get SampleType by token
  1315. // @Success 200 {object} sampletype.SampleType
  1316. // @router /updatasuppiercertsub [get]
  1317. func (this *OilTechnologyServiceController) UpdataSuppierCertSub() {
  1318. t := time.Now()
  1319. technologysvc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1320. technologysvc.DeleteTable(TmpOilSupplierCertSubName, "SupplierTypeCode='03'")
  1321. supsvc := supplier.GetOilSupplierService(utils.DBE)
  1322. var suppliercertList []suppliercert.OilSupplierCert
  1323. where := "SupplierTypeCode='03' AND OutsideFlog = '' AND (InFlag IN ('1','2')) "
  1324. supsvc.GetEntities(&suppliercertList, where)
  1325. var technologyClassList []technologyserviceclass.OilTechnologyServiceClass
  1326. supsvc.GetEntities(&technologyClassList, "")
  1327. var colsname = []string{"Name"}
  1328. for _, suppliercert := range suppliercertList {
  1329. var supplier supplier.OilSupplier
  1330. wheres := " Id=" + strconv.Itoa(suppliercert.SupplierId)
  1331. supsvc.GetEntity(&supplier, wheres)
  1332. log.Println(suppliercert.SupplierId)
  1333. var supplierCertSubList []suppliercertsub.OilSupplierCertSub
  1334. wheresup := "SupplierId = " + strconv.Itoa(suppliercert.SupplierId) + " and SupplierTypeCode='03' AND Type IN ('1', '3')"
  1335. supsvc.GetEntities(&supplierCertSubList, wheresup)
  1336. fmt.Println(len(supplierCertSubList))
  1337. mergerCertSkipField := ""
  1338. if supplier.CredentialFlag == "1" || supplier.CredentialFlag == "2" {
  1339. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1340. //三证合一或五证合一不需要的字段
  1341. mergerCertSkipField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  1342. }
  1343. for idx := 0; idx < len(supplierCertSubList); idx++ {
  1344. supplierCertSub := supplierCertSubList[idx]
  1345. decCode := supplierCertSub.Code
  1346. // 物资类的准入编码
  1347. for _, technologyClass := range technologyClassList {
  1348. // 如果编码相同的后 判断有没有改名 然后查询准入项需要哪些资质 去查资质表里有没有这些资质 没有就删除这个准入项
  1349. if supplierCertSub.Code == technologyClass.Code {
  1350. decCode = ""
  1351. technologyNameArr := this.GetTechnologyName(strconv.Itoa(technologyClass.Id))
  1352. for _, val := range technologyNameArr {
  1353. if strings.Contains(mergerCertSkipField, val) {
  1354. break
  1355. }
  1356. var supplierFile supplierfile.OilSupplierFile
  1357. where := "SupplierId=" + strconv.Itoa(suppliercert.SupplierId) + " and NeedFileType='" + val + "'" + " and SupplierTypeCode IN ('000', '03')"
  1358. has := supsvc.GetEntityByWhere(OilSupplierFileName, where, &supplierFile)
  1359. if !has {
  1360. log.Println(supplierCertSub.Code + "====" + val)
  1361. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  1362. break
  1363. }
  1364. if supplierCertSub.Name != technologyClass.Name {
  1365. var entity suppliercertsub.OilSupplierCertSub
  1366. entity.Name = technologyClass.Name
  1367. where := "Id = " + strconv.Itoa(supplierCertSub.Id)
  1368. supsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &entity, colsname, where)
  1369. }
  1370. }
  1371. break
  1372. }
  1373. }
  1374. if decCode != "" {
  1375. supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub)
  1376. }
  1377. }
  1378. }
  1379. elapsed := time.Since(t)
  1380. log.Println(elapsed)
  1381. var errinfo ErrorInfo
  1382. errinfo.Code = 0
  1383. errinfo.Message = "更新完成!"
  1384. this.Data["json"] = &errinfo
  1385. this.ServeJSON()
  1386. //xlFile.Save(excelFileName)
  1387. }
  1388. func (this *OilTechnologyServiceController) GetTechnologyName(classId string) []string {
  1389. var goodsAptitudeName string
  1390. var technologyFList []technologyservice.OilTechnologyF
  1391. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1392. where := "ClassId=" + classId
  1393. svc.GetOilTechnologyF(&technologyFList, where)
  1394. for _, goodsAptitude := range technologyFList {
  1395. t := reflect.TypeOf(goodsAptitude)
  1396. v := reflect.ValueOf(goodsAptitude)
  1397. for k := 0; k < t.NumField(); k++ {
  1398. if v.Field(k).Interface() == "1" {
  1399. var tableHeader tableheader.BaseTableheader
  1400. where := "Code='" + t.Field(k).Name + "' and CategoryCode = '03'"
  1401. has := svc.GetEntityByWhere(BaseTableHeader, where, &tableHeader)
  1402. if has {
  1403. goodsAptitudeName += tableHeader.Name + ","
  1404. }
  1405. }
  1406. }
  1407. }
  1408. goodsAptitudeName = strings.Trim(goodsAptitudeName, ",")
  1409. return strings.Split(goodsAptitudeName, ",")
  1410. }
  1411. // @Title 导出数据到word,作为导出pdf的中间步骤
  1412. // @Description 数据存入word
  1413. // @Success 200 {object} controllers.Request
  1414. // @router /exportpdf/:tbid/:typecode [post]
  1415. func (this *OilTechnologyServiceController) PdfExport() {
  1416. Id := this.Ctx.Input.Param(":tbid")
  1417. SupplierTypeCode := this.Ctx.Input.Param(":typecode")
  1418. var Url string
  1419. var fileName string
  1420. var model1 supplierdataentry.SupplierDataEntry
  1421. var model2 supplierdataentry.SupplierCertDataEntry
  1422. svc := supplierdataentry.GetSupplierDataEntryService(utils.DBE)
  1423. where1 := "1=1"
  1424. where1 += " AND Id = '" + Id + "'"
  1425. where2 := "SupplierId = '" + Id + "' and SupplierTypecode='" + SupplierTypeCode + "'"
  1426. svc.GetEntityByWhere(OilSupplierName, where1, &model1)
  1427. svc.GetEntityByWhere(OilSupplierCertName, where2, &model2)
  1428. var tabledata []supplierdataentry.SupplierCertSubEntry
  1429. where3 := "SupplierId = '" + Id + "' and SupplierTypecode='" + SupplierTypeCode + "' and Type in ('1','3')" //准入状态的准入项
  1430. svc.GetEntitysByOrderbyWhere(TmpOilSupplierCertSubName, where3, "1", &tabledata)
  1431. datamap := structToMapDemo(model1.OilSupplier)
  1432. if model2.SupplierTypeCode == "01" {
  1433. Url = utils.Cfg.MustValue("workflow", "goodsPdfHost")
  1434. fileName = "待删除物资类准入范围.docx"
  1435. } else if model2.SupplierTypeCode == "02" {
  1436. Url = utils.Cfg.MustValue("workflow", "basisPdfHost")
  1437. fileName = "待删除基建类准入范围.docx"
  1438. datamap["TJInNotify"] = model1.TJInNotify
  1439. } else {
  1440. Url = utils.Cfg.MustValue("workflow", "techPdfHost")
  1441. fileName = "待删除服务类准入范围.docx"
  1442. }
  1443. //model1
  1444. datamap["SetupTime"] = model1.SetupTime.Format("2006年01月02日")
  1445. datamap["QualifCert"] = model1.QualifCert
  1446. datamap["QualifCertLevel"] = model1.QualifCertLevel
  1447. datamap["SpecIndustryCert"] = model1.SpecIndustryCert
  1448. datamap["MaunLicense"] = model1.MaunLicense
  1449. if model1.HseTraining == "1" {
  1450. datamap["HseTraining"] = "是"
  1451. } else {
  1452. datamap["HseTraining"] = "否"
  1453. }
  1454. if model1.OperType != "" {
  1455. if model1.OperType == "1" || model1.OperType == "制造商" {
  1456. datamap["OperType"] = "√制造商 □代理商 □贸易商"
  1457. } else if model1.OperType == "2" || model1.OperType == "代理商" {
  1458. datamap["OperType"] = "□制造商 √代理商 □贸易商"
  1459. } else if model1.OperType == "3" || model1.OperType == "代理商" {
  1460. datamap["OperType"] = "□制造商 □代理商 √贸易商"
  1461. } else {
  1462. datamap["OperType"] = "□制造商 □代理商 □贸易商"
  1463. }
  1464. }
  1465. if model1.SpecTypeCode != "" {
  1466. if model1.SpecTypeCode == "1" {
  1467. datamap["SpecTypeCode"] = "√一般外部 □多元企业"
  1468. } else if model1.SpecTypeCode == "2" {
  1469. datamap["SpecTypeCode"] = "□一般外部 √多元企业"
  1470. } else {
  1471. datamap["SpecTypeCode"] = "□一般外部 □多元企业"
  1472. }
  1473. }
  1474. if model1.Grade == "1" {
  1475. datamap["Grade"] = "一级"
  1476. } else if model1.SpecTypeCode == "2" {
  1477. datamap["Grade"] = "二级"
  1478. }
  1479. datamap["Fax"] = model1.Fax
  1480. datamap["CompanyTel"] = model1.CompanyTel
  1481. datamap["SupplierName"] = model1.SupplierName
  1482. datamap["Country"] = model1.Country
  1483. datamap["MaunAgent"] = model1.MaunAgent
  1484. datamap["SupplierCertificate"] = model1.SupplierCertificate
  1485. datamap["MgrUnit"] = model1.MgrUnit
  1486. datamap["CommercialNo"] = model1.CommercialNo
  1487. datamap["CountryTaxNo"] = model1.CountryTaxNo
  1488. datamap["OrganCode"] = model1.OrganCode
  1489. datamap["Address"] = model1.Address
  1490. datamap["ZipCode"] = model1.ZipCode
  1491. datamap["LinkAddress"] = model1.LinkAddress
  1492. datamap["LinkZipCode"] = model1.LinkZipCode
  1493. datamap["QualitySystemCert"] = model1.QualitySystemCert
  1494. datamap["ProductQualityCert"] = model1.ProductQualityCert
  1495. datamap["MaunLicense"] = model1.MaunLicense
  1496. datamap["LegalPerson"] = model1.LegalPerson
  1497. datamap["CompanyType"] = model1.CompanyType
  1498. datamap["ContactName"] = model1.ContactName
  1499. datamap["RegCapital"] = strconv.FormatFloat(model1.RegCapital, 'f', 2, 64) + "万元" + model1.Currency
  1500. datamap["DepositBank"] = model1.DepositBank
  1501. datamap["BankAccount"] = model1.BankAccount
  1502. datamap["Mobile"] = model1.Mobile
  1503. datamap["EMail"] = model1.EMail
  1504. datamap["BankCreditRating"] = model1.BankCreditRating
  1505. datamap["BusinessScope"] = model1.BusinessScope
  1506. datamap["Telphone"] = model1.Telphone
  1507. datamap["AccessCardNo"] = model2.AccessCardNo
  1508. datamap["PrintYear"] = time.Now().Year()
  1509. datamap["PrintMonth"] = time.Now().Month()
  1510. datamap["PrintDay"] = time.Now().Day()
  1511. datamap["Name"] = ""
  1512. if len(tabledata) != 0 {
  1513. var Name string
  1514. Name = "\n待删除准入范围:" + tabledata[0].Code
  1515. Name = Name + " " + tabledata[0].Name
  1516. var i int
  1517. for i = 1; i < len(tabledata); i++ {
  1518. Name += ";"
  1519. Name += tabledata[i].Code
  1520. Name = Name + " " + tabledata[i].Name
  1521. }
  1522. //if i == 100 {
  1523. // Name += "(准入范围未完全显示,请到系统查看详情)"
  1524. //}
  1525. datamap["Name"] = datamap["Name"].(string) + Name
  1526. } else {
  1527. datamap["Name"] = datamap["Name"].(string)
  1528. }
  1529. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1530. retDocUrl := svcActiviti.FillWordTemplate(datamap, Url, fileName)
  1531. var datainfo ErrorDataInfo
  1532. datainfo.Code = 0
  1533. datainfo.Item = retDocUrl
  1534. datainfo.Message = "准备导出"
  1535. this.Data["json"] = &datainfo
  1536. this.ServeJSON()
  1537. }
  1538. // @Title get 清空导入的信息
  1539. // @Description get SampleType by token
  1540. // @Success 200 {object} sampletype.SampleType
  1541. // @router /truncateimport [get]
  1542. func (this *OilTechnologyServiceController) TruncateImport() {
  1543. session := utils.DBE.NewSession()
  1544. err := session.Begin()
  1545. defer session.Close()
  1546. svc := technologyservice.GetOilTechnologySession(session)
  1547. err = svc.TruncateTable(Tmp_TechnologyName)
  1548. var errorinfo ErrorInfo
  1549. if err != nil {
  1550. session.Rollback()
  1551. errorinfo.Code = -1
  1552. errorinfo.Message = "删除失败!"
  1553. this.Data["json"] = &errorinfo
  1554. this.ServeJSON()
  1555. }
  1556. err = svc.TruncateTable(Tmp_TechnologyClassName)
  1557. if err != nil {
  1558. session.Rollback()
  1559. errorinfo.Code = -1
  1560. errorinfo.Message = "删除失败!"
  1561. this.Data["json"] = &errorinfo
  1562. this.ServeJSON()
  1563. }
  1564. session.Commit()
  1565. errorinfo.Code = 0
  1566. errorinfo.Message = "删除成功!"
  1567. this.Data["json"] = &errorinfo
  1568. this.ServeJSON()
  1569. }
  1570. // @Title 导出到execl
  1571. // @Description 导出到execl
  1572. // @Success 200 {object} controllers.Request
  1573. // @router /exportexecl [post]
  1574. func (this *OilTechnologyServiceController) ExeclExport() {
  1575. // 填物资类信息表首页信息
  1576. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1577. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1578. var list2 []supplier.OilSupplierContrast
  1579. where := " 1=1"
  1580. svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierTecContrast", 0, 0, "Id", false, &list2, where)
  1581. fileName := "资质导入对比表.xlsx"
  1582. Url := utils.Cfg.MustValue("workflow", "ContrastExcel")
  1583. var datamap = make(map[string]interface{})
  1584. datamap["data"] = list2
  1585. retDocUrl := svcActiviti.ContrastExcel(datamap, Url, fileName)
  1586. var datainfo ErrorDataInfo
  1587. datainfo.Code = 0
  1588. datainfo.Item = retDocUrl
  1589. datainfo.Message = "打印成功"
  1590. this.Data["json"] = &datainfo
  1591. this.ServeJSON()
  1592. }
  1593. // @Title 新导入资质后,比对不合格的准入用户
  1594. // @Description 对比列表
  1595. // @Success 200 {object} []supplier.OilSupplierSelect
  1596. // @router /get-compare-tmp-supplier [get]
  1597. func (this *OilTechnologyServiceController) GetCompareTmpSupplier() {
  1598. //获取分页信息
  1599. page := this.GetPageInfoForm()
  1600. where := " 1=1 "
  1601. orderby := "Id"
  1602. asc := false
  1603. Order := this.GetString("Order")
  1604. Prop := this.GetString("Prop")
  1605. if Order != "" && Prop != "" {
  1606. orderby = Prop
  1607. if Order == "asc" {
  1608. asc = true
  1609. }
  1610. }
  1611. Id := this.GetString("Id")
  1612. SupplierName := this.GetString("SupplierName")
  1613. AccessCardNo := this.GetString("AccessCardNo")
  1614. SupplierTypeCode := this.GetString("SupplierTypeCode")
  1615. Code := this.GetString("Code")
  1616. Name := this.GetString("Name")
  1617. Conditions := this.GetString("Conditions")
  1618. IsDelete := this.GetString("IsDelete")
  1619. CreateOn := this.GetString("CreateOn")
  1620. CreateUserId := this.GetString("CreateUserId")
  1621. CreateBy := this.GetString("CreateBy")
  1622. ModifiedOn := this.GetString("ModifiedOn")
  1623. ModifiedUserId := this.GetString("ModifiedUserId")
  1624. ModifiedBy := this.GetString("ModifiedBy")
  1625. if Id != "" {
  1626. where = where + " and Id like '%" + Id + "%'"
  1627. }
  1628. if SupplierName != "" {
  1629. where = where + " and SupplierName like '%" + SupplierName + "%'"
  1630. }
  1631. if AccessCardNo != "" {
  1632. where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
  1633. }
  1634. if SupplierTypeCode != "" {
  1635. where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'"
  1636. }
  1637. if Code != "" {
  1638. where = where + " and Code like '%" + Code + "%'"
  1639. }
  1640. if Name != "" {
  1641. where = where + " and Name like '%" + Name + "%'"
  1642. }
  1643. if Conditions == "2" {
  1644. where = where + " and NoSubCnt > 0"
  1645. } else if Conditions == "3" {
  1646. where = where + " and Checked = '0'"
  1647. } else if Conditions == "4" {
  1648. where = where + " and Checked = '1"
  1649. }
  1650. if IsDelete != "" {
  1651. where = where + " and IsDelete like '%" + IsDelete + "%'"
  1652. }
  1653. if CreateUserId != "" {
  1654. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  1655. }
  1656. if CreateBy != "" {
  1657. where = where + " and CreateBy like '%" + CreateBy + "%'"
  1658. }
  1659. if ModifiedOn != "" {
  1660. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  1661. }
  1662. if ModifiedUserId != "" {
  1663. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  1664. }
  1665. if ModifiedBy != "" {
  1666. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  1667. }
  1668. if CreateOn != "" {
  1669. dates := strings.Split(CreateOn, ",")
  1670. if len(dates) == 2 {
  1671. minDate := dates[0]
  1672. maxDate := dates[1]
  1673. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  1674. }
  1675. }
  1676. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1677. var list2 []supplier.OilSupplierContrast
  1678. total := svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierTecContrast", page.CurrentPage, page.Size, orderby, asc, &list2, where)
  1679. var datainfo DataInfo
  1680. datainfo.Items = list2
  1681. datainfo.CurrentItemCount = total
  1682. datainfo.PageIndex = page.CurrentPage
  1683. datainfo.ItemsPerPage = page.Size
  1684. this.Data["json"] = &datainfo
  1685. this.ServeJSON()
  1686. }
  1687. // @Title 获取列表
  1688. // @Description get user by token
  1689. // @Success 200 {object} []goodsaptitude.OilGoodsAptitude
  1690. // @router /comparelist [get]
  1691. func (this *OilTechnologyServiceController) GetCompareList() {
  1692. //获取分页信息
  1693. page := this.GetPageInfoForm()
  1694. where := " 1=1 "
  1695. orderby := "Code"
  1696. asc := true
  1697. Order := this.GetString("Order")
  1698. Prop := this.GetString("Prop")
  1699. Conditions := this.GetString("Conditions")
  1700. if Conditions == "1" {
  1701. // 匹配上
  1702. where += " and b.Name = tmpb.Name"
  1703. } else if Conditions == "4" {
  1704. // 旧表有新表没
  1705. where += " and tmpb.Name is null"
  1706. } else if Conditions == "5" {
  1707. // 新表有,旧表没
  1708. where += " and tmpb.Name is null"
  1709. } else if Conditions == "6" {
  1710. // 资质+级别匹配
  1711. where += " and b.Name = tmpb.Name and (a.F01 = tmpa.F01 or (tmpa.F01 = '' && a.F01 is null)) and (a.F02 = tmpa.F02 or (tmpa.F02 = '' && a.F02 is null)) and (a.F03 = tmpa.F03 or (tmpa.F03 = '' && a.F03 is null)) and (a.F04 = tmpa.F04 or (tmpa.F04 = '' && a.F04 is null)) and (a.F05 = tmpa.F05 or (tmpa.F05 = '' && a.F05 is null)) and (a.F06 = tmpa.F06 or (tmpa.F06 = '' && a.F06 is null)) and (a.F07 = tmpa.F07 or (tmpa.F07 = '' && a.F07 is null)) and (a.F08 = tmpa.F08 or (tmpa.F08 = '' && a.F08 is null)) and (a.F09 = tmpa.F09 or (tmpa.F09 = '' && a.F09 is null)) and (a.F10 = tmpa.F10 or (tmpa.F10 = '' && a.F10 is null))" +
  1712. " and (a.F11 = tmpa.F11 or (tmpa.F11 = '' && a.F11 is null)) and (a.F12 = tmpa.F12 or (tmpa.F12 = '' && a.F12 is null)) and (a.F13 = tmpa.F13 or (tmpa.F13 = '' && a.F13 is null)) and (a.F14 = tmpa.F14 or (tmpa.F14 = '' && a.F14 is null)) and (a.F15 = tmpa.F15 or (tmpa.F15 = '' && a.F15 is null)) and (a.F16 = tmpa.F16 or (tmpa.F16 = '' && a.F16 is null)) and (a.F17 = tmpa.F17 or (tmpa.F17 = '' && a.F17 is null)) and (a.F18 = tmpa.F18 or (tmpa.F18 = '' && a.F18 is null)) and (a.F19 = tmpa.F19 or (tmpa.F19 = '' && a.F19 is null)) and (a.F20 = tmpa.F20 or (tmpa.F20 = '' && a.F20 is null))" +
  1713. " and (a.F21 = tmpa.F21 or (tmpa.F21 = '' && a.F21 is null)) and (a.F22 = tmpa.F22 or (tmpa.F22 = '' && a.F22 is null)) and (a.F23 = tmpa.F23 or (tmpa.F23 = '' && a.F23 is null)) and (a.F24 = tmpa.F24 or (tmpa.F24 = '' && a.F24 is null)) and (a.F25 = tmpa.F25 or (tmpa.F25 = '' && a.F25 is null)) and (a.F26 = tmpa.F26 or (tmpa.F26 = '' && a.F26 is null)) and (a.F27 = tmpa.F27 or (tmpa.F27 = '' && a.F27 is null)) and (a.F28 = tmpa.F28 or (tmpa.F28 = '' && a.F28 is null)) and (a.F29 = tmpa.F29 or (tmpa.F29 = '' && a.F29 is null)) and (a.F30 = tmpa.F30 or (tmpa.F30 = '' && a.F30 is null))" +
  1714. " and (a.F31 = tmpa.F31 or (tmpa.F31 = '' && a.F31 is null)) and (a.F32 = tmpa.F32 or (tmpa.F32 = '' && a.F32 is null)) and (a.F33 = tmpa.F33 or (tmpa.F33 = '' && a.F33 is null)) and (a.F34 = tmpa.F34 or (tmpa.F34 = '' && a.F34 is null)) and (a.F35 = tmpa.F35 or (tmpa.F35 = '' && a.F35 is null)) and (a.F36 = tmpa.F36 or (tmpa.F36 = '' && a.F36 is null)) and (a.F37 = tmpa.F37 or (tmpa.F37 = '' && a.F37 is null)) and (a.F38 = tmpa.F38 or (tmpa.F38 = '' && a.F38 is null)) and (a.F39 = tmpa.F39 or (tmpa.F39 = '' && a.F39 is null)) and (a.F40 = tmpa.F40 or (tmpa.F40 = '' && a.F40 is null))" +
  1715. " and (a.F41 = tmpa.F41 or (tmpa.F41 = '' && a.F41 is null)) and (a.F42 = tmpa.F42 or (tmpa.F42 = '' && a.F42 is null)) and (a.F43 = tmpa.F43 or (tmpa.F43 = '' && a.F43 is null)) and (a.F44 = tmpa.F44 or (tmpa.F44 = '' && a.F44 is null)) and (a.F45 = tmpa.F45 or (tmpa.F45 = '' && a.F45 is null)) and (a.F46 = tmpa.F46 or (tmpa.F46 = '' && a.F46 is null)) and (a.F47 = tmpa.F47 or (tmpa.F47 = '' && a.F47 is null)) and (a.F48 = tmpa.F48 or (tmpa.F48 = '' && a.F48 is null)) and (a.F49 = tmpa.F49 or (tmpa.F49 = '' && a.F49 is null)) and (a.F50 = tmpa.F50 or (tmpa.F50 = '' && a.F50 is null))" +
  1716. " and (a.F51 = tmpa.F51 or (tmpa.F51 = '' && a.F51 is null)) and (a.F52 = tmpa.F52 or (tmpa.F52 = '' && a.F52 is null))"
  1717. }
  1718. if Order != "" && Prop != "" {
  1719. orderby = Prop
  1720. if Order == "asc" {
  1721. asc = true
  1722. } else {
  1723. asc = false
  1724. }
  1725. }
  1726. CreateOn := this.GetString("CreateOn")
  1727. Code := this.GetString("Code")
  1728. Name := this.GetString("Name")
  1729. BigClassName := this.GetString("BigClassName")
  1730. BigClassCode := this.GetString("BigClassCode")
  1731. MiddleClassName := this.GetString("MiddleClassName")
  1732. SmallClassName := this.GetString("SmallClassName")
  1733. GoodsName := this.GetString("GoodsName")
  1734. GoodsLevel := this.GetString("GoodsLevel")
  1735. GoodsDesc := this.GetString("GoodsDesc")
  1736. Standard := this.GetString("Standard")
  1737. CompanyType := this.GetString("CompanyType")
  1738. if Code != "" {
  1739. where = where + " and b.Code like '%" + Code + "%'"
  1740. }
  1741. if Name != "" {
  1742. where = where + " and b.Name like '%" + Name + "%'"
  1743. }
  1744. if BigClassName != "" {
  1745. where = where + " and Name1 like '%" + BigClassName + "%'"
  1746. }
  1747. if BigClassCode != "" {
  1748. where = where + " and Code1 like '%" + BigClassCode + "%'"
  1749. }
  1750. if MiddleClassName != "" {
  1751. where = where + " and Name2 like '%" + MiddleClassName + "%'"
  1752. }
  1753. if SmallClassName != "" {
  1754. where = where + " and Name3 like '%" + SmallClassName + "%'"
  1755. }
  1756. if GoodsName != "" {
  1757. where = where + " and Name4 like '%" + GoodsName + "%'"
  1758. }
  1759. if GoodsLevel != "" {
  1760. where = where + " and GoodsLevel like '%" + GoodsLevel + "%'"
  1761. }
  1762. if GoodsDesc != "" {
  1763. where = where + " and GoodsDesc like '%" + GoodsDesc + "%'"
  1764. }
  1765. if Standard != "" {
  1766. where = where + " and Standard '%" + Standard + "%'"
  1767. }
  1768. if CompanyType != "" {
  1769. where = where + " and CompanyType '%" + CompanyType + "%'"
  1770. }
  1771. if CreateOn != "" {
  1772. dates := strings.Split(CreateOn, ",")
  1773. if len(dates) == 2 {
  1774. minDate := dates[0]
  1775. maxDate := dates[1]
  1776. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  1777. }
  1778. }
  1779. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1780. var list []technologyservice.OilTechnologyServiceTmp
  1781. total := svc.GetPClassEntities(page.CurrentPage, page.Size, orderby, asc, &list, where, Conditions)
  1782. var datainfo DataInfo
  1783. datainfo.Items = list
  1784. datainfo.CurrentItemCount = total
  1785. datainfo.PageIndex = page.CurrentPage
  1786. datainfo.ItemsPerPage = page.Size
  1787. this.Data["json"] = &datainfo
  1788. this.ServeJSON()
  1789. }
  1790. // @Title get 生成对比列表
  1791. // @Description get SampleType by token
  1792. // @Success 200 {object} sampletype.SampleType
  1793. // @router /create-contrast [get]
  1794. func (this *OilTechnologyServiceController) CreateContrast() {
  1795. go func() {
  1796. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1797. svc.TruncateTable("OilSupplierTecContrast")
  1798. // 插入对比列表
  1799. var list1 []supplier.OilSupplier
  1800. svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, 0, 0, "Id", false, &list1, " 1=1")
  1801. svc.DBE.Query("SET unique_checks=0;")
  1802. svc.DBE.Query("SET autocommit=0;")
  1803. for _, item := range list1 {
  1804. var list []supplier.OilSupplierContrast
  1805. where := " b.SupplierTypeCode='03' and a.Id = " + strconv.Itoa(item.Id)
  1806. svc.GetPagingTmpCheckedEntities(&list, where)
  1807. if list != nil {
  1808. var supplierCertSubList []suppliercertsub.OilSupplierCertSub
  1809. total := svc.GetTableTotal(" SupplierTypeCode='03' AND SupplierId = "+strconv.Itoa(item.Id), &supplierCertSubList)
  1810. total1 := svc.GetNoSubCntTotal("a.SupplierTypeCode = '03' and c.ClassId is null and a.SupplierId = " + strconv.Itoa(item.Id))
  1811. list[0].SubCnt = int(total)
  1812. //list[0].MinClassId = "0"
  1813. list[0].NoSubCnt = int(total1)
  1814. //for _, sub := range supplierCertSubList {
  1815. // var technologyClassList technologyserviceclass.OilTechnologyServiceClass
  1816. // where2 := "Name = '"+ sub.Name + "'"
  1817. // svc.GetEntityByWhere(Tmp_TechnologyClassName, where2, &technologyClassList)
  1818. // if technologyClassList.Id > 0{
  1819. // list[0].MinClassId = strconv.Itoa(technologyClassList.Id)
  1820. // } else {
  1821. // list[0].MinClassId = "0"
  1822. // break
  1823. // }
  1824. //}
  1825. list[0].SetupTime = time.Now()
  1826. svc.InsertEntityBytbl("OilSupplierTecContrast", list[0])
  1827. svc.DBE.Query("commit;")
  1828. }
  1829. }
  1830. svc.DBE.Query("SET unique_checks=1;")
  1831. svc.DBE.Query("SET autocommit=1;")
  1832. }()
  1833. var errorinfo ErrorInfo
  1834. errorinfo.Code = 0
  1835. errorinfo.Message = "成功!"
  1836. this.Data["json"] = &errorinfo
  1837. this.ServeJSON()
  1838. }
  1839. // @Title 查看对比列表的准入范围 2020-12-18
  1840. // @Description get user by token
  1841. // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
  1842. // @router /delcertsublist [get]
  1843. func (this *OilTechnologyServiceController) GetDelCertSubList() {
  1844. //获取分页信息
  1845. page := this.GetPageInfoForm()
  1846. where := " 1=1 "
  1847. orderby := "a.Id"
  1848. asc := false
  1849. Order := this.GetString("Order")
  1850. Prop := this.GetString("Prop")
  1851. if Order != "" && Prop != "" {
  1852. orderby = Prop
  1853. if Order == "asc" {
  1854. asc = true
  1855. }
  1856. }
  1857. Id := this.GetString("Id")
  1858. SupplierId := this.GetString("SupplierId")
  1859. SupplierCertId := this.GetString("SupplierCertId")
  1860. SupplierTypeCode := this.GetString("SupplierTypeCode")
  1861. Code := this.GetString("Code")
  1862. Name := this.GetString("Name")
  1863. Remark := this.GetString("Remark")
  1864. IsDelete := this.GetString("IsDelete")
  1865. CreateOn := this.GetString("CreateOn")
  1866. CreateUserId := this.GetString("CreateUserId")
  1867. CreateBy := this.GetString("CreateBy")
  1868. ModifiedOn := this.GetString("ModifiedOn")
  1869. ModifiedUserId := this.GetString("ModifiedUserId")
  1870. ModifiedBy := this.GetString("ModifiedBy")
  1871. if Id != "" {
  1872. where = where + " and a.Id like '%" + Id + "%'"
  1873. }
  1874. if SupplierId != "" {
  1875. where = where + " and a.SupplierId like '%" + SupplierId + "%'"
  1876. }
  1877. if SupplierCertId != "" {
  1878. where = where + " and a.SupplierCertId = '" + SupplierCertId + "'"
  1879. }
  1880. if SupplierTypeCode != "" {
  1881. where = where + " and a.SupplierTypeCode = '" + SupplierTypeCode + "'"
  1882. }
  1883. if Code != "" {
  1884. where = where + " and a.Code like '%" + Code + "%'"
  1885. }
  1886. if Name != "" {
  1887. where = where + " and a.Name like '%" + Name + "%'"
  1888. }
  1889. if Remark != "" {
  1890. where = where + " and a.Remark like '%" + Remark + "%'"
  1891. }
  1892. if IsDelete != "" {
  1893. where = where + " and a.IsDelete like '%" + IsDelete + "%'"
  1894. }
  1895. if CreateUserId != "" {
  1896. where = where + " and a.CreateUserId like '%" + CreateUserId + "%'"
  1897. }
  1898. if CreateBy != "" {
  1899. where = where + " and a.CreateBy like '%" + CreateBy + "%'"
  1900. }
  1901. if ModifiedOn != "" {
  1902. where = where + " and a.ModifiedOn like '%" + ModifiedOn + "%'"
  1903. }
  1904. if ModifiedUserId != "" {
  1905. where = where + " and a.ModifiedUserId like '%" + ModifiedUserId + "%'"
  1906. }
  1907. if ModifiedBy != "" {
  1908. where = where + " and a.ModifiedBy like '%" + ModifiedBy + "%'"
  1909. }
  1910. if CreateOn != "" {
  1911. dates := strings.Split(CreateOn, ",")
  1912. if len(dates) == 2 {
  1913. minDate := dates[0]
  1914. maxDate := dates[1]
  1915. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  1916. }
  1917. }
  1918. where = where + " and a.Type in (1, 3)"
  1919. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1920. var list []suppliercertsub.OilSupplierCertSub1
  1921. total := svc.GetPagingTmpSubEntities(page.CurrentPage, page.Size, orderby, asc, &list, where)
  1922. a := 0
  1923. for _, item := range list {
  1924. sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25),IF(ifnull(F26, '') = '', '', F26),IF(ifnull(F27, '') = '', '', F27),IF(ifnull(F28, '') = '', '', F28),IF(ifnull(F29, '') = '', '', F29),IF(ifnull(F30, '') = '', '', F30),IF(ifnull(F31, '') = '', '', F31),IF(ifnull(F32, '') = '', '', F32),IF(ifnull(F33, '') = '', '', F33),IF(ifnull(F34, '') = '', '', F34),IF(ifnull(F35, '') = '', '', F35),IF(ifnull(F36, '') = '', '', F36),IF(ifnull(F37, '') = '', '', F37),IF(ifnull(F38, '') = '', '', F38),IF(ifnull(F39, '') = '', '', F39),IF(ifnull(F40, '') = '', '', F40),IF(ifnull(F41, '') = '', '', F41),IF(ifnull(F42, '') = '', '', F42),IF(ifnull(F43, '') = '', '', F43),IF(ifnull(F44, '') = '', '', F44),IF(ifnull(F45, '') = '', '', F45),IF(ifnull(F46, '') = '', '', F46),IF(ifnull(F47, '') = '', '', F47),IF(ifnull(F48, '') = '', '', F48),IF(ifnull(F49, '') = '', '', F49),IF(ifnull(F50, '') = '', '', F50),IF(ifnull(F51, '') = '', '', F51),IF(ifnull(F52, '') = '', '', F52)) AS Codes FROM Tmp_OilTechnologyService a LEFT JOIN Tmp_OilTechnologyServiceClass class ON a.ClassId = class.Id"
  1925. sql += " where class.Name = '" + item.Name + "'"
  1926. model, _ := svc.DBE.QueryString(sql)
  1927. if model != nil {
  1928. code := strings.Split(model[0]["Codes"], ",")
  1929. i := 1
  1930. for _, value := range code {
  1931. if i == 41 || i == 42 || i == 1 {
  1932. if (code[0] == "1" && strings.Index(item.HeaderCodes, "F01") < 0) && (code[40] == "1" && strings.Index(item.HeaderCodes, "F41") < 0) && (code[41] == "1" && strings.Index(item.HeaderCodes, "F42") < 0) {
  1933. list[a].Checked = 1
  1934. sql1 := "select Name from Base_TableHeader where Code = 'F01' and CategoryCode = '03'"
  1935. model1, _ := svc.DBE.QueryString(sql1)
  1936. if strings.Index(list[a].HeaderName, model1[0]["Name"]) == -1 {
  1937. list[a].HeaderName += model1[0]["Name"] + " "
  1938. }
  1939. }
  1940. } else if i > 10 {
  1941. if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
  1942. list[a].Checked = 1
  1943. sql1 := "select Name from Base_TableHeader where Code = 'F" + strconv.Itoa(i) + "' and CategoryCode = '03'"
  1944. model1, _ := svc.DBE.QueryString(sql1)
  1945. list[a].HeaderName += model1[0]["Name"] + " "
  1946. }
  1947. } else {
  1948. if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
  1949. list[a].Checked = 1
  1950. sql1 := "select Name from Base_TableHeader where Code = 'F0" + strconv.Itoa(i) + "' and CategoryCode = '03'"
  1951. model1, _ := svc.DBE.QueryString(sql1)
  1952. list[a].HeaderName += model1[0]["Name"] + " "
  1953. }
  1954. }
  1955. i += 1
  1956. }
  1957. } else {
  1958. list[a].MinClassId = "0"
  1959. }
  1960. a += 1
  1961. }
  1962. var datainfo DataInfo
  1963. datainfo.Items = list
  1964. datainfo.CurrentItemCount = total
  1965. datainfo.PageIndex = page.CurrentPage
  1966. datainfo.ItemsPerPage = page.Size
  1967. this.Data["json"] = &datainfo
  1968. this.ServeJSON()
  1969. }
  1970. // @Title 确认更新后的删除/修改 2020-12-18
  1971. // @Description 修改实体
  1972. // @Success 200 {object} controllers.Request
  1973. // @router /deleteUpdate [post]
  1974. func (this *OilTechnologyServiceController) DeleteUpdate() {
  1975. var errinfo ErrorInfo
  1976. var err error
  1977. go func() {
  1978. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  1979. var list1 []goodsaptitude.GoodsBusiness2
  1980. svc.GetEntityJoin(OilTechnologyServiceName, OilTechnologyServiceClassName, &list1)
  1981. for _, item := range list1 {
  1982. var subDelete suppliercertsub.OilSupplierCertSub1
  1983. cols := []string{"SubClassId", "Code"}
  1984. subDelete.Code = item.Code
  1985. subDelete.SubClassId = item.Id
  1986. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "SupplierTypeCode = '03' and Name = '"+item.Name+"'")
  1987. }
  1988. //var list []goodsaptitude.Ids
  1989. //svc.DeleteTableBySelect(OilSupplierCertSubName, OilTechnologyServiceClassName, "a.SupplierTypeCode='03' AND b.Id IS NULL", &list, "Name")
  1990. //for _,id := range list{
  1991. // err = svc.DeleteTable(OilSupplierCertSubName, "Id = " + strconv.Itoa(id.Id))
  1992. //}
  1993. }()
  1994. errinfo.Message = "更新中,请勿重复更新!"
  1995. errinfo.Code = 0
  1996. this.Data["json"] = &errinfo
  1997. this.ServeJSON()
  1998. }
  1999. // @Title 暂停企业准入范围 2020-12-18
  2000. // @Description 修改实体
  2001. // @Success 200 {object} controllers.Request
  2002. // @router /suspend [post]
  2003. func (this *OilTechnologyServiceController) DeleteSuspend() {
  2004. var errinfo ErrorInfo
  2005. var err error
  2006. var list []supplier.OilSupplierContrast
  2007. svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
  2008. go func() {
  2009. svc.GetEntitysByWhere("OilSupplierTecContrast", "Checked = '0'", &list)
  2010. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  2011. DueTimeStr := paramSvc.GetBaseparameterMessage("GFZT", "paramset", "Suspend")
  2012. for _, item := range list {
  2013. var sub []suppliercertsub.OilSupplierCertSub
  2014. svc.GetEntitysByWhere("OilSupplierCertSub", "SupplierTypeCode = '03' and SupplierId = "+strconv.Itoa(item.Id), &sub)
  2015. for _, itemSub := range sub {
  2016. sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25),IF(ifnull(F26, '') = '', '', F26),IF(ifnull(F27, '') = '', '', F27),IF(ifnull(F28, '') = '', '', F28),IF(ifnull(F29, '') = '', '', F29),IF(ifnull(F30, '') = '', '', F30),IF(ifnull(F31, '') = '', '', F31),IF(ifnull(F32, '') = '', '', F32),IF(ifnull(F33, '') = '', '', F33),IF(ifnull(F34, '') = '', '', F34),IF(ifnull(F35, '') = '', '', F35),IF(ifnull(F36, '') = '', '', F36),IF(ifnull(F37, '') = '', '', F37),IF(ifnull(F38, '') = '', '', F38),IF(ifnull(F39, '') = '', '', F39),IF(ifnull(F40, '') = '', '', F40),IF(ifnull(F41, '') = '', '', F41),IF(ifnull(F42, '') = '', '', F42),IF(ifnull(F43, '') = '', '', F43),IF(ifnull(F44, '') = '', '', F44),IF(ifnull(F45, '') = '', '', F45),IF(ifnull(F46, '') = '', '', F46),IF(ifnull(F47, '') = '', '', F47),IF(ifnull(F48, '') = '', '', F48),IF(ifnull(F49, '') = '', '', F49),IF(ifnull(F50, '') = '', '', F50),IF(ifnull(F51, '') = '', '', F51),IF(ifnull(F52, '') = '', '', F52)) AS Codes FROM OilTechnologyService a LEFT JOIN OilTechnologyServiceClass class ON a.ClassId = class.Id"
  2017. sql += " where class.Name = '" + itemSub.Name + "'"
  2018. model, _ := svc.DBE.QueryString(sql)
  2019. var subDelete suppliercertsub.OilSupplierCertSub
  2020. if model != nil {
  2021. code := strings.Split(model[0]["Codes"], ",")
  2022. cols := []string{"DueTime", "CertSubStatus"}
  2023. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id))
  2024. subDelete.CertSubStatus = "2"
  2025. currentTime := time.Now()
  2026. days, _ := strconv.Atoi(DueTimeStr)
  2027. subDelete.DueTime = currentTime.AddDate(0, 0, days)
  2028. i := 1
  2029. //暂停
  2030. for _, value := range code {
  2031. if i == 41 || i == 42 || i == 1 {
  2032. if (code[0] == "1" && strings.Index(item.HeaderCodes, "F01") < 0) && (code[40] == "1" && strings.Index(item.HeaderCodes, "F41") < 0) && (code[41] == "1" && strings.Index(item.HeaderCodes, "F42") < 0) {
  2033. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id))
  2034. var model1 supplierpausereason.OilSupplierPauseReason
  2035. model1.SupplierId = item.Id
  2036. model1.CertSubId = itemSub.Id
  2037. model1.CertSubStatus = "2"
  2038. model1.SupplierCertId = itemSub.SupplierCertId
  2039. model1.BackReason = "老数据导入缺资质"
  2040. model1.CreateOn = time.Now()
  2041. model1.CreateBy = this.User.Realname
  2042. model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  2043. svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
  2044. break
  2045. }
  2046. } else if i > 10 {
  2047. if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
  2048. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id))
  2049. var model1 supplierpausereason.OilSupplierPauseReason
  2050. model1.SupplierId = item.Id
  2051. model1.CertSubId = itemSub.Id
  2052. model1.CertSubStatus = "2"
  2053. model1.SupplierCertId = itemSub.SupplierCertId
  2054. model1.BackReason = "老数据导入缺资质"
  2055. model1.CreateOn = time.Now()
  2056. model1.CreateBy = this.User.Realname
  2057. model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  2058. svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
  2059. break
  2060. }
  2061. } else {
  2062. if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
  2063. err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id))
  2064. var model1 supplierpausereason.OilSupplierPauseReason
  2065. model1.SupplierId = item.Id
  2066. model1.CertSubId = itemSub.Id
  2067. model1.CertSubStatus = "2"
  2068. model1.SupplierCertId = itemSub.SupplierCertId
  2069. model1.BackReason = "老数据导入缺资质"
  2070. model1.CreateOn = time.Now()
  2071. model1.CreateBy = this.User.Realname
  2072. model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  2073. svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1)
  2074. break
  2075. }
  2076. }
  2077. i += 1
  2078. }
  2079. } else {
  2080. // 删除
  2081. //err = svc.DeleteEntityById(itemSub.Id, &subDelete)
  2082. }
  2083. }
  2084. //err = svc.DeleteTable("OilSupplierTecContrast", "Id = " + strconv.Itoa(item.Id))
  2085. }
  2086. this.CreateContrast()
  2087. }()
  2088. errinfo.Message = "更新中,请勿重复更新!"
  2089. errinfo.Code = 0
  2090. this.Data["json"] = &errinfo
  2091. this.ServeJSON()
  2092. }
  2093. // @Title 服务类对比excel手动删除 2020-12-31
  2094. // @Description 修改实体
  2095. // @Success 200 {object} controllers.Request
  2096. // @router /manualDelete [get]
  2097. func (this *OilTechnologyServiceController) ManualDelete() {
  2098. var errinfo ErrorInfo
  2099. var list []supplier.ManualDelete
  2100. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  2101. where := "1=1"
  2102. svc.GetEntitysByWhere("TecDifferent", where, &list)
  2103. for _, value := range list {
  2104. var sub1 suppliercertsub.OilSupplierCertSub
  2105. var class technologyserviceclass.OilTechnologyServiceClass
  2106. if value.Operation == "删除" || value.Operation == "" {
  2107. svc.DeleteTable(OilSupplierCertSubName, "SupplierTypeCode='03' and Code = '"+value.Code+"' and Name = '"+value.Name+"'")
  2108. } else if value.Operation == "维持不动" {
  2109. } else if strings.Index(value.Operation, ",") > 0 {
  2110. //151508,151509
  2111. var sub []suppliercertsub.OilSupplierCertSub
  2112. svc.GetEntitysByWhere(OilSupplierCertSubName, "SupplierTypeCode='03' and Code = '"+value.Code+"' and Name = '"+value.Name+"'", &sub)
  2113. code := strings.Split(value.Operation, ",")
  2114. for _, c := range code {
  2115. svc.GetEntityByWhere(OilTechnologyServiceClassName, "Code = '"+c+"'", &class)
  2116. for _, s := range sub {
  2117. s.Name = class.Name
  2118. s.Code = class.Code
  2119. s.SubClassId = class.Id
  2120. s.Id = 0
  2121. svc.GetEntityByWhere(OilSupplierCertSubName, "SupplierTypeCode='03' and SupplierCertId = "+strconv.Itoa(s.SupplierCertId)+" and Name = '"+class.Name+"'", &sub1)
  2122. if sub1.Id > 0 {
  2123. continue
  2124. }
  2125. svc.InsertEntityBytbl(OilSupplierCertSubName, &s)
  2126. }
  2127. svc.DeleteTable(OilSupplierCertSubName, "SupplierTypeCode='03' and Code = '"+value.Code+"' and Name = '"+value.Name+"'")
  2128. }
  2129. } else {
  2130. //151507
  2131. svc.GetEntityByWhere(OilTechnologyServiceClassName, "Code = '"+value.Operation+"'", &class)
  2132. where1 := "SupplierTypeCode='03' and Code = '" + value.Code + "' and Name = '" + value.Name + "'"
  2133. cols := []string{"Name", "Code", "SubClassId"}
  2134. sub1.Name = class.Name
  2135. sub1.Code = class.Code
  2136. sub1.SubClassId = class.Id
  2137. svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &sub1, cols, where1)
  2138. //去重
  2139. svc.DeleteOilSupplierCertSub("Name = '" + class.Name + "'")
  2140. }
  2141. }
  2142. errinfo.Message = "更新成功!"
  2143. errinfo.Code = 0
  2144. this.Data["json"] = &errinfo
  2145. this.ServeJSON()
  2146. }
  2147. // @Title 2021-01-28 新增准入企业
  2148. // @Description 修改实体
  2149. // @Success 200 {object} controllers.Request
  2150. // @router /insertSupplierNew [get]
  2151. func (this *OilTechnologyServiceController) InsertSupplierNew() {
  2152. SupplierName := this.GetString("SupplierName")
  2153. var zcgf supplier.TmpZcgf
  2154. svc := technologyservice.GetOilTechnologyServiceService(utils.DBE)
  2155. svc.GetEntityByOrderbyWhere("企业名称 = '"+SupplierName+"'", &zcgf)
  2156. var errinfo ErrorInfo
  2157. if zcgf.Sub != "" {
  2158. subs := strings.Split(zcgf.Sub, ";")
  2159. for _, sub := range subs {
  2160. if sub == "" {
  2161. continue
  2162. }
  2163. s := strings.Split(sub, " ")
  2164. var tecDifferent supplier.ManualDelete
  2165. svc.GetEntityByWhere("TecDifferent", "Name = '"+s[1]+"'", &tecDifferent)
  2166. var supp supplier.OilSupplier
  2167. svc.GetEntityByWhere(OilSupplierName, "SupplierName = '"+SupplierName+"'", &supp)
  2168. var cert suppliercert.OilSupplierCert
  2169. svc.GetEntityByWhere(OilSupplierCertName, "SupplierId = "+strconv.Itoa(supp.Id), &cert)
  2170. var sub1 suppliercertsub.OilSupplierCertSub
  2171. if zcgf.Code == "物资类" {
  2172. var class technologyserviceclass.OilTechnologyServiceClass
  2173. s1 := strings.TrimLeft(s[0], "BM")
  2174. svc.GetEntityByWhere(OilTechnologyServiceClassName, "Code = '"+s1+"'", &class)
  2175. }
  2176. if zcgf.Code == "基建类" {
  2177. var class technologyserviceclass.OilTechnologyServiceClass
  2178. svc.GetEntityByWhere(OilTechnologyServiceClassName, "Name = '"+s[1]+"'", &class)
  2179. }
  2180. if zcgf.Code == "技术服务类" {
  2181. var class technologyserviceclass.OilTechnologyServiceClass
  2182. svc.GetEntityByWhere(OilTechnologyServiceClassName, "Name = '"+s[1]+"'", &class)
  2183. if tecDifferent.Code == "" {
  2184. sub1.Code = class.Code
  2185. sub1.Name = s[1]
  2186. sub1.SupplierId = supp.Id
  2187. sub1.SupplierCertId = cert.Id
  2188. sub1.SupplierTypeCode = "03"
  2189. sub1.SubClassId = class.Id
  2190. sub1.CertSubStatus = "1"
  2191. sub1.Type = "1"
  2192. sub1.CreateOn = time.Now()
  2193. sub1.CreateBy = "导入1"
  2194. svc.InsertEntityBytbl("OilSupplierCertSub", &sub1)
  2195. } else {
  2196. var sub1 suppliercertsub.OilSupplierCertSub
  2197. var class technologyserviceclass.OilTechnologyServiceClass
  2198. if tecDifferent.Operation == "删除" || tecDifferent.Operation == "" || tecDifferent.Operation == "维持不动" {
  2199. } else {
  2200. code := strings.Split(tecDifferent.Operation, ",")
  2201. for _, c := range code {
  2202. svc.GetEntityByWhere(OilTechnologyServiceClassName, "Code = '"+c+"'", &class)
  2203. sub1.Code = class.Code
  2204. sub1.Name = class.Name
  2205. sub1.SupplierId = supp.Id
  2206. sub1.SubClassId = class.Id
  2207. sub1.SupplierCertId = cert.Id
  2208. sub1.SupplierTypeCode = "03"
  2209. sub1.CertSubStatus = "1"
  2210. sub1.Type = "1"
  2211. sub1.CreateOn = time.Now()
  2212. sub1.CreateBy = "导入1"
  2213. svc.InsertEntityBytbl("OilSupplierCertSub", &sub1)
  2214. }
  2215. }
  2216. }
  2217. }
  2218. }
  2219. }
  2220. errinfo.Message = "更新成功!"
  2221. errinfo.Code = 0
  2222. this.Data["json"] = &errinfo
  2223. this.ServeJSON()
  2224. }