sign_api_controller.go 32KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  1. package controllers
  2. import (
  3. "XT_New/models"
  4. "XT_New/service"
  5. "encoding/base64"
  6. "encoding/json"
  7. "fmt"
  8. "github.com/astaxie/beego"
  9. "github.com/jung-kurt/gofpdf"
  10. "io/ioutil"
  11. "time"
  12. )
  13. type SignApiController struct {
  14. BaseAuthAPIController
  15. }
  16. func SignApiRegistRouters() {
  17. //获取短信验证码
  18. beego.Router("/api/sign/getsign", &SignApiController{}, "Get:GetSign")
  19. //创建个人用户并实名
  20. beego.Router("/api/sign/createrusername", &SignApiController{}, "Get:CreateUserName")
  21. //创建企业用户并实名
  22. beego.Router("/api/sign/createenterpriserealname", &SignApiController{}, "Get:CreateEnterPriseRealName")
  23. //添加企业成员
  24. beego.Router("/api/sign/createuserid", &SignApiController{}, "Get:CreateUserId")
  25. //创建个人印章
  26. beego.Router("/api/sign/createpersionseal", &SignApiController{}, "Get:CreatePersionSeal")
  27. //上传文件创建创建合同
  28. beego.Router("/api/sign/createuploadpact", &SignApiController{}, "Get:CreateUploadPact")
  29. //添加合同签署人
  30. beego.Router("/api/sign/addcontractsignatory", &SignApiController{}, "Get:AddContractSignatory")
  31. //获取短信验证
  32. beego.Router("/api/sign/getverificationcode", &SignApiController{}, "Get:GetVerificationCode")
  33. //后台签署(返回签署文件)
  34. beego.Router("/api/sign/createbackstagesign", &SignApiController{}, "Get:CreateBackStageSign")
  35. //署意愿认证-短信验证
  36. beego.Router("/api/sign/totestelment", &SignApiController{}, "Get:CreateEnterprise")
  37. //测试PDF
  38. beego.Router("/api/sign/totestthrityment", &SignApiController{}, "Get:GetTestThrityMent")
  39. //CA企业认证
  40. beego.Router("/api/sign/saveenerprise", &SignApiController{}, "Post:SaveEnerprise")
  41. //
  42. beego.Router("/api/sign/getenerprisebyid", &SignApiController{}, "Get:GetEnerPriseById")
  43. beego.Router("/api/sign/getmobilecode", &SignApiController{}, "Get:GetMobileCode")
  44. beego.Router("/api/sign/getpersionenterprise", &SignApiController{}, "Post:GetPersionEnterPrise")
  45. beego.Router("/api/sign/getpersenterprisebyid", &SignApiController{}, "Get:GetPerseEnterPriseById")
  46. beego.Router("/api/device/sign/creterpersionseal", &SignApiController{}, "Get:CreateNewPersionSeal")
  47. beego.Router("/api/device/sign/createnewenterprise", &SignApiController{}, "Get:CreateNewEnterPrise")
  48. beego.Router("/api/device/contractid", &SignApiController{}, "Get:GetContractId")
  49. beego.Router("/api/device/endenterprise", &SignApiController{}, "Get:EndEnterPrise")
  50. beego.Router("/api/device/getenterprisedetail", &SignApiController{}, "Get:GetEnterPriseDetail")
  51. beego.Router("/api/device/uploadprintorder", &SignApiController{}, "Post:UploadPrintOrder")
  52. //sdk 版本
  53. beego.Router("/api/device/createqianshuusername", &SignApiController{}, "Post:CreateQianshuUserName")
  54. //发送消息
  55. beego.Router("/api/device/createskdsendinformation", &SignApiController{}, "Post:CreateSdkSendInformation")
  56. //删除
  57. beego.Router("/api/device/tosavepdfinformation", &SignApiController{}, "Get:SavePdfInformation")
  58. beego.Router("/api/device/tocheckinformation", &SignApiController{}, "Get:ToCheckInformation")
  59. }
  60. // 短信服务接口
  61. func (this *SignApiController) GetSign() {
  62. phone := this.GetString("phone")
  63. fmt.Println("phone", phone)
  64. var tempphone string
  65. tempphone = "13318464642"
  66. sign := service.GetSignNameByPhone(tempphone)
  67. this.ServeSuccessJSON(map[string]interface{}{
  68. "sign": sign,
  69. })
  70. return
  71. }
  72. type Result2121 struct {
  73. Phone string `json:"phone"`
  74. DisPlayName string `json:"dis_play_name"`
  75. Authentication string `json:"authentication"`
  76. TwAuthReq struct {
  77. OneLineAuth string `json:"oneLineAuth"`
  78. ApiAuthReq struct {
  79. RealName float64 `json:"real_name"`
  80. IdCardType string `json:"id_card_type"`
  81. IdCardNum string `json:"id_card_num"`
  82. BankCard string `json:"bank_card"`
  83. CodeNumber string `json:"code_number"`
  84. VerifyCode string `json:"verify_code"`
  85. } `json:"apiAuthReq"`
  86. } `json:"twAuthReq"`
  87. }
  88. type MapData struct {
  89. dat struct {
  90. Code float64 `json:"code"`
  91. data struct {
  92. userId string `json:"userId"`
  93. }
  94. }
  95. }
  96. // 创建个人用户并实名
  97. func (this *SignApiController) CreateUserName() {
  98. phone := this.GetString("phone")
  99. disPlayName := this.GetString("disPlayName")
  100. sign, userId := service.CreateUserName(phone, disPlayName)
  101. var dat map[string]interface{}
  102. if err := json.Unmarshal([]byte(sign), &dat); err == nil {
  103. fmt.Println(dat)
  104. } else {
  105. fmt.Println(err)
  106. }
  107. this.ServeSuccessJSON(map[string]interface{}{
  108. "sign": sign,
  109. "dat": dat,
  110. "userId": userId,
  111. })
  112. return
  113. }
  114. // 创建个人印章
  115. func (this *SignApiController) CreatePersionSeal() {
  116. user_id := this.GetString("user_id")
  117. person_seal_type, _ := this.GetInt64("person_seal_type")
  118. person_seal_name := this.GetString("person_seal_name")
  119. person_seal_base := this.GetString("person_seal_base")
  120. color, _ := this.GetInt64("color")
  121. alpha, _ := this.GetInt64("alpha")
  122. width, _ := this.GetInt64("width")
  123. height, _ := this.GetInt64("height")
  124. border, _ := this.GetInt64("border")
  125. font_type, _ := this.GetInt64("font_type")
  126. sign, personSealId := service.CreatePersionSeal(user_id, person_seal_type, person_seal_name, person_seal_base, color, alpha, width, height, border, font_type)
  127. var dat map[string]interface{}
  128. if err := json.Unmarshal([]byte(sign), &dat); err == nil {
  129. fmt.Println(dat)
  130. } else {
  131. fmt.Println(err)
  132. }
  133. this.ServeSuccessJSON(map[string]interface{}{
  134. "sign": sign,
  135. "dat": dat,
  136. "personSealId": personSealId,
  137. })
  138. return
  139. }
  140. func (this *SignApiController) CreateUploadPact() {
  141. contractcode := this.GetString("contractcode")
  142. contractname := this.GetString("contractname")
  143. signcount, _ := this.GetInt64("signcount")
  144. docname := this.GetString("docname")
  145. contractbase := this.GetString("contractbase")
  146. creator := this.GetString("creator")
  147. enterpriseid := this.GetString("enterpriseid")
  148. signvalidays, _ := this.GetInt64("signvalidays")
  149. sysncurl := this.GetString("sysncurl")
  150. asyncurl := this.GetString("asyncurl")
  151. sign := service.CreateUploadPact(contractcode, contractname, signcount, docname, contractbase, creator, enterpriseid, signvalidays, sysncurl, asyncurl)
  152. this.ServeSuccessJSON(map[string]interface{}{
  153. "sign": sign,
  154. })
  155. return
  156. }
  157. // 添加企业成员
  158. func (this *SignApiController) CreateUserId() {
  159. userId := this.GetString("userId")
  160. displayName := this.GetString("displayName")
  161. sign := service.CreateUserId(userId, displayName)
  162. this.ServeSuccessJSON(map[string]interface{}{
  163. "sign": sign,
  164. })
  165. return
  166. }
  167. func (this *SignApiController) CreateEnterPriseRealName() {
  168. enterprisename := this.GetString("enterprisename")
  169. sign := service.CreateEnterPriseRealName(enterprisename)
  170. this.ServeSuccessJSON(map[string]interface{}{
  171. "sign": sign,
  172. })
  173. return
  174. }
  175. // 添加合同签署人
  176. func (this *SignApiController) AddContractSignatory() {
  177. contractId := this.GetString("contractId")
  178. signers := this.GetString("signers")
  179. var newContract models.NewContract
  180. newContract.ContractId = "156001444267295949"
  181. sign := service.AddContractSignatory(contractId, signers, newContract)
  182. this.ServeSuccessJSON(map[string]interface{}{
  183. "sign": sign,
  184. })
  185. return
  186. }
  187. type Struct2401 struct {
  188. someTimestampStyle []someTimestampStyle
  189. }
  190. type someTimestampStyle struct {
  191. ControlsKey string
  192. Pattern string
  193. Color string
  194. }
  195. func (this *SignApiController) CreateBackStageSign() {
  196. contractId := this.GetString("contractId")
  197. signers := this.GetString("signers")
  198. sign := service.CreateBackStageSign(contractId, signers)
  199. this.ServeSuccessJSON(map[string]interface{}{
  200. "sign": sign,
  201. })
  202. return
  203. }
  204. func (this *SignApiController) GetVerificationCode() {
  205. sign := service.GetVerificationCode()
  206. this.ServeSuccessJSON(map[string]interface{}{
  207. "sign": sign,
  208. })
  209. return
  210. }
  211. func (this *SignApiController) CreateEnterprise() {
  212. sign := service.CreateEnterprise()
  213. this.ServeSuccessJSON(map[string]interface{}{
  214. "sign": sign,
  215. })
  216. return
  217. }
  218. func (this *SignApiController) GetTestThrityMent() {
  219. pdf := gofpdf.New("P", "mm", "A4", "")
  220. pdf.AddPage()
  221. pdf.SetFont("Arial", "B", 16)
  222. pdf.Cell(40, 10, "Hello, World!")
  223. pdf.OutputFileAndClose("output.pdf")
  224. this.ServeSuccessJSON(map[string]interface{}{
  225. "sign": "msg",
  226. })
  227. return
  228. }
  229. func loremList() []string {
  230. return []string{
  231. "我爱你中国" +
  232. "tempor incididunt ut labore et dolore magna aliqua.",
  233. "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " +
  234. "aliquip ex ea commodo consequat.",
  235. "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum " +
  236. "dolore eu fugiat nulla pariatur.",
  237. "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui " +
  238. "officia deserunt mollit anim id est laborum.",
  239. }
  240. }
  241. func (this *SignApiController) SaveEnerprise() {
  242. orgId := this.GetAdminUserInfo().CurrentOrgId
  243. creater := this.GetAdminUserInfo().AdminUser.Id
  244. dataBody := make(map[string]interface{}, 0)
  245. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  246. fmt.Println("err", err)
  247. id := int64(dataBody["id"].(float64))
  248. org_type := int64(dataBody["org_type"].(float64))
  249. enterprise_name := dataBody["enterprise_name"].(string)
  250. code := dataBody["code"].(string)
  251. org_code := dataBody["org_code"].(string)
  252. legal_person_name := dataBody["legal_person_name"].(string)
  253. legal_id_card_num := dataBody["legal_id_card_num"].(string)
  254. legal_phone := dataBody["legal_phone"].(string)
  255. enterprise := models.XtDeviceEnterprise{
  256. ID: id,
  257. UserOrgId: orgId,
  258. OrgType: org_type,
  259. EnterpriseName: enterprise_name,
  260. Code: code,
  261. OrgCode: org_code,
  262. LegalPersonName: legal_person_name,
  263. LegalIdCardNum: legal_id_card_num,
  264. LegalPhone: legal_phone,
  265. Creater: creater,
  266. Ctime: time.Now().Unix(),
  267. Mtime: 0,
  268. Enterpriseid: "",
  269. Status: 1,
  270. }
  271. service.SaveEnerPrise(enterprise)
  272. //查找该机构有没有认证信息
  273. lastenterprise, _ := service.GetEnterPriseByUserOrgId(orgId)
  274. //调用企业认证接口
  275. if lastenterprise.ID > 0 {
  276. enterPrise, enterpriseid := service.CreateNewEnterPriseRealName(lastenterprise)
  277. fmt.Println("enterprise2ooo2oo2o2o2o", enterPrise)
  278. updateEnterprise := models.XtDeviceEnterprise{
  279. ID: enterprise.ID,
  280. UserOrgId: orgId,
  281. OrgType: org_type,
  282. EnterpriseName: enterprise_name,
  283. Code: code,
  284. OrgCode: org_code,
  285. LegalPersonName: legal_person_name,
  286. LegalIdCardNum: legal_id_card_num,
  287. LegalPhone: legal_phone,
  288. Creater: creater,
  289. Ctime: time.Now().Unix(),
  290. Mtime: 0,
  291. Enterpriseid: enterpriseid,
  292. Status: 1,
  293. }
  294. service.SaveEnerPrise(updateEnterprise)
  295. this.ServeSuccessJSON(map[string]interface{}{
  296. "enterPrise": enterPrise,
  297. })
  298. return
  299. }
  300. }
  301. func (this *SignApiController) GetEnerPriseById() {
  302. orgId := this.GetAdminUserInfo().CurrentOrgId
  303. enterPrise, _ := service.GetEnterPriseByUserOrgId(orgId)
  304. this.ServeSuccessJSON(map[string]interface{}{
  305. "enterPrise": enterPrise,
  306. })
  307. return
  308. }
  309. func (this *SignApiController) GetMobileCode() {
  310. phone := this.GetString("phone")
  311. sign, orderNumber := service.GetNewSignNameByPhone(phone)
  312. this.ServeSuccessJSON(map[string]interface{}{
  313. "sign": sign,
  314. "orderNumber": orderNumber,
  315. })
  316. return
  317. }
  318. func (this *SignApiController) GetPersionEnterPrise() {
  319. orgId := this.GetAdminUserInfo().CurrentOrgId
  320. creater := this.GetAdminUserInfo().AdminUser.Id
  321. dataBody := make(map[string]interface{}, 0)
  322. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  323. fmt.Println("err", err)
  324. id := int64(dataBody["id"].(float64))
  325. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  326. code := dataBody["code"].(string)
  327. display_name := dataBody["display_name"].(string)
  328. id_card_num := dataBody["id_card_num"].(string)
  329. phone := dataBody["phone"].(string)
  330. enterprise := models.XtDevicePersonEnterprise{
  331. ID: id,
  332. AdminUserId: admin_user_id,
  333. DisplayName: display_name,
  334. Phone: phone,
  335. IdCardNum: id_card_num,
  336. UserOrgId: orgId,
  337. Status: 1,
  338. Creater: creater,
  339. Ctime: time.Now().Unix(),
  340. Mtime: 0,
  341. UserId: "",
  342. }
  343. service.SavePersonEnterPrise(enterprise)
  344. lastEnterPrise, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  345. _, orderNumber := service.GetNewSignNameByPhone(phone)
  346. personEnterPrse, UserId := service.CreateNewUserName(lastEnterPrise.Phone, lastEnterPrise.DisplayName, code, orderNumber, lastEnterPrise.IdCardNum)
  347. firstenterprise := models.XtDevicePersonEnterprise{
  348. ID: id,
  349. AdminUserId: admin_user_id,
  350. DisplayName: display_name,
  351. Phone: phone,
  352. IdCardNum: id_card_num,
  353. UserOrgId: orgId,
  354. Status: 1,
  355. Creater: creater,
  356. Ctime: time.Now().Unix(),
  357. Mtime: 0,
  358. UserId: UserId,
  359. }
  360. service.SavePersonEnterPrise(firstenterprise)
  361. this.ServeSuccessJSON(map[string]interface{}{
  362. "personEnterPrse": personEnterPrse,
  363. })
  364. return
  365. }
  366. func (this *SignApiController) GetPerseEnterPriseById() {
  367. orgId := this.GetAdminUserInfo().CurrentOrgId
  368. admin_user_id, _ := this.GetInt64("admin_user_id")
  369. lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  370. this.ServeSuccessJSON(map[string]interface{}{
  371. "lastPerson": lastPerson,
  372. })
  373. return
  374. }
  375. func (this *SignApiController) CreateNewPersionSeal() {
  376. orgId := this.GetAdminUserInfo().CurrentOrgId
  377. admin_user_id, _ := this.GetInt64("admin_user_id")
  378. creater := this.GetAdminUserInfo().AdminUser.Id
  379. userName := service.GetLastAdminUserName(admin_user_id, orgId)
  380. //查询医护是否完成认证
  381. lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  382. if lastPerson.ID > 0 {
  383. this.ServeDynamicFailJsonSend("已完成认证,无需再次认证")
  384. return
  385. }
  386. if lastPerson.ID == 0 {
  387. //去认证
  388. personSeal, sealBase64 := service.CreateSKDPersionSeal(lastPerson.UserId, userName)
  389. fmt.Println("sealBase64", sealBase64)
  390. enterprise := models.XtDevicePersonEnterprise{
  391. AdminUserId: admin_user_id,
  392. DisplayName: "",
  393. Phone: "",
  394. IdCardNum: "",
  395. UserOrgId: orgId,
  396. Status: 1,
  397. Creater: creater,
  398. Ctime: time.Now().Unix(),
  399. Mtime: 0,
  400. UserId: "",
  401. Personsealid: "",
  402. Sealid: "",
  403. UserName: userName,
  404. Sealbase64: sealBase64,
  405. }
  406. service.CreateEnterpriseUserName(enterprise)
  407. this.ServeSuccessJSON(map[string]interface{}{
  408. "personSeal": personSeal,
  409. })
  410. return
  411. }
  412. }
  413. func (this *SignApiController) CreateNewEnterPrise() {
  414. //orgId := this.GetAdminUserInfo().CurrentOrgId
  415. //
  416. //admin_user_id, _ := this.GetInt64("admin_user_id")
  417. //
  418. //enterPrise, _ := service.GetEnterPriseByUserOrgId(orgId)
  419. //fmt.Println("地址日活", enterPrise.Enterpriseid)
  420. //lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  421. //
  422. //newEnterPrise, sealId := service.CreateNewEnterPrise(enterPrise.Enterpriseid, lastPerson.UserId)
  423. //
  424. //fmt.Println("newEnterPrise",newEnterPrise)
  425. //service.UpdatePersonEnterPrise(lastPerson.ID, sealId)
  426. newEnterPrise, _ := service.CreateSDKEnterPrise()
  427. //var url string
  428. //url = "http://localhost:8890/sdk/seal/createEnterpriseSeal"
  429. //appId := beego.AppConfig.String("sign_appid")
  430. //
  431. //serviceKye := beego.AppConfig.String("serviceKye")
  432. //
  433. //serviceCode := beego.AppConfig.String("serviceCode")
  434. //
  435. //maprequest := make(map[string]interface{})
  436. //
  437. //maprequest["sealType"] = 1
  438. //maprequest["enterpriseName"] = "深圳伊森时光科技有限公司"
  439. //maprequest["horizontalText"] = "财务专用章"
  440. //
  441. //byterequest, _ := json.Marshal(maprequest)
  442. //reader := bytes.NewReader(byterequest)
  443. //
  444. //signatureStr, _ := service.GenerateHMACSHA1SignatureTwo(maprequest, serviceKye, serviceCode)
  445. //fmt.Println("signatureStr", signatureStr)
  446. //request, err := http.NewRequest("POST", url, reader)
  447. //
  448. //fmt.Println("request23222222222222222", request)
  449. //if err != nil {
  450. // fmt.Println(err.Error())
  451. //}
  452. //
  453. //request.Header.Set("appId", appId)
  454. //request.Header.Set("serviceCode", serviceCode)
  455. //request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  456. //request.Header.Set("Content-Signature", signatureStr)
  457. //client := http.Client{}
  458. //
  459. //resp, err := client.Do(request)
  460. //if err != nil {
  461. // fmt.Println(err.Error())
  462. //
  463. //}
  464. //respBytes, err := ioutil.ReadAll(resp.Body)
  465. //if err != nil {
  466. // fmt.Println(err.Error())
  467. //
  468. //}
  469. //str := string(respBytes)
  470. //fmt.Println("strwowowowowo", str)
  471. //
  472. //var respJSON map[string]interface{}
  473. //if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  474. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  475. //}
  476. this.ServeSuccessJSON(map[string]interface{}{
  477. "newEnterPrise": newEnterPrise,
  478. })
  479. return
  480. }
  481. func (this *SignApiController) GetContractId() {
  482. sign := service.GetContractId()
  483. this.ServeSuccessJSON(map[string]interface{}{
  484. "sign": sign,
  485. })
  486. return
  487. }
  488. func (this *SignApiController) EndEnterPrise() {
  489. sign := service.EndEnterPrise()
  490. this.ServeSuccessJSON(map[string]interface{}{
  491. "sign": sign,
  492. })
  493. return
  494. }
  495. func (this *SignApiController) GetEnterPriseDetail() {
  496. sign, url := service.GetEnterPriseDetail()
  497. this.ServeSuccessJSON(map[string]interface{}{
  498. "sign": sign,
  499. "url": url,
  500. })
  501. return
  502. }
  503. func (this *SignApiController) UploadPrintOrder() {
  504. //pdfg, _ := wkhtml.NewPDFGenerator()
  505. //
  506. //htmlStr := `<html><body><h1 style="color:red;">This is an html
  507. // from pdf to test color<h1><img src="http://api.qrserver.com/v1/create-qr-
  508. //code/?data=HelloWorld" ></img></body></html>`
  509. //
  510. //pdfg.AddPage(wkhtml.NewPageReader(strings.NewReader(htmlStr)))
  511. //
  512. //// Create PDF document in internal buffer
  513. //err = pdfg.Create()
  514. //
  515. ////Your Pdf Name
  516. //err = pdfg.WriteFile("./Your_pdfname.pdf")
  517. //dataBody := make(map[string]interface{}, 0)
  518. //err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  519. //fmt.Println(err)
  520. //name := dataBody["name"].(string)
  521. //fmt.Println(name)
  522. //sign := service.CreateNewUploadPact(name)
  523. //fmt.Println("sign")
  524. //information, pdfBase64 := service.SavePdfInformation(name)
  525. pdf := gofpdf.New("P", "mm", "A4", "")
  526. pdf.AddPage()
  527. pdf.Text(5, 10, "血液净化治疗记录单")
  528. //wd := pdf.GetStringWidth(titleStr) + 6
  529. //fmt.Println("wd", wd)
  530. //pdf.SetY(0.6) //先要设置 Y,然后再设置 X。否则,会导致 X 失效
  531. //pdf.SetX((210 - wd) / 2) //水平居中的算法
  532. //pdf.AddUTF8Font("simkai", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
  533. //pdf.SetFont("simkai", "", 20)
  534. //将字体加载进来
  535. //AddUTF8Font("给字体起个别名", "", "fontPath")
  536. pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
  537. pdf.SetFont("simfang", "", 20)
  538. var title = "血液透析(滤过)记录表单"
  539. //表格居中显示
  540. pdf.Text(70, 10, title)
  541. wd := pdf.GetStringWidth(title) + 100
  542. fmt.Println("wd", wd)
  543. pdf.SetY(100) //先要设置 Y,然后再设置 X。否则,会导致 X 失效
  544. pdf.SetX((210 - wd) / 2) //水平居中的算法
  545. //pdf.SetLineWidth(0)
  546. //pdf.Line(10, 30, 585, 30)
  547. //pdf.Ln(1)
  548. //pdf.Write(10, "\n")
  549. var numuber = "100000"
  550. //表格居中显示
  551. pdf.SetFont("", "", 14) // 设置加粗字体和字号
  552. pdf.Text(10, 20, "病历号:"+numuber)
  553. pdf.SetFont("", "", 14) // 设置加粗字体和字号
  554. pdf.Text(60, 20, "姓名:")
  555. pdf.SetFont("", "", 14) // 设置正常字体和字号
  556. pdf.Text(90, 20, "性别:")
  557. pdf.SetFont("", "", 14) // 设置正常字体和字号
  558. pdf.Text(120, 20, "年龄:")
  559. pdf.SetFont("", "", 14) // 设置正常字体和字号
  560. pdf.Text(150, 20, "透析次数:")
  561. pdf.SetFont("", "", 14) // 设置正常字体和字号
  562. //表格居中显示
  563. pdf.SetFont("", "", 14) // 设置加粗字体和字号
  564. pdf.Text(10, 30, "入科方式:"+numuber)
  565. pdf.SetFont("", "", 14) // 设置加粗字体和字号
  566. pdf.Text(60, 30, "诊断:")
  567. //param1: 单元格的宽,为0时表示一行,单位根据new()里面设置的来
  568. //param2: 单元格的高,不能为0,单位根据new()里面设置的来
  569. //param3: 单元格内容
  570. //param4: 边框样式,一个空字符串表示无边框,“1”表示全边框,一个或多个“L”,“T”,“R”和“B”分别表示边界左,上,右,下
  571. //param5: 表示调用后当前位置的位置。可能的值为0,接着当前行继续,1换行,2目前没有试过
  572. //param6: 字体的位置,水平对齐包括"L", “C"或"R”(左,中,右)。垂直对齐由包含控制"T", “M”, “B"或"A”(上,中,下,基线),可以组合,比如说LT,CM等等
  573. //param7: 是否填充单元格,需要调用SetFillColor()方法.默认false
  574. //param8: 内部超链接,没用过
  575. //param9: 超链接,没用过
  576. pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
  577. pdf.SetFont("simfang", "", 14) // 设置字体、字号
  578. pdf.SetFillColor(200, 200, 200) // 设置填充颜色
  579. // 设置起始位置
  580. var x = 10.0
  581. var y = 40.0
  582. // 创建8行2列的表格
  583. for j := 0; j < 1; j++ {
  584. //cellText := fmt.Sprintf("行%d列%d", i+1, j+1) // 填充每个单元格的内容
  585. pdf.SetXY(x, y) // 设置当前位置
  586. pdf.CellFormat(15, 15, "时间", "1", 0, "C", false, 0, "") // 使用CellFormat()方法创建表格单元格
  587. pdf.CellFormat(20, 15, "血压(mmHg)", "1", 0, "CM", false, 0, "")
  588. pdf.CellFormat(20, 15, "脉搏(次/分)", "1", 0, "CM", false, 0, "")
  589. pdf.CellFormat(20, 15, "呼吸(次/分)", "1", 0, "CM", false, 0, "")
  590. pdf.CellFormat(20, 15, "血流量(ml/min)", "1", 0, "CM", false, 0, "")
  591. pdf.CellFormat(20, 15, "静脉压(mmHg)", "1", 0, "CM", false, 0, "")
  592. pdf.CellFormat(20, 15, "跨膜压(mmHg)", "1", 0, "CM", false, 0, "")
  593. pdf.CellFormat(20, 15, "透析液温(℃)", "1", 0, "CM", false, 0, "")
  594. pdf.CellFormat(20, 15, "钠浓度(mmol/L)", "1", 0, "CM", false, 0, "")
  595. pdf.CellFormat(20, 15, "超滤量(ml) ", "1", 0, "CM", false, 0, "")
  596. pdf.CellFormat(35, 15, "病情变化及处理", "1", 0, "CM", false, 0, "")
  597. y += 15 // 下一行起始位置的y坐标增加60(单元格高度)
  598. }
  599. x += 200.0 // 下一列起始位置的x坐标增加190(单元格宽度)
  600. y = 10.0 // 行起始位置的y坐标重置为10
  601. //设置表格单元格大小,
  602. //pdf.CellFormat(180, 15, "李王", "1", 0, "LM", false, 0, "")
  603. pdf.Ln(2)
  604. //pdf.Ln(2) 行距2mm
  605. if err := pdf.OutputFileAndClose("6.pdf"); err != nil {
  606. panic(err.Error())
  607. }
  608. this.ServeSuccessJSON(map[string]interface{}{
  609. //"sign": information,
  610. //"pdfBase64": pdfBase64,
  611. //"name": name,
  612. })
  613. }
  614. func (this *SignApiController) CreateQianshuUserName() {
  615. admin_user_id, _ := this.GetInt64("admin_user_id")
  616. orgId := this.GetAdminUserInfo().CurrentOrgId
  617. userName := service.GetLastAdminUserName(admin_user_id, orgId)
  618. idCardNumber := service.GetLastAdminUserIdCardNumber(admin_user_id, orgId)
  619. adminRole, _ := service.GetMobile(admin_user_id)
  620. //查询该医护人员是否已经签署了
  621. lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  622. if len(lastPerson.UserId) > 0 {
  623. this.ServeDynamicFailJsonSend("已完成签署,无需再次签署")
  624. return
  625. }
  626. if len(lastPerson.UserId) == 0 {
  627. //去签署
  628. sign, userId := service.CreateQianshuUserName(userName, adminRole.Mobile, idCardNumber)
  629. err := service.UpdatePersionEnterPrise(lastPerson.ID, userId)
  630. fmt.Println(err)
  631. this.ServeSuccessJSON(map[string]interface{}{
  632. "sign": sign,
  633. "userId": userId,
  634. })
  635. }
  636. }
  637. func (this *SignApiController) CreateSdkSendInformation() {
  638. information, orderId := service.CreateSdkSendInformation()
  639. this.ServeSuccessJSON(map[string]interface{}{
  640. "information": information,
  641. "orderId": orderId,
  642. })
  643. }
  644. func (this *SignApiController) SavePdfInformation() {
  645. var name string
  646. information, pdfBase64 := service.SavePdfInformation(name)
  647. informationOne := service.ToCheckInformation(pdfBase64)
  648. maprequest := make(map[string]interface{})
  649. Receiver := make(map[string]interface{})
  650. //业务单号
  651. maprequest["orderId"] = "13318464642"
  652. maprequest["signTitle"] = "举报合同"
  653. //file := "C:/Users/28169/Desktop/2.pdf"
  654. file := "/swspan/gopath/src/XT_New/static/6.pdf"
  655. fileBytes, _ := ioutil.ReadFile(file) // 读取file
  656. contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串
  657. //文件获取方式
  658. maprequest["fileType"] = 1
  659. maprequest["pdfBase64"] = contractBase64
  660. //合同内容
  661. maprequest["fileContent"] = contractBase64
  662. //签署用户人ID
  663. maprequest["userId"] = "JMO9U8JH4TN8E3QOI0GUVUF2"
  664. //业务单号
  665. maprequest["receiver"] = Receiver
  666. //签署人账号
  667. Receiver["account"] = "13318464642"
  668. //签署个人类型 1.个人 2.企业
  669. Receiver["signerType"] = 1
  670. //签署人姓名
  671. Receiver["realName "] = "马文强"
  672. // 证件类型
  673. Receiver["cardType"] = 0
  674. //证件编码
  675. Receiver["cardNumber"] = "430526199408156511"
  676. stepStamper := make(map[string]interface{})
  677. keywordSignControls := make([]map[string]interface{}, 0)
  678. //预冲者样式
  679. inputArrOne := make(map[string]interface{})
  680. inputArrOne["sealName"] = "1"
  681. inputArrOne["keyword"] = "医生签名"
  682. inputArrOne["pages"] = "0"
  683. inputArrOne["offsetX"] = "100"
  684. inputArrOne["offsetY"] = "100"
  685. keywordSignControls = append(keywordSignControls, inputArrOne)
  686. //穿刺者样式
  687. //inputArr := make(map[string]interface{})
  688. //inputArr["sealName"] = "2"
  689. //inputArr["keyword"] = "治疗护士"
  690. //inputArr["pages"] = "1"
  691. //inputArr["offsetX"] = "100"
  692. //inputArr["offsetY"] = "0"
  693. //
  694. //keywordSignControls = append(keywordSignControls, inputArr)
  695. //
  696. ////上机者
  697. //inputArrSix := make(map[string]interface{})
  698. //inputArrSix["sealName"] = "3"
  699. //inputArrSix["keyword"] = "核对护士"
  700. //inputArrSix["pages"] = "1"
  701. //inputArrSix["offsetX"] = "100"
  702. //inputArrSix["offsetY"] = "0"
  703. //
  704. //keywordSignControls = append(keywordSignControls, inputArrSix)
  705. //
  706. //stepStamper["keywordSignControls"] = keywordSignControls
  707. //
  708. ////医生签名
  709. //inputArrSeven := make(map[string]interface{})
  710. //inputArrSeven["sealName"] = "4"
  711. //inputArrSeven["keyword"] = "医生签名"
  712. //inputArrSeven["pages"] = "1"
  713. //inputArrSeven["offsetX"] = "100"
  714. //inputArrSeven["offsetY"] = "0"
  715. //
  716. //keywordSignControls = append(keywordSignControls, inputArrSeven)
  717. //
  718. //stepStamper["keywordSignControls"] = keywordSignControls
  719. //crossSignControls := make([]map[string]interface{}, 0)
  720. //
  721. //inputArrTwo := make(map[string]interface{})
  722. //inputArrTwo["sealName"] = "1"
  723. //inputArrTwo["positionX"] = "0"
  724. //inputArrTwo["positionY"] = "0"
  725. //inputArrTwo["pages"] = "0"
  726. //crossSignControls = append(crossSignControls, inputArrTwo)
  727. //
  728. //stepStamper["crossSignControls"] = crossSignControls
  729. //
  730. xySignControls := make([]map[string]interface{}, 0)
  731. inputArrThree := make(map[string]interface{})
  732. inputArrThree["sealName"] = "1"
  733. inputArrThree["positionX"] = "100"
  734. inputArrThree["positionY"] = "0"
  735. inputArrThree["pages"] = "0"
  736. xySignControls = append(xySignControls, inputArrThree)
  737. stepStamper["xySignControls"] = xySignControls
  738. maprequest["stepStamper"] = stepStamper
  739. seals := make([]map[string]interface{}, 0)
  740. //预冲者
  741. sealImagesList := make(map[string]interface{})
  742. fileOne := "/swspan/gopath/src/XT_New/static/huangzihui.jpg"
  743. fileBytesOne, _ := ioutil.ReadFile(fileOne) // 读取file
  744. contractBase64One := base64.StdEncoding.EncodeToString(fileBytesOne) // 加密成base64字符串
  745. sealImagesList["sealBase64"] = contractBase64One
  746. //控制签名的大小
  747. sealImagesList["width"] = "50"
  748. sealImagesList["height"] = "50"
  749. sealImagesList["verticalAlign"] = "middle"
  750. sealTextsList := make(map[string]interface{})
  751. sealTextsList["text"] = "2023年8月8日"
  752. sealTextsList["fontSize"] = "100"
  753. sealTextsList["fontColor"] = "#333333"
  754. sealTextsList["isTextArea"] = true
  755. sealTextsList["textAlign"] = 0
  756. sealTextsList["width"] = 150
  757. sealTextsList["height"] = 20
  758. sealsObj := make(map[string]interface{})
  759. sealsObj["sealWidth"] = "150"
  760. sealsObj["sealHeight"] = "150"
  761. sealsObj["sealName"] = "1"
  762. sealsObj["sealImage"] = sealImagesList
  763. sealsObj["sealText"] = sealTextsList
  764. seals = append(seals, sealsObj)
  765. //穿刺者
  766. //sealImagesListOne := make(map[string]interface{})
  767. //
  768. //fileTwo := "/swspan/gopath/src/XT_New/static/huangjunji.jpg"
  769. //
  770. //fileBytesTwo, _ := ioutil.ReadFile(fileTwo) // 读取file
  771. //
  772. //contractBase64Two := base64.StdEncoding.EncodeToString(fileBytesTwo) // 加密成base64字符串
  773. //sealImagesListOne["sealBase64"] = contractBase64Two
  774. ////控制签名的大小
  775. //sealImagesListOne["width"] = "50"
  776. //sealImagesListOne["height"] = "50"
  777. //sealImagesListOne["verticalAlign"] = "middle"
  778. //
  779. //sealTextsListOne := make(map[string]interface{})
  780. //sealTextsListOne["text"] = "2023年8月8日"
  781. //sealTextsListOne["fontSize"] = "100"
  782. //sealTextsListOne["fontColor"] = "100"
  783. //sealTextsListOne["isTextArea"] = true
  784. //sealTextsListOne["textAlign"] = 0
  785. //sealTextsListOne["width"] = 150
  786. //sealTextsListOne["height"] = 20
  787. //
  788. //sealsObjOne := make(map[string]interface{})
  789. //
  790. //sealsObjOne["sealWidth"] = "150"
  791. //sealsObjOne["sealHeight"] = "150"
  792. //sealsObjOne["sealName"] = "2"
  793. //sealsObjOne["sealImage"] = sealImagesListOne
  794. //sealsObjOne["sealText"] = sealTextsListOne
  795. //seals = append(seals, sealsObjOne)
  796. //间隔签名
  797. //上机者
  798. //sealImagesListTwo := make(map[string]interface{})
  799. //fileThree := "/swspan/gopath/src/XT_New/static/jianfeixia.jpg"
  800. //fileBytesThree, _ := ioutil.ReadFile(fileThree) // 读取file
  801. //contractBase64Three := base64.StdEncoding.EncodeToString(fileBytesThree) // 加密成base64字符串
  802. //sealImagesListTwo["sealBase64"] = contractBase64Three
  803. ////控制签名的大小
  804. //sealImagesListTwo["width"] = "50"
  805. //sealImagesListTwo["height"] = "50"
  806. //sealImagesListTwo["verticalAlign"] = "middle"
  807. //
  808. //sealTextsListTwo := make(map[string]interface{})
  809. //sealTextsListTwo["text"] = "2023年8月8日"
  810. //sealTextsListTwo["fontSize"] = "100"
  811. //sealTextsListTwo["fontColor"] = "100"
  812. //sealTextsListTwo["isTextArea"] = true
  813. //sealTextsListTwo["textAlign"] = 0
  814. //sealTextsListTwo["width"] = 150
  815. //sealTextsListTwo["height"] = 20
  816. //
  817. //sealsObjTwo := make(map[string]interface{})
  818. //
  819. //sealsObjTwo["sealWidth"] = "150"
  820. //sealsObjTwo["sealHeight"] = "150"
  821. //sealsObjTwo["sealName"] = "3"
  822. //sealsObjTwo["sealImage"] = sealImagesListTwo
  823. //sealsObjTwo["sealText"] = sealTextsListTwo
  824. //seals = append(seals, sealsObjTwo)
  825. //医生签名
  826. //sealImagesListThree := make(map[string]interface{})
  827. //fileFour := "/swspan/gopath/src/XT_New/static/jianfeixia.jpg"
  828. //fileBytesFour, _ := ioutil.ReadFile(fileFour) // 读取file
  829. //contractBase64Tour := base64.StdEncoding.EncodeToString(fileBytesFour) // 加密成base64字符串
  830. //sealImagesListThree["sealBase64"] = contractBase64Tour
  831. ////控制签名的大小
  832. //sealImagesListThree["width"] = "50"
  833. //sealImagesListThree["height"] = "50"
  834. //sealImagesListThree["verticalAlign"] = "middle"
  835. //
  836. //sealTextsListThree := make(map[string]interface{})
  837. //sealTextsListThree["text"] = "2023年8月8日"
  838. //sealTextsListThree["fontSize"] = "100"
  839. //sealTextsListThree["fontColor"] = "100"
  840. //sealTextsListThree["isTextArea"] = true
  841. //sealTextsListThree["textAlign"] = 0
  842. //sealTextsListThree["width"] = 150
  843. //sealTextsListThree["height"] = 20
  844. //
  845. //sealsObjThree := make(map[string]interface{})
  846. //
  847. //sealsObjThree["sealWidth"] = "150"
  848. //sealsObjThree["sealHeight"] = "150"
  849. //sealsObjThree["sealName"] = "4"
  850. //sealsObjThree["sealImage"] = sealImagesListThree
  851. //sealsObjThree["sealText"] = sealTextsListThree
  852. //seals = append(seals, sealsObjThree)
  853. maprequest["seals"] = seals
  854. maprequest["isUserWishes"] = true
  855. maprequest["phone"] = "13318464642"
  856. maprequest["verificationCode"] = "18888888888"
  857. this.ServeSuccessJSON(map[string]interface{}{
  858. "information": information,
  859. "orderId": pdfBase64,
  860. "informationOne": informationOne,
  861. "maprequest": maprequest,
  862. })
  863. }
  864. func (this *SignApiController) ToCheckInformation() {
  865. var name string
  866. information, pdfBase64 := service.SavePdfInformation(name)
  867. informationOne := service.ToCheckInformation(pdfBase64)
  868. this.ServeSuccessJSON(map[string]interface{}{
  869. "information": information,
  870. "informationOne": informationOne,
  871. })
  872. }