Compare commits

...

13 Commits

Author SHA1 Message Date
tan 6bea4c6325 commit 2 years ago
tan a8751d5b1e commit 2 years ago
tan e3bcc934d4 按需采集更新 3 years ago
tan c71c830113 按需采集更新 3 years ago
tan a31072036e 按需采集更新
# Conflicts:
#	src/main/java/com/docus/bgts/config/MyScheduling.java
#	src/main/java/com/docus/bgts/controller/BgtsController.java
#	src/main/java/com/docus/bgts/facade/IMzSyncService.java
3 years ago
zengwh f62d172d71 重构完整性校验,增加根据af_collect_task采集情况校验 3 years ago
zengwh 69f2603413 梅州增加按jzh查任务视图补偿接口 3 years ago
zengwh 79f619a4e1 Merge branch 'docus-active-query-service_1.2' of http://8.134.10.251:3000/RecordCollectService/docus-active-query-service into docus-active-query-service_1.1
 Conflicts:
	dataConfig/homeQualitySet.json
	pom.xml
	src/main/java/com/docus/bgts/config/MyScheduling.java
3 years ago
zengwh b24415be6a 梅州增加按jzh查任务视图补偿接口 3 years ago
谭哲荣 f3bc1e2b0e 添加批量按需采集 3 years ago
zengwh 8c4cc8413a 修改完整性查询,特殊字符处理 3 years ago
zengwh 23b2f854de 修改完整性查询,时间范围查询错误 3 years ago
zengwh 3d9bcecd4e 修改5分钟刷新一下完整性,不完整的查任务视图提供的文件路径并下载,增加根据时间区间刷新完整性接口 3 years ago

@ -0,0 +1,6 @@
源码版本控制
1. master: 采集器
2. docus-active-query-service_1.1: 增加梅州完整性校验
3. docus-active-query-service_1.2: 完善梅州完整性校验与增加按需采集
4. docus-active-query-service_1.3: 增加根据af_collect_task校验完整性

@ -30,7 +30,7 @@
<OUTHOSP_INDEX_NO/>
<OUTHOSP_NO/>
<INHOSP_INDEX_NO></INHOSP_INDEX_NO>
<INHOSP_NO>1123</INHOSP_NO>
<INHOSP_NO></INHOSP_NO>
<EMPI_ID></EMPI_ID>
<BEGIN_DATE>20211213</BEGIN_DATE>
<END_DATE>20211222</END_DATE>

@ -1,60 +1,23 @@
{
//,
"directory":["Msg","ReportInfo"],
//
"indexFlag":"就诊号",
//
"serialnum":"手术申请单号",
//
"filetitle":"文书名",
//
"downurl":"WEB_ADDRESS",
//id
"assortid":"15E7FE7803F545CB81390BC88E725240",
"assortid":"e3625e059eb74ad88772edb03abf3bf7",
//id
"collectorid":"14",
"collectorid":"24",
//( 1:2)
"filesource":1,
//(1:2ftp3)
"filestoragetype":1,
"filetype": 4,
//
"uploadConnector":"http://192.168.1.107:9291/api/downplatform/report",
//doubleBasic
"basicDirectory":["Msg","ReportInfo"],
//
"doubleBasic":["TestItemInfo","BioTestInfo"],
//
"bgtsParam":["Request","Msg","EMPI_ID"],
//
"bgtsRespon":["MsgInfo","Msg"],
//key
"examNo":"EXAM_NO",
//key
"examItemName":"EXAM_ITEM_NAME",
//
"pdfUrl":"PDF_URL",
//
"bgtsDetailParam":["Request","Msg","EXAM_NO"],
//
"bgtsDetailRespon":["MsgInfo","Msg","ReportInfo"],
//
"startCollectTime":"2016-04-11",
"uploadConnector":"http://127.0.0.1:9291/api/downplatform/report",
//
"startCollectTime":"2022-08-01",
//
"endCollectTime":"2022-08-01",
// 1: 0 :
"isStartCollect":"0",
//oracle
"namespace":"DOCUS",
//oracle
"tableName":"V_DOCUMENT_PDF",
//oracle
"collectTimeName":"ARCHIVE_DATE_TIME",
//----------
//0 1
"syncFlag":"0",
"pageSize":"1000",
//
"newSyncTime":"",
//
"syncTableName":"CIS_EMR_DOCUMENT",
"syncTableNamespaces":"DOCUS"
"isStartCollect":"1",
// 1: 0 :
"isCollect":"0",
// 1: 0 :
"isStartCollectDay":"0"
}

@ -0,0 +1 @@
{"lastTime":"2022-05-02 12:46:49"}

@ -137,6 +137,7 @@
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
@ -147,6 +148,34 @@
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>4.0.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.2.2.jre8</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
</dependencies>
<build>

@ -0,0 +1,43 @@
package com.docus.bgts.config;
import com.alibaba.druid.pool.DruidDataSource;
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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
@Configuration
@MapperScan(basePackages = DbSqlserverConfig.PACKAGE, sqlSessionFactoryRef = "dbsqlserverSqlSessionFactory")
public class DbSqlserverConfig {
// 这里一定要指定精准 否则后果不堪设想
static final String PACKAGE = "com.docus.bgts.mapper.dbsqlserver";
static final String MAPPER_LOCATION = "classpath:mapper/dbsqlserver/*.xml";
@Bean(name = "dbsqlserverDataSource")
@ConfigurationProperties(prefix = "spring.datasource.sqlserver-docus")
public DataSource secondDataSource(){
return new DruidDataSource();
}
/*注入事务*/
@Bean(name = "dbsqlserverTransactionManager")
public DataSourceTransactionManager secondTransactionManager() {
return new DataSourceTransactionManager(secondDataSource());
}
@Bean(name = "dbsqlserverSqlSessionFactory")
public SqlSessionFactory secondSqlSessionFactory(@Qualifier("dbsqlserverDataSource") DataSource secondDataSource)
throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(secondDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(DbSqlserverConfig.MAPPER_LOCATION));
return sessionFactory.getObject();
}
}

