update add生产BOM信息

master
yinq 3 months ago
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,106 @@
package org.dromara.mes.domain;
import org.dromara.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
/**
* BOM prod_material_bom
*
* @author Yinq
* @date 2025-01-08
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("prod_material_bom")
public class ProdMaterialBom extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "material_bom_id", type = IdType.AUTO)
private Long materialBomId;
/**
*
*/
private Long parentId;
/**
* ID
*/
private Long materialId;
/**
*
*/
private String materialName;
/**
* bom
*/
private String materialBomDesc;
/**
* bom
*/
private String materialBomVersion;
/**
*
*/
private String ancestors;
/**
*
*/
private Long standardAmount;
/**
* (1 0)
*/
private Long topFlag;
/**
* (0 1 2)
*/
private String checkType;
/**
* ID
*/
private Long projectId;
/**
* ()
*/
private Long assembleTime;
/**
* 1ERP 2 3MES
*/
private String materialClassfication;
/**
*
*/
private String attachId;
/**
* 1 0
*/
private String activeFlag;
/**
*
*/
private String remark;
}

@ -0,0 +1,105 @@
package org.dromara.mes.domain.bo;
import org.dromara.mes.domain.ProdMaterialBom;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
/**
* BOM prod_material_bom
*
* @author Yinq
* @date 2025-01-08
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = ProdMaterialBom.class, reverseConvertGenerate = false)
public class ProdMaterialBomBo extends BaseEntity {
/**
*
*/
private Long materialBomId;
/**
*
*/
private Long parentId;
/**
* ID
*/
@NotNull(message = "物料ID不能为空", groups = { AddGroup.class, EditGroup.class })
private Long materialId;
/**
*
*/
private String materialName;
/**
* bom
*/
private String materialBomDesc;
/**
* bom
*/
private String materialBomVersion;
/**
*
*/
private String ancestors;
/**
*
*/
private Long standardAmount;
/**
* (1 0)
*/
private Long topFlag;
/**
* (0 1 2)
*/
private String checkType;
/**
* ID
*/
private Long projectId;
/**
* ()
*/
private Long assembleTime;
/**
* 1ERP 2 3MES
*/
private String materialClassfication;
/**
*
*/
private String attachId;
/**
* 1 0
*/
private String activeFlag;
/**
*
*/
private String remark;
}

@ -0,0 +1,157 @@
package org.dromara.mes.domain.vo;
import org.dromara.mes.domain.ProdMaterialBom;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import org.dromara.common.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* BOM prod_material_bom
*
* @author Yinq
* @date 2025-01-08
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = ProdMaterialBom.class)
public class ProdMaterialBomVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
private Long materialBomId;
/**
*
*/
private Long parentId;
/**
* ID
*/
@ExcelProperty(value = "物料ID")
private Long materialId;
/**
*
*/
@ExcelProperty(value = "物料名称")
private String materialName;
/**
* bom
*/
private String materialBomDesc;
/**
* bom
*/
private String materialBomVersion;
/**
*
*/
private String ancestors;
/**
*
*/
@ExcelProperty(value = "标准数量")
private Long standardAmount;
/**
* (1 0)
*/
@ExcelProperty(value = "顶级标识(1是 0否)", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "active_flag")
private Long topFlag;
/**
* (0 1 2)
*/
@ExcelProperty(value = "校验类型(0不校验 1人工校验 2自动校验)", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "mes_check_type")
private String checkType;
/**
* ID
*/
@ExcelProperty(value = "项目ID")
private Long projectId;
/**
* ()
*/
@ExcelProperty(value = "装配时长(秒)")
private Long assembleTime;
/**
* 1ERP 2 3MES
*/
@ExcelProperty(value = "物料分类", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "material_classfication")
private String materialClassfication;
/**
*
*/
@ExcelProperty(value = "附件信息")
private String attachId;
/**
* 1 0
*/
@ExcelProperty(value = "激活标识", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "active_flag")
private String activeFlag;
/**
*
*/
@ExcelProperty(value = "备注")
private String remark;
/**
*
*/
@ExcelProperty(value = "创建部门")
private Long createDept;
/**
*
*/
@ExcelProperty(value = "创建人")
private Long createBy;
/**
*
*/
@ExcelProperty(value = "创建时间")
private Date createTime;
/**
*
*/
@ExcelProperty(value = "更新人")
private Long updateBy;
/**
*
*/
@ExcelProperty(value = "更新时间")
private Date updateTime;
}

@ -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;
/**
* BOMMapper
*
* @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;
/**
* BOMService
*
* @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;
/**
* BOMService
*
* @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…
Cancel
Save