public_api_controller.go 43KB

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