编辑代码

//JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。

import groovy.util.XmlSlurper;
import groovy.json.JsonSlurper

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


def xmlstr='''<?xml version="1.0" encoding="UTF-8"?>
<serviceResult><interface code='2151' successFlag='1' callMessage='查询已订购的附属_gzcrm(2151):1'><![CDATA[[{"prodUseType":"1000","offerSysType":"1200","offerName":"5G体验10元副卡功能费201907","isIndependent":"0","rstrFlag":"MUST","statusCd":"1000","lanId":8520100,"prodId":2339,"ownerCustId":511011930139,"expDate":"2040-05-17 15:39:18","offerType":"12","createOrgId":100075955,"effDate":"2020-05-17 15:39:18","offerDesc":"1.月功能费:10元/月/张,送来电显示及天翼云盘-免费版+189邮箱-免费版。\n2.生效规则及资费规则:副卡办理后立即生效,首月功能费按天折算,生效后即可共享主卡基础套餐内容。\n3.共享范围:主卡套餐内的流量和语音,主卡套餐外资费。\n4.原乐享/乐享家/飞Young主副卡用户:可变更为畅享套餐主副卡,副卡功能费及相关规则按照畅享套餐执行。\n5.停机保号/挂失停机:主副卡可以单独申请“停(复)机保号”、“挂失停(复)机”,同普通号码申请停复机流程;具体按照中国电信市场〔2014〕52号--《关于优化4G移动业务停、复机及上网卡套餐规则的通知》执行。\n6.信控/欠费停机:主卡“信控/欠费停(复)机”时,副卡进行关联停复机。","isNeedResRela":"0","regionId":8520103,"statusName":"有效","offerId":720013104,"ownerCustName":"李雨农","prodInstId":514117694778,"expProcMethod":"20","offerInstId":513115301074,"offerInstAttr":[],"createDate":"2019-08-17 10:33:03"},{"prodUseType":"1000","offerSysType":"1200","offerName":"CDMA-副卡当月保障套餐","isIndependent":"0","rstrFlag":"DEFAULT","statusCd":"1000","lanId":8520100,"prodId":2339,"ownerCustId":511011930139,"expDate":"2040-05-01 00:00:00","offerType":"13","createOrgId":100075955,"effDate":"2020-05-01 00:00:00","offerDesc":"资费政策:\n1.国内手机上网每500M_天_1元收费,以此叠加收费,600元封顶_月。\n2.国内语音按照0.15元_分钟收取。\n3.国内短信_彩信按照0.10元_条收取。\n4.全国接听免费。国内仅指中国大陆境内,不包含港澳台地区。\n5.副卡订购,仅用于主套餐未生效时新装副卡使用收费,订购副卡该资费立即生效。主套餐生效后该资费失效","isNeedResRela":"0","regionId":8520103,"statusName":"有效","offerId":700021953,"ownerCustName":"李雨农","prodInstId":514117694778,"expProcMethod":"20","offerInstId":513115301076,"offerInstAttr":[],"createDate":"2019-08-17 10:33:03"},{"prodUseType":"1000","offerSysType":"1200","offerName":"5G网络权益升级包(黄金会员)201910","isIndependent":"0","rstrFlag":"DEFAULT","statusCd":"1000","lanId":8520100,"prodId":2339,"ownerCustId":511011930139,"expDate":"2040-05-17 15:39:18","offerType":"12","createOrgId":100075955,"effDate":"2020-05-17 15:39:18","offerDesc":"(一)资费内容\n月费:0元,短信订购/退订编码:5GWLSJ/TD5GWLSJ。\n(二)适用范围\n适用于订购了5G畅享套餐和5G升级包的套餐内,除了订购黄金会员的号卡外,其他号卡订购。\n(三)使用规则\n订购后号卡可享受套餐可升级的对应档位会员的速率。\n(四)其它规则\n1.生效规则:订购立即生效,月底自动续订。\n2.变更、退订:次月生效。\n3.续约规则:5G升级会员副卡提速包资费有效期2年,到期时中国电信可以调整相关资费内容,如双方无异议自动续约2年。\n4.受理渠道:实体渠道、电子渠道、短厅\n5.受理系统:集约CRM系统(含集团能力开放),集团电子渠道。","isNeedResRela":"0","regionId":8520103,"statusName":"有效","offerId":85201402,"ownerCustName":"李雨农","prodInstId":514117694778,"expProcMethod":"20","offerInstId":513115301078,"offerInstAttr":[],"createDate":"2019-10-30 21:59:11"},{"prodUseType":"1000","offerSysType":"1200","offerName":"5G畅享副卡功能费1元","isIndependent":"0","rstrFlag":"OPTIONAL","statusCd":"1000","lanId":8520100,"prodId":2339,"ownerCustId":511011930139,"expDate":"2043-02-01 00:00:00","offerType":"12","createOrgId":2100051040,"effDate":"2023-02-01 00:00:00","offerDesc":"一、优惠内容\n优惠内容:每月减免副卡月功能费9元,实收1元;\n二、业务规则\n1.适用范围:仅对5G畅享系列套餐订购,与5G体验10元副卡功能费201907搭配销售。\n2.生失效规则:新用户立即生效,老用户次月生效,退订或变更次月生效;\n3.可选包:仅副卡可订购。","isNeedResRela":"0","regionId":8520102,"statusName":"有效","offerId":85203519,"ownerCustName":"李雨农","prodInstId":514117694778,"expProcMethod":"20","offerInstId":513169957285,"offerInstAttr":[],"createDate":"2020-05-06 15:48:04"}]]]></interface>
<interface code='2139' successFlag='1' callMessage='查询接入产品实例信息_gzkf(2139):1'><![CDATA[[{"prodUseType":"1000","statusDate":"2024-05-04 15:53:20","updateDate":"2024-10-02 17:11:49","accProdInstId":514117694778,"prodId":2339,"lanId":8520100,"useCustId":511018346764,"stopRentDate":"3000-01-01 00:00:00","paymentModeCd":"1201","prodInstAttrs":[{"statusDate":"2021-09-26 07:10:25","updateDate":"2022-01-12 19:30:59","dataVerNum":0,"attrValueId":2021082502,"statusCd":"1000","remark":"GY GEJ OLD_REGION_ID:8520102","parProdInstAttrId":-1,"attrValueName":"黄金会员","createStaff":-1,"attrId":2021082501,"prodInstId":514117694778,"attrValue":"8","prodInstAttrId":5110056101550,"attrName":"5QI","createDate":"2021-09-26 07:10:25","updateStaff":-1,"lastOrderItemId":-1},{"updateDate":"2024-10-02 17:11:49","dataVerNum":0,"statusCd":"1000","remark":"GY GEJ OLD_REGION_ID:8520102","parProdInstAttrId":-1,"createStaff":110098570,"attrId":851016,"prodInstId":514117694778,"attrValue":"511018346764","prodInstAttrId":5111000015724895,"attrName":"用户经办人客户ID","createDate":"2020-05-17 15:39:20","updateStaff":110098570,"lastOrderItemId":510527268970},{"updateDate":"2024-10-02 17:11:49","dataVerNum":0,"statusCd":"1000","remark":"GY GEJ OLD_REGION_ID:8520102","parProdInstAttrId":-1,"createStaff":110098570,"attrId":851017,"prodInstId":514117694778,"attrValue":"CRM3_51202410020165341482_17385854672_60_4040001117","prodInstAttrId":5111000015724896,"attrName":"用户经办人照片路径","createDate":"2020-05-17 15:39:20","updateStaff":110098570,"lastOrderItemId":510527268970},{"statusDate":"2020-05-17 15:38:10","updateDate":"2022-01-12 19:30:59","dataVerNum":0,"attrValueId":5002126710,"statusCd":"1000","remark":"GY GEJ OLD_REGION_ID:8520102","parProdInstAttrId":-1,"attrValueName":"普通卡","createStaff":110098570,"attrId":50021267,"prodInstId":514117694778,"attrValue":"10","prodInstAttrId":5111000015858418,"attrName":"实名登记类型","createDate":"2020-05-17 15:38:26","updateStaff":110098570,"lastOrderItemId":510098667348},{"statusDate":"2020-05-17 15:38:10","updateDate":"2022-01-12 19:30:59","dataVerNum":0,"attrValueId":5110005460,"statusCd":"1000","remark":"GY GEJ OLD_REGION_ID:8520102","parProdInstAttrId":-1,"attrValueName":"普通用户","createStaff":110098570,"attrId":511000546,"prodInstId":514117694778,"attrValue":"0","prodInstAttrId":5111000015858429,"attrName":"资费类型","createDate":"2020-05-17 15:38:26","updateStaff":110098570,"lastOrderItemId":510098667348}],"prodName":"CDMA","statusName":"在用","prodInstRels":[],"prodInstStates":[],"createDate":"2020-05-17 15:38:26","prodInstAccRels":[{"statusDate":"2020-05-17 15:38:10","updateDate":"2022-01-12 18:53:32","prodInstAcctRelId":5111000005051822,"acctId":517101497769,"statusCd":"1","ifDefaultAcctId":1,"priority":1,"ownerCustId":511011930139,"expDate":"3000-01-01 00:00:00","createStaff":110098570,"paymentLimitType":1,"acctItemGroupId":0,"effDate":"2020-05-17 15:38:26","prodInstId":514117694778,"createDate":"2020-05-17 15:38:26","updateStaff":110098570}],"accNum":"17385854672","prodInstContacts":[],"beginRentDate":"2020-05-17 15:39:18","firstFinishDate":"2020-05-17 15:39:18","statusCd":"100000","ownerCustId":511011930139,"prodInstAccNums":[{"accNum":"17385854672","platId":-1,"applyRegionId":8520102,"prodInstId":514117694778,"accNumType":"1000","prodInstAccNumId":5111000004383327}],"createStaff":110098570,"devStaffInfos":[{"devStaffInfoId":5111000016558152,"devStaffType":"1000","objId":514117694778,"statusCd":"1000","objType":"120000","devStaffId":110098570,"devOrgId":100075955}],"createOrgId":100075955,"regionId":8520103,"prodInstId":514117694778,"updateStaff":-10001}]]]></interface>
<interface code='2124' successFlag='1' callMessage='销售品(主套餐)实例查询_gzcrm(2124):1'><![CDATA[[{"offerSysType":"1600","offerName":"5G畅享169元套餐201910","isIndependent":"1","statusCd":"1000","lanId":8520100,"offerProdInstRel":[{"accNum":"17385636051","roleId":51393,"offerProdRelId":70074004,"relType":"1000","statusCd":"1000","prodId":2339,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2040-05-17 15:39:24","effDate":"2020-05-17 15:39:24","regionId":8520103,"roleName":"CDMA主卡","statusName":"有效","prodInstId":514117694779,"offerProdInstRelId":516118499356,"offerInstId":513115301067},{"accNum":"17385854672","roleId":51394,"offerProdRelId":70074003,"relType":"1000","statusCd":"1000","prodId":2339,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2040-05-17 15:39:24","effDate":"2020-05-17 15:39:24","regionId":8520103,"roleName":"CDMA副卡","statusName":"有效","prodInstId":514117694778,"offerProdInstRelId":516118499357,"offerInstId":513115301067},{"accNum":"17385814251","roleId":51394,"offerProdRelId":70074003,"relType":"1000","statusCd":"1000","prodId":2339,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2040-05-17 15:39:24","effDate":"2020-05-17 15:39:24","regionId":8520103,"roleName":"CDMA副卡","statusName":"有效","prodInstId":514117694774,"offerProdInstRelId":516118499358,"offerInstId":513115301067},{"accNum":"085150558656","roleId":51275,"offerProdRelId":70074342,"relType":"1000","statusCd":"1000","prodId":13748,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2040-05-17 15:39:24","effDate":"2020-05-17 15:39:24","regionId":8520103,"roleName":"宽带","statusName":"有效","prodInstId":514117694775,"offerProdInstRelId":516118499359,"offerInstId":513115301067,"account":"085150558656"},{"accNum":"085150558656@iptv","roleId":51396,"offerProdRelId":70074344,"relType":"1000","statusCd":"1000","prodId":14114,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2040-05-17 15:39:24","effDate":"2020-05-17 15:39:24","regionId":8520103,"roleName":"IPTV","statusName":"有效","prodInstId":514117694777,"offerProdInstRelId":516118499360,"offerInstId":513115301067,"account":"085150558656@iptv"},{"accNum":"ZNJJ8520102005315120","roleId":51413,"offerProdRelId":70078315,"relType":"1000","statusCd":"1000","prodId":6600552,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2040-05-17 15:39:24","effDate":"2023-01-14 12:23:52","regionId":8520103,"roleName":"智能家居","statusName":"有效","prodInstId":514178743972,"offerProdInstRelId":516209266673,"offerInstId":513115301067},{"accNum":"ZNJJ8520102005315172","roleId":51414,"offerProdRelId":70078316,"relType":"1000","statusCd":"1000","prodId":6600552,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2040-05-17 15:39:24","effDate":"2023-01-14 12:23:36","regionId":8520103,"roleName":"加装智能家居","statusName":"有效","prodInstId":514178743975,"offerProdInstRelId":516209266674,"offerInstId":513115301067},{"accNum":"17308514797","roleId":51394,"offerProdRelId":70074003,"relType":"1000","statusCd":"1000","prodId":2339,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2040-05-17 15:39:24","effDate":"2023-02-01 00:00:00","regionId":8520103,"roleName":"CDMA副卡","statusName":"有效","prodInstId":514117694782,"offerProdInstRelId":516209266675,"offerInstId":513115301067},{"accNum":"17385516973","roleId":51394,"offerProdRelId":70074003,"relType":"1000","statusCd":"1000","prodId":2339,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2040-05-17 15:39:24","effDate":"2023-02-01 00:00:00","regionId":8520103,"roleName":"CDMA副卡","statusName":"有效","prodInstId":514117694783,"offerProdInstRelId":516209266676,"offerInstId":513115301067}],"ownerCustId":511011930139,"expDate":"2040-05-17 15:39:24","createStaff":110098570,"offerType":"11","createOrgId":100075955,"effDate":"2020-05-17 15:39:24","offerDesc":"一、销售品内容\n(一)套餐方案\n1.档位:169元,流量:40GB,语音:800分钟,套外流量:3元/GB。\n2.融合优惠规则:一个5G畅享169元套餐可以叠加一条300M(条件具备的区域可提速到1000M)主宽带和一条300M副宽带(两条宽带仅异址可装)、二路天翼高清、一部固定电话组成分享计划,第一条宽带与本套餐手机捆绑使用期内可享受免费使用优惠,第二条宽带、二路天翼高清按照现行融合宽带资费标准收取。\n(二)资费说明\n1.国内接听免费,赠送来电显示和天翼云盘-免费版+189邮箱-免费版。\n2.套餐超出资费:\n(1)前100MB按0.03元/MB收费,达到100MB(3元)时,额外赠送用户924MB流量(即3元/1GB);流量超过1GB时,仍按上述原则(即每超出1GB按照3元/1GB收费)收费,以此类推。\n(2)国内通话:当月国内通话超出对应套餐档位所包含分钟数后,按国内0.15元/分钟计收,不足1分钟按1分钟计。\n(3)国内短/彩信:0.1元/条。\n(三)副卡资费说明\n1.允许办理副卡。\n2.月功能费:10元/月/张,送来电显示及天翼云盘-免费版+189邮箱-免费版。最多可办理4张副卡。\n3.生效规则及资费规则:副卡办理后立即生效,首月功能费按天折算,生效后即可共享主卡基础套餐内容。\n4.共享范围:主卡套餐内的流量和语音,主卡套餐外资费。\n5.原乐享/乐享家/飞Young/畅享主副卡用户:可变更为5G畅享套餐主副卡,副卡功能费及相关规则按照5G畅享套餐执行。\n6.停机保号/挂失停机:主卡申请停机保号,副卡和可选成员均需停机保号或者迁转为独立套餐;副卡和可选成员申请停机保号,主卡不受影响。\n7.信控/欠费停机:主卡信控/欠费停(复)机时,副卡和可选成员进行关联停复机。\n(四)其他资费说明\n1.国内通话和接听免费范围不包括港澳台地区和拨打信息台服务电话产生的费用。\n2.手机上网流量仅限中国大陆境内使用,只适用于中国电信现有移动通信网络,不含WLAN(Wi-Fi)上网。\n3.适用于流量不清零规则。\n4.适用于预付费和后付费用户。\n5.可订购语音和短信等加装包,可订购流量加装包;不可订购流量提速包。\n6.可订购电信畅享合约;不可订购乐享4G合约。\n7.套餐迁转规则:5G畅享套餐可迁转至其他在售4G、5G套餐。其他套餐用户也可迁转至本文内套餐,次月生效。\n8. 上网当月套餐外流量消费600元及600元的倍数则断网,次月初自动开通,如果客户当月申请继续使用,则继续提供服务,按照套外资费收费。套餐外流量消费费用包含按套餐外资费收取的上网流量费,不含用户订购的定 向、闲 时等各种流量包功能费。\n二、其他规则\n(一)生效规则\n1.新老用户均可订购,新用户订购立即生效,首月执行过渡期资费。老用户订购次月生效。\n过渡期资费:订购当月套餐月基本费按日折算(入网当日到月底),费用四舍五入到分,一次性收取;套餐订购当月套餐月基本费按日折算(入网当日到月底),费用四舍五入到分,一次性收取;套餐内容(语音、流量)按照对应流量和分钟数按天折算,四舍五入到分钟(MB)\n2.变更、退订:次月生效。\n(二)续约规则\n套餐资费的有效期为2年,到期时中国电信可调整相关资费内容,如双方无异议自动续约2年。\n(三)受理系统\n集约CRM系统(含集团能力开放)、集团电子渠道。","isNeedResRela":"0","regionId":8520103,"statusName":"有效","offerId":85201034,"ownerCustName":"李雨农","offerObjInstRel":[],"expProcMethod":"20","offerInstId":513115301067,"offerInstAttr":[],"createDate":"2019-10-11 19:16:31"},{"offerSysType":"1200","offerName":"5G畅享套餐流量体验包-增强版","isIndependent":"1","statusCd":"1000","lanId":8520100,"offerProdInstRel":[{"accNum":"17385636051","roleId":51393,"offerProdRelId":70079966,"relType":"1000","statusCd":"1000","prodId":2339,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2043-01-11 15:44:24","effDate":"2023-01-11 15:44:24","regionId":8520102,"roleName":"CDMA主卡","statusName":"有效","prodInstId":514117694779,"offerProdInstRelId":516209266697,"offerInstId":513169957297},{"accNum":"17385854672","roleId":51394,"offerProdRelId":70079967,"relType":"1000","statusCd":"1000","prodId":2339,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2043-01-11 15:44:24","effDate":"2023-01-11 15:44:24","regionId":8520102,"roleName":"CDMA副卡","statusName":"有效","prodInstId":514117694778,"offerProdInstRelId":516209266698,"offerInstId":513169957297},{"accNum":"17308514797","roleId":51394,"offerProdRelId":70079967,"relType":"1000","statusCd":"1000","prodId":2339,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2043-01-11 15:44:24","effDate":"2023-01-11 15:44:24","regionId":8520102,"roleName":"CDMA副卡","statusName":"有效","prodInstId":514117694782,"offerProdInstRelId":516209266699,"offerInstId":513169957297},{"accNum":"17385516973","roleId":51394,"offerProdRelId":70079967,"relType":"1000","statusCd":"1000","prodId":2339,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2043-01-11 15:44:24","effDate":"2023-01-11 15:44:24","regionId":8520102,"roleName":"CDMA副卡","statusName":"有效","prodInstId":514117694783,"offerProdInstRelId":516209280200,"offerInstId":513169957297},{"accNum":"17385814251","roleId":51394,"offerProdRelId":70079967,"relType":"1000","statusCd":"1000","prodId":2339,"lanId":8520100,"prodFuncType":"101","ownerCustId":511011930139,"expDate":"2043-01-11 15:44:24","effDate":"2023-01-11 15:44:24","regionId":8520102,"roleName":"CDMA副卡","statusName":"有效","prodInstId":514117694774,"offerProdInstRelId":516209280201,"offerInstId":513169957297}],"ownerCustId":511011930139,"expDate":"2043-01-11 15:44:24","createStaff":321043016,"offerType":"13","createOrgId":2100051040,"effDate":"2023-01-11 15:44:24","offerDesc":"一、资费内容\n(一)优惠条件:5G畅享129元及以上套餐,叠加4张副卡用户;月基本费:0元;国内流量:40GB。\n(二)仅对电信公司活动指定用户参与订购。\n(三)过渡期资费:订购当月按天折算一次性收费,流量包内流量按天折算一次性赠送。\n二、适用范围\n(一)适用于中国电信办理5G畅享129元及以上档次套餐用户。\n(二)仅主卡可订购,副卡可分享主卡订购的包月流量包内业务量。\n三、包内业务使用规则\n(一)国内流量只适用于中国电信现有移动通信网络,限在中国大陆境内(不含港澳台地区)使用,不含WLAN(wi-fi)上网。\n(二)流量抵扣顺序\n定 向流量包、畅享视频流量包、赠送闲 时流量、闲 时流量包、非账单支付假日流量包、1天流量包、3天流量包、7天流量包、30天流量包、畅聊流量包、后向全国流量月包、赠送全国流量、套餐内全国流量、非账单支付流量加餐包、流量加餐包、包月流量包、后向全国流量季包、非账单支付季/半年/年包流量、季/半年/年包流量、畅享升级包、畅享提速包,超出后执行套外流量资费,各省根据省内实际情况微调。\n(三)包月流量包的包内流量及月功能费,不计入套餐外流量封顶及费用封顶值计算。\n(四)仅主卡可订购,副卡可分享主卡订购的包月流量包内业务量。\n(五)不适用于流量不清零规则。\n四、其他规则\n(一)生效规则:新、老用户订购立即生效,变更或退订次月生效。订购当月功能费按日计扣(入网当日到月底),费用四舍五入到分;包内流量按天折算,流量向上取整到MB。\n(二)续约规则:包月流量包资费有效期为24个月,到期时中国电信可调整相关资费内容,如双方无异议自动续约2年。\n(三)依赖关系:5G畅享129元及以上套餐。\n(四)受理渠道:用户通过营业厅(纸质协议)、翼销售(电子协议)受理。\n(五)受理系统:集团集约CRM系统(含能力开放)。\n(六)生效规则:新、老用户订购立即生效(2023-02-15修改为老用户订购次月生效)。\n(七)生效规则:新、老用户订购立即生效(2023-03-21修改为新、老用户订购立即生效)。","isNeedResRela":"0","regionId":8520102,"statusName":"有效","offerId":85207704,"ownerCustName":"李雨农","offerObjInstRel":[],"expProcMethod":"20","offerInstId":513169957297,"offerInstAttr":[],"createDate":"2021-10-19 15:14:45"}]]]></interface>
<interface code='2136' successFlag='1' callMessage='城乡标识查询_gzcrm(2136):1'><![CDATA[{"msg":"未查询到数据!"}]]></interface>
<interface code='2109' successFlag='1' callMessage='号码归属地查询-gzkf(2109):1'><![CDATA[{"regionId":8520100,"regionName":"贵阳市"}]]></interface>
<interface code='2108' successFlag='1' callMessage='客户信息查询_gzkf(2108):1'><![CDATA[[{"serviceGrade":[],"occupation":"不便分类的其他从业人员","secrecyLevel":"1000","specialList":[],"isRealname":1,"extCustId":"998500240005679337","contactAddr":"贵州省贵阳市南明区小碧乡黄泥哨村二组12","custId":511011930139,"custNumber":"3851249890750000","custContactsInfoRel":[{"headFlag":1,"contactId":511014347813,"custId":511011930139,"custConnectId":511021000571,"statusCd":"1000","contactsInfos":[{"statusDate":"2016-08-24 10:02:57","contactId":511014347813,"contactName":"李雨农","contactAddr":"贵州省贵阳市南明区小碧乡黄泥哨村二组12","homePhone":"0","postAddr":"贵州省贵阳市南明区小碧乡黄泥哨村二组12","contactType":"1","partyId":511011930139,"contactGender":"4"}]}],"partyId":511011930139,"custBrand":[{"statusDate":"2016-08-25 02:25:49","brandId":1500,"custId":511011930139,"custBrandId":511028898535,"mainFlag":1}],"taxPayerInfo":[],"contactName":"李雨农","isInstead":0,"homePhone":"0","postAddr":"贵州省贵阳市南明区小碧乡黄泥哨村二组12","custAddr":"贵州省贵阳市南明区小碧乡黄泥哨村二组12","custAttr":[{"updateDate":"2016-08-25 02:25:49","attrId":40128,"custAttrId":511342100507,"custId":511011930139,"attrValue":"0","attrName":"客户子品牌","createDate":"2016-08-25 02:25:49"},{"updateDate":"2016-08-25 02:25:49","attrId":40127,"custAttrId":511342100508,"custId":511011930139,"attrValue":"203","attrName":"子群属性","createDate":"2016-08-25 02:25:49"},{"updateDate":"2016-08-24 10:02:57","attrId":40129,"custAttrId":511373406900,"custId":511011930139,"attrValue":"1","attrName":"客户类别码","createDate":"2016-08-24 10:02:57"},{"updateDate":"2016-08-24 10:02:57","attrId":40104,"custAttrId":511373406901,"custId":511011930139,"attrValue":"贵州省贵阳市南明区小碧乡黄泥哨村二组12","attrName":"客户英文名","createDate":"2016-08-24 10:02:57"},{"updateDate":"2016-08-24 10:02:57","attrId":1,"custAttrId":511373406902,"custId":511011930139,"attrValue":"0","attrName":"联系电话1","createDate":"2016-08-24 10:02:57"},{"updateDate":"2016-08-24 10:02:57","attrId":1000001,"custAttrId":511374350777,"custId":511011930139,"attrValue":"0","attrName":"一般纳税人标识","createDate":"2016-08-24 10:02:57"},{"updateDate":"2016-08-24 10:02:57","attrId":123101554,"custAttrId":511374350778,"custId":511011930139,"attrValue":"110086343","attrName":"受理员工","createDate":"2016-08-24 10:02:57"},{"updateDate":"2016-08-24 10:02:57","attrId":123101555,"custAttrId":511374350779,"custId":511011930139,"attrValue":"100030125","attrName":"受理渠道","createDate":"2016-08-24 10:02:57"},{"updateDate":"2023-04-02 08:48:01","attrId":40132,"custAttrId":5111000002270716,"custId":511011930139,"attrValue":"3400","attrName":"客户星级","createDate":"2020-06-03 06:56:55"}],"deputyNumber":"17385854672","custName":"李雨农","partyCert":[{"isRealnameCert":"10","isDefault":"1","certType":"1","effDate":"2019-08-17 19:01:52","certAddr":"贵州省贵阳市南明区小碧乡黄泥哨村二组12","partyCertId":511012626581,"statusCd":"1000","partyId":511011930139,"certNum":"520111200305272115"}],"enterDate":"2016-08-24 10:02:57","partyAttr":[{"statusDate":"2016-08-25 02:25:49","attrId":40128,"partyAttrId":511099780161,"attrValue":"0","partyId":511011930139,"attrName":"客户子品牌"},{"statusDate":"2016-08-25 02:25:49","attrId":40127,"partyAttrId":511099780166,"attrValue":"203","partyId":511011930139,"attrName":"子群属性"},{"statusDate":"2016-08-24 10:02:57","attrId":40129,"partyAttrId":511122031417,"attrValue":"1","partyId":511011930139,"attrName":"客户类别码"},{"statusDate":"2016-08-24 10:02:57","attrId":40104,"partyAttrId":511122031418,"attrValue":"贵州省贵阳市南明区小碧乡黄泥哨村二组12","partyId":511011930139,"attrName":"客户英文名"},{"statusDate":"2016-08-24 10:02:57","attrId":1,"partyAttrId":511122031419,"attrValue":"0","partyId":511011930139,"attrName":"联系电话1"},{"statusDate":"2016-08-24 10:02:57","attrId":1000001,"partyAttrId":511122893769,"attrValue":"0","partyId":511011930139,"attrName":"一般纳税人标识"},{"statusDate":"2016-08-24 10:02:57","attrId":123101554,"partyAttrId":511122893771,"attrValue":"110086343","partyId":511011930139,"attrName":"受理员工"},{"statusDate":"2016-08-24 10:02:57","attrId":123101555,"partyAttrId":511122893775,"attrValue":"100030125","partyId":511011930139,"attrName":"受理渠道"}],"regionId":8520102,"custType":"1100","custLabel":[],"custOrderId":-1,"contactPhone":"0","party":[{"partyName":"李雨农","remark":"集团客户中上线割接更新ext_party_id","statusCd":"1000","partyNbr":"5222489114486437","partyId":511011930139,"partyType":"1","partyAbbrname":"李雨农"}]}]]]></interface>
<interface code='2126' successFlag='1' callMessage='政企客户识别_gzyx(2126):1'><![CDATA[null]]></interface>
</serviceResult>'''



