LAPTOP-SNT8I5JK\Boounion
2025-09-19 334b16b4abb4cbe3d1d4e4f211efd6f4468ae09f
SourceCode/Bond/Servo/CControlJobManagerDlg.cpp
@@ -6,6 +6,7 @@
#include "CControlJobManagerDlg.h"
#include "afxdialogex.h"
#include "ToolUnits.h"
#include "RecipeManager.h"
bool CControlJobManagerDlg::m_bHasState = false;
@@ -423,6 +424,14 @@
void CControlJobManagerDlg::OnBnClickedButtonBathCompletion()
{
   // 先检查当前master
   auto& master = theApp.m_model.getMaster();
   if (!master.canCreateControlJob()) {
      AfxMessageBox("当前Master有未结批的Job, 请先结批处理");
      return;
   }
   // 先应用
   for (int i = 0; i < 3; i++) {
      if (m_pages[i]->IsWindowVisible()) {
@@ -446,8 +455,8 @@
   auto& master = theApp.m_model.getMaster();
   int EQID[] = { EQ_ID_LOADPORT1, EQ_ID_LOADPORT2, EQ_ID_LOADPORT3, EQ_ID_LOADPORT4 };
   std::vector<SERVO::CProcessJob*> pjs;
   for (auto item : m_pjWarps) {
      if (!item.addToCj) continue;
@@ -461,14 +470,14 @@
      }
      if (!bCheck) continue;
      SERVO::CLoadPort* pPort = (SERVO::CLoadPort*)master.getEquipment(EQID[item.port]);
      SERVO::CProcessJob* pScr = (SERVO::CProcessJob*)item.pj;
      SERVO::CProcessJob * pj = new SERVO::CProcessJob(pScr->id());
      pj->setRecipe(SERVO::RecipeMethod::NoTuning, pScr->recipeSpec());
      std::vector<SERVO::CarrierSlotInfo> carriers;
      SERVO::CarrierSlotInfo csi;
      csi.carrierId = "Port" + std::to_string(item.port + 1);
      csi.carrierId = pPort->getCassetteId();
      for (int i = 0; i < 8; i++) {
         if (item.checkSlot[i]) {
            csi.slots.push_back(i);
@@ -487,8 +496,108 @@
      return;
   }
   m_pControlJob->setPJs(pjs);
   m_pControlJob->clearIssues();
   int nRet = master.setProcessJobs(pjs);
   master.setControlJob(*m_pControlJob);
   if (nRet <= 0) {
      std::string msg("同步Process Job失败!");
      for (auto pj : pjs) {
         auto& issues = pj->issues();
         if (!issues.empty()) {
            msg.append("\n");
            msg.append(pj->id());
            msg.append(":\n");
            for (auto i : issues) {
               msg.append("[");
               msg.append(std::to_string(i.code));
               msg.append("]");
               msg.append(i.text);
               msg.append("\n");
            }
         }
      }
      AfxMessageBox(msg.c_str());
      return;
   }
   nRet = master.setControlJob(*m_pControlJob);
   if (nRet != 0) {
      std::string msg("同步ControlJob失败!");
      auto& issues = m_pControlJob->issues();
      if (!issues.empty()) {
         msg.append("\n");
         for (auto i : issues) {
            msg.append("[");
            msg.append(std::to_string(i.code));
            msg.append("]");
            msg.append(i.text);
            msg.append("\n");
         }
      }
      AfxMessageBox(msg.c_str());
      return;
   }
   // 假设成功,要判断,同步到slot的glass中,类型等
   if (true) {
      auto& master = theApp.m_model.getMaster();
      int EQID[] = { EQ_ID_LOADPORT1, EQ_ID_LOADPORT2, EQ_ID_LOADPORT3, EQ_ID_LOADPORT4 };
      for (int p = 0; p < 4; p++) {
         SERVO::CLoadPort* pPort = (SERVO::CLoadPort*)master.getEquipment(EQID[p]);
         for (int i = 0; i < SLOT_MAX; ++i) {
            SERVO::CSlot* pSlot = pPort->getSlot(i);
            if (!pSlot) {
               continue;
            }
            // 设置 Panel ID 和勾选框
            SERVO::CProcessJob* pj = (SERVO::CProcessJob*)m_pjWarps[p].pj;
            int nRecipeID = RecipeManager::getInstance().getIdByPPID(pj->recipeSpec());
            RecipeInfo stRecipeInfo = RecipeManager::getInstance().getRecipeByPPID(pj->recipeSpec());
            std::vector<DeviceRecipe> vecRecipeInfo = stRecipeInfo.vecDeviceList;
            SERVO::CGlass* pGlass = dynamic_cast<SERVO::CGlass*>(pSlot->getContext());
            SERVO::CJobDataS* pJobDataS = pGlass->getJobDataS();
            if (pGlass != nullptr && pJobDataS != nullptr) {
               pGlass->setScheduledForProcessing(m_pjWarps[p].checkSlot[i]);
               pGlass->setType(static_cast<SERVO::MaterialsType>(m_pjWarps[p].material[i]));
               SERVO::CJobDataS* pJobDataS = pGlass->getJobDataS();
               pJobDataS->setLotId("LotID1");
               pJobDataS->setProductId("ProductId1");
               pJobDataS->setOperationId("OPerationId");
               pJobDataS->setMaterialsType(m_pjWarps[p].material[i]);
               pJobDataS->setMasterRecipe(nRecipeID);
               for (const auto& info : vecRecipeInfo) {
                  const std::string& name = info.strDeviceName;
                  short nRecipeID = (short)info.nRecipeID;
                  if (name == EQ_NAME_EFEM) {
                     pJobDataS->setDeviceRecipeId(0, nRecipeID);
                  }
                  else if (name == EQ_NAME_BONDER1) {
                     pJobDataS->setDeviceRecipeId(1, nRecipeID);
                  }
                  else if (name == EQ_NAME_BONDER2) {
                     pJobDataS->setDeviceRecipeId(2, nRecipeID);
                  }
                  else if (name == EQ_NAME_BAKE_COOLING) {
                     pJobDataS->setDeviceRecipeId(3, nRecipeID);
                  }
                  else if (name == EQ_NAME_VACUUMBAKE) {
                     pJobDataS->setDeviceRecipeId(4, nRecipeID);
                  }
                  else if (name == EQ_NAME_MEASUREMENT) {
                     pJobDataS->setDeviceRecipeId(5, nRecipeID);
                  }
               }
            }
         }
      }
   }
   AfxMessageBox("断点检查一下数据");
}