|
|
@@ -985,14 +985,15 @@ class Synchronization extends Api
|
|
|
{
|
|
|
mkdir(ROOT_PATH.'public/'.date('Y-m-d',time()),0777,true);
|
|
|
}
|
|
|
- $lastID = \db('设备_产量计酬')->order('UniqId desc')->value('UniqId');
|
|
|
- if (empty($lastID)){
|
|
|
- $lastID = 0;
|
|
|
- }
|
|
|
+// $lastID = \db('设备_产量计酬')->order('UniqId desc')->value('UniqId');
|
|
|
+// if (empty($lastID)){
|
|
|
+// $lastID = 0;
|
|
|
+// }
|
|
|
$db4 = \db()->connect(config('database.db4'));
|
|
|
$where = [
|
|
|
- 'sczl_rq'=>date('Y-m-d',time()),
|
|
|
- 'UniqId' =>['>',$lastID]
|
|
|
+// 'sczl_rq'=>date('Y-m-d',time()),
|
|
|
+// 'UniqId' =>['>',$lastID]
|
|
|
+ 'sczl_rq' => ['>=','2024-04-01']
|
|
|
];
|
|
|
$productData = $db4->name('设备_产量计酬')
|
|
|
->where($where)
|
|
|
@@ -1050,13 +1051,14 @@ class Synchronization extends Api
|
|
|
$data[$key]['sczl_gdbh'] = $workcode;
|
|
|
}
|
|
|
//插入设备产量计酬数据
|
|
|
- $sql = \db('设备_产量计酬')->fetchSql(true)->insertAll($data);
|
|
|
- $res = \db()->query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $this->success('同步成功');
|
|
|
- }else{
|
|
|
- $this->error('同步失败');
|
|
|
+ \db()->startTrans();
|
|
|
+ try {
|
|
|
+ \db('设备_产量计酬')->where('sczl_rq','>=','2024-04-01 00:00:00')->delete();
|
|
|
+ $sql = \db('设备_产量计酬')->fetchSql(true)->insertAll($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ }catch (\Exception $e){
|
|
|
+ \db()->rollback();
|
|
|
}
|
|
|
-
|
|
|
+ $this->success('同步成功');
|
|
|
}
|
|
|
}
|