feat: 设备投料修改

This commit is contained in:
chengzhaofeng 2024-11-25 19:52:55 +08:00
parent be763e51c9
commit 72ae27820a
9 changed files with 245 additions and 0 deletions

View File

@ -0,0 +1,14 @@
package com.foreverwin.mom.wms.api.feign;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.wms.entity.InventoryLog;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(contextId = "remoteWmsInventoryLogServive", value = "mom-wms-biz")
public interface RemoteWmsInventoryLogService {
@PostMapping("/wms-inventory-log/api/createInventoryLog")
R createInventoryLog(@RequestBody InventoryLog inventoryLog);
}

View File

@ -2,6 +2,7 @@ package com.foreverwin.mom.wms.api.feign;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.common.security.annotation.Inner;
import com.foreverwin.mom.wms.dto.InventoryDto;
import com.foreverwin.mom.wms.entity.Inventory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@ -23,4 +24,13 @@ public interface RemoteWmsInventoryService {
@GetMapping("/wms-inventory/api/iqcGetLot/{documentNo}/{lineNo}/{itemNo}")
R<List<Inventory>> iqcGetLot(@PathVariable("documentNo") String documentNo,@PathVariable("lineNo") String lineNo,@PathVariable("itemNo") String itemNo);
@PostMapping("/wms-inventory/api/inventoryDto")
R<Inventory> getInventoryDto(String handle);
@PostMapping("/wms-inventory/api/update")
R update(@RequestBody Inventory inventory);
@PostMapping("/wms-inventory/selectByMaterialLot")
R<InventoryDto> selectByMaterialLot(@RequestBody InventoryDto dto);
}

View File

@ -3,13 +3,36 @@ package com.foreverwin.mom.wms.dto;
import com.foreverwin.mom.wms.entity.Inventory;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@Data
public class InventoryDto extends Inventory {
private String item;
private String itemDesc;
private String description;
private String unitOfMeasure;
private String carrier;
private String printer;
private String itemType;
private String storageBinBo;
private String operation;
private String operationBo;
private String shopOrder;
private String resource;
private String materialLot;
private String fifo;
private String fifoMaterialLot;
private String checkDateExp;
private String wmsInventoryBo;
private List<Map<String,Object>> outItemType;
private String itemGroup;
private String checkItemMaterialLot;
private BigDecimal checkItemQtyOnHand;
private String warehouse;
private String wmsWarehouseBo;
private String storageBin;
private String storageLocation;
private String supplierBatch;
}

View File

@ -4,6 +4,8 @@ import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.foreverwin.iep.common.base.FrontPage;
import com.foreverwin.iep.wms.dto.InventoryDTO;
import com.foreverwin.iep.wms.dto.WmsInventoryDto;
import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
@ -15,6 +17,7 @@ import com.foreverwin.mom.wms.entity.Inventory;
import com.foreverwin.mom.wms.service.BarCodeQueryService;
import com.foreverwin.mom.wms.service.FreezeService;
import com.foreverwin.mom.wms.service.ZWmsInventoryService;
import io.seata.spring.annotation.GlobalTransactional;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
@ -423,5 +426,48 @@ public class ZWmsInventoryController {
inventoryService.inventoryStocktaking(site, userName, inventoryList);
return R.ok();
}
@ApiOperation(value = "远程接口", notes = "远程接口")
@PostMapping("/api/update")
@GlobalTransactional
public R update(@RequestBody Inventory inventory) {
inventoryService.apiUpdate(inventory);
return R.ok();
}
/**
* 查询
*
* @param inventoryId 库存ID
* @return
*/
@ApiOperation(value = "查询id", notes = "查询id")
@PostMapping("/api/inventoryDto")
@GlobalTransactional
public R selectById(@RequestBody String inventoryId) {
return R.ok(inventoryService.getById(inventoryId));
}
/**
* 设备投料条码号查询
*/
@ApiOperation(value = "设备投料条码号查询", notes = "设备投料条码号查询")
@SysLog("设备投料条码号查询")
@PostMapping("/selectByMaterialLot")
@GlobalTransactional
public R selectByMaterialLot(@RequestBody InventoryDto dto) {
return R.ok(inventoryService.selectByMaterialLot(dto));
}
/**
* 设备投料条码号查询(校验物料组)
*/
@ApiOperation(value = "设备投料条码号校验物料组", notes = "设备投料条码号校验物料组")
@SysLog("设备投料条码号校验物料组")
@PostMapping("/checkItemGroup")
@GlobalTransactional
public R checkItemGroup(@RequestBody InventoryDto dto) {
return R.ok(inventoryService.checkItemGroup(dto));
}
//------------------------------------------------------------------------------------
}

