电力电子负计划
This commit is contained in:
parent
0b8c296521
commit
dd1fb2158b
|
|
@ -46,7 +46,7 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
||||||
}
|
}
|
||||||
String pkOrg = pmoAggVO.getParentVO().getPk_org();
|
String pkOrg = pmoAggVO.getParentVO().getPk_org();
|
||||||
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||||
if (checkIfOrg(orgCode, configParams)) {
|
if (!checkIfOrg(orgCode, configParams,"planOrg")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,16 +65,137 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
||||||
if (null == map.get("cbmaterialvid")) {
|
if (null == map.get("cbmaterialvid")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String material = map.get("cbmaterialvid").toString();
|
|
||||||
if (!checkProdect(material, pkOrg)) {
|
if(checkIfOrg(orgCode, configParams,"xbOrg")){
|
||||||
continue;
|
String material = map.get("cbmaterialvid").toString();
|
||||||
}
|
if (!checkProdect(material, pkOrg)) {
|
||||||
// 꿴璂셕뺍땐데
|
continue;
|
||||||
String plosql = "select cpoid from mm_plo where vsrcbid ='" + map.get("cpickm_bid") + "' and dr = 0";
|
}
|
||||||
List<Map<String, Object>> ploList = (List<Map<String, Object>>) dao.executeQuery(plosql, new MapListProcessor());
|
// 查询计划订单
|
||||||
for (Map<String, Object> plo : ploList) {
|
String plosql = "select cpoid from mm_plo where vsrcbid ='" + map.get("cpickm_bid") + "' and dr = 0";
|
||||||
|
List<Map<String, Object>> ploList = (List<Map<String, Object>>) dao.executeQuery(plosql, new MapListProcessor());
|
||||||
|
for (Map<String, Object> plo : ploList) {
|
||||||
|
// 查询请购单
|
||||||
|
String buyingreqsql = "select pk_praybill,pk_praybill_b,nnum from po_praybill_b where csourcebid ='" + plo.get("cpoid") + "' and dr = 0";
|
||||||
|
List<Map<String, Object>> buyingreq = (List<Map<String, Object>>) dao.executeQuery(buyingreqsql, new MapListProcessor());
|
||||||
|
for (Map<String, Object> map2 : buyingreq) {
|
||||||
|
|
||||||
|
if (UFDouble.ZERO_DBL.compareTo(new UFDouble(map.get("nplanoutnum").toString())) == 0) {
|
||||||
|
pmobids.add(map2.get("pk_praybill_b").toString());
|
||||||
|
pmoids.add(map2.get("pk_praybill").toString());
|
||||||
|
}
|
||||||
|
if (new UFDouble((BigDecimal) map2.get("nnum")).compareTo(new UFDouble((BigDecimal) map.get("nplanoutnum"))) > 0) {
|
||||||
|
// 查询采购合同
|
||||||
|
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()){
|
||||||
|
|
||||||
|
// ========== 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) {
|
||||||
|
// 查询到货单
|
||||||
|
String arriveordersql = "select pk_arriveorder_b from po_arriveorder_b where csourcebid ='" + order.get("pk_order_b") + "' and dr = 0";
|
||||||
|
List<Map<String, Object>> arriveorders = (List<Map<String, Object>>) dao.executeQuery(arriveordersql, new MapListProcessor());
|
||||||
|
// 20251216 备料重算优化 如果有到货单则不更新最终需求数量
|
||||||
|
int innum=arriveorders.size();
|
||||||
|
if ("C030".equals(orgCode) && innum ==0) {
|
||||||
|
// 更新采购合同
|
||||||
|
String sql1 = "update ct_pu_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_ct_pu_b='"
|
||||||
|
+ctpu.get("pk_ct_pu_b")+ "'";
|
||||||
|
int num1 = dao.executeUpdate(sql1);
|
||||||
|
// 更新请购单
|
||||||
|
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);
|
||||||
|
// 更新采购订单
|
||||||
|
String updateOrderSql = "update po_order_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_order_b='"
|
||||||
|
+ order.get("pk_order_b") + "'";
|
||||||
|
dao.executeUpdate(updateOrderSql);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (checkIfOrg(orgCode, configParams,"dldzOrg")) {
|
||||||
|
if (null == map.get("cbmaterialvid")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String material = map.get("cbmaterialvid").toString();
|
||||||
|
if (checkProdectCommon(material, pkOrg)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据 生产订单-备料计划-请购单-采购订单-到货单-采购入库 依次更新下游单据
|
||||||
|
// 生产订单-备料计划-请购单-采购合同-采购订单-到货单
|
||||||
// 查询请购单
|
// 查询请购单
|
||||||
String buyingreqsql = "select pk_praybill,pk_praybill_b,nnum from po_praybill_b where csourcebid ='" + plo.get("cpoid") + "' and dr = 0";
|
String buyingreqsql = "select pk_praybill,pk_praybill_b,nnum from po_praybill_b where csourcebid ='" + map.get("cpickm_bid") + "' and dr = 0";
|
||||||
List<Map<String, Object>> buyingreq = (List<Map<String, Object>>) dao.executeQuery(buyingreqsql, new MapListProcessor());
|
List<Map<String, Object>> buyingreq = (List<Map<String, Object>>) dao.executeQuery(buyingreqsql, new MapListProcessor());
|
||||||
for (Map<String, Object> map2 : buyingreq) {
|
for (Map<String, Object> map2 : buyingreq) {
|
||||||
|
|
||||||
|
|
@ -100,7 +221,7 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
||||||
int num = dao.executeUpdate(sql);
|
int num = dao.executeUpdate(sql);
|
||||||
SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil();
|
SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil();
|
||||||
JSONObject reqData = new JSONObject();
|
JSONObject reqData = new JSONObject();
|
||||||
reqData.put("org", "C030");// 莉廉긍쯤
|
reqData.put("org", "C013");// 组织编码
|
||||||
reqData.put("erpId", map2.get("pk_praybill_b"));// 请购单表体主键
|
reqData.put("erpId", map2.get("pk_praybill_b"));// 请购单表体主键
|
||||||
reqData.put("mainNum", map.get("nplanoutnum"));// 主数量
|
reqData.put("mainNum", map.get("nplanoutnum"));// 主数量
|
||||||
billUtil.reqBIPBill(reqData);
|
billUtil.reqBIPBill(reqData);
|
||||||
|
|
@ -123,7 +244,7 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
||||||
// 同步SRM请购单(和原有逻辑一致)
|
// 同步SRM请购单(和原有逻辑一致)
|
||||||
SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil();
|
SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil();
|
||||||
JSONObject reqData = new JSONObject();
|
JSONObject reqData = new JSONObject();
|
||||||
reqData.put("org", "C030");
|
reqData.put("org", orgCode);
|
||||||
reqData.put("erpId", map2.get("pk_praybill_b"));
|
reqData.put("erpId", map2.get("pk_praybill_b"));
|
||||||
reqData.put("mainNum", map.get("nplanoutnum"));
|
reqData.put("mainNum", map.get("nplanoutnum"));
|
||||||
billUtil.reqBIPBill(reqData);
|
billUtil.reqBIPBill(reqData);
|
||||||
|
|
@ -145,7 +266,7 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
||||||
int num = dao.executeUpdate(sql);
|
int num = dao.executeUpdate(sql);
|
||||||
SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil();
|
SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil();
|
||||||
JSONObject reqData = new JSONObject();
|
JSONObject reqData = new JSONObject();
|
||||||
reqData.put("org", "C030");// 莉廉긍쯤
|
reqData.put("org", orgCode);// 组织编码
|
||||||
reqData.put("erpId", map2.get("pk_praybill_b"));// 请购单表体主键
|
reqData.put("erpId", map2.get("pk_praybill_b"));// 请购单表体主键
|
||||||
reqData.put("mainNum", map.get("nplanoutnum"));// 主数量
|
reqData.put("mainNum", map.get("nplanoutnum"));// 主数量
|
||||||
billUtil.reqBIPBill(reqData);
|
billUtil.reqBIPBill(reqData);
|
||||||
|
|
@ -171,7 +292,7 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
||||||
dao.executeUpdate(updateOrderSql);
|
dao.executeUpdate(updateOrderSql);
|
||||||
SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil();
|
SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil();
|
||||||
JSONObject reqData = new JSONObject();
|
JSONObject reqData = new JSONObject();
|
||||||
reqData.put("org", "C030");// 莉廉긍쯤
|
reqData.put("org", orgCode);// 组织编码
|
||||||
reqData.put("erpId", map2.get("pk_praybill_b"));// 请购单表体主键
|
reqData.put("erpId", map2.get("pk_praybill_b"));// 请购单表体主键
|
||||||
reqData.put("mainNum", map.get("nplanoutnum"));// 主数量
|
reqData.put("mainNum", map.get("nplanoutnum"));// 主数量
|
||||||
billUtil.reqBIPBill(reqData);
|
billUtil.reqBIPBill(reqData);
|
||||||
|
|
@ -181,6 +302,7 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pmobids.size() > 0) {
|
if (pmobids.size() > 0) {
|
||||||
buyingreqRowClose(pmobids, pmoids);
|
buyingreqRowClose(pmobids, pmoids);
|
||||||
}
|
}
|
||||||
|
|
@ -251,17 +373,38 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
private boolean checkIfOrg(String code, Map<String, String> configParams, String planOrg) throws BusinessException {
|
||||||
String targetCode = configParams.get("xbOrg");
|
String targetCode = configParams.get(planOrg);
|
||||||
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
|
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
|
||||||
throw new BusinessException("未配置组织参数");
|
throw new BusinessException("未配置组织参数");
|
||||||
}
|
}
|
||||||
String[] orgItem = targetCode.split(",");
|
String[] orgItem = targetCode.split(",");
|
||||||
for (String orgCode : orgItem) {
|
for (String orgCode : orgItem) {
|
||||||
if (!orgCode.isEmpty() && orgCode.equals(code)) {
|
if (!orgCode.isEmpty() && orgCode.equals(code)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据物料查询物料库存信息页签-是否转通用进行判断
|
||||||
|
* 电力电子C013只处理未勾选是否转通用物料(专项物料)
|
||||||
|
* @param cmaterialvid
|
||||||
|
* @param pk_org
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Boolean checkProdectCommon(String cmaterialvid, String pk_org) {
|
||||||
|
String whereSql = " pk_material='" + cmaterialvid + "' and pk_org='" + pk_org + "' and nvl(dr,0)=0 ";
|
||||||
|
List<MaterialStockVO> list = null;
|
||||||
|
try {
|
||||||
|
list = (List<MaterialStockVO>) new BaseDAO().retrieveByClause(MaterialStockVO.class, whereSql);
|
||||||
|
} catch (DAOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (list != null && list.size() > 0) {
|
||||||
|
return list.get(0).getDef18() == null ? false : list.get(0).getDef18().equals(true);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue