feat:完善计量单位管理
This commit is contained in:
@@ -113,4 +113,19 @@ public class QuantityUnitRelationController implements BusinessControllerMarker
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/create-unit-with-relation")
|
||||
@Operation(summary = "创建单位并关联到量纲(组合接口)")
|
||||
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:create')")
|
||||
public CommonResult<QuantityUnitRelationRespVO> createUnitWithRelation(@Valid @RequestBody CreateUnitWithRelationReqVO createReqVO) {
|
||||
return success(quantityUnitRelationService.createUnitWithRelation(createReqVO));
|
||||
}
|
||||
|
||||
@PostMapping("/delete-unit-with-relation")
|
||||
@Operation(summary = "删除单位及关联关系(组合接口)")
|
||||
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:delete')")
|
||||
public CommonResult<Boolean> deleteUnitWithRelation(@Valid @RequestBody DeleteUnitWithRelationReqVO deleteReqVO) {
|
||||
quantityUnitRelationService.deleteUnitWithRelation(deleteReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.zt.plat.module.unitmanagement.controller.admin.QuantityUnitRelation.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 创建单位并关联到量纲 Request VO")
|
||||
@Data
|
||||
public class CreateUnitWithRelationReqVO {
|
||||
|
||||
@Schema(description = "量纲ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "量纲ID不能为空")
|
||||
private Long untQtyId;
|
||||
|
||||
@Schema(description = "单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "米")
|
||||
@NotEmpty(message = "单位名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "单位符号", requiredMode = Schema.RequiredMode.REQUIRED, example = "m")
|
||||
@NotEmpty(message = "单位符号不能为空")
|
||||
private String smb;
|
||||
|
||||
@Schema(description = "是否基准单位:0=否,1=是", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "是否基准单位不能为空")
|
||||
private Integer isBse;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.zt.plat.module.unitmanagement.controller.admin.QuantityUnitRelation.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 删除单位及关联关系 Request VO")
|
||||
@Data
|
||||
public class DeleteUnitWithRelationReqVO {
|
||||
|
||||
@Schema(description = "关联关系ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "关联关系ID不能为空")
|
||||
private Long relationId;
|
||||
|
||||
@Schema(description = "单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "单位ID不能为空")
|
||||
private Long untId;
|
||||
|
||||
}
|
||||
@@ -14,6 +14,9 @@ import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
|
||||
@Data
|
||||
public class UnitConversionPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "计量单位量ID(量纲ID)", example = "1")
|
||||
private Long untQtyId;
|
||||
|
||||
@Schema(description = "源单位ID", example = "26239")
|
||||
private Long srcUntId;
|
||||
|
||||
|
||||
@@ -13,6 +13,10 @@ public class UnitConversionSaveReqVO {
|
||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "339")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "计量单位量ID(量纲ID)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "量纲ID不能为空")
|
||||
private Long untQtyId;
|
||||
|
||||
@Schema(description = "源单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26239")
|
||||
@NotNull(message = "源单位ID不能为空")
|
||||
private Long srcUntId;
|
||||
|
||||
@@ -19,6 +19,7 @@ public interface UnitConversionMapper extends BaseMapperX<UnitConversionDO> {
|
||||
|
||||
default PageResult<UnitConversionDO> selectPage(UnitConversionPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<UnitConversionDO>()
|
||||
.eqIfPresent(UnitConversionDO::getUntQtyId, reqVO.getUntQtyId())
|
||||
.eqIfPresent(UnitConversionDO::getSrcUntId, reqVO.getSrcUntId())
|
||||
.eqIfPresent(UnitConversionDO::getTgtUntId, reqVO.getTgtUntId())
|
||||
.eqIfPresent(UnitConversionDO::getFctr, reqVO.getFctr())
|
||||
|
||||
@@ -33,6 +33,11 @@ public class UnitConversionDO extends BaseDO {
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 计量单位量ID(量纲ID)
|
||||
*/
|
||||
@TableField("UNT_QTY_ID")
|
||||
private Long untQtyId;
|
||||
/**
|
||||
* 源单位ID
|
||||
*/
|
||||
@TableField("SRC_UNT_ID")
|
||||
|
||||
@@ -67,4 +67,23 @@ public interface QuantityUnitRelationService {
|
||||
*/
|
||||
void batchSaveQuantityUnitRelations(@Valid QuantityUnitRelationBatchSaveReqVO batchSaveReqVO);
|
||||
|
||||
/**
|
||||
* 创建单位并关联到量纲(组合接口)
|
||||
* 1. 创建计量单位
|
||||
* 2. 创建量纲-单位关联关系
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 关联关系响应VO
|
||||
*/
|
||||
QuantityUnitRelationRespVO createUnitWithRelation(@Valid CreateUnitWithRelationReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 删除单位及关联关系(组合接口)
|
||||
* 1. 删除量纲-单位关联关系
|
||||
* 2. 删除计量单位
|
||||
*
|
||||
* @param deleteReqVO 删除信息
|
||||
*/
|
||||
void deleteUnitWithRelation(@Valid DeleteUnitWithRelationReqVO deleteReqVO);
|
||||
|
||||
}
|
||||
@@ -14,6 +14,9 @@ import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.zt.plat.module.unitmanagement.dal.dao.QuantityUnitRelation.QuantityUnitRelationMapper;
|
||||
import com.zt.plat.module.unitmanagement.service.UntInfo.UntInfoService;
|
||||
import com.zt.plat.module.unitmanagement.controller.admin.UntInfo.vo.UntInfoSaveReqVO;
|
||||
import com.zt.plat.module.unitmanagement.controller.admin.UntInfo.vo.UntInfoRespVO;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
||||
@@ -32,6 +35,9 @@ public class QuantityUnitRelationServiceImpl implements QuantityUnitRelationServ
|
||||
@Resource
|
||||
private QuantityUnitRelationMapper quantityUnitRelationMapper;
|
||||
|
||||
@Resource
|
||||
private UntInfoService untInfoService;
|
||||
|
||||
@Override
|
||||
public QuantityUnitRelationRespVO createQuantityUnitRelation(QuantityUnitRelationSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@@ -138,4 +144,32 @@ public class QuantityUnitRelationServiceImpl implements QuantityUnitRelationServ
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public QuantityUnitRelationRespVO createUnitWithRelation(CreateUnitWithRelationReqVO createReqVO) {
|
||||
// 1. 创建计量单位
|
||||
UntInfoSaveReqVO untInfoReqVO = new UntInfoSaveReqVO();
|
||||
untInfoReqVO.setName(createReqVO.getName());
|
||||
untInfoReqVO.setSmb(createReqVO.getSmb());
|
||||
UntInfoRespVO untInfoResp = untInfoService.createUntInfo(untInfoReqVO);
|
||||
|
||||
// 2. 创建量纲-单位关联关系
|
||||
QuantityUnitRelationSaveReqVO relationReqVO = new QuantityUnitRelationSaveReqVO();
|
||||
relationReqVO.setUntQtyId(createReqVO.getUntQtyId());
|
||||
relationReqVO.setUntId(untInfoResp.getId());
|
||||
relationReqVO.setIsBse(createReqVO.getIsBse());
|
||||
|
||||
return createQuantityUnitRelation(relationReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteUnitWithRelation(DeleteUnitWithRelationReqVO deleteReqVO) {
|
||||
// 1. 先删除关联关系(外键约束,必须先删除)
|
||||
deleteQuantityUnitRelation(deleteReqVO.getRelationId());
|
||||
|
||||
// 2. 再删除计量单位
|
||||
untInfoService.deleteUntInfo(deleteReqVO.getUntId());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user