Compare commits

..

27 Commits

Author SHA1 Message Date
wyb edb0fb4e7f feat: 厦门中医院联众工具处理,无需路径 5 months ago
wyb 81a2672a65 imp: 改进线程池使用 5 months ago
wyb 59bba70ffe imp: 改进线程池使用 5 months ago
wyb eb30e54eef feat: 添加job补偿人工部分 5 months ago
wyb dc62b04aee feat: 添加后期人工处理接口 5 months ago
wyb a5ff268a86 fix: 批量传根据第一次删除全部 5 months ago
wyb cc2b6d06d5 fix: 优化获取目录 5 months ago
wyb 1d15965dc9 fix: 优化目录确认规则直接使用equals 5 months ago
wyb 6201f3c7a5 fix: 修复目录确认规则,添加出院日期确认 5 months ago
wyb 930a9b3494 feat: 厦门中医院联众采集端 6 months ago
wyb 93b710be70 feat: 厦门中医院联众采集端 6 months ago
wyb c316a76c66 feat: 添加分批次调用 8 months ago
wyb 79593b9a9d fix:检查成功修复未删除文件 8 months ago
wyb cdbe3d579e fix:检查添加结果日志 8 months ago
wyb 470192354a feat: 市一联众添加检查接口 8 months ago
wyb 46499927e1 feat: 市一联众添加接口修改状态 10 months ago
wyb 03eb85f2f9 feat: 市一联众同步添加web,可以补偿同步 10 months ago
zhanghai 966e66abec 修改注释 12 months ago
zhanghai 15462c6a27 修改文件的上传超时时间,
修改线程数
12 months ago
zhanghai 9fdc6a8dbc 1. 打印日志
2. 调整同时并发上传参数。
3. 调整上传内容
1 year ago
zhanghai 2dcd666b7c 1. 打印日志
2. 调整同时并发上传参数。
3. 调整上传内容
1 year ago
zhanghai befeed1979 1. 打印日志
2. 调整同时并发上传参数。
3. 调整上传内容
1 year ago
zhanghai 7ad3f4f7b9 上传联众代码 1 year ago
zhanghai 26d841d833 上传联众代码 1 year ago
zhanghai 768bf819d4 打开配置信息 1 year ago
zhanghai 5f6feb7a57 修改为广州市市一 1 year ago
zhanghai aaf6559e4d 修改为广州市市一 1 year ago

@ -2,6 +2,7 @@
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />

@ -13,8 +13,48 @@
<version>2.4.9</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<!-- RESTful APIs swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.21</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.21</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.9.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
@ -35,6 +75,11 @@
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
@ -57,6 +102,25 @@
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.8</version>
</dependency>
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-jpeg</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-tiff</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
<build>
@ -75,6 +139,7 @@
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<swagger.version>2.9.2</swagger.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

@ -21,4 +21,19 @@ public class CommonResult<T> {
private T data;
public static <T> CommonResult<T> success(T data){
CommonResult commonResult = new CommonResult();
commonResult.setCode(0);
commonResult.setMsg("操作成功");
commonResult.setData(data);
return commonResult;
}
public static <T> CommonResult<T> failed(T data){
CommonResult commonResult = new CommonResult();
commonResult.setCode(500);
commonResult.setMsg("操作失败");
commonResult.setData(data);
return commonResult;
}
}

@ -0,0 +1,96 @@
package com.jiashi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Objects;
/**
* @author
*/
public class FilePathUtil {
private static final Logger logger = LoggerFactory.getLogger(FilePathUtil.class);
/**
*
*
* @return
*/
public static String currentPath() {
try {
File file = new File(".");
return file.getCanonicalPath();
} catch (Exception ex) {
return null;
}
}
/**
*
*
* @return
*/
public static String tempPath() {
String tempPath;
try {
tempPath = currentPath() + File.separator + "temp";
} catch (Exception ex) {
tempPath = "C:\\docus\\temp";
}
mkdirs(tempPath);
return tempPath;
}
/**
*
* @param path
*/
public static void mkdirs(String path) {
path = Objects.requireNonNull(path);
mkdirs(new File(path));
}
/**
*
* @param file
*/
public static void mkdirs(File file) {
if (!file.exists()) {
if (!file.mkdirs()) {
// Not processed
logger.warn("mkdirs error {}", file);
}
}
}
/**
*
* @param dir
*/
public static void deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
if (children!=null) {
//递归删除目录中的子目录下
for (String child : children) {
deleteDir(new File(dir, child));
}
}
}
// 目录此时为空,可以删除
dir.delete();
}
/**
*
* @param dir
*/
public static void deleteDir(String dir) {
deleteDir(new File(dir));
}
}

