Compare commits

..

No commits in common. '0a5376b42cce96216e3548291537cc451533a7bc' and 'cf243297fce5c2e4c64eda5e476a23fb752cc4f5' have entirely different histories.

  1. 23
      app/controller/Repeat.php
  2. 13
      app/view/repeat/index.html
  3. 102
      extend/service/CarInfoHandle.php

@ -2,7 +2,6 @@
namespace app\controller; namespace app\controller;
use app\BaseController; use app\BaseController;
use app\model\RepeatFrameT;
use library\Tree; use library\Tree;
use think\facade\Db; use think\facade\Db;
use think\response\Json; use think\response\Json;
@ -148,28 +147,6 @@ class Repeat extends BaseController
} }
public function recovery($id)
{
if(Db::table('repeat_data_t')->where('repeat_id', $id)->count() == 0) {
$this->json_data['code'] = 0;
$this->json_data['msg'] = '当前批次没有可恢复数量';
return json($this->json_data);
}
Db::startTrans();
try {
Db::query("insert into car_info_t( `id`, `register_date`, `car_man`, `car_number`, `car_phone`, `car_frame_no`, `car_no`, `engine_no`, `factory_model`, `purchase_price`, `company`, `insurer1_date`, `insurer2_date`, `id_man`, `id_number`, `id_phone`, `insured_man`, `insured_number`, `insured_phone`, `link_man_1`, `link_phone_1`, `link_man_2`, `link_phone_2`, `link_man_3`, `link_phone_3`, `is_delete`, `source`, `is_export_bhx`, `is_export_bmc`, `is_export_failed`, `is_export_none_bmc`, `is_update_bhx`, `create_timestamp`, `update_timestamp`, `is_export_failed_bmc`, `tag`)
select `id`, `register_date`, `car_man`, `car_number`, `car_phone`, `car_frame_no`, `car_no`, `engine_no`, `factory_model`, `purchase_price`, `company`, `insurer1_date`, `insurer2_date`, `id_man`, `id_number`, `id_phone`, `insured_man`, `insured_number`, `insured_phone`, `link_man_1`, `link_phone_1`, `link_man_2`, `link_phone_2`, `link_man_3`, `link_phone_3`, `is_delete`, `source`, `is_export_bhx`, `is_export_bmc`, `is_export_failed`, `is_export_none_bmc`, `is_update_bhx`, `create_timestamp`, `update_timestamp`, `is_export_failed_bmc`, `tag` from repeat_data_t where repeat_id=:id;",
['id' => $id]);
RepeatFrameT::where('repeat_data_t', $id)->delete();
Db::commit();
} catch (\Exception $e) {
Db::rollback();
$this->json_data['code'] = 0;
$this->json_data['msg'] = '恢复失败: '. $e->getMessage();
}
return json($this->json_data);
}
/** /**
* @param $params * @param $params
* @return array * @return array

@ -141,7 +141,6 @@
<div class="layui-form-item layui-col-md2" style="clear: none;"> <div class="layui-form-item layui-col-md2" style="clear: none;">
<div class="layui-input-block layui-text-right" id="tool-bar"> <div class="layui-input-block layui-text-right" id="tool-bar">
<button type="button" class="layui-btn layui-btn-sm" id="search-btn">搜索</button> <button type="button" class="layui-btn layui-btn-sm" id="search-btn">搜索</button>
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" id="recovery-btn">恢复</button>
</div> </div>
</div> </div>
</div> </div>
@ -254,18 +253,6 @@
where: param, where: param,
}, 'data'); }, 'data');
}); });
$('#recovery-btn').on('click', function(){
layer.prompt({title: '请输入删除任务ID值',}, function(value, index, elem){
index = layer.load();
//向服务端发送删除指令
$.post('{:url("/repeat/recovery/")}' + value, function (ret) {
layer.close(index);
layer.msg(ret.msg, function () {
layui.table.reload('carInfo');
});
});
});
});
}); });
function task_create(type,id = 0){ function task_create(type,id = 0){

@ -313,7 +313,7 @@ class CarInfoHandle
echo '当前进度:' . round($current / $count * 100, 3) . PHP_EOL; echo '当前进度:' . round($current / $count * 100, 3) . PHP_EOL;
} }
$sources = CarInfoT::where(['car_frame_no' => $item->car_frame_no]) $sources = CarInfoT::where(['car_frame_no' => $item->car_frame_no])
->order('car_phone desc, id desc')->select(); ->order('car_phone desc, insurer1_date desc, car_no desc, id desc')->select();
if ($sources->isEmpty()) if ($sources->isEmpty())
continue; continue;
$sources = $sources->toArray(); $sources = $sources->toArray();
@ -329,14 +329,81 @@ class CarInfoHandle
if (empty($source_a)) { if (empty($source_a)) {
$source_a = $sources[0]; $source_a = $sources[0];
array_shift($sources); array_shift($sources);
} Db::startTrans(); }
Db::startTrans();
try { try {
$car_phone_a_valid = preg_match('/^1[3-9][0-9]{9}/', $source_a['car_phone']);
foreach ($sources as $index => $source) { foreach ($sources as $index => $source) {
$car_phone_valid = preg_match('/^1[3-9][0-9]{9}/', $source['car_phone']); if (empty(trim($source['car_phone']))) {
// 当不是标准有效对比无效的情况下,要进行数据对比替换 foreach ($sources as $source_data) {
if (!($car_phone_a_valid && !$car_phone_valid)) { if (trim($source_a['insurer1_date']) != trim($source['insurer1_date']) && (trim($source_a['insurer1_date']) == '' || $source_a['insurer1_date'] < $source['insurer1_date'])) {
if ($car_phone_a_valid && $car_phone_valid) { // 都有效更新电话 list($source_a, $source) = [$source, $source_a];
} else if (trim($source_a['insurer2_date']) != trim($source['insurer2_date']) && (trim($source_a['insurer2_date']) == '' || $source_a['insurer2_date'] < $source['insurer2_date'])) {
list($source_a, $source) = [$source, $source_a];
} else if ($source_a['car_no'] != $source['car_no'] && (trim($source_a['car_no']) == '' || !in_array(mb_strlen($source_a['car_no']), [7,8]))) {
list($source_a, $source) = [$source, $source_a];
} else if ($source_a['register_date'] != $source['register_date'] && (trim($source_a['register_date']) == '' || $source_a['register_date'] < $source['register_date'])) {
list($source_a, $source) = [$source, $source_a];
}
$this->repeatDataHandle($source_data, $id, 'frame');
$delete_num ++;
}
RepeatFrameT::where('car_frame_no', $item->car_frame_no)->delete();
$sources = [];
break;
} else if ($source_a['car_phone'] == $source['car_phone']) {
if (trim($source_a['insurer1_date']) != trim($source['insurer1_date']) && (trim($source_a['insurer1_date']) == '' || $source_a['insurer1_date'] < $source['insurer1_date'])) {
list($source_a, $source) = [$source, $source_a];
$this->repeatDataHandle($source, $id, 'frame');
$delete_num ++;
unset($sources[$index]);
} else if (trim($source_a['insurer2_date']) != trim($source['insurer2_date']) && (trim($source_a['insurer2_date']) == '' || $source_a['insurer2_date'] < $source['insurer2_date'])) {
list($source_a, $source) = [$source, $source_a];
$this->repeatDataHandle($source, $id, 'frame');
$delete_num ++;
unset($sources[$index]);
} else if ($source_a['car_no'] != $source['car_no'] && (trim($source_a['car_no']) == '' || !in_array(mb_strlen($source_a['car_no']), [7,8]))) {
list($source_a, $source) = [$source, $source_a];
$this->repeatDataHandle($source, $id, 'frame');
$delete_num ++;
unset($sources[$index]);
} else if ($source_a['register_date'] != $source['register_date'] && (trim($source_a['register_date']) == '' || $source_a['register_date'] < $source['register_date'])) {
list($source_a, $source) = [$source, $source_a];
$this->repeatDataHandle($source, $id, 'frame');
$delete_num ++;
unset($sources[$index]);
}
if (isset($sources[$index])) {
$this->repeatDataHandle($source, $id, 'frame');
$delete_num ++;
unset($sources[$index]);
}
} else if (!preg_match('/^1[3-9][0-9]{9}/', $source['car_phone'])) {
if (preg_match('/^1[3-9][0-9]{9}/', $source_a['car_phone'])) {
} else if (trim($source_a['insurer1_date']) != trim($source['insurer1_date']) && (trim($source_a['insurer1_date']) == '' || $source_a['insurer1_date'] < $source['insurer1_date'])) {
list($source_a, $source) = [$source, $source_a];
} else if (trim($source_a['insurer2_date']) != trim($source['insurer2_date']) && (trim($source_a['insurer2_date']) == '' || $source_a['insurer2_date'] < $source['insurer2_date'])) {
list($source_a, $source) = [$source, $source_a];
} else if ($source_a['car_no'] != $source['car_no'] && (trim($source_a['car_no']) == '' || !in_array(mb_strlen($source_a['car_no']), [7,8]))) {
list($source_a, $source) = [$source, $source_a];
} else if ($source_a['register_date'] != $source['register_date'] && (trim($source_a['register_date']) == '' || $source_a['register_date'] < $source['register_date'])) {
list($source_a, $source) = [$source, $source_a];
}
$this->repeatDataHandle($source, $id, 'frame');
$delete_num ++;
unset($sources[$index]);
} else {
if (trim($source_a['insurer1_date']) != trim($source['insurer1_date']) && (trim($source_a['insurer1_date']) == '' || $source_a['insurer1_date'] < $source['insurer1_date'])) {
list($source_a, $source) = [$source, $source_a];
} else if (trim($source_a['insurer2_date']) != trim($source['insurer2_date']) && (trim($source_a['insurer2_date']) == '' || $source_a['insurer2_date'] < $source['insurer2_date'])) {
list($source_a, $source) = [$source, $source_a];
} else if ($source_a['car_no'] != $source['car_no'] && (trim($source_a['car_no']) == '' || !in_array(mb_strlen($source_a['car_no']), [7,8]))) {
list($source_a, $source) = [$source, $source_a];
} else if ($source_a['register_date'] != $source['register_date'] && (trim($source_a['register_date']) == '' || $source_a['register_date'] < $source['register_date'])) {
list($source_a, $source) = [$source, $source_a];
}
$phones = [$source['car_phone']]; $phones = [$source['car_phone']];
$phones_a = [$source_a['car_phone']]; $phones_a = [$source_a['car_phone']];
foreach (['id_phone', 'insured_phone', 'link_phone_1', 'link_phone_2', 'link_phone_3'] as $key) { foreach (['id_phone', 'insured_phone', 'link_phone_1', 'link_phone_2', 'link_phone_3'] as $key) {
@ -358,29 +425,12 @@ class CarInfoHandle
break; break;
} }
CarInfoT::where('id', $source_a['id'])->update($source_a); CarInfoT::where('id', $source_a['id'])->update($source_a);
}
} else if (!$car_phone_a_valid && $car_phone_valid) { // 标准无效,对比有效
list($source_a, $source) = [$source, $source_a];
} else if (trim($source_a['insurer1_date']) != trim($source['insurer1_date']) && (trim($source_a['insurer1_date']) == '' || $source_a['insurer1_date'] < $source['insurer1_date'])) {
list($source_a, $source) = [$source, $source_a];
} else if (trim($source_a['insurer2_date']) != trim($source['insurer2_date']) && (trim($source_a['insurer2_date']) == '' || $source_a['insurer2_date'] < $source['insurer2_date'])) {
list($source_a, $source) = [$source, $source_a];
} else if ($source_a['is_export_bmc'] == 0 && $source['is_export_bmc'] > 0) {
list($source_a, $source) = [$source, $source_a];
} else if ($source_a['is_update_bhx'] == 0 && $source['is_update_bhx'] > 0) {
list($source_a, $source) = [$source, $source_a];
} else if ($source_a['is_export_bhx'] == 0 && $source['is_export_bhx'] > 0) {
list($source_a, $source) = [$source, $source_a];
} else if ($source_a['car_no'] != $source['car_no'] && (trim($source_a['car_no']) == '' || !in_array(mb_strlen($source_a['car_no']), [7,8]))) {
list($source_a, $source) = [$source, $source_a];
} else if ($source_a['register_date'] != $source['register_date'] && (trim($source_a['register_date']) == '' || $source_a['register_date'] < $source['register_date'])) {
list($source_a, $source) = [$source, $source_a];
}
}
$this->repeatDataHandle($source, $id, 'frame'); $this->repeatDataHandle($source, $id, 'frame');
$delete_num ++; $delete_num ++;
unset($sources[$index]); unset($sources[$index]);
} }
}
}
if (empty($sources)) if (empty($sources))
RepeatFrameT::where('car_frame_no', $item->car_frame_no)->delete(); RepeatFrameT::where('car_frame_no', $item->car_frame_no)->delete();
Db::commit(); Db::commit();

Loading…
Cancel
Save