2db47680
hexiaodong
chore: 初始提交 php 遗...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
<?php
namespace app\admin\behavior;
use think\Db;
use think\Request;
class Fastflow
{
//发起审批前
public function fastflowBeforeStart(&$params){
}
//发起审批后
public function fastflowAfterStart(&$params){
}
//同意前
public function fastflowBeforeAgree(&$params){
}
//同意后
public function fastflowAfterAgree(&$params){
// \think\Cache::set('ab',$params);
}
//驳回前
public function fastflowBeforeBack(&$params){
}
//驳回后
public function fastflowAfterBack(&$params){
}
//会签前
public function fastflowBeforeSign(&$params){
}
//会签后
public function fastflowAfterSign(&$params){
}
//结束前
public function fastflowBeforeEnd(&$params){
}
//结束后
public function fastflowAfterEnd(&$params){
// \think\Cache::set('abbbb',$params);
if($params['bill']=='ats_asiitn'){
$this->card_late($params);
}
if($params['bill']=='ats_hvuxhg'){
\think\Cache::set('aabb', $params);
$this->leave($params);
}
$this->endSendNotice($params);
}
//处理结束草送
public function endSendNotice($params)
{
//$headers = Request::header();
//\think\Cache::set('abbbb',$headers);
// return;
$api = new \fastflow\api();
$last_thread = $api->getThreadById($params['thread_id']);
$thread = \think\Db::name('fastflow_thread')->where('prethread_id',$params['thread_id'])->where('process_id',$params['process_id'])->find();
//$fid = \think\Db::name('fastflow_bill')->where('bill_table',$params['bill'])->value('id');
$fid = \think\Db::name('fastflow_flow')->where('bill',$params['bill'])->value('id');
$list = $api->getAllNodes($fid);
// halt();
$staff_ids = null;
foreach ($list as $item){
if($item['id']==$thread['step_id']){
$staff_ids = $item['data']['workers']??null;
}
}
if(empty($staff_ids))return false;
$data = [
'carbon_scope'=>1,
'carbon_range'=>2,
'carbon_receiver'=>$staff_ids,
'bill'=>$params['bill'],
'bill_id'=>$params['bill_id']
];
$log_ids = [];
$log_rows = $api->getThreadLog($params['bill'],$params['bill_id']);
if ($log_rows) {
foreach ($log_rows as $row) {
foreach ($row as $item) {
$log_ids[] = $item['id'];
}
}
}
$staff_id = (explode(',',$thread['worker_checked_ids'])[0])??1;
//进行抄送
$res = $api->sendDealCarbon($data,$log_ids[0],$staff_id?$staff_id:1);
return true;
}
//处理补卡
public function card_late($params)
{
$find = Db::table($params['bill'])->where('id',$params['bill_id'])->find();
if($find){
//获取到了员工id和补卡时间,更改考勤打卡表和考勤规则表
$time = date('Y-m-d',strtotime($find['mdnidpcc']));
$staff_id = $find['initiator_id'];
//查询
Db::name('qingdong_attendance_statisc')->where('staff_id',$staff_id)->where('time',$time)->update([
'clock_in_status'=>5,
]);
}
}
//处理请假流程
public function leave($params)
{
$find = Db::table($params['bill'])->where('id',$params['bill_id'])->find();
if($find){
//获取到了员工id和请假时间段
$staff_id = $find['initiator_id'];
$start = $find['xyoqksln'];
$end = $find['izlpkveb'];
// halt($end="0000-00-00 00:00:00");
if($start=='0000-00-00 00:00:00' || $end=="0000-00-00 00:00:00"){
return false;
}
$time = date('Y-m-d',strtotime($start));
$statisc = Db::name('qingdong_attendance_statisc')->where(['time' => $time, 'staff_id' => $staff_id])->find();
if(empty($statisc)){
return;
throw new \think\Exception('暂未参加考勤打卡');
}
//halt([$time,$staff_id]);
$list = $this->getLeaveDates($start,$end,$statisc['start_time'],$statisc['end_time']);
\think\Cache::set('abd',$list);
foreach ($list as $ite){
Db::name('qingdong_attendance_statisc')->where('staff_id',$staff_id)->where('time',$ite)->update([
'clock_in_status'=>6,
]);
}
}
}
public function getLeaveDates($startDate, $endDate, $workStartTime, $workEndTime) {
// 将输入的日期和时间转换为时间戳
$leaveStart = strtotime($startDate);
$leaveEnd = strtotime($endDate);
// 获取两个日期之间的所有日期
$dates = [];
$currentDate = strtotime(date('Y-m-d', $leaveStart));
$endDate = strtotime(date('Y-m-d', $leaveEnd));
while ($currentDate <= $endDate) {
$dates[] = date('Y-m-d', $currentDate);
$currentDate = strtotime('+1 day', $currentDate);
}
// 判断日期是否在工作时间内
$leaveDates = [];
foreach ($dates as $date) {
$workStart = strtotime("$date $workStartTime");
$workEnd = strtotime("$date $workEndTime");
// 如果请假开始时间或结束时间在当天工作时间内,则算作请假
if (($leaveStart <= $workEnd && $leaveStart >= $workStart) ||
($leaveEnd >= $workStart && $leaveEnd <= $workEnd) ||
($leaveStart < $workStart && $leaveEnd > $workEnd)) {
$leaveDates[] = $date;
}
}
return $leaveDates;
}
}
|