Merge branch 'dev' into 'test'

Dev

See merge request jygk/dsc-base!27
This commit is contained in:
朝锦 杨
2026-01-23 06:59:10 +00:00
3 changed files with 21 additions and 1 deletions

View File

@@ -31,4 +31,13 @@ public interface DepartmentMaterialMapper extends BaseMapperX<DepartmentMaterial
.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())); // 更新时判断要排除自身
}
}

View File

@@ -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 jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.*;
@@ -69,6 +70,7 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
public DepartmentMaterialRespVO createDepartmentMaterial(DepartmentMaterialSaveReqVO createReqVO) {
// 插入
DepartmentMaterialDO departmentMaterial = BeanUtils.toBean(createReqVO, DepartmentMaterialDO.class);
validateNotExists(departmentMaterial); // 简单验证不存在相同分类物料
departmentMaterialMapper.insert(departmentMaterial);
// 构造完整响应,方便前端直接刷新数据
return CollUtil.getFirst(decorateDepartmentMaterials(Collections.singletonList(departmentMaterial)));
@@ -80,6 +82,7 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
validateDepartmentMaterialExists(updateReqVO.getId());
// 更新
DepartmentMaterialDO updateObj = BeanUtils.toBean(updateReqVO, DepartmentMaterialDO.class);
validateNotExists(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) {
if (departmentMaterialMapper.selectById(id) == null) {
throw exception(DEPARTMENT_MATERIAL_NOT_EXISTS);

View File

@@ -139,7 +139,7 @@ public class EntrustOrderOrderSaveReqVO {
@Schema(description = "采购组名称", example = "张三")
private String purchaseGroupName;
@Schema(description = "创建时间")
private LocalDateTime[] createTime;
private LocalDateTime createTime;
@Schema(description = "委托加工订单明细")
private List<EntrustOrderDetailSaveReqVO> entrustOrderDetails;