<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<task id="__HybmL1oq89KBah5mu9a">
  <name>鉴定证同步到智能人事</name>
  <parentId>__LgZds5MVHW3o08T7UcX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <description></description>
  <type>1</type>
  <runningTime>2022-07-23T10:10:05.000+08:00</runningTime>
  <interval>5</interval>
  <period>34</period>
  <runtimes>0</runtimes>
  <terminateScript><![CDATA[]]></terminateScript>
  <taskScript><![CDATA[(function(){
  //Packages.java.lang.System.err.println("================证书同步至智能人事=================");
  var sql0="select GROUP_CONCAT(id SEPARATOR ';') AS certificationId from tlk_scores where ID IN (select ID from tms.tlk_scores where item_synchronize ='1') ORDER BY CREATED desc  "
  println("sql0----------->"+sql0);
  var datasO = queryByDSName("tms", sql0);
  if (datasO.size() > 0) {
    for (var iterator = datasO.iterator(); iterator.hasNext();) {
      var map1 = iterator.next();//取值
      var certificationId = map1.get("certificationId");
      println("certificationId----------->"+certificationId);
    }
  }
  // Packages.java.lang.System.err.println("================certificationId================="+certificationId);
  if (isNotNull(certificationId)) {
    certificationId = ";"+certificationId
    var arrto = splitText(certificationId, ";");
    var process = getDocumentProcess();
    var tenant_user_id = ""


    for (var i = 0; i < arrto.length; i++) {
      println("id是"+arrto[i]);
      //Packages.java.lang.System.err.println("================arrto[i]================="+arrto[i]);
      if(arrto[i].indexOf("__gUvCL35mg8TQJmmdaFE") != -1){
        var certificationDoc = findDocument(arrto[i]);
        var confirmDate = certificationDoc.findItem("date").getValue();
        var docid=certificationDoc.getId();
        var name = certificationDoc.findItem("name").getValue();
        var certificateNO = certificationDoc.findItem("certificateNO").getValue();
        var idCardNo = certificationDoc.findItem("idCardNo").getValue();
        var date = certificationDoc.findItem("date").getValue();
        var userSql = "select t.id from obpm2.tenant_user_credentials duc inner join obpm2.tenant_users t on `duc`.`id` = `t`.`selected_credential_id` where duc.number = '"+idCardNo+"'";
        var datasuser = queryByDSName("obpm2", userSql);
        if (datasuser.size() > 0) {
          for (var iteratoruser = datasuser.iterator(); iteratoruser.hasNext();) {
            var map1 = iteratoruser.next();//取值
            tenant_user_id = map1.get("id");
          }
        }
        var types="8";
        var types2= "2";
        //Packages.java.lang.System.err.println("================tenant_user_id================="+tenant_user_id);
        if(isNotNull(tenant_user_id)&&isNotNull(name)&&isNotNull(certificateNO)&&isNotNull(idCardNo)&&isNotNull(confirmDate)){
          var insertsql=''
          var insertsql2=''
          println("confirmDate------------"+confirmDate)
         /* if(isNotNull(confirmDate)){
            confirmDate = confirmDate+" 00:00:00"
            confirmDate = new Date(Date.parse(confirmDate));
            println("confirmDate1111111111111"+confirmDate)
            confirmDate = format(confirmDate,"yyyy-MM-dd HH:mm:ss"); 
            println("confirmDate2222222222222"+confirmDate)
          }*/
          println("date------------"+date)
          
          insertsql="insert into obpm2.tenant_user_credentials (created_time,name,selected,id,tenant_user_id,credential_type,number,valid_date_to,valid_date_from,address) values('"+confirmDate+"','"+name+"','0', REPLACE ( '"+docid+"', '__gUvCL35mg8TQJmmdaFE', '__jlNfVcjppSliMYH6FkJ' ),'"+tenant_user_id+"','"+types+"','"+certificateNO+"','9999-12-31','"+date+"','北京市人力资源和社会保障局')"
         
          insertsql2="INSERT INTO obpm2.tenant_user_credential_details (areacode, certificateType,create_time,id, xm, active, idnum, zsbh, fzrq, fzjgmc, state,appraisalGrade) VALUES ('110000',  '"+types2+"','"+confirmDate+"', REPLACE ('"+docid+"', '__gUvCL35mg8TQJmmdaFE', '__jlNfVcjppSliMYH6FkJ' ), '"+name+"', '1' , '"+idCardNo+"','"+certificateNO+"','"+confirmDate+"', '北京市公安局', '1','' )"
          
        }
        println("进来插入语句----------->"+insertsql);
        println("进来插入语句2----------->"+insertsql2);
        insertByDSName("obpm2",insertsql);
         println("第一个insert成功！！！！！！！！")
        insertByDSName("obpm2",insertsql2);
        println("第二个insert成功！！！！！！！！")
        
        //Packages.java.lang.System.err.println("================进来插入语句================="+insertsql);
        certificationDoc.findItem("synchronize").setValue('2');
        println("----------->"+certificationDoc);
        //Packages.java.lang.System.err.println("================certificationDoc================="+certificationDoc);
        process.doUpdate(certificationDoc);
      }
      else{
        certificationDoc.findItem("synchronize").setValue('2');
        process.doUpdate(certificationDoc);
        //Packages.java.lang.System.err.println("==================进else==============="+certificationDoc);
      }
    }
  } 
  //Packages.java.lang.System.err.println("================证书同步至智能人事结束=================");
})()]]></taskScript>
  <modifyTime>2022-07-23T10:10:05.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>