fix:新增物料批次接口及批次拆分及接口。
This commit is contained in:
@@ -171,25 +171,30 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode DEVICE_CONFIG_FLOW_NOT_EXISTS = new ErrorCode(1_032_150_000, "设备通用流程配置不存在");
|
ErrorCode DEVICE_CONFIG_FLOW_NOT_EXISTS = new ErrorCode(1_032_150_000, "设备通用流程配置不存在");
|
||||||
|
|
||||||
// -------------物料试剂-------------
|
// -------------物料试剂-------------
|
||||||
ErrorCode MATERIAL_INFOMATION_NOT_EXISTS = new ErrorCode(1_032_150_000, "试剂耗材不存在");
|
ErrorCode MATERIAL_INFOMATION_NOT_EXISTS = new ErrorCode(1_032_160_000, "试剂耗材不存在");
|
||||||
ErrorCode MATERIAL_PRODUCT_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料大类不存在");
|
ErrorCode MATERIAL_PRODUCT_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料分类/大类不存在");
|
||||||
ErrorCode MATERIAL_PRODUCT_CODE_EXISTED = new ErrorCode(1_032_160_000, "物料大类编码重复");
|
ErrorCode MATERIAL_PRODUCT_CODE_EXISTED = new ErrorCode(1_032_160_000, "物料大类编码重复");
|
||||||
ErrorCode MATERIAL_LIFECYCLE_DETAIL_NOT_EXISTS = new ErrorCode(1_032_150_000, "物料通用流程明细不存在");
|
ErrorCode MATERIAL_CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_032_160_000, "分类下含有子分类或物料大类,不可删除");
|
||||||
ErrorCode MATERIAL_LIFECYCLE_NOT_EXISTS = new ErrorCode(1_032_150_000, "物料通用流程不存在");
|
ErrorCode MATERIAL_LIFECYCLE_DETAIL_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料通用流程明细不存在");
|
||||||
|
ErrorCode MATERIAL_LIFECYCLE_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料通用流程不存在");
|
||||||
|
|
||||||
ErrorCode MATERIAL_BATCH_NOT_EXISTS = new ErrorCode(1_032_150_000, "物料批次不存在");
|
ErrorCode MATERIAL_BATCH_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料批次不存在");
|
||||||
ErrorCode MATERIAL_BATCH_ASSIGN_NOT_EXISTS = new ErrorCode(1_032_150_000, "物料批次分发不存在");
|
ErrorCode MATERIAL_BATCH_ASSIGN_END = new ErrorCode(1_032_160_000, "物料批次已拆分,不可操作");
|
||||||
ErrorCode MATERIAL_INVENTORY_INBOUND_NOT_EXISTS = new ErrorCode(1_032_150_000, "入库,出库不存在");
|
ErrorCode GONGDUAN_BELONG_MATERIAL_BATCH_NOT_EQUAL = new ErrorCode(1_032_160_000, "工段所属的物料批次不一致");
|
||||||
ErrorCode MATERIAL_INVENTORY_INBOUND_DETAIL_NOT_EXISTS = new ErrorCode(1_032_150_000, "入库明细,出库明细等不存在");
|
ErrorCode GONGDUAN_QUANTITY_MATERIAL_BATCH_NOT_EQUAL = new ErrorCode(1_032_160_000, "工段累加数量和批次数量不一致");
|
||||||
|
|
||||||
ErrorCode SYSTEM_VERSION_MANAGEMENT_NOT_EXISTS = new ErrorCode(1_032_150_000, "客户端版本管理不存在");
|
ErrorCode MATERIAL_BATCH_ASSIGN_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料批次分发不存在");
|
||||||
|
ErrorCode MATERIAL_INVENTORY_INBOUND_NOT_EXISTS = new ErrorCode(1_032_160_000, "入库,出库不存在");
|
||||||
|
ErrorCode MATERIAL_INVENTORY_INBOUND_DETAIL_NOT_EXISTS = new ErrorCode(1_032_160_000, "入库明细,出库明细等不存在");
|
||||||
|
|
||||||
ErrorCode MATERIAL_LOCATION_NOT_EXISTS = new ErrorCode(1_032_150_000, "存放位置不存在");
|
ErrorCode SYSTEM_VERSION_MANAGEMENT_NOT_EXISTS = new ErrorCode(1_032_160_000, "客户端版本管理不存在");
|
||||||
ErrorCode MATERIAL_INVENTORY_CHECK_NOT_EXISTS = new ErrorCode(1_032_150_000, "库存盘点不存在");
|
|
||||||
ErrorCode MATERIAL_INVENTORY_CHECK_BATCH_NOT_EXISTS = new ErrorCode(1_032_150_000, "库存盘点项不存在");
|
ErrorCode MATERIAL_LOCATION_NOT_EXISTS = new ErrorCode(1_032_160_000, "存放位置不存在");
|
||||||
ErrorCode MATERIAL_INVENTORY_CHECK_DETAIL_NOT_EXISTS = new ErrorCode(1_032_150_000, "库存盘点明细不存在");
|
ErrorCode MATERIAL_INVENTORY_CHECK_NOT_EXISTS = new ErrorCode(1_032_160_000, "库存盘点不存在");
|
||||||
ErrorCode MATERIAL_INVENTORY_OUTBOUND_NOT_EXISTS = new ErrorCode(1_032_150_000, "出库不存在");
|
ErrorCode MATERIAL_INVENTORY_CHECK_BATCH_NOT_EXISTS = new ErrorCode(1_032_160_000, "库存盘点项不存在");
|
||||||
ErrorCode MATERIAL_INVENTORY_OUTBOUND_DETAIL_NOT_EXISTS = new ErrorCode(1_032_150_000, "出库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等不存在");
|
ErrorCode MATERIAL_INVENTORY_CHECK_DETAIL_NOT_EXISTS = new ErrorCode(1_032_160_000, "库存盘点明细不存在");
|
||||||
|
ErrorCode MATERIAL_INVENTORY_OUTBOUND_NOT_EXISTS = new ErrorCode(1_032_160_000, "出库不存在");
|
||||||
|
ErrorCode MATERIAL_INVENTORY_OUTBOUND_DETAIL_NOT_EXISTS = new ErrorCode(1_032_160_000, "出库明细,出库明细,含领用出库、退货出库、盘亏出库、销毁出库等不存在");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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.controller.vo.MaterialBatchSaveReqVO;
|
||||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO;
|
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.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 org.springframework.web.bind.annotation.*;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -35,7 +37,7 @@ import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 物料批次")
|
@Tag(name = "管理后台 - 物料批次")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/material-batch")
|
@RequestMapping("/qms/resource/material-batch")
|
||||||
@Validated
|
@Validated
|
||||||
public class MaterialBatchController implements BusinessControllerMarker {
|
public class MaterialBatchController implements BusinessControllerMarker {
|
||||||
|
|
||||||
@@ -45,15 +47,15 @@ public class MaterialBatchController implements BusinessControllerMarker {
|
|||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建物料批次")
|
@Operation(summary = "创建物料批次")
|
||||||
@PreAuthorize("@ss.hasPermission('qms:material-batch:create')")
|
// @PreAuthorize("@ss.hasPermission('qms:material-batch:create')")
|
||||||
public CommonResult<MaterialBatchRespVO> createMaterialBatch(@Valid @RequestBody MaterialBatchSaveReqVO createReqVO) {
|
public CommonResult<MaterialBatchRespVO> createMaterialBatch(@Validated(AddGroup.class) @RequestBody MaterialBatchSaveReqVO createReqVO) {
|
||||||
return success(materialBatchService.createMaterialBatch(createReqVO));
|
return success(materialBatchService.createMaterialBatch(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新物料批次")
|
@Operation(summary = "更新物料批次")
|
||||||
@PreAuthorize("@ss.hasPermission('qms:material-batch:update')")
|
// @PreAuthorize("@ss.hasPermission('qms:material-batch:update')")
|
||||||
public CommonResult<Boolean> updateMaterialBatch(@Valid @RequestBody MaterialBatchSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateMaterialBatch(@Validated(UpdateGroup.class) @RequestBody MaterialBatchSaveReqVO updateReqVO) {
|
||||||
materialBatchService.updateMaterialBatch(updateReqVO);
|
materialBatchService.updateMaterialBatch(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
@@ -61,7 +63,7 @@ public class MaterialBatchController implements BusinessControllerMarker {
|
|||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除物料批次")
|
@Operation(summary = "删除物料批次")
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@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) {
|
public CommonResult<Boolean> deleteMaterialBatch(@RequestParam("id") Long id) {
|
||||||
materialBatchService.deleteMaterialBatch(id);
|
materialBatchService.deleteMaterialBatch(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -70,7 +72,7 @@ public class MaterialBatchController implements BusinessControllerMarker {
|
|||||||
@DeleteMapping("/delete-list")
|
@DeleteMapping("/delete-list")
|
||||||
@Parameter(name = "ids", description = "编号", required = true)
|
@Parameter(name = "ids", description = "编号", required = true)
|
||||||
@Operation(summary = "批量删除物料批次")
|
@Operation(summary = "批量删除物料批次")
|
||||||
@PreAuthorize("@ss.hasPermission('qms:material-batch:delete')")
|
// @PreAuthorize("@ss.hasPermission('qms:material-batch:delete')")
|
||||||
public CommonResult<Boolean> deleteMaterialBatchList(@RequestBody BatchDeleteReqVO req) {
|
public CommonResult<Boolean> deleteMaterialBatchList(@RequestBody BatchDeleteReqVO req) {
|
||||||
materialBatchService.deleteMaterialBatchListByIds(req.getIds());
|
materialBatchService.deleteMaterialBatchListByIds(req.getIds());
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -79,7 +81,7 @@ public class MaterialBatchController implements BusinessControllerMarker {
|
|||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得物料批次")
|
@Operation(summary = "获得物料批次")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@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) {
|
public CommonResult<MaterialBatchRespVO> getMaterialBatch(@RequestParam("id") Long id) {
|
||||||
MaterialBatchDO materialBatch = materialBatchService.getMaterialBatch(id);
|
MaterialBatchDO materialBatch = materialBatchService.getMaterialBatch(id);
|
||||||
return success(BeanUtils.toBean(materialBatch, MaterialBatchRespVO.class));
|
return success(BeanUtils.toBean(materialBatch, MaterialBatchRespVO.class));
|
||||||
@@ -87,7 +89,7 @@ public class MaterialBatchController implements BusinessControllerMarker {
|
|||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得物料批次分页")
|
@Operation(summary = "获得物料批次分页")
|
||||||
@PreAuthorize("@ss.hasPermission('qms:material-batch:query')")
|
// @PreAuthorize("@ss.hasPermission('qms:material-batch:query')")
|
||||||
public CommonResult<PageResult<MaterialBatchRespVO>> getMaterialBatchPage(@Valid MaterialBatchPageReqVO pageReqVO) {
|
public CommonResult<PageResult<MaterialBatchRespVO>> getMaterialBatchPage(@Valid MaterialBatchPageReqVO pageReqVO) {
|
||||||
PageResult<MaterialBatchDO> pageResult = materialBatchService.getMaterialBatchPage(pageReqVO);
|
PageResult<MaterialBatchDO> pageResult = materialBatchService.getMaterialBatchPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, MaterialBatchRespVO.class));
|
return success(BeanUtils.toBean(pageResult, MaterialBatchRespVO.class));
|
||||||
@@ -106,4 +108,11 @@ public class MaterialBatchController implements BusinessControllerMarker {
|
|||||||
BeanUtils.toBean(list, MaterialBatchRespVO.class));
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -62,6 +62,7 @@ public class MaterialProductController extends AbstractFileUploadController impl
|
|||||||
return success(materialProductService.getMaterialCategoryTree());
|
return success(materialProductService.getMaterialCategoryTree());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
@GetMapping("/orig-material/{code}")
|
@GetMapping("/orig-material/{code}")
|
||||||
@Operation(summary = "根据物料编码获取外部系统原始物料")
|
@Operation(summary = "根据物料编码获取外部系统原始物料")
|
||||||
public CommonResult<Object> getOriginalMaterial(@PathVariable String code) {
|
public CommonResult<Object> getOriginalMaterial(@PathVariable String code) {
|
||||||
@@ -84,18 +85,18 @@ public class MaterialProductController extends AbstractFileUploadController impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PutMapping("/update")
|
// @PutMapping("/update")
|
||||||
@Operation(summary = "更新物料")
|
// @Operation(summary = "更新物料")
|
||||||
@PreAuthorize("@ss.hasPermission('qms:material-product:update')")
|
// @PreAuthorize("@ss.hasPermission('qms:material-product:update')")
|
||||||
public CommonResult<Boolean> updateMaterialProduct(@Valid @RequestBody MaterialProductSaveReqVO updateReqVO) {
|
// public CommonResult<Boolean> updateMaterialProduct(@Valid @RequestBody MaterialProductSaveReqVO updateReqVO) {
|
||||||
materialProductService.updateMaterialProduct(updateReqVO);
|
// materialProductService.updateMaterialProduct(updateReqVO);
|
||||||
return success(true);
|
// return success(true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除物料")
|
@Operation(summary = "删除物料分类或大类")
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@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) {
|
public CommonResult<Boolean> deleteMaterialProduct(@RequestParam("id") Long id) {
|
||||||
materialProductService.deleteMaterialProduct(id);
|
materialProductService.deleteMaterialProduct(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.zt.plat.module.qms.resource.material.controller.vo;
|
package com.zt.plat.module.qms.resource.material.controller.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@@ -20,8 +22,8 @@ public class MaterialBatchPageReqVO extends PageParam {
|
|||||||
@Schema(description = "批次编号")
|
@Schema(description = "批次编号")
|
||||||
private String batchNo;
|
private String batchNo;
|
||||||
|
|
||||||
@Schema(description = "总数量")
|
// @Schema(description = "总数量")
|
||||||
private String inboundQuantity;
|
// private BigDecimal inboundQuantity;
|
||||||
|
|
||||||
@Schema(description = "存放位置描述")
|
@Schema(description = "存放位置描述")
|
||||||
private String location;
|
private String location;
|
||||||
@@ -37,6 +39,12 @@ public class MaterialBatchPageReqVO extends PageParam {
|
|||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
private LocalDate[] dueDate;
|
private LocalDate[] dueDate;
|
||||||
|
|
||||||
|
@Schema(description = "分配部门id")
|
||||||
|
private Long assignDepartmentId;
|
||||||
|
|
||||||
|
@Schema(description = "分配部门名称")
|
||||||
|
private String assignDepartmentName;
|
||||||
|
|
||||||
@Schema(description = "验收状态", example = "1")
|
@Schema(description = "验收状态", example = "1")
|
||||||
private String acceptanceStatus;
|
private String acceptanceStatus;
|
||||||
|
|
||||||
@@ -46,8 +54,8 @@ public class MaterialBatchPageReqVO extends PageParam {
|
|||||||
@Schema(description = "检化验状态,NOT_STARTED-未开始,IN_PROGRESS-进行中,PASSED-通过,NOT_PASSED-未通过", example = "2")
|
@Schema(description = "检化验状态,NOT_STARTED-未开始,IN_PROGRESS-进行中,PASSED-通过,NOT_PASSED-未通过", example = "2")
|
||||||
private String assayStatus;
|
private String assayStatus;
|
||||||
|
|
||||||
@Schema(description = "检化验结果")
|
// @Schema(description = "检化验结果")
|
||||||
private String assayResult;
|
// private String assayResult;
|
||||||
|
|
||||||
@Schema(description = "所属部门")
|
@Schema(description = "所属部门")
|
||||||
private String systemDepartmentCode;
|
private String systemDepartmentCode;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import com.alibaba.excel.annotation.*;
|
import com.alibaba.excel.annotation.*;
|
||||||
@@ -17,6 +18,10 @@ public class MaterialBatchRespVO {
|
|||||||
@ExcelProperty("主键")
|
@ExcelProperty("主键")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "父id,为0时是批次,不为0时是工段", example = "1035")
|
||||||
|
@ExcelProperty("父id,为0时是批次,不为0时是工段")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
@Schema(description = "物料大类id", example = "9381")
|
@Schema(description = "物料大类id", example = "9381")
|
||||||
@ExcelProperty("物料大类id")
|
@ExcelProperty("物料大类id")
|
||||||
private Long productId;
|
private Long productId;
|
||||||
@@ -27,7 +32,7 @@ public class MaterialBatchRespVO {
|
|||||||
|
|
||||||
@Schema(description = "总数量")
|
@Schema(description = "总数量")
|
||||||
@ExcelProperty("总数量")
|
@ExcelProperty("总数量")
|
||||||
private String inboundQuantity;
|
private BigDecimal inboundQuantity;
|
||||||
|
|
||||||
@Schema(description = "存放位置描述")
|
@Schema(description = "存放位置描述")
|
||||||
@ExcelProperty("存放位置描述")
|
@ExcelProperty("存放位置描述")
|
||||||
@@ -45,6 +50,14 @@ public class MaterialBatchRespVO {
|
|||||||
@ExcelProperty("到期日期")
|
@ExcelProperty("到期日期")
|
||||||
private LocalDate dueDate;
|
private LocalDate dueDate;
|
||||||
|
|
||||||
|
@Schema(description = "分配部门id")
|
||||||
|
@ExcelProperty("分配部门id")
|
||||||
|
private Long assignDepartmentId;
|
||||||
|
|
||||||
|
@Schema(description = "分配部门名称")
|
||||||
|
@ExcelProperty("分配部门名称")
|
||||||
|
private String assignDepartmentName;
|
||||||
|
|
||||||
@Schema(description = "验收状态", example = "1")
|
@Schema(description = "验收状态", example = "1")
|
||||||
@ExcelProperty("验收状态")
|
@ExcelProperty("验收状态")
|
||||||
private String acceptanceStatus;
|
private String acceptanceStatus;
|
||||||
|
|||||||
@@ -1,26 +1,39 @@
|
|||||||
package com.zt.plat.module.qms.resource.material.controller.vo;
|
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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import jakarta.validation.constraints.Min;
|
||||||
import jakarta.validation.constraints.*;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import jakarta.validation.constraints.Null;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 物料批次新增/修改 Request VO")
|
@Schema(description = "管理后台 - 物料批次新增/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class MaterialBatchSaveReqVO {
|
public class MaterialBatchSaveReqVO {
|
||||||
|
|
||||||
|
@Null(groups = AddGroup.class, message = "新增数据 ID 必须为空")
|
||||||
|
@NotNull(groups = UpdateGroup.class, message = "修改数据 ID 不能为空")
|
||||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "9716")
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "9716")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "父id,为0时是批次,不为0时是工段", example = "1035")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
@Schema(description = "物料大类id", example = "9381")
|
@Schema(description = "物料大类id", example = "9381")
|
||||||
|
@NotNull(groups = AddGroup.class, message = "物料大类 ID 不能为空")
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
@Schema(description = "批次编号")
|
// @Schema(description = "批次编号")
|
||||||
private String batchNo;
|
// private String batchNo;
|
||||||
|
|
||||||
@Schema(description = "总数量")
|
@Schema(description = "总数量")
|
||||||
private String inboundQuantity;
|
@NotNull(groups = AddGroup.class, message = "总数量不能为空")
|
||||||
|
@Min(value = 0, message = "总数量不能小于0")
|
||||||
|
private BigDecimal inboundQuantity;
|
||||||
|
|
||||||
@Schema(description = "存放位置描述")
|
@Schema(description = "存放位置描述")
|
||||||
private String location;
|
private String location;
|
||||||
@@ -29,22 +42,29 @@ public class MaterialBatchSaveReqVO {
|
|||||||
private Long supplierId;
|
private Long supplierId;
|
||||||
|
|
||||||
@Schema(description = "生产日期")
|
@Schema(description = "生产日期")
|
||||||
|
@NotNull(groups = AddGroup.class, message = "生产日期不能为空")
|
||||||
private LocalDate manufacturerDate;
|
private LocalDate manufacturerDate;
|
||||||
|
|
||||||
@Schema(description = "到期日期")
|
@Schema(description = "到期日期")
|
||||||
private LocalDate dueDate;
|
private LocalDate dueDate;
|
||||||
|
|
||||||
@Schema(description = "验收状态", example = "1")
|
@Schema(description = "分配部门id")
|
||||||
private String acceptanceStatus;
|
private Long assignDepartmentId;
|
||||||
|
|
||||||
|
@Schema(description = "分配部门名称")
|
||||||
|
private String assignDepartmentName;
|
||||||
|
|
||||||
|
// @Schema(description = "验收状态", example = "1")
|
||||||
|
// private String acceptanceStatus;
|
||||||
|
|
||||||
@Schema(description = "是否检化验,1-是,0-否")
|
@Schema(description = "是否检化验,1-是,0-否")
|
||||||
private Integer assayFlag;
|
private Integer assayFlag;
|
||||||
|
|
||||||
@Schema(description = "检化验状态,NOT_STARTED-未开始,IN_PROGRESS-进行中,PASSED-通过,NOT_PASSED-未通过", example = "2")
|
// @Schema(description = "检化验状态,NOT_STARTED-未开始,IN_PROGRESS-进行中,PASSED-通过,NOT_PASSED-未通过", example = "IN_PROGRESS")
|
||||||
private String assayStatus;
|
// private String assayStatus;
|
||||||
|
|
||||||
@Schema(description = "检化验结果")
|
// @Schema(description = "检化验结果")
|
||||||
private String assayResult;
|
// private String assayResult;
|
||||||
|
|
||||||
@Schema(description = "所属部门")
|
@Schema(description = "所属部门")
|
||||||
private String systemDepartmentCode;
|
private String systemDepartmentCode;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import lombok.*;
|
|||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
|
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,6 +32,11 @@ public class MaterialBatchDO extends BusinessBaseDO {
|
|||||||
*/
|
*/
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 父id,为0时是批次,不为0时是工段
|
||||||
|
*/
|
||||||
|
@TableField("PRN_ID")
|
||||||
|
private Long parentId;
|
||||||
/**
|
/**
|
||||||
* 物料大类id
|
* 物料大类id
|
||||||
*/
|
*/
|
||||||
@@ -45,7 +51,7 @@ public class MaterialBatchDO extends BusinessBaseDO {
|
|||||||
* 总数量
|
* 总数量
|
||||||
*/
|
*/
|
||||||
@TableField("INB_QTY")
|
@TableField("INB_QTY")
|
||||||
private String inboundQuantity;
|
private BigDecimal inboundQuantity;
|
||||||
/**
|
/**
|
||||||
* 存放位置描述
|
* 存放位置描述
|
||||||
*/
|
*/
|
||||||
@@ -66,6 +72,16 @@ public class MaterialBatchDO extends BusinessBaseDO {
|
|||||||
*/
|
*/
|
||||||
@TableField("DUE_DT")
|
@TableField("DUE_DT")
|
||||||
private LocalDate dueDate;
|
private LocalDate dueDate;
|
||||||
|
/**
|
||||||
|
* 分配部门id
|
||||||
|
*/
|
||||||
|
@TableField("ASN_DEPT_ID")
|
||||||
|
private Long assignDepartmentId;
|
||||||
|
/**
|
||||||
|
* 分配部门名称
|
||||||
|
*/
|
||||||
|
@TableField("ASN_DEPT_NAME")
|
||||||
|
private String assignDepartmentName;
|
||||||
/**
|
/**
|
||||||
* 验收状态
|
* 验收状态
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,16 +18,17 @@ public interface MaterialBatchMapper extends BaseMapperX<MaterialBatchDO> {
|
|||||||
default PageResult<MaterialBatchDO> selectPage(MaterialBatchPageReqVO reqVO) {
|
default PageResult<MaterialBatchDO> selectPage(MaterialBatchPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<MaterialBatchDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<MaterialBatchDO>()
|
||||||
.eqIfPresent(MaterialBatchDO::getProductId, reqVO.getProductId())
|
.eqIfPresent(MaterialBatchDO::getProductId, reqVO.getProductId())
|
||||||
.eqIfPresent(MaterialBatchDO::getBatchNo, reqVO.getBatchNo())
|
.likeIfPresent(MaterialBatchDO::getBatchNo, reqVO.getBatchNo())
|
||||||
.eqIfPresent(MaterialBatchDO::getInboundQuantity, reqVO.getInboundQuantity())
|
.likeIfPresent(MaterialBatchDO::getLocation, reqVO.getLocation())
|
||||||
.eqIfPresent(MaterialBatchDO::getLocation, reqVO.getLocation())
|
|
||||||
.eqIfPresent(MaterialBatchDO::getSupplierId, reqVO.getSupplierId())
|
.eqIfPresent(MaterialBatchDO::getSupplierId, reqVO.getSupplierId())
|
||||||
.betweenIfPresent(MaterialBatchDO::getManufacturerDate, reqVO.getManufacturerDate())
|
.betweenIfPresent(MaterialBatchDO::getManufacturerDate, reqVO.getManufacturerDate())
|
||||||
.betweenIfPresent(MaterialBatchDO::getDueDate, reqVO.getDueDate())
|
.betweenIfPresent(MaterialBatchDO::getDueDate, reqVO.getDueDate())
|
||||||
|
.eqIfPresent(MaterialBatchDO::getAssignDepartmentId, reqVO.getAssignDepartmentId())
|
||||||
|
.likeIfPresent(MaterialBatchDO::getAssignDepartmentName, reqVO.getAssignDepartmentName())
|
||||||
.eqIfPresent(MaterialBatchDO::getAcceptanceStatus, reqVO.getAcceptanceStatus())
|
.eqIfPresent(MaterialBatchDO::getAcceptanceStatus, reqVO.getAcceptanceStatus())
|
||||||
.eqIfPresent(MaterialBatchDO::getAssayFlag, reqVO.getAssayFlag())
|
.eqIfPresent(MaterialBatchDO::getAssayFlag, reqVO.getAssayFlag())
|
||||||
.eqIfPresent(MaterialBatchDO::getAssayStatus, reqVO.getAssayStatus())
|
.eqIfPresent(MaterialBatchDO::getAssayStatus, reqVO.getAssayStatus())
|
||||||
.eqIfPresent(MaterialBatchDO::getAssayResult, reqVO.getAssayResult())
|
//.eqIfPresent(MaterialBatchDO::getAssayResult, reqVO.getAssayResult())
|
||||||
.eqIfPresent(MaterialBatchDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
|
.eqIfPresent(MaterialBatchDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
|
||||||
.eqIfPresent(MaterialBatchDO::getRemark, reqVO.getRemark())
|
.eqIfPresent(MaterialBatchDO::getRemark, reqVO.getRemark())
|
||||||
.betweenIfPresent(MaterialBatchDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(MaterialBatchDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
|||||||
@@ -61,4 +61,11 @@ public interface MaterialBatchService {
|
|||||||
*/
|
*/
|
||||||
PageResult<MaterialBatchDO> getMaterialBatchPage(MaterialBatchPageReqVO pageReqVO);
|
PageResult<MaterialBatchDO> getMaterialBatchPage(MaterialBatchPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次工段拆分
|
||||||
|
*
|
||||||
|
* @param createReqVOs 创建信息
|
||||||
|
* @return 工段编号
|
||||||
|
*/
|
||||||
|
List<MaterialBatchRespVO> assignMaterialBatchGongduan(@Valid List<MaterialBatchSaveReqVO> createReqVOs);
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,31 @@
|
|||||||
package com.zt.plat.module.qms.resource.material.service;
|
package com.zt.plat.module.qms.resource.material.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.google.protobuf.ServiceException;
|
||||||
|
import com.zt.plat.framework.common.exception.ErrorCode;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import com.zt.plat.module.qms.core.code.SequenceUtil;
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO;
|
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchRespVO;
|
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchRespVO;
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchSaveReqVO;
|
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.dal.dataobject.MaterialBatchDO;
|
||||||
|
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO;
|
||||||
|
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO;
|
||||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialBatchMapper;
|
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialBatchMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*;
|
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*;
|
||||||
@@ -28,20 +41,39 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MaterialBatchMapper materialBatchMapper;
|
private MaterialBatchMapper materialBatchMapper;
|
||||||
|
@Autowired
|
||||||
|
private SequenceUtil sequenceUtil;
|
||||||
|
@Autowired
|
||||||
|
private MaterialProductService materialProductService;
|
||||||
|
|
||||||
|
private final String sequenceKey = "QMS_MATERIAL_BATCH_NO";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialBatchRespVO createMaterialBatch(MaterialBatchSaveReqVO createReqVO) {
|
public MaterialBatchRespVO createMaterialBatch(MaterialBatchSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
MaterialBatchDO materialBatch = BeanUtils.toBean(createReqVO, MaterialBatchDO.class);
|
MaterialBatchDO mtrlBat = BeanUtils.toBean(createReqVO, MaterialBatchDO.class);
|
||||||
materialBatchMapper.insert(materialBatch);
|
|
||||||
|
// 批次编号
|
||||||
|
mtrlBat.setBatchNo(sequenceUtil.genCode(sequenceKey));
|
||||||
|
|
||||||
|
mtrlBat.setParentId(0L);
|
||||||
|
materialBatchMapper.insert(mtrlBat);
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
return BeanUtils.toBean(materialBatch, MaterialBatchRespVO.class);
|
return BeanUtils.toBean(mtrlBat, MaterialBatchRespVO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMaterialBatch(MaterialBatchSaveReqVO updateReqVO) {
|
public void updateMaterialBatch(MaterialBatchSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateMaterialBatchExists(updateReqVO.getId());
|
Long reqId = updateReqVO.getId();
|
||||||
|
validateMaterialBatchExists(reqId);
|
||||||
|
|
||||||
|
// 已经拆分工段的不可编辑
|
||||||
|
List<MaterialBatchDO> asnDOs = materialBatchMapper.selectList(Wrappers.lambdaQuery(MaterialBatchDO.class)
|
||||||
|
.eq(MaterialBatchDO::getParentId, reqId));
|
||||||
|
if (CollUtil.isNotEmpty(asnDOs)) throw exception(MATERIAL_BATCH_ASSIGN_END);
|
||||||
|
|
||||||
// 更新
|
// 更新
|
||||||
MaterialBatchDO updateObj = BeanUtils.toBean(updateReqVO, MaterialBatchDO.class);
|
MaterialBatchDO updateObj = BeanUtils.toBean(updateReqVO, MaterialBatchDO.class);
|
||||||
materialBatchMapper.updateById(updateObj);
|
materialBatchMapper.updateById(updateObj);
|
||||||
@@ -51,6 +83,12 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
|
|||||||
public void deleteMaterialBatch(Long id) {
|
public void deleteMaterialBatch(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateMaterialBatchExists(id);
|
validateMaterialBatchExists(id);
|
||||||
|
|
||||||
|
// 已经拆分的批次不可删除
|
||||||
|
List<MaterialBatchDO> asnDOs = materialBatchMapper.selectList(Wrappers.lambdaQuery(MaterialBatchDO.class)
|
||||||
|
.eq(MaterialBatchDO::getParentId, id));
|
||||||
|
if (CollUtil.isNotEmpty(asnDOs)) throw exception(MATERIAL_BATCH_ASSIGN_END);
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
materialBatchMapper.deleteById(id);
|
materialBatchMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
@@ -59,6 +97,10 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
|
|||||||
public void deleteMaterialBatchListByIds(List<Long> ids) {
|
public void deleteMaterialBatchListByIds(List<Long> ids) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateMaterialBatchExists(ids);
|
validateMaterialBatchExists(ids);
|
||||||
|
// 已经拆分的批次不可删除
|
||||||
|
List<MaterialBatchDO> asnDOs = materialBatchMapper.selectList(Wrappers.lambdaQuery(MaterialBatchDO.class)
|
||||||
|
.in(MaterialBatchDO::getParentId, ids));
|
||||||
|
if (CollUtil.isNotEmpty(asnDOs)) throw exception(MATERIAL_BATCH_ASSIGN_END);
|
||||||
// 删除
|
// 删除
|
||||||
materialBatchMapper.deleteByIds(ids);
|
materialBatchMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
@@ -86,4 +128,45 @@ public class MaterialBatchServiceImpl implements MaterialBatchService {
|
|||||||
return materialBatchMapper.selectPage(pageReqVO);
|
return materialBatchMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次工段拆分
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<MaterialBatchRespVO> assignMaterialBatchGongduan(List<MaterialBatchSaveReqVO> createReqVOs) {
|
||||||
|
// 是否已经拆分过
|
||||||
|
Long batId = createReqVOs.get(0).getParentId();
|
||||||
|
List<MaterialBatchDO> asnDOs = materialBatchMapper.selectList(Wrappers.lambdaQuery(MaterialBatchDO.class)
|
||||||
|
.eq(MaterialBatchDO::getParentId, batId));
|
||||||
|
// 1. 所属的批次需要是同一个
|
||||||
|
Set<Long> pIds = createReqVOs.stream().map(MaterialBatchSaveReqVO::getParentId).collect(Collectors.toSet());
|
||||||
|
if (pIds.size() > 1) throw exception(GONGDUAN_BELONG_MATERIAL_BATCH_NOT_EQUAL);
|
||||||
|
|
||||||
|
// 2. 拆分后的数量要相等
|
||||||
|
MaterialBatchDO mtrlBat = materialBatchMapper.selectById(batId);
|
||||||
|
if (mtrlBat == null) throw exception(MATERIAL_BATCH_NOT_EXISTS);
|
||||||
|
|
||||||
|
BigDecimal total = BigDecimal.valueOf(0);
|
||||||
|
for (MaterialBatchSaveReqVO batAsn : createReqVOs) {
|
||||||
|
total = total.add(batAsn.getInboundQuantity());
|
||||||
|
}
|
||||||
|
if (!total.equals(mtrlBat.getInboundQuantity()))
|
||||||
|
throw exception(GONGDUAN_QUANTITY_MATERIAL_BATCH_NOT_EQUAL);
|
||||||
|
// 修改工段
|
||||||
|
if (CollUtil.isNotEmpty(asnDOs)) {
|
||||||
|
// 删除之前的拆分数据,TODO 需要检查是否可以删除
|
||||||
|
materialBatchMapper.delete(Wrappers.lambdaQuery(MaterialBatchDO.class)
|
||||||
|
.eq(MaterialBatchDO::getParentId, batId));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 保存工段
|
||||||
|
List<MaterialBatchDO> gongEts = createReqVOs.stream().map(
|
||||||
|
batAsn -> BeanUtils.toBean(batAsn, MaterialBatchDO.class)).toList();
|
||||||
|
materialBatchMapper.insertBatch(gongEts);
|
||||||
|
|
||||||
|
return gongEts.stream().map(
|
||||||
|
gong -> BeanUtils.toBean(gong, MaterialBatchRespVO.class)
|
||||||
|
).toList();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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.dataobject.MaterialProductDO;
|
||||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialProductMapper;
|
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialProductMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -180,10 +181,10 @@ public class MaterialProductServiceImpl implements MaterialProductService {
|
|||||||
.setStandardMaterialFlag(prnCtg.getStandardMaterialFlag())
|
.setStandardMaterialFlag(prnCtg.getStandardMaterialFlag())
|
||||||
.setStandardSolutionFlag(prnCtg.getStandardSolutionFlag());
|
.setStandardSolutionFlag(prnCtg.getStandardSolutionFlag());
|
||||||
}
|
}
|
||||||
|
|
||||||
materialProductMapper.insert(mtrl);
|
materialProductMapper.insert(mtrl);
|
||||||
return BeanUtils.toBean(mtrl, MaterialProductRespVO.class);
|
// 更新 idPath
|
||||||
}
|
|
||||||
|
} else {
|
||||||
// 修改
|
// 修改
|
||||||
MaterialProductDO origDO = materialProductMapper.selectById(reqId);
|
MaterialProductDO origDO = materialProductMapper.selectById(reqId);
|
||||||
if (origDO == null) throw exception(MATERIAL_PRODUCT_NOT_EXISTS);
|
if (origDO == null) throw exception(MATERIAL_PRODUCT_NOT_EXISTS);
|
||||||
@@ -193,6 +194,7 @@ public class MaterialProductServiceImpl implements MaterialProductService {
|
|||||||
return BeanUtils.toBean(mtrl, MaterialProductRespVO.class);
|
return BeanUtils.toBean(mtrl, MaterialProductRespVO.class);
|
||||||
}
|
}
|
||||||
// 父节点有变更时更新 idPath
|
// 父节点有变更时更新 idPath
|
||||||
|
}
|
||||||
String newIdPath = getIdPath(mtrl);
|
String newIdPath = getIdPath(mtrl);
|
||||||
mtrl.setIdPath(newIdPath);
|
mtrl.setIdPath(newIdPath);
|
||||||
materialProductMapper.updateById(mtrl);
|
materialProductMapper.updateById(mtrl);
|
||||||
@@ -210,9 +212,23 @@ public class MaterialProductServiceImpl implements MaterialProductService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMaterialProduct(Long id) {
|
public void deleteMaterialProduct(Long id) {
|
||||||
// 校验存在
|
MaterialProductDO pdtDo = materialProductMapper.selectById(id);
|
||||||
validateMaterialProductExists(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);
|
materialProductMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user