add(hwmom-mes): 添加载具工装信息管理功能
parent
f7e072e180
commit
5379f1daea
@ -0,0 +1,117 @@
|
||||
package org.dromara.mes.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.mes.domain.vo.BaseToolingInfoVo;
|
||||
import org.dromara.mes.domain.bo.BaseToolingInfoBo;
|
||||
import org.dromara.mes.service.IBaseToolingInfoService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 载具工装信息
|
||||
* 前端访问路由地址为:/mes/baseToolingInfo
|
||||
*
|
||||
* @author zangch
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/baseToolingInfo")
|
||||
public class BaseToolingInfoController extends BaseController {
|
||||
|
||||
private final IBaseToolingInfoService baseToolingInfoService;
|
||||
|
||||
/**
|
||||
* 查询载具工装信息列表
|
||||
*/
|
||||
@SaCheckPermission("mes:baseToolingInfo:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BaseToolingInfoVo> list(BaseToolingInfoBo bo, PageQuery pageQuery) {
|
||||
return baseToolingInfoService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出载具工装信息列表
|
||||
*/
|
||||
@SaCheckPermission("mes:baseToolingInfo:export")
|
||||
@Log(title = "载具工装信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(BaseToolingInfoBo bo, HttpServletResponse response) {
|
||||
List<BaseToolingInfoVo> list = baseToolingInfoService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "载具工装信息", BaseToolingInfoVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取载具工装信息详细信息
|
||||
*
|
||||
* @param toolingId 主键
|
||||
*/
|
||||
@SaCheckPermission("mes:baseToolingInfo:query")
|
||||
@GetMapping("/{toolingId}")
|
||||
public R<BaseToolingInfoVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long toolingId) {
|
||||
return R.ok(baseToolingInfoService.queryById(toolingId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增载具工装信息
|
||||
*/
|
||||
@SaCheckPermission("mes:baseToolingInfo:add")
|
||||
@Log(title = "载具工装信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BaseToolingInfoBo bo) {
|
||||
return toAjax(baseToolingInfoService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改载具工装信息
|
||||
*/
|
||||
@SaCheckPermission("mes:baseToolingInfo:edit")
|
||||
@Log(title = "载具工装信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BaseToolingInfoBo bo) {
|
||||
return toAjax(baseToolingInfoService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除载具工装信息
|
||||
*
|
||||
* @param toolingIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("mes:baseToolingInfo:remove")
|
||||
@Log(title = "载具工装信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{toolingIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] toolingIds) {
|
||||
return toAjax(baseToolingInfoService.deleteWithValidByIds(List.of(toolingIds), true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下拉框查询载具工装信息列表
|
||||
*/
|
||||
|
||||
@GetMapping("getBaseToolingInfoList")
|
||||
public R<List<BaseToolingInfoVo>> getBaseToolingInfolist(BaseToolingInfoBo bo) {
|
||||
List<BaseToolingInfoVo> list = baseToolingInfoService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.dromara.mes.mapper;
|
||||
|
||||
import org.dromara.mes.domain.BaseToolingInfo;
|
||||
import org.dromara.mes.domain.vo.BaseToolingInfoVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 载具工装信息Mapper接口
|
||||
*
|
||||
* @author zangch
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
public interface BaseToolingInfoMapper extends BaseMapperPlus<BaseToolingInfo, BaseToolingInfoVo> {
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package org.dromara.mes.service;
|
||||
|
||||
import org.dromara.mes.domain.BaseToolingInfo;
|
||||
import org.dromara.mes.domain.vo.BaseToolingInfoVo;
|
||||
import org.dromara.mes.domain.bo.BaseToolingInfoBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 载具工装信息Service接口
|
||||
*
|
||||
* @author zangch
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
public interface IBaseToolingInfoService {
|
||||
|
||||
/**
|
||||
* 查询载具工装信息
|
||||
*
|
||||
* @param toolingId 主键
|
||||
* @return 载具工装信息
|
||||
*/
|
||||
BaseToolingInfoVo queryById(Long toolingId);
|
||||
|
||||
/**
|
||||
* 分页查询载具工装信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 载具工装信息分页列表
|
||||
*/
|
||||
TableDataInfo<BaseToolingInfoVo> queryPageList(BaseToolingInfoBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的载具工装信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 载具工装信息列表
|
||||
*/
|
||||
List<BaseToolingInfoVo> queryList(BaseToolingInfoBo bo);
|
||||
|
||||
/**
|
||||
* 新增载具工装信息
|
||||
*
|
||||
* @param bo 载具工装信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(BaseToolingInfoBo bo);
|
||||
|
||||
/**
|
||||
* 修改载具工装信息
|
||||
*
|
||||
* @param bo 载具工装信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(BaseToolingInfoBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除载具工装信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
package org.dromara.mes.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.mes.domain.bo.BaseToolingInfoBo;
|
||||
import org.dromara.mes.domain.vo.BaseToolingInfoVo;
|
||||
import org.dromara.mes.domain.BaseToolingInfo;
|
||||
import org.dromara.mes.mapper.BaseToolingInfoMapper;
|
||||
import org.dromara.mes.service.IBaseToolingInfoService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 载具工装信息Service业务层处理
|
||||
*
|
||||
* @author zangch
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BaseToolingInfoServiceImpl implements IBaseToolingInfoService {
|
||||
|
||||
private final BaseToolingInfoMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询载具工装信息
|
||||
*
|
||||
* @param toolingId 主键
|
||||
* @return 载具工装信息
|
||||
*/
|
||||
@Override
|
||||
public BaseToolingInfoVo queryById(Long toolingId){
|
||||
return baseMapper.selectVoById(toolingId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询载具工装信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 载具工装信息分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<BaseToolingInfoVo> queryPageList(BaseToolingInfoBo bo, PageQuery pageQuery) {
|
||||
MPJLambdaWrapper<BaseToolingInfo> lqw = buildQueryWrapper(bo);
|
||||
Page<BaseToolingInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的载具工装信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 载具工装信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<BaseToolingInfoVo> queryList(BaseToolingInfoBo bo) {
|
||||
MPJLambdaWrapper<BaseToolingInfo> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private MPJLambdaWrapper<BaseToolingInfo> buildQueryWrapper(BaseToolingInfoBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<BaseToolingInfo> lqw = JoinWrappers.lambda(BaseToolingInfo.class)
|
||||
.selectAll(BaseToolingInfo.class)
|
||||
.eq(bo.getToolingId() != null, BaseToolingInfo::getToolingId, bo.getToolingId())
|
||||
.eq(StringUtils.isNotBlank(bo.getToolingCode()), BaseToolingInfo::getToolingCode, bo.getToolingCode())
|
||||
.like(StringUtils.isNotBlank(bo.getToolingName()), BaseToolingInfo::getToolingName, bo.getToolingName())
|
||||
.eq(StringUtils.isNotBlank(bo.getToolingTypeCode()), BaseToolingInfo::getToolingTypeCode, bo.getToolingTypeCode())
|
||||
.eq(StringUtils.isNotBlank(bo.getToolingSpecCode()), BaseToolingInfo::getToolingSpecCode, bo.getToolingSpecCode())
|
||||
.eq(StringUtils.isNotBlank(bo.getToolingBarcode()), BaseToolingInfo::getToolingBarcode, bo.getToolingBarcode())
|
||||
.eq(StringUtils.isNotBlank(bo.getToolingRfidBarcode()), BaseToolingInfo::getToolingRfidBarcode, bo.getToolingRfidBarcode())
|
||||
.eq(StringUtils.isNotBlank(bo.getMaterialCode()), BaseToolingInfo::getMaterialCode, bo.getMaterialCode())
|
||||
.eq(bo.getWeight() != null, BaseToolingInfo::getWeight, bo.getWeight())
|
||||
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), BaseToolingInfo::getActiveFlag, bo.getActiveFlag())
|
||||
.orderByDesc(BaseToolingInfo::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增载具工装信息
|
||||
*
|
||||
* @param bo 载具工装信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(BaseToolingInfoBo bo) {
|
||||
BaseToolingInfo add = MapstructUtils.convert(bo, BaseToolingInfo.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setToolingId(add.getToolingId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改载具工装信息
|
||||
*
|
||||
* @param bo 载具工装信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(BaseToolingInfoBo bo) {
|
||||
BaseToolingInfo update = MapstructUtils.convert(bo, BaseToolingInfo.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(BaseToolingInfo entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除载具工装信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?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="org.dromara.mes.mapper.BaseToolingInfoMapper">
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue