Compare commits
2 Commits
9cd6448cae
...
e3ce6d8831
| Author | SHA1 | Date |
|---|---|---|
|
|
e3ce6d8831 | |
|
|
511f919d7c |
|
|
@ -22,7 +22,6 @@ import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
|
|||
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
||||
import nc.vo.org.OrgVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.lang.UFBoolean;
|
||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||
import nc.vo.scmpub.util.ArrayUtil;
|
||||
|
||||
|
|
@ -39,7 +38,7 @@ import java.util.stream.Stream;
|
|||
* @date 2025/9/1
|
||||
*/
|
||||
public class AfterApproveSyncHighpressureMesRule implements IRule<PMOAggVO> {
|
||||
|
||||
private static final BaseDAO baseDAO = new BaseDAO();
|
||||
private static final String LOG_INFO_NAME = "gymeslog";
|
||||
private static final Log logger = Log.getInstance(LOG_INFO_NAME);
|
||||
private Map<String, String> configParams;
|
||||
|
|
@ -62,8 +61,6 @@ public class AfterApproveSyncHighpressureMesRule implements IRule<PMOAggVO> {
|
|||
* 构建同步数据
|
||||
*/
|
||||
private void buildSyncData(PMOAggVO[] useVOs) throws BusinessException {
|
||||
BaseDAO baseDAO = new BaseDAO();
|
||||
|
||||
HYPubBO hybo = new HYPubBO();
|
||||
JSONObject list = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
|
|
@ -99,90 +96,22 @@ public class AfterApproveSyncHighpressureMesRule implements IRule<PMOAggVO> {
|
|||
}
|
||||
|
||||
// 自定义项30是Y时调用修改口,若不是则调用新增口
|
||||
String saleDef = (String) item.getAttributeValue("vdef30") == null ? "" : (String) item.getAttributeValue("vdef30");
|
||||
String saleDef = item.getAttributeValue("vdef30") == null ? "" : (String) item.getAttributeValue("vdef30");
|
||||
String cmoid = item.getCmoid();
|
||||
if (!saleDef.equals("Y")) {
|
||||
// 更新自定义项30为“Y”
|
||||
String updatesql = "update mm_mo set vdef30 = '" + "Y" + "' where cmoid = '" + item.getCmoid() + "'";
|
||||
String updatesql = "update mm_mo set vdef30 = 'Y' where cmoid = '" + cmoid + "'";
|
||||
baseDAO.executeUpdate(updatesql);
|
||||
|
||||
JSONObject itemObj = new JSONObject();
|
||||
// 填充子项基础信息
|
||||
|
||||
// String sql = " select pk_defdoclist from bd_defdoclist where code='zdy-001' and dr=0 ";
|
||||
// String o = (String) baseDAO.executeQuery(sql, new ColumnProcessor());
|
||||
|
||||
Object contractNum = hybo.findColValue("bd_defdoc", "code", " (pk_defdoc='" +item.getVdef2() + "') ");
|
||||
|
||||
itemObj.put("contractNum",contractNum ); // 销售订单号
|
||||
|
||||
Object cwarehouseid = hybo.findColValue("bd_stordoc", "code", " (pk_stordoc = '" + item.getAttributeValue("vdef31") + "') ");
|
||||
|
||||
itemObj.put("cwarehouseid", cwarehouseid); // 仓库编码
|
||||
Object pk_project = hybo.findColValue("bd_project", "project_name", " pk_project = '" + item.getCprojectid() + "' ");
|
||||
|
||||
itemObj.put("entryName", pk_project); // 项目名称
|
||||
itemObj.put("bipChildId", item.getCmoid()); // 子项主键ID
|
||||
|
||||
// 部门信息
|
||||
String deptsql = " select code,name from org_dept where pk_dept='" + item.getCdeptid() + "' and dr=0 ";
|
||||
Map<String, Object> tr = (Map<String, Object>) baseDAO.executeQuery(deptsql, new MapProcessor());
|
||||
itemObj.put("bipDeptName", tr.get("name")); // 生产部门名称
|
||||
itemObj.put("bipDeptId", tr.get("code")); // 生产部门编码
|
||||
|
||||
// 日期信息
|
||||
itemObj.put("requiredDate", item.getTrequiredate().toString()); // 需用日期
|
||||
|
||||
// if("55A2".equals(item.getVsrctype())){
|
||||
itemObj.put("bipParentProcessProductionOrderId", item.getVparentbillcode());
|
||||
itemObj.put("bipParentProcessProductionOrderRowNum", item.getVparentmorowno());
|
||||
// }
|
||||
// if("55A2".equals(item.getVfirsttype())){
|
||||
itemObj.put("bipOriginProcessProductionOrderId", item.getVfirstcode());
|
||||
itemObj.put("bipOriginProcessProductionOrderRowNum", item.getVfirstrowno());
|
||||
// }
|
||||
|
||||
|
||||
// 物料信息
|
||||
String mrlsql = "select code,name,graphid,pk_measdoc,materialtype from bd_material where pk_material = '" + cmaterialvid + "' ";
|
||||
Map<String, Object> mrl = (Map<String, Object>) baseDAO.executeQuery(mrlsql, new MapProcessor());
|
||||
itemObj.put("materialCode", mrl.get("code")); // 物料编码
|
||||
itemObj.put("materialName", mrl.get("name")); // 物料名称
|
||||
|
||||
itemObj.put("drawingNumber", drawingNumber); // 图号
|
||||
|
||||
Object unit = hybo.findColValue("bd_measdoc", "code", " pk_measdoc = '" + mrl.get("pk_measdoc") + "' ");
|
||||
itemObj.put("unit", unit); // 单位 pk_measdoc
|
||||
|
||||
// 生产信息
|
||||
itemObj.put("intervalModel", mrl.get("materialtype")); // 产品类型
|
||||
// itemObj.put("processCode", item.getProcedures()); // 工序编码
|
||||
itemObj.put("lineNumber", String.valueOf(item.getVrowno())); // 行号
|
||||
|
||||
// 库存信息
|
||||
itemObj.put("demandInventoryOrganization", item.getCrequireorg()); // 需求库存组织
|
||||
itemObj.put("plannedInputQuantity", (int) item.getNplanputastnum().doubleValue()); // 计划投入量
|
||||
itemObj.put("plannedOutputQuantity", (int) item.getNmmastnum().doubleValue()); // 计划产出量
|
||||
itemObj.put("plannedStartTime", item.getTplanstarttime().toString()); // 计划开工时间
|
||||
itemObj.put("plannedCompletionTime", item.getTplanendtime().toString()); // 计划完工时间
|
||||
itemObj.put("customerMaterialCode", item.getCcustmaterialid()); // 客户物料编码
|
||||
itemObj.put("productionBatch", item.getCbatchid()); // 生产批次(按BIP格式)
|
||||
itemObj.put("productionBatchNumber", item.getVbatchcode()); // 生产批次号(按BIP格式)
|
||||
itemObj.put("orderQuantity", item.getNastnum().doubleValue());
|
||||
contentArray.add(itemObj); // 将子项添加到数组
|
||||
|
||||
flags = "addOrder";
|
||||
} else {
|
||||
flags = "updateOrder";
|
||||
}
|
||||
JSONObject itemObj = new JSONObject();
|
||||
|
||||
// 填充子项基础信息
|
||||
//
|
||||
// String sql = " select pk_defdoclist from bd_defdoclist where code='zdy-001' and dr=0 ";
|
||||
// String o = (String) baseDAO.executeQuery(sql, new ColumnProcessor());
|
||||
|
||||
Object contractNum = hybo.findColValue("bd_defdoc", "code", " (pk_defdoc='" + item.getVdef2() + "') ");
|
||||
|
||||
itemObj.put("contractNum", contractNum); // 合同编号
|
||||
// itemObj.put("cwarehouseid", item.getAttributeValue("vbdef35")); // 仓库编号
|
||||
Object cwarehouseid = hybo.findColValue("bd_stordoc", "code", " (pk_stordoc = '" + item.getAttributeValue("vdef31") + "') ");
|
||||
|
||||
itemObj.put("cwarehouseid", cwarehouseid); // 仓库编码
|
||||
|
|
@ -193,27 +122,23 @@ public class AfterApproveSyncHighpressureMesRule implements IRule<PMOAggVO> {
|
|||
// 部门信息
|
||||
String deptsql = " select code,name from org_dept where pk_dept='" + item.getCdeptid() + "' and dr=0 ";
|
||||
Map<String, Object> tr = (Map<String, Object>) baseDAO.executeQuery(deptsql, new MapProcessor());
|
||||
itemObj.put("bipChildId", item.getCmoid()); // 子项主键ID
|
||||
itemObj.put("bipChildId", cmoid); // 子项主键ID
|
||||
itemObj.put("bipDeptName", tr.get("name")); // 生产部门名称
|
||||
itemObj.put("bipDeptId", tr.get("code")); // 生产部门编码
|
||||
|
||||
// 日期信息
|
||||
itemObj.put("requiredDate", item.getTrequiredate().toString()); // 需用日期
|
||||
// if("55A2".equals(item.getVsrctype())){
|
||||
// itemObj.put("bipParentProcessProductionOrderId", item.getVparentbillcode());
|
||||
// itemObj.put("bipParentProcessProductionOrderRowNum", item.getVparentmorowno());
|
||||
// }
|
||||
itemObj.put("bipParentProcessProductionOrderId", item.getVparentbillcode());
|
||||
itemObj.put("bipParentProcessProductionOrderRowNum", item.getVparentmorowno());
|
||||
// if("55A2".equals(item.getVfirsttype())){
|
||||
// 上级-上一个生产订单的信息
|
||||
itemObj.put("bipParentProcessProductionOrderId", null);
|
||||
itemObj.put("bipParentProcessProductionOrderRowNum", null);
|
||||
Map<String, String> prevOrderMap = findPrevOrder(cmoid);
|
||||
if (prevOrderMap != null && !prevOrderMap.isEmpty()) {
|
||||
itemObj.put("bipParentProcessProductionOrderId", prevOrderMap.get("vsrccode"));
|
||||
itemObj.put("bipParentProcessProductionOrderRowNum", prevOrderMap.get("vsrcrowno"));
|
||||
}
|
||||
// 顶级-源头单据信息
|
||||
itemObj.put("bipOriginProcessProductionOrderId", item.getVfirstcode());
|
||||
itemObj.put("bipOriginProcessProductionOrderRowNum", item.getVfirstrowno());
|
||||
// }else{
|
||||
// itemObj.put("bipOriginProcessProductionOrderId", item.getVfirstcode());
|
||||
// itemObj.put("bipOriginProcessProductionOrderRowNum", item.getVfirstrowno());
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// 物料信息
|
||||
String mrlsql = "select code,name,graphid,pk_measdoc,materialtype from bd_material where pk_material = '" + cmaterialvid + "' ";
|
||||
|
|
@ -221,14 +146,6 @@ public class AfterApproveSyncHighpressureMesRule implements IRule<PMOAggVO> {
|
|||
itemObj.put("materialCode", mrl.get("code")); // 物料编码
|
||||
itemObj.put("materialName", mrl.get("name")); // 物料名称
|
||||
|
||||
// String plansql = "select def1 from bd_materialplan where pk_org = '0001A11000000059XIB0' " + "and pk_material = '" + item.getCmaterialvid() + "' " + "and dr=0";//计划信息查询
|
||||
// Map<String, Object> plan = (Map<String, Object>) baseDAO.executeQuery(plansql, new MapProcessor());
|
||||
// if (plan != null && !plan.isEmpty()) {
|
||||
// itemObj.put("drawingNumber", plan.get("def1")); // 图号编码(计划信息查询高压生产中心)
|
||||
// } else {
|
||||
// itemObj.put("drawingNumber", "");
|
||||
// }
|
||||
|
||||
itemObj.put("drawingNumber", drawingNumber);
|
||||
Object unit = hybo.findColValue("bd_measdoc", "code", " pk_measdoc = '" + mrl.get("pk_measdoc") + "' ");
|
||||
itemObj.put("unit", unit); // 单位 pk_measdoc
|
||||
|
|
@ -250,17 +167,15 @@ public class AfterApproveSyncHighpressureMesRule implements IRule<PMOAggVO> {
|
|||
itemObj.put("orderQuantity", item.getNastnum().doubleValue());
|
||||
|
||||
contentArray.add(itemObj); // 将子项添加到数组
|
||||
|
||||
flags = "updateOrder";
|
||||
}
|
||||
|
||||
}
|
||||
String creator = pmoHeadVO.getCreator();
|
||||
String modifier = pmoHeadVO.getModifier();
|
||||
if (flags.equals("addOrder")) {
|
||||
String sql1 = " select user_name from sm_user where cuserid = '" + pmoHeadVO.getCreator() + "' ";
|
||||
String sql1 = " select user_name from sm_user where cuserid = '" + creator + "' ";
|
||||
String bipCreateBy = (String) baseDAO.executeQuery(sql1, new ColumnProcessor());
|
||||
singleObj.put("bipCreateBy", bipCreateBy); // 创建人ID
|
||||
} else {
|
||||
String sql1 = " select user_name from sm_user where cuserid = '" + pmoHeadVO.getModifier() + "' ";
|
||||
String sql1 = " select user_name from sm_user where cuserid = '" + modifier + "' ";
|
||||
String bipUpdateBy = (String) baseDAO.executeQuery(sql1, new ColumnProcessor());
|
||||
singleObj.put("bipUpdateBy", bipUpdateBy); // 修改人ID
|
||||
}
|
||||
|
|
@ -268,7 +183,7 @@ public class AfterApproveSyncHighpressureMesRule implements IRule<PMOAggVO> {
|
|||
jsonArray.add(singleObj);
|
||||
list.put("list", jsonArray);
|
||||
}
|
||||
if (list != null && !list.isEmpty()) {
|
||||
if (!list.isEmpty()) {
|
||||
pushData(list, flags);
|
||||
}
|
||||
}
|
||||
|
|
@ -299,6 +214,56 @@ public class AfterApproveSyncHighpressureMesRule implements IRule<PMOAggVO> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按来源链路逐级向上查找“上一张生产订单(55A2)”。
|
||||
* 规则:
|
||||
* 1) 若上级为空,返回null;
|
||||
* 2) 若到达源头单据且其类型不是55A2,返回null;
|
||||
* 3) 若遇到类型为55A2,则立即返回该生产订单
|
||||
*
|
||||
* @throws BusinessException 业务异常
|
||||
*/
|
||||
private Map<String, String> findPrevOrder(String currentMoBid) throws BusinessException {
|
||||
String nextBid = currentMoBid;
|
||||
while (nextBid != null) {
|
||||
String sql = "SELECT vsrctrantype, vsrcid, vsrcbid, vsrccode, vsrcrowno, vfirstid, vfirstbid FROM mm_mo WHERE dr = 0 AND cmoid = '" + nextBid + "'";
|
||||
Map<String, Object> row = (Map<String, Object>) baseDAO.executeQuery(sql, new MapProcessor());
|
||||
if (row == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String vsrctrantype = (String) row.get("vsrctrantype");
|
||||
String vsrcid = (String) row.get("vsrcid");
|
||||
String vsrcbid = (String) row.get("vsrcbid");
|
||||
String vsrccode = (String) row.get("vsrccode");
|
||||
String vsrcrowno = (String) row.get("vsrcrowno");
|
||||
String vfirstid = (String) row.get("vfirstid");
|
||||
|
||||
// 上级为空
|
||||
if (vsrctrantype == null || vsrcid == null || vsrcbid == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 命中上一张生产订单
|
||||
if ("55A2".equals(vsrctrantype)) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
result.put("vsrccode", vsrccode);
|
||||
result.put("vsrcrowno", vsrcrowno);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 已到达源头但源头不是生产订单,则结束返回null
|
||||
if (vsrcid.equals(vfirstid) && !"55A2".equals(vsrctrantype)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 继续向上(下一轮以来源明细作为当前明细)
|
||||
nextBid = vsrcbid;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
||||
String targetCode = configParams.get("gyOrg");
|
||||
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue