Commit 5eaa647a by huangtao

physic

parent 4a2d7d1c
......@@ -86,19 +86,4 @@ mysql-bak:
# #################################################
# 数据备份
# #################################################
sync:
# FIXME:服务地址
serverUrl: FIXME-serverUrl
localUrl: http://localhost:37098/api
# FIXME:模式:none(无备份) - 默认
# none(无备份):部署模式11 ——端侧部署+无服务器+无备份
# emsb(端侧主,服务器备):部署模式21——端侧部署+服务器备份
# smes(服务器主,端侧备):部署模式22/23/33——端侧部署OCR+服务器部署业务+双向备份
mode: none
modeJobMap:
none: []
# edge->server:全部表数据+文件
emsb: ["tableDataPusher", "filePusher"]
# edge->server:实物(IE)图片+文件数据+OCR识别结果
# server->edge:表数据+文件
smes: ["tableDataPusher", "filePusher", "tableDataPuller", "filePuller"]
/*
* Copyright [2021] [SaasPlatform ]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jmai.api.exception;
import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;
import lombok.Setter;
/**
*/
@Getter
@Setter
public class OpenException extends RuntimeException {
private OpenServiceCode openServiceCode;
public OpenException(OpenServiceCode openServiceCode) {
super(openServiceCode.getCode() + "," + openServiceCode.getMsg());
this.openServiceCode = openServiceCode;
}
public OpenException(OpenServiceCode openServiceCode, String detail) {
this(openServiceCode, detail, null);
}
public OpenException(OpenServiceCode openServiceCode, Throwable cause) {
this(openServiceCode, "", cause);
}
public OpenException(OpenServiceCode openServiceCode, String detail, Throwable cause) {
super(ObjectUtil.isEmpty(detail) ?
openServiceCode.getCode() + "," + openServiceCode.getMsg() :
openServiceCode.getCode() + "," + openServiceCode.getMsg() + ":" + detail,
cause);
this.openServiceCode = new OpenServiceCode() {
@Override
public int getCode() {
return openServiceCode.getCode();
}
@Override
public String getMsg() {
return openServiceCode.getMsg() + "," + detail;
}
};
}
public OpenException(int code, String msg) {
super(code + "," + msg);
this.openServiceCode = new OpenServiceCode() {
@Override
public int getCode() {
return code;
}
@Override
public String getMsg() {
return msg;
}
};
}
public OpenException(String msg) {
super(OpenExceptionCode.SYSTEM_400.getCode() + "," + msg);
this.openServiceCode = new OpenServiceCode() {
@Override
public int getCode() {
return OpenExceptionCode.SYSTEM_400.getCode();
}
@Override
public String getMsg() {
return msg;
}
};
}
}
/*
* Copyright [2021] [SaasPlatform ]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jmai.api.exception;
/**
*/
public enum OpenExceptionCode implements OpenServiceCode {
SYSTEM_500(500, "未知异常,请联系管理员"),
SYSTEM_501(500, "入参错误或入参不全"),
SYSTEM_502(502, "服务调用异常"),
SYSTEM_503(504, "服务调用超时"),
SYSTEM_400(400, "请求错误"),
SYSTEM_401(401, "token失效,请重新登录。"),
SYSTEM_403(403, "接口未授权,请联系管理员"),
SYSTEM_404(404, "路径不存在,请检查路径是否正确"),
SYSTEM_405(405, "请求方式错误"),
SYSTEM_406(406, "已存在下级组织,禁止删除"),
SYSTEM_409(409, "添加的数据已存在,禁止重复添加!"),
SYSTEM_410(410, "添加的数据入参错误或入参不全!"),
SYSTEM_412(412, "不满足条件,禁止添加!"),
SYSTEM_416(416, "已达到添加上限,禁止添加下一层级!"),
SYSTEM_417(417, "token为空,请重新登录!"),
SYSTEM_460(46012, "上传文件太大。"),
SYSTEM_480(48010, "数据重复。"),
SENTINEL_FLOW(429, "操作过于频繁稍后重试 [Sentinel]"),
SENTINEL_DEGRADE_FLOW(430, "服务降级,请稍后重试 [Sentinel]"),
SENTINEL_PARAM_FLOW(431, "参数访问过于频繁,请稍后重试 [Sentinel]"),
SENTINEL_SYSTEM_BLOCK(432, "系统异常,繁稍后重试 [Sentinel]"),
SENTINEL_AUTHORITY(433, "服务授权异常,稍后重试 [Sentinel]"),
JWT_TOKEN_EXPIRED(401031, "token已失效,请重新登录"),
JWT_SIGNATURE(401032, "token签名错误,请重新登录"),
JWT_ILLEGAL_ARGUMENT(401033, "token为空,请重新登录"),
JWT_PARSER_TOKEN_FAIL(401034, "token解析失败,请重新登录"),
TENANT_AUTH_NULL(701, "租户未开通此端权限"),
OPT_ERROR(702, "演示环境不可操作"),
NO_OPEN_PERMISSION(703, "该账户尚未开通任何权限"),
HTTP_REQUEST_ERROR(405011, "请求方式错误"),
HTTP_URL_ERROR(405012, "URL错误"),
;
private int code;
private String msg;
OpenExceptionCode(int code, String msg) {
this.code = code;
this.msg = msg;
}
@Override
public int getCode() {
return this.code;
}
@Override
public String getMsg() {
return this.msg;
}
public void setCode(int code) {
this.code = code;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
/*
* Copyright [2021] [SaasPlatform ]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jmai.api.exception;
/**
*/
public interface OpenServiceCode {
/**
* 响应编码
* @return
*/
int getCode();
/**
* 响应描述
* @return
*/
String getMsg();
}
......@@ -12,9 +12,14 @@
<artifactId>jmai-gw</artifactId>
<dependencies>
<!-- <dependency>-->
<!-- <groupId>com.jmai</groupId>-->
<!-- <artifactId>jmai-sys</artifactId>-->
<!-- <version>1.0.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.jmai</groupId>
<artifactId>jmai-sys</artifactId>
<artifactId>jmai-physic</artifactId>
<version>1.0.0</version>
</dependency>
<!-- main-module/pom.xml -->
......
......@@ -8,7 +8,8 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
@MapperScan(basePackages = {
"com.jmai.sys.mapper",
"com.jmai.x.*.mapper",
"com.jmai.physic.mapper",
"com.jmai.*.mapper",
})
@SpringBootApplication(scanBasePackages = {
......
<?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">
<parent>
<artifactId>jmai-platform</artifactId>
<groupId>com.jmai</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jmai-physic</artifactId>
<dependencies>
<dependency>
<groupId>com.jmai</groupId>
<artifactId>jmai-sys</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<!-- 数据库+MyBatis -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.46.1.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
</dependency>
<!-- 工具-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons.lang.version}</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>${commons.configuration.version}</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>transmittable-thread-local</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.aviator</groupId>
<artifactId>aviator</artifactId>
<version>5.4.1</version>
</dependency>
<!--二维码-->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
</dependency>
<!-- 日志 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</dependency>
<!-- Swagger -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.22</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
</dependency>
<dependency>
<groupId>com.taobao</groupId>
<artifactId>taobao-sdk-java-auto</artifactId>
<version>1706854173930-20250916</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/taobao-sdk-java-auto_1706854173930-20250916.jar</systemPath>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.jmai.physic.alihealth;
import cn.hutool.core.util.ObjectUtil;
import com.jmai.physic.dto.PhysicInfoDTO;
import com.taobao.api.ApiException;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.AlibabaAlihealthDrugtraceTopYljgQueryCodedetailRequest;
import com.taobao.api.response.AlibabaAlihealthDrugtraceTopYljgQueryCodedetailResponse;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
@Component
public class AlihealthService {
@Resource
private TaobaoClient taobaoClient;
public PhysicInfoDTO getPhysicInfo(String code) {
AlibabaAlihealthDrugtraceTopYljgQueryCodedetailRequest req = new AlibabaAlihealthDrugtraceTopYljgQueryCodedetailRequest();
req.setRefEntId("0820965d6b7b40858d2018238ad491cc");
req.setCodes("84654490010782300850");
AlibabaAlihealthDrugtraceTopYljgQueryCodedetailResponse rsp = null;
try {
rsp = taobaoClient.execute(req);
} catch (ApiException e) {
e.printStackTrace();
}
PhysicInfoDTO physicInfoDTO = new PhysicInfoDTO();
AlibabaAlihealthDrugtraceTopYljgQueryCodedetailResponse.ResultModel result = rsp.getResult();
// List<AlibabaAlihealthDrugtraceTopYljgQueryCodedetailResponse.CodeFullInfoDto> models = result.getModels();
List<AlibabaAlihealthDrugtraceTopYljgQueryCodedetailResponse.CodeFullInfoDto> models = result.getModels();
if(ObjectUtil.isNotEmpty(models)){
AlibabaAlihealthDrugtraceTopYljgQueryCodedetailResponse.CodeFullInfoDto codeFullInfoDto = models.get(0);
AlibabaAlihealthDrugtraceTopYljgQueryCodedetailResponse.CodeProduceInfoDto codeProduceInfoDTO = codeFullInfoDto.getCodeProduceInfoDTO();
List<AlibabaAlihealthDrugtraceTopYljgQueryCodedetailResponse.ProduceInfoDto> produceInfoList = codeProduceInfoDTO.getProduceInfoList();
if(ObjectUtil.isNotEmpty(produceInfoList)){
AlibabaAlihealthDrugtraceTopYljgQueryCodedetailResponse.ProduceInfoDto produceInfoDto = produceInfoList.get(0);
physicInfoDTO.setBatchNo(produceInfoDto.getBatchNo());
physicInfoDTO.setExprieDate(produceInfoDto.getExpireDate());
}
//药品信息
AlibabaAlihealthDrugtraceTopYljgQueryCodedetailResponse.DrugEntBaseDto drugEntBaseDTO = codeFullInfoDto.getDrugEntBaseDTO();
physicInfoDTO.setPhysicName(drugEntBaseDTO.getPhysicName());
physicInfoDTO.setPhysicTypeDesc(drugEntBaseDTO.getPhysicTypeDesc());
physicInfoDTO.setPkgSpecCrit(drugEntBaseDTO.getPkgSpecCrit());
physicInfoDTO.setPrepnSpec(drugEntBaseDTO.getPrepnSpec());
physicInfoDTO.setPrepnTypeDesc(drugEntBaseDTO.getPrepnTypeDesc());
//厂家信息
AlibabaAlihealthDrugtraceTopYljgQueryCodedetailResponse.PUserEntDto pUserEntDto = codeFullInfoDto.getpUserEntDTO();
physicInfoDTO.setFactoryName(pUserEntDto.getEntName());
}
return physicInfoDTO;
}
}
package com.jmai.physic.config;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class AliConfig {
private static final String APPKEY = "35128804";
private static final String APPSECRET = "66a27371154ff0e955d4a6fd9542ad6f";
private static final String URL = "http://gw.api.taobao.com/router/rest";
@Bean
public TaobaoClient taobaoClient(){
TaobaoClient client = new DefaultTaobaoClient(URL, APPKEY, APPSECRET);
return client;
}
}
package com.jmai.physic.controller;
import cn.hutool.core.util.ObjectUtil;
import com.jmai.physic.alihealth.AlihealthService;
import com.jmai.physic.dto.PhysicInfoDTO;
import com.jmai.physic.dto.PhysicWarehouseCreateReq;
import com.jmai.physic.service.PhysicWarehouseService;
import com.jmai.physic.vo.PhysicWarehouseVO;
import com.jmai.sys.AbstractService;
import com.jmai.sys.aop.Auth;
import com.jmai.sys.dto.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Optional;
@Slf4j
//@Auth
@RestController
@RequestMapping("/physicWarehouse")
@Api(tags = "药品入库单据")
@ApiImplicitParams({@ApiImplicitParam(paramType = "header", name = "Access-Token", value = "凭证", required = true, dataType = "string")})
public class PhysicWarehouseController extends AbstractService {
@Resource
private AlihealthService alihealthService;
@Resource
private PhysicWarehouseService physicWarehouseService;
@GetMapping("/getPhysicInfo")
@ApiOperation(value = "查询药品信息")
public ResponseData getPhysicInfo(@RequestParam String code) {
PhysicInfoDTO physicInfoDTO = alihealthService.getPhysicInfo(code);
return ResponseData.ok(physicInfoDTO);
}
@PostMapping("/create")
@ApiOperation(value = "创建入库单据")
public ResponseData<PhysicWarehouseVO> createPhysicWarehouse(@RequestBody @Valid PhysicWarehouseCreateReq req) {
PhysicWarehouseVO physicWarehouseVO = physicWarehouseService.createPhysicWarehouse(req);
return ResponseData.ok(physicWarehouseVO);
}
@PostMapping("/update")
@ApiOperation(value = "更新入库单据")
public ResponseData<PhysicWarehouseVO> updatePhysicWarehouse(@RequestBody @Valid PhysicWarehouseCreateReq req) {
PhysicWarehouseVO physicWarehouseVO = physicWarehouseService.createPhysicWarehouse(req);
return ResponseData.ok(physicWarehouseVO);
}
@PostMapping("/getInfo")
@ApiOperation(value = "获取入库单据信息")
public ResponseData<PhysicWarehouseVO> getInfo(@RequestParam Long physicWarehouseId) {
PhysicWarehouseVO physicWarehouseVO =physicWarehouseService.getInfo(physicWarehouseId);
return ResponseData.ok(physicWarehouseVO);
}
}
package com.jmai.physic.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PhysicInfoDTO {
private String physicName;
@ApiModelProperty(value = "药品类型")
private String physicType;
private String physicTypeDesc;
private String pkgSpecCrit;
private String prepnSpec;
private String prepnTypeDesc;
@ApiModelProperty(value = "失效时间")
private String exprieDate;
@ApiModelProperty(value = "厂家名称")
private String factoryName;
// @ApiModelProperty(value = "供应商")
// private String supplyName;
@ApiModelProperty(value = "批号")
private String batchNo;
}
package com.jmai.physic.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class PhysicWarehouseCreateReq {
private String physicName;
@ApiModelProperty(value = "药品类型")
private String physicType;
private String physicTypeDesc;
private String pkgSpecCrit;
private String prepnSpec;
private String prepnTypeDesc;
@ApiModelProperty(value = "失效时间")
private String exprieDate;
@ApiModelProperty(value = "厂家名称")
private String factoryName;
@ApiModelProperty(value = "供应商")
private String supplyName;
@NotBlank(message = "凭证号不能为空")
@ApiModelProperty(value = "凭证号")
private String voucherNo;
@ApiModelProperty(value = "批号")
private String batchNo;
}
package com.jmai.physic.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jmai.sys.entity.BaseVersionEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(description = "药品入库信息")
@TableName("physic_warehouse")
public class PhysicWarehouse extends BaseVersionEntity{
@ApiModelProperty(value = "药品名称")
private String physicName;
@ApiModelProperty(value = "药品类型")
private String physicType;
private String physicTypeDesc;
private String pkgSpecCrit;
private String prepnSpec;
private String prepnTypeDesc;
@ApiModelProperty(value = "失效时间")
private String exprieDate;
@ApiModelProperty(value = "凭证号")
private String voucherNo;
@ApiModelProperty(value = "批号")
private String batchNo;
@ApiModelProperty(value = "厂家名称")
private String factoryName;
@ApiModelProperty(value = "供应商")
private String supplyName;
@ApiModelProperty(value = "状态")
private Integer status;
}
package com.jmai.physic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jmai.physic.entity.PhysicWarehouse;
import com.jmai.sys.entity.SysFile;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface PhysicWarehouseMapper extends BaseMapper<PhysicWarehouse> {
}
package com.jmai.physic.service;
import com.jmai.physic.dto.PhysicWarehouseCreateReq;
import com.jmai.physic.vo.PhysicWarehouseVO;
public interface PhysicWarehouseService {
PhysicWarehouseVO createPhysicWarehouse(PhysicWarehouseCreateReq req);
PhysicWarehouseVO getInfo(Long physicWarehouseId);
}
package com.jmai.physic.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.jmai.physic.dto.PhysicWarehouseCreateReq;
import com.jmai.physic.entity.PhysicWarehouse;
import com.jmai.physic.mapper.PhysicWarehouseMapper;
import com.jmai.physic.service.PhysicWarehouseService;
import com.jmai.physic.vo.PhysicWarehouseVO;
import com.jmai.sys.AbstractService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class PhysicWarehouseServiceImpl extends AbstractService implements PhysicWarehouseService {
@Resource
private PhysicWarehouseMapper physicWarehouseMapper;
@Override
public PhysicWarehouseVO createPhysicWarehouse(PhysicWarehouseCreateReq req) {
PhysicWarehouse physicWarehouse = new PhysicWarehouse();
BeanUtil.copyProperties(req,physicWarehouse);
physicWarehouseMapper.insert(physicWarehouse);
PhysicWarehouseVO info = getInfo(physicWarehouse.getId());
return info;
}
@Override
public PhysicWarehouseVO getInfo(Long physicWarehouseId) {
PhysicWarehouse physicWarehouse = physicWarehouseMapper.selectById(physicWarehouseId);
PhysicWarehouseVO vo = new PhysicWarehouseVO();
BeanUtil.copyProperties(physicWarehouse,vo);
return vo;
}
}
package com.jmai.physic.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PhysicWarehouseVO {
@ApiModelProperty(value = "药品名称")
private String physicName;
@ApiModelProperty(value = "药品类型")
private String physicType;
private String physicTypeDesc;
private String pkgSpecCrit;
private String prepnSpec;
private String prepnTypeDesc;
@ApiModelProperty(value = "失效时间")
private String exprieDate;
@ApiModelProperty(value = "凭证号")
private String voucherNo;
@ApiModelProperty(value = "批号")
private String batchNo;
@ApiModelProperty(value = "厂家名称")
private String factoryName;
@ApiModelProperty(value = "供应商")
private String supplyName;
@ApiModelProperty(value = "状态 1 -待核验 2 -待复核 3 -已完成")
private Integer status;
}
......@@ -12,6 +12,7 @@
<artifactId>jmai-sys</artifactId>
<dependencies>
<dependency>
<groupId>com.jmai</groupId>
<artifactId>jmai-api</artifactId>
......
......@@ -19,7 +19,7 @@ import java.util.List;
@Auth
@RestController
@RequestMapping("/organization")
@Api(tags = "用户认证")
@Api(tags = "组织")
@ApiImplicitParams({@ApiImplicitParam(paramType = "header", name = "Access-Token", value = "凭证", required = true, dataType = "string")})
public class OrganizationController {
......
......@@ -97,18 +97,4 @@ public class UserController {
UserTokenDto dto = userService.refreshUserToken(req.getRefreshToken());
return ResponseData.ok(dto);
}
@PostMapping("/ssoLogin")
@ApiOperation(value = "单点登录", notes = "单点登录")
public ResponseData<UserTokenDto> ssoLogin() {
UserTokenDto dto = userService.getUserTokenOrThrow(SpringContextUtils.getToken());
return ResponseData.ok(dto);
}
@PostMapping("/listUserTypes")
@ApiOperation(value = "获取用户类型", notes = "获取用户类型列表")
public ResponseData<List<UserTypeDto>> listUserTypes() {
List<UserTypeDto> list = userService.listUserTypes();
return ResponseData.ok(list);
}
}
......@@ -19,8 +19,6 @@ public class SysUser extends BaseExtEntity implements IStatus {
@ApiModelProperty(value = "手机号")
private String mobile;
@ApiModelProperty(value = "密码盐")
private String salt;
@ApiModelProperty(value = "密码")
......
package com.jmai.sys.util;
import com.jmai.api.exception.OpenExceptionCode;
import com.jmai.api.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.*;
/**
* http 请求工具类
*/
@Slf4j
public final class HttpUtils {
//设置字符编码
private static final String CHARSET = "UTF-8";
private static final RestTemplate restTemplate;
static {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
// 连接超时:30秒
requestFactory.setConnectTimeout(60*1000);
// 读写超时:30分钟
requestFactory.setReadTimeout(30*60*1000);
restTemplate =new RestTemplate(requestFactory);
}
//释放资源,httpResponse为响应流,httpClient为请求客户端
private static void release(CloseableHttpResponse httpResponse, CloseableHttpClient httpClient) throws IOException {
if (httpResponse != null) {
httpResponse.close();
}
if (httpClient != null) {
httpClient.close();
}
}
/**
* 发送GET请求
*
* @param url url
* @param paramMap Params
* @param headersMap head
*/
public static String get(String url, Map<String, String> paramMap, Map<String, String> headersMap) throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
URIBuilder uriBuilder = new URIBuilder(url);
if (!CollectionUtils.isEmpty(paramMap)) {
List<NameValuePair> params = new ArrayList<>();
for (String key : paramMap.keySet()) {
params.add(new BasicNameValuePair(key, paramMap.get(key)));
}
uriBuilder.setParameters(params);
}
HttpGet httpget = new HttpGet(uriBuilder.build());
if (!CollectionUtils.isEmpty(headersMap)) {
headersMap.forEach(httpget::addHeader);
}
CloseableHttpResponse response = httpClient.execute(httpget);
HttpEntity entity = response.getEntity();
String result = EntityUtils.toString(entity, CHARSET);
httpget.releaseConnection();
release(response, httpClient);
return result;
}
/**
* 发送POST请求
*
* @param url url
* @param paramMap Params
* @param json body
* @param headersMap head
*/
public static String postJson(String url, Map<String, String> paramMap, String json, Map<String, String> headersMap) {
try {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setContentLanguage(Locale.CHINESE);
// 指定字符编码为UTF-8
headers.set(HttpHeaders.CONTENT_ENCODING, StandardCharsets.UTF_8.name());
headers.set(HttpHeaders.ACCEPT,"*/*");
URIBuilder uriBuilder = new URIBuilder(url);
if (!CollectionUtils.isEmpty(paramMap)) {
List<NameValuePair> params = new ArrayList<>();
for (String key : paramMap.keySet()) {
params.add(new BasicNameValuePair(key, paramMap.get(key)));
}
uriBuilder.setParameters(params);
}
if (!CollectionUtils.isEmpty(headersMap)){
for (Map.Entry<String, String> entry : headersMap.entrySet()) {
headers.add(entry.getKey(), entry.getValue());
}
}
org.springframework.http.HttpEntity<String> request = new org.springframework.http.HttpEntity<>(json, headers);
ResponseEntity<String> response = restTemplate.postForEntity(uriBuilder.build(), request, String.class);
// 获取返回的数据
String responseData = response.getBody();
// 使用指定的字符编码解析返回的数据
String decodedResponse = new String(responseData.getBytes(), StandardCharsets.UTF_8);
return decodedResponse;
} catch (URISyntaxException e) {
throw new ServiceException(OpenExceptionCode.HTTP_URL_ERROR.getCode(), "url=" + url, e);
}
}
public static String sendPostRequestAndParse(String url, String requestBodyJson, Map<String, String> headersMap) throws Exception{
log.info("HttpClientUtils.post url:{}",url);
SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory(
SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(), NoopHostnameVerifier.INSTANCE);
try (CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(scsf).build()) {
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader(org.apache.http.HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8");
if (!CollectionUtils.isEmpty(headersMap)){
for (Map.Entry<String, String> entry : headersMap.entrySet()) {
httpPost.setHeader(entry.getKey(), entry.getValue());
}
}
httpPost.setEntity(new StringEntity(requestBodyJson, StandardCharsets.UTF_8));
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
HttpEntity entity = response.getEntity();
if (entity != null) {
return EntityUtils.toString(entity, StandardCharsets.UTF_8);
}
}
}
return "";
}
public static String postJson(String url, String json) {
return postJson(url, Collections.emptyMap(), json, Collections.emptyMap());
}
public static String portalPostJson(String url,String userName,String password, Map<String, String> paramMap, String json, Map<String, String> headersMap) throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setContentLanguage(Locale.CHINESE);
// 指定字符编码为UTF-8
headers.set(HttpHeaders.CONTENT_ENCODING, StandardCharsets.UTF_8.name());
//账号密码
headers.setBasicAuth(userName,password);
URIBuilder uriBuilder = new URIBuilder(url);
if (!CollectionUtils.isEmpty(paramMap)) {
List<NameValuePair> params = new ArrayList<>();
for (String key : paramMap.keySet()) {
params.add(new BasicNameValuePair(key, paramMap.get(key)));
}
uriBuilder.setParameters(params);
}
for (Map.Entry<String, String> entry : headersMap.entrySet()) {
headers.add(entry.getKey(), entry.getValue());
}
org.springframework.http.HttpEntity<String> request = new org.springframework.http.HttpEntity<>(json, headers);
ResponseEntity<String> response = restTemplate.postForEntity(uriBuilder.build(), request, String.class);
return response.getBody();
}
public static void main(String[] args) throws Exception {
}
}
\ No newline at end of file
This diff could not be displayed because it is too large.
......@@ -12,6 +12,7 @@
<module>jmai-sys</module>
<module>jmai-api</module>
<module>jmai-gw</module>
<module>jmai-physic</module>
</modules>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment