package com.ruoyi.web.controller.pill;

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.common.utils.poi.ExcelUtil;
import com.ruoyi.pill.domain.PillExpiryWarning;
import com.ruoyi.pill.service.IPillExpiryWarningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 药品有效期预警，用于监控药品保质期Controller
 *
 * @author wuweiqiang
 * @date 2025-05-20
 */
@RestController
@RequestMapping("/pill/warning")
public class PillExpiryWarningController extends BaseController
{
    @Autowired
    private IPillExpiryWarningService pillExpiryWarningService;

    /**
     * 查询药品有效期预警，用于监控药品保质期列表
     */
    @PreAuthorize("@ss.hasPermi('pill:warning:list')")
    @GetMapping("/list")
    public TableDataInfo list(PillExpiryWarning pillExpiryWarning)
    {
        startPage();
        List<PillExpiryWarning> list = pillExpiryWarningService.selectPillExpiryWarningList(pillExpiryWarning);
        return getDataTable(list);
    }

    /**
     * 导出药品有效期预警，用于监控药品保质期列表
     */
    @PreAuthorize("@ss.hasPermi('pill:warning:export')")
    @Log(title = "药品有效期预警，用于监控药品保质期", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PillExpiryWarning pillExpiryWarning)
    {
        List<PillExpiryWarning> list = pillExpiryWarningService.selectPillExpiryWarningList(pillExpiryWarning);
        ExcelUtil<PillExpiryWarning> util = new ExcelUtil<PillExpiryWarning>(PillExpiryWarning.class);
        util.exportExcel(response, list, "药品有效期预警，用于监控药品保质期数据");
    }

    /**
     * 获取药品有效期预警，用于监控药品保质期详细信息
     */
    @PreAuthorize("@ss.hasPermi('pill:warning:query')")
    @GetMapping(value = "/{warningId}")
    public AjaxResult getInfo(@PathVariable("warningId") Long warningId)
    {
        return success(pillExpiryWarningService.selectPillExpiryWarningByWarningId(warningId));
    }

    /**
     * 新增药品有效期预警，用于监控药品保质期
     */
    @PreAuthorize("@ss.hasPermi('pill:warning:add')")
    @Log(title = "药品有效期预警，用于监控药品保质期", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PillExpiryWarning pillExpiryWarning)
    {
        return toAjax(pillExpiryWarningService.insertPillExpiryWarning(pillExpiryWarning));
    }

    /**
     * 修改药品有效期预警，用于监控药品保质期
     */
    @PreAuthorize("@ss.hasPermi('pill:warning:edit')")
    @Log(title = "药品有效期预警，用于监控药品保质期", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PillExpiryWarning pillExpiryWarning)
    {
        return toAjax(pillExpiryWarningService.updatePillExpiryWarning(pillExpiryWarning));
    }

    /**
     * 删除药品有效期预警，用于监控药品保质期
     */
    @PreAuthorize("@ss.hasPermi('pill:warning:remove')")
    @Log(title = "药品有效期预警，用于监控药品保质期", businessType = BusinessType.DELETE)
   @DeleteMapping("/{warningIds}")
    public AjaxResult remove(@PathVariable Long[] warningIds)
    {
        return toAjax(pillExpiryWarningService.deletePillExpiryWarningByWarningIds(warningIds));
    }
}

package com.ruoyi.pill.domain;

import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 药品有效期预警，用于监控药品保质期对象 pill_expiry_warning
 * 
 * @author wuweiqiang
 * @date 2025-05-20
 */
