commit c33e938d793db2b7a214ba7268db109170e1c786 Author: lzy Date: Mon Nov 15 11:27:25 2021 +0800 拆分按需采集 新增:采集接口 diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..4f55f03 --- /dev/null +++ b/lombok.config @@ -0,0 +1 @@ +lombok.var.flagUsage = ALLOW \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..e0e9836 --- /dev/null +++ b/pom.xml @@ -0,0 +1,132 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.5.6 + + + com.docus + demo + 0.0.1-SNAPSHOT + docus-active-query-service + Demo project for Spring Boot + + 1.8 + + + + org.springframework.boot + spring-boot-starter + + + + org.dom4j + dom4j + 2.1.1 + + + + jaxen + jaxen + 1.1.1 + + + com.alibaba + fastjson + 1.2.75 + + + mysql + mysql-connector-java + 8.0.15 + + + org.springframework.boot + spring-boot-starter-web + + + org.projectlombok + lombok + 1.16.14 + + + com.spring4all + swagger-spring-boot-starter + 1.9.0.RELEASE + + + + org.apache.commons + commons-lang3 + 3.4 + + + com.baomidou + mybatis-plus-boot-starter + 3.3.0 + + + org.springframework.boot + spring-boot-starter-test + test + + + org.apache.httpcomponents + httpcore + 4.4.5 + + + org.apache.httpcomponents + httpclient + 4.5.2 + + + org.apache.httpcomponents + httpmime + 4.4 + + + + org.apache.axis + axis + 1.4 + + + + org.apache.axis + axis-jaxrpc + 1.4 + + + + commons-discovery + commons-discovery + 0.2 + + + + commons-logging + commons-logging + 1.1.1 + + + + wsdl4j + wsdl4j + 1.6.2 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/src/main/java/com/docus/bgts/DemoApplication.java b/src/main/java/com/docus/bgts/DemoApplication.java new file mode 100644 index 0000000..14f8d6e --- /dev/null +++ b/src/main/java/com/docus/bgts/DemoApplication.java @@ -0,0 +1,14 @@ +package com.docus.bgts; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DemoApplication { + + public static void main(String[] args) { + System.setProperty("javax.xml.parsers.DocumentBuilderFactory","com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"); + SpringApplication.run(DemoApplication.class, args); + } + +} diff --git a/src/main/java/com/docus/bgts/config/MybatisPlusConfig.java b/src/main/java/com/docus/bgts/config/MybatisPlusConfig.java new file mode 100644 index 0000000..be9705c --- /dev/null +++ b/src/main/java/com/docus/bgts/config/MybatisPlusConfig.java @@ -0,0 +1,66 @@ +package com.docus.bgts.config; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties; +import com.baomidou.mybatisplus.core.MybatisConfiguration; +import com.baomidou.mybatisplus.core.config.GlobalConfig; +import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; +import lombok.RequiredArgsConstructor; +import lombok.experimental.var; +import org.apache.ibatis.logging.nologging.NoLoggingImpl; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.annotation.PostConstruct; +import java.util.Objects; + +@Configuration +@RequiredArgsConstructor +@EnableTransactionManagement +@MapperScan("com.docus.bgts.mapper") +@ConditionalOnClass(value = {PaginationInterceptor.class}) +public class MybatisPlusConfig { + + + private final MybatisPlusProperties mybatisPlusProperties; + @Bean + public PaginationInterceptor paginationInterceptor() { + PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); + return paginationInterceptor; + } + + @PostConstruct + public void initMybatisConfig(){ + mybatisPlusProperties.setMapperLocations(new String[]{"classpath*:/mapper/*Mapper.xml"}); + mybatisPlusProperties.setTypeAliasesPackage("com.docus.bgts.entity"); + + MybatisConfiguration configuration = mybatisPlusProperties.getConfiguration(); + if(Objects.isNull(configuration)){ + configuration=new MybatisConfiguration(); + } + configuration.setMapUnderscoreToCamelCase(true); + configuration.setCacheEnabled(true); + configuration.setLogImpl(NoLoggingImpl.class); + mybatisPlusProperties.setConfiguration(configuration); + + var globalConfig = mybatisPlusProperties.getGlobalConfig(); + if(Objects.isNull(globalConfig)){ + globalConfig=new GlobalConfig(); + } + GlobalConfig.DbConfig dbConfig = globalConfig.getDbConfig(); + if(Objects.isNull(dbConfig)){ + dbConfig=new GlobalConfig.DbConfig(); + } + configuration.setCallSettersOnNulls(true); + dbConfig.setIdType(IdType.ASSIGN_ID); + dbConfig.setTableUnderline(true); + dbConfig.setLogicDeleteValue("1"); + dbConfig.setLogicNotDeleteValue("0"); + dbConfig.setLogicDeleteField("def_flag"); + globalConfig.setDbConfig(dbConfig); + globalConfig.setBanner(false); + } +} \ No newline at end of file diff --git a/src/main/java/com/docus/bgts/controller/BgtsController.java b/src/main/java/com/docus/bgts/controller/BgtsController.java new file mode 100644 index 0000000..1afea3b --- /dev/null +++ b/src/main/java/com/docus/bgts/controller/BgtsController.java @@ -0,0 +1,92 @@ +package com.docus.bgts.controller; + + +import com.docus.bgts.entity.CommonResult; +import com.docus.bgts.facade.IAfCollectTaskService; +import com.docus.bgts.facade.IBgtsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.ibatis.annotations.Param; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +@Api(value = "采集接口", tags = "采集接口") +@RestController +public class BgtsController { + + Logger logger= LogManager.getLogger(BgtsController.class); + + @Autowired + IBgtsService bgtsService; + + @Autowired + IAfCollectTaskService afCollectTaskService; + + @ApiOperation("采集接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "empId",value = "患者主索引号",required = true,dataTypeClass = String.class), + @ApiImplicitParam(name = "collectSubId",value = "af_interface_collect_sub表id",required = true) + }) + @GetMapping("/collect") + public CommonResult collect(@RequestParam("empId") String empId, @Param("collectSubId") String collectSubId) { + try { + logger.info("采集接口接收到参数:\nempId--"+empId+"\ncollectSubId--"+collectSubId); + bgtsService.collect(empId,collectSubId); + afCollectTaskService.updateInterfaceCollect(collectSubId, 1); + } catch (RuntimeException e) { + e.printStackTrace(); + try { + afCollectTaskService.updateInterfaceCollect(collectSubId, 0); + }catch (Exception e1){ + return CommonResult.failed(e1.getMessage()); + } + return CommonResult.failed(e.getMessage()); + } + catch (Exception e) { + e.printStackTrace(); + } + return CommonResult.success("ok"); + } + + /** + * 按需采集 + * @param emamNo + * @return + */ + @ApiOperation("按需采集接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "emamNo",value = "报告单号",required = true,dataTypeClass = String.class), + @ApiImplicitParam(name = "empId",value = "患者主索引号",required = true,dataTypeClass = String.class), + @ApiImplicitParam(name = "collectSubId",value = "af_interface_collect_sub表id",required = true) + }) + @GetMapping("/collectByExamNo") + public CommonResult collectByExamNo(@RequestParam("emamNo") String emamNo, + @RequestParam("empId") String empId, + @Param("collectSubId") String collectSubId){ + try { + logger.info("按需采集接口接受参数:\nempId--"+empId+"\ncollectSubId--"+collectSubId+"\nemamNo--"+emamNo); + bgtsService.collectByExamNo(emamNo,empId,collectSubId); + afCollectTaskService.updateInterfaceCollect(collectSubId, 1); + }catch (RuntimeException e) { + e.printStackTrace(); + try { + afCollectTaskService.updateInterfaceCollect(collectSubId, 0); + }catch (Exception e1){ + return CommonResult.failed(e1.getMessage()); + } + return CommonResult.failed(e.getMessage()); + } + catch (Exception e) { + e.printStackTrace(); + } + return CommonResult.success("ok"); + } + +} diff --git a/src/main/java/com/docus/bgts/entity/AfCollectTask.java b/src/main/java/com/docus/bgts/entity/AfCollectTask.java new file mode 100644 index 0000000..b57bbee --- /dev/null +++ b/src/main/java/com/docus/bgts/entity/AfCollectTask.java @@ -0,0 +1,66 @@ +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; + +/** + *

+ * 病案采集任务 + *

+ * + * @author 曾文和 + * @since 2021-05-07 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value="AfCollectTask对象", description="病案采集任务") +public class AfCollectTask implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "id 雪花算法") + @TableId(value = "id", type = IdType.ID_WORKER_STR) + private Long id; + + @ApiModelProperty(value = "病案主键") + private String patientId; + + @ApiModelProperty(value = "af_archive_detail表id") + private Long afArchiveDetailId; + + @ApiModelProperty(value = "来源 1护理文书,2 电子病历,3 Pacs检查,4心电图,5手麻系统,6 Lis检验,7病案首页,8长临医嘱") + private String sysflag; + + @ApiModelProperty(value = "开始时间") + private Date startTime; + + @ApiModelProperty(value = "结束时间") + private Date endTime; + + @ApiModelProperty(value = "任务状态 0:未开始,1:完成,2:重新采集") + private String state; + + @ApiModelProperty(value = "同步时间") + private Date syncTime; + + @ApiModelProperty(value = "最新重新采集时间") + private Date recollectTime; + + @ApiModelProperty(value = "最新重新采集人") + private String recollectName; + + @ApiModelProperty(value = "备注") + private String remark; + + @ApiModelProperty("报告唯一单号") + private String c1; + @ApiModelProperty("文件标题") + private String c2; +} diff --git a/src/main/java/com/docus/bgts/entity/AfInterfaceCollect.java b/src/main/java/com/docus/bgts/entity/AfInterfaceCollect.java new file mode 100644 index 0000000..6a6a21f --- /dev/null +++ b/src/main/java/com/docus/bgts/entity/AfInterfaceCollect.java @@ -0,0 +1,25 @@ +package com.docus.bgts.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +@Data +@ApiModel("文件库中的省中医病案采集表") +public class AfInterfaceCollect implements Serializable { + + private Long id; + @ApiModelProperty(value = "任务流水号") + private String serialnum; + @ApiModelProperty(value = "记账号") + private String jzh; + @ApiModelProperty(value = "任务数") + private Integer taskCount; + @ApiModelProperty(value = "完成数") + private Integer completeCount; + @ApiModelProperty(value = "创建时间") + private Date createTime; +} diff --git a/src/main/java/com/docus/bgts/entity/AfInterfaceCollectSub.java b/src/main/java/com/docus/bgts/entity/AfInterfaceCollectSub.java new file mode 100644 index 0000000..00925c6 --- /dev/null +++ b/src/main/java/com/docus/bgts/entity/AfInterfaceCollectSub.java @@ -0,0 +1,27 @@ +package com.docus.bgts.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +@Data +@ApiModel("文件库中的省中医病案采集-子任务表") +public class AfInterfaceCollectSub implements Serializable { + private Long id; + @ApiModelProperty(value = "af_interface_collect表id") + private Long afInterfaceCollectId; + @ApiModelProperty(value = "采集器id") + private String collectsysCode; + @ApiModelProperty(value = "子任务流水号 同一份文件子任务需一致") + private String serialnumSub; + @ApiModelProperty(value = "记账号") + private String jzh; + @ApiModelProperty(value = "分类名称") + private String assortName; + @ApiModelProperty(value = "状态 0:未发起,1:成功,2:失败") + private Integer state; + @ApiModelProperty(value = "请求信息") + private String requestMessage; +} diff --git a/src/main/java/com/docus/bgts/entity/CommonResult.java b/src/main/java/com/docus/bgts/entity/CommonResult.java new file mode 100644 index 0000000..e7c0d69 --- /dev/null +++ b/src/main/java/com/docus/bgts/entity/CommonResult.java @@ -0,0 +1,152 @@ +package com.docus.bgts.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * + * @author docus + * @date 2020/3/28 16:23 + */ +@Data +@ApiModel("响应") +@AllArgsConstructor +@NoArgsConstructor +public class CommonResult { + @ApiModelProperty("响应码") + private Integer code; + @ApiModelProperty("响应消息") + private String msg; + @ApiModelProperty("响应实体") + private T data; + + public CommonResult(Integer code, String msg) { + this.code = code; + this.msg = msg; + } + + /** + * 成功返回结果 + * + * @param data 获取的数据 + * @param + * @return + */ + public static CommonResult success(T data) { + return new CommonResult(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data); + } + + /** + * 成功返回结果 + * + * @param data 获取的数据 + * @param message 提示信息 + * @param + * @return + */ + public static CommonResult success(T data, String message) { + return new CommonResult(ResultCode.SUCCESS.getCode(), message, data); + } + + /** + * 失败返回结果 + * + * @param errorCode 错误码 + * @param + * @return + */ + public static CommonResult failed(IErrorCode errorCode) { + return new CommonResult(errorCode.getCode(), errorCode.getMessage(), null); + } + + /** + * 失败返回结果 + * + * @param errorCode 错误码 + * @param message 提示信息 + * @param + * @return + */ + public static CommonResult failed(IErrorCode errorCode, String message) { + return new CommonResult(errorCode.getCode(), message, null); + } + + /** + * 失败返回结果 + * + * @param message 提示信息 + * @param + * @return + */ + public static CommonResult failed(String message) { + return new CommonResult(ResultCode.FAILED.getCode(), message, null); + } + + + /** + * 失败返回结果 + * + * @param + * @return + */ + public static CommonResult failed() { + return failed(ResultCode.FAILED); + } + + /** + * 参数验证失败返回结果 + * + * @param + * @return + */ + public static CommonResult validateFailed() { + return failed(ResultCode.VALIDATE_FAILED); + } + + /** + * 提示信息 + * + * @param message 提示信息 + * @param + * @return + */ + public static CommonResult validateFailed(String message) { + return new CommonResult(ResultCode.VALIDATE_FAILED.getCode(), message, null); + } + + /** + * 未登录返回结果 + * + * @param data 获取的数据 + * @param + * @return + */ + public static CommonResult unauthorized(T data) { + return new CommonResult(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getMessage(), data); + } + + /** + * 重防及重复请求 + * + * @param data 获取的数据 + * @param + * @return + */ + public static CommonResult preventreplay(T data) { + return new CommonResult(ResultCode.PREVENT_REPLAY.getCode(), ResultCode.PREVENT_REPLAY.getMessage(), data); + } + + /** + * 未授权返回结果 + * + * @param data 获取的数据 + * @param + * @return + */ + public static CommonResult forbidden(T data) { + return new CommonResult(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getMessage(), data); + } +} diff --git a/src/main/java/com/docus/bgts/entity/IErrorCode.java b/src/main/java/com/docus/bgts/entity/IErrorCode.java new file mode 100644 index 0000000..7acba19 --- /dev/null +++ b/src/main/java/com/docus/bgts/entity/IErrorCode.java @@ -0,0 +1,12 @@ +package com.docus.bgts.entity; + +/** + * @Description 封装API的错误码 + * @Author JacksonTu + * @Date 2020/3/28 16:26 + */ +public interface IErrorCode { + Integer getCode(); + + String getMessage(); +} diff --git a/src/main/java/com/docus/bgts/entity/ReportDownDto.java b/src/main/java/com/docus/bgts/entity/ReportDownDto.java new file mode 100644 index 0000000..a689fa9 --- /dev/null +++ b/src/main/java/com/docus/bgts/entity/ReportDownDto.java @@ -0,0 +1,25 @@ +package com.docus.bgts.entity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class ReportDownDto { + @ApiModelProperty(value = "采集器id") + private String collectorid; + + @ApiModelProperty(value = "采集器ip") + private String ip; + + @ApiModelProperty(value = "文件信息") + private List scanfiles; + + private ReportDownPatientDto patient; + + @ApiModelProperty(value = "分类id") + private String assortid; + + +} diff --git a/src/main/java/com/docus/bgts/entity/ReportDownPatientDto.java b/src/main/java/com/docus/bgts/entity/ReportDownPatientDto.java new file mode 100644 index 0000000..8509d86 --- /dev/null +++ b/src/main/java/com/docus/bgts/entity/ReportDownPatientDto.java @@ -0,0 +1,10 @@ +package com.docus.bgts.entity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class ReportDownPatientDto { + @ApiModelProperty(value = "记帐号") + private String jzh; +} diff --git a/src/main/java/com/docus/bgts/entity/ReportDownScanFileDto.java b/src/main/java/com/docus/bgts/entity/ReportDownScanFileDto.java new file mode 100644 index 0000000..7712d14 --- /dev/null +++ b/src/main/java/com/docus/bgts/entity/ReportDownScanFileDto.java @@ -0,0 +1,23 @@ +package com.docus.bgts.entity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class ReportDownScanFileDto { + @ApiModelProperty(value = "文件标题") + private String filetitle; + @ApiModelProperty(value = "采集类型(文件来源 1:采集器;2:扫描生产软件)") + private int filesource; + @ApiModelProperty(value = "下载类型(1:服务器本地;2:ftp服务器;3:共享文件夹)") + private int filestoragetype; + @ApiModelProperty(value = "下载地址") + private String downurl; + @ApiModelProperty(value = "档案信息") + private String recordid; + @ApiModelProperty("采集流水号") + private String serialnum; + @ApiModelProperty(value = "任务id") + private Long taskid; + +} diff --git a/src/main/java/com/docus/bgts/entity/ResultCode.java b/src/main/java/com/docus/bgts/entity/ResultCode.java new file mode 100644 index 0000000..27b93b0 --- /dev/null +++ b/src/main/java/com/docus/bgts/entity/ResultCode.java @@ -0,0 +1,42 @@ +package com.docus.bgts.entity; + + +/** + * @Description 枚举一些常用API操作码 + * @Author JacksonTu + * @Date 2020/3/28 16:26 + */ +public enum ResultCode implements IErrorCode { + + SUCCESS(0, "操作成功"), + FAILED(500, "操作失败"), + VALIDATE_FAILED(404, "参数检验失败"), + UNAUTHORIZED(401, "暂未登录或token已经过期"), + FORBIDDEN(403, "没有相关权限"), + PREVENT_REPLAY(405,"重复请求"), + NOT_EXIST(601,"数据不存在"), + NOT_ENABLE(600,"数据未启用"); + + + + + private Integer code; + private String message; + + private ResultCode(Integer code, String message) { + this.code = code; + this.message = message; + } + + @Override + public Integer getCode() { + return code; + } + + @Override + public String getMessage() { + return message; + } + + +} diff --git a/src/main/java/com/docus/bgts/enums/Codes.java b/src/main/java/com/docus/bgts/enums/Codes.java new file mode 100644 index 0000000..a31eb30 --- /dev/null +++ b/src/main/java/com/docus/bgts/enums/Codes.java @@ -0,0 +1,55 @@ +package com.docus.bgts.enums; + +/** + * 代码库 + */ +public enum Codes { + //接口成功 + SUCCESS("0", "成功"), + //接口失败 + ERROR("1", "失败"), + //web service返回根节点 + RESPONSE("100","Response"), + //web service返回二级节点 + RET_INFO("101","RetInfo"), + //web service 返回代码 + RET_CODE("102","RetCode"), + //web service返回描述部分 + RET_CON("103","RetCon"), + //web service 服务名 + EXTERNAL("9202","201_P_WS_JYBGTS"), + //静态文件存放位置 + JSON_ADDRESS("999","\\dataConfig\\homeQualitySet.json"), + //接收二级节点 + MSG("201","Msg"), + //节点根 + DIRECTORY("1000","directory"), + //上传接口地址 + UPLOAD("0","uploadConnector"), + //患者主索引号 + EMP_ID("0","indexFlag"), + //错误日志编号 + ERROR_CODE("500","12"), + //接收三级节点 +// PAT_INFO("202","PatInfo"), + //静态文件根元素名 + SELECT_COLUMNS("10000","selectColumns") + ; + //代码 + private String code; + //描述 + private String message; + + private Codes(String code, String messgae) { + this.code = code; + this.message = messgae; + } + + public String getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java b/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java new file mode 100644 index 0000000..2ee8f97 --- /dev/null +++ b/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java @@ -0,0 +1,25 @@ +package com.docus.bgts.facade; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.docus.bgts.entity.AfCollectTask; +import com.docus.bgts.entity.ReportDownDto; + +/** + *

+ * 病案采集任务 服务类 + *

+ * + * @author 曾文和 + * @since 2021-05-07 + */ +public interface IAfCollectTaskService extends IService { + /** + * 获取病案id通过报告唯一单号 + */ + String getpatientIdByEmpId(String empId); + + void insert(ReportDownDto reportDownDto); + + void updateInterfaceCollect(String collectSubId, int state); +} diff --git a/src/main/java/com/docus/bgts/facade/IBgtsService.java b/src/main/java/com/docus/bgts/facade/IBgtsService.java new file mode 100644 index 0000000..bb334b8 --- /dev/null +++ b/src/main/java/com/docus/bgts/facade/IBgtsService.java @@ -0,0 +1,23 @@ +package com.docus.bgts.facade; + +import javax.xml.rpc.ServiceException; +import java.io.UnsupportedEncodingException; +import java.rmi.RemoteException; + +public interface IBgtsService { + /** + * 采集 + * @param empId + */ + void collect(String empId, String collectSubId) throws Exception; + + /** + * 按需采集 + * @param emamNo + * @param empId + * @throws UnsupportedEncodingException + * @throws RemoteException + * @throws ServiceException + */ + void collectByExamNo(String emamNo, String empId, String collectSubId) throws UnsupportedEncodingException, RemoteException, ServiceException, Exception; +} diff --git a/src/main/java/com/docus/bgts/mapper/AfCollectTaskMapper.java b/src/main/java/com/docus/bgts/mapper/AfCollectTaskMapper.java new file mode 100644 index 0000000..27f9246 --- /dev/null +++ b/src/main/java/com/docus/bgts/mapper/AfCollectTaskMapper.java @@ -0,0 +1,23 @@ +package com.docus.bgts.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.docus.bgts.entity.AfCollectTask; +import org.apache.ibatis.annotations.Param; + +/** + *

+ * 病案采集任务 Mapper 接口 + *

+ * + * @author 曾文和 + * @since 2021-05-07 + */ +public interface AfCollectTaskMapper extends BaseMapper { + /** + * 获取病案id通过报告唯一单号 + * @param empId + * @return + */ + String getpatientIdByEmpId(@Param("jzh") String empId); +} diff --git a/src/main/java/com/docus/bgts/mapper/AfInterfaceCollectMapper.java b/src/main/java/com/docus/bgts/mapper/AfInterfaceCollectMapper.java new file mode 100644 index 0000000..aa1e32a --- /dev/null +++ b/src/main/java/com/docus/bgts/mapper/AfInterfaceCollectMapper.java @@ -0,0 +1,8 @@ +package com.docus.bgts.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.docus.bgts.entity.AfInterfaceCollect; + +public interface AfInterfaceCollectMapper extends BaseMapper { + +} diff --git a/src/main/java/com/docus/bgts/mapper/AfInterfaceCollectSubMapper.java b/src/main/java/com/docus/bgts/mapper/AfInterfaceCollectSubMapper.java new file mode 100644 index 0000000..016177b --- /dev/null +++ b/src/main/java/com/docus/bgts/mapper/AfInterfaceCollectSubMapper.java @@ -0,0 +1,7 @@ +package com.docus.bgts.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.docus.bgts.entity.AfInterfaceCollectSub; + +public interface AfInterfaceCollectSubMapper extends BaseMapper { +} diff --git a/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java b/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java new file mode 100644 index 0000000..b190c49 --- /dev/null +++ b/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java @@ -0,0 +1,111 @@ +package com.docus.bgts.service; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.docus.bgts.entity.*; +import com.docus.bgts.facade.IAfCollectTaskService; +import com.docus.bgts.mapper.AfCollectTaskMapper; +import com.docus.bgts.mapper.AfInterfaceCollectMapper; +import com.docus.bgts.mapper.AfInterfaceCollectSubMapper; +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 java.util.Date; +import java.util.List; + +/** + *

+ * 病案采集任务 服务实现类 + *

+ * + * @author 曾文和 + * @since 2021-05-07 + */ +@Service +public class AfCollectTaskServiceImpl extends ServiceImpl implements IAfCollectTaskService { + + @Autowired + AfCollectTaskMapper afCollectTaskMapper; + + @Autowired + AfInterfaceCollectMapper afInterfaceCollectMapper; + + @Autowired + AfInterfaceCollectSubMapper afInterfaceCollectSubMapper; + + @Override + public String getpatientIdByEmpId(String empId) { + String patientId = afCollectTaskMapper.getpatientIdByEmpId(empId); + return patientId; + } + + @Transactional + @Override + public void insert(ReportDownDto reportDownDto) { + AfCollectTask afCollectTask; + String patientId = getpatientIdByEmpId(reportDownDto.getPatient().getJzh()); + if (StringUtils.isBlank(patientId)) { + throw new RuntimeException("操作的病案信息不存在"); + } + Date date = new Date(); + Integer save = null; + List scanfiles = reportDownDto.getScanfiles(); + for (ReportDownScanFileDto scanfile : scanfiles) { + // 判断任务是否已存在 + afCollectTask = afCollectTaskMapper.selectOne(new QueryWrapper().eq("C1", scanfile.getSerialnum()).eq("sysflag", reportDownDto.getCollectorid())); + if (afCollectTask == null) { + //不存在 新增 + afCollectTask = new AfCollectTask(); + afCollectTask.setPatientId(patientId); + afCollectTask.setSysflag(reportDownDto.getCollectorid()); + afCollectTask.setState("0"); + afCollectTask.setSyncTime(date); + afCollectTask.setC1(scanfile.getSerialnum()); + afCollectTask.setC2(scanfile.getFiletitle()); + save = afCollectTaskMapper.insert(afCollectTask); + } else { + //存在就修改 + afCollectTask.setPatientId(patientId); + afCollectTask.setSysflag(reportDownDto.getCollectorid()); + afCollectTask.setState("0"); + afCollectTask.setSyncTime(date); + afCollectTask.setC1(scanfile.getSerialnum()); + afCollectTask.setC2(scanfile.getFiletitle()); + save = afCollectTaskMapper.updateById(afCollectTask); + } + + if (save <= 0) { + throw new RuntimeException("插入病案任务表数据出错"); + } + scanfile.setTaskid(afCollectTask.getId()); + } + reportDownDto.setScanfiles(scanfiles); + } + + @Override + public void updateInterfaceCollect(String collectSubId, int state) { + AfInterfaceCollectSub afInterfaceCollectSub = afInterfaceCollectSubMapper.selectById(collectSubId); + if (afInterfaceCollectSub == null) { + throw new RuntimeException("afInterfaceCollectSub表数据为空"); + } + int i; + afInterfaceCollectSub.setState(state); + i = afInterfaceCollectSubMapper.updateById(afInterfaceCollectSub); + if (i <= 0) { + throw new RuntimeException("记录任务数时出错"); + } + if (state == 1) { + AfInterfaceCollect afInterfaceCollect = afInterfaceCollectMapper.selectById(afInterfaceCollectSub.getAfInterfaceCollectId()); + afInterfaceCollect.setCompleteCount(afInterfaceCollect.getCompleteCount() + 1); + i = afInterfaceCollectMapper.updateById(afInterfaceCollect); + if (i <= 0) { + throw new RuntimeException("记录任务数时出错"); + } + } + + } + +} diff --git a/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java b/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java new file mode 100644 index 0000000..a221c26 --- /dev/null +++ b/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java @@ -0,0 +1,228 @@ +package com.docus.bgts.service; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.docus.bgts.entity.AfCollectTask; +import com.docus.bgts.entity.ReportDownDto; +import com.docus.bgts.entity.ReportDownPatientDto; +import com.docus.bgts.entity.ReportDownScanFileDto; +import com.docus.bgts.enums.Codes; +import com.docus.bgts.facade.IAfCollectTaskService; +import com.docus.bgts.facade.IBgtsService; +import com.docus.bgts.utils.FileUtils; +import com.docus.bgts.utils.HttpUtils; +import com.docus.bgts.utils.XmlUtils; +import org.apache.axis.client.Call; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import javax.xml.namespace.QName; +import javax.xml.rpc.ParameterMode; +import javax.xml.rpc.ServiceException; +import javax.xml.rpc.encoding.XMLType; +import java.io.ByteArrayInputStream; +import java.io.UnsupportedEncodingException; +import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class BgtsServiceImpl implements IBgtsService { + @Value("${ws.url}") + private String wsUrl; + @Value("${ws.namespaceUrl}") + private String wsNamespaceUrl; + @Value("${ws.localMethod}") + private String wsLocalMethod; + + @Autowired + IAfCollectTaskService afCollectTaskService; + + @Override + public void collect(String empId, String collectSubId) throws Exception { + //通过empId获取报告单号集合 + List exams = getExamNo(empId); + //通过报告单号集合采集 + collectExams(exams, empId); + } + + @Override + public void collectByExamNo(String emamNo, String empId, String collectSubId) throws Exception { + String[] strings = new String[2]; + //通过报告单号和系统id查询任务表 + String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); + AfCollectTask afCollectTask = afCollectTaskService.getOne(new QueryWrapper().eq("C1", emamNo).eq("sysflag", collectorid)); + strings[0] = emamNo; + strings[1] = afCollectTask.getC2(); + List exams = new ArrayList<>(); + exams.add(strings); + collectExams(exams, empId); + } + + /** + * 通过报告单号集合采集数据 + * + * @param exams + * @param empId + */ + private void collectExams(List exams, String empId) throws UnsupportedEncodingException, RemoteException, ServiceException { + //获取插入表数据 + ReportDownDto reportDownDto = getUrlCreateReportDto(exams, empId); + //插入文件af_collect_task表数据 + afCollectTaskService.insert(reportDownDto); +// reportDownDto.setTaskid(id); + //调用上传接口 + Map headMap = new HashMap<>(); + headMap.put("Content-Type", "application/json"); + String 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); + System.out.println(resMap); + if (String.valueOf(resMap.get("code")).equals("500")) { + throw new RuntimeException(String.valueOf(resMap.get("msg"))); + } + } + + /** + * 获取图片url,病返回插入表对象 + * + * @param exams + * @param empId + * @return + */ + private ReportDownDto getUrlCreateReportDto(List exams, String empId) throws UnsupportedEncodingException, ServiceException, RemoteException { + ReportDownDto reportDownDto = new ReportDownDto(); + ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(); + reportDownPatientDto.setJzh(empId); + reportDownDto.setPatient(reportDownPatientDto); + String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); + String assortid = String.valueOf(FileUtils.getJsonByName("assortid")); + reportDownDto.setAssortid(assortid); + reportDownDto.setCollectorid(collectorid); + List reportDownScanFileDtos = new ArrayList<>(); + ReportDownScanFileDto reportDownScanFileDto; + int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource"))); + int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype"))); + for (String[] exam : exams) { + reportDownScanFileDto = getScanByExam(exam); + reportDownScanFileDto.setFilesource(filesource); + reportDownScanFileDto.setFilestoragetype(filestoragetype); + reportDownScanFileDtos.add(reportDownScanFileDto); + } + reportDownDto.setScanfiles(reportDownScanFileDtos); + return reportDownDto; + } + + /** + * 创建ReportDownScanFileDto对象 通过报告单号 + * + * @param exam + * @return + */ + private ReportDownScanFileDto getScanByExam(String[] exam) throws UnsupportedEncodingException, ServiceException, RemoteException { + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setSerialnum(exam[0]); + reportDownScanFileDto.setFiletitle(exam[1]); + // 1、创建document对象 + Document document = DocumentHelper.createDocument(); +// Element request = document.addElement("Request"); +// Element msg = request.addElement("Msg"); +// msg.addElement("EXAM_NO").setText(exam[0]); + List bgtsDetailParam = (List) FileUtils.getJsonByName("bgtsDetailParam"); + Element request = null; + for (int i = 0; i < bgtsDetailParam.size(); i++) { + if (i == 0) { + request = document.addElement(bgtsDetailParam.get(i)); + } else { + request = request.addElement(bgtsDetailParam.get(i)); + } + } + request.setText(exam[0]); + String resXml = invokeWs(document.asXML()); + //解析XML + XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8"))); +// List dis = new ArrayList<>(); +// dis.add("MsgInfo"); +// dis.add("Msg"); +// dis.add("ReportInfo"); + List dis = (List) FileUtils.getJsonByName("bgtsDetailRespon"); + //数据所在节点 + Element element = xmlUtils.getElement(dis); + reportDownScanFileDto.setDownurl(element.element(String.valueOf(FileUtils.getJsonByName("pdfUrl"))) == null ? "" : element.element(String.valueOf(FileUtils.getJsonByName("pdfUrl"))).getText()); + return reportDownScanFileDto; + } + + /** + * 通过empId获取报告单号集合 + * + * @param empId + * @return + */ + private List getExamNo(String empId) throws Exception { + List exams = new ArrayList<>(); + // 1、创建document对象 + Document document = DocumentHelper.createDocument(); +// Element request = document.addElement("Request"); +// Element msg = request.addElement("Msg"); +// msg.addElement("EMPI_ID").setText(empId); + List bgtsParam = (List) FileUtils.getJsonByName("bgtsParam"); + Element request = null; + for (int i = 0; i < bgtsParam.size(); i++) { + if (i == 0) { + request = document.addElement(bgtsParam.get(i)); + } else { + request = request.addElement(bgtsParam.get(i)); + } + } + request.setText(empId); + String resXml = invokeWs(document.asXML()); + //解析XML + XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8"))); +// List dis = new ArrayList<>(); +// dis.add("MsgInfo"); +// dis.add("Msg"); + List dis = (List) FileUtils.getJsonByName("bgtsRespon"); + //数据所在节点 + Element element = xmlUtils.getElement(dis); + List 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; + } + + public String invokeWs(String xml) throws ServiceException, RemoteException { + Object[] object = new Object[]{xml};//请求参数 + org.apache.axis.client.Service service = new org.apache.axis.client.Service(); + Call call = (Call) service.createCall(); + call.setTargetEndpointAddress(wsUrl);// 远程调用路径 + // 调用的命名空间和方法名 + call.setOperationName(new QName(wsNamespaceUrl, wsLocalMethod)); + call.setUseSOAPAction(true); +// call.setSOAPActionURI(wsNamespaceUrl + "pushSurveyReport"); + call.addParameter("arg0", XMLType.XSD_STRING, ParameterMode.IN); + call.setReturnType(XMLType.XSD_STRING);// 返回值类型:String + call.setTimeout(100000);//超时 + String result = (String) call.invoke(object);// 远程调用 + System.out.println(result); + return result; + } + + +} diff --git a/src/main/java/com/docus/bgts/utils/FileUtils.java b/src/main/java/com/docus/bgts/utils/FileUtils.java new file mode 100644 index 0000000..7afb6b5 --- /dev/null +++ b/src/main/java/com/docus/bgts/utils/FileUtils.java @@ -0,0 +1,43 @@ +package com.docus.bgts.utils; + +import com.alibaba.fastjson.JSON; +import com.docus.bgts.enums.Codes; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +public class FileUtils { + /** + * 获取jar包所在位置 + * + * @return + */ + public static String currentPath() { + File dir = new File("."); + String currentpath = ""; + try { + currentpath = dir.getCanonicalPath(); + } catch (IOException e) { + e.printStackTrace(); + } + return currentpath; + } + + /** + * 获取静态文件中的内容 + * @param name + * @return + */ + public static Object getJsonByName(String name){ + //获取目录结构 + String path = FileUtils.currentPath(); + //解析json映射文件 + String json = JsonUtils.readJsonFile(path + Codes.JSON_ADDRESS.getMessage()); + Map jsonMap = JSON.parseObject(json, Map.class); + return jsonMap.get(name); + } + + + +} diff --git a/src/main/java/com/docus/bgts/utils/HttpUtils.java b/src/main/java/com/docus/bgts/utils/HttpUtils.java new file mode 100644 index 0000000..470ebbd --- /dev/null +++ b/src/main/java/com/docus/bgts/utils/HttpUtils.java @@ -0,0 +1,211 @@ +package com.docus.bgts.utils; + +import com.alibaba.fastjson.JSON; +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.*; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Map; + +public class HttpUtils { + private static PoolingHttpClientConnectionManager cm; + private static String EMPTY_STR = ""; + private static String UTF_8 = "UTF-8"; + + private static void init() { + if (cm == null) { + cm = new PoolingHttpClientConnectionManager(); + cm.setMaxTotal(50);// 整个连接池最大连接数 + cm.setDefaultMaxPerRoute(5);// 每路由最大连接数,默认值是2 + } + } + + /** + * 通过连接池获取HttpClient + * + * @return + */ + private static CloseableHttpClient getHttpClient() { + init(); + return HttpClients.custom().setConnectionManager(cm).build(); + } + /** + * @param url + * @return + */ + public static String get(String url) { + HttpGet httpGet = new HttpGet(url); + return getResult(httpGet); + } + /** + * @param url、params + * @return + */ + public static String get(String url, Map params) throws URISyntaxException { + URIBuilder ub = new URIBuilder(); + ub.setPath(url); + + ArrayList pairs = covertParams2NVPS(params); + ub.setParameters(pairs); + + HttpGet httpGet = new HttpGet(ub.build()); + return getResult(httpGet); + } + /** + * @param url、headers、params + * @return + */ + public static String get(String url, Map headers, Map params) + throws URISyntaxException { + URIBuilder ub = new URIBuilder(); + ub.setPath(url); + + if (params != null) { + ArrayList pairs = covertParams2NVPS(params); + ub.setParameters(pairs); + } + + HttpGet httpGet = new HttpGet(ub.build()); + for (Map.Entry param : headers.entrySet()) { + httpGet.addHeader(param.getKey(), String.valueOf(param.getValue())); + } + return getResult(httpGet); + } + /** + * @param url + * @return + */ + public static String post(String url) { + HttpPost httpPost = new HttpPost(url); + return getResult(httpPost); + } + /** + * @param url、params + * @return + */ + public static String post(String url, Map params) throws UnsupportedEncodingException { + HttpPost httpPost = new HttpPost(url); + httpPost.setEntity(new UrlEncodedFormEntity(covertParams2NVPS(params), "utf-8"));//设置表单提交编码 + +// httpPost.setEntity(new StringEntity(JSON.toJSONString(params), ContentType.APPLICATION_FORM_URLENCODED)); + return getResult(httpPost); + } + + public static String post(String url, Object params, Map head) throws UnsupportedEncodingException { + HttpPost httpPost = new HttpPost(url); + System.out.println(params); + httpPost.setEntity(new StringEntity(params.toString()));//设置表单提交编码 + if (params != null) { + for (Map.Entry param : head.entrySet()) { + httpPost.addHeader(param.getKey(), String.valueOf(param.getValue())); + } + } +// httpPost.setEntity(new StringEntity(JSON.toJSONString(params), ContentType.APPLICATION_FORM_URLENCODED)); + return getResult(httpPost); + } + + private static ArrayList covertParams2NVPS(Map params) { + ArrayList pairs = new ArrayList(); + for (Map.Entry param : params.entrySet()) { + if (param.getValue() != null) { + pairs.add(new BasicNameValuePair(param.getKey(), param.getValue())); + } + } + + return pairs; + } + /** + * @param url、headers、params + * @return + */ + public static String post(String url, Map headers, Map params) + throws UnsupportedEncodingException { + HttpPost httpPost = new HttpPost(url); + System.out.println(params); + if (params != null) { + for (Map.Entry param : headers.entrySet()) { + httpPost.addHeader(param.getKey(), String.valueOf(param.getValue())); + } + } + + httpPost.setEntity(new StringEntity(JSON.toJSONString(params), ContentType.APPLICATION_JSON)); + + return getResult(httpPost); + } + + /** + * 处理Http请求 + * + * @param request + * @return + */ + private static String getResult(HttpRequestBase request) { + // CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpClient httpClient = getHttpClient(); + try { + CloseableHttpResponse response = httpClient.execute(request); + // response.getStatusLine().getStatusCode(); + HttpEntity entity = response.getEntity(); + if (entity != null) { + // long len = entity.getContentLength();// -1 表示长度未知 + String result = EntityUtils.toString(entity, UTF_8); + response.close(); + // httpClient.close(); + return result; + } + } catch (ClientProtocolException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + + } + + return EMPTY_STR; + } + + /** + * 处理Http请求 + * + * @param requestBuilder + * @return + */ + private static String getResult(RequestBuilder requestBuilder) { + // CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpClient httpClient = getHttpClient(); + try { + CloseableHttpResponse response = httpClient.execute(requestBuilder.build()); + // response.getStatusLine().getStatusCode(); + HttpEntity entity = response.getEntity(); + if (entity != null) { + // long len = entity.getContentLength();// -1 表示长度未知 + String result = EntityUtils.toString(entity, UTF_8); + response.close(); + // httpClient.close(); + return result; + } + } catch (ClientProtocolException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + + } + + return EMPTY_STR; + } +} diff --git a/src/main/java/com/docus/bgts/utils/JsonUtils.java b/src/main/java/com/docus/bgts/utils/JsonUtils.java new file mode 100644 index 0000000..ddc6be0 --- /dev/null +++ b/src/main/java/com/docus/bgts/utils/JsonUtils.java @@ -0,0 +1,44 @@ +package com.docus.bgts.utils; + +import java.io.*; + +/** + * json工具类 + */ +public class JsonUtils { + + /** + * 读取json文件方法 + * @param fileName:json文件存在的本地地址 + * @return + */ + public static String readJsonFile(String fileName) { + String jsonStr = ""; + Reader reader=null; + FileReader fileReader=null; + try { + File jsonFile = new File(fileName); + fileReader = new FileReader(jsonFile); + reader = new InputStreamReader(new FileInputStream(jsonFile),"utf-8"); + int ch = 0; + StringBuffer sb = new StringBuffer(); + while ((ch = reader.read()) != -1) { + sb.append((char) ch); + } + fileReader.close(); + reader.close(); + jsonStr = sb.toString(); + return jsonStr; + } catch (IOException e) { + e.printStackTrace(); + return null; + }finally { + try { + reader.close(); + fileReader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/com/docus/bgts/utils/XmlUtils.java b/src/main/java/com/docus/bgts/utils/XmlUtils.java new file mode 100644 index 0000000..c4fd5e0 --- /dev/null +++ b/src/main/java/com/docus/bgts/utils/XmlUtils.java @@ -0,0 +1,139 @@ +package com.docus.bgts.utils; + + +import com.alibaba.fastjson.JSON; +import com.docus.bgts.enums.Codes; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class XmlUtils { + //定义解析器和文档对象 + private SAXReader saxReader; + private Document document; + + public XmlUtils(String path) { + //获取解析器 + saxReader = new SAXReader(); + try { + //获取文档对象 + document = saxReader.read(path); + } catch (DocumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public XmlUtils(InputStream path) { + //获取解析器 + saxReader = new SAXReader(); + try { + //获取文档对象 + document = saxReader.read(path); + } catch (DocumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 动态获取节点内容 + * @return + */ + public String getElement(String name){ + //获取根节点 + Element root = document.getRootElement(); + Object directory = FileUtils.getJsonByName(Codes.DIRECTORY.getMessage()); + Element current=root; + if(directory==null){ + throw new RuntimeException("没有定义目录结构"); + } + List directoryArr=(List)directory; + for (String dire : directoryArr) { + current=current.element(dire); + } + return current.element(name)==null?"":current.element(name).getText(); + } + + /** + * 根据路径动态获取节点 + * @return + */ + public Element getElement(List directory){ + //获取根节点 + Element root = document.getRootElement(); + + Element current=root; + List directoryArr=directory; + for (String dire : directoryArr) { + current=current.element(dire); + } + if(current==null){ + throw new RuntimeException("未找到对应节点"); + } + return current; + } + + /** + * 返回存在的根节点 + */ + public List getJsonByName(){ + //获取目录结构 + String path = FileUtils.currentPath(); + //解析json映射文件 + String json = JsonUtils.readJsonFile(path + Codes.JSON_ADDRESS.getMessage()); + Map jsonMap = JSON.parseObject(json, Map.class); + //判断是否多条 + List basicArr= (List) jsonMap.get("doubleBasic"); + List directory= (List) jsonMap.get("basicDirectory"); + List elements=null; + Element root=this.getElement(directory); + for (String basic : basicArr) { + elements=root.elements(basic); + if(elements!=null&&elements.size()>0){ + break; + } + } + if(elements==null||elements.size()==0){ + //只有一条 + List rootDirectory= (List) jsonMap.get("directory"); + root = this.getElement(rootDirectory); + elements=new ArrayList<>(); + elements.add(root); + } + return elements; + } + + /** + * 根据节点名称获取内容 + * + * @param name 节点名称 + * @return 节点内容 + */ + public String getElementText(String name) { + //定位根节点 + Element root = document.getRootElement(); + //根据名称定位节点 + Element msg = root.element(Codes.MSG.getMessage()); + if(msg==null){ + throw new RuntimeException("没有"+ Codes.MSG.getMessage()+"节点"); + } +// Element patInfo = msg.element(Codes.PAT_INFO.getMessage()); +// if(patInfo==null){ +// throw new RuntimeException("没有"+Codes.PAT_INFO.getMessage()+"节点"); +// } + Element element = msg.element(name); + if(element==null){ + return null; + } + //返回节点内容 + return element.getText(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..449811f --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,32 @@ +server: + port: 9302 +# http + +mybatis-plus: + configuration: + map-underscore-to-camel-case: true + call-setters-on-nulls: true + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + field-strategy: NOT_EMPTY + db-type: MYSQL + +system: + code: "201_P_WS_JYBGTS" + prop: 9202 +# web service + +ws: + url: http://localhost:8010/ws_server/weather?wsdl + namespaceUrl: http://service.serviceserver.nanmeishu.com/ + localPart: TestServiceService + localPort: TestServicePort + localMethod: OperationA + +spring: + datasource: + 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=UTC&rewriteBatchedStatements=true \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..8d89969 --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,50 @@ + + + + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + + configLog/log.log + + + + + + log/demo.%d.%i.log + + 15 + + + 10MB + + + + + + %d %p (%file:%line\)- %m%n + + + UTF-8 + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/AfCollectTaskMapper.xml b/src/main/resources/mapper/AfCollectTaskMapper.xml new file mode 100644 index 0000000..3242789 --- /dev/null +++ b/src/main/resources/mapper/AfCollectTaskMapper.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file