update add生产BOM信息
parent
6de83a8c98
commit
fe41ac0388
@ -0,0 +1,115 @@
|
||||
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.ProdMaterialBomVo;
|
||||
import org.dromara.mes.domain.bo.ProdMaterialBomBo;
|
||||
import org.dromara.mes.service.IProdMaterialBomService;
|
||||
|
||||
/**
|
||||
* 物料BOM信息
|
||||
* 前端访问路由地址为:/mes/materialBom
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/materialBom")
|
||||
public class ProdMaterialBomController extends BaseController {
|
||||
|
||||
private final IProdMaterialBomService prodMaterialBomService;
|
||||
|
||||
/**
|
||||
* 查询物料BOM信息列表
|
||||
*/
|
||||
@SaCheckPermission("mes:materialBom:list")
|
||||
@GetMapping("/list")
|
||||
public R<List<ProdMaterialBomVo>> list(ProdMaterialBomBo bo) {
|
||||
List<ProdMaterialBomVo> list = prodMaterialBomService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出物料BOM信息列表
|
||||
*/
|
||||
@SaCheckPermission("mes:materialBom:export")
|
||||
@Log(title = "物料BOM信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(ProdMaterialBomBo bo, HttpServletResponse response) {
|
||||
List<ProdMaterialBomVo> list = prodMaterialBomService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "物料BOM信息", ProdMaterialBomVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物料BOM信息详细信息
|
||||
*
|
||||
* @param materialBomId 主键
|
||||
*/
|
||||
@SaCheckPermission("mes:materialBom:query")
|
||||
@GetMapping("/{materialBomId}")
|
||||
public R<ProdMaterialBomVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long materialBomId) {
|
||||
return R.ok(prodMaterialBomService.queryById(materialBomId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物料BOM信息
|
||||
*/
|
||||
@SaCheckPermission("mes:materialBom:add")
|
||||
@Log(title = "物料BOM信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ProdMaterialBomBo bo) {
|
||||
return toAjax(prodMaterialBomService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物料BOM信息
|
||||
*/
|
||||
@SaCheckPermission("mes:materialBom:edit")
|
||||
@Log(title = "物料BOM信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ProdMaterialBomBo bo) {
|
||||
return toAjax(prodMaterialBomService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除物料BOM信息
|
||||
*
|
||||
* @param materialBomIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("mes:materialBom:remove")
|
||||
@Log(title = "物料BOM信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{materialBomIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] materialBomIds) {
|
||||
return toAjax(prodMaterialBomService.deleteWithValidByIds(List.of(materialBomIds), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉框查询物料BOM信息列表
|
||||
*/
|
||||
@GetMapping("getProdMaterialBomList")
|
||||
public R<List<ProdMaterialBomVo>> getProdMaterialBomlist(ProdMaterialBomBo bo) {
|
||||
List<ProdMaterialBomVo> list = prodMaterialBomService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.dromara.mes.mapper;
|
||||
|
||||
import org.dromara.mes.domain.ProdMaterialBom;
|
||||
import org.dromara.mes.domain.vo.ProdMaterialBomVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 物料BOM信息Mapper接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
public interface ProdMaterialBomMapper extends BaseMapperPlus<ProdMaterialBom, ProdMaterialBomVo> {
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package org.dromara.mes.service;
|
||||
|
||||
import org.dromara.mes.domain.ProdMaterialBom;
|
||||
import org.dromara.mes.domain.vo.ProdMaterialBomVo;
|
||||
import org.dromara.mes.domain.bo.ProdMaterialBomBo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 物料BOM信息Service接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
public interface IProdMaterialBomService {
|
||||
|
||||
/**
|
||||
* 查询物料BOM信息
|
||||
*
|
||||
* @param materialBomId 主键
|
||||
* @return 物料BOM信息
|
||||
*/
|
||||
ProdMaterialBomVo queryById(Long materialBomId);
|
||||
|
||||
|
||||
/**
|
||||
* 查询符合条件的物料BOM信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 物料BOM信息列表
|
||||
*/
|
||||
List<ProdMaterialBomVo> queryList(ProdMaterialBomBo bo);
|
||||
|
||||
/**
|
||||
* 新增物料BOM信息
|
||||
*
|
||||
* @param bo 物料BOM信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(ProdMaterialBomBo bo);
|
||||
|
||||
/**
|
||||
* 修改物料BOM信息
|
||||
*
|
||||
* @param bo 物料BOM信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(ProdMaterialBomBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除物料BOM信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
package org.dromara.mes.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.mes.domain.bo.ProdMaterialBomBo;
|
||||
import org.dromara.mes.domain.vo.ProdMaterialBomVo;
|
||||
import org.dromara.mes.domain.ProdMaterialBom;
|
||||
import org.dromara.mes.mapper.ProdMaterialBomMapper;
|
||||
import org.dromara.mes.service.IProdMaterialBomService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 物料BOM信息Service业务层处理
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
||||
|
||||
private final ProdMaterialBomMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询物料BOM信息
|
||||
*
|
||||
* @param materialBomId 主键
|
||||
* @return 物料BOM信息
|
||||
*/
|
||||
@Override
|
||||
public ProdMaterialBomVo queryById(Long materialBomId){
|
||||
return baseMapper.selectVoById(materialBomId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询符合条件的物料BOM信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 物料BOM信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<ProdMaterialBomVo> queryList(ProdMaterialBomBo bo) {
|
||||
MPJLambdaWrapper<ProdMaterialBom> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private MPJLambdaWrapper<ProdMaterialBom> buildQueryWrapper(ProdMaterialBomBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<ProdMaterialBom> lqw = JoinWrappers.lambda(ProdMaterialBom.class)
|
||||
.selectAll(ProdMaterialBom.class)
|
||||
.eq(bo.getMaterialBomId() != null, ProdMaterialBom::getMaterialBomId, bo.getMaterialBomId())
|
||||
.eq(bo.getParentId() != null, ProdMaterialBom::getParentId, bo.getParentId())
|
||||
.eq(bo.getMaterialId() != null, ProdMaterialBom::getMaterialId, bo.getMaterialId())
|
||||
.like(StringUtils.isNotBlank(bo.getMaterialName()), ProdMaterialBom::getMaterialName, bo.getMaterialName())
|
||||
.like(StringUtils.isNotBlank(bo.getMaterialBomDesc()), ProdMaterialBom::getMaterialBomDesc, bo.getMaterialBomDesc())
|
||||
.like(StringUtils.isNotBlank(bo.getMaterialBomVersion()), ProdMaterialBom::getMaterialBomVersion, bo.getMaterialBomVersion())
|
||||
.like(StringUtils.isNotBlank(bo.getAncestors()), ProdMaterialBom::getAncestors, bo.getAncestors())
|
||||
.eq(bo.getStandardAmount() != null, ProdMaterialBom::getStandardAmount, bo.getStandardAmount())
|
||||
.eq(bo.getTopFlag() != null, ProdMaterialBom::getTopFlag, bo.getTopFlag())
|
||||
.eq(StringUtils.isNotBlank(bo.getCheckType()), ProdMaterialBom::getCheckType, bo.getCheckType())
|
||||
.eq(bo.getProjectId() != null, ProdMaterialBom::getProjectId, bo.getProjectId())
|
||||
.eq(bo.getAssembleTime() != null, ProdMaterialBom::getAssembleTime, bo.getAssembleTime())
|
||||
.eq(StringUtils.isNotBlank(bo.getMaterialClassfication()), ProdMaterialBom::getMaterialClassfication, bo.getMaterialClassfication())
|
||||
.eq(StringUtils.isNotBlank(bo.getAttachId()), ProdMaterialBom::getAttachId, bo.getAttachId())
|
||||
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), ProdMaterialBom::getActiveFlag, bo.getActiveFlag())
|
||||
.orderByAsc(ProdMaterialBom::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物料BOM信息
|
||||
*
|
||||
* @param bo 物料BOM信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(ProdMaterialBomBo bo) {
|
||||
ProdMaterialBom add = MapstructUtils.convert(bo, ProdMaterialBom.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setMaterialBomId(add.getMaterialBomId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物料BOM信息
|
||||
*
|
||||
* @param bo 物料BOM信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(ProdMaterialBomBo bo) {
|
||||
ProdMaterialBom update = MapstructUtils.convert(bo, ProdMaterialBom.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(ProdMaterialBom entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除物料BOM信息信息
|
||||
*
|
||||
* @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.ProdMaterialBomMapper">
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue