diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/controller/WsMaInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/controller/WsMaInfoController.java index 76530c62..b5fa981b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/controller/WsMaInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/controller/WsMaInfoController.java @@ -64,6 +64,7 @@ public class WsMaInfoController extends BaseController { public AjaxResult delete(@PathVariable Integer id) { return service.delete(id); } + @ApiOperation(value = "获取机具类型") @PreventRepeatSubmit @SysLog(title = "获取机具类型", businessType = OperaType.DELETE, logType = 1, module = "获取机具类型") @@ -71,4 +72,13 @@ public class WsMaInfoController extends BaseController { public AjaxResult getMaTypeData() { return service.getMaTypeData(); } + + + @ApiOperation(value = "获取机具类型") + @PreventRepeatSubmit + @SysLog(title = "获取机具类型", businessType = OperaType.DELETE, logType = 1, module = "获取机具类型") + @PostMapping("/getMaModeData") + public AjaxResult getMaModeData(@RequestParam Integer parentId) { + return service.getMaModeData(parentId); + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/domain/WsMaInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/domain/WsMaInfo.java new file mode 100644 index 00000000..97e2996e --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/domain/WsMaInfo.java @@ -0,0 +1,95 @@ +package com.bonus.material.codeCollection.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 机具信息实体类,对应数据库表 ws_ma_info。 + * 用于记录每台机具的基础信息、检修信息、检验情况等。 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class WsMaInfo { + + /** + * 主键,自增ID + */ + private Integer id; + + /** + * 机具名称,如“电焊机”、“搅拌机” + */ + private String maName; + + /** + * 机具型号,例如“WX-3000” + */ + private String maModel; + + /** + * 机具编号,企业内部唯一标识编号 + */ + private String maCode; + + /** + * 供应商/生产厂家名称 + */ + private String supplier; + + /** + * 本次检验时间,格式建议为 yyyy-MM-dd + */ + private String thisCheckTime; + + /** + * 下次检验时间,格式建议为 yyyy-MM-dd + */ + private String nextCheckTime; + + /** + * 检修员姓名,表示最近一次负责检修的人员 + */ + private String repairMan; + + /** + * 检验员姓名,表示本次设备检验的执行人员 + */ + private String checkMan; + + /** + * 联系方式(通常为检修员或检验员电话) + */ + private String phone; + + /** + * 检验结论,例如“合格”、“不合格”、“需维修” + */ + private String result; + + /** + * 类型标识,默认 "1",可扩展为不同类型标识(如 "1": 自有设备,"2": 租赁设备) + */ + private String type; + + /** + * 机具的关联ID,可用于关联其它系统或模型表 + */ + private String modelId; + + /** + * 是否有效标志,默认 "1" 表示有效;"0" 表示已作废/逻辑删除 + */ + private String isActive; + + /** + * 最后操作用户(更新人),记录最后修改记录的用户标识或姓名 + */ + private String optUser; + + /** + * 最后更新时间,建议格式 yyyy-MM-dd HH:mm:ss + */ + private String optTime; +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/mapper/WsMaInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/mapper/WsMaInfoMapper.java index 2d664578..156c28ba 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/mapper/WsMaInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/mapper/WsMaInfoMapper.java @@ -62,4 +62,13 @@ public interface WsMaInfoMapper { */ @MapKey("id") List> getMaTypeData(); + + /** + * 获取机具规格下拉选 + * + * @return 机具规格集合 + */ + @MapKey("id") + List> getMaModeData(Integer parentId); + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/service/WsMaInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/service/WsMaInfoService.java new file mode 100644 index 00000000..286c4e82 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/service/WsMaInfoService.java @@ -0,0 +1,72 @@ +package com.bonus.material.codeCollection.service; + +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.codeCollection.domain.WsMaInfo; +import org.apache.ibatis.annotations.MapKey; + +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * WsMaInfoService + * 机具信息服务层接口(Service Layer) + * 提供机具信息的增删改查、业务封装等功能 + * 返回 AjaxResult 用于标准响应封装 + */ +public interface WsMaInfoService { + + /** + * 根据主键 ID 查询单个机具信息 + * + * @param id 主键ID + * @return AjaxResult,包含状态码、消息、数据(WsMaInfo) + */ + AjaxResult getById(Integer id); + + /** + * 查询所有机具信息(无分页) + * + * @return 机具列表(List) + */ + List getAll(); + + /** + * 新增一条机具记录 + * + * @param info 新增的 WsMaInfo 实体 + * @return AjaxResult,成功或失败信息 + */ + AjaxResult save(WsMaInfo info); + + /** + * 更新一条已有机具信息记录 + * + * @param info 待更新的 WsMaInfo 实体(必须含 ID) + * @return AjaxResult,成功或失败信息 + */ + AjaxResult update(WsMaInfo info); + + /** + * 根据主键 ID 删除记录 + * + * @param id 要删除的主键 ID + * @return AjaxResult,成功或失败信息 + */ + AjaxResult delete(Integer id); + + /** + * 获取机具类型下拉选 + * + * @return 机具类型集合 + */ + AjaxResult getMaTypeData(); + + + /** + * 获取机具规格下拉选 + * + * @return 机具规格集合 + */ + AjaxResult getMaModeData(Integer parentId); +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/service/impl/WsMaInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/service/impl/WsMaInfoServiceImpl.java new file mode 100644 index 00000000..c671cf5d --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/codeCollection/service/impl/WsMaInfoServiceImpl.java @@ -0,0 +1,160 @@ +package com.bonus.material.codeCollection.service.impl; + +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.codeCollection.domain.WsMaInfo; +import com.bonus.material.codeCollection.mapper.WsMaInfoMapper; +import com.bonus.material.codeCollection.service.WsMaInfoService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * {@code WsMaInfoServiceImpl} + *

+ * 机具信息服务实现类,实现了 {@link WsMaInfoService} 接口。 + * 提供对 {@code ws_ma_info} 表的增删改查业务逻辑,并统一返回 {@link AjaxResult} 格式结果。 + *

+ * + *

核心功能:

+ *
    + *
  • 根据ID获取机具信息
  • + *
  • 获取全部机具信息
  • + *
  • 新增机具信息
  • + *
  • 更新机具信息
  • + *
  • 删除机具信息
  • + *
+ */ +@Slf4j +@Service +public class WsMaInfoServiceImpl implements WsMaInfoService { + + /** + * 注入 Mapper,执行实际的数据库操作 + */ + @Resource + private WsMaInfoMapper mapper; + + /** + * 根据主键 ID 获取单条机具信息 + * + * @param id 机具主键ID + * @return AjaxResult,成功时返回 WsMaInfo 数据,失败时返回提示信息 + */ + @Override + public AjaxResult getById(Integer id) { + try { + WsMaInfo info = mapper.selectById(id); + return ObjectUtils.isNotEmpty(info) ? AjaxResult.success(info) : AjaxResult.error("未找到对应的机具信息,ID: " + id); + } catch (Exception e) { + log.error(e.getMessage()); + return AjaxResult.error("未找到对应的机具信息,ID: " + id); + } + } + + /** + * 获取全部机具信息列表(无分页) + * + * @return List 数据集合,由 Controller 封装为 AjaxResult + */ + @Override + public List getAll() { + return mapper.selectAll(); + } + + /** + * 新增一条机具信息记录 + * + * @param info 机具实体对象,需包含有效字段(如 maName, maCode 等) + * @return AjaxResult,成功或失败信息 + */ + @Override + public AjaxResult save(WsMaInfo info) { + try { + int result = mapper.insert(info); + return result > 0 ? AjaxResult.success("新增成功") : AjaxResult.error("新增失败"); + } catch (Exception e) { + log.error(e.getMessage()); + return AjaxResult.error("新增失败"); + } + + } + + /** + * 根据 ID 更新已有机具信息 + * + * @param info 包含更新字段及主键ID的机具实体 + * @return AjaxResult,操作成功与否 + */ + @Override + public AjaxResult update(WsMaInfo info) { + try { + if (info.getId() == null) { + return AjaxResult.error("ID不能为空"); + } + int result = mapper.update(info); + return result > 0 + ? AjaxResult.success("更新成功") + : AjaxResult.error("更新失败"); + } catch (Exception e) { + log.error(e.getMessage()); + return AjaxResult.error("更新失败"); + } + } + + /** + * 根据主键 ID 删除机具信息记录 + * + * @param id 待删除记录的主键 ID + * @return AjaxResult,操作是否成功 + */ + @Override + public AjaxResult delete(Integer id) { + try { + int result = mapper.deleteById(id); + return result > 0 + ? AjaxResult.success("删除成功") + : AjaxResult.error("删除失败"); + } catch (Exception e) { + log.error(e.getMessage()); + return AjaxResult.error("删除失败"); + } + } + + /** + * 获取机具类型下拉选 + * + * @return 机具类型集合 + */ + @Override + public AjaxResult getMaTypeData() { + try { + List> maTypeData = mapper.getMaTypeData(); + return ObjectUtils.isNotEmpty(maTypeData) ? AjaxResult.success(maTypeData) : AjaxResult.error(""); + } catch (Exception e) { + log.error(e.getMessage()); + return AjaxResult.error(""); + } + } + + /** + * 获取机具规格下拉选 + * + * @param parentId + * @return 机具规格集合 + */ + @Override + public AjaxResult getMaModeData(Integer parentId) { + try { + List> maTypeData = mapper.getMaModeData(parentId); + return ObjectUtils.isNotEmpty(maTypeData) ? AjaxResult.success(maTypeData) : AjaxResult.error(""); + } catch (Exception e) { + log.error(e.getMessage()); + return AjaxResult.error(""); + } + } +} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/codeCollection/WsMaInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/codeCollection/WsMaInfoMapper.xml new file mode 100644 index 00000000..61ed6421 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/codeCollection/WsMaInfoMapper.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO ws_ma_info ( + ma_name, ma_model, ma_code, supplier, this_check_time, next_check_time, + repair_man, check_man, phone, result, type, model_id, is_active, opt_user, opt_time + ) VALUES ( + #{maName}, #{maModel}, #{maCode}, #{supplier}, #{thisCheckTime}, #{nextCheckTime}, + #{repairMan}, #{checkMan}, #{phone}, #{result}, #{type}, #{modelId}, #{isActive}, #{optUser}, #{optTime} + ) + + + + UPDATE ws_ma_info SET + ma_name = #{maName}, + ma_model = #{maModel}, + ma_code = #{maCode}, + supplier = #{supplier}, + this_check_time = #{thisCheckTime}, + next_check_time = #{nextCheckTime}, + repair_man = #{repairMan}, + check_man = #{checkMan}, + phone = #{phone}, + result = #{result}, + type = #{type}, + model_id = #{modelId}, + is_active = #{isActive}, + opt_user = #{optUser}, + opt_time = #{optTime} + WHERE id = #{id} + + + + DELETE FROM ws_ma_info WHERE id = #{id} + + + + + +