diff --git a/src/main/java/com/emr/controller/FontShowRecordController.java b/src/main/java/com/emr/controller/FontShowRecordController.java index 73d74cd..b32a28f 100644 --- a/src/main/java/com/emr/controller/FontShowRecordController.java +++ b/src/main/java/com/emr/controller/FontShowRecordController.java @@ -1,6 +1,7 @@ package com.emr.controller; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.emr.annotation.OptionalLog; import com.emr.dao.CommomMapper; import com.emr.dao.Emr_DictionaryMapper; @@ -16,12 +17,15 @@ import com.emr.service.emrLog.LogService; import com.emr.service.emrPrintOrDownLoadInfo.PrintOrDownLoadInfoService; import com.emr.util.DateUtils; import com.emr.util.ExceptionPrintUtil; +import com.emr.util.HttpClientUtils; import com.emr.vo.EmrPrintOrDownLoadInfo.EmrPrintOrDownLoadInfoVo; +import com.emr.vo.User; import com.emr.vo.commomSearch.CommomTree; import com.emr.vo.commomSearch.CommomVo; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; +import org.apache.cxf.endpoint.Client; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.subject.Subject; @@ -32,6 +36,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; @@ -46,6 +51,8 @@ public class FontShowRecordController { private String WATERPICPATH; @Value("${EMR_RECORD_JSP}") private String EMRRECORDJSP; + @Value("${POWER_URLHEAD}") + private String POWER_URLHEAD; @Autowired private CommomMapper commomMapper; @Autowired @@ -556,4 +563,159 @@ public class FontShowRecordController { model.addAttribute("httpFilePath",httpFilePath); return "font/showPdfFrameFont"; } + + /** + * 祈福 + * + * @MethodName: + * @Description: 登录权限系统 + * @Param String patientId:patientId + * @Return + * @Author: 曾文和 + * @CreateDate: 2019-05-29 + * @UpdateUser: 曾文和 + * @UpdateDate: 2019-05-29 + * @UpdateRemark: 更新说明 + * @Version: 1.0 + */ + @RequestMapping(value="emrReordLoginByToken",method = RequestMethod.POST) + @ResponseBody + public ResultUtil emrReordLoginByToken(String token,String userName, HttpServletRequest request) throws Exception{ + if (StringUtils.isNoneBlank(token)) { + //创建连接工厂 + JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance(); + //创建客户端 + Object[] objects = new Object[0]; + Client client = null; + try { + client = dcf.createClient(POWER_URLHEAD + "/WebService/PowerWebService?wsdl"); + //动态调用getInfosByUserId方法 + objects = client.invoke("getInfosByUserId", token, "emr_record"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (null != client) { + client.destroy(); + } + } + Power_User powerUser = JSON.parseObject(objects[0].toString(), Power_User.class); + //返回用户为空跳转到登录权限系统界面 + //设置进session + powerUser.setUserName(userName); + request.getSession().setAttribute("CURRENT_USER", powerUser); + request.getSession().setAttribute("power_menus", powerUser.getMenus()); + request.getSession().setAttribute("token", token); + //验证shiro(有shiro才此操作) + UsernamePasswordToken userToken = new UsernamePasswordToken(userName, "123456"); + Subject subject = SecurityUtils.getSubject(); + subject.login(userToken); + //获取用户列表 + // 获得Http客户端 + if (StringUtils.isNotBlank(userName) && powerUser.getRoleId() == -100) { + try { + commomService.getUserList(userName, request); + } catch (Exception e) { + e.printStackTrace(); + } + } + return ResultUtil.ok(powerUser); + } + return ResultUtil.ok(); + } + + /** + * 祈福 + * + * @MethodName: + * @Description: 登录权限系统 + * @Param String patientId:patientId + * @Return + * @Author: 曾文和 + * @CreateDate: 2019-05-29 + * @UpdateUser: 曾文和 + * @UpdateDate: 2019-05-29 + * @UpdateRemark: 更新说明 + * @Version: 1.0 + */ + @RequestMapping(value="emrReordLogin") + @ResponseBody + public ResultUtil emrReordLogin(String userName, HttpServletRequest request) throws Exception{ + ResultUtil resultUtil = powerLogin(userName); + String token = resultUtil.getMsg(); + return emrReordLoginByToken(token, userName, request); + } + + /** + * 祈福 + * + * @MethodName: + * @Description: 跳转到档案预览 + * @Param String patientId:patientId + * @Return + * @Author: 曾文和 + * @CreateDate: 2019-05-29 + * @UpdateUser: 曾文和 + * @UpdateDate: 2019-05-29 + * @UpdateRemark: 更新说明 + * @Version: 1.0 + */ + @RequestMapping(value="powerLogin",method = RequestMethod.POST) + @ResponseBody + public ResultUtil powerLogin(String userName) throws Exception{ + if(StringUtils.isBlank(userName)){ + return ResultUtil.error("用户名不能为空"); + } + //请求权限系统登录 + Map map = new HashMap<>(); + String url = POWER_URLHEAD + "/font/getToken1"; + map.put("userName",userName); + String resultString = HttpClientUtils.doPost(url, map); + // 判断返回状态是否为200 + if(StringUtils.isNoneBlank(resultString)) { + JSONObject jsonObject = JSON.parseObject(resultString); + String extend = jsonObject.getString("extend"); + JSONObject extendObject = JSONObject.parseObject(extend); + String token = extendObject.getString("token"); + return ResultUtil.ok(token); + } + return null; + } + + /** + * 174医院、祈福 + * + * @MethodName: showRecord174 + * @Description: 跳转到档案预览 + * @Param String patientId:patientId + * @Return + * @Author: 曾文和 + * @CreateDate: 2019-05-29 + * @UpdateUser: 曾文和 + * @UpdateDate: 2019-05-29 + * @UpdateRemark: 更新说明 + * @Version: 1.0 + */ + @RequestMapping("showRecord") + public String showRecord174(String patientId,String userName, Model model, HttpServletRequest request) throws Exception{ + model.addAttribute("patientId", patientId); + //加载登陆者 + Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER"); + if (null == user) { + ResultUtil resultUtil = emrReordLogin(userName,request); + user = (Power_User)resultUtil.getData(); + } + model.addAttribute("user", user); + model.addAttribute("roleId", user.getRoleId()); + List printCount = null; + try { + printCount = printOrDownLoadInfoService.getPrintCount(patientId); + } catch (Exception e) { + ExceptionPrintUtil.printException(e); + e.printStackTrace(); + } + if (null != printCount && !printCount.isEmpty()) { + model.addAttribute("printCount", 1); + } + return "recordManage/commomSearch/showRecord174"; + } }