@ -4,10 +4,14 @@ import com.docus.bgts.enums.Codes;
import com.docus.bgts.facade.IBgtsService;
import com.docus.bgts.utils.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.List;
import java.util.Map;
@Component
public class MyConstruct {
@ -15,19 +19,55 @@ public class MyConstruct {
@Autowired
IBgtsService bgtsService;
private Logger logger = LogManager.getLogger(MyConstruct.class);
/**
*
*
*/
@PostConstruct
public void startCollectAll(){
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
String startCollectTime = String.valueOf(FileUtils.getJsonByName("startCollectTime"));
String isStartCollect = String.valueOf(FileUtils.getJsonByName("isStartCollect"));
if(collectorid.equals(Codes.SMCODE.getCode())&& StringUtils.isNotBlank(startCollectTime)&&isStartCollect!=null&&isStartCollect.equals("1")){
if(StringUtils.isNotBlank(startCollectTime)&&isStartCollect!=null&&isStartCollect.equals("1")){
bgtsService.collectAll();
}
}
// @PostConstruct
// public void tests(){
// //页码
// int startrow;
// //每页10条数据
// int endrow;
// a: for (startrow=1;;startrow+=10){
// endrow = 10 +startrow;
// List<Map> maps = bgtsService.test(startrow,endrow-1);
// System.err.println(startrow+"---------------"+(endrow-1));
// System.err.println("处理数据---"+maps);
// if (null == maps || maps.size() <= 0) {
// break;
// }
// }
//
//
// }
/**
*
*/
// @PostConstruct
// public void startCollectAll(){
// logger.info("全量采集开始------");
// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
// String startCollectTime = String.valueOf(FileUtils.getJsonByName("startCollectTime"));
// String isStartCollect = String.valueOf(FileUtils.getJsonByName("isStartCollect"));
// if(collectorid.equals(Codes.ZZCODE.getCode())&& StringUtils.isNotBlank(startCollectTime)&&isStartCollect!=null&&isStartCollect.equals("1")){
// bgtsService.collectAll();
// }
// }
//
//在spring容器关闭时释放
@PreDestroy

@ -1,10 +1,14 @@
package com.docus.bgts.config;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.docus.bgts.entity.TableJsonRead;
import com.docus.bgts.enums.Codes;
import com.docus.bgts.facade.IBgtsService;
import com.docus.bgts.facade.IMzSyncService;
import com.docus.bgts.service.CheckIntegrityService;
import com.docus.bgts.utils.FileUtils;
import com.docus.bgts.utils.HttpUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@ -12,6 +16,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -21,60 +26,144 @@ public class MyScheduling {
private String beatUrl;
public static String syncFlag;
private final String tempfilePrefix="dataConfig\\temp";
private final String tempDataFileName="collectTimeTemp";
private final String lastTimeStr="lastTime";
static {
syncFlag=FileUtils.getJsonByName("syncFlag").toString();
}
// static {
// syncFlag=FileUtils.getJsonByName("syncFlag").toString();
// }
@Autowired
IBgtsService bgtsService;
@Autowired
IMzSyncService mzSyncService;
CheckIntegrityService checkIntegrityService;
private Logger logger = LogManager.getLogger(MyScheduling.class);
//5分钟执行一次
@Scheduled(fixedRate = 1000 * 60 * 5)
public void beat() {
Map<String, String> params = new HashMap<>();
params.put("code", String.valueOf(FileUtils.getJsonByName("collectorid")));
try {
HttpUtils.get(beatUrl, params);
} catch (Exception e) {
e.printStackTrace();
logger.info("心跳推送出错,可能是住院服务没有开启");
}
}
//5分钟执行一次心跳
// @Scheduled(fixedRate = 1000 * 60 * 5)
// public void beat() {
// Map<String, String> params = new HashMap<>();
// params.put("code", String.valueOf(FileUtils.getJsonByName("collectorid")));
// try {
// HttpUtils.get(beatUrl, params);
// } catch (Exception e) {
// e.printStackTrace();
// logger.info("心跳推送出错,可能是住院服务没有开启");
// }
// }
/**
*
* /
* 10
*/
@Scheduled(fixedRate = 1000 * 60 * 10)
public void collect() {
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
String isStartCollect = String.valueOf(FileUtils.getJsonByName("isStartCollect"));
if (isStartCollect.equals("0")) {
return;
}
if ((!collectorid.equals(Codes.SMCODE.getCode())) && (!collectorid.equals(Codes.ZZCODE.getCode()))) {
return;
// @Scheduled(fixedRate = 1000 * 60 * 10)
// public void collect() {
// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
// if ((!collectorid.equals(Codes.SMCODE.getCode())) && (!collectorid.equals(Codes.ZZCODE.getCode()))) {
// return;
// }
// bgtsService.timerCollect();
// }
/**
*
*/
// @Scheduled(fixedRate = 1000*10)
// public void collectJzone(){
// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
// if (!collectorid.equals("24")){
// return;
// }
//bgtsService.timerCollectJz();
// }
/**
*
*/
@Scheduled(fixedDelay = 1000 * 60 * 10)
public void collectIncrement(){
String isCollect = String.valueOf(FileUtils.getJsonByName("isCollect"));
if (isCollect.equals("1")){
bgtsService.timerCollectSmIncrement();
}
bgtsService.timerCollect();
}
/**
*
*
*/
@Scheduled(fixedRate = 1000 * 60 * 30)
public void syncIntegrality() {
if (null == syncFlag || "0".equals(syncFlag)) {
} else {
mzSyncService.addSyncIntegrality();
@Scheduled(cron ="0 0 0 * * ?")
public void collectSm(){
String isStartCollectDay = String.valueOf(FileUtils.getJsonByName("isStartCollectDay"));
if (isStartCollectDay.equals("1")){
bgtsService.timerCollectSmDay();
}
}
/**
*
* 10
*/
// @Scheduled(fixedRate = 1000 * 60 *10 )
// public void collectByExamNo(){
// String collectOpen = String.valueOf(FileUtils.getJsonByName("collectOpen"));
// if (collectOpen.equals("1")){
// logger.info("按需采集开始----------");
// String collectStartDate = String.valueOf(FileUtils.getJsonByName("collectStartDate"));
// String collectEndDate = String.valueOf(FileUtils.getJsonByName("collectEndDate"));
// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
// bgtsService.collectByDate(collectStartDate,collectEndDate,collectorid);
// }
// }
/**
*
*/
// @Scheduled(fixedRate = 1000 * 5 * 60)
// public void syncIntegrality() {
// if (null == syncFlag || "0".equals(syncFlag)) {
//
// } else {
// //获取最后时间
// String lastDate = getLastDate();
// if(StringUtils.isNotBlank(lastDate)) {
// Date date = new Date();
// boolean flag = checkIntegrityService.addSyncIntegrality(lastDate, null);
// if(flag) {
// refreshLastDate(date);
// }
// }else{
// logger.info("采集时间为空");
// }
// }
// }
/**
*
* @return
*/
// private String getLastDate(){
// TableJsonRead tableJsonRead = new TableJsonRead();
// Map<String,String> map = tableJsonRead.Read(tempfilePrefix, tempDataFileName,Map.class);
// return map.get(lastTimeStr);
// }
/**
*
*/
// private void refreshLastDate(Date lastDate){
// String lastTime = DateUtil.format(lastDate, "yyyy-MM-dd HH:mm:ss");
// TableJsonRead tableJsonRead = new TableJsonRead();
// Map<String, String> map = new HashMap<>();
// map.put(lastTimeStr, lastTime);
// tableJsonRead.Save(tempfilePrefix, tempDataFileName, JSON.toJSONString(map));
// }
}

@ -6,6 +6,7 @@ import com.docus.bgts.entity.CommonResult;
import com.docus.bgts.facade.IAfCollectTaskService;
import com.docus.bgts.facade.IBgtsService;
import com.docus.bgts.facade.IMzSyncService;
import com.docus.bgts.service.CheckIntegrityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -25,7 +26,7 @@ public class BgtsController {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
IMzSyncService mzSyncService;
CheckIntegrityService checkIntegrityService;
@Autowired
IBgtsService bgtsService;
@ -39,19 +40,20 @@ public class BgtsController {
MyScheduling.syncFlag=flag;
}
@GetMapping("/test")
public String test(@RequestParam("empId") String empId,
@RequestParam("collectSubId") String collectSubId){
return bgtsService.test(collectSubId)+"---"+empId;
@GetMapping("/addSyncIntegrality")
public void addSyncIntegrality(@RequestParam("startDate")String startDate,String endDate){
checkIntegrityService.addSyncIntegrality(startDate,endDate);
}
@GetMapping("/syncIntegrality")
public void syncIntegrality(){
mzSyncService.syncIntegrality();
@GetMapping("/addSyncIntegralityByJzhs")
public CommonResult<String> addSyncIntegrality(@RequestParam("jzhs")String jzhs){
if(jzhs.split(",").length > 100){
return CommonResult.failed("jzh个数不能超过100个");
}
checkIntegrityService.addSyncIntegralityByJzhs(jzhs);
return CommonResult.success("完成");
}
@ApiOperation("采集接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "empId",value = "患者主索引号",required = true,dataTypeClass = String.class),
@ -82,6 +84,43 @@ public class BgtsController {
return CommonResult.success("ok");
}
@ApiOperation("Pacs采集接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "empId",value = "患者主索引号",required = true,dataTypeClass = String.class),
@ApiImplicitParam(name = "collectSubId",value = "af_interface_collect_sub表id",required = true),
@ApiImplicitParam(name = "admissDate",value = "入院时间",required = true),
@ApiImplicitParam(name = "disDate",value = "出院时间",required = true),
@ApiImplicitParam(name = "times",value = "住院次数",required = true)
})
@GetMapping("/collectPacs")
public CommonResult<String> collect(@RequestParam("collectSubId") String collectSubId,
@RequestParam("empId") String empId,
@RequestParam("admissDate") String admissDate,
@RequestParam("disDate") String disDate,
@RequestParam("times") String times){
try {
logger.info("采集接口接收到参数:\nempId--"+empId+"\ncollectSubId--"+collectSubId);
bgtsService.collectPacs(empId,admissDate,disDate,times);
logger.info("采集完成");
afCollectTaskService.updateInterfaceCollect(collectSubId, 1);
logger.info("------------采集结束-----------");
} catch (RuntimeException e) {
e.printStackTrace();
try {
afCollectTaskService.updateInterfaceCollect(collectSubId, 0);
}catch (Exception e1) {
logger.info(e1.getMessage());
return CommonResult.failed(e1.getMessage());
}
return CommonResult.failed(e.getMessage());
}
catch (Exception e) {
e.printStackTrace();
}
return CommonResult.success("ok");
}
/**
*
* @param emamNo
@ -109,4 +148,33 @@ public class BgtsController {
return CommonResult.success("ok");
}
/**
*
*/
@GetMapping("/collectByEx")
public CommonResult<String> collectByEx(@RequestParam("empId") String empId){
try{
bgtsService.collect(empId);
}catch (Exception e){
e.printStackTrace();
return CommonResult.failed(e.getMessage());
}
return CommonResult.success("ok");
}
@GetMapping("/xx")
public void collectxx(){
bgtsService.collectAll();
}
@GetMapping("/collectById")
public CommonResult<String> collectById(@RequestParam("inPatientId") String inPatientId,@RequestParam("vistId") String vistId){
try{
bgtsService.SmCollect(inPatientId,vistId);
}catch (Exception e){
e.printStackTrace();
return CommonResult.failed(e.getMessage());
}
return CommonResult.success("ok");
}
}

@ -0,0 +1,20 @@
package com.docus.bgts.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author
* @description: jzh
* @createTime 2022/5/2 11:37
*/
@Data
public class JzhListSync {
private String jzh;
/**
*
*/
private List<TaskDetail> taskDetails;
}

@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel("文件详情")
public class MzSyncDetails {
@ -11,4 +13,12 @@ public class MzSyncDetails {
private String serialnum;
@ApiModelProperty("文件标题")
private String fileTitle;
@ApiModelProperty("文件url")
private String fileUrl;
@ApiModelProperty("分类名称")
private String assortName;
@ApiModelProperty("采集器标识")
private String collectid;
@ApiModelProperty("创建时间")
private Date createTime;
}

@ -0,0 +1,38 @@
package com.docus.bgts.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel("急诊电子病历视图 ")
public class PatientBL {
/**
*
*/
@ApiModelProperty("就诊号")
private String visitId;
/**
* id
*/
@ApiModelProperty("文件id")
private String mRFileId;
/**
*
*/
@ApiModelProperty("文件名")
private String mRFileName;
/**
* pdf
*/
@ApiModelProperty("pdf下载路径")
private String pDFFilePath;
/**
*
*/
@ApiModelProperty("归档时间")
private String recodeTime;
}

@ -7,4 +7,10 @@ import lombok.Data;
public class ReportDownPatientDto {
@ApiModelProperty(value = "记帐号")
private String jzh;
@ApiModelProperty(value = "住院号")
private String inPatientNo;
@ApiModelProperty(value = "住院次数")
private String visitId;
@ApiModelProperty(value = "主键")
private String patientid;
}

@ -11,6 +11,8 @@ public class ReportDownScanFileDto {
private int filesource;
@ApiModelProperty(value = "下载类型(1:服务器本地2ftp服务器3共享文件夹)")
private int filestoragetype;
@ApiModelProperty(value = "文件类型(1:url2base643:url base64;4共享文件夹)")
private int filetype;
@ApiModelProperty(value = "下载地址")
private String downurl;
@ApiModelProperty(value = "档案信息")

@ -0,0 +1,142 @@
package com.docus.bgts.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* @description
* @author jiashi
* @date 2022-08-03
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel("门急诊基础数据 ")
public class TBasicOut implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("病案主键")
@TableId(value = "patient_id",type = IdType.ASSIGN_ID)
private String patientId;
/**
*
*/
@ApiModelProperty("登记号")
private String inpatientNo;
/**
*
*/
@ApiModelProperty("就诊号")
private String jzh;
/**
*
*/
@ApiModelProperty("档案号")
private String empId;
/**
*
*/
@ApiModelProperty("卡号")
private String admissId;
/**
*
*/
@ApiModelProperty("卡类型")
private String visitTypeCode;
/**
*
*/
@ApiModelProperty("患者姓名")
private String name;
/**
*
*/
@ApiModelProperty("就诊日期")
private Date disDate;
/**
*
*/
@ApiModelProperty("就诊科室")
private String disDept;
/**
*
*/
@ApiModelProperty("就诊科室名称")
private String disDeptName;
/**
*
*/
@ApiModelProperty("诊断医生代码")
private String diagDoctorCode;
/**
*
*/
@ApiModelProperty("诊断医生姓名")
private String diagDoctorName;
/**
* (01)
*/
@ApiModelProperty("是否作废(01是)")
private Integer isCancel;
/**
* 10
*/
@ApiModelProperty("是否归档 1已归档0未归档")
private Integer isArchive;
/**
*
*/
@ApiModelProperty("归档时间")
private Date archiveTime;
/**
* 1:af_archive_detail2:t_scan_assort
*/
@ApiModelProperty("文件来源 1:af_archive_detail2:t_scan_assort")
private Integer fileSource;
/**
*
*/
@ApiModelProperty("完整性描述")
private String integrityDesc;
/**
*
*/
@ApiModelProperty("创建时间")
private Date createTime;
/**
*
*/
@ApiModelProperty("修改时间")
private Date updateTime;
public TBasicOut() {}
}

@ -0,0 +1,95 @@
package com.docus.bgts.entity;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.util.StringUtils;
import java.io.*;
public class TableJsonRead {
/**
*
* @param path
* @param fileName
* @return
*/
public <T> T Read(String path,String fileName,Class<T> clazz){
String currentPath=CurrentPath();
path = currentPath+"\\"+path;
StringBuilder sb = new StringBuilder();
T dto =null;
File file = new File(path+"\\"+fileName);
try {
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
BufferedReader bufferedReader = null;
bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
String line;
while (!StringUtils.isEmpty(line = bufferedReader.readLine())) {
sb.append(line);
}
if (sb.length() > 0) {
ObjectMapper objectMapper = new ObjectMapper();
//dto = (T)JSONObject.parse(sb.toString());
dto= objectMapper.readValue(sb.toString(), clazz);
//dto = objectMapper.convertValue(o, new TypeReference<T>() { });
}
bufferedReader.close();
}
return dto;
}
catch (Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* jar
* @return
*/
private String CurrentPath(){
File dir = new File(".");
String currentpath ="";
try {
currentpath = dir.getCanonicalPath();
} catch (IOException e) {
e.printStackTrace();
}
return currentpath;
}
/**
* json
* @param path
* @param fileName
* @param data json
* @return
*/
public void Save(String path,String fileName,String data){
String currentPath=CurrentPath();
path = currentPath+"\\"+path;
FileWriter fwriter = null;
try {
fwriter = new FileWriter(path+"\\"+fileName);
fwriter.write(data);
} catch (IOException ex) {
ex.printStackTrace();
} finally {
try {
fwriter.flush();
fwriter.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}

@ -0,0 +1,17 @@
package com.docus.bgts.entity;
import lombok.Data;
/**
* @author
* @description: jzh
* @createTime 2022/5/2 11:49
*/
@Data
public class TaskDetail {
private Long id;
private String fileTitle;
private String state;
}

@ -0,0 +1,13 @@
package com.docus.bgts.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Test {
private String ;
private String ;
}

@ -0,0 +1,46 @@
package com.docus.bgts.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author
* @since 2021-04-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="ZdAssort对象", description="病案分类")
public class ZdAssort implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
@ApiModelProperty(value = "分类id")
private String assortId;
@ApiModelProperty(value = "分类名称")
private String assortName;
@ApiModelProperty(value = "分类排序")
private Integer assortSort;
@ApiModelProperty(value = "是否启用 1是0否")
private Integer effective;
@ApiModelProperty(value = "是否校验 1是0否")
private Integer isCheck;
@ApiModelProperty(value = "代码分类")
private String assortCode;
@ApiModelProperty(value = "等级")
private Integer level;
}

@ -4,6 +4,10 @@ package com.docus.bgts.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.docus.bgts.entity.AfCollectTask;
import com.docus.bgts.entity.ReportDownDto;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -21,5 +25,59 @@ public interface IAfCollectTaskService extends IService<AfCollectTask> {
void insert(ReportDownDto reportDownDto);
String getJzhByInpatientNo(String inPatientNo,String visitId);
void insertServer(ReportDownDto reportDownDto);
void updateInterfaceCollect(String collectSubId, int state);
/**
* jzh
* @param startDate
* @param endDate
* @return
*/
List<String> getjzhByDate(String startDate,String endDate);
/**
*
* @param patientIds
* @return
*/
List<String> getC1ByPatientId(List<String> patientIds,String collectorId);
/**
* patient_id
* @param C1s
* @return
*/
List<String> getPatientIdByC1(List<String> C1s);
/**
* jzh
* @param patientIds
* @return
*/
List<String> getJzhByPatientId(List<String> patientIds);
/**
* patient_id
*/
String getPatientIdByInpatientNo(String inPatientNo,String visitId);
/**
* patient_id
*/
String getPatientIdByInpatientNoAndDate(String inPatientNo,String disDate);
/**
* jzh
* @param jzhs
* @return
*/
List<Map> getCompleteIntegrity(List<String> jzhs);
}

@ -1,4 +1,8 @@
package com.docus.bgts.facade;
import java.util.List;
import java.util.Map;
public interface IBgtsService {
/**
*
@ -6,6 +10,8 @@ public interface IBgtsService {
*/
void collect(String empId) throws Exception;
void collectPacs(String empId,String admissDate,String disDate,String times) throws Exception;
/**
*
* @param emamNo
@ -13,15 +19,33 @@ public interface IBgtsService {
*/
void collectByExamNo(String emamNo, String empId) throws Exception;
/**
*
* @param startDate
* @param endDate
*/
void collectByDate(String startDate,String endDate,String collectorId);
/**
*
*/
void collectAll();
void collectxx();
/**
*
*/
void timerCollect();
String test(String collectSubId);
/**
*
*/
void timerCollectSmIncrement();
void timerCollectSmDay();
void SmCollect(String inPatientId,String vistId);
List<Map> test(int size,int current);
}

@ -1,13 +1,10 @@
package com.docus.bgts.facade;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface IMzSyncService {
/**
*
*/
void syncIntegrality();
/**
*
*/
void addSyncIntegrality();
List<Map> getCompleteIntegrity(List<String> jzhs);
}

@ -14,7 +14,7 @@ public interface AfCollectAddMapper extends BaseMapper<AfCollectAdd> {
/**
*
*/
Date getTimeByAdd();
Date getTimeByAdd(Integer classIfy);
/**
* jzh
@ -24,6 +24,12 @@ public interface AfCollectAddMapper extends BaseMapper<AfCollectAdd> {
*/
List<String> listJzh(@Param("pageNumber") int pageNumber,@Param("pageSize") Integer pageSize);
/**
* jzh
* @param jzh
* @return
*/
Map<String,Date> selectDate(@Param("jzh") String jzh);
/**
*
* @param mzSyncs
@ -49,8 +55,7 @@ public interface AfCollectAddMapper extends BaseMapper<AfCollectAdd> {
* jzh
* @param front
* @param later
* @param newSyncTime
* @return
*/
List<String> listJzhAndAdd(@Param("front") int front,@Param("later") int later,@Param("newSyncTime") String newSyncTime);
List<String> listJzhAndAdd(@Param("front") int front,@Param("later") int later,@Param("startDate") String startDate,@Param("endDate")String endDate);
}

@ -3,8 +3,11 @@ package com.docus.bgts.mapper.dbmysql;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.docus.bgts.entity.AfCollectTask;
import com.docus.bgts.entity.JzhListSync;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper
@ -16,8 +19,57 @@ import org.apache.ibatis.annotations.Param;
public interface AfCollectTaskMapper extends BaseMapper<AfCollectTask> {
/**
* id
* @param empId
* @param jzh
* @return
*/
String getpatientIdByEmpId(@Param("jzh") String jzh);
String getPatientIdByInpatientNo(@Param("inPatientNo") String inPatientNo,@Param("visitId") String visitId);
/**
* patient_id
* @param inPatientNo
* @param disDate
* @return
*/
String getPatientIdByInpatientNoAndDate(@Param("inPatientNo") String inPatientNo,@Param("disDate") String disDate);
String getJzhByInpatientNo(@Param("inPatientNo") String inPatientNo,@Param("visitId") String visitId);
/**
* jzh
* @param startDate
* @param endDate
* @return
*/
List<String> getjzhByDate(@Param("startDate") String startDate,@Param("endDate") String endDate);
/**
*
* @param patientIds
* @param collectorId
* @return
*/
String getpatientIdByEmpId(@Param("jzh") String empId);
List<String> getC1ByPatientId(@Param("patientIds") List<String> patientIds,@Param("collectorId") String collectorId);
/**
* patient_id
* @param C1s
* @return
*/
List<String> getPatientIdByC1(@Param("C1s") List<String> C1s);
/**
* jzh
* @param patientIds
* @return
*/
List<String> getJzhByPatientId(@Param("patientIds") List<String> patientIds);
/**
*
* @param jzhs
* @return
*/
List<JzhListSync> selectListByJzhs(@Param("jzhs") List<String> jzhs);
}

@ -0,0 +1,20 @@
package com.docus.bgts.mapper.dbmysql;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.docus.bgts.entity.TBasicOut;
/**
* <p>
* Mapper
* </p>
*
* @author jiashi
* @since 2021-08-03
*/
public interface TBasicOutMapper extends BaseMapper<TBasicOut> {
int insert(TBasicOut tbasicOut);
int update(TBasicOut tbasicOut);
TBasicOut selectByJzh(String jzh);
}

@ -0,0 +1,18 @@
package com.docus.bgts.mapper.dbmysql;
import com.docus.bgts.entity.MzSync;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper
* </p>
*
* @author
* @since 2021-04-23
*/
public interface TScanAssortMapper {
List<MzSync> selectFilesByJzhs(@Param("jzhs") List<String> jzhs);
}

@ -0,0 +1,30 @@
package com.docus.bgts.mapper.dbmysql;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.docus.bgts.entity.ZdAssort;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper
* </p>
*
* @author
* @since 2021-04-20
*/
public interface ZdAssortMapper extends BaseMapper<ZdAssort> {
/**
*
* @param assortName
* @return
*/
List<ZdAssort> selectAll(@Param("assortName") String assortName);
/**
* zdAssort
* @param zdAssort
*/
void insertZdAssort(@Param("zdAssort") ZdAssort zdAssort);
}

@ -8,8 +8,6 @@ import java.util.List;
public interface MzSyncMapper {
List<MzSync> listMzSync(@Param("jzhs") List<String> jzhs,
@Param("front") int front ,
@Param("later") int later,
@Param("tableName") String tableName,
@Param("tableNamespace") String tableNamespace);

@ -0,0 +1,10 @@
package com.docus.bgts.mapper.dbsqlserver;
import com.docus.bgts.entity.PatientBL;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface PatientBLMapper {
List<PatientBL> selectByVisitId(@Param("visitId") String visitId);
}

@ -0,0 +1,10 @@
package com.docus.bgts.mapper.dbsqlserver;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
public interface PatientBRMapper {
List<Map> selectAll(@RequestParam("size") int size, @RequestParam("current") int current,@RequestParam("startDate") String startDate,@RequestParam("endDate") String endDate);
}

@ -0,0 +1,16 @@
package com.docus.bgts.mapper.dbsqlserver;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
public interface ScanningMapper {
List<Map> selectAll(@RequestParam("size") int size, @RequestParam("current") int current, @RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate);
List<Map> selectAllByDisDate(@RequestParam("size") int size, @RequestParam("current") int current, @RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate);
List<Map> selectByInPatientId(@RequestParam("inPatientId") String inPatientId,@RequestParam("vistId") String vistId);
int selectRow(@RequestParam("inPatientId") String inPatientId,@RequestParam("vistId") String vistId);
}

@ -0,0 +1,10 @@
package com.docus.bgts.mapper.dbsqlserver;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
public interface TestttMapper {
List<Map> selectAll(@RequestParam("size") int size,@RequestParam("current") int current);
}

@ -9,14 +9,14 @@ import com.docus.bgts.mapper.dbmysql.AfCollectTaskMapper;
import com.docus.bgts.mapper.dbmysql.AfInterfaceCollectMapper;
import com.docus.bgts.mapper.dbmysql.AfInterfaceCollectSubMapper;
import com.docus.bgts.mapper.dboracle.TestMapper;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;
/**
* <p>
@ -29,6 +29,8 @@ import java.util.List;
@Service
public class AfCollectTaskServiceImpl extends ServiceImpl<AfCollectTaskMapper, AfCollectTask> implements IAfCollectTaskService {
public static int MAX_SIZE_PER_TIME = 10;
@Autowired
TestMapper testMapper;
@ -50,8 +52,8 @@ public class AfCollectTaskServiceImpl extends ServiceImpl<AfCollectTaskMapper, A
@Override
public void insert(ReportDownDto reportDownDto) {
AfCollectTask afCollectTask;
String patientId = getpatientIdByEmpId(reportDownDto.getPatient().getJzh());
if (StringUtils.isBlank(patientId)) {
String inpatientNo = getpatientIdByEmpId(reportDownDto.getPatient().getJzh());
if (StringUtils.isBlank(inpatientNo)) {
throw new RuntimeException("操作的病案信息不存在");
}
Date date = new Date();
@ -63,7 +65,7 @@ public class AfCollectTaskServiceImpl extends ServiceImpl<AfCollectTaskMapper, A
if (afCollectTask == null) {
//不存在 新增
afCollectTask = new AfCollectTask();
afCollectTask.setPatientId(patientId);
afCollectTask.setPatientId(inpatientNo);
afCollectTask.setSysflag(reportDownDto.getCollectorid());
afCollectTask.setState("0");
afCollectTask.setSyncTime(date);
@ -79,7 +81,7 @@ public class AfCollectTaskServiceImpl extends ServiceImpl<AfCollectTaskMapper, A
} else {
//存在就修改
afCollectTask.setPatientId(patientId);
afCollectTask.setPatientId(inpatientNo);
afCollectTask.setSysflag(reportDownDto.getCollectorid());
afCollectTask.setState("0");
afCollectTask.setSyncTime(date);
@ -93,6 +95,58 @@ public class AfCollectTaskServiceImpl extends ServiceImpl<AfCollectTaskMapper, A
reportDownDto.setScanfiles(scanfiles);
}
@Override
public String getJzhByInpatientNo(String inPatientNo, String visitId) {
return afCollectTaskMapper.getJzhByInpatientNo(inPatientNo,visitId);
}
@Override
public void insertServer(ReportDownDto reportDownDto) {
AfCollectTask afCollectTask;
// String patientId = getpatientIdByEmpId(reportDownDto.getPatient().getJzh());
//String patientId = getPatientIdByInpatientNo(reportDownDto.getPatient().getInPatientNo(), reportDownDto.getPatient().getVisitId());
if (StringUtils.isBlank(reportDownDto.getPatient().getPatientid())) {
throw new RuntimeException("操作的病案信息不存在");
}
Date date = new Date();
Integer save = null;
List<ReportDownScanFileDto> scanfiles = reportDownDto.getScanfiles();
for (ReportDownScanFileDto scanfile : scanfiles) {
// 判断任务是否已存在
afCollectTask = afCollectTaskMapper.selectOne(new QueryWrapper<AfCollectTask>().eq("C1", scanfile.getSerialnum()).eq("sysflag", reportDownDto.getCollectorid()));
if (afCollectTask == null) {
//不存在 新增
afCollectTask = new AfCollectTask();
afCollectTask.setPatientId(reportDownDto.getPatient().getPatientid());
afCollectTask.setSysflag(reportDownDto.getCollectorid());
afCollectTask.setState("0");
afCollectTask.setSyncTime(date);
afCollectTask.setC1(scanfile.getSerialnum());
afCollectTask.setC2(scanfile.getFiletitle());
afCollectTask.setC3(reportDownDto.getPatient().getJzh());
save = afCollectTaskMapper.insert(afCollectTask);
if (save <= 0) {
throw new RuntimeException("插入病案任务表数据出错");
}else {
log.warn("插入病案成功");
}
} else {
//存在就修改
afCollectTask.setPatientId(reportDownDto.getPatient().getPatientid());
afCollectTask.setSysflag(reportDownDto.getCollectorid());
afCollectTask.setState("0");
afCollectTask.setSyncTime(date);
afCollectTask.setC1(scanfile.getSerialnum());
afCollectTask.setC2(scanfile.getFiletitle());
save = afCollectTaskMapper.updateById(afCollectTask);
log.warn(reportDownDto.getPatient().getPatientid()+"----修改病案成功"+scanfile.getSerialnum());
}
scanfile.setTaskid(afCollectTask.getId());
}
reportDownDto.setScanfiles(scanfiles);
}
@Override
public void updateInterfaceCollect(String collectSubId, int state) {
log.warn("开始记录采集");
@ -119,4 +173,114 @@ public class AfCollectTaskServiceImpl extends ServiceImpl<AfCollectTaskMapper, A
}
@Override
public List<String> getjzhByDate(String startDate, String endDate) {
List<String> patientIds = afCollectTaskMapper.getjzhByDate(startDate, endDate);
return patientIds;
}
@Override
public List<String> getC1ByPatientId(List<String> patientIds, String collectorId) {
List<List<String>> batchPatientIds = Lists.partition(patientIds, MAX_SIZE_PER_TIME);
List<String> c1s = new ArrayList<>();
for (List<String> batchPatientId : batchPatientIds) {
List<String> c1 = afCollectTaskMapper.getC1ByPatientId(batchPatientId, collectorId);
if (c1 != null && c1.size() != 0 ) {
for (String s : c1) {
c1s.add(s);
}
}
}
return c1s;
}
@Override
public List<String> getPatientIdByC1(List<String> C1s) {
List<List<String>> batchPatientIds = Lists.partition(C1s, MAX_SIZE_PER_TIME);
List<String> patientIds = new ArrayList<>();
for (List<String> batchC1s : batchPatientIds) {
List<String> patientId = afCollectTaskMapper.getPatientIdByC1(batchC1s);
if (patientId != null && patientId.size() != 0 ) {
for (String s : patientId) {
patientIds.add(s);
}
}
}
return patientIds;
}
@Override
public List<String> getJzhByPatientId(List<String> patientIds) {
List<String> jzhs = new ArrayList<>();
List<List<String>> batchPatientIds = Lists.partition(patientIds, MAX_SIZE_PER_TIME);
for (List<String> batchPatientId : batchPatientIds) {
List<String> jzh = afCollectTaskMapper.getJzhByPatientId(batchPatientId);
if (jzh != null && jzh.size() !=0 ) {
for (String s : jzh) {
jzhs.add(s);
}
}
}
return jzhs;
}
@Override
public String getPatientIdByInpatientNo(String inPatientNo, String visitId) {
return afCollectTaskMapper.getPatientIdByInpatientNo(inPatientNo, visitId);
}
@Override
public String getPatientIdByInpatientNoAndDate(String inPatientNo, String disDate) {
return afCollectTaskMapper.getPatientIdByInpatientNoAndDate(inPatientNo,disDate);
}
/**
* jzh
* @param jzhs
* @return
*/
@Override
public List<Map> getCompleteIntegrity(List<String> jzhs) {
//根据记帐号查询任务完成情况
List<JzhListSync> taskList = afCollectTaskMapper.selectListByJzhs(jzhs);
List<Map> maps = new ArrayList<>();
if(!CollectionUtils.isEmpty(taskList)){
//遍历判断完整性
for(String jzh : jzhs){
//定义不完整描述
StringBuilder integrity = new StringBuilder();
for(JzhListSync jzhListSync : taskList){
if(jzhListSync.getJzh().equals(jzh)){
//获取jzh对应任务明细集合
List<TaskDetail> taskDetails = jzhListSync.getTaskDetails();
for(TaskDetail taskDetail : taskDetails) {
//获取完成状态
String state = taskDetail.getState();
if (StringUtils.isBlank(state) || !"3".equals(state)){
//未完成状态
if(StringUtils.isNotBlank(integrity)){
integrity.append(",");
}
integrity.append(taskDetail.getFileTitle()).append("缺失");
}
}
break;
}
}
//定义完整性map
Map<String,String> map = new HashMap<>();
if(StringUtils.isBlank(integrity)){
integrity = new StringBuilder("完整");
}
map.put("jzh",jzh);
map.put("file_title",integrity.toString());
maps.add(map);
}
}
return maps;
}
}

@ -1,32 +1,45 @@
package com.docus.bgts.service;
import ch.qos.logback.core.util.FileUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.docus.bgts.entity.*;
import com.docus.bgts.enums.Codes;
import com.docus.bgts.facade.IAfCollectTaskService;
import com.docus.bgts.facade.IBgtsService;
import com.docus.bgts.mapper.dbmysql.AfCollectAddMapper;
import com.docus.bgts.mapper.dbmysql.AfInterfaceCollectSubMapper;
import com.docus.bgts.mapper.dbmysql.MrReportErrorMapper;
import com.docus.bgts.mapper.dbmysql.*;
import com.docus.bgts.mapper.dboracle.VDocumentPdfMapper;
import com.docus.bgts.mapper.dbsqlserver.PatientBLMapper;
import com.docus.bgts.mapper.dbsqlserver.PatientBRMapper;
import com.docus.bgts.mapper.dbsqlserver.ScanningMapper;
import com.docus.bgts.mapper.dbsqlserver.TestttMapper;
import com.docus.bgts.utils.*;
import org.apache.commons.codec.digest.MurmurHash2;
import org.apache.commons.codec.digest.MurmurHash3;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.helpers.IOUtils;
import org.apache.http.client.utils.DateUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.Text;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.ByteArrayInputStream;
import java.io.*;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@Service
@ -53,6 +66,26 @@ public class BgtsServiceImpl implements IBgtsService {
@Autowired
AfCollectAddMapper afCollectAddMapper;
@Autowired
AfCollectTaskMapper afCollectTaskMapper;
@Autowired
TestttMapper testMapper;
@Autowired
PatientBRMapper patientBRMapper;
@Autowired
PatientBLMapper patientBLMapper;
@Autowired
TBasicOutMapper tBasicOutMapper;
@Autowired
ScanningMapper scanningMapper;
@Override
public void collect(String empId) throws Exception {
//通过empId获取报告单号集合
@ -62,7 +95,23 @@ public class BgtsServiceImpl implements IBgtsService {
//插入文件af_collect_task表数据
afCollectTaskService.insert(reportDownDto);
//通过报告单号集合采集
collectExams(exams, empId,reportDownDto);
collectExams(exams, empId, reportDownDto);
}
@Override
public void collectPacs(String empId, String admissDate, String disDate, String times) throws Exception {
//通过empId获取报告单号集合
List<String[]> exams = getExamNo(empId, admissDate, disDate);
String jzh = afCollectTaskService.getJzhByInpatientNo(empId, times);
if (null == jzh) {
throw new RuntimeException("通过住院号与住院次数未匹配到患者");
}
//获取插入表数据
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, jzh);
//插入文件af_collect_task表数据
afCollectTaskService.insert(reportDownDto);
//通过报告单号集合采集
collectExams(exams, empId, reportDownDto);
}
@Override
@ -77,7 +126,7 @@ public class BgtsServiceImpl implements IBgtsService {
exams.add(strings);
//获取插入表数据
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, empId);
collectExams(exams, empId,reportDownDto);
collectExams(exams, empId, reportDownDto);
}
@Override
@ -92,14 +141,125 @@ public class BgtsServiceImpl implements IBgtsService {
//当前日期
Date date = new Date();
String dateStr = simpleDateFormat.format(date);
collectByDates(startCollectTime, dateStr);
collectByDateJz(startCollectTime, dateStr);
//更新采集时间
addAfCollectAdd(date);
// addAfCollectAdd(date);
logger.info("--------------全量采集结束------------------");
}
@Override
public void collectxx() {
logger.info("----------全量采集开始-----------");
//1.获取最早采集日期
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startCollectTime = null;
startCollectTime = String.valueOf(FileUtils.getJsonByName("startCollectTime"));
logger.info("----------采集初始时间:" + startCollectTime + " -------------------");
//当前日期
Date date = new Date();
String dateStr = simpleDateFormat.format(date);
collectByDateTest(startCollectTime, dateStr);
//更新采集时间
// addAfCollectAdd(date);
logger.info("--------------全量采集结束------------------");
}
// /**
// * 根据时间到采集任务 手麻
// *
// * @param startDate
// * @param endDate
// */
// private void collectByDates(String startDate, String endDate) {
// //页码
// int current;
// //每页10条数据
// int size;
// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
// String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
// int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
// int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
// Map<String, Object> headMap = new HashMap<>();
// headMap.put("Content-Type", "application/json");
// SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
// String indexFlag = String.valueOf(FileUtils.getJsonByName("indexFlag"));
// String serialnum = String.valueOf(FileUtils.getJsonByName("serialnum"));
// String filetitle = String.valueOf(FileUtils.getJsonByName("filetitle"));
// String downurl = String.valueOf(FileUtils.getJsonByName("downurl"));
// List<String> fieldArr = new ArrayList<>();
// fieldArr.add(indexFlag);
// fieldArr.add(serialnum);
// if (StringUtils.isNotBlank(filetitle)) {
// fieldArr.add(filetitle);
// }
// fieldArr.add(downurl);
// String namespace = String.valueOf(FileUtils.getJsonByName("namespace"));
// String tableName = String.valueOf(FileUtils.getJsonByName("tableName"));
// String collectTimeName = String.valueOf(FileUtils.getJsonByName("collectTimeName"));
// List<Map> maps;
// //2.获取第一页10条数据开始采集
// for (current = 1; ; current++) {
// size = 10 * current;
// maps = vDocumentPdfMapper.listCollectPage(size - 10, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName);
// logger.info("处理采集数据:" + maps);
// if (null == maps || maps.size() <= 0) {
// break;
// }
// maps:
// for (Map map : maps) {
// //获取过滤报告单
// String[] filterReports = String.valueOf(FileUtils.getJsonByName("filterReport")).split(",");
// if (filterReports.length > 0) {
// for (String filterReport : filterReports) {
// //需要过滤的报告单存在则不采集
// if (String.valueOf(map.get(filetitle)).equals(filterReport)) {
// continue maps;
// }
// }
// }
// ReportDownDto reportDownDto = new ReportDownDto();
// reportDownDto.setCollectorid(collectorid);
// reportDownDto.setAssortid(assortid);
// ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
// reportDownPatientDto.setJzh(String.valueOf(map.get(indexFlag)));
// reportDownDto.setPatient(reportDownPatientDto);
//
// List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
// ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
// reportDownScanFileDto.setDownurl(String.valueOf(map.get(downurl)));
// reportDownScanFileDto.setFilestoragetype(filestoragetype);
// reportDownScanFileDto.setFilesource(filesource);
// reportDownScanFileDto.setFiletitle(map.get(filetitle) == null ? "重症" + (System.currentTimeMillis()) : String.valueOf(map.get(filetitle)));
// reportDownScanFileDto.setSerialnum(StringUtils.isNotBlank(String.valueOf(map.get(serialnum))) ? String.valueOf(map.get(serialnum)) : String.valueOf(idWorker.nextId()));
// reportDownScanFileDtos.add(reportDownScanFileDto);
// reportDownDto.setScanfiles(reportDownScanFileDtos);
// String post;
// try {
// afCollectTaskService.insert(reportDownDto);
// //String uploadConnector = String.valueOf(FileUtils.getJsonByName("uploadConnector"));
// //调用下载接口
// post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class));
// Map resMap = JSON.parseObject(post, Map.class);
// logger.info(reportDownDto);
// if (String.valueOf(resMap.get("code")).equals("500")) {
// throw new RuntimeException(String.valueOf(resMap.get("msg")));
// }
// } catch (Exception e) {
// //打印错误日志
// logger.info("采集出错:" + reportDownDto);
// logger.info(e);
// String stackTrace = ExceptionUtils.getStackTrace(e);
// logger.info("错误信息----------" + stackTrace);
// addMrReportErrorLog(reportDownDto);
// e.printStackTrace();
// }
// }
// }
// }
/**
*
*
*
* @param startDate
* @param endDate
@ -118,24 +278,30 @@ public class BgtsServiceImpl implements IBgtsService {
SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
String indexFlag = String.valueOf(FileUtils.getJsonByName("indexFlag"));
String serialnum = String.valueOf(FileUtils.getJsonByName("serialnum"));
String filetitle = String.valueOf(FileUtils.getJsonByName("filetitle"));
//String filetitle = String.valueOf(FileUtils.getJsonByName("filetitle"));
String downurl = String.valueOf(FileUtils.getJsonByName("downurl"));
List<String> fieldArr=new ArrayList<>();
String inPatientNo = String.valueOf(FileUtils.getJsonByName("inPatientNo"));
String visitId = String.valueOf(FileUtils.getJsonByName("visitId"));
List<String> fieldArr = new ArrayList<>();
fieldArr.add(indexFlag);
fieldArr.add(serialnum);
if(StringUtils.isNotBlank(filetitle)){
fieldArr.add(filetitle);
}
fieldArr.add(inPatientNo);
fieldArr.add(visitId);
// if(StringUtils.isNotBlank(filetitle)){
// fieldArr.add(filetitle);
// }
fieldArr.add(downurl);
String namespace = String.valueOf(FileUtils.getJsonByName("namespace"));
String tableName = String.valueOf(FileUtils.getJsonByName("tableName"));
String collectTimeName = String.valueOf(FileUtils.getJsonByName("collectTimeName"));
List<Map> maps;
//2.获取第一页10条数据开始采集
logger.info("开始时间-----" + startDate + "结束时间-----" + "\n" + endDate);
for (current = 1; ; current++) {
size = 10 * current;
maps = vDocumentPdfMapper.listCollectPage(current, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName);
logger.info("处理采集数据:"+maps);
maps = vDocumentPdfMapper.listCollectPage(size - 10, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName);
logger.info("处理采集数据:" + maps);
if (null == maps || maps.size() <= 0) {
break;
}
@ -143,30 +309,43 @@ public class BgtsServiceImpl implements IBgtsService {
ReportDownDto reportDownDto = new ReportDownDto();
reportDownDto.setCollectorid(collectorid);
reportDownDto.setAssortid(assortid);
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
reportDownPatientDto.setJzh(String.valueOf(map.get(indexFlag)));
reportDownPatientDto.setInPatientNo(String.valueOf(map.get(inPatientNo)));
reportDownPatientDto.setVisitId(String.valueOf(map.get(visitId)));
reportDownDto.setPatient(reportDownPatientDto);
// reportDownPatientDto.setJzh(String.valueOf(map.get(indexFlag)));
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
reportDownScanFileDto.setDownurl(String.valueOf(map.get(downurl)));
reportDownScanFileDto.setFilestoragetype(filestoragetype);
reportDownScanFileDto.setFilesource(filesource);
reportDownScanFileDto.setFiletitle(map.get(filetitle)==null?"重症"+(System.currentTimeMillis()):String.valueOf(map.get(filetitle)));
reportDownScanFileDto.setSerialnum(StringUtils.isNotBlank(String.valueOf(map.get(serialnum)))?String.valueOf(map.get(serialnum)):String.valueOf(idWorker.nextId()));
//reportDownScanFileDto.setFiletitle(map.get(filetitle)==null?"重症"+(System.currentTimeMillis()):String.valueOf(map.get(filetitle)));
reportDownScanFileDto.setFiletitle(StringUtils.isNotBlank(String.valueOf(map.get(serialnum))) ? String.valueOf(map.get(serialnum)) : String.valueOf(idWorker.nextId()));
reportDownScanFileDto.setSerialnum(StringUtils.isNotBlank(String.valueOf(map.get(serialnum))) ? String.valueOf(map.get(serialnum)) : String.valueOf(idWorker.nextId()));
reportDownScanFileDtos.add(reportDownScanFileDto);
reportDownDto.setScanfiles(reportDownScanFileDtos);
String post;
try {
afCollectTaskService.insert(reportDownDto);
post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class));
Map resMap = JSON.parseObject(post, Map.class);
if (String.valueOf(resMap.get("code")).equals("500")) {
throw new RuntimeException(String.valueOf(resMap.get("msg")));
afCollectTaskService.insertServer(reportDownDto);
//String uploadConnector = String.valueOf(FileUtils.getJsonByName("uploadConnector"));
String jzh = afCollectTaskService.getJzhByInpatientNo(reportDownDto.getPatient().getInPatientNo(), reportDownDto.getPatient().getVisitId());
if (null != jzh && !("").equals(jzh)) {
reportDownPatientDto.setJzh(jzh);
reportDownDto.setPatient(reportDownPatientDto);
post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class));
Map resMap = JSON.parseObject(post, Map.class);
logger.info(reportDownDto);
if (String.valueOf(resMap.get("code")).equals("500")) {
throw new RuntimeException(String.valueOf(resMap.get("msg")));
}
}
} catch (Exception e) {
logger.info("采集出错:"+reportDownDto);
//打印错误日志
logger.info("采集出错:" + reportDownDto);
logger.info(e);
// String stackTrace = ExceptionUtils.getStackTrace(e);
// logger.info("错误信息----------"+stackTrace);
addMrReportErrorLog(reportDownDto);
e.printStackTrace();
}
@ -174,11 +353,89 @@ public class BgtsServiceImpl implements IBgtsService {
}
}
@Override
public void timerCollectSmDay() {
logger.info("------采集器开始采集---------");
//获取前一天开始结束时间
Map<String, String> time = getSmCollectionTime(new Date());
collectByDateSm(time.get("startDate"), time.get("endDate"));
//更新采集时间
logger.info("--------采集器结束采集------");
}
@Override
public void SmCollect(String inPatientId,String vistId) {
List<Map> maps = scanningMapper.selectByInPatientId(inPatientId,vistId);
int i = scanningMapper.selectRow(inPatientId,vistId);
logger.info(inPatientId+"患者扫描病历共"+i+"条----");
Map<String, Object> headMap = new HashMap<>();
headMap.put("Content-Type", "application/json");
int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
int filetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filetype")));
String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
int i1 =0;
for (Map map : maps) {
try {
i1++;
logger.info("当前第"+i1+"条------");
ReportDownDto reportDownDto = new ReportDownDto();
reportDownDto.setCollectorid(collectorid);
reportDownDto.setAssortid(String.valueOf(map.get("分类id")));
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
// reportDownPatientDto.setInPatientNo(String.valueOf(map.get("住院号")));
// reportDownPatientDto.setVisitId(String.valueOf(map.get("次数")));
String patientId = afCollectTaskService.getPatientIdByInpatientNo(String.valueOf(map.get("住院号")), String.valueOf(map.get("次数")));
if (null != patientId) {
reportDownPatientDto.setPatientid(patientId);
reportDownDto.setPatient(reportDownPatientDto);
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
reportDownScanFileDto.setFiletype(filetype);
reportDownScanFileDto.setDownurl(String.valueOf(map.get("图像路径")) + "/" + String.valueOf(map.get("文件名")));
reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")).substring(0,map.get("文件名").toString().indexOf(".")));
//处理下载地址为唯一值
String ser = String.valueOf(map.get("主键")) + String.valueOf(map.get("分段名称")) + String.valueOf(map.get("文件名"));
reportDownScanFileDto.setSerialnum(ser);
reportDownScanFileDto.setFilestoragetype(filestoragetype);
reportDownScanFileDto.setFilesource(filesource);
reportDownScanFileDtos.add(reportDownScanFileDto);
reportDownDto.setScanfiles(reportDownScanFileDtos);
afCollectTaskService.insertServer(reportDownDto);
String post;
logger.info("上传下载参数-----" + reportDownDto);
post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class));
Map resMap = JSON.parseObject(post, Map.class);
if (String.valueOf(resMap.get("code")).equals("500")) {
logger.info("下载服务-------" + String.valueOf(resMap.get("msg")));
}
} else {
logger.info(String.valueOf(map.get("住院号")) + "患者基础信息不存在!");
}
} catch (Exception e) {
logger.error(String.valueOf(map.get("住院号")) + e.getMessage());
}
}
}
@Override
public void timerCollect() {
logger.info("------采集器开始采集---------");
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
//1.获取上次采集时间
Date time = afCollectAddMapper.getTimeByAdd();
Date time;
if (collectorid.equals("5")) {
time = afCollectAddMapper.getTimeByAdd(5);
} else if (collectorid.equals("15")) {
time = afCollectAddMapper.getTimeByAdd(15);
} else {
time = afCollectAddMapper.getTimeByAdd(24);
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startDate = simpleDateFormat.format(time);
//当前日期
@ -191,12 +448,307 @@ public class BgtsServiceImpl implements IBgtsService {
}
@Override
public String test(String collectSubId) {
AfInterfaceCollectSub x = afInterfaceCollectSubMapper.selectById(collectSubId);
System.out.println(x);
return x.toString();
public void timerCollectSmIncrement() {
logger.info("------采集器开始采集---------");
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
//1.获取上次采集时间
Date time;
time = afCollectAddMapper.getTimeByAdd(25);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startDate = simpleDateFormat.format(time);
//当前日期
Date date = new Date();
String endDate = simpleDateFormat.format(date);
logger.info("增量采集开始----采集扫描日期区间为"+startDate+"-----"+endDate);
collectByDateSm(startDate, endDate);
//更新采集时间
addAfCollectAdd(date);
logger.info("--------采集器结束采集------");
}
/**
*
*
* @param date
* @return
*/
public static Map<String, String> getSmCollectionTime(Date date) {
Date dBefore;
Calendar calendar = Calendar.getInstance(); //得到日历
calendar.setTime(date);//把当前时间赋给日历
calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天
dBefore = calendar.getTime(); //得到前一天的时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //设置时间格式
String defaultStartDate = sdf.format(dBefore); //格式化前一天
defaultStartDate = defaultStartDate + " 00:00:00";
String defaultEndDate = defaultStartDate.substring(0, 10) + " 23:59:59";
Map<String, String> map = new HashMap<>();
map.put("startDate", defaultStartDate);
map.put("endDate", defaultEndDate);
return map;
}
/**
*
*/
private void collectByDateJz(String startDate, String endDate) {
//页码
int startrow;
//每页10条数据
int endrow;
//2.获取第一页10条数据开始采集
logger.info("开始时间-----" + startDate + "结束时间-----" + "\n" + endDate);
Map<String, Object> headMap = new HashMap<>();
headMap.put("Content-Type", "application/json");
int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
int filetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filetype")));
String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
List<Map> maps;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String format;
for (startrow = 1; ; startrow += 10) {
endrow = 10 + startrow;
maps = scanningMapper.selectAllByDisDate(startrow, endrow - 1, startDate, endDate);
logger.info("处理采集数据" + maps);
// List<Map> maps = patientBRMapper.selectAll(1,1,startDate,endDate);
if (null == maps || maps.size() <= 0) {
break;
}
try {
for (Map map : maps) {
try {
ReportDownDto reportDownDto = new ReportDownDto();
reportDownDto.setCollectorid(collectorid);
reportDownDto.setAssortid(String.valueOf(map.get("分类id")));
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
// reportDownPatientDto.setInPatientNo(String.valueOf(map.get("住院号")));
// reportDownPatientDto.setVisitId(String.valueOf(map.get("次数")));
Date parse = simpleDateFormat.parse(String.valueOf(map.get("出院日期")));
format = simpleDateFormat.format(parse);
String patientId = afCollectTaskService.getPatientIdByInpatientNoAndDate(String.valueOf(map.get("住院号")),format);
if (null != patientId) {
reportDownPatientDto.setPatientid(patientId);
reportDownDto.setPatient(reportDownPatientDto);
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
reportDownScanFileDto.setFiletype(filetype);
reportDownScanFileDto.setDownurl(String.valueOf(map.get("图像路径")) + "/" + String.valueOf(map.get("文件名")));
reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")).substring(0,map.get("文件名").toString().indexOf(".")));
//处理下载地址为唯一值
String ser = String.valueOf(map.get("主键")) + String.valueOf(map.get("分段名称")) + String.valueOf(map.get("文件名"));
logger.info("唯一值++++++" + ser);
reportDownScanFileDto.setSerialnum(ser);
reportDownScanFileDto.setFilestoragetype(filestoragetype);
reportDownScanFileDto.setFilesource(filesource);
reportDownScanFileDtos.add(reportDownScanFileDto);
reportDownDto.setScanfiles(reportDownScanFileDtos);
afCollectTaskService.insertServer(reportDownDto);
String post;
logger.info("上传下载参数-----" + reportDownDto);
post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class));
Map resMap = JSON.parseObject(post, Map.class);
if (String.valueOf(resMap.get("code")).equals("500")) {
logger.info("下载服务-------" + String.valueOf(resMap.get("msg")));
}
} else {
logger.info(String.valueOf(map.get("住院号")) + "患者基础信息不存在!");
}
} catch (Exception e) {
logger.error(String.valueOf(map.get("住院号")) + e.getMessage());
}
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage());
} catch (Throwable e) {
logger.error("throwable{}", e.getMessage());
}
// System.err.println(startrow+"---------------"+(endrow-1));
// System.err.println("处理数据---"+maps);
maps.clear();
}
}
/**
*
*/
private void collectByDateTest(String startDate, String endDate) {
//页码
int startrow;
//每页10条数据
int endrow;
//2.获取第一页10条数据开始采集
logger.info("开始时间-----" + startDate + "结束时间-----" + "\n" + endDate);
Map<String, Object> headMap = new HashMap<>();
headMap.put("Content-Type", "application/json");
int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
int filetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filetype")));
String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
List<Map> maps;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String format;
for (startrow = 1; ; startrow += 10) {
endrow = 10 + startrow;
maps = scanningMapper.selectAllByDisDate(startrow, endrow - 1, startDate, endDate);
logger.info("处理采集数据" + maps);
// List<Map> maps = patientBRMapper.selectAll(1,1,startDate,endDate);
if (null == maps || maps.size() <= 0) {
break;
}
try {
for (Map map : maps) {
try {
ReportDownDto reportDownDto = new ReportDownDto();
reportDownDto.setCollectorid(collectorid);
reportDownDto.setAssortid(String.valueOf(map.get("分类id")));
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
// reportDownPatientDto.setInPatientNo(String.valueOf(map.get("住院号")));
// reportDownPatientDto.setVisitId(String.valueOf(map.get("次数")));
Date parse = simpleDateFormat.parse(String.valueOf(map.get("出院日期")));
format = simpleDateFormat.format(parse);
String patientId = afCollectTaskService.getPatientIdByInpatientNoAndDate(String.valueOf(map.get("住院号")), format);
if (null != patientId) {
reportDownPatientDto.setPatientid(patientId);
reportDownDto.setPatient(reportDownPatientDto);
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
reportDownScanFileDto.setFiletype(filetype);
reportDownScanFileDto.setDownurl(String.valueOf(map.get("图像路径")) + "/" + String.valueOf(map.get("文件名")));
reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")));
//处理下载地址为唯一值
String ser = String.valueOf(map.get("图像路径").hashCode()) + "/" + String.valueOf(map.get("文件名").hashCode());
int i1 = MurmurHash2.hash32(ser);
reportDownScanFileDto.setSerialnum(Integer.toBinaryString(i1).toString());
reportDownScanFileDto.setFilestoragetype(filestoragetype);
reportDownScanFileDto.setFilesource(filesource);
reportDownScanFileDtos.add(reportDownScanFileDto);
reportDownDto.setScanfiles(reportDownScanFileDtos);
afCollectTaskService.insertServer(reportDownDto);
String post;
logger.info("上传下载参数-----" + reportDownDto);
post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class));
Map resMap = JSON.parseObject(post, Map.class);
if (String.valueOf(resMap.get("code")).equals("500")) {
logger.info("下载服务-------" + String.valueOf(resMap.get("msg")));
}
} else {
logger.info(String.valueOf(map.get("住院号")) + "患者基础信息不存在!");
}
} catch (Exception e) {
logger.error(String.valueOf(map.get("住院号")) + e.getMessage());
}
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage());
} catch (Throwable e) {
logger.error("throwable{}", e.getMessage());
}
// System.err.println(startrow+"---------------"+(endrow-1));
// System.err.println("处理数据---"+maps);
maps.clear();
}
}
/**
*
*/
private void collectByDateSm(String startDate, String endDate) {
//页码
int startrow;
//每页10条数据
int endrow;
//2.获取第一页10条数据开始采集
logger.info("开始时间-----" + startDate + "结束时间-----" + "\n" + endDate);
Map<String, Object> headMap = new HashMap<>();
headMap.put("Content-Type", "application/json");
int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
int filetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filetype")));
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
List<Map> maps;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String format;
for (startrow = 1; ; startrow += 10) {
endrow = 10 + startrow;
maps = scanningMapper.selectAll(startrow, endrow - 1, startDate, endDate);
// List<Map> maps = patientBRMapper.selectAll(1,1,startDate,endDate);
if (null == maps || maps.size() <= 0) {
break;
}
try {
logger.info("处理采集数据" + maps);
for (Map map : maps) {
try {
ReportDownDto reportDownDto = new ReportDownDto();
reportDownDto.setCollectorid(collectorid);
reportDownDto.setAssortid(String.valueOf(map.get("分类id")));
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
// reportDownPatientDto.setInPatientNo(String.valueOf(map.get("住院号")));
// reportDownPatientDto.setVisitId(String.valueOf(map.get("次数")));
Date parse = simpleDateFormat.parse(String.valueOf(map.get("出院日期")));
format = simpleDateFormat.format(parse);
String patientId = afCollectTaskService.getPatientIdByInpatientNoAndDate(String.valueOf(map.get("住院号")), format);
reportDownPatientDto.setPatientid(patientId);
reportDownDto.setPatient(reportDownPatientDto);
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
reportDownScanFileDto.setFiletype(filetype);
reportDownScanFileDto.setDownurl(String.valueOf(map.get("图像路径")) + "/" + String.valueOf(map.get("文件名")));
reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")).substring(0,map.get("文件名").toString().indexOf(".")));
//处理下载地址为唯一值
String ser = String.valueOf(map.get("主键")) + String.valueOf(map.get("分段名称")) + String.valueOf(map.get("文件名"));
reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")));
reportDownScanFileDto.setSerialnum(ser);
reportDownScanFileDto.setFilestoragetype(filestoragetype);
reportDownScanFileDto.setFilesource(filesource);
reportDownScanFileDtos.add(reportDownScanFileDto);
reportDownDto.setScanfiles(reportDownScanFileDtos);
afCollectTaskService.insertServer(reportDownDto);
String post;
logger.info("上传下载参数-----" + reportDownDto);
post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class));
Map resMap = JSON.parseObject(post, Map.class);
if (String.valueOf(resMap.get("code")).equals("500")) {
logger.info("下载服务{}", String.valueOf(resMap.get("msg")));
}
} catch (Exception e) {
logger.error(String.valueOf(map.get("住院号") + "错误信息" + e.getMessage()));
}
}
} catch (Exception e) {
e.printStackTrace();
} catch (Throwable t) {
logger.error("throwable{}", t.getMessage());
}
maps.clear();
}
}
/**
*
*/
@ -204,7 +756,7 @@ public class BgtsServiceImpl implements IBgtsService {
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
AfCollectAdd afCollectAdd = new AfCollectAdd();
afCollectAdd.setBeginStageDate(date);
afCollectAddMapper.update(afCollectAdd,new QueryWrapper<AfCollectAdd>().eq("classify",collectorid));
afCollectAddMapper.update(afCollectAdd, new QueryWrapper<AfCollectAdd>().eq("classify", collectorid));
}
/**
@ -227,7 +779,7 @@ public class BgtsServiceImpl implements IBgtsService {
* @param exams
* @param empId
*/
private void collectExams(List<String[]> exams, String empId,ReportDownDto reportDownDto) throws Exception {
private void collectExams(List<String[]> exams, String empId, ReportDownDto reportDownDto) throws Exception {
//调用上传接口
Map<String, Object> headMap = new HashMap<>();
headMap.put("Content-Type", "application/json");
@ -269,6 +821,7 @@ public class BgtsServiceImpl implements IBgtsService {
return reportDownDto;
}
/**
* ReportDownScanFileDto
*
@ -279,15 +832,16 @@ public class BgtsServiceImpl implements IBgtsService {
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
reportDownScanFileDto.setSerialnum(exam[0]);
reportDownScanFileDto.setFiletitle(exam[1]);
XmlUtils reqXmlUtils=new XmlUtils(FileUtils.getXmlDetailsPath());
XmlUtils reqXmlUtils = new XmlUtils(FileUtils.getXmlDetailsPath());
Element esbEntry = reqXmlUtils.getMsgElement();
esbEntry.element("EXAM_NO").setText(exam[0]);
String resXml = invokeWs(reqXmlUtils.getDocument().asXML());
logger.info("明细入参------------" + reqXmlUtils.getDocument().asXML());
//解析XML
XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8")));
String success = xmlUtils.isSuccess();
if(!success.equals("ok")){
logger.info("发送错误:"+success);
if (!success.equals("ok")) {
logger.info("发送错误:" + success);
throw new RuntimeException(success);
}
List<String> dis = (List<String>) FileUtils.getJsonByName("bgtsDetailRespon");
@ -306,9 +860,64 @@ public class BgtsServiceImpl implements IBgtsService {
private List<String[]> getExamNo(String empId) throws Exception {
List<String[]> exams = new ArrayList<>();
XmlUtils reqXmlUtils=new XmlUtils(FileUtils.getXmlPath());
XmlUtils reqXmlUtils = new XmlUtils(FileUtils.getXmlPath());
Element reqElement = reqXmlUtils.getMsgElement();
Map<String, Date> map = afCollectAddMapper.selectDate(empId);
reqElement.element("INHOSP_NO").setText(empId);
reqElement.element("BEGIN_DATE").setText(new SimpleDateFormat(FileUtils.getJsonByName("dateFormat").toString()).format(map.get("admiss_date")));
reqElement.element("END_DATE").setText(new SimpleDateFormat(FileUtils.getJsonByName("dateFormat").toString()).format(map.get("dis_date")));
logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------");
String xml = reqXmlUtils.getDocument().asXML();
logger.info("---------------------------");
logger.info(xml);
logger.info("----------------------------");
String resXml = invokeWs(xml);
logger.info("---------返回值-------------");
logger.info(resXml);
logger.info("-----------------------------");
//解析XML
XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8")));
String success = xmlUtils.isSuccess();
if (!success.equals("ok")) {
logger.info("发送错误:" + success);
throw new RuntimeException(success);
}
List<String> dis = (List<String>) FileUtils.getJsonByName("bgtsRespon");
//数据所在节点
Element element = xmlUtils.getElement(dis);
List<Element> examInfos = element.elements("ExamInfo");
Element examNo;
String[] key;
for (Element examInfo : examInfos) {
key = new String[2];
examNo = examInfo.element(String.valueOf(FileUtils.getJsonByName("examNo")));
if (examNo != null) {
key[0] = examNo.getText();
}
Element examItemInfo = examInfo.element("ExamItemInfo");
if (examItemInfo != null) {
key[1] = examItemInfo.element(String.valueOf(FileUtils.getJsonByName("examItemName"))).getText();
}
exams.add(key);
}
return exams;
}
/**
* empId pacs
*
* @param empId
* @return
*/
private List<String[]> getExamNo(String empId, String admissDate, String disDate) throws Exception {
List<String[]> exams = new ArrayList<>();
XmlUtils reqXmlUtils = new XmlUtils(FileUtils.getXmlPath());
Element reqElement = reqXmlUtils.getMsgElement();
Map<String, Date> map = afCollectAddMapper.selectDate(empId);
reqElement.element("INHOSP_INDEX_NO").setText(empId);
reqElement.element("BEGIN_DATE").setText(admissDate);
reqElement.element("END_DATE").setText(disDate);
logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------");
String xml = reqXmlUtils.getDocument().asXML();
logger.info("---------------------------");
@ -321,8 +930,8 @@ public class BgtsServiceImpl implements IBgtsService {
//解析XML
XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8")));
String success = xmlUtils.isSuccess();
if(!success.equals("ok")){
logger.info("发送错误:"+success);
if (!success.equals("ok")) {
logger.info("发送错误:" + success);
throw new RuntimeException(success);
}
List<String> dis = (List<String>) FileUtils.getJsonByName("bgtsRespon");
@ -347,6 +956,61 @@ public class BgtsServiceImpl implements IBgtsService {
}
/**
*
*
* @param startDate
* @param endDate
* @param collectorId
*/
public void collectByDate(String startDate, String endDate, String collectorId) {
//通过日期查询patientId集合
List<String> patientIds = afCollectTaskService.getjzhByDate(startDate, endDate);
//通过patientId集合与采集器编号查询报告单号
//List<String> c1s = afCollectTaskService.getC1ByPatientId(patientIds, collectorId);
//通过唯一报告单号查询patient_id
//List<String> patientIdByC1 = afCollectTaskService.getPatientIdByC1(c1s);
//通过patientId集合查询jzh
//List<String> jzhs = afCollectTaskService.getJzhByPatientId(patientIds);
//int i = -1;
//循环jzh与报告单号c1调用按需采集
// for (String c1 : c1s) {
// try {
// if (i<c1s.size()) {
// i++;
// //System.err.println(c1s.get(i) + "--------" + jzhs.get(i));
// //HttpUtils.get("127.0.0.1:"+port+"/collectByExamNo?emamNo="+c1+"&empId="+jzh);
// collectByExamNo(c1s.get(i), jzhs.get(i));
// }
//
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
try {
for (String patientId : patientIds) {
if (patientId != null) {
logger.info("按需采集------患者" + patientId);
collect(patientId);
}
}
// for (String jzh : jzhs) {
// if (jzh!=null) {
// logger.info("按需采集------患者"+jzh);
// collect(jzh);
// }
// }
} catch (Exception e) {
e.printStackTrace();
}
}
public List<Map> test(int size, int current) {
return testMapper.selectAll(size, current);
}
/**
* web service
*
@ -367,3 +1031,4 @@ public class BgtsServiceImpl implements IBgtsService {
}

@ -0,0 +1,133 @@
package com.docus.bgts.service;
import com.docus.bgts.facade.IAfCollectTaskService;
import com.docus.bgts.facade.IMzSyncService;
import com.docus.bgts.mapper.dbmysql.AfCollectAddMapper;
import com.docus.bgts.utils.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @author
* @description:
* @createTime 2022/5/2 10:34
*/
@Service
public class CheckIntegrityService {
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
AfCollectAddMapper afCollectAddMapper;
@Autowired
IMzSyncService iMzSyncService;
@Autowired
IAfCollectTaskService afCollectTaskService;
/**
*
* @param startDate
* @param endDate
* @return
*/
public boolean addSyncIntegrality(String startDate,String endDate) {
//1
//定义是否更新采集时间
boolean flag = true;
log.info("增量完整性同步开始");
long startTime = System.currentTimeMillis();
//获取分页数
Integer pageSize = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("pageSize")));
List<String> jzhs;
int front;
for (int i = 0; ; i++) {
front = i * pageSize;
jzhs = afCollectAddMapper.listJzhAndAdd(front, pageSize, startDate,endDate);
if (jzhs.size() == 0) {
if(i == 0){
flag = false;
}
break;
} else {
//校验完整性
addSyncIntegralityByJzhsMethod(jzhs);
}
}
long endTime = System.currentTimeMillis();
log.info("增量完整性同步结束,程序执行时间为:" + (endTime - startTime) + "毫秒");
return flag;
}
/**
*
* @param jzhs
*/
public void addSyncIntegralityByJzhsMethod(List<String> jzhs) {
//处理完整性描述
List<Map> maps = getCompleteInegruty(jzhs);
//完整性检验写入
integralityBySyncs(maps);
log.info("本次成功同步数:" + maps.size());
}
/**
*
* @return
*/
private List<Map> getCompleteInegruty(List<String> jzhs){
//获取配置的校验完整性方式1:根据af_collect_task完成情况 2:梅州根据信息科提供任务视图
Integer checkIntegrityType = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("checkIntegrityType")));
if(null == checkIntegrityType){
throw new RuntimeException("homeQualitySet文件中校验方式checkIntegrityType需要配置");
}
List<Map> maps = new ArrayList<>();
if(checkIntegrityType == 1){
//根据af_collect_task校验完整性
maps = afCollectTaskService.getCompleteIntegrity(jzhs);
}else if(checkIntegrityType == 2){
//校验梅州完整性
maps = iMzSyncService.getCompleteIntegrity(jzhs);
}
return maps;
}
/**
*
* @param maps {"jzh":,"file_title"}
*/
private void integralityBySyncs(List<Map> maps) {
StringBuilder sql;
if (!CollectionUtils.isEmpty(maps)) {
sql = new StringBuilder();
for (Map map : maps) {
sql.append("update docus_medicalrecord.t_basic set integrity_desc=");
sql.append("'");
sql.append(map.get("file_title"));
sql.append("',update_time=now()");
sql.append(" where jzh=");
sql.append("'");
sql.append(map.get("jzh"));
sql.append("'");
sql.append(";");
}
System.out.println(sql);
afCollectAddMapper.dynamicSql(sql.toString());
}
}
/**
* jzh
* @param jzhs
*/
public void addSyncIntegralityByJzhs(String jzhs) {
List<String> jzhList = Arrays.asList(jzhs.split(","));
addSyncIntegralityByJzhsMethod(jzhList);
}
}

@ -1,22 +1,21 @@
package com.docus.bgts.service;
import com.docus.bgts.entity.MzSync;
import com.docus.bgts.entity.*;
import com.docus.bgts.facade.IMzSyncService;
import com.docus.bgts.mapper.dbmysql.AfCollectAddMapper;
import com.docus.bgts.mapper.dbmysql.TScanAssortMapper;
import com.docus.bgts.mapper.dboracle.MzSyncMapper;
import com.docus.bgts.utils.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
*
@ -35,7 +34,6 @@ public class MzSyncService implements IMzSyncService {
*
*/
private String newSyncTime;
{
tableName = String.valueOf(FileUtils.getJsonByName("syncTableName"));
tableNamespaces = String.valueOf(FileUtils.getJsonByName("syncTableNamespaces"));
@ -49,96 +47,104 @@ public class MzSyncService implements IMzSyncService {
@Autowired
MzSyncMapper mzSyncMapper;
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
TScanAssortMapper tScanAssortMapper;
@Override
public void addSyncIntegrality() {
log.info("增量完整性同步开始");
long startTime = System.currentTimeMillis();
//获取分页数
Integer pageSize = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("pageSize")));
List<String> jzhs;
int front;
int later;
List<MzSync> mzSyncs;
for (int i = 0; ; i++) {
front = i * pageSize;
later = pageSize;
jzhs = afCollectAddMapper.listJzhAndAdd(front, later, newSyncTime);
if (jzhs.size() == 0) {
break;
} else {
mzSyncs = mzSyncMapper.listMzSync(jzhs, front, later, tableName, tableNamespaces);
//完整性检验写入
integralityBySyncs(mzSyncs);
}
if (mzSyncs.size() != 0) {
log.info("本次成功同步数:" + mzSyncs.size());
}
}
long endTime = System.currentTimeMillis();
log.info("增量完整性同步结束,程序执行时间为:" + (endTime - startTime) + "毫秒");
}
@Autowired
UpdateFileService updateFileService;
/**
*
*
* @param jzhs
* @return
*/
// @Transactional
@Override
public void syncIntegrality() {
log.info("完整性同步开始");
long startTime = System.currentTimeMillis();
//获取分页数
Integer pageSize = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("pageSize")));
List<String> jzhs;
int front;
int later;
List<MzSync> mzSyncs;
for (int i = 0; ; i++) {
front = i * pageSize;
later = pageSize;
jzhs = afCollectAddMapper.listJzh(front, later);
if (jzhs.size() == 0) {
break;
} else {
mzSyncs = mzSyncMapper.listMzSync(jzhs, front, later, tableName, tableNamespaces);
//完整性检验写入
integralityBySyncs(mzSyncs);
}
if (mzSyncs.size() != 0) {
log.info("本次成功同步数:" + mzSyncs.size());
}
}
long endTime = System.currentTimeMillis();
log.info("完整性同步结束,程序执行时间为:" + (endTime - startTime) + "毫秒");
public List<Map> getCompleteIntegrity(List<String> jzhs){
//根据记帐号查询任务视图
List<MzSync> mzSyncs = mzSyncMapper.listMzSync(jzhs,tableName, tableNamespaces);
//校验完整性
List<Map> maps = verifyIntegrity(mzSyncs,jzhs);
return maps;
}
/**
*
*
*
* @param mzSyncs
* @param jzhs
* @return
*/
private void integralityBySyncs(List<MzSync> mzSyncs ,List<String>) {
StringBuilder sql;
if (mzSyncs.size() != 0) {
List<Map> maps = afCollectAddMapper.integrality(mzSyncs);
System.out.println(maps);
sql = new StringBuilder();
for (Map map : maps) {
sql.append("update docus_medicalrecord.t_basic set integrity_desc=");
sql.append("'");
sql.append(map.get("file_title"));
sql.append("',update_time=now()");
sql.append(" where jzh=");
sql.append("'");
sql.append(map.get("jzh"));
sql.append("jzh");
sql.append("'");
sql.append(";");
private List<Map> verifyIntegrity(List<MzSync> mzSyncs, List<String> jzhs) {
List<Map> maps = new ArrayList<>();
//根据记账号集合查询文件表有效的文件集合
List<MzSync> fileList = tScanAssortMapper.selectFilesByJzhs(jzhs);
//遍历按记账号分组的任务视图
for(MzSync mzSync : mzSyncs){
//定义返回map
Map map = new HashMap();
//获取jzh
String jzh = mzSync.getJzh();
//遍历任务试图文件集合
List<MzSyncDetails> mzSyncDetails = mzSync.getMzSyncDetails();
//定义是否存在
boolean recordFlag = false;
//定义缺失文件集合
StringBuilder faultFileTitles = new StringBuilder();
for(MzSyncDetails mzSyncDetail : mzSyncDetails){
//获取文件名称
String fileTitle = mzSyncDetail.getFileTitle();
if(StringUtils.isNotBlank(fileTitle) && fileTitle.contains("急诊病历")){
recordFlag = true;
}
//获取文件序列号
String serialnum = mzSyncDetail.getSerialnum();
//获取采集器标识
String collectid = mzSyncDetail.getCollectid();
//定义是否存在
boolean flag = false;
if(!CollectionUtils.isEmpty(fileList)){
for(MzSync obj : fileList){
//获取jzh
String jzh1 = obj.getJzh();
if(jzh1.equals(jzh)){
List<MzSyncDetails> mzSyncDetails1 = obj.getMzSyncDetails();
for(MzSyncDetails vo : mzSyncDetails1){
//获取文件序列号
String serialnum1 = vo.getSerialnum();
//获取采集器标识
String collectid1 = vo.getCollectid();
if(serialnum.equals(serialnum1) && collectid.equals(collectid1)){
flag = true;
mzSyncDetail.setCollectid(vo.getCollectid());
break;
}
}
}
}
}
//遍历文件
if(!flag){
if(StringUtils.isNotBlank(faultFileTitles)){
faultFileTitles.append(",");
}
faultFileTitles.append(fileTitle + "缺失");
//调下载服务
updateFileService.updateFile(jzh,mzSyncDetail);
}
}
//添加急诊病历缺失
if(!recordFlag){
if(StringUtils.isNotBlank(faultFileTitles)){
faultFileTitles.append(",");
}
faultFileTitles.append("急诊病历缺失");
}
if(StringUtils.isBlank(faultFileTitles)){
faultFileTitles = new StringBuilder("完整");
}
System.out.println(sql);
afCollectAddMapper.dynamicSql(sql.toString());
map.put("jzh",jzh);
map.put("file_title",faultFileTitles.toString());
maps.add(map);
}
return maps;
}
}

@ -0,0 +1,159 @@
package com.docus.bgts.service;
import com.alibaba.fastjson.JSON;
import com.docus.bgts.entity.*;
import com.docus.bgts.enums.Codes;
import com.docus.bgts.facade.IAfCollectTaskService;
import com.docus.bgts.mapper.dbmysql.ZdAssortMapper;
import com.docus.bgts.utils.FileUtils;
import com.docus.bgts.utils.HttpUtils;
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 org.springframework.util.CollectionUtils;
import java.io.UnsupportedEncodingException;
import java.util.*;
/**
* @author
* @description:
* @createTime 2022/5/2 10:48
*/
@Service
public class UpdateFileService {
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
IAfCollectTaskService afCollectTaskService;
@Autowired
ZdAssortMapper zdAssortMapper;
/**
*{
* "assortid": "string",
* "collectorid": "string",
* "ip": "string",
* "patient": {
* "jzh": "string"
* },
* "scanfiles": [
* {
* "downurl": "string",
* "filesource": 0,
* "filestoragetype": 0,
* "filetitle": "string",
* "filetype": 0,
* "serialnum": "string",
* "taskid": 0
* }
* ],
* "scanusercode": "string",
* "scanusername": "string"
* }
*/
public void updateFile(String jzh, MzSyncDetails mzSyncDetail) {
ReportDownDto reportDownDto;
ReportDownScanFileDto reportDownScanFileDto;
ReportDownPatientDto reportDownPatientDto;
//临时资料存储
String serialnum;
String filetitle;
String downurl;
String collectorid = "";
String assortid = getAssortid(mzSyncDetail.getAssortName());
reportDownDto = new ReportDownDto();
reportDownDto.setAssortid(assortid);
//获取基本数据信息
List<ReportDownScanFileDto> reportDownDtoArr = new ArrayList<>();
reportDownPatientDto = new ReportDownPatientDto();
reportDownPatientDto.setJzh(jzh);
log.info("患者主索引号:" + jzh);
reportDownDto.setPatient(reportDownPatientDto);
filetitle = mzSyncDetail.getFileTitle();
downurl = mzSyncDetail.getFileUrl();
if(StringUtils.isBlank(downurl)){
return;
}
//特殊处理url
downurl = subStrUrl(downurl);
if(StringUtils.isBlank(downurl)){
return;
}
//获取采集流水号
serialnum = mzSyncDetail.getSerialnum();
collectorid = mzSyncDetail.getCollectid();
reportDownScanFileDto = new ReportDownScanFileDto();
reportDownScanFileDto.setDownurl(downurl);
reportDownScanFileDto.setFiletitle(filetitle);
reportDownScanFileDto.setSerialnum(serialnum);
reportDownScanFileDto.setFilesource(1);
reportDownScanFileDto.setFilestoragetype(1);
reportDownDtoArr.add(reportDownScanFileDto);
reportDownDto.setCollectorid(collectorid);
reportDownDto.setScanfiles(reportDownDtoArr);
afCollectTaskService.insert(reportDownDto);
String post = "";
log.info("--------执行上传功能----------");
Map params = JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class);
Map<String, Object> headMap = new HashMap<>();
headMap.put("Content-Type", "application/json");
try {
post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, params);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
// String post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), map, headMap);
if (StringUtils.isBlank(post)) {
log.info("--------上传时出现错误,可能是文件服务没有启动----------");
throw new RuntimeException("上传时出现错误,可能是文件服务没有启动");
}
Map resMap = JSON.parseObject(post, Map.class);
if (String.valueOf(resMap.get("code")).equals("500")) {
throw new RuntimeException(String.valueOf(resMap.get("msg")));
} else {
log.info("----------执行成功-----------");
}
}
/**
* id
*
* @return
*/
private String getAssortid(String assortName) {
String assortId = String.valueOf(FileUtils.getJsonByName("assortid"));
if (StringUtils.isBlank(assortId)) {
List<ZdAssort> zdAssorts = zdAssortMapper.selectAll(assortName);
if (CollectionUtils.isEmpty(zdAssorts)) {
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
ZdAssort zdAssort = new ZdAssort();
zdAssort.setAssortName(assortName);
zdAssort.setAssortId(uuid);
zdAssort.setEffective(1);
zdAssortMapper.insertZdAssort(zdAssort);
assortId = uuid;
} else {
assortId = zdAssorts.get(0).getAssortId();
}
}
return assortId;
}
/**
* url
* @param str
* @return
*/
private String subStrUrl(String str) {
List<String> replaceUrls = (List<String>) FileUtils.getJsonByName("replaceUrl");
if(null != replaceUrls){
for(String replaceUrl : replaceUrls){
str = str.replaceAll(replaceUrl,"");
}
}
return str;
}
}

@ -1,3 +1,4 @@
#version:1.3
server:
port: 9308
# http
@ -24,9 +25,15 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver
username: docus
password: docus702
url: jdbc:mysql://db.docus.cn:3306/docus_archivefile?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true&allowMultiQueries=true
url: jdbc:mysql://localhost:3306/docus_archivefile?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true&allowMultiQueries=true
oracle-docus:
driver-class-name: oracle.jdbc.driver.OracleDriver
# url: jdbc:oracle:thin:@localhost:1521:ORCL
url: jdbc:oracle:thin:@192.168.117.100:1521:helowin
username: docus
password: docus702
sqlserver-docus:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
username: sa
password: 123456
url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=jizhen

@ -21,8 +21,8 @@
<!-- 活动文件的名字会根据fileNamePattern的值每隔一段时间改变一次 -->
<!-- 文件名log/demo.2017-12-05.0.log -->
<fileNamePattern>log/demo.%d.%i.log</fileNamePattern>
<!-- 每产生一个日志文件,该日志文件的保存期限为15-->
<maxHistory>15</maxHistory>
<!-- 每产生一个日志文件,该日志文件的保存期限为30-->
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- maxFileSize:这是活动文件的大小默认值是10MB测试时可改成1KB看效果 -->
<maxFileSize>10MB</maxFileSize>

@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.docus.bgts.mapper.dbmysql.AfCollectAddMapper">
<select id="getTimeByAdd" resultType="date">
select begin_stage_date from af_collect_add where classify=5 limit 0,1
select begin_stage_date from af_collect_add where classify=#{classIfy} limit 0,1
</select>
<select id="listJzh" resultType="string">
@ -15,6 +15,12 @@
limit ${pageNumber},${pageSize}
</select>
<select id="selectDate" resultType="java.util.Map">
select admiss_date,dis_date
from docus_medicalrecord.t_basic
where jzh=#{jzh}
</select>
<select id="integrality" resultType="map">
<foreach collection="mzSyncs" item="mzSync" separator=" union all ">
SELECT
@ -54,7 +60,14 @@
docus_medicalrecord.t_basic a
JOIN t_scan_assort b ON a.patient_id = b.patient_id
WHERE
b.create_time >= #{newSyncTime}
<choose>
<when test="endDate != null and endDate != ''">
b.create_time BETWEEN #{startDate} AND concat(#{endDate},' 23:59:59')
</when>
<otherwise>
b.create_time >= #{startDate}
</otherwise>
</choose>
AND a.jzh IS NOT NULL
GROUP BY
jzh

@ -4,8 +4,90 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.docus.bgts.mapper.dbmysql.AfCollectTaskMapper">
<select id="getpatientIdByEmpId" resultType="string">
select patient_id
from docus_medicalrecord.t_basic_out
where jzh = #{jzh}
</select>
<select id="getjzhByDate" resultType="string">
select jzh
from docus_medicalrecord.t_basic
where dis_date between #{startDate} and #{endDate}
</select>
<select id="getC1ByPatientId" resultType="string">
select C1
from af_collect_task
where
patient_id in
<foreach collection="patientIds" open="(" close=")" item="patientId" separator=",">
#{patientId}
</foreach>
and sysflag=#{collectorId}
</select>
<select id="getJzhByPatientId" resultType="String">
select jzh
from docus_medicalrecord.t_basic
where
patient_id in
<foreach collection="patientIds" open="(" close=")" item="patientId" separator=",">
#{patientId}
</foreach>
</select>
<select id="getPatientIdByC1" resultType="String">
select patient_id
from af_collect_task
where
C1 in
<foreach collection="C1s" open="(" close=")" item="c1" separator=",">
#{c1}
</foreach>
</select>
<!--根据jzh分组查询任务完成情况-->
<select id="selectListByJzhs" resultMap="groupByJzh">
SELECT
id,
c3 jzh,
c2 fileTitle,
state
FROM
af_collect_task
WHERE
c3 IN
(<foreach collection="jzhs" item="jzh" separator=",">
#{jzh}
</foreach>)
</select>
<select id="getPatientIdByInpatientNo" resultType="java.lang.String">
select patient_id
from docus_medicalrecord.t_basic
where inpatient_no=#{inPatientNo}
and admiss_times=#{visitId}
and ph is null
</select>
<select id="getJzhByInpatientNo" resultType="java.lang.String">
select jzh
from docus_medicalrecord.t_basic
where inpatient_no=#{inPatientNo}
and admiss_times=#{visitId}
and ph is null
</select>
<select id="getPatientIdByInpatientNoAndDate" resultType="java.lang.String">
select patient_id
from docus_medicalrecord.t_basic
where jzh=#{jzh}
where inpatient_no=#{inPatientNo}
and DATE_FORMAT(dis_date,'%Y-%m-%d')=#{disDate}
and ph is null
</select>
<resultMap id="groupByJzh" type="com.docus.bgts.entity.JzhListSync">
<result property="jzh" column="jzh"></result>
<collection property="taskDetails" ofType="com.docus.bgts.entity.TaskDetail">
<result property="id" column="id"></result>
<result property="state" column="state"></result>
<result property="fileTitle" column="fileTitle"></result>
</collection>
</resultMap>
</mapper>

@ -0,0 +1,61 @@
<?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.docus.bgts.mapper.dbmysql.TBasicOutMapper">
<insert id="insert" >
insert into docus_medicalrecord.t_basic_out (patient_id,inpatient_no,jzh,admiss_id,name,dis_date,dis_dept,dis_dept_name,diag_doctor_code,diag_doctor_name,create_time)
values (#{patientId},#{inpatientNo},#{jzh},#{admissId},#{name},#{disDate},#{disDept},#{disDeptName},#{diagDoctorCode},#{diagDoctorName},#{createTime})
</insert>
<update id="update">
update docus_medicalrecord.t_basic_out
<set>
<if test="inpatientNo!=null">
inpatient_no=#{inpatientNo},
</if>
<if test="jzh!=null">
jzh=#{jzh},
</if>
<if test="admissId!=null">
admiss_id=#{admissId},
</if>
<if test="name!=null">
name=#{name},
</if>
<if test="disDate!=null">
dis_date=#{disDate},
</if>
<if test="disDept!=null">
dis_dept=#{disDept},
</if>
<if test="disDeptName!=null">
dis_dept_name=#{disDeptName},
</if>
<if test="diagDoctorCode!=null">
diag_doctor_code=#{diagDoctorCode},
</if>
<if test="diagDoctorName!=null">
diag_doctor_name=#{diagDoctorName},
</if>
<if test="updateTime!=null">
update_time=#{updateTime},
</if>
</set>
where patient_id=#{patientId}
</update>
<select id="selectByJzh" resultType="com.docus.bgts.entity.TBasicOut">
select *
from docus_medicalrecord.t_basic_out
where jzh=#{jzh}
</select>
</mapper>

@ -0,0 +1,25 @@
<?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.docus.bgts.mapper.dbmysql.TScanAssortMapper">
<!--根据记账号集合查询文件信息集合-->
<select id="selectFilesByJzhs" resultMap="mzSyncAnddeI">
SELECT
C3 jzh,
sysflag collectid,
c1 serialnum,
c2 fileTitle
FROM
af_collect_task
WHERE
state = '3'
AND C3 IN <foreach collection="jzhs" item="jzh" close=")" open="(" separator=",">#{jzh}</foreach>
</select>
<resultMap id="mzSyncAnddeI" type="com.docus.bgts.entity.MzSync">
<result property="jzh" column="jzh"></result>
<collection property="mzSyncDetails" ofType="com.docus.bgts.entity.MzSyncDetails">
<result property="serialnum" column="serialnum"></result>
<result property="fileTitle" column="file_title"></result>
<result property="collectid" column="collectid"></result>
</collection>
</resultMap>
</mapper>

@ -0,0 +1,22 @@
<?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.docus.bgts.mapper.dbmysql.ZdAssortMapper">
<resultMap id="BaseResultMap" type="com.docus.bgts.entity.ZdAssort">
</resultMap>
<select id="selectAll" resultMap="BaseResultMap">
SELECT
assort_id,
assort_name
FROM
zd_assort
WHERE
effective = 1
<if test="assortName != null and assortName != ''">
AND assort_name = #{assortName}
</if>
</select>
<insert id="insertZdAssort">
insert into zd_assort(assort_id,assort_name,effective) values(#{zdAssort.assortId},#{zdAssort.assortName},#{zdAssort.effective})
</insert>
</mapper>

@ -9,24 +9,30 @@
(SELECT "NAVICAT_TABLE".*, ROWNUM "NAVICAT_ROWNUM"
FROM
(SELECT
a.DOCUMENT_TOPIC as assortName,
a.DOCUMENT_TITLE as file_title,
a.UNIQUE_ID as serialnum,
<foreach collection="jzhs" item="jzh" close=")" open="(" separator=",">
#{jzh} as jzh,
a.VISITING_SERIAL_NUMBER as jzh,
a.ARCHIVED_URL as fileUrl,
a.DOCUMENT_PRODUCER as collectid,
ROWID "NAVICAT_ROWID"
FROM "${tableNamespace}"."${tableName}" a
where VISITING_SERIAL_NUMBER in
<foreach collection="jzhs" item="jzh" close=")" open="(" separator=",">
#{jzh}
</foreach>
) "NAVICAT_TABLE"
)
</select>
<resultMap id="mzSyncAnddeI" type="com.docus.bgts.entity.MzSync">
<result property="jzh" column="jzh"></result>
<collection property="mzSyncDetails" ofType="com.docus.bgts.entity.MzSyncDetails">
<result property="assortName" column="assortName"></result>
<result property="serialnum" column="serialnum"></result>
<result property="fileTitle" column="file_title"></result>
<result property="fileUrl" column="fileUrl"></result>
<result property="collectid" column="collectid"></result>
</collection>
</resultMap>
</mapper>

@ -5,26 +5,29 @@
<mapper namespace="com.docus.bgts.mapper.dboracle.VDocumentPdfMapper">
<select id="listCollectPage" resultType="map">
SELECT
*
*
FROM
(
SELECT
"NAVICAT_TABLE".*,
ROWNUM "NAVICAT_ROWNUM"
FROM
(
SELECT
<foreach collection="fieldArr" item="field" separator=",">
${namespace}.${tableName}.${field}
</foreach>
FROM
${namespace}.${tableName}
WHERE
${collectTimeName} BETWEEN TO_DATE ( #{startTime}, 'YYYY-MM-DD HH24:MI:SS' )
AND TO_DATE ( #{endTime}, 'YYYY-MM-DD HH24:MI:SS' )
) "NAVICAT_TABLE"
SELECT
"NAVICAT_TABLE".*,
ROWNUM "NAVICAT_ROWNUM"
FROM
(
SELECT
<foreach collection="fieldArr" item="field" separator=",">
${namespace}.${tableName}.${field}
</foreach>
FROM
${namespace}.${tableName}
WHERE
${collectTimeName} BETWEEN TO_DATE ( #{startTime}, 'YYYY-MM-DD HH24:MI:SS' )
AND TO_DATE ( #{endTime}, 'YYYY-MM-DD HH24:MI:SS' )
) "NAVICAT_TABLE"
WHERE
ROWNUM &lt;= ${size}
)
WHERE
ROWNUM &lt;= ${size} ) WHERE "NAVICAT_ROWNUM" &gt;= ${current}
"NAVICAT_ROWNUM" &gt; ${current}
</select>
</mapper>

@ -0,0 +1,9 @@
<?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.docus.bgts.mapper.dbsqlserver.PatientBLMapper">
<select id="selectByVisitId" resultType="com.docus.bgts.entity.PatientBL">
select * from view_patient_BL where VisitId=#{visitId} and PDFFilePath is not null
</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.docus.bgts.mapper.dbsqlserver.PatientBRMapper">
<select id="selectAll" resultType="map">
select * from (
select ROW_NUMBER() OVER(Order by DIS_DATE ) AS RowId,*
from view_patient_BR) t
where INHOSP_NO=600100123346
</select>
<select id="selectAlll" resultType="map">
select * from (
select ROW_NUMBER() OVER(Order by DIS_DATE ) AS RowId,*
from view_patient_BR) t
where RowId between #{size} and #{current} and DIS_DATE between #{startDate} and #{endDate};
</select>
</mapper>

@ -0,0 +1,44 @@
<?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.docus.bgts.mapper.dbsqlserver.ScanningMapper">
<select id="selectAll" resultType="map">
select *
from (
select ROW_NUMBER() OVER(Order by 扫描日期 ) AS RowId,*
from pat_sm
where 扫描日期 between #{startDate} and #{endDate}
and 扫描盘号 like 'G%') t
where RowId between #{size} and #{current}
</select>
<!-- <select id="selectAllByDisDate111" resultType="map">-->
<!-- select * from (-->
<!-- select ROW_NUMBER() OVER(Order by 出院日期 ) AS RowId,*-->
<!-- from pat_sm where 出院日期 between #{startDate} and #{endDate} and 扫描盘号 like 'G%') t-->
<!-- where RowId between #{size} and #{current}-->
<!-- </select>-->
<select id="selectAllByDisDate" resultType="map">
select *
from (
select ROW_NUMBER() OVER(Order by 出院日期 ) AS RowId,*
from pat_sm
where 出院日期 between #{startDate} and #{endDate}
and 扫描盘号 like 'G%') t
where RowId between #{size} and #{current}
</select>
<select id="selectByInpatientId" resultType="map">
select *
from pat_sm
where and 扫描盘号 like 'G%'
</select>
<select id="selectByInPatientId" resultType="map">
select * from pat_sm where 住院号=#{inPatientId} and 次数=#{vistId}
</select>
<select id="selectRow" resultType="int">
select count(*) from pat_sm where 住院号=#{inPatientId} and 次数=#{vistId}
</select>
</mapper>

@ -0,0 +1,13 @@
<?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.docus.bgts.mapper.dbsqlserver.TestttMapper">
<select id="selectAll" resultType="map">
select * from (
select ROW_NUMBER() OVER(Order by RecodeTime ) AS RowId,*
from patient_BL) t
where RowId between #{size} and #{current};
</select>
</mapper>
Loading…
Cancel
Save