初始化

master
linjj 4 months ago
commit 2c35ee79f5

@ -0,0 +1,11 @@
springboot项目集成工具
mvc
mybatis-plus
mybatis-plus分页
springTest
logback日志
全局异常
knife4j API界面
druid数据库监控界面
redis
拦截器

@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>collector-gm</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springbootDemo</name>
<description>springbootDemo</description>
<properties>
<java.version>1.8</java.version>
<skipTests>true</skipTests>
<mybatisPlus.version>3.4.1</mybatisPlus.version>
<alibabadruid.version>1.2.1</alibabadruid.version>
<knife4j.version>2.0.9</knife4j.version>
<fastjson.version>2.0.11</fastjson.version>
<commons-pool2.version>2.6.0</commons-pool2.version>
<itext.version>2.1.7</itext.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!--mybatis-plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatisPlus.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>${mybatisPlus.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<!--druid监控-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${alibabadruid.version}</version>
</dependency>
<!-- swaggerui相关依赖 -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j.version}</version>
</dependency>
<!-- Jackson Json处理工具包 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!-- redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- spring2.X集成redis所需common-pool2-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>${commons-pool2.version}</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt.runtime.3_7_1</groupId>
<artifactId>com.lowagie.text</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.10</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>wsjz-releases</id>
<name>Releases Repository</name>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>wsjz-snapshots</id>
<name>Snapshot Repository</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,19 @@
package com.example;
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.annotation.ComponentScan;
@SpringBootApplication
@MapperScan("com.example.duplicate.infrastructure.dao")
@Slf4j
public class SpringbootDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootDemoApplication.class, args);
log.info("------------------启动完成----------------------");
}
}

@ -0,0 +1,57 @@
package com.example.aother.annotation.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import java.util.ArrayList;
import java.util.List;
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {
/**
* controller
*/
String controllerPackagePath = "com.example";
@Bean(value = "defaultApi2")
public Docket defaultApi2() {
List<Parameter> pars = new ArrayList<>();
ParameterBuilder tokenPar = new ParameterBuilder();
tokenPar.name("token")
.description("用户token")
.defaultValue("")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(false)
.build();
pars.add(tokenPar.build());
//添加head参数end
Docket docket=new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder()
//.title("swagger-bootstrap-ui-demo RESTful APIs")
.description("# swagger-bootstrap-ui-demo RESTful APIs")
.termsOfServiceUrl("www.codeleader.top")
.version("1.0")
.build())
.globalOperationParameters(pars)
//分组名称
.groupName("2.X版本")
.select()
//这里指定Controller扫描包路径
.apis(RequestHandlerSelectors.basePackage(controllerPackagePath))
.paths(PathSelectors.any())
.build();
return docket;
}
}

@ -0,0 +1,27 @@
package com.example.aother.annotation.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisPlusConfig{
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
paginationInnerInterceptor.setDbType(DbType.MYSQL);
paginationInnerInterceptor.setOverflow(true);
interceptor.addInnerInterceptor(paginationInnerInterceptor);
OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor = new OptimisticLockerInnerInterceptor();
interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor);
return interceptor;
}
}

@ -0,0 +1,42 @@
package com.example.aother.annotation.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisConfig {
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory);
//Json序列化器
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
jackson2JsonRedisSerializer.setObjectMapper(om);
//String序列化器
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
//key采用String序列化器
template.setKeySerializer(stringRedisSerializer);
template.setHashKeySerializer(stringRedisSerializer);
//value采用Json序列化器
template.setValueSerializer(jackson2JsonRedisSerializer);
template.setHashValueSerializer(jackson2JsonRedisSerializer);
template.afterPropertiesSet();
return template;
}
}

@ -0,0 +1,4 @@
package com.example.aother.annotation.exception;
public class Package {
}

@ -0,0 +1,4 @@
package com.example.aother.common;
public class Package {
}

