若依项目源代码
https://gitee.com/ben10rk/ruoyi-his
〇、创建his-medicine模块
0) 在创建好的若依后端项目中创建一个maven模块his-medicine

1)his模块的整合步骤
①)his的依赖
这个是若依项目所有系统模块都需要添加的依赖,domain和controller继承的类就在这里面。
<!-- 通用工具-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
②)安装his模块

③) 在ruoyi-admin模块中引入his模块
实质上在项目运行时,实际运行的是ruoyi-admin项目,所有其他模块的文件最终都放到此模块下。

一、实现his的思路:
his医院信息管理系统的业务对象包括生产厂家、供应商、药品、订单、订单详情等等,要想完成一个his,首先需要把所有的业务对象的增删改查基础代码写出来,单表的增删改查过程虽然可以直接使用代码生成器,所以首先可以尝试自己手动写一个系统对象,熟悉若依的系统框架到底是怎么运行的;
然后再考虑复杂的业务场景。
整个业务流程如图:

对应的业务需求:
二、生产厂家系统:
每种药品可以由多个生产厂家生产
三、药品系统:
药品包含预警值drug_warn,药品数量drug_num,药品状态drug_status
使用定时任务每天进行校验:
当药品数量大于或小于预警值时,修改对应的药品状态
四、经销商系统:
采购员采购时可以选择不同的经销商
五、采购商系统:
1) 创建购物车:
本来使用redis数据库存储药品信息,这里直接设计的mysql数据库的购物车表;
存储药品信息,使用jackson提供的ObjectMapper对象HashMap<Long,Drug>转换为json格式,键为药品的id,值为药品的信息
ObjectMapper对象,读取json格式使用ObjectMapper对象的readValue()
存储药品信息时,直接使用json格式文本存储。这一步可以直接将药品的单价,购买数量,规格全部存储。降低多次访问数据库查询药品信息。
可以选择药品的购买数量及经销商
//cart为存储的药品信息对象。
//将json转换为map
HashMap<Long, HisMedicineDrug> hashMapNew = objectMapper.readValue(cart, new TypeReference<HashMap<Long, HisMedicineDrug>>() {
});
hashMapNew.put(drugId, hisMedicineDrug);
//hisCart为购物车对象
//将map转换为json
String s = objectMapper.writeValueAsString(hashMapNew);
hisCart.setCart(s);
cartMapper.updateCart(hisCart)
2) 给购物车中的药品创建订单:
删除购物车对应id药品信息,并创建订单和订单详情
订单的订单号为随机值
订单详情中存储了购买的药品id和购买数量num,还有对应的订单主键id
3) 修改,删除订单详情:
修改药品购买数量,删除某个药品
六、审核管理员 检验管理员 入库管理员系统:
订单状态的业务流程:
订单状态: 为常量数据,存在若依字典库中
待审核 采购员提交订单 审核通过 审核 审核 驳回 审核 驳回 订单异常 采购员提出异常 作废 审核对异常订单作废 待检验 采购员确认采购完毕 检验异常 检验员 检验异常 待入库 检验员 检验成功 入库成功 其他业务系统 待结算 其他业务系统
关闭 流程结束
二、生产厂家系统:
1)数据库sql建表语句
drop table if exists his_medicine_factory
CREATE TABLE `his_medicine_factory` (
`factory_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '厂家ID',
`factory_name` varchar(100) DEFAULT NULL COMMENT '厂家名称',
`factory_code` varchar(50) NOT NULL COMMENT '厂家编码',
`factory_person` varchar(50) NOT NULL COMMENT '厂家联系人',
`factory_phone` char(11) DEFAULT '00' COMMENT '联系方式',
`factory_keyword` varchar(50) DEFAULT '' COMMENT '厂家关键字',
`factory_address` varchar(100) DEFAULT '' COMMENT '厂家地址',
`status` char(1) DEFAULT '0' COMMENT '(0正常 1 禁用)',
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`factory_id`)
) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8 COMMENT='生产厂家信息表';
2)单表增删改查的实现
写一个生产厂家的管理系统可以对照写好的部门系统SysPost格式,从后端到前端不管是代码的格式还是界面elementplus标签 岗位系统是比较好的参考例子。


〇)domain
通过若依写好的岗位管理系统发现所有实体类都继承了BaseEntity
BaseEntity主要用来存放一些公共的属性值,对应的也就是数据库中表中的公共字段
那根据数据库创建的实体类MedicineFactory也继承BaseEntity

package com.ruoyi.domain;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.sql.Date;
/**
* @author rk
* @description: TODO
* @date 2024/8/28 19:08
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MedicineFactory extends BaseEntity {
private Long factoryId;
private String factoryName;
private String factoryCode;
private String factoryPerson;
private String factoryPhone;
private String factoryKeyword;
private String factoryAddress;
private String status;
private String createBy;
private Date createTime;
private String updateBy;
private Date updateTime;
private String remake;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date startTime;
@DateTimeFormat(pattern = "yyyy-MM-dd" )
private Date endTime;
}
①mapper 没有影响 ,照写
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"">
<mapper namespace="com.ruoyi.mapper.HisMedicineFactoryMapper">
<resultMap id="factory" type="com.ruoyi.domain.MedicineFactory">
<id column="factory_id" property="factoryId"></id>
<result column="factory_name" property="factoryName"></result>
<result column="factory_code" property="factoryCode"></result>
<result column="factory_person" property="factoryPerson"></result>
<result column="factory_phone" property="factoryPhone"></result>
<result column="factory_keyword" property="factoryKeyword"></result>
<result column="factory_address" property="factoryAddress"></result>
<result column="create_by" property="createBy"></result>
<result column="create_time" property="createTime"></result>
<result column="update_by" property="updateBy"></result>
<result column="update_time" property="updateTime"></result>
<result column="remark" property="remark"></result>
<!--
<association property="" resultMap=""></association>-->
</resultMap>
<sql id="selectFactory">
select factory_id,factory_name,factory_code,factory_person,
factory_phone ,factory_keyword,factory_address,create_by,create_time,
update_by,update_time,remark,status
from his_medicine_factory
</sql>
<select id="selectFactoryList" resultMap="factory">
<include refid="selectFactory"></include>
<where>
<if test="factoryName!=null and factoryName!=''">
and factory_name like concat('%',#{factoryName},'%')
</if>
<if test="factoryKeyword!=null and factoryKeyword!=''">
and factory_keyword = #{factoryKeyword}
</if>
<if test="factoryPhone!=null and factoryPhone!=''">
and factory_phone = #{factoryPhone}
</if>
<if test="status!=null and status!=''">
and status = #{status}
</if>
<if test="params.startTime!=null and params.startTime!=''">
and create_time >= #{params.startTime}
</if>
<if test="params.endTime!=null and params.endTime!=''">
and create_time <= #{params.endTime}
</if>
</where>
</select>
<update id="updateFactory">
update his_medicine_factory
<set>
<if test="factoryCode != null and factoryCode != ''">factory_code = #{factoryCode},</if>
<if test="factoryPerson != null and factoryPerson != ''">factory_person = #{factoryPerson},</if>
<if test="factoryKeyword != null and factoryKeyword !=''">factory_keyword = #{factoryKeyword},</if>
<if test="factoryAddress != null and factoryAddress !=''">factory_address = #{factoryAddress},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where factory_id = #{factoryId}
</update>
<insert id="addFactory">
insert into his_medicine_factory
values(0,#{factoryName},#{factoryCode},#{factoryPerson},#{factoryPhone},#{factoryKeyword},
#{factoryAddress},#{status},#{createBy},sysdate(),
0,NULL,#{remake})
</insert>
<delete id="deleteFactoryById">
delete from his_medicine_factory
where factory_id = #{id}
</delete>
<select id="selectFactoryById" resultMap="factory">
<include refid="selectFactory"></include>
where factory_id = #{id}
</select>
</mapper>
package com.ruoyi.mapper;
import com.ruoyi.domain.MedicineFactory;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface HisMedicineFactoryMapper {
List<MedicineFactory> selectFactoryList(MedicineFactory medicineFactory);
int updateFactory(MedicineFactory medicineFactory);
int addFactory(MedicineFactory medicineFactory);
int deleteFactoryById(Long id);
MedicineFactory selectFactoryById(Long id);
}
②service 没有影响 ,照写
package com.ruoyi.service;
import com.ruoyi.domain.MedicineFactory;
import java.util.List;
public interface IHisMedicineFactory {
List<MedicineFactory> selectFactoryList(MedicineFactory medicineFactory);
int updateFactory(MedicineFactory medicineFactory);
int addFactory(MedicineFactory medicineFactory);
int deleteFactoryById(Long id);
MedicineFactory selectFactoryById(Long id);
}
package com.ruoyi.service.impl;
import com.ruoyi.mapper.HisMedicineFactoryMapper;
import com.ruoyi.service.IHisMedicineFactory;
import com.ruoyi.domain.MedicineFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author rk
* @description: TODO
* @date 2024/8/28 20:26
*/
@Service
public class HisMedicineFactoryImpl implements IHisMedicineFactory {
@Autowired
private HisMedicineFactoryMapper hisMedicineFactoryMapper;
@Override
public List<MedicineFactory> selectFactoryList(MedicineFactory medicineFactory) {
return hisMedicineFactoryMapper.selectFactoryList(medicineFactory);
}
@Override
public int updateFactory(MedicineFactory medicineFactory) {
return hisMedicineFactoryMapper.updateFactory(medicineFactory);
}
@Override
public int addFactory(MedicineFactory medicineFactory) {
return hisMedicineFactoryMapper.addFactory(medicineFactory);
}
@Override
public int deleteFactoryById(Long id) {
return hisMedicineFactoryMapper.deleteFactoryById(id);
}
@Override
public MedicineFactory selectFactoryById(Long id) {
return hisMedicineFactoryMapper.selectFactoryById(id);
}
}
③controller
controller类的代码放在ruoyi-admin目录下;
需要继承BaseController ;
每个单元方法上添加检验权限标识符的注解@PreAuthorize
package com.ruoyi.web.controller.medicine;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.MedicineFactory;
import com.ruoyi.service.IHisMedicineFactory;
import com.ruoyi.system.domain.SysPost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author rk
* @description: TODO
* @date 2024/8/28 20:34
*/
@RestController
@RequestMapping("medicine/factory")
public class MedicineController extends BaseController {
@Autowired
private IHisMedicineFactory hisMedicineFactory;
/**
*
*/
@PreAuthorize("@ss.hasPermi('medicine:factory:list')")
@GetMapping("/list")
public TableDataInfo list(MedicineFactory medicineFactory)
{
startPage();
List<MedicineFactory> list = hisMedicineFactory.selectFactoryList(medicineFactory);
return getDataTable(list);
}
/**
* 根据岗位编号获取详细信息
*/
@PreAuthorize("@ss.hasPermi('medicine:factory:list')")
@GetMapping(value = "/list/{id}")
public AjaxResult getInfo(@PathVariable Long id)
{
return success(hisMedicineFactory.selectFactoryById(id));
}
@PreAuthorize("@ss.hasPermi('medicine:factory:add')")
@PostMapping
public AjaxResult add(@Validated @RequestBody MedicineFactory medicineFactory)
{
medicineFactory.setCreateBy(getUsername());
return toAjax(hisMedicineFactory.addFactory(medicineFactory));
}
/**
* 修改岗位
*/
@PreAuthorize("@ss.hasPermi('medicine:factory:edit')")
@PutMapping
public AjaxResult edit(@Validated @RequestBody MedicineFactory medicineFactory)
{
medicineFactory.setUpdateBy(getUsername());
return toAjax(hisMedicineFactory.updateFactory(medicineFactory));
}
/**
* 删除岗位
*/
@PreAuthorize("@ss.hasPermi('medicine:factory:remove')")
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id)
{
return toAjax(hisMedicineFactory.deleteFactoryById(id));
}
}
3)对应的前端界面
〇)界面效果

①)登录若依管理系统手动添加对应的路由地址和url


②) 前端代码
界面的elementplus标签和script内语法可以参照岗位系统的前端界面post.vue代码。js文件也只需要参照api下的post.js,若依前端内部已经封装好了axios的调用函数request(),只需要提供method,url,data就可以使用。



三、药品系统
1) sql建表语句:
CREATE TABLE `his_medicine_drug` (
`drug_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '药品ID',
`drug_name` varchar(100) DEFAULT NULL COMMENT '药片名称',
`drug_code` varchar(50) NOT NULL COMMENT '药品编码',
`drug_keyword` varchar(50) NOT NULL COMMENT '药片关键字',
`factory_id` bigint(20) NOT NULL COMMENT '生产厂家ID',
`drug_type` char(1) NOT NULL COMMENT '药品类型',
`drug_prescription` char(1) NOT NULL COMMENT '处方类型',
`drug_unit` char(1) NOT NULL COMMENT '单位',
`drug_price` double DEFAULT NULL COMMENT '销售价格--预留字段',
`drug_num` int(11) NOT NULL COMMENT '库存数量',
`drug_warn` int(11) NOT NULL COMMENT '预警值',
`status` char(1) DEFAULT '0' COMMENT '(0正常 1 禁用)',
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`drug_id`)
) ENGINE=InnoDB AUTO_INCREMENT=103 DEFAULT CHARSET=utf8 COMMENT='药品信息表';
四、经销商系统
1) sql建表语句:
CREATE TABLE `his_medicine_supplier` (
`supplier_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '供应商ID',
`supplier_name` varchar(100) DEFAULT NULL COMMENT '供应商名称',
`supplier_person` varchar(50) NOT NULL COMMENT '供应商联系人',
`supplier_phone` char(11) DEFAULT '00' COMMENT '供应商方式',
`supplier_bank` varchar(50) DEFAULT '' COMMENT '银行卡号',
`supplier_address` varchar(100) DEFAULT '' COMMENT '供应商地址',
`status` char(1) DEFAULT '0' COMMENT '(0正常 1 禁用)',
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`supplier_id`)
) ENGINE=InnoDB AUTO_INCREMENT=103 DEFAULT CHARSET=utf8 COMMENT='供应商信息表';
五、采购商系统
1) sql建表语句:核心业务 需要设计多张表
①订单表:
drop table if EXISTS his_medicine_order ;
CREATE TABLE `his_medicine_order` (
`order_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '订单ID',
`order_num` varchar(100) DEFAULT NULL COMMENT '订单编号',
`order_person` bigint(20) NOT NULL COMMENT '制单人',
`supplier_id` bigint(20) NOT NULL COMMENT '供应商ID',
`order_money` double COMMENT '订单总金额',
`order_status` char(2) COMMENT '订单状态',
`status` char(1) DEFAULT '0' COMMENT '(0正常 1 禁用)',
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`order_id`)
) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8 COMMENT='订单信息表';
②订单详情表:
drop table if EXISTS his_medicine_order_detail ;
CREATE TABLE `his_medicine_order_detail` (
`detail_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '详情ID',
`drug_id` bigint(20) DEFAULT NULL COMMENT '药品ID',
`detail_num` int NOT NULL COMMENT '数量',
`detail_money` double NOT NULL COMMENT '药品单价',
`detail_batch` varchar(50) DEFAULT '00' COMMENT '批次号',
`order_id` bigint(20) COMMENT '订单ID',
`status` char(1) DEFAULT '0' COMMENT '(0正常 1 禁用)',
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`detail_id`)
) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8 COMMENT='订单详情信息表';
③购物车表:
create table his_medicine_cart(
id bigint not null primary key auto_increment,
user_id bigint not null,
cart text,
remark varchar(500)
)
六、审核管理员 检验管理员 入库管理员系统
1) sql建表语句:
①审核表
drop table if EXISTS his_medicine_order_audit;
CREATE TABLE `his_medicine_order_audit` (
`audit_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '审核ID',
`audit_person` bigint(20) DEFAULT NULL COMMENT '审核人',
`audit_content` varchar(50) NOT NULL COMMENT '审核意见',
`audit_result` char(1) NOT NULL COMMENT '审核结果',
`order_id` bigint(20) COMMENT '订单ID',
`status` char(1) DEFAULT '0' COMMENT '(0正常 1 禁用)',
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`audit_id`)
) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8 COMMENT='审核信息表';
②检验表
drop table if EXISTS his_medicine_order_check;
CREATE TABLE `his_medicine_order_check` (
`check_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '检验记录ID',
`check_person` bigint(20) DEFAULT NULL COMMENT '检验人',
`check_content` text NOT NULL COMMENT '检验意见',
`check_result` varchar(50) NOT NULL COMMENT '检验结果',
`order_id` bigint(20) COMMENT '订单ID',
`status` char(1) DEFAULT '0' COMMENT '(0正常 1 禁用)',
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`check_id`)
) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8 COMMENT='检验记录信息表';
③入库表
drop table if EXISTS his_medicine_order_rep ;
CREATE TABLE `his_medicine_order_rep` (
`rep_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '入库记录ID',
`rep_person` bigint(20) DEFAULT NULL COMMENT '入库人',
`rep_content` text NOT NULL COMMENT '入库意见',
`rep_result` char(1) NOT NULL COMMENT '入库结果',
`order_id` bigint(20) COMMENT '订单ID',
`status` char(1) DEFAULT '0' COMMENT '(0正常 1 禁用)',
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`rep_id`)
) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8 COMMENT='入库记录信息表';
(责任编辑:)
|