public class PillExpiryWarning extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    private Long warningId;

    /** 药品ID（关联pill_drug.drug_id） */
    @Excel(name = "药品ID", readConverterExp = "关=联pill_drug.drug_id")
    private Long drugId;

    /** 厂家ID（关联pill_factory.factory_id） */
    @Excel(name = "厂家ID", readConverterExp = "关=联pill_factory.factory_id")
    private Long factoryId;

    /** 药品生产日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "药品生产日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date productionDate;

    /** 保质期（天） */
    @Excel(name = "保质期", readConverterExp = "天=")
    private Long validityPeriod;

    /** 进货单ID（关联pill_purchase.purchase_id） */
    @Excel(name = "进货单ID", readConverterExp = "关=联pill_purchase.purchase_id")
    private Long purchaseId;

    /** 库存数量 */
    @Excel(name = "库存数量")
    private Long stock;

    public void setWarningId(Long warningId) 
    {
        this.warningId = warningId;
    }

    public Long getWarningId() 
    {
        return warningId;
    }

    public void setDrugId(Long drugId) 
    {
        this.drugId = drugId;
    }

    public Long getDrugId() 
    {
        return drugId;
    }

    public void setFactoryId(Long factoryId) 
    {
        this.factoryId = factoryId;
    }

    public Long getFactoryId() 
    {
        return factoryId;
    }

    public void setProductionDate(Date productionDate) 
    {
        this.productionDate = productionDate;
    }

    public Date getProductionDate() 
    {
        return productionDate;
    }

    public void setValidityPeriod(Long validityPeriod) 
    {
        this.validityPeriod = validityPeriod;
    }

    public Long getValidityPeriod() 
    {
        return validityPeriod;
    }

    public void setPurchaseId(Long purchaseId) 
    {
        this.purchaseId = purchaseId;
    }

    public Long getPurchaseId() 
    {
        return purchaseId;
    }

    public void setStock(Long stock) 
    {
        this.stock = stock;
    }

    public Long getStock() 
    {
        return stock;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("warningId", getWarningId())
            .append("drugId", getDrugId())
            .append("factoryId", getFactoryId())
            .append("productionDate", getProductionDate())
            .append("validityPeriod", getValidityPeriod())
            .append("purchaseId", getPurchaseId())
            .append("stock", getStock())
            .append("createTime", getCreateTime())
            .toString();
    }
}

package com.ruoyi.pill.mapper;

import java.util.List;
import com.ruoyi.pill.domain.PillExpiryWarning;

/**
 * 药品有效期预警，用于监控药品保质期Mapper接口
 * 
 * @author wuweiqiang
 * @date 2025-05-20
 */
public interface PillExpiryWarningMapper 
{
    /**
     * 查询药品有效期预警，用于监控药品保质期
     * 
     * @param warningId 药品有效期预警，用于监控药品保质期主键
     * @return 药品有效期预警，用于监控药品保质期
     */
    public PillExpiryWarning selectPillExpiryWarningByWarningId(Long warningId);

    /**
     * 查询药品有效期预警，用于监控药品保质期列表
     * 
     * @param pillExpiryWarning 药品有效期预警，用于监控药品保质期
     * @return 药品有效期预警，用于监控药品保质期集合
     */
    public List<PillExpiryWarning> selectPillExpiryWarningList(PillExpiryWarning pillExpiryWarning);

    /**
     * 新增药品有效期预警，用于监控药品保质期
     * 
     * @param pillExpiryWarning 药品有效期预警，用于监控药品保质期
     * @return 结果
     */
    public int insertPillExpiryWarning(PillExpiryWarning pillExpiryWarning);

    /**
     * 修改药品有效期预警，用于监控药品保质期
     * 
     * @param pillExpiryWarning 药品有效期预警，用于监控药品保质期
     * @return 结果
     */
    public int updatePillExpiryWarning(PillExpiryWarning pillExpiryWarning);

    /**
     * 删除药品有效期预警，用于监控药品保质期
     * 
     * @param warningId 药品有效期预警，用于监控药品保质期主键
     * @return 结果
     */
    public int deletePillExpiryWarningByWarningId(Long warningId);

    /**
     * 批量删除药品有效期预警，用于监控药品保质期
     * 
     * @param warningIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deletePillExpiryWarningByWarningIds(Long[] warningIds);
}

package com.ruoyi.pill.service;

import java.util.List;
import com.ruoyi.pill.domain.PillExpiryWarning;

/**
 * 药品有效期预警，用于监控药品保质期Service接口
 * 
 * @author wuweiqiang
 * @date 2025-05-20
 */
public interface IPillExpiryWarningService 
{
    /**
     * 查询药品有效期预警，用于监控药品保质期
     * 
     * @param warningId 药品有效期预警，用于监控药品保质期主键
     * @return 药品有效期预警，用于监控药品保质期
     */
    public PillExpiryWarning selectPillExpiryWarningByWarningId(Long warningId);

