提交merge1.3

This commit is contained in:
2025-12-27 15:30:25 +08:00
parent 8c607c8749
commit 088861f66e
1245 changed files with 220442 additions and 77616 deletions

View File

@@ -74,4 +74,13 @@ public interface IGfStudentListAppService {
* @param response 响应
*/
void importTemplate(HttpServletResponse response);
<<<<<<< HEAD
=======
/**
* peis数据同步
*/
R<?> synPeis();
>>>>>>> v1.3
}

View File

@@ -5,6 +5,10 @@ import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
<<<<<<< HEAD
=======
import com.core.common.enums.DelFlag;
>>>>>>> v1.3
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -15,7 +19,10 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R;
<<<<<<< HEAD
import com.core.common.enums.DeleteFlag;
=======
>>>>>>> v1.3
import com.core.common.utils.AssignSeqUtil;
import com.core.common.utils.DateUtils;
import com.core.common.utils.SecurityUtils;
@@ -194,7 +201,11 @@ public class GfRatioApplicationRecordAppServiceImpl implements IGfRatioApplicati
// 查询指定项目现行比例
List<GfRatio> gfRatioList = gfRatioService.list(new LambdaQueryWrapper<GfRatio>()
.eq(GfRatio::getDefinitionId, gfRatioApplicationRecordDto.getDefinitionId())
<<<<<<< HEAD
.eq(GfRatio::getDeleteFlag, DeleteFlag.NOT_DELETED.getCode()));
=======
.eq(GfRatio::getDeleteFlag, DelFlag.NO.getCode()));
>>>>>>> v1.3
// 验证时间是否重叠
if (!gfRatioList.isEmpty()) {
for (GfRatio r : gfRatioList) {
@@ -548,7 +559,11 @@ public class GfRatioApplicationRecordAppServiceImpl implements IGfRatioApplicati
List<GfRatio> typeRatioList = gfRatioService
.list(new LambdaQueryWrapper<GfRatio>().eq(GfRatio::getRatioType, GfRatioType.TYPE_RATIO.getValue())
.eq(GfRatio::getYbClass, chargeItemDefinitionList.get(0).getYbType()).eq(GfRatio::getYbLv, ybLv)
<<<<<<< HEAD
.eq(GfRatio::getDeleteFlag, DeleteFlag.NOT_DELETED.getCode()));
=======
.eq(GfRatio::getDeleteFlag, DelFlag.NO.getCode()));
>>>>>>> v1.3
if (!typeRatioList.isEmpty()) {
oldRatio = typeRatioList.get(0).getSelfRatio();
}
@@ -556,7 +571,11 @@ public class GfRatioApplicationRecordAppServiceImpl implements IGfRatioApplicati
// 查询历史小项比例
List<GfRatio> historicalRatioList =
gfRatioService.list(new LambdaQueryWrapper<GfRatio>().eq(GfRatio::getDefinitionId, definitionId)
<<<<<<< HEAD
.eq(GfRatio::getDeleteFlag, DeleteFlag.NOT_DELETED.getCode()).orderByDesc(GfRatio::getId));
=======
.eq(GfRatio::getDeleteFlag, DelFlag.NO.getCode()).orderByDesc(GfRatio::getId));
>>>>>>> v1.3
BigDecimal oldTwiceRatio = null;
if (!historicalRatioList.isEmpty()) {
GfRatio latestRatio = historicalRatioList.get(0);

View File

@@ -12,7 +12,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R;
<<<<<<< HEAD
import com.core.common.enums.DeleteFlag;
=======
import com.core.common.enums.DelFlag;
>>>>>>> v1.3
import com.openhis.common.enums.GfItemType;
import com.openhis.common.enums.GfRatioType;
import com.openhis.common.enums.ybenums.YbChrgitmLv;
@@ -59,7 +63,11 @@ public class GfRatioManageAppServiceImpl implements IGfRatioManageAppService {
// 查询DB中的所有大项比例
List<GfRatio> gfRatioList = gfRatioService
.list(new LambdaQueryWrapper<GfRatio>().eq(GfRatio::getRatioType, GfRatioType.TYPE_RATIO.getValue())
<<<<<<< HEAD
.eq(GfRatio::getDeleteFlag, DeleteFlag.NOT_DELETED.getCode()));
=======
.eq(GfRatio::getDeleteFlag, DelFlag.NO.getCode()));
>>>>>>> v1.3
// 做成医保分项+医保等级拼接的Map
Map<String, GfRatio> gfRatioMap =
gfRatioList.stream().collect(Collectors.toMap(e -> e.getYbClass() + e.getYbLv(), Function.identity()));

View File

@@ -1,11 +1,40 @@
package com.openhis.web.nenu.appservice.impl;
<<<<<<< HEAD
import java.time.format.DateTimeParseException;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
=======
import java.io.IOException;
import java.time.format.DateTimeParseException;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSON;
import com.core.common.enums.TenantOptionDict;
import com.core.common.exception.ServiceException;
import com.core.web.util.TenantOptionUtil;
import com.openhis.web.nenu.dto.GfStudentPeisDto;
import com.openhis.web.nenu.dto.PeisStudentPatientDto;
import com.openhis.web.patientmanage.mapper.PatientManageMapper;
import com.openhis.yb.dto.BaseInfo;
import com.openhis.yb.dto.BaseParam;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
>>>>>>> v1.3
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@@ -16,7 +45,11 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R;
<<<<<<< HEAD
import com.core.common.enums.DeleteFlag;
=======
import com.core.common.enums.DelFlag;
>>>>>>> v1.3
import com.core.common.utils.*;
import com.core.common.utils.poi.ExcelUtil;
import com.openhis.administration.domain.Patient;
@@ -111,14 +144,22 @@ public class GfStudentListAppServiceImpl implements IGfStudentListAppService {
// 学号重复验证
List<PatientStudent> sameStudentIdStudents = patientStudentService.list(
new LambdaQueryWrapper<PatientStudent>().eq(PatientStudent::getStudentId, gfStudentListDto.getStudentId())
<<<<<<< HEAD
.eq(PatientStudent::getDeleteFlag, DeleteFlag.NOT_DELETED.getCode()));
=======
.eq(PatientStudent::getDeleteFlag, DelFlag.NO.getCode()));
>>>>>>> v1.3
if (!sameStudentIdStudents.isEmpty()) {
return R.fail("学号" + gfStudentListDto.getStudentId() + "在系统中已存在");
}
// 学生信息重复校验
List<PatientStudent> sameIdNumberStudents = patientStudentService.list(
new LambdaQueryWrapper<PatientStudent>().eq(PatientStudent::getIdNumber, gfStudentListDto.getIdNumber())
<<<<<<< HEAD
.eq(PatientStudent::getDeleteFlag, DeleteFlag.NOT_DELETED.getCode()));
=======
.eq(PatientStudent::getDeleteFlag, DelFlag.NO.getCode()));
>>>>>>> v1.3
Long existingPatientId = null;
if (!sameIdNumberStudents.isEmpty()) {
for (PatientStudent ps : sameIdNumberStudents) {
@@ -145,7 +186,11 @@ public class GfStudentListAppServiceImpl implements IGfStudentListAppService {
// 判断患者信息是否有重复
List<Patient> sameIdNumberPatients = patientService
.list(new LambdaQueryWrapper<Patient>().eq(Patient::getIdCard, gfStudentListDto.getIdNumber())
<<<<<<< HEAD
.eq(Patient::getDeleteFlag, DeleteFlag.NOT_DELETED.getCode()));
=======
.eq(Patient::getDeleteFlag, DelFlag.NO.getCode()));
>>>>>>> v1.3
if (!sameIdNumberPatients.isEmpty()) {
// 已存在则取存在的
existingPatientId = sameIdNumberPatients.get(0).getId();
@@ -238,7 +283,11 @@ public class GfStudentListAppServiceImpl implements IGfStudentListAppService {
@Override
public R<?> delete(Long id) {
patientStudentService.update(new LambdaUpdateWrapper<PatientStudent>()
<<<<<<< HEAD
.set(PatientStudent::getDeleteFlag, DeleteFlag.DELETED.getCode()).eq(PatientStudent::getId, id));
=======
.set(PatientStudent::getDeleteFlag, DelFlag.YES.getCode()).eq(PatientStudent::getId, id));
>>>>>>> v1.3
return R.ok();
}
@@ -416,13 +465,21 @@ public class GfStudentListAppServiceImpl implements IGfStudentListAppService {
for (GfStudentListImportDto importDto : importDtoList) {
List<PatientStudent> sameStudentIdStudents = patientStudentService.list(
new LambdaQueryWrapper<PatientStudent>().eq(PatientStudent::getStudentId, importDto.getStudentId())
<<<<<<< HEAD
.eq(PatientStudent::getDeleteFlag, DeleteFlag.NOT_DELETED.getCode()));
=======
.eq(PatientStudent::getDeleteFlag, DelFlag.NO.getCode()));
>>>>>>> v1.3
if (!sameStudentIdStudents.isEmpty()) {
dbRepeatedValidateMsgList.add("■ 第" + importDto.getLineNumber() + "行的学号在系统中已存在;");
}
List<PatientStudent> sameIdNumberStudents = patientStudentService
.list(new LambdaQueryWrapper<PatientStudent>().eq(PatientStudent::getIdNumber, importDto.getIdNumber())
<<<<<<< HEAD
.eq(PatientStudent::getDeleteFlag, DeleteFlag.NOT_DELETED.getCode()));
=======
.eq(PatientStudent::getDeleteFlag, DelFlag.NO.getCode()));
>>>>>>> v1.3
if (!sameIdNumberStudents.isEmpty()) {
for (PatientStudent ps : sameIdNumberStudents) {
if (!ps.getEnrollmentDate().after(importDto.getGraduationDate())
@@ -440,4 +497,153 @@ public class GfStudentListAppServiceImpl implements IGfStudentListAppService {
return R.ok();
}
<<<<<<< HEAD
=======
@Override
public R<?> synPeis() {
//List<GfStudentPeisDto> patientBusNoList = gfStudentListAppMapper.getPatientBusNoList();
try {
// 1. 获取总记录数
List<GfStudentPeisDto> patientBusNoList = gfStudentListAppMapper.getPatientBusNoList();
int totalCount = patientBusNoList.size();
if (totalCount == 0) {
return R.ok("未查询到数据");
}
//log.info("开始传输学生数据,总记录数: {}", totalCount);
// 2. 分批处理参数
int pageSize = 1000; // 每批大小
int pageNum = 1;
int totalPages = (int) Math.ceil((double) totalCount / pageSize);
AtomicInteger processedCount = new AtomicInteger(0);
List<Long> failedBatches = new ArrayList<>();
List<ArrayList<GfStudentPeisDto>> lists = IntStream.range(0, (totalCount + pageSize - 1) / pageSize)
.mapToObj(i -> {
int start = i * pageSize;
int end = Math.min(start + pageSize, totalCount);
return new ArrayList<>(patientBusNoList.subList(start, end));
})
.collect(Collectors.toList());
// 3. 分批处理
for (ArrayList<GfStudentPeisDto> list:lists) {
//log.info("开始处理第 {}/{} 批", pageNum, totalPages);
PeisStudentPatientDto peisStudentPatientDto = new PeisStudentPatientDto();
peisStudentPatientDto.setStudentList(list);
peisStudentPatientDto.setCustomerId("");
peisStudentPatientDto.setRequestType("");
// 发送请求
boolean success = sendBatchDataWithRetry(peisStudentPatientDto, 3); // 重试3次
if (success) {
int currentProcessed = processedCount.addAndGet(list.size());
//log.info("第 {} 批处理成功,当前累计处理: {} 条",
// pageNum, currentProcessed);
} else {
failedBatches.add((long) pageNum);
//log.error("第 {} 批处理失败,已记录到失败列表", pageNum);
}
// 进度控制
if (pageNum % 5 == 0) {
double progress = (double) pageNum / totalPages * 100;
//log.info("传输进度: {}/{} ({:.2f}%)",
// pageNum, totalPages, progress);
}
// 批次间隔,避免对接口造成压力
Thread.sleep(200);
pageNum++;
}
// 4. 返回结果
String message = String.format("数据传输完成。总记录数: %d成功处理: %d 条",
totalCount, processedCount.get());
if (!failedBatches.isEmpty()) {
message += String.format(",失败批次: %s", failedBatches);
// 可以在这里添加失败批次的重试逻辑
retryFailedBatches(failedBatches);
}
return R.ok(message);
} catch (Exception e) {
//log.error("数据传输异常", e);
return R.fail("数据传输失败: " + e.getMessage());
}
}
private boolean sendBatchDataWithRetry(PeisStudentPatientDto peisStudentPatientDto, int maxRetries) {
int retryCount = 0;
List<GfStudentPeisDto> studentList = peisStudentPatientDto.getStudentList();
while (retryCount <= maxRetries) {
try {
return sendSingleBatchHttpRequest(peisStudentPatientDto);
} catch (Exception e) {
retryCount++;
if (retryCount > maxRetries) {
//log.error("批次数据发送失败,已达最大重试次数: {}", maxRetries, e);
return false;
}
try {
// 指数退避
long delay = (long) Math.pow(2, retryCount) * 1000;
Thread.sleep(delay);
//log.info("第 {} 次重试批次数据", retryCount);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
return false;
}
}
}
return false;
}
/**
* 发送http请求2025/05/02经测试若以自带的工具类发送请求失败故使用原peis系统中成功调用的写法重新封装
*
* @param peisStudentPatientDto 参数
* @return
*/
private boolean sendSingleBatchHttpRequest(PeisStudentPatientDto peisStudentPatientDto) {
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(90000).setConnectionRequestTimeout(90000)
.setSocketTimeout(90000).build();
CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).build();
CloseableHttpResponse response = null;
// 发送请求
try {
HttpPost httpPost = new HttpPost(TenantOptionUtil.getOptionContent(TenantOptionDict.PEIS_SERVER_URL)+"/wx/auth/syncHisInfo");
StringEntity stringEntity = new StringEntity(JSON.toJSONString(peisStudentPatientDto), ContentType.APPLICATION_JSON);
httpPost.setEntity(stringEntity);
// 执行http请求
response = httpClient.execute(httpPost);
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException("Http请求异常请稍后再试。");
} finally {
try {
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
private void retryFailedBatches(List<Long> failedBatchNumbers) {
// 实现失败批次的重试逻辑
// 可以根据业务需求决定是否重试
}
>>>>>>> v1.3
}

View File

@@ -105,4 +105,16 @@ public class GfStudentListController {
public void importTemplate(HttpServletResponse response) {
gfStudentListAppService.importTemplate(response);
}
<<<<<<< HEAD
=======
/**
* peis同步
*
*/
@PostMapping("/sy-peis")
public R<?> synPeis() {
return gfStudentListAppService.synPeis();
}
>>>>>>> v1.3
}

View File

@@ -0,0 +1,40 @@
package com.openhis.web.nenu.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 公费医疗-学生名单peis同步
*
* @author Thanking
* @date 2025-12-16
*/
@Data
public class GfStudentPeisDto implements Serializable {
/**
* 姓名
*/
private String name;
/**
* 学号
*/
private String studentId;
/**
* 身份证号码
*/
private String idNumber;
/**
* 患者编号
*/
private String busNo;
/**
* 状态
*/
private String status;
}

View File

@@ -0,0 +1,19 @@
package com.openhis.web.nenu.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class PeisStudentPatientDto implements Serializable {
private static final long serialVersionUID = 1L;
private String customerId;
private String requestType;
private List<GfStudentPeisDto> studentList;
}

View File

@@ -1,5 +1,9 @@
package com.openhis.web.nenu.mapper;
<<<<<<< HEAD
=======
import com.openhis.web.nenu.dto.GfStudentPeisDto;
>>>>>>> v1.3
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@@ -9,6 +13,11 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.openhis.web.nenu.dto.GfStudentListDto;
<<<<<<< HEAD
=======
import java.util.List;
>>>>>>> v1.3
/**
* 公费医疗-学生名单管理 Mapper
*
@@ -28,4 +37,27 @@ public interface GfStudentListAppMapper {
IPage<GfStudentListDto> selectGfStudentListPage(@Param("page") Page<GfStudentListDto> page,
@Param(Constants.WRAPPER) QueryWrapper<GfStudentListDto> queryWrapper);
<<<<<<< HEAD
=======
/**
* 获取学生名单peis同步列表
*
* @return 学生名单peis同步列表
*/
List<GfStudentPeisDto> getPatientBusNoList(@Param("pageNum")int pageNum, @Param("pageSize")int pageSize);
/**
* 获取学生名单peis同步列表
*
* @return 学生名单peis同步列表
*/
List<GfStudentPeisDto> getPatientBusNoList();
/**
* 获取学生名单peis同步列表数量
*
* @return 学生名单peis同步列表数量
*/
Long getPatientBusNoCount();
>>>>>>> v1.3
}