def jsonSlr4Json = null;
def xmlSlr = new XmlSlurper().parseText(xmlstr);

def jsonSlr1 = xmlSlr.interface.find{node->node.@code=="2108"};
def jsonSlr2 = xmlSlr.interface.find{node->node.@code=="2109"};


def jsonSlr4 = xmlSlr.interface.find{node->node.@code=="2126"};
jsonSlr4Json = new JsonSlurper().parseText("$jsonSlr4");


def jsonSlr5 = xmlSlr.interface.find{node->node.@code=="2139"};
def jsonSlr6 = xmlSlr.interface.find{node->node.@code=="2136"};
def jsonSlr7 = xmlSlr.interface.find{node->node.@code=="2124"};
def jsonSlr8 = xmlSlr.interface.find{node->node.@code=="2151"};

def customers = new JsonSlurper().parseText("$jsonSlr1");
def jsonSlr2Json = new JsonSlurper().parseText("$jsonSlr2");


def jsonSlr5Json = new JsonSlurper().parseText("$jsonSlr5");
def jsonSlr6Json = new JsonSlurper().parseText("$jsonSlr6");
def jsonSlr7Json = new JsonSlurper().parseText("$jsonSlr7");
def jsonSlr8Json = new JsonSlurper().parseText("$jsonSlr8");
//客户ID
def custId="";
//客户姓名
def custName = "";
//联系人姓名
def contactName = "";
//地市ID
def regionId = "";
//证件号码
def certNum = "";
//证件类型
def certType = "";
//用户星级
def userLevel = "";
//客户类别
def custType = ""
//用户品牌
def userBrand = ""
// 用户地址
def custAddr = ""
//客户年龄
def customerAge = ""
//客户性别
def custGender = ""
//计费状态
def prodState = "100000"
//入网时间
def enterDate = "";
//网龄
def internetAge = "";
//重要客户
def importantCustomer = "";
//政企关键人
def goverKeyPerson = "";
//客户经理
def custManager = "";
//客户经理电话
def custManagerPhone = "";
//产品实例ID
def productId = "";
def dxTeleAreaID= "";
//城乡标识
def cityFlag=1;
//已订购的销售品offerId
def crmOfferId = ""
//装机地址
def addressDesc = "";
def addressId= "";
def acctId= "";
def paymentModeCd = "";
def isSafeBrain = "";


if(jsonSlr6Json!=null && jsonSlr6Json.code==null && jsonSlr6Json.site_positiontype!='' && jsonSlr6Json.site_positiontype!=null){
    if(jsonSlr6Json.site_positiontype=="城市"){
        cityFlag=0;
    }else{
        cityFlag=1;
    }
}
def state = ""
def StopStateName = ""

//获取用户地市
if(jsonSlr2Json.regionId){
regionId = jsonSlr2Json.regionId;
}


if(customers instanceof List && customers.size()>0){
    custName = customers[0].custName;
    custId = customers[0].custId;
    contactName = customers[0].contactName;
    custType = customers[0].custType;
    custAddr = customers[0].custAddr;
    //入网时间
    if(customers[0].enterDate==null || customers[0].enterDate.equals("null")){

    }else{
        enterDate = customers[0].enterDate;
    }

    def partyCertList = customers[0].partyCert
    
    println ("customers[0]---------------------------" + customers[0]);
    println ("partyCertList---------------------------" + partyCertList);
    
    
    if(partyCertList instanceof List && partyCertList.size()>0){
        certType = partyCertList[0].certType
        certNum = partyCertList[0].certNum
        // 身份证号
        def idCardNumber = String.valueOf(certNum)
        def patt = '';
        boolean ifID ;
        if(idCardNumber.length()==15){
            patt = '^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$';
        }else if(idCardNumber.length()==18){
            patt = '^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$';
        }
        if(patt.equals("")){
            ifID = false;
        }else{
            Pattern r = Pattern.compile(patt);
            Matcher matcher = r.matcher(idCardNumber);
            ifID = matcher.find();
        }

        if(ifID && idCardNumber.length()==18){
            // 判断性别
            def genderDigit = Integer.parseInt(idCardNumber.substring(16, 17))
            if (genderDigit % 2 == 0) {
                custGender = "2"
            } else {
                custGender = "1"
            }
            // 计算年龄
            def birthDateString = idCardNumber.substring(6, 14)
            def birthDate = new SimpleDateFormat("yyyyMMdd").parse(birthDateString)
            def now = new Date()
            customerAge = now.year - birthDate.year
        }else{
            custGender = "0"
            customerAge = ""
        }
        
    }

    def custBrandList = customers[0].custBrand
    if(custBrandList instanceof List && custBrandList.size()>0){
        userBrand = custBrandList[0].mainFlag
    }

    def custAttrList = customers[0].custAttr
    if(custAttrList instanceof List && custAttrList.size()>0) {
        for (int i = 0; i < custAttrList.size(); i++) { // 使用 .size() 方法获取列表元素个数
            def attrid = custAttrList[i].attrId
            if (attrid == 40132) {
                userLevel = custAttrList[i].attrValue
            }
        }
    }
}

