bom: 修复 BOM 版本号计算异常

- 优化了 BOM 版本号计算逻辑,确保在查询不到数据时默认版本号为 1
- 使用 BigInteger 替代 Long 类型,避免数据类型转换异常
- 重构了代码结构,提高了可读性和维护性
This commit is contained in:
maolei 2025-06-05 10:46:01 +08:00
parent e61ba42d30
commit e7190ac324
2 changed files with 6 additions and 80 deletions

View File

@ -138,80 +138,6 @@ public class AfterSignRuleSyncInToMesProcess implements IRule<GeneralInVO> {
}
}
private void syncTransferIn(GeneralInVO generalInVO) throws BusinessException {
GeneralInHeadVO head = generalInVO.getHead();
// 表体body信息拼接
JSONArray details = new JSONArray();
// 填充details
for (GeneralInBodyVO body : generalInVO.getBodys()) {
JSONObject temp = new JSONObject();
temp.put("orderNo", head.getVbillcode()); // 通知单ID
temp.put("sequenceNum", body.getCrowno()); // 通知单序号
temp.put("type", "DBRK"); // 事务类型
MaterialVersionVO materialVersionVO = (MaterialVersionVO) IUIFSERVICE.queryByPrimaryKey(MaterialVersionVO.class, body.getCmaterialvid());
if (Objects.isNull(materialVersionVO)) {
throw new BusinessException("物料信息不存在, 主键:" + body.getCmaterialvid());
}
temp.put("materialId", materialVersionVO.getCode()); // 物料ID
temp.put("outQty", body.getNnum() != null ? body.getNnum().doubleValue() : null); // 应发数量
temp.put("actInQty", body.getNshouldnum() != null ? body.getNshouldnum().doubleValue() : null); // 实收数量
temp.put("assistActInQry", body.getNassistnum() != null ? body.getNassistnum().doubleValue() : 0); // 辅助实收数量
temp.put("productNum", null); // 产品编号
temp.put("inStorageId", body.getClocationid()); // 库位
temp.put("inBatchNum", body.getVbatchcode()); // 物料批号
temp.put("customId", null); // 客户ID
temp.put("supplierId", null); // 供应商ID
temp.put("manufactureDate", null); // 生产日期
temp.put("color", null); // 颜色
temp.put("packLen", null); // 包装长度
temp.put("packSize", null); // 包装尺寸
temp.put("remark", body.getVnotebody()); // 备注 ()
details.add(temp);
}
JSONObject info = new JSONObject();
info.put("details", details); // 明细
// 从head中取数
info.put("orderNo", head.getVbillcode()); // 通知单ID
info.put("type", "DBRK"); // 事务类型
info.put("outDate", head.getDbilldate() != null ? head.getDbilldate().toString() : null); // 出库日期
StordocVO outWarehouse = (StordocVO) IUIFSERVICE.queryByPrimaryKey(StordocVO.class, head.getCwarehouseid());
if (Objects.isNull(outWarehouse)) {
throw new BusinessException("拨出仓库信息不存在, 主键:" + head.getCwarehouseid());
}
if (outWarehouse.getCode() != null && outWarehouse.getCode().length() > 4) {
throw new BusinessException("MES系统拨出仓库编码[" + outWarehouse.getCode() + "]不能超过4位请选择合适的仓库!");
}
info.put("outStoreId", outWarehouse.getCode()); // 仓库ID
StordocVO inWarehouse = (StordocVO) IUIFSERVICE.queryByPrimaryKey(StordocVO.class, head.getCotherwhid());
if (Objects.isNull(inWarehouse)) {
throw new BusinessException("拨入仓库信息不存在, 主键:" + head.getCotherwhid());
}
if (inWarehouse.getCode() != null && inWarehouse.getCode().length() > 4) {
throw new BusinessException("MES系统拨入仓库编码[" + inWarehouse.getCode() + "]不能超过4位请选择合适的仓库!");
}
info.put("inStoreId", inWarehouse.getCode()); // 仓库ID
info.put("workerNo", null);
info.put("worker", null);
info.put("storeKeeper", head.getCwhsmanagerid());
info.put("returned", "N"); // 是否退库
info.put("mark", "N"); // 生成标志
info.put("remark", head.getVnote()); // 备注 ()
// 拼接数据,先创建一个jsonObject
JSONObject requestData = new JSONObject();
requestData.put("operation_type", "I"); // 操作
requestData.put("info", info);
obmlog.debug("调拨入库requestData:" + requestData.toJSONString());
HTTP_POST_OTHER_SYS.sendToExternalSystem("/GTHINKING/AjaxService/N_KCSJJS/101527013.ashx/gt_rec_api_dbrkdj", requestData);
obmlog.debug("调拨入库单 " + head.getVbillcode() + " 同步成功");
}
private String transferCodeByPk(String tableName, String selectField, String pkField, String pk) throws BusinessException {
if (StringUtils.isEmpty(pk)) {
return null;

View File

@ -116,10 +116,10 @@ public class AfterSignRuleSyncOutToMesProcess implements IRule<GeneralOutVO> {
if ("4I-01".equals(trantypecode)) {
syncOtherOut(generalOutVO);
}
// // 딧꺅놔욋/瘻욋데
// else if ("4I-02".equals(trantypecode)) {
// syncTransferOut(generalOutVO);
// }
// 딧꺅놔욋/瘻욋데
else if ("4I-02".equals(trantypecode)) {
syncTransferOut(generalOutVO);
}
}
@ -131,7 +131,7 @@ public class AfterSignRuleSyncOutToMesProcess implements IRule<GeneralOutVO> {
// 填充details
for (GeneralOutBodyVO body : generalOutVO.getBodys()) {// body中取数
JSONObject temp = new JSONObject();
temp.put("orderNo", head.getVbillcode()); // 繫列데ID
// temp.put("orderNo", head.getVbillcode()); // 繫列데ID
temp.put("sequenceNum", body.getCrowno()); // 通知单序号
temp.put("type", "DBCK"); // 事务类型
temp.put("genType", null);
@ -159,7 +159,7 @@ public class AfterSignRuleSyncOutToMesProcess implements IRule<GeneralOutVO> {
JSONObject info = new JSONObject();
info.put("details", details);
// 从head中取数
info.put("orderNo", head.getVbillcode()); // 繫列데ID
// info.put("orderNo", head.getVbillcode()); // 繫列데ID
info.put("type", "DBCK"); // 事务类型
info.put("genType", null);
info.put("outDate", head.getDbilldate().toString());