diff --git a/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java b/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java index ab2fbfa4..1b3e4f95 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java @@ -32,6 +32,11 @@ public interface Constants { String SITE_ADMIN = "SITE_ADMIN"; + //上料 + String ACTION_CODE_LOAD="1"; + //卸料 + String ACTION_CODE_UNLOAD="2"; + //--------------------检验项目|任务----------------------------------------------------------------------------------- // 新建 String INSPECTION_TASK_STATUS_NEW="NEW"; diff --git a/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java b/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java index 6ce621e9..6a5d8eed 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java @@ -126,6 +126,9 @@ public enum HandleEnum { /**检验任务明细**/ INSPECTION_TASK_DETAIL("InspectionTaskDetailBO:","InspectionTaskDetailBO:{0},{1}"), + /**上料**/ + LOAD_INVENTORY("LoadInventoryBO:","LoadInventoryBO:{0},{1}"), + /**用户**/ USR("UserBo","UserBo:{0},{1}"); diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/CommonService.java b/common/src/main/java/com/foreverwin/mesnac/common/service/CommonService.java index bb64da5a..785bd6c3 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/CommonService.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/CommonService.java @@ -2,6 +2,8 @@ package com.foreverwin.mesnac.common.service; import com.foreverwin.mesnac.meapi.model.Operation; +import java.math.BigDecimal; + public interface CommonService { /** * 根据资源或工作中心查找车间 @@ -16,4 +18,6 @@ public interface CommonService { * @return */ Operation getOperationBySfcBo(String sfcBo); + + void updateInventory(String site, String inventoryId, BigDecimal measuredQty); } diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/CommonServiceImpl.java b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/CommonServiceImpl.java index 075eee47..1b73e4da 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/CommonServiceImpl.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/CommonServiceImpl.java @@ -3,6 +3,7 @@ package com.foreverwin.mesnac.common.service.impl; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.foreverwin.mesnac.common.service.CommonService; +import com.foreverwin.mesnac.common.util.ExceptionUtil; import com.foreverwin.mesnac.common.util.StringUtil; import com.foreverwin.mesnac.meapi.mapper.OperationMapper; import com.foreverwin.mesnac.meapi.model.Operation; @@ -11,11 +12,17 @@ import com.foreverwin.mesnac.meapi.model.WorkCenterMember; import com.foreverwin.mesnac.meapi.service.WorkCenterMemberService; import com.foreverwin.mesnac.meapi.service.WorkCenterService; import com.foreverwin.modular.core.exception.BusinessException; +import com.foreverwin.modular.core.meext.MEServices; +import com.sap.me.inventory.InventoryIdentifier; +import com.sap.me.inventory.InventoryServiceInterface; +import com.sap.me.inventory.InventoryStatusEnum; +import com.sap.me.inventory.InventoryValidateAndUpdateRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.util.List; @Service @Transactional(rollbackFor = Exception.class) @@ -59,4 +66,34 @@ public class CommonServiceImpl implements CommonService { Operation operation = operationMapper.selectOperationBySfcBo(sfcBo, LocaleContextHolder.getLocale().getLanguage()); return operation; } + @Override + public void updateInventory(String site, String inventoryId, BigDecimal measuredQty) { + try { + InventoryServiceInterface inventoryService = MEServices.create("com.sap.me.inventory", "InventoryService", site); + com.sap.me.inventory.Inventory inventory = inventoryService.findInventory(new InventoryIdentifier(inventoryId)); + if (inventory != null) { + InventoryValidateAndUpdateRequest updateRequest = new InventoryValidateAndUpdateRequest(); + updateRequest.setInventoryId(inventory.getInventoryId()); + updateRequest.setItemRef(inventory.getItemRef()); + updateRequest.setQuantityOnHand(measuredQty); + updateRequest.setStatus(InventoryStatusEnum.AVAILABLE); + updateRequest.setAssyDataTypeRef(inventory.getAssyDataTypeRef()); + updateRequest.setOperationLocationRef(inventory.getOperationLocRef()); + updateRequest.setOperationLocationReserve(inventory.isOperationLocRes()); + updateRequest.setShopOrderLocationRef(inventory.getShopOrderLocRef()); + updateRequest.setShopOrderLocationReserve(inventory.isShopOrderLocRes()); + updateRequest.setWorkCenterLocationRef(inventory.getWorkCenterLocRef()); + updateRequest.setWorkCenterLocationReserve(inventory.isWorkCenterLocRes()); + updateRequest.setResourceLocationRef(inventory.getResourceLocRef()); + updateRequest.setResourceLocationReserve(inventory.isResourceLocRes()); + updateRequest.setStorageLocationRef(inventory.getStorageLocationRef()); + updateRequest.setAssemblyDataList(inventory.getAssemblyDataList()); + updateRequest.setModifiedDateTime(inventory.getModifiedDateTime()); + inventoryService.validateAndUpdate(updateRequest); + } + } catch (Exception e) { + e.printStackTrace(); + ExceptionUtil.throwException(e); + } + } } diff --git a/meapi/src/main/resources/mapper/SfcMapper.xml b/meapi/src/main/resources/mapper/SfcMapper.xml index 8c683e9e..5abc2826 100644 --- a/meapi/src/main/resources/mapper/SfcMapper.xml +++ b/meapi/src/main/resources/mapper/SfcMapper.xml @@ -666,7 +666,7 @@ - + diff --git a/production/src/main/resources/mapper/SfcCrossMapper.xml b/production/src/main/resources/mapper/SfcCrossMapper.xml index 496f31d7..44d4c30d 100644 --- a/production/src/main/resources/mapper/SfcCrossMapper.xml +++ b/production/src/main/resources/mapper/SfcCrossMapper.xml @@ -135,7 +135,7 @@ WHERE sfc.site = #{site} and WHEN SSTEP.QTY_IN_QUEUE > 0 THEN '排队中' ELSE '新建' END STEP_STATUS FROM SFC S - LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.HANDLE AND IT.LOCALE='zh' + LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.ITEM_BO AND IT.LOCALE='zh' INNER JOIN SFC_ROUTING SRI ON S.HANDLE=SRI.SFC_BO INNER JOIN SFC_ROUTER SR ON SRI.HANDLE=SR.SFC_ROUTING_BO AND SR.IN_USE='true' INNER JOIN ROUTER_STEP RS ON RS.ROUTER_BO=sr.ROUTER_BO @@ -154,7 +154,7 @@ WHERE sfc.site = #{site} and SELECT ZSD.sfc,ZSD.operation,IT.DESCRIPTION item_Description,ST.STATUS,s.qty,ZSD.DISPATCH_NO,ZSD.STEP_ID FROM Z_SFC_DISPATCH ZSD JOIN SFC S ON ZSD.SFC=s.SFC AND ZSD.SITE=s.SITE - LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.HANDLE AND IT.LOCALE=#{locale} + LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.ITEM_BO AND IT.LOCALE=#{locale} INNER JOIN STATUS ST ON ST.HANDLE = S.STATUS_BO WHERE zsd.SITE=#{site} AND zsd.DISPATCH_STATUS='START' AND ZSD.RESRCE=#{resrce}