@ -0,0 +1,226 @@
package com.example.duplicate.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.duplicate.controller.param.UploadBatchFileParam;
import com.example.duplicate.controller.param.updateTaskDto;
import com.example.duplicate.controller.param.FileUpload;
import com.example.duplicate.service.TaskService;
import com.example.utils.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @ClassName TaskController
* @Description
* @Author linjj
* @Date 2024/8/5 14:21
* @Version 1.0
*/
@RestController
@RequestMapping("/task")
@Api(value = "任务接口", tags = "任务对外接口")
@Slf4j
public class TaskController {
@Autowired
private TaskService taskService;
/**
* @description:
* @params: collectid
* @return: data
* @author linjj
* @date: 2024/8/5 14:46
*/
@PostMapping("/getTask")
@ApiOperation("获取任务接口")
@ResponseBody
public CommonResult<?> GetTask(@RequestParam @ApiParam(required = false, name = "collectId", value = "采集器id") String collectId) {
return taskService.GetTask(collectId);
}
/**
* @description:
* @params: masterId
* @return: data
* @author linjj
* @date: 2024/8/5 15:31
*/
//补偿接口
@PostMapping(value = "repairTask")
@ApiOperation("补偿患者所有采集任务接口")
@ResponseBody
public CommonResult<?> repairTask(@RequestParam @ApiParam(required = false, name = "masterId", value = "患者masterId") String masterId) {
if (StringUtils.isBlank(masterId)) {
return CommonResult.failed("masterId不能为空");
}
return taskService.repairTask(masterId);
}
/**
* @description:
* @params: masterId
* @params: collectId
* @return: CommonResult
* @author linjj
* @date: 2024/8/6 9:15
*/
@PostMapping(value = "repairTaskByCollectId")
@ApiOperation("补偿患者单个采集任务接口")
@ResponseBody
public CommonResult<?> repairTask(@RequestParam @ApiParam(required = false, name = "masterId", value = "患者masterId") String masterId,
@RequestParam @ApiParam(required = false, name = "collectId", value = "采集器id") String collectId) {
if (StringUtils.isBlank(masterId)) {
return CommonResult.failed("masterId不能为空");
}
if (StringUtils.isBlank(collectId)) {
return CommonResult.failed("collectId不能为空");
}
return taskService.repairTaskByCollectId(masterId, collectId);
}
/**
* @description: idid
* @params: masterId
* @params: collectId
* @author linjj
* @date: 2024/12/26 14:30
*/
@PostMapping(value = "delFileBySource")
@ApiOperation("根据采集器id患者id删除单据")
@ResponseBody
public CommonResult<?> delFileBySource(@RequestParam @ApiParam(required = false, name = "masterId", value = "患者masterId") String masterId,
@RequestParam @ApiParam(required = false, name = "collectId", value = "采集器id") String collectId) {
if (StringUtils.isBlank(masterId)) {
return CommonResult.failed("masterId不能为空");
}
if (StringUtils.isBlank(collectId)) {
return CommonResult.failed("collectId不能为空");
}
return taskService.delFileBySource(masterId,collectId);
}
/**
* @description:
* @params: updateTaskDto
* @return: CommonResult
* @author linjj
* @date: 2024/8/6 9:17
*/
@PostMapping(value = "updateTask")
@ApiOperation("维护任务表接口")
@ResponseBody
public CommonResult<?> updateTask(updateTaskDto dto) {
return taskService.updateTask(dto);
}
/**
* @description:
* @params: files
* @params: uploadBatchFileParam
* @return: CommonResult
* @author linjj
* @date: 2024/8/6 14:13
*/
@PostMapping(value = "fileUpload")
@ApiOperation("文件上传接口")
@ResponseBody
public CommonResult<?> fileUpload(@RequestPart("files") MultipartFile[] files, UploadBatchFileParam uploadBatchFileParam) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = dateFormat.format(new Date());
//成功流水号id
List<String> serialNumberIds = new ArrayList<>();
//失败流水号id
List<String> failIds = new ArrayList<>();
if (Objects.isNull(uploadBatchFileParam) || Objects.isNull(uploadBatchFileParam.getUploadFileParams())) {
log.info(format + "文件上传参数为空!");
return CommonResult.failed("文件上传参数为空!");
}
log.info(format + "本次文件上传传输参数为:" + JSONObject.toJSONString(uploadBatchFileParam));
List<FileUpload> fileUpload = JSONArray.parseArray(uploadBatchFileParam.getUploadFileParams(), FileUpload.class);
for (FileUpload dto : fileUpload) {
if (StringUtils.isBlank(dto.getMasterid())) {
log.info(format + "病案主键不能为空!");
return CommonResult.failed("病案主键不能为空");
}
if (StringUtils.isBlank(dto.getAssortid())) {
log.info(format + "文件分段id不能为空");
return CommonResult.failed("文件分段id不能为空");
}
if (StringUtils.isBlank(dto.getSource())) {
log.info(format + "文件来源不能为空!");
return CommonResult.failed("文件来源不能为空");
}
if (StringUtils.isBlank(dto.getSubassort())) {
log.info(format + "文件MD5码不能为空不能为空");
return CommonResult.failed("文件MD5码不能为空不能为空");
}
if (StringUtils.isBlank(dto.getTitle())) {
log.info(format + "保存数据库文件名不能为空!");
return CommonResult.failed("保存数据库文件名不能为空");
}
if (StringUtils.isBlank(dto.getFileName())) {
log.info(format + "真实文件名不能为空!");
return CommonResult.failed("真实文件名不能为空");
}
if (StringUtils.isBlank(dto.getSerialNumber())) {
log.info(format + "文件MD5码不能为空不能为空");
return CommonResult.failed("文件MD5码不能为空不能为空");
}
}
if (fileUpload.size() != files.length) {
log.info(format + "文件上传参数为空!");
return CommonResult.failed("文件上传数量与参数不一致");
}
// 参数不含上传的,不匹配
List<String> originalFileNames = fileUpload.stream().map(item -> String.valueOf(item.getFileName())).collect(Collectors.toList());
for (MultipartFile file : files) {
if (!originalFileNames.contains(file.getOriginalFilename())) {
log.info(format + "文件上传参数为空!");
return CommonResult.failed("原文件名不匹配!");
}
}
for (MultipartFile file : files) {
for (FileUpload uploadFileParam : fileUpload) {
if (uploadFileParam.getFileName().equals(file.getOriginalFilename())) {
if (taskService.fileUpload(file, uploadFileParam)) {
serialNumberIds.add(uploadFileParam.getSubassort());
} else {
failIds.add(uploadFileParam.getSubassort());
}
}
}
}
log.info("本次文件上传传输完成,成功流水号:" + JSONObject.toJSONString(serialNumberIds));
log.info("本次文件上传传输完成,失败流水号:" + JSONObject.toJSONString(failIds));
return CommonResult.success("本次文件上传传输完成");
}
/**
* @description: 7
* @author linjj
* @date: 2024/8/19 4:32
*/
@PostMapping(value = "compensate")
@ApiOperation("补偿7月份后医嘱历史病历")
@ResponseBody
public CommonResult<?> compensate() {
taskService.compensate();
return CommonResult.success("补偿完成");
}
}

@ -0,0 +1,33 @@
package com.example.duplicate.controller.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ArchiveDetailDto {
private String id;
//文件路径
private String pdfPath;
//主键id
private String masterid;
//更新时间
private String uploaddatetime;
//更新时间
private String assortid;
//文件来源
private String source;
//分段信息
private String subassort;
//标题
private String title;
//标识
private String flag;
//标识
private String sys;
//文件唯一id
private String serialNumber;
//扩展字段
private String C1;
}

@ -0,0 +1,41 @@
package com.example.duplicate.controller.param;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @description: ArchiveOtherExtDto
* @author linjj
* @date: 2024/8/5 9:21
*/
@Data
public class ArchiveOtherExtDto implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "病案主键")
@TableId(value = "patient_id", type = IdType.ASSIGN_ID)
private Long id;
//更新时间
private String SycTime;
//任务id
private String otherID;
//采集器标识
private Integer sysFlag;
//个更新时间
private String sysUpdateTime;
//记帐号
private String jzh;
//住院号
private String zyh;
//标识
private Integer statusFlag;
//主键id
private String MID;
//扩展字段
private String C1;
}

@ -0,0 +1,30 @@
package com.example.duplicate.controller.param;
import lombok.Data;
/**
* @description:
* @author linjj
* @date: 2024/8/6 14:17
*/
@Data
public class FileUpload {
//主键id
private String masterid;
//分类id
private String assortid;
//来源
private String source;
//文件MD5码
private String subassort;
//标题
private String title;
//文件名
private String fileName;
//文件MD5码
private String SerialNumber;
//采集器id标识
private String C1;
}

@ -0,0 +1,28 @@
package com.example.duplicate.controller.param;
import com.example.duplicate.controller.vo.ArchiveMasterVo;
import lombok.Data;
/**
* @description:
* @author linjj
* @date: 2024/8/2 16:45
*/
@Data
public class PrintParam {
private String id;
//住院号
private String inpNo;
//住院次数
private String visitId;
//患者姓名
private String name;
//出院科室
private String deptName;
//出院时间
private String dischargeDateTime;
//住院时间
private String admissionDateTime;
}

@ -0,0 +1,11 @@
package com.example.duplicate.controller.param;
import lombok.Data;
@Data
public class UploadBatchFileParam {
private String uploadFileParams;
}

