feat(Oa盘点单创建):新增Oa盘点单创建

This commit is contained in:
chengzhaofeng 2024-12-14 10:25:49 +08:00
parent 78c990d6a4
commit 6d6a95b293
4 changed files with 84 additions and 3 deletions

View File

@ -0,0 +1,32 @@
package com.foreverwin.mom.wms.api.feign;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.wms.dto.InventoryDto;
import com.foreverwin.mom.wms.dto.IqcResultNoticeDto;
import com.foreverwin.mom.wms.entity.Inventory;
import com.foreverwin.mom.wms.entity.ZWmsInventoryCheck;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @program: mom-wms-biz
* @description: 盘点单表远程调用-OA
* @author: Snow
* @create: 2024-11-20 15:20:08
*/
@FeignClient(contextId = "remoteWmsInventoryCheckService", value = "mom-wms-biz")
public interface RemoteWmsInventoryCheckService {
/**
* 创建盘点单
* @param zWmsInventoryCheck
* @return
*/
@PostMapping("/z-wms-inventory-check/api/save")
R apiSave(@RequestBody ZWmsInventoryCheck zWmsInventoryCheck);
}

View File

@ -1,15 +1,19 @@
package com.foreverwin.mom.wms.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
/**
@ -18,10 +22,9 @@ import java.time.LocalDateTime;
* @author chengzhaofeng
* @date 2024-11-26 09:53:09
*/
@Data
@TableName("z_wms_inventory_check")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "盘点单表")
@Data
public class ZWmsInventoryCheck extends Model<ZWmsInventoryCheck> {
private static final long serialVersionUID = 1L;
@ -37,6 +40,7 @@ public class ZWmsInventoryCheck extends Model<ZWmsInventoryCheck> {
* 工厂
*/
@ApiModelProperty(value="工厂")
@JSONField(name = "SITE")
private String site;
/**
@ -61,18 +65,21 @@ public class ZWmsInventoryCheck extends Model<ZWmsInventoryCheck> {
* 仓库
*/
@ApiModelProperty(value="仓库")
@JSONField(name = "WAREHOUSE")
private String warehouse;
/**
* 货位
*/
@ApiModelProperty(value="货位")
@JSONField(name = "STORAGE_LOCATION")
private String storageLocation;
/**
* 物料
*/
@ApiModelProperty(value="物料")
@JSONField(name = "ITEM")
private String item;
/**
@ -126,3 +133,6 @@ public class ZWmsInventoryCheck extends Model<ZWmsInventoryCheck> {
private String differenceType;
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.foreverwin.iep.integration.constant.Msg;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.foreverwin.mom.common.log.annotation.SysLog;
@ -96,6 +97,24 @@ public class ZWmsInventoryCheckController {
return R.ok(zWmsInventoryCheckService.saveByCustom(zWmsInventoryCheck));
}
/**
* 新增盘点单表,远程接口
* @param zWmsInventoryCheck 盘点单表
* @return R
*/
@ApiOperation(value = "新增盘点单表,远程接口", notes = "新增盘点单表,远程接口")
@SysLog("新增盘点单表,远程接口" )
@PostMapping("/api/save")
public R apiSave(@RequestBody ZWmsInventoryCheck zWmsInventoryCheck) {
ZWmsInventoryCheck zWmsInventoryCheckResult;
try {
zWmsInventoryCheckResult = zWmsInventoryCheckService.saveByCustom(zWmsInventoryCheck);
} catch (Exception e) {
return R.failed( "盘点单创建失败:" + e.getMessage());
}
return R.ok(zWmsInventoryCheckResult.getCheckNo());
}
/**
* 修改盘点单表
* @param zWmsInventoryCheck 盘点单表

View File

@ -18,10 +18,12 @@ import com.foreverwin.mom.wms.entity.Inventory;
import com.foreverwin.mom.wms.entity.InventoryCheck;
import com.foreverwin.mom.wms.entity.StorageBin;
import com.foreverwin.mom.wms.entity.StorageLocation;
import com.foreverwin.mom.wms.entity.WareHouse;
import com.foreverwin.mom.wms.entity.ZWmsInventoryCheck;
import com.foreverwin.mom.wms.entity.ZWmsInventoryCheckCount;
import com.foreverwin.mom.wms.entity.ZWmsInventoryCheckSnapshot;
import com.foreverwin.mom.wms.mapper.ZWmsInventoryCheckMapper;
import com.foreverwin.mom.wms.service.WareHouseService;
import com.foreverwin.mom.wms.service.WmsItemService;
import com.foreverwin.mom.wms.service.WmsStorageLocationService;
import com.foreverwin.mom.wms.service.ZWmsInventoryCheckCountService;
@ -67,6 +69,10 @@ public class ZWmsInventoryCheckServiceImpl extends ServiceImpl<ZWmsInventoryChec
private final ZWmsInventoryCheckCountService zWmsInventoryCheckCountService;
private final ZWmsInventoryService zWmsInventoryService;
private final WareHouseService wareHouseService;
@Override
public ZWmsInventoryCheck saveByCustom(ZWmsInventoryCheck zWmsInventoryCheck) {
String site = TenantContextHolder.getTenantId();
@ -74,6 +80,12 @@ public class ZWmsInventoryCheckServiceImpl extends ServiceImpl<ZWmsInventoryChec
String storageLocation = zWmsInventoryCheck.getStorageLocation();
String item = zWmsInventoryCheck.getItem();
String warehouse = zWmsInventoryCheck.getWarehouse();
if (StrUtil.isBlank(warehouse) && StrUtil.isBlank(storageLocation) && StrUtil.isBlank(item)) {
throw BusinessException.build("仓库、区域、物料三个条件中必须选择一个条件!");
}
zWmsInventoryCheck.setSite(site);
if(StrUtil.isNotBlank(item)){
Item item1 = itemService.selectCurrentByMes(site, item);
@ -89,6 +101,14 @@ public class ZWmsInventoryCheckServiceImpl extends ServiceImpl<ZWmsInventoryChec
throw BusinessException.build("区域(存储位置)编号[" + storageLocation + "]不存在!");
}
}
if(StrUtil.isNotBlank(warehouse)){
WareHouse wareHouse = wareHouseService.getOne(Wrappers.<WareHouse>lambdaQuery()
.eq(WareHouse::getWarehouse,warehouse)
.eq(WareHouse::getSite,site));
if (wareHouse == null) {
throw BusinessException.build("仓库[" + storageLocation + "]不存在!");
}
}
LocalDateTime time = LocalDateTime.now();
zWmsInventoryCheck.setCreator(user);
zWmsInventoryCheck.setDateCreate(time);
@ -109,7 +129,6 @@ public class ZWmsInventoryCheckServiceImpl extends ServiceImpl<ZWmsInventoryChec
zWmsInventoryCheck.setCheckNo(checkNo);
String handle = InventoryCheck.genHandle(site, checkNo);
zWmsInventoryCheck.setHandle(handle);
super.save(zWmsInventoryCheck);
// 创建盘点快照,根据盘点单创建条件,查询出满足条件的条码
List<ZWmsInventoryCheckSnapshot> zWmsInventoryCheckSnapshotList = zWmsInventoryCheckMapper.selectSnapshotInfo(zWmsInventoryCheck);
@ -121,6 +140,7 @@ public class ZWmsInventoryCheckServiceImpl extends ServiceImpl<ZWmsInventoryChec
}).collect(Collectors.toList());
zWmsInventoryCheckSnapshotService.saveBatch(zWmsInventoryCheckSnapshotList);
super.save(zWmsInventoryCheck);
return zWmsInventoryCheck;
}