From 736bac6eaff990960e0e3d3823ca515fa0d66eab Mon Sep 17 00:00:00 2001 From: songguoqiang <765017469@qq.com> Date: Wed, 8 May 2024 15:40:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A4=87=E4=BB=B6=E5=8F=B0=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/eam/enums/DictTypeConstants.java | 1 + .../module/eam/enums/ErrorCodeConstants.java | 3 + .../itemaccounts/ItemAccountsController.java | 47 ++++++ .../itemaccounts/vo/ItemAccountsBaseVO.java | 3 + .../vo/ItemAccountsPageReqVO.java | 3 + .../itemaccounts/vo/ItemAccountsRespVO.java | 10 ++ .../ItemNewTurnInController.java | 139 +++++++++++++++++ .../itemnewturnin/vo/ItemNewTurnInBaseVO.java | 56 +++++++ .../vo/ItemNewTurnInCreateReqVO.java | 14 ++ .../vo/ItemNewTurnInExcelVO.java | 55 +++++++ .../vo/ItemNewTurnInExportReqVO.java | 15 ++ .../vo/ItemNewTurnInPageReqVO.java | 17 ++ .../itemnewturnin/vo/ItemNewTurnInRespVO.java | 16 ++ .../vo/ItemNewTurnInUpdateReqVO.java | 14 ++ .../itemnewturnin/ItemNewTurnInConvert.java | 37 +++++ .../itemaccounts/ItemAccountsDO.java | 4 + .../itemnewturnin/ItemNewTurnInDO.java | 77 +++++++++ .../itemnewturnin/ItemNewTurnInMapper.java | 33 ++++ .../itemAccount/ItemAccountStatusEnum.java | 41 +++++ .../module/eam/service/item/ItemService.java | 8 + .../eam/service/item/ItemServiceImpl.java | 10 ++ .../itemaccounts/ItemAccountsService.java | 21 +++ .../itemaccounts/ItemAccountsServiceImpl.java | 147 +++++++++++++++++- .../itemnewturnin/ItemNewTurnInService.java | 80 ++++++++++ .../ItemNewTurnInServiceImpl.java | 107 +++++++++++++ .../eam/service/location/LocationService.java | 8 + .../service/location/LocationServiceImpl.java | 9 ++ .../locationarea/LocationAreaService.java | 8 + .../locationarea/LocationAreaServiceImpl.java | 8 + 29 files changed, 984 insertions(+), 7 deletions(-) create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/ItemNewTurnInController.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInBaseVO.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInCreateReqVO.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInExcelVO.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInExportReqVO.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInPageReqVO.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInRespVO.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInUpdateReqVO.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/convert/itemnewturnin/ItemNewTurnInConvert.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemnewturnin/ItemNewTurnInDO.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemnewturnin/ItemNewTurnInMapper.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/enums/itemAccount/ItemAccountStatusEnum.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemnewturnin/ItemNewTurnInService.java create mode 100644 win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemnewturnin/ItemNewTurnInServiceImpl.java diff --git a/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/DictTypeConstants.java b/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/DictTypeConstants.java index b791d5b..87f0f83 100644 --- a/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/DictTypeConstants.java +++ b/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/DictTypeConstants.java @@ -101,4 +101,5 @@ public interface DictTypeConstants { String CONTAINER_CONTENT_TYPE = "container_content_type"; // 器具内容类型 String EQUIPMENT_INDEX_NAME = "equipment_index_name"; //设备年度目标指标名称分类字段 String FACTORY_TYPE = "factory_type"; // 月指标导入厂区字典 + String ITEM_ACCOUNT_LOCATION_TYPE = "item_account_location_type"; // 备件台账库位类型 } diff --git a/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/ErrorCodeConstants.java b/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/ErrorCodeConstants.java index 9df6163..c8b0077 100644 --- a/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/ErrorCodeConstants.java +++ b/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/ErrorCodeConstants.java @@ -157,5 +157,8 @@ public interface ErrorCodeConstants { ErrorCode CLASS_TYPE_DATA_REPEAT = new ErrorCode(1_000_020_063, "厂区和班组固定,不能重复"); + ErrorCode ITEM_TYPE_LOCATION_EXIST = new ErrorCode(1_000_020_063, "备件编码库位类型库位编码已存在,不能重复添加"); + ErrorCode ITEM_NEW_TURN_IN_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_000_020_063, "数据不能为空"); + } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/ItemAccountsController.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/ItemAccountsController.java index 278a626..2b39ca7 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/ItemAccountsController.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/ItemAccountsController.java @@ -7,8 +7,14 @@ import com.win.framework.excel.core.util.ExcelUtils; import com.win.framework.operatelog.core.annotations.OperateLog; import com.win.module.eam.controller.itemaccounts.vo.*; import com.win.module.eam.convert.itemaccounts.ItemAccountsConvert; +import com.win.module.eam.dal.dataobject.item.ItemDO; import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO; +import com.win.module.eam.dal.dataobject.location.LocationDO; +import com.win.module.eam.dal.dataobject.locationarea.LocationAreaDO; +import com.win.module.eam.service.item.ItemService; import com.win.module.eam.service.itemaccounts.ItemAccountsService; +import com.win.module.eam.service.location.LocationService; +import com.win.module.eam.service.locationarea.LocationAreaService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -39,6 +45,15 @@ public class ItemAccountsController { @Resource private ItemAccountsService itemAccountsService; + @Resource + private ItemService itemService; + + @Resource + private LocationService locationService; + + @Resource + private LocationAreaService locationAreaService; + @PostMapping("/create") @Operation(summary = "创建备件台账") @PreAuthorize("@ss.hasPermission('item:itemAccounts:create')") @@ -46,6 +61,20 @@ public class ItemAccountsController { return success(itemAccountsService.createItemAccounts(createReqVO)); } +// @PostMapping("/createIn") +// @Operation(summary = "增入库只能新增账内和新到货") +// @PreAuthorize("@ss.hasPermission('item:itemAccounts:createIn')") +// public CommonResult createIn(@Valid @RequestBody ItemAccountsCreateReqVO createReqVO) { +// return success(itemAccountsService.createIn(createReqVO)); +// } + + @PostMapping("/newTurnIn") + @Operation(summary = "新到货转账内") + @PreAuthorize("@ss.hasPermission('item:itemAccounts:newTurnIn')") + public CommonResult newTurnIn(@Valid @RequestBody ItemAccountsCreateReqVO createReqVO) { + return success(itemAccountsService.newTurnIn(createReqVO)); + } + @PutMapping("/update") @Operation(summary = "更新备件台账") @PreAuthorize("@ss.hasPermission('item:itemAccounts:update')") @@ -87,6 +116,16 @@ public class ItemAccountsController { public CommonResult> getItemAccountsPage(@Valid ItemAccountsPageReqVO pageVO) { PageResult pageResult = itemAccountsService.getItemAccountsPage(pageVO); PageResult result = ItemAccountsConvert.INSTANCE.convertPage(pageResult); + for(ItemAccountsRespVO vo:result.getList()){ + ItemDO itemDO = itemService.getByNumber(vo.getItemNumber()); + vo.setItemName(itemDO.getName()); + LocationDO locationDO = locationService.getByNumber(vo.getLocationNumber()); + vo.setLocationName(locationDO.getName()); + LocationAreaDO locationAreaDO = locationAreaService.getByNumber(vo.getAreaNumber()); + vo.setAreaName(locationAreaDO.getName()); + Boolean b = itemAccountsService.qtyZore(vo.getItemNumber()); + vo.setDisplay(b); + } return success(result); } @@ -173,6 +212,14 @@ public class ItemAccountsController { public CommonResult> getLocationSenior(@Valid @RequestBody CustomConditions conditions) { PageResult pageResult = itemAccountsService.getItemAccountsSenior(conditions); PageResult result = ItemAccountsConvert.INSTANCE.convertPage(pageResult); + for(ItemAccountsRespVO vo:result.getList()){ + ItemDO itemDO = itemService.getByNumber(vo.getItemNumber()); + vo.setItemName(itemDO.getName()); + LocationDO locationDO = locationService.getByNumber(vo.getLocationNumber()); + vo.setLocationName(locationDO.getName()); + LocationAreaDO locationAreaDO = locationAreaService.getByNumber(vo.getAreaNumber()); + vo.setAreaName(locationAreaDO.getName()); + } return success(result); } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsBaseVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsBaseVO.java index 7683774..271bdf8 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsBaseVO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsBaseVO.java @@ -146,6 +146,9 @@ public class ItemAccountsBaseVO { */ @Schema(description = "类别") private String category; + + @Schema(description = "库位类型") + private String type; /** * 描述 */ diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsPageReqVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsPageReqVO.java index fe6656f..6714079 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsPageReqVO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsPageReqVO.java @@ -21,4 +21,7 @@ public class ItemAccountsPageReqVO extends PageParam { @Schema(description = "是否可用") private String available; + @Schema(description = "库位类型") + private String type; + } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsRespVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsRespVO.java index 354cdc2..a75df88 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsRespVO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsRespVO.java @@ -16,4 +16,14 @@ public class ItemAccountsRespVO extends ItemAccountsBaseVO { @Schema(description = "创建时间") private LocalDateTime createTime; + private String locationName; + + private String areaName; + + private String itemName; + /** + * 是否显示更换库位按钮 + */ + private Boolean display; + } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/ItemNewTurnInController.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/ItemNewTurnInController.java new file mode 100644 index 0000000..9e8751b --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/ItemNewTurnInController.java @@ -0,0 +1,139 @@ +package com.win.module.eam.controller.itemnewturnin; + +import com.win.module.eam.controller.itemnewturnin.vo.*; +import io.swagger.v3.oas.annotations.Parameters; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.*; +import java.io.IOException; + +import com.win.framework.common.pojo.PageResult; +import com.win.framework.common.pojo.CommonResult; +import static com.win.framework.common.pojo.CommonResult.success; + +import com.win.framework.excel.core.util.ExcelUtils; + +import com.win.framework.operatelog.core.annotations.OperateLog; +import static com.win.framework.operatelog.core.enums.OperateTypeEnum.*; + +import com.win.module.eam.dal.dataobject.itemnewturnin.ItemNewTurnInDO; +import com.win.module.eam.convert.itemnewturnin.ItemNewTurnInConvert; +import com.win.module.eam.service.itemnewturnin.ItemNewTurnInService; +import org.springframework.web.multipart.MultipartFile; + +@Tag(name = "管理后台 - 备件台账新到货转账内变更记录") +@RestController +@RequestMapping("/eam/item-new-turn-in") +@Validated +public class ItemNewTurnInController { + + @Resource + private ItemNewTurnInService itemNewTurnInService; + + @PostMapping("/create") + @Operation(summary = "创建备件台账新到货转账内变更记录") + @PreAuthorize("@ss.hasPermission('eam:item-new-turn-in:create')") + public CommonResult createItemNewTurnIn(@Valid @RequestBody ItemNewTurnInCreateReqVO createReqVO) { + return success(itemNewTurnInService.createItemNewTurnIn(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新备件台账新到货转账内变更记录") + @PreAuthorize("@ss.hasPermission('eam:item-new-turn-in:update')") + public CommonResult updateItemNewTurnIn(@Valid @RequestBody ItemNewTurnInUpdateReqVO updateReqVO) { + int result = itemNewTurnInService.updateItemNewTurnIn(updateReqVO); + return success(result > 0); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除备件台账新到货转账内变更记录") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('eam:item-new-turn-in:delete')") + public CommonResult deleteItemNewTurnIn(@RequestParam("id") Long id) { + int result = itemNewTurnInService.deleteItemNewTurnIn(id); + return success(result > 0); + } + + @GetMapping("/get") + @Operation(summary = "获得备件台账新到货转账内变更记录") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('eam:item-new-turn-in:query')") + public CommonResult getItemNewTurnIn(@RequestParam("id") Long id) { + ItemNewTurnInDO itemNewTurnIn = itemNewTurnInService.getItemNewTurnIn(id); + return success(ItemNewTurnInConvert.INSTANCE.convert(itemNewTurnIn)); + } + + @GetMapping("/list") + @Operation(summary = "获得备件台账新到货转账内变更记录列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('eam:item-new-turn-in:query')") + public CommonResult> getItemNewTurnInList(@RequestParam("ids") Collection ids) { + List list = itemNewTurnInService.getItemNewTurnInList(ids); + return success(ItemNewTurnInConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得备件台账新到货转账内变更记录分页") + @PreAuthorize("@ss.hasPermission('eam:item-new-turn-in:query')") + public CommonResult> getItemNewTurnInPage(@Valid ItemNewTurnInPageReqVO pageVO) { + PageResult pageResult = itemNewTurnInService.getItemNewTurnInPage(pageVO); + return success(ItemNewTurnInConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出备件台账新到货转账内变更记录 Excel") + @PreAuthorize("@ss.hasPermission('eam:item-new-turn-in:export')") + @OperateLog(type = EXPORT) + public void exportItemNewTurnInExcel(@Valid ItemNewTurnInExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = itemNewTurnInService.getItemNewTurnInList(exportReqVO); + // 导出 Excel + List datas = ItemNewTurnInConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "备件台账新到货转账内变更记录.xls", "数据", ItemNewTurnInExcelVO.class, datas); + } + + @GetMapping("/get-import-template") + @Operation(summary = "获得导入备件台账新到货转账内变更记录模板") + public void importTemplate(HttpServletResponse response) throws IOException { + List list = Arrays.asList(); + // 输出 + ExcelUtils.write(response, "备件台账新到货转账内变更记录基本信息导入模板.xls", "备件台账新到货转账内变更记录基本信息列表", ItemNewTurnInExcelVO.class, list); + } + + @PostMapping("/import") + @Operation(summary = "导入备件台账新到货转账内变更记录基本信息") + @Parameters({ + @Parameter(name = "file", description = "Excel 文件", required = true), + @Parameter(name = "mode", description = "导入模式1更新2追加3覆盖", example = "1"), + @Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true") + }) + @PreAuthorize("@ss.hasPermission('eam:item-new-turn-in:import')") + public CommonResult> importExcel(HttpServletResponse response, + @RequestParam("file") MultipartFile file, + @RequestParam(value = "mode") Integer mode, + @RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { + + List list = ExcelUtils.read(file, ItemNewTurnInExcelVO.class); + List errorList = itemNewTurnInService.importItemNewTurnInList(list, mode, updatePart); + + Map returnMap = new HashMap<>(); + returnMap.put("errorCount", errorList.size()); + if(!errorList.isEmpty()) { + String url = ExcelUtils.writeLocalFile("备件台账新到货转账内变更记录基本信息导入错误数据" + LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) + ".xlsx", "错误列表", errorList); + returnMap.put("errorFile", url); + } + + return success(returnMap); + } +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInBaseVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInBaseVO.java new file mode 100644 index 0000000..0a6b3e9 --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInBaseVO.java @@ -0,0 +1,56 @@ +package com.win.module.eam.controller.itemnewturnin.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import java.math.BigDecimal; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; + +/** + * 备件台账新到货转账内变更记录 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class ItemNewTurnInBaseVO { + + @Schema(description = "备件编码", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "备件编码不能为空") + private String itemNumber; + + @Schema(description = "库位编码", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "库位编码不能为空") + private String locationNumber; + + @Schema(description = "库区编码", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "库区编码不能为空") + private String areaNumber; + + @Schema(description = "描述", example = "随便") + private String description; + + @Schema(description = "新到货数量") + private BigDecimal newQty; + + @Schema(description = "账内数量") + private BigDecimal inQty; + + @Schema(description = "转换后账内数量") + private BigDecimal qty; + + @Schema(description = "地点ID", example = "4783") + private String siteId; + + @Schema(description = "是否可用") + private String available; + + @Schema(description = "变更操作字典") + private String type; + + @Schema(description = "并发乐观锁") + private Integer concurrencyStamp; + +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInCreateReqVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInCreateReqVO.java new file mode 100644 index 0000000..4c5a674 --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInCreateReqVO.java @@ -0,0 +1,14 @@ +package com.win.module.eam.controller.itemnewturnin.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 备件台账新到货转账内变更记录创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ItemNewTurnInCreateReqVO extends ItemNewTurnInBaseVO { + +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInExcelVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInExcelVO.java new file mode 100644 index 0000000..d619e93 --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInExcelVO.java @@ -0,0 +1,55 @@ +package com.win.module.eam.controller.itemnewturnin.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import java.math.BigDecimal; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 备件台账新到货转账内变更记录 Excel VO + * + * @author 超级管理员 + */ +@Data +public class ItemNewTurnInExcelVO { + + @ExcelProperty("备件编码") + private String itemNumber; + + @ExcelProperty("库位编码") + private String locationNumber; + + @ExcelProperty("库区编码") + private String areaNumber; + + @ExcelProperty("描述") + private String description; + + @ExcelProperty("新到货数量") + private BigDecimal newQty; + + @ExcelProperty("账内数量") + private BigDecimal inQty; + + @ExcelProperty("转换后账内数量") + private BigDecimal qty; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("地点ID") + private String siteId; + + @ExcelProperty("是否可用") + private String available; + + @ExcelProperty("并发乐观锁") + private Integer concurrencyStamp; + +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInExportReqVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInExportReqVO.java new file mode 100644 index 0000000..98b3d88 --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInExportReqVO.java @@ -0,0 +1,15 @@ +package com.win.module.eam.controller.itemnewturnin.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.win.framework.common.pojo.PageParam; + +@Schema(description = "管理后台 - 备件台账新到货转账内变更记录 Excel 导出 Request VO,参数和 ItemNewTurnInPageReqVO 是一致的") +@Data +public class ItemNewTurnInExportReqVO { + + @Schema(description = "备件编码") + private String itemNumber; + +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInPageReqVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInPageReqVO.java new file mode 100644 index 0000000..e14a173 --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInPageReqVO.java @@ -0,0 +1,17 @@ +package com.win.module.eam.controller.itemnewturnin.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.win.framework.common.pojo.PageParam; + +@Schema(description = "管理后台 - 备件台账新到货转账内变更记录分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ItemNewTurnInPageReqVO extends PageParam { + + @Schema(description = "备件编码") + private String itemNumber; + +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInRespVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInRespVO.java new file mode 100644 index 0000000..f519ec5 --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInRespVO.java @@ -0,0 +1,16 @@ +package com.win.module.eam.controller.itemnewturnin.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 备件台账新到货转账内变更记录 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ItemNewTurnInRespVO extends ItemNewTurnInBaseVO { + + @Schema(description = "创建时间") + private LocalDateTime createTime; + +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInUpdateReqVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInUpdateReqVO.java new file mode 100644 index 0000000..4e25fdd --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemnewturnin/vo/ItemNewTurnInUpdateReqVO.java @@ -0,0 +1,14 @@ +package com.win.module.eam.controller.itemnewturnin.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 备件台账新到货转账内变更记录更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ItemNewTurnInUpdateReqVO extends ItemNewTurnInBaseVO { + +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/convert/itemnewturnin/ItemNewTurnInConvert.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/convert/itemnewturnin/ItemNewTurnInConvert.java new file mode 100644 index 0000000..66f949a --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/convert/itemnewturnin/ItemNewTurnInConvert.java @@ -0,0 +1,37 @@ +package com.win.module.eam.convert.itemnewturnin; + +import java.util.*; + +import com.win.framework.common.pojo.PageResult; + +import com.win.module.eam.controller.itemnewturnin.vo.ItemNewTurnInCreateReqVO; +import com.win.module.eam.controller.itemnewturnin.vo.ItemNewTurnInExcelVO; +import com.win.module.eam.controller.itemnewturnin.vo.ItemNewTurnInRespVO; +import com.win.module.eam.controller.itemnewturnin.vo.ItemNewTurnInUpdateReqVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import com.win.module.eam.dal.dataobject.itemnewturnin.ItemNewTurnInDO; + +/** + * 备件台账新到货转账内变更记录 Convert + * + * @author 超级管理员 + */ +@Mapper +public interface ItemNewTurnInConvert { + + ItemNewTurnInConvert INSTANCE = Mappers.getMapper(ItemNewTurnInConvert.class); + + ItemNewTurnInDO convert(ItemNewTurnInCreateReqVO bean); + + ItemNewTurnInDO convert(ItemNewTurnInUpdateReqVO bean); + + ItemNewTurnInRespVO convert(ItemNewTurnInDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemaccounts/ItemAccountsDO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemaccounts/ItemAccountsDO.java index ceacd09..85c924b 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemaccounts/ItemAccountsDO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemaccounts/ItemAccountsDO.java @@ -50,6 +50,10 @@ public class ItemAccountsDO extends BaseDO { * 是否账内库TRUE账内FALSE账外 */ private String isInAccount; + /** + * 库位类型 + */ + private String type; /** * 地点ID */ diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemnewturnin/ItemNewTurnInDO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemnewturnin/ItemNewTurnInDO.java new file mode 100644 index 0000000..d696acd --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemnewturnin/ItemNewTurnInDO.java @@ -0,0 +1,77 @@ +package com.win.module.eam.dal.dataobject.itemnewturnin; + +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import java.math.BigDecimal; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import com.win.framework.mybatis.core.dataobject.BaseDO; + +/** + * 备件台账新到货转账内变更记录 DO + * + * @author 超级管理员 + */ +@TableName("record_item_new_turn_in") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ItemNewTurnInDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 备件编码 + */ + private String itemNumber; + /** + * 库位编码 + */ + private String locationNumber; + /** + * 库区编码 + */ + private String areaNumber; + /** + * 变更操作字典 + */ + private String type; + /** + * 描述 + */ + private String description; + /** + * 新到货数量 + */ + private BigDecimal newQty; + /** + * 账内数量 + */ + private BigDecimal inQty; + /** + * 转换后账内数量 + */ + private BigDecimal qty; + /** + * 地点ID + */ + private String siteId; + /** + * 是否可用 + */ + private String available; + /** + * 并发乐观锁 + */ + private Integer concurrencyStamp; + +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemnewturnin/ItemNewTurnInMapper.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemnewturnin/ItemNewTurnInMapper.java new file mode 100644 index 0000000..868016e --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemnewturnin/ItemNewTurnInMapper.java @@ -0,0 +1,33 @@ +package com.win.module.eam.dal.mysql.itemnewturnin; + +import java.util.*; + +import com.win.framework.common.pojo.PageResult; +import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.win.framework.mybatis.core.mapper.BaseMapperX; +import com.win.module.eam.controller.itemnewturnin.vo.ItemNewTurnInExportReqVO; +import com.win.module.eam.controller.itemnewturnin.vo.ItemNewTurnInPageReqVO; +import com.win.module.eam.dal.dataobject.itemnewturnin.ItemNewTurnInDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 备件台账新到货转账内变更记录 Mapper + * + * @author 超级管理员 + */ +@Mapper +public interface ItemNewTurnInMapper extends BaseMapperX { + + default PageResult selectPage(ItemNewTurnInPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(ItemNewTurnInDO::getItemNumber, reqVO.getItemNumber()) + .orderByDesc(ItemNewTurnInDO::getId)); + } + + default List selectList(ItemNewTurnInExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(ItemNewTurnInDO::getItemNumber, reqVO.getItemNumber()) + .orderByDesc(ItemNewTurnInDO::getId)); + } + +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/enums/itemAccount/ItemAccountStatusEnum.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/enums/itemAccount/ItemAccountStatusEnum.java new file mode 100644 index 0000000..803c1b0 --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/enums/itemAccount/ItemAccountStatusEnum.java @@ -0,0 +1,41 @@ +package com.win.module.eam.enums.itemAccount; + +public enum ItemAccountStatusEnum { + + IN("0", "账内"), + OUT("1", "账外"), + NEW("2", "新到货"), + ; + private String code; + private String name; + + ItemAccountStatusEnum(String code, String name) { + this.code = code; + this.name = name; + } + + public String getCode() { + return this.code; + } + + public String getName() { + return this.name; + } + + /** + * 用状态值获取枚举 + * + * @param code + * @return + */ + static ItemAccountStatusEnum getOrderStatusEnum(String code) { + for (ItemAccountStatusEnum orderStatusEnum : values()) { + if (orderStatusEnum.getCode().equals(code)) { + return orderStatusEnum; + } + } + return null; + } + + +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemService.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemService.java index 414f941..40f6186 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemService.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemService.java @@ -136,4 +136,12 @@ public interface ItemService { * @return 导入结果 */ public List importItemList(List datas, Integer mode, boolean updatePart); + + /** + *根据备件编码查询备件信息 + * @param number + * @return + */ + ItemDO getByNumber(String number); + } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java index e60d9d8..fe3cf41 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java @@ -281,4 +281,14 @@ public class ItemServiceImpl implements ItemService { }); return errorList; } + + @Override + public ItemDO getByNumber(String number) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("number",number); + queryWrapper.eq("available","TRUE"); + return itemMapper.selectOne(queryWrapper); + } + + } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsService.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsService.java index 95286dc..e1f3978 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsService.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsService.java @@ -25,6 +25,20 @@ public interface ItemAccountsService { */ Long createItemAccounts(@Valid ItemAccountsCreateReqVO createReqVO); + /** + * 新增入库只能新增账内和新到货 + * @param createReqVO + * @return + */ + Long createIn(@Valid ItemAccountsCreateReqVO createReqVO); + + /** + * 新到货转账内 + * @param createReqVO + * @return + */ + Long newTurnIn(@Valid ItemAccountsCreateReqVO createReqVO); + /** * 更新备件台账 * @@ -118,4 +132,11 @@ public interface ItemAccountsService { * @return 备件不分页 */ List getItemAccountsNoPage(ItemAccountsPageReqVO pageReqVO); + + /** + * 根据当前备件编码查询所有库存是否为0 + * @param number + * @return + */ + Boolean qtyZore(String number); } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java index 8601b9a..b2e8240 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java @@ -9,15 +9,19 @@ import com.win.framework.common.pojo.CustomConditions; import com.win.framework.common.pojo.PageResult; import com.win.module.eam.controller.itemaccounts.vo.*; import com.win.module.eam.convert.itemaccounts.ItemAccountsConvert; +import com.win.module.eam.dal.dataobject.devicemaintenancejob.DeviceMaintenanceJobMainDO; import com.win.module.eam.dal.dataobject.item.ItemDO; import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO; import com.win.module.eam.dal.dataobject.itemlocationreplace.ItemLocationReplaceDO; +import com.win.module.eam.dal.dataobject.itemnewturnin.ItemNewTurnInDO; import com.win.module.eam.dal.dataobject.location.LocationDO; import com.win.module.eam.dal.mysql.item.ItemMapper; import com.win.module.eam.dal.mysql.itemaccounts.ItemAccountsMapper; import com.win.module.eam.dal.mysql.itemlocationreplace.ItemLocationReplaceMapper; +import com.win.module.eam.dal.mysql.itemnewturnin.ItemNewTurnInMapper; import com.win.module.eam.dal.mysql.location.LocationMapper; import com.win.module.eam.enums.basic.BooleanTypeEnum; +import com.win.module.eam.enums.itemAccount.ItemAccountStatusEnum; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; @@ -30,8 +34,9 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import static com.win.module.eam.enums.ErrorCodeConstants.LOCATION_CAN_NOT_REPLACE; -import static com.win.module.eam.enums.ErrorCodeConstants.LOCATION_CAN_NOT_REPLACE2; +import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.win.module.eam.enums.ErrorCodeConstants.*; +import static com.win.module.eam.enums.ErrorCodeConstants.CLASSTYPR_NO_NOMAL; /** * 备件台账 Service 实现类 @@ -54,13 +59,115 @@ public class ItemAccountsServiceImpl implements ItemAccountsService { @Resource private ItemMapper itemMapper; + @Resource + private ItemNewTurnInMapper itemNewTurnInMapper; + @Override public Long createItemAccounts(ItemAccountsCreateReqVO createReqVO) { - // 插入 - ItemAccountsDO itemAccounts = ItemAccountsConvert.INSTANCE.convert(createReqVO); - itemAccountsMapper.insert(itemAccounts); - // 返回 - return itemAccounts.getId(); + long id = 0; + //校验 + ItemAccountsDO itemAccountsDO = validateItemAndTypeAndLocation(createReqVO.getItemNumber(), createReqVO.getType(), createReqVO.getLocationNumber()); + if(itemAccountsDO!=null){//存在则更新库存 + ItemAccountsDO updateObj = ItemAccountsConvert.INSTANCE.convert(createReqVO); + BigDecimal qty = itemAccountsDO.getQty(); + BigDecimal add = updateObj.getQty().add(qty); + updateObj.setQty(add); + updateObj.setId(itemAccountsDO.getId()); + itemAccountsMapper.updateById(updateObj); + id = updateObj.getId(); + }else{ + // 插入 + ItemAccountsDO itemAccounts = ItemAccountsConvert.INSTANCE.convert(createReqVO); + itemAccountsMapper.insert(itemAccounts); + id = itemAccounts.getId(); + } + return id; + } + + @Override + public Long createIn(ItemAccountsCreateReqVO createReqVO) { + long id = 0; + //校验 + ItemAccountsDO itemAccountsDO = validateItemAndTypeAndLocation(createReqVO.getItemNumber(), createReqVO.getType(), createReqVO.getLocationNumber()); + if(itemAccountsDO!=null){//存在则更新库存 + ItemAccountsDO updateObj = ItemAccountsConvert.INSTANCE.convert(createReqVO); + BigDecimal qty = itemAccountsDO.getQty(); + BigDecimal add = updateObj.getQty().add(qty); + updateObj.setQty(add); + updateObj.setId(itemAccountsDO.getId()); + itemAccountsMapper.updateById(updateObj); + id = updateObj.getId(); + }else{ + // 插入 + ItemAccountsDO itemAccounts = ItemAccountsConvert.INSTANCE.convert(createReqVO); + itemAccountsMapper.insert(itemAccounts); + id = itemAccounts.getId(); + } + return id; + } + + @Override + @Transactional + public Long newTurnIn(ItemAccountsCreateReqVO createReqVO) { + long id = 0; + BigDecimal newqty = null; + ItemAccountsDO itemAccountsDO = itemAccountsMapper.selectById(createReqVO.getId()); + if(itemAccountsDO==null){// + throw exception(ITEM_TYPE_LOCATION_EXIST);//新到货数据不存在 + } + ItemNewTurnInDO itemNewTurnInDO = new ItemNewTurnInDO();//变更记录 + newqty = createReqVO.getQty(); + //查询有无账内库存 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("item_number",itemAccountsDO.getItemNumber()); + queryWrapper.eq("type", ItemAccountStatusEnum.IN.getCode()); + queryWrapper.eq("location_number",itemAccountsDO.getLocationNumber()); + queryWrapper.eq("available","TRUE"); + List itemAccountsDOS = itemAccountsMapper.selectList(queryWrapper); + if(!itemAccountsDOS.isEmpty()){//有数据更新 + + //往账内添加库存 + BigDecimal qty = itemAccountsDOS.get(0).getQty(); + BigDecimal add = newqty.add(qty); + ItemAccountsDO itemAccountsDO1 = new ItemAccountsDO(); + itemAccountsDO1.setId(itemAccountsDOS.get(0).getId()); + itemAccountsDO1.setQty(add); + int i = itemAccountsMapper.updateById(itemAccountsDO1); + //记录新到货转账内 + id = itemAccountsDO1.getId(); + itemNewTurnInDO.setType("3"); + itemNewTurnInDO.setItemNumber(createReqVO.getItemNumber()); + itemNewTurnInDO.setAreaNumber(createReqVO.getAreaNumber()); + itemNewTurnInDO.setLocationNumber(createReqVO.getLocationNumber()); + itemNewTurnInDO.setNewQty(newqty); + itemNewTurnInDO.setInQty(itemAccountsDOS.get(0).getQty()); + itemNewTurnInDO.setQty(add); + }else{//无数据插入 + ItemAccountsDO itemAccounts = ItemAccountsConvert.INSTANCE.convert(createReqVO); + itemAccounts.setType(ItemAccountStatusEnum.IN.getCode()); + itemAccounts.setId(null); + itemAccountsMapper.insert(itemAccounts); + id = itemAccounts.getId(); + itemNewTurnInDO.setType("2"); + itemNewTurnInDO.setItemNumber(itemAccounts.getItemNumber()); + itemNewTurnInDO.setAreaNumber(itemAccounts.getAreaNumber()); + itemNewTurnInDO.setLocationNumber(itemAccounts.getLocationNumber()); + itemNewTurnInDO.setNewQty(newqty); + itemNewTurnInDO.setQty(newqty); + } + //记录表 + itemNewTurnInMapper.insert(itemNewTurnInDO); + //更新新到货数量 + BigDecimal qty = itemAccountsDO.getQty(); + if(qty.compareTo(newqty) == 0){//等于删除 + itemAccountsMapper.deleteById(createReqVO.getId()); + }else{//更新数量 + BigDecimal difference = qty.subtract(newqty); + itemAccountsDO.setQty(difference); + itemAccountsMapper.updateById(itemAccountsDO); + } + //itemAccountsMapper.deleteById(createReqVO.getId()); + return id; } @Override @@ -233,4 +340,30 @@ public class ItemAccountsServiceImpl implements ItemAccountsService { return itemAccountsMapper.selectNoPage(pageReqVO); } + @Override + public Boolean qtyZore(String number) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("item_number",number); + queryWrapper.eq("available","TRUE"); + queryWrapper.ne("qty","0.00"); + List itemDOS = itemAccountsMapper.selectList(queryWrapper); + if(itemDOS.isEmpty()){ + return true; + }else{ + return false; + } + } + + /** + * 新增校验备件编号+类型+库位编码唯一 + */ + private ItemAccountsDO validateItemAndTypeAndLocation(String itemNumber,String type,String locationNumber) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("item_number",itemNumber); + queryWrapper.eq("type",type); + queryWrapper.eq("location_number",locationNumber); + queryWrapper.eq("available","TRUE"); + return itemAccountsMapper.selectOne(queryWrapper); + } + } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemnewturnin/ItemNewTurnInService.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemnewturnin/ItemNewTurnInService.java new file mode 100644 index 0000000..bba4578 --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemnewturnin/ItemNewTurnInService.java @@ -0,0 +1,80 @@ +package com.win.module.eam.service.itemnewturnin; + +import java.util.*; +import javax.validation.*; + +import com.win.module.eam.controller.itemnewturnin.vo.*; +import com.win.module.eam.dal.dataobject.itemnewturnin.ItemNewTurnInDO; +import com.win.framework.common.pojo.PageResult; + +/** + * 备件台账新到货转账内变更记录 Service 接口 + * + * @author 超级管理员 + */ +public interface ItemNewTurnInService { + + /** + * 创建备件台账新到货转账内变更记录 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createItemNewTurnIn(@Valid ItemNewTurnInCreateReqVO createReqVO); + + /** + * 更新备件台账新到货转账内变更记录 + * + * @param updateReqVO 更新信息 + */ + Integer updateItemNewTurnIn(@Valid ItemNewTurnInUpdateReqVO updateReqVO); + + /** + * 删除备件台账新到货转账内变更记录 + * + * @param id 编号 + */ + Integer deleteItemNewTurnIn(Long id); + + /** + * 获得备件台账新到货转账内变更记录 + * + * @param id 编号 + * @return 备件台账新到货转账内变更记录 + */ + ItemNewTurnInDO getItemNewTurnIn(Long id); + + /** + * 获得备件台账新到货转账内变更记录列表 + * + * @param ids 编号 + * @return 备件台账新到货转账内变更记录列表 + */ + List getItemNewTurnInList(Collection ids); + + /** + * 获得备件台账新到货转账内变更记录分页 + * + * @param pageReqVO 分页查询 + * @return 备件台账新到货转账内变更记录分页 + */ + PageResult getItemNewTurnInPage(ItemNewTurnInPageReqVO pageReqVO); + + /** + * 获得备件台账新到货转账内变更记录列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 备件台账新到货转账内变更记录列表 + */ + List getItemNewTurnInList(ItemNewTurnInExportReqVO exportReqVO); + + /** + * 导入备件台账新到货转账内变更记录主信息 + * + * @param datas 导入备件台账新到货转账内变更记录主信息列表 + * @param mode 导入模式1更新2追加3覆盖 + * @param updatePart 是否支持更新 + * @return 导入结果 + */ + public List importItemNewTurnInList(List datas, Integer mode, boolean updatePart); +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemnewturnin/ItemNewTurnInServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemnewturnin/ItemNewTurnInServiceImpl.java new file mode 100644 index 0000000..d79178e --- /dev/null +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemnewturnin/ItemNewTurnInServiceImpl.java @@ -0,0 +1,107 @@ +package com.win.module.eam.service.itemnewturnin; + +import cn.hutool.core.collection.CollUtil; +import com.win.module.eam.controller.itemnewturnin.vo.*; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import com.win.module.eam.dal.dataobject.itemnewturnin.ItemNewTurnInDO; +import com.win.framework.common.pojo.PageResult; + +import com.win.module.eam.convert.itemnewturnin.ItemNewTurnInConvert; +import com.win.module.eam.dal.mysql.itemnewturnin.ItemNewTurnInMapper; + +import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.win.module.eam.enums.ErrorCodeConstants.*; + +/** + * 备件台账新到货转账内变更记录 Service 实现类 + * + * @author 超级管理员 + */ +@Service +@Validated +public class ItemNewTurnInServiceImpl implements ItemNewTurnInService { + + @Resource + private ItemNewTurnInMapper itemNewTurnInMapper; + + @Override + public Long createItemNewTurnIn(ItemNewTurnInCreateReqVO createReqVO) { + // 插入 + ItemNewTurnInDO itemNewTurnIn = ItemNewTurnInConvert.INSTANCE.convert(createReqVO); + itemNewTurnInMapper.insert(itemNewTurnIn); + // 返回 + return itemNewTurnIn.getId(); + } + + @Override + public Integer updateItemNewTurnIn(ItemNewTurnInUpdateReqVO updateReqVO) { + // 校验存在 + //validateItemNewTurnInExists(updateReqVO.getId()); + // 更新 + ItemNewTurnInDO updateObj = ItemNewTurnInConvert.INSTANCE.convert(updateReqVO); + return itemNewTurnInMapper.updateById(updateObj); + } + + @Override + public Integer deleteItemNewTurnIn(Long id) { + // 校验存在 + validateItemNewTurnInExists(id); + // 删除 + return itemNewTurnInMapper.deleteById(id); + } + + private void validateItemNewTurnInExists(Long id) { + if (itemNewTurnInMapper.selectById(id) == null) { + throw exception(ITEM_NEW_TURN_IN_IMPORT_LIST_IS_EMPTY); + } + } + + @Override + public ItemNewTurnInDO getItemNewTurnIn(Long id) { + return itemNewTurnInMapper.selectById(id); + } + + @Override + public List getItemNewTurnInList(Collection ids) { + return itemNewTurnInMapper.selectBatchIds(ids); + } + + @Override + public PageResult getItemNewTurnInPage(ItemNewTurnInPageReqVO pageReqVO) { + return itemNewTurnInMapper.selectPage(pageReqVO); + } + + @Override + public List getItemNewTurnInList(ItemNewTurnInExportReqVO exportReqVO) { + return itemNewTurnInMapper.selectList(exportReqVO); + } + + @Override + public List importItemNewTurnInList(List datas, Integer mode, boolean updatePart) { + if (CollUtil.isEmpty(datas)) { + throw exception(ITEM_NEW_TURN_IN_IMPORT_LIST_IS_EMPTY); + } + + List errorList = new ArrayList<>(); + datas.forEach(item -> { +// if(errorList == null){ +// // 判断如果不存在,在进行插入 +// ItemNewTurnInDO obj = itemNewTurnInMapper.selectByCode(item.getCode()); +// if (obj == null&& mode != 3) { +// itemNewTurnInMapper.insert(ItemNewTurnInConvert.INSTANCE.convert(item)); +// } +// else if (obj != null && mode != 2) {// 如果存在,判断是否允许更新 +// ItemNewTurnInDO itemNewTurnInDO = ItemNewTurnInConvert.INSTANCE.convert(item); +// itemNewTurnInDO.setId(obj.getId()); +// itemNewTurnInMapper.updateById(obj); +// } +// } + }); + + return errorList; + } +} diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationService.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationService.java index cb66c51..956a976 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationService.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationService.java @@ -3,6 +3,7 @@ package com.win.module.eam.service.location; import com.win.framework.common.pojo.CustomConditions; import com.win.framework.common.pojo.PageResult; import com.win.module.eam.controller.location.vo.*; +import com.win.module.eam.dal.dataobject.item.ItemDO; import com.win.module.eam.dal.dataobject.location.LocationDO; import javax.validation.Valid; @@ -108,4 +109,11 @@ public interface LocationService { * @return 分页列表 */ PageResult getLocationSenior(CustomConditions conditions); + + /** + *根据编码查询信息 + * @param number + * @return + */ + LocationDO getByNumber(String number); } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationServiceImpl.java index 922bdab..c04d31f 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationServiceImpl.java @@ -6,6 +6,7 @@ import com.win.framework.common.pojo.CustomConditions; import com.win.framework.common.pojo.PageResult; import com.win.module.eam.controller.location.vo.*; import com.win.module.eam.convert.location.LocationConvert; +import com.win.module.eam.dal.dataobject.item.ItemDO; import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO; import com.win.module.eam.dal.dataobject.itemapplyrequest.ItemApplyRequestDetailDO; import com.win.module.eam.dal.dataobject.location.LocationDO; @@ -211,5 +212,13 @@ public class LocationServiceImpl implements LocationService { return locationMapper.selectSenior(conditions); } + @Override + public LocationDO getByNumber(String number) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("number",number); + queryWrapper.eq("available","TRUE"); + return locationMapper.selectOne(queryWrapper); + } + } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaService.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaService.java index ccd3bfa..5fff3a2 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaService.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaService.java @@ -3,6 +3,7 @@ package com.win.module.eam.service.locationarea; import com.win.framework.common.pojo.CustomConditions; import com.win.framework.common.pojo.PageResult; import com.win.module.eam.controller.locationarea.vo.*; +import com.win.module.eam.dal.dataobject.location.LocationDO; import com.win.module.eam.dal.dataobject.locationarea.LocationAreaDO; import javax.validation.Valid; @@ -77,4 +78,11 @@ public interface LocationAreaService { * @return 分页列表 */ PageResult getLocationAreaSenior(CustomConditions conditions); + + /** + *根据编码查询信息 + * @param number + * @return + */ + LocationAreaDO getByNumber(String number); } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaServiceImpl.java index 02b0624..4ff5450 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaServiceImpl.java @@ -117,4 +117,12 @@ public class LocationAreaServiceImpl implements LocationAreaService { public PageResult getLocationAreaSenior(CustomConditions conditions) { return locationAreaMapper.selectSenior(conditions); } + + @Override + public LocationAreaDO getByNumber(String number) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("number",number); + queryWrapper.eq("available","TRUE"); + return locationAreaMapper.selectOne(queryWrapper); + } } From b49a2d8bd64fe0a39fe438b95dd3adce1fd0c6bb Mon Sep 17 00:00:00 2001 From: songguoqiang <765017469@qq.com> Date: Wed, 8 May 2024 21:32:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=87=E4=BB=B6=E5=BD=92=E8=BF=98=20?= =?UTF-8?q?=E5=A4=87=E4=BB=B6=E5=87=BA=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../itemaccounts/ItemAccountsController.java | 16 ++++++++++ .../ItemInLocationController.java | 26 ++++++++++++++++- .../vo/ItemInLocationBaseVO.java | 11 +++++-- .../vo/ItemInLocationRespVO.java | 2 ++ .../ItemOutLocationController.java | 27 ++++++++++++++++- .../vo/ItemOutLocationBaseVO.java | 8 ++++- .../vo/ItemOutLocationRespVO.java | 3 +- .../iteminlocation/ItemInLocationDO.java | 6 ++++ .../itemoutlocation/ItemOutLocationDO.java | 5 ++++ .../itemaccounts/ItemAccountsService.java | 15 ++++++++++ .../itemaccounts/ItemAccountsServiceImpl.java | 29 +++++++++++++++++++ 11 files changed, 142 insertions(+), 6 deletions(-) diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/ItemAccountsController.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/ItemAccountsController.java index 2b39ca7..fd8c90e 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/ItemAccountsController.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/ItemAccountsController.java @@ -219,6 +219,8 @@ public class ItemAccountsController { vo.setLocationName(locationDO.getName()); LocationAreaDO locationAreaDO = locationAreaService.getByNumber(vo.getAreaNumber()); vo.setAreaName(locationAreaDO.getName()); + Boolean b = itemAccountsService.qtyZore(vo.getItemNumber()); + vo.setDisplay(b); } return success(result); } @@ -232,4 +234,18 @@ public class ItemAccountsController { return success(ItemAccountsConvert.INSTANCE.convertList(pageResult)); } + @GetMapping("/getByLocationNumber") + @Operation(summary = "根据库位获取备件台账") + @Parameter(name = "id", description = "编号", required = true, example = "1024") +// @PreAuthorize("@ss.hasPermission('eam:item-accounts:query')") + public CommonResult getByLocationNumber(@RequestParam("locationNumber") String locationNumber) { + ItemAccountsDO itemAccounts = itemAccountsService.getByLocationNumber(locationNumber); + ItemAccountsRespVO convert = ItemAccountsConvert.INSTANCE.convert(itemAccounts); + if(convert!=null){ + ItemDO itemDO = itemService.getByNumber(itemAccounts.getItemNumber()); + convert.setItemName(itemDO==null?"":itemDO.getName()); + } + return success(convert); + } + } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/ItemInLocationController.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/ItemInLocationController.java index be7e59c..cc8d641 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/ItemInLocationController.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/ItemInLocationController.java @@ -6,9 +6,14 @@ import com.win.framework.common.pojo.PageResult; import com.win.framework.excel.core.util.ExcelUtils; import com.win.framework.operatelog.core.annotations.OperateLog; import com.win.module.eam.controller.iteminlocation.vo.*; +import com.win.module.eam.controller.itemoutlocation.vo.ItemOutLocationRespVO; import com.win.module.eam.convert.iteminlocation.ItemInLocationConvert; +import com.win.module.eam.dal.dataobject.item.ItemDO; import com.win.module.eam.dal.dataobject.iteminlocation.ItemInLocationDO; +import com.win.module.eam.dal.dataobject.location.LocationDO; +import com.win.module.eam.service.item.ItemService; import com.win.module.eam.service.iteminlocation.ItemInLocationService; +import com.win.module.eam.service.location.LocationService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -36,6 +41,12 @@ public class ItemInLocationController { @Resource private ItemInLocationService itemInLocationService; + @Resource + private ItemService itemService; + + @Resource + private LocationService locationService; + @PostMapping("/create") @Operation(summary = "创建备件入库记录") @PreAuthorize("@ss.hasPermission('item:itemInLocation:create')") @@ -83,7 +94,14 @@ public class ItemInLocationController { //@PreAuthorize("@ss.hasPermission('record:item-in-location:query')") public CommonResult> getItemInLocationPage(@Valid ItemInLocationPageReqVO pageVO) { PageResult pageResult = itemInLocationService.getItemInLocationPage(pageVO); - return success(ItemInLocationConvert.INSTANCE.convertPage(pageResult)); + PageResult result = ItemInLocationConvert.INSTANCE.convertPage(pageResult); + for(ItemInLocationRespVO vo:result.getList()){ +// ItemDO itemDO = itemService.getByNumber(vo.getItemNumber()); +// vo.setItemName(itemDO.getName()); + LocationDO locationDO = locationService.getByNumber(vo.getLocationNumber()); + vo.setLocationName(locationDO.getName()); + } + return success(result); } @GetMapping("/export-excel") @@ -112,6 +130,12 @@ public class ItemInLocationController { public CommonResult> getLocationSenior(@Valid @RequestBody CustomConditions conditions) { PageResult pageResult = itemInLocationService.getItemInLocationSenior(conditions); PageResult result = ItemInLocationConvert.INSTANCE.convertPage(pageResult); + for(ItemInLocationRespVO vo:result.getList()){ +// ItemDO itemDO = itemService.getByNumber(vo.getItemNumber()); +// vo.setItemName(itemDO.getName()); + LocationDO locationDO = locationService.getByNumber(vo.getLocationNumber()); + vo.setLocationName(locationDO.getName()); + } return success(result); } } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationBaseVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationBaseVO.java index a4a22ff..8c9dee7 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationBaseVO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationBaseVO.java @@ -16,11 +16,11 @@ public class ItemInLocationBaseVO { private Long id; @Schema(description = "入库编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "入库编号不能为空") + //@NotNull(message = "入库编号不能为空") private String number; @Schema(description = "备件编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "备件编号不能为空") + //@NotNull(message = "备件编号不能为空") private String itemNumber; @Schema(description = "库位编号", requiredMode = Schema.RequiredMode.REQUIRED) @@ -33,4 +33,11 @@ public class ItemInLocationBaseVO { @Schema(description = "数量") private BigDecimal qty; + + @Schema(description = "归还人id") + private String returner; + + @Schema(description = "归还人名称") + private String returnName; + } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationRespVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationRespVO.java index d68972f..37c61e8 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationRespVO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationRespVO.java @@ -9,5 +9,7 @@ import java.time.LocalDateTime; @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class ItemInLocationRespVO extends ItemInLocationBaseVO { + private String itemName; + private String locationName; } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/ItemOutLocationController.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/ItemOutLocationController.java index af27a47..5205499 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/ItemOutLocationController.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/ItemOutLocationController.java @@ -5,10 +5,16 @@ import com.win.framework.common.pojo.CustomConditions; import com.win.framework.common.pojo.PageResult; import com.win.framework.excel.core.util.ExcelUtils; import com.win.framework.operatelog.core.annotations.OperateLog; +import com.win.module.eam.controller.itemaccounts.vo.ItemAccountsRespVO; import com.win.module.eam.controller.itemoutlocation.vo.*; import com.win.module.eam.convert.itemoutlocation.ItemOutLocationConvert; +import com.win.module.eam.dal.dataobject.item.ItemDO; import com.win.module.eam.dal.dataobject.itemoutlocation.ItemOutLocationDO; +import com.win.module.eam.dal.dataobject.location.LocationDO; +import com.win.module.eam.dal.dataobject.locationarea.LocationAreaDO; +import com.win.module.eam.service.item.ItemService; import com.win.module.eam.service.itemoutlocation.ItemOutLocationService; +import com.win.module.eam.service.location.LocationService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -36,6 +42,12 @@ public class ItemOutLocationController { @Resource private ItemOutLocationService itemOutLocationService; + @Resource + private ItemService itemService; + + @Resource + private LocationService locationService; + @PostMapping("/create") @Operation(summary = "创建备件出库记录") @PreAuthorize("@ss.hasPermission('item:itemOutLocation:create')") @@ -83,7 +95,14 @@ public class ItemOutLocationController { // @PreAuthorize("@ss.hasPermission('record:item-out-location:query')") public CommonResult> getItemOutLocationPage(@Valid ItemOutLocationPageReqVO pageVO) { PageResult pageResult = itemOutLocationService.getItemOutLocationPage(pageVO); - return success(ItemOutLocationConvert.INSTANCE.convertPage(pageResult)); + PageResult result = ItemOutLocationConvert.INSTANCE.convertPage(pageResult); + for(ItemOutLocationRespVO vo:result.getList()){ + ItemDO itemDO = itemService.getByNumber(vo.getItemNumber()); + vo.setItemName(itemDO.getName()); + LocationDO locationDO = locationService.getByNumber(vo.getLocationNumber()); + vo.setLocationName(locationDO.getName()); + } + return success(result); } @GetMapping("/export-excel") @@ -112,6 +131,12 @@ public class ItemOutLocationController { public CommonResult> getLocationSenior(@Valid @RequestBody CustomConditions conditions) { PageResult pageResult = itemOutLocationService.getItemOutLocationSenior(conditions); PageResult result = ItemOutLocationConvert.INSTANCE.convertPage(pageResult); + for(ItemOutLocationRespVO vo:result.getList()){ + ItemDO itemDO = itemService.getByNumber(vo.getItemNumber()); + vo.setItemName(itemDO.getName()); + LocationDO locationDO = locationService.getByNumber(vo.getLocationNumber()); + vo.setLocationName(locationDO.getName()); + } return success(result); } } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationBaseVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationBaseVO.java index 460f794..0e0b20f 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationBaseVO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationBaseVO.java @@ -16,7 +16,7 @@ public class ItemOutLocationBaseVO { private Long id; @Schema(description = "出库编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出库编号不能为空") + //@NotNull(message = "出库编号不能为空") private String number; @Schema(description = "备件编号", requiredMode = Schema.RequiredMode.REQUIRED) @@ -33,4 +33,10 @@ public class ItemOutLocationBaseVO { @Schema(description = "数量") private BigDecimal qty; + @Schema(description = "领用人id") + private String receiver; + + @Schema(description = "领用人名称") + private String receiveName; + } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationRespVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationRespVO.java index a12b8c3..c1b6c57 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationRespVO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationRespVO.java @@ -9,5 +9,6 @@ import java.time.LocalDateTime; @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class ItemOutLocationRespVO extends ItemOutLocationBaseVO { - + private String itemName; + private String locationName; } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/iteminlocation/ItemInLocationDO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/iteminlocation/ItemInLocationDO.java index 0484225..f5eb867 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/iteminlocation/ItemInLocationDO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/iteminlocation/ItemInLocationDO.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.Version; import com.win.framework.mybatis.core.dataobject.BaseDO; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.math.BigDecimal; @@ -35,10 +36,15 @@ public class ItemInLocationDO extends BaseDO { * 备件编号 */ private String itemNumber; + /** * 库位编号 */ private String locationNumber; + /** + * 归还人 + */ + private String returner; /** * 入库类型 */ diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemoutlocation/ItemOutLocationDO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemoutlocation/ItemOutLocationDO.java index 91f7473..ce8d67b 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemoutlocation/ItemOutLocationDO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/itemoutlocation/ItemOutLocationDO.java @@ -35,6 +35,7 @@ public class ItemOutLocationDO extends BaseDO { * 备件编号 */ private String itemNumber; + /** * 库位编号 */ @@ -47,6 +48,10 @@ public class ItemOutLocationDO extends BaseDO { * 数量 */ private BigDecimal qty; + /** + * 领用人id + */ + private String receiver; /** * 地点ID */ diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsService.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsService.java index e1f3978..520f52d 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsService.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsService.java @@ -6,6 +6,7 @@ import com.win.module.eam.controller.itemaccounts.vo.*; import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO; import javax.validation.Valid; +import java.math.BigDecimal; import java.util.Collection; import java.util.List; import java.util.Map; @@ -61,6 +62,13 @@ public interface ItemAccountsService { */ ItemAccountsDO getItemAccounts(Long id); + /** + * 根据库位编码查询备件信息 + * @param locationNumber + * @return + */ + ItemAccountsDO getByLocationNumber(String locationNumber); + /** * 获得备件台账列表 * @@ -139,4 +147,11 @@ public interface ItemAccountsService { * @return */ Boolean qtyZore(String number); + + /** + * 根据库位编码查询备件所有库存 + * @param locationNumber + * @return + */ + BigDecimal getAllByLocation(String locationNumber); } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java index b2e8240..0f5bd36 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java @@ -198,6 +198,22 @@ public class ItemAccountsServiceImpl implements ItemAccountsService { return itemAccountsMapper.selectById(id); } + @Override + public ItemAccountsDO getByLocationNumber(String locationNumber) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("location_number",locationNumber); + queryWrapper.eq("available","TRUE"); + List itemAccountsDOS = itemAccountsMapper.selectList(queryWrapper); + if(itemAccountsDOS.isEmpty()){ + return new ItemAccountsDO(); + }else{//有数据查询所有的库存 + ItemAccountsDO itemAccountsDO = itemAccountsDOS.get(0); + BigDecimal allByLocation = getAllByLocation(locationNumber); + itemAccountsDO.setQty(allByLocation); + return itemAccountsDO; + } + } + @Override public List getItemAccountsList(Collection ids) { return itemAccountsMapper.selectBatchIds(ids); @@ -354,6 +370,19 @@ public class ItemAccountsServiceImpl implements ItemAccountsService { } } + @Override + public BigDecimal getAllByLocation(String locationNumber) { + BigDecimal qty = BigDecimal.ZERO; + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("location_number",locationNumber); + queryWrapper.eq("available","TRUE"); + List itemDOS = itemAccountsMapper.selectList(queryWrapper); + for(ItemAccountsDO en:itemDOS){ + qty = qty.add(en.getQty()); + } + return qty; + } + /** * 新增校验备件编号+类型+库位编码唯一 */