public_api_controller.go 41KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "encoding/json"
  7. "fmt"
  8. "os"
  9. "path"
  10. "runtime"
  11. "strings"
  12. "time"
  13. "github.com/astaxie/beego"
  14. )
  15. type PublicApiController struct {
  16. BaseAPIController
  17. }
  18. func PublicApiRegistRouters() {
  19. beego.Router("/api/public/getadviceconfig", &PublicApiController{}, "Get:GetDoctorAdviceConfig")
  20. beego.Router("/api/public/servertime", &PublicApiController{}, "Get:GetServerTime")
  21. beego.Router("/api/app/release", &PublicApiController{}, "Get:AppRelease")
  22. beego.Router("/api/get", &PublicApiController{}, "Get:GetJson")
  23. beego.Router("/api/public/handledata", &PublicApiController{}, "get:HandleData")
  24. beego.Router("/api/public/handlestockdata", &PublicApiController{}, "get:HandleStockData")
  25. beego.Router("/api/public/handlecomdata", &PublicApiController{}, "get:HandleComData")
  26. beego.Router("/hello", &PublicApiController{}, "get:HandleComData")
  27. }
  28. func (c *PublicApiController) GetDoctorAdviceConfig() {
  29. drugs, _, _ := service.GetPublicDrugDics()
  30. drugways, _, _ := service.GetPublicDrugWayDics()
  31. efs, _, _ := service.GetPublicExecutionFrequencyDics()
  32. c.ServeSuccessJSON(map[string]interface{}{
  33. "drugs": drugs,
  34. "drugways": drugways,
  35. "efs": efs,
  36. })
  37. }
  38. func (c *PublicApiController) GetServerTime() {
  39. timeNow := time.Now()
  40. timeNowStamp := timeNow.Unix()
  41. timeNowStr := timeNow.Format("2006-01-02 15:04:05")
  42. c.ServeSuccessJSON(map[string]interface{}{
  43. "time": timeNowStr,
  44. "timestamp": timeNowStamp,
  45. })
  46. }
  47. func (c *PublicApiController) AppRelease() {
  48. // appId := c.GetString("appid")
  49. version := c.GetString("version")
  50. appType, _ := c.GetInt64("app_type", 0)
  51. appVersion, err := service.GetAppVersionByAppType(appType)
  52. if err != nil {
  53. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  54. return
  55. }
  56. if appVersion == nil {
  57. c.ServeSuccessJSON(map[string]interface{}{
  58. "version": nil,
  59. "state": 2,
  60. })
  61. return
  62. }
  63. state := strings.Compare(version, appVersion.Version)
  64. // state := 1
  65. if state < 0 {
  66. c.ServeSuccessJSON(map[string]interface{}{
  67. "version": appVersion,
  68. "state": appVersion.Status,
  69. })
  70. return
  71. }
  72. c.ServeSuccessJSON(map[string]interface{}{
  73. "version": nil,
  74. "state": 2,
  75. })
  76. return
  77. }
  78. func (this *PublicApiController) GetJson() {
  79. type Global struct {
  80. DeviceSN string
  81. Version string
  82. Timestamp string
  83. InterfaceSource string
  84. }
  85. type RBPResultModel struct {
  86. Sys string
  87. Dia string
  88. HR string
  89. MeasureTime string
  90. }
  91. type ScannerResultModel struct {
  92. Code string
  93. }
  94. type IDCardResultModel struct {
  95. IDCardNo string
  96. UserName string
  97. Age string
  98. Female string
  99. Male string
  100. SocialSecurityNo string
  101. }
  102. type JsonTemp struct {
  103. Global Global
  104. RBPResultModel RBPResultModel
  105. ScannerResultModel ScannerResultModel
  106. IDCardResultModel IDCardResultModel
  107. }
  108. var person JsonTemp
  109. err3 := json.Unmarshal([]byte(this.GetString("params")), &person)
  110. fmt.Println(err3)
  111. fmt.Println(person.Global)
  112. //temp := JsonTemp{
  113. // Global:Global{
  114. // DeviceSN:"1122",
  115. // Version:"1122",
  116. // Timestamp:"1222",
  117. // InterfaceSource:"1233",
  118. // },
  119. // RBPResultModel: RBPResultModel{
  120. // Sys:"12",
  121. // Dia:"22",
  122. // HR:"23",
  123. // MeasureTime:"123",
  124. // },
  125. // ScannerResultModel:ScannerResultModel{
  126. // Code:"1233",
  127. // },
  128. // IDCardResultModel:IDCardResultModel{
  129. // IDCardNo:"123",
  130. // UserName:"123",
  131. // Age:"123",
  132. // Female:"123",
  133. // Male:"123",
  134. // SocialSecurityNo:"123",
  135. // },
  136. //}
  137. //
  138. //jsonBytes, err := json.Marshal(temp)
  139. //if err != nil {
  140. // fmt.Println(err)
  141. //}
  142. //fmt.Println(string(jsonBytes))
  143. }
  144. func (c *PublicApiController) HandleData() {
  145. //service.HandleData()
  146. org_app, _ := service.GetAllAppOrg()
  147. //org_role, _ := service.GetAllRole()
  148. //
  149. //var org_ids []int64
  150. for _, apps := range org_app {
  151. xt_org_app, _ := service.GetAppByType(int64(apps.OrgId), 3)
  152. //org_app_6, _ := service.GetAppByType(int64(apps.OrgId), 6)
  153. //org_app_7, _ := service.GetAppByType(int64(apps.OrgId), 7)
  154. //org_app_8, _ := service.GetAppByType(int64(apps.OrgId), 8)
  155. //org_app_9, _ := service.GetAppByType(int64(apps.OrgId), 9)
  156. //org_app_10, _ := service.GetAppByType(int64(apps.OrgId), 10)
  157. //org_app_11, _ := service.GetAppByType(int64(apps.OrgId), 11)
  158. //org_app_12, _ := service.GetAppByType(int64(apps.OrgId), 12)
  159. //org_app_13, _ := service.GetAppByType(int64(apps.OrgId), 13)
  160. //org_app_14, _ := service.GetAppByType(int64(apps.OrgId), 14)
  161. //org_app_15, _ := service.GetAppByType(int64(apps.OrgId), 15)
  162. //org_app_16, _ := service.GetAppByType(int64(apps.OrgId), 16)
  163. //org_app_17, _ := service.GetAppByType(int64(apps.OrgId), 17)
  164. org_app_18, _ := service.GetAppByType(int64(apps.OrgId), 18)
  165. var xt_temp_org_app *models.OrgApp
  166. //var mall_temp_org_app *models.OrgApp
  167. if xt_org_app == nil || xt_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  168. app, _ := service.GetOrgAppA(0, 3)
  169. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  170. if org == nil || org.Id == 0 {
  171. continue
  172. }
  173. app.Id = 0
  174. app.OrgId = apps.OrgId
  175. app.Creator = int(org.Creator)
  176. app.Number = 0
  177. app.Status = 1
  178. app.ModifyTime = time.Now().Unix()
  179. app.CreateTime = time.Now().Unix()
  180. service.CreateOrgApp(app)
  181. xt_temp_org_app = app
  182. } else {
  183. xt_temp_org_app = xt_org_app
  184. }
  185. //if scrm_org_app == nil || scrm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  186. //
  187. // app, _ := service.GetOrgAppA(0, 1)
  188. // //org, _ := service.GetOrgById(int64(12))
  189. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  190. // if org == nil || org.Id == 0 {
  191. // continue
  192. // }
  193. //
  194. //
  195. // app.OrgId = apps.OrgId
  196. // app.Id = 0
  197. //
  198. // app.Creator = int(org.Creator)
  199. // app.Number = 0
  200. // app.Status = 1
  201. // app.ModifyTime = time.Now().Unix()
  202. // app.CreateTime = time.Now().Unix()
  203. // service.CreateOrgApp(app)
  204. //
  205. //}
  206. //
  207. //if cdm_org_app == nil || cdm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  208. // app, _ := service.GetOrgAppA(0, 4)
  209. // //org, _ := service.GetOrgById(int64(12))
  210. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  211. // if org == nil || org.Id == 0 {
  212. // continue
  213. // }
  214. //
  215. //
  216. // app.OrgId = apps.OrgId
  217. // app.Creator = int(org.Creator)
  218. // app.Number = 0
  219. // app.Id = 0
  220. //
  221. // app.Status = 1
  222. // app.ModifyTime = time.Now().Unix()
  223. // app.CreateTime = time.Now().Unix()
  224. // service.CreateOrgApp(app)
  225. //}
  226. //
  227. //if mall_org_app == nil || mall_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  228. // app, _ := service.GetOrgAppA(0, 5)
  229. // //org, _ := service.GetOrgById(int64(12))
  230. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  231. //
  232. // if org == nil || org.Id == 0 {
  233. // continue
  234. // }
  235. //
  236. // app.OrgId = apps.OrgId
  237. // app.Creator = int(org.Creator)
  238. // app.Number = 0
  239. // app.Id = 0
  240. //
  241. // app.Status = 1
  242. // app.ModifyTime = time.Now().Unix()
  243. // app.CreateTime = time.Now().Unix()
  244. // service.CreateOrgApp(app)
  245. // mall_temp_org_app = app
  246. //} else {
  247. // mall_temp_org_app = mall_org_app
  248. //}
  249. //
  250. //if org_app_16 == nil || org_app_16.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  251. // app, _ := service.GetOrgAppA(0, 16)
  252. // //org, _ := service.GetOrgById(int64(12))
  253. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  254. // if org == nil || org.Id == 0 {
  255. // continue
  256. // }
  257. //
  258. // app.OrgId = apps.OrgId
  259. // app.Creator = int(org.Creator)
  260. // app.Number = 11
  261. // app.Id = 0
  262. // app.Status = 1
  263. // app.ModifyTime = time.Now().Unix()
  264. // app.CreateTime = time.Now().Unix()
  265. // app.Pid = xt_temp_org_app.Id
  266. // service.CreateOrgApp(app)
  267. //
  268. //}
  269. //
  270. //if org_app_17 == nil || org_app_17.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  271. // app, _ := service.GetOrgAppA(0, 17)
  272. // //org, _ := service.GetOrgById(int64(12))
  273. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  274. // if org == nil || org.Id == 0 {
  275. // continue
  276. // }
  277. //
  278. // app.OrgId = apps.OrgId
  279. // app.Creator = int(org.Creator)
  280. // app.Number = 12
  281. // app.Id = 0
  282. // app.Status = 1
  283. // app.ModifyTime = time.Now().Unix()
  284. // app.CreateTime = time.Now().Unix()
  285. // app.Pid = xt_temp_org_app.Id
  286. // service.CreateOrgApp(app)
  287. //
  288. //}
  289. if org_app_18 == nil || org_app_18.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  290. app, _ := service.GetOrgAppA(0, 18)
  291. //org, _ := service.GetOrgById(int64(12))
  292. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  293. if org == nil || org.Id == 0 {
  294. continue
  295. }
  296. app.OrgId = apps.OrgId
  297. app.Creator = int(org.Creator)
  298. app.Number = 5
  299. app.Id = 0
  300. app.Status = 1
  301. app.ModifyTime = time.Now().Unix()
  302. app.CreateTime = time.Now().Unix()
  303. app.Pid = xt_temp_org_app.Id
  304. service.CreateOrgApp(app)
  305. }
  306. //if org_app_7 == nil || org_app_7.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  307. // app, _ := service.GetOrgAppA(0, 7)
  308. // //org, _ := service.GetOrgById(int64(12))
  309. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  310. // if org == nil || org.Id == 0 {
  311. // continue
  312. // }
  313. //
  314. //
  315. // app.OrgId = apps.OrgId
  316. // app.Creator = int(org.Creator)
  317. // app.Number = 2
  318. // app.Status = 2
  319. // app.Id = 0
  320. //
  321. // app.ModifyTime = time.Now().Unix()
  322. // app.CreateTime = time.Now().Unix()
  323. // app.Pid = xt_temp_org_app.Id
  324. //
  325. // service.CreateOrgApp(app)
  326. //}
  327. //if org_app_8 == nil || org_app_8.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  328. // app, _ := service.GetOrgAppA(0, 8)
  329. // //org, _ := service.GetOrgById(int64(12))
  330. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  331. // if org == nil || org.Id == 0 {
  332. // continue
  333. // }
  334. //
  335. //
  336. // app.OrgId = apps.OrgId
  337. // app.Creator = int(org.Creator)
  338. // app.Number = 3
  339. // app.Id = 0
  340. //
  341. // app.Pid = mall_temp_org_app.Id
  342. //
  343. // app.Status = 1
  344. // app.ModifyTime = time.Now().Unix()
  345. // app.CreateTime = time.Now().Unix()
  346. // service.CreateOrgApp(app)
  347. //}
  348. //if org_app_9 == nil || org_app_9.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  349. // app, _ := service.GetOrgAppA(0, 9)
  350. // //org, _ := service.GetOrgById(int64(12))
  351. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  352. // if org == nil || org.Id == 0 {
  353. // continue
  354. // }
  355. //
  356. //
  357. // app.OrgId = apps.OrgId
  358. // app.Pid = xt_temp_org_app.Id
  359. //
  360. // app.Creator = int(org.Creator)
  361. // app.Number = 4
  362. // app.Id = 0
  363. //
  364. // app.Status = 1
  365. // app.ModifyTime = time.Now().Unix()
  366. // app.CreateTime = time.Now().Unix()
  367. // service.CreateOrgApp(app)
  368. //
  369. //}
  370. //if org_app_10 == nil || org_app_10.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  371. // app, _ := service.GetOrgAppA(0, 10)
  372. // //org, _ := service.GetOrgById(int64(12))
  373. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  374. // if org == nil || org.Id == 0 {
  375. // continue
  376. // }
  377. //
  378. //
  379. // app.OrgId = apps.OrgId
  380. // app.Creator = int(org.Creator)
  381. // app.Pid = xt_temp_org_app.Id
  382. //
  383. // app.Number = 5
  384. // app.Id = 0
  385. //
  386. // app.Status = 1
  387. // app.ModifyTime = time.Now().Unix()
  388. // app.CreateTime = time.Now().Unix()
  389. // service.CreateOrgApp(app)
  390. //}
  391. //if org_app_11 == nil || org_app_11.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  392. // app, _ := service.GetOrgAppA(0, 11)
  393. // //org, _ := service.GetOrgById(int64(12))
  394. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  395. // if org == nil || org.Id == 0 {
  396. // continue
  397. // }
  398. //
  399. //
  400. // app.OrgId = apps.OrgId
  401. // app.Creator = int(org.Creator)
  402. // app.Pid = xt_temp_org_app.Id
  403. // app.Id = 0
  404. //
  405. // app.Number = 6
  406. // app.Status = 1
  407. // app.ModifyTime = time.Now().Unix()
  408. // app.CreateTime = time.Now().Unix()
  409. // service.CreateOrgApp(app)
  410. //}
  411. //if org_app_12 == nil || org_app_12.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  412. // app, _ := service.GetOrgAppA(0, 12)
  413. // //org, _ := service.GetOrgById(int64(12))
  414. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  415. // if org == nil || org.Id == 0 {
  416. // continue
  417. // }
  418. //
  419. //
  420. // app.OrgId = apps.OrgId
  421. // app.Creator = int(org.Creator)
  422. // app.Pid = xt_temp_org_app.Id
  423. // app.Number = 7
  424. // app.Status = 1
  425. // app.Id = 0
  426. //
  427. // app.ModifyTime = time.Now().Unix()
  428. // app.CreateTime = time.Now().Unix()
  429. // service.CreateOrgApp(app)
  430. //}
  431. //if org_app_13 == nil || org_app_13.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  432. // app, _ := service.GetOrgAppA(0, 13)
  433. // //org, _ := service.GetOrgById(int64(12))
  434. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  435. // if org == nil || org.Id == 0 {
  436. // continue
  437. // }
  438. //
  439. //
  440. // app.OrgId = apps.OrgId
  441. // app.Creator = int(org.Creator)
  442. // app.Pid = xt_temp_org_app.Id
  443. // app.Number = 8
  444. // app.Id = 0
  445. // app.Status = 1
  446. // app.ModifyTime = time.Now().Unix()
  447. // app.CreateTime = time.Now().Unix()
  448. // service.CreateOrgApp(app)
  449. //}
  450. //if org_app_14 == nil || org_app_14.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  451. // app, _ := service.GetOrgAppA(0, 14)
  452. // //org, _ := service.GetOrgById(int64(12))
  453. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  454. // if org == nil || org.Id == 0 {
  455. // continue
  456. // }
  457. //
  458. //
  459. // app.OrgId = apps.OrgId
  460. // app.Creator = int(org.Creator)
  461. // app.Pid = xt_temp_org_app.Id
  462. // app.Id = 0
  463. // app.Number = 9
  464. // app.Status = 1
  465. // app.ModifyTime = time.Now().Unix()
  466. // app.CreateTime = time.Now().Unix()
  467. // service.CreateOrgApp(app)
  468. //}
  469. //if org_app_15 == nil || org_app_15.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  470. // app, _ := service.GetOrgAppA(0, 15)
  471. // //org, _ := service.GetOrgById(int64(12))
  472. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  473. // if org == nil || org.Id == 0 {
  474. // continue
  475. // }
  476. //
  477. // app.OrgId = apps.OrgId
  478. // app.Creator = int(org.Creator)
  479. // app.Pid = xt_temp_org_app.Id
  480. // app.Number = 10
  481. // app.Status = 1
  482. // app.Id = 0
  483. // app.ModifyTime = time.Now().Unix()
  484. // app.CreateTime = time.Now().Unix()
  485. // service.CreateOrgApp(app)
  486. //}
  487. }
  488. //for _, role := range org_role {
  489. // org_ids = append(org_ids, role.OrgId)
  490. //}
  491. //
  492. //
  493. ////创建内置角色
  494. //InitRoleAndPurviews(org_ids)
  495. //var org_id int = 0
  496. //管理员
  497. //app_roles := service.GetAllUserRoleByUserTypeOne(org_id)
  498. //for _, item := range app_roles{
  499. // var ids string
  500. // if len(item.RoleIds) == 0{
  501. // ids = strconv.FormatInt( item.RoleId,10)
  502. // }else{
  503. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  504. // }
  505. // service.UpdateRoleIds(item.Id, ids)
  506. //}
  507. //护士医生
  508. //app_roles2 := service.GetAllUserRoleByUserTypeOther()
  509. // for _, item := range app_roles2{
  510. // var ids string
  511. // if len(item.RoleIds) == 0{
  512. // ids = strconv.FormatInt( item.RoleId,10)
  513. // }else{
  514. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  515. // }
  516. // if item.UserType == 2{
  517. // role := service.FindRoleByUserTypeOne(item.OrgId)
  518. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  519. //
  520. // } else if item.UserType == 3{
  521. // role := service.FindRoleByUserTypeTwo(item.OrgId)
  522. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  523. // }
  524. // service.UpdateRoleIds(item.Id, ids)
  525. // }
  526. //c.ServeSuccessJSON(map[string]interface{}{
  527. // "msg": "ok",
  528. //})
  529. }
  530. func InitRoleAndPurviews(org_ids []int64) {
  531. roles := LoadRoleConfig("./role.json").Roles
  532. for _, org_id := range org_ids {
  533. app, _ := service.GetOrgAppB(org_id, 3)
  534. role, _ := service.GetSystemRole(org_id)
  535. if app == nil || app.Id == 0 {
  536. continue
  537. }
  538. if len(role) == 0 {
  539. for _, item := range roles {
  540. role := &models.Role{
  541. RoleName: item.RoleName,
  542. RoleIntro: item.RoleIntroduction,
  543. Creator: 0,
  544. OrgId: org_id,
  545. AppId: app.Id,
  546. IsSuperAdmin: false,
  547. Status: 1,
  548. CreateTime: time.Now().Unix(),
  549. ModifyTime: time.Now().Unix(),
  550. Number: item.Number,
  551. IsSystem: item.IsSystem,
  552. }
  553. err := service.CreateOrgRoleB(role)
  554. if err == nil {
  555. purview := &models.RolePurview{
  556. RoleId: role.Id,
  557. OrgId: org_id,
  558. AppId: role.AppId,
  559. PurviewIds: item.PurviewIds,
  560. Status: 1,
  561. CreateTime: time.Now().Unix(),
  562. ModifyTime: time.Now().Unix(),
  563. }
  564. func_purview := &models.SgjUserRoleFuncPurview{
  565. RoleId: role.Id,
  566. OrgId: org_id,
  567. AppId: role.AppId,
  568. PurviewIds: item.FuncIds,
  569. Status: 1,
  570. Ctime: time.Now().Unix(),
  571. Mtime: time.Now().Unix(),
  572. }
  573. service.CreateRolePurviewB(purview)
  574. service.CreateFuncRolePurviewB(func_purview)
  575. }
  576. }
  577. }
  578. }
  579. }
  580. type RoleConfig struct {
  581. Roles []*models.VMUserRoleAndPurview "json:roles"
  582. }
  583. func LoadRoleConfig(dataFile string) *RoleConfig {
  584. var config RoleConfig
  585. _, filename, _, _ := runtime.Caller(1)
  586. datapath := path.Join(path.Dir(filename), dataFile)
  587. config_file, err := os.Open(datapath)
  588. if err != nil {
  589. emit("Failed to open config file '%s': %s\n", datapath, err)
  590. return &config
  591. }
  592. fi, _ := config_file.Stat()
  593. buffer := make([]byte, fi.Size())
  594. _, err = config_file.Read(buffer)
  595. buffer, err = StripComments(buffer) //去掉注释
  596. if err != nil {
  597. emit("Failed to strip comments from json: %s\n", err)
  598. return &config
  599. }
  600. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  601. err = json.Unmarshal(buffer, &config) //解析json格式数据
  602. if err != nil {
  603. emit("Failed unmarshalling json: %s\n", err)
  604. return &config
  605. }
  606. return &config
  607. }
  608. type GoodTypesConfig struct {
  609. GoodTypes []*models.VMGoodsType "json:list"
  610. }
  611. func LoadGoodTypeConfig(dataFile string) *GoodTypesConfig {
  612. var config GoodTypesConfig
  613. _, filename, _, _ := runtime.Caller(1)
  614. datapath := path.Join(path.Dir(filename), dataFile)
  615. config_file, err := os.Open(datapath)
  616. if err != nil {
  617. emit("Failed to open config file '%s': %s\n", datapath, err)
  618. return &config
  619. }
  620. fi, _ := config_file.Stat()
  621. buffer := make([]byte, fi.Size())
  622. _, err = config_file.Read(buffer)
  623. buffer, err = StripComments(buffer) //去掉注释
  624. if err != nil {
  625. emit("Failed to strip comments from json: %s\n", err)
  626. return &config
  627. }
  628. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  629. err = json.Unmarshal(buffer, &config) //解析json格式数据
  630. if err != nil {
  631. emit("Failed unmarshalling json: %s\n", err)
  632. return &config
  633. }
  634. return &config
  635. }
  636. func (c *PublicApiController) HandleStockData() {
  637. org, _ := service.FindAllOrgByImportType()
  638. for _, item := range org {
  639. if item.Id != 3907 || item.Id != 9779 || item.Id != 9883 {
  640. goodTypes := &models.GoodsType{
  641. TypeCode: "14000000",
  642. TypeName: "穿刺针",
  643. Remark: "",
  644. Ctime: time.Now().Unix(),
  645. Mtime: time.Now().Unix(),
  646. Creater: 0,
  647. Modifier: 0,
  648. OrgId: item.Id,
  649. Status: 1,
  650. Type: 1,
  651. Number: 1,
  652. }
  653. service.AddSigleGoodType(goodTypes)
  654. goodTypes1 := &models.GoodsType{
  655. TypeCode: "14000001",
  656. TypeName: "透析器",
  657. Remark: "",
  658. Ctime: time.Now().Unix(),
  659. Mtime: time.Now().Unix(),
  660. Creater: 0,
  661. Modifier: 0,
  662. OrgId: item.Id,
  663. Status: 1,
  664. Type: 1,
  665. Number: 2,
  666. }
  667. service.AddSigleGoodType(goodTypes1)
  668. goodTypes2 := &models.GoodsType{
  669. TypeCode: "14000002",
  670. TypeName: "灌流器",
  671. Remark: "",
  672. Ctime: time.Now().Unix(),
  673. Mtime: time.Now().Unix(),
  674. Creater: 0,
  675. Modifier: 0,
  676. OrgId: item.Id,
  677. Status: 1,
  678. Type: 1,
  679. Number: 3,
  680. }
  681. service.AddSigleGoodType(goodTypes2)
  682. goodTypes3 := &models.GoodsType{
  683. TypeCode: "14000003",
  684. TypeName: "血路管",
  685. Remark: "",
  686. Ctime: time.Now().Unix(),
  687. Mtime: time.Now().Unix(),
  688. Creater: 0,
  689. Modifier: 0,
  690. OrgId: item.Id,
  691. Status: 1,
  692. Type: 1,
  693. Number: 4,
  694. }
  695. service.AddSigleGoodType(goodTypes3)
  696. goodTypes4 := &models.GoodsType{
  697. TypeCode: "14000004",
  698. TypeName: "血滤补液管",
  699. Remark: "",
  700. Ctime: time.Now().Unix(),
  701. Mtime: time.Now().Unix(),
  702. Creater: 0,
  703. Modifier: 0,
  704. OrgId: item.Id,
  705. Status: 1,
  706. Type: 1,
  707. Number: 5,
  708. }
  709. service.AddSigleGoodType(goodTypes4)
  710. goodTypes5 := &models.GoodsType{
  711. TypeCode: "14000005",
  712. TypeName: "注射器",
  713. Remark: "",
  714. Ctime: time.Now().Unix(),
  715. Mtime: time.Now().Unix(),
  716. Creater: 0,
  717. Modifier: 0,
  718. OrgId: item.Id,
  719. Status: 1,
  720. Type: 1,
  721. Number: 6,
  722. }
  723. service.AddSigleGoodType(goodTypes5)
  724. goodTypes6 := &models.GoodsType{
  725. TypeCode: "14000006",
  726. TypeName: "护理包(内瘘穿刺包)",
  727. Remark: "",
  728. Ctime: time.Now().Unix(),
  729. Mtime: time.Now().Unix(),
  730. Creater: 0,
  731. Modifier: 0,
  732. OrgId: item.Id,
  733. Status: 1,
  734. Type: 1,
  735. Number: 7,
  736. }
  737. service.AddSigleGoodType(goodTypes6)
  738. goodTypes7 := &models.GoodsType{
  739. TypeCode: "14000007",
  740. TypeName: "细菌过滤器",
  741. Remark: "",
  742. Ctime: time.Now().Unix(),
  743. Mtime: time.Now().Unix(),
  744. Creater: 0,
  745. Modifier: 0,
  746. OrgId: item.Id,
  747. Status: 1,
  748. Type: 1,
  749. Number: 8,
  750. }
  751. service.AddSigleGoodType(goodTypes7)
  752. goodTypes8 := &models.GoodsType{
  753. TypeCode: "14000008",
  754. TypeName: "血液透析干粉",
  755. Remark: "",
  756. Ctime: time.Now().Unix(),
  757. Mtime: time.Now().Unix(),
  758. Creater: 0,
  759. Modifier: 0,
  760. OrgId: item.Id,
  761. Status: 1,
  762. Type: 1,
  763. Number: 9,
  764. }
  765. service.AddSigleGoodType(goodTypes8)
  766. goodTypes9 := &models.GoodsType{
  767. TypeCode: "14000009",
  768. TypeName: "A液",
  769. Remark: "",
  770. Ctime: time.Now().Unix(),
  771. Mtime: time.Now().Unix(),
  772. Creater: 0,
  773. Modifier: 0,
  774. OrgId: item.Id,
  775. Status: 1,
  776. Type: 1,
  777. Number: 10,
  778. }
  779. service.AddSigleGoodType(goodTypes9)
  780. goodTypes10 := &models.GoodsType{
  781. TypeCode: "14000010",
  782. TypeName: "B液",
  783. Remark: "",
  784. Ctime: time.Now().Unix(),
  785. Mtime: time.Now().Unix(),
  786. Creater: 0,
  787. Modifier: 0,
  788. OrgId: item.Id,
  789. Status: 1,
  790. Type: 1,
  791. Number: 11,
  792. }
  793. service.AddSigleGoodType(goodTypes10)
  794. goodTypes11 := &models.GoodsType{
  795. TypeCode: "14000011",
  796. TypeName: "导管包",
  797. Remark: "",
  798. Ctime: time.Now().Unix(),
  799. Mtime: time.Now().Unix(),
  800. Creater: 0,
  801. Modifier: 0,
  802. OrgId: item.Id,
  803. Status: 1,
  804. Type: 1,
  805. Number: 12,
  806. }
  807. service.AddSigleGoodType(goodTypes11)
  808. goodTypes12 := &models.GoodsType{
  809. TypeCode: "14000012",
  810. TypeName: "血液透析导管",
  811. Remark: "",
  812. Ctime: time.Now().Unix(),
  813. Mtime: time.Now().Unix(),
  814. Creater: 0,
  815. Modifier: 0,
  816. OrgId: item.Id,
  817. Status: 1,
  818. Type: 1,
  819. Number: 13,
  820. }
  821. service.AddSigleGoodType(goodTypes12)
  822. }
  823. }
  824. }
  825. func (c *PublicApiController) HandleComData() {
  826. org_ids := []int64{3907, 9779, 9883}
  827. for _, id := range org_ids {
  828. //查处所有处方记录
  829. prescriptions, _ := service.FindAllPrescription(id)
  830. if id == 3907 {
  831. for _, item := range prescriptions {
  832. if item.Niprocart > 0 {
  833. before := &models.DialysisBeforePrepare{
  834. UserOrgId: id,
  835. PatientId: item.PatientId,
  836. RecordDate: item.RecordDate,
  837. Count: 1,
  838. Ctime: item.RecordDate,
  839. Mtime: item.RecordDate,
  840. Creater: item.Creater,
  841. Modifier: item.Creater,
  842. Status: 1,
  843. }
  844. before.GoodId = item.Niprocart
  845. before.GoodTypeId = 241
  846. service.AddSigleDialysisBeforePre(before)
  847. }
  848. if item.Jms > 0 {
  849. before := &models.DialysisBeforePrepare{
  850. UserOrgId: id,
  851. PatientId: item.PatientId,
  852. RecordDate: item.RecordDate,
  853. Count: 1,
  854. Ctime: item.RecordDate,
  855. Mtime: item.RecordDate,
  856. Creater: item.Creater,
  857. Modifier: item.Creater,
  858. Status: 1,
  859. }
  860. before.GoodId = item.Jms
  861. before.GoodTypeId = 233
  862. service.AddSigleDialysisBeforePre(before)
  863. }
  864. if item.FistulaNeedleSet > 0 {
  865. before := &models.DialysisBeforePrepare{
  866. UserOrgId: id,
  867. PatientId: item.PatientId,
  868. RecordDate: item.RecordDate,
  869. Count: 1,
  870. Ctime: item.RecordDate,
  871. Mtime: item.RecordDate,
  872. Creater: item.Creater,
  873. Modifier: item.Creater,
  874. Status: 1,
  875. }
  876. before.GoodId = item.FistulaNeedleSet
  877. before.GoodTypeId = 233
  878. service.AddSigleDialysisBeforePre(before)
  879. }
  880. if item.FistulaNeedleSet16 > 0 {
  881. before := &models.DialysisBeforePrepare{
  882. UserOrgId: id,
  883. PatientId: item.PatientId,
  884. RecordDate: item.RecordDate,
  885. Count: 1,
  886. Ctime: item.RecordDate,
  887. Mtime: item.RecordDate,
  888. Creater: item.Creater,
  889. Modifier: item.Creater,
  890. Status: 1,
  891. }
  892. before.GoodId = item.FistulaNeedleSet16
  893. before.GoodTypeId = 233
  894. service.AddSigleDialysisBeforePre(before)
  895. }
  896. if item.Hemoperfusion > 0 {
  897. before := &models.DialysisBeforePrepare{
  898. UserOrgId: id,
  899. PatientId: item.PatientId,
  900. RecordDate: item.RecordDate,
  901. Count: 1,
  902. Ctime: item.RecordDate,
  903. Mtime: item.RecordDate,
  904. Creater: item.Creater,
  905. Modifier: item.Creater,
  906. Status: 1,
  907. }
  908. before.GoodId = item.Hemoperfusion
  909. before.GoodTypeId = 235
  910. service.AddSigleDialysisBeforePre(before)
  911. }
  912. if item.DialyserSterilised > 0 {
  913. before := &models.DialysisBeforePrepare{
  914. UserOrgId: id,
  915. PatientId: item.PatientId,
  916. RecordDate: item.RecordDate,
  917. Count: 1,
  918. Ctime: item.RecordDate,
  919. Mtime: item.RecordDate,
  920. Creater: item.Creater,
  921. Modifier: item.Creater,
  922. Status: 1,
  923. }
  924. before.GoodId = item.DialyserSterilised
  925. before.GoodTypeId = 234
  926. service.AddSigleDialysisBeforePre(before)
  927. }
  928. if item.Filtryzer > 0 {
  929. before := &models.DialysisBeforePrepare{
  930. UserOrgId: id,
  931. PatientId: item.PatientId,
  932. RecordDate: item.RecordDate,
  933. Count: 1,
  934. Ctime: item.RecordDate,
  935. Mtime: item.RecordDate,
  936. Creater: item.Creater,
  937. Modifier: item.Creater,
  938. Status: 1,
  939. }
  940. before.GoodId = item.Filtryzer
  941. before.GoodTypeId = 234
  942. service.AddSigleDialysisBeforePre(before)
  943. }
  944. if item.Dialyzers > 0 {
  945. before := &models.DialysisBeforePrepare{
  946. UserOrgId: id,
  947. PatientId: item.PatientId,
  948. RecordDate: item.RecordDate,
  949. Count: 1,
  950. Ctime: item.RecordDate,
  951. Mtime: item.RecordDate,
  952. Creater: item.Creater,
  953. Modifier: item.Creater,
  954. Status: 1,
  955. }
  956. before.GoodId = item.Dialyzers
  957. before.GoodTypeId = 234
  958. service.AddSigleDialysisBeforePre(before)
  959. }
  960. if item.Injector > 0 {
  961. before := &models.DialysisBeforePrepare{
  962. UserOrgId: id,
  963. PatientId: item.PatientId,
  964. RecordDate: item.RecordDate,
  965. Count: 1,
  966. Ctime: item.RecordDate,
  967. Mtime: item.RecordDate,
  968. Creater: item.Creater,
  969. Modifier: item.Creater,
  970. Status: 1,
  971. }
  972. before.GoodId = item.Injector
  973. before.GoodTypeId = 238
  974. service.AddSigleDialysisBeforePre(before)
  975. }
  976. if item.Bloodlines > 0 {
  977. before := &models.DialysisBeforePrepare{
  978. UserOrgId: id,
  979. PatientId: item.PatientId,
  980. RecordDate: item.RecordDate,
  981. Count: 1,
  982. Ctime: item.RecordDate,
  983. Mtime: item.RecordDate,
  984. Creater: item.Creater,
  985. Modifier: item.Creater,
  986. Status: 1,
  987. }
  988. before.GoodId = item.Bloodlines
  989. before.GoodTypeId = 236
  990. service.AddSigleDialysisBeforePre(before)
  991. }
  992. if item.TubingHemodialysis > 0 {
  993. before := &models.DialysisBeforePrepare{
  994. UserOrgId: id,
  995. PatientId: item.PatientId,
  996. RecordDate: item.RecordDate,
  997. Count: 1,
  998. Ctime: item.RecordDate,
  999. Mtime: item.RecordDate,
  1000. Creater: item.Creater,
  1001. Modifier: item.Creater,
  1002. Status: 1,
  1003. }
  1004. before.GoodId = item.TubingHemodialysis
  1005. before.GoodTypeId = 237
  1006. service.AddSigleDialysisBeforePre(before)
  1007. }
  1008. if item.Package > 0 {
  1009. before := &models.DialysisBeforePrepare{
  1010. UserOrgId: id,
  1011. PatientId: item.PatientId,
  1012. RecordDate: item.RecordDate,
  1013. Count: 1,
  1014. Ctime: item.RecordDate,
  1015. Mtime: item.RecordDate,
  1016. Creater: item.Creater,
  1017. Modifier: item.Creater,
  1018. Status: 1,
  1019. }
  1020. before.GoodId = item.Package
  1021. before.GoodTypeId = 239
  1022. service.AddSigleDialysisBeforePre(before)
  1023. }
  1024. if item.ALiquid > 0 {
  1025. before := &models.DialysisBeforePrepare{
  1026. UserOrgId: id,
  1027. PatientId: item.PatientId,
  1028. RecordDate: item.RecordDate,
  1029. Count: 1,
  1030. Ctime: item.RecordDate,
  1031. Mtime: item.RecordDate,
  1032. Creater: item.Creater,
  1033. Modifier: item.Creater,
  1034. Status: 1,
  1035. }
  1036. before.GoodId = item.ALiquid
  1037. before.GoodTypeId = 242
  1038. service.AddSigleDialysisBeforePre(before)
  1039. }
  1040. }
  1041. } else if id == 9779 {
  1042. for _, item := range prescriptions {
  1043. if item.Niprocart > 0 {
  1044. before := &models.DialysisBeforePrepare{
  1045. UserOrgId: id,
  1046. PatientId: item.PatientId,
  1047. RecordDate: item.RecordDate,
  1048. Count: 1,
  1049. Ctime: item.RecordDate,
  1050. Mtime: item.RecordDate,
  1051. Creater: item.Creater,
  1052. Modifier: item.Creater,
  1053. Status: 1,
  1054. }
  1055. before.GoodId = item.Niprocart
  1056. before.GoodTypeId = 254
  1057. service.AddSigleDialysisBeforePre(before)
  1058. }
  1059. if item.Jms > 0 {
  1060. before := &models.DialysisBeforePrepare{
  1061. UserOrgId: id,
  1062. PatientId: item.PatientId,
  1063. RecordDate: item.RecordDate,
  1064. Count: 1,
  1065. Ctime: item.RecordDate,
  1066. Mtime: item.RecordDate,
  1067. Creater: item.Creater,
  1068. Modifier: item.Creater,
  1069. Status: 1,
  1070. }
  1071. before.GoodId = item.Jms
  1072. before.GoodTypeId = 246
  1073. service.AddSigleDialysisBeforePre(before)
  1074. }
  1075. if item.FistulaNeedleSet > 0 {
  1076. before := &models.DialysisBeforePrepare{
  1077. UserOrgId: id,
  1078. PatientId: item.PatientId,
  1079. RecordDate: item.RecordDate,
  1080. Count: 1,
  1081. Ctime: item.RecordDate,
  1082. Mtime: item.RecordDate,
  1083. Creater: item.Creater,
  1084. Modifier: item.Creater,
  1085. Status: 1,
  1086. }
  1087. before.GoodId = item.FistulaNeedleSet
  1088. before.GoodTypeId = 246
  1089. service.AddSigleDialysisBeforePre(before)
  1090. }
  1091. if item.FistulaNeedleSet16 > 0 {
  1092. before := &models.DialysisBeforePrepare{
  1093. UserOrgId: id,
  1094. PatientId: item.PatientId,
  1095. RecordDate: item.RecordDate,
  1096. Count: 1,
  1097. Ctime: item.RecordDate,
  1098. Mtime: item.RecordDate,
  1099. Creater: item.Creater,
  1100. Modifier: item.Creater,
  1101. Status: 1,
  1102. }
  1103. before.GoodId = item.FistulaNeedleSet16
  1104. before.GoodTypeId = 246
  1105. service.AddSigleDialysisBeforePre(before)
  1106. }
  1107. if item.Hemoperfusion > 0 {
  1108. before := &models.DialysisBeforePrepare{
  1109. UserOrgId: id,
  1110. PatientId: item.PatientId,
  1111. RecordDate: item.RecordDate,
  1112. Count: 1,
  1113. Ctime: item.RecordDate,
  1114. Mtime: item.RecordDate,
  1115. Creater: item.Creater,
  1116. Modifier: item.Creater,
  1117. Status: 1,
  1118. }
  1119. before.GoodId = item.Hemoperfusion
  1120. before.GoodTypeId = 248
  1121. service.AddSigleDialysisBeforePre(before)
  1122. }
  1123. if item.DialyserSterilised > 0 {
  1124. before := &models.DialysisBeforePrepare{
  1125. UserOrgId: id,
  1126. PatientId: item.PatientId,
  1127. RecordDate: item.RecordDate,
  1128. Count: 1,
  1129. Ctime: item.RecordDate,
  1130. Mtime: item.RecordDate,
  1131. Creater: item.Creater,
  1132. Modifier: item.Creater,
  1133. Status: 1,
  1134. }
  1135. before.GoodId = item.DialyserSterilised
  1136. before.GoodTypeId = 247
  1137. service.AddSigleDialysisBeforePre(before)
  1138. }
  1139. if item.Filtryzer > 0 {
  1140. before := &models.DialysisBeforePrepare{
  1141. UserOrgId: id,
  1142. PatientId: item.PatientId,
  1143. RecordDate: item.RecordDate,
  1144. Count: 1,
  1145. Ctime: item.RecordDate,
  1146. Mtime: item.RecordDate,
  1147. Creater: item.Creater,
  1148. Modifier: item.Creater,
  1149. Status: 1,
  1150. }
  1151. before.GoodId = item.Filtryzer
  1152. before.GoodTypeId = 247
  1153. service.AddSigleDialysisBeforePre(before)
  1154. }
  1155. if item.Dialyzers > 0 {
  1156. before := &models.DialysisBeforePrepare{
  1157. UserOrgId: id,
  1158. PatientId: item.PatientId,
  1159. RecordDate: item.RecordDate,
  1160. Count: 1,
  1161. Ctime: item.RecordDate,
  1162. Mtime: item.RecordDate,
  1163. Creater: item.Creater,
  1164. Modifier: item.Creater,
  1165. Status: 1,
  1166. }
  1167. before.GoodId = item.Dialyzers
  1168. before.GoodTypeId = 247
  1169. service.AddSigleDialysisBeforePre(before)
  1170. }
  1171. if item.Injector > 0 {
  1172. before := &models.DialysisBeforePrepare{
  1173. UserOrgId: id,
  1174. PatientId: item.PatientId,
  1175. RecordDate: item.RecordDate,
  1176. Count: 1,
  1177. Ctime: item.RecordDate,
  1178. Mtime: item.RecordDate,
  1179. Creater: item.Creater,
  1180. Modifier: item.Creater,
  1181. Status: 1,
  1182. }
  1183. before.GoodId = item.Injector
  1184. before.GoodTypeId = 251
  1185. service.AddSigleDialysisBeforePre(before)
  1186. }
  1187. if item.Bloodlines > 0 {
  1188. before := &models.DialysisBeforePrepare{
  1189. UserOrgId: id,
  1190. PatientId: item.PatientId,
  1191. RecordDate: item.RecordDate,
  1192. Count: 1,
  1193. Ctime: item.RecordDate,
  1194. Mtime: item.RecordDate,
  1195. Creater: item.Creater,
  1196. Modifier: item.Creater,
  1197. Status: 1,
  1198. }
  1199. before.GoodId = item.Bloodlines
  1200. before.GoodTypeId = 249
  1201. service.AddSigleDialysisBeforePre(before)
  1202. }
  1203. if item.TubingHemodialysis > 0 {
  1204. before := &models.DialysisBeforePrepare{
  1205. UserOrgId: id,
  1206. PatientId: item.PatientId,
  1207. RecordDate: item.RecordDate,
  1208. Count: 1,
  1209. Ctime: item.RecordDate,
  1210. Mtime: item.RecordDate,
  1211. Creater: item.Creater,
  1212. Modifier: item.Creater,
  1213. Status: 1,
  1214. }
  1215. before.GoodId = item.TubingHemodialysis
  1216. before.GoodTypeId = 250
  1217. service.AddSigleDialysisBeforePre(before)
  1218. }
  1219. if item.Package > 0 {
  1220. before := &models.DialysisBeforePrepare{
  1221. UserOrgId: id,
  1222. PatientId: item.PatientId,
  1223. RecordDate: item.RecordDate,
  1224. Count: 1,
  1225. Ctime: item.RecordDate,
  1226. Mtime: item.RecordDate,
  1227. Creater: item.Creater,
  1228. Modifier: item.Creater,
  1229. Status: 1,
  1230. }
  1231. before.GoodId = item.Package
  1232. before.GoodTypeId = 252
  1233. service.AddSigleDialysisBeforePre(before)
  1234. }
  1235. if item.ALiquid > 0 {
  1236. before := &models.DialysisBeforePrepare{
  1237. UserOrgId: id,
  1238. PatientId: item.PatientId,
  1239. RecordDate: item.RecordDate,
  1240. Count: 1,
  1241. Ctime: item.RecordDate,
  1242. Mtime: item.RecordDate,
  1243. Creater: item.Creater,
  1244. Modifier: item.Creater,
  1245. Status: 1,
  1246. }
  1247. before.GoodId = item.ALiquid
  1248. before.GoodTypeId = 255
  1249. service.AddSigleDialysisBeforePre(before)
  1250. }
  1251. }
  1252. } else if id == 9883 {
  1253. for _, item := range prescriptions {
  1254. if item.Niprocart > 0 {
  1255. before := &models.DialysisBeforePrepare{
  1256. UserOrgId: id,
  1257. PatientId: item.PatientId,
  1258. RecordDate: item.RecordDate,
  1259. Count: 1,
  1260. Ctime: item.RecordDate,
  1261. Mtime: item.RecordDate,
  1262. Creater: item.Creater,
  1263. Modifier: item.Creater,
  1264. Status: 1,
  1265. }
  1266. before.GoodId = item.Niprocart
  1267. before.GoodTypeId = 267
  1268. service.AddSigleDialysisBeforePre(before)
  1269. }
  1270. if item.Jms > 0 {
  1271. before := &models.DialysisBeforePrepare{
  1272. UserOrgId: id,
  1273. PatientId: item.PatientId,
  1274. RecordDate: item.RecordDate,
  1275. Count: 1,
  1276. Ctime: item.RecordDate,
  1277. Mtime: item.RecordDate,
  1278. Creater: item.Creater,
  1279. Modifier: item.Creater,
  1280. Status: 1,
  1281. }
  1282. before.GoodId = item.Jms
  1283. before.GoodTypeId = 259
  1284. service.AddSigleDialysisBeforePre(before)
  1285. }
  1286. if item.FistulaNeedleSet > 0 {
  1287. before := &models.DialysisBeforePrepare{
  1288. UserOrgId: id,
  1289. PatientId: item.PatientId,
  1290. RecordDate: item.RecordDate,
  1291. Count: 1,
  1292. Ctime: item.RecordDate,
  1293. Mtime: item.RecordDate,
  1294. Creater: item.Creater,
  1295. Modifier: item.Creater,
  1296. Status: 1,
  1297. }
  1298. before.GoodId = item.FistulaNeedleSet
  1299. before.GoodTypeId = 259
  1300. service.AddSigleDialysisBeforePre(before)
  1301. }
  1302. if item.FistulaNeedleSet16 > 0 {
  1303. before := &models.DialysisBeforePrepare{
  1304. UserOrgId: id,
  1305. PatientId: item.PatientId,
  1306. RecordDate: item.RecordDate,
  1307. Count: 1,
  1308. Ctime: item.RecordDate,
  1309. Mtime: item.RecordDate,
  1310. Creater: item.Creater,
  1311. Modifier: item.Creater,
  1312. Status: 1,
  1313. }
  1314. before.GoodId = item.FistulaNeedleSet16
  1315. before.GoodTypeId = 259
  1316. service.AddSigleDialysisBeforePre(before)
  1317. }
  1318. if item.Hemoperfusion > 0 {
  1319. before := &models.DialysisBeforePrepare{
  1320. UserOrgId: id,
  1321. PatientId: item.PatientId,
  1322. RecordDate: item.RecordDate,
  1323. Count: 1,
  1324. Ctime: item.RecordDate,
  1325. Mtime: item.RecordDate,
  1326. Creater: item.Creater,
  1327. Modifier: item.Creater,
  1328. Status: 1,
  1329. }
  1330. before.GoodId = item.Hemoperfusion
  1331. before.GoodTypeId = 261
  1332. service.AddSigleDialysisBeforePre(before)
  1333. }
  1334. if item.DialyserSterilised > 0 {
  1335. before := &models.DialysisBeforePrepare{
  1336. UserOrgId: id,
  1337. PatientId: item.PatientId,
  1338. RecordDate: item.RecordDate,
  1339. Count: 1,
  1340. Ctime: item.RecordDate,
  1341. Mtime: item.RecordDate,
  1342. Creater: item.Creater,
  1343. Modifier: item.Creater,
  1344. Status: 1,
  1345. }
  1346. before.GoodId = item.DialyserSterilised
  1347. before.GoodTypeId = 260
  1348. service.AddSigleDialysisBeforePre(before)
  1349. }
  1350. if item.Filtryzer > 0 {
  1351. before := &models.DialysisBeforePrepare{
  1352. UserOrgId: id,
  1353. PatientId: item.PatientId,
  1354. RecordDate: item.RecordDate,
  1355. Count: 1,
  1356. Ctime: item.RecordDate,
  1357. Mtime: item.RecordDate,
  1358. Creater: item.Creater,
  1359. Modifier: item.Creater,
  1360. Status: 1,
  1361. }
  1362. before.GoodId = item.Filtryzer
  1363. before.GoodTypeId = 260
  1364. service.AddSigleDialysisBeforePre(before)
  1365. }
  1366. if item.Dialyzers > 0 {
  1367. before := &models.DialysisBeforePrepare{
  1368. UserOrgId: id,
  1369. PatientId: item.PatientId,
  1370. RecordDate: item.RecordDate,
  1371. Count: 1,
  1372. Ctime: item.RecordDate,
  1373. Mtime: item.RecordDate,
  1374. Creater: item.Creater,
  1375. Modifier: item.Creater,
  1376. Status: 1,
  1377. }
  1378. before.GoodId = item.Dialyzers
  1379. before.GoodTypeId = 260
  1380. service.AddSigleDialysisBeforePre(before)
  1381. }
  1382. if item.Injector > 0 {
  1383. before := &models.DialysisBeforePrepare{
  1384. UserOrgId: id,
  1385. PatientId: item.PatientId,
  1386. RecordDate: item.RecordDate,
  1387. Count: 1,
  1388. Ctime: item.RecordDate,
  1389. Mtime: item.RecordDate,
  1390. Creater: item.Creater,
  1391. Modifier: item.Creater,
  1392. Status: 1,
  1393. }
  1394. before.GoodId = item.Injector
  1395. before.GoodTypeId = 264
  1396. service.AddSigleDialysisBeforePre(before)
  1397. }
  1398. if item.Bloodlines > 0 {
  1399. before := &models.DialysisBeforePrepare{
  1400. UserOrgId: id,
  1401. PatientId: item.PatientId,
  1402. RecordDate: item.RecordDate,
  1403. Count: 1,
  1404. Ctime: item.RecordDate,
  1405. Mtime: item.RecordDate,
  1406. Creater: item.Creater,
  1407. Modifier: item.Creater,
  1408. Status: 1,
  1409. }
  1410. before.GoodId = item.Bloodlines
  1411. before.GoodTypeId = 262
  1412. service.AddSigleDialysisBeforePre(before)
  1413. }
  1414. if item.TubingHemodialysis > 0 {
  1415. before := &models.DialysisBeforePrepare{
  1416. UserOrgId: id,
  1417. PatientId: item.PatientId,
  1418. RecordDate: item.RecordDate,
  1419. Count: 1,
  1420. Ctime: item.RecordDate,
  1421. Mtime: item.RecordDate,
  1422. Creater: item.Creater,
  1423. Modifier: item.Creater,
  1424. Status: 1,
  1425. }
  1426. before.GoodId = item.TubingHemodialysis
  1427. before.GoodTypeId = 263
  1428. service.AddSigleDialysisBeforePre(before)
  1429. }
  1430. if item.Package > 0 {
  1431. before := &models.DialysisBeforePrepare{
  1432. UserOrgId: id,
  1433. PatientId: item.PatientId,
  1434. RecordDate: item.RecordDate,
  1435. Count: 1,
  1436. Ctime: item.RecordDate,
  1437. Mtime: item.RecordDate,
  1438. Creater: item.Creater,
  1439. Modifier: item.Creater,
  1440. Status: 1,
  1441. }
  1442. before.GoodId = item.Package
  1443. before.GoodTypeId = 265
  1444. service.AddSigleDialysisBeforePre(before)
  1445. }
  1446. if item.ALiquid > 0 {
  1447. before := &models.DialysisBeforePrepare{
  1448. UserOrgId: id,
  1449. PatientId: item.PatientId,
  1450. RecordDate: item.RecordDate,
  1451. Count: 1,
  1452. Ctime: item.RecordDate,
  1453. Mtime: item.RecordDate,
  1454. Creater: item.Creater,
  1455. Modifier: item.Creater,
  1456. Status: 1,
  1457. }
  1458. before.GoodId = item.ALiquid
  1459. before.GoodTypeId = 268
  1460. service.AddSigleDialysisBeforePre(before)
  1461. }
  1462. }
  1463. }
  1464. }
  1465. }