//转换地市编码
def areaCode='0851';
def busiArea = '11';
def userLocation = '11';
if("8520100".equals(regionId)){
    areaCode ='0851';
    busiArea = '1';
    userLocation = '1';
}else if("8520300".equals(regionId)){
    areaCode ='0852';
    busiArea = '2';
    userLocation = '2';
}else if("8520400".equals(regionId)){
    areaCode ='0853';
    busiArea = '3';
    userLocation = '3';
}else if("8522700".equals(regionId)){
    areaCode ='0854';
    busiArea = '4';
    userLocation = '4';
}else if("8522600".equals(regionId)){
    areaCode ='0855';
    busiArea = '5';
    userLocation = '5';
}else if("8522200".equals(regionId)){
    areaCode ='0856';
    busiArea = '6';
    userLocation = '6';
}else if("8522400".equals(regionId)){
    areaCode ='0857';
    busiArea = '7';
    userLocation = '7';
}else if("8520200".equals(regionId)){
    areaCode ='0858';
    busiArea = '8';
    userLocation = '8';
}else if("8522300".equals(regionId)){
    areaCode ='0859';
    busiArea = '9';
    userLocation = '9';
}else if("8520000".equals(regionId)){
    areaCode ='0850';
}

//计算网龄
if(internetAge.equals("") && !enterDate.equals("")){
    try {
        SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        println ("入网时间enterDate:" + enterDate);
        String str = enterDate;
        println ("入网时间str:" + str);
        Date startDate = format2.parse(str);
        Date endDate = new Date();
        Calendar startCalendar = Calendar.getInstance();
        startCalendar.setTime(startDate);
        int startYear = startCalendar.get(Calendar.YEAR);
        int startMonth = startCalendar.get(Calendar.MONTH) + 1;
        int startDay = startCalendar.get(Calendar.DAY_OF_MONTH);
        Calendar endCalendar = Calendar.getInstance();
        endCalendar.setTime(endDate);
        int endYear = endCalendar.get(Calendar.YEAR);
        int endMonth = endCalendar.get(Calendar.MONTH) + 1;
        int endDay = endCalendar.get(Calendar.DAY_OF_MONTH);
        int diffYear = endYear - startYear;
        int diffMonth = endMonth - startMonth;
        int months = diffYear * 12 + diffMonth;
        if(startDay>endDay){
            months=months-1;
        }
        //年数
        int roundNum;
        //月数
        int remainder;
        if(months>=12){
            roundNum = months/12;
            remainder = months%12;
            if(remainder==0){
                internetAge = roundNum+"年";
            }else{
                internetAge = roundNum+"年"+remainder+"月";    
            }
        }else{
            internetAge = months+"月";
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
try{
    if(jsonSlr4Json!=null && !jsonSlr4Json.containsKey('code')){
        
        if(jsonSlr4Json.pointOwnerImportant!='' && jsonSlr4Json.pointOwnerImportant!=null){
            //获取重要客户
            importantCustomer = jsonSlr4Json.pointOwnerImportant;
        }
        if(jsonSlr4Json.pointContactName!='' && jsonSlr4Json.pointContactName!=null){
            //获取政企关键人
            goverKeyPerson = jsonSlr4Json.pointContactName;
        }
        if(jsonSlr4Json.pointStaffName!='' && jsonSlr4Json.pointStaffName!=null){
            //获取客户经理
            custManager = jsonSlr4Json.pointStaffName;
        }
        if(jsonSlr4Json.pointStaffNbr!='' && jsonSlr4Json.pointStaffNbr!=null){
            //获取客户经理电话
            custManagerPhone = jsonSlr4Json.pointStaffNbr;
        } 
    }
}catch (Exception e) {
    e.printStackTrace();
}

if(jsonSlr5Json[0]!=null && jsonSlr5Json[0].prodInstId!=null){
    productId = jsonSlr5Json[0].prodInstId;
}
if(jsonSlr5Json[0]!=null && jsonSlr5Json[0].addressDesc!=null){
    addressDesc = jsonSlr5Json[0].addressDesc
}
if(jsonSlr5Json[0]!=null && jsonSlr5Json[0].addressId!=null){
    addressId = jsonSlr5Json[0].addressId
}

if(jsonSlr5Json[0]!=null && jsonSlr5Json[0].regionId!=null){
    dxTeleAreaID = jsonSlr5Json[0].regionId
}
if(jsonSlr5Json[0]!=null && jsonSlr5Json[0].paymentModeCd!=null){
    paymentModeCd = jsonSlr5Json[0].paymentModeCd
}
if(jsonSlr5Json[0]!=null && jsonSlr5Json[0].prodInstAccRels[0]!=null && jsonSlr5Json[0].prodInstAccRels[0].acctId!=null){
    acctId = jsonSlr5Json[0].prodInstAccRels[0].acctId
}


if (jsonSlr7Json.size()>0 && jsonSlr7Json[0].offerId){
     crmOfferId = jsonSlr7Json[0].offerId
}

if(jsonSlr8Json instanceof List && jsonSlr8Json.size()>0){
   for (int i = 0; i < jsonSlr8Json.size(); i++) {
            def fsOfferName = jsonSlr8Json[i].offerName
            if (fsOfferName.contains("安全大脑")){
                isSafeBrain = "1"
            }
        }
}

def jsonstrx= '{"custId":"'+custId+
        '","cityFlag":'+cityFlag+
        ',"regionId":"'+regionId+
        '","dxTeleAreaID":"'+dxTeleAreaID+
        '","busiArea":"'+busiArea+
        '","userLocation":"'+userLocation+
        '","custName":"'+custName+
        '","contactName":"'+contactName+
        '","certNum":"'+certNum+
        '","certType":"'+certType+
        '","userLevel":"'+userLevel+
        '","custType":"'+custType+
        '","userBrand":"'+userBrand+
        '","custAddr":"'+custAddr+
        '","customerAge":"'+customerAge+
        '","custGender":"'+custGender+
        '","prodState":"","networkAccessTime":"'+enterDate+
        '","internetAge":"'+internetAge+
        '","importantCustomer":"'+importantCustomer+
        '","goverKeyPerson":"'+goverKeyPerson+
        '","custManager":"'+custManager+
        '","productId":"'+productId+
        '","crmOfferId":"'+crmOfferId+
        '","addressDesc":"'+addressDesc+
        '","addressId":"'+addressId+
        '","acctId":"'+acctId+
        '","isSafeBrain":"'+isSafeBrain+
        '","paymentModeCd":"'+paymentModeCd+
        '","custManagerPhone":"'+custManagerPhone+
        '"}';
printf("$jsonstrx")