View File

@ -8,6 +8,7 @@ import com.foreverwin.mom.common.security.util.SecurityUtils;
import com.foreverwin.iep.common.base.FrontPage;
import com.foreverwin.mom.wms.entity.InventoryLog;
import com.foreverwin.mom.wms.service.ZWmsInventoryLogService;
import io.seata.spring.annotation.GlobalTransactional;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
@ -109,4 +110,15 @@ public class ZWmsInventoryLogController {
public R removeById(@PathVariable String handle) {
return R.ok(inventoryLogService.removeById(handle));
}
/**
* 新增日志(远程api)
*/
@ApiOperation(value = "新增日志(远程api)", notes = "新增日志(远程api)")
@SysLog("新增日志(远程api)" )
@PostMapping("/api/createInventoryLog")
@GlobalTransactional
public R createInventoryLog(@RequestBody InventoryLog inventoryLog) {
return R.ok(inventoryLogService.save(inventoryLog));
}
}

View File

@ -105,4 +105,10 @@ public interface ZWmsInventoryService extends IService<Inventory> {
List<ScanCodeDTO> selectInvByCode(String site, String user, String code);
List<ScanCodeDTO> selectTrayInvByCode(String site, String user, String code);
void apiUpdate(Inventory apiInventory);
InventoryDto selectByMaterialLot(InventoryDto dto);
InventoryDto checkItemGroup(InventoryDto dto);
}

View File

