库房bug修复

This commit is contained in:
2026-06-02 14:22:50 +08:00
parent 03ed8f258f
commit c6e4c4bb06
8 changed files with 141 additions and 3 deletions

View File

@@ -183,6 +183,8 @@ public class SysOaWarehouseController extends BaseController {
});
sysOaWarehouseMaster.setWarehouseList(list);
sysOaWarehouseMaster.setMasterNum(UUID.randomUUID().toString());
// 导入入口跳过"必须关联采购需求"校验,后续可在采购需求处手动关联
sysOaWarehouseMaster.setSkipRequirementCheck(true);
iSysOaWarehouseMasterService.insertByBo(sysOaWarehouseMaster);
return R.ok(result.getAnalysis());
}

View File

@@ -83,6 +83,11 @@ public class SysOaWarehouseMasterBo extends BaseEntity {
private Long requirementId;
/**
* 导入场景跳过"必须关联采购需求"校验(仅 import 入口传 true
*/
private transient Boolean skipRequirementCheck;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;

View File

@@ -9,11 +9,14 @@ import com.ruoyi.system.mapper.SysUserMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@@ -64,6 +67,49 @@ public class ImCredentialsController extends BaseController {
return R.ok(data);
}
/**
* 给指定 OA 用户在 OpenIM 注册账号(如未注册)。
* 用于发消息前确保对方 imUserId 存在 —— 解决 OpenIM "RecordNotFoundError 1004"。
* <p>支持单个或批量,幂等。
*/
@PostMapping("/ensure")
public R<Map<String, Object>> ensureTargets(@RequestBody Map<String, Object> body) {
if (LoginHelper.getUserId() == null) return R.fail("未登录");
@SuppressWarnings("unchecked")
List<Object> raw = (List<Object>) body.get("userIds");
if (raw == null || raw.isEmpty()) return R.fail("userIds 不能为空");
int ok = 0, fail = 0;
Map<String, String> results = new HashMap<>();
for (Object o : raw) {
Long uid;
try {
uid = Long.parseLong(o.toString());
} catch (Exception e) {
fail++;
continue;
}
ImBind exist = bindMapper.selectById(uid);
if (exist != null && exist.getImUserId() != null && !exist.getImUserId().isEmpty()) {
ok++;
results.put(uid.toString(), exist.getImUserId());
continue;
}
ImBind bind = ensureBind(uid);
if (bind != null) {
ok++;
results.put(uid.toString(), bind.getImUserId());
} else {
fail++;
}
}
Map<String, Object> data = new HashMap<>();
data.put("ok", ok);
data.put("fail", fail);
data.put("bindings", results);
return R.ok(data);
}
/** 给指定 OA userId 在 OpenIM 主 API 直接注册一个账号并落 bind 表 */
private ImBind ensureBind(Long oaUserId) {
SysUser u = userMapper.selectById(oaUserId);

View File

@@ -171,9 +171,11 @@ public class SysOaWarehouseMasterServiceImpl implements ISysOaWarehouseMasterSer
add.setRemark("办公耗材自动写入");
}
// 规则 2入库type=1必须强关联采购需求requirement_id
// 规则 2入库type=1默认必须强关联采购需求requirement_id
// 导入入口会显式传 skipRequirementCheck=true单纯导入物料后续在采购需求处手动关联
if (add.getType() != null && add.getType() == 1
&& add.getRequirementId() == null) {
&& add.getRequirementId() == null
&& !Boolean.TRUE.equals(bo.getSkipRequirementCheck())) {
throw new RuntimeException("入库必须关联采购需求,请先选择需求");
}

View File

@@ -168,6 +168,8 @@ public class SysOaWarehouseTaskServiceImpl implements ISysOaWarehouseTaskService
sysOaWarehouseMaster.setStatus(0L);
sysOaWarehouseMaster.setMasterNum(UUID.randomUUID().toString());
sysOaWarehouseMaster.setSignUser(LoginHelper.getNickName());
// 操作时间必须落库,否则前端按 signTime 排序/筛选时看不到今天提报的单
sysOaWarehouseMaster.setSignTime(new java.util.Date());
Boolean flag = masterMapper.insert(sysOaWarehouseMaster) > 0;
Long masterId = sysOaWarehouseMaster.getMasterId();
for (SysOaWarehouseTaskBo sysOaWarehouseTaskBo : boList) {