@@ -31,4 +31,13 @@ public interface DepartmentMaterialMapper extends BaseMapperX<DepartmentMaterial
|
|||||||
.orderByDesc(DepartmentMaterialDO::getId));
|
.orderByDesc(DepartmentMaterialDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Long countExist(DepartmentMaterialDO reqVO) {
|
||||||
|
return selectCount(new LambdaQueryWrapperX<DepartmentMaterialDO>()
|
||||||
|
.eqIfPresent(DepartmentMaterialDO::getInfomationId, reqVO.getInfomationId())
|
||||||
|
.eqIfPresent(DepartmentMaterialDO::getClassesId, reqVO.getClassesId())
|
||||||
|
.eqIfPresent(DepartmentMaterialDO::getDeptId, reqVO.getDeptId())
|
||||||
|
.eqIfPresent(DepartmentMaterialDO::getDictionaryDataValue, reqVO.getDictionaryDataValue())
|
||||||
|
.neIfPresent(DepartmentMaterialDO::getId,reqVO.getId())); // 更新时判断要排除自身
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropert
|
|||||||
import com.zt.plat.module.base.service.masterdatasync.support.MasterDataPropertyDefinition;
|
import com.zt.plat.module.base.service.masterdatasync.support.MasterDataPropertyDefinition;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -69,6 +70,7 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
public DepartmentMaterialRespVO createDepartmentMaterial(DepartmentMaterialSaveReqVO createReqVO) {
|
public DepartmentMaterialRespVO createDepartmentMaterial(DepartmentMaterialSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
DepartmentMaterialDO departmentMaterial = BeanUtils.toBean(createReqVO, DepartmentMaterialDO.class);
|
DepartmentMaterialDO departmentMaterial = BeanUtils.toBean(createReqVO, DepartmentMaterialDO.class);
|
||||||
|
validateNotExists(departmentMaterial); // 简单验证不存在相同分类物料
|
||||||
departmentMaterialMapper.insert(departmentMaterial);
|
departmentMaterialMapper.insert(departmentMaterial);
|
||||||
// 构造完整响应,方便前端直接刷新数据
|
// 构造完整响应,方便前端直接刷新数据
|
||||||
return CollUtil.getFirst(decorateDepartmentMaterials(Collections.singletonList(departmentMaterial)));
|
return CollUtil.getFirst(decorateDepartmentMaterials(Collections.singletonList(departmentMaterial)));
|
||||||
@@ -80,6 +82,7 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
validateDepartmentMaterialExists(updateReqVO.getId());
|
validateDepartmentMaterialExists(updateReqVO.getId());
|
||||||
// 更新
|
// 更新
|
||||||
DepartmentMaterialDO updateObj = BeanUtils.toBean(updateReqVO, DepartmentMaterialDO.class);
|
DepartmentMaterialDO updateObj = BeanUtils.toBean(updateReqVO, DepartmentMaterialDO.class);
|
||||||
|
validateNotExists(updateObj); // 简单验证不存在重复相同分类物料
|
||||||
departmentMaterialMapper.updateById(updateObj);
|
departmentMaterialMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +109,14 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validateNotExists(DepartmentMaterialDO departmentMaterial) {
|
||||||
|
Long cnt = departmentMaterialMapper.countExist(departmentMaterial);
|
||||||
|
if (cnt != null && cnt > 0) {
|
||||||
|
// 已存在未删除的同一条
|
||||||
|
throw exception(DEPARTMENT_MATERIAL_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void validateDepartmentMaterialExists(Long id) {
|
private void validateDepartmentMaterialExists(Long id) {
|
||||||
if (departmentMaterialMapper.selectById(id) == null) {
|
if (departmentMaterialMapper.selectById(id) == null) {
|
||||||
throw exception(DEPARTMENT_MATERIAL_NOT_EXISTS);
|
throw exception(DEPARTMENT_MATERIAL_NOT_EXISTS);
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class EntrustOrderOrderSaveReqVO {
|
|||||||
@Schema(description = "采购组名称", example = "张三")
|
@Schema(description = "采购组名称", example = "张三")
|
||||||
private String purchaseGroupName;
|
private String purchaseGroupName;
|
||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
private LocalDateTime[] createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@Schema(description = "委托加工订单明细")
|
@Schema(description = "委托加工订单明细")
|
||||||
private List<EntrustOrderDetailSaveReqVO> entrustOrderDetails;
|
private List<EntrustOrderDetailSaveReqVO> entrustOrderDetails;
|
||||||
|
|||||||
Reference in New Issue
Block a user