fix:新增物料批次接口及批次拆分及接口。

This commit is contained in:
shusir
2026-01-26 18:05:23 +08:00
parent 2336c370fa
commit 0d164c660e
11 changed files with 251 additions and 72 deletions

View File

@@ -5,6 +5,8 @@ import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchRespV
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchSaveReqVO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO;
import com.zt.plat.module.qms.resource.material.service.MaterialBatchService;
import com.zt.plat.module.qms.resource.material.valid.AddGroup;
import com.zt.plat.module.qms.resource.material.valid.UpdateGroup;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@@ -35,7 +37,7 @@ import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
@Tag(name = "管理后台 - 物料批次")
@RestController
@RequestMapping("/qms/material-batch")
@RequestMapping("/qms/resource/material-batch")
@Validated
public class MaterialBatchController implements BusinessControllerMarker {
@@ -45,15 +47,15 @@ public class MaterialBatchController implements BusinessControllerMarker {
@PostMapping("/create")
@Operation(summary = "创建物料批次")
@PreAuthorize("@ss.hasPermission('qms:material-batch:create')")
public CommonResult<MaterialBatchRespVO> createMaterialBatch(@Valid @RequestBody MaterialBatchSaveReqVO createReqVO) {
// @PreAuthorize("@ss.hasPermission('qms:material-batch:create')")
public CommonResult<MaterialBatchRespVO> createMaterialBatch(@Validated(AddGroup.class) @RequestBody MaterialBatchSaveReqVO createReqVO) {
return success(materialBatchService.createMaterialBatch(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新物料批次")
@PreAuthorize("@ss.hasPermission('qms:material-batch:update')")
public CommonResult<Boolean> updateMaterialBatch(@Valid @RequestBody MaterialBatchSaveReqVO updateReqVO) {
// @PreAuthorize("@ss.hasPermission('qms:material-batch:update')")
public CommonResult<Boolean> updateMaterialBatch(@Validated(UpdateGroup.class) @RequestBody MaterialBatchSaveReqVO updateReqVO) {
materialBatchService.updateMaterialBatch(updateReqVO);
return success(true);
}
@@ -61,7 +63,7 @@ public class MaterialBatchController implements BusinessControllerMarker {
@DeleteMapping("/delete")
@Operation(summary = "删除物料批次")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('qms:material-batch:delete')")
// @PreAuthorize("@ss.hasPermission('qms:material-batch:delete')")
public CommonResult<Boolean> deleteMaterialBatch(@RequestParam("id") Long id) {
materialBatchService.deleteMaterialBatch(id);
return success(true);
@@ -70,7 +72,7 @@ public class MaterialBatchController implements BusinessControllerMarker {
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除物料批次")
@PreAuthorize("@ss.hasPermission('qms:material-batch:delete')")
// @PreAuthorize("@ss.hasPermission('qms:material-batch:delete')")
public CommonResult<Boolean> deleteMaterialBatchList(@RequestBody BatchDeleteReqVO req) {
materialBatchService.deleteMaterialBatchListByIds(req.getIds());
return success(true);
@@ -79,7 +81,7 @@ public class MaterialBatchController implements BusinessControllerMarker {
@GetMapping("/get")
@Operation(summary = "获得物料批次")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('qms:material-batch:query')")
// @PreAuthorize("@ss.hasPermission('qms:material-batch:query')")
public CommonResult<MaterialBatchRespVO> getMaterialBatch(@RequestParam("id") Long id) {
MaterialBatchDO materialBatch = materialBatchService.getMaterialBatch(id);
return success(BeanUtils.toBean(materialBatch, MaterialBatchRespVO.class));
@@ -87,7 +89,7 @@ public class MaterialBatchController implements BusinessControllerMarker {
@GetMapping("/page")
@Operation(summary = "获得物料批次分页")
@PreAuthorize("@ss.hasPermission('qms:material-batch:query')")
// @PreAuthorize("@ss.hasPermission('qms:material-batch:query')")
public CommonResult<PageResult<MaterialBatchRespVO>> getMaterialBatchPage(@Valid MaterialBatchPageReqVO pageReqVO) {
PageResult<MaterialBatchDO> pageResult = materialBatchService.getMaterialBatchPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, MaterialBatchRespVO.class));
@@ -106,4 +108,11 @@ public class MaterialBatchController implements BusinessControllerMarker {
BeanUtils.toBean(list, MaterialBatchRespVO.class));
}
@PostMapping("/assign-gongduan")
@Operation(summary = "批次工段拆分")
// @PreAuthorize("@ss.hasPermission('qms:material-batch:create')")
public CommonResult<List<MaterialBatchRespVO>> assignMaterialBatchGongduan(@Valid @RequestBody List<MaterialBatchSaveReqVO> createReqVOs) {
return success(materialBatchService.assignMaterialBatchGongduan(createReqVOs));
}
}

View File

@@ -62,6 +62,7 @@ public class MaterialProductController extends AbstractFileUploadController impl
return success(materialProductService.getMaterialCategoryTree());
}
// TODO
@GetMapping("/orig-material/{code}")
@Operation(summary = "根据物料编码获取外部系统原始物料")
public CommonResult<Object> getOriginalMaterial(@PathVariable String code) {
@@ -84,18 +85,18 @@ public class MaterialProductController extends AbstractFileUploadController impl
}
@PutMapping("/update")
@Operation(summary = "更新物料")
@PreAuthorize("@ss.hasPermission('qms:material-product:update')")
public CommonResult<Boolean> updateMaterialProduct(@Valid @RequestBody MaterialProductSaveReqVO updateReqVO) {
materialProductService.updateMaterialProduct(updateReqVO);
return success(true);
}
// @PutMapping("/update")
// @Operation(summary = "更新物料")
// @PreAuthorize("@ss.hasPermission('qms:material-product:update')")
// public CommonResult<Boolean> updateMaterialProduct(@Valid @RequestBody MaterialProductSaveReqVO updateReqVO) {
// materialProductService.updateMaterialProduct(updateReqVO);
// return success(true);
// }
@DeleteMapping("/delete")
@Operation(summary = "删除物料")
@Operation(summary = "删除物料分类或大类")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('qms:material-product:delete')")
// @PreAuthorize("@ss.hasPermission('qms:material-product:delete')")
public CommonResult<Boolean> deleteMaterialProduct(@RequestParam("id") Long id) {
materialProductService.deleteMaterialProduct(id);
return success(true);

View File

@@ -1,10 +1,12 @@
package com.zt.plat.module.qms.resource.material.controller.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.zt.plat.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -20,8 +22,8 @@ public class MaterialBatchPageReqVO extends PageParam {
@Schema(description = "批次编号")
private String batchNo;
@Schema(description = "总数量")
private String inboundQuantity;
// @Schema(description = "总数量")
// private BigDecimal inboundQuantity;
@Schema(description = "存放位置描述")
private String location;
@@ -37,6 +39,12 @@ public class MaterialBatchPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDate[] dueDate;
@Schema(description = "分配部门id")
private Long assignDepartmentId;
@Schema(description = "分配部门名称")
private String assignDepartmentName;
@Schema(description = "验收状态", example = "1")
private String acceptanceStatus;
@@ -46,8 +54,8 @@ public class MaterialBatchPageReqVO extends PageParam {
@Schema(description = "检化验状态,NOT_STARTED-未开始IN_PROGRESS-进行中PASSED-通过NOT_PASSED-未通过", example = "2")
private String assayStatus;
@Schema(description = "检化验结果")
private String assayResult;
// @Schema(description = "检化验结果")
// private String assayResult;
@Schema(description = "所属部门")
private String systemDepartmentCode;

View File

@@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@@ -17,6 +18,10 @@ public class MaterialBatchRespVO {
@ExcelProperty("主键")
private Long id;
@Schema(description = "父id,为0时是批次不为0时是工段", example = "1035")
@ExcelProperty("父id,为0时是批次不为0时是工段")
private Long parentId;
@Schema(description = "物料大类id", example = "9381")
@ExcelProperty("物料大类id")
private Long productId;
@@ -27,7 +32,7 @@ public class MaterialBatchRespVO {
@Schema(description = "总数量")
@ExcelProperty("总数量")
private String inboundQuantity;
private BigDecimal inboundQuantity;
@Schema(description = "存放位置描述")
@ExcelProperty("存放位置描述")
@@ -45,6 +50,14 @@ public class MaterialBatchRespVO {
@ExcelProperty("到期日期")
private LocalDate dueDate;
@Schema(description = "分配部门id")
@ExcelProperty("分配部门id")
private Long assignDepartmentId;
@Schema(description = "分配部门名称")
@ExcelProperty("分配部门名称")
private String assignDepartmentName;
@Schema(description = "验收状态", example = "1")
@ExcelProperty("验收状态")
private String acceptanceStatus;

View File

@@ -1,26 +1,39 @@
package com.zt.plat.module.qms.resource.material.controller.vo;
import com.zt.plat.module.qms.resource.material.valid.AddGroup;
import com.zt.plat.module.qms.resource.material.valid.UpdateGroup;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import jakarta.validation.constraints.*;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Null;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
@Schema(description = "管理后台 - 物料批次新增/修改 Request VO")
@Data
public class MaterialBatchSaveReqVO {
@Null(groups = AddGroup.class, message = "新增数据 ID 必须为空")
@NotNull(groups = UpdateGroup.class, message = "修改数据 ID 不能为空")
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "9716")
private Long id;
@Schema(description = "父id,为0时是批次不为0时是工段", example = "1035")
private Long parentId;
@Schema(description = "物料大类id", example = "9381")
@NotNull(groups = AddGroup.class, message = "物料大类 ID 不能为空")
private Long productId;
@Schema(description = "批次编号")
private String batchNo;
// @Schema(description = "批次编号")
// private String batchNo;
@Schema(description = "总数量")
private String inboundQuantity;
@NotNull(groups = AddGroup.class, message = "总数量不能为空")
@Min(value = 0, message = "总数量不能小于0")
private BigDecimal inboundQuantity;
@Schema(description = "存放位置描述")
private String location;
@@ -29,22 +42,29 @@ public class MaterialBatchSaveReqVO {
private Long supplierId;
@Schema(description = "生产日期")
@NotNull(groups = AddGroup.class, message = "生产日期不能为空")
private LocalDate manufacturerDate;
@Schema(description = "到期日期")
private LocalDate dueDate;
@Schema(description = "验收状态", example = "1")
private String acceptanceStatus;
@Schema(description = "分配部门id")
private Long assignDepartmentId;
@Schema(description = "分配部门名称")
private String assignDepartmentName;
// @Schema(description = "验收状态", example = "1")
// private String acceptanceStatus;
@Schema(description = "是否检化验,1-是0-否")
private Integer assayFlag;
@Schema(description = "检化验状态,NOT_STARTED-未开始IN_PROGRESS-进行中PASSED-通过NOT_PASSED-未通过", example = "2")
private String assayStatus;
// @Schema(description = "检化验状态,NOT_STARTED-未开始IN_PROGRESS-进行中PASSED-通过NOT_PASSED-未通过", example = "IN_PROGRESS")
// private String assayStatus;
@Schema(description = "检化验结果")
private String assayResult;
// @Schema(description = "检化验结果")
// private String assayResult;
@Schema(description = "所属部门")
private String systemDepartmentCode;

View File

@@ -4,6 +4,7 @@ import lombok.*;
import com.baomidou.mybatisplus.annotation.*;
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
@@ -31,6 +32,11 @@ public class MaterialBatchDO extends BusinessBaseDO {
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 父id,为0时是批次不为0时是工段
*/
@TableField("PRN_ID")
private Long parentId;
/**
* 物料大类id
*/
@@ -45,7 +51,7 @@ public class MaterialBatchDO extends BusinessBaseDO {
* 总数量
*/
@TableField("INB_QTY")
private String inboundQuantity;
private BigDecimal inboundQuantity;
/**
* 存放位置描述
*/
@@ -66,6 +72,16 @@ public class MaterialBatchDO extends BusinessBaseDO {
*/
@TableField("DUE_DT")
private LocalDate dueDate;
/**
* 分配部门id
*/
@TableField("ASN_DEPT_ID")
private Long assignDepartmentId;
/**
* 分配部门名称
*/
@TableField("ASN_DEPT_NAME")
private String assignDepartmentName;
/**
* 验收状态
*/

View File

@@ -18,16 +18,17 @@ public interface MaterialBatchMapper extends BaseMapperX<MaterialBatchDO> {
default PageResult<MaterialBatchDO> selectPage(MaterialBatchPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MaterialBatchDO>()
.eqIfPresent(MaterialBatchDO::getProductId, reqVO.getProductId())
.eqIfPresent(MaterialBatchDO::getBatchNo, reqVO.getBatchNo())
.eqIfPresent(MaterialBatchDO::getInboundQuantity, reqVO.getInboundQuantity())
.eqIfPresent(MaterialBatchDO::getLocation, reqVO.getLocation())
.likeIfPresent(MaterialBatchDO::getBatchNo, reqVO.getBatchNo())
.likeIfPresent(MaterialBatchDO::getLocation, reqVO.getLocation())
.eqIfPresent(MaterialBatchDO::getSupplierId, reqVO.getSupplierId())
.betweenIfPresent(MaterialBatchDO::getManufacturerDate, reqVO.getManufacturerDate())
.betweenIfPresent(MaterialBatchDO::getDueDate, reqVO.getDueDate())
.eqIfPresent(MaterialBatchDO::getAssignDepartmentId, reqVO.getAssignDepartmentId())
.likeIfPresent(MaterialBatchDO::getAssignDepartmentName, reqVO.getAssignDepartmentName())
.eqIfPresent(MaterialBatchDO::getAcceptanceStatus, reqVO.getAcceptanceStatus())
.eqIfPresent(MaterialBatchDO::getAssayFlag, reqVO.getAssayFlag())
.eqIfPresent(MaterialBatchDO::getAssayStatus, reqVO.getAssayStatus())
.eqIfPresent(MaterialBatchDO::getAssayResult, reqVO.getAssayResult())
//.eqIfPresent(MaterialBatchDO::getAssayResult, reqVO.getAssayResult())
.eqIfPresent(MaterialBatchDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
.eqIfPresent(MaterialBatchDO::getRemark, reqVO.getRemark())
.betweenIfPresent(MaterialBatchDO::getCreateTime, reqVO.getCreateTime())

View File

@@ -61,4 +61,11 @@ public interface MaterialBatchService {
*/
PageResult<MaterialBatchDO> getMaterialBatchPage(MaterialBatchPageReqVO pageReqVO);
/**
* 批次工段拆分
*
* @param createReqVOs 创建信息
* @return 工段编号
*/
List<MaterialBatchRespVO> assignMaterialBatchGongduan(@Valid List<MaterialBatchSaveReqVO> createReqVOs);
}

View File

@@ -14,6 +14,7 @@ import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductSav
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO;
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialProductMapper;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@@ -180,19 +181,20 @@ public class MaterialProductServiceImpl implements MaterialProductService {
.setStandardMaterialFlag(prnCtg.getStandardMaterialFlag())
.setStandardSolutionFlag(prnCtg.getStandardSolutionFlag());
}
materialProductMapper.insert(mtrl);
return BeanUtils.toBean(mtrl, MaterialProductRespVO.class);
// 更新 idPath
} else {
// 修改
MaterialProductDO origDO = materialProductMapper.selectById(reqId);
if (origDO == null) throw exception(MATERIAL_PRODUCT_NOT_EXISTS);
Long newParentId = createReqVO.getParentId();
if (origDO.getParentId().equals(newParentId)) {
materialProductMapper.updateById(mtrl);
return BeanUtils.toBean(mtrl, MaterialProductRespVO.class);
}
// 父节点有变更时更新 idPath
}
// 修改
MaterialProductDO origDO = materialProductMapper.selectById(reqId);
if (origDO == null) throw exception(MATERIAL_PRODUCT_NOT_EXISTS);
Long newParentId = createReqVO.getParentId();
if (origDO.getParentId().equals(newParentId)) {
materialProductMapper.updateById(mtrl);
return BeanUtils.toBean(mtrl, MaterialProductRespVO.class);
}
// 父节点有变更时更新 idPath
String newIdPath = getIdPath(mtrl);
mtrl.setIdPath(newIdPath);
materialProductMapper.updateById(mtrl);
@@ -210,9 +212,23 @@ public class MaterialProductServiceImpl implements MaterialProductService {
@Override
public void deleteMaterialProduct(Long id) {
// 校验存在
validateMaterialProductExists(id);
// 删除
MaterialProductDO pdtDo = materialProductMapper.selectById(id);
if (pdtDo == null) throw exception(MATERIAL_PRODUCT_NOT_EXISTS);
// 分类
if (DataTypeConstant.DATA_TYPE_CATEGORY.equals(pdtDo.getNodeType())) {
// 分类下有子分类或大类时不可删除
// boolean exists = materialProductMapper.exists(Wrappers.lambdaQuery(MaterialProductDO.class)
// .like(MaterialProductDO::getIdPath, id)
// .ne(MaterialProductDO::getId, id));
boolean exists = materialProductMapper.exists(Wrappers.lambdaQuery(MaterialProductDO.class)
.eq(MaterialProductDO::getParentId, id));
if (exists) throw exception(MATERIAL_CATEGORY_EXISTS_CHILDREN);
}
// 大类
else {
// 大类下批次时不可删除 TODO 以及其他不可删除的情况
}
materialProductMapper.deleteById(id);
}