@ -2,44 +2,52 @@ package com.jiashi;
import com.google.gson.Gson;
import com.jiashi.service.FormField;
import okhttp3.*;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class FileUploader {
public static CommonResult uploadFilesWithParams(List<File> files, String uploadUrl, List<FormField> params) throws IOException {
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(6000, TimeUnit.SECONDS)
.readTimeout(6000, TimeUnit.SECONDS)
.writeTimeout(6000, TimeUnit.SECONDS)
.build();
MultipartBody.Builder builder = new MultipartBody.Builder();
for (File file : files) {
RequestBody body = RequestBody.create(MediaType.parse("multipart/form-data"), file);
public static CommonResult uploadFilesWithParams(List<File> files, String uploadUrl, List<FormField> params) {
try {
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(6000, TimeUnit.SECONDS)
.readTimeout(6000, TimeUnit.SECONDS)
.writeTimeout(6000, TimeUnit.SECONDS)
.build();
MultipartBody.Builder builder = new MultipartBody.Builder();
for (File file : files) {
RequestBody body = RequestBody.create(MediaType.parse("multipart/form-data"), file);
// RequestBody body = RequestBody.create(MediaType.parse("image/jpeg"), file);
builder.addFormDataPart("files", file.getName(), body);
}
for(FormField formField:params){
builder.addFormDataPart(formField.getKey(), formField.getValue());
}
// 下行是上传的json的对象其中上面的fileName和下行的fromData需和后台接口名字一致
RequestBody requestBody = builder.setType(MultipartBody.FORM).build();
final Request request = new Request.Builder()
.url(uploadUrl)
.post(requestBody)
.build();
Response response = client.newCall(request).execute();
String responseBody = response.body().string();
CommonResult commonResult = new Gson().fromJson(responseBody, CommonResult.class);
return commonResult;
builder.addFormDataPart("files", file.getName(), body);
}
for(FormField formField:params){
builder.addFormDataPart(formField.getKey(), formField.getValue());
}
// 下行是上传的json的对象其中上面的fileName和下行的fromData需和后台接口名字一致
RequestBody requestBody = builder.setType(MultipartBody.FORM).build();
final Request request = new Request.Builder()
.url(uploadUrl)
.post(requestBody)
.build();
Response response = client.newCall(request).execute();
String responseBody = response.body().string();
CommonResult commonResult = new Gson().fromJson(responseBody, CommonResult.class);
return commonResult;
}catch (Exception ex){
throw new RuntimeException(ex);
}
}
public static void deleteFolder(File folder) {
@ -54,28 +62,58 @@ public class FileUploader {
folder.delete();
}
public static void main(String[] args) throws IOException {
List<File> files = new ArrayList<>();
files.add(new File("C:\\jiahsi-saomiao\\413425_刘燊杨_20221009_004624\\16763947060057863381.jpg"));
// files.add(new File("C:\\jiahsi-saomiao\\413425_刘燊杨_20221009_004624\\16763947060420811242.jpg"));
// 额外的表单字段参数
List<FormField> params = new ArrayList<>();
params.add(new FormField("uploadFileParams", "[ {\"inpatientNo\":\"35131\", \"disDate\":\"2020-07-30 00:00:00.000\", \"fileTitle\":\"16763947060057863381.jpg\", \"uploadFileName\":\"16763947060057863381.jpg\", \"assortId\":\"078F7675CB0048EDBE586D59831C57B0\" ,\n" +
"\"patientId\":\"12312312\",\n" +
"\"name\":\"长三\",\n" +
"\"admissDate\":\"2022-02-01\",\n" +
"\"sex\":\"男女\"\n" +
"}\n" +
"]"));
// 上传URL
String uploadUrl = "http://192.168.16.116:8711/api/downplatform/fileUploadJpg";
public static void main(String[] args) {
FileUploader fileUploader = new FileUploader();
ExecutorService syncExecutors = Executors.newFixedThreadPool(2);
syncExecutors.execute(fileUploader::t1);
try {
syncExecutors.execute(fileUploader::t2);
}catch (Exception ex){
ex.printStackTrace();
}finally {
syncExecutors.shutdown();
}
}
public void t1(){
for (int i = 0; i < 10; i++) {
System.out.println("t1 >>>> "+i);
try {
Thread.sleep(3*1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
// 执行批量上传
uploadFilesWithParams(files, uploadUrl, params);
public void t2(){
for (int i = 0; i < 10; i++) {
System.out.println("t2 >>>> "+i);
}
}
// public static void main(String[] args) throws IOException {
// List<File> files = new ArrayList<>();
// files.add(new File("C:\\jiahsi-saomiao\\413425_刘燊杨_20221009_004624\\16763947060057863381.jpg"));
//// files.add(new File("C:\\jiahsi-saomiao\\413425_刘燊杨_20221009_004624\\16763947060420811242.jpg"));
//
//
// // 额外的表单字段参数
// List<FormField> params = new ArrayList<>();
// params.add(new FormField("uploadFileParams", "[ {\"inpatientNo\":\"35132331\", \"admiss_id\":\"12312342342312\",\"admiss_times\":\"1\",\"disDate\":\"2020-07-30 00:00:00.000\", \"fileTitle\":\"16763947060057863381.jpg\", \"uploadFileName\":\"16763947060057863381.jpg\", \"assortId\":\"078F7675CB0048EDBE586D59831C57B0\" ,\n" +
// "\"patientId\":\"12323432412312\",\n" +
// "\"name\":\"长三\",\n" +
// "\"admissDate\":\"2022-02-01\",\n" +
// "\"sex\":\"男\"\n" +
// "}\n" +
// "]"));
//
// // 上传URL
// String uploadUrl = "http://192.168.16.116:9511/fileUploadJpg";
//
// // 执行批量上传
// CommonResult commonResult = uploadFilesWithParams(files, uploadUrl, params);
// System.out.println(new Gson().toJson(commonResult));
// }
}

@ -0,0 +1,45 @@
package com.jiashi.config;
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* api /swagger-ui.html
* @author Zheng Jie
* @date 2018-11-23
*/
@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUI
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
ParameterBuilder ticketPar = new ParameterBuilder();
return new Docket(DocumentationType.SWAGGER_2)
.enable(true)
.apiInfo(apiInfo())
.select()
.paths(Predicates.not(PathSelectors.regex("/error.*")))
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("接口文档")
.version("1.0")
.build();
}
}

@ -0,0 +1,36 @@
package com.jiashi.controller;
import com.jiashi.CommonResult;
import com.jiashi.service.UpdateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author YongBin Wen
* @date 2025/2/13 19:50
*/
@RestController
@Slf4j
@Api(tags = "厦门中医院联众同步接口")
@RequestMapping("/xiamenzyy/lianzhong")
public class LianZhongSyncController {
@Autowired
private UpdateService updateService;
@ApiOperation(value = "补偿状态为4的患者状态为2原因是没找到患者目录的手动处理后添加目录并且状态改为4")
@GetMapping("/sync/dirnotexists")
public CommonResult<String> sycDirNotExists() {
try {
updateService.sycDirNotExists();
return CommonResult.success("补偿完毕!");
} catch (Exception ex) {
log.error("补偿异常 "+ex.getMessage(),ex);
return CommonResult.failed("补偿异常!");
}
}
}

@ -22,4 +22,14 @@ public interface CardInfoRepository extends JpaRepository<CardInfo, String>, Jpa
@Modifying
@Query("update CardInfo set state=:state where id in :ids")
public void updateState(List<String> ids, Integer state);
@Transactional(rollbackFor = Exception.class)
@Modifying
@Query("update CardInfo set state=:state,describe = :describe where id = :id")
void updateState(String id, Integer state, String describe);
@Transactional(rollbackFor = Exception.class)
@Modifying
@Query("update CardInfo set findpicpath=:findpicpath where id = :id")
void updatePicPath(String id, String findpicpath);
}

@ -2,20 +2,28 @@ package com.jiashi.dao;
import com.jiashi.service.CardInfo;
import com.jiashi.service.Picture;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;
import javax.persistence.criteria.Predicate;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@Repository
@Slf4j
public class DataQuery {
@ -25,48 +33,121 @@ public class DataQuery {
@Autowired
private PictureRepository pictureRepository;
public List<CardInfo> dateQuery(){
Specification<CardInfo> specification = (root, query, cb) -> {
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(root.<String>get("state"), 0));
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
};
@Value("${lz.disdate-range:}")
private String disdateRange;
private static final Lock cardInfoTableLock = new ReentrantLock();
public List<CardInfo> dateQuery() {
cardInfoTableLock.lock();
try {
Specification<CardInfo> specification = (root, query, cb) -> {
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(root.<String>get("state"), 0));
if (StringUtils.hasText(disdateRange)) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String[] split = disdateRange.split(",");
try {
predicates.add(cb.between(root.<Date>get("outdate"), simpleDateFormat.parse(split[0]), simpleDateFormat.parse(split[1])));
} catch (ParseException e) {
log.error("出院时间条件错误:" + disdateRange + "," + e.getMessage(), e);
}
}
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
};
Sort.Order sortCreateTime = Sort.Order.asc("outdate");
Sort sort = Sort.by(sortCreateTime);
Pageable pageable = PageRequest.of(0, 1000, sort);
Page<CardInfo> all = cardInfoRepository.findAll(specification, pageable);
return all.toList();
} finally {
cardInfoTableLock.unlock();
Sort.Order sortCreateTime = Sort.Order.asc("outdate");
Sort sort = Sort.by(sortCreateTime);
Pageable pageable = PageRequest.of(0, 100, sort);
Page<CardInfo> all = cardInfoRepository.findAll(specification, pageable);
return all.toList();
}
}
public List<CardInfo> dateQuery(int state) {
cardInfoTableLock.lock();
try {
Specification<CardInfo> specification = (root, query, cb) -> {
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(root.<String>get("state"), state));
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
};
List<CardInfo> all = cardInfoRepository.findAll(specification);
return all;
} finally {
cardInfoTableLock.unlock();
public void updateBatch(List<CardInfo> cardInfos){
for(CardInfo cardInfo:cardInfos){
cardInfo.setState(1);
}
cardInfoRepository.saveAll(cardInfos);
}
public void updateBatchState(List<CardInfo> cardInfos,Integer state){
List<String> ids = new ArrayList<>();
for(CardInfo cardInfo:cardInfos){
String id = cardInfo.getId();
ids.add(id);
}
cardInfoRepository.updateState(ids,state);
public List<CardInfo> dateQueryByInpNo(String inpNo) {
cardInfoTableLock.lock();
try {
Specification<CardInfo> specification = (root, query, cb) -> {
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(root.<String>get("patno"), inpNo));
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
};
Sort.Order sortCreateTime = Sort.Order.asc("outdate");
Sort sort = Sort.by(sortCreateTime);
Pageable pageable = PageRequest.of(0, 1000, sort);
Page<CardInfo> all = cardInfoRepository.findAll(specification, pageable);
return all.toList();
} finally {
cardInfoTableLock.unlock();
}
}
public void updateBatch(List<CardInfo> cardInfos) {
cardInfoTableLock.lock();
try {
for (CardInfo cardInfo : cardInfos) {
cardInfo.setState(1);
}
cardInfoRepository.saveAll(cardInfos);
} finally {
cardInfoTableLock.unlock();
}
public void updateBatchState(CardInfo cardInfo,Integer state){
}
cardInfoRepository.updateState(cardInfo.getId(),state);
public void updateBatchState(List<CardInfo> cardInfos, Integer state) {
cardInfoTableLock.lock();
try {
List<String> ids = new ArrayList<>();
for (CardInfo cardInfo : cardInfos) {
String id = cardInfo.getId();
ids.add(id);
}
cardInfoRepository.updateState(ids, state);
} finally {
cardInfoTableLock.unlock();
}
}
public List<Picture> getPictures(String FileId){
public void updateBatchState(CardInfo cardInfo, Integer state) {
cardInfoTableLock.lock();
try {
cardInfoRepository.updateState(cardInfo.getId(), state);
} finally {
cardInfoTableLock.unlock();
}
}
public List<Picture> getPictures(String FileId) {
Specification<Picture> specification = (root, query, cb) -> {
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(root.<String>get("fileid"), FileId));
@ -77,4 +158,24 @@ public class DataQuery {
}
public void updateBatchState(CardInfo cardInfo, Integer state, String desc) {
cardInfoTableLock.lock();
try {
cardInfoRepository.updateState(cardInfo.getId(), state, desc);
} finally {
cardInfoTableLock.unlock();
}
}
public void updatePicPath(CardInfo cardInfo, String findpicpath) {
cardInfoTableLock.lock();
try {
cardInfoRepository.updatePicPath(cardInfo.getId(), findpicpath);
} finally {
cardInfoTableLock.unlock();
}
}
}

@ -1,10 +1,8 @@
package com.jiashi.service;
import com.jiashi.MyDateUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -32,27 +30,47 @@ public class CardInfo {
private Date outdate;
@Column(name="indate")
private Date indate;
private String outdeptcode;
@Column(name="outdeptname")
private String outdeptname;
@Column(name="patsex")
private String patsex;
@Column(name="pat_path")
private String pat_path;
@Column(name="patbirthday")
private Date patbirthday;
private Integer state;
private String describe;
@Column(name="findpicpath")
private String findpicpath;
private String icdecode11;
private String icdename11;
@Column(name="mjwesticde")
private String mjwesticde;
@Column(name="mjwestname")
private String mjwestname;
private String patciticard;
private Integer patage;
private String indeptcode;
private String indeptname;
private String outwardname;
public String getOutdateStr(){
return MyDateUtil.dateToString(this.outdate,"yyyy-MM-dd");
}
public String getOutdateStr2(){
return MyDateUtil.dateToString(this.outdate,"yyyy-MM-dd HH:mm:ss");
}
private Integer patnum;
private String gestno;
public String getIndateStr(){
return MyDateUtil.dateToString(this.indate,"yyyy-MM-dd HH:mm:ss");
}
}

@ -0,0 +1,109 @@
package com.jiashi.service;
import lombok.Data;
import java.util.List;
/**
*
*/
@Data
public class LianZhongUploadInfo {
/**
*
*
*/
@Data
public static class PatientInfo {
/**
*
*/
private String inpatientNo;
/**
*
*/
private Integer admissTimes;
/**
*
*/
private String name;
/**
* 12
*/
private String sex;
/**
*
*/
private String sexName;
/**
* -
*/
private Integer age;
/**
* yyyy-MM-dd HH:mm:ss
*/
private String admissDate;
/**
* yyyy-MM-dd HH:mm:ss
*/
private String disDate;
/**
*
*/
private String admissDeptName;
/**
*
*/
private String disDeptName;
/**
*
*/
private String idCard;
/**
*
*/
private String mainDiagCode;
/**
*
*/
private String mainDiagName;
/**
*
*/
private String mainOperateCode;
/**
*
*/
private String mainOperateName;
}
/**
*
*
*/
@Data
public static class FileInfo {
/**
* id
*/
private String assortId;
/**
*
*/
private String fileTitle;
/**
*
*/
private String uploadFileName;
/**
*
*/
private int sort;
}
private PatientInfo patientInfo;
private List<FileInfo> fileInfos;
private int delAllFile;
}

@ -4,23 +4,22 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.*;
@Entity
@Table(name = "T_Picture")
@Data
@NoArgsConstructor
@AllArgsConstructor
@IdClass(PicturePk.class)
public class Picture {
@Id
@Column(name="picid")
private String picid;
@Id
@Column(name="picname")
private String picname;
@Id
@Column(name="fileid")
private String fileid;
@Column(name="rotatedegree")
@ -29,9 +28,7 @@ public class Picture {
@Column(name="pickind")
private String pickind;
public String getFileUrl(){
String fileUrl = "d:/pic/" + this.getFileid() + "/" + this.getPicname();
return fileUrl;
}
@Column(name="picno")
private Integer picno;
}

@ -0,0 +1,11 @@
package com.jiashi.service;
import lombok.Data;
import java.io.Serializable;
@Data
public class PicturePk implements Serializable {
private String picname;
private String fileid;
}

@ -2,23 +2,44 @@ package com.jiashi.service;
import com.google.gson.Gson;
import com.jiashi.CommonResult;
import com.jiashi.FilePathUtil;
import com.jiashi.FileUploader;
import com.jiashi.dao.DataQuery;
import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.Thumbnails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
@Component
@Slf4j
@ -26,132 +47,533 @@ public class UpdateService {
@Autowired
private DataQuery dataQuery;
@Value("${lz.uploadUrl:http://129.7.1.25:9511/lianzhong/batchFileUploadJpg}")
private String uploadUrl;
public List<CardInfo> updateData(){
private Set<String> lianZhongPatPicDirs = new HashSet<>();
/**
* +10+8
*/
private Map<String, Map<String, Set<String>>> lianZhongPatPicDirMap = new HashMap<>();
public List<CardInfo> updateData() {
List<CardInfo> cardInfos = dataQuery.dateQuery();
dataQuery.updateBatchState(cardInfos,1);
dataQuery.updateBatchState(cardInfos, 1);
return cardInfos;
}
//state 状态标识。0 未开始, 1 正在进行, 3. 已经成功。 4. 失败。5. 不需要上传的
@PostConstruct
public void upload() {
String uniUrl = "http://10.2.3.24";
List<CardInfo> cardInfos = null;
ExecutorService executor2 = Executors.newFixedThreadPool(2);
ExecutorService executor = Executors.newFixedThreadPool(5);
do {
try{
cardInfos = this.updateData();
List<Future> futures2 = new ArrayList<>();
for (CardInfo cardInfo : cardInfos) {
log.info("开始同步"+cardInfo.getPatno());
Future future2 = executor2.submit(()->{
try{
List<Picture> pictures = dataQuery.getPictures(cardInfo.getId());
if(pictures==null||pictures.size()==0){
//如果是空的则不同步
dataQuery.updateBatchState(cardInfo,5);
return;
}
List<Future> futures = new ArrayList<>();
for (Picture picture : pictures) {
Future future = executor.submit(() -> {
public void upload() {
initLianZhongPatPicDir();
ExecutorService syncExecutors = Executors.newFixedThreadPool(2);
syncExecutors.execute(this::syncNotStart);
syncExecutors.execute(this::sycDirNotExistsJob);
}
public void syncNotStart() {
log.info("联众同步数据启动>>>>>>>>>>>>>>>>>>>>");
String syncDir = FilePathUtil.currentPath() + File.separator + "lianzhong-sync";
FilePathUtil.mkdirs(syncDir);
int corePoolSize = Runtime.getRuntime().availableProcessors();
int maximumPoolSize = corePoolSize * 2;
long keepAliveTime = 300L;
TimeUnit unit = TimeUnit.SECONDS;
LinkedBlockingDeque<Runnable> workQueue = new LinkedBlockingDeque<>();
ThreadFactory threadFactory = Executors.defaultThreadFactory();
ThreadPoolExecutor.CallerRunsPolicy handler = new ThreadPoolExecutor.CallerRunsPolicy();
ExecutorService patientExecutors = Executors.newFixedThreadPool(corePoolSize);
ThreadPoolExecutor fileExecutor = new ThreadPoolExecutor(corePoolSize,
maximumPoolSize,
keepAliveTime,
unit,
workQueue,
threadFactory,
handler);
try {
while (true) {
List<CardInfo> cardInfos = this.updateData();
if (!CollectionUtils.isEmpty(cardInfos)) {
List<Future> patientFutures = new ArrayList<>();
for (CardInfo cardInfo : cardInfos) {
String picDir = syncDir + File.separator + cardInfo.getId();
FilePathUtil.mkdirs(picDir);
Future patientFuture = patientExecutors.submit(() -> {
try {
List<Picture> pictures = dataQuery.getPictures(cardInfo.getId());
if (CollectionUtils.isEmpty(pictures)) {
//如果是空的则不同步
dataQuery.updateBatchState(cardInfo, 5);
FilePathUtil.deleteDir(picDir);
return;
}
dataQuery.updatePicPath(cardInfo, "联众工具转换");
List<Future> fileFutures = new ArrayList<>();
for (Picture picture : pictures) {
Future fileFuture = fileExecutor.submit(() -> {
SimpleDateFormat sdfYmd = new SimpleDateFormat("yyyy-MM-dd");
String destJpgFilePath = picDir + File.separator + removeFileExtension(picture.getPicname()) + ".jpg";
String cmd = "C:\\lztool\\Debug\\lianzhong.exe 003 192.169.2.170 " + cardInfo.getId() + " " + picture.getPicid() + " " + cardInfo.getPatno() + " " + sdfYmd.format(cardInfo.getOutdate()) + " " + picture.getPicname() + " " + destJpgFilePath + " http://192.169.2.170:8080 " + picture.getRotatedegree();
try {
java.lang.Process process = java.lang.Runtime.getRuntime().exec(cmd);//执行命令生成cube
process.waitFor();
}catch (Exception ex){
log.error("图片转换异常,命令:"+cmd,ex);
}
});
fileFutures.add(fileFuture);
}
for (Future future : fileFutures) {
try {
String dir = "d:\\pic\\"+picture.getFileid();
// 创建File对象
File directory = new File(dir);
// 判断目录是否存在
if (!directory.exists()) {
// 目录不存在,创建目录
boolean created = directory.mkdirs();
if (created) {
log.info("目录创建成功:" + dir);
} else {
log.info("目录创建失败:" + dir);
future.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
LianZhongUploadInfo.PatientInfo patientInfo = convert(cardInfo);
List<LianZhongUploadInfo.FileInfo> fileInfos = new ArrayList<>();
List<String> faultFileNames = new ArrayList<>();
List<File> files = new ArrayList<>();
for (Picture picture : pictures) {
File pictureFile = new File(picDir + File.separator + removeFileExtension(picture.getPicname()) + ".jpg");
if (!pictureFile.exists()) {
faultFileNames.add(picture.getPicname());
continue;
}
files.add(pictureFile);
LianZhongUploadInfo.FileInfo fileInfo = new LianZhongUploadInfo.FileInfo();
fileInfo.setFileTitle(picture.getPicname());
fileInfo.setUploadFileName(pictureFile.getName());
fileInfo.setAssortId(picture.getPickind());
fileInfo.setSort(picture.getPicno());
fileInfos.add(fileInfo);
}
if (files.isEmpty()) {
dataQuery.updateBatchState(cardInfo, 2, "未获取到图片!");
// 删除文件
FilePathUtil.deleteDir(picDir);
return;
}
LianZhongUploadInfo uploadInfo = new LianZhongUploadInfo();
uploadInfo.setPatientInfo(patientInfo);
uploadInfo.setFileInfos(fileInfos);
uploadInfo.setDelAllFile(1);
try {
Map<String, LianZhongUploadInfo.FileInfo> fileInfoMap = fileInfos.stream()
.collect(Collectors.toMap(LianZhongUploadInfo.FileInfo::getUploadFileName, Function.identity()));
boolean success = true;
// 上传
int totalSize = files.size();
int batchSize = 500;
if (totalSize > batchSize) {
for (int i = 0; i < totalSize; i += batchSize) {
ArrayList<File> batch = new ArrayList<>();
List<LianZhongUploadInfo.FileInfo> uploadFileInfoList = new ArrayList<>();
// 计算当前批次的结束索引
int end = Math.min(i + batchSize, totalSize);
for (int j = i; j < end; j++) {
batch.add(files.get(j));
uploadFileInfoList.add(fileInfoMap.get(files.get(j).getName()));
}
uploadInfo.setFileInfos(uploadFileInfoList);
// 额外的表单字段参数
List<FormField> params = new ArrayList<>();
String s = new Gson().toJson(uploadInfo);
params.add(new FormField("uploadFileParams", s));
CommonResult commonResult = FileUploader.uploadFilesWithParams(batch, uploadUrl, params);
boolean res = commonResult.getCode() == 0;
success = success && res;
uploadInfo.setDelAllFile(0);
}
String cmd = "D:\\lianzhong\\Debug\\Debug\\lianzhong.exe 003 192.168.8.74 " + cardInfo.getId() + " " + picture.getPicid() + " " + cardInfo.getPatno() + " " + cardInfo.getOutdateStr() + " " + picture.getPicname() + " " + picture.getFileUrl() + " " + uniUrl + " " + picture.getRotatedegree();
log.info(cmd);
java.lang.Process process = java.lang.Runtime.getRuntime().exec(cmd);//执行命令生成cube
process.waitFor();
} catch (Exception e) {
log.error(e.getMessage(),e);
e.printStackTrace();
} else {
// 额外的表单字段参数
List<FormField> params = new ArrayList<>();
String s = new Gson().toJson(uploadInfo);
params.add(new FormField("uploadFileParams", s));
CommonResult commonResult = FileUploader.uploadFilesWithParams(files, uploadUrl, params);
success = commonResult.getCode() == 0;
}
});
futures.add(future);
}
for (Future future : futures) {
try {
future.get();
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
if (success) {
dataQuery.updateBatchState(cardInfo, 3);
} else {
dataQuery.updateBatchState(cardInfo, 2, "上传服务端出现异常!");
}
} catch (Exception e) {
dataQuery.updateBatchState(cardInfo, 2, e.getMessage());
log.error(e.getMessage(), e);
}
if (!faultFileNames.isEmpty()) {
// 不完整
dataQuery.updateBatchState(cardInfo, 2, String.join(",", faultFileNames + " 无法转换jpg图片"));
}
}
List<File> files = new ArrayList<>();
List<UploadInfo> uploadInfos = new ArrayList<>();
for(Picture picture : pictures){
files.add(new File(picture.getFileUrl()));
UploadInfo uploadInfo = new UploadInfo(cardInfo.getPatno(), cardInfo.getOutdateStr2(), picture.getPicname(), picture.getPicname(), picture.getPickind(), cardInfo.getId(), cardInfo.getPatname(), cardInfo.getIndateStr(), cardInfo.getPatsex());
uploadInfos.add(uploadInfo);
// 删除文件
FilePathUtil.deleteDir(picDir);
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
FilePathUtil.deleteDir(picDir);
dataQuery.updateBatchState(cardInfo, 2, ex.getMessage());
}
});
patientFutures.add(patientFuture);
}
for (Future future : patientFutures) {
future.get();
}
continue;
}
TimeUnit.SECONDS.sleep(300);
}
} catch (Exception ex) {
log.error("联众同步数据异常:" + ex.getMessage(), ex);
} finally {
patientExecutors.shutdown();
fileExecutor.shutdown();
}
}
public void sycDirNotExistsJob() {
while (true) {
try {
sycDirNotExists();
TimeUnit.SECONDS.sleep(600);
} catch (Exception ex) {
log.error("补偿异常 " + ex.getMessage(), ex);
}
}
// 额外的表单字段参数
List<FormField> params = new ArrayList<>();
String s = new Gson().toJson(uploadInfos);
params.add(new FormField("uploadFileParams", s));
log.info("请求参数:"+s);
// 上传
try {
CommonResult commonResult = FileUploader.uploadFilesWithParams(files, "http://10.2.130.59:8712/api/downplatform/fileUploadJpg", params);
if(commonResult.getCode()==0){
dataQuery.updateBatchState(cardInfo,3);
}
}else{
dataQuery.updateBatchState(cardInfo,4);
log.error(commonResult.getMsg());
}
} catch (Exception e) {
dataQuery.updateBatchState(cardInfo,4);
log.error(e.getMessage(),e);
}
// 删除文件
String dir = "d:\\pic\\"+cardInfo.getId();
File file = new File(dir);
FileUploader.deleteFolder(file);
}catch (Exception e){
dataQuery.updateBatchState(cardInfo,4);
log.error(e.getMessage(),e);
e.printStackTrace();
public void sycDirNotExists() {
log.info("联众补偿数据启动>>>>>>>>>>>>>>>>>>>>");
String syncDir = FilePathUtil.currentPath() + File.separator + "lianzhong-makeup-sync";
FilePathUtil.mkdirs(syncDir);
List<CardInfo> cardInfos = dataQuery.dateQuery(4);
if (!CollectionUtils.isEmpty(cardInfos)) {
for (CardInfo cardInfo : cardInfos) {
String picDir = syncDir + File.separator + cardInfo.getId();
FilePathUtil.mkdirs(picDir);
List<Picture> pictures = dataQuery.getPictures(cardInfo.getId());
String lianZhongDir = cardInfo.getFindpicpath();
if (lianZhongDir == null) {
FilePathUtil.deleteDir(picDir);
continue;
}
for (Picture picture : pictures) {
String tifFilePath = lianZhongDir + File.separator + removeFileExtension(picture.getPicname()) + ".tif";
File tifFile = new File(tifFilePath);
if (tifFile.exists()) {
try {
BufferedImage read = ImageIO.read(tifFile);
Thumbnails.of(read)
.scale(1)
.outputFormat("jpg")
.rotate(picture.getRotatedegree())
.toFile(picDir + File.separator + removeFileExtension(picture.getPicname()) + ".jpg");
read.flush();
} catch (IOException e) {
log.error("补偿转换文件失败pictureId=" + picture.getPicid() + "," + e.getMessage(), e);
}
});
futures2.add(future2);
}
}
LianZhongUploadInfo.PatientInfo patientInfo = convert(cardInfo);
List<LianZhongUploadInfo.FileInfo> fileInfos = new ArrayList<>();
List<String> faultFileNames = new ArrayList<>();
List<File> files = new ArrayList<>();
for (Picture picture : pictures) {
File pictureFile = new File(picDir + File.separator + removeFileExtension(picture.getPicname()) + ".jpg");
if (!pictureFile.exists()) {
faultFileNames.add(picture.getPicname());
continue;
}
files.add(pictureFile);
LianZhongUploadInfo.FileInfo fileInfo = new LianZhongUploadInfo.FileInfo();
fileInfo.setFileTitle(picture.getPicname());
fileInfo.setUploadFileName(pictureFile.getName());
fileInfo.setAssortId(picture.getPickind());
fileInfo.setSort(picture.getPicno());
fileInfos.add(fileInfo);
}
if (files.isEmpty()) {
dataQuery.updateBatchState(cardInfo, 2, "未获取到图片!");
// 删除文件
FilePathUtil.deleteDir(picDir);
continue;
}
for (Future future : futures2) {
try {
future.get();
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
LianZhongUploadInfo uploadInfo = new LianZhongUploadInfo();
uploadInfo.setPatientInfo(patientInfo);
uploadInfo.setFileInfos(fileInfos);
uploadInfo.setDelAllFile(1);
Map<String, LianZhongUploadInfo.FileInfo> fileInfoMap = fileInfos.stream()
.collect(Collectors.toMap(LianZhongUploadInfo.FileInfo::getUploadFileName, Function.identity()));
boolean success = true;
// 上传
int totalSize = files.size();
int batchSize = 500;
if (totalSize > batchSize) {
for (int i = 0; i < totalSize; i += batchSize) {
ArrayList<File> batch = new ArrayList<>();
List<LianZhongUploadInfo.FileInfo> uploadFileInfoList = new ArrayList<>();
// 计算当前批次的结束索引
int end = Math.min(i + batchSize, totalSize);
for (int j = i; j < end; j++) {
batch.add(files.get(j));
uploadFileInfoList.add(fileInfoMap.get(files.get(j).getName()));
}
uploadInfo.setFileInfos(uploadFileInfoList);
// 额外的表单字段参数
List<FormField> params = new ArrayList<>();
String s = new Gson().toJson(uploadInfo);
params.add(new FormField("uploadFileParams", s));
CommonResult commonResult = FileUploader.uploadFilesWithParams(batch, uploadUrl, params);
boolean res = commonResult.getCode() == 0;
success = success && res;
uploadInfo.setDelAllFile(0);
}
} else {
// 额外的表单字段参数
List<FormField> params = new ArrayList<>();
String s = new Gson().toJson(uploadInfo);
params.add(new FormField("uploadFileParams", s));
CommonResult commonResult = FileUploader.uploadFilesWithParams(files, uploadUrl, params);
success = commonResult.getCode() == 0;
}
}catch(Exception e) {
log.error(e.getMessage(),e);
if (success) {
dataQuery.updateBatchState(cardInfo, 3);
}
if (!faultFileNames.isEmpty()) {
// 不完整
dataQuery.updateBatchState(cardInfo, 2, String.join(",", faultFileNames + " 无法转换jpg图片"));
}
// 删除文件
FilePathUtil.deleteDir(picDir);
}
}
}
public static void main(String[] args) {
UpdateService updateService = new UpdateService();
System.out.println(new Gson().toJson(updateService.lianZhongPatPicDirs));
System.out.println(new Gson().toJson(updateService.lianZhongPatPicDirMap));
updateService.initLianZhongPatPicDir();
System.out.println(new Gson().toJson(updateService.lianZhongPatPicDirs));
System.out.println(new Gson().toJson(updateService.lianZhongPatPicDirMap));
Map<String, Set<String>> stringSetMap = updateService.lianZhongPatPicDirMap.get("75");
System.out.println(new Gson().toJson(stringSetMap));
Set<String> strings = stringSetMap.get("12345");
System.out.println(new Gson().toJson(strings));
int processors = Runtime.getRuntime().availableProcessors();
System.out.println(processors);
}
}while (cardInfos != null && cardInfos.size() > 0) ;
private void initLianZhongPatPicDir() {
log.info(">>>>>>>>>>>>初始化联众患者文件目录");
String readFilePath = FilePathUtil.currentPath() + File.separator + "lianzhong-patpic-dir.txt";
File readFile = new File(readFilePath);
if (readFile.exists()) {
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(readFile))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
lianZhongPatPicDirs.add(line);
}
initLianZhongPatPicDirsMap(lianZhongPatPicDirs);
return;
} catch (Exception ex) {
log.error(">>>>>>>>>>>> 初始化联众患者文件目录读取存储文件错误!");
}
}
List<String> rootDirs = Arrays.asList("D:\\UnionNet\\ServerD", "D:\\UnionNet\\ServerD_ny", "D:\\UnionNet\\ServerDTemp",
"G:\\UnionNet\\ServerD", "G:\\UnionNet\\ServerD_ny", "G:\\UnionNet\\ServerDTemp");
for (String rootDir : rootDirs) {
File rootDirFile = new File(rootDir);
if (!rootDirFile.exists()) {
continue;
}
// 第一层 年 ,如果有,后面基本都会有
File[] level1 = rootDirFile.listFiles();
if (level1 == null || level1.length <= 0) {
continue;
}
for (File level1File : level1) {
// 第二层 年月
File[] level2 = level1File.listFiles();
if (level2 == null || level2.length <= 0) {
continue;
}
for (File level2File : level2) {
if (level2File.isDirectory()) {
// 第三层 年月日
File[] level3 = level2File.listFiles();
if (level3 == null || level3.length <= 0) {
continue;
}
for (File level3File : level3) {
if (level3File.isDirectory()) {
// 第四层,患者存放文件的最后一级目录
File[] level4 = level3File.listFiles();
if (level4 == null || level4.length <= 0) {
continue;
}
for (File level4File : level4) {
if (level4File.isDirectory()) {
lianZhongPatPicDirs.add(level4File.getPath());
}
}
}
}
}
}
}
}
if (!lianZhongPatPicDirs.isEmpty()) {
initLianZhongPatPicDirsMap(lianZhongPatPicDirs);
try (BufferedWriter writer = new BufferedWriter(new FileWriter(readFile));) {
for (String picDir : lianZhongPatPicDirs) {
writer.write(picDir);
writer.newLine();
}
} catch (Exception ex) {
log.error("持久化联众患者文件目录错误:" + ex.getMessage(), ex);
if (readFile.exists()) {
readFile.delete();
}
}
}
}
/**
* +10+8
*/
private void initLianZhongPatPicDirsMap(Set<String> lianZhongPatPicDirs) {
for (String lianZhongPatPicDir : lianZhongPatPicDirs) {
File patPicDirFile = new File(lianZhongPatPicDir);
String name = patPicDirFile.getName();
String flag = name.substring(0, 2);
String maybe = name.substring(2).substring(0, 10);
maybe = removeLeadingZeros(maybe);
Map<String, Set<String>> maybeMap = lianZhongPatPicDirMap.getOrDefault(flag, new HashMap<>());
Set<String> maybeVal = maybeMap.getOrDefault(maybe, new HashSet<>());
maybeVal.add(lianZhongPatPicDir);
maybeMap.put(maybe, maybeVal);
lianZhongPatPicDirMap.put(flag, maybeMap);
}
}
private LianZhongUploadInfo.PatientInfo convert(CardInfo cardInfo) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LianZhongUploadInfo.PatientInfo patientInfo = new LianZhongUploadInfo.PatientInfo();
patientInfo.setInpatientNo(cardInfo.getPatno());
String gestno = cardInfo.getGestno();
// 123步设置住院次数
Integer admissTimes = cardInfo.getPatnum();
if (admissTimes == null && StringUtils.hasText(gestno)) {
try {
String admissTimesStr = removeLeadingZeros(gestno.substring(gestno.length() - 3));
admissTimes = Integer.valueOf(admissTimesStr);
} catch (Exception ex) {
log.error("无法解析gestno{} 当中的住院次数!", gestno);
}
}
// 没办法获取那就直接用出院的日期当住院次数
if (admissTimes == null) {
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMdd");
admissTimes = Integer.valueOf(sdf2.format(cardInfo.getOutdate()));
}
patientInfo.setAdmissTimes(admissTimes);
patientInfo.setAge(cardInfo.getPatage());
patientInfo.setName(cardInfo.getPatname());
patientInfo.setSex("1".equals(cardInfo.getPatsex()) ? "男" : "女");
patientInfo.setSexName("");
patientInfo.setAdmissDate(cardInfo.getIndate() == null ? null : sdf.format(cardInfo.getIndate()));
patientInfo.setDisDate(cardInfo.getOutdate() == null ? null : sdf.format(cardInfo.getOutdate()));
patientInfo.setAdmissDeptName(cardInfo.getIndeptname());
patientInfo.setDisDeptName(cardInfo.getOutdeptname());
patientInfo.setIdCard(cardInfo.getPatciticard());
patientInfo.setMainDiagCode(null);
patientInfo.setMainDiagName(null);
patientInfo.setMainOperateCode(null);
patientInfo.setMainOperateName(null);
return patientInfo;
}
private String findLianZhongDir(CardInfo cardInfo) {
String gestno = cardInfo.getGestno();
String patno = cardInfo.getPatno();
// Date outdate = cardInfo.getOutdate();
String pathPrefix = cardInfo.getPat_path().substring(0, 2);
/// 取消出院日期判断,日期可能不是出院日期
//SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
// String outDateFormat = sdf.format(outdate);
Map<String, Set<String>> maybeMap = lianZhongPatPicDirMap.get(pathPrefix);
// gestno 或者 patno 进行 识别
if (StringUtils.hasText(gestno)) {
Set<String> picsByGestno = maybeMap.get(removeLeadingZeros(gestno));
if (!CollectionUtils.isEmpty(picsByGestno) && picsByGestno.size() == 1) {
return new ArrayList<>(picsByGestno).get(0);
}
}
Set<String> picsByPatno = maybeMap.get(removeLeadingZeros(patno));
if (!CollectionUtils.isEmpty(picsByPatno) && picsByPatno.size() == 1) {
return new ArrayList<>(picsByPatno).get(0);
}
return null;
}
public static String removeLeadingZeros(String str) {
if (str == null || str.isEmpty()) {
return str; // 如果字符串为空或null直接返回
}
int index = 0;
// 循环检查每个字符,直到找到不是'0'的字符
while (index < str.length() && str.charAt(index) == '0') {
index++;
}
// 返回从第一个非'0'字符开始到字符串末尾的子字符串
return str.substring(index);
}
public static String removeFileExtension(String fileName) {
// 检查文件名是否为空或没有后缀
if (fileName == null || !fileName.contains(".")) {
return fileName;
}
// 找到最后一个'.'字符的位置
int lastDotIndex = fileName.lastIndexOf('.');
// 截取不包含后缀的部分
return fileName.substring(0, lastDotIndex);
}
}

@ -1,150 +0,0 @@
package com.jiashi.service;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* [ {"inpatientNo":"35131", "disDate":"2020-07-30 00:00:00.000", "fileTitle":"0001.jpg", "uploadFileName":"1.jpg", "assortId":"078F7675CB0048EDBE586D59831C57B0" ,
* "patientId":"12312312",
* "name":"长三",
* "admissDate":"住院时间",
* "sex":"男女"
* }
* ]
*/
@Data
public class UploadInfo {
private String inpatientNo;
private String disDate;
private String fileTitle;
private String uploadFileName;
private String assortId;
private String patientId;
private String name;
private String admissDate;
private String sex;
public UploadInfo(String inpatientNo, String disDate, String fileTitle, String uploadFileName, String assortId, String patientId, String name, String admissDate, String sex) {
this.inpatientNo = inpatientNo;
this.disDate = disDate;
this.fileTitle = fileTitle;
this.uploadFileName = uploadFileName;
this.assortId = assortId;
this.patientId = patientId;
this.name = name;
this.admissDate = admissDate;
this.sex = sex;
this.ssAssortId();
}
public void ssAssortId() {
switch (assortId) {
case "1":
this.assortId = "2111";
break;
case "2":
this.assortId = "2112";
break;
case "3":
this.assortId = "2113";
break;
case "4":
this.assortId = "2114";
break;
case "5":
this.assortId = "2115";
break;
case "6":
this.assortId = "2116";
break;
case "7":
this.assortId = "2117";
break;
case "8":
this.assortId = "2118";
break;
case "9":
this.assortId = "2119";
break;
case "10":
this.assortId = "21110";
break;
case "11":
this.assortId = "21111";
break;
case "12":
this.assortId = "21112";
break;
case "13":
this.assortId = "21113";
break;
case "14":
this.assortId = "21114";
break;
case "15":
this.assortId = "21115";
break;
case "16":
this.assortId = "21116";
break;
case "17":
this.assortId = "21117";
break;
case "18":
this.assortId = "21118";
break;
case "19":
this.assortId = "21119";
break;
case "20":
this.assortId = "21120";
break;
case "21":
this.assortId = "21121";
break;
case "22":
this.assortId = "21122";
break;
case "23":
this.assortId = "21123";
break;
case "24":
this.assortId = "21124";
break;
case "25":
this.assortId = "21125";
break;
case "26":
this.assortId = "21126";
break;
case "27":
this.assortId = "21127";
break;
case "28":
this.assortId = "21128";
break;
case "29":
this.assortId = "21129";
break;
case "30":
this.assortId = "21130";
break;
case "31":
this.assortId = "21131";
break;
case "32":
this.assortId = "21132";
break;
case "33":
this.assortId = "21133";
break;
default:
this.assortId = "21133";
}
}
}

@ -2,11 +2,15 @@
server:
port: 8282
lz:
disdate-range: 2024-01-01 00:00:00,2024-08-01 00:00:00
uploadUrl: http://129.7.1.25:9511/lianzhong/batchFileUploadJpg
spring:
datasource:
url: jdbc:sqlserver://10.2.130.59:1433;DatabaseName=u_medrecord
url: jdbc:sqlserver://192.169.2.170:1433;DatabaseName=u_medrecord
username: sa
password: admin123
password: 17931@Uni
# url: jdbc:sqlserver://10.36.116.108:1433;DatabaseName=emr_record
# username: sa
# password: xjgs+docus911

@ -12,4 +12,8 @@ ON [dbo].[t_card_info_upload] (
CREATE NONCLUSTERED INDEX [index_outdate]
ON [dbo].[t_card_info_upload] (
[outdate]
)
)
--
-- t_card_info_upload id

@ -0,0 +1,69 @@
<!-- Logback configuration. See http://logback.qos.ch/manual/index.html -->
<configuration scan="true" scanPeriod="10 seconds">
<!-- 以下配置修改自springboot -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- Simple file output -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>${FILE_LOG_PATTERN:-%d{yyyy-MM-dd HH:mm:ss.SSS} [${HOSTNAME}]${LOG_LEVEL_PATTERN:-%5p} ${PID:- }
--- [%t] %-40.40logger{39} %L : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}
</pattern>
<charset>UTF-8</charset>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>log/discovery-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>debug</level>
</filter>
<!-- Safely log to the same file from multiple JVMs. Degrades performance! -->
<prudent>true</prudent>
</appender>
<appender name="FILE_ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>512</queueSize>
<appender-ref ref="FILE"/>
</appender>
<!-- Console output -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint}
[${HOSTNAME}]%clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint}
%clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %L %clr(:){faint}
%m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}
</pattern>
<charset>UTF-8</charset>
</encoder>
<!-- Only log level WARN and above -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>debug</level>
</filter>
</appender>
<!-- For loggers in the these namespaces, log at all levels. -->
<logger name="pedestal" level="ALL"/>
<logger name="hammock-cafe" level="ALL"/>
<logger name="user" level="ALL"/>
<!--显示日志-->
<logger name="org.springframework.jdbc.core" additivity="false" level="DEBUG">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE_ASYNC"/>
</logger>
<root level="INFO">
<appender-ref ref="FILE_ASYNC"/>
<appender-ref ref="STDOUT"/>
</root>
</configuration>

@ -1,7 +1,13 @@
package com.jiashi;
import okhttp3.*;
import com.google.gson.Gson;
import com.jiashi.service.LianZhongUploadInfo;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import java.io.File;
import java.io.IOException;
@ -43,23 +49,45 @@ public class FileUploader {
public static void main(String[] args) throws IOException {
List<File> files = new ArrayList<>();
files.add(new File("C:\\Downloads\\LH0001.jpg"));
File file1 = new File("C:\\Users\\wyb\\Pictures\\head.jpg");
File file2 = new File("C:\\Users\\wyb\\Pictures\\毒王90.jpg");
files.add(file1);
files.add(file2);
// files.add(new File("C:\\jiahsi-saomiao\\413425_刘燊杨_20221009_004624\\16763947060420811242.jpg"));
LianZhongUploadInfo.PatientInfo patientInfo = new LianZhongUploadInfo.PatientInfo();
patientInfo.setInpatientNo("wyb-lianzhong001");
patientInfo.setAdmissTimes(1);
patientInfo.setDisDate("2025-01-01 00:00:00");
patientInfo.setName("厦门中医院联众测试");
LianZhongUploadInfo.FileInfo fileInfo1 = new LianZhongUploadInfo.FileInfo();
fileInfo1.setSort(1);
fileInfo1.setFileTitle("head");
fileInfo1.setUploadFileName(file1.getName());
fileInfo1.setAssortId("wyb-lianzhong");
LianZhongUploadInfo.FileInfo fileInfo2 = new LianZhongUploadInfo.FileInfo();
fileInfo2.setSort(2);
fileInfo2.setFileTitle("head2");
fileInfo2.setUploadFileName(file2.getName());
fileInfo2.setAssortId("wyb-lianzhong-2");
ArrayList<LianZhongUploadInfo.FileInfo> fileInfos = new ArrayList<>();
fileInfos.add(fileInfo1);
fileInfos.add(fileInfo2);
LianZhongUploadInfo uploadInfo = new LianZhongUploadInfo();
uploadInfo.setPatientInfo(patientInfo);
uploadInfo.setFileInfos(fileInfos);
// 额外的表单字段参数
List<FormField> params = new ArrayList<>();
params.add(new FormField("uploadFileParams", "[ {\"inpatientNo\":\"35131\", \"disDate\":\"2020-07-30 00:00:00.000\", \"fileTitle\":\"16763947060057863381.jpg\", \"uploadFileName\":\"16763947060057863381.jpg\", \"assortId\":\"078F7675CB0048EDBE586D59831C57B0\" ,\n" +
"\"patientId\":\"12312312\",\n" +
"\"name\":\"长三\",\n" +
"\"admissDate\":\"2022-02-01\",\n" +
"\"sex\":\"男女\"\n" +
"}\n" +
"]"));
params.add(new FormField("uploadFileParams", new Gson().toJson(uploadInfo)));
// 上传URL
String uploadUrl = "http://192.168.16.116:8711/api/downplatform/fileUploadJpg";
String uploadUrl = "http://127.0.0.1:9511/lianzhong/batchFileUploadJpg";
// 执行批量上传
uploadFilesWithParams(files, uploadUrl, params);

Loading…
Cancel
Save