<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<task id="__WxCyH0i7nFSPRqUx9uH">
  <name>行业培训证书生成</name>
  <parentId>__LgZds5MVHW3o08T7UcX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <description></description>
  <type>1</type>
  <runningTime>2025-06-25T17:28:30.000+08:00</runningTime>
  <interval>10</interval>
  <period>34</period>
  <runtimes>0</runtimes>
  <terminateScript><![CDATA[]]></terminateScript>
  <taskScript><![CDATA[(function () {
  var process = getDocumentProcess();
  var sqlO = "select id from tlk_train_exam_person WHERE item_card_status='1' order by item_confirm_time limit 50";
  var datasO = queryByDSName("tms", sqlO);
  if (datasO.size() > 0) {
    for (var iterator = datasO.iterator(); iterator.hasNext();) {
      var map1 = iterator.next();//取值
      var exam_person_id= map1.get("id");
      var examPersonInfoDoc = findDocument(exam_person_id);
      var person_name = examPersonInfoDoc.findItem("person_name").getValue();
      var employee_id = examPersonInfoDoc.findItem("employee_id").getValue();
      var domain_name = examPersonInfoDoc.findItem("domain_name").getValue();
      var domain_id = examPersonInfoDoc.findItem("domain_id").getValue();
      var idcard_no = examPersonInfoDoc.findItem("idcard_no").getValue();
      var exam_id = examPersonInfoDoc.findItem("exam_id").getValue();
      var plan_id = examPersonInfoDoc.findItem("plan_id").getValue();
      var train_domain_name = examPersonInfoDoc.findItem("train_domain_name").getValue();
      var train_domain_id = examPersonInfoDoc.findItem("train_domain_id").getValue();
      var seat = examPersonInfoDoc.findItem("seat").getValue();
      var formProcess = getFormProcess();
      var subform = formProcess.doView("__NdhNgpOlr5hJZanQYkD");
      var doc = process.doNew(subform, getWebUser(), createParamsTable());
      doc.findItem("exam_person_id").setValue(exam_person_id);
      doc.findItem("person_name").setValue(person_name);
      doc.findItem("employee_id").setValue(employee_id);
      doc.findItem("domain_name").setValue(domain_name);
      doc.findItem("domain_id").setValue(domain_id);
      doc.findItem("idcard_no").setValue(idcard_no);
      var examInfoDoc = findDocument(exam_id);
      var point_type_id = examInfoDoc.findItem("point_type").getValue();
      var typesql="select item_certificate_type,item_certificate_number_head from tlk_train_certification_type_config where item_point_type='"+point_type_id+"' order by created desc limit 1 "
      var typedatas = queryByDSName("tms",typesql);
      var certificate_type= ""
      var certificate_number_head = ""
      if(typedatas.size()>0){
        for(var typeiterator = typedatas.iterator();typeiterator.hasNext();){
          var typemap1 = typeiterator.next();//取值
          var certificate_type= typemap1.get("item_certificate_type");
          var certificate_number_head = typemap1.get("item_certificate_number_head");
        }
      }
      doc.findItem("certificate_type").setValue(certificate_type);
      var nosql="select item_certificate_number from tlk_train_certification_no_config where item_train_domain_id='"+train_domain_id+"' order by created desc limit 1 "
      var nodatas = queryByDSName("tms",nosql);
      var certificate_number= ""
      if(nodatas.size()>0){
        for(var noiterator = nodatas.iterator();noiterator.hasNext();){
          var nomap1 = noiterator.next();//取值
          var certificate_number= nomap1.get("item_certificate_number");
        }
      }
      var certificate_no=certificate_number_head+format(getToday(),"yyMMdd")+certificate_number+Packages.org.apache.commons.lang3.StringUtils.leftPad(splitText(seat, ".")[0],3,"0")
      doc.findItem("certificate_no").setValue(certificate_no);
      doc.findItem("certificate_date").setValue(format(getToday(),"yyyy-MM-dd HH:mm:ss"));
      doc.findItem("status").setValue('1');
      doc.findItem("train_domain_name").setValue(train_domain_name);
      doc.findItem("train_domain_id").setValue(train_domain_id);
      var planInfoDoc = findDocument(plan_id);
      var train_start_time = planInfoDoc.findItem("train_start_time").getValue();
      var train_end_time = planInfoDoc.findItem("train_end_time").getValue();
      doc.findItem("train_start_time").setValue(train_start_time);
      doc.findItem("train_end_time").setValue(train_end_time);
      var usersql="select tenant_user_id,head_photo from obpm2.tenant_user_credentials where number = '"+idcard_no+"' "
      var userdatas = queryByDSName("tms",usersql);
      var tenant_user_id= ""
      var head_photo = ""
      if(userdatas.size()>0){
        for(var useriterator = userdatas.iterator();useriterator.hasNext();){
          var usermap1 = useriterator.next();//取值
          var tenant_user_id= usermap1.get("tenant_user_id");
          var head_photo= usermap1.get("head_photo");
        }
      }
      doc.findItem("certificate_photo").setValue(head_photo);
      doc.setDomainid(domain_id)
      process.doCreate(doc);
      var insertsql2="INSERT INTO obpm2.tenant_user_credential_details (areacode,create_time, certificateType,id, xm, active, idnum, zsbh, fzrq, fzjgmc, state,appraisalGrade,tenant_user_id,trainId,trainName,companyId,companyName) VALUES ('110000', '"+format(getToday(),"yyyy-MM-dd HH:mm:ss")+"','13',  '"+doc.getId()+"', '"+person_name+"', '1' , '"+idcard_no+"','"+certificate_no+"','"+format(getToday(),"yyyy-MM-dd HH:mm:ss")+"', '"+train_domain_name+"', '1','5','"+tenant_user_id+"','"+train_domain_id+"','"+train_domain_name+"','"+domain_id+"','"+domain_name+"' )"
      insertByDSName("tms",insertsql2);
      examPersonInfoDoc.findItem("card_status").setValue("2")
      process.doUpdate(examPersonInfoDoc);
    }
  }
})()]]></taskScript>
  <modifyTime>2025-06-25T17:28:30.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></rDate>
  <rTime></rTime>
</task>