xuhy
2025-09-05 bde85e957a1034ebee0edd1e4d440c0dfbdcfe19
Merge remote-tracking branch 'origin/master'
8个文件已修改
1个文件已添加
370 ■■■■■ 已修改文件
ruoyi-admin/pom.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpSupplierWarehousingController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/importExcel/TErpGoodsExcel.java 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpGoods.java 65 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/pom.xml
@@ -151,12 +151,12 @@
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.17</version>
            <version>4.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.17</version>
            <version>4.1.2</version>
        </dependency>
        <dependency>
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java
@@ -1,25 +1,47 @@
package com.ruoyi.web.controller.api;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.utils.WebUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.TErpGoodsAddDto;
import com.ruoyi.system.dto.TErpGoodsInfoSaveDto;
import com.ruoyi.system.dto.TErpGoodsUpdateStatusDto;
import com.ruoyi.system.importExcel.TErpGoodsExcel;
import com.ruoyi.system.model.TErpGoods;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.service.TErpGoodsService;
import com.ruoyi.system.vo.TErpGoodsVO;
import com.ruoyi.web.controller.tool.ImportExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
/**
 * <p>
@@ -117,6 +139,70 @@
        return R.ok(goods);
    }
    @ApiOperation(value = "商品管理信息导出--导出")
    @PostMapping("/export")
    public void listExport(@RequestBody TErpGoodsQuery query)
    {
        SysUser user = tokenService.getLoginUser().getUser();
        List<TErpGoodsVO> pageList = erpGoodsService.listExport(query,user);
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TErpGoodsVO.class, pageList);
        HttpServletResponse response = WebUtils.response();
        assert response != null;
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("商品管理信息导出.xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    @ApiOperation(value = "商品管理信息导入")
    @PostMapping("/importFile")
    public AjaxResult importFile(@RequestParam(value = "file") MultipartFile file ) {
        SysUser user = tokenService.getLoginUser().getUser();
        JSONObject jsonObject = new JSONObject();
        ImportParams params = new ImportParams();
        params.setHeadRows(1); //表头行数
        String msg = null;
        InputStream inputStream = null;
        TErpGoods goods = new TErpGoods();
        try {
            inputStream = file.getInputStream();
            List<TErpGoodsExcel> carAnnuallyImportExcels = ExcelImportUtil.importExcel(inputStream, TErpGoodsExcel.class, params);
            // 处理车辆数据
            for (TErpGoodsExcel erpGoodsExcel : carAnnuallyImportExcels) {
                System.out.println(erpGoodsExcel);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("车辆年检记录导入失败!");
        }finally {
            try {
                inputStream.close();
            } catch (IOException e) {
                throw new ServiceException(e.getMessage());
            }
        }
        return AjaxResult.success(jsonObject);
    }
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpSupplierWarehousingController.java
@@ -58,7 +58,7 @@
    @ApiOperation(value = "供应商库存详情")
    @GetMapping(value = "/detail")
    public R<List<TErpGoodsWarehouseLastVO>> detail(String id, String warehouseName) {
    public R<List<TErpGoodsWarehouseLastVO>> detail(@RequestParam String id, String warehouseName) {
        SysUser user = tokenService.getLoginUser().getUser();
        return R.ok(erpSupplierWarehousingService.detail(id,warehouseName,user));
    }
ruoyi-system/src/main/java/com/ruoyi/system/importExcel/TErpGoodsExcel.java
New file
@@ -0,0 +1,115 @@
package com.ruoyi.system.importExcel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "商品导入Excel")
public class TErpGoodsExcel {
    @Excel(width = 30,name = "*商品名称")
    private String goodsName;
    @Excel(width = 30,name = "*商品标识码")
    private String goodsIdCode;
    @Excel(width = 30,name = "*国药准字号")
    private String quasiNumber;
    @Excel(width = 30,name = "*生产厂家")
    private String manufacturer;
    @Excel(width = 30,name = "*制剂规格")
    private String formulationSpec;
    @Excel(width = 30,name = "*包装规格")
    private String packingSpec;
    @Excel(width = 30,name = "商品69码")
    private String goodsYards;
    @Excel(width = 30,name = "保养周期(天)")
    private String maintenanceInterval;
    @Excel(width = 30,name = "最低采购数量")
    private String lowPurchaseQuantity;
    @Excel(width = 30,name = "最低采购单位")
    private String lowUnitName;
    @Excel(width = 30,name = "是否为处方药",replace = {"1_是","2_否"})
    private String isPrescriptionDrug;
    @ApiModelProperty(value = "商品规格")
    @TableField("goods_spec")
    private String goodsSpec;
    @Excel(width = 30,name = "*预警库存")
    private String warningInventory;
    @ApiModelProperty(value = "商品售价")
    @TableField("sales_amount")
    private String salesAmount;
    @Excel(width = 30,name = "包装单位")
    private String packingUnitName;
    @Excel(width = 30,name = "使用说明")
    private String instructionsUse;
    @Excel(width = 30,name = "副作用")
    private String sideEffect;
    @Excel(width = 30,name = "*诊所采购价")
    private String clinicPurchasePrice;
    @Excel(width = 30,name = "*商品类型")
    private String typeName;
    @Excel(width = 30,name = "拼音简码")
    private String simplifiedCode;
    @Excel(width = 30,name = "剂型")
    private String dosageForm;
    @Excel(width = 30,name = "用途分类")
    private String usageClassification;
    @Excel(width = 30,name = "商品名(品牌)")
    private String productBrand;
    @Excel(width = 30,name = "产地")
    private String placeOfOrigin;
    @Excel(width = 30,name = "主要成分")
    private String ingredient;
    @Excel(width = 30,name = "性状")
    private String trait;
    @Excel(width = 30,name = "适应症")
    private String indication;
    @Excel(width = 30,name = "禁忌")
    private String taboo;
    @Excel(width = 30,name = "注意事项")
    private String precautions;
    @Excel(width = 30,name = "相互作用")
    private String interaction;
    @Excel(width = 30,name = "贮藏")
    private String storage;
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java
@@ -22,4 +22,5 @@
    List<TErpGoodsVO> pageList(@Param("query") TErpGoodsQuery query, @Param("pageInfo") PageInfo<TErpGoodsVO> pageInfo, @Param("user") SysUser user);
    List<TErpGoodsVO> listExport(@Param("query") TErpGoodsQuery query, @Param("user") SysUser user);
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpGoods.java
@@ -1,5 +1,6 @@
package com.ruoyi.system.model;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.*;
import com.ruoyi.common.core.domain.BaseModel;
import io.swagger.annotations.ApiModel;
@@ -41,27 +42,49 @@
    @ApiModelProperty(value = "商品名称")
    @TableField("goods_name")
    @Excel(name = "*商品名称")
    private String goodsName;
    @ApiModelProperty(value = "商品标识码")
    @TableField("goods_id_code")
    @Excel(name = "*商品标识码")
    private String goodsIdCode;
    @ApiModelProperty(value = "国药准字号")
    @TableField("quasi_number")
    @Excel(name = "*国药准字号")
    private String quasiNumber;
    @ApiModelProperty(value = "生产厂家")
    @TableField("manufacturer")
    @Excel(name = "*生产厂家")
    private String manufacturer;
    @ApiModelProperty(value = "制剂规格")
    @TableField("formulation_spec")
    @Excel(name = "*制剂规格")
    private String formulationSpec;
    @ApiModelProperty(value = "包装规格")
    @TableField("packing_spec")
    @Excel(name = "*包装规格")
    private String packingSpec;
    @ApiModelProperty(value = "商品类型名称")
    @TableField(exist = false)
    @Excel(name = "*商品类型")
    private String typeName;
    @ApiModelProperty(value = "诊所采购价")
    @TableField("clinic_purchase_price")
    @Excel(name = "*诊所采购价")
    private BigDecimal clinicPurchasePrice;
    @ApiModelProperty(value = "预警库存")
    @TableField("warning_inventory")
    @Excel(name = "*预警库存")
    private Integer warningInventory;
    @ApiModelProperty(value = "商品类型id")
    @TableField("type_id")
@@ -69,31 +92,40 @@
    @ApiModelProperty(value = "商品69码")
    @TableField("goods_yards")
    @Excel(name = "商品69码")
    private String goodsYards;
    @ApiModelProperty(value = "保养周期")
    @TableField("maintenance_interval")
    @Excel(name = "保养周期(天)")
    private String maintenanceInterval;
    @ApiModelProperty(value = "最低采购数量")
    @TableField("low_purchase_quantity")
    @Excel(name = "最低采购数量")
    private Integer lowPurchaseQuantity;
    @ApiModelProperty(value = "最低采购单位,单位id")
    @TableField("low_unit_id")
    private String lowUnitId;
    @Excel(name = "最低采购单位")
    @TableField(exist = false)
    private String lowUnitName;
    @ApiModelProperty(value = "是否为处方药 1=是 2=否")
    @TableField("is_prescription_drug")
    @Excel(name = "是否为处方药",replace = {"是_1","否_2"})
    private Integer isPrescriptionDrug;
    @Excel(name = "包装单位")
    @TableField(exist = false)
    private String packingUnitName;
    @ApiModelProperty(value = "商品规格")
    @TableField("goods_spec")
    private String goodsSpec;
    @ApiModelProperty(value = "预警库存")
    @TableField("warning_inventory")
    private Integer warningInventory;
    @ApiModelProperty(value = "商品售价")
    @TableField("sales_amount")
@@ -103,17 +135,18 @@
    @TableField("packing_unit_id")
    private String packingUnitId;
    @ApiModelProperty(value = "使用说明")
    @TableField("instructions_use")
    @Excel(name = "使用说明")
    private String instructionsUse;
    @ApiModelProperty(value = "副作用")
    @TableField("side_effect")
    @Excel(name = "副作用")
    private String sideEffect;
    @ApiModelProperty(value = "诊所采购价")
    @TableField("clinic_purchase_price")
    private BigDecimal clinicPurchasePrice;
    @ApiModelProperty(value = "平台分佣金额")
    @TableField("platform_commission_price")
@@ -123,56 +156,64 @@
    private Integer state;
    @ApiModelProperty(value = "商品类型名称")
    @TableField(exist = false)
    private String typeName;
    @ApiModelProperty(value = "拼音简码")
    @TableField("simplified_code")
    @Excel(name = "拼音简码")
    private String simplifiedCode;
    @ApiModelProperty(value = "剂型")
    @TableField("dosage_form")
    @Excel(name = "剂型")
    private String dosageForm;
    @ApiModelProperty(value = "用途分类")
    @TableField("usage_classification")
    @Excel(name = "用途分类")
    private String usageClassification;
    @ApiModelProperty(value = "商品品牌名")
    @TableField("product_brand")
    @Excel(name = "商品名(品牌)")
    private String productBrand;
    @ApiModelProperty(value = "产地")
    @TableField("place_of_origin")
    @Excel(name = "产地")
    private String placeOfOrigin;
    @ApiModelProperty(value = "成分")
    @TableField("ingredient")
    @Excel(name = "主要成分")
    private String ingredient;
    @ApiModelProperty(value = "性状")
    @TableField("trait")
    @Excel(name = "性状")
    private String trait;
    @ApiModelProperty(value = "适应症")
    @TableField("indication")
    @Excel(name = "适应症")
    private String indication;
    @ApiModelProperty(value = "禁忌")
    @TableField("taboo")
    @Excel(name = "禁忌")
    private String taboo;
    @ApiModelProperty(value = "注意事项")
    @TableField("precautions")
    @Excel(name = "注意事项")
    private String precautions;
    @ApiModelProperty(value = "相互作用")
    @TableField("interaction")
    @Excel(name = "相互作用")
    private String interaction;
    @ApiModelProperty(value = "贮藏")
    @TableField("storage")
    @Excel(name = "贮藏")
    private String storage;
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java
@@ -8,6 +8,7 @@
import com.ruoyi.system.vo.TErpGoodsVO;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
 * <p>
@@ -26,7 +27,16 @@
     */
    PageInfo<TErpGoodsVO> pageList(TErpGoodsQuery query, SysUser user);
    /**
     *  导出
     * @param query
     * @return
     */
    List<TErpGoodsVO> listExport(TErpGoodsQuery query, SysUser user);
    boolean isExit(String goodsIdCode,String quasiNumber);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -4,12 +4,10 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.mapper.TErpGoodsMapper;
