<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<task id="__yacBQT0qIKOmXIeyQFU">
  <name>等级证证书发放</name>
  <parentId>__LgZds5MVHW3o08T7UcX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <description></description>
  <type>1</type>
  <runningTime>2022-07-23T10:10:01.000+08:00</runningTime>
  <interval>5</interval>
  <period>34</period>
  <runtimes>0</runtimes>
  <terminateScript><![CDATA[]]></terminateScript>
  <taskScript><![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' and LASTFLOWOPERATION is null"
  //  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 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("certificateFrom", cultivateCompany);
            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.setDomainid(domainid)
            var birthDay = idCardNo.substring(6, 10) + "-" + idCardNo.substring(10, 12) + "-" + idCardNo.substring(12, 14);
            println("生日"+birthDay);
            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("================等级证结束=================");
})()]]></taskScript>
  <modifyTime>2022-07-23T10:10:01.000+08:00</modifyTime>
  <creator>Admin</creator>
  <creatorid>Ai6hllhNjS2ull9TKGb</creatorid>
  <totalRuntimes>0</totalRuntimes>
  <state>0</state>
  <startupType>1</startupType>
  <dayOfMonth>1</dayOfMonth>
  <repeatTimes>0</repeatTimes>
  <frequency>0</frequency>
  <executedCount>0</executedCount>
  <rDate>2021-11-24</rDate>
  <rTime>09:35:18</rTime>
</task>