From 201a2d7f3388490560c9fc4131e059abaf5af55b Mon Sep 17 00:00:00 2001 From: Leon <3066758958@qq.com> Date: Tue, 13 Jul 2021 10:44:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E9=97=B4=E5=8F=91=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/DataImportConstant.java | 9 ++ .../src/main/resources/application-dev.yml | 14 ++- .../src/main/resources/application-local.yml | 2 +- .../controller/CallItemController.java | 6 +- .../controller/IssueItemController.java | 26 +++- .../SurplusItemReturnController.java | 2 +- .../mesnac/dispatch/dto/IssueItemDto.java | 23 +++- .../mesnac/dispatch/model/IssueItem.java | 8 +- .../dispatch/service/IssueItemService.java | 5 + .../service/impl/IssueItemServiceImpl.java | 112 +++++++++++++++++- 10 files changed, 183 insertions(+), 24 deletions(-) diff --git a/common/src/main/java/com/foreverwin/mesnac/common/constant/DataImportConstant.java b/common/src/main/java/com/foreverwin/mesnac/common/constant/DataImportConstant.java index 746ffb42..5deb1588 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/constant/DataImportConstant.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/constant/DataImportConstant.java @@ -94,4 +94,13 @@ public interface DataImportConstant { String NC_CODE_CATEGORY_FAILURE = "故障"; String NC_CODE_CATEGORY_DEFECT = "缺陷"; String NC_CODE_CATEGORY_REPAIR = "修复"; + + //物料类型-原始 + String ITEM_MATERIAL_TYPE_ROH = "ROH"; + //物料类型-半成品 + String ITEM_MATERIAL_TYPE_HALB = "HALB"; + //物料类型-已完成 + String ITEM_MATERIAL_TYPE_FERT = "FERT"; + //物料类型-包装 + String ITEM_MATERIAL_TYPE_VERP = "VERP"; } diff --git a/console/src/main/resources/application-dev.yml b/console/src/main/resources/application-dev.yml index c4ca7256..68bc17c7 100644 --- a/console/src/main/resources/application-dev.yml +++ b/console/src/main/resources/application-dev.yml @@ -6,5 +6,17 @@ spring: wip: driver-class-name: com.sap.db.jdbc.Driver jndi-name: jdbc/jts/wipPool - + activemq: + enabled: false + brokerUrl: tcp://localhost:61616?wireFormat.maxInactivityDuration=0 + password: admin + user: admin + pool: + enabled: true + max-connections: 10 +ftp: + host: 106.52.244.124 + port: 21 + username: zjw + password: zhaojiawei diff --git a/console/src/main/resources/application-local.yml b/console/src/main/resources/application-local.yml index b9642b34..02e00be8 100644 --- a/console/src/main/resources/application-local.yml +++ b/console/src/main/resources/application-local.yml @@ -9,7 +9,7 @@ spring: password: wip driver-class-name: oracle.jdbc.OracleDriver activemq: - enabled: true + enabled: false brokerUrl: tcp://localhost:61616?wireFormat.maxInactivityDuration=0 password: admin user: admin diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/CallItemController.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/CallItemController.java index d0d7b17a..065bd182 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/CallItemController.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/CallItemController.java @@ -12,7 +12,9 @@ import org.springframework.web.bind.annotation.*; import com.foreverwin.mesnac.dispatch.service.CallItemService; import com.foreverwin.mesnac.dispatch.model.CallItem; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; /** @@ -174,10 +176,10 @@ public class CallItemController { issueItemDto.setDispatchNo(dispatchNo); issueItemDto.setMatchResource(matchResource); if (StringUtil.notBlank(requiredFromDate)) { - issueItemDto.setRequiredFromDT(LocalDateTime.parse(requiredFromDate)); + issueItemDto.setRequiredFromDT(LocalDate.parse(requiredFromDate, DateTimeFormatter.ISO_DATE)); } if (StringUtil.notBlank(requiredToDate)) { - issueItemDto.setRequiredToDT(LocalDateTime.parse(requiredToDate)); + issueItemDto.setRequiredToDT(LocalDate.parse(requiredToDate, DateTimeFormatter.ISO_DATE)); } result = callItemService.findIssueItemList(issueItemDto); diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/IssueItemController.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/IssueItemController.java index b74f6038..3f5c5a2d 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/IssueItemController.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/IssueItemController.java @@ -1,17 +1,14 @@ package com.foreverwin.mesnac.dispatch.controller; +import com.alibaba.fastjson.JSONObject; +import com.foreverwin.modular.core.exception.BusinessException; import com.foreverwin.modular.core.util.R; -import com.foreverwin.modular.core.util.FrontPage; import com.foreverwin.modular.core.util.CommonMethods; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.foreverwin.mesnac.dispatch.service.IssueItemService; -import com.foreverwin.mesnac.dispatch.model.IssueItem; -import java.util.List; /** * @@ -37,4 +34,23 @@ public class IssueItemController { return R.ok(); } + + + @ResponseBody + @PostMapping("/issueItem") + public R issueItem(@RequestBody JSONObject jsonObject){ + try { + if (jsonObject == null) { + throw BusinessException.build("请添加发料清单!"); + } + String site = CommonMethods.getSite(); + String user = CommonMethods.getUser(); + + issueItemService.issueItem(site, user, jsonObject); + } catch (Exception e) { + return R.failed(e.getMessage()); + } + + return R.ok(); + } } \ No newline at end of file diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/SurplusItemReturnController.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/SurplusItemReturnController.java index 5a6b753a..ef37c6f8 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/SurplusItemReturnController.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/SurplusItemReturnController.java @@ -71,6 +71,6 @@ public class SurplusItemReturnController { return R.failed(e.getMessage()); } - return R.ok("物料条码【" +inventory+ "】余料退回操作成功!"); + return R.ok(0,"物料条码【" +inventory+ "】余料退回操作成功!"); } } \ No newline at end of file diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/dto/IssueItemDto.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/dto/IssueItemDto.java index b6b8c430..0b83b500 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/dto/IssueItemDto.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/dto/IssueItemDto.java @@ -1,18 +1,21 @@ package com.foreverwin.mesnac.dispatch.dto; import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDate; import java.time.LocalDateTime; public class IssueItemDto implements Serializable { private String site; + private String item; private String resource; private String workCenter; private String shopOrder; private String dispatchNo; private Boolean matchResource; - private LocalDateTime requiredFromDT; - private LocalDateTime requiredToDT; + private LocalDate requiredFromDT; + private LocalDate requiredToDT; public String getSite() { return site; @@ -22,6 +25,14 @@ public class IssueItemDto implements Serializable { this.site = site; } + public String getItem() { + return item; + } + + public void setItem(String item) { + this.item = item; + } + public String getResource() { return resource; } @@ -62,19 +73,19 @@ public class IssueItemDto implements Serializable { this.matchResource = matchResource; } - public LocalDateTime getRequiredFromDT() { + public LocalDate getRequiredFromDT() { return requiredFromDT; } - public void setRequiredFromDT(LocalDateTime requiredFromDT) { + public void setRequiredFromDT(LocalDate requiredFromDT) { this.requiredFromDT = requiredFromDT; } - public LocalDateTime getRequiredToDT() { + public LocalDate getRequiredToDT() { return requiredToDT; } - public void setRequiredToDT(LocalDateTime requiredToDT) { + public void setRequiredToDT(LocalDate requiredToDT) { this.requiredToDT = requiredToDT; } } diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/IssueItem.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/IssueItem.java index f23c701e..fa6e98da 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/IssueItem.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/IssueItem.java @@ -4,6 +4,8 @@ import java.io.Serializable; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; + +import java.math.BigDecimal; import java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; @@ -63,7 +65,7 @@ public class IssueItem extends Model { * 发料数量 */ @TableField("QTY") - private Double qty; + private BigDecimal qty; /** * 创建用户 */ @@ -142,11 +144,11 @@ public class IssueItem extends Model { this.inventory = inventory; } - public Double getQty() { + public BigDecimal getQty() { return qty; } - public void setQty(Double qty) { + public void setQty(BigDecimal qty) { this.qty = qty; } diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/IssueItemService.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/IssueItemService.java index 2821e334..a3fdd3f7 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/IssueItemService.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/IssueItemService.java @@ -1,8 +1,11 @@ package com.foreverwin.mesnac.dispatch.service; ; +import com.alibaba.fastjson.JSONObject; +import com.foreverwin.mesnac.dispatch.dto.IssueItemDto; import com.foreverwin.mesnac.dispatch.model.IssueItem; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; import java.util.Map; @@ -17,4 +20,6 @@ import java.util.Map; public interface IssueItemService extends IService { Map scanIssueInventory(String site, String item, String inventory); + + void issueItem(String site, String user, JSONObject jsonObject); } \ No newline at end of file diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/IssueItemServiceImpl.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/IssueItemServiceImpl.java index bff7c72e..baab0a86 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/IssueItemServiceImpl.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/IssueItemServiceImpl.java @@ -1,6 +1,10 @@ package com.foreverwin.mesnac.dispatch.service.impl; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.foreverwin.mesnac.common.constant.DataImportConstant; import com.foreverwin.mesnac.common.enums.HandleEnum; +import com.foreverwin.mesnac.common.util.ExceptionUtil; import com.foreverwin.mesnac.dispatch.model.IssueItem; import com.foreverwin.mesnac.dispatch.mapper.IssueItemMapper; import com.foreverwin.mesnac.dispatch.model.ItemBatch; @@ -12,14 +16,17 @@ import com.foreverwin.mesnac.meapi.model.Item; import com.foreverwin.mesnac.meapi.service.InventoryService; import com.foreverwin.mesnac.meapi.service.ItemService; import com.foreverwin.modular.core.exception.BusinessException; +import com.foreverwin.modular.core.meext.MEServices; import com.sap.me.common.MaterialType; +import com.sap.me.common.ObjectReference; +import com.sap.me.inventory.*; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.*; /** @@ -37,8 +44,6 @@ public class IssueItemServiceImpl extends ServiceImpl issueItemList = new ArrayList<>(); + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + if (!oddments) { + //非余料发料 原材料-创建库存,计算发料数量; 半成品-只计算发料数量 + InventoryServiceInterface meInventoryService; + try { + meInventoryService = MEServices.create("com.sap.me.inventory", "InventoryService", site); + } catch (Exception e) { + throw BusinessException.build("获取标准库存操作服务失败:" + e.getMessage()); + } + + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject _jsonObject = jsonArray.getJSONObject(i); + + String inventory = _jsonObject.getString("inventory"); + String qty = _jsonObject.getString("qty"); + BigDecimal qtyOnHand = new BigDecimal(qty); + + if (MaterialType.RAW.value().equals(materialType)) { + List itemBatchList = itemBatchService.findItemBatch(site, item, inventory); + if (itemBatchList == null || itemBatchList.size() <= 0) { + throw BusinessException.build("扫描的物料条码【 " + inventory + " 】不存在!"); + } + + try { + //查询库存是否存在 + ObjectReference objectReference = new ObjectReference(); + String inventoryBo = HandleEnum.INVENTORY.getHandle(site, inventory); + objectReference.setRef(inventoryBo); + com.sap.me.inventory.Inventory inventoryModel = meInventoryService.findInventoryByRef(objectReference); + + if (inventoryModel == null) { + //库存创建 + InventoryValidateAndAddRequest request = new InventoryValidateAndAddRequest(); + request.setItemRef(itemBo); + request.setInventoryId(inventory); + request.setQuantityOnHand(qtyOnHand); + meInventoryService.validateAndAdd(request); + } else { + qtyOnHand = qtyOnHand.add(inventoryModel.getQtyOnHand()); + + //库存修改 + InventoryValidateAndUpdateWithReceiveQuantityOverrideRequest request = new InventoryValidateAndUpdateWithReceiveQuantityOverrideRequest(); + request.setItemRef(itemBo); + request.setInventoryId(inventory); + request.setReceiveQty(qtyOnHand); + request.setQuantityOnHand(qtyOnHand); + request.setModifiedDateTime(inventoryModel.getModifiedDateTime()); + meInventoryService.validateAndUpdateWithReceiveQtyOverride(request); + } + } catch (Exception e) { + ExceptionUtil.throwException(e); + } + } + + //发料明细记录 + IssueItem issueItem = new IssueItem(); + issueItem.setHandle("IssueItemBO:" + site + "," + UUID.randomUUID().toString()); + issueItem.setSite(site); + issueItem.setCallItemNo(""); + issueItem.setShopOrder(""); + issueItem.setSfc(""); + issueItem.setItem(item); + issueItem.setInventory(inventory); + issueItem.setQty(new BigDecimal(qty)); + issueItem.setCreateUser(user); + issueItem.setCreatedDateTime(dateTime); + issueItem.setModifyUser(user); + issueItem.setModifiedDateTime(dateTime); + issueItemList.add(issueItem); + }//end for + }// end if + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + if (issueItemList != null && issueItemList.size() > 0) { + this.saveBatch(issueItemList); + } + } } \ No newline at end of file