@ -61,6 +61,9 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
private final RemoteNextNumberService remoteNextNumberService;
private final ZWmsInventoryMapper inventoryMapper;
@Autowired
public void setWmsCarrierMemberService(@Lazy WmsCarrierMemberService wmsCarrierMemberService) {
this.wmsCarrierMemberService = wmsCarrierMemberService;
@ -595,4 +598,65 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
public List<ScanCodeDTO> selectTrayInvByCode(String site, String user, String code) {
return baseMapper.selectTrayInvByCode(Inventory.genHandle(site, code), Carrier.genHandle(site, code));
}
@Override
public void apiUpdate(Inventory apiInventory) {
Inventory inventory = super.getById(apiInventory.getHandle());
inventory.setQtyOnHand(apiInventory.getQtyOnHand());
inventory.setUpdater(apiInventory.getUpdater());
inventory.setUpdateTime(apiInventory.getUpdateTime());
super.updateById(inventory);
}
@Override
public InventoryDto selectByMaterialLot(InventoryDto dto) {
String site = TenantContextHolder.getTenantId();
dto.setSite(site);
Inventory inventory = super.getOne(Wrappers.lambdaQuery(Inventory.class)
.eq(Inventory::getInventoryId, dto.getMaterialLot())
.eq(Inventory::getSite, site));
if (inventory == null) {
throw BusinessException.build("库存"+dto.getMaterialLot()+"不存在");
}
//查询设备 仓库 比较查询出来的仓库是否跟当前库存的仓库是否一致
List<InventoryDto> resrceWareHouse = inventoryMapper.selectByResrceWareHouse(dto);
if (!resrceWareHouse.isEmpty()) {
if (!inventory.getErpStorageLocation().equals(resrceWareHouse.get(0).getWarehouse())) {
throw BusinessException.build("库存"+dto.getMaterialLot()+"仓库不一致");
}
}
//查询料件批号的物料是否在当前工单的BOM中
InventoryDto inventoryDto = inventoryMapper.selectByMaterialLot(dto);
if (inventoryDto == null) {
throw BusinessException.build("料件"+inventory.getItemBo().split(",")[1]+"不在当前工单的BOM中");
}
inventoryDto.setWmsWarehouseBo(resrceWareHouse.get(0).getWmsWarehouseBo());
inventoryDto.setSupplierBatch(inventory.getVendorBatchNo());
//校验料件库存先进先出
if ("Y".equals(dto.getFifo())) {
List<Inventory> list = super.list(Wrappers.lambdaQuery(Inventory.class)
.eq(Inventory::getSite,site)
.eq(Inventory::getStatus,"1001")
.gt(Inventory::getQtyOnHand, BigDecimal.ZERO)
.eq(Inventory::getErpStorageLocation, inventory.getErpStorageLocation())
.eq(Inventory::getItemBo, inventory.getItemBo())
.orderByAsc(Inventory::getProductionDate));
if (!list.isEmpty()) {
LocalDateTime productionDate = list.get(0).getProductionDate();
boolean before = productionDate.isBefore(inventoryDto.getProductionDate());
if (before) {
inventoryDto.setFifo("N");//N表示返回前端有弹窗提示 先进先出
inventoryDto.setFifoMaterialLot(list.get(0).getInventoryId());
}
}
}
return inventoryDto;
}
@Override
public InventoryDto checkItemGroup(InventoryDto dto) {
return null;
}
}

View File

@ -64,4 +64,10 @@ public interface ZWmsInventoryMapper extends BaseMapper<Inventory> {
List<ScanCodeDTO> selectTrayInvByCode(@Param("inventoryBo")String inventoryBo, @Param("carrierBo")String carrierBo);
InventoryDto selectByMaterialLot (@Param("dto")InventoryDto dto);
List<InventoryDto> selectByResrceWareHouse(@Param("dto")InventoryDto dto);
InventoryDto selectWorkCenter(@Param("dto")InventoryDto dto);
}

View File

