diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java index 000c79fd..8782d5d6 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInfomationController.java @@ -36,7 +36,7 @@ import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*; @Tag(name = "管理后台 - 物料实例") @RestController -@RequestMapping("/qms/material-infomation") +@RequestMapping("/qms/resource/material-infomation") @Validated public class MaterialInfomationController implements BusinessControllerMarker { @@ -80,12 +80,21 @@ public class MaterialInfomationController implements BusinessControllerMarker { @GetMapping("/get") @Operation(summary = "获得物料实例") @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('qms:material-infomation:query')") +// @PreAuthorize("@ss.hasPermission('qms:material-infomation:query')") public CommonResult getMaterialInfomation(@RequestParam("id") Long id) { MaterialInfomationDO materialInfomation = materialInfomationService.getMaterialInfomation(id); return success(BeanUtils.toBean(materialInfomation, MaterialInfomationRespVO.class)); } + @GetMapping("/get-by-code") + @Operation(summary = "根据物料编码获取物料") + @Parameter(name = "code", description = "编码", required = true, example = "SN001") +// @PreAuthorize("@ss.hasPermission('qms:material-infomation:query')") + public CommonResult getMaterialInfomationWithPdtInfoByInfCode(@RequestParam("code") String code) { + MaterialInfomationRespVO materialInfomation = materialInfomationService.getMaterialInfomationWithPdtInfoByInfCode(code); + return success(materialInfomation); + } + @GetMapping("/page") @Operation(summary = "获得物料实例分页") // @PreAuthorize("@ss.hasPermission('qms:material-infomation:query')") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryInboundDetailController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryInboundDetailController.java index 5f824992..930938bd 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryInboundDetailController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryInboundDetailController.java @@ -7,6 +7,7 @@ import com.zt.plat.framework.common.pojo.PageParam; import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO; import com.zt.plat.framework.common.util.object.BeanUtils; +import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore; import com.zt.plat.framework.excel.core.util.ExcelUtils; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailRespVO; @@ -33,20 +34,21 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RestController @RequestMapping("/qms/resource/material-inventory-inbound-detail") @Validated +@DeptDataPermissionIgnore(enable = "true") public class MaterialInventoryInboundDetailController implements BusinessControllerMarker { @Resource private MaterialInventoryInboundDetailService materialInventoryInboundDetailService; - @PostMapping("/create") +// @PostMapping("/create") @Operation(summary = "创建入库明细,验收入库、盘盈入库等") @PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound-detail:create')") public CommonResult createMaterialInventoryInboundDetail(@Valid @RequestBody MaterialInventoryInboundDetailSaveReqVO createReqVO) { return success(materialInventoryInboundDetailService.createMaterialInventoryInboundDetail(createReqVO)); } - @PutMapping("/update") +// @PutMapping("/update") @Operation(summary = "更新入库明细,验收入库、盘盈入库等") @PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound-detail:update')") public CommonResult updateMaterialInventoryInboundDetail(@Valid @RequestBody MaterialInventoryInboundDetailSaveReqVO updateReqVO) { @@ -54,7 +56,7 @@ public class MaterialInventoryInboundDetailController implements BusinessControl return success(true); } - @DeleteMapping("/delete") +// @DeleteMapping("/delete") @Operation(summary = "删除入库明细,验收入库、盘盈入库等") @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound-detail:delete')") @@ -63,7 +65,7 @@ public class MaterialInventoryInboundDetailController implements BusinessControl return success(true); } - @DeleteMapping("/delete-list") +// @DeleteMapping("/delete-list") @Parameter(name = "ids", description = "编号", required = true) @Operation(summary = "批量删除入库明细,验收入库、盘盈入库等") @PreAuthorize("@ss.hasPermission('qms:material-inventory-inbound-detail:delete')") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryOutboundController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryOutboundController.java new file mode 100644 index 00000000..8ee92d69 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryOutboundController.java @@ -0,0 +1,116 @@ +package com.zt.plat.module.qms.resource.material.controller.admin; + +import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog; +import com.zt.plat.framework.business.annotation.FileUploadController; +import com.zt.plat.framework.business.controller.AbstractFileUploadController; +import com.zt.plat.framework.business.interceptor.BusinessControllerMarker; +import com.zt.plat.framework.common.pojo.CommonResult; +import com.zt.plat.framework.common.pojo.PageParam; +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO; +import com.zt.plat.framework.common.util.object.BeanUtils; +import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore; +import com.zt.plat.framework.excel.core.util.ExcelUtils; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundPageReqVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundRespVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundSaveReqVO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryOutboundDO; +import com.zt.plat.module.qms.resource.material.service.MaterialInventoryOutboundService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.io.IOException; +import java.util.List; + +import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT; +import static com.zt.plat.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 物料出库") +@RestController +@RequestMapping("/qms/resource/material-inventory-outbound") +@Validated +@FileUploadController(source = "qms.materialinventoryoutbound") +@DeptDataPermissionIgnore(enable = "true") +public class MaterialInventoryOutboundController extends AbstractFileUploadController implements BusinessControllerMarker{ + + static { + FileUploadController annotation = MaterialInventoryOutboundController.class.getAnnotation(FileUploadController.class); + if (annotation != null) { + setFileUploadInfo(annotation); + } + } + + @Resource + private MaterialInventoryOutboundService materialInventoryOutboundService; + + @PostMapping("/add") + @Operation(summary = "新增物料出库") +// @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound:create')") + public CommonResult createMaterialInventoryOutbound(@Valid @RequestBody MaterialInventoryOutboundSaveReqVO createReqVO) { + return success(materialInventoryOutboundService.createMaterialInventoryOutbound(createReqVO)); + } + +// @PutMapping("/update") + @Operation(summary = "更新物料出库") + @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound:update')") + public CommonResult updateMaterialInventoryOutbound(@Valid @RequestBody MaterialInventoryOutboundSaveReqVO updateReqVO) { + materialInventoryOutboundService.updateMaterialInventoryOutbound(updateReqVO); + return success(true); + } + +// @DeleteMapping("/delete") + @Operation(summary = "删除物料出库") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound:delete')") + public CommonResult deleteMaterialInventoryOutbound(@RequestParam("id") Long id) { + materialInventoryOutboundService.deleteMaterialInventoryOutbound(id); + return success(true); + } + +// @DeleteMapping("/delete-list") + @Parameter(name = "ids", description = "编号", required = true) + @Operation(summary = "批量删除物料出库") + @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound:delete')") + public CommonResult deleteMaterialInventoryOutboundList(@RequestBody BatchDeleteReqVO req) { + materialInventoryOutboundService.deleteMaterialInventoryOutboundListByIds(req.getIds()); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得物料出库") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound:query')") + public CommonResult getMaterialInventoryOutbound(@RequestParam("id") Long id) { + MaterialInventoryOutboundDO materialInventoryOutbound = materialInventoryOutboundService.getMaterialInventoryOutbound(id); + return success(BeanUtils.toBean(materialInventoryOutbound, MaterialInventoryOutboundRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得物料出库分页") +// @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound:query')") + public CommonResult> getMaterialInventoryOutboundPage(@Valid MaterialInventoryOutboundPageReqVO pageReqVO) { + PageResult pageResult = materialInventoryOutboundService.getMaterialInventoryOutboundPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, MaterialInventoryOutboundRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出物料出库 Excel") + @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportMaterialInventoryOutboundExcel(@Valid MaterialInventoryOutboundPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = materialInventoryOutboundService.getMaterialInventoryOutboundPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "物料出库.xls", "数据", MaterialInventoryOutboundRespVO.class, + BeanUtils.toBean(list, MaterialInventoryOutboundRespVO.class)); + } + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryOutboundDetailController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryOutboundDetailController.java new file mode 100644 index 00000000..cf041b61 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryOutboundDetailController.java @@ -0,0 +1,106 @@ +package com.zt.plat.module.qms.resource.material.controller.admin; + +import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog; +import com.zt.plat.framework.business.interceptor.BusinessControllerMarker; +import com.zt.plat.framework.common.pojo.CommonResult; +import com.zt.plat.framework.common.pojo.PageParam; +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO; +import com.zt.plat.framework.common.util.object.BeanUtils; +import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore; +import com.zt.plat.framework.excel.core.util.ExcelUtils; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundDetailPageReqVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundDetailRespVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundDetailSaveReqVO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryOutboundDetailDO; +import com.zt.plat.module.qms.resource.material.service.MaterialInventoryOutboundDetailService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.io.IOException; +import java.util.List; + +import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT; +import static com.zt.plat.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 出库明细") +@RestController +@RequestMapping("/qms/resource/material-inventory-outbound-detail") +@Validated +@DeptDataPermissionIgnore(enable = "true") +public class MaterialInventoryOutboundDetailController implements BusinessControllerMarker{ + + @Resource + private MaterialInventoryOutboundDetailService materialInventoryOutboundDetailService; + + @PostMapping("/create") + @Operation(summary = "创建出库明细") + @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound-detail:create')") + public CommonResult createMaterialInventoryOutboundDetail(@Valid @RequestBody MaterialInventoryOutboundDetailSaveReqVO createReqVO) { + return success(materialInventoryOutboundDetailService.createMaterialInventoryOutboundDetail(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新出库明细") + @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound-detail:update')") + public CommonResult updateMaterialInventoryOutboundDetail(@Valid @RequestBody MaterialInventoryOutboundDetailSaveReqVO updateReqVO) { + materialInventoryOutboundDetailService.updateMaterialInventoryOutboundDetail(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除出库明细") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound-detail:delete')") + public CommonResult deleteMaterialInventoryOutboundDetail(@RequestParam("id") Long id) { + materialInventoryOutboundDetailService.deleteMaterialInventoryOutboundDetail(id); + return success(true); + } + + @DeleteMapping("/delete-list") + @Parameter(name = "ids", description = "编号", required = true) + @Operation(summary = "批量删除出库明细") + @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound-detail:delete')") + public CommonResult deleteMaterialInventoryOutboundDetailList(@RequestBody BatchDeleteReqVO req) { + materialInventoryOutboundDetailService.deleteMaterialInventoryOutboundDetailListByIds(req.getIds()); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得出库明细") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound-detail:query')") + public CommonResult getMaterialInventoryOutboundDetail(@RequestParam("id") Long id) { + MaterialInventoryOutboundDetailDO materialInventoryOutboundDetail = materialInventoryOutboundDetailService.getMaterialInventoryOutboundDetail(id); + return success(BeanUtils.toBean(materialInventoryOutboundDetail, MaterialInventoryOutboundDetailRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得出库明细分页") +// @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound-detail:query')") + public CommonResult> getOutboundDetailPageWithPdtInfo(@Valid MaterialInventoryOutboundDetailPageReqVO pageReqVO) { + PageResult pageResult = materialInventoryOutboundDetailService.getOutboundDetailPageWithMaterialInfo(pageReqVO); + return success(pageResult); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出出库明细 Excel") + @PreAuthorize("@ss.hasPermission('qms:material-inventory-outbound-detail:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportMaterialInventoryOutboundDetailExcel(@Valid MaterialInventoryOutboundDetailPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = materialInventoryOutboundDetailService.getMaterialInventoryOutboundDetailPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "出库明细.xls", "数据", MaterialInventoryOutboundDetailRespVO.class, + BeanUtils.toBean(list, MaterialInventoryOutboundDetailRespVO.class)); + } + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInfomationRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInfomationRespVO.java index 516d5faf..edd8be51 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInfomationRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInfomationRespVO.java @@ -26,10 +26,32 @@ public class MaterialInfomationRespVO { @ExcelProperty("批次id") private Long batchId; + @Schema(description = "批次编号") + @ExcelProperty("批次编号") + private String batchNo; + + @Schema(description = "工段id") + @ExcelProperty("工段id") + private Long gongduanId; + + @Schema(description = "工段部门id") + @ExcelProperty("工段部门id") + private Long assignDepartmentId; + /** + * 分配部门名称 + */ + @Schema(description = "工段分配部门名称") + @ExcelProperty("工段分配部门名称") + private String assignDepartmentName; + @Schema(description = "存放位置", example = "13603") @ExcelProperty("存放位置") private String locationId; + @Schema(description = "存放位置编码") + @ExcelProperty("存放位置编码") + private String locationCode; + @Schema(description = "编码") @ExcelProperty("编码") private String code; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryInboundSaveReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryInboundSaveReqVO.java index 55803265..6775bca2 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryInboundSaveReqVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryInboundSaveReqVO.java @@ -2,6 +2,7 @@ package com.zt.plat.module.qms.resource.material.controller.vo; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; import lombok.Data; import java.math.BigDecimal; @@ -18,6 +19,7 @@ public class MaterialInventoryInboundSaveReqVO { private String title; @Schema(description = "业务类型,【字典】【jy_material_in_bsn_type】验收入库、盘盈入库等", example = "2") + @NotNull(message = "业务类型不能为空") private String businessType; @Schema(description = "业务类型编码") diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundDetailPageReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundDetailPageReqVO.java new file mode 100644 index 00000000..5140c9db --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundDetailPageReqVO.java @@ -0,0 +1,39 @@ +package com.zt.plat.module.qms.resource.material.controller.vo; + +import com.zt.plat.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 出库明细分页 Request VO") +@Data +public class MaterialInventoryOutboundDetailPageReqVO extends PageParam { + + @Schema(description = "物料大类id", example = "13529") + private Long productId; + + @Schema(description = "出库单id", example = "13529") + private Long outboundId; + + @Schema(description = "物料实例id", example = "1502") + private Long infomationId; + + @Schema(description = "数量") + private BigDecimal quantity; + + @Schema(description = "所属部门") + private String systemDepartmentCode; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundDetailRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundDetailRespVO.java new file mode 100644 index 00000000..78b733eb --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundDetailRespVO.java @@ -0,0 +1,97 @@ +package com.zt.plat.module.qms.resource.material.controller.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 出库明细 Response VO") +@Data +@ExcelIgnoreUnannotated +public class MaterialInventoryOutboundDetailRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17148") + @ExcelProperty("主键") + private Long id; + + @Schema(description = "出库单id", example = "13529") + @ExcelProperty("出库单id") + private Long outboundId; + + // 批次 + @Schema(description = "批次id", example = "13529") + @ExcelProperty("批次id") + private Long batchId; + + @Schema(description = "批次编号") + @ExcelProperty("批次编号") + private String batchNo; + // 工段 + @Schema(description = "工段id", example = "13529") + @ExcelProperty("工段id") + private Long gongduanId; + + @Schema(description = "工段名称", example = "13529") + @ExcelProperty("工段名称") + private String assignDepartmentName; + + @Schema(description = "物料实例id", example = "1502") + @ExcelProperty("物料实例id") + private Long infomationId; + + @Schema(description = "物料编码") + @ExcelProperty("物料编码") + private String infomationCode; + + @Schema(description = "物料名称") + @ExcelProperty("物料名称") + private String infomationName; + + @Schema(description = "业务类型") + @ExcelProperty("业务类型") + private String businessType; + + @Schema(description = "存放位置名称") + @ExcelProperty("存放位置名称") + private String locationName; + + @Schema(description = "存放位置编码") + @ExcelProperty("存放位置编码") + private String locationCode; + + @Schema(description = "领用人id", example = "7209") + @ExcelProperty("领用人id") + private Long managerUserId; + + @Schema(description = "领用人", example = "张三") + @ExcelProperty("领用人") + private String managerUserName; + + @Schema(description = "数量") + @ExcelProperty("数量") + private BigDecimal quantity; + + @Schema(description = "所属部门") + @ExcelProperty("所属部门") + private String systemDepartmentCode; + + @Schema(description = "备注") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "创建者") + @ExcelProperty("创建者") + private Long creator; + + @Schema(description = "创建人名称") + @ExcelProperty("创建人名称") + private String creatorName; + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundDetailSaveReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundDetailSaveReqVO.java new file mode 100644 index 00000000..54bd3817 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundDetailSaveReqVO.java @@ -0,0 +1,30 @@ +package com.zt.plat.module.qms.resource.material.controller.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Schema(description = "管理后台 - 出库明细新增/修改 Request VO") +@Data +public class MaterialInventoryOutboundDetailSaveReqVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17148") + private Long id; + + @Schema(description = "出库单id", example = "13529") + private Long outboundId; + + @Schema(description = "物料实例id", example = "1502") + private Long infomationId; + + @Schema(description = "数量") + private BigDecimal quantity; + + @Schema(description = "所属部门") + private String systemDepartmentCode; + + @Schema(description = "备注") + private String remark; + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundPageReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundPageReqVO.java new file mode 100644 index 00000000..bff344b0 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundPageReqVO.java @@ -0,0 +1,67 @@ +package com.zt.plat.module.qms.resource.material.controller.vo; + +import com.zt.plat.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; +import java.util.List; + +import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 物料出库分页 Request VO") +@Data +public class MaterialInventoryOutboundPageReqVO extends PageParam { + + @Schema(description = "标题") + private String title; + + @Schema(description = "业务类型,领用出库、盘亏出库等", example = "2") + private String businessType; + + @Schema(description = "业务类型编码") + private String businessTypeCode; + + @Schema(description = "申请人") + private String applyUser; + + @Schema(description = "申请人id", example = "13273") + private Long applyUserId; + + @Schema(description = "申请部门") + private String applyDepartment; + + @Schema(description = "申请部门id", example = "845") + private Long applyDepartmentId; + + @Schema(description = "申请时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] applyTime; + + @Schema(description = "监督人") + private String superviseUser; + + @Schema(description = "监督人id", example = "14493") + private Long superviseUserId; + + @Schema(description = "流程实例id", example = "6208") + private String flowInstanceId; + + @Schema(description = "意见json") + private String commentJson; + + @Schema(description = "流程审批状态", example = "1") + private String flowStatus; + + @Schema(description = "所属部门") + private String systemDepartmentCode; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundRespVO.java new file mode 100644 index 00000000..229eff06 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundRespVO.java @@ -0,0 +1,83 @@ +package com.zt.plat.module.qms.resource.material.controller.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 物料出库 Response VO") +@Data +@ExcelIgnoreUnannotated +public class MaterialInventoryOutboundRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "10436") + @ExcelProperty("主键") + private Long id; + + @Schema(description = "标题") + @ExcelProperty("标题") + private String title; + + @Schema(description = "业务类型,领用出库、盘亏出库等", example = "2") + @ExcelProperty("业务类型,领用出库、盘亏出库等") + private String businessType; + + @Schema(description = "业务类型编码") + @ExcelProperty("业务类型编码") + private String businessTypeCode; + + @Schema(description = "申请人") + @ExcelProperty("申请人") + private String applyUser; + + @Schema(description = "申请人id", example = "13273") + @ExcelProperty("申请人id") + private Long applyUserId; + + @Schema(description = "申请部门") + @ExcelProperty("申请部门") + private String applyDepartment; + + @Schema(description = "申请部门id", example = "845") + @ExcelProperty("申请部门id") + private Long applyDepartmentId; + + @Schema(description = "申请时间") + @ExcelProperty("申请时间") + private LocalDateTime applyTime; + + @Schema(description = "监督人") + @ExcelProperty("监督人") + private String superviseUser; + + @Schema(description = "监督人id", example = "14493") + @ExcelProperty("监督人id") + private Long superviseUserId; + + @Schema(description = "流程实例id", example = "6208") + @ExcelProperty("流程实例id") + private String flowInstanceId; + + @Schema(description = "意见json") + @ExcelProperty("意见json") + private String commentJson; + + @Schema(description = "流程审批状态", example = "1") + @ExcelProperty("流程审批状态") + private String flowStatus; + + @Schema(description = "所属部门") + @ExcelProperty("所属部门") + private String systemDepartmentCode; + + @Schema(description = "备注") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundSaveReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundSaveReqVO.java new file mode 100644 index 00000000..943aec7a --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialInventoryOutboundSaveReqVO.java @@ -0,0 +1,68 @@ +package com.zt.plat.module.qms.resource.material.controller.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Null; +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.List; + +@Schema(description = "管理后台 - 物料出库新增/修改 Request VO") +@Data +public class MaterialInventoryOutboundSaveReqVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "10436") + private Long id; + + @Schema(description = "标题") + private String title; + + @Schema(description = "业务类型,领用出库、盘亏出库等", example = "2") + @NotNull(message = "业务类型不能为空") + private String businessType; + + @Schema(description = "业务类型编码") + private String businessTypeCode; + + @Schema(description = "申请人") + private String applyUser; + + @Schema(description = "申请人id", example = "13273") + @NotNull(message = "申请人id不能为空") + private Long applyUserId; + + @Schema(description = "申请部门") + private String applyDepartment; + + @Schema(description = "申请部门id", example = "845") + private Long applyDepartmentId; + + @Schema(description = "申请时间") + private LocalDateTime applyTime; + + @Schema(description = "监督人") + private String superviseUser; + + @Schema(description = "监督人id", example = "14493") + private Long superviseUserId; + + @Schema(description = "流程实例id", example = "6208") + private String flowInstanceId; + + @Schema(description = "意见json") + private String commentJson; + + @Schema(description = "流程审批状态", example = "1") + private String flowStatus; + + @Schema(description = "所属部门") + private String systemDepartmentCode; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "物料实例id集合") + private List infomationIds; + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInfomationDO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInfomationDO.java index 768b00a4..eb0f77ac 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInfomationDO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInfomationDO.java @@ -111,7 +111,7 @@ public class MaterialInfomationDO extends BusinessBaseDO { * 所属部门ID */ @TableField("MNGR_DEPT_ID") - private Integer managerDepartmentId; + private Long managerDepartmentId; /** * 领用人部门 */ diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInventoryOutboundDO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInventoryOutboundDO.java new file mode 100644 index 00000000..846ae96d --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInventoryOutboundDO.java @@ -0,0 +1,109 @@ +package com.zt.plat.module.qms.resource.material.dal.dataobject; + +import com.baomidou.mybatisplus.annotation.*; +import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO; +import lombok.*; + +import java.time.LocalDateTime; +/** +* 物料出库 DO +* +* @author 后台管理 +*/ +@TableName("t_mtrl_invt_outb") +@KeySequence("t_mtrl_invt_outb_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +/** +* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO +*/ +public class MaterialInventoryOutboundDO extends BusinessBaseDO { + + + + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + /** + * 标题 + */ + @TableField("TTL") + private String title; + /** + * 业务类型,领用出库、盘亏出库等 + */ + @TableField("BSN_TP") + private String businessType; + /** + * 业务类型编码 + */ + @TableField("BSN_TP_CD") + private String businessTypeCode; + /** + * 申请人 + */ + @TableField("APL_USER") + private String applyUser; + /** + * 申请人id + */ + @TableField("APL_USER_ID") + private Long applyUserId; + /** + * 申请部门 + */ + @TableField("APL_DEPT") + private String applyDepartment; + /** + * 申请部门id + */ + @TableField("APL_DEPT_ID") + private Long applyDepartmentId; + /** + * 申请时间 + */ + @TableField("APL_TM") + private LocalDateTime applyTime; + /** + * 监督人 + */ + @TableField("SUPR_USER") + private String superviseUser; + /** + * 监督人id + */ + @TableField("SUPR_USER_ID") + private Long superviseUserId; + /** + * 流程实例id + */ + @TableField("FLW_INSC_ID") + private String flowInstanceId; + /** + * 意见json + */ + @TableField("CMT_JSON") + private String commentJson; + /** + * 流程审批状态 + */ + @TableField("FLW_STS") + private String flowStatus; + /** + * 所属部门 + */ + @TableField("SYS_DEPT_CD") + private String systemDepartmentCode; + /** + * 备注 + */ + @TableField("RMK") + private String remark; + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInventoryOutboundDetailDO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInventoryOutboundDetailDO.java new file mode 100644 index 00000000..661dc201 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialInventoryOutboundDetailDO.java @@ -0,0 +1,59 @@ +package com.zt.plat.module.qms.resource.material.dal.dataobject; + +import com.baomidou.mybatisplus.annotation.*; +import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO; +import lombok.*; + +import java.math.BigDecimal; +/** +* 出库明细 DO +* +* @author 后台管理 +*/ +@TableName("t_mtrl_invt_outb_dtl") +@KeySequence("t_mtrl_invt_outb_dtl_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +/** +* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO +*/ +public class MaterialInventoryOutboundDetailDO extends BusinessBaseDO { + + + + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + /** + * 出库单id + */ + @TableField("OUTB_ID") + private Long outboundId; + /** + * 物料实例id + */ + @TableField("INF_ID") + private Long infomationId; + /** + * 数量 + */ + @TableField("QTY") + private BigDecimal quantity; + /** + * 所属部门 + */ + @TableField("SYS_DEPT_CD") + private String systemDepartmentCode; + /** + * 备注 + */ + @TableField("RMK") + private String remark; + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialBatchMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialBatchMapper.java index 18870025..0dbfc50e 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialBatchMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialBatchMapper.java @@ -8,6 +8,7 @@ import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX; import com.zt.plat.framework.security.core.LoginUser; import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils; +import com.zt.plat.module.qms.core.aspect.annotation.QmsPermission; import com.zt.plat.module.qms.enums.QmsCommonConstant; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchRespVO; @@ -74,13 +75,9 @@ public interface MaterialBatchMapper extends BaseMapperX { return selectJoinPage(reqVO, MaterialBatchRespVO.class, wrapper); } + @QmsPermission(deptDataRoleCodes = "ytjyDeptAndSub", moduleDataRoleCodes = "qms_material_manager") default PageResult selectGongPage(MaterialBatchPageReqVO reqVO, List pdtIds) { - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - Long visitDeptId = null; - if (loginUser != null) { - visitDeptId = loginUser.getVisitDeptId(); - } MPJLambdaWrapper wrapper = new MPJLambdaWrapperX() .selectAll(MaterialBatchDO.class) .selectAs(MaterialProductDO::getName, MaterialBatchRespVO::getProductName) @@ -96,7 +93,6 @@ public interface MaterialBatchMapper extends BaseMapperX { .ne(MaterialBatchDO::getAcceptanceStatus, MaterialAcceptStatus.accepted.name()) // 未处理的不允许再次选择 .notExists("SELECT 1 FROM t_mtrl_lfc_dtl ld WHERE ld.BAT_GONG_ID = t.ID AND ld.TMT_STS = 0 AND ld.DELETED = 0") -// .eq(onlyGong != null && visitDeptId != null && onlyGong, MaterialBatchDO::getAssignDepartmentId, visitDeptId) .in(CollUtil.isNotEmpty(pdtIds), MaterialBatchDO::getProductId, pdtIds) .eq(CollUtil.isEmpty(pdtIds) && reqVO.getProductId() != null, MaterialBatchDO::getProductId, reqVO.getProductId()) .likeIfExists(MaterialBatchDO::getBatchNo, reqVO.getBatchNo()) @@ -113,13 +109,9 @@ public interface MaterialBatchMapper extends BaseMapperX { return selectJoinPage(reqVO, MaterialBatchRespVO.class, wrapper); } + @QmsPermission(deptDataRoleCodes = "ytjyDeptAndSub", moduleDataRoleCodes = "qms_material_manager") default PageResult selectAcceptedGongPage(MaterialBatchPageReqVO reqVO, List pdtIds) { - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - Long visitDeptId = null; - if (loginUser != null) { - visitDeptId = loginUser.getVisitDeptId(); - } MPJLambdaWrapper wrapper = new MPJLambdaWrapperX() .selectAll(MaterialBatchDO.class) .selectAs(MaterialProductDO::getName, MaterialBatchRespVO::getProductName) @@ -133,7 +125,6 @@ public interface MaterialBatchMapper extends BaseMapperX { .ne(MaterialBatchDO::getParentId, 0) .eq(MaterialBatchDO::getSubmitStatus, 1) .eq(MaterialBatchDO::getAcceptanceStatus, reqVO.getAcceptanceStatus()) - // .eq(onlyGong != null && visitDeptId != null && onlyGong, MaterialBatchDO::getAssignDepartmentId, visitDeptId) .in(CollUtil.isNotEmpty(pdtIds), MaterialBatchDO::getProductId, pdtIds) .eq(CollUtil.isEmpty(pdtIds) && reqVO.getProductId() != null, MaterialBatchDO::getProductId, reqVO.getProductId()) .likeIfExists(MaterialBatchDO::getBatchNo, reqVO.getBatchNo()) @@ -152,8 +143,10 @@ public interface MaterialBatchMapper extends BaseMapperX { .le(reqVO.getTreatment(), MaterialBatchDO::getInboundQuantity, MaterialBatchDO::getInboundEndQuantity) // 未处理 .gt(!reqVO.getTreatment(), MaterialBatchDO::getInboundQuantity, MaterialBatchDO::getInboundEndQuantity) -// .between(reqVO.getCreateTime() != null && reqVO.getCreateTime().length == 2, MaterialBatchDO::getCreateTime, reqVO.getCreateTime()[0], reqVO.getCreateTime()[1]) .orderByDesc(MaterialBatchDO::getParentId); + if (reqVO.getCreateTime() != null && reqVO.getCreateTime().length == 2) { + wrapper.between(MaterialBatchDO::getCreateTime, reqVO.getCreateTime()[0], reqVO.getCreateTime()[1]); + } return selectJoinPage(reqVO, MaterialBatchRespVO.class, wrapper); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInfomationMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInfomationMapper.java index 2c23f8fb..db3348d1 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInfomationMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInfomationMapper.java @@ -5,8 +5,10 @@ import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX; +import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigWarehouseLocationDO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationRespVO; +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 org.apache.ibatis.annotations.Mapper; @@ -61,7 +63,13 @@ public interface MaterialInfomationMapper extends BaseMapperX wrapper = new MPJLambdaWrapperX() + .select(MaterialInfomationDO::getId, + MaterialInfomationDO::getProductId, MaterialInfomationDO::getBatchId, MaterialInfomationDO::getGongduanId, + MaterialInfomationDO::getCode, MaterialInfomationDO::getPublishStatus, + MaterialInfomationDO::getUsageStatus, MaterialInfomationDO::getManagerDepartmentId, + MaterialInfomationDO::getManagerDepartmentName, MaterialInfomationDO::getManagerUserId, MaterialInfomationDO::getManagerUserName, + MaterialInfomationDO::getOpenStatus, MaterialInfomationDO::getOpenUserId, MaterialInfomationDO::getOpenUserName, + MaterialInfomationDO::getOpenDate, MaterialInfomationDO::getExpirationDate, MaterialInfomationDO::getExpirationFlag, + MaterialInfomationDO::getRemainingVolume, MaterialInfomationDO::getUseEndFlag, + MaterialInfomationDO::getSystemDepartmentCode, MaterialInfomationDO::getRemark, + MaterialInfomationDO::getCreateTime, MaterialInfomationDO::getUpdateTime) + .select(MaterialProductDO::getName, MaterialProductDO::getSpecification, + MaterialProductDO::getModelNo, MaterialProductDO::getParameter, MaterialProductDO::getManufacturer, + MaterialProductDO::getUnit, MaterialProductDO::getDue) + .selectAs("batch.BAT_NO", MaterialInfomationRespVO::getBatchNo) + .selectAs("gongduan.ASN_DEPT_NAME", MaterialInfomationRespVO::getAssignDepartmentName) + .selectAs(ConfigWarehouseLocationDO::getCode, MaterialInfomationRespVO::getLocationCode) + .leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialInfomationDO::getProductId) + .leftJoin(MaterialBatchDO.class, "batch", MaterialBatchDO::getId, MaterialInfomationDO::getBatchId) + .leftJoin(MaterialBatchDO.class, "gongduan", MaterialBatchDO::getId, MaterialInfomationDO::getGongduanId) + .leftJoin(ConfigWarehouseLocationDO.class, ConfigWarehouseLocationDO::getId, MaterialInfomationDO::getLocationId) + .eq(MaterialInfomationDO::getCode, code); + return selectJoinOne(MaterialInfomationRespVO.class, wrapper); + } } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryInboundDetailMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryInboundDetailMapper.java index d36e6e20..11501339 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryInboundDetailMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryInboundDetailMapper.java @@ -64,7 +64,7 @@ public interface MaterialInventoryInboundDetailMapper extends BaseMapperX { + + default PageResult selectPage(MaterialInventoryOutboundDetailPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(MaterialInventoryOutboundDetailDO::getOutboundId, reqVO.getOutboundId()) + .eqIfPresent(MaterialInventoryOutboundDetailDO::getInfomationId, reqVO.getInfomationId()) + .eqIfPresent(MaterialInventoryOutboundDetailDO::getQuantity, reqVO.getQuantity()) + .eqIfPresent(MaterialInventoryOutboundDetailDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode()) + .eqIfPresent(MaterialInventoryOutboundDetailDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(MaterialInventoryOutboundDetailDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(MaterialInventoryOutboundDetailDO::getId)); + } + + default PageResult selectPageWithMaterialInfo(MaterialInventoryOutboundDetailPageReqVO reqVO){ + MPJLambdaWrapperX wrapperX = new MPJLambdaWrapperX() + .selectAll(MaterialInventoryOutboundDetailDO.class) + .selectAs(MaterialInfomationDO::getCode, MaterialInventoryOutboundDetailRespVO::getInfomationCode) + .selectAs(MaterialInfomationDO::getManagerUserId, MaterialInventoryOutboundDetailRespVO::getManagerUserId) + .selectAs(MaterialInfomationDO::getManagerUserName, MaterialInventoryOutboundDetailRespVO::getManagerUserName) + .selectAs(MaterialProductDO::getName, MaterialInventoryOutboundDetailRespVO::getInfomationName) + .selectAs(MaterialInventoryOutboundDO::getBusinessType, MaterialInventoryOutboundDetailRespVO::getBusinessType) + .selectAs(ConfigWarehouseLocationDO::getName, MaterialInventoryOutboundDetailRespVO::getLocationName) + .selectAs(ConfigWarehouseLocationDO::getCode, MaterialInventoryOutboundDetailRespVO::getLocationCode) + .leftJoin(MaterialInfomationDO.class, MaterialInfomationDO::getId, MaterialInventoryOutboundDetailDO::getInfomationId) + .leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialInfomationDO::getProductId) + .leftJoin(MaterialInventoryOutboundDO.class, MaterialInventoryOutboundDO::getId, MaterialInventoryOutboundDetailDO::getOutboundId) + .leftJoin(ConfigWarehouseLocationDO.class, ConfigWarehouseLocationDO::getId, MaterialInfomationDO::getLocationId) + .eqIfPresent(MaterialProductDO::getId, reqVO.getProductId()) + .eqIfPresent(MaterialInventoryOutboundDetailDO::getOutboundId, reqVO.getOutboundId()) + .eqIfPresent(MaterialInventoryOutboundDetailDO::getInfomationId, reqVO.getInfomationId()) + .eqIfPresent(MaterialInventoryOutboundDetailDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode()) + .eqIfPresent(MaterialInventoryOutboundDetailDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(MaterialInventoryOutboundDetailDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(MaterialInventoryOutboundDetailDO::getId); + return selectJoinPage(reqVO, MaterialInventoryOutboundDetailRespVO.class, wrapperX); + } +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryOutboundMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryOutboundMapper.java new file mode 100644 index 00000000..f8826279 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryOutboundMapper.java @@ -0,0 +1,39 @@ +package com.zt.plat.module.qms.resource.material.dal.mapper; + +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; +import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundPageReqVO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryOutboundDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 物料出库 Mapper + * + * @author 后台管理 + */ +@Mapper +public interface MaterialInventoryOutboundMapper extends BaseMapperX { + + default PageResult selectPage(MaterialInventoryOutboundPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(MaterialInventoryOutboundDO::getTitle, reqVO.getTitle()) + .eqIfPresent(MaterialInventoryOutboundDO::getBusinessType, reqVO.getBusinessType()) + .eqIfPresent(MaterialInventoryOutboundDO::getBusinessTypeCode, reqVO.getBusinessTypeCode()) + .eqIfPresent(MaterialInventoryOutboundDO::getApplyUser, reqVO.getApplyUser()) + .eqIfPresent(MaterialInventoryOutboundDO::getApplyUserId, reqVO.getApplyUserId()) + .eqIfPresent(MaterialInventoryOutboundDO::getApplyDepartment, reqVO.getApplyDepartment()) + .eqIfPresent(MaterialInventoryOutboundDO::getApplyDepartmentId, reqVO.getApplyDepartmentId()) + .betweenIfPresent(MaterialInventoryOutboundDO::getApplyTime, reqVO.getApplyTime()) + .eqIfPresent(MaterialInventoryOutboundDO::getSuperviseUser, reqVO.getSuperviseUser()) + .eqIfPresent(MaterialInventoryOutboundDO::getSuperviseUserId, reqVO.getSuperviseUserId()) + .eqIfPresent(MaterialInventoryOutboundDO::getFlowInstanceId, reqVO.getFlowInstanceId()) + .eqIfPresent(MaterialInventoryOutboundDO::getCommentJson, reqVO.getCommentJson()) + .eqIfPresent(MaterialInventoryOutboundDO::getFlowStatus, reqVO.getFlowStatus()) + .eqIfPresent(MaterialInventoryOutboundDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode()) + .eqIfPresent(MaterialInventoryOutboundDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(MaterialInventoryOutboundDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(MaterialInventoryOutboundDO::getId)); + } + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialInboundType.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialInboundType.java new file mode 100644 index 00000000..5e1aadef --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialInboundType.java @@ -0,0 +1,28 @@ +package com.zt.plat.module.qms.resource.material.enums; + +import lombok.Getter; + +/** + * 物料入库业务类型 + */ +@Getter +public enum MaterialInboundType { + acceptanceInbound("验收入库"), + + checkOverInbound("盘盈入库"); + + private final String name; + + MaterialInboundType(String name) { + this.name = name; + } + + public static MaterialFlowType fromName(String name) { + for (MaterialFlowType type : MaterialFlowType.values()) { + if (type.getName().equals(name)) { + return type; + } + } + throw new IllegalArgumentException("No enum constant with name: " + name); + } +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialOutboundType.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialOutboundType.java new file mode 100644 index 00000000..82061fb0 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/enums/MaterialOutboundType.java @@ -0,0 +1,28 @@ +package com.zt.plat.module.qms.resource.material.enums; + +import lombok.Getter; + +/** + * 物料出库业务类型 + */ +@Getter +public enum MaterialOutboundType { + receiveOutbound("领用出库"), + + checkShortOutbound("盘亏出库"); + + private final String name; + + MaterialOutboundType(String name) { + this.name = name; + } + + public static MaterialFlowType fromName(String name) { + for (MaterialFlowType type : MaterialFlowType.values()) { + if (type.getName().equals(name)) { + return type; + } + } + throw new IllegalArgumentException("No enum constant with name: " + name); + } +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java index e3f0ea7e..f01ea0fe 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java @@ -83,4 +83,28 @@ public interface MaterialInfomationService { * @return 物料实例分页 */ PageResult getMaterialInfomationPageWithPdtInfo(@Valid MaterialInfomationPageReqVO pageReqVO); + + /** + * 根据物料编号获取物料信息 + * + * @param code 物料编号 + * @return 物料信息 + */ + MaterialInfomationRespVO getMaterialInfomationWithPdtInfoByInfCode(String code); + + /** + * 根据物料实例id集合 获取物料信息 + * + * @param infomationIds id集合 + * @return 物料信息 + */ + List getMaterialInfomationsByIds(List infomationIds); + + /** + * 更新物料实例领用状态 + * + * @param infomationUpdate 修改 + * @param infIds id集合 + */ + void updateInfomationByInfIds(MaterialInfomationDO infomationUpdate, List infIds); } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java index b4bd754f..270e3559 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java @@ -120,4 +120,22 @@ public class MaterialInfomationServiceImpl implements MaterialInfomationService return materialInfomationMapper.selectPageWithPdtInfo(pageReqVO); } + @Override + public MaterialInfomationRespVO getMaterialInfomationWithPdtInfoByInfCode(String code) { + + return materialInfomationMapper.selectOneWithPdtInfoByInfCode(code); + } + + @Override + public List getMaterialInfomationsByIds(List infomationIds) { + return materialInfomationMapper.selectByIds(infomationIds); + } + + @Override + public void updateInfomationByInfIds(MaterialInfomationDO infomationUpdate, List infIds) { + + materialInfomationMapper.update(infomationUpdate, Wrappers.lambdaQuery(MaterialInfomationDO.class) + .in(MaterialInfomationDO::getId, infIds)); + } + } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryOutboundDetailService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryOutboundDetailService.java new file mode 100644 index 00000000..63799d94 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryOutboundDetailService.java @@ -0,0 +1,78 @@ +package com.zt.plat.module.qms.resource.material.service; + +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundDetailPageReqVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundDetailRespVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundDetailSaveReqVO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryOutboundDetailDO; +import jakarta.validation.Valid; + +import java.util.List; + +/** + * 出库明细 Service 接口 + * + * @author 后台管理 + */ +public interface MaterialInventoryOutboundDetailService { + + /** + * 创建出库明细 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + MaterialInventoryOutboundDetailRespVO createMaterialInventoryOutboundDetail(@Valid MaterialInventoryOutboundDetailSaveReqVO createReqVO); + + /** + * 更新出库明细 + * + * @param updateReqVO 更新信息 + */ + void updateMaterialInventoryOutboundDetail(@Valid MaterialInventoryOutboundDetailSaveReqVO updateReqVO); + + /** + * 删除出库明细 + * + * @param id 编号 + */ + void deleteMaterialInventoryOutboundDetail(Long id); + + /** + * 批量删除出库明细 + * + * @param ids 编号 + */ + void deleteMaterialInventoryOutboundDetailListByIds(List ids); + + /** + * 获得出库明细 + * + * @param id 编号 + * @return 出库明细 + */ + MaterialInventoryOutboundDetailDO getMaterialInventoryOutboundDetail(Long id); + + /** + * 获得出库明细分页 + * + * @param pageReqVO 分页查询 + * @return 出库明细分页 + */ + PageResult getMaterialInventoryOutboundDetailPage(MaterialInventoryOutboundDetailPageReqVO pageReqVO); + + /** + * 批量保存出库明细 + * + * @param outboundDetailDOS 出库明细 + */ + void saveBatch(List outboundDetailDOS); + + /** + * 获取出库明细分页带物料信息 + * + * @param pageReqVO 分页查询 + * @return 出库明细分页 + */ + PageResult getOutboundDetailPageWithMaterialInfo(@Valid MaterialInventoryOutboundDetailPageReqVO pageReqVO); +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryOutboundDetailServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryOutboundDetailServiceImpl.java new file mode 100644 index 00000000..bf701ca1 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryOutboundDetailServiceImpl.java @@ -0,0 +1,100 @@ +package com.zt.plat.module.qms.resource.material.service; + +import cn.hutool.core.collection.CollUtil; +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.common.util.object.BeanUtils; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundDetailPageReqVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundDetailRespVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundDetailSaveReqVO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryOutboundDetailDO; +import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryOutboundDetailMapper; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.List; + +import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.zt.plat.module.qms.enums.ErrorCodeConstants.MATERIAL_INVENTORY_OUTBOUND_DETAIL_NOT_EXISTS; + +/** + * 出库明细 Service 实现类 + * + * @author 后台管理 + */ +@Service +@Validated +public class MaterialInventoryOutboundDetailServiceImpl implements MaterialInventoryOutboundDetailService { + + @Resource + private MaterialInventoryOutboundDetailMapper materialInventoryOutboundDetailMapper; + + @Override + public MaterialInventoryOutboundDetailRespVO createMaterialInventoryOutboundDetail(MaterialInventoryOutboundDetailSaveReqVO createReqVO) { + // 插入 + MaterialInventoryOutboundDetailDO materialInventoryOutboundDetail = BeanUtils.toBean(createReqVO, MaterialInventoryOutboundDetailDO.class); + materialInventoryOutboundDetailMapper.insert(materialInventoryOutboundDetail); + // 返回 + return BeanUtils.toBean(materialInventoryOutboundDetail, MaterialInventoryOutboundDetailRespVO.class); + } + + @Override + public void updateMaterialInventoryOutboundDetail(MaterialInventoryOutboundDetailSaveReqVO updateReqVO) { + // 校验存在 + validateMaterialInventoryOutboundDetailExists(updateReqVO.getId()); + // 更新 + MaterialInventoryOutboundDetailDO updateObj = BeanUtils.toBean(updateReqVO, MaterialInventoryOutboundDetailDO.class); + materialInventoryOutboundDetailMapper.updateById(updateObj); + } + + @Override + public void deleteMaterialInventoryOutboundDetail(Long id) { + // 校验存在 + validateMaterialInventoryOutboundDetailExists(id); + // 删除 + materialInventoryOutboundDetailMapper.deleteById(id); + } + + @Override + public void deleteMaterialInventoryOutboundDetailListByIds(List ids) { + // 校验存在 + validateMaterialInventoryOutboundDetailExists(ids); + // 删除 + materialInventoryOutboundDetailMapper.deleteByIds(ids); + } + + private void validateMaterialInventoryOutboundDetailExists(List ids) { + List list = materialInventoryOutboundDetailMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(MATERIAL_INVENTORY_OUTBOUND_DETAIL_NOT_EXISTS); + } + } + + private void validateMaterialInventoryOutboundDetailExists(Long id) { + if (materialInventoryOutboundDetailMapper.selectById(id) == null) { + throw exception(MATERIAL_INVENTORY_OUTBOUND_DETAIL_NOT_EXISTS); + } + } + + @Override + public MaterialInventoryOutboundDetailDO getMaterialInventoryOutboundDetail(Long id) { + return materialInventoryOutboundDetailMapper.selectById(id); + } + + @Override + public PageResult getMaterialInventoryOutboundDetailPage(MaterialInventoryOutboundDetailPageReqVO pageReqVO) { + return materialInventoryOutboundDetailMapper.selectPage(pageReqVO); + } + + @Override + public void saveBatch(List outboundDetailDOS) { + materialInventoryOutboundDetailMapper.insertBatch(outboundDetailDOS); + } + + @Override + public PageResult getOutboundDetailPageWithMaterialInfo(MaterialInventoryOutboundDetailPageReqVO pageReqVO) { + + return materialInventoryOutboundDetailMapper.selectPageWithMaterialInfo(pageReqVO); + } + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryOutboundService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryOutboundService.java new file mode 100644 index 00000000..e413a23b --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryOutboundService.java @@ -0,0 +1,64 @@ +package com.zt.plat.module.qms.resource.material.service; + +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundPageReqVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundRespVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundSaveReqVO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryOutboundDO; +import jakarta.validation.Valid; + +import java.util.List; + +/** + * 物料出库 Service 接口 + * + * @author 后台管理 + */ +public interface MaterialInventoryOutboundService { + + /** + * 创建物料出库 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + MaterialInventoryOutboundRespVO createMaterialInventoryOutbound(@Valid MaterialInventoryOutboundSaveReqVO createReqVO); + + /** + * 更新物料出库 + * + * @param updateReqVO 更新信息 + */ + void updateMaterialInventoryOutbound(@Valid MaterialInventoryOutboundSaveReqVO updateReqVO); + + /** + * 删除物料出库 + * + * @param id 编号 + */ + void deleteMaterialInventoryOutbound(Long id); + + /** + * 批量删除物料出库 + * + * @param ids 编号 + */ + void deleteMaterialInventoryOutboundListByIds(List ids); + + /** + * 获得物料出库 + * + * @param id 编号 + * @return 物料出库 + */ + MaterialInventoryOutboundDO getMaterialInventoryOutbound(Long id); + + /** + * 获得物料出库分页 + * + * @param pageReqVO 分页查询 + * @return 物料出库分页 + */ + PageResult getMaterialInventoryOutboundPage(MaterialInventoryOutboundPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryOutboundServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryOutboundServiceImpl.java new file mode 100644 index 00000000..9af6622a --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInventoryOutboundServiceImpl.java @@ -0,0 +1,145 @@ +package com.zt.plat.module.qms.resource.material.service; + +import cn.hutool.core.collection.CollUtil; +import com.zt.plat.framework.common.exception.ServiceException; +import com.zt.plat.framework.common.pojo.CommonResult; +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.common.util.object.BeanUtils; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundPageReqVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundRespVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryOutboundSaveReqVO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryOutboundDO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryOutboundDetailDO; +import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryOutboundMapper; +import com.zt.plat.module.system.api.dept.DeptApi; +import com.zt.plat.module.system.api.dept.dto.DeptRespDTO; +import com.zt.plat.module.system.api.user.AdminUserApi; +import com.zt.plat.module.system.api.user.dto.AdminUserRespDTO; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.zt.plat.module.qms.enums.ErrorCodeConstants.MATERIAL_INVENTORY_OUTBOUND_NOT_EXISTS; + +/** + * 物料出库 Service 实现类 + * + * @author 后台管理 + */ +@Slf4j +@Service +@Validated +public class MaterialInventoryOutboundServiceImpl implements MaterialInventoryOutboundService { + + @Resource + private MaterialInventoryOutboundMapper materialInventoryOutboundMapper; + + @Autowired + private AdminUserApi adminUserApi; + @Autowired + private DeptApi deptApi; + @Autowired + private MaterialInfomationService materialInfomationService; + @Autowired + private MaterialInventoryOutboundDetailService materialInventoryOutboundDetailService; + + @Transactional + @Override + public MaterialInventoryOutboundRespVO createMaterialInventoryOutbound(MaterialInventoryOutboundSaveReqVO createReqVO) { + + MaterialInventoryOutboundDO outboundDO = BeanUtils.toBean(createReqVO, MaterialInventoryOutboundDO.class); + + List infomationIds = createReqVO.getInfomationIds(); + if (CollUtil.isEmpty(infomationIds)) return BeanUtils.toBean(outboundDO, MaterialInventoryOutboundRespVO.class); + List infs = materialInfomationService.getMaterialInfomationsByIds(infomationIds); + if (CollUtil.isEmpty(infs) || infs.size() != infomationIds.size()) + throw new ServiceException(1_032_160_000, "物料信息不存在或与传入的数量不匹配"); + for (MaterialInfomationDO inf : infs) { + if (inf.getUsageStatus() == 1) throw new ServiceException(1_032_160_000, "物料【"+ inf.getName() + ":" + inf.getCode() +"】已出库"); + } + // 获取申请人信息 + Long applyUserId = createReqVO.getApplyUserId(); + CommonResult userResult = adminUserApi.getUser(applyUserId); + AdminUserRespDTO applyUser = userResult.getData(); + CommonResult deptResult = deptApi.getDept(applyUser.getDeptId()); + DeptRespDTO applyDept = deptResult.getData(); + outboundDO.setApplyUserId(applyUserId).setApplyUser(applyUser.getNickname()) + .setApplyDepartmentId(applyDept.getId()).setApplyDepartment(applyDept.getName()) + .setApplyTime(LocalDateTime.now()); + + materialInventoryOutboundMapper.insert(outboundDO); + // 保存出库明细 + List outboundDetailDOS = infomationIds.stream().map( + id -> new MaterialInventoryOutboundDetailDO() + .setOutboundId(outboundDO.getId()) + .setInfomationId(id) + .setQuantity(BigDecimal.valueOf(1))).toList(); + materialInventoryOutboundDetailService.saveBatch(outboundDetailDOS); + // 修改物料实例状态 + List infIds = infs.stream().map(MaterialInfomationDO::getId).toList(); + MaterialInfomationDO infomationUpdate = new MaterialInfomationDO() + .setUsageStatus(1) + .setManagerUserId(outboundDO.getApplyUserId()).setManagerUserName(outboundDO.getApplyUser()) + .setManagerDepartmentId(outboundDO.getApplyDepartmentId()).setManagerDepartmentName(outboundDO.getApplyDepartment()); + materialInfomationService.updateInfomationByInfIds(infomationUpdate, infIds); + return BeanUtils.toBean(outboundDO, MaterialInventoryOutboundRespVO.class); + } + + @Override + public void updateMaterialInventoryOutbound(MaterialInventoryOutboundSaveReqVO updateReqVO) { + // 校验存在 + validateMaterialInventoryOutboundExists(updateReqVO.getId()); + // 更新 + MaterialInventoryOutboundDO updateObj = BeanUtils.toBean(updateReqVO, MaterialInventoryOutboundDO.class); + materialInventoryOutboundMapper.updateById(updateObj); + } + + @Override + public void deleteMaterialInventoryOutbound(Long id) { + // 校验存在 + validateMaterialInventoryOutboundExists(id); + // 删除 + materialInventoryOutboundMapper.deleteById(id); + } + + @Override + public void deleteMaterialInventoryOutboundListByIds(List ids) { + // 校验存在 + validateMaterialInventoryOutboundExists(ids); + // 删除 + materialInventoryOutboundMapper.deleteByIds(ids); + } + + private void validateMaterialInventoryOutboundExists(List ids) { + List list = materialInventoryOutboundMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(MATERIAL_INVENTORY_OUTBOUND_NOT_EXISTS); + } + } + + private void validateMaterialInventoryOutboundExists(Long id) { + if (materialInventoryOutboundMapper.selectById(id) == null) { + throw exception(MATERIAL_INVENTORY_OUTBOUND_NOT_EXISTS); + } + } + + @Override + public MaterialInventoryOutboundDO getMaterialInventoryOutbound(Long id) { + return materialInventoryOutboundMapper.selectById(id); + } + + @Override + public PageResult getMaterialInventoryOutboundPage(MaterialInventoryOutboundPageReqVO pageReqVO) { + return materialInventoryOutboundMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryOutboundDetailMapper.xml b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryOutboundDetailMapper.xml new file mode 100644 index 00000000..b9650aaf --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryOutboundDetailMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryOutboundMapper.xml b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryOutboundMapper.xml new file mode 100644 index 00000000..49373b99 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialInventoryOutboundMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file