Compare commits

...

2 Commits

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

@ -2,6 +2,7 @@
namespace app\controller;
use app\BaseController;
use app\model\RepeatFrameT;
use library\Tree;
use think\facade\Db;
use think\response\Json;
@ -147,6 +148,28 @@ 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
* @return array

@ -141,6 +141,7 @@
<div class="layui-form-item layui-col-md2" style="clear: none;">
<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-danger layui-btn-sm" id="recovery-btn">恢复</button>
</div>
</div>
</div>
@ -253,6 +254,18 @@
where: param,
}, '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){

@ -313,7 +313,7 @@ class CarInfoHandle
echo '当前进度:' . round($current / $count * 100, 3) . PHP_EOL;
}
$sources = CarInfoT::where(['car_frame_no' => $item->car_frame_no])
->order('car_phone desc, insurer1_date desc, car_no desc, id desc')->select();
->order('car_phone desc, id desc')->select();
if ($sources->isEmpty())
continue;
$sources = $sources->toArray();
@ -329,107 +329,57 @@ class CarInfoHandle
if (empty($source_a)) {
$source_a = $sources[0];
array_shift($sources);
}
Db::startTrans();
} Db::startTrans();
try {
$car_phone_a_valid = preg_match('/^1[3-9][0-9]{9}/', $source_a['car_phone']);
foreach ($sources as $index => $source) {
if (empty(trim($source['car_phone']))) {
foreach ($sources as $source_data) {
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];
$car_phone_valid = preg_match('/^1[3-9][0-9]{9}/', $source['car_phone']);
// 当不是标准有效对比无效的情况下,要进行数据对比替换
if (!($car_phone_a_valid && !$car_phone_valid)) {
if ($car_phone_a_valid && $car_phone_valid) { // 都有效更新电话
$phones = [$source['car_phone']];
$phones_a = [$source_a['car_phone']];
foreach (['id_phone', 'insured_phone', 'link_phone_1', 'link_phone_2', 'link_phone_3'] as $key) {
if (preg_match('/^1[3-9][0-9]{9}/', $source_a[$key]) && !in_array($source_a[$key], $phones_a))
$phones_a[] = $source_a[$key];
if (preg_match('/^1[3-9][0-9]{9}/', $source[$key]) && !in_array($source[$key], $phones))
$phones[] = $source[$key];
}
$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'])) {
$phones = array_unique(array_merge($phones_a, $phones));
// 可用电话大于6个时跳过
if (count($phones) <= 6) {
array_shift($phones);
foreach (['id_phone', 'insured_phone', 'link_phone_1', 'link_phone_2', 'link_phone_3'] as $key) {
if (in_array($source_a[$key], $phones))
array_shift($phones);
else
$source_a[$key] = array_shift($phones);
if (empty($source_a[$key]) || empty($phones))
break;
}
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];
$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]))) {
} else if ($source_a['is_export_bmc'] == 0 && $source['is_export_bmc'] > 0) {
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'])) {
} else if ($source_a['is_update_bhx'] == 0 && $source['is_update_bhx'] > 0) {
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'])) {
} 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];
}
$phones = [$source['car_phone']];
$phones_a = [$source_a['car_phone']];
foreach (['id_phone', 'insured_phone', 'link_phone_1', 'link_phone_2', 'link_phone_3'] as $key) {
if (preg_match('/^1[3-9][0-9]{9}/', $source_a[$key]) && !in_array($source_a[$key], $phones_a))
$phones_a[] = $source_a[$key];
if (preg_match('/^1[3-9][0-9]{9}/', $source[$key]) && !in_array($source[$key], $phones))
$phones[] = $source[$key];
}
$phones = array_unique(array_merge($phones_a, $phones));
// 可用电话大于6个时跳过
if (count($phones) <= 6) {
array_shift($phones);
foreach (['id_phone', 'insured_phone', 'link_phone_1', 'link_phone_2', 'link_phone_3'] as $key) {
if (in_array($source_a[$key], $phones))
array_shift($phones);
else
$source_a[$key] = array_shift($phones);
if (empty($source_a[$key]) || empty($phones))
break;
}
CarInfoT::where('id', $source_a['id'])->update($source_a);
$this->repeatDataHandle($source, $id, 'frame');
$delete_num ++;
unset($sources[$index]);
}
}
$this->repeatDataHandle($source, $id, 'frame');
$delete_num ++;
unset($sources[$index]);
}
if (empty($sources))
RepeatFrameT::where('car_frame_no', $item->car_frame_no)->delete();

Loading…
Cancel
Save