接口模式确定

This commit is contained in:
jiangs 2025-05-21 16:19:52 +08:00
parent 2834ef95bb
commit 530e6e3cbc
12 changed files with 241 additions and 7 deletions

View File

@ -148,6 +148,12 @@
<artifactId>pinyin4j</artifactId> <artifactId>pinyin4j</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.czlis</groupId>
<artifactId>lis-interfaceCommon</artifactId>
<version>8.0.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -41,6 +41,32 @@ public class RuoYiConfig {
*/ */
private static String captchaType; private static String captchaType;
/**
* 接口类型
*/
private static String interfaceType;
/**
* 接口地址
*/
private static String interfaceUrl;
public static String getInterfaceUrl() {
return interfaceUrl;
}
public static void setInterfaceUrl(String interfaceUrl) {
RuoYiConfig.interfaceUrl = interfaceUrl;
}
public static String getInterfaceType() {
return interfaceType;
}
public static void setInterfaceType(String interfaceType) {
RuoYiConfig.interfaceType = interfaceType;
}
public String getName() { public String getName() {
return name; return name;
} }

View File

@ -0,0 +1,100 @@
package com.czlis.common.utils.lisinterface;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.czlis.common.config.RuoYiConfig;
import com.czlis.common.core.domain.Result;
import com.czlis.interfaceCommon.mapper.LisInterfaceMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Component
public class LisInterfaceUtil {
@Resource
LisInterfaceMapper lisInterfaceMapper;
public Result invokeLisInterface(String type,String inValue) {
String interfaceType = RuoYiConfig.getInterfaceType();
switch (interfaceType){
case "1": //存储过程
return invokeSP(type, inValue);
case "2": //http方式
return invokeHttp(type, inValue);
}
return new Result("-1","无效的接口方式,请检查配置文件的interfaceType!!");
}
/**
* 存储过程方式调用接口
* @param type
* @param inValue
* @return
*/
public Result invokeSP(String type,String inValue){
Map<String,Object> map = new HashMap<>();
map.put("invalue",inValue);
map.put("retcode","");
map.put("retmsg","");
switch (type){
case "getreqinterface":
lisInterfaceMapper.sp_lis_getreqinterface(map);
break;
case "setdict":
lisInterfaceMapper.sp_lis_setdict(map);
break;
case "setreport":
lisInterfaceMapper.sp_lis_setreport(map);
break;
case "setreqstatus":
lisInterfaceMapper.sp_lis_setreqstatus(map);
break;
case "daymessage":
lisInterfaceMapper.sp_lis_daymessage(map);
break;
}
String retCode = String.valueOf(map.get("retcode"));
String retMsg = String.valueOf(map.get("retmsg"));
log.info("调用存储过程{}返回值:{},{}",type,retCode,retMsg);
if(retCode.equals("0")){
return new Result("0","调用接口成功!");
}else{
return new Result("-1","调用接口失败!"+retMsg);
}
}
/**
* http方式调用接口
* @param transCode
* @param jsonStr
* @return
*/
public Result invokeHttp(String transCode,String jsonStr){
String interfaceUrl = RuoYiConfig.getInterfaceUrl();
if(interfaceUrl == null || "".equals(interfaceUrl)) return new Result("-1","没有配置地址,请检查interfaceUrl配置项!!!");
interfaceUrl = interfaceUrl+"/"+transCode;
String retMsg = "";
try {
HttpRequest httpRequest = HttpRequest.post(interfaceUrl);
httpRequest.header("Content-Type","application/json");
HttpResponse httpResponse = httpRequest.body(jsonStr).execute();
int status = httpResponse.getStatus();
retMsg = httpResponse.body();
if (status != 200) {
log.info("调用http接口失败:"+retMsg);
return new Result("-1","调用http接口失败:"+retMsg);
}
}catch (Exception e){
e.printStackTrace();
log.error("调用lis的http接口出错:",e);
}
return new Result("0","调用接口成功!",retMsg);
}
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.czlis</groupId>
<artifactId>czlis</artifactId>
<version>8.0.0</version>
</parent>
<artifactId>lis-interfaceCommon</artifactId>
</project>

View File

@ -0,0 +1,12 @@
package com.czlis.interfaceCommon.mapper;
import java.util.Map;
public interface LisInterfaceMapper {
void sp_lis_getreqinterface(Map<String,Object> map);
void sp_lis_setreqstatus(Map<String,Object> map);
void sp_lis_setreport(Map<String,Object> map);
void sp_lis_setdict(Map<String,Object> map);
void sp_lis_daymessage(Map<String,Object> map);
}

View File

@ -0,0 +1,4 @@
package com.czlis.interfaceCommon.service;
public interface LisInterfaceService {
}

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.czlis.interfaceCommon.mapper.LisInterfaceMapper">
<select id="sp_lis_getreqinterface" parameterType="map" statementType="CALLABLE" useCache="false">
{call sp_lis_getreqinterface(#{invalue,mode=IN,jdbcType=VARCHAR},
#{retcode,mode=OUT,jdbcType=INTEGER},
#{retmsg,mode=OUT,jdbcType=VARCHAR})
}
</select>
<select id="sp_lis_setreqstatus" parameterType="map" statementType="CALLABLE" useCache="false">
{call sp_lis_setreqstatus(#{invalue,mode=IN,jdbcType=VARCHAR},
#{retcode,mode=OUT,jdbcType=INTEGER},
#{retmsg,mode=OUT,jdbcType=VARCHAR})
}
</select>
<select id="sp_lis_setreport" parameterType="map" statementType="CALLABLE" useCache="false">
{call sp_lis_setreport(#{invalue,mode=IN,jdbcType=VARCHAR},
#{retcode,mode=OUT,jdbcType=INTEGER},
#{retmsg,mode=OUT,jdbcType=VARCHAR})
}
</select>
<select id="sp_lis_setdict" parameterType="map" statementType="CALLABLE" useCache="false">
{call sp_lis_setdict(#{invalue,mode=IN,jdbcType=VARCHAR},
#{retcode,mode=OUT,jdbcType=INTEGER},
#{retmsg,mode=OUT,jdbcType=VARCHAR})
}
</select>
<select id="sp_lis_daymessage" parameterType="map" statementType="CALLABLE" useCache="false">
{call sp_lis_daymessage(#{invalue,mode=IN,jdbcType=VARCHAR},
#{retcode,mode=OUT,jdbcType=INTEGER},
#{retmsg,mode=OUT,jdbcType=VARCHAR})
}
</select>
</mapper>

View File

@ -111,7 +111,7 @@ public class SecurityConfig {
requests.antMatchers("/login", "/register", "/captchaImage").permitAll() requests.antMatchers("/login", "/register", "/captchaImage").permitAll()
// 静态资源,可匿名访问 // 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**","/zyreq/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
.antMatchers("/doc.html").permitAll() //Knife4j 过滤 .antMatchers("/doc.html").permitAll() //Knife4j 过滤
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated(); .anyRequest().authenticated();

View File

@ -12,6 +12,8 @@ czlis:
addressEnabled: false addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证 # 验证码类型 math 数字计算 char 字符验证
captchaType: math captchaType: math
interfaceType: 1
interfaceUrl: http://localhost:8080
# 开发环境配置 # 开发环境配置
server: server:
@ -55,7 +57,7 @@ spring:
# 国际化资源文件路径 # 国际化资源文件路径
basename: i18n/messages basename: i18n/messages
profiles: profiles:
active: prod active: druid
# 文件上传 # 文件上传
servlet: servlet:
multipart: multipart:
@ -67,7 +69,7 @@ spring:
devtools: devtools:
restart: restart:
# 热部署开关 # 热部署开关
enabled: true enabled: false
# redis 配置 # redis 配置
redis: redis:
# 地址 # 地址
@ -115,10 +117,10 @@ mybatis:
#org.apache.ibatis.logging.stdout.StdOutImpl #org.apache.ibatis.logging.stdout.StdOutImpl
# PageHelper分页插件 # PageHelper分页插件
#pagehelper: pagehelper:
# helperDialect: sqlserver helperDialect: sqlserver
# supportMethodsArguments: true supportMethodsArguments: true
# params: count=countSql params: count=countSql
# Swagger配置 # Swagger配置
swagger: swagger:

View File

@ -0,0 +1,9 @@
package com.czlis.mzcx;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/mzcx")
public class MZCXController {
}

View File

@ -242,6 +242,12 @@
<version>${czlis.version}</version> <version>${czlis.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.czlis</groupId>
<artifactId>lis-interfaceCommon</artifactId>
<version>${czlis.version}</version>
</dependency>
<!-- hutool工具类 --> <!-- hutool工具类 -->
<dependency> <dependency>
@ -289,6 +295,7 @@
<module>zycx</module> <module>zycx</module>
<module>zybgcx</module> <module>zybgcx</module>
<module>lis-quartz</module> <module>lis-quartz</module>
<module>lis-interfaceCommon</module>
</modules> </modules>
<packaging>pom</packaging> <packaging>pom</packaging>

View File

@ -4,6 +4,7 @@ import com.czlis.common.core.controller.BaseController;
import com.czlis.common.core.domain.Result; import com.czlis.common.core.domain.Result;
import com.czlis.common.core.domain.entity.LabReqmain; import com.czlis.common.core.domain.entity.LabReqmain;
import com.czlis.common.core.page.TableDataInfo; import com.czlis.common.core.page.TableDataInfo;
import com.czlis.common.utils.lisinterface.LisInterfaceUtil;
import com.czlis.zycx.pojo.Web_getBarcode; import com.czlis.zycx.pojo.Web_getBarcode;
import com.czlis.zycx.service.ZycxService; import com.czlis.zycx.service.ZycxService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
@ -27,6 +29,9 @@ public class ZycxController extends BaseController {
@Autowired @Autowired
private ZycxService zycxService; private ZycxService zycxService;
@Resource
LisInterfaceUtil lisInterfaceUtil;
@ApiOperation("获取申请单") @ApiOperation("获取申请单")
@GetMapping("/query") @GetMapping("/query")
@ -52,6 +57,12 @@ public class ZycxController extends BaseController {
return zycxService.execSQD(sqh,userid,status,yljg); return zycxService.execSQD(sqh,userid,status,yljg);
} }
// @GetMapping("/test1")
// public Result test1(String inValue){
// log.info("测试的数据:{}",inValue);
// return lisInterfaceUtil.invokeSP(inValue);
// }