diff --git a/app/controller/Repeat.php b/app/controller/Repeat.php new file mode 100644 index 0000000..d82569f --- /dev/null +++ b/app/controller/Repeat.php @@ -0,0 +1,350 @@ +fetch(); + } + + /** + * @return Json + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function data(){ + $params = $this->request->param(); + $page = $this->request->param('page', 1); + $limit = $this->request->param('limit', 20); + if ($page <= 1) { + $page = 1; + } + $offset = ($page - 1) * $limit; + $map = $this->getQueryCondition($params); + $query = Db::table('repeat_data_t')->alias('car_info_t')->field('car_info_t.*') + ->where($map) + ->order('repeat_data_t.car_frame_no desc'); + if (isset($params['is_delete_frame']) && $params['is_delete_frame'] > 0) { + $query = $query->where('repeat_data_t.repeat_id', '=', $params['is_delete_frame']); + } + $map_or1 = []; + $map_or2 = []; + $insurer_month1 = $params['insurer_month1']??''; + $insurer_day1 = $params['insurer_day1']??''; + $insurer_month2 = $params['insurer_month2']??''; + $insurer_day2 = $params['insurer_day2']??''; + if($insurer_month1 != '' && $insurer_day1 == '') { + $map_or1[] = [Db::raw('month(car_info_t.insurer1_date)'), '>=', $insurer_month1]; + $map_or2[] = [Db::raw('month(car_info_t.insurer2_date)'), '>=', $insurer_month1]; + } else if ($insurer_month1 == '' && $insurer_day1 != '') { + $map_or1[] = [Db::raw('day(car_info_t.insurer1_date)'), '>=', $insurer_day1]; + $map_or2[] = [Db::raw('day(car_info_t.insurer2_date)'), '>=', $insurer_day1]; + } else if ($insurer_month1 != '' && $insurer_day1 != '') { + $map_or1[] = [Db::raw('DATE_FORMAT(car_info_t.insurer1_date,"%m-%d")'), '>=', substr('0' . $insurer_month1, -2) . '-' . substr('0' . $insurer_day1, -2)]; + $map_or2[] = [Db::raw('DATE_FORMAT(car_info_t.insurer2_date,"%m-%d")'), '>=', substr('0' . $insurer_month1, -2) . '-' . substr('0' . $insurer_day1, -2)]; + } + if($insurer_month2 != '' && $insurer_day2 == '') { + $map_or1[] = [Db::raw('month(car_info_t.insurer1_date)'), '<=', $insurer_month2]; + $map_or2[] = [Db::raw('month(car_info_t.insurer2_date)'), '<=', $insurer_month2]; + } else if ($insurer_month2 == '' && $insurer_day2 != '') { + $map_or1[] = [Db::raw('day(car_info_t.insurer1_date)'), '<=', $insurer_day2]; + $map_or2[] = [Db::raw('day(car_info_t.insurer2_date)'), '<=', $insurer_day2]; + } else if ($insurer_month2 != '' && $insurer_day2 != '') { + $map_or1[] = [Db::raw('DATE_FORMAT(car_info_t.insurer1_date,"%m-%d")'), '<=', substr('0' . $insurer_month2, -2) . '-' . substr('0' . $insurer_day2, -2)]; + $map_or2[] = [Db::raw('DATE_FORMAT(car_info_t.insurer2_date,"%m-%d")'), '<=', substr('0' . $insurer_month2, -2) . '-' . substr('0' . $insurer_day2, -2)]; + } + if(count($map_or1) > 0){ + $map_or1 = array_merge([['car_info_t.insurer1_date', '<>', '']],$map_or1); + } + if(count($map_or2) > 0){ + $map_or2 = array_merge([['car_info_t.insurer1_date', '=', ''],['car_info_t.insurer2_date', '<>', '']],$map_or2); + } + if (count($map_or1) > 0 && count($map_or2) > 0) { + $query = $query->where(function ($query) use ($map_or1, $map_or2) { + if (count($map_or1) > 0 && count($map_or2) > 0) { + $query->whereOr([$map_or1, $map_or2]); + } + }); + } + if (isset($params['data_filter']) && !empty($params['data_filter'])) { + $map = $this->getAddStatusQuery(array_flip($params['data_filter'])); + if(count($map) > 1 ){ + $query = $query->where(function ($query) use ($map) { + if (count($map) > 0){ + $query->whereOr($map); + } + }); + }else { + $query = $query->where($map); + } + } + $count = $query->count(); + $list = $query->limit($offset, $limit)->select()->toArray(); + foreach ($list as &$item) { + $item['export_bhx_name'] = $jobs_name[$item['is_export_bhx']]['queue'] ?? ''; + $item['export_bmc_name'] = $jobs_name[$item['is_export_bmc']]['queue'] ?? ''; + $item['bhx_download_times'] = $jobs_name[$item['is_export_bhx']]['download_times'] ?? 0; + $item['bmc_download_times'] = $jobs_name[$item['is_export_bmc']]['download_times'] ?? 0; + } + $this->layui_data['data'] = $list; + $this->layui_data['count'] = $count; + return json($this->layui_data); + } + + /** + * 显示编辑资源表单页. + * + * @param int $id + * @return string + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function edit($id) + { + $car_info = Db::table('repeat_data_t')->find($id); + if($this->request->isGet()){ + $this->assign('info', $car_info); + return $this->fetch(); + }else if($this->request->isPost()){ + $data = $this->request->param(); + $car_info->car_no = $data['car_no'] ?? $car_info->car_no; + $car_info->car_frame_no = $data['car_frame_no'] ?? $car_info->car_frame_no; + $car_info->engine_no = $data['engine_no'] ?? $car_info->engine_no; + $car_info->factory_model = $data['factory_model'] ?? $car_info->factory_model; + $car_info->register_date = $data['register_date'] ?? $car_info->register_date; + $car_info->purchase_price = $data['purchase_price'] ?? $car_info->purchase_price; + $car_info->company = $data['company'] ?? $car_info->company; + $car_info->insurer1_date = $data['insurer1_date'] ?? $car_info->insurer1_date; + $car_info->insurer2_date = $data['insurer2_date'] ?? $car_info->insurer2_date; + $car_info->car_man = $data['car_man'] ?? $car_info->car_man; + $car_info->car_number = $data['car_number'] ?? $car_info->car_number; + $car_info->car_phone = $data['car_phone'] ?? $car_info->car_phone; + $car_info->id_man = $data['id_man'] ?? $car_info->id_man; + $car_info->id_number = $data['id_number'] ?? $car_info->id_number; + $car_info->update_timestamp = date('Y-m-d H:i:s'); + if($car_info->save()){ + return json($this->json_data); + }else { + $this->json_data['code'] = 0; + $this->json_data['msg'] = '保存失败'; + return json($this->layui_data); + } + } + + } + + /** + * @param $params + * @return array + */ + private function getQueryCondition($params) + { + $map = []; + if (isset($params['car_man']) && $params['car_man'] != '') { + $car_man = explode(',', str_replace(',', '', $params['car_man'])); + array_walk($car_man, function (&$value) { + $value = '%' . $value . '%'; + }); + $map[] = ['car_info_t.car_man', 'like', $car_man]; + } + if (isset($params['factory_model']) && $params['factory_model'] != '') { + $factory_model = explode(',', str_replace(',', '', $params['factory_model'])); + array_walk($factory_model, function (&$value) { + $value = '%' . $value . '%'; + }); + $map[] = ['car_info_t.factory_model', 'like', $factory_model]; + } + if (isset($params['car_frame_no']) && $params['car_frame_no'] != '') { + $map[] = ['car_info_t.car_frame_no', '=', $params['car_frame_no']]; + } + if (isset($params['car_no']) && $params['car_no'] != '') { + $map[] = ['car_info_t.car_no', '=', $params['car_no']]; + } + if (isset($params['car_number']) && $params['car_number'] != '') { + $map[] = ['car_info_t.car_number', '=', $params['car_number']]; + } + if (isset($params['car_phone']) && $params['car_phone'] != '') { + $map[] = ['car_info_t.car_phone', '=', $params['car_phone']]; + } + if (isset($params['register_date']) && $params['register_date'] != '') { + $map[] = ['car_info_t.register_date', '=', $params['register_date']]; + } + if (isset($params['car_phone_empty']) && $params['car_phone_empty'] == 'yes') { + $map[] = ['car_info_t.car_phone', '<>', '']; + } + if (isset($params['car_phone_empty']) && $params['car_phone_empty'] == 'no') { + $map[] = ['car_info_t.car_phone', '=', '']; + } + if (isset($params['car_phone_repeat']) && $params['car_phone_repeat'] == 'yes') { + $map[] = ['car_info_t.id', '=', 'peer_phone_t.id']; + } + if (isset($params['is_update_bhx']) && $params['is_update_bhx'] > 0 ) { + $map[] = ['car_info_t.is_update_bhx', '=', $params['is_update_bhx']]; + } + if (isset($params['is_export_bhx']) && $params['is_export_bhx'] > 0 ) { + $map[] = ['car_info_t.is_export_bhx', '=', $params['is_export_bhx']]; + } + if (isset($params['is_export_bmc']) && $params['is_export_bmc'] > 0 ) { + $map[] = ['car_info_t.is_export_bmc', '=', $params['is_export_bmc']]; + } + if (isset($params['is_export_failed']) && $params['is_export_failed'] > 0 ) { + $map[] = ['car_info_t.is_export_failed', '=', $params['is_export_failed']]; + } + if (isset($params['is_export_failed_bmc']) && $params['is_export_failed_bmc'] > 0 ) { + $map[] = ['car_info_t.is_export_failed_bmc', '=', $params['is_export_failed_bmc']]; + } + if (isset($params['is_export_none_bmc']) && $params['is_export_none_bmc'] > 0 ) { + $map[] = ['car_info_t.is_export_none_bmc', '=', $params['is_export_none_bmc']]; + } + + if (isset($params['source']) && $params['source'] > 0 ) { + $map[] = ['car_info_t.source', '=', $params['source']]; + } + if(isset($params['register_date1']) && $params['register_date1'] != ''){ + $map[] = ['car_info_t.register_date', '>=', $params['register_date1']]; + } + if(isset($params['register_date2']) && $params['register_date2'] != ''){ + $map[] = ['car_info_t.register_date', '<=', $params['register_date2']]; + } + if (isset($params['price1']) && $params['price1'] != '') { + $map[] = ['car_info_t.purchase_price', '>=', $params['price1'] * 10000]; + } + if (isset($params['price2']) && $params['price2'] != '') { + $map[] = ['car_info_t.purchase_price', '<=', $params['price2'] * 10000]; + } + return $map; + } + + /** + * 添加状态筛选 + * @param $data_filter + * @return array + */ + private function getAddStatusQuery($data_filter) + { + $tree = new Tree(); + $tree->setNode(1, isset($data_filter['bhx']) ? [['car_info_t.is_export_bhx', '>', 0]] : []); + $tree->setNode(2, isset($data_filter['none']) ? [['car_info_t.is_export_bhx', '=', 0]] : []); + if(isset($data_filter['bhx_success'])){ + $tree->setNode(3, [[ + ['car_info_t.is_export_bhx', '>', 0], + ['car_info_t.is_update_bhx', '>', 0], + ]],1); + $tree->setNode(1, [], 0); + }else { + $tree->setNode(3, [],1); + } + if(isset($data_filter['bhx_failed'])){ + $tree->setNode(4, [[ + ['car_info_t.is_export_bhx', '>', 0], + ['car_info_t.is_update_bhx', '<', 0], + ]],1); + $tree->setNode(1, [], 0); + }else { + $tree->setNode(4, [],1); + } + if(isset($data_filter['bhx_none'])){ + $tree->setNode(5, [[ + ['car_info_t.is_export_bhx', '>', 0], + ['car_info_t.is_update_bhx', '=', 0], + ]],1); + $tree->setNode(1, [], 0); + }else { + $tree->setNode(5, [],1); + } + if(isset($data_filter['none_bmc'])){ + $tree->setNode(6, [[ + ['car_info_t.is_export_bhx', '=', 0], + ['car_info_t.is_export_none_bmc', '>', 0], + ]],2); + $tree->setNode(2, [], 0); + }else { + $tree->setNode(6, [],2); + } + if(isset($data_filter['none_none'])){ + $tree->setNode(7, [[ + ['car_info_t.is_export_bhx', '=', 0], + ['car_info_t.is_export_none_bmc', '=', 0], + ]],2); + $tree->setNode(2, [], 0); + }else { + $tree->setNode(7, [],2); + } + if(isset($data_filter['bhx_success_bmc'])){ + $tree->setNode(8, [[ + ['car_info_t.is_export_bhx', '>', 0], + ['car_info_t.is_update_bhx', '>', 0], + ['car_info_t.is_export_bmc', '>', 0], + ]],3); + $tree->setNode(3, [], 0); + }else { + $tree->setNode(8, [],3); + } + if(isset($data_filter['bhx_success_none'])){ + $tree->setNode(9, [[ + ['car_info_t.is_export_bhx', '>', 0], + ['car_info_t.is_update_bhx', '>', 0], + ['car_info_t.is_export_bmc', '=', 0], + ]],3); + $tree->setNode(3, [], 0); + }else { + $tree->setNode(9, [],3); + } + if(isset($data_filter['bhx_failed_bmc'])){ + $tree->setNode(10, [[ + ['car_info_t.is_export_bhx', '>', 0], + ['car_info_t.is_update_bhx', '<', 0], + ['car_info_t.is_export_bmc', '=', 0], + ['car_info_t.is_export_failed', '=', 0], + ['car_info_t.is_export_failed_bmc', '>', 0], + ]],4); + $tree->setNode(4, [], 0); + }else { + $tree->setNode(10, [],4); + } + if(isset($data_filter['bhx_failed_bhx'])){ + $tree->setNode(11, [[ + ['car_info_t.is_export_bhx', '>', 0], + ['car_info_t.is_export_bhx', '>', 0], + ['car_info_t.is_update_bhx', '<', 0], + ['car_info_t.is_export_bmc', '=', 0], + ['car_info_t.is_export_failed', '>', 0], + ]],4); + $tree->setNode(4, [], 0); + }else { + $tree->setNode(11, [],4); + } + if(isset($data_filter['bhx_failed_none'])){ + $tree->setNode(12, [[ + ['car_info_t.is_export_bhx', '>', 0], + ['car_info_t.is_update_bhx', '<', 0], + ['car_info_t.is_export_bmc', '=', 0], + ['car_info_t.is_export_failed', '=', 0], + ['car_info_t.is_export_failed_bmc', '=', 0], + ]],4); + $tree->setNode(4, [], 0); + }else { + $tree->setNode(12, [],4); + } + + $map = $tree->getAllChildrenNodes(0, function ($value) { + return count($value) > 0; + }, function ($value) { + return $value; + }); + return array_column(array_filter($map), null); + } +} diff --git a/app/view/index/edit.html.bak b/app/view/index/edit.html.bak deleted file mode 100644 index 45b9758..0000000 --- a/app/view/index/edit.html.bak +++ /dev/null @@ -1,170 +0,0 @@ -{extend name="public/base" /} -{block name="header"} - -{/block} -{block name="body"} -
-
-
- -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
- {if $info.is_export_bhx == 0 && $info.is_update_bhx == 0 && $info.is_export_bmc == 0 && - $info.is_export_failed == 0 && $info.is_export_none_bmc == 0 && $info.is_export_failed_bmc == 0} - 未处理 - {/if} - {if $info.is_export_bhx > 0 /} - 导出至清洗 - {/if} - {if $info.is_export_bhx > 0 && $info.is_update_bhx > 0 /} - 清洗成功 - {/if} - {if $info.is_export_bhx > 0 && $info.is_update_bhx == -1 /} - 清洗失败 - {/if} - {if $info.is_export_bhx > 0 && $info.is_export_failed > 0 /} - 导出清洗失败 - {/if} - {if $info.is_export_bhx > 0 && $info.is_export_failed_bmc > 0 /} - 导出清洗失败至上传 - {/if} - {if $info.is_export_bhx > 0 && $info.is_update_bhx > 0 && $info.is_export_bmc > 0 /} - 导出清洗成功至上传 - {/if} - {if $info.is_export_none_bmc > 0 /} - 导出未处理至上传 - {/if} -
-
-
- - - -
-
-
-{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/app/view/public/header.html.bak b/app/view/public/header.html.bak deleted file mode 100644 index e28f9a3..0000000 --- a/app/view/public/header.html.bak +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - 数据处理 - - - \ No newline at end of file diff --git a/app/view/public/layout.html b/app/view/public/layout.html index 201d427..ed3dd69 100644 --- a/app/view/public/layout.html +++ b/app/view/public/layout.html @@ -9,6 +9,7 @@
diff --git a/app/view/index/index.html.bak b/app/view/repeat/index.html similarity index 51% rename from app/view/index/index.html.bak rename to app/view/repeat/index.html index b5cd98b..4e2eb84 100644 --- a/app/view/index/index.html.bak +++ b/app/view/repeat/index.html @@ -60,16 +60,6 @@
- -
- -
- 万 -
-
-
-
- 万 -
@@ -84,7 +74,7 @@
- +
日 @@ -96,50 +86,19 @@
-
-
- -
- - - - -
-
-
- -
- -
-
-
- -
- - - + +
+
-
-
- -
- - {if $repeat_frame_count > 0 } - - {/if} - {if $peer_phone_count > 0 } - - {/if} +
-
+
+
- 重置条件 - -
@@ -152,7 +111,6 @@ -{/block} \ No newline at end of file +{/block}