|
|
@@ -520,4 +520,428 @@ class Synchronization extends Api
|
|
|
$this->success('人事组织结构同步成功');
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 物料存货编码数据同步
|
|
|
+ * @return void
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function InventoryCodeData()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $db3 = \db()->connect(config('database.db3'));
|
|
|
+ $OrganizationalDataList = $db3->name('U8_04物料编码')
|
|
|
+ ->where('MES接收时间',null)
|
|
|
+ ->where('MES接收状态','0')
|
|
|
+ ->select();
|
|
|
+ if (empty($OrganizationalDataList)){
|
|
|
+ $this->success('未找到新的物料编码');
|
|
|
+ }
|
|
|
+ $i = 0;
|
|
|
+ foreach ($OrganizationalDataList as $key=>$value){
|
|
|
+ $data = [
|
|
|
+ '物料代码'=>$value['物料代码'],
|
|
|
+ '物料名称'=>$value['物料名称'],
|
|
|
+ '规格'=>$value['规格'],
|
|
|
+ '采购单位'=>$value['采购单位'],
|
|
|
+ '领用单位'=>$value['领用单位'],
|
|
|
+ '单位换算率'=>$value['单位换算率'],
|
|
|
+ '单价'=>$value['单价'],
|
|
|
+ '币种'=>$value['币种'],
|
|
|
+ '物料备注'=>$value['物料备注'],
|
|
|
+ '状态'=>$value['状态'],
|
|
|
+ 'Sys_id'=>'[272/超级用户]',
|
|
|
+ 'Sys_rq'=>date('Y-m-d H:i:s',time()),
|
|
|
+ 'Mod_rq'=>'1900-01-01 00:00:00',
|
|
|
+ 'U8UID'=>$value['U8_UID'],
|
|
|
+ 'UniqId'=>$value['UniqId'],
|
|
|
+ ];
|
|
|
+ $number = \db('物料_存货编码')
|
|
|
+ ->where('Uniqid',$value['UniqId'])
|
|
|
+ ->count();
|
|
|
+ if ($number === 0){
|
|
|
+ $sql = \db('物料_存货编码')->fetchSql(true)->insert($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res === false){
|
|
|
+ $i++;
|
|
|
+ }else{
|
|
|
+ $sqlString = $db3->name('U8_04物料编码')
|
|
|
+ ->where('UniqId', $value['UniqId'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update([
|
|
|
+ 'MES接收时间' => date('Y-m-d H:i:s', time()),
|
|
|
+ 'MES接收状态' => '1'
|
|
|
+ ]);
|
|
|
+ $db3->execute($sqlString);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $sql = \db('物料_存货编码')
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->where('UniqId',$value['UniqId'])
|
|
|
+ ->update($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res === false){
|
|
|
+ $i++;
|
|
|
+ }else{
|
|
|
+ $sqlString = $db3->name('U8_04物料编码')
|
|
|
+ ->where('UniqId', $value['UniqId'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update([
|
|
|
+ 'MES接收时间' => date('Y-m-d H:i:s', time()),
|
|
|
+ 'MES接收状态' => '1'
|
|
|
+ ]);
|
|
|
+ $db3->execute($sqlString);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($i !== 0){
|
|
|
+ $this->error('物料编码同步失败');
|
|
|
+ }else{
|
|
|
+ $this->success('物料编码同步成功');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客户供应商数据同步
|
|
|
+ * @return void
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function CustomerSupplierData()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $db3 = \db()->connect(config('database.db3'));
|
|
|
+ $OrganizationalDataList = $db3->name('U8_03客户供应商')
|
|
|
+ ->where('MES接收时间',null)
|
|
|
+ ->where('MES接收状态','0')
|
|
|
+ ->select();
|
|
|
+ if (empty($OrganizationalDataList)){
|
|
|
+ $this->success('未找到新的客户供应商');
|
|
|
+ }
|
|
|
+ $i = 0;
|
|
|
+ foreach ($OrganizationalDataList as $key=>$value){
|
|
|
+ $data = [
|
|
|
+ '类型'=>$value['类型'],
|
|
|
+ '编号'=>$value['编号'],
|
|
|
+ '名称'=>$value['名称'],
|
|
|
+ '简称'=>$value['简称'],
|
|
|
+ '地址'=>$value['地址'],
|
|
|
+ '对口部门'=>$value['对口部门'],
|
|
|
+ '联系人'=>$value['联系人'],
|
|
|
+ '电话'=>$value['电话'],
|
|
|
+ '业务员'=>$value['业务员'],
|
|
|
+ '币种'=>$value['币种'],
|
|
|
+ 'Sys_id'=>'[272/超级用户]',
|
|
|
+ 'Sys_rq'=>date('Y-m-d H:i:s',time()),
|
|
|
+ 'Mod_rq'=>'1900-01-01 00:00:00',
|
|
|
+ 'U8UID'=>$value['U8_UID'],
|
|
|
+ 'UniqId'=>$value['UniqId'],
|
|
|
+ ];
|
|
|
+ $number = \db('erp_客户供应商')
|
|
|
+ ->where('Uniqid',$value['UniqId'])
|
|
|
+ ->count();
|
|
|
+ if ($number === 0){
|
|
|
+ $sql = \db('erp_客户供应商')->fetchSql(true)->insert($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res === false){
|
|
|
+ $i++;
|
|
|
+ }else{
|
|
|
+ $sqlString = $db3->name('U8_03客户供应商')
|
|
|
+ ->where('UniqId', $value['UniqId'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update([
|
|
|
+ 'MES接收时间' => date('Y-m-d H:i:s', time()),
|
|
|
+ 'MES接收状态' => '1'
|
|
|
+ ]);
|
|
|
+ $db3->execute($sqlString);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $sql = \db('erp_客户供应商')
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->where('UniqId',$value['UniqId'])
|
|
|
+ ->update($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res === false){
|
|
|
+ $i++;
|
|
|
+ }else{
|
|
|
+ $sqlString = $db3->name('U8_03客户供应商')
|
|
|
+ ->where('UniqId', $value['UniqId'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update([
|
|
|
+ 'MES接收时间' => date('Y-m-d H:i:s', time()),
|
|
|
+ 'MES接收状态' => '1'
|
|
|
+ ]);
|
|
|
+ $db3->execute($sqlString);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($i !== 0){
|
|
|
+ $this->error('客户供应商同步失败');
|
|
|
+ }else{
|
|
|
+ $this->success('客户供应商同步成功');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 物料领用记录数据同步
|
|
|
+ * @return void
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function ReceiptRecordData()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $db3 = \db()->connect(config('database.db3'));
|
|
|
+ $OrganizationalDataList = $db3->name('U8_07物料领用')
|
|
|
+ ->where('MES接收时间',null)
|
|
|
+ ->where('MES接收状态','0')
|
|
|
+ ->select();
|
|
|
+ if (empty($OrganizationalDataList)){
|
|
|
+ $this->success('未找到新的物料领用记录');
|
|
|
+ }
|
|
|
+ $i = 0;
|
|
|
+ foreach ($OrganizationalDataList as $key=>$value){
|
|
|
+ $data = [
|
|
|
+ 'st_rq'=>$value['日期'],
|
|
|
+ 'st_jylb'=>$value['交易类别'],
|
|
|
+ 'st_gdbh'=>$value['工单编号'],
|
|
|
+ '采购单号'=>$value['采购单号'],
|
|
|
+ '供方批次'=>$value['供方批次'],
|
|
|
+ 'st_wlbh'=>$value['物料编号'],
|
|
|
+ 'st_sl'=>$value['领用数量'],
|
|
|
+ 'st_dw'=>$value['领用单位'],
|
|
|
+ '领用单价'=>$value['领用单价'],
|
|
|
+ 'st_desc'=>$value['备注'],
|
|
|
+ '仓库编号'=>$value['仓库编号'],
|
|
|
+ 'st_dpt'=>$value['采购单号'],
|
|
|
+ 'st_jtbh'=>$value['机台编号'],
|
|
|
+ 'sys_id'=>'[272/超级用户]',
|
|
|
+ 'sys_rq'=>date('Y-m-d H:i:s',time()),
|
|
|
+ 'mod_rq'=>'1900-01-01 00:00:00',
|
|
|
+ 'U8UID'=>$value['U8_UID'],
|
|
|
+ 'Uniqid'=>$value['UniqId'],
|
|
|
+ ];
|
|
|
+ $number = \db('物料_收发记录')
|
|
|
+ ->where('Uniqid',$value['UniqId'])
|
|
|
+ ->count();
|
|
|
+ if ($number === 0){
|
|
|
+ $sql = \db('物料_收发记录')->fetchSql(true)->insert($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res === false){
|
|
|
+ $i++;
|
|
|
+ }else{
|
|
|
+ $sqlString = $db3->name('U8_07物料领用')
|
|
|
+ ->where('UniqId', $value['UniqId'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update([
|
|
|
+ 'MES接收时间' => date('Y-m-d H:i:s', time()),
|
|
|
+ 'MES接收状态' => '1'
|
|
|
+ ]);
|
|
|
+ $db3->execute($sqlString);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $sql = \db('物料_收发记录')
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->where('UniqId',$value['UniqId'])
|
|
|
+ ->update($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res === false){
|
|
|
+ $i++;
|
|
|
+ }else{
|
|
|
+ $sqlString = $db3->name('U8_07物料领用')
|
|
|
+ ->where('UniqId', $value['UniqId'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update([
|
|
|
+ 'MES接收时间' => date('Y-m-d H:i:s', time()),
|
|
|
+ 'MES接收状态' => '1'
|
|
|
+ ]);
|
|
|
+ $db3->execute($sqlString);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($i !== 0){
|
|
|
+ $this->error('物料领用记录同步失败');
|
|
|
+ }else{
|
|
|
+ $this->success('物料领用记录同步成功');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 仓库信息数据同步
|
|
|
+ * @return void
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function WarehouseInformationData()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $db3 = \db()->connect(config('database.db3'));
|
|
|
+ $OrganizationalDataList = $db3->name('U8_12仓库信息')
|
|
|
+ ->where('MES接收时间',null)
|
|
|
+ ->where('MES接收状态','0')
|
|
|
+ ->select();
|
|
|
+ if (empty($OrganizationalDataList)){
|
|
|
+ $this->success('未找到新的仓库信息');
|
|
|
+ }
|
|
|
+ $i = 0;
|
|
|
+ foreach ($OrganizationalDataList as $key=>$value){
|
|
|
+ $data = [
|
|
|
+ '编号'=>$value['编号'],
|
|
|
+ '名称'=>$value['名称'],
|
|
|
+ 'Sys_id'=>'[272/超级用户]',
|
|
|
+ 'Sys_rq'=>date('Y-m-d H:i:s',time()),
|
|
|
+ 'Mod_rq'=>'1900-01-01 00:00:00',
|
|
|
+ 'U8UID'=>$value['U8_UID'],
|
|
|
+ 'UniqId'=>$value['UniqId'],
|
|
|
+ ];
|
|
|
+ $number = \db('物料_仓库信息')
|
|
|
+ ->where('Uniqid',$value['UniqId'])
|
|
|
+ ->count();
|
|
|
+ if ($number === 0){
|
|
|
+ $sql = \db('物料_仓库信息')->fetchSql(true)->insert($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res === false){
|
|
|
+ $i++;
|
|
|
+ }else{
|
|
|
+ $sqlString = $db3->name('U8_12仓库信息')
|
|
|
+ ->where('UniqId', $value['UniqId'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update([
|
|
|
+ 'MES接收时间' => date('Y-m-d H:i:s', time()),
|
|
|
+ 'MES接收状态' => '1'
|
|
|
+ ]);
|
|
|
+ $db3->execute($sqlString);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $sql = \db('物料_仓库信息')
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->where('UniqId',$value['UniqId'])
|
|
|
+ ->update($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res === false){
|
|
|
+ $i++;
|
|
|
+ }else{
|
|
|
+ $sqlString = $db3->name('U8_12仓库信息')
|
|
|
+ ->where('UniqId', $value['UniqId'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update([
|
|
|
+ 'MES接收时间' => date('Y-m-d H:i:s', time()),
|
|
|
+ 'MES接收状态' => '1'
|
|
|
+ ]);
|
|
|
+ $db3->execute($sqlString);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($i !== 0){
|
|
|
+ $this->error('仓库信息同步失败');
|
|
|
+ }else{
|
|
|
+ $this->success('仓库信息同步成功');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 职位编码数据同步
|
|
|
+ * @return void
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function PositionData()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $db3 = \db()->connect(config('database.db3'));
|
|
|
+ $OrganizationalDataList = $db3->name('U8_13职位编码')
|
|
|
+ ->where('MES接收时间',null)
|
|
|
+ ->where('MES接收状态','0')
|
|
|
+ ->select();
|
|
|
+ if (empty($OrganizationalDataList)){
|
|
|
+ $this->success('未找到新的职位编码');
|
|
|
+ }
|
|
|
+ $i = 0;
|
|
|
+ foreach ($OrganizationalDataList as $key=>$value){
|
|
|
+ $data = [
|
|
|
+ '职位编码'=>$value['职位编码'],
|
|
|
+ '职位名称'=>$value['职位名称'],
|
|
|
+ '定编人数'=>0,
|
|
|
+ '备注说明'=>'',
|
|
|
+ 'sys_id'=>'[272/超级用户]',
|
|
|
+ 'sys_rq'=>date('Y-m-d H:i:s',time()),
|
|
|
+ 'Mod_rq'=>'1900-01-01 00:00:00',
|
|
|
+ 'U8UID'=>$value['U8_UID'],
|
|
|
+ 'UniqID'=>$value['UniqID'],
|
|
|
+ ];
|
|
|
+ $number = \db('人事_职位编码')
|
|
|
+ ->where('Uniqid',$value['UniqID'])
|
|
|
+ ->count();
|
|
|
+ if ($number === 0){
|
|
|
+ $sql = \db('人事_职位编码')->fetchSql(true)->insert($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res === false){
|
|
|
+ $i++;
|
|
|
+ }else{
|
|
|
+ $sqlString = $db3->name('U8_13职位编码')
|
|
|
+ ->where('UniqID', $value['UniqID'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update([
|
|
|
+ 'MES接收时间' => date('Y-m-d H:i:s', time()),
|
|
|
+ 'MES接收状态' => '1'
|
|
|
+ ]);
|
|
|
+ $db3->execute($sqlString);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $sql = \db('人事_职位编码')
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->where('UniqID',$value['UniqID'])
|
|
|
+ ->update($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res === false){
|
|
|
+ $i++;
|
|
|
+ }else{
|
|
|
+ $sqlString = $db3->name('U8_13职位编码')
|
|
|
+ ->where('UniqID', $value['UniqID'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update([
|
|
|
+ 'MES接收时间' => date('Y-m-d H:i:s', time()),
|
|
|
+ 'MES接收状态' => '1'
|
|
|
+ ]);
|
|
|
+ $db3->execute($sqlString);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($i !== 0){
|
|
|
+ $this->error('职位编码同步失败');
|
|
|
+ }else{
|
|
|
+ $this->success('职位编码同步成功');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|