Commit f3255ab9 by zhangtw

物料信息物料分类

parent 6e8acd67
import request from '@/utils/request'
// 查询物料列表
export function listMaterials(query) {
return request({
url: '/inventory/materials/list',
method: 'get',
params: query
})
}
// 查询物料详细
export function getMaterials(id) {
return request({
url: '/inventory/materials/' + id,
method: 'get'
})
}
// 新增物料
export function addMaterials(data) {
return request({
url: '/inventory/materials',
method: 'post',
data: data
})
}
// 修改物料
export function updateMaterials(data) {
return request({
url: '/inventory/materials',
method: 'put',
data: data
})
}
// 删除物料
export function delMaterials(id) {
return request({
url: '/inventory/materials/' + id,
method: 'delete'
})
}
import request from '@/utils/request'
// 查询物料分类列表
export function listMaterials_category(query) {
return request({
url: '/inventory/materials_category/list',
method: 'get',
params: query
})
}
// 查询物料分类详细
export function getMaterials_category(id) {
return request({
url: '/inventory/materials_category/' + id,
method: 'get'
})
}
// 新增物料分类
export function addMaterials_category(data) {
return request({
url: '/inventory/materials_category',
method: 'post',
data: data
})
}
// 修改物料分类
export function updateMaterials_category(data) {
return request({
url: '/inventory/materials_category',
method: 'put',
data: data
})
}
// 删除物料分类
export function delMaterials_category(id) {
return request({
url: '/inventory/materials_category/' + id,
method: 'delete'
})
}
......@@ -161,6 +161,23 @@ export const dynamicRoutes = [
meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
}
]
},
{
path: '/inventory',
component: Layout,
name: 'Inventory',
meta: { title: '基础信息管理', icon: 'el-icon-menu' },
children: [
{
path: 'materials',
component: () => import('@/views/inventory/materials/index'),
name: 'Materials',
meta: {
title: '物料管理',
permissions: ['inventory:materials:list']
}
}
]
}
]
......
package com.ruoyi.web.controller.inventory;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.utils.uuid.UUID;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.inventory.domain.MaterialsCategory;
import com.ruoyi.inventory.service.IMaterialsCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 物料分类Controller
*
* @author ruoyi
* @date 2025-11-28
*/
@RestController
@RequestMapping("/inventory/materials_category")
public class MaterialsCategoryController extends BaseController
{
@Autowired
private IMaterialsCategoryService materialsCategoryService;
/**
* 查询物料分类列表
*/
@PreAuthorize("@ss.hasPermi('inventory:materials_category:list')")
@GetMapping("/list")
public TableDataInfo list(MaterialsCategory materialsCategory)
{
startPage();
List<MaterialsCategory> list = materialsCategoryService.selectMaterialsCategoryList(materialsCategory);
return getDataTable(list);
}
/**
* 导出物料分类列表
*/
@PreAuthorize("@ss.hasPermi('inventory:materials_category:export')")
@Log(title = "物料分类", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MaterialsCategory materialsCategory)
{
List<MaterialsCategory> list = materialsCategoryService.selectMaterialsCategoryList(materialsCategory);
ExcelUtil<MaterialsCategory> util = new ExcelUtil<MaterialsCategory>(MaterialsCategory.class);
util.exportExcel(response, list, "物料分类数据");
}
/**
* 获取物料分类详细信息
*/
@PreAuthorize("@ss.hasPermi('inventory:materials_category:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return success(materialsCategoryService.selectMaterialsCategoryById(id));
}
/**
* 新增物料分类
*/
@PreAuthorize("@ss.hasPermi('inventory:materials_category:add')")
@Log(title = "物料分类", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MaterialsCategory materialsCategory)
{
materialsCategory.setId(UUID.randomUUID().toString());
return toAjax(materialsCategoryService.insertMaterialsCategory(materialsCategory));
}
/**
* 修改物料分类
*/
@PreAuthorize("@ss.hasPermi('inventory:materials_category:edit')")
@Log(title = "物料分类", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MaterialsCategory materialsCategory)
{
return toAjax(materialsCategoryService.updateMaterialsCategory(materialsCategory));
}
/**
* 删除物料分类
*/
@PreAuthorize("@ss.hasPermi('inventory:materials_category:remove')")
@Log(title = "物料分类", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(materialsCategoryService.deleteMaterialsCategoryByIds(ids));
}
}
package com.ruoyi.web.controller.inventory;
import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.inventory.domain.Owners;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.inventory.domain.Materials;
import com.ruoyi.inventory.service.IMaterialsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 物料Controller
*
* @author ruoyi
* @date 2025-11-28
*/
@RestController
@RequestMapping("/inventory/materials")
public class MaterialsController extends BaseController
{
@Autowired
private IMaterialsService materialsService;
/**
* 查询物料列表
*/
@PreAuthorize("@ss.hasPermi('inventory:materials:list')")
@GetMapping("/list")
public TableDataInfo list(Materials materials)
{
startPage();
List<Materials> list = materialsService.selectMaterialsList(materials);
return getDataTable(list);
}
/**
* 导出物料列表
*/
@PreAuthorize("@ss.hasPermi('inventory:materials:export')")
@Log(title = "物料", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Materials materials)
{
List<Materials> list = materialsService.selectMaterialsList(materials);
ExcelUtil<Materials> util = new ExcelUtil<Materials>(Materials.class);
util.exportExcel(response, list, "物料数据");
}
/**
* 获取物料详细信息
*/
@PreAuthorize("@ss.hasPermi('inventory:materials:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return success(materialsService.selectMaterialsById(id));
}
/**
* 新增物料
*/
@PreAuthorize("@ss.hasPermi('inventory:materials:add')")
@Log(title = "物料", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Materials materials)
{
materials.setId(UUID.randomUUID().toString());
return toAjax(materialsService.insertMaterials(materials));
}
/**
* 修改物料
*/
@PreAuthorize("@ss.hasPermi('inventory:materials:edit')")
@Log(title = "物料", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Materials materials)
{
return toAjax(materialsService.updateMaterials(materials));
}
/**
* 删除物料
*/
@PreAuthorize("@ss.hasPermi('inventory:materials:remove')")
@Log(title = "物料", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(materialsService.deleteMaterialsByIds(ids));
}
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
ExcelUtil<Materials> util = new ExcelUtil<Materials>(Materials.class);
util.importTemplateExcel(response, "物料信息");
}
@PreAuthorize("@ss.hasPermi('inventory:materials:import')")
@Log(title = "物料信息导入", businessType = BusinessType.IMPORT)
@PostMapping("/import")
public AjaxResult importTemplate(MultipartFile file , boolean updateSupport) throws Exception
{
ExcelUtil<Materials> util = new ExcelUtil<Materials>(Materials.class);
List<Materials> materialsList = util.importExcel(file.getInputStream());
String operName = getUsername();
String message = materialsService.importMaterials(materialsList, updateSupport, operName);
return success(message);
}
}
......@@ -6,7 +6,8 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://demo.docmis.cn:23500/inventory_manager?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# 数据库连接地址
url: jdbc:mysql://demo.docmis.cn:23500/inventory_manager?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useSSL=false
username: root
password: '!QAZ2wsx#EDC2022'
# 从库数据源
......
package com.ruoyi.inventory.domain;
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;
/**
* 物料对象 materials
*
* @author ruoyi
* @date 2025-11-28
*/
public class Materials extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 编号 */
private String id;
/** 物料编码 检索条件 */
@Excel(name = "物料编码")
private String materialCode;
/** 物料名称 检索条件 */
@Excel(name = "物料名称")
private String materialName;
/** SAP物料号 检索条件 */
@Excel(name = "SAP物料号")
private String sapNo;
/** TS Code 检索条件 */
@Excel(name = "TS Code")
private String tsCode;
/** 物料分类 检索条件 */
@Excel(name = "物料分类")
private String categoryCode;
/** 危险类别ID 字典 */
@Excel(name = "危险类别ID")
private String hazardId;
/** 规格型号 检索条件 */
@Excel(name = "规格型号")
private String specification;
/** 计量单位 字典 */
@Excel(name = "计量单位")
private String materialUnit;
/** 单位重量 */
@Excel(name = "单位重量")
private Long unitWeight;
/** 包装重量 */
@Excel(name = "包装重量")
private Long packageWeight;
/** 总重量 */
@Excel(name = "总重量")
private Long totalWeight;
/** 体积 */
@Excel(name = "体积")
private Long volume;
/** 保质期天数 */
@Excel(name = "保质期天数")
private Long shelfLifeDays;
/** 存储温度要求 */
@Excel(name = "存储温度要求")
private String storageTemperature;
/** 特殊存储要求 */
@Excel(name = "特殊存储要求")
private String specialRequirements;
/** 是否批次管理 1-是 0-否 */
@Excel(name = "是否批次管理 1-是 0-否")
private Long isBatchManaged;
/** 是否序列号管理 1-是 0-否 */
@Excel(name = "是否序列号管理 1-是 0-否")
private Long isSerialManaged;
/** 最低库存 */
@Excel(name = "最低库存")
private Long minStockLevel;
/** 最高库存 */
@Excel(name = "最高库存")
private Long maxStockLevel;
/** 是否正在使用 1-是 0-否 */
@Excel(name = "是否正在使用 1-是 0-否")
private Long isUsed;
/** 是否激活 1-是 0-否 */
@Excel(name = "是否激活 1-是 0-否")
private Long isActive;
/** 风险等级 字典 */
@Excel(name = "风险等级")
private String riskLevel;
/** 排序 */
@Excel(name = "排序")
private Long sortNo;
/** 创建日期 */
private String createUserCode;
/** 排序号 */
private String updateUserCode;
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public void setMaterialCode(String materialCode)
{
this.materialCode = materialCode;
}
public String getMaterialCode()
{
return materialCode;
}
public void setMaterialName(String materialName)
{
this.materialName = materialName;
}
public String getMaterialName()
{
return materialName;
}
public void setSapNo(String sapNo)
{
this.sapNo = sapNo;
}
public String getSapNo()
{
return sapNo;
}
public void setTsCode(String tsCode)
{
this.tsCode = tsCode;
}
public String getTsCode()
{
return tsCode;
}
public void setCategoryCode(String categoryCode)
{
this.categoryCode = categoryCode;
}
public String getCategoryCode()
{
return categoryCode;
}
public void setHazardId(String hazardId)
{
this.hazardId = hazardId;
}
public String getHazardId()
{
return hazardId;
}
public void setSpecification(String specification)
{
this.specification = specification;
}
public String getSpecification()
{
return specification;
}
public void setMaterialUnit(String materialUnit)
{
this.materialUnit = materialUnit;
}
public String getMaterialUnit()
{
return materialUnit;
}
public void setUnitWeight(Long unitWeight)
{
this.unitWeight = unitWeight;
}
public Long getUnitWeight()
{
return unitWeight;
}
public void setPackageWeight(Long packageWeight)
{
this.packageWeight = packageWeight;
}
public Long getPackageWeight()
{
return packageWeight;
}
public void setTotalWeight(Long totalWeight)
{
this.totalWeight = totalWeight;
}
public Long getTotalWeight()
{
return totalWeight;
}
public void setVolume(Long volume)
{
this.volume = volume;
}
public Long getVolume()
{
return volume;
}
public void setShelfLifeDays(Long shelfLifeDays)
{
this.shelfLifeDays = shelfLifeDays;
}
public Long getShelfLifeDays()
{
return shelfLifeDays;
}
public void setStorageTemperature(String storageTemperature)
{
this.storageTemperature = storageTemperature;
}
public String getStorageTemperature()
{
return storageTemperature;
}
public void setSpecialRequirements(String specialRequirements)
{
this.specialRequirements = specialRequirements;
}
public String getSpecialRequirements()
{
return specialRequirements;
}
public void setIsBatchManaged(Long isBatchManaged)
{
this.isBatchManaged = isBatchManaged;
}
public Long getIsBatchManaged()
{
return isBatchManaged;
}
public void setIsSerialManaged(Long isSerialManaged)
{
this.isSerialManaged = isSerialManaged;
}
public Long getIsSerialManaged()
{
return isSerialManaged;
}
public void setMinStockLevel(Long minStockLevel)
{
this.minStockLevel = minStockLevel;
}
public Long getMinStockLevel()
{
return minStockLevel;
}
public void setMaxStockLevel(Long maxStockLevel)
{
this.maxStockLevel = maxStockLevel;
}
public Long getMaxStockLevel()
{
return maxStockLevel;
}
public Long getIsUsed() { return isUsed; }
public void setIsUsed(Long isUsed) { this.isUsed = isUsed; }
public void setIsActive(Long isActive)
{
this.isActive = isActive;
}
public Long getIsActive()
{
return isActive;
}
public void setRiskLevel(String riskLevel)
{
this.riskLevel = riskLevel;
}
public String getRiskLevel()
{
return riskLevel;
}
public void setSortNo(Long sortNo)
{
this.sortNo = sortNo;
}
public Long getSortNo()
{
return sortNo;
}
public void setCreateUserCode(String createUserCode)
{
this.createUserCode = createUserCode;
}
public String getCreateUserCode()
{
return createUserCode;
}
public void setUpdateUserCode(String updateUserCode)
{
this.updateUserCode = updateUserCode;
}
public String getUpdateUserCode()
{
return updateUserCode;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("materialCode", getMaterialCode())
.append("materialName", getMaterialName())
.append("sapNo", getSapNo())
.append("tsCode", getTsCode())
.append("categoryCode", getCategoryCode())
.append("hazardId", getHazardId())
.append("specification", getSpecification())
.append("materialUnit", getMaterialUnit())
.append("unitWeight", getUnitWeight())
.append("packageWeight", getPackageWeight())
.append("totalWeight", getTotalWeight())
.append("volume", getVolume())
.append("shelfLifeDays", getShelfLifeDays())
.append("storageTemperature", getStorageTemperature())
.append("specialRequirements", getSpecialRequirements())
.append("isBatchManaged", getIsBatchManaged())
.append("isSerialManaged", getIsSerialManaged())
.append("minStockLevel", getMinStockLevel())
.append("maxStockLevel", getMaxStockLevel())
.append("isUsed",getIsUsed())
.append("isActive", getIsActive())
.append("riskLevel", getRiskLevel())
.append("sortNo", getSortNo())
.append("createTime", getCreateTime())
.append("createUserCode", getCreateUserCode())
.append("updateTime", getUpdateTime())
.append("updateUserCode", getUpdateUserCode())
.toString();
}
}
package com.ruoyi.inventory.domain;
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;
/**
* 物料分类对象 materials_category
*
* @author ruoyi
* @date 2025-11-28
*/
public class MaterialsCategory extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 编号 */
private String id;
/** 物料编码 检索条件 */
@Excel(name = "物料编码 检索条件")
private String categoryCode;
/** 物料名称 检索条件 */
@Excel(name = "物料名称 检索条件")
private String categoryName;
/** 排序 */
@Excel(name = "排序")
private Long sortNo;
/** 创建日期 */
private String createUserCode;
/** 排序号 */
private String updateUserCode;
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public void setCategoryCode(String categoryCode)
{
this.categoryCode = categoryCode;
}
public String getCategoryCode()
{
return categoryCode;
}
public void setCategoryName(String categoryName)
{
this.categoryName = categoryName;
}
public String getCategoryName()
{
return categoryName;
}
public void setSortNo(Long sortNo)
{
this.sortNo = sortNo;
}
public Long getSortNo()
{
return sortNo;
}
public void setCreateUserCode(String createUserCode)
{
this.createUserCode = createUserCode;
}
public String getCreateUserCode()
{
return createUserCode;
}
public void setUpdateUserCode(String updateUserCode)
{
this.updateUserCode = updateUserCode;
}
public String getUpdateUserCode()
{
return updateUserCode;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("categoryCode", getCategoryCode())
.append("categoryName", getCategoryName())
.append("sortNo", getSortNo())
.append("createTime", getCreateTime())
.append("createUserCode", getCreateUserCode())
.append("updateTime", getUpdateTime())
.append("updateUserCode", getUpdateUserCode())
.toString();
}
}
package com.ruoyi.inventory.mapper;
import java.util.List;
import com.ruoyi.inventory.domain.MaterialsCategory;
/**
* 物料分类Mapper接口
*
* @author ruoyi
* @date 2025-11-28
*/
public interface MaterialsCategoryMapper
{
/**
* 查询物料分类
*
* @param id 物料分类主键
* @return 物料分类
*/
public MaterialsCategory selectMaterialsCategoryById(String id);
/**
* 查询物料分类列表
*
* @param materialsCategory 物料分类
* @return 物料分类集合
*/
public List<MaterialsCategory> selectMaterialsCategoryList(MaterialsCategory materialsCategory);
/**
* 新增物料分类
*
* @param materialsCategory 物料分类
* @return 结果
*/
public int insertMaterialsCategory(MaterialsCategory materialsCategory);
/**
* 修改物料分类
*
* @param materialsCategory 物料分类
* @return 结果
*/
public int updateMaterialsCategory(MaterialsCategory materialsCategory);
/**
* 删除物料分类
*
* @param id 物料分类主键
* @return 结果
*/
public int deleteMaterialsCategoryById(String id);
/**
* 批量删除物料分类
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteMaterialsCategoryByIds(String[] ids);
}
package com.ruoyi.inventory.mapper;
import java.util.List;
import com.ruoyi.inventory.domain.Materials;
import org.apache.ibatis.annotations.Param;
/**
* 物料Mapper接口
*
* @author ruoyi
* @date 2025-11-28
*/
public interface MaterialsMapper
{
/**
* 查询物料
*
* @param id 物料主键
* @return 物料
*/
public Materials selectMaterialsById(String id);
/**
* 查询物料列表
*
* @param materials 物料
* @return 物料集合
*/
public List<Materials> selectMaterialsList(Materials materials);
/**
* 新增物料
*
* @param materials 物料
* @return 结果
*/
public int insertMaterials(Materials materials);
/**
* 修改物料
*
* @param materials 物料
* @return 结果
*/
public int updateMaterials(Materials materials);
/**
* 删除物料
*
* @param id 物料主键
* @return 结果
*/
public int deleteMaterialsById(String id);
/**
* 批量删除物料
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteMaterialsByIds(String[] ids);
public int updateMaterialsIsUsedByIds(String[] ids);
}
package com.ruoyi.inventory.service;
import java.util.List;
import com.ruoyi.inventory.domain.MaterialsCategory;
/**
* 物料分类Service接口
*
* @author ruoyi
* @date 2025-11-28
*/
public interface IMaterialsCategoryService
{
/**
* 查询物料分类
*
* @param id 物料分类主键
* @return 物料分类
*/
public MaterialsCategory selectMaterialsCategoryById(String id);
/**
* 查询物料分类列表
*
* @param materialsCategory 物料分类
* @return 物料分类集合
*/
public List<MaterialsCategory> selectMaterialsCategoryList(MaterialsCategory materialsCategory);
/**
* 新增物料分类
*
* @param materialsCategory 物料分类
* @return 结果
*/
public int insertMaterialsCategory(MaterialsCategory materialsCategory);
/**
* 修改物料分类
*
* @param materialsCategory 物料分类
* @return 结果
*/
public int updateMaterialsCategory(MaterialsCategory materialsCategory);
/**
* 批量删除物料分类
*
* @param ids 需要删除的物料分类主键集合
* @return 结果
*/
public int deleteMaterialsCategoryByIds(String[] ids);
/**
* 删除物料分类信息
*
* @param id 物料分类主键
* @return 结果
*/
public int deleteMaterialsCategoryById(String id);
}
package com.ruoyi.inventory.service;
import java.util.List;
import com.ruoyi.inventory.domain.Materials;
import com.ruoyi.inventory.domain.Owners;
/**
* 物料Service接口
*
* @author ruoyi
* @date 2025-11-28
*/
public interface IMaterialsService
{
/**
* 查询物料
*
* @param id 物料主键
* @return 物料
*/
public Materials selectMaterialsById(String id);
/**
* 查询物料列表
*
* @param materials 物料
* @return 物料集合
*/
public List<Materials> selectMaterialsList(Materials materials);
/**
* 新增物料
*
* @param materials 物料
* @return 结果
*/
public int insertMaterials(Materials materials);
/**
* 修改物料
*
* @param materials 物料
* @return 结果
*/
public int updateMaterials(Materials materials);
/**
* 批量删除物料
*
* @param ids 需要删除的物料主键集合
* @return 结果
*/
public int deleteMaterialsByIds(String[] ids);
/**
* 删除物料信息
*
* @param id 物料主键
* @return 结果
*/
public int deleteMaterialsById(String id);
public String importMaterials(List<Materials> materialsList, Boolean isUpdateSupport, String operName);
}
package com.ruoyi.inventory.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.inventory.mapper.MaterialsCategoryMapper;
import com.ruoyi.inventory.domain.MaterialsCategory;
import com.ruoyi.inventory.service.IMaterialsCategoryService;
/**
* 物料分类Service业务层处理
*
* @author ruoyi
* @date 2025-11-28
*/
@Service
public class MaterialsCategoryServiceImpl implements IMaterialsCategoryService
{
@Autowired
private MaterialsCategoryMapper materialsCategoryMapper;
/**
* 查询物料分类
*
* @param id 物料分类主键
* @return 物料分类
*/
@Override
public MaterialsCategory selectMaterialsCategoryById(String id)
{
return materialsCategoryMapper.selectMaterialsCategoryById(id);
}
/**
* 查询物料分类列表
*
* @param materialsCategory 物料分类
* @return 物料分类
*/
@Override
public List<MaterialsCategory> selectMaterialsCategoryList(MaterialsCategory materialsCategory)
{
return materialsCategoryMapper.selectMaterialsCategoryList(materialsCategory);
}
/**
* 新增物料分类
*
* @param materialsCategory 物料分类
* @return 结果
*/
@Override
public int insertMaterialsCategory(MaterialsCategory materialsCategory)
{
materialsCategory.setCreateTime(DateUtils.getNowDate());
return materialsCategoryMapper.insertMaterialsCategory(materialsCategory);
}
/**
* 修改物料分类
*
* @param materialsCategory 物料分类
* @return 结果
*/
@Override
public int updateMaterialsCategory(MaterialsCategory materialsCategory)
{
materialsCategory.setUpdateTime(DateUtils.getNowDate());
return materialsCategoryMapper.updateMaterialsCategory(materialsCategory);
}
/**
* 批量删除物料分类
*
* @param ids 需要删除的物料分类主键
* @return 结果
*/
@Override
public int deleteMaterialsCategoryByIds(String[] ids)
{
return materialsCategoryMapper.deleteMaterialsCategoryByIds(ids);
}
/**
* 删除物料分类信息
*
* @param id 物料分类主键
* @return 结果
*/
@Override
public int deleteMaterialsCategoryById(String id)
{
return materialsCategoryMapper.deleteMaterialsCategoryById(id);
}
}
package com.ruoyi.inventory.service.impl;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.inventory.domain.Owners;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.inventory.mapper.MaterialsMapper;
import com.ruoyi.inventory.domain.Materials;
import com.ruoyi.inventory.service.IMaterialsService;
/**
* 物料Service业务层处理
*
* @author ruoyi
* @date 2025-11-28
*/
@Service
public class MaterialsServiceImpl implements IMaterialsService
{
@Autowired
private MaterialsMapper materialsMapper;
/**
* 查询物料
*
* @param id 物料主键
* @return 物料
*/
@Override
public Materials selectMaterialsById(String id)
{
return materialsMapper.selectMaterialsById(id);
}
/**
* 查询物料列表
*
* @param materials 物料
* @return 物料
*/
@Override
public List<Materials> selectMaterialsList(Materials materials)
{
return materialsMapper.selectMaterialsList(materials);
}
/**
* 新增物料
*
* @param materials 物料
* @return 结果
*/
@Override
public int insertMaterials(Materials materials)
{
materials.setCreateTime(DateUtils.getNowDate());
return materialsMapper.insertMaterials(materials);
}
/**
* 修改物料
*
* @param materials 物料
* @return 结果
*/
@Override
public int updateMaterials(Materials materials)
{
materials.setUpdateTime(DateUtils.getNowDate());
return materialsMapper.updateMaterials(materials);
}
/**
* 批量修改物料的使用状态
*
* @param ids 需要删除的物料主键
* @return 结果
*/
@Override
public int deleteMaterialsByIds(String[] ids)
{
return materialsMapper.updateMaterialsIsUsedByIds(ids);
}
/**
* 删除物料信息
*
* @param id 物料主键
* @return 结果
*/
@Override
public int deleteMaterialsById(String id)
{
return materialsMapper.deleteMaterialsById(id);
}
@Override
public String importMaterials(List<Materials> materialsList, Boolean isUpdateSupport, String operName)
{
if (StringUtils.isNull(materialsList) || materialsList.size() == 0)
{
throw new ServiceException("导入用户数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
Date now = DateUtils.getNowDate();
Long userId = SecurityUtils.getUserId();
String operId = userId.toString();
for (Materials materials : materialsList)
{
try
{
materials.setId(UUID.randomUUID().toString());
// 填充创建人、创建时间、修改人、修改时间
materials.setCreateBy(operId);
materials.setCreateTime(now);
materials.setUpdateBy(operId);
materials.setUpdateTime(now);
// 填充创建用户编码和更新用户编码
materials.setCreateUserCode(operId);
materials.setUpdateUserCode(operId);
// 设置默认值
if (materials.getIsActive() == null)
{
materials.setIsActive(1L); // 默认激活
}
if (materials.getIsUsed() == null)
{
materials.setIsUsed(1L); // 默认未删除
}
if (materials.getSortNo() == null)
{
materials.setSortNo(0L); // 默认排序号
}
materialsMapper.insertMaterials(materials);
successNum++;
successMsg.append("<br/>" + successNum + "、物料 " + materials.getMaterialName() + " 导入成功");
}
catch (Exception e)
{
failureNum++;
String msg = "<br/>" + failureNum + "、物料 " + materials.getMaterialName() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
}
}
if (failureNum > 0)
{
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确");
throw new ServiceException(failureMsg.toString());
}
else
{
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
}
<?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.inventory.mapper.MaterialsCategoryMapper">
<resultMap type="MaterialsCategory" id="MaterialsCategoryResult">
<result property="id" column="id" />
<result property="categoryCode" column="category_code" />
<result property="categoryName" column="category_name" />
<result property="sortNo" column="sort_no" />
<result property="createTime" column="create_time" />
<result property="createUserCode" column="create_user_code" />
<result property="updateTime" column="update_time" />
<result property="updateUserCode" column="update_user_code" />
</resultMap>
<sql id="selectMaterialsCategoryVo">
select id, category_code, category_name, sort_no, create_time, create_user_code, update_time, update_user_code from materials_category
</sql>
<select id="selectMaterialsCategoryList" parameterType="MaterialsCategory" resultMap="MaterialsCategoryResult">
<include refid="selectMaterialsCategoryVo"/>
<where>
<if test="categoryCode != null and categoryCode != ''"> and category_code like concat('%', #{categoryCode}, '%')</if>
<if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
<if test="sortNo != null "> and sort_no = #{sortNo}</if>
<if test="createTime != null "> and create_time like concat('%', #{createTime}, '%')</if>
<if test="updateTime != null "> and update_time like concat('%', #{updateTime}, '%')</if>
</where>
order by sort_no asc
</select>
<select id="selectMaterialsCategoryById" parameterType="String" resultMap="MaterialsCategoryResult">
<include refid="selectMaterialsCategoryVo"/>
where id = #{id}
order by sort_no asc
</select>
<insert id="insertMaterialsCategory" parameterType="MaterialsCategory">
insert into materials_category
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="categoryCode != null">category_code,</if>
<if test="categoryName != null">category_name,</if>
<if test="sortNo != null">sort_no,</if>
<if test="createTime != null">create_time,</if>
<if test="createUserCode != null">create_user_code,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateUserCode != null">update_user_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="categoryCode != null">#{categoryCode},</if>
<if test="categoryName != null">#{categoryName},</if>
<if test="sortNo != null">#{sortNo},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createUserCode != null">#{createUserCode},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateUserCode != null">#{updateUserCode},</if>
</trim>
</insert>
<update id="updateMaterialsCategory" parameterType="MaterialsCategory">
update materials_category
<trim prefix="SET" suffixOverrides=",">
<if test="categoryCode != null">category_code = #{categoryCode},</if>
<if test="categoryName != null">category_name = #{categoryName},</if>
<if test="sortNo != null">sort_no = #{sortNo},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createUserCode != null">create_user_code = #{createUserCode},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateUserCode != null">update_user_code = #{updateUserCode},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteMaterialsCategoryById" parameterType="String">
delete from materials_category where id = #{id}
</delete>
<delete id="deleteMaterialsCategoryByIds" parameterType="String">
delete from materials_category where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论