@ -0,0 +1,32 @@
package com.example.duplicate.controller.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName updateTaskDto
* @Description
* @Author linjj
* @Date 2024/3/8 11:10
* @Version 1.0
*/
@Data
public class updateTaskDto {
@ApiModelProperty(value="主键id",name="mid", required=true)
private String mid;
@ApiModelProperty(value="患者信息",name="sycObj", required=true)
private String sycObj;
@ApiModelProperty(value="任务状态",name="statusFlag", required=true)
private int statusFlag;
@ApiModelProperty(value="采集器id",name="sysFlag", required=true)
private int sysFlag;
@ApiModelProperty(value="开始时间",name="startTime", required=true)
private String startTime;
@ApiModelProperty(value="结束时间",name="endTime", required=true)
private String endTime;
@ApiModelProperty(value="备注",name="pinResult", required=true)
private String pinResult;
}

@ -0,0 +1,31 @@
package com.example.duplicate.controller.vo;
import lombok.Data;
/**
* @ClassName ArchiveMasterVo
* @Description
* @Author linjj
* @Date 2024/8/2 15:59
* @Version 1.0
*/
@Data
public class ArchiveMasterVo {
private String id;
//住院号
private String inpNo;
//住院次数
private String visitId;
//记帐号
private String patientId;
//出院科室
private String deptName;
//出院时间
private String dischargeDateTime;
//患者姓名
private String name;
//住院时间
private String admissionDateTime;
}

@ -0,0 +1,85 @@
package com.example.duplicate.controller.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @description:
* @author linjj
* @date: 2024/8/5 9:09
*/
@Data
public class ArchiveOtherExtVo {
@ApiModelProperty(value = "病案主键")
@TableId(value = "patient_id", type = IdType.ASSIGN_ID)
private Long id;
private Date syctime;
private String sycobj;
private Long otherid;
private Integer sysflag;
private Date sysupdatetime;
private String jzh;
private String zyh;
private Date stime;
private Date etime;
private Integer statusflag;
private String presult;
private String mid;
private String did;
private String c1;
private String c2;
private String c3;
private String c4;
private String c5;
private String c6;
private String c7;
private String c8;
private String c9;
private String c10;
private BigDecimal n1;
private BigDecimal n2;
private BigDecimal n3;
private Date t1;
private Date t2;
private Date t3;
private Date t4;
private Date t5;
private Date t6;
}

@ -0,0 +1,4 @@
package com.example.duplicate.infrastructure;
public class Package {
}

@ -0,0 +1,29 @@
package com.example.duplicate.infrastructure.dao;
import com.example.duplicate.controller.param.ArchiveDetailDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @InterfaceName ArchiveDetailMapper
* @Description
* @Author linjj
* @Date 2024/8/6 14:29
* @Version 1.0
*/
@Mapper
public interface ArchiveDetailMapper {
List<ArchiveDetailDto> getDetailBySerialNumber(String serialNumber);
boolean deleteByPrimaryKey(String id);
boolean delFileBySource(@Param("masterId")String masterId,@Param("collectId")String collectId);
boolean insertSel(ArchiveDetailDto record);
}

@ -0,0 +1,23 @@
package com.example.duplicate.infrastructure.dao;
import com.example.duplicate.controller.vo.ArchiveMasterVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @InterfaceName Archive_master
* @Author linjj
* @Date 2024/8/2 15:54
* @Version 1.0
*/
@Mapper
public interface ArchiveMasterMapper {
//轮询根据时间获取患者信息
List<ArchiveMasterVo> getMedicalAdviceTask();
//根据masterId获取患者信息
List<ArchiveMasterVo> getArchiveMasterByMasterId(@Param("masterId")String masterId);
List<String> getMasterid();
}

@ -0,0 +1,30 @@
package com.example.duplicate.infrastructure.dao;
import com.example.duplicate.controller.param.ArchiveOtherExtDto;
import com.example.duplicate.controller.param.updateTaskDto;
import com.example.duplicate.controller.vo.ArchiveOtherExtVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @InterfaceName ArchiveOtherExtMapper
* @Description
* @Author linjj
* @Date 2024/8/5 8:52
* @Version 1.0
*/
@Mapper
public interface ArchiveOtherExtMapper {
List<ArchiveOtherExtVo> getOtherByMidAndFlag(@Param("mid")String mid, @Param("sysFlag")int sysFlag);
Boolean addOther(ArchiveOtherExtDto archiveOtherExtDto);
Boolean updateByMid(updateTaskDto dto);
Boolean updateStatic(@Param("mid")String mid, @Param("sysFlag")String sysFlag);
}

@ -0,0 +1,21 @@
package com.example.duplicate.service;
import com.example.utils.CommonResult;
/**
* @InterfaceName MedicalAdviceService
* @Description
* @Author linjj
* @Date 2024/8/2 15:47
* @Version 1.0
*/
public interface MedicalAdviceService {
/**
* @description:
* @author linjj
* @date: 2024/8/2 15:52
*/
CommonResult<?> pollingAddTask();
}

@ -0,0 +1,73 @@
package com.example.duplicate.service;
import com.example.duplicate.controller.param.updateTaskDto;
import com.example.duplicate.controller.param.FileUpload;
import com.example.utils.CommonResult;
import org.springframework.web.multipart.MultipartFile;
/**
* @InterfaceName TaskService
* @Description
* @Author linjj
* @Date 2024/8/5 14:44
* @Version 1.0
*/
public interface TaskService {
/**
* @description:
* @params: collectId
* @return: CommonResult
* @author linjj
* @date: 2024/8/5 14:41
*/
CommonResult GetTask(String collectId);
/**
* @description:
* @params: masterId
* @return: CommonResult
* @author linjj
* @date: 2024/8/5 15:32
*/
CommonResult repairTask(String masterId);
/**
* @description:
* @params: masterId
* @params: collectId
* @return: CommonResult
* @author linjj
* @date: 2024/8/5 17:25
*/
CommonResult repairTaskByCollectId(String masterId,String collectId);
/**
* @description: idid
* @params: masterId
* @params: collectId
* @author linjj
* @date: 2024/12/26 14:32
*/
CommonResult delFileBySource(String masterId,String collectId);
/**
* @description:
* @params: updateTaskDto
* @return: CommonResult
* @author linjj
* @date: 2024/8/6 9:27
*/
CommonResult updateTask(updateTaskDto dto);
/**
* @description:
* @params: file
* @params: FileUpload
* @return: Boolean
* @author linjj
* @date: 2024/8/6 14:22
*/
Boolean fileUpload(MultipartFile file, FileUpload dto);
/**
* @description: 7
* @author linjj
* @date: 2024/8/19 4:32
*/
CommonResult compensate();
}

