<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<activity id="__EN2w7siyxLjzfavtiIM">
  <name>测试等级</name>
  <parentId>__WvmJVaojPRkDOsoZgz0</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <type>1</type>
  <onActionForm></onActionForm>
  <onActionView>__YFtuKZvXnAZ9yq82gJF</onActionView>
  <colorType>default</colorType>
  <beforeActionScript><![CDATA[#include "echoProvince";
(function () {
    Packages.java.lang.System.err.println("================等级证证书发放执行=================");
    var sqlO = "SELECT GROUP_CONCAT(id SEPARATOR ';') AS examPersonId  FROM tlk_level_class_student WHERE ITEM_CARDSTATE='2'"
    //  Packages.java.lang.System.err.println("================sqlO================="+sqlO);
    var datasO = queryByDSName("tms", sqlO);
    //  Packages.java.lang.System.err.println("================datasO================="+datasO);
    if (datasO.size() > 0) {
        for (var iterator = datasO.iterator(); iterator.hasNext();) {
            var map1 = iterator.next();//取值
            var examPersonId = map1.get("examPersonId");
        }
    }
    //Packages.java.lang.System.err.println("examPersonId-->"+examPersonId);
    if (isNotNull(examPersonId)) {
        var arrto = splitText(examPersonId, ";");
        var process = getDocumentProcess();
        for (var i = 0; i < arrto.length; i++) {
            var examPersonInfoDoc = findDocument(arrto[i]);
            var applyId = examPersonInfoDoc.findItem("applyId").getValue();
             var securityId = examPersonInfoDoc.findItem("securityId").getValue();
            var graduationTestResults = examPersonInfoDoc.findItem("graduationTestResults").getValue();
            //  Packages.java.lang.System.err.println("================testState================="+securityId+"是"+testState);
            if (graduationTestResults == "1") {
                var sqlR = "select * from tlk_grade_registration where id='" + applyId + "' ";
              Packages.java.lang.System.err.println("================等级证证书发放执行======sqlR==========="+sqlR);
                var datas = queryByDSName("tms", sqlR);
                if (datas.size() > 0) {
                    for (var iteratorr = datas.iterator(); iteratorr.hasNext();) {
                        var map2 = iteratorr.next();//取值
                        var personId = map2.get("id");
                        var domainid = map2.get("domainid");
                        var name = map2.get("ITEM_NAME");
                        var idCardNo = map2.get("ITEM_IDCARDNO");
                        var birth = idCardNo.substring(6, 10) + "-" + idCardNo.substring(10, 12) + "-" + idCardNo.substring(12, 14);
                        var birthDay = format(birth, "yyyy-MM-dd");
                        var avatar = map2.get("ITEM_AVATAR");
                        var today = format(getToday(), "yyyy-MM-dd");
                        var cultivateCompany = map2.get("ITEM_TRAINNAME");
                        var CompanyNameToGet = map2.get("ITEM_LEARNNAME");
                        var cultivateCompanyCode = map2.get("ITEM_TRAINID");
                        var CompanyNameToGetCode = map2.get("ITEM_LEARNID");
                        var sqlr="select * from baibaodunflow.vw_organization where id='"+domainid+"'";
                        var datass = queryByDSName("tms", sqlr);

                        if (datass.size() > 0) {

                            for (var iteratorj = datass.iterator(); iteratorj.hasNext();) {

                                var map3 = iteratorj.next();//取值
                                var registerprovince = map3.get("place_of_register_province_name");
                               // var registerprovince = splitText(registerprovinces, ",")[0];
                                var OFFICEADDRESSID = map3.get("unify_social_credit_code");
                                println(registerprovince);
                            }
                        }
                        var ResultCodeJsonObject = new Packages.cn.myapps.util.serial.number.GenerateSerialNumber();
                        var numberr = ResultCodeJsonObject.getSerialNumber("bapx");
                       // Packages.java.lang.System.err.println("================numberr=================" + numberr);
                        var process = getDocumentProcess();
                        var formProcess = getFormProcess();
                        var subform = formProcess.doView("__JPHvq5gsbT0nuFotaqq");
                        var doc = process.doNew(subform, getWebUser(), createParamsTable());
                        doc.addStringItem("securityId", securityId);
                        doc.addStringItem("name", name);
                        doc.addStringItem("idCardType", "1");
                        doc.addStringItem("idCardNo", idCardNo);
                        doc.addStringItem("certificateType", "2");
                        doc.addStringItem("certificateNO", (echoProvince(registerprovince) + numberr));
                        doc.addStringItem("confirmDate", today);
                        doc.addStringItem("certificateFrom", registerprovince + "公安局");
                        doc.addStringItem("certificateFromNO", OFFICEADDRESSID);
                        doc.addStringItem("certificateDate", today);
                        doc.addStringItem("status", 1)//datart.getItemValueAsString("ID_NUMBER"));             
                        doc.addStringItem("cultivateCompany", cultivateCompany);
                        doc.addStringItem("CompanyNameToGet", CompanyNameToGet);
                        doc.addStringItem("cultivateCompanyCode", cultivateCompanyCode);
                        doc.addStringItem("CompanyNameToGetCode", CompanyNameToGetCode);
                        doc.addStringItem("oneInchPhoto", avatar);
                        doc.addStringItem("birthday", birthDay);
                        doc.addStringItem("personId", personId);
                       doc.addStringItem("level", "5");
                       Packages.java.lang.System.err.println("================等级证证书发放执行======doc==========="+doc);
                        //doc.addIntItem("progress",0);  
                        //      Packages.java.lang.System.err.println("================doc================="+doc);
                        process.doCreate(doc);
                    //  var uuid = new Packages.cn.myapps.util.sequence.Sequence();
                  //    var sqlV = "insert into baibaodunflow.tlk_Certificate (id,formid,applicationid,ITEM_CERTIFICATETYPE,ITEM_CERTIFICATENO,ITEM_CERTIFICATEFROM,ITEM_CERTIFICATEFROMNO,ITEM_CERTIFICATEDATE,ITEM_SECURITYNAME,ITEM_STATUS,ITEM_CONFIRMDATE,ITEM_CULTIVATECOMPANY,ITEM_COMPANYNAMETOGET,ITEM_DOCUMENTID,ITEM_DOCUMENTTYPE,ITEM_CULTIVATECOMPANYCODE,ITEM_COMPANYNAMETOGETCODE,ITEM_PIRTURE,ITEM_BIRTHDATE) values('" + uuid.getSequence() + "--__TTeElnX8IULbf7iTxsM','__TTeElnX8IULbf7iTxsG','__DXZvc8mnEmDqMARhK7G','2','"+echoProvince(registerprovince) + numberr + "','" + registerprovince + "','','" + today + "','" + name + "','1','" + today + "','" + cultivateCompany + "','" + CompanyNameToGet + "','" + idCardNo + "','1','" + cultivateCompanyCode + "','" + CompanyNameToGetCode + "','" + avatar + "','" + birthDay + "')";
                       //    Packages.java.lang.System.err.println("================sqlV=================" + sqlV);
                    //    insertByDSName("baibaodunFlow", sqlV);

                    }
                    examPersonInfoDoc.findItem("cardState").setValue("1");
                    process.doUpdate(examPersonInfoDoc);
                }
            }
        }
    }
    Packages.java.lang.System.err.println("================等级证结束=================");
})()]]></beforeActionScript>
  <afterActionScript><![CDATA[]]></afterActionScript>
  <hiddenScript><![CDATA[true]]></hiddenScript>
  <readonlyScript><![CDATA[]]></readonlyScript>
  <editMode>0</editMode>
  <fileNameScript><![CDATA[]]></fileNameScript>
  <orderno>5</orderno>
  <parentView>__WvmJVaojPRkDOsoZgz0</parentView>
  <impmappingconfigid></impmappingconfigid>
  <jumpType>0</jumpType>
  <expSub>false</expSub>
  <icon></icon>
  <disableFlowNode>false</disableFlowNode>
  <changeFlowOperator>false</changeFlowOperator>
  <changeFlowCc>false</changeFlowCc>
  <multiLanguageLabel></multiLanguageLabel>
  <dispatcherMode>0</dispatcherMode>
  <dispatcherUrl><![CDATA[]]></dispatcherUrl>
  <dispatcherParams><![CDATA[[{"paramKey":"","paramValue":""}]]]></dispatcherParams>
  <jumpMode>0</jumpMode>
  <jumpActOpenType>0</jumpActOpenType>
  <withOld>false</withOld>
  <actionType>0</actionType>
  <actionSelection>0</actionSelection>
  <workFlowType>0</workFlowType>
  <contextMenu>true</contextMenu>
  <showInToolbar>true</showInToolbar>
  <label><![CDATA[]]></label>
</activity>