public_api_controller.go 44KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746
  1. package controllers
  2. import (
  3. "Xcx_New/enums"
  4. "Xcx_New/models"
  5. "Xcx_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. //var f_a *os.File
  20. //
  21. //
  22. // func init() {
  23. // org_id, _ := beego.AppConfig.Int64("org_id")
  24. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  25. // Mkdir(miConfig.OrgName+"日志")
  26. // month := time.Unix(1557042972, 0).Format("1")
  27. // year := time.Now().Format("2006")
  28. // month = time.Now().Format("01")
  29. // day := time.Now().Format("02")
  30. // file := strconv.FormatInt( org_id, 10) + "_"+ year + month + day + "_log"
  31. // file_name := file + ".txt"
  32. // file_path := miConfig.OrgName+"日志" + "/" + file_name
  33. // exist, _ := PathExists(file_path)
  34. // if exist {//存在
  35. // f_a, _ := os.OpenFile(file_path,os.O_WRONLY,0644)
  36. // content := "新的日志内容吧"
  37. // n, _ := f_a.Seek(0,2)
  38. // f_a.WriteAt([]byte(content),n)
  39. //
  40. // } else { //不存在
  41. // fmt.Println("文件不存在,创建文件")
  42. // f, err := os.Create(miConfig.OrgName+"日志" + "/" + file_name)
  43. // defer f.Close()
  44. // if err !=nil {
  45. // } else {
  46. // _,err=f.Write([]byte("记录日志"))
  47. // }
  48. // }
  49. //
  50. // }
  51. func PublicApiRegistRouters() {
  52. beego.Router("/api/public/getadviceconfig", &PublicApiController{}, "Get:GetDoctorAdviceConfig")
  53. beego.Router("/api/public/servertime", &PublicApiController{}, "Get:GetServerTime")
  54. beego.Router("/api/app/release", &PublicApiController{}, "Get:AppRelease")
  55. beego.Router("/api/get", &PublicApiController{}, "Get:GetJson")
  56. beego.Router("/api/public/handledata", &PublicApiController{}, "get:HandleData")
  57. beego.Router("/api/public/handlestockdata", &PublicApiController{}, "get:HandleStockData")
  58. beego.Router("/api/public/handlecomdata", &PublicApiController{}, "get:HandleComData")
  59. beego.Router("/hello", &PublicApiController{}, "get:HandleComData")
  60. beego.Router("/handel", &PublicApiController{}, "get:HandleHIS")
  61. //beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
  62. }
  63. func (c *PublicApiController) GetDoctorAdviceConfig() {
  64. drugs, _, _ := service.GetPublicDrugDics()
  65. drugways, _, _ := service.GetPublicDrugWayDics()
  66. efs, _, _ := service.GetPublicExecutionFrequencyDics()
  67. c.ServeSuccessJSON(map[string]interface{}{
  68. "drugs": drugs,
  69. "drugways": drugways,
  70. "efs": efs,
  71. })
  72. }
  73. func (c *PublicApiController) GetServerTime() {
  74. timeNow := time.Now()
  75. timeNowStamp := timeNow.Unix()
  76. timeNowStr := timeNow.Format("2006-01-02 15:04:05")
  77. c.ServeSuccessJSON(map[string]interface{}{
  78. "time": timeNowStr,
  79. "timestamp": timeNowStamp,
  80. })
  81. }
  82. func (c *PublicApiController) AppRelease() {
  83. // appId := c.GetString("appid")
  84. version := c.GetString("version")
  85. appType, _ := c.GetInt64("app_type", 0)
  86. appVersion, err := service.GetAppVersionByAppType(appType)
  87. if err != nil {
  88. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  89. return
  90. }
  91. if appVersion == nil {
  92. c.ServeSuccessJSON(map[string]interface{}{
  93. "version": nil,
  94. "state": 2,
  95. })
  96. return
  97. }
  98. state := strings.Compare(version, appVersion.Version)
  99. // state := 1
  100. if state < 0 {
  101. c.ServeSuccessJSON(map[string]interface{}{
  102. "version": appVersion,
  103. "state": appVersion.Status,
  104. })
  105. return
  106. }
  107. c.ServeSuccessJSON(map[string]interface{}{
  108. "version": nil,
  109. "state": 2,
  110. })
  111. return
  112. }
  113. func (this *PublicApiController) GetJson() {
  114. type Global struct {
  115. DeviceSN string
  116. Version string
  117. Timestamp string
  118. InterfaceSource string
  119. }
  120. type RBPResultModel struct {
  121. Sys string
  122. Dia string
  123. HR string
  124. MeasureTime string
  125. }
  126. type ScannerResultModel struct {
  127. Code string
  128. }
  129. type IDCardResultModel struct {
  130. IDCardNo string
  131. UserName string
  132. Age string
  133. Female string
  134. Male string
  135. SocialSecurityNo string
  136. }
  137. type JsonTemp struct {
  138. Global Global
  139. RBPResultModel RBPResultModel
  140. ScannerResultModel ScannerResultModel
  141. IDCardResultModel IDCardResultModel
  142. }
  143. var person JsonTemp
  144. err3 := json.Unmarshal([]byte(this.GetString("params")), &person)
  145. fmt.Println(err3)
  146. fmt.Println(person.Global)
  147. //temp := JsonTemp{
  148. // Global:Global{
  149. // DeviceSN:"1122",
  150. // Version:"1122",
  151. // Timestamp:"1222",
  152. // InterfaceSource:"1233",
  153. // },
  154. // RBPResultModel: RBPResultModel{
  155. // Sys:"12",
  156. // Dia:"22",
  157. // HR:"23",
  158. // MeasureTime:"123",
  159. // },
  160. // ScannerResultModel:ScannerResultModel{
  161. // Code:"1233",
  162. // },
  163. // IDCardResultModel:IDCardResultModel{
  164. // IDCardNo:"123",
  165. // UserName:"123",
  166. // Age:"123",
  167. // Female:"123",
  168. // Male:"123",
  169. // SocialSecurityNo:"123",
  170. // },
  171. //}
  172. //
  173. //jsonBytes, err := json.Marshal(temp)
  174. //if err != nil {
  175. // fmt.Println(err)
  176. //}
  177. //fmt.Println(string(jsonBytes))
  178. }
  179. func (c *PublicApiController) HandleData() {
  180. //service.HandleData()
  181. org_app, _ := service.GetAllAppOrg()
  182. //org_role, _ := service.GetAllRole()
  183. //
  184. //var org_ids []int64
  185. for _, apps := range org_app {
  186. xt_org_app, _ := service.GetAppByType(int64(apps.OrgId), 3)
  187. //org_app_6, _ := service.GetAppByType(int64(apps.OrgId), 6)
  188. //org_app_7, _ := service.GetAppByType(int64(apps.OrgId), 7)
  189. //org_app_8, _ := service.GetAppByType(int64(apps.OrgId), 8)
  190. //org_app_9, _ := service.GetAppByType(int64(apps.OrgId), 9)
  191. //org_app_10, _ := service.GetAppByType(int64(apps.OrgId), 10)
  192. //org_app_11, _ := service.GetAppByType(int64(apps.OrgId), 11)
  193. //org_app_12, _ := service.GetAppByType(int64(apps.OrgId), 12)
  194. //org_app_13, _ := service.GetAppByType(int64(apps.OrgId), 13)
  195. //org_app_14, _ := service.GetAppByType(int64(apps.OrgId), 14)
  196. //org_app_15, _ := service.GetAppByType(int64(apps.OrgId), 15)
  197. //org_app_16, _ := service.GetAppByType(int64(apps.OrgId), 16)
  198. //org_app_17, _ := service.GetAppByType(int64(apps.OrgId), 17)
  199. org_app_18, _ := service.GetAppByType(int64(apps.OrgId), 18)
  200. var xt_temp_org_app *models.OrgApp
  201. //var mall_temp_org_app *models.OrgApp
  202. if xt_org_app == nil || xt_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  203. app, _ := service.GetOrgAppA(0, 3)
  204. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  205. if org == nil || org.Id == 0 {
  206. continue
  207. }
  208. app.Id = 0
  209. app.OrgId = apps.OrgId
  210. app.Creator = int(org.Creator)
  211. app.Number = 0
  212. app.Status = 1
  213. app.ModifyTime = time.Now().Unix()
  214. app.CreateTime = time.Now().Unix()
  215. service.CreateOrgApp(app)
  216. xt_temp_org_app = app
  217. } else {
  218. xt_temp_org_app = xt_org_app
  219. }
  220. //if scrm_org_app == nil || scrm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  221. //
  222. // app, _ := service.GetOrgAppA(0, 1)
  223. // //org, _ := service.GetOrgById(int64(12))
  224. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  225. // if org == nil || org.Id == 0 {
  226. // continue
  227. // }
  228. //
  229. //
  230. // app.OrgId = apps.OrgId
  231. // app.Id = 0
  232. //
  233. // app.Creator = int(org.Creator)
  234. // app.Number = 0
  235. // app.Status = 1
  236. // app.ModifyTime = time.Now().Unix()
  237. // app.CreateTime = time.Now().Unix()
  238. // service.CreateOrgApp(app)
  239. //
  240. //}
  241. //
  242. //if cdm_org_app == nil || cdm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  243. // app, _ := service.GetOrgAppA(0, 4)
  244. // //org, _ := service.GetOrgById(int64(12))
  245. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  246. // if org == nil || org.Id == 0 {
  247. // continue
  248. // }
  249. //
  250. //
  251. // app.OrgId = apps.OrgId
  252. // app.Creator = int(org.Creator)
  253. // app.Number = 0
  254. // app.Id = 0
  255. //
  256. // app.Status = 1
  257. // app.ModifyTime = time.Now().Unix()
  258. // app.CreateTime = time.Now().Unix()
  259. // service.CreateOrgApp(app)
  260. //}
  261. //
  262. //if mall_org_app == nil || mall_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  263. // app, _ := service.GetOrgAppA(0, 5)
  264. // //org, _ := service.GetOrgById(int64(12))
  265. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  266. //
  267. // if org == nil || org.Id == 0 {
  268. // continue
  269. // }
  270. //
  271. // app.OrgId = apps.OrgId
  272. // app.Creator = int(org.Creator)
  273. // app.Number = 0
  274. // app.Id = 0
  275. //
  276. // app.Status = 1
  277. // app.ModifyTime = time.Now().Unix()
  278. // app.CreateTime = time.Now().Unix()
  279. // service.CreateOrgApp(app)
  280. // mall_temp_org_app = app
  281. //} else {
  282. // mall_temp_org_app = mall_org_app
  283. //}
  284. //
  285. //if org_app_16 == nil || org_app_16.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  286. // app, _ := service.GetOrgAppA(0, 16)
  287. // //org, _ := service.GetOrgById(int64(12))
  288. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  289. // if org == nil || org.Id == 0 {
  290. // continue
  291. // }
  292. //
  293. // app.OrgId = apps.OrgId
  294. // app.Creator = int(org.Creator)
  295. // app.Number = 11
  296. // app.Id = 0
  297. // app.Status = 1
  298. // app.ModifyTime = time.Now().Unix()
  299. // app.CreateTime = time.Now().Unix()
  300. // app.Pid = xt_temp_org_app.Id
  301. // service.CreateOrgApp(app)
  302. //
  303. //}
  304. //
  305. //if org_app_17 == nil || org_app_17.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  306. // app, _ := service.GetOrgAppA(0, 17)
  307. // //org, _ := service.GetOrgById(int64(12))
  308. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  309. // if org == nil || org.Id == 0 {
  310. // continue
  311. // }
  312. //
  313. // app.OrgId = apps.OrgId
  314. // app.Creator = int(org.Creator)
  315. // app.Number = 12
  316. // app.Id = 0
  317. // app.Status = 1
  318. // app.ModifyTime = time.Now().Unix()
  319. // app.CreateTime = time.Now().Unix()
  320. // app.Pid = xt_temp_org_app.Id
  321. // service.CreateOrgApp(app)
  322. //
  323. //}
  324. if org_app_18 == nil || org_app_18.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  325. app, _ := service.GetOrgAppA(0, 18)
  326. //org, _ := service.GetOrgById(int64(12))
  327. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  328. if org == nil || org.Id == 0 {
  329. continue
  330. }
  331. app.OrgId = apps.OrgId
  332. app.Creator = int(org.Creator)
  333. app.Number = 5
  334. app.Id = 0
  335. app.Status = 1
  336. app.ModifyTime = time.Now().Unix()
  337. app.CreateTime = time.Now().Unix()
  338. app.Pid = xt_temp_org_app.Id
  339. service.CreateOrgApp(app)
  340. }
  341. //if org_app_7 == nil || org_app_7.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  342. // app, _ := service.GetOrgAppA(0, 7)
  343. // //org, _ := service.GetOrgById(int64(12))
  344. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  345. // if org == nil || org.Id == 0 {
  346. // continue
  347. // }
  348. //
  349. //
  350. // app.OrgId = apps.OrgId
  351. // app.Creator = int(org.Creator)
  352. // app.Number = 2
  353. // app.Status = 2
  354. // app.Id = 0
  355. //
  356. // app.ModifyTime = time.Now().Unix()
  357. // app.CreateTime = time.Now().Unix()
  358. // app.Pid = xt_temp_org_app.Id
  359. //
  360. // service.CreateOrgApp(app)
  361. //}
  362. //if org_app_8 == nil || org_app_8.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  363. // app, _ := service.GetOrgAppA(0, 8)
  364. // //org, _ := service.GetOrgById(int64(12))
  365. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  366. // if org == nil || org.Id == 0 {
  367. // continue
  368. // }
  369. //
  370. //
  371. // app.OrgId = apps.OrgId
  372. // app.Creator = int(org.Creator)
  373. // app.Number = 3
  374. // app.Id = 0
  375. //
  376. // app.Pid = mall_temp_org_app.Id
  377. //
  378. // app.Status = 1
  379. // app.ModifyTime = time.Now().Unix()
  380. // app.CreateTime = time.Now().Unix()
  381. // service.CreateOrgApp(app)
  382. //}
  383. //if org_app_9 == nil || org_app_9.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  384. // app, _ := service.GetOrgAppA(0, 9)
  385. // //org, _ := service.GetOrgById(int64(12))
  386. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  387. // if org == nil || org.Id == 0 {
  388. // continue
  389. // }
  390. //
  391. //
  392. // app.OrgId = apps.OrgId
  393. // app.Pid = xt_temp_org_app.Id
  394. //
  395. // app.Creator = int(org.Creator)
  396. // app.Number = 4
  397. // app.Id = 0
  398. //
  399. // app.Status = 1
  400. // app.ModifyTime = time.Now().Unix()
  401. // app.CreateTime = time.Now().Unix()
  402. // service.CreateOrgApp(app)
  403. //
  404. //}
  405. //if org_app_10 == nil || org_app_10.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  406. // app, _ := service.GetOrgAppA(0, 10)
  407. // //org, _ := service.GetOrgById(int64(12))
  408. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  409. // if org == nil || org.Id == 0 {
  410. // continue
  411. // }
  412. //
  413. //
  414. // app.OrgId = apps.OrgId
  415. // app.Creator = int(org.Creator)
  416. // app.Pid = xt_temp_org_app.Id
  417. //
  418. // app.Number = 5
  419. // app.Id = 0
  420. //
  421. // app.Status = 1
  422. // app.ModifyTime = time.Now().Unix()
  423. // app.CreateTime = time.Now().Unix()
  424. // service.CreateOrgApp(app)
  425. //}
  426. //if org_app_11 == nil || org_app_11.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  427. // app, _ := service.GetOrgAppA(0, 11)
  428. // //org, _ := service.GetOrgById(int64(12))
  429. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  430. // if org == nil || org.Id == 0 {
  431. // continue
  432. // }
  433. //
  434. //
  435. // app.OrgId = apps.OrgId
  436. // app.Creator = int(org.Creator)
  437. // app.Pid = xt_temp_org_app.Id
  438. // app.Id = 0
  439. //
  440. // app.Number = 6
  441. // app.Status = 1
  442. // app.ModifyTime = time.Now().Unix()
  443. // app.CreateTime = time.Now().Unix()
  444. // service.CreateOrgApp(app)
  445. //}
  446. //if org_app_12 == nil || org_app_12.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  447. // app, _ := service.GetOrgAppA(0, 12)
  448. // //org, _ := service.GetOrgById(int64(12))
  449. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  450. // if org == nil || org.Id == 0 {
  451. // continue
  452. // }
  453. //
  454. //
  455. // app.OrgId = apps.OrgId
  456. // app.Creator = int(org.Creator)
  457. // app.Pid = xt_temp_org_app.Id
  458. // app.Number = 7
  459. // app.Status = 1
  460. // app.Id = 0
  461. //
  462. // app.ModifyTime = time.Now().Unix()
  463. // app.CreateTime = time.Now().Unix()
  464. // service.CreateOrgApp(app)
  465. //}
  466. //if org_app_13 == nil || org_app_13.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  467. // app, _ := service.GetOrgAppA(0, 13)
  468. // //org, _ := service.GetOrgById(int64(12))
  469. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  470. // if org == nil || org.Id == 0 {
  471. // continue
  472. // }
  473. //
  474. //
  475. // app.OrgId = apps.OrgId
  476. // app.Creator = int(org.Creator)
  477. // app.Pid = xt_temp_org_app.Id
  478. // app.Number = 8
  479. // app.Id = 0
  480. // app.Status = 1
  481. // app.ModifyTime = time.Now().Unix()
  482. // app.CreateTime = time.Now().Unix()
  483. // service.CreateOrgApp(app)
  484. //}
  485. //if org_app_14 == nil || org_app_14.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  486. // app, _ := service.GetOrgAppA(0, 14)
  487. // //org, _ := service.GetOrgById(int64(12))
  488. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  489. // if org == nil || org.Id == 0 {
  490. // continue
  491. // }
  492. //
  493. //
  494. // app.OrgId = apps.OrgId
  495. // app.Creator = int(org.Creator)
  496. // app.Pid = xt_temp_org_app.Id
  497. // app.Id = 0
  498. // app.Number = 9
  499. // app.Status = 1
  500. // app.ModifyTime = time.Now().Unix()
  501. // app.CreateTime = time.Now().Unix()
  502. // service.CreateOrgApp(app)
  503. //}
  504. //if org_app_15 == nil || org_app_15.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  505. // app, _ := service.GetOrgAppA(0, 15)
  506. // //org, _ := service.GetOrgById(int64(12))
  507. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  508. // if org == nil || org.Id == 0 {
  509. // continue
  510. // }
  511. //
  512. // app.OrgId = apps.OrgId
  513. // app.Creator = int(org.Creator)
  514. // app.Pid = xt_temp_org_app.Id
  515. // app.Number = 10
  516. // app.Status = 1
  517. // app.Id = 0
  518. // app.ModifyTime = time.Now().Unix()
  519. // app.CreateTime = time.Now().Unix()
  520. // service.CreateOrgApp(app)
  521. //}
  522. }
  523. //for _, role := range org_role {
  524. // org_ids = append(org_ids, role.OrgId)
  525. //}
  526. //
  527. //
  528. ////创建内置角色
  529. //InitRoleAndPurviews(org_ids)
  530. //var org_id int = 0
  531. //管理员
  532. //app_roles := service.GetAllUserRoleByUserTypeOne(org_id)
  533. //for _, item := range app_roles{
  534. // var ids string
  535. // if len(item.RoleIds) == 0{
  536. // ids = strconv.FormatInt( item.RoleId,10)
  537. // }else{
  538. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  539. // }
  540. // service.UpdateRoleIds(item.Id, ids)
  541. //}
  542. //护士医生
  543. //app_roles2 := service.GetAllUserRoleByUserTypeOther()
  544. // for _, item := range app_roles2{
  545. // var ids string
  546. // if len(item.RoleIds) == 0{
  547. // ids = strconv.FormatInt( item.RoleId,10)
  548. // }else{
  549. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  550. // }
  551. // if item.UserType == 2{
  552. // role := service.FindRoleByUserTypeOne(item.OrgId)
  553. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  554. //
  555. // } else if item.UserType == 3{
  556. // role := service.FindRoleByUserTypeTwo(item.OrgId)
  557. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  558. // }
  559. // service.UpdateRoleIds(item.Id, ids)
  560. // }
  561. //c.ServeSuccessJSON(map[string]interface{}{
  562. // "msg": "ok",
  563. //})
  564. }
  565. func InitRoleAndPurviews(org_ids []int64) {
  566. roles := LoadRoleConfig("./role.json").Roles
  567. for _, org_id := range org_ids {
  568. app, _ := service.GetOrgAppB(org_id, 3)
  569. role, _ := service.GetSystemRole(org_id)
  570. if app == nil || app.Id == 0 {
  571. continue
  572. }
  573. if len(role) == 0 {
  574. for _, item := range roles {
  575. role := &models.Role{
  576. RoleName: item.RoleName,
  577. RoleIntro: item.RoleIntroduction,
  578. Creator: 0,
  579. OrgId: org_id,
  580. AppId: app.Id,
  581. IsSuperAdmin: false,
  582. Status: 1,
  583. CreateTime: time.Now().Unix(),
  584. ModifyTime: time.Now().Unix(),
  585. Number: item.Number,
  586. IsSystem: item.IsSystem,
  587. }
  588. err := service.CreateOrgRoleB(role)
  589. if err == nil {
  590. purview := &models.RolePurview{
  591. RoleId: role.Id,
  592. OrgId: org_id,
  593. AppId: role.AppId,
  594. PurviewIds: item.PurviewIds,
  595. Status: 1,
  596. CreateTime: time.Now().Unix(),
  597. ModifyTime: time.Now().Unix(),
  598. }
  599. func_purview := &models.SgjUserRoleFuncPurview{
  600. RoleId: role.Id,
  601. OrgId: org_id,
  602. AppId: role.AppId,
  603. PurviewIds: item.FuncIds,
  604. Status: 1,
  605. Ctime: time.Now().Unix(),
  606. Mtime: time.Now().Unix(),
  607. }
  608. service.CreateRolePurviewB(purview)
  609. service.CreateFuncRolePurviewB(func_purview)
  610. }
  611. }
  612. }
  613. }
  614. }
  615. type RoleConfig struct {
  616. Roles []*models.VMUserRoleAndPurview "json:roles"
  617. }
  618. func LoadRoleConfig(dataFile string) *RoleConfig {
  619. var config RoleConfig
  620. _, filename, _, _ := runtime.Caller(1)
  621. datapath := path.Join(path.Dir(filename), dataFile)
  622. config_file, err := os.Open(datapath)
  623. if err != nil {
  624. emit("Failed to open config file '%s': %s\n", datapath, err)
  625. return &config
  626. }
  627. fi, _ := config_file.Stat()
  628. buffer := make([]byte, fi.Size())
  629. _, err = config_file.Read(buffer)
  630. buffer, err = StripComments(buffer) //去掉注释
  631. if err != nil {
  632. emit("Failed to strip comments from json: %s\n", err)
  633. return &config
  634. }
  635. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  636. err = json.Unmarshal(buffer, &config) //解析json格式数据
  637. if err != nil {
  638. emit("Failed unmarshalling json: %s\n", err)
  639. return &config
  640. }
  641. return &config
  642. }
  643. type GoodTypesConfig struct {
  644. GoodTypes []*models.VMGoodsType "json:list"
  645. }
  646. func LoadGoodTypeConfig(dataFile string) *GoodTypesConfig {
  647. var config GoodTypesConfig
  648. _, filename, _, _ := runtime.Caller(1)
  649. datapath := path.Join(path.Dir(filename), dataFile)
  650. config_file, err := os.Open(datapath)
  651. if err != nil {
  652. emit("Failed to open config file '%s': %s\n", datapath, err)
  653. return &config
  654. }
  655. fi, _ := config_file.Stat()
  656. buffer := make([]byte, fi.Size())
  657. _, err = config_file.Read(buffer)
  658. buffer, err = StripComments(buffer) //去掉注释
  659. if err != nil {
  660. emit("Failed to strip comments from json: %s\n", err)
  661. return &config
  662. }
  663. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  664. err = json.Unmarshal(buffer, &config) //解析json格式数据
  665. if err != nil {
  666. emit("Failed unmarshalling json: %s\n", err)
  667. return &config
  668. }
  669. return &config
  670. }
  671. func (c *PublicApiController) HandleStockData() {
  672. org, _ := service.FindAllOrgByImportType()
  673. for _, item := range org {
  674. if item.Id != 3907 || item.Id != 9779 || item.Id != 9883 {
  675. goodTypes := &models.GoodsType{
  676. TypeCode: "14000000",
  677. TypeName: "穿刺针",
  678. Remark: "",
  679. Ctime: time.Now().Unix(),
  680. Mtime: time.Now().Unix(),
  681. Creater: 0,
  682. Modifier: 0,
  683. OrgId: item.Id,
  684. Status: 1,
  685. Type: 1,
  686. Number: 1,
  687. }
  688. service.AddSigleGoodType(goodTypes)
  689. goodTypes1 := &models.GoodsType{
  690. TypeCode: "14000001",
  691. TypeName: "透析器",
  692. Remark: "",
  693. Ctime: time.Now().Unix(),
  694. Mtime: time.Now().Unix(),
  695. Creater: 0,
  696. Modifier: 0,
  697. OrgId: item.Id,
  698. Status: 1,
  699. Type: 1,
  700. Number: 2,
  701. }
  702. service.AddSigleGoodType(goodTypes1)
  703. goodTypes2 := &models.GoodsType{
  704. TypeCode: "14000002",
  705. TypeName: "灌流器",
  706. Remark: "",
  707. Ctime: time.Now().Unix(),
  708. Mtime: time.Now().Unix(),
  709. Creater: 0,
  710. Modifier: 0,
  711. OrgId: item.Id,
  712. Status: 1,
  713. Type: 1,
  714. Number: 3,
  715. }
  716. service.AddSigleGoodType(goodTypes2)
  717. goodTypes3 := &models.GoodsType{
  718. TypeCode: "14000003",
  719. TypeName: "血路管",
  720. Remark: "",
  721. Ctime: time.Now().Unix(),
  722. Mtime: time.Now().Unix(),
  723. Creater: 0,
  724. Modifier: 0,
  725. OrgId: item.Id,
  726. Status: 1,
  727. Type: 1,
  728. Number: 4,
  729. }
  730. service.AddSigleGoodType(goodTypes3)
  731. goodTypes4 := &models.GoodsType{
  732. TypeCode: "14000004",
  733. TypeName: "血滤补液管",
  734. Remark: "",
  735. Ctime: time.Now().Unix(),
  736. Mtime: time.Now().Unix(),
  737. Creater: 0,
  738. Modifier: 0,
  739. OrgId: item.Id,
  740. Status: 1,
  741. Type: 1,
  742. Number: 5,
  743. }
  744. service.AddSigleGoodType(goodTypes4)
  745. goodTypes5 := &models.GoodsType{
  746. TypeCode: "14000005",
  747. TypeName: "注射器",
  748. Remark: "",
  749. Ctime: time.Now().Unix(),
  750. Mtime: time.Now().Unix(),
  751. Creater: 0,
  752. Modifier: 0,
  753. OrgId: item.Id,
  754. Status: 1,
  755. Type: 1,
  756. Number: 6,
  757. }
  758. service.AddSigleGoodType(goodTypes5)
  759. goodTypes6 := &models.GoodsType{
  760. TypeCode: "14000006",
  761. TypeName: "护理包(内瘘穿刺包)",
  762. Remark: "",
  763. Ctime: time.Now().Unix(),
  764. Mtime: time.Now().Unix(),
  765. Creater: 0,
  766. Modifier: 0,
  767. OrgId: item.Id,
  768. Status: 1,
  769. Type: 1,
  770. Number: 7,
  771. }
  772. service.AddSigleGoodType(goodTypes6)
  773. goodTypes7 := &models.GoodsType{
  774. TypeCode: "14000007",
  775. TypeName: "细菌过滤器",
  776. Remark: "",
  777. Ctime: time.Now().Unix(),
  778. Mtime: time.Now().Unix(),
  779. Creater: 0,
  780. Modifier: 0,
  781. OrgId: item.Id,
  782. Status: 1,
  783. Type: 1,
  784. Number: 8,
  785. }
  786. service.AddSigleGoodType(goodTypes7)
  787. goodTypes8 := &models.GoodsType{
  788. TypeCode: "14000008",
  789. TypeName: "血液透析干粉",
  790. Remark: "",
  791. Ctime: time.Now().Unix(),
  792. Mtime: time.Now().Unix(),
  793. Creater: 0,
  794. Modifier: 0,
  795. OrgId: item.Id,
  796. Status: 1,
  797. Type: 1,
  798. Number: 9,
  799. }
  800. service.AddSigleGoodType(goodTypes8)
  801. goodTypes9 := &models.GoodsType{
  802. TypeCode: "14000009",
  803. TypeName: "A液",
  804. Remark: "",
  805. Ctime: time.Now().Unix(),
  806. Mtime: time.Now().Unix(),
  807. Creater: 0,
  808. Modifier: 0,
  809. OrgId: item.Id,
  810. Status: 1,
  811. Type: 1,
  812. Number: 10,
  813. }
  814. service.AddSigleGoodType(goodTypes9)
  815. goodTypes10 := &models.GoodsType{
  816. TypeCode: "14000010",
  817. TypeName: "B液",
  818. Remark: "",
  819. Ctime: time.Now().Unix(),
  820. Mtime: time.Now().Unix(),
  821. Creater: 0,
  822. Modifier: 0,
  823. OrgId: item.Id,
  824. Status: 1,
  825. Type: 1,
  826. Number: 11,
  827. }
  828. service.AddSigleGoodType(goodTypes10)
  829. goodTypes11 := &models.GoodsType{
  830. TypeCode: "14000011",
  831. TypeName: "导管包",
  832. Remark: "",
  833. Ctime: time.Now().Unix(),
  834. Mtime: time.Now().Unix(),
  835. Creater: 0,
  836. Modifier: 0,
  837. OrgId: item.Id,
  838. Status: 1,
  839. Type: 1,
  840. Number: 12,
  841. }
  842. service.AddSigleGoodType(goodTypes11)
  843. goodTypes12 := &models.GoodsType{
  844. TypeCode: "14000012",
  845. TypeName: "血液透析导管",
  846. Remark: "",
  847. Ctime: time.Now().Unix(),
  848. Mtime: time.Now().Unix(),
  849. Creater: 0,
  850. Modifier: 0,
  851. OrgId: item.Id,
  852. Status: 1,
  853. Type: 1,
  854. Number: 13,
  855. }
  856. service.AddSigleGoodType(goodTypes12)
  857. }
  858. }
  859. }
  860. func (c *PublicApiController) HandleComData() {
  861. org_ids := []int64{3907, 9779, 9883}
  862. for _, id := range org_ids {
  863. //查处所有处方记录
  864. prescriptions, _ := service.FindAllPrescription(id)
  865. if id == 3907 {
  866. for _, item := range prescriptions {
  867. if item.Niprocart > 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.Niprocart
  880. before.GoodTypeId = 241
  881. service.AddSigleDialysisBeforePre(before)
  882. }
  883. if item.Jms > 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.Jms
  896. before.GoodTypeId = 233
  897. service.AddSigleDialysisBeforePre(before)
  898. }
  899. if item.FistulaNeedleSet > 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.FistulaNeedleSet
  912. before.GoodTypeId = 233
  913. service.AddSigleDialysisBeforePre(before)
  914. }
  915. if item.FistulaNeedleSet16 > 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.FistulaNeedleSet16
  928. before.GoodTypeId = 233
  929. service.AddSigleDialysisBeforePre(before)
  930. }
  931. if item.Hemoperfusion > 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.Hemoperfusion
  944. before.GoodTypeId = 235
  945. service.AddSigleDialysisBeforePre(before)
  946. }
  947. if item.DialyserSterilised > 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.DialyserSterilised
  960. before.GoodTypeId = 234
  961. service.AddSigleDialysisBeforePre(before)
  962. }
  963. if item.Filtryzer > 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.Filtryzer
  976. before.GoodTypeId = 234
  977. service.AddSigleDialysisBeforePre(before)
  978. }
  979. if item.Dialyzers > 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.Dialyzers
  992. before.GoodTypeId = 234
  993. service.AddSigleDialysisBeforePre(before)
  994. }
  995. if item.Injector > 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.Injector
  1008. before.GoodTypeId = 238
  1009. service.AddSigleDialysisBeforePre(before)
  1010. }
  1011. if item.Bloodlines > 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.Bloodlines
  1024. before.GoodTypeId = 236
  1025. service.AddSigleDialysisBeforePre(before)
  1026. }
  1027. if item.TubingHemodialysis > 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.TubingHemodialysis
  1040. before.GoodTypeId = 237
  1041. service.AddSigleDialysisBeforePre(before)
  1042. }
  1043. if item.Package > 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.Package
  1056. before.GoodTypeId = 239
  1057. service.AddSigleDialysisBeforePre(before)
  1058. }
  1059. if item.ALiquid > 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.ALiquid
  1072. before.GoodTypeId = 242
  1073. service.AddSigleDialysisBeforePre(before)
  1074. }
  1075. }
  1076. } else if id == 9779 {
  1077. for _, item := range prescriptions {
  1078. if item.Niprocart > 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.Niprocart
  1091. before.GoodTypeId = 254
  1092. service.AddSigleDialysisBeforePre(before)
  1093. }
  1094. if item.Jms > 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.Jms
  1107. before.GoodTypeId = 246
  1108. service.AddSigleDialysisBeforePre(before)
  1109. }
  1110. if item.FistulaNeedleSet > 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.FistulaNeedleSet
  1123. before.GoodTypeId = 246
  1124. service.AddSigleDialysisBeforePre(before)
  1125. }
  1126. if item.FistulaNeedleSet16 > 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.FistulaNeedleSet16
  1139. before.GoodTypeId = 246
  1140. service.AddSigleDialysisBeforePre(before)
  1141. }
  1142. if item.Hemoperfusion > 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.Hemoperfusion
  1155. before.GoodTypeId = 248
  1156. service.AddSigleDialysisBeforePre(before)
  1157. }
  1158. if item.DialyserSterilised > 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.DialyserSterilised
  1171. before.GoodTypeId = 247
  1172. service.AddSigleDialysisBeforePre(before)
  1173. }
  1174. if item.Filtryzer > 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.Filtryzer
  1187. before.GoodTypeId = 247
  1188. service.AddSigleDialysisBeforePre(before)
  1189. }
  1190. if item.Dialyzers > 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.Dialyzers
  1203. before.GoodTypeId = 247
  1204. service.AddSigleDialysisBeforePre(before)
  1205. }
  1206. if item.Injector > 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.Injector
  1219. before.GoodTypeId = 251
  1220. service.AddSigleDialysisBeforePre(before)
  1221. }
  1222. if item.Bloodlines > 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.Bloodlines
  1235. before.GoodTypeId = 249
  1236. service.AddSigleDialysisBeforePre(before)
  1237. }
  1238. if item.TubingHemodialysis > 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.TubingHemodialysis
  1251. before.GoodTypeId = 250
  1252. service.AddSigleDialysisBeforePre(before)
  1253. }
  1254. if item.Package > 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.Package
  1267. before.GoodTypeId = 252
  1268. service.AddSigleDialysisBeforePre(before)
  1269. }
  1270. if item.ALiquid > 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.ALiquid
  1283. before.GoodTypeId = 255
  1284. service.AddSigleDialysisBeforePre(before)
  1285. }
  1286. }
  1287. } else if id == 9883 {
  1288. for _, item := range prescriptions {
  1289. if item.Niprocart > 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.Niprocart
  1302. before.GoodTypeId = 267
  1303. service.AddSigleDialysisBeforePre(before)
  1304. }
  1305. if item.Jms > 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.Jms
  1318. before.GoodTypeId = 259
  1319. service.AddSigleDialysisBeforePre(before)
  1320. }
  1321. if item.FistulaNeedleSet > 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.FistulaNeedleSet
  1334. before.GoodTypeId = 259
  1335. service.AddSigleDialysisBeforePre(before)
  1336. }
  1337. if item.FistulaNeedleSet16 > 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.FistulaNeedleSet16
  1350. before.GoodTypeId = 259
  1351. service.AddSigleDialysisBeforePre(before)
  1352. }
  1353. if item.Hemoperfusion > 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.Hemoperfusion
  1366. before.GoodTypeId = 261
  1367. service.AddSigleDialysisBeforePre(before)
  1368. }
  1369. if item.DialyserSterilised > 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.DialyserSterilised
  1382. before.GoodTypeId = 260
  1383. service.AddSigleDialysisBeforePre(before)
  1384. }
  1385. if item.Filtryzer > 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.Filtryzer
  1398. before.GoodTypeId = 260
  1399. service.AddSigleDialysisBeforePre(before)
  1400. }
  1401. if item.Dialyzers > 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.Dialyzers
  1414. before.GoodTypeId = 260
  1415. service.AddSigleDialysisBeforePre(before)
  1416. }
  1417. if item.Injector > 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.Injector
  1430. before.GoodTypeId = 264
  1431. service.AddSigleDialysisBeforePre(before)
  1432. }
  1433. if item.Bloodlines > 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.Bloodlines
  1446. before.GoodTypeId = 262
  1447. service.AddSigleDialysisBeforePre(before)
  1448. }
  1449. if item.TubingHemodialysis > 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.TubingHemodialysis
  1462. before.GoodTypeId = 263
  1463. service.AddSigleDialysisBeforePre(before)
  1464. }
  1465. if item.Package > 0 {
  1466. before := &models.DialysisBeforePrepare{
  1467. UserOrgId: id,
  1468. PatientId: item.PatientId,
  1469. RecordDate: item.RecordDate,
  1470. Count: 1,
  1471. Ctime: item.RecordDate,
  1472. Mtime: item.RecordDate,
  1473. Creater: item.Creater,
  1474. Modifier: item.Creater,
  1475. Status: 1,
  1476. }
  1477. before.GoodId = item.Package
  1478. before.GoodTypeId = 265
  1479. service.AddSigleDialysisBeforePre(before)
  1480. }
  1481. if item.ALiquid > 0 {
  1482. before := &models.DialysisBeforePrepare{
  1483. UserOrgId: id,
  1484. PatientId: item.PatientId,
  1485. RecordDate: item.RecordDate,
  1486. Count: 1,
  1487. Ctime: item.RecordDate,
  1488. Mtime: item.RecordDate,
  1489. Creater: item.Creater,
  1490. Modifier: item.Creater,
  1491. Status: 1,
  1492. }
  1493. before.GoodId = item.ALiquid
  1494. before.GoodTypeId = 268
  1495. service.AddSigleDialysisBeforePre(before)
  1496. }
  1497. }
  1498. }
  1499. }
  1500. }
  1501. func (c *PublicApiController) HandleHIS() {
  1502. his, _ := service.GetAllHisInfo(9919)
  1503. for _, item := range his {
  1504. fsn := strings.Split(item.FeedetlSn, "-")
  1505. item.FeedetlSn = fsn[0] + "-" + fsn[1] + "-" + strconv.FormatInt(item.ID, 10)
  1506. fmt.Println(item.FeedetlSn)
  1507. service.UpDateHis2(item)
  1508. }
  1509. }
  1510. //func (c *PublicApiController)HandleOrder(){
  1511. // //orders, _ := service.GetAllHisOrder()
  1512. //
  1513. //
  1514. // order, _ := service.GetLastHisOrder()
  1515. //
  1516. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  1517. //
  1518. //
  1519. // //fmt.Println(fpNumber)
  1520. //
  1521. // //for index, item := range orders {
  1522. // // item.FaPiaoCode ="144072080589"
  1523. // // var zero string
  1524. // // if 1520 + int64(index) >= 1000{
  1525. // // zero = "0000" + strconv.FormatInt(1520 + int64(index),10)
  1526. // // }else if 1520 + int64(index) >= 10000{
  1527. // // zero = "000" + strconv.FormatInt(1520 + int64(index),10)
  1528. // // } else if 1520 + int64(index) >= 100000{
  1529. // // zero = "00" +strconv.FormatInt(1520 + int64(index),10)
  1530. // // } else if 1520 + int64(index) >= 1000000{
  1531. // // zero = "0" +strconv.FormatInt(1520 + int64(index),10)
  1532. // // }else {
  1533. // // zero = strconv.FormatInt(1520 + int64(index),10)
  1534. // // }
  1535. // // item.FaPiaoNumber = zero
  1536. // // service.SaveOrder(item)
  1537. // //}
  1538. //}
  1539. func Mkdir(dir string) {
  1540. // 创建文件夹
  1541. exist, err := PathExists(dir)
  1542. if err != nil {
  1543. fmt.Println(err.Error())
  1544. } else {
  1545. if exist {
  1546. fmt.Println(dir + "文件夹已存在!")
  1547. } else {
  1548. // 文件夹名称,权限
  1549. err := os.Mkdir(dir, os.ModePerm)
  1550. if err != nil {
  1551. fmt.Println(dir+"文件夹创建失败:", err.Error())
  1552. } else {
  1553. fmt.Println(dir + "文件夹创建成功!")
  1554. }
  1555. }
  1556. }
  1557. }
  1558. func PathExists(path string) (bool, error) {
  1559. _, err := os.Stat(path)
  1560. if err == nil {
  1561. return true, nil
  1562. }
  1563. if os.IsNotExist(err) {
  1564. return false, nil
  1565. }
  1566. return false, err
  1567. }