|
@@ -15,19 +15,14 @@ class FyySqlServerService extends Service
|
|
|
{
|
|
|
public $db = null;
|
|
|
public $error = null;
|
|
|
- public $host = "s6j9560970.goho.co";//数据库外网域名
|
|
|
- public $host_api = 'https://s6j9560970.goho.co:443';//用友接口外网域名
|
|
|
- public $port = 44773;
|
|
|
- public $database = "UFDATA_999_2023";
|
|
|
+ public $host = "192.168.0.157";//数据库外网域名
|
|
|
+ public $host_api = '192.168.0.157';//用友接口外网域名
|
|
|
+ public $port = 1433;
|
|
|
+ public $database = "UFDATA_001_2024";
|
|
|
public $url = "";
|
|
|
- public $sAccID = "(default)@999";
|
|
|
- public $sUserID = "demo";
|
|
|
+ public $sAccID = "(default)@001";
|
|
|
+ public $sUserID = "0001";
|
|
|
public $sPassword = "";
|
|
|
- private $database_select = [
|
|
|
- '001' => 'UFDATA_001_2023',
|
|
|
- '002' => 'UFDATA_002_2023',
|
|
|
- '999' => 'UFDATA_999_2023'
|
|
|
- ];
|
|
|
|
|
|
public function __construct($user_id = [])
|
|
|
{
|
|
@@ -37,44 +32,18 @@ class FyySqlServerService extends Service
|
|
|
$this->error = '福羊羊数据库连接用户参数不能为空!';
|
|
|
return;
|
|
|
}
|
|
|
- //账套
|
|
|
- $zt = Request()->header('zt');
|
|
|
- if (!$zt && isset($user_id['zt'])) $zt = $user_id['zt'];
|
|
|
- $this->database = $this->database_select[$zt] ?? '';
|
|
|
- $this->sAccID = '(default)@' . $zt;
|
|
|
|
|
|
//获取用友账号密码
|
|
|
- if (isset($user_id['zt'])) {
|
|
|
- $database = (new FinishedOrderService())->getConnectionName($user_id['zt']);
|
|
|
- $model = new Employee();
|
|
|
- $model->setConnection($database);
|
|
|
- $emp = $model->where('id', $user_id['id'])->select('sqlserver_account', 'sqlserver_password')->first();
|
|
|
- } else {
|
|
|
- $emp = Employee::where('id', $user_id['id'])->select('sqlserver_account', 'sqlserver_password')->first();
|
|
|
- }
|
|
|
- if (empty($emp)) {
|
|
|
- $this->error = '福羊羊连接构造失败!';
|
|
|
+ $emp = Employee::where('id', $user_id['id'])->select('sqlserver_account', 'sqlserver_password')->first();
|
|
|
+ if (empty($emp) || empty($emp->sqlserver_account)) {
|
|
|
+ $this->error = '福羊羊连接构造失败,未找到账号对应的用友账号信息';
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
//用友接口统一登录账号密码
|
|
|
$this->sUserID = $emp->sqlserver_account ?? '';
|
|
|
$this->sPassword = $emp->sqlserver_password ?? '';
|
|
|
-
|
|
|
- //之前测试留下的入口 现在没用
|
|
|
- $key = 'fyy_sql_server' . $user_id['id'];
|
|
|
- $fyy_array = Redis::get($key);
|
|
|
- if (!empty($fyy_array)) {
|
|
|
- $fyy_array = json_decode($fyy_array, true);
|
|
|
- if (!empty($fyy_array['sqlserver_database'])) $this->database = $this->database_select[$fyy_array['sqlserver_zt']];
|
|
|
- if (!empty($fyy_array['sqlserver_zt'])) $this->sAccID = '(default)@' . $fyy_array['sqlserver_zt'];
|
|
|
- if (!empty($fyy_array['sqlserver_host'])) $this->host = $fyy_array['sqlserver_host'];
|
|
|
- if (!empty($fyy_array['sqlserver_host_api'])) $this->host_api = $fyy_array['sqlserver_host_api'];
|
|
|
- if (!empty($fyy_array['sqlserver_port'])) $this->port = $fyy_array['sqlserver_port'];
|
|
|
- if (!empty($fyy_array['sqlserver_account'])) $this->sUserID = $fyy_array['sqlserver_account'];
|
|
|
- if (!empty($fyy_array['sqlserver_password'])) $this->sPassword = $fyy_array['sqlserver_password'];
|
|
|
- }
|
|
|
$this->url = $this->host_api . "/U8Sys/U8API";
|
|
|
- //----------
|
|
|
|
|
|
if (!$this->db) {
|
|
|
$config = [
|
|
@@ -89,7 +58,6 @@ class FyySqlServerService extends Service
|
|
|
// 进行数据库连接
|
|
|
Config::set('database.connections.sqlsrvs', $config);
|
|
|
|
|
|
-
|
|
|
$pdo = DB::connection('sqlsrvs')->getPdo();
|
|
|
if ($pdo instanceof \PDO) {
|
|
|
// 连接成功的逻辑代码
|
|
@@ -104,81 +72,8 @@ class FyySqlServerService extends Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //假数据
|
|
|
- private function fakeData()
|
|
|
- {
|
|
|
- $return = [
|
|
|
- [
|
|
|
- 'out_order_no' => '001',
|
|
|
- 'out_order_no_time' => 1685928995,
|
|
|
- 'customer_no' => '201603012',
|
|
|
- 'customer_name' => '巴大胡',
|
|
|
- 'table_header_mark' => '表头备注',
|
|
|
- 'product_no' => '产品编码001',
|
|
|
- 'product_title' => '产品名称001',
|
|
|
- 'product_size' => '产品规格30c',
|
|
|
- 'product_unit' => '产品单位米',
|
|
|
- 'order_quantity' => 100,
|
|
|
- 'product_quantity_on_hand' => 50,
|
|
|
- 'technology_material' => '工艺材质',
|
|
|
- 'technology_name' => '工艺名称:同命',
|
|
|
- 'wood_name' => '木皮名称:梭梭树皮',
|
|
|
- 'process_mark' => '加工备注',
|
|
|
- 'table_body_mark' => '表体备注',
|
|
|
- 'out_crt_man' => '外部人员一',
|
|
|
- 'out_checker_man' => '外部人员二',
|
|
|
- 'out_checker_time' => 1685928995,
|
|
|
- ],
|
|
|
- [
|
|
|
- 'out_order_no' => '001',
|
|
|
- 'out_order_no_time' => 1685928995,
|
|
|
- 'customer_no' => '201603012',
|
|
|
- 'customer_name' => '巴大胡',
|
|
|
- 'table_header_mark' => '表头备注',
|
|
|
- 'product_no' => '产品编码002',
|
|
|
- 'product_title' => '产品名称002',
|
|
|
- 'product_size' => '产品规格30d',
|
|
|
- 'product_unit' => '产品单位米',
|
|
|
- 'order_quantity' => 100,
|
|
|
- 'product_quantity_on_hand' => 50,
|
|
|
- 'technology_material' => '工艺材质',
|
|
|
- 'technology_name' => '工艺名称:同命',
|
|
|
- 'wood_name' => '木皮名称:梭梭树皮',
|
|
|
- 'process_mark' => '加工备注',
|
|
|
- 'table_body_mark' => '表体备注',
|
|
|
- 'out_crt_man' => '外部人员一',
|
|
|
- 'out_checker_man' => '外部人员二',
|
|
|
- 'out_checker_time' => 1685928995,
|
|
|
- ],
|
|
|
- [
|
|
|
- 'out_order_no' => '002',
|
|
|
- 'out_order_no_time' => 1685928995,
|
|
|
- 'customer_no' => '201603012',
|
|
|
- 'customer_name' => '巴大胡',
|
|
|
- 'table_header_mark' => '表头备注',
|
|
|
- 'product_no' => '产品编码002',
|
|
|
- 'product_title' => '产品名称002',
|
|
|
- 'product_size' => '产品规格30d',
|
|
|
- 'product_unit' => '产品单位米',
|
|
|
- 'order_quantity' => 100,
|
|
|
- 'product_quantity_on_hand' => 50,
|
|
|
- 'technology_material' => '工艺材质',
|
|
|
- 'technology_name' => '工艺名称:同命',
|
|
|
- 'wood_name' => '木皮名称:梭梭树皮',
|
|
|
- 'process_mark' => '加工备注',
|
|
|
- 'table_body_mark' => '表体备注',
|
|
|
- 'out_crt_man' => '外部人员一',
|
|
|
- 'out_checker_man' => '外部人员二',
|
|
|
- 'out_checker_time' => 1685928995,
|
|
|
- ],
|
|
|
- ];
|
|
|
- return $return;
|
|
|
- }
|
|
|
-
|
|
|
public function is_same_month($timestamp1, $timestamp2)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
// 格式化时间戳为年份和月份
|
|
|
$year1 = date('Y', $timestamp1);
|
|
|
$month1 = date('m', $timestamp1);
|
|
@@ -532,60 +427,6 @@ class FyySqlServerService extends Service
|
|
|
return $message;
|
|
|
}
|
|
|
|
|
|
- //产成品入库单单据号
|
|
|
- public function createOrderNumberAboutSCRK()
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
- $current_month = date('m'); // 获取当前月份
|
|
|
- $date1 = date('y') . $current_month; // 格式 "2307"
|
|
|
- $date2 = date('Y') . $current_month; // 格式 "202307"
|
|
|
-
|
|
|
- $record = $this->db->table('VoucherHistory')
|
|
|
- ->where('CardNumber', '0411')
|
|
|
- ->whereRaw("(cSeed = '{$date1}' or cSeed = '{$date2}')")
|
|
|
- ->select('cNumber')
|
|
|
- ->first();
|
|
|
- $record = (array)$record;
|
|
|
- if (empty($record)) return [false, '未找到产成品入库当月流水号信息!'];
|
|
|
-
|
|
|
- $tmp = $record['cNumber'] + 1;
|
|
|
- if (strlen($tmp) > 4) return [false, '产成品入库当月流水号超过四位数!'];
|
|
|
-
|
|
|
- $number = str_pad($tmp, 4, '0', STR_PAD_LEFT);
|
|
|
- $number = $tmp . $number;
|
|
|
- $ccode = "SCRK" . $date2 . $number;
|
|
|
-
|
|
|
- return [true, $ccode];
|
|
|
- }
|
|
|
-
|
|
|
- //销售出库单单据号
|
|
|
- public function createOrderNumberAboutXC()
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
- $current_month = date('m'); // 获取当前月份
|
|
|
- $date1 = date('y') . $current_month; // 格式 "2307"
|
|
|
- $date2 = date('Y') . $current_month; // 格式 "202307"
|
|
|
-
|
|
|
- $record = $this->db->table('VoucherHistory')
|
|
|
- ->where('CardNumber', '0303')
|
|
|
- ->whereRaw("(cSeed = '{$date1}' or cSeed = '{$date2}')")
|
|
|
- ->select('cNumber')
|
|
|
- ->first();
|
|
|
- $record = (array)$record;
|
|
|
- if (empty($record)) return [false, '未找到销售出库单当月流水号信息!'];
|
|
|
-
|
|
|
- $tmp = $record['cNumber'] + 1;
|
|
|
- if (strlen($tmp) > 4) return [false, '销售出库单当月流水号超过四位数!'];
|
|
|
-
|
|
|
- $number = str_pad($tmp, 4, '0', STR_PAD_LEFT);
|
|
|
- $number = $tmp . $number;
|
|
|
- $ccode = "XC" . $date2 . $number;
|
|
|
-
|
|
|
- return [true, $ccode];
|
|
|
- }
|
|
|
-
|
|
|
public function post_helper($url, $data, $header = [], $timeout = 60)
|
|
|
{
|
|
|
$ch = curl_init();
|