@ -52,6 +52,32 @@
<result property="warranty" column="WARRANTY"/>
<result property="item" column="ITEM"/>
</resultMap>
<resultMap id="fullMap" extends="inventoryMap" type="com.foreverwin.mom.wms.dto.InventoryDto">
<result property="item" column="ITEM"/>
<result property="itemType" column="ITEM_TYPE"/>
<result property="itemDesc" column="ITEM_DESC"/>
<result property="itemGroup" column="ITEM_GROUP"/>
<result property="description" column="DESCRIPTION"/>
<result property="unitOfMeasure" column="UNIT_OF_MEASURE"/>
<result property="carrier" column="CARRIER"/>
<result property="printer" column="PRINTER"/>
<result property="materialLot" column="MATERIAL_LOT"/>
<result property="storageBinBo" column="STORAGE_BIN_BO"/>
<result property="operation" column="OPERATION"/>
<result property="operationBo" column="OPERATION_BO"/>
<result property="shopOrder" column="SHOP_ORDER"/>
<result property="resource" column="RESOURCE"/>
<result property="fifo" column="FIFO"/>
<result property="fifoMaterialLot" column="FIFO_MATERIAL_LOT"/>
<result property="checkDateExp" column="CHECK_DATE_EXP"/>
<result property="wmsInventoryBo" column="WMS_INVENTORY_BO"/>
<result property="checkItemMaterialLot" column="CHECK_ITEM_MATERIAL_LOT"/>
<result property="checkItemQtyOnHand" column="CHECK_ITEM_QTY_ON_HAND"/>
<result property="warehouse" column="WAREHOUSE"/>
<result property="wmsWarehouseBo" column="WAREHOUSE_BO"/>
<result property="storageBin" column="STORAGE_BIN"/>
<result property="storageLocation" column="STORAGE_LOCATION"/>
</resultMap>
<select id="getInventoryDtoPage" resultType="com.foreverwin.mom.wms.dto.InventoryDto">
select wi.handle, wi.`INVENTORY_ID`, wi.`QTY_ON_HAND`, i.`UNIT_OF_MEASURE` , i.`ITEM`, i.`DESCRIPTION`
@ -346,4 +372,42 @@
)
ORDER BY WCM.`CREATE_TIME` desc
</select>
<select id="selectByMaterialLot" resultMap="fullMap">
SELECT a.SHOP_ORDER ,op.OPERATION ,i.ITEM ,i.DESCRIPTION ITEM_DESC,wi.*,wi.HANDLE WMS_INVENTORY_BO,wi.INVENTORY_ID MATERIAL_LOT
from wip.SHOP_ORDER a
join wip.BOM b on a.PLANNED_BOM_BO = b.HANDLE
join wip.BOM_COMPONENT c on c.BOM_BO = b.HANDLE
join wip.OPERATION op on op.HANDLE = c.OPERATION_BO
join wip.item i on (c.COMPONENT_GBO = concat('ItemBO:', concat(i.SITE, concat(',', concat(i.ITEM,',#'))))
and i.CURRENT_REVISION = 'Y')
join wms.WMS_INVENTORY wi on wi.ITEM_BO = i.HANDLE
where wi.SITE = #{dto.site} and wi.INVENTORY_ID = #{dto.materialLot}
and a.SHOP_ORDER = #{dto.shopOrder} and op.OPERATION = #{dto.operation}
and wi.STATUS ='1001' and wi.QTY_ON_HAND > 0 and c.BOM_COMPONENT_TYPE ='N'
</select>
<select id="selectWorkCenter" resultMap="fullMap">
SELECT WI.*,ws.WAREHOUSE_BO
from wms.WMS_INVENTORY wi
join wms.WMS_STORAGE_BIN wn on wn.HANDLE = wi.WMS_STORAGE_BIN_BO
join wms.WMS_STORAGE_LOCATION ws on ws.HANDLE = wn.STORAGE_LOCATION_BO
join wip.WORK_CENTER wc on wc.HANDLE = ws.WORK_CENTER_BO
join wip.WORK_CENTER_MEMBER wr on wr.WORK_CENTER_BO = wc.HANDLE
join wip.RESRCE r on r.HANDLE = wr.WORK_CENTER_OR_RESOURCE_GBO
join wms.WMS_WAREHOUSE we on we.HANDLE = ws.WAREHOUSE_BO
where wi.SITE =#{dto.site} and wi.INVENTORY_ID = #{dto.materialLot}
and r.RESRCE = #{dto.resource}
and wi.STATUS ='1001' and wi.QTY_ON_HAND > 0;
</select>
<select id="selectByResrceWareHouse" resultMap="fullMap">
SELECT ws.WAREHOUSE_BO ,we.WAREHOUSE ,r.RESRCE,wr.WORK_CENTER
from wms.WMS_STORAGE_BIN wn
join wms.WMS_STORAGE_LOCATION ws on ws.HANDLE = wn.STORAGE_LOCATION_BO
join wms.WMS_WAREHOUSE we on we.HANDLE = ws.WAREHOUSE_BO
join wip.WORK_CENTER wr on wr.FAB_BASIS_BO = ws.FAB_NO_BO
join wip.WORK_CENTER_MEMBER wm on wm.WORK_CENTER_BO = wr.HANDLE
join wip.RESRCE r on r.HANDLE = wm.WORK_CENTER_OR_RESOURCE_GBO
where r.RESRCE =#{dto.resource} and r.SITE = #{dto.site}
</select>
</mapper>