sign_api_controller.go 46KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528
  1. package controllers
  2. import (
  3. "encoding/base64"
  4. "encoding/json"
  5. "fmt"
  6. "io/ioutil"
  7. "strconv"
  8. "time"
  9. "XT_New/models"
  10. "XT_New/service"
  11. "XT_New/utils"
  12. "github.com/astaxie/beego"
  13. )
  14. type SignApiController struct {
  15. BaseAuthAPIController
  16. }
  17. func SignApiRegistRouters() {
  18. //获取短信验证码
  19. beego.Router("/api/sign/getsign", &SignApiController{}, "Get:GetSign")
  20. //创建个人用户并实名
  21. beego.Router("/api/sign/createrusername", &SignApiController{}, "Get:CreateUserName")
  22. //创建企业用户并实名
  23. beego.Router("/api/sign/createenterpriserealname", &SignApiController{}, "Get:CreateEnterPriseRealName")
  24. //添加企业成员
  25. beego.Router("/api/sign/createuserid", &SignApiController{}, "Get:CreateUserId")
  26. //创建个人印章
  27. beego.Router("/api/sign/createpersionseal", &SignApiController{}, "Get:CreatePersionSeal")
  28. //上传文件创建创建合同
  29. beego.Router("/api/sign/createuploadpact", &SignApiController{}, "Get:CreateUploadPact")
  30. //添加合同签署人
  31. beego.Router("/api/sign/addcontractsignatory", &SignApiController{}, "Get:AddContractSignatory")
  32. //获取短信验证
  33. beego.Router("/api/sign/getverificationcode", &SignApiController{}, "Get:GetVerificationCode")
  34. //后台签署(返回签署文件)
  35. beego.Router("/api/sign/createbackstagesign", &SignApiController{}, "Get:CreateBackStageSign")
  36. //署意愿认证-短信验证
  37. beego.Router("/api/sign/totestelment", &SignApiController{}, "Get:CreateEnterprise")
  38. //测试PDF
  39. beego.Router("/api/sign/totestthrityment", &SignApiController{}, "Get:GetTestThrityMent")
  40. //CA企业认证
  41. beego.Router("/api/sign/saveenerprise", &SignApiController{}, "Post:SaveEnerprise")
  42. //
  43. beego.Router("/api/sign/getenerprisebyid", &SignApiController{}, "Get:GetEnerPriseById")
  44. beego.Router("/api/sign/getmobilecode", &SignApiController{}, "Get:GetMobileCode")
  45. beego.Router("/api/sign/getpersionenterprise", &SignApiController{}, "Post:GetPersionEnterPrise")
  46. beego.Router("/api/sign/getpersenterprisebyid", &SignApiController{}, "Get:GetPerseEnterPriseById")
  47. beego.Router("/api/device/sign/creterpersionseal", &SignApiController{}, "Get:CreateNewPersionSeal")
  48. beego.Router("/api/device/sign/createnewenterprise", &SignApiController{}, "Get:CreateNewEnterPrise")
  49. beego.Router("/api/device/contractid", &SignApiController{}, "Get:GetContractId")
  50. beego.Router("/api/device/endenterprise", &SignApiController{}, "Get:EndEnterPrise")
  51. beego.Router("/api/device/getenterprisedetail", &SignApiController{}, "Get:GetEnterPriseDetail")
  52. beego.Router("/api/device/uploadprintorder", &SignApiController{}, "Post:UploadPrintOrder")
  53. //sdk 版本
  54. beego.Router("/api/device/createqianshuusername", &SignApiController{}, "Post:CreateQianshuUserName")
  55. //发送消息
  56. beego.Router("/api/device/createskdsendinformation", &SignApiController{}, "Post:CreateSdkSendInformation")
  57. //删除
  58. beego.Router("/api/device/tosavepdfinformation", &SignApiController{}, "Get:SavePdfInformation")
  59. beego.Router("/api/device/tocheckinformation", &SignApiController{}, "Get:ToCheckInformation")
  60. beego.Router("/api/device/toautodrug", &SignApiController{}, "Get:ToAutoDrug")
  61. beego.Router("/api/device/toautodiagnose", &SignApiController{}, "Get:ToAutoDiagnose")
  62. //加油
  63. beego.Router("/api/device/toautojiayou", &SignApiController{}, "Get:ToAutoJiaYou")
  64. //显示字段脚本
  65. beego.Router("/api/device/getfieldconfiglist", &SignApiController{}, "Get:GetFieldConfigList")
  66. beego.Router("/api/device/tocheckquery", &SignApiController{}, "Get:ToCheckQuery")
  67. }
  68. // 短信服务接口
  69. func (this *SignApiController) GetSign() {
  70. phone := this.GetString("phone")
  71. fmt.Println("phone", phone)
  72. var tempphone string
  73. tempphone = "13318464642"
  74. sign := service.GetSignNameByPhone(tempphone)
  75. this.ServeSuccessJSON(map[string]interface{}{
  76. "sign": sign,
  77. })
  78. return
  79. }
  80. type Result2121 struct {
  81. Phone string `json:"phone"`
  82. DisPlayName string `json:"dis_play_name"`
  83. Authentication string `json:"authentication"`
  84. TwAuthReq struct {
  85. OneLineAuth string `json:"oneLineAuth"`
  86. ApiAuthReq struct {
  87. RealName float64 `json:"real_name"`
  88. IdCardType string `json:"id_card_type"`
  89. IdCardNum string `json:"id_card_num"`
  90. BankCard string `json:"bank_card"`
  91. CodeNumber string `json:"code_number"`
  92. VerifyCode string `json:"verify_code"`
  93. } `json:"apiAuthReq"`
  94. } `json:"twAuthReq"`
  95. }
  96. type MapData struct {
  97. dat struct {
  98. Code float64 `json:"code"`
  99. data struct {
  100. userId string `json:"userId"`
  101. }
  102. }
  103. }
  104. // 创建个人用户并实名
  105. func (this *SignApiController) CreateUserName() {
  106. phone := this.GetString("phone")
  107. disPlayName := this.GetString("disPlayName")
  108. sign, userId := service.CreateUserName(phone, disPlayName)
  109. var dat map[string]interface{}
  110. if err := json.Unmarshal([]byte(sign), &dat); err == nil {
  111. fmt.Println(dat)
  112. } else {
  113. fmt.Println(err)
  114. }
  115. this.ServeSuccessJSON(map[string]interface{}{
  116. "sign": sign,
  117. "dat": dat,
  118. "userId": userId,
  119. })
  120. return
  121. }
  122. // 创建个人印章
  123. func (this *SignApiController) CreatePersionSeal() {
  124. user_id := this.GetString("user_id")
  125. person_seal_type, _ := this.GetInt64("person_seal_type")
  126. person_seal_name := this.GetString("person_seal_name")
  127. person_seal_base := this.GetString("person_seal_base")
  128. color, _ := this.GetInt64("color")
  129. alpha, _ := this.GetInt64("alpha")
  130. width, _ := this.GetInt64("width")
  131. height, _ := this.GetInt64("height")
  132. border, _ := this.GetInt64("border")
  133. font_type, _ := this.GetInt64("font_type")
  134. sign, personSealId := service.CreatePersionSeal(user_id, person_seal_type, person_seal_name, person_seal_base, color, alpha, width, height, border, font_type)
  135. var dat map[string]interface{}
  136. if err := json.Unmarshal([]byte(sign), &dat); err == nil {
  137. fmt.Println(dat)
  138. } else {
  139. fmt.Println(err)
  140. }
  141. this.ServeSuccessJSON(map[string]interface{}{
  142. "sign": sign,
  143. "dat": dat,
  144. "personSealId": personSealId,
  145. })
  146. return
  147. }
  148. func (this *SignApiController) CreateUploadPact() {
  149. contractcode := this.GetString("contractcode")
  150. contractname := this.GetString("contractname")
  151. signcount, _ := this.GetInt64("signcount")
  152. docname := this.GetString("docname")
  153. contractbase := this.GetString("contractbase")
  154. creator := this.GetString("creator")
  155. enterpriseid := this.GetString("enterpriseid")
  156. signvalidays, _ := this.GetInt64("signvalidays")
  157. sysncurl := this.GetString("sysncurl")
  158. asyncurl := this.GetString("asyncurl")
  159. sign := service.CreateUploadPact(contractcode, contractname, signcount, docname, contractbase, creator, enterpriseid, signvalidays, sysncurl, asyncurl)
  160. this.ServeSuccessJSON(map[string]interface{}{
  161. "sign": sign,
  162. })
  163. return
  164. }
  165. // 添加企业成员
  166. func (this *SignApiController) CreateUserId() {
  167. userId := this.GetString("userId")
  168. displayName := this.GetString("displayName")
  169. sign := service.CreateUserId(userId, displayName)
  170. this.ServeSuccessJSON(map[string]interface{}{
  171. "sign": sign,
  172. })
  173. return
  174. }
  175. func (this *SignApiController) CreateEnterPriseRealName() {
  176. enterprisename := this.GetString("enterprisename")
  177. sign := service.CreateEnterPriseRealName(enterprisename)
  178. this.ServeSuccessJSON(map[string]interface{}{
  179. "sign": sign,
  180. })
  181. return
  182. }
  183. // 添加合同签署人
  184. func (this *SignApiController) AddContractSignatory() {
  185. contractId := this.GetString("contractId")
  186. signers := this.GetString("signers")
  187. var newContract models.NewContract
  188. newContract.ContractId = "156001444267295949"
  189. sign := service.AddContractSignatory(contractId, signers, newContract)
  190. this.ServeSuccessJSON(map[string]interface{}{
  191. "sign": sign,
  192. })
  193. return
  194. }
  195. type Struct2401 struct {
  196. someTimestampStyle []someTimestampStyle
  197. }
  198. type someTimestampStyle struct {
  199. ControlsKey string
  200. Pattern string
  201. Color string
  202. }
  203. func (this *SignApiController) CreateBackStageSign() {
  204. contractId := this.GetString("contractId")
  205. signers := this.GetString("signers")
  206. sign := service.CreateBackStageSign(contractId, signers)
  207. this.ServeSuccessJSON(map[string]interface{}{
  208. "sign": sign,
  209. })
  210. return
  211. }
  212. func (this *SignApiController) GetVerificationCode() {
  213. sign := service.GetVerificationCode()
  214. this.ServeSuccessJSON(map[string]interface{}{
  215. "sign": sign,
  216. })
  217. return
  218. }
  219. func (this *SignApiController) CreateEnterprise() {
  220. sign := service.CreateEnterprise()
  221. this.ServeSuccessJSON(map[string]interface{}{
  222. "sign": sign,
  223. })
  224. return
  225. }
  226. func (this *SignApiController) GetTestThrityMent() {
  227. //pdf := gofpdf.New("P", "mm", "A4", "")
  228. //pdf.AddPage()
  229. //pdf.SetFont("Arial", "B", 16)
  230. //pdf.Cell(40, 10, "Hello, World!")
  231. //pdf.OutputFileAndClose("output.pdf")
  232. //
  233. //this.ServeSuccessJSON(map[string]interface{}{
  234. // "sign": "msg",
  235. //})
  236. //return
  237. }
  238. func loremList() []string {
  239. return []string{
  240. "我爱你中国" +
  241. "tempor incididunt ut labore et dolore magna aliqua.",
  242. "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " +
  243. "aliquip ex ea commodo consequat.",
  244. "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum " +
  245. "dolore eu fugiat nulla pariatur.",
  246. "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui " +
  247. "officia deserunt mollit anim id est laborum.",
  248. }
  249. }
  250. func (this *SignApiController) SaveEnerprise() {
  251. orgId := this.GetAdminUserInfo().CurrentOrgId
  252. creater := this.GetAdminUserInfo().AdminUser.Id
  253. dataBody := make(map[string]interface{}, 0)
  254. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  255. fmt.Println("err", err)
  256. id := int64(dataBody["id"].(float64))
  257. org_type := int64(dataBody["org_type"].(float64))
  258. enterprise_name := dataBody["enterprise_name"].(string)
  259. code := dataBody["code"].(string)
  260. org_code := dataBody["org_code"].(string)
  261. legal_person_name := dataBody["legal_person_name"].(string)
  262. legal_id_card_num := dataBody["legal_id_card_num"].(string)
  263. legal_phone := dataBody["legal_phone"].(string)
  264. enterprise := models.XtDeviceEnterprise{
  265. ID: id,
  266. UserOrgId: orgId,
  267. OrgType: org_type,
  268. EnterpriseName: enterprise_name,
  269. Code: code,
  270. OrgCode: org_code,
  271. LegalPersonName: legal_person_name,
  272. LegalIdCardNum: legal_id_card_num,
  273. LegalPhone: legal_phone,
  274. Creater: creater,
  275. Ctime: time.Now().Unix(),
  276. Mtime: 0,
  277. Enterpriseid: "",
  278. Status: 1,
  279. }
  280. service.SaveEnerPrise(enterprise)
  281. //查找该机构有没有认证信息
  282. lastenterprise, _ := service.GetEnterPriseByUserOrgId(orgId)
  283. //调用企业认证接口
  284. if lastenterprise.ID > 0 {
  285. enterPrise, enterpriseid := service.CreateNewEnterPriseRealName(lastenterprise)
  286. fmt.Println("enterprise2ooo2oo2o2o2o", enterPrise)
  287. updateEnterprise := models.XtDeviceEnterprise{
  288. ID: enterprise.ID,
  289. UserOrgId: orgId,
  290. OrgType: org_type,
  291. EnterpriseName: enterprise_name,
  292. Code: code,
  293. OrgCode: org_code,
  294. LegalPersonName: legal_person_name,
  295. LegalIdCardNum: legal_id_card_num,
  296. LegalPhone: legal_phone,
  297. Creater: creater,
  298. Ctime: time.Now().Unix(),
  299. Mtime: 0,
  300. Enterpriseid: enterpriseid,
  301. Status: 1,
  302. }
  303. service.SaveEnerPrise(updateEnterprise)
  304. this.ServeSuccessJSON(map[string]interface{}{
  305. "enterPrise": enterPrise,
  306. })
  307. return
  308. }
  309. }
  310. func (this *SignApiController) GetEnerPriseById() {
  311. orgId := this.GetAdminUserInfo().CurrentOrgId
  312. enterPrise, _ := service.GetEnterPriseByUserOrgId(orgId)
  313. this.ServeSuccessJSON(map[string]interface{}{
  314. "enterPrise": enterPrise,
  315. })
  316. return
  317. }
  318. func (this *SignApiController) GetMobileCode() {
  319. phone := this.GetString("phone")
  320. sign, orderNumber := service.GetNewSignNameByPhone(phone)
  321. this.ServeSuccessJSON(map[string]interface{}{
  322. "sign": sign,
  323. "orderNumber": orderNumber,
  324. })
  325. return
  326. }
  327. func (this *SignApiController) GetPersionEnterPrise() {
  328. orgId := this.GetAdminUserInfo().CurrentOrgId
  329. creater := this.GetAdminUserInfo().AdminUser.Id
  330. dataBody := make(map[string]interface{}, 0)
  331. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  332. fmt.Println("err", err)
  333. id := int64(dataBody["id"].(float64))
  334. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  335. code := dataBody["code"].(string)
  336. display_name := dataBody["display_name"].(string)
  337. id_card_num := dataBody["id_card_num"].(string)
  338. phone := dataBody["phone"].(string)
  339. enterprise := models.XtDevicePersonEnterprise{
  340. ID: id,
  341. AdminUserId: admin_user_id,
  342. DisplayName: display_name,
  343. Phone: phone,
  344. IdCardNum: id_card_num,
  345. UserOrgId: orgId,
  346. Status: 1,
  347. Creater: creater,
  348. Ctime: time.Now().Unix(),
  349. Mtime: 0,
  350. UserId: "",
  351. }
  352. service.SavePersonEnterPrise(enterprise)
  353. lastEnterPrise, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  354. _, orderNumber := service.GetNewSignNameByPhone(phone)
  355. personEnterPrse, UserId := service.CreateNewUserName(lastEnterPrise.Phone, lastEnterPrise.DisplayName, code, orderNumber, lastEnterPrise.IdCardNum)
  356. firstenterprise := models.XtDevicePersonEnterprise{
  357. ID: id,
  358. AdminUserId: admin_user_id,
  359. DisplayName: display_name,
  360. Phone: phone,
  361. IdCardNum: id_card_num,
  362. UserOrgId: orgId,
  363. Status: 1,
  364. Creater: creater,
  365. Ctime: time.Now().Unix(),
  366. Mtime: 0,
  367. UserId: UserId,
  368. }
  369. service.SavePersonEnterPrise(firstenterprise)
  370. this.ServeSuccessJSON(map[string]interface{}{
  371. "personEnterPrse": personEnterPrse,
  372. })
  373. return
  374. }
  375. func (this *SignApiController) GetPerseEnterPriseById() {
  376. orgId := this.GetAdminUserInfo().CurrentOrgId
  377. admin_user_id, _ := this.GetInt64("admin_user_id")
  378. lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  379. this.ServeSuccessJSON(map[string]interface{}{
  380. "lastPerson": lastPerson,
  381. })
  382. return
  383. }
  384. func (this *SignApiController) CreateNewPersionSeal() {
  385. orgId := this.GetAdminUserInfo().CurrentOrgId
  386. admin_user_id, _ := this.GetInt64("admin_user_id")
  387. creater := this.GetAdminUserInfo().AdminUser.Id
  388. userName := service.GetLastAdminUserName(admin_user_id, orgId)
  389. //查询医护是否完成认证
  390. lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  391. if lastPerson.ID > 0 {
  392. this.ServeDynamicFailJsonSend("已完成认证,无需再次认证")
  393. return
  394. }
  395. if lastPerson.ID == 0 {
  396. //去认证
  397. personSeal, sealBase64 := service.CreateSKDPersionSeal(lastPerson.UserId, userName)
  398. fmt.Println("sealBase64", sealBase64)
  399. enterprise := models.XtDevicePersonEnterprise{
  400. AdminUserId: admin_user_id,
  401. DisplayName: "",
  402. Phone: "",
  403. IdCardNum: "",
  404. UserOrgId: orgId,
  405. Status: 1,
  406. Creater: creater,
  407. Ctime: time.Now().Unix(),
  408. Mtime: 0,
  409. UserId: "",
  410. Personsealid: "",
  411. Sealid: "",
  412. UserName: userName,
  413. Sealbase64: sealBase64,
  414. }
  415. service.CreateEnterpriseUserName(enterprise)
  416. this.ServeSuccessJSON(map[string]interface{}{
  417. "personSeal": personSeal,
  418. })
  419. return
  420. }
  421. }
  422. func (this *SignApiController) CreateNewEnterPrise() {
  423. //orgId := this.GetAdminUserInfo().CurrentOrgId
  424. //
  425. //admin_user_id, _ := this.GetInt64("admin_user_id")
  426. //
  427. //enterPrise, _ := service.GetEnterPriseByUserOrgId(orgId)
  428. //fmt.Println("地址日活", enterPrise.Enterpriseid)
  429. //lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  430. //
  431. //newEnterPrise, sealId := service.CreateNewEnterPrise(enterPrise.Enterpriseid, lastPerson.UserId)
  432. //
  433. //fmt.Println("newEnterPrise",newEnterPrise)
  434. //service.UpdatePersonEnterPrise(lastPerson.ID, sealId)
  435. newEnterPrise, _ := service.CreateSDKEnterPrise()
  436. //var url string
  437. //url = "http://localhost:8890/sdk/seal/createEnterpriseSeal"
  438. //appId := beego.AppConfig.String("sign_appid")
  439. //
  440. //serviceKye := beego.AppConfig.String("serviceKye")
  441. //
  442. //serviceCode := beego.AppConfig.String("serviceCode")
  443. //
  444. //maprequest := make(map[string]interface{})
  445. //
  446. //maprequest["sealType"] = 1
  447. //maprequest["enterpriseName"] = "深圳伊森时光科技有限公司"
  448. //maprequest["horizontalText"] = "财务专用章"
  449. //
  450. //byterequest, _ := json.Marshal(maprequest)
  451. //reader := bytes.NewReader(byterequest)
  452. //
  453. //signatureStr, _ := service.GenerateHMACSHA1SignatureTwo(maprequest, serviceKye, serviceCode)
  454. //fmt.Println("signatureStr", signatureStr)
  455. //request, err := http.NewRequest("POST", url, reader)
  456. //
  457. //fmt.Println("request23222222222222222", request)
  458. //if err != nil {
  459. // fmt.Println(err.Error())
  460. //}
  461. //
  462. //request.Header.Set("appId", appId)
  463. //request.Header.Set("serviceCode", serviceCode)
  464. //request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  465. //request.Header.Set("Content-Signature", signatureStr)
  466. //client := http.Client{}
  467. //
  468. //resp, err := client.Do(request)
  469. //if err != nil {
  470. // fmt.Println(err.Error())
  471. //
  472. //}
  473. //respBytes, err := ioutil.ReadAll(resp.Body)
  474. //if err != nil {
  475. // fmt.Println(err.Error())
  476. //
  477. //}
  478. //str := string(respBytes)
  479. //fmt.Println("strwowowowowo", str)
  480. //
  481. //var respJSON map[string]interface{}
  482. //if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  483. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  484. //}
  485. this.ServeSuccessJSON(map[string]interface{}{
  486. "newEnterPrise": newEnterPrise,
  487. })
  488. return
  489. }
  490. func (this *SignApiController) GetContractId() {
  491. sign := service.GetContractId()
  492. this.ServeSuccessJSON(map[string]interface{}{
  493. "sign": sign,
  494. })
  495. return
  496. }
  497. func (this *SignApiController) EndEnterPrise() {
  498. sign := service.EndEnterPrise()
  499. this.ServeSuccessJSON(map[string]interface{}{
  500. "sign": sign,
  501. })
  502. return
  503. }
  504. func (this *SignApiController) GetEnterPriseDetail() {
  505. sign, url := service.GetEnterPriseDetail()
  506. this.ServeSuccessJSON(map[string]interface{}{
  507. "sign": sign,
  508. "url": url,
  509. })
  510. return
  511. }
  512. func (this *SignApiController) UploadPrintOrder() {
  513. orderList, _ := service.GetDialysisOrderListOne(21741)
  514. for _, item := range orderList {
  515. service.UpdateSchedulePatient(item.PatientId, item.DialysisDate, item.ZoneId, item.BedID)
  516. }
  517. //list, _ := service.GetAllPatientNew(10375)
  518. //for _, item := range list {
  519. //
  520. // hans := item.Name // 要转换的汉字字符串
  521. // // 创建一个拼音转换器
  522. // p := pinyin.NewArgs()
  523. //
  524. // // 将汉字转为拼音
  525. // pinyinSlice := pinyin.Pinyin(hans, p)
  526. //
  527. // // 输出拼音
  528. // fmt.Println("Pinyin:", pinyinSlice)
  529. //
  530. // // 获取首字母
  531. // firstLetter := ""
  532. // for _, py := range pinyinSlice {
  533. // if len(py) > 0 {
  534. // firstLetter += string(py[0][0])
  535. // }
  536. // }
  537. //
  538. // item.FirstLetter = firstLetter
  539. // service.UpdatePatientNew(item.ID, item.FirstLetter)
  540. // // 输出首字母
  541. // //fmt.Println("First Letter:", firstLetter)
  542. //}
  543. //baseList, _ := service.GeteAllBaseList(10375)
  544. //for _, item := range baseList {
  545. // hans := item.DrugName // 要转换的汉字字符串
  546. // // 创建一个拼音转换器
  547. // p := pinyin.NewArgs()
  548. // // 将汉字转为拼音
  549. // pinyinSlice := pinyin.Pinyin(hans, p)
  550. // // 获取首字母
  551. // firstLetter := ""
  552. // for _, py := range pinyinSlice {
  553. // if len(py) > 0 {
  554. // firstLetter += string(py[0][0])
  555. // }
  556. // }
  557. // item.FirstLetter = firstLetter
  558. // service.UpdateBaseList(item.ID, item.FirstLetter)
  559. //}
  560. //pdf := gofpdf.New("P", "mm", "A4", "")
  561. //pdf.AddPage()
  562. //pdf.Text(5, 10, "血液净化治疗记录单")
  563. //
  564. //pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
  565. //pdf.SetFont("simfang", "", 20)
  566. //var title = "血液透析(滤过)记录表单"
  567. ////表格居中显示
  568. //pdf.Text(70, 10, title)
  569. //wd := pdf.GetStringWidth(title) + 100
  570. //fmt.Println("wd", wd)
  571. //pdf.SetY(100) //先要设置 Y,然后再设置 X。否则,会导致 X 失效
  572. //pdf.SetX((210 - wd) / 2) //水平居中的算法
  573. //var numuber = "张三"
  574. ////表格居中显示
  575. //pdf.SetFont("", "", 14) // 设置加粗字体和字号
  576. //pdf.Text(10, 20, "姓名:"+numuber)
  577. //pdf.SetFont("", "", 14) // 设置加粗字体和字号
  578. //pdf.Text(35, 20, "性别:"+"男")
  579. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  580. //pdf.Text(60, 20, "年龄:"+"18")
  581. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  582. //pdf.Text(90, 20, "门诊:"+"住院")
  583. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  584. //pdf.Text(120, 20, "病区:"+"A区")
  585. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  586. //pdf.Text(150, 20, "床号:"+"1号")
  587. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  588. //pdf.Text(180, 20, "透析号:")
  589. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  590. //pdf.Text(210, 20, "住院号/门诊号:")
  591. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  592. ////表格居中显示
  593. //pdf.SetFont("", "", 14) // 设置加粗字体和字号
  594. //pdf.Text(10, 30, "入科方式:"+numuber)
  595. //pdf.SetFont("", "", 14) // 设置加粗字体和字号
  596. //pdf.Text(60, 30, "诊断:")
  597. //
  598. //pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
  599. //pdf.SetFont("simfang", "", 16) // 设置字体、字号
  600. //pdf.SetFillColor(200, 200, 200)
  601. ////// 设置起始位置
  602. //var x = 10.0
  603. //var y = 40.0
  604. //pdf.SetXY(x, y)
  605. //// 设置填充颜色
  606. //pdf.CellFormat(200, 15, "透析前情况", "1", 0, "CM", false, 0, "") // 使用CellFormat()方法创建表格单元格
  607. //param1: 单元格的宽,为0时表示一行,单位根据new()里面设置的来
  608. //param2: 单元格的高,不能为0,单位根据new()里面设置的来
  609. //param3: 单元格内容
  610. //param4: 边框样式,一个空字符串表示无边框,“1”表示全边框,一个或多个“L”,“T”,“R”和“B”分别表示边界左,上,右,下
  611. //param5: 表示调用后当前位置的位置。可能的值为0,接着当前行继续,1换行,2目前没有试过
  612. //param6: 字体的位置,水平对齐包括"L", “C"或"R”(左,中,右)。垂直对齐由包含控制"T", “M”, “B"或"A”(上,中,下,基线),可以组合,比如说LT,CM等等
  613. //param7: 是否填充单元格,需要调用SetFillColor()方法.默认false
  614. //param8: 内部超链接,没用过
  615. //param9: 超链接,没用过
  616. //pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
  617. //pdf.SetFont("simfang", "", 8) // 设置字体、字号
  618. //pdf.SetFillColor(200, 200, 200) // 设置填充颜色
  619. //
  620. //// 设置起始位置
  621. //var x = 10.0
  622. //var y = 40.0
  623. ////创建8行2列的表格
  624. //
  625. //for j := 0; j < 1; j++ {
  626. // // 填充每个单元格的内容
  627. // pdf.SetXY(x, y) // 设置当前位置
  628. // pdf.CellFormat(20, 15, "时间", "1", 0, "CM", false, 0, "") // 使用CellFormat()方法创建表格单元格
  629. // pdf.CellFormat(20, 15, "血压(mmHg)", "1", 0, "CM", false, 0, "")
  630. // pdf.CellFormat(20, 15, "脉搏(次/分)", "1", 0, "CM", false, 0, "")
  631. // pdf.CellFormat(20, 15, "呼吸(次/分)", "1", 0, "CM", false, 0, "")
  632. // pdf.CellFormat(20, 15, "血流量(ml/min)", "1", 0, "CM", false, 0, "")
  633. // pdf.CellFormat(20, 15, "静脉压(mmHg)", "1", 0, "CM", false, 0, "")
  634. // pdf.CellFormat(20, 15, "跨膜压(mmHg)", "1", 0, "CM", false, 0, "")
  635. // pdf.CellFormat(20, 15, "透析液温(℃)", "1", 0, "CM", false, 0, "")
  636. // pdf.CellFormat(20, 15, "钠浓度(mmol/L)", "1", 0, "CM", false, 0, "")
  637. // pdf.CellFormat(20, 15, "超滤量(ml) ", "1", 0, "CM", false, 0, "")
  638. // pdf.CellFormat(35, 15, "病情变化及处理", "1", 0, "CM", false, 0, "")
  639. //
  640. // y += 15 // 下一行起始位置的y坐标增加60(单元格高度)
  641. //}
  642. //for j := 0; j < 1; j++ {
  643. // // 填充每个单元格的内容
  644. // pdf.SetXY(x, y) // 设置当前位置
  645. // pdf.CellFormat(20, 15, "13:57", "1", 0, "CM", false, 0, "") // 使用CellFormat()方法创建表格单元格
  646. // pdf.CellFormat(20, 15, "120/90", "1", 0, "CM", false, 0, "")
  647. // pdf.CellFormat(20, 15, "64", "1", 0, "CM", false, 0, "")
  648. // pdf.CellFormat(20, 15, "100", "1", 0, "CM", false, 0, "")
  649. // pdf.CellFormat(20, 15, "100", "1", 0, "CM", false, 0, "")
  650. // pdf.CellFormat(20, 15, "100", "1", 0, "CM", false, 0, "")
  651. // pdf.CellFormat(20, 15, "90", "1", 0, "CM", false, 0, "")
  652. // pdf.CellFormat(20, 15, "36.5", "1", 0, "CM", false, 0, "")
  653. // pdf.CellFormat(20, 15, "26", "1", 0, "CM", false, 0, "")
  654. // pdf.CellFormat(20, 15, "100", "1", 0, "CM", false, 0, "")
  655. // pdf.CellFormat(35, 15, "及时九嶷山", "1", 0, "CM", false, 0, "")
  656. //
  657. // y += 15 // 下一行起始位置的y坐标增加60(单元格高度)
  658. //}
  659. //x += 200.0 // 下一列起始位置的x坐标增加190(单元格宽度)
  660. //y = 10.0 // 行起始位置的y坐标重置为10
  661. //
  662. //pdf.Ln(2)
  663. //if err := pdf.OutputFileAndClose("6.pdf"); err != nil {
  664. // panic(err.Error())
  665. //}
  666. // 此处可以继续绘制表格的其他部分,例如内容行等。
  667. // ...
  668. // 保存PDF文档到文件
  669. //err := pdf.OutputFileAndClose("treatment_sheet_with_header.pdf")
  670. //if err != nil {
  671. // panic(err)
  672. //}
  673. this.ServeSuccessJSON(map[string]interface{}{
  674. //"sign": information,
  675. //"pdfBase64": pdfBase64,
  676. //"name": name,
  677. })
  678. }
  679. func (this *SignApiController) CreateQianshuUserName() {
  680. admin_user_id, _ := this.GetInt64("admin_user_id")
  681. orgId := this.GetAdminUserInfo().CurrentOrgId
  682. userName := service.GetLastAdminUserName(admin_user_id, orgId)
  683. idCardNumber := service.GetLastAdminUserIdCardNumber(admin_user_id, orgId)
  684. adminRole, _ := service.GetMobile(admin_user_id)
  685. //查询该医护人员是否已经签署了
  686. lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  687. if len(lastPerson.UserId) > 0 {
  688. this.ServeDynamicFailJsonSend("已完成签署,无需再次签署")
  689. return
  690. }
  691. if len(lastPerson.UserId) == 0 {
  692. //去签署
  693. sign, userId := service.CreateQianshuUserName(userName, adminRole.Mobile, idCardNumber)
  694. err := service.UpdatePersionEnterPrise(lastPerson.ID, userId)
  695. fmt.Println(err)
  696. this.ServeSuccessJSON(map[string]interface{}{
  697. "sign": sign,
  698. "userId": userId,
  699. })
  700. }
  701. }
  702. func (this *SignApiController) CreateSdkSendInformation() {
  703. information, orderId := service.CreateSdkSendInformation()
  704. this.ServeSuccessJSON(map[string]interface{}{
  705. "information": information,
  706. "orderId": orderId,
  707. })
  708. }
  709. func (this *SignApiController) SavePdfInformation() {
  710. var name string
  711. information, pdfBase64 := service.SavePdfInformation(name)
  712. informationOne := service.ToCheckInformation(pdfBase64)
  713. maprequest := make(map[string]interface{})
  714. Receiver := make(map[string]interface{})
  715. //业务单号
  716. maprequest["orderId"] = "13318464642"
  717. maprequest["signTitle"] = "举报合同"
  718. //file := "C:/Users/28169/Desktop/2.pdf"
  719. file := "/swspan/gopath/src/XT_New/static/6.pdf"
  720. fileBytes, _ := ioutil.ReadFile(file) // 读取file
  721. contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串
  722. //文件获取方式
  723. maprequest["fileType"] = 1
  724. maprequest["pdfBase64"] = contractBase64
  725. //合同内容
  726. maprequest["fileContent"] = contractBase64
  727. //签署用户人ID
  728. maprequest["userId"] = "JMO9U8JH4TN8E3QOI0GUVUF2"
  729. //业务单号
  730. maprequest["receiver"] = Receiver
  731. //签署人账号
  732. Receiver["account"] = "13318464642"
  733. //签署个人类型 1.个人 2.企业
  734. Receiver["signerType"] = 1
  735. //签署人姓名
  736. Receiver["realName "] = "马文强"
  737. // 证件类型
  738. Receiver["cardType"] = 0
  739. //证件编码
  740. Receiver["cardNumber"] = "430526199408156511"
  741. stepStamper := make(map[string]interface{})
  742. keywordSignControls := make([]map[string]interface{}, 0)
  743. //预冲者样式
  744. inputArrOne := make(map[string]interface{})
  745. inputArrOne["sealName"] = "1"
  746. inputArrOne["keyword"] = "医生签名"
  747. inputArrOne["pages"] = "0"
  748. inputArrOne["offsetX"] = "100"
  749. inputArrOne["offsetY"] = "100"
  750. keywordSignControls = append(keywordSignControls, inputArrOne)
  751. //穿刺者样式
  752. //inputArr := make(map[string]interface{})
  753. //inputArr["sealName"] = "2"
  754. //inputArr["keyword"] = "治疗护士"
  755. //inputArr["pages"] = "1"
  756. //inputArr["offsetX"] = "100"
  757. //inputArr["offsetY"] = "0"
  758. //
  759. //keywordSignControls = append(keywordSignControls, inputArr)
  760. //
  761. ////上机者
  762. //inputArrSix := make(map[string]interface{})
  763. //inputArrSix["sealName"] = "3"
  764. //inputArrSix["keyword"] = "核对护士"
  765. //inputArrSix["pages"] = "1"
  766. //inputArrSix["offsetX"] = "100"
  767. //inputArrSix["offsetY"] = "0"
  768. //
  769. //keywordSignControls = append(keywordSignControls, inputArrSix)
  770. //
  771. //stepStamper["keywordSignControls"] = keywordSignControls
  772. //
  773. ////医生签名
  774. //inputArrSeven := make(map[string]interface{})
  775. //inputArrSeven["sealName"] = "4"
  776. //inputArrSeven["keyword"] = "医生签名"
  777. //inputArrSeven["pages"] = "1"
  778. //inputArrSeven["offsetX"] = "100"
  779. //inputArrSeven["offsetY"] = "0"
  780. //
  781. //keywordSignControls = append(keywordSignControls, inputArrSeven)
  782. //
  783. //stepStamper["keywordSignControls"] = keywordSignControls
  784. //crossSignControls := make([]map[string]interface{}, 0)
  785. //
  786. //inputArrTwo := make(map[string]interface{})
  787. //inputArrTwo["sealName"] = "1"
  788. //inputArrTwo["positionX"] = "0"
  789. //inputArrTwo["positionY"] = "0"
  790. //inputArrTwo["pages"] = "0"
  791. //crossSignControls = append(crossSignControls, inputArrTwo)
  792. //
  793. //stepStamper["crossSignControls"] = crossSignControls
  794. //
  795. xySignControls := make([]map[string]interface{}, 0)
  796. inputArrThree := make(map[string]interface{})
  797. inputArrThree["sealName"] = "1"
  798. inputArrThree["positionX"] = "100"
  799. inputArrThree["positionY"] = "0"
  800. inputArrThree["pages"] = "0"
  801. xySignControls = append(xySignControls, inputArrThree)
  802. stepStamper["xySignControls"] = xySignControls
  803. maprequest["stepStamper"] = stepStamper
  804. seals := make([]map[string]interface{}, 0)
  805. //预冲者
  806. sealImagesList := make(map[string]interface{})
  807. fileOne := "/swspan/gopath/src/XT_New/static/huangzihui.jpg"
  808. fileBytesOne, _ := ioutil.ReadFile(fileOne) // 读取file
  809. contractBase64One := base64.StdEncoding.EncodeToString(fileBytesOne) // 加密成base64字符串
  810. sealImagesList["sealBase64"] = contractBase64One
  811. //控制签名的大小
  812. sealImagesList["width"] = "50"
  813. sealImagesList["height"] = "50"
  814. sealImagesList["verticalAlign"] = "middle"
  815. sealTextsList := make(map[string]interface{})
  816. sealTextsList["text"] = "2023年8月8日"
  817. sealTextsList["fontSize"] = "100"
  818. sealTextsList["fontColor"] = "#333333"
  819. sealTextsList["isTextArea"] = true
  820. sealTextsList["textAlign"] = 0
  821. sealTextsList["width"] = 150
  822. sealTextsList["height"] = 20
  823. sealsObj := make(map[string]interface{})
  824. sealsObj["sealWidth"] = "150"
  825. sealsObj["sealHeight"] = "150"
  826. sealsObj["sealName"] = "1"
  827. sealsObj["sealImage"] = sealImagesList
  828. sealsObj["sealText"] = sealTextsList
  829. seals = append(seals, sealsObj)
  830. //穿刺者
  831. //sealImagesListOne := make(map[string]interface{})
  832. //
  833. //fileTwo := "/swspan/gopath/src/XT_New/static/huangjunji.jpg"
  834. //
  835. //fileBytesTwo, _ := ioutil.ReadFile(fileTwo) // 读取file
  836. //
  837. //contractBase64Two := base64.StdEncoding.EncodeToString(fileBytesTwo) // 加密成base64字符串
  838. //sealImagesListOne["sealBase64"] = contractBase64Two
  839. ////控制签名的大小
  840. //sealImagesListOne["width"] = "50"
  841. //sealImagesListOne["height"] = "50"
  842. //sealImagesListOne["verticalAlign"] = "middle"
  843. //
  844. //sealTextsListOne := make(map[string]interface{})
  845. //sealTextsListOne["text"] = "2023年8月8日"
  846. //sealTextsListOne["fontSize"] = "100"
  847. //sealTextsListOne["fontColor"] = "100"
  848. //sealTextsListOne["isTextArea"] = true
  849. //sealTextsListOne["textAlign"] = 0
  850. //sealTextsListOne["width"] = 150
  851. //sealTextsListOne["height"] = 20
  852. //
  853. //sealsObjOne := make(map[string]interface{})
  854. //
  855. //sealsObjOne["sealWidth"] = "150"
  856. //sealsObjOne["sealHeight"] = "150"
  857. //sealsObjOne["sealName"] = "2"
  858. //sealsObjOne["sealImage"] = sealImagesListOne
  859. //sealsObjOne["sealText"] = sealTextsListOne
  860. //seals = append(seals, sealsObjOne)
  861. //间隔签名
  862. //上机者
  863. //sealImagesListTwo := make(map[string]interface{})
  864. //fileThree := "/swspan/gopath/src/XT_New/static/jianfeixia.jpg"
  865. //fileBytesThree, _ := ioutil.ReadFile(fileThree) // 读取file
  866. //contractBase64Three := base64.StdEncoding.EncodeToString(fileBytesThree) // 加密成base64字符串
  867. //sealImagesListTwo["sealBase64"] = contractBase64Three
  868. ////控制签名的大小
  869. //sealImagesListTwo["width"] = "50"
  870. //sealImagesListTwo["height"] = "50"
  871. //sealImagesListTwo["verticalAlign"] = "middle"
  872. //
  873. //sealTextsListTwo := make(map[string]interface{})
  874. //sealTextsListTwo["text"] = "2023年8月8日"
  875. //sealTextsListTwo["fontSize"] = "100"
  876. //sealTextsListTwo["fontColor"] = "100"
  877. //sealTextsListTwo["isTextArea"] = true
  878. //sealTextsListTwo["textAlign"] = 0
  879. //sealTextsListTwo["width"] = 150
  880. //sealTextsListTwo["height"] = 20
  881. //
  882. //sealsObjTwo := make(map[string]interface{})
  883. //
  884. //sealsObjTwo["sealWidth"] = "150"
  885. //sealsObjTwo["sealHeight"] = "150"
  886. //sealsObjTwo["sealName"] = "3"
  887. //sealsObjTwo["sealImage"] = sealImagesListTwo
  888. //sealsObjTwo["sealText"] = sealTextsListTwo
  889. //seals = append(seals, sealsObjTwo)
  890. //医生签名
  891. //sealImagesListThree := make(map[string]interface{})
  892. //fileFour := "/swspan/gopath/src/XT_New/static/jianfeixia.jpg"
  893. //fileBytesFour, _ := ioutil.ReadFile(fileFour) // 读取file
  894. //contractBase64Tour := base64.StdEncoding.EncodeToString(fileBytesFour) // 加密成base64字符串
  895. //sealImagesListThree["sealBase64"] = contractBase64Tour
  896. ////控制签名的大小
  897. //sealImagesListThree["width"] = "50"
  898. //sealImagesListThree["height"] = "50"
  899. //sealImagesListThree["verticalAlign"] = "middle"
  900. //
  901. //sealTextsListThree := make(map[string]interface{})
  902. //sealTextsListThree["text"] = "2023年8月8日"
  903. //sealTextsListThree["fontSize"] = "100"
  904. //sealTextsListThree["fontColor"] = "100"
  905. //sealTextsListThree["isTextArea"] = true
  906. //sealTextsListThree["textAlign"] = 0
  907. //sealTextsListThree["width"] = 150
  908. //sealTextsListThree["height"] = 20
  909. //
  910. //sealsObjThree := make(map[string]interface{})
  911. //
  912. //sealsObjThree["sealWidth"] = "150"
  913. //sealsObjThree["sealHeight"] = "150"
  914. //sealsObjThree["sealName"] = "4"
  915. //sealsObjThree["sealImage"] = sealImagesListThree
  916. //sealsObjThree["sealText"] = sealTextsListThree
  917. //seals = append(seals, sealsObjThree)
  918. maprequest["seals"] = seals
  919. maprequest["isUserWishes"] = true
  920. maprequest["phone"] = "13318464642"
  921. maprequest["verificationCode"] = "18888888888"
  922. this.ServeSuccessJSON(map[string]interface{}{
  923. "information": information,
  924. "orderId": pdfBase64,
  925. "informationOne": informationOne,
  926. "maprequest": maprequest,
  927. })
  928. }
  929. func (this *SignApiController) ToCheckInformation() {
  930. var name string
  931. information, pdfBase64 := service.SavePdfInformation(name)
  932. informationOne := service.ToCheckInformation(pdfBase64)
  933. this.ServeSuccessJSON(map[string]interface{}{
  934. "information": information,
  935. "informationOne": informationOne,
  936. })
  937. }
  938. func (this *SignApiController) ToAutoDrug() {
  939. //advice, _ := service.GetAutoDrugList(9919)
  940. //
  941. //for _, item := range advice {
  942. // //查找该患者是否出库过
  943. // outList, _ := service.GetDrugAutoWarehouseOutList(item.PatientId, item.UserOrgId, item.DrugId, item.AdviceDate)
  944. // if outList.ID == 0 {
  945. // service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
  946. // }
  947. //}
  948. //prescriptionList, _ := service.GetAllPrescriptionList(10579)
  949. list, _ := service.GetScheduleListByOrder(10579)
  950. for _, item := range list {
  951. soluton, _ := service.GetDialysisSoluton(item.PatientId, item.ModeId)
  952. var DialysisMachineName string
  953. if len(soluton.DialysisDialyszers) > 0 {
  954. DialysisMachineName = soluton.DialysisDialyszers
  955. }
  956. //if len(soluton.DialyzerPerfusionApparatus) > 0 {
  957. // DialysisMachineName = DialysisMachineName + "," + soluton.DialyzerPerfusionApparatus
  958. //}
  959. if len(soluton.DialysisIrrigation) > 0 {
  960. DialysisMachineName = DialysisMachineName + "," + soluton.DialysisIrrigation
  961. }
  962. if len(soluton.DialysisStrainer) > 0 {
  963. DialysisMachineName = DialysisMachineName + "," + soluton.DialysisStrainer
  964. }
  965. DialysisMachineName = DialysisMachineName
  966. service.UpdateDialysisSchedule(item.ID, DialysisMachineName)
  967. }
  968. //for _, item := range prescriptionList {
  969. // var DialysisMachineName string
  970. // if len(item.DialysisDialyszers) > 0 {
  971. // DialysisMachineName = item.DialysisDialyszers
  972. // }
  973. // if len(item.DialyzerPerfusionApparatus) > 0 {
  974. // DialysisMachineName = DialysisMachineName + "," + item.DialyzerPerfusionApparatus
  975. // }
  976. //
  977. // if len(item.DialysisIrrigation) > 0 {
  978. // DialysisMachineName = DialysisMachineName + "," + item.DialysisIrrigation
  979. // }
  980. //
  981. // if len(item.DialysisStrainer) > 0 {
  982. // DialysisMachineName = DialysisMachineName + "," + item.DialysisStrainer
  983. // }
  984. // DialysisMachineName = DialysisMachineName
  985. // service.UpdateSchPatient(item.PatientId, item.RecordDate, item.UserOrgId, DialysisMachineName)
  986. //}
  987. this.ServeSuccessJSON(map[string]interface{}{
  988. "msg": "ok",
  989. })
  990. }
  991. func (this *SignApiController) ToAutoDiagnose() {
  992. //orgId := this.GetAdminUserInfo().CurrentOrgId
  993. //order, _ := service.GetDialysisOrderTotalCount()
  994. //
  995. //for _, item := range order {
  996. //
  997. // service.ModifyPatient(item.PatientId, item.Count)
  998. //}
  999. //list, _ := service.GetNewAllpatient(orgId)
  1000. //
  1001. //for _, item := range list {
  1002. // service.UpdateAllPatient(item.BloodId, item.Diagnose, item.UserOrgId)
  1003. //}
  1004. //list, _ := service.GetAllDialysisOrderTwo(10340)
  1005. //
  1006. //for _, item := range list {
  1007. // schedule, _ := service.GetLastScheduleByUserOrg(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType)
  1008. // service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType, schedule.ID)
  1009. //}
  1010. //drugList, _ := service.GetAllBaseDrugList(10318)
  1011. //for _, item := range drugList {
  1012. // service.UpdateDrugWarehouseInfoByDrug(item.ID, item.MinPrice, item.OrgId)
  1013. //
  1014. // //service.UpdateHisDoctorAdviceOne(item.ID, item.MinPrice, item.OrgId)
  1015. //}
  1016. //goodList, _ := service.GetAllGoodList(10571)
  1017. //for _, item := range goodList {
  1018. // service.UpdasteGoodWarehouseInfoByGood(item.ID, item.PackingPrice, item.OrgId)
  1019. //}
  1020. //list, _ := service.GetAllDialysisPrescription(29190)
  1021. //
  1022. //for _, item := range list {
  1023. // service.UpdateSchedulePrescrition(item.PatientId, item.RecordDate, item.UserOrgId, item.ModeId)
  1024. //}
  1025. //list, _ := service.GetPatientLapseList()
  1026. //
  1027. //fmt.Println(list)
  1028. //if len(list) > 0 {
  1029. // for _, items := range list {
  1030. // schedulelist, _ := service.GetPatientScheduleListByItem(items.ID)
  1031. // if len(schedulelist) < 2 {
  1032. // for _, it := range schedulelist {
  1033. // orderList, _ := service.GetAllDialysisOrder(it.PatientId, 1731254400, 1731254400)
  1034. // for _, item := range orderList {
  1035. // schedule, _ := service.GetLastScheduleByUserOrg(item.PatientId, item.DialysisDate, item.UserOrgId, item.BedId, item.ZoneId, item.SchedualType)
  1036. // prescribeOne, _ := service.GetDialysisPrescribeOne(item.UserOrgId, item.PatientId, item.DialysisDate)
  1037. // service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, item.UserOrgId, item.BedId, item.ZoneId, item.SchedualType, schedule.ID, prescribeOne.ModeId)
  1038. // }
  1039. //
  1040. // }
  1041. // }
  1042. // }
  1043. //}
  1044. adviceList, _ := service.GetHisDoctorAdviceNoCheck(10721)
  1045. if len(adviceList) > 0 {
  1046. for _, item := range adviceList {
  1047. checkObj, _ := service.GetDobuleCheckOne(item.UserOrgId, item.AdviceDate, item.PatientId)
  1048. service.UpdateHisAdvice(item.PatientId, item.AdviceDate, item.UserOrgId, checkObj.Creater, checkObj.CheckDate)
  1049. }
  1050. }
  1051. this.ServeSuccessJSON(map[string]interface{}{
  1052. "msg": "ok",
  1053. })
  1054. }
  1055. func (this *SignApiController) ToAutoJiaYou() {
  1056. list, _ := service.GetPrescriptionListOne(10579)
  1057. for _, item := range list {
  1058. schedule, _ := service.GetPatientScheduleById(item.PatientId, item.RecordDate)
  1059. var DialysisMachineName string
  1060. if len(item.DialysisDialyszers) > 0 {
  1061. DialysisMachineName = item.DialysisDialyszers
  1062. }
  1063. if len(item.DialysisIrrigation) > 0 {
  1064. DialysisMachineName = DialysisMachineName + "," + item.DialysisIrrigation
  1065. }
  1066. if len(item.DialysisStrainer) > 0 {
  1067. DialysisMachineName = DialysisMachineName + "," + item.DialysisStrainer
  1068. }
  1069. DialysisMachineName = DialysisMachineName
  1070. service.UpdateDialysisScheduleOne(schedule.ID, item.ModeId, DialysisMachineName)
  1071. }
  1072. }
  1073. func (this *SignApiController) GetFieldConfigList() {
  1074. orderList, _ := service.GetDialysisOrderByUserOrgId()
  1075. if len(orderList) > 0 {
  1076. filedConfigList, _ := service.GetFieldConfigList(9442)
  1077. for _, item := range orderList {
  1078. for _, it := range filedConfigList {
  1079. //查询该机构该模式是否有这个字段
  1080. fiedConfigObj, _ := service.GetFieldConfigByOrgId(item.UserOrgId, it.FiledNameCn, it.Module)
  1081. if fiedConfigObj.ID == 0 {
  1082. config := models.FiledConfig{
  1083. OrgId: item.UserOrgId,
  1084. Module: it.Module,
  1085. FiledName: it.FiledName,
  1086. FiledNameCn: it.FiledNameCn,
  1087. IsShow: 2,
  1088. CreateTime: time.Now().Unix(),
  1089. UpdateTime: time.Now().Unix(),
  1090. SysModule: it.SysModule,
  1091. IsWrite: it.IsWrite,
  1092. IsSecondMenu: it.IsSecondMenu,
  1093. }
  1094. service.CretedConfig(config)
  1095. }
  1096. }
  1097. }
  1098. }
  1099. //filedConfig, _ := service.GetFieldConfigGroupList(7)
  1100. //if len(filedConfig) > 0 {
  1101. // for _, item := range filedConfig {
  1102. // //查询该机构
  1103. // fiedConfigObj, _ := service.GetFieldConfigByOrgId(9442, item.FiledNameCn, item.Module)
  1104. //
  1105. // if fiedConfigObj.ID == 0 {
  1106. //
  1107. // config := models.FiledConfig{
  1108. // OrgId: 9442,
  1109. // Module: item.Module,
  1110. // FiledName: item.FiledName,
  1111. // FiledNameCn: item.FiledNameCn,
  1112. // IsShow: 2,
  1113. // CreateTime: time.Now().Unix(),
  1114. // UpdateTime: time.Now().Unix(),
  1115. // SysModule: item.SysModule,
  1116. // IsWrite: item.IsWrite,
  1117. // IsSecondMenu: item.IsSecondMenu,
  1118. // }
  1119. //
  1120. // service.CretedConfig(config)
  1121. // }
  1122. // }
  1123. //}
  1124. this.ServeSuccessJSON(map[string]interface{}{
  1125. "msg": "ok",
  1126. })
  1127. }
  1128. // 校验库存的脚本
  1129. func (this *SignApiController) ToCheckQuery() {
  1130. //获取监测监控的库存情况
  1131. queryList, _ := service.GetAllCheckQuery()
  1132. var recordDateStr = time.Now().Format("2006-01-02")
  1133. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  1134. if len(queryList) > 0 {
  1135. for _, item := range queryList {
  1136. //查询今日该机构总的医嘱数量
  1137. adviceList, _ := service.GetAllDoctorAdviceQueryList(item.UserOrgId, recordDate.Unix())
  1138. if len(adviceList) > 0 {
  1139. for _, it := range adviceList {
  1140. var prescription_count int64
  1141. var out_count int64
  1142. advice, _ := service.GetDrugListById(it.DrugId, it.AdviceDate, it.PatientId)
  1143. medical, _ := service.GetBaseDrugMedical(it.DrugId)
  1144. if len(advice) > 0 {
  1145. for _, its := range advice {
  1146. prescribingNumberSix := strconv.FormatFloat(its.PrescribingNumber, 'f', -1, 64)
  1147. prescribingNumberSeven, _ := strconv.ParseInt(prescribingNumberSix, 10, 64)
  1148. if its.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
  1149. prescription_count += prescribingNumberSeven * medical.MinNumber
  1150. }
  1151. if its.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
  1152. prescription_count += prescribingNumberSeven
  1153. }
  1154. if its.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
  1155. prescription_count += prescribingNumberSeven
  1156. }
  1157. }
  1158. }
  1159. outinfo, _ := service.GetDrugWarehouseOutQueryListById(it.DrugId, it.AdviceDate, it.PatientId)
  1160. if len(outinfo) > 0 {
  1161. for _, s := range outinfo {
  1162. if s.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
  1163. out_count += s.Count * medical.MinNumber
  1164. }
  1165. if s.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
  1166. out_count += s.Count
  1167. }
  1168. if s.CountUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
  1169. out_count += s.Count
  1170. }
  1171. }
  1172. }
  1173. patients, _ := service.GetPatientName(it.PatientId)
  1174. var specifaciton_name string
  1175. specifaciton_name = medical.Dose + medical.DoseUnit + "*" + strconv.FormatInt(medical.MinNumber, 10) + medical.MinUnit + "/" + medical.MaxUnit
  1176. //如果当天医嘱数量和出库数量不一致,那么则插入到数据库
  1177. if prescription_count != out_count {
  1178. checkQuery := models.XtDrugCheckQuery{
  1179. DrugId: it.DrugId,
  1180. RecordDate: it.AdviceDate,
  1181. AdviceCount: prescription_count,
  1182. OutCount: out_count,
  1183. PatientId: it.PatientId,
  1184. UserOrgId: it.UserOrgId,
  1185. ExecutionState: it.ExecutionState,
  1186. IsMedicine: it.IsMedicine,
  1187. DrugName: medical.DrugName,
  1188. SpecificationName: specifaciton_name,
  1189. Name: patients.Name,
  1190. }
  1191. service.CreateCheckQuery(checkQuery)
  1192. }
  1193. }
  1194. }
  1195. //查询今日改机构耗材的总的医嘱数量
  1196. projectList, _ := service.GetAllPrescriptionProjectList(item.UserOrgId, recordDate.Unix())
  1197. if len(projectList) > 0 {
  1198. for _, item := range projectList {
  1199. var prescription_count int64
  1200. var out_count int64
  1201. project, _ := service.GetProjectListByPatient(item.PatientId, item.ProjectId, item.RecordDate)
  1202. for _, its := range project {
  1203. count, _ := strconv.ParseInt(its.Count, 10, 64)
  1204. prescription_count += count
  1205. }
  1206. outList, _ := service.GetWarehosueOutQueryList(item.PatientId, item.ProjectId, item.RecordDate)
  1207. for _, s := range outList {
  1208. out_count += s.Count
  1209. }
  1210. goodIdThirty, _ := service.GetGoodInformationByGoodIdThirty(item.ProjectId)
  1211. patients, _ := service.GetPatientName(item.PatientId)
  1212. //fmt.Println("hahhahahahahhh", item.ProjectId)
  1213. //fmt.Println("prescription_count", prescription_count)
  1214. //fmt.Println("out_count", out_count)
  1215. if prescription_count != out_count {
  1216. stockCheckQuery := models.XtStockCheckQuery{
  1217. GoodId: item.ProjectId,
  1218. RecordDate: item.RecordDate,
  1219. AdviceCount: prescription_count,
  1220. OutCount: out_count,
  1221. PatientId: item.PatientId,
  1222. UserOrgId: item.UserOrgId,
  1223. GoodName: goodIdThirty.GoodName,
  1224. SpecificationName: goodIdThirty.SpecificationName,
  1225. Name: patients.Name,
  1226. }
  1227. service.CreteStockCheckQuery(stockCheckQuery)
  1228. }
  1229. }
  1230. }
  1231. }
  1232. }
  1233. this.ServeSuccessJSON(map[string]interface{}{
  1234. "msg": "ok",
  1235. })
  1236. }