ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/HNGatherPatArchiveController.java
@@ -48,9 +48,39 @@ @PostMapping("/hnDataGather") @ApiOperation("河南数据采集") public AjaxResult hnDataGather(@RequestBody HnDataGatherVO hnDataGatherVO) { log.info("开始按天同步用户数据,时间范围: {} 到 {}", hnDataGatherVO.getStartOutHospTime(), hnDataGatherVO.getEndOutHospTime()); log.info("开始按天同步用户数据,时间范围: {} 到 {}", hnDataGatherVO.getStartTime(), hnDataGatherVO.getEndTime()); Boolean aBoolean = ihnGatherPatArchiveService.hnDataGather(hnDataGatherVO); return AjaxResult.success(aBoolean); } /** * 查询疾病列表数据采集 */ @PostMapping("/selectIcd10List") @ApiOperation("查询疾病列表数据采集") public AjaxResult selectIcd10List(@RequestBody Icd10 icd10) { Integer integer = ihnGatherPatArchiveService.selectIcd10List(icd10); return AjaxResult.success(integer); } /** * 用户信息集合信息数据采集 */ @PostMapping("/selectUserList") @ApiOperation("用户信息集合信息数据采集") public AjaxResult selectUserList(@RequestBody SysUser sysUser) { Integer integer = ihnGatherPatArchiveService.selectUserList(sysUser); return AjaxResult.success(integer); } /** * 部门信息集合信息数据采集 */ @PostMapping("/selectDeptList") @ApiOperation("部门信息集合信息数据采集") public AjaxResult selectDeptList(@RequestBody SysDept sysDept) { Integer integer = ihnGatherPatArchiveService.selectDeptList(sysDept); return AjaxResult.success(integer); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/sso/SSOController.java
@@ -3,7 +3,9 @@ import com.alibaba.fastjson.JSON; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.HttpUtil; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.http.HttpUtils; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.service.ISysUserService; import com.smartor.domain.SSOTokenResponse; @@ -25,6 +27,8 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; /** * SSO单点登录控制器 @@ -91,99 +95,44 @@ * 访问路径:http://域名:8095/sso/login */ @GetMapping("") public void ssoLogin(HttpServletResponse response, HttpServletRequest request) throws IOException { public void ssoLogin() { log.info("收到SSO登录请求,开始重定向到授权服务器"); // 获取客户端IP String clientIp = getClientIp(request); boolean isInternal = isInternalNetwork(clientIp); // 构建授权URL String authUrl = buildAuthorizationUrl(isInternal); log.info("重定向到授权URL: {}", authUrl); response.sendRedirect(authUrl); } /** * SSO回调处理 */ @GetMapping("/callback") public void ssoCallback(@RequestParam(required = false) String code, @RequestParam(required = false) String state, @RequestParam(required = false) String error, HttpServletResponse response, HttpServletRequest request) throws IOException { log.info("收到SSO回调,code: {}, state: {}, error: {}", code, state, error); if (error != null) { log.error("SSO授权失败: {}", error); try { response.sendRedirect("/login?sso_error=" + URLEncoder.encode(error, "UTF-8")); } catch (Exception e) { log.error("重定向失败", e); response.sendRedirect("/login?sso_error=unknown_error"); } return; } if (code == null || !this.state.equals(state)) { log.error("SSO回调参数错误,code: {}, state: {}", code, state); response.sendRedirect("/login?sso_error=invalid_callback"); return; } // Authorize鉴权接口 String param = "client_id=" + clientId + "&redirect_uri=" + internalRedirectUri + "&response_type=code" + "&state=" + state + "&scope=" + scope; log.info("【Authorize鉴权接口】入参为:{}", param); String s = HttpUtils.sendGet(internalAuthorizeUrl, param); Map<String, String> result = getResult(s); String code = result.get("code"); try { // 获取客户端IP String clientIp = getClientIp(request); boolean isInternal = isInternalNetwork(clientIp); SSOTokenResponse accessToken = getAccessToken(code, true); SSOUserInfo userInfo = getUserInfo(accessToken.getAccess_token(), true); // 1. 用code换取access_token SSOTokenResponse tokenResponse = getAccessToken(code, isInternal); log.info("获取到access_token: {}", tokenResponse.getAccess_token()); createLocalSession(userInfo); // 2. 用access_token获取用户信息 SSOUserInfo userInfo = getUserInfo(tokenResponse.getAccess_token(), isInternal); log.info("获取到用户信息: {}", userInfo); // 3. 根据用户信息创建本地会话 String token = createLocalSession(userInfo); // 4. 重定向到前端首页,携带token String frontendUrl = "/#/index?token=" + token; response.sendRedirect(frontendUrl); } catch (RuntimeException e) { log.error("SSO业务处理失败: {}", e.getMessage(), e); try { response.sendRedirect("/login?sso_error=" + URLEncoder.encode(e.getMessage(), "UTF-8")); } catch (Exception ex) { log.error("重定向失败", ex); response.sendRedirect("/login?sso_error=system_error"); } } catch (Exception e) { log.error("SSO登录处理失败", e); response.sendRedirect("/login?sso_error=login_failed"); e.printStackTrace(); } } /** * 构建授权URL */ private String buildAuthorizationUrl(boolean isInternal) { try { String redirectUri = getRedirectUri(isInternal); return getAuthorizeUrl(isInternal) + "?" + "client_id=" + clientId + "&redirect_uri=" + URLEncoder.encode(redirectUri, "UTF-8") + "&response_type=code" + "&state=" + state + "&scope=" + URLEncoder.encode(scope, "UTF-8"); } catch (Exception e) { log.error("构建授权URL失败", e); throw new RuntimeException("构建授权URL失败", e); private Map<String, String> getResult(String param) { Map<String, String> paramMap = new HashMap<>(); if (param == null || !param.contains("?")) { return paramMap; } String query = param.substring(param.indexOf('?') + 1); String[] pairs = query.split("&"); for (String pair : pairs) { String[] kv = pair.split("=", 2); String key = kv[0]; String value = kv.length > 1 ? kv[1] : ""; paramMap.put(key, value); } return paramMap; } /** @@ -202,8 +151,7 @@ HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(params, headers); ResponseEntity<String> response = restTemplate.exchange( getTokenUrl(isInternal), HttpMethod.POST, request, String.class); ResponseEntity<String> response = restTemplate.exchange(getTokenUrl(isInternal), HttpMethod.POST, request, String.class); log.info("Token响应: {}", response.getBody()); @@ -229,8 +177,7 @@ HttpEntity<String> entity = new HttpEntity<>(headers); ResponseEntity<String> response = restTemplate.exchange( getUserinfoUrl(isInternal), HttpMethod.GET, entity, String.class); ResponseEntity<String> response = restTemplate.exchange(getUserinfoUrl(isInternal), HttpMethod.GET, entity, String.class); log.info("用户信息响应: {}", response.getBody()); @@ -262,7 +209,9 @@ LoginUser loginUser = new LoginUser(localUser.getUserId(), localUser.getDeptId(), localUser, null); // 生成token return tokenService.createToken(loginUser); String token = tokenService.createToken(loginUser); log.info("生成的token为:{}", token); return token; } /** ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java
@@ -3,9 +3,7 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; import com.ruoyi.quartz.service.ICollectHISMapperService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -23,7 +21,7 @@ /** * 调度日志操作处理 * * * @author ruoyi */ @RestController @@ -58,7 +56,7 @@ ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class); util.exportExcel(response, list, "调度日志"); } /** * 根据调度编号获取详细信息 */ smartor/src/main/java/com/smartor/domain/HnDataGatherVO.java
@@ -26,7 +26,7 @@ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = " ", width = 30, dateFormat = "yyyy-MM-dd") @ApiModelProperty(value = "开始出院日期") private Date startOutHospTime; private Date startTime; /** * 结束出院日期 @@ -34,7 +34,10 @@ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = " ", width = 30, dateFormat = "yyyy-MM-dd") @ApiModelProperty(value = "结束出院日期") private Date endOutHospTime; private Date endTime; } smartor/src/main/java/com/smartor/domain/SvyLibTemplateScriptVO.java
@@ -122,7 +122,7 @@ * 是否隐藏 */ @Excel(name = " 是否隐藏 ") @ApiModelProperty("是否隐藏") @ApiModelProperty("是否隐藏:0否(默认) 1是") private Long ishide; /** smartor/src/main/java/com/smartor/service/impl/HNGatherPatArchiveServiceImpl.java
@@ -104,7 +104,27 @@ patArchiveMapper.insertPatArchiveSingle(patArchives.get(0)); pm.setPatid(patArchives.get(0).getId()); } patMedInhospMapper.insertPatMedInhosp(pm); if (!Objects.isNull(patMedInhosp.getStartInHospTime()) && !Objects.isNull(patMedInhosp.getEndInHospTime())) { //入院 pm.setInhospstate("0"); pm.setCreateTime(new Date()); patMedInhospMapper.insertPatMedInhosp(pm); } else if (!Objects.isNull(patMedInhosp.getStartOutHospTime()) && !Objects.isNull(patMedInhosp.getEndOutHospTime())) { //出院 pm.setInhospstate("1"); pm.setUpdateTime(new Date()); PatMedInhosp pmi = new PatMedInhosp(); pmi.setSerialnum(pm.getSerialnum()); List<PatMedInhosp> patMedInhospList1 = patMedInhospMapper.selectPatMedInhospList(pmi); if (CollectionUtils.isEmpty(patMedInhospList1)) { pm.setCreateTime(new Date()); patMedInhospMapper.insertPatMedInhosp(pm); } else { pm.setInhospid(patMedInhospList1.get(0).getInhospid()); patMedInhospMapper.updatePatMedInhosp(pm); } } } return 0; } @@ -112,23 +132,32 @@ @Override public Boolean hnDataGather(HnDataGatherVO hnDataGatherVO) { LocalDate startDate = hnDataGatherVO.getStartOutHospTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); LocalDate endDate = hnDataGatherVO.getEndOutHospTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); LocalDate startDate = hnDataGatherVO.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); LocalDate endDate = hnDataGatherVO.getEndTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); Integer po = null; // 循环处理每一天 for (LocalDate currentDate = startDate; !currentDate.isAfter(endDate); currentDate = currentDate.plusDays(1)) { PatMedInhosp dailyCondition = new PatMedInhosp(); //处理入院 LocalDateTime dayStart = currentDate.atStartOfDay(); LocalDateTime dayEnd = currentDate.atTime(23, 59, 59); dailyCondition.setStartInHospTime(Date.from(dayStart.atZone(ZoneId.systemDefault()).toInstant())); dailyCondition.setEndInHospTime(Date.from(dayEnd.atZone(ZoneId.systemDefault()).toInstant())); selectPatMedInhospList(dailyCondition); //处理出院 dailyCondition.setStartInHospTime(null); dailyCondition.setEndInHospTime(null); dailyCondition.setStartOutHospTime(Date.from(dayStart.atZone(ZoneId.systemDefault()).toInstant())); dailyCondition.setEndOutHospTime(Date.from(dayEnd.atZone(ZoneId.systemDefault()).toInstant())); Integer pi = selectPatMedInhospList(dailyCondition); selectPatMedInhospList(dailyCondition); //处理门诊 PatMedOuthosp patMedOuthosp = new PatMedOuthosp(); patMedOuthosp.setBeginTime(Date.from(dayStart.atZone(ZoneId.systemDefault()).toInstant())); patMedOuthosp.setEndTime(Date.from(dayEnd.atZone(ZoneId.systemDefault()).toInstant())); po = selectPatMedOuthospList(patMedOuthosp); selectPatMedOuthospList(patMedOuthosp); } return true; }