package com.hzya.frame.sysnew.grovy.service.impl;


import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.sysnew.grovy.service.IGroovyIntegrationService;
import com.hzya.frame.util.GroovyUtil;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Groovy 脚本执行实现类
 *
 * @author 👻👻👻👻👻👻👻👻👻👻 gjh
 * @version 1.0
 * @content
 * @date 2024-05-15 13:50
 */
@Service(value = "groovyIntegrationService")
public class GroovyIntegrationServiceImpl implements IGroovyIntegrationService {
    private static final Logger logger = LoggerFactory.getLogger(GroovyIntegrationServiceImpl.class);


    @Override
    public Object groovyScriptExecution(JSONObject jsonObject) {
        Object object = GroovyUtil.execute(jsonObject);
        return object;
    }

    public static void main(String[] args) {
        java.lang.String str = "{\"data\":{\"enablestate\":\"2\",\"user_password\":\"Hzya@1314\",\"gender\":\"12312\",\"user_name\":\"测试用户\",\"modify_time\":1719305835000,\"document_rule_num\":112,\"pk_org\":{\"org_mnecode\":\"1\",\"modify_time\":1718866279000,\"document_rule_num\":4,\"add_status\":\"0\",\"org_address\":\"1\",\"delete_status\":\"1\",\"org_innercode\":\"1\",\"id\":\"f7a8cee35fce4aa8ab266b3c7f125d7d\",\"data_status\":\"F\",\"modify_user_id\":\"1\",\"org_name\":\"开发部\",\"sorts\":4,\"document_rule\":\"ZZ-2024-06-20-00004\",\"create_user_id\":\"1\",\"create_time\":1718864103000,\"company_id\":\"Y\",\"org_memo\":\"1\",\"update_status\":\"0\",\"sts\":\"Y\",\"org_tel\":\"1\",\"org_id\":\"Y\",\"org_ncindustry\":\"1\",\"org_fatherorg\":\"c4913dde8da142bab4206fc084269382\",\"org_code\":\"003\",\"org_principal\":\"1\",\"org_countryzone\":\"1\"},\"add_status\":\"0\",\"pwdlevelcode\":\"\",\"user_type\":\"1\",\"user_code\":\"17633965916\",\"delete_status\":\"1\",\"id\":\"d99fe4e1c211450a960f7a1057da0d2c\",\"data_status\":\"F\",\"modify_user_id\":\"1\",\"sorts\":346,\"document_rule\":\"YH-2024-06-25-00112\",\"create_user_id\":\"1\",\"create_time\":1719305229000,\"company_id\":\"Y\",\"user_code_q\":\"KP003\",\"format\":\"ZH-CN\",\"mobile\":\"123123\",\"identityverifycode\":\"静态密码验证\",\"islocked\":\"N\",\"update_status\":\"0\",\"base_doc_type\":\"0\",\"sts\":\"Y\",\"login_name\":\"123123\",\"pwdparam\":\"2024-06-17\",\"org_id\":\"Y\",\"abledate\":\"2024-06-17 00:00:00\",\"isca\":\"Y\",\"contentlang\":\"ZH\"},\"query\":\"[]\",\"header\":\"[{\\\"parameterType\\\":\\\"fundamental\\\",\\\"length\\\":\\\"100\\\",\\\"index\\\":0,\\\"description\\\":\\\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA87rrNR\\\",\\\"concreteType\\\":\\\"String\\\",\\\"id\\\":\\\"7127798c-b731-453a-b3ac-cfe9033eeace\\\",\\\"parameterName\\\":\\\"pubKey\\\",\\\"required\\\":true,\\\"example\\\":\\\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA87rrNREgMNeOEOwlvM2iqqEfshDadRHziDSB2PbRnoMqSv1nGr3XBlZuseNj5HmxDEkLhOdfyw0yjzoz3wK7XhFpeN4Iyf7NT7hps5jAQMEpnul9Qwmj5qUr/eK5SaO9H8n7sh9BvCdrX9oRUh+U2/ceA3O+y/MUHk5DRvSadc8FhpqbOaNBbAzPnyYAwpVUPvaJ90jcGN1ZG99HR1GEzC+Cn9s6vgt7dYL6ysMs36bSP47xraDSxpfr0CLwa6JV/9KjLIeqL1ZaMtK0CJ1zJGCBA6O6kgxeE9Ul7q2lSS6mPAEJ78izaTYsrjhLpKT+eTtFBOLFbiCrbLp8tVE5kwIDAQAB\\\"},{\\\"parameterType\\\":\\\"fundamental\\\",\\\"length\\\":\\\"50\\\",\\\"index\\\":1,\\\"description\\\":\\\"OA\\\",\\\"concreteType\\\":\\\"String\\\",\\\"id\\\":\\\"7f965281-df0f-4d2f-b005-07e061fcde49\\\",\\\"parameterName\\\":\\\"client_id\\\",\\\"required\\\":true,\\\"example\\\":\\\"OA\\\"},{\\\"parameterType\\\":\\\"authport\\\",\\\"length\\\":\\\"50\\\",\\\"index\\\":2,\\\"concreteType\\\":\\\"String\\\",\\\"id\\\":\\\"cbc0e105-17c0-4385-8863-8903303edc1f\\\",\\\"parameterName\\\":\\\"access_token\\\",\\\"example\\\":[\\\"attribute\\\",\\\"data\\\",\\\"access_token\\\"]}]\",\"body\":\"[{\\\"index\\\":0,\\\"id\\\":\\\"beeedbc6-24c2-4093-9a5e-20fced9fb1b4\\\",\\\"parameterName\\\":\\\"body\\\",\\\"first\\\":true}]\"}";
        A88772 s = new A88772();
        s.execute(str);
    }

    static class A88772 {
        String execute(String jsonStr) {
            com.alibaba.fastjson.JSONObject returnObject = new com.alibaba.fastjson.JSONObject();
            com.alibaba.fastjson.JSONObject bodys = new com.alibaba.fastjson.JSONObject();

            com.alibaba.fastjson.JSONObject reqData = com.alibaba.fastjson.JSON.parseObject(jsonStr);
            com.alibaba.fastjson.JSONObject data = reqData.getJSONObject("data");
            com.alibaba.fastjson.JSONObject ufinterfaceObject = new com.alibaba.fastjson.JSONObject();
            ufinterfaceObject.put("billtype", "customer");
            ufinterfaceObject.put("isexchange", "Y");
            ufinterfaceObject.put("replace", "Y");
            ufinterfaceObject.put("sender", "openUser");
            ufinterfaceObject.put("account", "ycjf");
            ufinterfaceObject.put("groupcode", "ycjf");
            com.alibaba.fastjson.JSONObject billObject = new com.alibaba.fastjson.JSONObject();
            com.alibaba.fastjson.JSONObject billheadObject = new com.alibaba.fastjson.JSONObject();
            billheadObject.put("code", data.get("code"));
            billheadObject.put("custprop", data.get("custprop"));
            billheadObject.put("custstate", data.get("custstate"));
            billheadObject.put("pk_custclass", data.get("pk_custclass"));
            billheadObject.put("pk_country", data.get("pk_country"));
            billheadObject.put("pk_timezone", "P0800");
            billheadObject.put("pk_format", "ZH-CN");
            billheadObject.put("enablestate", data.get("enablestate"));
            billheadObject.put("name", data.get("name"));
            billheadObject.put("pk_group", data.get("pk_group"));
            billheadObject.put("pk_org", data.get("pk_org"));
            billheadObject.put("taxpayerid", data.get("taxpayerid"));
            billObject.put("billhead", billheadObject);
            ufinterfaceObject.put("bill", billObject);
            bodys.put("ufinterface", ufinterfaceObject);
            returnObject.put("bodys",bodys.toJSONString());
            return returnObject.toJSONString();





        }
    }


}