    /**
     * 查询药品有效期预警，用于监控药品保质期列表
     * 
     * @param pillExpiryWarning 药品有效期预警，用于监控药品保质期
     * @return 药品有效期预警，用于监控药品保质期集合
     */
    public List<PillExpiryWarning> selectPillExpiryWarningList(PillExpiryWarning pillExpiryWarning);

    /**
     * 新增药品有效期预警，用于监控药品保质期
     * 
     * @param pillExpiryWarning 药品有效期预警，用于监控药品保质期
     * @return 结果
     */
    public int insertPillExpiryWarning(PillExpiryWarning pillExpiryWarning);

    /**
     * 修改药品有效期预警，用于监控药品保质期
     * 
     * @param pillExpiryWarning 药品有效期预警，用于监控药品保质期
     * @return 结果
     */
    public int updatePillExpiryWarning(PillExpiryWarning pillExpiryWarning);

    /**
     * 批量删除药品有效期预警，用于监控药品保质期
     * 
     * @param warningIds 需要删除的药品有效期预警，用于监控药品保质期主键集合
     * @return 结果
     */
    public int deletePillExpiryWarningByWarningIds(Long[] warningIds);

    /**
     * 删除药品有效期预警，用于监控药品保质期信息
     * 
     * @param warningId 药品有效期预警，用于监控药品保质期主键
     * @return 结果
     */
    public int deletePillExpiryWarningByWarningId(Long warningId);
}

<?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.ruoyi.pill.mapper.PillExpiryWarningMapper">
    
    <resultMap type="PillExpiryWarning" id="PillExpiryWarningResult">
        <result property="warningId"    column="warning_id"    />
        <result property="drugId"    column="drug_id"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="productionDate"    column="production_date"    />
        <result property="validityPeriod"    column="validity_period"    />
        <result property="purchaseId"    column="purchase_id"    />
        <result property="stock"    column="stock"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectPillExpiryWarningVo">
        select warning_id, drug_id, factory_id, production_date, validity_period, purchase_id, stock, create_time from pill_expiry_warning
    </sql>

    <select id="selectPillExpiryWarningList" parameterType="PillExpiryWarning" resultMap="PillExpiryWarningResult">
        <include refid="selectPillExpiryWarningVo"/>
        <where>  
            <if test="drugId != null "> and drug_id = #{drugId}</if>
            <if test="factoryId != null "> and factory_id = #{factoryId}</if>
            <if test="productionDate != null "> and production_date = #{productionDate}</if>
            <if test="validityPeriod != null "> and validity_period = #{validityPeriod}</if>
            <if test="purchaseId != null "> and purchase_id = #{purchaseId}</if>
            <if test="stock != null "> and stock = #{stock}</if>
        </where>
    </select>
    
    <select id="selectPillExpiryWarningByWarningId" parameterType="Long" resultMap="PillExpiryWarningResult">
        <include refid="selectPillExpiryWarningVo"/>
        where warning_id = #{warningId}
    </select>

    <insert id="insertPillExpiryWarning" parameterType="PillExpiryWarning" useGeneratedKeys="true" keyProperty="warningId">
        insert into pill_expiry_warning
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="drugId != null">drug_id,</if>
            <if test="factoryId != null">factory_id,</if>
            <if test="productionDate != null">production_date,</if>
            <if test="validityPeriod != null">validity_period,</if>
            <if test="purchaseId != null">purchase_id,</if>
            <if test="stock != null">stock,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="drugId != null">#{drugId},</if>
            <if test="factoryId != null">#{factoryId},</if>
            <if test="productionDate != null">#{productionDate},</if>
            <if test="validityPeriod != null">#{validityPeriod},</if>
            <if test="purchaseId != null">#{purchaseId},</if>
            <if test="stock != null">#{stock},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updatePillExpiryWarning" parameterType="PillExpiryWarning">
        update pill_expiry_warning
        <trim prefix="SET" suffixOverrides=",">
            <if test="drugId != null">drug_id = #{drugId},</if>
            <if test="factoryId != null">factory_id = #{factoryId},</if>
            <if test="productionDate != null">production_date = #{productionDate},</if>
            <if test="validityPeriod != null">validity_period = #{validityPeriod},</if>
            <if test="purchaseId != null">purchase_id = #{purchaseId},</if>
            <if test="stock != null">stock = #{stock},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where warning_id = #{warningId}
    </update>

