void TableContractModel::setTableModelUp() { Role hackRole = newRole(0, 0, 0, 0, tr("Role description")); this->iInsertedRole.setValue(hackRole); if(!this->insertRows(0,1, QModelIndex())) qDebug() << "hackRole insert problems"; //setData(this->index(0, QModelIndex(), QVariant(), Qt::EditRole); Employee hackEmployee = newEmployee(tr("Employee's Name"), tr("000000-0000")); this->iInsertedEmployee.setValue(hackEmployee); if(!this->insertRows(1,1, QModelIndex())) qDebug() << "hackEmployee insert problems"; //setData(QModelIndex(), QVariant(), Qt::EditRole); Contract hackContract = newContract(hackRole.iRoleId, hackEmployee.iEmployeeId); this->iInsertedContract.setValue(hackContract); if(!this->insertRows(2,1, QModelIndex())) qDebug() << "hackContract insert problems"; //setData(QModelIndex(), QVariant(), Qt::EditRole); Work hackWork = newWork(hackContract.iContractId,0,0,0); this->iInsertedWork.setValue(hackWork); if(!this->insertRows(3,1, QModelIndex())) qDebug() << "hackWork insert problems"; //setData(QModelIndex(), QVariant(), Qt::EditRole); }
void TableContractModel::addWork(int aContractIndex, double aHours, double aRealizedOutcome, double aMonths) { QVariant contractindex = rowTypeIndex(aContractIndex); qDebug() << "aContractIndex" << aContractIndex << "contractindex" << contractindex; if(!contractindex.isValid()) return; qint64 contractId = this->iContracts[contractindex.value<int>()].iContractId; qDebug() << "contractId" << contractId; if (contractId == 0) return; Work hackWork = newWork(contractId, aHours, aRealizedOutcome, aMonths); this->iInsertedWork.setValue(hackWork); if(!this->insertRows(typeRow(3),1, QModelIndex())) qDebug() << "addWork insert problems"; //setData(QModelIndex(), QVariant(), Qt::EditRole); }
YK_ID YKCreateMTOrderParamExtern::GetMaintainWork(YK_ID resId) { YK_ID rtWorkId = GetExistMTWork(); if(rtWorkId == 0) { YKItemSPtr item = GetValue()->GetItem(); if(item.ValidObj()) //物品存在,根据物品及数量产生订单,展开 { YKOrderExtern orderPtr(YKOrderExtern::CreatNew(GetValue()->GetNumber(),item->GetID())); orderPtr.UpdateIOItem(); orderPtr.GetValue()->SetType(YKOrder::OrderType_MTOrder); orderPtr.CreateOrderCode(); list<YKWorkSPtr> workList; orderPtr.GetValue()->GetWorkIds().Filter(workList); if(!workList.empty()) //订单有工作 { GetValue()->AddOrderList(orderPtr.GetID()); YKWorkExtern work(workList.front().GetID()); work.CreatAvbResource(); list<YKWorkSPtr> sonWorkList; work.GetValue()->GetSonWorkList().Filter(sonWorkList); if(!sonWorkList.empty()) { rtWorkId = sonWorkList.front()->GetID(); } else { YKOrderExtern(orderPtr).Delete(); } } else { YKOrderExtern(orderPtr).Delete(); } } if(rtWorkId == 0) { //处理直接生成维护订单和维护工作的情况 if(GetValue()->GetTime().GetTime() > 0) { YKOrderSPtr newOrder = g_Application.Get<YKMapOrder>()->CreateObj(0); newOrder->SetType(YKOrder::OrderType_MTOrder); newOrder->SetAmount(1); newOrder->SetDiffer(YKOrder::OrderDiffer_Auto); YKOrderExtern temp(newOrder); temp.CreateOrderCode(); //是否需要默认物品 YKWorkExtern newWork(YKWorkExtern::CreatNew(1,newOrder->GetID(),0)); newWork.GetValue()->SetSpecifyProduceTm(GetValue()->GetTime().GetExtraString()); //产生工作可用资源 YKWorkAvbResourceSPtr workAvb = YKWorkAvbResourceExtern::CreateNewAvbRes(newOrder,newWork.GetID(),GetValue()->GetID(),YKOrder::OrderType_MTOrder,resId); //工作可用资源 DBWork(newWork.GetValue()).AddWorkResourcePtr(workAvb); newOrder->AddWork(newWork.GetID()); GetValue()->AddOrderList(newOrder->GetID()); YKWorkSPtr sonWork = newWork.CreatSplitSonWork(newWork.GetValue()->GetPlantAmount()); rtWorkId = sonWork->GetID(); } } } if(rtWorkId > 0) g_Application.Get<YKMapWork>()->AddSchedulerWork(rtWorkId); return rtWorkId; }