From cac8d292911a995ac388160704ca8713ea76cd55 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 28 八月 2025 14:33:25 +0800
Subject: [PATCH] 河南数据采集代码提交
---
ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java | 6 -
ruoyi-admin/src/main/java/com/ruoyi/web/controller/sso/SSOController.java | 125 +++++++++----------------------
smartor/src/main/java/com/smartor/domain/HnDataGatherVO.java | 7 +
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/HNGatherPatArchiveController.java | 32 +++++++
smartor/src/main/java/com/smartor/service/impl/HNGatherPatArchiveServiceImpl.java | 39 ++++++++-
smartor/src/main/java/com/smartor/domain/SvyLibTemplateScriptVO.java | 2
6 files changed, 110 insertions(+), 101 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/HNGatherPatArchiveController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/HNGatherPatArchiveController.java
index 3be114b..0ae17bd 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/HNGatherPatArchiveController.java
+++ b/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);
+ }
+
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/sso/SSOController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/sso/SSOController.java
index 0df2993..78296c7 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/sso/SSOController.java
+++ b/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 @@
* 璁块棶璺緞锛歨ttp://鍩熷悕:8095/sso/login
*/
@GetMapping("")
- public void ssoLogin(HttpServletResponse response, HttpServletRequest request) throws IOException {
+ public void ssoLogin() {
log.info("鏀跺埌SSO鐧诲綍璇锋眰锛屽紑濮嬮噸瀹氬悜鍒版巿鏉冩湇鍔″櫒");
- // 鑾峰彇瀹㈡埛绔疘P
- 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鍥炶皟锛宑ode: {}, 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鍥炶皟鍙傛暟閿欒锛宑ode: {}, 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("銆怉uthorize閴存潈鎺ュ彛銆戝叆鍙備负锛歿}", param);
+ String s = HttpUtils.sendGet(internalAuthorizeUrl, param);
+ Map<String, String> result = getResult(s);
+ String code = result.get("code");
try {
- // 鑾峰彇瀹㈡埛绔疘P
- String clientIp = getClientIp(request);
- boolean isInternal = isInternalNetwork(clientIp);
+ SSOTokenResponse accessToken = getAccessToken(code, true);
+ SSOUserInfo userInfo = getUserInfo(accessToken.getAccess_token(), true);
- // 1. 鐢╟ode鎹㈠彇access_token
- SSOTokenResponse tokenResponse = getAccessToken(code, isInternal);
- log.info("鑾峰彇鍒癮ccess_token: {}", tokenResponse.getAccess_token());
+ createLocalSession(userInfo);
- // 2. 鐢╝ccess_token鑾峰彇鐢ㄦ埛淇℃伅
- SSOUserInfo userInfo = getUserInfo(tokenResponse.getAccess_token(), isInternal);
- log.info("鑾峰彇鍒扮敤鎴蜂俊鎭�: {}", userInfo);
-
- // 3. 鏍规嵁鐢ㄦ埛淇℃伅鍒涘缓鏈湴浼氳瘽
- String token = createLocalSession(userInfo);
-
- // 4. 閲嶅畾鍚戝埌鍓嶇棣栭〉锛屾惡甯oken
- 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("鐢熸垚鐨則oken涓猴細{}", token);
+ return token;
}
/**
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java
index 16134f3..f3ca8c3 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java
+++ b/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, "璋冨害鏃ュ織");
}
-
+
/**
* 鏍规嵁璋冨害缂栧彿鑾峰彇璇︾粏淇℃伅
*/
diff --git a/smartor/src/main/java/com/smartor/domain/HnDataGatherVO.java b/smartor/src/main/java/com/smartor/domain/HnDataGatherVO.java
index a0acdb0..8c337c6 100644
--- a/smartor/src/main/java/com/smartor/domain/HnDataGatherVO.java
+++ b/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;
+
+
+
}
diff --git a/smartor/src/main/java/com/smartor/domain/SvyLibTemplateScriptVO.java b/smartor/src/main/java/com/smartor/domain/SvyLibTemplateScriptVO.java
index d8c1010..afadacd 100644
--- a/smartor/src/main/java/com/smartor/domain/SvyLibTemplateScriptVO.java
+++ b/smartor/src/main/java/com/smartor/domain/SvyLibTemplateScriptVO.java
@@ -122,7 +122,7 @@
* 鏄惁闅愯棌
*/
@Excel(name = " 鏄惁闅愯棌 ")
- @ApiModelProperty("鏄惁闅愯棌")
+ @ApiModelProperty("鏄惁闅愯棌:0鍚︼紙榛樿锛� 1鏄�")
private Long ishide;
/**
diff --git a/smartor/src/main/java/com/smartor/service/impl/HNGatherPatArchiveServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/HNGatherPatArchiveServiceImpl.java
index 934a87a..3ae6888 100644
--- a/smartor/src/main/java/com/smartor/service/impl/HNGatherPatArchiveServiceImpl.java
+++ b/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;
}
--
Gitblit v1.9.3