清除重复记录只保留一条

static void NJ_MF_CleanRepeat(Args _args)
{
    NJ_sInventTable     NJ_sInventTable;                //
    NJ_sSetting         NJ_sSetting,curNJ_sSetting;     //镶口
    NJ_sHead            NJ_sHead,curNj_sHead;           //围头
    NJ_sShank           NJ_sShank,curNJ_sShank;         //比
    NJ_sOthers          NJ_sOthers,curNJ_sOthers;       //其它
/*   NJ_sHead_tmp        tmpNJ_sHead;
    NJ_sOthers_tmp      tmpNJ_sOthers;
    NJ_sShank_tmp       tmpNJ_sShank;
    NJ_sSetting_tmp     tmpNJ_sSetting; */
    TextBuffer          txtBuffer = new TextBuffer();
    int                 i;
    str txtfilePath;
    container                   conFilter = ["Text Files(*.txt)", "*.txt"];

    ;
/*

    insert_recordset tmpNJ_sSetting(RefRecID, NJ_sItemId, NJ_sSetting1StoneWeight, NJ_sSetting1Plug, NJ_sSetting1Size, NJ_sSetting1Size1,
                         NJ_sSetting1ClawQtyId, NJ_sSetting1ClawSharpId, NJ_sSetting1Parts, NJ_sSetting1ShapeId, NJ_sSetting1ClawOneID,
                         NJ_sSetting1StoneQty, NJ_sSetting1StoneQtyWeight, InventSettingId, NJ_sSettingId, NJ_sSetting1ShapeId1,
                         NJ_sSetting1Setting, NJ_sSettingQty)
            select RefRecID, NJ_sItemId, NJ_sSetting1StoneWeight, NJ_sSetting1Plug, NJ_sSetting1Size, NJ_sSetting1Size1,
                         NJ_sSetting1ClawQtyId, NJ_sSetting1ClawSharpId, NJ_sSetting1Parts, NJ_sSetting1ShapeId, NJ_sSetting1ClawOneID,
                         NJ_sSetting1StoneQty, NJ_sSetting1StoneQtyWeight, InventSettingId, NJ_sSettingId, NJ_sSetting1ShapeId1,
                         NJ_sSetting1Setting, NJ_sSettingQty from NJ_sSetting group by
                         RefRecID, NJ_sItemId, NJ_sSetting1StoneWeight, NJ_sSetting1Plug, NJ_sSetting1Size, NJ_sSetting1Size1,
                         NJ_sSetting1ClawQtyId, NJ_sSetting1ClawSharpId, NJ_sSetting1Parts, NJ_sSetting1ShapeId, NJ_sSetting1ClawOneID,
                         NJ_sSetting1StoneQty, NJ_sSetting1StoneQtyWeight, InventSettingId, NJ_sSettingId, NJ_sSetting1ShapeId1,
                         NJ_sSetting1Setting, NJ_sSettingQty;

    insert_recordset tmpNJ_sHead(RefRecID, NJ_sItemId, NJ_sHeadShapeId, NJ_sHeadStoneQty, NJ_sHeadStoneQtyWeight, NJ_sHeadSize,
                        NJ_sHeadSize1, NJ_sHeadSettingID, NJ_sHeadStoneWeight, NJ_sHeadIsMainStone, NJ_sHeadId, NJ_sHeadQty, NJ_sHeadShapeId2)
             select RefRecID, NJ_sItemId, NJ_sHeadShapeId, NJ_sHeadStoneQty, NJ_sHeadStoneQtyWeight, NJ_sHeadSize,
                        NJ_sHeadSize1, NJ_sHeadSettingID, NJ_sHeadStoneWeight, NJ_sHeadIsMainStone, NJ_sHeadId, NJ_sHeadQty, NJ_sHeadShapeId2
                        from NJ_sHead group by RefRecID, NJ_sItemId, NJ_sHeadShapeId, NJ_sHeadStoneQty, NJ_sHeadStoneQtyWeight, NJ_sHeadSize,
                        NJ_sHeadSize1, NJ_sHeadSettingID, NJ_sHeadStoneWeight, NJ_sHeadIsMainStone, NJ_sHeadId, NJ_sHeadQty, NJ_sHeadShapeId2;

     insert_recordset tmpNJ_sOthers(RefRecID, NJ_sItemId, NJ_sOthersShapeId, NJ_sOthersStoneQty, NJ_sOthersStoneQtyWeight, NJ_sOthersSize,
                        NJ_sOthersSize1, NJ_sOthersSettingID, NJ_sOthersStoneWeight)
             select RefRecID, NJ_sItemId, NJ_sOthersShapeId, NJ_sOthersStoneQty, NJ_sOthersStoneQtyWeight, NJ_sOthersSize,
                        NJ_sOthersSize1, NJ_sOthersSettingID, NJ_sOthersStoneWeight
                        from NJ_sOthers group by RefRecID, NJ_sItemId, NJ_sOthersShapeId,NJ_sOthersStoneQty, NJ_sOthersStoneQtyWeight, NJ_sOthersSize,
                        NJ_sOthersSize1, NJ_sOthersSettingID, NJ_sOthersStoneWeight;

     insert_recordset tmpNJ_sShank(RefRecID, NJ_sItemId, NJ_sShankShapeId, NJ_sShankStoneQty, NJ_sShankStoneQtyWeight, NJ_sShankSize, NJ_sShankSize1,
                        NJ_sShankSettingID, NJ_sShankStoneWeight)
             select RefRecID, NJ_sItemId, NJ_sShankShapeId, NJ_sShankStoneQty, NJ_sShankStoneQtyWeight, NJ_sShankSize, NJ_sShankSize1,
                        NJ_sShankSettingID, NJ_sShankStoneWeight from NJ_sShank group by RefRecID, NJ_sItemId, NJ_sShankShapeId, NJ_sShankStoneQty,
                        NJ_sShankStoneQtyWeight, NJ_sShankSize, NJ_sShankSize1, NJ_sShankSettingID, NJ_sShankStoneWeight;

*/

//print (select nj_sItemId,count(recid) from nj_sHead group by nj_sItemId).nj_sItemId;

while select count(recid),RefRecID, NJ_sItemId, NJ_sHeadShapeId, NJ_sHeadStoneQty, NJ_sHeadStoneQtyWeight, NJ_sHeadSize,
                        NJ_sHeadSize1, NJ_sHeadSettingID, NJ_sHeadStoneWeight, NJ_sHeadIsMainStone, NJ_sHeadId, NJ_sHeadQty, NJ_sHeadShapeId2
                        from nj_sHead
                        group by RefRecID, NJ_sItemId, NJ_sHeadShapeId, NJ_sHeadStoneQty, NJ_sHeadStoneQtyWeight, NJ_sHeadSize,
                        NJ_sHeadSize1, NJ_sHeadSettingID, NJ_sHeadStoneWeight, NJ_sHeadIsMainStone, NJ_sHeadId, NJ_sHeadQty, NJ_sHeadShapeId2
                        {

                            if(nj_sHead.RecId>1)
                            {
                            i = 1;
                            while select curNj_sHead where curNj_sHead.NJ_sItemId == nj_sHead.NJ_sItemId
                                                    && curNj_sHead.RefRecID == nj_sHead.RefRecID
                                                    && curNj_sHead.NJ_sHeadShapeId == nj_sHead.NJ_sHeadShapeId
                                                    && curNj_sHead.NJ_sHeadStoneQty == nj_sHead.NJ_sHeadStoneQty
                                                    && curNj_sHead.NJ_sHeadStoneQtyWeight == nj_sHead.NJ_sHeadStoneQtyWeight
                                                    && curNj_sHead.NJ_sHeadSize == nj_sHead.NJ_sHeadSize
                                                    && curNj_sHead.NJ_sHeadSize1 == nj_sHead.NJ_sHeadSize1
                                                    && curNj_sHead.NJ_sHeadSettingID == nj_sHead.NJ_sHeadSettingID
                                                    && curNj_sHead.NJ_sHeadStoneWeight ==nj_sHead.NJ_sHeadStoneWeight
                                                    && curNj_sHead.NJ_sHeadIsMainStone == nj_sHead.NJ_sHeadIsMainStone
                                                    && curNj_sHead.NJ_sHeadId == nj_sHead.NJ_sHeadId
                                                    && curNj_sHead.NJ_sHeadQty == nj_sHead.NJ_sHeadQty
                                                    && curNj_sHead.NJ_sHeadShapeId2 == nj_sHead.NJ_sHeadShapeId2
                                                    {
                                                        if(i <= nj_sHead.RecId - 1)
                                                        {
                                                            //curNj_sHead.doDelete();
                                                            print strfmt("围头,%1 , %2 , %3" ,curNj_sHead.NJ_sItemId,curNj_sHead.RecId,nj_sHead.RecId);
                                                            txtBuffer.appendText(strfmt("围头,%1 , %2 , %3 \n"  ,curNj_sHead.NJ_sItemId,curNj_sHead.RecId,nj_sHead.RecId));
                                                            i++;
                                                        }
                                                    }

                            }
                        }
while select count(recid),RefRecID, NJ_sItemId, NJ_sSetting1StoneWeight, NJ_sSetting1Plug, NJ_sSetting1Size, NJ_sSetting1Size1,
                         NJ_sSetting1ClawQtyId, NJ_sSetting1ClawSharpId, NJ_sSetting1Parts, NJ_sSetting1ShapeId, NJ_sSetting1ClawOneID,
                         NJ_sSetting1StoneQty, NJ_sSetting1StoneQtyWeight, InventSettingId, NJ_sSettingId, NJ_sSetting1ShapeId1,
                         NJ_sSetting1Setting, NJ_sSettingQty
                         from NJ_sSetting
                         group by RefRecID, NJ_sItemId, NJ_sSetting1StoneWeight, NJ_sSetting1Plug, NJ_sSetting1Size, NJ_sSetting1Size1,
                         NJ_sSetting1ClawQtyId, NJ_sSetting1ClawSharpId, NJ_sSetting1Parts, NJ_sSetting1ShapeId, NJ_sSetting1ClawOneID,
                         NJ_sSetting1StoneQty, NJ_sSetting1StoneQtyWeight, InventSettingId, NJ_sSettingId, NJ_sSetting1ShapeId1,
                         NJ_sSetting1Setting, NJ_sSettingQty
                         {
                            if(NJ_sSetting.RecId > 1)
                            {
                             i = 1;
                             while select curNJ_sSetting where curNJ_sSetting.RefRecID == nj_sSetting.RefRecID
                                                            && curNJ_sSetting.NJ_sItemId == nj_sSetting.NJ_sItemId
                                                            && curNJ_sSetting.NJ_sSetting1StoneWeight == nj_sSetting.NJ_sSetting1StoneWeight
                                                            && curNJ_sSetting.NJ_sSetting1Plug == nj_sSetting.NJ_sSetting1Plug
                                                            && curNJ_sSetting.NJ_sSetting1Size == nj_sSetting.NJ_sSetting1Size
                                                            && curNJ_sSetting.NJ_sSetting1Size1 == nj_sSetting.NJ_sSetting1Size1
                                                            && curNJ_sSetting.NJ_sSetting1ClawQtyId == nj_sSetting.NJ_sSetting1ClawQtyId
                                                            && curNJ_sSetting.NJ_sSetting1ClawSharpId == nj_sSetting.NJ_sSetting1ClawSharpId
                                                            && curNJ_sSetting.NJ_sSetting1Parts == nj_sSetting.NJ_sSetting1Parts
                                                            && curNJ_sSetting.NJ_sSetting1ShapeId == nj_sSetting.NJ_sSetting1ShapeId
                                                            && curNJ_sSetting.NJ_sSetting1ClawOneID == nj_sSetting.NJ_sSetting1ClawOneID
                                                            && curNJ_sSetting.NJ_sSetting1StoneQty == nj_sSetting.NJ_sSetting1StoneQty
                                                            && curNJ_sSetting.NJ_sSetting1StoneQtyWeight == nj_sSetting.NJ_sSetting1StoneQtyWeight
                                                            && curNJ_sSetting.InventSettingId == curNJ_sSetting.InventSettingId
                                                            && curNJ_sSetting.NJ_sSettingId == curNJ_sSetting.NJ_sSettingId
                                                            && curNJ_sSetting.NJ_sSetting1ShapeId1 == curNJ_sSetting.NJ_sSetting1ShapeId1
                                                            && curNJ_sSetting.NJ_sSetting1Setting == curNJ_sSetting.NJ_sSetting1Setting
                                                            && curNJ_sSetting.NJ_sSettingQty == curNJ_sSetting.NJ_sSettingQty
                                                            {
                                                                if(i <= NJ_sSetting.RecId - 1)
                                                                {
                                                                //curNJ_sSetting.doDelete();
                                                                print strfmt("镶口, %1 , %2 , %3" ,curNJ_sSetting.NJ_sItemId,curNJ_sSetting.RecId,NJ_sSetting.RecId);
                                                                txtBuffer.appendText(strfmt("镶口, %1 , %2 , %3 \n" ,curNJ_sSetting.NJ_sItemId,curNJ_sSetting.RecId,NJ_sSetting.RecId));
                                                                i++;
                                                                }

                                                            }
                            }

                         }

while select count(recid),RefRecID, NJ_sItemId, NJ_sOthersShapeId, NJ_sOthersStoneQty, NJ_sOthersStoneQtyWeight, NJ_sOthersSize,
                        NJ_sOthersSize1, NJ_sOthersSettingID, NJ_sOthersStoneWeight
                        from NJ_sOthers
                        group by RefRecID, NJ_sItemId, NJ_sOthersShapeId, NJ_sOthersStoneQty, NJ_sOthersStoneQtyWeight, NJ_sOthersSize,
                        NJ_sOthersSize1, NJ_sOthersSettingID, NJ_sOthersStoneWeight
                        {
                         if(NJ_sOthers.recid > 1)
                         {
                          i = 1;
                          while select curNJ_sOthers where curNJ_sOthers.RefRecID == NJ_sOthers.RefRecID
                                                    && curNJ_sOthers.NJ_sItemId == NJ_sOthers.NJ_sItemId
                                                    && curNJ_sOthers.NJ_sOthersShapeId == NJ_sOthers.NJ_sOthersShapeId
                                                    && curNJ_sOthers.NJ_sOthersStoneQty == NJ_sOthers.NJ_sOthersStoneQty
                                                    && curNJ_sOthers.NJ_sOthersStoneQtyWeight == NJ_sOthers.NJ_sOthersStoneQtyWeight
                                                    && curNJ_sOthers.NJ_sOthersSize == NJ_sOthers.NJ_sOthersSize
                                                    && curNJ_sOthers.NJ_sOthersSize1 == NJ_sOthers.NJ_sOthersSize1
                                                    && curNJ_sOthers.NJ_sOthersSettingID == NJ_sOthers.NJ_sOthersSettingID
                                                    && curNJ_sOthers.NJ_sOthersStoneWeight == NJ_sOthers.NJ_sOthersStoneWeight
                                                    {
                                                        if (i <= NJ_sOthers.RecId - 1)
                                                        {
                                                            //curNJ_sOthers.doDelete();
                                                            print strfmt("其它,%1  %2  %3" ,curNJ_sOthers.NJ_sItemId,curNJ_sOthers.RecId,NJ_sOthers.RecId);
                                                            txtBuffer.appendText(strfmt("其它,%1  %2  %3 \n" ,curNJ_sOthers.NJ_sItemId,curNJ_sOthers.RecId,NJ_sOthers.RecId));
                                                            i++;
                                                        }
                                                    }
                         }

                        }

while select count(RecId),RefRecID, NJ_sItemId, NJ_sShankShapeId, NJ_sShankStoneQty, NJ_sShankStoneQtyWeight, NJ_sShankSize, NJ_sShankSize1,
                        NJ_sShankSettingID, NJ_sShankStoneWeight
                        from NJ_sShank group by RefRecID, NJ_sItemId, NJ_sShankShapeId, NJ_sShankStoneQty, NJ_sShankStoneQtyWeight, NJ_sShankSize, NJ_sShankSize1,
                        NJ_sShankSettingID, NJ_sShankStoneWeight
                        {
                            if(NJ_sShank.RecId >1)
                            {
                             i=1;
                             while select curNJ_sShank where curNJ_sShank.RefRecID == NJ_sShank.RefRecID
                                                        && curNJ_sShank.NJ_sItemId == NJ_sShank.NJ_sItemId
                                                        && curNJ_sShank.NJ_sShankShapeId == NJ_sShank.NJ_sShankShapeId
                                                        && curNJ_sShank.NJ_sShankStoneQty == NJ_sShank.NJ_sShankStoneQty
                                                        && curNJ_sShank.NJ_sShankStoneQtyWeight == NJ_sShank.NJ_sShankStoneQtyWeight
                                                        && curNJ_sShank.NJ_sShankSize == NJ_sShank.NJ_sShankSize
                                                        && curNJ_sShank.NJ_sShankSize1 == NJ_sShank.NJ_sShankSize1
                                                        && curNJ_sShank.NJ_sShankSettingID == NJ_sShank.NJ_sShankSettingID
                                                        && curNJ_sShank.NJ_sShankStoneWeight == NJ_sShank.NJ_sShankStoneWeight
                                                        {
                                                            if(i <= NJ_sShank.RecId - 1)
                                                            {
                                                                //curNJ_sShank.doDelete();
                                                                print strfmt("比, %1 , %2 , %3 " ,curNJ_sShank.NJ_sItemId,curNJ_sShank.RecId,NJ_sShank.RecId);
                                                                txtBuffer.appendText(strfmt("比, %1 , %2 , %3 \n" ,curNJ_sShank.NJ_sItemId,curNJ_sShank.RecId,NJ_sShank.RecId));
                                                                i++;
                                                            }
                                                        }
                            }

                        }

    txtfilePath = Winapi::getSaveFileName(0, conFilter,"", "Specify SaveFile Name", "", "");
    if(txtfilePath)
    {
        txtBuffer.toFile(txtfilePath);
    }
pause;

}

posted @ 2011-12-22 09:27  perock  阅读(250)  评论(0编辑  收藏  举报