sign_api_controller.go 44KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493
  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(10892)
  1005. fmt.Println("list=============", list)
  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. this.ServeSuccessJSON(map[string]interface{}{
  1021. "msg": "ok",
  1022. })
  1023. }
  1024. func (this *SignApiController) ToAutoJiaYou() {
  1025. list, _ := service.GetPrescriptionListOne(10579)
  1026. for _, item := range list {
  1027. schedule, _ := service.GetPatientScheduleById(item.PatientId, item.RecordDate)
  1028. var DialysisMachineName string
  1029. if len(item.DialysisDialyszers) > 0 {
  1030. DialysisMachineName = item.DialysisDialyszers
  1031. }
  1032. if len(item.DialysisIrrigation) > 0 {
  1033. DialysisMachineName = DialysisMachineName + "," + item.DialysisIrrigation
  1034. }
  1035. if len(item.DialysisStrainer) > 0 {
  1036. DialysisMachineName = DialysisMachineName + "," + item.DialysisStrainer
  1037. }
  1038. DialysisMachineName = DialysisMachineName
  1039. service.UpdateDialysisScheduleOne(schedule.ID, item.ModeId, DialysisMachineName)
  1040. }
  1041. }
  1042. func (this *SignApiController) GetFieldConfigList() {
  1043. orderList, _ := service.GetDialysisOrderByUserOrgId()
  1044. if len(orderList) > 0 {
  1045. filedConfigList, _ := service.GetFieldConfigList(9442)
  1046. for _, item := range orderList {
  1047. for _, it := range filedConfigList {
  1048. //查询该机构该模式是否有这个字段
  1049. fiedConfigObj, _ := service.GetFieldConfigByOrgId(item.UserOrgId, it.FiledNameCn, it.Module)
  1050. if fiedConfigObj.ID == 0 {
  1051. config := models.FiledConfig{
  1052. OrgId: item.UserOrgId,
  1053. Module: it.Module,
  1054. FiledName: it.FiledName,
  1055. FiledNameCn: it.FiledNameCn,
  1056. IsShow: 2,
  1057. CreateTime: time.Now().Unix(),
  1058. UpdateTime: time.Now().Unix(),
  1059. SysModule: it.SysModule,
  1060. IsWrite: it.IsWrite,
  1061. IsSecondMenu: it.IsSecondMenu,
  1062. }
  1063. service.CretedConfig(config)
  1064. }
  1065. }
  1066. }
  1067. }
  1068. //filedConfig, _ := service.GetFieldConfigGroupList(7)
  1069. //if len(filedConfig) > 0 {
  1070. // for _, item := range filedConfig {
  1071. // //查询该机构
  1072. // fiedConfigObj, _ := service.GetFieldConfigByOrgId(9442, item.FiledNameCn, item.Module)
  1073. //
  1074. // if fiedConfigObj.ID == 0 {
  1075. //
  1076. // config := models.FiledConfig{
  1077. // OrgId: 9442,
  1078. // Module: item.Module,
  1079. // FiledName: item.FiledName,
  1080. // FiledNameCn: item.FiledNameCn,
  1081. // IsShow: 2,
  1082. // CreateTime: time.Now().Unix(),
  1083. // UpdateTime: time.Now().Unix(),
  1084. // SysModule: item.SysModule,
  1085. // IsWrite: item.IsWrite,
  1086. // IsSecondMenu: item.IsSecondMenu,
  1087. // }
  1088. //
  1089. // service.CretedConfig(config)
  1090. // }
  1091. // }
  1092. //}
  1093. this.ServeSuccessJSON(map[string]interface{}{
  1094. "msg": "ok",
  1095. })
  1096. }
  1097. // 校验库存的脚本
  1098. func (this *SignApiController) ToCheckQuery() {
  1099. //获取监测监控的库存情况
  1100. queryList, _ := service.GetAllCheckQuery()
  1101. var recordDateStr = time.Now().Format("2006-01-02")
  1102. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  1103. if len(queryList) > 0 {
  1104. for _, item := range queryList {
  1105. //查询今日该机构总的医嘱数量
  1106. adviceList, _ := service.GetAllDoctorAdviceQueryList(item.UserOrgId, recordDate.Unix())
  1107. if len(adviceList) > 0 {
  1108. for _, it := range adviceList {
  1109. var prescription_count int64
  1110. var out_count int64
  1111. advice, _ := service.GetDrugListById(it.DrugId, it.AdviceDate, it.PatientId)
  1112. medical, _ := service.GetBaseDrugMedical(it.DrugId)
  1113. if len(advice) > 0 {
  1114. for _, its := range advice {
  1115. prescribingNumberSix := strconv.FormatFloat(its.PrescribingNumber, 'f', -1, 64)
  1116. prescribingNumberSeven, _ := strconv.ParseInt(prescribingNumberSix, 10, 64)
  1117. if its.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
  1118. prescription_count += prescribingNumberSeven * medical.MinNumber
  1119. }
  1120. if its.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
  1121. prescription_count += prescribingNumberSeven
  1122. }
  1123. if its.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
  1124. prescription_count += prescribingNumberSeven
  1125. }
  1126. }
  1127. }
  1128. outinfo, _ := service.GetDrugWarehouseOutQueryListById(it.DrugId, it.AdviceDate, it.PatientId)
  1129. if len(outinfo) > 0 {
  1130. for _, s := range outinfo {
  1131. if s.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
  1132. out_count += s.Count * medical.MinNumber
  1133. }
  1134. if s.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
  1135. out_count += s.Count
  1136. }
  1137. if s.CountUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
  1138. out_count += s.Count
  1139. }
  1140. }
  1141. }
  1142. patients, _ := service.GetPatientName(it.PatientId)
  1143. var specifaciton_name string
  1144. specifaciton_name = medical.Dose + medical.DoseUnit + "*" + strconv.FormatInt(medical.MinNumber, 10) + medical.MinUnit + "/" + medical.MaxUnit
  1145. //如果当天医嘱数量和出库数量不一致,那么则插入到数据库
  1146. if prescription_count != out_count {
  1147. checkQuery := models.XtDrugCheckQuery{
  1148. DrugId: it.DrugId,
  1149. RecordDate: it.AdviceDate,
  1150. AdviceCount: prescription_count,
  1151. OutCount: out_count,
  1152. PatientId: it.PatientId,
  1153. UserOrgId: it.UserOrgId,
  1154. ExecutionState: it.ExecutionState,
  1155. IsMedicine: it.IsMedicine,
  1156. DrugName: medical.DrugName,
  1157. SpecificationName: specifaciton_name,
  1158. Name: patients.Name,
  1159. }
  1160. service.CreateCheckQuery(checkQuery)
  1161. }
  1162. }
  1163. }
  1164. //查询今日改机构耗材的总的医嘱数量
  1165. projectList, _ := service.GetAllPrescriptionProjectList(item.UserOrgId, recordDate.Unix())
  1166. if len(projectList) > 0 {
  1167. for _, item := range projectList {
  1168. var prescription_count int64
  1169. var out_count int64
  1170. project, _ := service.GetProjectListByPatient(item.PatientId, item.ProjectId, item.RecordDate)
  1171. for _, its := range project {
  1172. count, _ := strconv.ParseInt(its.Count, 10, 64)
  1173. prescription_count += count
  1174. }
  1175. outList, _ := service.GetWarehosueOutQueryList(item.PatientId, item.ProjectId, item.RecordDate)
  1176. for _, s := range outList {
  1177. out_count += s.Count
  1178. }
  1179. goodIdThirty, _ := service.GetGoodInformationByGoodIdThirty(item.ProjectId)
  1180. patients, _ := service.GetPatientName(item.PatientId)
  1181. //fmt.Println("hahhahahahahhh", item.ProjectId)
  1182. //fmt.Println("prescription_count", prescription_count)
  1183. //fmt.Println("out_count", out_count)
  1184. if prescription_count != out_count {
  1185. stockCheckQuery := models.XtStockCheckQuery{
  1186. GoodId: item.ProjectId,
  1187. RecordDate: item.RecordDate,
  1188. AdviceCount: prescription_count,
  1189. OutCount: out_count,
  1190. PatientId: item.PatientId,
  1191. UserOrgId: item.UserOrgId,
  1192. GoodName: goodIdThirty.GoodName,
  1193. SpecificationName: goodIdThirty.SpecificationName,
  1194. Name: patients.Name,
  1195. }
  1196. service.CreteStockCheckQuery(stockCheckQuery)
  1197. }
  1198. }
  1199. }
  1200. }
  1201. }
  1202. this.ServeSuccessJSON(map[string]interface{}{
  1203. "msg": "ok",
  1204. })
  1205. }