@ -0,0 +1,118 @@
package com.example.duplicate.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.example.duplicate.controller.param.ArchiveOtherExtDto;
import com.example.duplicate.controller.param.PrintParam;
import com.example.duplicate.controller.vo.ArchiveMasterVo;
import com.example.duplicate.controller.vo.ArchiveOtherExtVo;
import com.example.duplicate.infrastructure.dao.ArchiveMasterMapper;
import com.example.duplicate.infrastructure.dao.ArchiveOtherExtMapper;
import com.example.duplicate.service.MedicalAdviceService;
import com.example.utils.CommonResult;
import com.example.utils.RedisMq;
import com.example.utils.SnowflakeIdWorker;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @ClassName MedicalAdviceServiceImpl
* @Description
* @Author linjj
* @Date 2024/8/2 15:48
* @Version 1.0
*/
@Service
@Slf4j
public class MedicalAdviceServiceImpl implements MedicalAdviceService {
@Value("${collectIdList}")
private String collectIdList;
@Autowired
private ArchiveMasterMapper ArchiveMasterMapper;
@Autowired
private ArchiveOtherExtMapper archiveOtherExtMapper;
@Autowired(required = false)
private RedisMq redisMq;
private String redisKey = "docus:task:topic_collect_%s_queue:%s";
@Override
public CommonResult<?> pollingAddTask() {
//获取当前30分钟前出院病历生成医嘱任务
List<ArchiveMasterVo> medicalAdviceTask = ArchiveMasterMapper.getMedicalAdviceTask();
if (CollectionUtils.isEmpty(medicalAdviceTask)) {
log.info("当前没有需要生成任务的病历");
return CommonResult.failed("当前没有需要生成任务的病历");
}
PrintParam printParam = new PrintParam();
//任务表入参
ArchiveOtherExtDto dto = new ArchiveOtherExtDto();
//任务生成时间
Date date = new Date();
SimpleDateFormat SycTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//补偿所有采集器id集合
List<String> collectIds = Arrays.asList(collectIdList.split(","));
//生成任务
for (ArchiveMasterVo tasks : medicalAdviceTask) {
//增加所有采集id的任务
for (String collectId : collectIds) {
try {
//查询任务表是否存在,不存在新增
List<ArchiveOtherExtVo> others = archiveOtherExtMapper.getOtherByMidAndFlag(tasks.getId(), Integer.parseInt(collectId));
if (CollectionUtils.isEmpty(others)) {
//任务表新增
dto.setId(SnowflakeIdWorker.idWorker.nextId());
dto.setSycTime(SycTime.format(date));
dto.setOtherID("0");
dto.setSysFlag(Integer.parseInt(collectId));
dto.setSysUpdateTime(SycTime.format(date));
dto.setJzh(tasks.getPatientId());
dto.setZyh(tasks.getInpNo());
dto.setStatusFlag(0);
dto.setMID(tasks.getId());
if (collectId.equals("8")){
dto.setC1("长临医嘱");
}
if (collectId.equals("1")){
dto.setC1("护理记录");
}
//任务表新增任务
if (archiveOtherExtMapper.addOther(dto)) {
//存放队列消息
GenerateQueue(tasks, printParam, 5, collectId);
log.info("轮询增加任务成功,id为:" + tasks.getId());
}
}
} catch (Exception e) {
log.error("轮询增加任务失败,id为:" + tasks.getId(), e);
}
}
}
return CommonResult.success("轮询完成已经增加任务");
}
//生成队列消息
private void GenerateQueue(ArchiveMasterVo task, PrintParam data, Integer ispriority, String collectid) {
data.setId(task.getId());
data.setInpNo(task.getInpNo());
data.setVisitId(task.getVisitId());
data.setDeptName(task.getDeptName());
data.setDischargeDateTime(task.getDischargeDateTime());
data.setName(task.getName());
data.setAdmissionDateTime(task.getAdmissionDateTime());
String key = String.format(redisKey, collectid, ispriority);
redisMq.push(key, JSON.toJSONString(data, SerializerFeature.WriteDateUseDateFormat, SerializerFeature.WriteMapNullValue));
}
}

