正在显示
40 个修改的文件
包含
1945 行增加
和
0 行删除
Config/IEDriverServer.exe
0 → 100644
不能预览此文件类型
Config/interface.dll
0 → 100644
不能预览此文件类型
不能预览此文件类型
Config/yzfUSBShareUnit.dll
0 → 100644
不能预览此文件类型
不能预览此文件类型
Config/负责资产交接.docx
0 → 100644
不能预览此文件类型
MenBai/MenBai.7z
0 → 100644
不能预览此文件类型
MenBai/USBDevsM20170928.7z
已删除
100644 → 0
不能预览此文件类型
SMS_Cat/新酷卡接收短信、存储短信 开发/开发/MYSQL使用教程.docx
0 → 100644
不能预览此文件类型
SMS_Cat/新酷卡接收短信、存储短信 开发/开发/MYSQL数据库建表.sql
0 → 100644
1 | +# -------------------------------------------------------- | |
2 | +# Host: 127.0.0.1 | |
3 | +# Server version: 5.5.53 | |
4 | +# Server OS: Win32 | |
5 | +# HeidiSQL version: 6.0.0.3603 | |
6 | +# Date/time: 2018-04-02 16:59:14 | |
7 | +# -------------------------------------------------------- | |
8 | + | |
9 | +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | |
10 | +/*!40101 SET NAMES utf8 */; | |
11 | +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | |
12 | +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | |
13 | + | |
14 | +# Dumping database structure for spcard | |
15 | +DROP DATABASE IF EXISTS `spcard`; | |
16 | +CREATE DATABASE IF NOT EXISTS `spcard` /*!40100 DEFAULT CHARACTER SET utf8 */; | |
17 | +USE `spcard`; | |
18 | + | |
19 | + | |
20 | +# Dumping structure for table spcard.port_info | |
21 | +DROP TABLE IF EXISTS `port_info`; | |
22 | +CREATE TABLE IF NOT EXISTS `port_info` ( | |
23 | + `Id` int(11) NOT NULL AUTO_INCREMENT, | |
24 | + `PortNum` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '端口号', | |
25 | + `IMSI` varchar(255) NOT NULL DEFAULT '' COMMENT '用户识别码(IMSI)', | |
26 | + `ICCID` varchar(255) DEFAULT '' COMMENT '卡识别码(ICCID)', | |
27 | + `PhoNum` varchar(255) DEFAULT NULL COMMENT '手机号', | |
28 | + PRIMARY KEY (`Id`) | |
29 | +) ENGINE=MyISAM DEFAULT CHARSET=utf8; | |
30 | + | |
31 | +# Data exporting was unselected. | |
32 | + | |
33 | + | |
34 | +# Dumping structure for table spcard.sms_recv | |
35 | +DROP TABLE IF EXISTS `sms_recv`; | |
36 | +CREATE TABLE IF NOT EXISTS `sms_recv` ( | |
37 | + `Id` int(11) NOT NULL AUTO_INCREMENT, | |
38 | + `PortNum` int(11) unsigned DEFAULT '0' COMMENT '接收短信的端口号', | |
39 | + `PhoNum` varchar(255) DEFAULT '' COMMENT '手机号', | |
40 | + `IMSI` varchar(255) DEFAULT NULL COMMENT '用户识别码(IMSI)', | |
41 | + `ICCID` varchar(255) DEFAULT NULL COMMENT '卡识别码(ICCID)', | |
42 | + `smsDate` varchar(255) NOT NULL DEFAULT '' COMMENT '短信日期,注意是smsDate而不是smsData', | |
43 | + `smsNumber` varchar(255) NOT NULL DEFAULT '' COMMENT '短信号码', | |
44 | + `smsContent` varchar(255) NOT NULL DEFAULT '' COMMENT '短信内容', | |
45 | + PRIMARY KEY (`Id`) | |
46 | +) ENGINE=MyISAM DEFAULT CHARSET=utf8; | |
47 | + | |
48 | +# Data exporting was unselected. | |
49 | + | |
50 | + | |
51 | +# Dumping structure for table spcard.sms_send | |
52 | +DROP TABLE IF EXISTS `sms_send`; | |
53 | +CREATE TABLE IF NOT EXISTS `sms_send` ( | |
54 | + `Id` int(11) NOT NULL AUTO_INCREMENT, | |
55 | + `PortNum` int(11) DEFAULT '-1' COMMENT '大于0表示指定端口号发送', | |
56 | + `smsNumber` varchar(255) NOT NULL DEFAULT '' COMMENT '接收号码', | |
57 | + `smsSubject` varchar(255) DEFAULT '' COMMENT '彩信标题,如果发送彩信不能为空', | |
58 | + `smsContent` varchar(255) NOT NULL DEFAULT '' COMMENT '发送内容', | |
59 | + `smsType` int(11) unsigned DEFAULT '0' COMMENT '0:短信 1:彩信', | |
60 | + `PhoNum` varchar(255) DEFAULT NULL COMMENT '手机号', | |
61 | + `smsState` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '0:未发送 1:已在发送队列 2:发送成功 3:发送失败', | |
62 | + PRIMARY KEY (`Id`) | |
63 | +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; | |
64 | + | |
65 | +# Data exporting was unselected. | |
66 | +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | |
67 | +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | |
68 | +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | |
... | ... |
SMS_Cat/新酷卡接收短信、存储短信 开发/开发/SOCKET接口说明.txt
0 → 100644
1 | +SOCKET接口使用说明 | |
2 | + | |
3 | +功能说明:酷网通可以作为服务端,实现SOCKET通讯,实现三大功能: | |
4 | + | |
5 | +1> 支持端口信息和新短信主动上报。 | |
6 | + | |
7 | +2> 客户端可以向酷网通软件发送数据,提交酷网通任务设置里所有格式的任务。 | |
8 | + | |
9 | +3> 客户端支持发送指令给酷网通软件,操作卡池设备自动换卡。 | |
10 | + | |
11 | + | |
12 | +酷网通配置SOCKET功能: | |
13 | + | |
14 | +1> 软件默认已开启SOCKET服务功能,端口号为:16908,可在【工具】->【SOCKET服务对接设置】配置,重启软件生效。 | |
15 | + | |
16 | +2> 目录下有SOCKET测试工具可用于测试SOCKET指令。 | |
17 | + | |
18 | + | |
19 | +SOCKET指令使用说明: | |
20 | + | |
21 | +1> 端口信息上报,只要client连接上酷网通,端口信息有变会自动往client发送数据,格式为:+DEVICES:端口信息数据长度,端口信息|。 | |
22 | + | |
23 | + 如:+DEVICES:66,COM12,13800000001,460010000000002,89860000000085125121,350212021210245| | |
24 | + | |
25 | +2> 客户端收到新短信格式为:+NEW_SMS:端口号┇手机号┇发送号码┇接收时间┇短信内容。 | |
26 | + | |
27 | +3> 客户端提交的短信发送成功上报格式为:+NEW_SMS:短信ID┇端口号┇手机号┇发送号码┇接收时间┇短信内容。 | |
28 | + | |
29 | +4> 客户端提交的短信发送失败上报格式为:+SMS_FAIL:短信ID┇端口号┇手机号┇发送号码┇接收时间┇短信内容。 | |
30 | + | |
31 | +5> 客户端指定端口发送短信格式为:AP$SENDSMS=数据库ID,端口号,发送号码,发送内容 (注:数据库ID没有可指定一个整数) | |
32 | + | |
33 | +6> 客户端提交任务设置任务格式为:AP$TASK=数据长度,端口号,数据 (注:端口号小于或等于0表示该任务发送到所有通道) | |
34 | + | |
35 | + 数据格式为json格式: 如:{"taskname":"短信","tasktype":"短信","number":"10001","content":"102","count":1,"waittime":2} | |
36 | + | |
37 | + 字段值参照软件任务设置,如果是语音,则tasktype对应的类型是"语音",同理彩信对应的类型是"彩信",以任务设置类型为准。 | |
38 | + | |
39 | + 数据长度仅计算数据的长度不含端口号。 | |
40 | + | |
41 | + 如发送短信102到10001,数据长度93(注:中文占两字节)发送到COM66,指令参考:AP$TASK=93,66,{"taskname":"短信","tasktype":"短信","number":"10001","content":"102","count":1,"waittime":2} | |
42 | + | |
43 | + 同样刷流量任务(注:流量任务content对应内容中括号不带必须去掉),指令参考:AP$TASK=213,66,{"taskname":"流量任务","tasktype":"刷流量","number":"","content":"2┇2,网址自动轮转┇1.00-1.00┇NokiaN82/1.0 (20.1.062) SymbianOS/9.2 Series60/3.1 Profile/MIDP-2.0 Configuration/CLDC-1.1┇","count":1,"waittime":2} | |
44 | + | |
45 | + 其他任务同样参考设置,互打互发除外。 | |
46 | + | |
47 | +7> 卡池换卡指令:AP$SIM=端口号,序号; (注:如果端口号小于0表示全部通道一起换卡) | |
48 | + | |
49 | +8> 卡池指定手机号换卡指令:AP$SIMPHONUM=手机号; (注:必须先保存手机号对应的卡池位置) | |
50 | + | |
51 | +9> 获取指令端口信息:AP$PORTREAD=端口号,如:AP$PORTREAD=66,获取COM66端口信息,AP$PORTREAD=-1,获取全部端口信息。 | |
52 | + | |
53 | +10> 读取新短信指令:AP$SMS=端口号,端口号小于0是表示读取全部端口新短信。 | |
54 | + | |
55 | +11> 获取端口号信息:AP$DEVICES=端口号,端口号小于0是表示读取全部端口信息。 | |
56 | + | |
57 | +12> 任务执行结果查询:AP$TASKRESULT? | |
58 | + | |
59 | +13> 根据ICCID换卡:AP$SIMICCID=ICCID | |
60 | + | |
61 | + | |
62 | + | |
63 | + | |
64 | + | |
... | ... |
SMS_Cat/新酷卡接收短信、存储短信 开发/开发/SOCKET测试工具.exe
0 → 100644
不能预览此文件类型
SMS_Cat/新酷卡接收短信、存储短信 开发/开发/二次开发说明.txt
0 → 100644
1 | +二次开发说明 | |
2 | + | |
3 | +功能说明: | |
4 | + | |
5 | +1> 从酷网通软件自带ACCESS数据库中读取端口信息和新短信。 | |
6 | + | |
7 | +2> 可以往酷网通自带的ACCESS数据库中写入需要发送的短信。 | |
8 | + | |
9 | +3> 数据库的密码为:gd2013 | |
10 | + | |
11 | + | |
12 | +具体实现: | |
13 | + | |
14 | +1> 需要从数据库读取端口号信息的,可读取数据库OtInfo.mdb中的Devices表,可实时更新端口号信息。 | |
15 | + | |
16 | +2> 需要从数据库读取新短信的,可读取数据库SMS.mdb中的L_SMS表,保存的是所有接收到的新短信。 | |
17 | + | |
18 | +3> 如果需要以文本文件的方式读取短信的,可在安装目录下面的【全部短信】和【最新短信】文件夹读取对应的文本文件短信即可。 | |
19 | + | |
20 | +4> 外部短信发送,可将需要发送的短信写入数据库OtInfo.mdb的SMSOutbox表中,如果要指定端口发送,可设置字段comport的值, | |
21 | + | |
22 | + 注(comport的值为整型),字段taskname的值可为空,仅区分短信用。 | |
23 | + | |
24 | +5> 以文本文件的方式写入发送短信,文件命名为:短信发送.txt,格式为:手机号,内容或端口号(格式如COM1),手机号,内容。 | |
25 | + | |
26 | + 一行一条信息,多条信息回车换行,将此文件保存到安装目录下面Config文件夹即可。 | |
27 | + | |
28 | + | |
29 | +对接总结: | |
30 | + | |
31 | +在线手机号码:OtInfo.mdb——Devices表,Comport是端口号,phonum是手机号码 | |
32 | + | |
33 | +短信接收记录:SMS.mdb——L_SMS表,number是号码, content是短信内容,simnum 是发送的号码字段 | |
34 | + | |
35 | +提交发送短信:OtInfo.mdb——SMSOutbox表,comport是端口号,number是接收号码,content是短信内容 | |
36 | + | |
37 | +发送短信结果:SUCCESS.mdb——L_SUCCESS表,pcui是端口号,number是接收号码,content是短信内容 | |
38 | + | |
39 | + | |
40 | + | |
... | ... |
SMS_Cat/新酷卡接收短信、存储短信 开发/新酷卡(20180819).exe
0 → 100644
不能预览此文件类型
SMS_Cat/新酷卡接收短信、存储短信 开发/新酷卡使用文档.docx
0 → 100644
不能预览此文件类型
SMS_Cat/设备安装简单说明.docx
0 → 100644
不能预览此文件类型
此 diff 太大无法显示。
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
UnPack/unpack/bot.ico
0 → 100644
不能预览此文件类型
UnPack/unpack/sibot/Bot.exe
0 → 100644
不能预览此文件类型
UnPack/unpack/sibot/Controller.exe
0 → 100644
不能预览此文件类型
UnPack/unpack/sibot/Worker.exe
0 → 100644
不能预览此文件类型
UnPack/unpack/sibot/bot_ins_110100.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | |
2 | +import time | |
3 | +import re | |
4 | +import os | |
5 | +import datetime | |
6 | +from lxml import etree | |
7 | +import win32api | |
8 | +from win32.lib import win32con | |
9 | +from sibot.common import constant | |
10 | +from sibot.worker.bot.bot import Bot as RootBot | |
11 | +from selenium.webdriver.support.select import Select | |
12 | +from sibot.common.bot_log import BotLogger | |
13 | +from sibot.common import waclient | |
14 | +from sibot.common.utils import check_id_num | |
15 | + | |
16 | +logger = BotLogger(os.path.basename(__file__), logname=2).getLogger() | |
17 | + | |
18 | + | |
19 | +class Bot(RootBot): | |
20 | + """ | |
21 | + 北京地区社保缴纳机器人 | |
22 | + """ | |
23 | + def __init__(self, job): | |
24 | + super(Bot, self).__init__(job) | |
25 | + self.login_url = "http://fuwu.rsj.beijing.gov.cn/csibiz/csirp/login.jsp" | |
26 | + self.login_url1 = "https://yzt.beijing.gov.cn/am/UI/Login?module=BjzwCert&goto=https%3A%2F%2Fyzt.beijing.gov.cn%2Fam%2Foauth2%2Fauthorize%3Fservice%3DbjzwService%26response_type%3Dcode%26client_id%3D688350606_02%26scope%3Dcn%2Buid%2BidCardNumber%2BextProperties%2BcredenceClass%26redirect_uri%3Dhttp%253A%252F%252Ffuwu.rsj.beijing.gov.cn%252Funitplatform%252FYZTAuth%26encoded%3Dfalse%26encoded%3Dfalse&lackFlag=NA" | |
27 | + # self.login_url = "https://yzt.beijing.gov.cn/am/UI/Login?module=BjzwCert&lackFlag=NA" | |
28 | + self.driver.implicitly_wait(30) | |
29 | + | |
30 | + def login(self): | |
31 | + """北京社保网站登录操作""" | |
32 | + for i in range(5): | |
33 | + try: | |
34 | + logger.info('start login beijing ----------') | |
35 | + self.driver.get(self.login_url1) # 登陆窗口 | |
36 | + self.driver.implicitly_wait(30) # 隐式等待30秒 | |
37 | + time.sleep(3) | |
38 | + # 旧登录方式抓取登陆错误方法 | |
39 | + # sound_code = self.driver.page_source | |
40 | + # if '本月系统维护' in sound_code: | |
41 | + # message = etree.HTML(sound_code).xpath('/html/body/table/tbody/tr[1]/td/text()') | |
42 | + # message = message[0].replace('\n\t', '') + message[1].replace('\n\t', '').replace(' ', '') | |
43 | + # logger.error(message) | |
44 | + # return False | |
45 | + | |
46 | + # 判断数字证书是否成功加载 | |
47 | + # if not self.driver.find_elements_by_xpath('//*[@id="UserList"]/option'): | |
48 | + # logger.errors("证书加载失败") | |
49 | + # self.driver.refresh() | |
50 | + # continue | |
51 | + | |
52 | + # 输入帐号密码等信息 | |
53 | + # js = 'document.getElementById("wrapper").style.display="none";' | |
54 | + # self.driver.execute_script(js) | |
55 | + # js = 'document.getElementsByClassName("pop")[0].style.display="none";' | |
56 | + # self.driver.execute_script(js) | |
57 | + # time.sleep(1) | |
58 | + # self.driver.find_element_by_id('popButton1').click() # 选择北京市统一身份认证平台登录 | |
59 | + # time.sleep(1) | |
60 | + # self.driver.find_element_by_id('popButton4').click() # 否 | |
61 | + # time.sleep(8) | |
62 | + # | |
63 | + # self.driver.switch_to_frame('header') # 进入 frame表单 | |
64 | + # self.driver.find_element_by_xpath('/html/body/div/div[1]/p/a[2]').click() # 点击法人登录 | |
65 | + # self.driver.switch_to_default_content() # 退出 frame表单 | |
66 | + time.sleep(2) | |
67 | + # current_window = self.driver.current_window_handle # 存储当前窗口的id | |
68 | + # all_windows = self.driver.window_handles # 获取打开的全部窗口 | |
69 | + # for window in all_windows: # 循环全部窗口 直到有新的窗口 | |
70 | + # if window != current_window: | |
71 | + # self.driver.switch_to.window(window) # switch_to.window 切换窗口 | |
72 | + self.driver.maximize_window() # 新打开窗口全屏 | |
73 | + time.sleep(2) | |
74 | + # self.driver.find_element_by_xpath('//*[@id="userId"]/ul/li[1]/a').click() # 点击证书登录 | |
75 | + # time.sleep(4) | |
76 | + | |
77 | + self.driver.find_element_by_id('password').send_keys(self.job.usb_cert_pwd) # usb_cert_pwd 证书密码 | |
78 | + self.driver.find_element_by_xpath('//*[@id="cert_div"]/div[6]/input').click() # 点击登陆 | |
79 | + self.driver.find_element_by_xpath('//*[@id="cert_div"]/div[6]/input').click() # 点击登陆 | |
80 | + time.sleep(8) | |
81 | + | |
82 | + # 旧登录方式抓取登陆错误方法 | |
83 | + # try: | |
84 | + # alert_text = self.driver.switch_to_alert().text | |
85 | + # if '口令错误' in alert_text: | |
86 | + # logger.error('alert_text: {}'.format(alert_text)) | |
87 | + # self.driver.switch_to_alert().accept() | |
88 | + # return False | |
89 | + # if '过期' in alert_text: | |
90 | + # logger.error('alert_text: {}'.format(alert_text)) | |
91 | + # self.driver.switch_to_alert().accept() | |
92 | + # except Exception as e: | |
93 | + # logger.error(str(e)) | |
94 | + | |
95 | + # try: | |
96 | + # source_code = self.driver.page_source | |
97 | + # time.sleep(1) | |
98 | + # if '认证失败,请检查登录凭证是否正确' in source_code or '点击返回首页' in source_code: | |
99 | + # logger.error("发现并处理错误页面") | |
100 | + # return False | |
101 | + # except Exception as e: | |
102 | + # logger.error(str(e)) | |
103 | + | |
104 | + # 新的登陆方式抓取登陆错误方法 | |
105 | + | |
106 | + # 弹出框 | |
107 | + # alert(一个按钮),confirm(两个按钮),prompt(两个按钮+输入框) | |
108 | + # driver.switch_to.alert.text # 获取弹出框的文本信息 | |
109 | + # driver.switch_to.alert.accept() # 确认 | |
110 | + # driver.switch_to.alert.dismiss() # 取消 | |
111 | + | |
112 | + try: | |
113 | + alert_text = self.driver.switch_to_alert().text # 获取弹出框 的文本 | |
114 | + if '校验证书密码失败' in alert_text: | |
115 | + logger.error('alert_text: {}'.format(alert_text)) | |
116 | + self.driver.switch_to_alert().accept() # 在弹出框上 点击确认 | |
117 | + return False | |
118 | + if '输入证书密码' in alert_text: | |
119 | + logger.error('alert_text: {}'.format(alert_text)) | |
120 | + self.driver.switch_to_alert().accept() | |
121 | + continue | |
122 | + if '过期' in alert_text: | |
123 | + logger.error('alert_text: {}'.format(alert_text)) | |
124 | + self.driver.switch_to_alert().accept() | |
125 | + time.sleep(2) | |
126 | + sound_code = self.driver.page_source # 获取页面的数据/源码 | |
127 | + time.sleep(1) | |
128 | + if '请检查登录凭证是否正确' in sound_code or '点击返回首页' in sound_code: | |
129 | + logger.error('页面错误,重新加载') | |
130 | + self.driver.refresh() # 刷新浏览器 | |
131 | + continue | |
132 | + except Exception as e: | |
133 | + logger.error(str(e)) | |
134 | + for j in range(1, 100): # 有问题 | |
135 | + declare_xpath = \ | |
136 | + self.driver.find_element_by_xpath('/html/body/div[3]/div/div[2]/ul/li[' + str(j) + ']/a') | |
137 | + declare_text = declare_xpath.text | |
138 | + if declare_text == '社会保险网上申报': | |
139 | + declare_xpath.click() | |
140 | + time.sleep(5) | |
141 | + break # 跳出整个循环 | |
142 | + | |
143 | + | |
144 | + return True | |
145 | + except Exception as e: | |
146 | + logger.error(str(e)) | |
147 | + self.driver.refresh() | |
148 | + continue # 跳出本次循环 | |
149 | + return False | |
150 | + | |
151 | + def __increase(self): | |
152 | + # 获取增员类型办理任务 | |
153 | + # __get_tasks:获取指定条件的任务函数 constant:常量文件 OP_TYPE_INCREASE:增员 STATUS_INIT:状态初始化 | |
154 | + tasks = self.__get_tasks(constant.OP_TYPE_INCREASE, constant.STATUS_INIT) | |
155 | + if not tasks: | |
156 | + return | |
157 | + | |
158 | + self.close_notice() # 关闭页面悬浮div弹框 | |
159 | + | |
160 | + for task in tasks: | |
161 | + # waclient:请求sass平台文件 get_si_task:更新社保公积金待办任务 | |
162 | + task_detail, err_code = waclient.get_si_task(self.ctx, task['id']) | |
163 | + if err_code != 200: | |
164 | + break | |
165 | + | |
166 | + # 下载新参保人员证件照 | |
167 | + if 'person_attachments' in task_detail: | |
168 | + attachs = task['person_attachments'] # 有问题 | |
169 | + if attachs is not None and len(attachs) > 0: | |
170 | + file_object = attachs[0] | |
171 | + local_file_path, status_code = waclient.download_file(self.ctx, file_object) # download_file:获取云平台对象文件 | |
172 | + if status_code == 200: | |
173 | + task_detail['idphoto'] = local_file_path # 有问题 | |
174 | + | |
175 | + response = self.do_increase(task_detail) # do_increase:北京社保增员操作 | |
176 | + ins = self.get_all_ins(task_detail) | |
177 | + if not ins: | |
178 | + ins = ['医疗保险', '生育保险', '养老保险', '失业保险', '工伤保险'] | |
179 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_CONFORMING) | |
180 | + | |
181 | + if not self.is_once_submit_increase(): | |
182 | + hhr_type = '' | |
183 | + comment = response[1] | |
184 | + if self.is_once_submit(): | |
185 | + return_status = constant.STATUS_SUCCESS | |
186 | + else: | |
187 | + return_status = constant.STATUS_CONFORMING | |
188 | + | |
189 | + comment_list = response[1].split('#') | |
190 | + if len(comment_list) >= 2: | |
191 | + comment = comment_list[0] | |
192 | + hhr_type = comment_list[1] | |
193 | + print('---***---') | |
194 | + print(response) | |
195 | + print(comment) | |
196 | + print(return_status) | |
197 | + print(comment_list) | |
198 | + print(hhr_type) | |
199 | + # logger.info('---***---') | |
200 | + # logger.info(response) | |
201 | + # logger.info(comment) | |
202 | + # logger.info(return_status) | |
203 | + # logger.info(comment_list) | |
204 | + # logger.info(hhr_type) | |
205 | + if response[0] != constant.STATUS_INIT: | |
206 | + if not response[0]: | |
207 | + return_status = constant.STATUS_FAIL | |
208 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_FAIL) | |
209 | + else: | |
210 | + return_status = constant.STATUS_INIT | |
211 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_INIT) | |
212 | + if comment.isdigit(): | |
213 | + return_status = constant.STATUS_SUCCESS | |
214 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_SUCCESS) | |
215 | + if '不能进行转入人员增加' in comment: | |
216 | + return_status = constant.STATUS_SUCCESS | |
217 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_SUCCESS) | |
218 | + | |
219 | + response = waclient.update_si_task(self.ctx, task['id'], return_status, comment, hhr_type=hhr_type, result=result) | |
220 | + if response[1] != 200: | |
221 | + logger.error("Task Status Update Fail: " + str(task['id'])) | |
222 | + | |
223 | + if 'idphoto' in task_detail.keys(): | |
224 | + self.del_batch_file(task_detail['idphoto']) | |
225 | + | |
226 | + def do_increase(self, task): | |
227 | + """北京社保增员操作""" | |
228 | + if task['handle_type'] == "0": | |
229 | + return self.new_ginseng(task) # 北京地区社保新参保 | |
230 | + elif task['handle_type'] == "1": # 北京社保转入人员参保 | |
231 | + return self.transfer_staff(task) | |
232 | + | |
233 | + def new_ginseng(self, task): | |
234 | + """北京地区社保新参保""" | |
235 | + id_num = task['insured_id_num'] | |
236 | + name = task['insured_name'] | |
237 | + # id_type = task['insured_id_type'] | |
238 | + timestamp = task['start_month'] # 获取时间戳 | |
239 | + payers = task['huji_type'] # 缴费人员类别 | |
240 | + tel = task['insured_mobile'] | |
241 | + wage = task['base'] | |
242 | + nation = '汉族' | |
243 | + photo = '' | |
244 | + if 'idphoto' in task.keys(): | |
245 | + photo = task['idphoto'] | |
246 | + | |
247 | + # 判断身份证号码的有效性 | |
248 | + id_num = id_num.upper().replace(' ', '') # upper() 字符串小写转大写 | |
249 | + if not check_id_num(id_num=id_num): # check_id_num:验证身份证号的正确性 | |
250 | + return False, '请输入正确的身份证号: {}'.format(id_num) | |
251 | + if photo == '': | |
252 | + return False, '未上传证件照附件' | |
253 | + # 判断必须字段是否为空 | |
254 | + if not name: | |
255 | + return False, '姓名为空' | |
256 | + if not photo: | |
257 | + return False, '电子照片为空' | |
258 | + if not timestamp: | |
259 | + return False, '参保工作日期有误' | |
260 | + if not payers: | |
261 | + return False, '缴费人员类别有误' | |
262 | + if not tel or len(tel) != 11 or not re.findall('^\d*$', tel): | |
263 | + return False, '手机号有误' | |
264 | + if not wage: | |
265 | + return False, '月均工资数据有误' | |
266 | + | |
267 | + if payers == '外地农村': | |
268 | + payers = '外埠农村劳动力' | |
269 | + elif payers == '外地城镇': | |
270 | + payers = '外埠场镇职工' | |
271 | + elif payers == '本地城镇': | |
272 | + payers = '本地城镇职工' | |
273 | + elif payers == '本地农村': | |
274 | + payers = '本地农村劳动力' | |
275 | + | |
276 | + time_local = time.localtime(timestamp) | |
277 | + work_date = time.strftime("%Y-%m-%d", time_local) # 将时间戳转换成格式时间 | |
278 | + | |
279 | + ext_infos = task['ext_info'] # ext_infos 里面包含了 非被填字段 | |
280 | + per_nation = '工人' # 个人身份 | |
281 | + hukou_address = '' # 户口所在地地址 | |
282 | + hukou_code = '' # 户口所在地邮政编码 | |
283 | + now_address = '' # 居住地联系地址 | |
284 | + now_address_code = '' # 居住地联系邮政编码 | |
285 | + bill_way = '网上查询' # 对账单方式 | |
286 | + education = '大学' # 文化程度 | |
287 | + bank_name = '' # 委托代发银行名称 | |
288 | + bank_num = '' # 委托代发银行账号 | |
289 | + medical1 = '' # 定点医疗机构1 | |
290 | + medical2 = '' # 定点医疗机构2 | |
291 | + medical3 = '' # 定点医疗机构3 | |
292 | + medical4 = '' # 定点医疗机构4 | |
293 | + medical5 = '' # 定点医疗机构5 | |
294 | + four_save_reason = '其它新参统' # 四险个人缴费原因 | |
295 | + | |
296 | + # 开始对每个扩展字段进行查询和赋值 | |
297 | + staff_type = '' # 员工类型 | |
298 | + uniform_code = '' # 统一社会信用代码 | |
299 | + uniform = '' # 用工单位 | |
300 | + work_post = '' # 岗位 | |
301 | + salary = '' # 合同约定工资薪金 | |
302 | + laborStartDate = '' # 劳动合同开始时间 | |
303 | + laborEndDate = '' # 劳动合同结束时间 | |
304 | + contract_type = '固定期限劳动合同' | |
305 | + singed_contract = '' | |
306 | + # 开始对每个扩展字段进行查询和赋值 # 有问题 | |
307 | + for ext_info in ext_infos: | |
308 | + if ext_info['name'] == '个人身份': | |
309 | + per_nation = ext_info['value'] | |
310 | + if ext_info['name'] == '户口所在地地址': | |
311 | + hukou_address = ext_info['value'] | |
312 | + if ext_info['name'] == '户口所在地邮政编码': | |
313 | + hukou_code = ext_info['value'].replace(' ', '') | |
314 | + if ext_info['name'] == '居住地(联系)地址': | |
315 | + now_address = ext_info['value'] | |
316 | + if ext_info['name'] == '居住地(联系)邮政编码': | |
317 | + now_address_code = ext_info['value'] | |
318 | + if '对账单方式' in ext_info['name']: | |
319 | + bill_way = ext_info['value'] | |
320 | + if ext_info['name'] == '文化程度': | |
321 | + education = ext_info['value'] | |
322 | + if ext_info['name'] == '委托代发银行名称': | |
323 | + bank_name = ext_info['value'] | |
324 | + if bank_name == "北京银行" or bank_name == "农商银行" or bank_name == "广发银行": | |
325 | + bank_name += "(只限本市)" | |
326 | + if ext_info['name'] == '委托代发银行账号': | |
327 | + bank_num = ext_info['value'].replace(' ', '') | |
328 | + if ext_info['name'] == '定点医疗机构1': | |
329 | + medical1 = ext_info['value'].replace(' ', '') | |
330 | + if ext_info['name'] == '定点医疗机构2': | |
331 | + medical2 = ext_info['value'].replace(' ', '') | |
332 | + if ext_info['name'] == '定点医疗机构3': | |
333 | + medical3 = ext_info['value'].replace(' ', '') | |
334 | + if ext_info['name'] == '定点医疗机构4': | |
335 | + medical4 = ext_info['value'].replace(' ', '') | |
336 | + if ext_info['name'] == '定点医疗机构5': | |
337 | + medical5 = ext_info['value'].replace(' ', '') | |
338 | + if ext_info['name'] == '民族': | |
339 | + nation = ext_info['value'] | |
340 | + if '族' not in nation: | |
341 | + nation += '族' | |
342 | + if '四险个人缴费原因' in ext_info['name']: | |
343 | + four_save_reason = ext_info['value'].replace(' ', '') | |
344 | + if ext_info['name'] == '员工类型': | |
345 | + staff_type = ext_info['value'] | |
346 | + if ext_info['name'] == '统一社会信用代码': | |
347 | + uniform_code = ext_info['value'] | |
348 | + if ext_info['name'] == '用工单位': | |
349 | + uniform = ext_info['value'] | |
350 | + if ext_info['name'] == '岗位': | |
351 | + work_post = ext_info['value'] | |
352 | + if ext_info['name'] == '劳动合同约定工资': | |
353 | + salary = ext_info['value'] | |
354 | + if ext_info['name'] == '劳动合同起止时间': | |
355 | + laborStartDate = ext_info['value'] | |
356 | + if ext_info['name'] == '劳动合同结束时间': | |
357 | + laborEndDate = ext_info['value'] | |
358 | + if ext_info['name'] == '是否已签订电子劳动合同': | |
359 | + singed_contract = ext_info['value'] | |
360 | + | |
361 | + # 判断用户扩展字段的完整性 | |
362 | + if not hukou_address: | |
363 | + return False, '户口所在地地址为空' # 有问题 | |
364 | + if not hukou_code: | |
365 | + return False, '户口所在地邮政编码为空' | |
366 | + if not now_address: | |
367 | + now_address = hukou_address | |
368 | + if not now_address_code: | |
369 | + now_address_code = hukou_code | |
370 | + if not bank_name: | |
371 | + return False, '委托代发银行名称为空' | |
372 | + if not bank_num: | |
373 | + return False, '委托代发银行账号为空' | |
374 | + if not medical1: | |
375 | + return False, '定点医疗机构1为空' | |
376 | + if not medical2: | |
377 | + return False, '定点医疗机构2为空' | |
378 | + if per_nation not in ['工人', '干部']: | |
379 | + return False, '个人身份数据有误' | |
380 | + if not task['insurances']: | |
381 | + return False, '参加险种为空' | |
382 | + if not contract_type: | |
383 | + contract_type = '固定期限劳动合同' | |
384 | + if not education: | |
385 | + education = '大学' | |
386 | + if not singed_contract: | |
387 | + singed_contract = '否' | |
388 | + | |
389 | + # 判断区分人力资源账户和单立户 | |
390 | + if self.job.mark == '人力资源': | |
391 | + if not staff_type: | |
392 | + staff_type = '本单位员工' | |
393 | + # return False, '员工类型为空' | |
394 | + if not uniform_code: | |
395 | + return False, '统一社会信用代码为空' | |
396 | + if not work_post: | |
397 | + return False, '岗位为空' | |
398 | + if not salary: | |
399 | + salary = wage | |
400 | + # return False, '合同约定工资薪金为空' | |
401 | + if not laborStartDate: | |
402 | + return False, '劳动合同起止时间' | |
403 | + if not laborEndDate: | |
404 | + return False, '劳动合同结束时间为空' | |
405 | + | |
406 | + comment = '网络或服务器繁忙,请稍后再试' | |
407 | + for i in range(3): | |
408 | + status, comment = self.check_nav_show(div_id='level:1', one_id='link000', two_id='link002') # check_nav_show:检查左侧导航是否显示二级导航 | |
409 | + if not status: | |
410 | + return constant.STATUS_INIT, comment | |
411 | + self.driver.switch_to.default_content() | |
412 | + try: | |
413 | + self.driver.find_element_by_xpath('/html/body/div[last()]/div[@class="popup_top"]/h2/a').click() | |
414 | + except Exception as e: | |
415 | + logger.info('没有提示') | |
416 | + logger.error(str(e)) | |
417 | + time.sleep(2) | |
418 | + try: | |
419 | + self.driver.find_element_by_xpath('/html/body/div[@class="popwrap"]/div/h2/a').click() | |
420 | + except Exception as e: | |
421 | + logger.info('没有提示') | |
422 | + logger.error(str(e)) | |
423 | + self.driver.switch_to.default_content() | |
424 | + self.driver.switch_to.frame('center') | |
425 | + self.driver.switch_to.frame('mainFrame') | |
426 | + try: | |
427 | + self.driver.find_element_by_id('idcard').send_keys(id_num) # 输入身份证号 | |
428 | + self.driver.find_element_by_id('name').send_keys(name) # 输入姓名 | |
429 | + select = Select(self.driver.find_element_by_id("cardType")) # 证件类型 | |
430 | + select.select_by_visible_text('居民身份证') # select_by_visible_text 下拉框的文本值 | |
431 | + time.sleep(1) | |
432 | + self.driver.find_element_by_id('reg').click() # 确定 | |
433 | + time.sleep(1) | |
434 | + # self.driver.switch_to.default_content() | |
435 | + # self.driver.switch_to.frame('center') | |
436 | + # try: | |
437 | + # self.driver.find_element_by_xpath('/html/body/div[@class="popwrap"]/div/h2/a').click() | |
438 | + # except Exception as e: | |
439 | + # logger.info('没有提示') | |
440 | + # logger.error(str(e)) | |
441 | + try: # 有问题 | |
442 | + # '/html/body/table[2]/tbody/tr/td/table[1]/tbody/tr/td/font/ul/li/span').text | |
443 | + source_text = self.driver.page_source | |
444 | + # if '系统提示' in source_text: | |
445 | + # js_ad = "var aa=document.getElementsByClassName('popup_top')[0];aa.parentNode.removeChild(aa)" | |
446 | + # self.driver.execute_script(js_ad) | |
447 | + # else: | |
448 | + # logger.info('没有广告') | |
449 | + if re.findall('业务系统中已有该身份证号', source_text): | |
450 | + return False, "业务系统中已有该身份证号" | |
451 | + elif re.findall('个人信息登记业务中已存在', source_text): | |
452 | + # 点击【编辑按钮】 | |
453 | + lists = self.driver.find_elements_by_xpath('//*[@id="allform"]/table[1]/tbody/tr')[1:] | |
454 | + for k in range(len(lists)): | |
455 | + try: | |
456 | + count = k + 2 | |
457 | + xpath1 = "//*[@id='allform']/table[1]/tbody/tr[" + str(count) + "]/td[2]/div[1]/input[2]" | |
458 | + card_num = self.driver.find_element_by_xpath(xpath1).get_attribute('value') | |
459 | + if id_num in card_num: | |
460 | + xpath2 = "//*[@id='allform']/table[1]/tbody/tr[" + str(count) + "]/td[9]/div/a" | |
461 | + self.driver.find_element_by_xpath(xpath2).click() | |
462 | + break | |
463 | + except Exception as e: | |
464 | + logger.error(str(e)) | |
465 | + except Exception as e: | |
466 | + logger.error(str(e)) | |
467 | + | |
468 | + time.sleep(2) | |
469 | + # is_selected | |
470 | + ylbx_check = self.driver.find_element_by_id('kinds-1') | |
471 | + if not ylbx_check.is_selected(): | |
472 | + ylbx_check.click() | |
473 | + | |
474 | + sybx_check = self.driver.find_element_by_id('kinds-2') | |
475 | + if not sybx_check.is_selected(): | |
476 | + sybx_check.click() | |
477 | + | |
478 | + gsbx_check = self.driver.find_element_by_id('kinds-3') | |
479 | + if not gsbx_check.is_selected(): | |
480 | + gsbx_check.click() | |
481 | + | |
482 | + syubx_check = self.driver.find_element_by_id('kinds-4') | |
483 | + if not syubx_check.is_selected(): | |
484 | + syubx_check.click() | |
485 | + | |
486 | + jbylbx_check = self.driver.find_element_by_id('kinds-5') | |
487 | + if not jbylbx_check.is_selected(): | |
488 | + jbylbx_check.click() | |
489 | + | |
490 | + # self.driver.find_element_by_id('name').clear() | |
491 | + # self.driver.find_element_by_id('name').send_keys(name) # 姓名 | |
492 | + select = Select(self.driver.find_element_by_id("psnstatus")) # 个人身份 | |
493 | + select.select_by_visible_text(per_nation) #定位 select 下拉框 | |
494 | + self.driver.find_element_by_id('workdate').clear() | |
495 | + self.driver.find_element_by_id('workdate').send_keys(work_date) # 工作日期 | |
496 | + js = "document.getElementById('photo').setAttribute('onchange',' ')" # 去除弹窗 | |
497 | + self.driver.execute_script(js) | |
498 | + self.driver.find_element_by_id('photo').send_keys(photo) # 上传照片 | |
499 | + time.sleep(1) | |
500 | + self.driver.find_element_by_id('photobutton').click() # 上传 | |
501 | + time.sleep(3) | |
502 | + | |
503 | + select_nation = Select(self.driver.find_element_by_id('nation')) # 设置名族 | |
504 | + select_nation.select_by_visible_text(nation) | |
505 | + select = Select(self.driver.find_element_by_id("feepsntype")) # 缴费人员类别 | |
506 | + select.select_by_index(0) # 下拉框的索引 | |
507 | + time.sleep(0.5) | |
508 | + select.select_by_visible_text(payers) | |
509 | + | |
510 | + self.driver.find_element_by_id('residentaddr').clear() | |
511 | + self.driver.find_element_by_id('residentaddr').send_keys(hukou_address) # 籍贯 | |
512 | + self.driver.find_element_by_id('residentzip').clear() | |
513 | + self.driver.find_element_by_id('residentzip').send_keys(hukou_code) # 籍贯邮编 | |
514 | + self.driver.find_element_by_id("address").clear() # 清除输入框内容 | |
515 | + self.driver.find_element_by_id('address').send_keys(now_address) # 现住址 | |
516 | + self.driver.find_element_by_id('zip').clear() | |
517 | + self.driver.find_element_by_id('zip').send_keys(now_address_code) # 现住址邮编 | |
518 | + | |
519 | + select = Select(self.driver.find_element_by_id('getBillMethod')) # 对账单方式 | |
520 | + select.select_by_visible_text(bill_way) | |
521 | + select = Select(self.driver.find_element_by_id('education')) # 文化程度 | |
522 | + select.select_by_visible_text(education) | |
523 | + self.driver.find_element_by_id('tel').clear() | |
524 | + self.driver.find_element_by_id('tel').send_keys(tel) # 手机号 | |
525 | + self.driver.find_element_by_id('cellphone').clear() | |
526 | + self.driver.find_element_by_id('cellphone').send_keys(tel) | |
527 | + self.driver.find_element_by_id('salary').clear() | |
528 | + self.driver.find_element_by_id('salary').send_keys(wage) | |
529 | + | |
530 | + bank_list = self.driver.find_elements_by_xpath('//*[@id="deputybank"]/option') | |
531 | + select = Select(self.driver.find_element_by_id('deputybank')) # 委托代发银行名称 | |
532 | + for item in bank_list: | |
533 | + if item.text in bank_name: | |
534 | + select.select_by_visible_text(item.text) | |
535 | + break | |
536 | + | |
537 | + self.driver.find_element_by_id('deputybankaccount').clear() | |
538 | + self.driver.find_element_by_id('deputybankaccount').send_keys(bank_num) # 银行卡号 | |
539 | + | |
540 | + # 配置定点医疗机构1 | |
541 | + self.driver.find_element_by_id('set1').click() # 配置定点医疗机构1 | |
542 | + self.driver.switch_to.frame('hosp1Frame') # 切换到frame下寻找元素 | |
543 | + self.driver.find_element_by_id('personInfoReg_search').send_keys(medical1) # 输入医院1 | |
544 | + self.driver.find_elements_by_tag_name('input')[2].click() | |
545 | + time.sleep(1) | |
546 | + tds = self.driver.find_elements_by_tag_name('td') | |
547 | + if len(tds) <= 4: | |
548 | + return False, '定点医疗机构1不存在' | |
549 | + | |
550 | + # 选择查询到的医疗机构1 | |
551 | + inputs = self.driver.find_elements_by_tag_name('input') | |
552 | + for item in inputs: | |
553 | + if item.get_attribute('value') == '选择': | |
554 | + item.click() | |
555 | + break | |
556 | + self.driver.switch_to.default_content() # 退出frame | |
557 | + self.driver.switch_to.frame('center') | |
558 | + self.driver.switch_to.frame('mainFrame') # 切换到frame下寻找元素 | |
559 | + time.sleep(1) | |
560 | + | |
561 | + # 配置定点医疗机构2 | |
562 | + self.driver.find_element_by_id('set2').click() # 配置定点医疗机构1 | |
563 | + self.driver.switch_to.frame('hosp2Frame') # 切换到frame下寻找元素 | |
564 | + self.driver.find_element_by_id('personInfoReg_search').send_keys(medical2) # 输入医院2 | |
565 | + self.driver.find_elements_by_tag_name('input')[2].click() | |
566 | + time.sleep(1) | |
567 | + tds = self.driver.find_elements_by_tag_name('td') | |
568 | + if len(tds) <= 4: | |
569 | + return False, '定点医疗机构2不存在' | |
570 | + | |
571 | + # 选择查询到的医疗机构1 | |
572 | + inputs = self.driver.find_elements_by_tag_name('input') | |
573 | + for j in inputs: | |
574 | + if j.get_attribute('value') == '选择': | |
575 | + j.click() | |
576 | + break | |
577 | + self.driver.switch_to.default_content() # 退出frame | |
578 | + self.driver.switch_to.frame('center') | |
579 | + self.driver.switch_to.frame('mainFrame') # 切换到frame下寻找元素 | |
580 | + time.sleep(1) | |
581 | + | |
582 | + # 配置定点医疗机构3 | |
583 | + if medical3: | |
584 | + self.__select_medical('set3', 'hosp3Frame', medical3) | |
585 | + # 配置定点医疗机构4 | |
586 | + if medical4: | |
587 | + self.__select_medical('set4', 'hosp4Frame', medical4) | |
588 | + # 配置定点医疗机构5 | |
589 | + if medical5: | |
590 | + self.__select_medical('set5', 'hosp5Frame', medical5) | |
591 | + | |
592 | + select = Select(self.driver.find_element_by_id('hosReason')) # 医保个人缴费原因 | |
593 | + select.select_by_visible_text('新参统') | |
594 | + select = Select(self.driver.find_element_by_id('fourReason')) # 四险个人缴费原因 | |
595 | + select.select_by_visible_text(four_save_reason) | |
596 | + # 新增中新加字段 | |
597 | + if self.job.mark == '人力资源': | |
598 | + # js_val = 'document.getElementById("staffType").value="劳务外包员工"' | |
599 | + select = Select(self.driver.find_element_by_id("staffType")) # 员工类型 | |
600 | + select.select_by_visible_text(staff_type) | |
601 | + # self.driver.execute_script(js_val) | |
602 | + # time.sleep(1) | |
603 | + # self.driver.find_element_by_id('staffType').send_keys('劳务外包员工') | |
604 | + time.sleep(1) | |
605 | + # js = "document.getElementById('photo').setAttribute('onchange',' ')" # 去除弹窗 | |
606 | + # self.driver.execute_script(js) | |
607 | + if staff_type == '劳务外包员工': | |
608 | + time.sleep(3) | |
609 | + self.new_system_prompt() | |
610 | + # js_cl1 = "document.getElementsByTagName('div')[1].style.display='none'" | |
611 | + # self.driver.execute_script(js_cl1) | |
612 | + # time.sleep(2) | |
613 | + # js = "document.getElementById('coverTop').style.display='none'" | |
614 | + # self.driver.execute_script(js) | |
615 | + # self.left_click(1259, 357) | |
616 | + time.sleep(1) | |
617 | + if staff_type != '本单位员工': | |
618 | + self.driver.find_element_by_id('employerUscc').send_keys(uniform_code) # 输入社会统一信用代码 | |
619 | + # TODO 统一信用代码输入错误处理 | |
620 | + js = "document.getElementById('employerDeptName').removeAttribute('readonly')" # 删除元素 | |
621 | + self.driver.execute_script(js) | |
622 | + time.sleep(1) | |
623 | + self.driver.find_element_by_id('employerDeptName').send_keys(uniform) # 填写用工单位名称 | |
624 | + # 设置合同开始时间 | |
625 | + try: | |
626 | + time.sleep(1) | |
627 | + js_start = 'document.getElementById("laborStartDate").value="%s";' % (laborStartDate) # | |
628 | + self.driver.execute_script(js_start) | |
629 | + time.sleep(2) | |
630 | + js_end = 'document.getElementById("laborEndDate").value="%s";' % (laborEndDate) # | |
631 | + self.driver.execute_script(js_end) | |
632 | + # self.driver.switch_to_default_content() | |
633 | + # self.driver.switch_to.frame('center') | |
634 | + # self.driver.switch_to.frame('mainFrame') | |
635 | + # self.driver.find_element_by_id('laborStartDate').clear() | |
636 | + # self.driver.find_element_by_id('laborStartDate').send_keys(laborStartDate) # 输入劳动合同开始时间 | |
637 | + # self.driver.switch_to.frame(0) | |
638 | + # self.driver.find_element_by_id('dpTodayInput').click() # 点击日期窗口的今天按钮 | |
639 | + except Exception as e: | |
640 | + logger.error(str(e)) | |
641 | + self.driver.refresh() | |
642 | + continue | |
643 | + time.sleep(1) | |
644 | + | |
645 | + # 设置合同结束时间 | |
646 | + # try: | |
647 | + # # self.driver.switch_to_default_content() | |
648 | + # # self.driver.switch_to.frame('center') | |
649 | + # # self.driver.switch_to.frame('mainFrame') | |
650 | + # # year, month, day = self.__date() | |
651 | + # js = "document.getElementById('laborEndDate').removeAttribute('readonly')" # 删除元素 | |
652 | + # self.driver.execute_script(js) | |
653 | + # # endDay = str(year) + '-' + str(month) + '-' + str(day) | |
654 | + # self.driver.find_element_by_id('laborEndDate').send_keys(laborEndDate) # 输入合同结束时间 | |
655 | + # self.driver.find_element_by_xpath( | |
656 | + # '//*[@id="newform"]/table[1]/tbody/tr/td/table/tbody/tr[9]/td[1]/strong').click() | |
657 | + # time.sleep(1) | |
658 | + # except Exception as e: | |
659 | + # logger.error(str(e)) | |
660 | + # self.driver.refresh() | |
661 | + # continue | |
662 | + time.sleep(2) | |
663 | + # 劳动合同类型 | |
664 | + select = Select(self.driver.find_element_by_id("laborContractType")) | |
665 | + select.select_by_visible_text(contract_type) | |
666 | + time.sleep(2) | |
667 | + if singed_contract in '否': | |
668 | + self.driver.find_element_by_id('signElectronicLabor0').click() | |
669 | + else: | |
670 | + self.driver.find_element_by_id('signElectronicLabor1').click() | |
671 | + time.sleep(2) | |
672 | + # self.driver.find_element_by_xpath( | |
673 | + # '//*[@id="newform"]/table[1]/tbody/tr/td/table/tbody/tr[9]/td[1]/strong').click() | |
674 | + # self.driver.find_element_by_id('employerDeptName').click() # 带出用工单位名称 | |
675 | + select = Select(self.driver.find_element_by_id("workPost")) # 岗位 | |
676 | + select.select_by_visible_text(work_post) | |
677 | + self.driver.find_element_by_id('contractSalary').send_keys(salary) # 合同约定工资薪金 | |
678 | + time.sleep(1) | |
679 | + time.sleep(2) | |
680 | + self.driver.find_element_by_id('submitshow').click() # 提交按钮 | |
681 | + try: | |
682 | + time.sleep(1) | |
683 | + self.driver.switch_to_alert().accept() # 弹窗处理 | |
684 | + except Exception as e: | |
685 | + logger.error(str(e)) | |
686 | + try: | |
687 | + time.sleep(1) | |
688 | + self.new_system_prompt() | |
689 | + except Exception as e: | |
690 | + logger.error(str(e)) | |
691 | + time.sleep(2) | |
692 | + for _ in range(3): | |
693 | + try: | |
694 | + # 确认用户信息悬浮框 | |
695 | + time.sleep(3) | |
696 | + self.driver.find_element_by_xpath('//*[@id="newDiv"]/button[1]').click() | |
697 | + break | |
698 | + except Exception as e: | |
699 | + logger.error(str(e)) | |
700 | + time.sleep(2) | |
701 | + continue | |
702 | + | |
703 | + for m in range(3): | |
704 | + # 处理操作业务成功的逻辑 | |
705 | + try: | |
706 | + msg = self.driver.find_element_by_xpath('/html/body/div[2]/form[1]/table[1]/tbody/tr[1]/td[1]/div[1]/span').text | |
707 | + if '业务导入失败' in msg: | |
708 | + logger.error(msg) | |
709 | + return True, msg | |
710 | + elif '业务导入成功' in msg: | |
711 | + logger.info(msg) | |
712 | + gov_ids = re.findall('\d{16}', msg) | |
713 | + if gov_ids: | |
714 | + gov_id = gov_ids[0].strip() | |
715 | + return True, gov_id | |
716 | + except Exception as e: | |
717 | + logger.error(str(e)) | |
718 | + return True, "等待查询反馈" | |
719 | + except Exception as e: | |
720 | + logger.error(str(e)) | |
721 | + self.driver.refresh() | |
722 | + continue | |
723 | + return constant.STATUS_INIT, comment | |
724 | + | |
725 | + def transfer_staff(self, task): | |
726 | + """北京社保转入人员参保""" | |
727 | + id_num = task['insured_id_num'] | |
728 | + name = task['insured_name'] | |
729 | + wage = task['base'] | |
730 | + | |
731 | + id_num = id_num.upper().replace(' ', '') | |
732 | + if not check_id_num(id_num=id_num): | |
733 | + logger.error('请输入正确的身份证号: {}'.format(id_num)) | |
734 | + return False, '请输入正确的身份证号: {}'.format(id_num) | |
735 | + | |
736 | + ext_infos = task['ext_info'] | |
737 | + staff_type = '' # 员工类型 | |
738 | + uniform_code = '' # 统一社会信用代码 | |
739 | + uniform = '' # 用工单位 | |
740 | + work_post = '' # 岗位 | |
741 | + salary = '' # 合同约定工资薪金 | |
742 | + laborStartDate = '' # 劳动合同开始时间 | |
743 | + laborEndDate = '' # 劳动合同结束时间 | |
744 | + contract_type = '' | |
745 | + singed_contract = '' | |
746 | + for ext_info in ext_infos: | |
747 | + if ext_info['name'] == '员工类型': | |
748 | + staff_type = ext_info['value'] | |
749 | + if ext_info['name'] == '统一社会信用代码': | |
750 | + uniform_code = ext_info['value'] | |
751 | + if ext_info['name'] == '用工单位': | |
752 | + uniform = ext_info['value'] | |
753 | + if ext_info['name'] == '岗位': | |
754 | + work_post = ext_info['value'] | |
755 | + if ext_info['name'] == '合同约定工资薪金': | |
756 | + salary = ext_info['value'] | |
757 | + if ext_info['name'] == '劳动合同开始时间': | |
758 | + laborStartDate = ext_info['value'] | |
759 | + if ext_info['name'] == '劳动合同结束时间': | |
760 | + laborEndDate = ext_info['value'] | |
761 | + if ext_info['name'] == '劳动合同类型': | |
762 | + contract_type = ext_info['value'] | |
763 | + if ext_info['name'] == '是否已签订电子劳动合同': | |
764 | + singed_contract = ext_info['value'] | |
765 | + | |
766 | + # 判断区分人力资源账户和单立户 | |
767 | + if self.job.mark == '人力资源': | |
768 | + if not staff_type: | |
769 | + staff_type = '本单位员工' | |
770 | + # return False, '员工类型为空' | |
771 | + if not uniform_code: | |
772 | + return False, '统一社会信用代码为空' | |
773 | + if not work_post: | |
774 | + return False, '岗位为空' | |
775 | + if not salary: | |
776 | + salary = wage | |
777 | + # return False, '合同约定工资薪金为空' | |
778 | + if not laborStartDate: | |
779 | + return False, '劳动合同开始时间为空' | |
780 | + if not laborEndDate: | |
781 | + return False, '劳动合同结束时间为空' | |
782 | + if not contract_type: | |
783 | + contract_type = '固定期限劳动合同' | |
784 | + if not singed_contract: | |
785 | + singed_contract = '否' | |
786 | + | |
787 | + | |
788 | + comment = '网络或服务器繁忙,请稍后再试' | |
789 | + for i in range(3): | |
790 | + status, comment = self.check_nav_show(div_id='level:1', one_id='link000', two_id='link003') | |
791 | + if not status: | |
792 | + return constant.STATUS_INIT, comment | |
793 | + | |
794 | + self.system_prompt() | |
795 | + | |
796 | + try: | |
797 | + time.sleep(1) | |
798 | + self.driver.find_element_by_xpath('//*[@id="Layer2"]/table/tbody/tr[1]/td[2]/a').click() # 点击关闭 | |
799 | + except Exception as e: | |
800 | + logger.error(str(e)) | |
801 | + self.driver.switch_to.default_content() | |
802 | + try: | |
803 | + # self.driver.find_element_by_xpath('/html/body/div[@class="popwrap"]/div/h2/a').click() | |
804 | + self.driver.find_element_by_xpath('/html/body/div[last()]/div[@class="popup_top"]/h2/a').click() | |
805 | + except Exception as e: | |
806 | + logger.info('没有提示') | |
807 | + logger.error(str(e)) | |
808 | + time.sleep(2) | |
809 | + try: | |
810 | + self.driver.find_element_by_xpath('/html/body/div[@class="popwrap"]/div/h2/a').click() | |
811 | + except Exception as e: | |
812 | + logger.info('没有提示') | |
813 | + logger.error(str(e)) | |
814 | + self.driver.switch_to.default_content() | |
815 | + self.driver.switch_to.frame('center') | |
816 | + self.driver.switch_to.frame('mainFrame') | |
817 | + try: | |
818 | + time.sleep(1) | |
819 | + self.driver.find_element_by_id('button').click() # 点击普通增员 | |
820 | + except Exception as e: | |
821 | + logger.error(str(e)) | |
822 | + self.driver.refresh() | |
823 | + continue | |
824 | + | |
825 | + try: | |
826 | + time.sleep(1) | |
827 | + self.driver.find_element_by_xpath('//*[@id="Layer2"]/table/tbody/tr[1]/td[2]/a').click() # 点击关闭 | |
828 | + except Exception as e: | |
829 | + logger.error(str(e)) | |
830 | + | |
831 | + try: | |
832 | + self.driver.find_element_by_id('dataNormalAdd.idCard').send_keys(id_num) # 输入身份证号 | |
833 | + self.driver.find_element_by_id('dataNormalAdd.personName').send_keys(name) # 输入姓名 | |
834 | + self.driver.find_element_by_xpath('//*[@id="newform"]/table[1]/tbody/tr/td/table/tbody/tr[2]/td[2]/label[2]/input').click() # 点击查询 | |
835 | + time.sleep(1) | |
836 | + | |
837 | + # 判断该人员是否可以正常转入 | |
838 | + card_text = self.driver.find_element_by_xpath("//*[@id='listzone']/table[2]/tbody/tr[1]/td[1]/table[1]/tbody/tr[2]/td[2]").text | |
839 | + if id_num not in card_text: | |
840 | + cause = self.driver.find_element_by_xpath("//*[@id='messages']/ul[1]/li[1]/span").text | |
841 | + if '查询结果为空' in cause or '不能进行转入人员增加' in cause: | |
842 | + return False, cause | |
843 | + return True, cause | |
844 | + | |
845 | + person_type = self.driver.find_element_by_xpath('//*[@id="listzone"]/table[2]/tbody/tr/td/table/tbody/tr[5]/td[2]').text | |
846 | + person_type = person_type.replace(' ', '').replace('\n', '').replace('\t', '') | |
847 | + hhr_type = person_type # 转入人员必须返回户籍类型 | |
848 | + logger.info("转入户籍类型:" + str(hhr_type)) | |
849 | + | |
850 | + if person_type == '自由职业人员': | |
851 | + person_type = '本市城镇职工' | |
852 | + elif person_type == '本市农村劳动力(24号文)': | |
853 | + person_type = '本市农村劳动力(养24号文)' | |
854 | + elif person_type == '灵活就业': | |
855 | + logger.info('户籍类型:灵活就业') | |
856 | + return False, person_type | |
857 | + select = Select(self.driver.find_element_by_id('personType')) # 缴费人员类别 | |
858 | + select.select_by_visible_text(person_type) | |
859 | + self.driver.find_element_by_id('pay').send_keys(wage) # 申报月工资收入 | |
860 | + | |
861 | + # logger.info('备注字段:{}'.format(self.job.mark)) | |
862 | + if self.job.mark in '人力资源': | |
863 | + print(self.job.mark) | |
864 | + time.sleep(2) | |
865 | + select = Select(self.driver.find_element_by_id("staffType")) # 员工类型 | |
866 | + select.select_by_visible_text(staff_type) | |
867 | + time.sleep(1) | |
868 | + # 设置合同开始时间 | |
869 | + try: | |
870 | + time.sleep(1) | |
871 | + js_start = 'document.getElementById("laborStartDate").value="%s";' % (laborStartDate) # | |
872 | + self.driver.execute_script(js_start) | |
873 | + time.sleep(2) | |
874 | + js_end = 'document.getElementById("laborEndDate").value="%s";' % (laborEndDate) # | |
875 | + self.driver.execute_script(js_end) | |
876 | + # self.driver.switch_to_default_content() | |
877 | + # self.driver.switch_to.frame('center') | |
878 | + # self.driver.switch_to.frame('mainFrame') | |
879 | + # self.driver.find_element_by_id('laborStartDate').clear() | |
880 | + # self.driver.find_element_by_id('laborStartDate').send_keys(laborStartDate) # 输入劳动合同开始时间 | |
881 | + # self.driver.switch_to.frame(0) | |
882 | + # self.driver.find_element_by_id('dpTodayInput').click() # 点击日期窗口的今天按钮 | |
883 | + except Exception as e: | |
884 | + logger.error(str(e)) | |
885 | + self.driver.refresh() | |
886 | + continue | |
887 | + time.sleep(1) | |
888 | + # 设置合同结束时间 | |
889 | + # try: | |
890 | + # # self.driver.switch_to_default_content() | |
891 | + # # self.driver.switch_to.frame('center') | |
892 | + # # self.driver.switch_to.frame('mainFrame') | |
893 | + # # year, month, day = self.__date() | |
894 | + # js = "document.getElementById('laborEndDate').removeAttribute('readonly')" # 删除元素 | |
895 | + # self.driver.execute_script(js) | |
896 | + # # endDay = str(year) + '-' + str(month) + '-' + str(day) | |
897 | + # self.driver.find_element_by_id('laborEndDate').send_keys(laborEndDate) # 输入合同结束时间 | |
898 | + # self.driver.find_element_by_xpath('//*[@id="newform"]/table[1]/tbody/tr/td/table/tbody/tr[9]/td[1]/strong').click() | |
899 | + # time.sleep(1) | |
900 | + # except Exception as e: | |
901 | + # logger.error(str(e)) | |
902 | + # self.driver.refresh() | |
903 | + # continue | |
904 | + # 劳动合同类型 | |
905 | + select = Select(self.driver.find_element_by_id("laborContractType")) | |
906 | + select.select_by_visible_text(contract_type) | |
907 | + time.sleep(2) | |
908 | + # 签订劳动合同时间 | |
909 | + # self.driver.find_element_by_id('laborSignDate').clear() | |
910 | + # self.driver.find_element_by_id('laborSignDate').send_keys(laborStartDate) | |
911 | + # self.driver.switch_to_default_content() | |
912 | + # self.driver.switch_to.frame('center') | |
913 | + # self.driver.switch_to.frame('mainFrame') | |
914 | + time.sleep(2) | |
915 | + if staff_type == '劳务外包员工': | |
916 | + self.system_prompt() | |
917 | + if staff_type != '本单位员工': | |
918 | + self.driver.find_element_by_id('employerUscc').send_keys(uniform_code) # 输入社会统一信用代码 | |
919 | + # TODO 统一信用代码输入错误处理 | |
920 | + js = "document.getElementById('employerDeptName').removeAttribute('readonly')" # 删除元素 | |
921 | + self.driver.execute_script(js) | |
922 | + time.sleep(1) | |
923 | + # self.driver.find_element_by_id('employerDeptName').send_keys(uniform) # 填写用工单位名称 | |
924 | + self.driver.find_element_by_id('employerDeptName').click() # 填写用工单位名称 | |
925 | + # self.driver.find_element_by_xpath( | |
926 | + # '//*[@id="newform"]/table[1]/tbody/tr/td/table/tbody/tr[9]/td[1]/strong').click() | |
927 | + # self.driver.find_element_by_id('employerDeptName').click() # 带出用工单位名称 | |
928 | + select = Select(self.driver.find_element_by_id("workPost")) # 岗位 | |
929 | + select.select_by_visible_text(work_post) | |
930 | + self.driver.find_element_by_id('contractSalary').send_keys(salary) # 合同约定工资薪金 | |
931 | + time.sleep(2) | |
932 | + # 是否已签订电子劳动合同 | |
933 | + if singed_contract in '否': | |
934 | + time.sleep(2) | |
935 | + self.driver.find_element_by_id('signElectronicLabor0').click() | |
936 | + else: | |
937 | + time.sleep(2) | |
938 | + self.driver.find_element_by_id('signElectronicLabor1').click() | |
939 | + else: | |
940 | + try: | |
941 | + time.sleep(1) # | |
942 | + js_start = 'document.getElementById("laborStartDate").value="%s";' % (laborStartDate) # | |
943 | + self.driver.execute_script(js_start) | |
944 | + time.sleep(2) | |
945 | + js_end = 'document.getElementById("laborEndDate").value="%s";' % (laborEndDate) # | |
946 | + self.driver.execute_script(js_end) | |
947 | + except Exception as e: | |
948 | + logger.error(str(e)) | |
949 | + self.driver.refresh() | |
950 | + continue | |
951 | + time.sleep(1) | |
952 | + # 劳动合同类型 | |
953 | + select = Select(self.driver.find_element_by_id("laborContractType")) | |
954 | + select.select_by_visible_text(contract_type) | |
955 | + time.sleep(2) | |
956 | + select = Select(self.driver.find_element_by_id("workPost")) # 岗位 | |
957 | + select.select_by_visible_text(work_post) | |
958 | + time.sleep(2) | |
959 | + self.driver.find_element_by_id('contractSalary').send_keys(salary) # 合同约定工资薪金 | |
960 | + time.sleep(2) | |
961 | + # 是否已签订电子劳动合同 | |
962 | + if singed_contract in '否': | |
963 | + time.sleep(2) | |
964 | + self.driver.find_element_by_id('signElectronicLabor0').click() | |
965 | + else: | |
966 | + time.sleep(2) | |
967 | + self.driver.find_element_by_id('signElectronicLabor1').click() | |
968 | + time.sleep(1) | |
969 | + | |
970 | + # return True, '等待查询反馈' | |
971 | + self.driver.find_element_by_id('submitButton').click() # 点击【提交】 | |
972 | + | |
973 | + # 判断弹窗错误信息 | |
974 | + try: | |
975 | + alert_text = self.driver.switch_to_alert().text | |
976 | + logger.error('{}'.format(alert_text)) | |
977 | + self.driver.switch_to_alert().accept() | |
978 | + return False, alert_text | |
979 | + except Exception as e: | |
980 | + logger.error(str(e)) | |
981 | + | |
982 | + for k in range(4): | |
983 | + time.sleep(2) | |
984 | + sound_code = self.driver.page_source | |
985 | + if '人员已处于正常缴费状态' in sound_code: | |
986 | + return True, '等待查询反馈' + '#' + hhr_type | |
987 | + elif '业务操作失败' in sound_code: | |
988 | + logger.error('业务操作失败') | |
989 | + cause = self.driver.find_element_by_xpath('//*[@id="0"]/td/table/tbody/tr[3]/td/span/span').text | |
990 | + return True, cause + '#' + hhr_type | |
991 | + elif '业务操作成功' in sound_code: | |
992 | + gov_id = self.driver.find_element_by_xpath('//*[@id="0"]/td/table/tbody/tr[2]/td/span/span').text | |
993 | + logger.info("转入流水号:" + str(gov_id)) | |
994 | + if gov_id: | |
995 | + gov_id = gov_id.replace(' ', '') | |
996 | + return True, gov_id + '#' + hhr_type | |
997 | + return True, '等待查询反馈' | |
998 | + except Exception as e: | |
999 | + logger.error(str(e)) | |
1000 | + self.driver.refresh() | |
1001 | + continue | |
1002 | + return constant.STATUS_INIT, comment | |
1003 | + | |
1004 | + def __decrease(self): # 有问题 | |
1005 | + logger.info('start decrease ') | |
1006 | + tasks = self.__get_tasks(constant.OP_TYPE_DECREASE, constant.STATUS_INIT) | |
1007 | + if not tasks: | |
1008 | + return | |
1009 | + try: | |
1010 | + self.close_notice() | |
1011 | + except Exception as e: | |
1012 | + logger.info(str(e)) | |
1013 | + | |
1014 | + for task in tasks: | |
1015 | + task_detail, err_code = waclient.get_si_task(self.ctx, task['id']) | |
1016 | + if err_code != 200: | |
1017 | + break | |
1018 | + | |
1019 | + response = self.do_decrease(task_detail) | |
1020 | + comment = response[1] | |
1021 | + | |
1022 | + # logger.info(('---***---')) | |
1023 | + # logger.info(response) | |
1024 | + # logger.info(comment) | |
1025 | + ins = self.get_all_ins(task_detail) | |
1026 | + if not ins: | |
1027 | + ins = ['医疗保险', '生育保险', '养老保险', '失业保险', '工伤保险'] | |
1028 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_CONFORMING) | |
1029 | + | |
1030 | + if self.is_once_submit(): | |
1031 | + return_status = constant.STATUS_SUCCESS | |
1032 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_SUCCESS) | |
1033 | + else: | |
1034 | + return_status = constant.STATUS_CONFORMING | |
1035 | + | |
1036 | + # if response[0] != constant.STATUS_INIT: | |
1037 | + # if not response[0]: | |
1038 | + # return_status = constant.STATUS_FAIL | |
1039 | + # result = self.return_ins_result(ins=ins, status=constant.STATUS_FAIL) | |
1040 | + # else: | |
1041 | + # return_status = constant.STATUS_INIT | |
1042 | + # result = self.return_ins_result(ins=ins, status=constant.STATUS_INIT) | |
1043 | + print('---***--') | |
1044 | + print(return_status) | |
1045 | + print(comment) | |
1046 | + print(result) | |
1047 | + if '等待查询反馈' in comment: | |
1048 | + return_status = constant.STATUS_CONFORMING | |
1049 | + if comment.isdigit(): # 减员成功 | |
1050 | + return_status = constant.STATUS_SUCCESS | |
1051 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_SUCCESS) | |
1052 | + if '无权查看此人信息' in comment: | |
1053 | + return_status = constant.STATUS_SUCCESS | |
1054 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_FAIL) | |
1055 | + if '[养老缴费(中断)转出未转入] [失业缴费(中断)转出未转入] [工伤缴费(中断)转出未转入] [医保缴费 (暂停)缴费]' in comment: | |
1056 | + return_status = constant.STATUS_SUCCESS | |
1057 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_SUCCESS) | |
1058 | + if '人员已处于中断缴费状态,不允许重复减员' in comment: | |
1059 | + return_status = constant.STATUS_SUCCESS | |
1060 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_SUCCESS) | |
1061 | + response = waclient.update_si_task(self.ctx, task['id'], return_status, comment, result=result) | |
1062 | + | |
1063 | + if response[1] != 200: | |
1064 | + logger.error("Task Status Update Fail: " + task['id']) | |
1065 | + | |
1066 | + def do_decrease(self, task): | |
1067 | + """北京社保减员操作""" | |
1068 | + logger.info('statr do decrease') | |
1069 | + id_num = task['insured_id_num'] | |
1070 | + name = task['insured_name'] | |
1071 | + | |
1072 | + ext_infos = task['ext_info'] | |
1073 | + decrease_reason = '' # 个人停止缴费原因 | |
1074 | + for ext_info in ext_infos: | |
1075 | + if ext_info['name'] == '个人停止缴费原因': | |
1076 | + decrease_reason = ext_info['value'] | |
1077 | + if not decrease_reason: | |
1078 | + decrease_reason = '本人意愿解除劳动合同' | |
1079 | + # return False, '请输入正确的个人停止缴费原因' | |
1080 | + if decrease_reason not in ['劳动合同期满', '非本人意愿解除劳动合同', '本人意愿解除劳动合同']: | |
1081 | + return False, '请输入正确的个人停止缴费原因: {}'.format(decrease_reason) | |
1082 | + | |
1083 | + if not check_id_num(id_num=id_num): | |
1084 | + logger.error('请输入正确的身份证号: {}'.format(id_num)) | |
1085 | + return False, '请输入正确的身份证号: {}'.format(id_num) | |
1086 | + | |
1087 | + comment = '网络或服务器繁忙,请稍后再试' | |
1088 | + for i in range(3): | |
1089 | + status, comment = self.check_nav_show(div_id='level:1', one_id='link000', two_id='link005') | |
1090 | + if not status: | |
1091 | + return constant.STATUS_INIT, comment | |
1092 | + | |
1093 | + self.driver.switch_to.default_content() # 退出frame | |
1094 | + self.driver.switch_to.frame('center') | |
1095 | + self.driver.switch_to.frame('mainFrame') # 切换到frame下寻找元素 | |
1096 | + | |
1097 | + try: | |
1098 | + time.sleep(1) | |
1099 | + self.driver.find_element_by_xpath('//*[@id="Layer2"]/table/tbody/tr[1]/td[2]/a').click() | |
1100 | + except Exception as e: | |
1101 | + logger.error(str(e)) | |
1102 | + | |
1103 | + try: | |
1104 | + self.driver.find_element_by_id('cut').click() # 点击零星减员 | |
1105 | + time.sleep(1) | |
1106 | + except Exception as e: | |
1107 | + logger.error(str(e)) | |
1108 | + self.driver.refresh() | |
1109 | + continue | |
1110 | + | |
1111 | + try: | |
1112 | + self.driver.find_element_by_id('idCard').send_keys(id_num) # 输入身份证号 | |
1113 | + self.driver.find_element_by_id('personName').send_keys(name) # 输入名字 | |
1114 | + time.sleep(1) | |
1115 | + self.driver.find_element_by_id('select').click() # 点击查询 | |
1116 | + try: | |
1117 | + printinfo = self.driver.find_element_by_id('printinfo') | |
1118 | + if printinfo.is_displayed(): | |
1119 | + cause1 = self.driver.find_element_by_xpath("//*[@id='tbody1']/tr[2]/td[2]/font").text | |
1120 | + return False, cause1 | |
1121 | + wronginfo = self.driver.find_element_by_id('wronginfo') | |
1122 | + if wronginfo.is_displayed(): | |
1123 | + cause2 = self.driver.find_element_by_xpath("//*[@id='tbody1']/tr[3]/td[2]/font").text | |
1124 | + return False, cause2 | |
1125 | + retireinfo = self.driver.find_element_by_id('retireinfo') | |
1126 | + if retireinfo.is_displayed(): | |
1127 | + cause3 = self.driver.find_element_by_xpath("//*[@id='tbody1']/tr[4]/td[2]/font").text | |
1128 | + return False, cause3 | |
1129 | + except Exception as e: | |
1130 | + logger.error(str(e)) | |
1131 | + # self.driver.refresh() | |
1132 | + # continue | |
1133 | + | |
1134 | + # 判断用户是否已停缴、中止、断缴等状态 | |
1135 | + time.sleep(1) | |
1136 | + jfzt_text = self.driver.find_element_by_xpath('//*[@id="tbody2"]/tr[3]/td[2]').text | |
1137 | + if len(re.findall(r'正常', jfzt_text)) != 4: | |
1138 | + return True, jfzt_text | |
1139 | + time.sleep(2) | |
1140 | + # 点击提交按钮 | |
1141 | + logger.info("开始点击提交按钮... ...") | |
1142 | + | |
1143 | + # TODO 减员改动待测试 | |
1144 | + select = Select(self.driver.find_element_by_id("reason")) # 个人停止缴费原因 | |
1145 | + select.select_by_visible_text(decrease_reason) | |
1146 | + time.sleep(1) | |
1147 | + # self.driver.find_element_by_xpath('/html/body/div[3]/h2/a').click() # 关闭提示信息 | |
1148 | + # self.driver.find_element_by_xpath('/html/body/div[-1]/h2/a').click() # 关闭提示信息 | |
1149 | + time.sleep(1) | |
1150 | + # js_cl = "$('.popup').remove()" | |
1151 | + # self.driver.execute_script(js_cl) | |
1152 | + js = "var aa=document.getElementsByClassName('popup')[0];aa.parentNode.removeChild(aa)" | |
1153 | + self.driver.execute_script(js) | |
1154 | + # self.left_click(1259, 357) | |
1155 | + time.sleep(1) | |
1156 | + js_cl1 = 'var child=document.getElementById("cover");child.parentNode.removeChild(child);' | |
1157 | + self.driver.execute_script(js_cl1) | |
1158 | + time.sleep(1) | |
1159 | + # 点击提交按钮 | |
1160 | + self.driver.find_element_by_id('submit').click() # 保存 save # 提交:submit | |
1161 | + time.sleep(10) | |
1162 | + for k in range(4): | |
1163 | + time.sleep(3) | |
1164 | + sound_code = self.driver.page_source | |
1165 | + if '服务器繁忙' in sound_code: | |
1166 | + logger.error('服务器繁忙,请稍后再试') | |
1167 | + self.driver.refresh() | |
1168 | + continue | |
1169 | + elif '业务操作失败' in sound_code: | |
1170 | + logger.error('减员失败,请检查是否重复减员') | |
1171 | + cause = etree.HTML(sound_code).xpath('//*[@id="cutform"]/table/tbody/tr[2]/td/table/tbody/tr[2]/td/p/span[2]/text()') | |
1172 | + if cause: | |
1173 | + cause = cause[1] + cause[2] | |
1174 | + return True, '业务操作失败: ' + cause | |
1175 | + elif '业务操作成功' in sound_code: | |
1176 | + gov_id = self.driver.find_element_by_xpath('//*[@id="cutform"]/table/tbody/tr[2]/td/table/tbody/tr[2]/td/p/span/span').text | |
1177 | + if gov_id: | |
1178 | + gov_id = gov_id.replace(' ', '') | |
1179 | + return True, gov_id | |
1180 | + return True, '等待查询反馈' | |
1181 | + except Exception as e: | |
1182 | + logger.error(str(e)) | |
1183 | + self.driver.refresh() | |
1184 | + continue | |
1185 | + return constant.STATUS_INIT, comment | |
1186 | + | |
1187 | + def __payback(self): | |
1188 | + tasks = self.__get_tasks(constant.OP_TYPE_PAYBACK, constant.STATUS_INIT) | |
1189 | + if not tasks: | |
1190 | + return | |
1191 | + | |
1192 | + self.close_notice() | |
1193 | + | |
1194 | + # 判断业务办理时间 | |
1195 | + try: | |
1196 | + msg = self.driver.find_element_by_xpath('/html/body/table[3]/tbody/tr/td').text | |
1197 | + if '该申报业务办理时间为每月5日-25日' in msg: | |
1198 | + return | |
1199 | + except Exception as e: | |
1200 | + logger.error(str(e)) | |
1201 | + | |
1202 | + for task in tasks: | |
1203 | + task_detail, err_code = waclient.get_si_task(self.ctx, task['id']) | |
1204 | + if err_code != 200: | |
1205 | + break | |
1206 | + | |
1207 | + response = self.do_payback(task_detail) | |
1208 | + comment = response[1] | |
1209 | + ins = self.get_all_ins(task_detail) | |
1210 | + if not ins: | |
1211 | + ins = ['医疗保险', '生育保险', '养老保险', '失业保险', '工伤保险'] | |
1212 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_CONFORMING) | |
1213 | + | |
1214 | + if not self.is_once_submit_payback(): | |
1215 | + if self.is_once_submit(): | |
1216 | + return_status = constant.STATUS_SUCCESS | |
1217 | + else: | |
1218 | + return_status = constant.STATUS_CONFORMING | |
1219 | + | |
1220 | + if response[0] != constant.STATUS_INIT: | |
1221 | + if not response[0]: | |
1222 | + return_status = constant.STATUS_FAIL | |
1223 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_FAIL) | |
1224 | + else: | |
1225 | + return_status = constant.STATUS_INIT | |
1226 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_INIT) | |
1227 | + | |
1228 | + response = waclient.update_si_task(self.ctx, task['id'], return_status, comment, result=result) | |
1229 | + if response[1] != 200: | |
1230 | + logger.error("Task Status Update Fail: " + task['id']) | |
1231 | + | |
1232 | + def do_payback(self, task): | |
1233 | + """北京社保补缴操作""" | |
1234 | + id_num = task['insured_id_num'] | |
1235 | + name = task['insured_name'] | |
1236 | + start_month = task['start_month'] | |
1237 | + end_month = task['end_month'] | |
1238 | + | |
1239 | + id_num = id_num.upper().replace(' ', '') | |
1240 | + if not check_id_num(id_num=id_num): | |
1241 | + logger.error('请输入正确的身份证号: {}'.format(id_num)) | |
1242 | + return False, '请输入正确的身份证号: {}'.format(id_num) | |
1243 | + | |
1244 | + month_lst = [] | |
1245 | + start = time.strftime('%Y-%m', time.localtime(start_month)) | |
1246 | + end = time.strftime('%Y-%m', time.localtime(end_month)) | |
1247 | + start_month = time.strptime(start, '%Y-%m') | |
1248 | + end_month = time.strptime(end, '%Y-%m') | |
1249 | + start_month = datetime.datetime(start_month[0], start_month[1], start_month[2], start_month[3], start_month[4], start_month[5]) | |
1250 | + end_month = datetime.datetime(end_month[0], end_month[1], end_month[2], end_month[3], end_month[4], end_month[5]) | |
1251 | + result = (end_month - start_month).days | |
1252 | + if result < 0: | |
1253 | + return False, '补缴起始日期不能大于结束日期' | |
1254 | + elif result == 0: | |
1255 | + month_lst.append(start) | |
1256 | + elif 0 < result < 56: | |
1257 | + month_lst.append(start) | |
1258 | + elif 56 <= result < 84: | |
1259 | + month_lst.append(start) | |
1260 | + month_lst.append(end) | |
1261 | + elif 84 <= result < 112: | |
1262 | + month_lst.append(start) | |
1263 | + lst = start.split('-') | |
1264 | + mid = '' | |
1265 | + if int(lst[1]) <= 11: | |
1266 | + mid = lst[0] + '-' + str(int(lst[1]) + 1) | |
1267 | + elif int(lst[1]) == 12: | |
1268 | + mid = str(int(lst[0]) + 1) + "-01" | |
1269 | + month_lst.append(mid) | |
1270 | + month_lst.append(end) | |
1271 | + else: | |
1272 | + return False, '补缴日期不能超过规定3个月以上' | |
1273 | + | |
1274 | + comment = '网络或服务器繁忙,请稍后再试' | |
1275 | + for i in range(3): | |
1276 | + status, comment = self.check_nav_show(div_id='level:1', one_id='link000', two_id='link031') | |
1277 | + if not status: | |
1278 | + return constant.STATUS_INIT, comment | |
1279 | + | |
1280 | + # 判断业务办理时间 | |
1281 | + try: | |
1282 | + msg = self.driver.find_element_by_xpath('/html/body/table[3]/tbody/tr/td').text | |
1283 | + if '该申报业务办理时间为每月5日-25日' in msg: | |
1284 | + return | |
1285 | + except Exception as e: | |
1286 | + logger.error(str(e)) | |
1287 | + | |
1288 | + try: | |
1289 | + time.sleep(1) | |
1290 | + self.driver.find_element_by_id('addIndaddButton').click() # 点击新增补缴 | |
1291 | + time.sleep(2) | |
1292 | + self.driver.find_element_by_name('idCode').send_keys(id_num) # 输入身份证号 | |
1293 | + self.driver.find_element_by_name('name').send_keys(name) # 输入姓名 | |
1294 | + self.driver.find_element_by_id('addQueryBtn').click() # 点击查询 | |
1295 | + time.sleep(2) | |
1296 | + | |
1297 | + try: | |
1298 | + source_text = self.driver.page_source | |
1299 | + if '没有找到符合条件的个人用户信息' in source_text: | |
1300 | + return False, '没有找到符合条件的个人用户信息' | |
1301 | + elif '该人不在该单位' in source_text: | |
1302 | + return False, '该人不在该单位' | |
1303 | + elif '未查询到满足延迟三个月补缴条件的数据' in source_text: | |
1304 | + return True, '未查询到满足延迟三个月补缴条件的数据,如需办理其他补缴业务请通过经办窗口办理。' | |
1305 | + | |
1306 | + # payback_btn = self.driver.find_element_by_id('buttonSubmit') | |
1307 | + # if not payback_btn: | |
1308 | + # msg = self.driver.find_element_by_xpath('//*[@id="show"]/table[2]/tbody/tr[1]/td/span').text | |
1309 | + # if msg is not None: | |
1310 | + # return False, msg | |
1311 | + except Exception as e: | |
1312 | + logger.error(str(e)) | |
1313 | + | |
1314 | + trs = self.driver.find_elements_by_xpath('//*[@id="indAddPayForm"]/table/tbody/tr') | |
1315 | + if not trs: | |
1316 | + self.driver.refresh() | |
1317 | + continue | |
1318 | + | |
1319 | + for k in range(1, len(trs)+1): | |
1320 | + mark_xpath = "//*[@id='indAddPayForm']/table/tbody/tr[" + str(k) + "]/td" | |
1321 | + tds = self.driver.find_elements_by_xpath(mark_xpath) | |
1322 | + if len(tds) != 15: | |
1323 | + continue | |
1324 | + checkbox = self.driver.find_element_by_xpath(mark_xpath + "[1]/input[1]") | |
1325 | + month_text = self.driver.find_element_by_xpath(mark_xpath + "[2]").text | |
1326 | + month_text.strip() | |
1327 | + | |
1328 | + if not checkbox.is_enabled(): | |
1329 | + continue | |
1330 | + if not checkbox.is_selected() and month_text in month_lst: | |
1331 | + checkbox.click() | |
1332 | + | |
1333 | + try: | |
1334 | + # 个人补缴申报导入 | |
1335 | + self.driver.find_element_by_id("buttonSubmit").click() | |
1336 | + self.driver.switch_to_alert().accept() | |
1337 | + except Exception as e: | |
1338 | + logger.error(str(e)) | |
1339 | + | |
1340 | + for _ in range(3): | |
1341 | + try: | |
1342 | + time.sleep(2) | |
1343 | + status = self.driver.find_element_by_xpath('/html/body/table/tbody/tr/td/table/tbody/tr[2]/td/p').text | |
1344 | + # '/html/body/table/tbody/tr/td/table/tbody/tr[3]/td/p/span/span/text()' # 流水号 | |
1345 | + if status and '操作成功' not in status: # 个人补缴申报导入操作成功! | |
1346 | + return False, status | |
1347 | + # 点击返回按钮 | |
1348 | + self.driver.find_element_by_xpath('/html/body/center/input').click() | |
1349 | + break | |
1350 | + except Exception as e: | |
1351 | + logger.error(str(e)) | |
1352 | + continue | |
1353 | + | |
1354 | + # 选择保存成功的记录 | |
1355 | + for _ in range(3): | |
1356 | + try: | |
1357 | + time.sleep(2) | |
1358 | + record_trs = self.driver.find_elements_by_xpath('/html/body/div[1]/table/tbody[2]/tr') | |
1359 | + if len(record_trs) <= 1: | |
1360 | + return True, "等待查询反馈" | |
1361 | + | |
1362 | + for n in range(1, len(record_trs)): | |
1363 | + # idcard_xpath = "/html/body/div[1]/table/tbody[2]/tr[" + str(n) + "]/td[4]" | |
1364 | + check_xpath = "/html/body/div[1]/table/tbody[2]/tr[" + str(n) + "]/td[1]/input" | |
1365 | + # if id_num != self.driver.find_element_by_xpath(idcard_xpath).text: | |
1366 | + # continue | |
1367 | + cb_record = self.driver.find_element_by_xpath(check_xpath) | |
1368 | + if not cb_record.is_selected(): | |
1369 | + cb_record.click() | |
1370 | + break | |
1371 | + except Exception as e: | |
1372 | + logger.error(str(e)) | |
1373 | + continue | |
1374 | + | |
1375 | + try: | |
1376 | + # 汇总提交 | |
1377 | + self.driver.find_element_by_id('submitButton').click() | |
1378 | + self.driver.switch_to_alert().accept() | |
1379 | + except Exception as e: | |
1380 | + logger.error(str(e)) | |
1381 | + | |
1382 | + # 最终交易结果页面 | |
1383 | + for _ in range(3): | |
1384 | + try: | |
1385 | + time.sleep(2) | |
1386 | + status = self.driver.find_element_by_xpath('/html/body/table/tbody/tr/td/table/tbody/tr[2]/td/p').text | |
1387 | + if status and '操作成功' not in status: # 个人补缴申报导入操作成功! | |
1388 | + return True, status | |
1389 | + id_code = self.driver.find_element_by_xpath('/html/body/table/tbody/tr/td/table/tbody/tr[3]/td/p/span/span').text | |
1390 | + return True, id_code | |
1391 | + except Exception as e: | |
1392 | + logger.error(str(e)) | |
1393 | + continue | |
1394 | + return True, "等待查询反馈" | |
1395 | + except Exception as e: | |
1396 | + logger.error(str(e)) | |
1397 | + self.driver.refresh() | |
1398 | + continue | |
1399 | + return constant.STATUS_INIT, comment | |
1400 | + | |
1401 | + def __confirm(self): | |
1402 | + tasks = self.__get_tasks('', constant.STATUS_CONFORMING) | |
1403 | + if not tasks: | |
1404 | + return | |
1405 | + | |
1406 | + self.close_notice() | |
1407 | + | |
1408 | + for task in tasks: | |
1409 | + task_detail, err_code = waclient.get_si_task(self.ctx, task['id']) | |
1410 | + if err_code != 200: | |
1411 | + break | |
1412 | + | |
1413 | + response = self.do_confirm(task_detail) | |
1414 | + confirm_result = response[0] | |
1415 | + comment = response[1] | |
1416 | + ins = self.get_all_ins(task_detail) | |
1417 | + if not ins: | |
1418 | + ins = ['医疗保险', '生育保险', '养老保险', '失业保险', '工伤保险'] | |
1419 | + result = self.return_ins_result(ins=ins) | |
1420 | + | |
1421 | + if confirm_result == constant.STATUS_FAIL: | |
1422 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_FAIL) | |
1423 | + elif confirm_result == constant.STATUS_CONFORMING: | |
1424 | + continue | |
1425 | + elif confirm_result == constant.STATUS_INIT: | |
1426 | + result = self.return_ins_result(ins=ins, status=constant.STATUS_INIT) | |
1427 | + | |
1428 | + response = waclient.update_si_task(self.ctx, task['id'], confirm_result, comment, result=result) | |
1429 | + if response[1] != 200: | |
1430 | + logger.error("Task Status Update Fail: ", task['id']) | |
1431 | + | |
1432 | + def do_confirm(self, task): | |
1433 | + """北京社保查询""" | |
1434 | + comment = task['comment'] | |
1435 | + if re.findall('(\d{16})', comment) and len(comment) <= 17: | |
1436 | + return constant.STATUS_SUCCESS, '成功' | |
1437 | + else: | |
1438 | + id_num = task['insured_id_num'] | |
1439 | + op_type = task['op_type'] | |
1440 | + | |
1441 | + for i in range(3): | |
1442 | + status, comments = self.check_nav_show(div_id='level:2', one_id='link012', two_id='link013') | |
1443 | + if not status: | |
1444 | + return constant.STATUS_CONFORMING, comment | |
1445 | + | |
1446 | + # 设置开始日期 | |
1447 | + try: | |
1448 | + self.driver.switch_to.default_content() # 退出frame | |
1449 | + self.driver.switch_to.frame('center') | |
1450 | + self.driver.switch_to.frame('mainFrame') # 切换到frame下寻找元素 | |
1451 | + time.sleep(2) | |
1452 | + self.driver.find_element_by_id('startDate').click() | |
1453 | + self.driver.switch_to_frame(self.driver.find_element_by_xpath("//iframe[contains(@src,'http://fuwu.rsj.beijing.gov.cn/csibiz/csirp/js/datepicker/My97DatePicker.htm')]")) | |
1454 | + time.sleep(2) | |
1455 | + self.driver.find_element_by_id('dpOkInput').click() | |
1456 | + time.sleep(2) | |
1457 | + # self.driver.switch_to.frame(0) | |
1458 | + # start_trs = self.driver.find_elements_by_xpath('/html/body/div/div[3]/table/tbody/tr') | |
1459 | + # if len(start_trs) == 7: | |
1460 | + # start_tds = self.driver.find_elements_by_xpath('/html/body/div/div[3]/table/tbody/tr[2]/td') | |
1461 | + # for item in start_tds: | |
1462 | + # if item.text == '1': | |
1463 | + # item.click() | |
1464 | + # break | |
1465 | + except Exception as e: | |
1466 | + logger.error(str(e)) | |
1467 | + self.driver.refresh() | |
1468 | + continue | |
1469 | + | |
1470 | + # 设置结束日期 | |
1471 | + try: | |
1472 | + self.driver.switch_to_default_content() | |
1473 | + self.driver.switch_to.frame('center') | |
1474 | + self.driver.switch_to.frame('mainFrame') | |
1475 | + time.sleep(2) | |
1476 | + self.driver.find_element_by_id('endDate').click() | |
1477 | + # http://fuwu.rsj.beijing.gov.cn/csibiz/csirp/js/datepicker/My97DatePicker.htm | |
1478 | + time.sleep(2) | |
1479 | + self.driver.switch_to_frame(self.driver.find_element_by_xpath( | |
1480 | + "//iframe[contains(@src,'http://fuwu.rsj.beijing.gov.cn/csibiz/csirp/js/datepicker/My97DatePicker.htm')]")) | |
1481 | + time.sleep(2) | |
1482 | + # self.driver.switch_to.frame(0) | |
1483 | + self.driver.find_element_by_id('dpOkInput').click() # 点击日期窗口的确定按钮 | |
1484 | + except Exception as e: | |
1485 | + logger.error(str(e)) | |
1486 | + self.driver.refresh() | |
1487 | + continue | |
1488 | + | |
1489 | + self.driver.switch_to_default_content() | |
1490 | + self.driver.switch_to.frame('center') | |
1491 | + self.driver.switch_to.frame('mainFrame') | |
1492 | + self.driver.find_element_by_id('idCard').clear() | |
1493 | + self.driver.find_element_by_id('idCard').send_keys(id_num) | |
1494 | + dataTypeSelect = Select(self.driver.find_element_by_id('dataTypeSelect')) | |
1495 | + | |
1496 | + if op_type == constant.OP_TYPE_INCREASE: | |
1497 | + if task['handle_type'] == "0": | |
1498 | + dataTypeSelect.select_by_visible_text('新参保人员登记') | |
1499 | + elif task['handle_type'] == "1": | |
1500 | + dataTypeSelect.select_by_visible_text('转入人员增加') | |
1501 | + elif op_type == constant.OP_TYPE_DECREASE: | |
1502 | + dataTypeSelect.select_by_visible_text('普通减员') | |
1503 | + | |
1504 | + statusSelect = Select(self.driver.find_element_by_id('statusSelect')) | |
1505 | + statusSelect.select_by_visible_text('处理结束') | |
1506 | + | |
1507 | + self.driver.find_element_by_id('button_1').click() # 点击查询 | |
1508 | + time.sleep(2) | |
1509 | + | |
1510 | + trs = self.driver.find_elements_by_xpath('/html/body/table[4]/tbody/tr') | |
1511 | + if len(trs) < 2: | |
1512 | + return constant.STATUS_FAIL, comment | |
1513 | + | |
1514 | + k = 1 | |
1515 | + for _ in trs: | |
1516 | + k += 1 | |
1517 | + try: # /html/body/table[5]/tbody/tr[2]/td[8]/div | |
1518 | + result = self.driver.find_element_by_xpath("/html/body/table[4]/tbody/tr[" + str(k) + "]/td[8]/div").text | |
1519 | + if '成功' in result: | |
1520 | + return constant.STATUS_SUCCESS, '成功' | |
1521 | + elif '失败' in result: | |
1522 | + msg = self.driver.find_element_by_xpath("/html/body/table[4]/tbody/tr[" + str(k) + "]/td[9]/div").text | |
1523 | + return constant.STATUS_FAIL, msg | |
1524 | + else: | |
1525 | + # msg = self.driver.find_element_by_xpath("/html/body/table[4]/tbody/tr[" + str(k) + "]/td[9]/div").text | |
1526 | + return constant.STATUS_FAIL, comment | |
1527 | + except Exception as e: | |
1528 | + logger.error(str(e)) | |
1529 | + time.sleep(1) | |
1530 | + return constant.STATUS_CONFORMING, comment | |
1531 | + | |
1532 | + def is_once_submit(self): | |
1533 | + return False | |
1534 | + | |
1535 | + def close_notice(self): | |
1536 | + """关闭页面悬浮div弹框""" | |
1537 | + for i in range(3): | |
1538 | + try: | |
1539 | + self.driver.switch_to_default_content() | |
1540 | + self.driver.switch_to.frame('center') | |
1541 | + self.driver.switch_to_frame('mainFrame') | |
1542 | + xpath = '//*[@id="wBox"]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr/td[2]/div' | |
1543 | + # xpath = '//div[@class="wBox_close_on"]' | |
1544 | + self.driver.find_element_by_xpath(xpath).click() | |
1545 | + except Exception as e: | |
1546 | + logger.error(str(e)) | |
1547 | + time.sleep(1) | |
1548 | + | |
1549 | + def check_nav_show(self, div_id='', one_id='', two_id=''): | |
1550 | + """检查左侧导航是否显示二级导航""" | |
1551 | + k = 0 | |
1552 | + while True: | |
1553 | + k += 1 | |
1554 | + if k == 6: | |
1555 | + return False, '服务器繁忙,请稍后再试' | |
1556 | + | |
1557 | + try: | |
1558 | + time.sleep(1) | |
1559 | + self.driver.switch_to.default_content() | |
1560 | + self.driver.switch_to.frame('center') | |
1561 | + self.driver.switch_to.frame('leftFrame') # 切换到frame下寻找元素 | |
1562 | + | |
1563 | + display = [] | |
1564 | + if div_id != '': | |
1565 | + styles = self.driver.find_element_by_id(div_id).get_attribute('style') | |
1566 | + styles = styles.replace(' ', '').strip().lower() | |
1567 | + display = re.findall('display:none', styles) | |
1568 | + | |
1569 | + if display: | |
1570 | + if one_id != "" and two_id != "": | |
1571 | + self.driver.find_element_by_id(one_id).click() | |
1572 | + time.sleep(1) | |
1573 | + self.driver.find_element_by_id(two_id).click() | |
1574 | + else: | |
1575 | + self.driver.find_element_by_id(two_id).click() | |
1576 | + | |
1577 | + time.sleep(1) | |
1578 | + | |
1579 | + sound_code = self.driver.page_source | |
1580 | + # /html/body/table[3]/tbody/tr/td | |
1581 | + if '此业务的使用日期' in sound_code: | |
1582 | + msg = '此业务的使用日期为每月5日至22日(逢节假日不提前,也不错后)' | |
1583 | + return False, msg | |
1584 | + elif '此业务每天的使用时间' in sound_code: | |
1585 | + logger.error('此业务每天的使用时间为6:00—22:00') | |
1586 | + return False, '此业务每天的使用时间为6:00—22:00' | |
1587 | + # elif '404' in sound_code: | |
1588 | + # logger.error('页面出现404错误') | |
1589 | + # self.driver.refresh() | |
1590 | + # continue | |
1591 | + elif '服务器繁忙' in sound_code: | |
1592 | + logger.error('服务器繁忙,请稍后再试') | |
1593 | + self.driver.refresh() | |
1594 | + continue | |
1595 | + return True, '' | |
1596 | + except Exception as e: | |
1597 | + logger.error(str(e)) | |
1598 | + self.driver.refresh() | |
1599 | + continue | |
1600 | + | |
1601 | + def __select_medical(self, *args): | |
1602 | + """判断是否有医疗机构3,4,5""" | |
1603 | + self.driver.find_element_by_id(args[0]).click() # 配置医疗机构 | |
1604 | + self.driver.switch_to.frame(args[1]) # 切换到frame下寻找元素 | |
1605 | + self.driver.find_element_by_id('personInfoReg_search').send_keys(args[2]) # 输入医院 | |
1606 | + self.driver.find_elements_by_tag_name('input')[2].click() | |
1607 | + time.sleep(1) | |
1608 | + tds = self.driver.find_elements_by_tag_name('td') | |
1609 | + if len(tds) >= 5: | |
1610 | + inputs = self.driver.find_elements_by_tag_name('input') | |
1611 | + for j in inputs: | |
1612 | + if j.get_attribute('value') == '选择': | |
1613 | + j.click() | |
1614 | + break | |
1615 | + self.driver.switch_to.default_content() # 退出frame | |
1616 | + self.driver.switch_to.frame('center') | |
1617 | + self.driver.switch_to.frame('mainFrame') # 切换到frame下寻找元素 | |
1618 | + time.sleep(2) | |
1619 | + | |
1620 | + def system_prompt(self): | |
1621 | + """关闭系统提示窗口""" | |
1622 | + time.sleep(1) | |
1623 | + self.driver.switch_to.default_content() # 退出frame | |
1624 | + # msg_xpath = self.driver.find_element_by_xpath('/html/body/div[3]/div/h2/a') # 系统提示 | |
1625 | + # if msg_xpath: | |
1626 | + # msg_xpath.click() | |
1627 | + try: | |
1628 | + self.driver.find_element_by_xpath('/html/body/div[3]/div/h2/a').click() # 关闭系统提示 | |
1629 | + except: | |
1630 | + pass | |
1631 | + | |
1632 | + self.driver.switch_to.default_content() # 退出frame | |
1633 | + self.driver.switch_to.frame('center') | |
1634 | + self.driver.switch_to.frame('mainFrame') # 切换到frame下寻找元素 | |
1635 | + def new_system_prompt(self): | |
1636 | + """新关闭系统提示窗口""" | |
1637 | + time.sleep(8) | |
1638 | + self.driver.switch_to.default_content() # 退出frame | |
1639 | + self.driver.switch_to.default_content() # 退出frame | |
1640 | + # msg_xpath = self.driver.find_element_by_xpath('/html/body/div[3]/div/h2/a') # 系统提示 | |
1641 | + # if msg_xpath: | |
1642 | + # msg_xpath.click() | |
1643 | + # source_text = self.driver.page_source | |
1644 | + # print(source_text) | |
1645 | + try: | |
1646 | + self.driver.find_element_by_xpath('//div[@class="popwrap"]/div/h2/a').click() # 关闭系统提示 | |
1647 | + except Exception as e: | |
1648 | + logger.error(str(e)) | |
1649 | + | |
1650 | + self.driver.switch_to.default_content() # 退出frame | |
1651 | + self.driver.switch_to.frame('center') | |
1652 | + self.driver.switch_to.frame('mainFrame') # 切换到frame下寻找元素 | |
1653 | + | |
1654 | + def __date(self): | |
1655 | + """合同日期计算""" | |
1656 | + year = datetime.datetime.now().year + 3 | |
1657 | + month = datetime.datetime.now().month | |
1658 | + day = datetime.datetime.now().day - 1 | |
1659 | + if day == 0: | |
1660 | + month = month - 1 | |
1661 | + if month == 0: | |
1662 | + month = 12 | |
1663 | + if month == 2: | |
1664 | + day = 28 | |
1665 | + elif month == 2 or month == 4 or month == 6 or month == 9 or month == 11: | |
1666 | + day = 30 | |
1667 | + else: | |
1668 | + day = 31 | |
1669 | + | |
1670 | + return year, month, day | |
1671 | + | |
1672 | + def left_click(x, y): | |
1673 | + win32api.SetCursorPos([x, y]) | |
1674 | + | |
1675 | + win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) | |
1676 | + win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) | |
... | ... |
UnPack/unpack/sibot/common/city_code.json
0 → 100644
此 diff 太大无法显示。
UnPack/unpack/sibot/log/sibot.log
0 → 100644
1 | +botclient 532 2022-02-10 15:12:45,687 ERROR :<_Rendezvous of RPC that terminated with: | |
2 | + status = StatusCode.UNKNOWN | |
3 | + details = "Stream removed" | |
4 | + debug_error_string = "{"created":"@1644477165.685000000","description":"Error received from peer ipv4:172.17.35.193:60001","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"Stream removed","grpc_status":2}" | |
5 | +> | |
6 | +service 459 2022-02-10 16:24:00,328 ERROR :'No job by the id of id_auto_time was found' | |
7 | +server 118 2022-02-10 16:24:04,102 ERROR : | |
8 | +service 459 2022-02-10 16:27:12,413 ERROR :'No job by the id of id_auto_time was found' | |
9 | +op_type 20 2022-02-10 16:27:22,127 INFO :get_op_types sucessful | |
10 | +op_type 20 2022-02-10 16:27:24,401 INFO :get_op_types sucessful | |
11 | +op_type 20 2022-02-10 16:27:30,541 INFO :get_op_types sucessful | |
12 | +op_type 20 2022-02-10 16:27:32,587 INFO :get_op_types sucessful | |
13 | +botclient 663 2022-02-10 18:33:08,006 ERROR :<_Rendezvous of RPC that terminated with: | |
14 | + status = StatusCode.UNIMPLEMENTED | |
15 | + details = "Method not found!" | |
16 | + debug_error_string = "{"created":"@1644489188.006000000","description":"Error received from peer ipv4:172.17.35.193:60001","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"Method not found!","grpc_status":12}" | |
17 | +> | |
18 | +main_form 1012 2022-02-10 18:33:08,006 ERROR :argument of type 'NoneType' is not iterable | |
... | ... |
UnPack/unpack/sibot/sibot.conf
0 → 100644
1 | +[data] | |
2 | +path=sibot.db | |
3 | +filepath=download_file | |
4 | + | |
5 | +[hro] | |
6 | +api_endpoint=https://api.workai.com.cn | |
7 | +client_id=106716051667947520 | |
8 | +client_secret=7bbcecb0-b7f8-4f48-8e94-e748c32edc26 | |
9 | + | |
10 | +[ca_drivers] | |
11 | +path=["C:\\GM3000\\GM3000Mon.exe"] | |
12 | + | |
13 | +[time_point] | |
14 | +auto=1 | |
15 | + | |
16 | +[flag] | |
17 | +dev=1 | |
18 | +download=1 | |
19 | +city_code=350100 | |
20 | + | |
21 | +[terminals] | |
22 | +terminal = 0 | |
\ No newline at end of file | ||
... | ... |
UnPack/unpack/sibot/sibot.db
0 → 100644
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
UnPack/unpack/sibot/减员1.xlsx
0 → 100644
不能预览此文件类型
UnPack/unpack/sibot/社保外部后道减员导入.xlsx
0 → 100644
不能预览此文件类型
UnPack/unpack/tax_bot.ico
0 → 100644
不能预览此文件类型
UnPack/unpack/taxbot.ico
0 → 100644
不能预览此文件类型
UnPack/unpack/单个打包.bat
0 → 100644
1 | +@echo off | |
2 | + | |
3 | +ping 127.0.0.1 -n 1 > nul | |
4 | +echo ... | |
5 | +echo ... | |
6 | +echo 开始打包Worker | |
7 | + | |
8 | +F:\OFFICE\CODE\stand_alone\environment\sibot\Scripts\pyinstaller.exe -Fc --hidden-import=pkg_resources --distpath=./hefei --icon=sbkj.ico F:\OFFICE\CODE\stand_alone\sibot\sibot\worker\server.py -n Worker | |
9 | + | |
10 | +echo 打包Controller结束 | |
11 | +echo ... | |
12 | +echo ... | |
13 | +echo ... | |
14 | +echo 开始删除编译临时文件... | |
15 | +rmdir /S /Q .\build | |
16 | +del /a /f /s .\Worker.spec | |
17 | +echo 删除编译临时文件完成... | |
\ No newline at end of file | ||
... | ... |
UnPack/unpack/社保机器人正式版.bat
0 → 100644
1 | +@echo off | |
2 | + | |
3 | +ping 127.0.0.1 -n 1 > nul | |
4 | +echo ... | |
5 | +echo ... | |
6 | +echo 开始打包Controlle | |
7 | + | |
8 | +D:\developer\python\Scripts\pyinstaller.exe -Fc --hidden-import=pkg_resources --distpath=./sibot --icon=bot.ico D:\developer\Code\alone\sibot\sibot\controller\server.py -n Controller | |
9 | + | |
10 | +echo 打包Controlle结束 | |
11 | + | |
12 | + | |
13 | +ping 127.0.0.1 -n 1 > nul | |
14 | +echo ... | |
15 | +echo ... | |
16 | +echo 开始打包Worker | |
17 | + | |
18 | +D:\developer\python\Scripts\pyinstaller.exe -Fc --hidden-import=pkg_resources --distpath=./sibot --icon=bot.ico D:\developer\Code\alone\sibot\sibot\worker\server.py -n Worker | |
19 | + | |
20 | +echo 打包Worker结束 | |
21 | + | |
22 | +ping 127.0.0.1 -n 1 > nul | |
23 | +echo ... | |
24 | +echo ... | |
25 | +echo 开始打包Bot | |
26 | + | |
27 | +D:\developer\python\Scripts\pyinstaller.exe -Fw --hidden-import=pkg_resources --distpath=./sibot --icon=bot.ico D:\developer\Code\alone\sibot\sibot\watcher\server.py -n Bot | |
28 | + | |
29 | +echo 打包Bot结束 | |
30 | + | |
31 | +echo ... | |
32 | +echo ... | |
33 | +echo ... | |
34 | +echo 开始删除编译临时文件... | |
35 | +rmdir /S /Q .\build | |
36 | +del /a /f /s .\Controller.spec | |
37 | +del /a /f /s .\Worker.spec | |
38 | +del /a /f /s .\Bot.spec | |
39 | +del /a /f /s .\BotClient.spec | |
40 | +echo 删除编译临时文件完成... | |
\ No newline at end of file | ||
... | ... |
请
注册
或
登录
后发表评论