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 4fb7267..5292d32 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 @@ -56,6 +56,13 @@ public class ItemInLocationController { return success(itemInLocationService.createItemInLocation(createReqVO)); } + @PostMapping("/createPDA") + @Operation(summary = "PDA创建备件入库记录") + @PreAuthorize("@ss.hasPermission('item:itemInLocation:create')") + public CommonResult createPDA(@Valid @RequestBody ItemInLocationCreateReqVO createReqVO) { + return success(itemInLocationService.createPDA(createReqVO)); + } + @PutMapping("/update") @Operation(summary = "更新备件入库记录") @PreAuthorize("@ss.hasPermission('item:itemInLocation:update')") 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 8c9dee7..fabcae0 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 @@ -24,7 +24,7 @@ public class ItemInLocationBaseVO { private String itemNumber; @Schema(description = "库位编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "库位编号不能为空") + //@NotNull(message = "库位编号不能为空") private String locationNumber; @Schema(description = "入库类型", example = "1") @@ -34,7 +34,7 @@ public class ItemInLocationBaseVO { private BigDecimal qty; - @Schema(description = "归还人id") + @Schema(description = "归还人") private String returner; @Schema(description = "归还人名称") diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationCreateReqVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationCreateReqVO.java index b1edd97..84b4fbb 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationCreateReqVO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/iteminlocation/vo/ItemInLocationCreateReqVO.java @@ -11,4 +11,7 @@ import javax.validation.constraints.*; @ToString(callSuper = true) public class ItemInLocationCreateReqVO extends ItemInLocationBaseVO { private String areaNumber; + + @Schema(description = "库位备件和数量") + private List> itemNumbers; } 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 aed1975..29e27bb 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 @@ -58,6 +58,13 @@ public class ItemOutLocationController { return success(itemOutLocationService.createItemOutLocation(createReqVO)); } + @PostMapping("/createPDA") + @Operation(summary = "PDA创建备件出库记录") + @PreAuthorize("@ss.hasPermission('item:itemOutLocation:create')") + public CommonResult createPDA(@Valid @RequestBody ItemOutLocationCreateReqVO createReqVO) { + return success(itemOutLocationService.createPDA(createReqVO)); + } + @PutMapping("/update") @Operation(summary = "更新备件出库记录") @PreAuthorize("@ss.hasPermission('item:itemOutLocation:update')") 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 dc53c1b..41d0688 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 @@ -20,11 +20,11 @@ public class ItemOutLocationBaseVO { private String number; @Schema(description = "备件编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "备件编号不能为空") + //@NotNull(message = "备件编号不能为空") private String itemNumber; @Schema(description = "库位编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "库位编号不能为空") + //@NotNull(message = "库位编号不能为空") private String locationNumber; @Schema(description = "出库类型", example = "1") diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationCreateReqVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationCreateReqVO.java index 30b65d3..80b743e 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationCreateReqVO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemoutlocation/vo/ItemOutLocationCreateReqVO.java @@ -12,4 +12,7 @@ import javax.validation.constraints.*; public class ItemOutLocationCreateReqVO extends ItemOutLocationBaseVO { private String areaNumber; + @Schema(description = "库位备件和数量") + private List> itemNumbers; + } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/iteminlocation/ItemInLocationService.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/iteminlocation/ItemInLocationService.java index e1dd66d..cbc5a22 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/iteminlocation/ItemInLocationService.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/iteminlocation/ItemInLocationService.java @@ -26,6 +26,7 @@ public interface ItemInLocationService { * @return 编号 */ Long createItemInLocation(@Valid ItemInLocationCreateReqVO createReqVO); + Long createPDA(@Valid ItemInLocationCreateReqVO createReqVO); /** * 更新备件入库记录 diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/iteminlocation/ItemInLocationServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/iteminlocation/ItemInLocationServiceImpl.java index 483c971..98484eb 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/iteminlocation/ItemInLocationServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/iteminlocation/ItemInLocationServiceImpl.java @@ -1,5 +1,6 @@ package com.win.module.eam.service.iteminlocation; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.win.framework.common.pojo.CustomConditions; import com.win.framework.common.pojo.PageResult; import com.win.module.eam.controller.iteminlocation.vo.ItemInLocationCreateReqVO; @@ -9,8 +10,10 @@ import com.win.module.eam.controller.iteminlocation.vo.ItemInLocationUpdateReqVO import com.win.module.eam.controller.transaction.vo.TransactionCreateReqVO; import com.win.module.eam.convert.iteminlocation.ItemInLocationConvert; import com.win.module.eam.dal.dataobject.iteminlocation.ItemInLocationDO; +import com.win.module.eam.dal.dataobject.itemorder.ItemOrderDetailDO; import com.win.module.eam.dal.dataobject.location.LocationDO; import com.win.module.eam.dal.mysql.iteminlocation.ItemInLocationMapper; +import com.win.module.eam.dal.mysql.location.LocationMapper; import com.win.module.eam.enums.itemAccount.ItemAccountStatusEnum; import com.win.module.eam.enums.transaction.TransactionEnum; import com.win.module.eam.service.transaction.TransactionService; @@ -19,9 +22,11 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.win.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @@ -42,6 +47,9 @@ public class ItemInLocationServiceImpl implements ItemInLocationService { @Resource private TransactionService transactionService; + @Resource + private LocationMapper locationMapper; + @Override @Transactional public Long createItemInLocation(ItemInLocationCreateReqVO createReqVO) { @@ -69,6 +77,47 @@ public class ItemInLocationServiceImpl implements ItemInLocationService { return itemInLocation.getId(); } + @Override + @Transactional + public Long createPDA(ItemInLocationCreateReqVO createReqVO) { + long i=0l; + List> itemList = createReqVO.getItemNumbers();//备件号集合 + List list = new ArrayList<>(); + if(createReqVO.getItemNumbers()!=null&& !createReqVO.getItemNumbers().isEmpty()){ + for (Map map : itemList) { + String itemNumber = map.get("itemNumber").toString();//备件号 + String qty = map.get("qty").toString();//入库数量 + String locationNumber = map.get("locationNumber").toString();//库位 + LocationDO byNumber = locationMapper.getByNumber(locationNumber); + // 插入 + createReqVO.setAreaNumber(byNumber.getAreaNumber()); + createReqVO.setItemNumber(itemNumber); + createReqVO.setLocationNumber(locationNumber); + createReqVO.setQty(new BigDecimal(qty)); + ItemInLocationDO itemInLocation = ItemInLocationConvert.INSTANCE.convert(createReqVO); + itemInLocation.setType(TransactionEnum.RETURN_IN.getCode()); + itemInLocationMapper.insert(itemInLocation); + i = itemInLocation.getId(); + //添加库存事务 + TransactionCreateReqVO transactionCreateReqVO = new TransactionCreateReqVO(); + transactionCreateReqVO.setItemNumber(createReqVO.getItemNumber()); + transactionCreateReqVO.setLocationNumber(createReqVO.getLocationNumber()); + transactionCreateReqVO.setAreaNumber(createReqVO.getAreaNumber()); + transactionCreateReqVO.setTransactionType("IN"); + transactionCreateReqVO.setQty(createReqVO.getQty()); + transactionCreateReqVO.setDescribes("备件归还");//描述 + transactionCreateReqVO.setOperator(createReqVO.getReturner()); + transactionCreateReqVO.setCreator(getLoginUserId().toString()); + transactionCreateReqVO.setAssociatedNumber(null); + transactionCreateReqVO.setInventoryAction(TransactionEnum.RETURN_IN.getCode()); + transactionCreateReqVO.setType(ItemAccountStatusEnum.OUT.getCode()); + list.add(transactionCreateReqVO); + } + transactionService.create(list); + } + return i; + } + @Override public Integer updateItemInLocation(ItemInLocationUpdateReqVO updateReqVO) { // 校验存在 diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemoutlocation/ItemOutLocationService.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemoutlocation/ItemOutLocationService.java index 6cccef4..6528957 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemoutlocation/ItemOutLocationService.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemoutlocation/ItemOutLocationService.java @@ -27,6 +27,8 @@ public interface ItemOutLocationService { */ Long createItemOutLocation(@Valid ItemOutLocationCreateReqVO createReqVO); + Long createPDA(@Valid ItemOutLocationCreateReqVO createReqVO); + /** * 更新备件出库记录 * diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemoutlocation/ItemOutLocationServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemoutlocation/ItemOutLocationServiceImpl.java index 9bc8633..9d66af3 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemoutlocation/ItemOutLocationServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemoutlocation/ItemOutLocationServiceImpl.java @@ -7,10 +7,13 @@ import com.win.module.eam.controller.itemoutlocation.vo.ItemOutLocationExportReq import com.win.module.eam.controller.itemoutlocation.vo.ItemOutLocationPageReqVO; import com.win.module.eam.controller.itemoutlocation.vo.ItemOutLocationUpdateReqVO; import com.win.module.eam.controller.transaction.vo.TransactionCreateReqVO; +import com.win.module.eam.convert.iteminlocation.ItemInLocationConvert; import com.win.module.eam.convert.itemoutlocation.ItemOutLocationConvert; +import com.win.module.eam.dal.dataobject.iteminlocation.ItemInLocationDO; import com.win.module.eam.dal.dataobject.itemoutlocation.ItemOutLocationDO; import com.win.module.eam.dal.dataobject.location.LocationDO; import com.win.module.eam.dal.mysql.itemoutlocation.ItemOutLocationMapper; +import com.win.module.eam.dal.mysql.location.LocationMapper; import com.win.module.eam.enums.itemAccount.ItemAccountStatusEnum; import com.win.module.eam.enums.transaction.TransactionEnum; import com.win.module.eam.service.transaction.TransactionService; @@ -19,9 +22,11 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.win.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @@ -42,6 +47,9 @@ public class ItemOutLocationServiceImpl implements ItemOutLocationService { @Resource private TransactionService transactionService; + @Resource + private LocationMapper locationMapper; + @Override @Transactional public Long createItemOutLocation(ItemOutLocationCreateReqVO createReqVO) { @@ -69,6 +77,46 @@ public class ItemOutLocationServiceImpl implements ItemOutLocationService { return itemOutLocation.getId(); } + @Override + public Long createPDA(ItemOutLocationCreateReqVO createReqVO) { + long i=0l; + List> itemList = createReqVO.getItemNumbers();//备件号集合 + List list = new ArrayList<>(); + if(createReqVO.getItemNumbers()!=null&& !createReqVO.getItemNumbers().isEmpty()){ + for (Map map : itemList) { + String itemNumber = map.get("itemNumber").toString();//备件号 + String qty = map.get("qty").toString();//入库数量 + String locationNumber = map.get("locationNumber").toString();//库位 + LocationDO byNumber = locationMapper.getByNumber(locationNumber); + // 插入 + createReqVO.setAreaNumber(byNumber.getAreaNumber()); + createReqVO.setItemNumber(itemNumber); + createReqVO.setLocationNumber(locationNumber); + createReqVO.setQty(new BigDecimal(qty)); + ItemOutLocationDO outLocationDO = ItemOutLocationConvert.INSTANCE.convert(createReqVO); + outLocationDO.setType(TransactionEnum.RETURN_IN.getCode()); + itemOutLocationMapper.insert(outLocationDO); + i = outLocationDO.getId(); + //添加库存事务 + TransactionCreateReqVO transactionCreateReqVO = new TransactionCreateReqVO(); + transactionCreateReqVO.setItemNumber(createReqVO.getItemNumber()); + transactionCreateReqVO.setLocationNumber(createReqVO.getLocationNumber()); + transactionCreateReqVO.setAreaNumber(createReqVO.getAreaNumber()); + transactionCreateReqVO.setTransactionType("OUT"); + transactionCreateReqVO.setQty(createReqVO.getQty()); + transactionCreateReqVO.setDescribes("备件出库");//描述 + transactionCreateReqVO.setOperator(createReqVO.getReceiver()); + transactionCreateReqVO.setCreator(getLoginUserId().toString()); + transactionCreateReqVO.setAssociatedNumber(null); + transactionCreateReqVO.setInventoryAction(TransactionEnum.REQUISITION_OUT.getCode()); + transactionCreateReqVO.setType(ItemAccountStatusEnum.IN.getCode()); + list.add(transactionCreateReqVO); + } + transactionService.create(list); + } + return i; + } + @Override public Integer updateItemOutLocation(ItemOutLocationUpdateReqVO updateReqVO) { // 校验存在 diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/transaction/TransactionServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/transaction/TransactionServiceImpl.java index 0347af9..9f6bde1 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/transaction/TransactionServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/transaction/TransactionServiceImpl.java @@ -75,7 +75,7 @@ public class TransactionServiceImpl implements TransactionService { for(TransactionDO en:transactionDOS){//循环出库存记录 TransactionDO transactionDO = TransactionConvert.INSTANCE.convert(createReqVO); transactionDO.setType(en.getType()); - transactionDO.setInventoryAction(en.getInventoryAction()); + transactionDO.setInventoryAction(en.getInventoryAction()==null?transactionDO.getInventoryAction():en.getInventoryAction()); transactionDO.setQty(en.getQty()); result += Mapper.insert(transactionDO); } diff --git a/win-server/src/main/resources/application.yaml b/win-server/src/main/resources/application.yaml index 6c293db..7ae5271 100644 --- a/win-server/src/main/resources/application.yaml +++ b/win-server/src/main/resources/application.yaml @@ -8,7 +8,7 @@ spring: profiles: include: druid - active: prod + active: test main: allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。