@ -0,0 +1,308 @@
package com.example.duplicate.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.example.duplicate.controller.param.*;
import com.example.duplicate.controller.vo.ArchiveMasterVo;
import com.example.duplicate.controller.vo.ArchiveOtherExtVo;
import com.example.duplicate.infrastructure.dao.ArchiveDetailMapper;
import com.example.duplicate.infrastructure.dao.ArchiveMasterMapper;
import com.example.duplicate.infrastructure.dao.ArchiveOtherExtMapper;
import com.example.duplicate.service.TaskService;
import com.example.utils.CommonResult;
import com.example.utils.RedisMq;
import com.example.utils.SnowflakeIdWorker;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @ClassName TaskServiceImpl
* @Description
* @Author linjj
* @Date 2024/8/5 14:44
* @Version 1.0
*/
@Service
@Slf4j
public class TaskServiceImpl implements TaskService {
@Autowired(required = false)
private RedisMq redisMq;
private String redisKey = "docus:task:topic_collect_%s_queue:%s";
@Value("${repairCollectIds}")
private String repairCollectIds;
@Autowired
private ArchiveMasterMapper archiveMasterMapper;
@Autowired
private ArchiveOtherExtMapper archiveOtherExtMapper;
@Autowired
private ArchiveDetailMapper archiveDetailMapper;
@Autowired
private TaskService taskService;
@Value("${savePath}")
private String savePath;
@Override
public CommonResult GetTask(String collectId) {
String message = "";
for (int i = 10; i >= 1; i--) {
String key = String.format(redisKey, collectId, i);
message = redisMq.pop(key);
if (!StringUtils.isEmpty(message) && !message.equals("null")) {
break;
}
}
if (StringUtils.isEmpty(message) || message.equals("null")) {
return CommonResult.failed("暂无队列数据");
} else {
PrintParam data = JSON.parseObject(message, PrintParam.class);
log.info("采集器id为" + collectId + "的队列消费信息:" + data);
return CommonResult.success(data);
}
}
@Override
public CommonResult repairTask(String masterId) {
PrintParam printParam = new PrintParam();
//任务表入参
ArchiveOtherExtDto dto = new ArchiveOtherExtDto();
//任务生成时间
Date date = new Date();
SimpleDateFormat SycTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//补偿所有采集器id集合
List<String> collectIds = Arrays.asList(repairCollectIds.split(","));
//获取当前患者基础信息
List<ArchiveMasterVo> archiveMasters = archiveMasterMapper.getArchiveMasterByMasterId(masterId);
if (CollectionUtils.isEmpty(archiveMasters)) {
log.info("补偿所有采集查询不到masterId为:" + masterId + "的患者住院信息补偿失败");
return CommonResult.failed("补偿所有采集查询不到masterId为:" + masterId + "的患者住院信息补偿失败");
}
for (String collectId : collectIds) {
try {
//查询当前患者要补偿采集器是否存在任务,不存在时新增任务
List<ArchiveOtherExtVo> others = archiveOtherExtMapper.getOtherByMidAndFlag(archiveMasters.get(0).getId(), Integer.parseInt(collectId));
if (CollectionUtils.isEmpty(others)) {
//任务表新增
dto.setId(SnowflakeIdWorker.idWorker.nextId());
dto.setSycTime(SycTime.format(date));
dto.setOtherID("0");
dto.setSysFlag(Integer.parseInt(collectId));
dto.setSysUpdateTime(SycTime.format(date));
dto.setJzh(archiveMasters.get(0).getPatientId());
dto.setZyh(archiveMasters.get(0).getInpNo());
dto.setStatusFlag(0);
dto.setMID(archiveMasters.get(0).getId());
if (collectId.equals("8")) {
dto.setC1("长临医嘱");
}
if (collectId.equals("1")) {
dto.setC1("护理记录");
}
archiveOtherExtMapper.addOther(dto);
}
GenerateQueue(archiveMasters.get(0), printParam, 10, collectId);
} catch (Exception e) {
log.error("masterId为:" + masterId + "的患者补偿所有采集器失败", e.getMessage(), e);
}
}
log.info("masterId为:" + masterId + "的患者所有采集器补偿成功");
return CommonResult.success("masterId为:" + masterId + "的患者所有采集器补偿成功");
}
@Override
public CommonResult repairTaskByCollectId(String masterId, String collectId) {
PrintParam printParam = new PrintParam();
//任务表入参
ArchiveOtherExtDto dto = new ArchiveOtherExtDto();
//任务生成时间
Date date = new Date();
SimpleDateFormat SycTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//获取当前患者基础信息
List<ArchiveMasterVo> archiveMasters = archiveMasterMapper.getArchiveMasterByMasterId(masterId);
if (CollectionUtils.isEmpty(archiveMasters)) {
log.info("补偿单个查询不到masterId为:" + masterId + "的患者住院信息补偿失败");
return CommonResult.failed("补偿单个查询不到masterId为:" + masterId + "的患者住院信息补偿失败");
}
//查询任务表数据是否存在不存在时任务表新增存在时将任务状态改为0
List<ArchiveOtherExtVo> others = archiveOtherExtMapper.getOtherByMidAndFlag(masterId, Integer.parseInt(collectId));
if (CollectionUtils.isEmpty(others)) {
//任务表新增
dto.setId(SnowflakeIdWorker.idWorker.nextId());
dto.setSycTime(SycTime.format(date));
dto.setOtherID("0");
dto.setSysFlag(Integer.parseInt(collectId));
dto.setSysUpdateTime(SycTime.format(date));
dto.setJzh(archiveMasters.get(0).getPatientId());
dto.setZyh(archiveMasters.get(0).getInpNo());
dto.setStatusFlag(0);
dto.setMID(archiveMasters.get(0).getId());
if (collectId.equals("8")) {
dto.setC1("长临医嘱");
}
if (collectId.equals("1")) {
dto.setC1("护理记录");
}
archiveOtherExtMapper.addOther(dto);
} else {
archiveOtherExtMapper.updateStatic(masterId, collectId);
}
GenerateQueue(archiveMasters.get(0), printParam, 10, collectId);
log.info("补偿患者单个采集器成功masterId为:" + masterId + "的患者住院信息补偿失败");
return CommonResult.success("补偿患者单个采集器成功");
}
@Override
public CommonResult delFileBySource(String masterId, String collectId) {
try {
//根据患者masterIdcollectId删除
boolean stactic = archiveDetailMapper.delFileBySource(masterId, collectId);
if (stactic) {
return CommonResult.success("删除成功,masterId:" + masterId);
}
} catch (Exception e) {
return CommonResult.failed("删除失败,masterId:" + masterId);
}
return CommonResult.failed("删除失败,masterId:" + masterId);
}
@Override
public CommonResult updateTask(updateTaskDto dto) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = dateFormat.format(new Date());
log.info(format + "本次维护任务表传输参数为:" + JSONObject.toJSONString(dto));
if (StringUtils.isBlank(dto.getMid())) {
log.info(format + "Mid不能为空");
log.info(dto.getMid());
return CommonResult.failed("Mid名不能为空");
}
if (StringUtils.isBlank(dto.getStartTime())) {
log.info(format + "开始时间不能为空!");
return CommonResult.failed("开始时间不能为空");
}
if (StringUtils.isBlank(dto.getEndTime())) {
log.info(format + "结束时间不能为空!");
return CommonResult.failed("结束时间不能为空");
}
if (StringUtils.isBlank(String.valueOf(dto.getStatusFlag()))) {
log.info(format + "任务状态不能为空!");
return CommonResult.failed("任务状态不能为空");
}
if (StringUtils.isBlank(dto.getSycObj())) {
log.info(format + "SycObj患者信息不能为空");
return CommonResult.failed("SycObj患者信息不能为空");
}
if (StringUtils.isBlank(dto.getPinResult())) {
log.info(format + "备注信息不能为空!");
return CommonResult.failed("备注信息不能为空");
}
if (StringUtils.isBlank(String.valueOf(dto.getSysFlag()))) {
log.info(format + "任务分类不能为空!");
return CommonResult.failed("任务分类不能为空");
}
if (archiveOtherExtMapper.updateByMid(dto)) {
return CommonResult.success("id为:" + dto.getMid() + "任务表维护成功");
}
return CommonResult.success("id为:" + dto.getMid() + "任务表维护失败");
}
@Override
public Boolean fileUpload(MultipartFile file, FileUpload dto) {
//使用yyyyMMddHHmmssSSS格式作为文件名
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String newDate = format.format(date);
//文件更新时间
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//文件保存目录
String filePathdir = savePath + File.separatorChar + dto.getMasterid();
File filePath = new File(filePathdir);
//判断文件夹是否存在不存在创建文件夹
if (!filePath.exists()) {
filePath.mkdirs();
}
//文件地址
String saveFilePath = filePathdir + File.separatorChar + newDate + ".pdf";
try {
file.transferTo(new File(saveFilePath));
} catch (IOException e) {
log.info("保存文件失败流水号:" + dto.getSubassort());
return false;
}
try {
//判断文件表是否存在流水号存则更新
List<ArchiveDetailDto> archiveDetailList = archiveDetailMapper.getDetailBySerialNumber(dto.getSubassort());
if (!CollectionUtils.isEmpty(archiveDetailList)) {
for (ArchiveDetailDto details : archiveDetailList) {
//存在删除对应记录
if (archiveDetailMapper.deleteByPrimaryKey(details.getId())) {
File file1 = new File(details.getPdfPath());
try {
file1.delete(); // 删除照片
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
//保存文件表
ArchiveDetailDto archiveDetail = new ArchiveDetailDto();
archiveDetail.setId(newDate);
archiveDetail.setPdfPath(saveFilePath);
archiveDetail.setMasterid(dto.getMasterid());
archiveDetail.setUploaddatetime(dateFormat.format(new Date()));
archiveDetail.setAssortid(dto.getAssortid());
archiveDetail.setSource(dto.getSource());
archiveDetail.setSubassort(dto.getSubassort());
archiveDetail.setTitle(dto.getTitle());
archiveDetail.setFlag("0");
archiveDetail.setC1(dto.getC1());
if (archiveDetailMapper.insertSel(archiveDetail)) {
return true;
}
} catch (Exception e) {
return false;
}
return false;
}
@Override
public CommonResult compensate() {
//查询所有需要补偿患者id
List<String> ids = archiveMasterMapper.getMasterid();
for (String id : ids) {
taskService.repairTask(id);
}
return CommonResult.success("补偿7月份患者医嘱成功");
}
//生成队列消息
private void GenerateQueue(ArchiveMasterVo task, PrintParam data, Integer ispriority, String collectid) {
data.setId(task.getId());
data.setInpNo(task.getInpNo());
data.setVisitId(task.getVisitId());
data.setDeptName(task.getDeptName());
data.setDischargeDateTime(task.getDischargeDateTime());
data.setName(task.getName());
data.setAdmissionDateTime(task.getAdmissionDateTime());
String key = String.format(redisKey, collectid, ispriority);
redisMq.push(key, JSON.toJSONString(data, SerializerFeature.WriteDateUseDateFormat, SerializerFeature.WriteMapNullValue));
}
}

@ -0,0 +1,37 @@
package com.example.quartz;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @ClassName CollectorConfig
* @Description
* @Author linjj
* @Date 2024/8/2 14:45
* @Version 1.0
*/
@Configuration
public class CollectorConfig {
@Value("${medicalAdviceTime}")
private String medicalAdviceTime;
@Bean
public JobDetail MedicalAdvice() {
return JobBuilder.newJob(MedicalAdviceQuartz.class).withIdentity("MedicalAdviceQuartz").storeDurably().build();
}
@Bean
public Trigger pacsPushTrigger() {
return TriggerBuilder.newTrigger().forJob(MedicalAdvice())
.withIdentity("MedicalAdviceQuartz")
.withSchedule(CronScheduleBuilder.cronSchedule(medicalAdviceTime))
.build();
}
}

@ -0,0 +1,28 @@
package com.example.quartz;
import com.example.duplicate.service.MedicalAdviceService;
import com.example.utils.CommonResult;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import javax.annotation.Resource;
/**
* @description:
* @author linjj
* @date: 2024/8/2 15:46
*/
public class MedicalAdviceQuartz extends QuartzJobBean {
@Resource
private MedicalAdviceService medicalAdviceService;
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) {
//每半小时轮询一次基础表增加任务
medicalAdviceService.pollingAddTask();
}
}

@ -0,0 +1,152 @@
package com.example.utils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* @author docus
* @date 2020/3/28 16:23
*/
@Data
@ApiModel("响应")
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> {
@ApiModelProperty("响应码")
private Integer code;
@ApiModelProperty("响应消息")
private String msg;
@ApiModelProperty("响应实体")
private T data;
public CommonResult(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
/**
*
*
* @param data
* @param <T>
* @return
*/
public static <T> CommonResult<T> success(T data) {
return new CommonResult<T>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data);
}
/**
*
*
* @param data
* @param message
* @param <T>
* @return
*/
public static <T> CommonResult<T> success(T data, String message) {
return new CommonResult<T>(ResultCode.SUCCESS.getCode(), message, data);
}
/**
*
*
* @param errorCode
* @param <T>
* @return
*/
public static <T> CommonResult<T> failed(IErrorCode errorCode) {
return new CommonResult<T>(errorCode.getCode(), errorCode.getMessage(), null);
}
/**
*
*
* @param errorCode
* @param message
* @param <T>
* @return
*/
public static <T> CommonResult<T> failed(IErrorCode errorCode, String message) {
return new CommonResult<T>(errorCode.getCode(), message, null);
}
/**
*
*
* @param message
* @param <T>
* @return
*/
public static <T> CommonResult<T> failed(String message) {
return new CommonResult<T>(ResultCode.FAILED.getCode(), message, null);
}
/**
*
*
* @param <T>
* @return
*/
public static <T> CommonResult<T> failed() {
return failed(ResultCode.FAILED);
}
/**
*
*
* @param <T>
* @return
*/
public static <T> CommonResult<T> validateFailed() {
return failed(ResultCode.VALIDATE_FAILED);
}
/**
*
*
* @param message
* @param <T>
* @return
*/
public static <T> CommonResult<T> validateFailed(String message) {
return new CommonResult<T>(ResultCode.VALIDATE_FAILED.getCode(), message, null);
}
/**
*
*
* @param data
* @param <T>
* @return
*/
public static <T> CommonResult<T> unauthorized(T data) {
return new CommonResult<T>(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getMessage(), data);
}
/**
*
*
* @param data
* @param <T>
* @return
*/
public static <T> CommonResult<T> preventreplay(T data) {
return new CommonResult<T>(ResultCode.PREVENT_REPLAY.getCode(), ResultCode.PREVENT_REPLAY.getMessage(), data);
}
/**
*
*
* @param data
* @param <T>
* @return
*/
public static <T> CommonResult<T> forbidden(T data) {
return new CommonResult<T>(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getMessage(), data);
}
}

@ -0,0 +1,12 @@
package com.example.utils;
/**
* @Description API
* @Author JacksonTu
* @Date 2020/3/28 16:26
*/
public interface IErrorCode {
Integer getCode();
String getMessage();
}

@ -0,0 +1,37 @@
package com.example.utils;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class IpUtil {
public static String getIp(HttpServletRequest request) {
String ipAddress = request.getHeader("x-forwarded-for");
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getHeader("Proxy-Client-IP");
}
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getHeader("WL-Proxy-Client-IP");
}
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getRemoteAddr();
if (ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")) {
//根据网卡取本机配置的IP
InetAddress inet = null;
try {
inet = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
ipAddress = inet.getHostAddress();
}
}
//对于通过多个代理的情况第一个IP为客户端真实IP,多个IP按照','分割
if (ipAddress != null && ipAddress.length() > 15) { //"***.***.***.***".length() = 15
if (ipAddress.indexOf(",") > 0) {
ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
}
}
return ipAddress;
}
}

