连州人民生成目录

master
Godblessyou 3 months ago
parent e54404474c
commit a5d2f314dc

@ -22,6 +22,7 @@
<fastjson.version>2.0.11</fastjson.version>
<commons-pool2.version>2.6.0</commons-pool2.version>
<itext.version>2.1.7</itext.version>
<lombok.version>1.18.30</lombok.version>
</properties>
<dependencies>
<dependency>
@ -56,6 +57,8 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<!--mybatis-plus-->
<dependency>

@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
@ -19,8 +20,14 @@ import java.io.File;
@MapperScan("com.example.duplicate.infrastructure.dao")
public class SpringbootDemoApplication {
public static void main(String[] args) {
ConfigurableApplicationContext ctx =
SpringApplication.run(SpringbootDemoApplication.class, args);
// ① 看 Environment 里有没有 spring.datasource.url
String url = ctx.getEnvironment().getProperty("spring.datasource.url");
System.out.println(">>> 实际读取的 url = " + url);
}

@ -1,64 +0,0 @@
package com.example.duplicate.config;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import javax.sql.DataSource;
/**
* @ClassName RecordConfig
* @Description Pacs
* @Author linjj
* @Date 2023/8/2 16:48
* @Version 1.0
*/
@Configuration
// 指定主数据库扫描对应的Mapper文件生成代理对象
@MapperScan(basePackages ="com.example.duplicate.infrastructure.configOneDao" ,sqlSessionFactoryRef = "configOneSqlSessionFactory")
public class ConfigOne {
// mapper.xml所在地址
private static final String MAPPER_LOCATION = "classpath*:mapper/*.xml";
/**
* Primary
*
*/
@Bean(name = "configOneDataSource")
// 读取spring.datasource.master前缀的配置文件映射成对应的配置对象
@ConfigurationProperties(prefix = "spring.datasource.db1")
public DataSource dataSource() {
DataSource build = DataSourceBuilder.create().build();
return build;
}
/**
* Primary
*/
@Bean(name = "configOneTransactionManager")
public PlatformTransactionManager dataSourceTransactionManager(@Qualifier("configOneDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
/**
* sessionPrimary
*/
@Bean(name = "configOneSqlSessionFactory")
public SqlSessionFactory sqlSessionFactory(@Qualifier("configOneDataSource") DataSource dataSource) throws Exception {
final SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
sessionFactoryBean.setDataSource(dataSource);
sessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(ConfigOne.MAPPER_LOCATION));
return sessionFactoryBean.getObject();
}
}

@ -1,70 +0,0 @@
package com.example.duplicate.config;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import javax.sql.DataSource;
/**
* @ClassName RecordConfig
* @Description
* @Author linjj
* @Date 2023/8/2 16:48
* @Version 1.0
*/
@Configuration
// 指定主数据库扫描对应的Mapper文件生成代理对象
@MapperScan(basePackages ="com.example.duplicate.infrastructure.configTwoDao" ,sqlSessionFactoryRef = "configTwoSqlSessionFactory")
public class ConfigTwo {
// mapper.xml所在地址
private static final String MAPPER_LOCATION = "classpath*:mapper2/*.xml";
/**
* Primary
*
*/
@Primary
@Bean(name = "configTwoDataSource")
// 读取spring.datasource.master前缀的配置文件映射成对应的配置对象
@ConfigurationProperties(prefix = "spring.datasource.db2")
public DataSource dataSource() {
DataSource build = DataSourceBuilder.create().build();
return build;
}
/**
* Primary
*/
@Bean(name = "configTwoTransactionManager")
@Primary
public PlatformTransactionManager dataSourceTransactionManager(@Qualifier("configTwoDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
/**
* sessionPrimary
*/
@Bean(name = "configTwoSqlSessionFactory")
@Primary
public SqlSessionFactory sqlSessionFactory(@Qualifier("configTwoDataSource") DataSource dataSource) throws Exception {
final SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
sessionFactoryBean.setDataSource(dataSource);
sessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(ConfigTwo.MAPPER_LOCATION));
return sessionFactoryBean.getObject();
}
}

@ -46,4 +46,15 @@ public class LzRmController {
return ResultBody.success("完成");
}
@ResponseBody
@RequestMapping(value = "getPath", method = RequestMethod.POST)
@ApiOperation(value = "检查错误目录", notes = "检查错误目录")
public ResultBody getPath(){
lzRmService.getPath();
return ResultBody.success("完成");
}
}

@ -1,85 +0,0 @@
package com.example.duplicate.controller;
import com.example.duplicate.controller.vo.CommomtableCopyVo;
import com.example.duplicate.infrastructure.configOneDao.CommomtableMapper;
import com.example.duplicate.service.MessageLogService;
import com.example.duplicate.service.MessageLogTwoService;
import com.example.duplicate.service.MessageSubordinateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @ClassName ZJYYController
* @Description
* @Author linjj
* @Date 2023/10/13 13:49
* @Version 1.0
*/
@RestController
@Api(value = "湛江医院接口", tags = "湛江医院相关接口", description = "湛江医院相关接口")
@RequestMapping("/ZJYY")
@Slf4j
public class ZJYYController {
@Autowired
MessageSubordinateService messageSubordinateService;
@Autowired
MessageLogService messageLogService;
@Autowired
MessageLogTwoService messageLogTwoService;
@Autowired
CommomtableMapper commomtableMapper;
@RequestMapping(value = "delMessage" , method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "删除messageSubordinate内容" , notes = "删除messageSubordinate内容")
public int delMessage() {
return messageSubordinateService.delMessage();
}
@RequestMapping(value = "delMessageLog" , method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "删除messageLog内容" , notes = "删除messageLog内容")
public int delMessageLog() {
return messageLogService.delMessageLog();
}
@RequestMapping(value = "addMessageLog" , method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "移动messageLog内容" , notes = "移动messageLog内容")
public int addMessageLog(){
return messageLogTwoService.addMessageLog();
}
@RequestMapping(value = "addMessage" , method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "移动messageScanning表数据" , notes = "移动messageScanning表数据")
public int addMessage(){
return messageSubordinateService.addMessage();
}
@RequestMapping(value = "com" , method = RequestMethod.GET)
@ResponseBody
public String com(){
List<CommomtableCopyVo> com = commomtableMapper.com();
for (CommomtableCopyVo list:com){
StringBuffer sb=new StringBuffer();
sb.append("(inp_no =' "+list.getInpatientNo()+" 'and visit_id = '"+list.getAdmissTimes()+" ' ) or");
log.info(sb.toString());
}
return"";
}
}

@ -1,23 +0,0 @@
package com.example.duplicate.infrastructure.configTwoDao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.duplicate.controller.vo.MessageLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @ClassName MessageLogMapper
* @Description
* @Author linjj
* @Date 2023/10/13 13:58
* @Version 1.0
*/
@Mapper
public interface MessageLogTwoMapper {
int addAll(@Param("list")List<MessageLog> list);
}

@ -1,24 +0,0 @@
package com.example.duplicate.infrastructure.configTwoDao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.duplicate.controller.vo.MessageLog;
import com.example.duplicate.controller.vo.MessageSubordinate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @ClassName MessageLogMapper
* @Description
* @Author linjj
* @Date 2023/10/13 13:58
* @Version 1.0
*/
@Mapper
public interface MessageSubordinateTwoMapper {
int addAll(@Param("list")List<MessageSubordinate> list);
}

@ -1,4 +1,4 @@
package com.example.duplicate.infrastructure.configOneDao;
package com.example.duplicate.infrastructure.dao;
import com.example.duplicate.controller.vo.AddArchiveDetail;
import org.apache.ibatis.annotations.Mapper;

@ -1,4 +1,4 @@
package com.example.duplicate.infrastructure.configOneDao;
package com.example.duplicate.infrastructure.dao;
import com.example.duplicate.controller.vo.AddArchiveMasterVo;
import com.example.duplicate.controller.vo.ArchiveMasterVo;

@ -1,4 +1,4 @@
package com.example.duplicate.infrastructure.configOneDao;
package com.example.duplicate.infrastructure.dao;
import com.example.duplicate.controller.vo.*;

@ -1,4 +1,4 @@
package com.example.duplicate.infrastructure.configOneDao;
package com.example.duplicate.infrastructure.dao;
import com.example.duplicate.controller.vo.CommomtableCopyVo;
import com.example.duplicate.controller.vo.ZdAssortVo;

@ -1,4 +1,4 @@
package com.example.duplicate.infrastructure.configOneDao;
package com.example.duplicate.infrastructure.dao;
import com.example.duplicate.controller.vo.MessageLog;

@ -1,4 +1,4 @@
package com.example.duplicate.infrastructure.configOneDao;
package com.example.duplicate.infrastructure.dao;
import com.example.duplicate.controller.vo.MessageSubordinate;

@ -1,6 +1,5 @@
package com.example.duplicate.infrastructure.configOneDao;
package com.example.duplicate.infrastructure.dao;
import com.example.duplicate.controller.vo.AddArchiveDetail;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

@ -1,4 +1,4 @@
package com.example.duplicate.infrastructure.configOneDao;
package com.example.duplicate.infrastructure.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.duplicate.controller.vo.FliePath;

@ -12,4 +12,6 @@ public interface LzRmService {
int LzRmSplit();
void Batch();
void getPath();
}

@ -1,15 +0,0 @@
package com.example.duplicate.service;
/**
* @ClassName MessageLogService
* @Description MessageLog
* @Author linjj
* @Date 2023/10/13 15:19
* @Version 1.0
*/
public interface MessageLogService {
int delMessageLog();
}

@ -1,13 +0,0 @@
package com.example.duplicate.service;
/**
* @ClassName MessageLogService
* @Description MessageLog
* @Author linjj
* @Date 2023/10/13 15:19
* @Version 1.0
*/
public interface MessageLogTwoService {
int addMessageLog();
}

@ -1,20 +0,0 @@
package com.example.duplicate.service;
/**
* @ClassName ZJYYService
* @Description
* @Author linjj
* @Date 2023/10/13 13:49
* @Version 1.0
*/
public interface MessageSubordinateService {
int delMessage();
int addMessage();
}

@ -3,8 +3,8 @@ package com.example.duplicate.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.duplicate.controller.vo.*;
import com.example.duplicate.infrastructure.configOneDao.CommomtableMapper;
import com.example.duplicate.infrastructure.configOneDao.QualityMapper;
import com.example.duplicate.infrastructure.dao.CommomtableMapper;
import com.example.duplicate.infrastructure.dao.QualityMapper;
import com.example.duplicate.service.DuplicateService;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;

@ -1,20 +1,20 @@
package com.example.duplicate.service.impl;
import com.example.duplicate.controller.vo.*;
import com.example.duplicate.infrastructure.configOneDao.ArchiveDetailMapper;
import com.example.duplicate.infrastructure.configOneDao.ArchiveMasterMapper;
import com.example.duplicate.infrastructure.configOneDao.CommomtableMapper;
import com.example.duplicate.infrastructure.configOneDao.LzRmMapper;
import com.example.duplicate.infrastructure.dao.ArchiveDetailMapper;
import com.example.duplicate.infrastructure.dao.ArchiveMasterMapper;
import com.example.duplicate.infrastructure.dao.CommomtableMapper;
import com.example.duplicate.infrastructure.dao.LzRmMapper;
import com.example.duplicate.service.LzRmService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -47,7 +47,7 @@ public class LzRmServiceImpl implements LzRmService {
/* 日期解析工具 */
private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyyMMdd");
private static final String ROOT_DIR = "F:\\连州人民2期 已丢图像";
@Override
public int LzRmSplit() {
//新增状态
@ -85,7 +85,7 @@ public class LzRmServiceImpl implements LzRmService {
@Override
public void Batch() {
File root = new File("D:/tmp");
File root = new File("F://连州人民2期 已丢图像");
File[] firstLevelFolders = root.listFiles(File::isDirectory);
if (firstLevelFolders == null) return;
@ -124,6 +124,67 @@ public class LzRmServiceImpl implements LzRmService {
}
}
@Override
public void getPath() {
try {
Files.walk(Paths.get(ROOT_DIR))
.filter(Files::isDirectory)
.filter(p -> !p.toString().equals(ROOT_DIR))
.forEach(p -> checkFolder(p.toFile()));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static void checkFolder(File dir) {
String name = dir.getName();
if (!name.contains("-")) return;
String[] p = name.split("-", -1);
StringBuilder err = new StringBuilder();
/* 0. 参数个数 */
if (p.length != 7) {
err.append("参数个数=").append(p.length).append("应为7");
// 长度不足直接报,后面不再校验
log.info("【不合规】" + dir + " 原因:" + err);
return;
}
/* 1. 顺序反病案号≤3位 且 住院次数≥5位 */
if (p[1].matches("\\d{1,3}") && p[2].matches("\\d{5,}")) {
err.append("病案号与住院次数位置反病案号≤3位且住院次数≥5位");
}
/* 2. 基本格式校验(允许 数字 | 无 | - | 空串) */
if (!p[0].matches("^(\\d+|无|-)?$")) err.append("盘号格式错误;");
if (!p[1].matches("^(\\d+|无|-)?$")) err.append("病案号格式错误;");
if (!p[2].matches("^(\\d+|无|-)?$")) err.append("住院次数格式错误;");
/* 3. 日期yyyyMMdd 或 无/- */
if (!p[4].matches("(\\d{8}|无|-)")) {
// 如果是纯数字但长度不对 → 格式错
if (p[4].matches("\\d+") && p[4].length() != 8) {
err.append("出院日期格式错误;");
} else if (!p[4].equals("无") && !p[4].equals("-")) {
// 非数字、非无、非- → 格式错
err.append("出院日期格式错误;");
}
}
/* 4. 旧病案号:数字 或 无/- */
/* 旧病案号:数字 | 无 | - | 空串 */
if (!p[6].matches("^(\\d+|无|-|)$")) {
err.append("旧病案号格式错误;");
}
/* 5. 输出结果 */
if (err.length() > 0) {
log.info("【不合规】" + dir + " 原因:" + err);
}
}
/**
* @description: Archive_Master
* @params: commomtableCopyVo

@ -1,47 +0,0 @@
package com.example.duplicate.service.impl;
import com.example.duplicate.controller.vo.MessageLogVo;
import com.example.duplicate.infrastructure.configOneDao.MessageLogMapper;
import com.example.duplicate.service.MessageLogService;
import com.example.utils.ListUtilsNew;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @ClassName MessageLogServiceImpl
* @Description
* @Author linjj
* @Date 2023/10/13 15:19
* @Version 1.0
*/
@Service
public class MessageLogServiceImpl implements MessageLogService {
@Autowired
MessageLogMapper messageLogMapper;
@Value("${ZJ_DATE_TIME_LOG}")
private String dateTime;
@Override
public int delMessageLog() {
//查询需要删除数据条数
int messageLogNum = messageLogMapper.getMessageLogNum(dateTime);
//需要次数
double num = ((double) messageLogNum) / 100;
int circulateNum= (int) Math.ceil(num);
for (int i=0;i<circulateNum;i++){
//查询需要删除数据的id每次查100条
List<MessageLogVo> list = messageLogMapper.getAllByIds(dateTime);
//id集合
List<String> idList = ListUtilsNew.distinctSelect(list, MessageLogVo::getId);
//转成逗号拼接
String ids = String.join(",", idList);
messageLogMapper.del(ids);
}
return 1;
}
}

@ -1,52 +0,0 @@
package com.example.duplicate.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.duplicate.controller.vo.MessageLog;
import com.example.duplicate.infrastructure.configOneDao.MessageLogMapper;
import com.example.duplicate.infrastructure.configTwoDao.MessageLogTwoMapper;
import com.example.duplicate.service.MessageLogTwoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @ClassName MessageLogServiceImpl
* @Description
* @Author linjj
* @Date 2023/10/13 15:19
* @Version 1.0
*/
@Service
public class MessageLogTwoServiceImpl implements MessageLogTwoService {
@Autowired
private MessageLogMapper messageLogMapper;
@Autowired
private MessageLogTwoMapper messageLogTwoMapper;
@Value("${ZJ_DATE_TIME_LOG}")
private String dateTime;
@Override
public int addMessageLog() {
//查询需要移动数据条数
int messageLogNum = messageLogMapper.getMessageLogNum(dateTime);
//需要次数
double num = ((double) messageLogNum) / 100;
int circulateNum= (int) Math.ceil(num);
for (int i=0;i<circulateNum;i++){
//查询同步时间
String synchronousTime = messageLogMapper.getSynchronousTime();
//查询需要同步的数据每次查100条
List<MessageLog> allBy = messageLogMapper.getAllBy(synchronousTime);
//插入新数据库
messageLogTwoMapper.addAll(allBy);
//记录更新时间
String dischargeDateTime = allBy.get(allBy.size() - 1).getDischargeDateTime();
messageLogMapper.updateSynchronousTime(dischargeDateTime);
}
return 1;
}
}

@ -1,143 +0,0 @@
package com.example.duplicate.service.impl;
import com.example.duplicate.controller.vo.ArchiveMasterVo;
import com.example.duplicate.controller.vo.MessageLog;
import com.example.duplicate.controller.vo.MessageSubordinate;
import com.example.duplicate.controller.vo.MessageSubordinateVo;
import com.example.duplicate.infrastructure.configOneDao.ArchiveMasterMapper;
import com.example.duplicate.infrastructure.configOneDao.MessageLogMapper;
import com.example.duplicate.infrastructure.configOneDao.MessageSubordinateMapper;
import com.example.duplicate.infrastructure.configTwoDao.MessageLogTwoMapper;
import com.example.duplicate.infrastructure.configTwoDao.MessageSubordinateTwoMapper;
import com.example.duplicate.service.MessageSubordinateService;
import com.example.utils.ListUtilsNew;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @ClassName ZJYYServiceImpl
* @Description
* @Author linjj
* @Date 2023/10/13 13:50
* @Version 1.0
*/
@Service
@Slf4j
public class MessageSubordinateServiceImpl implements MessageSubordinateService {
static final Logger logger = LoggerFactory.getLogger(MessageSubordinateServiceImpl.class);
@Value("${ZJ_DATE_TIME_MESSAGE}")
private String dateTime;
@Autowired
MessageSubordinateMapper messageSubordinateMapper;
@Autowired
MessageSubordinateTwoMapper messageSubordinateTwoMapper;
@Autowired
ArchiveMasterMapper archiveMasterMapper;
@Autowired
MessageLogMapper messageLogMapper;
@Autowired
MessageLogTwoMapper messageLogTwoMapper;
@Override
public int delMessage() {
//查询需要删除数据条数
int messageNum = messageSubordinateMapper.getMessageNum(dateTime);
//需要次数
double num = ((double) messageNum) / 100;
int circulateNum = (int) Math.ceil(num);
for (int i = 0; i < circulateNum; i++) {
//查询需要删除数据的id每次查100条
List<MessageSubordinateVo> list = messageSubordinateMapper.getAllByIds();
//id集合
List<String> idList = ListUtilsNew.distinctSelect(list, MessageSubordinateVo::getId);
//转成逗号拼接
String ids = String.join(",", idList);
messageSubordinateMapper.del(ids);
}
return 1;
}
@Override
public int addMessage() {
//查询一共有多少份病历需要同步
int masterIdNum = archiveMasterMapper.masterIdNum(dateTime);
//需要次数
double num = ((double) masterIdNum) / 100;
//少数往前进1确保不丢失数据
int circulateNum = (int) Math.ceil(num);
for (int i = 0; i < circulateNum; i++) {
//每次查询100份病历
List<ArchiveMasterVo> masterId = archiveMasterMapper.getMasterId(dateTime);
if (masterId.size() == 0) {
return 0;
}
//masterId集合
List<String> idList = ListUtilsNew.distinctSelect(masterId, ArchiveMasterVo::getId);
//转成逗号拼接
String masterIds = String.join(",", idList);
//根据masterId查询message_log表
List<MessageLog> messageLogList = messageLogMapper.getAllByMasterId(masterIds);
//获取message_log表id集合
List<String> messageLogId = ListUtilsNew.distinctSelect(messageLogList, MessageLog::getId);
//如果档次100条记录没有messageLogId那么保存记录后结束本次循环
if (messageLogId.size() == 0) {
//保存处理过的masterId
archiveMasterMapper.add(idList);
continue;
}
//根据message_log表id操作message_subordinate表
messageSubordinate(messageLogId);
//操作完message_subordinate表操作message_log表
messageLog(messageLogList);
//保存处理过的masterId
archiveMasterMapper.add(idList);
}
return 0;
}
private void messageSubordinate(List<String> messageLogId) {
//分批次
List<List<String>> newList = ListUtils.partition(messageLogId, 100);
for (List<String> messageList : newList) {
//转成字符串类型逗号拼接
String messageLogIds = String.join(",", messageList);
//查询100条
List<MessageSubordinate> list = messageSubordinateMapper.getAllByMessageLogId(messageLogIds);
if (list.size()==0){
continue;
}
//往新表插入
messageSubordinateTwoMapper.addAll(list);
//新表插入完成删除旧表
messageSubordinateMapper.del(messageLogIds);
}
}
private void messageLog(List<MessageLog> messageLogList) {
List<List<MessageLog>> newList = ListUtils.partition(messageLogList, 100);
for (List<MessageLog> messageList : newList) {
//往新表中拆入数据
messageLogTwoMapper.addAll(messageList);
//获取这100条message_log表id集合
List<String> ids = ListUtilsNew.distinctSelect(messageList, MessageLog::getId);
//移除旧表数据
String messageLogIds = String.join(",", ids);
messageLogMapper.del(messageLogIds);
}
}
}

@ -5,30 +5,10 @@ server:
spring:
datasource:
# db1: #数据源1
# jdbc-url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=DB_PrivilegeManagement_LZRMYY
# username: sa
# password: docus@904
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# type: com.alibaba.druid.pool.DruidDataSource
# db2: #数据源2
# jdbc-url: jdbc:sqlserver://10.6.1.125:1433;DatabaseName=beifen
# username: sa
# password: Sql@2012
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# type: com.alibaba.druid.pool.DruidDataSource
db1: #数据源1
jdbc-url: jdbc:sqlserver://192.168.2.22:1433;DatabaseName=qf_record_lin
username: sa
url: jdbc:mysql://127.0.0.1:3306/docus_archivefile?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&characterEncoding=utf8
username: root
password: 123456
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
type: com.alibaba.druid.pool.DruidDataSource
db2: #数据源2
jdbc-url: jdbc:sqlserver://192.168.2.22:1433;DatabaseName=gzsrm
username: sa
password: 123456
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
#加快springboot初始化延缓初始化加载
main:
lazy-initialization: true

@ -14,7 +14,7 @@
<!-- 以下的大概意思是1.先按日期存日志日期变了将前一天的日志文件名重命名为XXX%日期%索引新的日志仍然是demo.log -->
<!-- 2.如果日期没有发生变化但是当前日志的文件大小超过1KB时对当前日志进行分割 重命名-->
<appender name="demolog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>D:\logs\springbootDemo.log</File>
<File>./logs/springbootDemo.log</File>
<!-- rollingPolicy:当发生滚动时,决定 RollingFileAppender 的行为,涉及文件移动和重命名。 -->
<!-- TimeBasedRollingPolicy 最常用的滚动策略,它根据时间来制定滚动策略,既负责滚动也负责出发滚动 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
@ -31,7 +31,7 @@
<encoder>
<!-- pattern节点用来设置日志的输入格式 -->
<pattern>
[%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%X{traceId}] [%L] [%-5p] %m%n
[%L] [%-5p] %m%n
</pattern>
<charset>utf-8</charset>
<!-- 记录日志的编码:此处设置字符集 - -->

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.duplicate.infrastructure.configOneDao.ArchiveDetailMapper">
<mapper namespace="com.example.duplicate.infrastructure.dao.ArchiveDetailMapper">
<insert id="addArchiveDetail">

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.duplicate.infrastructure.configOneDao.ArchiveMasterMapper">
<mapper namespace="com.example.duplicate.infrastructure.dao.ArchiveMasterMapper">
<insert id="add">
insert into master_id (masterId)
values

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.duplicate.infrastructure.configOneDao.CommomtableMapper">
<mapper namespace="com.example.duplicate.infrastructure.dao.CommomtableMapper">
<insert id="addAddLzRmComm">
insert into CommonTable (patient_id, admiss_id, admiss_times, inpatient_no, name, dis_date, dis_dept_name,
ph, gdh,splitName)

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.duplicate.infrastructure.configOneDao.LzRmMapper">
<mapper namespace="com.example.duplicate.infrastructure.dao.LzRmMapper">
<update id="updateSynchronousTime">
update commomtable_copy
set spilStatic=#{spilStatic}

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.duplicate.infrastructure.configOneDao.MessageLogMapper">
<mapper namespace="com.example.duplicate.infrastructure.dao.MessageLogMapper">
<resultMap id="BaseResultMap" type="com.example.duplicate.controller.vo.MessageLog">
<id column="id" property="id" />

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.duplicate.infrastructure.configOneDao.MessageSubordinateMapper">
<mapper namespace="com.example.duplicate.infrastructure.dao.MessageSubordinateMapper">
<resultMap id="BaseResultMap" type="com.example.duplicate.controller.vo.MessageSubordinate">

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.duplicate.infrastructure.configOneDao.MidMapper">
<mapper namespace="com.example.duplicate.infrastructure.dao.MidMapper">
<select id="getMid" resultType="java.lang.String">
SELECT

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.duplicate.infrastructure.configOneDao.QualityMapper" >
<mapper namespace="com.example.duplicate.infrastructure.dao.QualityMapper" >
<insert id="addPh" parameterType="java.util.List">
insert into ph (ph
)

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.duplicate.infrastructure.configTwoDao.MessageLogTwoMapper">
<insert id="addAll">
insert into message_log (id,create_time,end_time,execution_time,input_content,
interface_name,out_content,out_json,remark,result,type,xml_create_time,xml_execution_time,
master_id,webservice_info)
values
<foreach collection="list" item="item" separator=",">(#{item.id},#{item.createTime},#{item.endTime},
#{item.executionTime},#{item.inputContent},#{item.interfaceName},#{item.outContent},
#{item.outJson},#{item.remark},#{item.result},#{item.type},#{item.xmlCreateTime},#{item.xmlExecutionTime},
#{item.masterId},#{item.webserviceInfo}
)
</foreach>
</insert>
</mapper>

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.duplicate.infrastructure.configTwoDao.MessageSubordinateTwoMapper">
<insert id="addAll">
insert into message_subordinate (id,content_json,message_id,patient_main,status,remark,runs)
values
<foreach collection="list" item="item" separator=",">(#{item.id},#{item.contentJson},#{item.messageId},
#{item.patientMain},#{item.status},#{item.remark},#{item.runs}
)
</foreach>
</insert>
</mapper>

@ -4,97 +4,88 @@ package com.example;
import com.example.duplicate.controller.vo.Commomtable;
import com.example.duplicate.infrastructure.configOneDao.CommomtableMapper;
import com.example.duplicate.infrastructure.configOneDao.MidMapper;
import com.example.duplicate.infrastructure.configOneDao.QualityMapper;
import com.example.duplicate.infrastructure.dao.CommomtableMapper;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ofdrw.converter.ofdconverter.ImageConverter;
import org.ofdrw.layout.OFDDoc;
import org.ofdrw.layout.PageLayout;
import org.ofdrw.layout.element.Img;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.imageio.ImageIO;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = com.example.SpringbootDemoApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Slf4j
public class DemoApplicationTests {
@Autowired
private static CommomtableMapper commomtableMapper;
/* 日期解析工具 */
private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyyMMdd");
private static final String ROOT_DIR = "F:\\连州人民2期 已丢图像";
public static void main(String[] args) throws ParseException {
File root = new File("D:/tmp");
/* 2. 日期格式 */
private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyyMMdd");
File[] firstLevelFolders = root.listFiles(File::isDirectory);
if (firstLevelFolders == null) return;
public static void main(String[] args) throws Exception {
Files.walk(Paths.get(ROOT_DIR))
.filter(Files::isDirectory)
.filter(p -> !p.toString().equals(ROOT_DIR))
.forEach(p -> checkFolder(p.toFile()));
}
for (File folder : firstLevelFolders) {
List<Commomtable> batch = new ArrayList<>();
File[] subFolders = folder.listFiles(File::isDirectory);
if (subFolders == null) continue;
private static void checkFolder(File dir) {
String name = dir.getName();
if (!name.contains("-")) return;
for (int i = 0; i < subFolders.length; i++) {
File sub = subFolders[i];
String[] p = sub.getName().split("-", -1);
String[] p = name.split("-", -1);
StringBuilder err = new StringBuilder();
Commomtable c = new Commomtable();
c.setPatientId(new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS").format(new java.util.Date())+ String.format("%03d", i));
c.setInpatientNo(seg(p, 0));
c.setAdmissTimes(seg(p, 1));
c.setName(seg(p, 2));
c.setDisDate(parseDate(seg(p, 3)));
c.setDisDept(seg(p, 4));
c.setOldInpatientNo(seg(p, 5));
c.setFilePath(sub.getAbsolutePath());
/* 0. 参数个数 */
if (p.length != 7) {
err.append("参数个数=").append(p.length).append("应为7");
// 长度不足直接报,后面不再校验
System.out.println("【不合规】" + dir + " 原因:" + err);
return;
}
batch.add(c);
/* 1. 顺序反病案号≤3位 且 住院次数≥5位 */
if (p[1].matches("\\d{1,3}") && p[2].matches("\\d{5,}")) {
err.append("病案号与住院次数位置反病案号≤3位且住院次数≥5位");
}
/* 模拟批量新增:这里只是打印,实际可调用 Mapper/DAO 批量插入 */
System.out.println(">>> 准备批量插入一级文件夹:" + folder.getName()
+ ",共 " + batch.size() + " 条");
batch.forEach(System.out::println);
// TODO: 调用 service.batchInsert(batch);
File newDir = new File(folder.getParent(), folder.getName() + "-1");
/* 2. 基本格式校验(允许 数字 | 无 | - | 空串) */
if (!p[0].matches("^(\\d+|无|-)?$")) err.append("盘号格式错误;");
if (!p[1].matches("^(\\d+|无|-)?$")) err.append("病案号格式错误;");
if (!p[2].matches("^(\\d+|无|-)?$")) err.append("住院次数格式错误;");
/* 3. 日期yyyyMMdd 或 无/- */
if (!p[4].matches("(\\d{8}|无|-)")) {
// 如果是纯数字但长度不对 → 格式错
if (p[4].matches("\\d+") && p[4].length() != 8) {
err.append("出院日期格式错误;");
} else if (!p[4].equals("无") && !p[4].equals("-")) {
// 非数字、非无、非- → 格式错
err.append("出院日期格式错误;");
}
}
/* 辅助:缺段补“无” */
private static String seg(String[] arr, int i) {
return i < arr.length && !arr[i].isEmpty() ? arr[i] : "无";
/* 4. 旧病案号:数字 或 无/- */
/* 旧病案号:数字 | 无 | - | 空串 */
if (!p[6].matches("^(\\d+|无|-|)$")) {
err.append("旧病案号格式错误;");
}
/* 辅助:解析日期,失败给 null */
private static Date parseDate(String src) {
if ("无".equals(src)) return null;
try {
return SDF.parse(src);
} catch (ParseException e) {
return null;
/* 5. 输出结果 */
if (err.length() > 0) {
log.info("【不合规】" + dir + " 原因:" + err);
}
}
}

Loading…
Cancel
Save