|
|
|
|
@ -1,10 +1,13 @@
|
|
|
|
|
package cn.iocoder.yudao.module.erp.service.mold;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
|
|
import cn.iocoder.yudao.module.common.controller.admin.mold.vo.*;
|
|
|
|
|
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldBrandDO;
|
|
|
|
|
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldBrandProductDO;
|
|
|
|
|
@ -12,6 +15,7 @@ import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO;
|
|
|
|
|
import cn.iocoder.yudao.module.common.dal.dataobject.moldrepair.MoldRepairDO;
|
|
|
|
|
import cn.iocoder.yudao.module.common.dal.dataobject.moldrepair.MoldRepairLineDO;
|
|
|
|
|
import cn.iocoder.yudao.module.common.dal.dataobject.moldticketresults.MoldTicketResultsDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldBrandTreeRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
|
|
|
|
|
import cn.iocoder.yudao.module.common.dal.mysql.mold.MoldBrandMapper;
|
|
|
|
|
@ -21,10 +25,10 @@ import cn.iocoder.yudao.module.common.dal.mysql.moldrepair.MoldRepairLineMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.common.dal.mysql.moldrepair.MoldRepairMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.common.dal.mysql.moldticketresults.MoldTicketResultsMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.common.controller.admin.moldticketmanagement.enums.MoldPlanTypeEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@ -65,6 +69,17 @@ public class MoldBrandServiceImpl implements MoldBrandService {
|
|
|
|
|
@Override
|
|
|
|
|
public Long createMoldBrand(MoldBrandSaveReqVO createReqVO) {
|
|
|
|
|
// 插入
|
|
|
|
|
// MoldBrandDO moldBrand = BeanUtils.toBean(createReqVO, MoldBrandDO.class);
|
|
|
|
|
String Code = createReqVO.getCode();
|
|
|
|
|
if (StrUtil.isBlank(Code)) {
|
|
|
|
|
throw new ServiceException(ErrorCodeConstants.MOLD_BRAND_CODE_EMPTY);
|
|
|
|
|
}
|
|
|
|
|
boolean exists = moldBrandMapper.exists(
|
|
|
|
|
new LambdaQueryWrapperX<MoldBrandDO>().eq(MoldBrandDO::getCode, Code)
|
|
|
|
|
);
|
|
|
|
|
if (exists) {
|
|
|
|
|
throw new ServiceException(ErrorCodeConstants.MOLD_BRAND_CODE_DUPLICATE);
|
|
|
|
|
}
|
|
|
|
|
MoldBrandDO moldBrand = BeanUtils.toBean(createReqVO, MoldBrandDO.class);
|
|
|
|
|
moldBrandMapper.insert(moldBrand);
|
|
|
|
|
// 返回
|
|
|
|
|
@ -158,7 +173,18 @@ public class MoldBrandServiceImpl implements MoldBrandService {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public Long createMold(MoldDO mold) {
|
|
|
|
|
public Long createMold(MoldSaveReqVO createReqVO) {
|
|
|
|
|
String Code = createReqVO.getCode();
|
|
|
|
|
if (StrUtil.isBlank(Code)) {
|
|
|
|
|
throw new ServiceException(ErrorCodeConstants.MOLD_CODE_EMPTY);
|
|
|
|
|
}
|
|
|
|
|
boolean exists = moldMapper.exists(
|
|
|
|
|
new LambdaQueryWrapperX<MoldDO>().eq(MoldDO::getCode, Code)
|
|
|
|
|
);
|
|
|
|
|
if (exists) {
|
|
|
|
|
throw new ServiceException(ErrorCodeConstants.MOLD_CODE_DUPLICATE);
|
|
|
|
|
}
|
|
|
|
|
MoldDO mold = BeanUtils.toBean(createReqVO, MoldDO.class);
|
|
|
|
|
moldMapper.insert(mold);
|
|
|
|
|
return mold.getId();
|
|
|
|
|
}
|
|
|
|
|
@ -317,4 +343,35 @@ public class MoldBrandServiceImpl implements MoldBrandService {
|
|
|
|
|
private void deleteMoldBrandProductByBrandId(Long brandId) {
|
|
|
|
|
moldBrandProductMapper.deleteByBrandId(brandId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<MoldBrandTreeRespVO> getMoldBrandTree() {
|
|
|
|
|
// 1. 查询所有模具类型
|
|
|
|
|
List<MoldBrandDO> allMoldBrands = moldBrandMapper.selectList();
|
|
|
|
|
|
|
|
|
|
// 2. 构建树形结构
|
|
|
|
|
return buildMoldBrandTree(allMoldBrands);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建树形结构
|
|
|
|
|
*/
|
|
|
|
|
private List<MoldBrandTreeRespVO> buildMoldBrandTree(List<MoldBrandDO> allMoldBrands) {
|
|
|
|
|
return allMoldBrands.stream()
|
|
|
|
|
.map(this::convertToTreeRespVO)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
private MoldBrandTreeRespVO convertToTreeRespVO(MoldBrandDO moldBrand) {
|
|
|
|
|
// 使用BeanUtils或手动设置属性
|
|
|
|
|
MoldBrandTreeRespVO respVO = new MoldBrandTreeRespVO();
|
|
|
|
|
|
|
|
|
|
// 复制公共属性(假设MoldBrandRespVO有对应的方法)
|
|
|
|
|
BeanUtils.copyProperties(moldBrand, respVO);
|
|
|
|
|
|
|
|
|
|
// 设置树状结构属性
|
|
|
|
|
respVO.setChildren(new ArrayList<>()); // 空子节点
|
|
|
|
|
respVO.setLeaf(true); // 叶子节点
|
|
|
|
|
return respVO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|