推送srm优化

This commit is contained in:
lihao 2026-01-15 17:54:10 +08:00
parent 361f4c29c2
commit 6e5f6cae07
1 changed files with 51 additions and 4 deletions

View File

@ -87,21 +87,68 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
String ctpusql = "select pk_ct_pu_b from ct_pu_b where csrcbid ='" + map2.get("pk_praybill_b") + "' and dr = 0";
List<Map<String, Object>> ctpus = (List<Map<String, Object>>) dao.executeQuery(ctpusql, new MapListProcessor());
if(ctpus.isEmpty()){
// ¸üÐÂÇ빺µ¥
String sql = "update po_praybill_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_praybill_b='"
+ map2.get("pk_praybill_b") + "'";
int num = dao.executeUpdate(sql);
// ========== 20260108 新增逻辑路径2无采购合同请购单直接关联采购订单 ==========
// 直接查询请购单关联的采购订单跳过采购合同
String directOrderSql = "select pk_order_b from po_order_b where csourcebid ='" + map2.get("pk_praybill_b") + "' and dr = 0";
List<Map<String, Object>> directOrders = (List<Map<String, Object>>) dao.executeQuery(directOrderSql, new MapListProcessor());
// 遍历直接关联的采购订单
if(directOrders.isEmpty()){
// 更新请购单
String sql = "update po_praybill_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_praybill_b='"
+ map2.get("pk_praybill_b") + "'";
int num = dao.executeUpdate(sql);
SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil();
JSONObject reqData = new JSONObject();
reqData.put("org", "C030");// 组织编码
reqData.put("erpId", map2.get("pk_praybill_b"));// 请购单表体主键
reqData.put("mainNum", map.get("nplanoutnum"));// 主数量
billUtil.reqBIPBill(reqData);
}
for (Map<String, Object> directOrder : directOrders) {
// 查询到货单
String directArriveSql = "select pk_arriveorder_b from po_arriveorder_b where csourcebid ='" + directOrder.get("pk_order_b") + "' and dr = 0";
List<Map<String, Object>> directArriveOrders = (List<Map<String, Object>>) dao.executeQuery(directArriveSql, new MapListProcessor());
int directInnum = directArriveOrders.size();
// 同样的判断条件C030组织且无到货单时更新
if ("C030".equals(orgCode) && directInnum == 0) {
// 更新请购单
String qgsql = "update po_praybill_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_praybill_b='"
+ map2.get("pk_praybill_b") + "'";
dao.executeUpdate(qgsql);
// 更新采购订单
String updateDirectOrderSql = "update po_order_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_order_b='"
+ directOrder.get("pk_order_b") + "'";
dao.executeUpdate(updateDirectOrderSql);
// 同步SRM请购单和原有逻辑一致
SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil();
JSONObject reqData = new JSONObject();
reqData.put("org", "C030");
reqData.put("erpId", map2.get("pk_praybill_b"));
reqData.put("mainNum", map.get("nplanoutnum"));
billUtil.reqBIPBill(reqData);
}
}
}
for (Map<String, Object> ctpu : ctpus) {
// 脤戙粒劃隆等
String ordersql = "select pk_order_b from po_order_b where csourcebid ='" + ctpu.get("pk_ct_pu_b") + "' and dr = 0";
List<Map<String, Object>> orders = (List<Map<String, Object>>) dao.executeQuery(ordersql, new MapListProcessor());
if(orders.isEmpty()){
// 更新请购单
String qgsql = "update po_praybill_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_praybill_b='"
+ map2.get("pk_praybill_b") + "'";
dao.executeUpdate(qgsql);
// 載陔粒劃磁肮
String sql = "update ct_pu_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_ct_pu_b='"
+ ctpu.get("pk_ct_pu_b") + "'";
int num = dao.executeUpdate(sql);
SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil();
JSONObject reqData = new JSONObject();
reqData.put("org", "C030");// 组织编码
reqData.put("erpId", map2.get("pk_praybill_b"));// 请购单表体主键
reqData.put("mainNum", map.get("nplanoutnum"));// 主数量
billUtil.reqBIPBill(reqData);
}
for (Map<String, Object> order : orders) {
// 脤戙善億等