|
|
@@ -7,6 +7,7 @@ use app\api\controller\OrderSuperLoss;
|
|
|
use think\db\exception\DataNotFoundException;
|
|
|
use think\db\exception\ModelNotFoundException;
|
|
|
use think\exception\DbException;
|
|
|
+use think\Db;
|
|
|
|
|
|
/**
|
|
|
* 成品入仓维护接口
|
|
|
@@ -441,6 +442,8 @@ class FinishedProductWarehousing extends Api
|
|
|
if(!$this->request->isPost()){
|
|
|
$this->error('请求方式错误');
|
|
|
}
|
|
|
+ //连接mongodb
|
|
|
+ $mongodb = Db::connect(config('database.mongodb'));
|
|
|
$req = $this->request->param();
|
|
|
$arr = [
|
|
|
'Sys_id',
|
|
|
@@ -483,6 +486,8 @@ class FinishedProductWarehousing extends Api
|
|
|
try{
|
|
|
$sql = db('成品入仓')->fetchSql(true)->insert($data);
|
|
|
$bool = db()->query($sql);
|
|
|
+ //新增进MongoDB
|
|
|
+ $res = $mongodb->name('finished_products')->insert($data);
|
|
|
// 提交事务
|
|
|
db()->commit();
|
|
|
} catch (\Exception $e) {
|
|
|
@@ -522,6 +527,8 @@ class FinishedProductWarehousing extends Api
|
|
|
if(!$this->request->isPost()){
|
|
|
$this->error('请求方式错误');
|
|
|
}
|
|
|
+ //连接mongodb
|
|
|
+ $mongodb = Db::connect(config('database.mongodb'));
|
|
|
$req = $this->request->param();
|
|
|
$arr = [
|
|
|
'入仓类型', '仓库编号', '仓库名称',
|
|
|
@@ -561,12 +568,15 @@ class FinishedProductWarehousing extends Api
|
|
|
$this->error($existingRecord['jjcp_gdbh'].'工单 -- 印件'.$existingRecord['jjcp_yjno'].'已经进入末版,无法继续操作');
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
//开启事务
|
|
|
db()->startTrans();
|
|
|
try{
|
|
|
$sql = db('成品入仓')->where('UniqId',$req['UniqId'])->fetchSql(true)->update($data);
|
|
|
$bool = db()->query($sql);
|
|
|
+ //同步更新monodb数据
|
|
|
+ $res = $mongodb->name('finished_products')
|
|
|
+ ->where('UniqId', (int)$req['UniqId']) // 使用实际的UniqId值
|
|
|
+ ->update($data);
|
|
|
// 提交事务
|
|
|
db()->commit();
|
|
|
} catch (\Exception $e) {
|
|
|
@@ -606,6 +616,8 @@ class FinishedProductWarehousing extends Api
|
|
|
if(!$this->request->isPost()){
|
|
|
$this->error('请求方式错误');
|
|
|
}
|
|
|
+ //连接mongodb
|
|
|
+ $mongodb = Db::connect(config('database.mongodb'));
|
|
|
$req = $this->request->param();
|
|
|
|
|
|
if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
|
|
|
@@ -616,6 +628,11 @@ class FinishedProductWarehousing extends Api
|
|
|
db()->startTrans();
|
|
|
try{
|
|
|
$bool = db('成品入仓')->where('UniqId',$req['UniqId'])->delete();
|
|
|
+ //同时删除mongdb数据
|
|
|
+ //同步更新monodb数据
|
|
|
+ $res = $mongodb->name('finished_products')
|
|
|
+ ->where('UniqId', (int)$req['UniqId']) // 使用实际的UniqId值
|
|
|
+ ->delete();
|
|
|
// 提交事务
|
|
|
db()->commit();
|
|
|
} catch (\Exception $e) {
|