// DlgCloundResult.cpp : 实现文件 // #include "stdafx.h" #include "YLGL.h" #include "DlgCloundResult.h" // CDlgCloundResult 对话框 IMPLEMENT_DYNAMIC(CDlgCloundResult, CDialog) CDlgCloundResult::CDlgCloundResult(CWnd* pParent /*=NULL*/) : CDialog(CDlgCloundResult::IDD, pParent) { m_pList = NULL; m_nSelItem = -1; m_nAdd = 0; m_nCloundType = 0; } CDlgCloundResult::~CDlgCloundResult() { } void CDlgCloundResult::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_LIST2, m_SortList); DDX_Control(pDX, IDC_COMBO1, m_ctrlCombox); } BEGIN_MESSAGE_MAP(CDlgCloundResult, CDialog) ON_BN_CLICKED(BTN_DOWNRESULT, OnBnClickedDownresult) ON_BN_CLICKED(BTN_SYNRESULT, OnBnClickedSynresult) ON_BN_CLICKED(BTN_EXPORTXLS, OnBnClickedExportxls) ON_BN_CLICKED(BTN_QUERY, OnBnClickedQuery) ON_BN_CLICKED(BTN_CLEAN, OnBnClickedClean) END_MESSAGE_MAP() // CDlgCloundResult 消息处理程序 BOOL CDlgCloundResult::OnInitDialog() { CDialog::OnInitDialog(); // TODO: 在此添加额外的初始化 InitListCtrl(); //GetCloundResult(); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } void CDlgCloundResult::InitListCtrl() { if ( m_nCloundType == 0 ) m_SortList.SetHeadings("订单号,100;顾客1,100;顾客2,100;商品ID,100;商品名称,100;选片日期,100;相片,100;" ); else m_SortList.SetHeadings("订单号,100;顾客1,100;顾客2,100;选样日期,100;要求,100;" ); m_SortList.m_bSortSupport = TRUE; m_SortList.LoadColumnInfo(1002); } void CDlgCloundResult::UpdateDataSortList(vector& vtOrdJson) { m_SortList.DeleteAllItems2(); int nSize = 0; // 解析出Json内容; int i = 0; vector::iterator it = vtOrdJson.begin(); for ( ; it != vtOrdJson.end(); it++ ) { nSize += it->vtSpJson.size(); } //CArray AryCloundResult; m_AryCloundResult.RemoveAll(); m_AryCloundResult.SetSize(nSize, 1); m_SortList.m_arLabels.SetSize(nSize,1); for ( it = vtOrdJson.begin(); it != vtOrdJson.end(); it++ ) { vector::iterator iit; for ( iit = it->vtSpJson.begin(); iit != it->vtSpJson.end(); iit++ ) { m_AryCloundResult.ElementAt(i).RemoveAll(); m_AryCloundResult.ElementAt(i).Add(it->strorder); // 0.订单号; m_AryCloundResult.ElementAt(i).Add(it->strCustomer1); // 1.顾客1; m_AryCloundResult.ElementAt(i).Add(it->strCustomer2); // 2.顾客2; m_AryCloundResult.ElementAt(i).Add(iit->strSpId); // 3.商品ID; m_AryCloundResult.ElementAt(i).Add(iit->strSpName); // 4.商品名称; m_AryCloundResult.ElementAt(i).Add(it->strXPDate); // 5.选片日期; m_AryCloundResult.ElementAt(i).Add(iit->strImgs); // 6.商品相片串; m_AryCloundResult.ElementAt(i).Add(iit->strImgs); // 7.选片状态; m_AryCloundResult.ElementAt(i).Add(it->strCust1PY); // 8.顾客1拼音; m_AryCloundResult.ElementAt(i).Add(it->strCust2PY); // 9.顾客1拼音; i++; } } //AryCloundResult.SetSize(i,1); int nIndex = 0; for ( i = 0; i < nSize; i++) { m_SortList.m_arLabels.ElementAt(i).Copy(m_AryCloundResult.ElementAt(i)); } m_SortList.m_arLabels.SetSize(nSize, 1); m_SortList.m_LabelCount = nSize; m_SortList.SetItemCountEx(nSize); } void CDlgCloundResult::UpdateDataSortList2(IN vector& vtXYJson) { m_SortList.DeleteAllItems2(); int nSize = vtXYJson.size(); int i = 0; m_AryCloundResult.RemoveAll(); m_AryCloundResult.SetSize(nSize, 1); m_SortList.m_arLabels.SetSize(nSize,1); vector::iterator it; for ( it = vtXYJson.begin(); it != vtXYJson.end(); it++ ) { m_AryCloundResult.ElementAt(i).RemoveAll(); m_AryCloundResult.ElementAt(i).Add(it->strorder); // 0.订单号; m_AryCloundResult.ElementAt(i).Add(it->strCustomer1); // 1.顾客1; m_AryCloundResult.ElementAt(i).Add(it->strCustomer2); // 2.顾客2; m_AryCloundResult.ElementAt(i).Add(it->strXYDate); // 3.选样日期; m_AryCloundResult.ElementAt(i).Add(it->strJsonResult); // 4.要求; m_AryCloundResult.ElementAt(i).Add(it->strSJStatus); // 5.设计状态; m_AryCloundResult.ElementAt(i).Add(it->strCust1PY); // 6.拼音1; m_AryCloundResult.ElementAt(i).Add(it->strCust2PY); // 7.拼音2; i++; } //AryCloundResult.SetSize(i,1); int nIndex = 0; for ( i = 0; i < nSize; i++) { m_SortList.m_arLabels.ElementAt(i).Copy(m_AryCloundResult.ElementAt(i)); } m_SortList.m_arLabels.SetSize(nSize, 1); m_SortList.m_LabelCount = nSize; m_SortList.SetItemCountEx(nSize); } void CDlgCloundResult::GetCloundResult() { if ( m_pList == NULL ) return; m_AryCloundInfo.SetSize(m_pList->m_arLabels.GetSize(),1); if ( m_nCloundType == 0 ) { int i = 0; for ( i = 0; i < m_pList->m_arLabels.GetSize(); i++ ) { // 取出生成云链接的订单; m_AryCloundInfo.ElementAt(i).RemoveAll(); m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(0)); // 0.订单号; m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(1)); // 1.顾客1; m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(2)); // 2.顾客2; m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(19)); // 3.云地址; m_AryCloundInfo.ElementAt(i).Add(_T("")); // 4.用于存放选片结果,暂时置空; m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(17)); // 5.顾客1拼音; m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(18)); // 6.顾客2拼音; m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(5)); // 7.选片状态; } INT nIndex = 0; CString strTemp = g_branchname.IsEmpty() ? g_domain : g_branchname; if ( ( nIndex = strTemp.Find(_T(".ly.com"))) == -1) { AfxMessageBox(_T("域名无效!")); return; } strTemp = strTemp.Left(nIndex); CString strBranchId = strTemp.Right(6); // 获取云选片结果; CString strUniqueId = _T(""); vector vtOrdJson; if ( lyfzLibrary::LoadCloudSelectionLib() ) { nIndex = 0; TCHAR szResultValue[8912] = {0}; for ( i = 0; i < m_AryCloundInfo.GetSize(); i++ ) { strUniqueId.Format(_T("%s_A_%s_0"), strBranchId, m_AryCloundInfo.ElementAt(i).ElementAt(0)); if ( ( nIndex = m_AryCloundInfo.ElementAt(i).ElementAt(3).Find(lyfzLibrary::g_strCloundHost)) != -1) { lyfzLibrary::STOrdJson tagOrdJson; strTemp = m_AryCloundInfo.ElementAt(i).ElementAt(3).Mid(lyfzLibrary::g_strCloundHost.GetLength() + nIndex); lyfzLibrary::g_getcloundresult(0, strUniqueId, strTemp, szResultValue, 8912); m_AryCloundInfo.ElementAt(i).SetAt(4, szResultValue); // 解析Json; tagOrdJson.strorder = m_AryCloundInfo.ElementAt(i).ElementAt(0); tagOrdJson.strCustomer1 = m_AryCloundInfo.ElementAt(i).ElementAt(1); tagOrdJson.strCustomer2 = m_AryCloundInfo.ElementAt(i).ElementAt(2); tagOrdJson.strCust1PY = m_AryCloundInfo.ElementAt(i).ElementAt(5); tagOrdJson.strCust1PY = m_AryCloundInfo.ElementAt(i).ElementAt(6); tagOrdJson.strXPStatus = m_AryCloundInfo.ElementAt(i).ElementAt(7); // 日期; strTemp = szResultValue; if ( (nIndex = strTemp.Find(_T(", \"last_modify_time\": "))) != -1 ) { tagOrdJson.strXPDate = strTemp.Mid(nIndex+strlen(_T(", \"last_modify_time\": "))); tagOrdJson.strXPDate.TrimRight(_T("\"")); tagOrdJson.strXPDate.TrimLeft(_T("\"")); strTemp = strTemp.Left(nIndex); if ( ( nIndex = strTemp.Find(_T("\"pick_list\": ["))) != -1 ) { strTemp = strTemp.Mid(nIndex + strlen(_T("\"pick_list\": ["))); strTemp = strTemp.Mid(0, strTemp.GetLength() - 1); sprintf(szResultValue, _T("%s"), strTemp); } } lyfzLibrary::getXPJsonresult(szResultValue,tagOrdJson.vtSpJson); vtOrdJson.push_back(tagOrdJson); } } lyfzLibrary::FreeCloudSelectionLib(); } #if 0 // 获取数据库保存的云数据; g_sendhead.bsql = 0; g_sendhead.code[0] = 241; g_sendhead.tabcount = 1; CString strFilter = _T("CloundType = 0"); CArray AryCloundInfo; g_pMainWnd->ProcessChatMessageRequest2(strFilter); if ( !g_bSendOK ) return; DataToArray(&AryCloundInfo); // 显示并同步结果; int j = 0; BOOL bExist = FALSE; CString strSQL = _T(""); for ( i = 0; i < AryCloundOrder.GetSize(); i++ ) { if ( AryCloundOrder.ElementAt(i).ElementAt(2).IsEmpty() ) continue; bExist = FALSE; for ( j = 0; j < AryCloundInfo.GetSize(); j++ ) { if ( AryCloundOrder.ElementAt(i).ElementAt(0) == AryCloundInfo.ElementAt(j).ElementAt(0) ) bExist = TRUE; } if ( bExist ) { if ( AryCloundOrder.ElementAt(i).ElementAt(2) == AryCloundInfo.ElementAt(j-1).ElementAt(4) ) continue; strSQL.Format(_T("update [CloundSelection] set [ResultJson] = '%s' where [order] = '%s'"), AryCloundOrder.ElementAt(i).ElementAt(0), AryCloundOrder.ElementAt(i).ElementAt(2)); } else strSQL.Format(_T("insert into [CloundSelection]( [order], [CloundType], [ResultJson]) values('%s', 0, '%s') "), AryCloundOrder.ElementAt(i).ElementAt(0), AryCloundOrder.ElementAt(i).ElementAt(2)); g_sendhead.bsql = true; g_pMainWnd->ProcessChatMessageRequest2(strSQL); } #endif UpdateDataSortList(vtOrdJson); } else { int i = 0; for ( i = 0; i < m_pList->m_arLabels.GetSize(); i++ ) { // 取出生成云链接的订单; m_AryCloundInfo.ElementAt(i).RemoveAll(); m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(0 + m_nAdd)); // 0.订单号; m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(1 + m_nAdd)); // 1.顾客1; m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(2 + m_nAdd)); // 2.顾客2; m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(21 + m_nAdd)); // 3.云地址; m_AryCloundInfo.ElementAt(i).Add(_T("")); // 4.用于存放选片结果,暂时置空; m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(19 + m_nAdd)); // 5.顾客1拼音; m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(20 + m_nAdd)); // 6.顾客2拼音; m_AryCloundInfo.ElementAt(i).Add(m_pList->m_arLabels.ElementAt(i).ElementAt(5 + m_nAdd)); // 7.设计状态; } INT nIndex = 0; CString strTemp = g_branchname.IsEmpty() ? g_domain : g_branchname; if ( ( nIndex = strTemp.Find(_T(".ly.com"))) == -1) { AfxMessageBox(_T("域名无效!")); return; } strTemp = strTemp.Left(nIndex); CString strBranchId = strTemp.Right(6); // 获取云选片结果; CString strUniqueId = _T(""); vector vtXYJson; if ( lyfzLibrary::LoadCloudSelectionLib() ) { nIndex = 0; TCHAR szResultValue[8912] = {0}; for ( i = 0; i < m_AryCloundInfo.GetSize(); i++ ) { strUniqueId.Format(_T("%s_A_%s_1"), strBranchId, m_AryCloundInfo.ElementAt(i).ElementAt(0)); if ( ( nIndex = m_AryCloundInfo.ElementAt(i).ElementAt(3).Find(lyfzLibrary::g_strCloundHost)) != -1) { lyfzLibrary::STXYJson tagXYJson; strTemp = m_AryCloundInfo.ElementAt(i).ElementAt(3).Mid(lyfzLibrary::g_strCloundHost.GetLength() + nIndex); lyfzLibrary::g_getcloundresult(m_nCloundType, strUniqueId, strTemp, szResultValue, 8912); m_AryCloundInfo.ElementAt(i).SetAt(4, szResultValue); // 解析Json; tagXYJson.strorder = m_AryCloundInfo.ElementAt(i).ElementAt(0); tagXYJson.strCustomer1 = m_AryCloundInfo.ElementAt(i).ElementAt(1); tagXYJson.strCustomer2 = m_AryCloundInfo.ElementAt(i).ElementAt(2); tagXYJson.strCust1PY = m_AryCloundInfo.ElementAt(i).ElementAt(5); tagXYJson.strCust2PY = m_AryCloundInfo.ElementAt(i).ElementAt(6); tagXYJson.strSJStatus = m_AryCloundInfo.ElementAt(i).ElementAt(7); strTemp = szResultValue; if ( (nIndex = strTemp.Find(_T(", \"last_modify_time\": "))) != -1 ) { tagXYJson.strXYDate = strTemp.Mid(nIndex+strlen(_T(", \"last_modify_time\": "))); tagXYJson.strXYDate.TrimRight(_T("\"")); tagXYJson.strXYDate.TrimLeft(_T("\"")); strTemp = strTemp.Left(nIndex); if ( ( nIndex = strTemp.Find(_T("\"pick_list\": ["))) != -1 ) { strTemp = strTemp.Mid(nIndex + strlen(_T("\"pick_list\": ["))); strTemp = strTemp.Mid(0, strTemp.GetLength() - 1); sprintf(szResultValue, _T("%s"), strTemp); } } lyfzLibrary::getXYJsonresult(szResultValue,tagXYJson.strJsonResult); vtXYJson.push_back(tagXYJson); } } lyfzLibrary::FreeCloudSelectionLib(); } UpdateDataSortList2(vtXYJson); } } void CDlgCloundResult::OnBnClickedDownresult() // 下载结果; { // TODO: 在此添加控件通知处理程序代码 GetCloundResult(); } void CDlgCloundResult::OnBnClickedSynresult() // 同步结果; { // TODO: 在此添加控件通知处理程序代码 POSITION pos = m_SortList.GetFirstSelectedItemPosition(); if ( pos == NULL ) { AfxMessageBox(_T("请选择要同步的记录")); return; } if ( MessageBox(_T("同步后将覆盖店内选片结果,是否继续?"), _T("温馨提示!"), MB_ICONWARNING|MB_YESNO) != MB_CANCELTRYCONTINUE ) { return; } INT nItem = 0; CString strSQL = _T(""); CString strOrder = _T(""); if ( m_nCloundType == 0 ) { CString strSpId = _T(""); CString strNo = _T(""); while ( pos ) { nItem = m_SortList.GetNextSelectedItem(pos); strOrder = m_SortList.GetItemText(nItem, 0); strSpId = m_SortList.GetItemText(nItem,3); strNo = m_SortList.GetItemText(nItem, 6); strSQL.Format(_T("update dindansp set no = '%s' where id = '%s' and [spid] = '%s'"), strNo, strOrder, strSpId); g_sendhead.bsql = true; g_pMainWnd->ProcessChatMessageRequest2(strSQL); } } else { CString strbz2 = _T(""); while ( pos ) { nItem = m_SortList.GetNextSelectedItem(pos); strOrder = m_SortList.GetItemText(nItem, 0); strbz2 = m_SortList.GetItemText(nItem,4); strSQL.Format(_T("update dindan set bz2 = '%s' where id = '%s' "), strbz2, strOrder); g_sendhead.bsql = true; g_pMainWnd->ProcessChatMessageRequest2(strSQL); } } } void CDlgCloundResult::OnBnClickedExportxls() // 导出xls; { // TODO: 在此添加控件通知处理程序代码 ListToXLS(&m_SortList, _T("C:\\云选片结果.xls"), 0); } void CDlgCloundResult::FillUpList(IN CString& strQuery) { INT nSize = m_AryCloundResult.GetSize(); m_SortList.DeleteAllItems2(); m_SortList.m_arLabels.SetSize(nSize); if ( m_nCloundType == 0 ) { if ( strQuery.IsEmpty() ) { for ( int i = 0; i < nSize; i++) { m_SortList.m_arLabels.ElementAt(i).Copy(m_AryCloundResult.ElementAt(i)); } m_SortList.m_LabelCount = nSize; m_SortList.SetItemCountEx(nSize); } else { int j = 0; int nType = GetType(strQuery); if ( nType == 2 ) // 拼音; { strQuery.MakeUpper(); for ( int i = 0; i < nSize; i++ ) { if ( m_AryCloundResult.ElementAt(i).ElementAt(7).Find(strQuery) != -1 || m_AryCloundResult.ElementAt(i).ElementAt(8).Find(strQuery) != -1 ) { m_SortList.m_arLabels.ElementAt(j++).Copy(m_AryCloundResult.ElementAt(i)); } } } else // 其他; { for ( int i = 0; i < nSize; i++ ) { if ( m_AryCloundResult.ElementAt(i).ElementAt(0).Find(strQuery) != -1 || // 订单号; m_AryCloundResult.ElementAt(i).ElementAt(1).Find(strQuery) != -1 || // 姓名1; m_AryCloundResult.ElementAt(i).ElementAt(2).Find(strQuery) != -1 || // 姓名2; m_AryCloundResult.ElementAt(i).ElementAt(3).Find(strQuery) != -1 || // 商品ID; m_AryCloundResult.ElementAt(i).ElementAt(4).Find(strQuery) != -1 || // 商品名称; m_AryCloundResult.ElementAt(i).ElementAt(5).Find(strQuery) != -1 || // 日期; m_AryCloundResult.ElementAt(i).ElementAt(6).Find(strQuery) != -1 // 相片串; ) { m_SortList.m_arLabels.ElementAt(j++).Copy(m_AryCloundResult.ElementAt(i)); } } } m_SortList.m_arLabels.SetSize(j,1); m_SortList.m_LabelCount = j; m_SortList.SetItemCountEx(j); } } else { if ( strQuery.IsEmpty() ) { for ( int i = 0; i < nSize; i++) { m_SortList.m_arLabels.ElementAt(i).Copy(m_AryCloundResult.ElementAt(i)); } m_SortList.m_LabelCount = nSize; m_SortList.SetItemCountEx(nSize); } else { int j = 0; int nType = GetType(strQuery); if ( nType == 2 ) // 拼音; { strQuery.MakeUpper(); for ( int i = 0; i < nSize; i++ ) { if ( m_AryCloundResult.ElementAt(i).ElementAt(5).Find(strQuery) != -1 || m_AryCloundResult.ElementAt(i).ElementAt(6).Find(strQuery) != -1 ) { m_SortList.m_arLabels.ElementAt(j++).Copy(m_AryCloundResult.ElementAt(i)); } } } else // 其他; { for ( int i = 0; i < nSize; i++ ) { if ( m_AryCloundResult.ElementAt(i).ElementAt(0).Find(strQuery) != -1 || // 订单号; m_AryCloundResult.ElementAt(i).ElementAt(1).Find(strQuery) != -1 || // 姓名1; m_AryCloundResult.ElementAt(i).ElementAt(2).Find(strQuery) != -1 || // 姓名2; m_AryCloundResult.ElementAt(i).ElementAt(3).Find(strQuery) != -1 || // 日期; m_AryCloundResult.ElementAt(i).ElementAt(4).Find(strQuery) != -1 // 要求; ) { m_SortList.m_arLabels.ElementAt(j++).Copy(m_AryCloundResult.ElementAt(i)); } } } m_SortList.m_arLabels.SetSize(j,1); m_SortList.m_LabelCount = j; m_SortList.SetItemCountEx(j); } } } void CDlgCloundResult::OnBnClickedQuery() { // TODO: 在此添加控件通知处理程序代码 UpdateData(); CString strQuery = _T(""); GetDlgItemText(IDC_COMBO1, strQuery); FillUpList(strQuery); } void CDlgCloundResult::OnBnClickedClean() { // TODO: 在此添加控件通知处理程序代码 } void CDlgCloundResult::OnOK() { // TODO: 在此添加专用代码和/或调用基类 OnBnClickedQuery(); //CDialog::OnOK(); } void CDlgCloundResult::OnCancel() { // TODO: 在此添加专用代码和/或调用基类 CDialog::OnCancel(); }