    <delete id="deletePillExpiryWarningByWarningId" parameterType="Long">
        delete from pill_expiry_warning where warning_id = #{warningId}
    </delete>

    <delete id="deletePillExpiryWarningByWarningIds" parameterType="String">
        delete from pill_expiry_warning where warning_id in 
        <foreach item="warningId" collection="array" open="(" separator="," close=")">
            #{warningId}
        </foreach>
    </delete>
</mapper>

-- ----------------------------
-- Table structure for pill_purchase
-- ----------------------------
DROP TABLE IF EXISTS `pill_purchase`;
CREATE TABLE `pill_purchase` (
  `purchase_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '进货单ID',
  `drug_id` bigint(20) NOT NULL COMMENT '药品ID（关联pill_drug.drug_id）',
  `factory_id` bigint(20) NOT NULL COMMENT '生产厂家ID（关联pill_factory.factory_id）',
  `purchase_time` datetime NOT NULL COMMENT '进货时间',
  `purchase_price` decimal(10,2) NOT NULL COMMENT '进货单价（元）',
  `purchase_num` int(10) NOT NULL COMMENT '进货数量',
  `remark` varchar(500) DEFAULT NULL COMMENT '进货备注',
  `create_by` varchar(50) DEFAULT NULL COMMENT '创建者',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) DEFAULT NULL COMMENT '更新者',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`purchase_id`),
  KEY `idx_drug_id` (`drug_id`),
  KEY `idx_factory_id` (`factory_id`),
  CONSTRAINT `fk_purchase_drug` FOREIGN KEY (`drug_id`) REFERENCES `pill_drug` (`drug_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_purchase_factory` FOREIGN KEY (`factory_id`) REFERENCES `pill_factory` (`factory_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=utf8 COMMENT='药品进货记录表';

/*
Navicat MySQL Data Transfer

Source Server         : test
Source Server Version : 50717
Source Host           : localhost:3306
Source Database       : storage1

Target Server Type    : MYSQL
Target Server Version : 50717
File Encoding         : 65001

Date: 2022-09-25 17:33:23
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for pill_drug
-- ----------------------------
DROP TABLE IF EXISTS `pill_drug`;
CREATE TABLE `pill_drug` (
  `drug_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '药品ID',
  `drug_name` varchar(50) DEFAULT NULL COMMENT '药品名称',
  `drug_code` varchar(50) DEFAULT NULL COMMENT '药品编码',
  `factory_id` bigint(20) DEFAULT NULL COMMENT '生产厂家',
  `drug_type` char(1) DEFAULT NULL COMMENT '药品类型',
  `prescription_type` char(1) DEFAULT NULL COMMENT '处方类型',
  `unit` varchar(10) DEFAULT NULL COMMENT '单位',
  `price` int(10) DEFAULT NULL COMMENT '价格',
  `num` int(10) DEFAULT NULL COMMENT '库存量',
  `warn_value` int(10) DEFAULT NULL COMMENT '预警值',
  `conversion` int(10) DEFAULT NULL COMMENT '换算量',
  `status` char(1) DEFAULT NULL COMMENT '状态',
  `create_by` varchar(50) DEFAULT NULL COMMENT '创建者',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) DEFAULT NULL 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='药品信息';

-- ----------------------------
-- Records of pill_drug
-- ----------------------------
INSERT INTO `pill_drug` VALUES ('101', '十全大补丸', 'dbw0001', '101', '0', '0', '瓶', '200', '100', '50', '1', '0', 'admin', '2022-08-27 16:03:29', null, null, null);
INSERT INTO `pill_drug` VALUES ('102', '阿莫西林', 'zcy0002', '102', '1', '1', '盒', '15', '300', '50', '1', '0', 'admin', '2022-09-15 16:03:29', null, null, null);

/*
Navicat MySQL Data Transfer

Source Server         : test
Source Server Version : 50717
Source Host           : localhost:3306
Source Database       : storage

Target Server Type    : MYSQL
Target Server Version : 50717
File Encoding         : 65001

Date: 2022-09-25 15:48:01
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for pill_factory
-- ----------------------------
DROP TABLE IF EXISTS `pill_factory`;
CREATE TABLE `pill_factory` (
  `factory_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '厂家ID',
  `factory_name` varchar(50) DEFAULT NULL COMMENT '厂家名称',
  `factory_code` varchar(50) DEFAULT NULL COMMENT '厂家编码',
  `contact` varchar(30) DEFAULT NULL COMMENT '联系人',
  `phone` varchar(30) DEFAULT NULL COMMENT '电话',
  `keyword` varchar(20) DEFAULT NULL COMMENT '关键字',
  `status` char(1) DEFAULT NULL COMMENT '状态',
  `create_by` varchar(50) DEFAULT NULL COMMENT '创建者',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) DEFAULT NULL COMMENT '更新者',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`factory_id`)
) ENGINE=InnoDB AUTO_INCREMENT=105 DEFAULT CHARSET=utf8 COMMENT='生产厂家信息';

-- ----------------------------
-- Records of pill_factory
-- ----------------------------
INSERT INTO `pill_factory` VALUES ('101', '云南白药集团股份有限公司', '000011', 'admin', '023-88887777', 'ynby', '0', 'admin', '2022-09-26 16:15:29', null, null, null);
INSERT INTO `pill_factory` VALUES ('102', '哈药集团股份有限公司', '000022', 'admin', '023-88887777', 'hyjt', '0', 'admin', '2022-09-26 16:15:29', 'admin', '2022-09-26 20:34:01', null);
INSERT INTO `pill_factory` VALUES ('103', '太极集团有限公司', '000033', 'admin', '023-88887777', 'tjjt', '0', 'admin', '2022-09-26 16:15:29', null, null, null);
INSERT INTO `pill_factory` VALUES ('104', '上海医药集团有限公司', '000033', 'admin', '023-99998888', 'shyy', '0', 'admin', '2022-09-26 20:12:57', null, null, null);

DROP TABLE IF EXISTS `pill_expiry_warning`;
CREATE TABLE `pill_expiry_warning` (
  `warning_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `drug_id` bigint(20) NOT NULL COMMENT '药品ID（关联pill_drug.drug_id）',
  `factory_id` bigint(20) NOT NULL COMMENT '厂家ID（关联pill_factory.factory_id）',
  `production_date` date NOT NULL COMMENT '药品生产日期',
  `validity_period` int(10) NOT NULL COMMENT '保质期（天）',
  `purchase_id` bigint(20) NOT NULL COMMENT '进货单ID（关联pill_purchase.purchase_id）',
  `stock` int(10) NOT NULL COMMENT '库存数量',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
  PRIMARY KEY (`warning_id`),
  KEY `idx_drug_id` (`drug_id`),
  KEY `idx_factory_id` (`factory_id`),
  CONSTRAINT `fk_expiry_drug` FOREIGN KEY (`drug_id`) REFERENCES `pill_drug` (`drug_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_expiry_factory` FOREIGN KEY (`factory_id`) REFERENCES `pill_factory` (`factory_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_expiry_purchase` FOREIGN KEY (`purchase_id`) REFERENCES `pill_purchase` (`purchase_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='药品有效期预警表，用于监控药品保质期';
帮忙修改代码
要显示 药品名称 生产厂家 药品生产日期 保质期 进货时间（pill_purchase） 药品距离多少天过期 库存
将purchase_time由pill_purchase表联合查询，让该表时需同步
不要改变我的文件名，给我修改后完整的代码