Commit 2c4eec27 authored by 蒋林's avatar 蒋林

1. 维修单相关接口开发

parent 705ad4ec
......@@ -37,20 +37,8 @@ class Galanz extends BaseController
$values = $obj->GetValues();
$this->saveLog($values['out_trade_no'], 'queryOrder', $param);
//搜索订单
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd'], $obj);
$search = $sourceGalanzObj->SearchOrder($values['out_trade_no']);
if (empty($search)) {
$obj->ReturnMessage(false, '查询的订单不存在');
}
//订单详情
$order = $sourceGalanzObj->OrderDetail($search[0][0]);
if (!isset($order['new_name']) && !$order['new_name']) {
$obj->ReturnMessage(false, '查询的订单不存在');
}
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getCallOrder($values['out_trade_no'], $sourceGalanzObj);
//字段过滤
$fields = [
......@@ -78,20 +66,8 @@ class Galanz extends BaseController
$values = $obj->GetValues();
$this->saveLog($values['work_order_no'], 'queryWorkOrder', $param);
//搜索订单
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd'], $obj);
$search = $sourceGalanzObj->SearchWorkOrder($values['work_order_no']);
if (empty($search)) {
$obj->ReturnMessage(false, '查询的维修单不存在');
}
//订单详情
$order = $sourceGalanzObj->WorkOrderDetail($search[0][0]);
if (!isset($order['new_name']) && !$order['new_name']) {
$obj->ReturnMessage(false, '查询的维修单不存在');
}
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getWorkOrder($values['work_order_no'], $sourceGalanzObj);
$obj->ReturnMessage(true, '', $order);
}
......@@ -107,26 +83,12 @@ class Galanz extends BaseController
$values = $obj->GetValues();
$this->saveLog($values['up_order_no'], 'queryUserProfileOrder', $param);
//搜索订单
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd'], $obj);
$search = $sourceGalanzObj->SearchUserProfieOrder($values['mobile'], $values['up_order_no']);
if (empty($search)) {
$obj->ReturnMessage(false, '查询的安装单不存在');
}
//订单详情
$order = $sourceGalanzObj->UserProfileOrderDetail($search[0][0]);
if (!isset($order['new_number']) && !$order['new_number']) {
$obj->ReturnMessage(false, '查询的安装单不存在');
}
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getUserProfileOrder($values['mobile'], $values['up_order_no'], $sourceGalanzObj);
$obj->ReturnMessage(true, '', $order);
}
//搜索维修单
//保存订单
public function saveOrder()
{
......@@ -139,20 +101,8 @@ class Galanz extends BaseController
$values = $obj->GetValues();
$this->saveLog($values['out_trade_no'], 'saveOrder', $param);
//搜索订单
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd'], $obj);
$search = $sourceGalanzObj->SearchOrder($values['out_trade_no']);
if (empty($search)) {
$obj->ReturnMessage(false, '查询的订单不存在');
}
//订单详情
$order = $sourceGalanzObj->OrderDetail($search[0][0]);
if (!isset($order['new_name']) && !$order['new_name']) {
$obj->ReturnMessage(false, '查询的订单不存在');
}
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getCallOrder($values['out_trade_no'], $sourceGalanzObj);
//处理参数
if ($values['new_sitecontacttime'] != '') {
......@@ -230,19 +180,8 @@ class Galanz extends BaseController
$this->saveLog($values['out_trade_no'], 'createWorkOrder', $param);
//搜索订单
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd'], $obj);
$search = $sourceGalanzObj->SearchOrder($values['out_trade_no']);
if (empty($search)) {
$obj->ReturnMessage(false, '查询的订单不存在');
}
//订单详情
$order = $sourceGalanzObj->OrderDetail($search[0][0]);
if (!isset($order['new_name']) && !$order['new_name']) {
$obj->ReturnMessage(false, '查询的订单不存在');
}
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getWorkOrder($values['out_trade_no'], $sourceGalanzObj);
//保存订单
$result = $sourceGalanzObj->CreateWorkOrder($order['new_id'], $order);
......@@ -265,62 +204,77 @@ class Galanz extends BaseController
$obj->SetValues($param);
$obj->CheckCreateUserProfileOrderValues();
$values = $obj->GetValues();
$this->saveLog($values['out_trade_no'], 'createUserprofileOrder', $param);
$this->saveLog($values['up_order_no'], 'createUserprofileOrder', $param);
//搜索订单
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd'], $obj);
$search = $sourceGalanzObj->SearchOrder($values['out_trade_no']);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getUserProfileOrder($values['mobile'], $values['up_order_no'], $sourceGalanzObj);
if (empty($search)) {
$obj->ReturnMessage(false, '查询的订单不存在');
}
//保存订单
$result = $sourceGalanzObj->CreateUserProfileOrder($order['new_id'], $order);
//订单详情
$order = $sourceGalanzObj->OrderDetail($search[0][0]);
$obj->ReturnMessage(true, '', $result);
}
if (!isset($order['new_name']) && !$order['new_name']) {
$obj->ReturnMessage(false, '查询的订单不存在');
}
public function saveUserProfileOrder()
{
$param = $this->input->post();
//验证参数
$obj = $this->receiveGalanzObj();
$obj->SetValues($param);
$obj->CheckSaveUserProfileOrderValues();
$values = $obj->GetValues();
$this->saveLog($values['up_order_no'], 'saveUserProfileOrder', $param);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getUserProfileOrder($values['mobile'], $values['up_order_no'], $sourceGalanzObj);
//保存订单
$result = $sourceGalanzObj->CreateUserProfileOrder($order['new_id'], $order);
$result = $sourceGalanzObj->SaveUserProfileOrder($order['new_id'], $order);
$obj->ReturnMessage(true, '', $result);
}
//保存维修单
public function saveWorkOrder()
public function sendUserProfileOrder()
{
$param = $this->input->post();
//验证参数
$obj = $this->receiveGalanzObj();
$obj->SetValues($param);
$obj->CheckSaveWorkOrderValues();
$obj->CheckSendUserProfileOrderValues();
$values = $obj->GetValues();
$this->saveLog($values['work_order_no'], 'saveWorkOrder', $param);
$this->saveLog($values['up_order_no'], 'sendUserProfileOrder', $param);
//搜索订单
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd'], $obj);
$search = $sourceGalanzObj->SearchWorkOrder($values['out_trade_no']);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getUserProfileOrder($values['mobile'], $values['up_order_no'], $sourceGalanzObj);
if (empty($search)) {
$obj->ReturnMessage(false, '查询的维修单不存在');
}
//发送订单
$result = $sourceGalanzObj->SendUserProfileOrder($order['new_id'], $order);
//订单详情
$order = $sourceGalanzObj->WorkOrderDetail($search[0][0]);
$obj->ReturnMessage(true, '', $result);
}
if (!isset($order['new_name']) && !$order['new_name']) {
$obj->ReturnMessage(false, '查询的维修单不存在');
}
//保存维修单
public function saveWorkOrder()
{
$param = $this->input->post();
//保存订单
//验证参数
$obj = $this->receiveGalanzObj();
$obj->SetValues($param);
$obj->CheckSaveWorkOrderValues();
$values = $obj->GetValues();
$this->saveLog($values['work_order_no'], 'saveWorkOrder', $param);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getWorkOrder($values['work_order_no'], $sourceGalanzObj);
$result = $sourceGalanzObj->SaveWorkOrder($order['new_id'], $order);
$obj->ReturnMessage(true, '', $result);
}
//发送维修单
public function sendWorkOrder()
{
$param = $this->input->post();
......@@ -332,96 +286,242 @@ class Galanz extends BaseController
$values = $obj->GetValues();
$this->saveLog($values['work_order_no'], 'sendWorkOrder', $param);
//搜索订单
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd'], $obj);
$search = $sourceGalanzObj->SearchWorkOrder($values['out_trade_no']);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getWorkOrder($values['work_order_no'], $sourceGalanzObj);
$result = $sourceGalanzObj->SendWorkOrder($order['new_id'], $order);
if (empty($search)) {
$obj->ReturnMessage(false, '查询的维修单不存在');
}
$obj->ReturnMessage(true, '', $result);
}
//订单详情
$order = $sourceGalanzObj->WorkOrderDetail($search[0][0]);
//维修单-添加机器信息
public function addProdWorkOrder()
{
$param = $this->input->post();
if (!isset($order['new_name']) && !$order['new_name']) {
$obj->ReturnMessage(false, '查询的维修单不存在');
}
//验证参数
$obj = $this->receiveGalanzObj();
$obj->SetValues($param);
$obj->CheckAddProdWorkOrderValues();
$values = $obj->GetValues();
$this->saveLog($values['work_order_no'], 'addProdWorkOrder', $param);
//发送订单
$result = $sourceGalanzObj->SendWorkOrder($order['new_id'], $order);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getWorkOrder($values['work_order_no'], $sourceGalanzObj);
$result = $sourceGalanzObj->ProdGetWorkOrder($order['new_id'], $order, $values['txtproducenumber']);
$obj->ReturnMessage(true, '', $result);
}
public function saveUserProfileOrder()
//维修单-添加故障信息
public function addErrorWorkOrder()
{
$param = $this->input->post();
//验证参数
$obj = $this->receiveGalanzObj();
$obj->SetValues($param);
$obj->CheckSaveUserProfileOrderValues();
$obj->CheckAddErrorWorkOrderValues();
$values = $obj->GetValues();
$this->saveLog($values['up_order_no'], 'saveUserProfileOrder', $param);
$this->saveLog($values['work_order_no'], 'addErrorWorkOrder', $param);
//搜索订单
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd'], $obj);
$search = $sourceGalanzObj->SearchUserProfieOrder($values['mobile'], $values['up_order_no']);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getWorkOrder($values['work_order_no'], $sourceGalanzObj);
$result = $sourceGalanzObj->ErrorAddWorkOrder($order['new_id'], $order);
if (empty($search)) {
$obj->ReturnMessage(false, '查询的安装单不存在');
}
$obj->ReturnMessage(true, '', $result);
}
//订单详情
$order = $sourceGalanzObj->UserProfileOrderDetail($search[0][0]);
//维修单-添加配件信息
public function addPartsWorkOrder()
{
$param = $this->input->post();
if (!isset($order['new_number']) && !$order['new_number']) {
$obj->ReturnMessage(false, '查询的安装单不存在');
}
//验证参数
$obj = $this->receiveGalanzObj();
$obj->SetValues($param);
$obj->CheckAddPartsWorkOrderValues();
$values = $obj->GetValues();
$this->saveLog($values['work_order_no'], 'addPartsWorkOrder', $param);
//保存订单
$result = $sourceGalanzObj->SaveUserProfileOrder($order['new_id'], $order);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$order = $this->getWorkOrder($values['work_order_no'], $sourceGalanzObj);
$result = $sourceGalanzObj->PartsAddAddWorkOrder($order['new_id'], $order);
$obj->ReturnMessage(true, '', $result);
}
public function sendUserProfileOrder()
//维修单:故障信息-故障现象
public function lookupErrormModule()
{
$param = $this->input->post();
//验证参数
$obj = $this->receiveGalanzObj();
$obj->SetValues($param);
$obj->CheckSendUserProfileOrderValues();
$obj->CheckLookupErrormModuleValues();
$values = $obj->GetValues();
$this->saveLog($values['up_order_no'], 'sendUserProfileOrder', $param);
$this->saveLog($values['workorderproductid'], 'lookupErrormModule', $param);
//搜索订单
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd'], $obj);
$search = $sourceGalanzObj->SearchUserProfieOrder($values['mobile'], $values['up_order_no']);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$result = $sourceGalanzObj->LookupErrormModule($values['workorderproductid']);
$obj->ReturnMessage(true, '', $result);
}
//维修单:故障信息-原因分类
public function lookupErrorGroup()
{
$param = $this->input->post();
//验证参数
$obj = $this->receiveGalanzObj();
$obj->SetValues($param);
$obj->CheckLookupErrorGroupValues();
$values = $obj->GetValues();
$this->saveLog($values['errormoduleid'], 'lookupErrorGroup', $param);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$result = $sourceGalanzObj->LookupErrorGroup($values['errormoduleid']);
$obj->ReturnMessage(true, '', $result);
}
//维修单:故障信息-维修措施
public function lookupErrorSolution()
{
$param = $this->input->post();
//验证参数
$obj = $this->receiveGalanzObj();
$obj->SetValues($param);
$obj->CheckLookupErrorSolutionValues();
$values = $obj->GetValues();
$this->saveLog($values['errorgroupid'], 'lookupErrorSolution', $param);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$result = $sourceGalanzObj->LookupErrorSolution($values['errorgroupid']);
$obj->ReturnMessage(true, '', $result);
}
//维修单:换件信息-不良品名称
public function lookupErrorParts()
{
$param = $this->input->post();
//验证参数
$obj = $this->receiveGalanzObj();
$obj->SetValues($param);
$obj->CheckLookupErrorPartsValues();
$values = $obj->GetValues();
$this->saveLog($values['errorsolutionid'], 'lookupErrorParts', $param);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$result = $sourceGalanzObj->LookupErrorParts($values['errorsolutionid'], $values['workorderproductid']);
$obj->ReturnMessage(true, '', $result);
}
//维修单:换件信息-良品名称
public function lookupParts()
{
$param = $this->input->post();
//验证参数
$obj = $this->receiveGalanzObj();
$obj->SetValues($param);
$obj->CheckLookupPartsValues();
$values = $obj->GetValues();
$this->saveLog($values['errorpartsid'], 'lookupParts', $param);
$sourceGalanzObj = $this->sourceGalanzObj($values['account'], $values['pwd']);
$result = $sourceGalanzObj->LookupParts($values['siteid'], $values['errorpartsid']);
$obj->ReturnMessage(true, '', $result);
}
/**
* 获取派工单单信息
* @param $order_no
* @param $sourceGalanzObj
* @return mixed
*/
private function getCallOrder($order_no, $sourceGalanzObj)
{
$search = $sourceGalanzObj->SearchOrder($order_no);
if (empty($search)) {
$obj->ReturnMessage(false, '查询的安装单不存在');
return_msg(false, '查询的派工单不存在');
}
//订单详情
$order = $sourceGalanzObj->UserProfileOrderDetail($search[0][0]);
$order = $sourceGalanzObj->OrderDetail($search[0][0]);
if (!isset($order['new_number']) && !$order['new_number']) {
$obj->ReturnMessage(false, '查询的安装单不存在');
if (!isset($order['new_name']) && !$order['new_name']) {
return_msg(false, '查询的派工单不存在');
}
//发送订单
$result = $sourceGalanzObj->SendUserProfileOrder($order['new_id'], $order);
return $order;
}
$obj->ReturnMessage(true, '', $result);
/**
* 获取维修单信息
* @param $order_no
* @param $sourceGalanzObj
* @return mixed
*/
private function getWorkOrder($order_no, $sourceGalanzObj)
{
//搜索订单
$search = $sourceGalanzObj->SearchWorkOrder($order_no);
if (empty($search)) {
return_msg(false, '查询的维修单不存在');
}
//订单详情
$order = $sourceGalanzObj->WorkOrderDetail($search[0][0]);
if (!isset($order['new_name']) && !$order['new_name']) {
return_msg(false, '查询的维修单不存在');
}
return $order;
}
private function diff($data, $keys)
/**
* 获取安装单信息
* @param $mobile
* @param $order_no
* @param $sourceGalanzObj
* @return mixed
*/
private function getUserProfileOrder($mobile, $order_no, $sourceGalanzObj)
{
return array_diff_key($data, array_fill_keys($keys, ''));
//搜索订单
$search = $sourceGalanzObj->SearchUserProfieOrder($mobile, $order_no);
if (empty($search)) {
return_msg(false, '查询的安装单不存在');
}
//订单详情
$order = $sourceGalanzObj->UserProfileOrderDetail($search[0][0]);
if (!isset($order['new_number']) && !$order['new_number']) {
return_msg(false, '查询的安装单不存在');
}
return $order;
}
/**
* 保存日志
*
* @param $search
* @param $method
* @param $data
*/
private function saveLog($search, $method, $data)
{
//记录日志
......@@ -429,28 +529,28 @@ class Galanz extends BaseController
$this->api_log_model->add($search, 'galanz', $method, $data);
}
/**
* 格兰仕接口类
* @return ReceiveGalanz
*/
private function receiveGalanzObj()
{
$this->load->library('Receive/ReceiveGalanz', null, 'ReceiveGalanz');
return $this->ReceiveGalanz;
}
private function sourceGalanzObj($username, $pwd, $obj)
/**
* 格兰仕抓取类
* @param $username
* @param $pwd
* @return SourceGalanz
*/
private function sourceGalanzObj($username, $pwd)
{
// $this->load->config('account', true);
// $account = $this->config->item('account');
// $galanzAccount = $account['galanz'];
//
// if (!array_key_exists($username, $galanzAccount)) {
// $obj->ReturnMessage(false, '用户名不存在');
// }
//$this->load->library('Source/SourceGalanz', $galanzAccount[$username], 'SourceGalanz');
$pwd = str_aes($pwd, '', 'de');
if (!$pwd) {
$obj->ReturnMessage(false, '密码无效');
return_msg(false, '密码无效');
}
$account = [
......@@ -463,4 +563,9 @@ class Galanz extends BaseController
return $this->SourceGalanz;
}
private function diff($data, $keys)
{
return array_diff_key($data, array_fill_keys($keys, ''));
}
}
\ No newline at end of file
......@@ -16,44 +16,121 @@ defined('BASEPATH') OR exit('No direct script access allowed');
class Rgalanz extends BaseController
{
//protected static $apiUrl = 'http://wxh.pp.cn/';
// protected static $apiUrl = 'http://wxh.pp.cn/';
protected static $apiUrl = 'http://testwxh.pp.cc/';
public function t()
public function test()
{
$url = "http://localhost/test/weixiuhui.php";
$obj = $this->galanzObj();
$data['appid'] = '10001';
$data['account'] = 'R75510005';
$data['pwd'] = str_aes('dgqh!769');
$data['work_order_no'] = 'WO2016090100560';
$data['txtproducenumber'] = '15AA50100001295';
$data['nonce_str'] = $obj->GetNonceStr();
$obj->SetValues($data);
$obj->SetSign();
$values = $obj->GetValues();
$data['username'] = '10001';
$data['username1'] = 'CALL2016082400507';
$data['username2'] = 'c01000005';
$url = self::$apiUrl . "api/galanz/addProdWorkOrder";
$result = $this->curlPost($url, $values);
$result = $this->curlPost($url, $data);
$result['data'] = json_decode($result['data'], true);
print_r($result);
$this->show($result);
}
public function createWorkOrder()
public function addErrorWorkOrder()
{
$obj = $this->galanzObj();
$data['appid'] = '10001';
$data['out_trade_no'] = 'CALL2016082400507';
$data['account'] = 'c01000005';
$data['account'] = 'R75510005';
$data['pwd'] = str_aes('dgqh!769');
$data['work_order_no'] = 'WO2016090100560';
$data['nonce_str'] = $obj->GetNonceStr();
$obj->SetValues($data);
$obj->SetSign();
$values = $obj->GetValues();
$url = self::$apiUrl . "api/galanz/addErrorWorkOrder";
$result = $this->curlPost($url, $values);
$result['data'] = json_decode($result['data'], true);
$this->show($result);
}
public function lookupErrormModule()
{
$obj = $this->galanzObj();
$data['appid'] = '10001';
$data['account'] = 'R75510005';
$data['pwd'] = str_aes('dgqh!769');
$data['workorderproductid'] = '74da8159-d418-47d4-8397-b12aac319285';
$data['nonce_str'] = $obj->GetNonceStr();
$obj->SetValues($data);
$obj->SetSign();
$values = $obj->GetValues();
$url = self::$apiUrl . "api/galanz/lookupErrormModule";
$result = $this->curlPost($url, $values);
$result['data'] = json_decode($result['data'], true);
$this->show($result);
}
public function lookupErrorGroup()
{
$obj = $this->galanzObj();
$data['appid'] = '10001';
$data['account'] = 'R75510005';
$data['pwd'] = str_aes('dgqh!769');
$data['errormoduleid'] = 'a5f47f85-d161-e411-80cb-00155d016a1c';
$data['nonce_str'] = $obj->GetNonceStr();
$obj->SetValues($data);
$obj->SetSign();
$values = $obj->GetValues();
$url = self::$apiUrl . "api/galanz/CreateWorkOrder";
$url = self::$apiUrl . "api/galanz/lookupErrorGroup";
$result = $this->curlPost($url, $values);
$result = json_decode($result['data'], true);
$result['data'] = json_decode($result['data'], true);
$this->show($result);
}
public function lookupErrorSolution()
{
$obj = $this->galanzObj();
$data['appid'] = '10001';
$data['account'] = 'R75510005';
$data['pwd'] = str_aes('dgqh!769');
$data['errorgroupid'] = '9017fc9e-ebb7-4e06-bbd0-58f2a74e1ffe';
$data['nonce_str'] = $obj->GetNonceStr();
$obj->SetValues($data);
$obj->SetSign();
$values = $obj->GetValues();
$url = self::$apiUrl . "api/galanz/lookupErrorSolution";
$result = $this->curlPost($url, $values);
$result['data'] = json_decode($result['data'], true);
$this->show($result['data']);
}
public function queryOrder()
{
$obj = $this->galanzObj();
......
......@@ -65,7 +65,7 @@ class Sgalanz extends BaseController
public function orderDetail()
{
$obj = $this->galanzObj();
$list = $obj->OrderDetail('3911c4cd-6855-4a2c-8085-6e489972e6a3');
$list = $obj->OrderDetail('07be1e36-75bd-4394-8a6f-d09e387e869e');
$this->show($list);
}
......@@ -73,15 +73,53 @@ class Sgalanz extends BaseController
public function workOrderDetail()
{
$obj = $this->galanzObj();
$list = $obj->WorkOrderDetail('511626f5-c8d8-4840-92ce-a01902f522d4');
$list = $obj->WorkOrderDetail('b4562475-1eac-415d-8713-653f8ea7d7c3');
$this->show($list);
}
public function prodAddWorkOrder()
{
$obj = $this->galanzObj();
$list = $obj->WorkOrderDetail('b4562475-1eac-415d-8713-653f8ea7d7c3');
$result = $obj->ProdGetWorkOrder($list['new_id'], $list, '15C1321000388166');
$this->show($result);
}
public function errorAddWorkOrder()
{
$obj = $this->galanzObj();
$list = $obj->WorkOrderDetail('b4562475-1eac-415d-8713-653f8ea7d7c3');
$result = $obj->ErrorAddWorkOrder($list['new_id'], $list);
$this->show($result);
}
public function lookupSingle()
{
$obj = $this->galanzObj();
//$list = $obj->WorkOrderDetail('b4562475-1eac-415d-8713-653f8ea7d7c3');
$result['a'] = $obj->LookupErrormModule('c7d14361-df35-4147-966f-ee671298d3eb');
$result['b'] = $obj->LookupErrorGroup($result['a'][0]['id']);
$result['c'] = $obj->LookupErrorSolution($result['b'][0]['id']);
$result['d1'] = $obj->LookupErrorParts($result['c'][0]['id'], 'c7d14361-df35-4147-966f-ee671298d3eb');
$result['d2'] = $obj->LookupParts('6f562a61-3a22-4a16-9e42-f3306dcc10a0', '48e24c55-7b53-46ae-8e43-c20e2435adbc');
$this->show($result);
}
private function galanzObj()
{
// $account = [
// 'username' => 'c01000005',
// 'pwd' => 'weixiuhui010'
// ];
$account = [
'username' => 'c01000005',
'pwd' => 'weixiuhui010'
'username' => 'R75510005',
'pwd' => 'dgqh!769'
];
$this->load->library('Source/SourceGalanz', $account, 'SourceGalanz');
......
......@@ -43,6 +43,43 @@ function str_aes($str, $key='', $type='en')
return $result;
}
/**
* 接口返回值
* @param bool $code
* @param string $msg
* @param array $data
*/
function return_msg($code= true, $msg = '', $data = [])
{
$return['return_code'] = $code ? 'SUCCESS' : 'FAIL';
$return['return_msg'] = $code ? '成功' : $msg;
if ($data) {
if (!is_array($data)) {
$return['return_data'] = $data;
}
if (is_array($data) && $data) {
$flag = false;
foreach ($data as $k => $v) {
if (is_array($v)) {
$flag = true;
break;
}
}
if ($flag) {
$return['return_data'] = $data;
} else {
$return = array_merge($return, $data);
}
}
}
echo json_encode($return, JSON_UNESCAPED_UNICODE);
die();
}
function curl_get($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
......
......@@ -186,8 +186,22 @@ class Receive
if (!is_array($data)) {
$return['return_data'] = $data;
}
$return = array_merge($return, $data);
if (is_array($data) && $data) {
$flag = false;
foreach ($data as $k => $v) {
if (is_array($v)) {
$flag = true;
break;
}
}
if ($flag) {
$return['return_data'] = $data;
} else {
$return = array_merge($return, $data);
}
}
}
return json_encode($return, JSON_UNESCAPED_UNICODE);
......
......@@ -15,13 +15,13 @@ class ReceiveGalanz extends Receive
*/
public function CheckQueryOrderValues()
{
$fileds = ['out_trade_no', 'account'];
$fileds = ['out_trade_no'];
$this->CheckValues($fileds);
}
public function CheckQueryWorkOrderValues()
{
$fileds = ['work_order_no', 'account'];
$fileds = ['work_order_no'];
$this->CheckValues($fileds);
}
......@@ -30,7 +30,7 @@ class ReceiveGalanz extends Receive
*/
public function CheckSearchOrderValues()
{
$fileds = ['out_trade_no', 'account'];
$fileds = ['out_trade_no'];
$this->CheckValues($fileds);
}
......@@ -39,7 +39,7 @@ class ReceiveGalanz extends Receive
*/
public function CheckSaveOrderValues()
{
$fileds = ['out_trade_no', 'account'];
$fileds = ['out_trade_no'];
$this->CheckValues($fileds);
$dfields = [
......@@ -78,7 +78,7 @@ class ReceiveGalanz extends Receive
*/
public function CheckCreateWorkOrderValues()
{
$fileds = ['out_trade_no', 'account'];
$fileds = ['out_trade_no'];
$this->CheckValues($fileds);
}
......@@ -87,31 +87,79 @@ class ReceiveGalanz extends Receive
*/
public function CheckCreateUserProfileOrderValues()
{
$fileds = ['out_trade_no', 'account'];
$fileds = ['out_trade_no'];
$this->CheckValues($fileds);
}
public function CheckSaveWorkOrderValues()
{
$fileds = ['work_order_no', 'account'];
$fileds = ['work_order_no'];
$this->CheckValues($fileds);
}
public function CheckSendWorkOrderValues()
{
$fileds = ['work_order_no', 'account'];
$fileds = ['work_order_no'];
$this->CheckValues($fileds);
}
public function CheckSaveUserProfileOrderValues()
{
$fileds = ['up_order_no', 'account'];
$fileds = ['up_order_no'];
$this->CheckValues($fileds);
}
public function CheckSendUserProfileOrderValues()
{
$fileds = ['up_order_no', 'account'];
$fileds = ['up_order_no'];
$this->CheckValues($fileds);
}
public function CheckAddProdWorkOrderValues()
{
$fileds = ['work_order_no', 'txtproducenumber'];
$this->CheckValues($fileds);
}
public function CheckAddErrorWorkOrderValues()
{
$fileds = ['work_order_no'];
$this->CheckValues($fileds);
}
public function CheckAddPartsWorkOrderValues()
{
$fileds = ['work_order_no'];
$this->CheckValues($fileds);
}
public function CheckLookupErrormModuleValues()
{
$fileds = ['workorderproductid'];
$this->CheckValues($fileds);
}
public function CheckLookupErrorGroupValues()
{
$fileds = ['errormoduleid'];
$this->CheckValues($fileds);
}
public function CheckLookupErrorSolutionValues()
{
$fileds = ['errorgroupid'];
$this->CheckValues($fileds);
}
public function CheckLookupErrorPartsValues()
{
$fileds = ['errorsolutionid','workorderproductid'];
$this->CheckValues($fileds);
}
public function CheckLookupPartsValues()
{
$fileds = ['siteid','errorpartsid'];
$this->CheckValues($fileds);
}
......@@ -133,6 +181,14 @@ class ReceiveGalanz extends Receive
$this->ReturnMessage(false, '签名错误!');
}
if (!array_key_exists('account', $this->values) || $this->values['account'] == '') {
$this->ReturnMessage(false, "account参数错误!");
}
if (!array_key_exists('pwd', $this->values) || $this->values['pwd'] == '') {
$this->ReturnMessage(false, "pwd参数错误!");
}
if ($fields) {
foreach ($fields as $v) {
if (!array_key_exists($v, $this->values) || $this->values[$v] == '') {
......
......@@ -15,16 +15,6 @@ class SourceGalanz extends Source
public function __construct($account)
{
//默认账号
// $CI =& get_instance();
// $CI->load->config('account', true);
// $accountConfig = $CI->config->item('account');
// $galanzAccount = $accountConfig['galanz'];
//
// if (!array_key_exists($account['username'], $galanzAccount)) {
// die("galanz系统账号({$account['username']})不存在");
// }
self::$account = $account;
self::$cookieFilePath = PUBDIR . "cookie/galanz_". self::$account['username'] .".cookie";
self::$captchaFilePath = PUBDIR . "captcha/galanz_". self::$account['username'] .".gif";
......@@ -32,9 +22,61 @@ class SourceGalanz extends Source
//判断是否登陆
$result = $this->IsLogin();
if ($result == false) {
echo json_encode(['return_code' => 'FAIL', 'return_msg' => '登陆失败'], JSON_UNESCAPED_UNICODE);
die();
return_msg(false, '登陆失败');
}
}
public function IsLogin()
{
$url = self::$host . '/Complaint/new_srv_callinMP.aspx?type=unsubscribe';
$result = $this->GetUrlContents($url);
if (strlen(addslashes($result)) < 2000) {
$flag = false;
//登陆
$result = $this->Login();
if ($result['code'] == 302) {
$flag = true;
} else {
if (file_exists(self::$cookieFilePath)) {
unlink(self::$cookieFilePath);
}
}
} else {
$flag = true;
}
return $flag;
}
public function Login()
{
$loginUrl = self::$host . "/FLoginNew.aspx";
$captchaUrl = self::$host . "/SystemSetting/CheckCode.aspx";
$content = $this->SetUrlCookie($loginUrl);
$this->SaveUrlCaptcha($captchaUrl);
$post = [
'__EVENTTARGET' => '',
'__EVENTARGUMENT' => '',
'loguser' => '',
'txtUserCode' => self::$account['username'],
'txtPassword' => self::$account['pwd'],
'txtCheckCode' => get_uuapi(self::$captchaFilePath),
];
preg_match_all('/<input[^>]+name="([^"]+)"[^>]+value="([^"]*)"/', $content, $arr);
foreach ($arr[1] as $k => $v) {
$post[$v] = $arr[2][$k];
}
$headers = $this->Header($loginUrl);
return $this->CurlPost($loginUrl, $post, $headers);
}
/**
......@@ -132,7 +174,7 @@ class SourceGalanz extends Source
$result = $this->CurlPost($url, $post, $headers);
$result = gzdecode($result['data']);
preg_match_all('/(<tr>\s+<td class="checkbox">[\s\S]+?<\/tr>)/', $result, $tr);
preg_match_all('/<tr>\s+<td class="checkbox">[\s\S]+?<\/tr>/', $result, $tr);
$orders = [];
......@@ -187,7 +229,7 @@ class SourceGalanz extends Source
$result = $this->CurlPost($url, $post, $headers);
$result = gzdecode($result['data']);
preg_match_all('/(<tr>\s+<td class="checkbox">[\s\S]+?<\/tr>)/', $result, $tr);
preg_match_all('/<tr>\s+<td class="checkbox">[\s\S]+?<\/tr>/', $result, $tr);
$orders = [];
......@@ -258,7 +300,7 @@ class SourceGalanz extends Source
$result = $this->CurlPost($url, $post, $headers);
$result = gzdecode($result['data']);
preg_match_all('/(<tr>\s+<td class="checkbox">[\s\S]+?<\/tr>)/', $result, $tr);
preg_match_all('/<tr>\s+<td class="checkbox">[\s\S]+?<\/tr>/', $result, $tr);
$orders = [];
......@@ -328,8 +370,8 @@ class SourceGalanz extends Source
preg_match_all('/<td[^>]*>[\s\S]+?<\/td>/', $v, $td);
if ($td[0]) {
// $reg = $this->OrderFormReg('chk');
// $temp['chk'] = $this->OrderFormValue($td[0][0], $reg);
$reg = $this->OrderFormReg('chk');
$temp['chk'] = $this->OrderFormValue($td[0][0], $reg);
$reg = $this->OrderFormReg('cbiserror', 'checkbox');
$temp['cbiserror'] = $this->OrderFormValue($td[0][1], $reg, 'checkbox');
......@@ -337,14 +379,14 @@ class SourceGalanz extends Source
$reg = $this->OrderFormReg('txtproducenumber', 'text');
$temp['txtproducenumber'] = $this->OrderFormValue($td[0][2], $reg, 'text');
// $reg = $this->OrderFormReg('new_producttypeid', 'text');
// $temp['new_producttypeid'] = $this->OrderFormValue($td[0][3], $reg, 'text');
$reg = $this->OrderFormReg('new_producttypeid', 'text');
$temp['new_producttypeid'] = $this->OrderFormValue($td[0][3], $reg, 'text');
$reg = $this->OrderFormReg('new_producttypeidName', 'text');
$temp['new_producttypeidName'] = $this->OrderFormValue($td[0][3], $reg, 'text');
// $reg = $this->OrderFormReg('new_productmodelid', 'text');
// $temp['new_productmodelid'] = $this->OrderFormValue($td[0][4], $reg, 'text');
$reg = $this->OrderFormReg('new_productmodelid', 'text');
$temp['new_productmodelid'] = $this->OrderFormValue($td[0][4], $reg, 'text');
$reg = $this->OrderFormReg('new_productmodelidName', 'text');
$temp['new_productmodelidName'] = $this->OrderFormValue($td[0][4], $reg, 'text');
......@@ -387,14 +429,14 @@ class SourceGalanz extends Source
preg_match_all('/<td[^>]*>[\s\S]+?<\/td>/', $v, $td);
if ($td[0]) {
// $reg = $this->OrderFormReg('chk');
// $temp['chk'] = $this->OrderFormValue($td[0][0], $reg);
//
// $reg = $this->OrderFormReg('new_srv_workorderproductid', 'text');
// $temp['new_srv_workorderproductid'] = $this->OrderFormValue($td[0][0], $reg, 'text');
//
// $reg = $this->OrderFormReg('New_srv_wokordererrorid', 'text');
// $temp['New_srv_wokordererrorid'] = $this->OrderFormValue($td[0][0], $reg, 'text');
$reg = $this->OrderFormReg('chk');
$temp['chk'] = $this->OrderFormValue($td[0][0], $reg);
$reg = $this->OrderFormReg('new_srv_workorderproductid', 'text');
$temp['new_srv_workorderproductid'] = $this->OrderFormValue($td[0][0], $reg, 'text');
$reg = $this->OrderFormReg('New_srv_wokordererrorid', 'text');
$temp['New_srv_wokordererrorid'] = $this->OrderFormValue($td[0][0], $reg, 'text');
$reg = $this->OrderFormReg('new_name', 'span');
$temp['new_name'] = $this->OrderFormValue($td[0][1], $reg, 'span');
......@@ -402,8 +444,8 @@ class SourceGalanz extends Source
$reg = $this->OrderFormReg('new_errorpart', 'span');
$temp['new_errorpart'] = $this->OrderFormValue($td[0][2], $reg, 'span');
// $reg = $this->OrderFormReg('new_errormoduleid', 'text');
// $temp['new_errormoduleid'] = $this->OrderFormValue($td[0][3], $reg, 'text');
$reg = $this->OrderFormReg('new_errormoduleid', 'text');
$temp['new_errormoduleid'] = $this->OrderFormValue($td[0][3], $reg, 'text');
$reg = $this->OrderFormReg('new_errormoduleidName', 'text');
$temp['new_errormoduleidName'] = $this->OrderFormValue($td[0][3], $reg, 'text');
......@@ -411,8 +453,8 @@ class SourceGalanz extends Source
$reg = $this->OrderFormReg('new_errordesc', 'span');
$temp['new_errordesc'] = $this->OrderFormValue($td[0][4], $reg, 'span');
// $reg = $this->OrderFormReg('new_errorgroupid', 'text');
// $temp['new_errorgroupid'] = $this->OrderFormValue($td[0][5], $reg, 'text');
$reg = $this->OrderFormReg('new_errorgroupid', 'text');
$temp['new_errorgroupid'] = $this->OrderFormValue($td[0][5], $reg, 'text');
$reg = $this->OrderFormReg('new_errorgroupidName', 'text');
$temp['new_errorgroupidName'] = $this->OrderFormValue($td[0][5], $reg, 'text');
......@@ -420,8 +462,8 @@ class SourceGalanz extends Source
$reg = $this->OrderFormReg('new_causedesc', 'span');
$temp['new_causedesc'] = $this->OrderFormValue($td[0][6], $reg, 'span');
// $reg = $this->OrderFormReg('new_srv_errorsolutionid', 'text');
// $temp['new_srv_errorsolutionid'] = $this->OrderFormValue($td[0][7], $reg, 'text');
$reg = $this->OrderFormReg('new_srv_errorsolutionid', 'text');
$temp['new_srv_errorsolutionid'] = $this->OrderFormValue($td[0][7], $reg, 'text');
$reg = $this->OrderFormReg('new_srv_errorsolutionidName', 'text');
$temp['new_srv_errorsolutionidName'] = $this->OrderFormValue($td[0][7], $reg, 'span');
......@@ -449,11 +491,11 @@ class SourceGalanz extends Source
preg_match_all('/<td[^>]*>[\s\S]+?<\/td>/', $v, $td);
if ($td[0]) {
// $reg = $this->OrderFormReg('chk');
// $temp['chk'] = $this->OrderFormValue($td[0][0], $reg);
//
// $reg = $this->OrderFormReg('new_srv_wokordererrorid', 'text');
// $temp['new_srv_wokordererrorid'] = $this->OrderFormValue($td[0][1], $reg, 'text');
$reg = $this->OrderFormReg('chk');
$temp['chk'] = $this->OrderFormValue($td[0][0], $reg);
$reg = $this->OrderFormReg('new_srv_wokordererrorid', 'text');
$temp['new_srv_wokordererrorid'] = $this->OrderFormValue($td[0][1], $reg, 'text');
$reg = $this->OrderFormReg('new_srv_wokordererroridName', 'span');
$temp['new_srv_wokordererroridName'] = $this->OrderFormValue($td[0][1], $reg, 'span');
......@@ -461,8 +503,8 @@ class SourceGalanz extends Source
$reg = $this->OrderFormReg('new_oldpartsid', 'span');
$temp['new_oldpartsid'] = $this->OrderFormValue($td[0][2], $reg, 'span');
// $reg = $this->OrderFormReg('new_errorpartsid', 'text');
// $temp['new_errorpartsid'] = $this->OrderFormValue($td[0][2], $reg, 'text');
$reg = $this->OrderFormReg('new_errorpartsid', 'text');
$temp['new_errorpartsid'] = $this->OrderFormValue($td[0][2], $reg, 'text');
$reg = $this->OrderFormReg('new_errorpartsidName', 'text');
$temp['new_errorpartsidName'] = $this->OrderFormValue($td[0][2], $reg, 'text');
......@@ -470,8 +512,8 @@ class SourceGalanz extends Source
$reg = $this->OrderFormReg('new_newpartsid', 'span');
$temp['new_newpartsid'] = $this->OrderFormValue($td[0][3], $reg, 'span');
// $reg = $this->OrderFormReg('new_partsid', 'text');
// $temp['new_partsid'] = $this->OrderFormValue($td[0][4], $reg, 'text');
$reg = $this->OrderFormReg('new_partsid', 'text');
$temp['new_partsid'] = $this->OrderFormValue($td[0][4], $reg, 'text');
$reg = $this->OrderFormReg('new_partsidName', 'text');
$temp['new_partsidName'] = $this->OrderFormValue($td[0][4], $reg, 'text');
......@@ -532,85 +574,229 @@ class SourceGalanz extends Source
return $result;
}
public function SaveWorkOrder($id, $data)
public function SaveUserProfileOrder($id, $data)
{
$result = $this->HandelWorkOrder($id, $data, 'save');
$result = $this->HandelUserProfileOrder($id, $data, 'save');
return $result;
}
public function SendWorkOrder($id, $data)
public function SendUserProfileOrder($id, $data)
{
$result = $this->HandelWorkOrder($id, $data, 'send');
$result = $this->HandelUserProfileOrder($id, $data, 'send');
return $result;
}
public function SaveUserProfileOrder($id, $data)
public function SaveWorkOrder($id, $data)
{
$result = $this->HandelUserProfileOrder($id, $data, 'save');
$result = $this->HandelWorkOrder($id, $data, 'Save');
return $result;
}
public function SendUserProfileOrder($id, $data)
public function SendWorkOrder($id, $data)
{
$result = $this->HandelUserProfileOrder($id, $data, 'send');
$result = $this->HandelWorkOrder($id, $data, 'Send');
return $result;
}
public function IsLogin()
/**
* 维修单 - 保存机器信息
* @param $id
* @param $data
* @param $producenumber
* @return mixed
*/
public function ProdGetWorkOrder($id, $data, $producenumber)
{
$url = self::$host . '/Complaint/new_srv_callinMP.aspx?type=unsubscribe';
$result = $this->GetUrlContents($url);
if (empty($data['machine'])) {
$order = $this->ProdAddWorkOrder($id, $data);
} else {
$flag = true;
foreach ($data['machine'] as $k => $v) {
if ($v['txtproducenumber'] == '') {
$flag = false;
}
if (strlen(addslashes($result)) < 2000) {
$flag = false;
if ($v['txtproducenumber'] == $producenumber) {
return_msg(false, '条码'.$producenumber.'已存在');
}
}
//登陆
$result = $this->Login();
if ($result['code'] == 302) {
$flag = true;
if ($flag) {
$order = $this->ProdAddWorkOrder($id, $data);
} else {
if (file_exists(self::$cookieFilePath)) {
unlink(self::$cookieFilePath);
}
$order = $data;
}
}
} else {
$flag = true;
foreach ($order['machine'] as $k => $v) {
if ($v['txtproducenumber'] == '') {
$order['machine'][$k]['txtproducenumber'] = $producenumber;
}
}
return $flag;
$result = $this->HandelWorkOrder($id, $order, 'ProdGet');
$this->WorkOrderError($result);
$order = $this->WorkOrderDetail($id);
return $order;
}
public function Login()
/**
* 维修单 - 新增机器信息
*
* @param $id
* @param $data
* @return mixed
*/
public function ProdAddWorkOrder($id, $data)
{
$loginUrl = self::$host . "/FLoginNew.aspx";
$captchaUrl = self::$host . "/SystemSetting/CheckCode.aspx";
$this->HandelWorkOrder($id, $data, 'ProdAdd');
$order = $this->WorkOrderDetail($id);
return $order;
}
$content = $this->SetUrlCookie($loginUrl);
$this->SaveUrlCaptcha($captchaUrl);
/**
* 维修单 - 新增故障信息
*
* @param $id
* @param $data
* @return mixed
*/
public function ErrorAddWorkOrder($id, $data)
{
$result = $this->HandelWorkOrder($id, $data, 'ErrorAdd');
$this->WorkOrderError($result);
$order = $this->WorkOrderDetail($id);
return $order;
}
$post = [
'__EVENTTARGET' => '',
'__EVENTARGUMENT' => '',
'loguser' => '',
'txtUserCode' => self::$account['username'],
'txtPassword' => self::$account['pwd'],
'txtCheckCode' => get_uuapi(self::$captchaFilePath),
];
/**
* 维修单 - 新增换件信息
*
* @param $id
* @param $data
* @return mixed
*/
public function PartsAddAddWorkOrder($id, $data)
{
$result = $this->HandelWorkOrder($id, $data, 'PartsAdd');
$this->WorkOrderError($result);
$order = $this->WorkOrderDetail($id);
return $order;
}
preg_match_all('/<input[^>]+name="([^"]+)"[^>]+value="([^"]*)"/', $content, $arr);
/**
* 故障信息 - 故障现象
* @param $workorderproductid
* @return array
*/
public function LookupErrormModule($workorderproductid)
{
return $this->LookupSingle('lookupErrormodule', $workorderproductid);
}
foreach ($arr[1] as $k => $v) {
$post[$v] = $arr[2][$k];
}
/**
* 故障信息 - 原因分类
* @param $errormoduleid
* @return array
*/
public function LookupErrorGroup($errormoduleid)
{
return $this->LookupSingle('lookupErrorgroup', $errormoduleid);
}
$headers = $this->Header($loginUrl);
/**
* 故障信息 - 维修措施
* @param $errorgroupid
* @return array
*/
public function LookupErrorSolution($errorgroupid)
{
return $this->LookupSingle('lookupErrorsolution', $errorgroupid);
}
return $this->CurlPost($loginUrl, $post, $headers);
/**
* 换件信息 - 不良品名称
* @param $errorsolutionid
* @param $workorderproductid
* @return array
*/
public function LookupErrorParts($errorsolutionid, $workorderproductid)
{
return $this->LookupSingle('lookupErrorparts', $errorsolutionid.'%20'.$workorderproductid);
}
/**
* 换件信息 - 良品名称
* @param $siteid
* @param $errorpartsid
* @return array
*/
public function LookupParts($siteid, $errorpartsid)
{
return $this->LookupSingle('lookupParts', $siteid.'%20'.$errorpartsid);
}
private function LookupSingle($key, $val)
{
$url = self::$host . "/Common/lookupSingle.aspx?lookupname={$key}&param={$val}";
$result = $this->GetUrlContents($url);
preg_match_all('/<tr[^>]+style="Cursor:hand"[^>]*>[\s\S]+?<\/tr>/', $result, $tr);
$list = [];
if ($tr[0]) {
switch ($key) {
case 'lookupErrorsolution':
foreach ($tr[0] as $k => $v) {
preg_match_all('/<font color="#333333">([^<]+)</', $v, $txt);
if (isset($txt[1]) && $txt[1]) {
$temp['id'] = $txt[1][1];
$temp['no'] = $txt[1][3];
$temp['name'] = $txt[1][2];
$list[] = $temp;
}
}
break;
case 'lookupParts':
foreach ($tr[0] as $k => $v) {
preg_match_all('/<font color="#333333">([^<]+)</', $v, $txt);
if (isset($txt[1]) && $txt[1]) {
$temp['id'] = $txt[1][1];
$temp['no'] = $txt[1][2];
$temp['name'] = $txt[1][3];
$temp['line'] = $txt[1][4];
$temp['superclass'] = $txt[1][5];
$temp['subclass'] = $txt[1][6];
$temp['stock'] = $txt[1][7];
$list[] = $temp;
}
}
break;
default:
foreach ($tr[0] as $k => $v) {
preg_match_all('/<font color="#333333">([^<]+)</', $v, $txt);
if (isset($txt[1]) && $txt[1]) {
$temp['id'] = $txt[1][1];
$temp['name'] = $txt[1][2];
$temp['no'] = $txt[1][3];
$list[] = $temp;
}
}
}
}
return $list;
}
/**
......@@ -765,25 +951,15 @@ class SourceGalanz extends Source
private function HandelWorkOrder($id, $data, $type)
{
switch ($type){
case 'save':
$target = 'ctl00$ContentQuery$btnSave';
break;
case 'send':
$target = 'ctl00$ContentQuery$btnSend';
break;
}
$post = [
'__EVENTTARGET' => $target,
'__EVENTTARGET' => '',
'__EVENTARGUMENT' => '',
'__LASTFOCUS' => '',
'__VIEWSTATE' => $data['__VIEWSTATE'],
'__SCROLLPOSITIONX' => '0',
'__SCROLLPOSITIONY' => '0',
'ctl00$hidPageSiteMapTitle' => '维修单-编辑页面',
'ctl00$ContentHeader$hidFormId' => $data['new_id'],
'ctl00$ContentHeader$hidFormId' => $id,
'ctl00$ContentHeader$hidUserId' => $data['hidUserId'],
'ctl00$ContentHeader$hidIsKT' => $data['hidIsKT'],
'ctl00$ContentHeader$hidformPosition' => $data['hidformPosition'],
......@@ -804,15 +980,6 @@ class SourceGalanz extends Source
'ctl00$ContentData$new_uninvsestreasonName' => $data['new_uninvsestreasonName'],
'ctl00$ContentData$new_reconsidermemo' => $data['new_reconsidermemo'],
'ctl00$ContentData$new_approvalremark' => $data['new_approvalremark'],
'ctl00$ContentData$rptProd$ctl00$cbiserror' => '',
'ctl00$ContentData$rptProd$ctl00$txtproducenumber' => '',
'ctl00$ContentData$rptProd$ctl00$new_producttypeid' => '',
'ctl00$ContentData$rptProd$ctl00$new_producttypeidName' => '',
'ctl00$ContentData$rptProd$ctl00$new_productmodelid' => '',
'ctl00$ContentData$rptProd$ctl00$new_productmodelidName' => '',
'ctl00$ContentData$rptProd$ctl00$hidnew_productnumber' => '',
'ctl00$ContentData$rptProd$ctl00$hidnew_modelnumber' => '',
'ctl00$ContentData$rptProd$ctl00$new_goldcardno' => '',
'ctl00$ContentData$new_custname' => $data['new_custname'],
'ctl00$ContentData$new_custmobile' => $data['new_custmobile'],
'ctl00$ContentData$new_custtel' => $data['new_custtel'],
......@@ -844,25 +1011,6 @@ class SourceGalanz extends Source
'ctl00$ContentData$new_reliefmemo' => $data['new_reliefmemo'],
'ctl00$ContentData$new_siteremark' => $data['new_siteremark'],
'ctl00$ContentData$new_approvalstep' => $data['new_approvalstep'],
'ctl00$ContentData$rptError$ctl00$chk' => '',
'ctl00$ContentData$rptError$ctl00$new_srv_workorderproductid' => '',
'ctl00$ContentData$rptError$ctl00$New_srv_wokordererrorid' => '',
'ctl00$ContentData$rptError$ctl00$new_errormoduleid' => '',
'ctl00$ContentData$rptError$ctl00$new_errormoduleidName' => '',
'ctl00$ContentData$rptError$ctl00$new_errorgroupid' => '',
'ctl00$ContentData$rptError$ctl00$new_errorgroupidName' => '',
'ctl00$ContentData$rptError$ctl00$new_srv_errorsolutionid' => '',
'ctl00$ContentData$rptError$ctl00$new_srv_errorsolutionidName' => '',
'ctl00$ContentData$rptError$ctl00$new_befpic' => '',
'ctl00$ContentData$rptError$ctl00$file_imgbef' => '',
'ctl00$ContentData$rptError$ctl00$new_aftpic' => '',
'ctl00$ContentData$rptError$ctl00$file_imgaft' => '',
'ctl00$ContentData$rptParts$ctl00$new_srv_wokordererrorid' => '',
'ctl00$ContentData$rptParts$ctl00$new_errorpartsid' => '',
'ctl00$ContentData$rptParts$ctl00$new_errorpartsidName' => '',
'ctl00$ContentData$rptParts$ctl00$new_partsid' => '',
'ctl00$ContentData$rptParts$ctl00$new_partsidName' => '',
'ctl00$ContentData$rptParts$ctl00$new_qty' => '',
'ctl00$ContentData$new_baseamount' => $data['new_baseamount'],
'ctl00$ContentData$new_mileamount' => $data['new_mileamount'],
'ctl00$ContentData$productname' => $data['productname'],
......@@ -873,7 +1021,40 @@ class SourceGalanz extends Source
'ctl00$ContentData$new_othersuggest' => $data['new_othersuggest'],
];
return $post;
switch ($type){
case 'Save':
$post['__EVENTTARGET'] = 'ctl00$ContentQuery$btnSave';
break;
case 'Send':
$post['__EVENTTARGET'] = 'ctl00$ContentQuery$btnSend';
break;
case 'ProdAdd':
$post['__EVENTTARGET'] = 'ctl00$ContentData$btnProdAdd';
break;
case 'ProdGet':
$post['__EVENTTARGET'] = 'ctl00$ContentData$btnProdGet';
break;
case 'ErrorAdd':
$post['__EVENTTARGET'] = 'ctl00$ContentData$btnErrorAdd';
break;
case 'PartsAdd':
$post['__EVENTTARGET'] = 'ctl00$ContentData$btnPartsAdd';
break;
}
$machine = $this->HandelWorkOrderMachineParam($data['machine']);
$post = array_merge($post, $machine);
$fault = $this->HandelWorkOrderFaultParam($data['fault']);
$post = array_merge($post, $fault);
$parts = $this->HandelWorkOrderPartsParam($data['parts']);
$post = array_merge($post, $parts);
$url = self::$host . '/repair/new_srv_workorderEP.aspx?mainid=&mainidname=&attrcode=&id=' . $id;
$headers = $this->Header($url);
......@@ -886,6 +1067,88 @@ class SourceGalanz extends Source
return $result;
}
private function HandelWorkOrderMachineParam($data)
{
$result = [];
if ($data) {
foreach ($data as $k => $v) {
$tempKey = str_pad($k, 2, '0', STR_PAD_LEFT);
$post = [
'ctl00$ContentData$rptProd$ctl'.$tempKey.'$cbiserror' => $v['cbiserror'] ? 'on' : '',
'ctl00$ContentData$rptProd$ctl'.$tempKey.'$txtproducenumber' => $v['txtproducenumber'],
'ctl00$ContentData$rptProd$ctl'.$tempKey.'$new_producttypeid' => $v['new_producttypeid'],
'ctl00$ContentData$rptProd$ctl'.$tempKey.'$new_producttypeidName' => $v['new_producttypeidName'],
'ctl00$ContentData$rptProd$ctl'.$tempKey.'$new_productmodelid' => $v['new_productmodelid'],
'ctl00$ContentData$rptProd$ctl'.$tempKey.'$new_productmodelidName' => $v['new_productmodelidName'],
'ctl00$ContentData$rptProd$ctl'.$tempKey.'$hidnew_productnumber' => $v['hidnew_productnumber'],
'ctl00$ContentData$rptProd$ctl'.$tempKey.'$hidnew_modelnumber' => $v['hidnew_modelnumber'],
'ctl00$ContentData$rptProd$ctl'.$tempKey.'$new_goldcardno' => $v['new_goldcardno'],
];
$result = array_merge($result, $post);
}
}
return $result;
}
private function HandelWorkOrderFaultParam($data)
{
$result = [];
if ($data) {
foreach ($data as $k => $v) {
$tempKey = str_pad($k, 2, '0', STR_PAD_LEFT);
$post = [
'ctl00$ContentData$rptError$ctl'.$tempKey.'$chk' => $v['chk'],
'ctl00$ContentData$rptError$ctl'.$tempKey.'$new_srv_workorderproductid' => $v['new_srv_workorderproductid'],
'ctl00$ContentData$rptError$ctl'.$tempKey.'$New_srv_wokordererrorid' => $v['New_srv_wokordererrorid'],
'ctl00$ContentData$rptError$ctl'.$tempKey.'$new_errormoduleid' => $v['new_errormoduleid'],
'ctl00$ContentData$rptError$ctl'.$tempKey.'$new_errormoduleidName' => $v['new_errormoduleidName'],
'ctl00$ContentData$rptError$ctl'.$tempKey.'$new_errorgroupid' => $v['new_errorgroupid'],
'ctl00$ContentData$rptError$ctl'.$tempKey.'$new_errorgroupidName' => $v['new_errorgroupidName'],
'ctl00$ContentData$rptError$ctl'.$tempKey.'$new_srv_errorsolutionid' => $v['new_srv_errorsolutionid'],
'ctl00$ContentData$rptError$ctl'.$tempKey.'$new_srv_errorsolutionidName' => $v['new_srv_errorsolutionidName'],
'ctl00$ContentData$rptError$ctl'.$tempKey.'$new_befpic' => '',
'ctl00$ContentData$rptError$ctl'.$tempKey.'$file_imgbef' => '',
'ctl00$ContentData$rptError$ctl'.$tempKey.'$new_aftpic' => '',
'ctl00$ContentData$rptError$ctl'.$tempKey.'$file_imgaft' => '',
];
$result = array_merge($result, $post);
}
}
return $result;
}
private function HandelWorkOrderPartsParam($data)
{
$result = [];
if ($data) {
foreach ($data as $k => $v) {
$tempKey = str_pad($k, 2, '0', STR_PAD_LEFT);
$post = [
'ctl00$ContentData$rptParts$ctl'.$tempKey.'$new_srv_wokordererrorid' => $v['new_srv_wokordererrorid'],
'ctl00$ContentData$rptParts$ctl'.$tempKey.'$new_errorpartsid' => $v['new_errorpartsid'],
'ctl00$ContentData$rptParts$ctl'.$tempKey.'$new_errorpartsidName' => $v['new_errorpartsidName'],
'ctl00$ContentData$rptParts$ctl'.$tempKey.'$new_partsid' => $v['new_partsid'],
'ctl00$ContentData$rptParts$ctl'.$tempKey.'$new_partsidName' => $v['new_partsidName'],
'ctl00$ContentData$rptParts$ctl'.$tempKey.'$new_qty' => $v['new_qty'],
];
$result = array_merge($result, $post);
}
}
return $result;
}
/**
* 处理安装单
* @param $id
......@@ -911,7 +1174,7 @@ class SourceGalanz extends Source
'__LASTFOCUS' => '',
'__VIEWSTATE' => $data['__VIEWSTATE'],
'ctl00$hidPageSiteMapTitle' => '安装单录入—编辑页面',
'ctl00$ContentHeader$hidFormId' => $data['new_id'],
'ctl00$ContentHeader$hidFormId' => $id,
'ctl00$ContentHeader$hidproductgroupid' => $data['hidproductgroupid'],
'ctl00$ContentData$new_number' => $data['new_number'],
'ctl00$ContentData$new_srv_callinid' => $data['new_srv_callinid'],
......@@ -1294,9 +1557,9 @@ class SourceGalanz extends Source
'type' => 'text',
'reg' => $this->OrderFormReg('new_countyid')
],
'new_countyidname' => [
'new_countyidName' => [
'type' => 'text',
'reg' => $this->OrderFormReg('new_countyidname')
'reg' => $this->OrderFormReg('new_countyidName')
], //区/县
'new_townid' => [
'type' => 'text',
......@@ -1758,4 +2021,13 @@ class SourceGalanz extends Source
return $header;
}
private function WorkOrderError($html)
{
preg_match('/<scriptt[^>]*>alert\("([^"]+)"\);?<\/scriptt>/', $html, $arr);
$error = isset($arr[1]) ? $arr[1] : '';
if ($error) {
return_msg(false, $error);
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment