Commit c76f8fdd69a693a71c29f3dcee1b03b4496399a3
1 parent
d014bbe1
入库出库迁移
Showing
13 changed files
with
818 additions
and
222 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/materialinventory/MaterialInventoryController.java
| 1 | package com.zteits.urbanops.module.garden.controller.admin.materialinventory; | 1 | package com.zteits.urbanops.module.garden.controller.admin.materialinventory; |
| 2 | 2 | ||
| 3 | -import com.zteits.urbanops.framework.common.pojo.CommonResult; | ||
| 4 | -import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 5 | -import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 6 | -import com.zteits.urbanops.framework.excel.core.util.ExcelUtils; | ||
| 7 | -import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO; | ||
| 8 | -import com.zteits.urbanops.module.garden.service.materialinventory.MaterialInventoryService; | ||
| 9 | -import io.swagger.v3.oas.annotations.Operation; | ||
| 10 | -import io.swagger.v3.oas.annotations.tags.Tag; | 3 | +import org.springframework.web.bind.annotation.*; |
| 11 | import jakarta.annotation.Resource; | 4 | import jakarta.annotation.Resource; |
| 12 | -import jakarta.servlet.http.HttpServletResponse; | 5 | +import org.springframework.validation.annotation.Validated; |
| 13 | import org.springframework.security.access.prepost.PreAuthorize; | 6 | import org.springframework.security.access.prepost.PreAuthorize; |
| 14 | -import org.springframework.web.bind.annotation.*; | 7 | +import io.swagger.v3.oas.annotations.tags.Tag; |
| 8 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 9 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 15 | 10 | ||
| 11 | +import jakarta.validation.constraints.*; | ||
| 12 | +import jakarta.validation.*; | ||
| 13 | +import jakarta.servlet.http.*; | ||
| 14 | +import java.util.*; | ||
| 16 | import java.io.IOException; | 15 | import java.io.IOException; |
| 17 | -import java.util.List; | ||
| 18 | 16 | ||
| 17 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 18 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 19 | +import com.zteits.urbanops.framework.common.pojo.CommonResult; | ||
| 20 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 19 | import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | 21 | import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; |
| 20 | 22 | ||
| 23 | +import com.zteits.urbanops.framework.excel.core.util.ExcelUtils; | ||
| 24 | + | ||
| 25 | +import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog; | ||
| 26 | +import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.*; | ||
| 27 | + | ||
| 28 | +import com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo.*; | ||
| 29 | +import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO; | ||
| 30 | +import com.zteits.urbanops.module.garden.service.materialinventory.MaterialInventoryService; | ||
| 31 | + | ||
| 21 | @Tag(name = "管理后台 - 物料库存") | 32 | @Tag(name = "管理后台 - 物料库存") |
| 22 | @RestController | 33 | @RestController |
| 23 | -@RequestMapping("/material/inventory") | 34 | +@RequestMapping("/garden/material-inventory") |
| 35 | +@Validated | ||
| 24 | public class MaterialInventoryController { | 36 | public class MaterialInventoryController { |
| 25 | 37 | ||
| 26 | @Resource | 38 | @Resource |
| 27 | - private MaterialInventoryService inventoryService; | ||
| 28 | - | ||
| 29 | - @PostMapping("/listForPage") | ||
| 30 | - @Operation(summary = "物料库存-分页查询") | ||
| 31 | - @PreAuthorize("@ss.hasPermission('material:inventory:list')") | ||
| 32 | - public CommonResult<PageResult<MaterialInventoryDO>> listForPage(@RequestBody MaterialInventoryDO where, | ||
| 33 | - @RequestParam(value = "pageNum", required = false) Integer pageNum, | ||
| 34 | - @RequestParam(value = "pageSize", required = false) Integer pageSize) { | ||
| 35 | - PageParam page = new PageParam(); | ||
| 36 | - page.setPageNo(pageNum == null ? 1 : pageNum); | ||
| 37 | - page.setPageSize(pageSize == null ? 10 : pageSize); | ||
| 38 | - return success(inventoryService.selectPage(page, where)); | 39 | + private MaterialInventoryService materialInventoryService; |
| 40 | + | ||
| 41 | + @PostMapping("/create") | ||
| 42 | + @Operation(summary = "创建物料库存") | ||
| 43 | + @PreAuthorize("@ss.hasPermission('garden:material-inventory:create')") | ||
| 44 | + public CommonResult<Long> createMaterialInventory(@Valid @RequestBody MaterialInventorySaveReqVO createReqVO) { | ||
| 45 | + return success(materialInventoryService.createMaterialInventory(createReqVO)); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @PutMapping("/update") | ||
| 49 | + @Operation(summary = "更新物料库存") | ||
| 50 | + @PreAuthorize("@ss.hasPermission('garden:material-inventory:update')") | ||
| 51 | + public CommonResult<Boolean> updateMaterialInventory(@Valid @RequestBody MaterialInventorySaveReqVO updateReqVO) { | ||
| 52 | + materialInventoryService.updateMaterialInventory(updateReqVO); | ||
| 53 | + return success(true); | ||
| 39 | } | 54 | } |
| 40 | 55 | ||
| 41 | - @GetMapping("/export") | ||
| 42 | - @Operation(summary = "物料库存-导出") | ||
| 43 | - @PreAuthorize("@ss.hasPermission('material:inventory:export')") | ||
| 44 | - public void export(MaterialInventoryDO where, HttpServletResponse response) throws IOException { | ||
| 45 | - List<MaterialInventoryDO> list = inventoryService.selectPage(new PageParam(), where).getList(); | ||
| 46 | - ExcelUtils.write(response, "物料库存.xls", "数据", MaterialInventoryDO.class, list); | 56 | + @DeleteMapping("/delete") |
| 57 | + @Operation(summary = "删除物料库存") | ||
| 58 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 59 | + @PreAuthorize("@ss.hasPermission('garden:material-inventory:delete')") | ||
| 60 | + public CommonResult<Boolean> deleteMaterialInventory(@RequestParam("id") Long id) { | ||
| 61 | + materialInventoryService.deleteMaterialInventory(id); | ||
| 62 | + return success(true); | ||
| 47 | } | 63 | } |
| 48 | 64 | ||
| 49 | - @GetMapping("/updateByAlermNum") | ||
| 50 | - @Operation(summary = "物料库存-阈值更新") | ||
| 51 | - @PreAuthorize("@ss.hasPermission('material:inventory:export')") | ||
| 52 | - public CommonResult<Boolean> updateInventoryAlermNum(@RequestParam("material_id") Long materialId, | ||
| 53 | - @RequestParam("alerm_num") Long alermNum) { | ||
| 54 | - return success(inventoryService.updateInventoryAlarmNum(materialId, alermNum)); | 65 | + @DeleteMapping("/delete-list") |
| 66 | + @Parameter(name = "ids", description = "编号", required = true) | ||
| 67 | + @Operation(summary = "批量删除物料库存") | ||
| 68 | + @PreAuthorize("@ss.hasPermission('garden:material-inventory:delete')") | ||
| 69 | + public CommonResult<Boolean> deleteMaterialInventoryList(@RequestParam("ids") List<Long> ids) { | ||
| 70 | + materialInventoryService.deleteMaterialInventoryListByIds(ids); | ||
| 71 | + return success(true); | ||
| 55 | } | 72 | } |
| 56 | -} | 73 | + |
| 74 | + @GetMapping("/get") | ||
| 75 | + @Operation(summary = "获得物料库存") | ||
| 76 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 77 | + @PreAuthorize("@ss.hasPermission('garden:material-inventory:query')") | ||
| 78 | + public CommonResult<MaterialInventoryRespVO> getMaterialInventory(@RequestParam("id") Long id) { | ||
| 79 | + MaterialInventoryDO materialInventory = materialInventoryService.getMaterialInventory(id); | ||
| 80 | + return success(BeanUtils.toBean(materialInventory, MaterialInventoryRespVO.class)); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @GetMapping("/page") | ||
| 84 | + @Operation(summary = "获得物料库存分页") | ||
| 85 | + @PreAuthorize("@ss.hasPermission('garden:material-inventory:query')") | ||
| 86 | + public CommonResult<PageResult<MaterialInventoryRespVO>> getMaterialInventoryPage(@Valid MaterialInventoryPageReqVO pageReqVO) { | ||
| 87 | + PageResult<MaterialInventoryDO> pageResult = materialInventoryService.getMaterialInventoryPage(pageReqVO); | ||
| 88 | + return success(BeanUtils.toBean(pageResult, MaterialInventoryRespVO.class)); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + @GetMapping("/export-excel") | ||
| 92 | + @Operation(summary = "导出物料库存 Excel") | ||
| 93 | + @PreAuthorize("@ss.hasPermission('garden:material-inventory:export')") | ||
| 94 | + @ApiAccessLog(operateType = EXPORT) | ||
| 95 | + public void exportMaterialInventoryExcel(@Valid MaterialInventoryPageReqVO pageReqVO, | ||
| 96 | + HttpServletResponse response) throws IOException { | ||
| 97 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 98 | + List<MaterialInventoryDO> list = materialInventoryService.getMaterialInventoryPage(pageReqVO).getList(); | ||
| 99 | + // 导出 Excel | ||
| 100 | + ExcelUtils.write(response, "物料库存.xls", "数据", MaterialInventoryRespVO.class, | ||
| 101 | + BeanUtils.toBean(list, MaterialInventoryRespVO.class)); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | +} | ||
| 57 | \ No newline at end of file | 105 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/materialinventory/vo/MaterialInventoryPageReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | + | ||
| 12 | +@Schema(description = "管理后台 - 物料库存分页 Request VO") | ||
| 13 | +@Data | ||
| 14 | +public class MaterialInventoryPageReqVO extends PageParam { | ||
| 15 | + | ||
| 16 | + @Schema(description = "物料ID", example = "29414") | ||
| 17 | + private Long materialId; | ||
| 18 | + | ||
| 19 | + @Schema(description = "物料名称", example = "李四") | ||
| 20 | + private String materialName; | ||
| 21 | + | ||
| 22 | + @Schema(description = "物料类型ID", example = "24853") | ||
| 23 | + private Long materialTypeId; | ||
| 24 | + | ||
| 25 | + @Schema(description = "耗材类型名称", example = "芋艿") | ||
| 26 | + private String materialTypeName; | ||
| 27 | + | ||
| 28 | + @Schema(description = "类别ID", example = "30568") | ||
| 29 | + private Long typeId; | ||
| 30 | + | ||
| 31 | + @Schema(description = "类别名称:药品", example = "芋艿") | ||
| 32 | + private String typeName; | ||
| 33 | + | ||
| 34 | + @Schema(description = "类别明细ID", example = "6252") | ||
| 35 | + private Long typeDetailId; | ||
| 36 | + | ||
| 37 | + @Schema(description = "类别明细", example = "芋艿") | ||
| 38 | + private String typeDetailName; | ||
| 39 | + | ||
| 40 | + @Schema(description = "规格") | ||
| 41 | + private String specifications; | ||
| 42 | + | ||
| 43 | + @Schema(description = "归属单位ID", example = "25626") | ||
| 44 | + private Long belongCompanyId; | ||
| 45 | + | ||
| 46 | + @Schema(description = "归属单位", example = "李四") | ||
| 47 | + private String belongCompanyName; | ||
| 48 | + | ||
| 49 | + @Schema(description = "单位ID", example = "6480") | ||
| 50 | + private Long unitId; | ||
| 51 | + | ||
| 52 | + @Schema(description = "单位", example = "王五") | ||
| 53 | + private String unitName; | ||
| 54 | + | ||
| 55 | + @Schema(description = "当前库存数量") | ||
| 56 | + private Long currentNum; | ||
| 57 | + | ||
| 58 | + @Schema(description = "出库总数量(出库累加)") | ||
| 59 | + private Long outTotalNum; | ||
| 60 | + | ||
| 61 | + @Schema(description = "库存总数量(入库累加)") | ||
| 62 | + private Long inventoryTotalNum; | ||
| 63 | + | ||
| 64 | + @Schema(description = "创建时间") | ||
| 65 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 66 | + private LocalDateTime[] createTime; | ||
| 67 | + | ||
| 68 | + @Schema(description = "库存预警阈值") | ||
| 69 | + private Long inventoryAlermNum; | ||
| 70 | + | ||
| 71 | + @Schema(description = "部门ID", example = "11349") | ||
| 72 | + private Long deptId; | ||
| 73 | + | ||
| 74 | +} | ||
| 0 | \ No newline at end of file | 75 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/materialinventory/vo/MaterialInventoryRespVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import cn.idev.excel.annotation.*; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 物料库存 Response VO") | ||
| 11 | +@Data | ||
| 12 | +@ExcelIgnoreUnannotated | ||
| 13 | +public class MaterialInventoryRespVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "库存ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10980") | ||
| 16 | + @ExcelProperty("库存ID") | ||
| 17 | + private Long inventoryId; | ||
| 18 | + | ||
| 19 | + @Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29414") | ||
| 20 | + @ExcelProperty("物料ID") | ||
| 21 | + private Long materialId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "物料名称", example = "李四") | ||
| 24 | + @ExcelProperty("物料名称") | ||
| 25 | + private String materialName; | ||
| 26 | + | ||
| 27 | + @Schema(description = "物料类型ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "24853") | ||
| 28 | + @ExcelProperty("物料类型ID") | ||
| 29 | + private Long materialTypeId; | ||
| 30 | + | ||
| 31 | + @Schema(description = "耗材类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 32 | + @ExcelProperty("耗材类型名称") | ||
| 33 | + private String materialTypeName; | ||
| 34 | + | ||
| 35 | + @Schema(description = "类别ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30568") | ||
| 36 | + @ExcelProperty("类别ID") | ||
| 37 | + private Long typeId; | ||
| 38 | + | ||
| 39 | + @Schema(description = "类别名称:药品", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 40 | + @ExcelProperty("类别名称:药品") | ||
| 41 | + private String typeName; | ||
| 42 | + | ||
| 43 | + @Schema(description = "类别明细ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6252") | ||
| 44 | + @ExcelProperty("类别明细ID") | ||
| 45 | + private Long typeDetailId; | ||
| 46 | + | ||
| 47 | + @Schema(description = "类别明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 48 | + @ExcelProperty("类别明细") | ||
| 49 | + private String typeDetailName; | ||
| 50 | + | ||
| 51 | + @Schema(description = "规格", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 52 | + @ExcelProperty("规格") | ||
| 53 | + private String specifications; | ||
| 54 | + | ||
| 55 | + @Schema(description = "归属单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25626") | ||
| 56 | + @ExcelProperty("归属单位ID") | ||
| 57 | + private Long belongCompanyId; | ||
| 58 | + | ||
| 59 | + @Schema(description = "归属单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | ||
| 60 | + @ExcelProperty("归属单位") | ||
| 61 | + private String belongCompanyName; | ||
| 62 | + | ||
| 63 | + @Schema(description = "单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6480") | ||
| 64 | + @ExcelProperty("单位ID") | ||
| 65 | + private Long unitId; | ||
| 66 | + | ||
| 67 | + @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 68 | + @ExcelProperty("单位") | ||
| 69 | + private String unitName; | ||
| 70 | + | ||
| 71 | + @Schema(description = "当前库存数量", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 72 | + @ExcelProperty("当前库存数量") | ||
| 73 | + private Long currentNum; | ||
| 74 | + | ||
| 75 | + @Schema(description = "出库总数量(出库累加)", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 76 | + @ExcelProperty("出库总数量(出库累加)") | ||
| 77 | + private Long outTotalNum; | ||
| 78 | + | ||
| 79 | + @Schema(description = "库存总数量(入库累加)", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 80 | + @ExcelProperty("库存总数量(入库累加)") | ||
| 81 | + private Long inventoryTotalNum; | ||
| 82 | + | ||
| 83 | + @Schema(description = "创建时间") | ||
| 84 | + @ExcelProperty("创建时间") | ||
| 85 | + private LocalDateTime createTime; | ||
| 86 | + | ||
| 87 | + @Schema(description = "库存预警阈值", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 88 | + @ExcelProperty("库存预警阈值") | ||
| 89 | + private Long inventoryAlermNum; | ||
| 90 | + | ||
| 91 | + @Schema(description = "部门ID", example = "11349") | ||
| 92 | + @ExcelProperty("部门ID") | ||
| 93 | + private Long deptId; | ||
| 94 | + | ||
| 95 | +} | ||
| 0 | \ No newline at end of file | 96 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/materialinventory/vo/MaterialInventorySaveReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import jakarta.validation.constraints.*; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - 物料库存新增/修改 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class MaterialInventorySaveReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "库存ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10980") | ||
| 13 | + private Long inventoryId; | ||
| 14 | + | ||
| 15 | + @Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29414") | ||
| 16 | + @NotNull(message = "物料ID不能为空") | ||
| 17 | + private Long materialId; | ||
| 18 | + | ||
| 19 | + @Schema(description = "物料名称", example = "李四") | ||
| 20 | + private String materialName; | ||
| 21 | + | ||
| 22 | + @Schema(description = "物料类型ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "24853") | ||
| 23 | + @NotNull(message = "物料类型ID不能为空") | ||
| 24 | + private Long materialTypeId; | ||
| 25 | + | ||
| 26 | + @Schema(description = "耗材类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 27 | + @NotEmpty(message = "耗材类型名称不能为空") | ||
| 28 | + private String materialTypeName; | ||
| 29 | + | ||
| 30 | + @Schema(description = "类别ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30568") | ||
| 31 | + @NotNull(message = "类别ID不能为空") | ||
| 32 | + private Long typeId; | ||
| 33 | + | ||
| 34 | + @Schema(description = "类别名称:药品", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 35 | + @NotEmpty(message = "类别名称:药品不能为空") | ||
| 36 | + private String typeName; | ||
| 37 | + | ||
| 38 | + @Schema(description = "类别明细ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6252") | ||
| 39 | + @NotNull(message = "类别明细ID不能为空") | ||
| 40 | + private Long typeDetailId; | ||
| 41 | + | ||
| 42 | + @Schema(description = "类别明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 43 | + @NotEmpty(message = "类别明细不能为空") | ||
| 44 | + private String typeDetailName; | ||
| 45 | + | ||
| 46 | + @Schema(description = "规格", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 47 | + @NotEmpty(message = "规格不能为空") | ||
| 48 | + private String specifications; | ||
| 49 | + | ||
| 50 | + @Schema(description = "归属单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25626") | ||
| 51 | + @NotNull(message = "归属单位ID不能为空") | ||
| 52 | + private Long belongCompanyId; | ||
| 53 | + | ||
| 54 | + @Schema(description = "归属单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | ||
| 55 | + @NotEmpty(message = "归属单位不能为空") | ||
| 56 | + private String belongCompanyName; | ||
| 57 | + | ||
| 58 | + @Schema(description = "单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6480") | ||
| 59 | + @NotNull(message = "单位ID不能为空") | ||
| 60 | + private Long unitId; | ||
| 61 | + | ||
| 62 | + @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 63 | + @NotEmpty(message = "单位不能为空") | ||
| 64 | + private String unitName; | ||
| 65 | + | ||
| 66 | + @Schema(description = "当前库存数量", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 67 | + @NotNull(message = "当前库存数量不能为空") | ||
| 68 | + private Long currentNum; | ||
| 69 | + | ||
| 70 | + @Schema(description = "出库总数量(出库累加)", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 71 | + @NotNull(message = "出库总数量(出库累加)不能为空") | ||
| 72 | + private Long outTotalNum; | ||
| 73 | + | ||
| 74 | + @Schema(description = "库存总数量(入库累加)", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 75 | + @NotNull(message = "库存总数量(入库累加)不能为空") | ||
| 76 | + private Long inventoryTotalNum; | ||
| 77 | + | ||
| 78 | + @Schema(description = "库存预警阈值", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 79 | + @NotNull(message = "库存预警阈值不能为空") | ||
| 80 | + private Long inventoryAlermNum; | ||
| 81 | + | ||
| 82 | + @Schema(description = "部门ID", example = "11349") | ||
| 83 | + private Long deptId; | ||
| 84 | + | ||
| 85 | +} | ||
| 0 | \ No newline at end of file | 86 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/materialinventoryin/vo/MaterialInventoryInSaveReqVO.java
| @@ -15,53 +15,14 @@ public class MaterialInventoryInSaveReqVO { | @@ -15,53 +15,14 @@ public class MaterialInventoryInSaveReqVO { | ||
| 15 | @Schema(description = "入库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16290") | 15 | @Schema(description = "入库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16290") |
| 16 | private Long id; | 16 | private Long id; |
| 17 | 17 | ||
| 18 | - @Schema(description = "入库批次号", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 19 | - @NotEmpty(message = "入库批次号不能为空") | ||
| 20 | - private String inventoryInNo; | ||
| 21 | - | ||
| 22 | @Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7335") | 18 | @Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7335") |
| 23 | @NotNull(message = "物料ID不能为空") | 19 | @NotNull(message = "物料ID不能为空") |
| 24 | private Long materialId; | 20 | private Long materialId; |
| 25 | 21 | ||
| 26 | - @Schema(description = "物料名称", example = "芋艿") | ||
| 27 | - private String materialName; | ||
| 28 | - | ||
| 29 | - @Schema(description = "物料类型ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "27813") | ||
| 30 | - @NotNull(message = "物料类型ID不能为空") | ||
| 31 | - private Long materialTypeId; | ||
| 32 | - | ||
| 33 | - @Schema(description = "耗材类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | ||
| 34 | - @NotEmpty(message = "耗材类型名称不能为空") | ||
| 35 | - private String materialTypeName; | ||
| 36 | - | ||
| 37 | - @Schema(description = "类别ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "24913") | ||
| 38 | - @NotNull(message = "类别ID不能为空") | ||
| 39 | - private Long typeId; | ||
| 40 | - | ||
| 41 | - @Schema(description = "类别名称:药品", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | ||
| 42 | - @NotEmpty(message = "类别名称:药品不能为空") | ||
| 43 | - private String typeName; | ||
| 44 | - | ||
| 45 | - @Schema(description = "类别明细ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "53") | ||
| 46 | - @NotNull(message = "类别明细ID不能为空") | ||
| 47 | - private Long typeDetailId; | ||
| 48 | - | ||
| 49 | - @Schema(description = "类别明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") | ||
| 50 | - @NotEmpty(message = "类别明细不能为空") | ||
| 51 | - private String typeDetailName; | ||
| 52 | - | ||
| 53 | @Schema(description = "规格", requiredMode = Schema.RequiredMode.REQUIRED) | 22 | @Schema(description = "规格", requiredMode = Schema.RequiredMode.REQUIRED) |
| 54 | @NotEmpty(message = "规格不能为空") | 23 | @NotEmpty(message = "规格不能为空") |
| 55 | private String specifications; | 24 | private String specifications; |
| 56 | 25 | ||
| 57 | - @Schema(description = "归属单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "27639") | ||
| 58 | - @NotNull(message = "归属单位ID不能为空") | ||
| 59 | - private Long belongCompanyId; | ||
| 60 | - | ||
| 61 | - @Schema(description = "归属单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 62 | - @NotEmpty(message = "归属单位不能为空") | ||
| 63 | - private String belongCompanyName; | ||
| 64 | - | ||
| 65 | @Schema(description = "入库数量", requiredMode = Schema.RequiredMode.REQUIRED) | 26 | @Schema(description = "入库数量", requiredMode = Schema.RequiredMode.REQUIRED) |
| 66 | @NotNull(message = "入库数量不能为空") | 27 | @NotNull(message = "入库数量不能为空") |
| 67 | private Long inInventoryNum; | 28 | private Long inInventoryNum; |
| @@ -70,14 +31,6 @@ public class MaterialInventoryInSaveReqVO { | @@ -70,14 +31,6 @@ public class MaterialInventoryInSaveReqVO { | ||
| 70 | @NotNull(message = "单价不能为空") | 31 | @NotNull(message = "单价不能为空") |
| 71 | private BigDecimal materialPrice; | 32 | private BigDecimal materialPrice; |
| 72 | 33 | ||
| 73 | - @Schema(description = "单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11362") | ||
| 74 | - @NotNull(message = "单位ID不能为空") | ||
| 75 | - private Long unitId; | ||
| 76 | - | ||
| 77 | - @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | ||
| 78 | - @NotEmpty(message = "单位不能为空") | ||
| 79 | - private String unitName; | ||
| 80 | - | ||
| 81 | @Schema(description = "采购日期", requiredMode = Schema.RequiredMode.REQUIRED) | 34 | @Schema(description = "采购日期", requiredMode = Schema.RequiredMode.REQUIRED) |
| 82 | @NotNull(message = "采购日期不能为空") | 35 | @NotNull(message = "采购日期不能为空") |
| 83 | private LocalDateTime buyDate; | 36 | private LocalDateTime buyDate; |
| @@ -94,7 +47,4 @@ public class MaterialInventoryInSaveReqVO { | @@ -94,7 +47,4 @@ public class MaterialInventoryInSaveReqVO { | ||
| 94 | @NotEmpty(message = "联系人 电话不能为空") | 47 | @NotEmpty(message = "联系人 电话不能为空") |
| 95 | private String contactsPhone; | 48 | private String contactsPhone; |
| 96 | 49 | ||
| 97 | - @Schema(description = "部门ID", example = "18025") | ||
| 98 | - private Long deptId; | ||
| 99 | - | ||
| 100 | -} | ||
| 101 | \ No newline at end of file | 50 | \ No newline at end of file |
| 51 | +} |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/materialinventoryout/vo/MaterialInventoryOutSaveReqVO.java
| @@ -14,10 +14,6 @@ public class MaterialInventoryOutSaveReqVO { | @@ -14,10 +14,6 @@ public class MaterialInventoryOutSaveReqVO { | ||
| 14 | @Schema(description = "入库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18713") | 14 | @Schema(description = "入库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18713") |
| 15 | private Long id; | 15 | private Long id; |
| 16 | 16 | ||
| 17 | - @Schema(description = "入库批次号", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 18 | - @NotEmpty(message = "入库批次号不能为空") | ||
| 19 | - private String inventoryOutNo; | ||
| 20 | - | ||
| 21 | @Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "14541") | 17 | @Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "14541") |
| 22 | @NotNull(message = "物料ID不能为空") | 18 | @NotNull(message = "物料ID不能为空") |
| 23 | private Long materialId; | 19 | private Long materialId; |
| @@ -25,67 +21,12 @@ public class MaterialInventoryOutSaveReqVO { | @@ -25,67 +21,12 @@ public class MaterialInventoryOutSaveReqVO { | ||
| 25 | @Schema(description = "物料名称", example = "芋艿") | 21 | @Schema(description = "物料名称", example = "芋艿") |
| 26 | private String materialName; | 22 | private String materialName; |
| 27 | 23 | ||
| 28 | - @Schema(description = "物料类型ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9209") | ||
| 29 | - @NotNull(message = "物料类型ID不能为空") | ||
| 30 | - private Long materialTypeId; | ||
| 31 | - | ||
| 32 | - @Schema(description = "耗材类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 33 | - @NotEmpty(message = "耗材类型名称不能为空") | ||
| 34 | - private String materialTypeName; | ||
| 35 | - | ||
| 36 | - @Schema(description = "类别ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "12624") | ||
| 37 | - @NotNull(message = "类别ID不能为空") | ||
| 38 | - private Long typeId; | ||
| 39 | - | ||
| 40 | - @Schema(description = "类别名称:药品", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 41 | - @NotEmpty(message = "类别名称:药品不能为空") | ||
| 42 | - private String typeName; | ||
| 43 | - | ||
| 44 | - @Schema(description = "类别明细ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "24611") | ||
| 45 | - @NotNull(message = "类别明细ID不能为空") | ||
| 46 | - private Long typeDetailId; | ||
| 47 | - | ||
| 48 | - @Schema(description = "类别明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 49 | - @NotEmpty(message = "类别明细不能为空") | ||
| 50 | - private String typeDetailName; | ||
| 51 | - | ||
| 52 | - @Schema(description = "规格", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 53 | - @NotEmpty(message = "规格不能为空") | ||
| 54 | - private String specifications; | ||
| 55 | - | ||
| 56 | - @Schema(description = "归属单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17128") | ||
| 57 | - @NotNull(message = "归属单位ID不能为空") | ||
| 58 | - private Long belongCompanyId; | ||
| 59 | - | ||
| 60 | - @Schema(description = "归属单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | ||
| 61 | - @NotEmpty(message = "归属单位不能为空") | ||
| 62 | - private String belongCompanyName; | ||
| 63 | - | ||
| 64 | @Schema(description = "出库数量", requiredMode = Schema.RequiredMode.REQUIRED) | 24 | @Schema(description = "出库数量", requiredMode = Schema.RequiredMode.REQUIRED) |
| 65 | @NotNull(message = "出库数量不能为空") | 25 | @NotNull(message = "出库数量不能为空") |
| 66 | private Long outInventoryNum; | 26 | private Long outInventoryNum; |
| 67 | 27 | ||
| 68 | - @Schema(description = "单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1033") | ||
| 69 | - @NotNull(message = "单位ID不能为空") | ||
| 70 | - private Long unitId; | ||
| 71 | - | ||
| 72 | - @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 73 | - @NotEmpty(message = "单位不能为空") | ||
| 74 | - private String unitName; | ||
| 75 | - | ||
| 76 | @Schema(description = "出库日期", requiredMode = Schema.RequiredMode.REQUIRED) | 28 | @Schema(description = "出库日期", requiredMode = Schema.RequiredMode.REQUIRED) |
| 77 | @NotNull(message = "出库日期不能为空") | 29 | @NotNull(message = "出库日期不能为空") |
| 78 | private LocalDateTime outDate; | 30 | private LocalDateTime outDate; |
| 79 | 31 | ||
| 80 | - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对") | ||
| 81 | - @NotEmpty(message = "备注不能为空") | ||
| 82 | - private String remark; | ||
| 83 | - | ||
| 84 | - @Schema(description = "部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "22618") | ||
| 85 | - @NotNull(message = "部门ID不能为空") | ||
| 86 | - private Long deptId; | ||
| 87 | - | ||
| 88 | - @Schema(description = "类型: 1:手动出库;2:养护类出库", example = "1") | ||
| 89 | - private Integer type; | ||
| 90 | - | ||
| 91 | -} | ||
| 92 | \ No newline at end of file | 32 | \ No newline at end of file |
| 33 | +} |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/materialinventory/MaterialInventoryDO.java
| 1 | package com.zteits.urbanops.module.garden.dal.dataobject.materialinventory; | 1 | package com.zteits.urbanops.module.garden.dal.dataobject.materialinventory; |
| 2 | 2 | ||
| 3 | -import com.baomidou.mybatisplus.annotation.TableId; | ||
| 4 | -import com.baomidou.mybatisplus.annotation.TableName; | 3 | +import lombok.*; |
| 4 | +import java.util.*; | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.*; | ||
| 5 | import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | 8 | import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; |
| 6 | -import lombok.Data; | ||
| 7 | 9 | ||
| 10 | +/** | ||
| 11 | + * 物料库存 DO | ||
| 12 | + * | ||
| 13 | + * @author 超级管理员 | ||
| 14 | + */ | ||
| 8 | @TableName("garden_material_inventory") | 15 | @TableName("garden_material_inventory") |
| 16 | +@KeySequence("garden_material_inventory_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 9 | @Data | 17 | @Data |
| 18 | +@EqualsAndHashCode(callSuper = true) | ||
| 19 | +@ToString(callSuper = true) | ||
| 20 | +@Builder | ||
| 21 | +@NoArgsConstructor | ||
| 22 | +@AllArgsConstructor | ||
| 10 | public class MaterialInventoryDO extends BaseDO { | 23 | public class MaterialInventoryDO extends BaseDO { |
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 库存ID | ||
| 27 | + */ | ||
| 11 | @TableId | 28 | @TableId |
| 12 | private Long inventoryId; | 29 | private Long inventoryId; |
| 30 | + /** | ||
| 31 | + * 物料ID | ||
| 32 | + */ | ||
| 13 | private Long materialId; | 33 | private Long materialId; |
| 34 | + /** | ||
| 35 | + * 物料名称 | ||
| 36 | + */ | ||
| 14 | private String materialName; | 37 | private String materialName; |
| 38 | + /** | ||
| 39 | + * 物料类型ID | ||
| 40 | + */ | ||
| 15 | private Long materialTypeId; | 41 | private Long materialTypeId; |
| 42 | + /** | ||
| 43 | + * 耗材类型名称 | ||
| 44 | + */ | ||
| 16 | private String materialTypeName; | 45 | private String materialTypeName; |
| 46 | + /** | ||
| 47 | + * 类别ID | ||
| 48 | + */ | ||
| 17 | private Long typeId; | 49 | private Long typeId; |
| 50 | + /** | ||
| 51 | + * 类别名称:药品 | ||
| 52 | + */ | ||
| 18 | private String typeName; | 53 | private String typeName; |
| 54 | + /** | ||
| 55 | + * 类别明细ID | ||
| 56 | + */ | ||
| 19 | private Long typeDetailId; | 57 | private Long typeDetailId; |
| 58 | + /** | ||
| 59 | + * 类别明细 | ||
| 60 | + */ | ||
| 20 | private String typeDetailName; | 61 | private String typeDetailName; |
| 62 | + /** | ||
| 63 | + * 规格 | ||
| 64 | + */ | ||
| 21 | private String specifications; | 65 | private String specifications; |
| 66 | + /** | ||
| 67 | + * 归属单位ID | ||
| 68 | + */ | ||
| 22 | private Long belongCompanyId; | 69 | private Long belongCompanyId; |
| 70 | + /** | ||
| 71 | + * 归属单位 | ||
| 72 | + */ | ||
| 23 | private String belongCompanyName; | 73 | private String belongCompanyName; |
| 74 | + /** | ||
| 75 | + * 单位ID | ||
| 76 | + */ | ||
| 24 | private Long unitId; | 77 | private Long unitId; |
| 78 | + /** | ||
| 79 | + * 单位 | ||
| 80 | + */ | ||
| 25 | private String unitName; | 81 | private String unitName; |
| 82 | + /** | ||
| 83 | + * 当前库存数量 | ||
| 84 | + */ | ||
| 26 | private Long currentNum; | 85 | private Long currentNum; |
| 86 | + /** | ||
| 87 | + * 出库总数量(出库累加) | ||
| 88 | + */ | ||
| 27 | private Long outTotalNum; | 89 | private Long outTotalNum; |
| 90 | + /** | ||
| 91 | + * 库存总数量(入库累加) | ||
| 92 | + */ | ||
| 28 | private Long inventoryTotalNum; | 93 | private Long inventoryTotalNum; |
| 29 | - private String status; | 94 | + /** |
| 95 | + * 库存预警阈值 | ||
| 96 | + */ | ||
| 30 | private Long inventoryAlermNum; | 97 | private Long inventoryAlermNum; |
| 98 | + /** | ||
| 99 | + * 部门ID | ||
| 100 | + */ | ||
| 31 | private Long deptId; | 101 | private Long deptId; |
| 32 | -} | 102 | + |
| 103 | + | ||
| 104 | +} | ||
| 33 | \ No newline at end of file | 105 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/materialinventory/MaterialInventoryMapper.java
| 1 | package com.zteits.urbanops.module.garden.dal.mysql.materialinventory; | 1 | package com.zteits.urbanops.module.garden.dal.mysql.materialinventory; |
| 2 | 2 | ||
| 3 | -import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | 3 | +import java.util.*; |
| 4 | + | ||
| 5 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 4 | import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX; | 6 | import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | +import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO; | 8 | import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO; |
| 6 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | +import com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo.*; | ||
| 7 | 11 | ||
| 12 | +/** | ||
| 13 | + * 物料库存 Mapper | ||
| 14 | + * | ||
| 15 | + * @author 超级管理员 | ||
| 16 | + */ | ||
| 8 | @Mapper | 17 | @Mapper |
| 9 | public interface MaterialInventoryMapper extends BaseMapperX<MaterialInventoryDO> { | 18 | public interface MaterialInventoryMapper extends BaseMapperX<MaterialInventoryDO> { |
| 10 | 19 | ||
| 11 | - default MaterialInventoryDO selectByMaterialId(Long materialId) { | ||
| 12 | - return selectOne(new LambdaQueryWrapperX<MaterialInventoryDO>().eq(MaterialInventoryDO::getMaterialId, materialId)); | ||
| 13 | - } | ||
| 14 | - | ||
| 15 | - default MaterialInventoryDO selectByTypeDetailId(Long typeDetailId, Long companyId) { | ||
| 16 | - return selectOne(new LambdaQueryWrapperX<MaterialInventoryDO>() | ||
| 17 | - .eq(MaterialInventoryDO::getTypeDetailId, typeDetailId) | ||
| 18 | - .eq(MaterialInventoryDO::getBelongCompanyId, companyId)); | ||
| 19 | - } | ||
| 20 | - | ||
| 21 | - default int updateInventoryByMaterialId(Long inventoryId, Long outNum) { | ||
| 22 | - MaterialInventoryDO inv = selectById(inventoryId); | ||
| 23 | - if (inv == null) return 0; | ||
| 24 | - MaterialInventoryDO upd = new MaterialInventoryDO(); | ||
| 25 | - upd.setInventoryId(inventoryId); | ||
| 26 | - upd.setCurrentNum(inv.getCurrentNum() - outNum); | ||
| 27 | - upd.setOutTotalNum(inv.getOutTotalNum() == null ? outNum : inv.getOutTotalNum() + outNum); | ||
| 28 | - return updateById(upd); | 20 | + default PageResult<MaterialInventoryDO> selectPage(MaterialInventoryPageReqVO reqVO) { |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<MaterialInventoryDO>() | ||
| 22 | + .eqIfPresent(MaterialInventoryDO::getMaterialId, reqVO.getMaterialId()) | ||
| 23 | + .likeIfPresent(MaterialInventoryDO::getMaterialName, reqVO.getMaterialName()) | ||
| 24 | + .eqIfPresent(MaterialInventoryDO::getMaterialTypeId, reqVO.getMaterialTypeId()) | ||
| 25 | + .likeIfPresent(MaterialInventoryDO::getMaterialTypeName, reqVO.getMaterialTypeName()) | ||
| 26 | + .eqIfPresent(MaterialInventoryDO::getTypeId, reqVO.getTypeId()) | ||
| 27 | + .likeIfPresent(MaterialInventoryDO::getTypeName, reqVO.getTypeName()) | ||
| 28 | + .eqIfPresent(MaterialInventoryDO::getTypeDetailId, reqVO.getTypeDetailId()) | ||
| 29 | + .likeIfPresent(MaterialInventoryDO::getTypeDetailName, reqVO.getTypeDetailName()) | ||
| 30 | + .eqIfPresent(MaterialInventoryDO::getSpecifications, reqVO.getSpecifications()) | ||
| 31 | + .eqIfPresent(MaterialInventoryDO::getBelongCompanyId, reqVO.getBelongCompanyId()) | ||
| 32 | + .likeIfPresent(MaterialInventoryDO::getBelongCompanyName, reqVO.getBelongCompanyName()) | ||
| 33 | + .eqIfPresent(MaterialInventoryDO::getUnitId, reqVO.getUnitId()) | ||
| 34 | + .likeIfPresent(MaterialInventoryDO::getUnitName, reqVO.getUnitName()) | ||
| 35 | + .eqIfPresent(MaterialInventoryDO::getCurrentNum, reqVO.getCurrentNum()) | ||
| 36 | + .eqIfPresent(MaterialInventoryDO::getOutTotalNum, reqVO.getOutTotalNum()) | ||
| 37 | + .eqIfPresent(MaterialInventoryDO::getInventoryTotalNum, reqVO.getInventoryTotalNum()) | ||
| 38 | + .betweenIfPresent(MaterialInventoryDO::getCreateTime, reqVO.getCreateTime()) | ||
| 39 | + .eqIfPresent(MaterialInventoryDO::getInventoryAlermNum, reqVO.getInventoryAlermNum()) | ||
| 40 | + .eqIfPresent(MaterialInventoryDO::getDeptId, reqVO.getDeptId()) | ||
| 41 | + .orderByDesc(MaterialInventoryDO::getMaterialId)); | ||
| 29 | } | 42 | } |
| 30 | 43 | ||
| 31 | - default int updateInventoryAlarmNum(Long materialId, Long inventoryAlermNum) { | ||
| 32 | - MaterialInventoryDO inv = selectByMaterialId(materialId); | ||
| 33 | - if (inv == null) return 0; | ||
| 34 | - MaterialInventoryDO upd = new MaterialInventoryDO(); | ||
| 35 | - upd.setInventoryId(inv.getInventoryId()); | ||
| 36 | - upd.setInventoryAlermNum(inventoryAlermNum); | ||
| 37 | - return updateById(upd); | ||
| 38 | - } | ||
| 39 | } | 44 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/ErrorCodeConstants.java
| @@ -86,5 +86,5 @@ public interface ErrorCodeConstants { | @@ -86,5 +86,5 @@ public interface ErrorCodeConstants { | ||
| 86 | ErrorCode MATERIAL_INVENTORY_IN_NOT_EXISTS = new ErrorCode(1-100-004-004, "物料入库不存在"); | 86 | ErrorCode MATERIAL_INVENTORY_IN_NOT_EXISTS = new ErrorCode(1-100-004-004, "物料入库不存在"); |
| 87 | 87 | ||
| 88 | ErrorCode MATERIAL_INVENTORY_OUT_NOT_EXISTS = new ErrorCode(1-100-004-005, "物料出库不存在"); | 88 | ErrorCode MATERIAL_INVENTORY_OUT_NOT_EXISTS = new ErrorCode(1-100-004-005, "物料出库不存在"); |
| 89 | - | 89 | + ErrorCode MATERIAL_INVENTORY_NOT_EXISTS = new ErrorCode(1-100-004-006, "物料库存不存在"); |
| 90 | } | 90 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventory/MaterialInventoryService.java
| 1 | package com.zteits.urbanops.module.garden.service.materialinventory; | 1 | package com.zteits.urbanops.module.garden.service.materialinventory; |
| 2 | 2 | ||
| 3 | -import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 4 | -import com.zteits.urbanops.framework.common.pojo.PageResult; | 3 | +import java.util.*; |
| 4 | +import jakarta.validation.*; | ||
| 5 | +import com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo.*; | ||
| 5 | import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO; | 6 | import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO; |
| 7 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 8 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 6 | 9 | ||
| 10 | +/** | ||
| 11 | + * 物料库存 Service 接口 | ||
| 12 | + * | ||
| 13 | + * @author 超级管理员 | ||
| 14 | + */ | ||
| 7 | public interface MaterialInventoryService { | 15 | public interface MaterialInventoryService { |
| 8 | - PageResult<MaterialInventoryDO> selectPage(PageParam pageParam, MaterialInventoryDO where); | ||
| 9 | - Boolean updateInventoryAlarmNum(Long materialId, Long alermNum); | 16 | + |
| 17 | + /** | ||
| 18 | + * 创建物料库存 | ||
| 19 | + * | ||
| 20 | + * @param createReqVO 创建信息 | ||
| 21 | + * @return 编号 | ||
| 22 | + */ | ||
| 23 | + Long createMaterialInventory(@Valid MaterialInventorySaveReqVO createReqVO); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 更新物料库存 | ||
| 27 | + * | ||
| 28 | + * @param updateReqVO 更新信息 | ||
| 29 | + */ | ||
| 30 | + void updateMaterialInventory(@Valid MaterialInventorySaveReqVO updateReqVO); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 删除物料库存 | ||
| 34 | + * | ||
| 35 | + * @param id 编号 | ||
| 36 | + */ | ||
| 37 | + void deleteMaterialInventory(Long id); | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 批量删除物料库存 | ||
| 41 | + * | ||
| 42 | + * @param ids 编号 | ||
| 43 | + */ | ||
| 44 | + void deleteMaterialInventoryListByIds(List<Long> ids); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 获得物料库存 | ||
| 48 | + * | ||
| 49 | + * @param id 编号 | ||
| 50 | + * @return 物料库存 | ||
| 51 | + */ | ||
| 52 | + MaterialInventoryDO getMaterialInventory(Long id); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 获得物料库存分页 | ||
| 56 | + * | ||
| 57 | + * @param pageReqVO 分页查询 | ||
| 58 | + * @return 物料库存分页 | ||
| 59 | + */ | ||
| 60 | + PageResult<MaterialInventoryDO> getMaterialInventoryPage(MaterialInventoryPageReqVO pageReqVO); | ||
| 61 | + | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * 新增物料库存 | ||
| 65 | + * | ||
| 66 | + * @param materialInventory 物料库存 | ||
| 67 | + * @return 结果 | ||
| 68 | + */ | ||
| 69 | + public int insertMaterialInventory(MaterialInventoryDO materialInventory); | ||
| 70 | + /** | ||
| 71 | + * 更新物料库存 | ||
| 72 | + * | ||
| 73 | + * @param materialInventory 物料库存 | ||
| 74 | + * @return 结果 | ||
| 75 | + */ | ||
| 76 | + public int updateTdMaterialInventory(MaterialInventoryDO materialInventory); | ||
| 77 | + /** | ||
| 78 | + * @Author wangqian | ||
| 79 | + * @Description 查询物料信息根据 | ||
| 80 | + * @Date 2025/11/28 23:36 | ||
| 81 | + * @Param materialId | ||
| 82 | + */ | ||
| 83 | + MaterialInventoryDO selectTdMaterialInventoryByMaterialId(Long materialId); | ||
| 84 | + | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * 更新出库库库存信息 | ||
| 88 | + * @param inventoryId | ||
| 89 | + * @param outNum 出库数量 | ||
| 90 | + * @return | ||
| 91 | + */ | ||
| 92 | + int updateInVentoryByMaterialId(MaterialInventoryDO materialInventory, Long outNum); | ||
| 10 | } | 93 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventory/MaterialInventoryServiceImpl.java
| 1 | package com.zteits.urbanops.module.garden.service.materialinventory; | 1 | package com.zteits.urbanops.module.garden.service.materialinventory; |
| 2 | 2 | ||
| 3 | -import com.zteits.urbanops.framework.common.pojo.PageParam; | 3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| 4 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||
| 4 | import com.zteits.urbanops.framework.common.pojo.PageResult; | 5 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 6 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 7 | +import com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo.MaterialInventoryPageReqVO; | ||
| 8 | +import com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo.MaterialInventorySaveReqVO; | ||
| 5 | import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO; | 9 | import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO; |
| 6 | import com.zteits.urbanops.module.garden.dal.mysql.materialinventory.MaterialInventoryMapper; | 10 | import com.zteits.urbanops.module.garden.dal.mysql.materialinventory.MaterialInventoryMapper; |
| 7 | import jakarta.annotation.Resource; | 11 | import jakarta.annotation.Resource; |
| 8 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 13 | +import org.springframework.validation.annotation.Validated; | ||
| 9 | 14 | ||
| 15 | +import java.util.List; | ||
| 16 | + | ||
| 17 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 18 | +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.MATERIAL_INVENTORY_NOT_EXISTS; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * 物料库存 Service 实现类 | ||
| 22 | + * | ||
| 23 | + * @author 超级管理员 | ||
| 24 | + */ | ||
| 10 | @Service | 25 | @Service |
| 26 | +@Validated | ||
| 11 | public class MaterialInventoryServiceImpl implements MaterialInventoryService { | 27 | public class MaterialInventoryServiceImpl implements MaterialInventoryService { |
| 12 | 28 | ||
| 13 | @Resource | 29 | @Resource |
| 14 | - private MaterialInventoryMapper mapper; | 30 | + private MaterialInventoryMapper materialInventoryMapper; |
| 31 | + | ||
| 32 | + @Override | ||
| 33 | + public Long createMaterialInventory(MaterialInventorySaveReqVO createReqVO) { | ||
| 34 | + // 插入 | ||
| 35 | + MaterialInventoryDO materialInventory = BeanUtils.toBean(createReqVO, MaterialInventoryDO.class); | ||
| 36 | + materialInventoryMapper.insert(materialInventory); | ||
| 37 | + | ||
| 38 | + // 返回 | ||
| 39 | + return materialInventory.getMaterialId(); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + @Override | ||
| 43 | + public void updateMaterialInventory(MaterialInventorySaveReqVO updateReqVO) { | ||
| 44 | + // 校验存在 | ||
| 45 | + validateMaterialInventoryExists(updateReqVO.getMaterialId()); | ||
| 46 | + // 更新 | ||
| 47 | + MaterialInventoryDO updateObj = BeanUtils.toBean(updateReqVO, MaterialInventoryDO.class); | ||
| 48 | + materialInventoryMapper.updateById(updateObj); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + public void deleteMaterialInventory(Long id) { | ||
| 53 | + // 校验存在 | ||
| 54 | + validateMaterialInventoryExists(id); | ||
| 55 | + // 删除 | ||
| 56 | + materialInventoryMapper.deleteById(id); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + public void deleteMaterialInventoryListByIds(List<Long> ids) { | ||
| 61 | + // 删除 | ||
| 62 | + materialInventoryMapper.deleteByIds(ids); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + | ||
| 66 | + private void validateMaterialInventoryExists(Long id) { | ||
| 67 | + if (materialInventoryMapper.selectById(id) == null) { | ||
| 68 | + throw exception(MATERIAL_INVENTORY_NOT_EXISTS); | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Override | ||
| 73 | + public MaterialInventoryDO getMaterialInventory(Long id) { | ||
| 74 | + return materialInventoryMapper.selectById(id); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + @Override | ||
| 78 | + public PageResult<MaterialInventoryDO> getMaterialInventoryPage(MaterialInventoryPageReqVO pageReqVO) { | ||
| 79 | + return materialInventoryMapper.selectPage(pageReqVO); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @Override | ||
| 83 | + public int insertMaterialInventory(MaterialInventoryDO materialInventory) { | ||
| 84 | + LambdaQueryWrapper<MaterialInventoryDO> queryWrapper = Wrappers.lambdaQuery(); | ||
| 85 | + queryWrapper.eq(MaterialInventoryDO::getBelongCompanyId, materialInventory.getBelongCompanyId()); | ||
| 86 | + queryWrapper.eq(MaterialInventoryDO::getTypeDetailId, materialInventory.getTypeDetailId()); | ||
| 87 | + MaterialInventoryDO object = materialInventoryMapper.selectOne(queryWrapper); | ||
| 88 | + if(object != null){ | ||
| 89 | + object.setInventoryTotalNum(object.getInventoryTotalNum()+ materialInventory.getCurrentNum()); | ||
| 90 | + object.setCurrentNum(object.getCurrentNum()+materialInventory.getCurrentNum()); | ||
| 91 | + return materialInventoryMapper.updateById(object); | ||
| 92 | + } else { | ||
| 93 | + return materialInventoryMapper.insert(materialInventory); | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + @Override | ||
| 97 | + public int updateTdMaterialInventory(MaterialInventoryDO materialInventory) { | ||
| 98 | + // 校验存在 | ||
| 99 | + validateMaterialInventoryExists(materialInventory.getInventoryId()); | ||
| 100 | + | ||
| 101 | + return materialInventoryMapper.updateById(materialInventory); | ||
| 102 | + } | ||
| 15 | 103 | ||
| 16 | @Override | 104 | @Override |
| 17 | - public PageResult<MaterialInventoryDO> selectPage(PageParam pageParam, MaterialInventoryDO where) { | ||
| 18 | - return mapper.selectPage(pageParam, null, new com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX<MaterialInventoryDO>() | ||
| 19 | - .eqIfPresent(MaterialInventoryDO::getMaterialId, where.getMaterialId()) | ||
| 20 | - .likeIfPresent(MaterialInventoryDO::getMaterialName, where.getMaterialName()) | ||
| 21 | - .eqIfPresent(MaterialInventoryDO::getTypeDetailId, where.getTypeDetailId()) | ||
| 22 | - .eqIfPresent(MaterialInventoryDO::getBelongCompanyId, where.getBelongCompanyId()) | ||
| 23 | - .orderByDesc(MaterialInventoryDO::getUpdateTime)); | 105 | + public MaterialInventoryDO selectTdMaterialInventoryByMaterialId(Long materialId) { |
| 106 | + LambdaQueryWrapper<MaterialInventoryDO> queryWrapper = Wrappers.lambdaQuery(); | ||
| 107 | + queryWrapper.eq(MaterialInventoryDO::getTypeDetailId, materialId); | ||
| 108 | + return materialInventoryMapper.selectOne(queryWrapper); | ||
| 24 | } | 109 | } |
| 25 | 110 | ||
| 26 | @Override | 111 | @Override |
| 27 | - public Boolean updateInventoryAlarmNum(Long materialId, Long alermNum) { | ||
| 28 | - return mapper.updateInventoryAlarmNum(materialId, alermNum) > 0; | 112 | + public int updateInVentoryByMaterialId(MaterialInventoryDO materialInventory, Long outNum) { |
| 113 | + MaterialInventoryDO out = new MaterialInventoryDO(); | ||
| 114 | + out.setInventoryId(materialInventory.getInventoryId()); | ||
| 115 | + out.setOutTotalNum(materialInventory.getInventoryTotalNum() + outNum); | ||
| 116 | + out.setCurrentNum(materialInventory.getCurrentNum() - outNum); | ||
| 117 | + return materialInventoryMapper.updateById(materialInventory); | ||
| 29 | } | 118 | } |
| 30 | } | 119 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventoryin/MaterialInventoryInServiceImpl.java
| 1 | package com.zteits.urbanops.module.garden.service.materialinventoryin; | 1 | package com.zteits.urbanops.module.garden.service.materialinventoryin; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.util.RandomUtil; | ||
| 5 | +import com.zteits.urbanops.module.garden.dal.dataobject.material.MaterialDO; | ||
| 6 | +import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO; | ||
| 7 | +import com.zteits.urbanops.module.garden.dal.mysql.material.MaterialMapper; | ||
| 8 | +import com.zteits.urbanops.module.garden.service.materialinventory.MaterialInventoryService; | ||
| 4 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
| 5 | import jakarta.annotation.Resource; | 10 | import jakarta.annotation.Resource; |
| 6 | import org.springframework.validation.annotation.Validated; | 11 | import org.springframework.validation.annotation.Validated; |
| @@ -15,9 +20,13 @@ import com.zteits.urbanops.framework.common.util.object.BeanUtils; | @@ -15,9 +20,13 @@ import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 15 | 20 | ||
| 16 | import com.zteits.urbanops.module.garden.dal.mysql.materialinventoryin.MaterialInventoryInMapper; | 21 | import com.zteits.urbanops.module.garden.dal.mysql.materialinventoryin.MaterialInventoryInMapper; |
| 17 | 22 | ||
| 23 | +import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; | ||
| 18 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | 24 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 25 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0; | ||
| 19 | import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.convertList; | 26 | import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.convertList; |
| 20 | import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.diffList; | 27 | import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.diffList; |
| 28 | +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; | ||
| 29 | +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserDeptId; | ||
| 21 | import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; | 30 | import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; |
| 22 | 31 | ||
| 23 | /** | 32 | /** |
| @@ -32,38 +41,127 @@ public class MaterialInventoryInServiceImpl implements MaterialInventoryInServic | @@ -32,38 +41,127 @@ public class MaterialInventoryInServiceImpl implements MaterialInventoryInServic | ||
| 32 | @Resource | 41 | @Resource |
| 33 | private MaterialInventoryInMapper materialInventoryInMapper; | 42 | private MaterialInventoryInMapper materialInventoryInMapper; |
| 34 | 43 | ||
| 44 | + @Resource | ||
| 45 | + private MaterialMapper materialMapper; | ||
| 46 | + | ||
| 47 | + @Resource | ||
| 48 | + private MaterialInventoryService materialInventoryService; | ||
| 49 | + | ||
| 35 | @Override | 50 | @Override |
| 51 | + @Transactional | ||
| 36 | public Long createMaterialInventoryIn(MaterialInventoryInSaveReqVO createReqVO) { | 52 | public Long createMaterialInventoryIn(MaterialInventoryInSaveReqVO createReqVO) { |
| 53 | + //参数校验 | ||
| 54 | + MaterialDO material = materialMapper.selectOne(MaterialDO::getMaterialId,createReqVO.getMaterialId()); | ||
| 55 | + if(null == material){ | ||
| 56 | + throw exception0(BAD_REQUEST.getCode(), "无效参数-materialId"); | ||
| 57 | + } | ||
| 58 | + MaterialInventoryInDO in = new MaterialInventoryInDO(); | ||
| 59 | + in.setInventoryInNo(System.currentTimeMillis()+ RandomUtil.randomInt(10, 100000)+""); | ||
| 60 | + in.setMaterialId(createReqVO.getMaterialId()); | ||
| 61 | + in.setMaterialName(material.getMaterialName()); | ||
| 62 | + in.setMaterialTypeId(material.getMaterialTypeId()); | ||
| 63 | + in.setMaterialTypeName(material.getMaterialTypeName()); | ||
| 64 | + in.setTypeId(material.getTypeId()); | ||
| 65 | + in.setTypeName(material.getTypeName()); | ||
| 66 | + in.setTypeDetailId(material.getTypeDetailId()); | ||
| 67 | + in.setTypeDetailName(material.getTypeDetailName()); | ||
| 68 | + in.setSpecifications(material.getSpecifications()); | ||
| 69 | + in.setBelongCompanyId(material.getBelongCompanyId()); | ||
| 70 | + in.setBelongCompanyName(material.getBelongCompanyName()); | ||
| 71 | + in.setInInventoryNum(createReqVO.getInInventoryNum()); | ||
| 72 | + in.setMaterialPrice(createReqVO.getMaterialPrice()); | ||
| 73 | + in.setUnitId(material.getUnitId()); | ||
| 74 | + in.setUnitName(material.getUnitName()); | ||
| 75 | + in.setBuyDate(createReqVO.getBuyDate()); | ||
| 76 | + in.setSupplierName(createReqVO.getSupplierName()); | ||
| 77 | + in.setContactsName(createReqVO.getContactsName()); | ||
| 78 | + in.setContactsPhone(createReqVO.getContactsPhone()); | ||
| 79 | + in.setDeptId(getLoginUserDeptId()); | ||
| 80 | + | ||
| 37 | // 插入 | 81 | // 插入 |
| 38 | - MaterialInventoryInDO materialInventoryIn = BeanUtils.toBean(createReqVO, MaterialInventoryInDO.class); | ||
| 39 | - materialInventoryInMapper.insert(materialInventoryIn); | 82 | + //MaterialInventoryInDO materialInventoryIn = BeanUtils.toBean(createReqVO, MaterialInventoryInDO.class); |
| 83 | + materialInventoryInMapper.insert(in); | ||
| 84 | + | ||
| 85 | + //更新库存 | ||
| 86 | + MaterialInventoryDO inventory = new MaterialInventoryDO(); | ||
| 87 | + inventory.setMaterialId(in.getMaterialId()); | ||
| 88 | + inventory.setMaterialName(in.getMaterialName()); | ||
| 89 | + inventory.setMaterialTypeId(in.getMaterialTypeId()); | ||
| 90 | + inventory.setMaterialTypeName(in.getMaterialTypeName()); | ||
| 91 | + inventory.setTypeId(material.getTypeId()); | ||
| 92 | + inventory.setTypeName(material.getTypeName()); | ||
| 93 | + inventory.setTypeDetailId(material.getTypeDetailId()); | ||
| 94 | + inventory.setTypeDetailName(material.getTypeDetailName()); | ||
| 95 | + inventory.setSpecifications(in.getSpecifications()); | ||
| 96 | + inventory.setBelongCompanyId(in.getBelongCompanyId()); | ||
| 97 | + inventory.setBelongCompanyName(in.getBelongCompanyName()); | ||
| 98 | + inventory.setUnitId(in.getUnitId()); | ||
| 99 | + inventory.setUnitName(in.getUnitName()); | ||
| 100 | + inventory.setCurrentNum(in.getInInventoryNum()); | ||
| 101 | + inventory.setOutTotalNum(0L); | ||
| 102 | + inventory.setInventoryTotalNum(in.getInInventoryNum()); | ||
| 103 | + inventory.setDeptId(getLoginUserDeptId()); | ||
| 104 | + materialInventoryService.insertMaterialInventory(inventory); | ||
| 40 | 105 | ||
| 41 | // 返回 | 106 | // 返回 |
| 42 | - return materialInventoryIn.getId(); | 107 | + return in.getId(); |
| 43 | } | 108 | } |
| 44 | 109 | ||
| 45 | @Override | 110 | @Override |
| 111 | + @Transactional | ||
| 46 | public void updateMaterialInventoryIn(MaterialInventoryInSaveReqVO updateReqVO) { | 112 | public void updateMaterialInventoryIn(MaterialInventoryInSaveReqVO updateReqVO) { |
| 47 | // 校验存在 | 113 | // 校验存在 |
| 48 | validateMaterialInventoryInExists(updateReqVO.getId()); | 114 | validateMaterialInventoryInExists(updateReqVO.getId()); |
| 115 | + //查询库存管理参数 | ||
| 116 | + MaterialDO material = materialMapper.selectOne(MaterialDO::getMaterialId,updateReqVO.getMaterialId()); | ||
| 117 | + if(null == material){ | ||
| 118 | + throw exception0(BAD_REQUEST.getCode(), "无效参数-materialId"); | ||
| 119 | + } | ||
| 49 | // 更新 | 120 | // 更新 |
| 50 | MaterialInventoryInDO updateObj = BeanUtils.toBean(updateReqVO, MaterialInventoryInDO.class); | 121 | MaterialInventoryInDO updateObj = BeanUtils.toBean(updateReqVO, MaterialInventoryInDO.class); |
| 122 | + updateObj.setMaterialName(material.getMaterialName()); | ||
| 123 | + updateObj.setMaterialTypeId(material.getMaterialTypeId()); | ||
| 124 | + updateObj.setMaterialTypeName(material.getMaterialTypeName()); | ||
| 125 | + updateObj.setSpecifications(material.getSpecifications()); | ||
| 126 | + updateObj.setBelongCompanyId(material.getBelongCompanyId()); | ||
| 127 | + updateObj.setBelongCompanyName(material.getBelongCompanyName()); | ||
| 128 | + updateObj.setUnitId(material.getUnitId()); | ||
| 129 | + updateObj.setUnitName(material.getUnitName()); | ||
| 51 | materialInventoryInMapper.updateById(updateObj); | 130 | materialInventoryInMapper.updateById(updateObj); |
| 52 | } | 131 | } |
| 53 | 132 | ||
| 54 | @Override | 133 | @Override |
| 134 | + @Transactional | ||
| 55 | public void deleteMaterialInventoryIn(Long id) { | 135 | public void deleteMaterialInventoryIn(Long id) { |
| 56 | // 校验存在 | 136 | // 校验存在 |
| 57 | - validateMaterialInventoryInExists(id); | 137 | + MaterialInventoryInDO materialInventoryIn = materialInventoryInMapper.selectById(id); |
| 138 | + if (null == materialInventoryIn) { | ||
| 139 | + throw exception(MATERIAL_INVENTORY_IN_NOT_EXISTS); | ||
| 140 | + } | ||
| 141 | + MaterialInventoryDO materialInventory = materialInventoryService.selectTdMaterialInventoryByMaterialId(materialInventoryIn.getMaterialId()); | ||
| 142 | + if(null == materialInventory){ | ||
| 143 | + throw exception0(BAD_REQUEST.getCode(),"参数错误"); | ||
| 144 | + } | ||
| 145 | + //库存已使用 | ||
| 146 | + if(materialInventory.getCurrentNum() < materialInventoryIn.getInInventoryNum()){ | ||
| 147 | + throw exception0(BAD_REQUEST.getCode(),"库存已使用"); | ||
| 148 | + } | ||
| 149 | + //入库记录减扣 | ||
| 150 | + MaterialInventoryDO inventory = new MaterialInventoryDO(); | ||
| 151 | + inventory.setInventoryId(materialInventory.getInventoryId()); | ||
| 152 | + inventory.setMaterialId(materialInventory.getMaterialId()); | ||
| 153 | + inventory.setCurrentNum(materialInventory.getCurrentNum() - materialInventoryIn.getInInventoryNum()); | ||
| 154 | + inventory.setInventoryTotalNum(materialInventory.getInventoryTotalNum() - materialInventoryIn.getInInventoryNum()); | ||
| 155 | + materialInventoryService.updateTdMaterialInventory(inventory); | ||
| 58 | // 删除 | 156 | // 删除 |
| 59 | materialInventoryInMapper.deleteById(id); | 157 | materialInventoryInMapper.deleteById(id); |
| 60 | } | 158 | } |
| 61 | 159 | ||
| 62 | @Override | 160 | @Override |
| 63 | - public void deleteMaterialInventoryInListByIds(List<Long> ids) { | 161 | + public void deleteMaterialInventoryInListByIds(List<Long> ids) { |
| 64 | // 删除 | 162 | // 删除 |
| 65 | materialInventoryInMapper.deleteByIds(ids); | 163 | materialInventoryInMapper.deleteByIds(ids); |
| 66 | - } | 164 | + } |
| 67 | 165 | ||
| 68 | 166 | ||
| 69 | private void validateMaterialInventoryInExists(Long id) { | 167 | private void validateMaterialInventoryInExists(Long id) { |
| @@ -82,4 +180,4 @@ public class MaterialInventoryInServiceImpl implements MaterialInventoryInServic | @@ -82,4 +180,4 @@ public class MaterialInventoryInServiceImpl implements MaterialInventoryInServic | ||
| 82 | return materialInventoryInMapper.selectPage(pageReqVO); | 180 | return materialInventoryInMapper.selectPage(pageReqVO); |
| 83 | } | 181 | } |
| 84 | 182 | ||
| 85 | -} | ||
| 86 | \ No newline at end of file | 183 | \ No newline at end of file |
| 184 | +} |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventoryout/MaterialInventoryOutServiceImpl.java
| 1 | package com.zteits.urbanops.module.garden.service.materialinventoryout; | 1 | package com.zteits.urbanops.module.garden.service.materialinventoryout; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.collection.CollUtil; | ||
| 4 | -import org.springframework.stereotype.Service; | ||
| 5 | -import jakarta.annotation.Resource; | ||
| 6 | -import org.springframework.validation.annotation.Validated; | ||
| 7 | -import org.springframework.transaction.annotation.Transactional; | ||
| 8 | - | ||
| 9 | -import java.util.*; | ||
| 10 | -import com.zteits.urbanops.module.garden.controller.admin.materialinventoryout.vo.*; | ||
| 11 | -import com.zteits.urbanops.module.garden.dal.dataobject.materialinventoryout.MaterialInventoryOutDO; | ||
| 12 | import com.zteits.urbanops.framework.common.pojo.PageResult; | 3 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 13 | -import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 14 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; | 4 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 15 | - | 5 | +import com.zteits.urbanops.module.garden.controller.admin.materialinventoryout.vo.MaterialInventoryOutPageReqVO; |
| 6 | +import com.zteits.urbanops.module.garden.controller.admin.materialinventoryout.vo.MaterialInventoryOutSaveReqVO; | ||
| 7 | +import com.zteits.urbanops.module.garden.dal.dataobject.material.MaterialDO; | ||
| 8 | +import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO; | ||
| 9 | +import com.zteits.urbanops.module.garden.dal.dataobject.materialinventoryout.MaterialInventoryOutDO; | ||
| 10 | +import com.zteits.urbanops.module.garden.dal.mysql.material.MaterialMapper; | ||
| 16 | import com.zteits.urbanops.module.garden.dal.mysql.materialinventoryout.MaterialInventoryOutMapper; | 11 | import com.zteits.urbanops.module.garden.dal.mysql.materialinventoryout.MaterialInventoryOutMapper; |
| 12 | +import com.zteits.urbanops.module.garden.service.materialinventory.MaterialInventoryService; | ||
| 13 | +import jakarta.annotation.Resource; | ||
| 14 | +import org.springframework.stereotype.Service; | ||
| 15 | +import org.springframework.validation.annotation.Validated; | ||
| 16 | + | ||
| 17 | +import java.util.List; | ||
| 17 | 18 | ||
| 19 | +import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; | ||
| 18 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | 20 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 19 | -import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.convertList; | ||
| 20 | -import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.diffList; | ||
| 21 | -import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; | 21 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0; |
| 22 | +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.MATERIAL_INVENTORY_OUT_NOT_EXISTS; | ||
| 22 | 23 | ||
| 23 | /** | 24 | /** |
| 24 | * 物料出库 Service 实现类 | 25 | * 物料出库 Service 实现类 |
| @@ -31,15 +32,47 @@ public class MaterialInventoryOutServiceImpl implements MaterialInventoryOutServ | @@ -31,15 +32,47 @@ public class MaterialInventoryOutServiceImpl implements MaterialInventoryOutServ | ||
| 31 | 32 | ||
| 32 | @Resource | 33 | @Resource |
| 33 | private MaterialInventoryOutMapper materialInventoryOutMapper; | 34 | private MaterialInventoryOutMapper materialInventoryOutMapper; |
| 35 | + @Resource | ||
| 36 | + private MaterialMapper materialMapper; | ||
| 34 | 37 | ||
| 38 | + @Resource | ||
| 39 | + private MaterialInventoryService materialInventoryService; | ||
| 35 | @Override | 40 | @Override |
| 36 | public Long createMaterialInventoryOut(MaterialInventoryOutSaveReqVO createReqVO) { | 41 | public Long createMaterialInventoryOut(MaterialInventoryOutSaveReqVO createReqVO) { |
| 37 | // 插入 | 42 | // 插入 |
| 38 | - MaterialInventoryOutDO materialInventoryOut = BeanUtils.toBean(createReqVO, MaterialInventoryOutDO.class); | ||
| 39 | - materialInventoryOutMapper.insert(materialInventoryOut); | 43 | + MaterialInventoryOutDO out = BeanUtils.toBean(createReqVO, MaterialInventoryOutDO.class); |
| 44 | + //参数校验 | ||
| 45 | + MaterialDO material = materialMapper.selectOne(MaterialDO::getMaterialId,createReqVO.getMaterialId()); | ||
| 46 | + if(null == material){ | ||
| 47 | + throw exception0(BAD_REQUEST.getCode(), "无效参数-materialId"); | ||
| 48 | + } | ||
| 49 | + MaterialInventoryDO materialInventory = materialInventoryService.selectTdMaterialInventoryByMaterialId(out.getMaterialId()); | ||
| 50 | + if(null == materialInventory){ | ||
| 51 | + throw exception0(BAD_REQUEST.getCode(),createReqVO.getMaterialName()+"没有库存"); | ||
| 52 | + } | ||
| 53 | + //当前库存不足,无法出库 | ||
| 54 | + if(materialInventory.getCurrentNum() < out.getOutInventoryNum()){ | ||
| 55 | + throw exception0(BAD_REQUEST.getCode(),"当前库存不足,无法出库"); | ||
| 56 | + } | ||
| 40 | 57 | ||
| 58 | + out.setMaterialName(material.getMaterialName()); | ||
| 59 | + out.setMaterialTypeId(material.getMaterialTypeId()); | ||
| 60 | + out.setMaterialTypeName(material.getMaterialTypeName()); | ||
| 61 | + out.setTypeId(material.getTypeId()); | ||
| 62 | + out.setTypeName(material.getTypeName()); | ||
| 63 | + out.setTypeDetailId(material.getTypeDetailId()); | ||
| 64 | + out.setTypeDetailName(material.getTypeDetailName()); | ||
| 65 | + out.setSpecifications(material.getSpecifications()); | ||
| 66 | + out.setBelongCompanyId(material.getBelongCompanyId()); | ||
| 67 | + out.setBelongCompanyName(material.getBelongCompanyName()); | ||
| 68 | + out.setUnitId(material.getUnitId()); | ||
| 69 | + out.setUnitName(material.getUnitName()); | ||
| 70 | + materialInventoryOutMapper.insert(out); | ||
| 71 | + | ||
| 72 | + //更新库存 | ||
| 73 | + materialInventoryService.updateInVentoryByMaterialId(materialInventory, out.getOutInventoryNum()); | ||
| 41 | // 返回 | 74 | // 返回 |
| 42 | - return materialInventoryOut.getId(); | 75 | + return out.getId(); |
| 43 | } | 76 | } |
| 44 | 77 | ||
| 45 | @Override | 78 | @Override |
| @@ -54,7 +87,30 @@ public class MaterialInventoryOutServiceImpl implements MaterialInventoryOutServ | @@ -54,7 +87,30 @@ public class MaterialInventoryOutServiceImpl implements MaterialInventoryOutServ | ||
| 54 | @Override | 87 | @Override |
| 55 | public void deleteMaterialInventoryOut(Long id) { | 88 | public void deleteMaterialInventoryOut(Long id) { |
| 56 | // 校验存在 | 89 | // 校验存在 |
| 57 | - validateMaterialInventoryOutExists(id); | 90 | + MaterialInventoryOutDO materialInventoryOut = materialInventoryOutMapper.selectById(id); |
| 91 | + if (null == materialInventoryOut) { | ||
| 92 | + throw exception(MATERIAL_INVENTORY_OUT_NOT_EXISTS); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + //查询库存 | ||
| 96 | + MaterialInventoryDO materialInventory = materialInventoryService.selectTdMaterialInventoryByMaterialId(materialInventoryOut.getMaterialId()); | ||
| 97 | + if(null == materialInventory){ | ||
| 98 | + throw exception0(BAD_REQUEST.getCode(),"参数错误"); | ||
| 99 | + } | ||
| 100 | + //库存已使用 | ||
| 101 | + if(materialInventory.getCurrentNum() < materialInventoryOut.getOutInventoryNum()){ | ||
| 102 | + throw exception0(BAD_REQUEST.getCode(),"库存已使用"); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + //入库记录减扣 | ||
| 106 | + MaterialInventoryDO inventory = new MaterialInventoryDO(); | ||
| 107 | + inventory.setInventoryId(materialInventory.getInventoryId()); | ||
| 108 | + inventory.setMaterialId(materialInventory.getMaterialId()); | ||
| 109 | + inventory.setCurrentNum(materialInventory.getCurrentNum() + materialInventoryOut.getOutInventoryNum()); | ||
| 110 | + inventory.setInventoryTotalNum(materialInventory.getInventoryTotalNum() + materialInventoryOut.getOutInventoryNum()); | ||
| 111 | + inventory.setOutTotalNum(materialInventory.getOutTotalNum() - materialInventoryOut.getOutInventoryNum()); | ||
| 112 | + materialInventoryService.updateTdMaterialInventory(inventory); | ||
| 113 | + | ||
| 58 | // 删除 | 114 | // 删除 |
| 59 | materialInventoryOutMapper.deleteById(id); | 115 | materialInventoryOutMapper.deleteById(id); |
| 60 | } | 116 | } |
| @@ -82,4 +138,4 @@ public class MaterialInventoryOutServiceImpl implements MaterialInventoryOutServ | @@ -82,4 +138,4 @@ public class MaterialInventoryOutServiceImpl implements MaterialInventoryOutServ | ||
| 82 | return materialInventoryOutMapper.selectPage(pageReqVO); | 138 | return materialInventoryOutMapper.selectPage(pageReqVO); |
| 83 | } | 139 | } |
| 84 | 140 | ||
| 85 | -} | ||
| 86 | \ No newline at end of file | 141 | \ No newline at end of file |
| 142 | +} |