@ -0,0 +1,21 @@
package com.example.utils;
import java.security.MessageDigest;
public class Md5Util {
public static String encrypt(String dataStr) {
try {
MessageDigest m = MessageDigest.getInstance("MD5");
m.update(dataStr.getBytes("UTF8"));
byte[] s = m.digest();
StringBuilder result = new StringBuilder();
for (int i = 0; i < s.length; i++) {
result.append(Integer.toHexString((0x000000FF & s[i]) | 0xFFFFFF00).substring(6));
}
return result.toString();
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
}

@ -0,0 +1,89 @@
package com.example.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class RedisMq {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private RedisTemplate redisTemplate;
/**
*
*
* @param message
*/
public void push(String messageKey, String message) {
String Key = messageKey;
stringRedisTemplate.opsForList().leftPush(Key, message);
}
public void deleteKey(String Key)
{
try {
redisTemplate.delete(Key);
} catch (Exception e) {
return;
}
}
public void deleteAllKey(List<String> ids)
{
try {
redisTemplate.delete(ids);
} catch (Exception e) {
return;
}
}
public void pushAll(String messageKey, List<String> messages) {
String Key = messageKey;
stringRedisTemplate.opsForList().leftPushAll(Key, messages);
}
/**
*
* @return
*/
public long size(String messageKey) {
String Key = messageKey;
try {
return stringRedisTemplate.opsForList().size(messageKey);
} catch (Exception e) {
return 0;
}
}
/**
* ,null
* rightPop1.key,2.3.
*
* @return
*/
public String pop(String messageKey) {
String Key = messageKey;
try {
return String.valueOf(stringRedisTemplate.opsForList().rightPop(Key));
} catch (Exception e) {
return null;
}
}
/**
* key
* @param messageKey
* @return
*/
public boolean IsExist(String messageKey){
return stringRedisTemplate.hasKey(messageKey);
}
}

@ -0,0 +1,42 @@
package com.example.utils;
/**
* @Description API
* @Author JacksonTu
* @Date 2020/3/28 16:26
*/
public enum ResultCode implements IErrorCode {
SUCCESS(0, "操作成功"),
FAILED(500, "操作失败"),
VALIDATE_FAILED(404, "参数检验失败"),
UNAUTHORIZED(401, "暂未登录或token已经过期"),
FORBIDDEN(403, "没有相关权限"),
PREVENT_REPLAY(405,"重复请求"),
NOT_EXIST(601,"数据不存在"),
NOT_ENABLE(600,"数据未启用");
private Integer code;
private String message;
private ResultCode(Integer code, String message) {
this.code = code;
this.message = message;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getMessage() {
return message;
}
}

@ -0,0 +1,142 @@
package com.example.utils;
public class SnowflakeIdWorker {
public static final SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
/**
* (2015-01-01)
*/
private final long twepoch = 1420041600000L;
/**
* id
*/
private final long workerIdBits = 5L;
/**
* id
*/
private final long datacenterIdBits = 5L;
/**
* id31 ()
*/
private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
/**
* id31
*/
private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
/**
* id
*/
private final long sequenceBits = 12L;
/**
* ID12
*/
private final long workerIdShift = sequenceBits;
/**
* id17(12+5)
*/
private final long datacenterIdShift = sequenceBits + workerIdBits;
/**
* 22(5+5+12)
*/
private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
/**
* 4095 (0b111111111111=0xfff=4095)
*/
private final long sequenceMask = -1L ^ (-1L << sequenceBits);
/**
* ID(0~31)
*/
private long workerId;
/**
* ID(0~31)
*/
private long datacenterId;
/**
* (0~4095)
*/
private long sequence = 0L;
/**
* ID
*/
private long lastTimestamp = -1L;
/**
*
* @param workerId ID (0~31)
* @param datacenterId ID (0~31)
*/
public SnowflakeIdWorker(long workerId, long datacenterId) {
if (workerId > maxWorkerId || workerId < 0) {
throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
}
if (datacenterId > maxDatacenterId || datacenterId < 0) {
throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
}
this.workerId = workerId;
this.datacenterId = datacenterId;
}
/**
* ID (线)
* @return SnowflakeId
*/
public synchronized long nextId() {
long timestamp = timeGen();
// 如果当前时间小于上一次ID生成的时间戳说明系统时钟回退过这个时候应当抛出异常
if (timestamp < lastTimestamp) {
throw new RuntimeException(
String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
}
// 如果是同一时间生成的,则进行毫秒内序列
if (lastTimestamp == timestamp) {
sequence = (sequence + 1) & sequenceMask;
// 毫秒内序列溢出
if (sequence == 0) {
//阻塞到下一个毫秒,获得新的时间戳
timestamp = tilNextMillis(lastTimestamp);
}
}
// 时间戳改变,毫秒内序列重置
else {
sequence = 0L;
}
// 上次生成ID的时间截
lastTimestamp = timestamp;
// 移位并通过或运算拼到一起组成64位的ID
return ((timestamp - twepoch) << timestampLeftShift) //
| (datacenterId << datacenterIdShift) //
| (workerId << workerIdShift) //
| sequence;
}
/**
*
* @param lastTimestamp ID
* @return
*/
protected long tilNextMillis(long lastTimestamp) {
long timestamp = timeGen();
while (timestamp <= lastTimestamp) {
timestamp = timeGen();
}
return timestamp;
}
/**
*
* @return ()
*/
protected long timeGen() {
return System.currentTimeMillis();
}
public static void main(String[] args) throws InterruptedException {
SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
for (int i = 0; i < 10; i++) {
long id = idWorker.nextId();
Thread.sleep(1);
System.out.println(id);
}
}
}

@ -0,0 +1,62 @@
server:
port: 8003
spring:
datasource:
url: jdbc:sqlserver://db.docus.cn:1433;DatabaseName=emr_record
username: sa
password: docus@702
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
type: com.alibaba.druid.pool.DruidDataSource
#加快springboot初始化延缓初始化加载
main:
lazy-initialization: true
#加快springboot初始化关闭jmx监控
jmx:
enabled: false
redis:
# Redis 服务器地址
host: redis.docus.cn
# host: 127.0.0.1
# 连接端口号
port: 6379
# #密码
# password: JSdocus@702
# 数据库索引0 - 15
database: 0
# 连接超时时间(毫秒)
timeout: 10000
# lettuce 参数
lettuce:
pool:
# 最大连接数(使用负值表示没有限制) 默认为 8
max-active: 10
# 最大阻塞等待时间(使用负值表示没有限制) 默认为 -1 ms
max-wait: -1
# 最大空闲连接 默认为 8
max-idle: 5
# 最小空闲连接 默认为 0
min-idle: 0
mybatis:
mapper-locations: classpath*:mapper/*Mapper.xml
type-aliases-package: com.example.entity
# 控制台打印sql语句
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
logging:
config: classpath:logback-spring.xml
level:
com.example.mapper: info
#定时轮速新增任务
medicalAdviceTime: 0 0/30 * * * ?
#medicalAdviceTime: 0/1 * * * * ?
#定时轮询时需要新增的采集标识
collectIdList: 1,8
#补偿时,需要补偿的采集器标识,可以支持多个使用逗号','隔开
repairCollectIds: 1,8
#文件保存地址
savePath: D:\reload

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>logback-spring.xml</contextName>
<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!--按天生成日志,即一天只生成一个文件夹和一个日志文件-->
<appender name="logFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<Prudent>true</Prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>
collector/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log
</FileNamePattern>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} -%msg%n
</Pattern>
</layout>
</appender>
<!-- logger节点可选节点作用是指明具体的包或类的日志输出级别
以及要使用的<appender>(可以把<appender>理解为一个日志模板)。
addtivity非必写属性是否向上级loger传递打印信息。默认是true-->
<logger name="com.framework.job" additivity="false">
<appender-ref ref="console"/>
<appender-ref ref="logFile"/>
</logger>
<!--项目的整体的日志打印级别为info-->
<root level="info">
<appender-ref ref="console"/>
<appender-ref ref="logFile"/>
</root>
</configuration>

@ -0,0 +1,89 @@
<?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.dao.ArchiveDetailMapper">
<insert id="insertSel">
insert into archive_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
id,
<if test="pdfPath != null">
PDF_PATH,
</if>
<if test="masterid != null">
MasterID,
</if>
<if test="uploaddatetime != null">
UpLoadDateTime,
</if>
<if test="assortid != null">
AssortID,
</if>
<if test="source != null">
Source,
</if>
<if test="subassort != null">
SubAssort,
</if>
<if test="title != null">
Title,
</if>
<if test="flag != null">
flag,
</if>
<if test="sys != null">
Sys,
</if>
<if test="C1 != null">
C1,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<!--<if test="id != null and id!=''">-->
(select replace(newid(),'-','')),
<!--</if>-->
<if test="pdfPath != null">
#{pdfPath,jdbcType=NVARCHAR},
</if>
<if test="masterid != null">
#{masterid,jdbcType=NVARCHAR},
</if>
<if test="uploaddatetime != null">
#{uploaddatetime,jdbcType=NVARCHAR},
</if>
<if test="assortid != null">
#{assortid,jdbcType=NVARCHAR},
</if>
<if test="source != null">
#{source,jdbcType=NVARCHAR},
</if>
<if test="subassort != null">
#{subassort,jdbcType=NVARCHAR},
</if>
<if test="title != null">
#{title,jdbcType=NVARCHAR},
</if>
<if test="flag != null">
#{flag,jdbcType=NVARCHAR},
</if>
<if test="sys != null">
#{sys,jdbcType=NVARCHAR},
</if>
<if test="C1 != null">
#{C1,jdbcType=NVARCHAR},
</if>
</trim>
</insert>
<delete id="deleteByPrimaryKey">
delete from archive_detail
where id = #{id,jdbcType=NVARCHAR}
</delete>
<delete id="delFileBySource">
delete from archive_detail
where MasterID = #{MasterID} AND flag=#{collectId}
</delete>
<select id="getDetailBySerialNumber" resultType="com.example.duplicate.controller.param.ArchiveDetailDto">
select * from archive_detail where Subassort=#{serialNumber}
</select>
</mapper>

@ -0,0 +1,20 @@
<?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.dao.ArchiveMasterMapper">
<select id="getMedicalAdviceTask" resultType="com.example.duplicate.controller.vo.ArchiveMasterVo">
SELECT *
from archive_master
WHERE discharge_date_time >= dateadd(minute,-30, GETDATE())
</select>
<select id="getArchiveMasterByMasterId" resultType="com.example.duplicate.controller.vo.ArchiveMasterVo">
select *
from archive_master
where id = #{masterId}
</select>
<select id="getMasterid" resultType="java.lang.String">
select id from archive_master WHERE discharge_date_time>='2024-07-01 00:00:00' and discharge_date_time &lt;='2024-08-10 23:59:59'
</select>
</mapper>

@ -0,0 +1,104 @@
<?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.dao.ArchiveOtherExtMapper">
<insert id="addOther">
insert into archive_other_ext
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
ID,
</if>
<if test="SycTime != null" >
SycTime,
</if>
<if test="otherID != null" >
otherID,
</if>
<if test="sysFlag != null" >
sysFlag,
</if>
<if test="sysUpdateTime != null" >
sysUpdateTime,
</if>
<if test="jzh != null" >
jzh,
</if>
<if test="zyh != null" >
zyh,
</if>
<if test="statusFlag != null" >
statusFlag,
</if>
<if test="MID != null" >
MID,
</if>
<if test="C1 != null" >
C1,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id},
</if>
<if test="SycTime != null" >
#{SycTime},
</if>
<if test="otherID != null" >
#{otherID},
</if>
<if test="sysFlag != null" >
#{sysFlag},
</if>
<if test="sysUpdateTime != null" >
#{sysUpdateTime},
</if>
<if test="jzh != null" >
#{jzh},
</if>
<if test="zyh != null" >
#{zyh},
</if>
<if test="statusFlag != null" >
#{statusFlag},
</if>
<if test="MID != null" >
#{MID},
</if>
<if test="C1 != null" >
#{C1},
</if>
</trim>
</insert>
<select id="getOtherByMidAndFlag" resultType="com.example.duplicate.controller.vo.ArchiveOtherExtVo">
select * from archive_other_ext where MID=#{mid} and sysFlag=#{sysFlag}
</select>
<update id="updateByMid">
update archive_other_ext
<set >
<if test="sycObj != null" >
SycObj = #{sycObj},
</if>
<if test="startTime != null" >
stime = #{startTime},
</if>
<if test="endTime != null" >
eTime = #{endTime},
</if>
<if test="statusFlag != null" >
statusFlag = #{statusFlag},
</if>
<if test="pinResult != null" >
pResult = #{pinResult},
</if>
</set>
where MID = #{mid} and sysFlag=#{sysFlag}
</update>
<update id="updateStatic">
update archive_other_ext set statusFlag=0 where MID = #{mid} and sysFlag=#{sysFlag}
</update>
</mapper>

@ -0,0 +1,38 @@
package com.example;
import com.example.utils.Md5Util;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = com.example.SpringbootDemoApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class DemoApplicationTests {
@Test
public void contextLoads() {
Timer timer = new Timer();
Date date = new Date();
int a = 2;
for (int i = 0; i < a; i++) {
TimerTask task = new TimerTask() {
public void run() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSSS");
Long id = Long.valueOf(sdf.format(System.currentTimeMillis()));
SimpleDateFormat SycTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println("id" + id);
System.out.println("SycTime" + SycTime.format(date));
}
};
timer.schedule(task, 2000);//延迟2秒执行
}
}
}
Loading…
Cancel
Save