import com.ruoyi.system.mapper.TErpGoodsTypeMapper;
import com.ruoyi.system.mapper.TErpSupplierInventoryMapper;
import com.ruoyi.system.mapper.TErpSupplierWarehousingMapper;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.model.TErpGoods;
import com.ruoyi.system.model.TErpGoodsType;
import com.ruoyi.system.model.TErpGoodsUnit;
import com.ruoyi.system.model.TSysBanner;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.service.TErpGoodsService;
@@ -17,6 +15,7 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -34,6 +33,10 @@
    @Resource
    private TErpGoodsTypeMapper erpGoodsTypeMapper;
    @Resource
    private TErpGoodsUnitMapper erpGoodsUnitMapper;
    @Override
    public PageInfo<TErpGoodsVO> pageList(TErpGoodsQuery query, SysUser user) {
@@ -47,11 +50,42 @@
            List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds);
            for (TErpGoodsVO tErpGoodsVO : list) {
                typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName()));
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
    @Override
    public List<TErpGoodsVO> listExport(TErpGoodsQuery query, SysUser user) {
        List<TErpGoodsVO> list = this.baseMapper.listExport(query,user);
        if(list.isEmpty()){
            return list;
        }
        List<String> typeIds = list.stream().map(TErpGoods::getTypeId).collect(Collectors.toList());
        if(!typeIds.isEmpty()){
            List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds);
            for (TErpGoodsVO tErpGoodsVO : list) {
                typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName()));
                tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName());
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
        List<String> lowUnitIds = list.stream().map(TErpGoods::getLowUnitId).collect(Collectors.toList());
        if(!lowUnitIds.isEmpty()){
            List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(lowUnitIds);
            for (TErpGoodsVO tErpGoodsVO : list) {
                tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoodsVO.getLowUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setLowUnitName(t.getUnitName()));
            }
        }
        List<String> packingUnitId = list.stream().map(TErpGoods::getPackingUnitId).collect(Collectors.toList());
        if(!packingUnitId.isEmpty()){
            List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(lowUnitIds);
            for (TErpGoodsVO tErpGoodsVO : list) {
                tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoodsVO.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setPackingUnitName(t.getUnitName()));
            }
        }
        return list;
    }
    @Override
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -37,7 +37,20 @@
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, supplier_clinic_id, goods_source, goods_name, goods_id_code, quasi_number, manufacturer, formulation_spec, packing_spec, type_id, goods_yards, maintenance_interval, low_purchase_quantity, low_unit_id, is_prescription_drug, goods_spec, warning_inventory, sales_amount, packing_unit_id, instructions_use, side_effect, clinic_purchase_price, platform_commission_price, create_time, update_time, create_by,`state`, update_by, disabled
        id, supplier_clinic_id, goods_source, goods_name, goods_id_code, quasi_number, manufacturer, formulation_spec, packing_spec, type_id, goods_yards, maintenance_interval, low_purchase_quantity, low_unit_id, is_prescription_drug, goods_spec, warning_inventory, sales_amount, packing_unit_id, instructions_use, side_effect, clinic_purchase_price, platform_commission_price, create_time, update_time, create_by,`state`, update_by, disabled,
          simplified_code,
