|
@@ -176,7 +176,7 @@ class ViolationProductDataJobs implements ShouldQueue
|
|
|
$insert_product_data['company_category_name'] = $company_data->category_name ? $company_data->category_name : '';
|
|
$insert_product_data['company_category_name'] = $company_data->category_name ? $company_data->category_name : '';
|
|
|
}
|
|
}
|
|
|
//获取指定人员信息
|
|
//获取指定人员信息
|
|
|
- if ($specify_responsible_person == 0) {
|
|
|
|
|
|
|
+ if ($specify_responsible_person == 0) {
|
|
|
$where_query1 = [];
|
|
$where_query1 = [];
|
|
|
$where_query2 = [];
|
|
$where_query2 = [];
|
|
|
$where_query3 = [];
|
|
$where_query3 = [];
|
|
@@ -204,7 +204,30 @@ class ViolationProductDataJobs implements ShouldQueue
|
|
|
$where_query3[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
|
|
$where_query3[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
|
|
|
}
|
|
}
|
|
|
//并行查询第一责任人
|
|
//并行查询第一责任人
|
|
|
- $first_responsible_person = $EmployeeModel->where($where_query1)->orWhere($where_query2)->orWhere($where_query3)->pluck('id')->implode(',');
|
|
|
|
|
|
|
+ $EmployeeModel = $EmployeeModel->where(function ($q) use ($employee_id_list, $company_id) {
|
|
|
|
|
+ if (!empty($employee_id_list)) {
|
|
|
|
|
+ $q->where('company_id', $company_id)
|
|
|
|
|
+ ->orWhereIn('id', $employee_id_list)
|
|
|
|
|
+ ->where('status', 0)
|
|
|
|
|
+ ->where('duty_type', 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ })->orWhere(function ($q) use ($employee_id_area, $company_id) {
|
|
|
|
|
+ if (!empty($employee_id_area)) {
|
|
|
|
|
+ $q->where('company_id', $company_id)
|
|
|
|
|
+ ->whereIn('id', $employee_id_area)
|
|
|
|
|
+ ->where('status', 0)
|
|
|
|
|
+ ->where('duty_type', 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
|
|
|
|
|
+ if (!empty($employee_id_platform)) {
|
|
|
|
|
+ $q->where('company_id', $company_id)
|
|
|
|
|
+ ->whereIn('id', $employee_id_platform)
|
|
|
|
|
+ ->where('status', 0)
|
|
|
|
|
+ ->where('duty_type', 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
|
|
|
|
|
+ //调试记录查询条件
|
|
|
$insert_product_data['first_responsible_person'] = $first_responsible_person;
|
|
$insert_product_data['first_responsible_person'] = $first_responsible_person;
|
|
|
//查询责任人
|
|
//查询责任人
|
|
|
$where_query1 = [];
|
|
$where_query1 = [];
|
|
@@ -234,8 +257,32 @@ class ViolationProductDataJobs implements ShouldQueue
|
|
|
$where_query3[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
|
|
$where_query3[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
|
|
|
}
|
|
}
|
|
|
//并行查询责任人
|
|
//并行查询责任人
|
|
|
- $responsible_person = $EmployeeModel->where($where_query1)->orWhere($where_query2)->orWhere($where_query3)->pluck('id')->implode(',');
|
|
|
|
|
|
|
+ $EmployeeModel = new EmployeeModel();
|
|
|
|
|
+ $EmployeeModel = $EmployeeModel->where(function ($q) use ($employee_id_list, $company_id) {
|
|
|
|
|
+ if (!empty($employee_id_list)) {
|
|
|
|
|
+ $q->where('company_id', $company_id)
|
|
|
|
|
+ ->orWhereIn('id', $employee_id_list)
|
|
|
|
|
+ ->where('status', 0)
|
|
|
|
|
+ ->where('duty_type', 2);//责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ }
|
|
|
|
|
+ })->orWhere(function ($q) use ($employee_id_area, $company_id) {
|
|
|
|
|
+ if (!empty($employee_id_area)) {
|
|
|
|
|
+ $q->where('company_id', $company_id)
|
|
|
|
|
+ ->whereIn('id', $employee_id_area)
|
|
|
|
|
+ ->where('status', 0)
|
|
|
|
|
+ ->where('duty_type', 2);//责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ }
|
|
|
|
|
+ })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
|
|
|
|
|
+ if (!empty($employee_id_platform)) {
|
|
|
|
|
+ $q->where('company_id', $company_id)
|
|
|
|
|
+ ->whereIn('id', $employee_id_platform)
|
|
|
|
|
+ ->where('status', 0)
|
|
|
|
|
+ ->where('duty_type', 2);//责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ $responsible_person = $EmployeeModel->pluck('id')->implode(',');
|
|
|
$insert_product_data['responsible_person'] = $responsible_person;
|
|
$insert_product_data['responsible_person'] = $responsible_person;
|
|
|
|
|
+
|
|
|
//溯源责任人
|
|
//溯源责任人
|
|
|
$source_responsible_person = '';
|
|
$source_responsible_person = '';
|
|
|
if ($first_responsible_person && $responsible_person) {
|
|
if ($first_responsible_person && $responsible_person) {
|