dosage_form,
usage_classification,
product_brand,
place_of_origin,
ingredient,
trait,
indication,
taboo,
precautions,
interaction,
storage
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.vo.TErpGoodsVO">
        select <include refid="Base_Column_List"/>
@@ -65,5 +78,31 @@
        </if>
        order by create_time desc
    </select>
    <select id="listExport" resultType="com.ruoyi.system.vo.TErpGoodsVO">
        select <include refid="Base_Column_List"/>
        from t_erp_goods where disabled = 0
        <if test="query.goodsName != null and query.goodsName != ''">
            and goods_name like concat('%',#{query.goodsName},'%')
        </if>
        <if test="query.goodsIdCode != null and query.goodsIdCode != ''">
            and goods_id_code like concat('%',#{query.goodsIdCode},'%')
        </if>
        <if test="query.typeId != null and query.typeId != ''">
            and type_id = #{query.typeId}
        </if>
        <if test="query.quasiNumber != null and query.quasiNumber != ''">
            and quasi_number like concat('%',#{query.quasiNumber},'%')
        </if>
        <if test="query.state != null ">
            and state = #{query.state}
        </if>
        <if test="user.roleType != null and user.roleType == 4 ">
            and goods_source =1 and supplier_clinic_id =#{user.userId}
        </if>
        <if test="user.roleType != null and user.roleType == 5 ">
            and goods_source =2 and supplier_clinic_id =#{user.userId}
        </if>
        order by create_time desc
    </select>
</mapper>