Пример #1
0
        public MApiModel.recApi12.Rootobject AccessApi12(MApiModel.api12.Rootobject api12)
        {
            List <string> listData = new List <string>();
            string        strData  = "";

            for (int i = 0; i < api12.data.Length; i++)
            {
                strData += JsonHelper.ObjectToJson(api12.data[i]);
                if (i != api12.data.Length - 1)
                {
                    strData += ",";
                }
            }


            string strParam = "comid=" + api12.comid + "&action=" + api12.action + "&token=" + api12.token + "&data=[" + strData + "]";

            string result = Helper.PostData(strParam);

            return(JsonHelper.ToObject <MApiModel.recApi12.Rootobject>(result));
        }
Пример #2
0
        public MApiModel.recApi12.Rootobject AccessApi12(MApiModel.api12.Rootobject api12)
        {
            //List<string> listData = new List<string>();
            //string strData = "";
            //for (int i = 0; i < api12.data.Length; i++)
            //{
            //    strData += JsonHelper.ObjectToJson(api12.data[i]);
            //    if (i != api12.data.Length - 1) strData += ",";
            //}


            //string strParam = "comid=" + api12.comid + "&action=" + api12.action + "&token=" + api12.token + "&data=[" + strData + "]";

            //string result = Helper.PostData(strParam);
            //return JsonHelper.ToObject<MApiModel.recApi12.Rootobject>(result);

            var url = "https://tms.monalisagroup.com.cn/mapi/doAction";

            HttpClient client = new HttpClient();

            client.Timeout = new TimeSpan(0, 0, 10, 0);
            HttpContent content = new FormUrlEncodedContent(api12.ModelToDic <MApiModel.api12.Rootobject>());

            try
            {
                var    data    = client.PostAsync(url, content).Result;
                string jsonStr = data.Content.ReadAsStringAsync().Result;

                var result = JSONhelper.ConvertToObject <MApiModel.recApi12.Rootobject>(jsonStr);

                return(result);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            tumMessage = "";
            switch (optype)
            {
            case "0":
                try
                {
                    _dataSrouce = _service.GetDeliveryList(
                        Global.LoginUser,
                        brand,
                        xq == "全部" ? "" : xq,
                        "",
                        status,
                        car,
                        "",
                        account,
                        expresscompany,
                        txt厂家单号.Text,
                        txt发货计划单号.Text,
                        txt组柜单号.Text,
                        txt工程名称.Text,
                        startdate == "0001/01/01" ? "" : startdate,
                        enddate == "0001/01/01" ? "" : enddate,
                        !chkClose.Checked);
                }
                catch (Exception ee)
                {
                    tumMessage = ee.ToStr();
                }


                break;

            case "2":
                try
                {
                    FrmAuditDialog dialog = new FrmAuditDialog("审核", "请选择你要做的处理", "通过", "不通过");
                    DialogResult   result = dialog.ShowDialog();
                    if (result == DialogResult.Yes)
                    {
                        //调用发货计划审核接口
                        int res3 = _service.AuditDeliveryByIDs(ids_sh, 3, Global.LoginUser);
                        MsgHelper.ShowInformation("处理成功!");
                    }
                    else if (result == DialogResult.No)
                    {
                        //调用发货计划审核接口
                        int res2 = _service.AuditDeliveryByIDs(ids_sh, 4, Global.LoginUser);
                        MsgHelper.ShowInformation("处理成功!");
                    }

                    foreach (var model in _dataSrouce)
                    {
                        foreach (string id in list)
                        {
                            if (model.FID == id)
                            {
                                model.FCHECK = true;
                            }
                        }
                    }
                }
                catch (Exception ee)
                {
                    tumMessage = ee.ToStr();
                }
                break;

            case "3":
                //调用发货计划删除接口
                try
                {
                    int res = _service.AuditAntiDeliveryByIDs(ids_sh);
                    if (res > 0)
                    {
                        MsgHelper.ShowInformation("处理成功!");
                    }
                }
                catch (Exception ee)
                {
                    tumMessage = ee.ToStr();
                }
                break;

            case "4":
                //调用发货计划接口
                try
                {
                    fid_tb.Clear();
                    for (int k = 0; k < listModels.Count; k++)
                    {
                        V_ICSEOUTBILLMODEL           rowData = listModels[k];
                        List <MApiModel.api12.Datum> LItem   = new List <MApiModel.api12.Datum>();
                        var entryList = _service.GetDeliveryEntryList(rowData.FID);

                        foreach (var sub22 in entryList)
                        {
                            v_thdModel v = _service.getTHD(sub22.thdbm);
                            sub22.khmc = v.khmc;
                            sub22.khhm = v.khhm;
                            sub22.gg   = v.cpgg;
                            sub22.xh   = v.cpxh;
                            sub22.pz   = v.cppz;
                            sub22.dw   = v.dw;
                            sub22.dj   = v.dj;
                            sub22.pz   = v.cppz;
                            sub22.xh   = v.cpxh;
                            sub22.gg   = v.cpgg;
                            sub22.khhm = v.khhm;
                            sub22.khmc = v.khmc;
                            sub22.cpdj = v.cpdj;
                            sub22.pzhm = v.pzhm;
                            sub22.kdrq = v.rq.ToString("yyyy-MM-dd");
                            sub22.cpcm = v.cpcm;
                            sub22.cpsh = v.cpsh;
                        }

                        string comid = "2";

                        foreach (var subEntry in entryList)
                        {
                            v_thdModel vTHD = _service.getTHD(subEntry.thdbm);
                            comid = vTHD.DB;

                            //list.Add(rowData.FID);
                            MApiModel.api12.Datum subItem = new MApiModel.api12.Datum();
                            subItem.pzhm = rowData.FBILLNO.Replace("DP", "");
                            subItem.rq   = rowData.FBILLDATE.Year + "/" + (rowData.FBILLDATE.Month < 10 ? "0" + rowData.FBILLDATE.Month.ToStr() : rowData.FBILLDATE.Month.ToStr()) + "/" + (rowData.FBILLDATE.Day < 10 ? "0" + rowData.FBILLDATE.Day.ToStr() : rowData.FBILLDATE.Day.ToStr());
                            subItem.khhm = vTHD.khhm;
                            subItem.khmc = vTHD.khmc;

                            subItem.pzlb = "";
                            subItem.cplb = 0;
                            //subItem.pjhm = string.IsNullOrEmpty(rowData.thdbm)?"":rowData.thdbm;
                            subItem.zdr  = "300384";
                            subItem.pjhm = string.IsNullOrEmpty(vTHD.pzhm) ? "" : vTHD.pzhm;

                            // string[] strArr = pro.FSRCCODE.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries);
                            //产品品种

                            subItem.cppz = vTHD.cppz;
                            //产品规格
                            subItem.cpgg = vTHD.cpgg;
                            //产品型号
                            subItem.cpxh = vTHD.cpxh;


                            subItem.cpdj    = vTHD.cpdj;
                            subItem.cpsh    = string.IsNullOrEmpty(vTHD.cpsh) ? "" : vTHD.cpsh; // string.IsNullOrEmpty(subEntry.FCOLORNO)?"":subEntry.FCOLORNO;
                            subItem.cpcm    = string.IsNullOrEmpty(vTHD.cpcm) ? "" : vTHD.cpcm; // string.IsNullOrEmpty(subEntry.FSTOCKNUMBER)?0:int.Parse(subEntry.FSTOCKNUMBER);
                            subItem.package = vTHD.tpackage;
                            subItem.dw      = vTHD.dw;
                            subItem.ks      = int.Parse(vTHD.ks);
                            subItem.sl      = (int)subEntry.FCOMMITQTY;
                            subItem.bz      = string.IsNullOrEmpty(subEntry.FREMARK) ? "" : subEntry.FREMARK;
                            subItem.gg      = vTHD.gg == null ? "" : vTHD.gg;

                            try
                            {
                                decimal dGGS = subItem.ks * subItem.sl * decimal.Parse(vTHD.gg);
                                subItem.ggs = dGGS.ToStr();
                            }
                            catch
                            {
                                subItem.ggs = vTHD.GGS == null ? "" : vTHD.GGS;
                            }


                            subItem.pjhm1 = "";
                            //
                            //subItem.package = vTHD.tpackage;
                            subItem.pjhm2    = "";
                            subItem.telphone = string.IsNullOrEmpty(rowData.FDELIVERERTEL) ? "123456789" : rowData.FDELIVERERTEL;

                            string strCarno = "";
                            strCarno += string.IsNullOrEmpty(rowData.FCARNUMBER) ? "" : rowData.FCARNUMBER;
                            strCarno += string.IsNullOrEmpty(rowData.FDELIVERER) ? "" : " 司机:" + rowData.FDELIVERER;
                            strCarno += string.IsNullOrEmpty(rowData.FDELIVERERTEL) ? "" : " 电话:" + rowData.FDELIVERERTEL;

                            decimal dLength = decimal.Parse(IniHelper.ReadString(Global.IniUrl, "CONFIG", "cph", "40"));

                            if (strCarno.Length > (int)dLength)
                            {
                                strCarno = strCarno.Substring(0, (int)dLength - 1);
                            }

                            subItem.carno = strCarno.Trim().Replace("  ", "");


                            subItem.jsdz     = string.IsNullOrEmpty(rowData.FRECEIVER_DISTRICT_NAME) ? "广东省" : rowData.FRECEIVER_DISTRICT_NAME;
                            subItem.jsr      = subItem.telphone;
                            subItem.pjhm3    = rowData.FBILLNO.Replace("DP", "");
                            subItem.ysfs     = string.IsNullOrEmpty(rowData.FDELIVERY_METHODNAME) ? "" : rowData.FDELIVERY_METHODNAME;
                            subItem.jsfs     = "";
                            subItem.Province = string.IsNullOrEmpty(rowData.FRECEIVER_PROVINCE_NAME) ? "广东省" : rowData.FRECEIVER_PROVINCE_NAME;
                            subItem.City     = string.IsNullOrEmpty(rowData.FRECEIVER_CITY_NAME) ? "佛山市" : rowData.FRECEIVER_CITY_NAME;
                            subItem.Region   = "南海区";
                            subItem.bz       = string.IsNullOrEmpty(rowData.FREMARK) ? "" : rowData.FREMARK;
                            LItem.Add(subItem);
                        }

                        if (LItem.Count > 0)
                        {
                            MApiModel.api12.Rootobject getapi6 = new MApiModel.api12.Rootobject();
                            getapi6.data  = LItem.ToArray();
                            getapi6.comid = int.Parse(comid);
                            string fid = rowData.FID;

                            if (!fid_tb.ContainsKey(fid) && fid != "")
                            {
                                fid_tb.Add(fid, getapi6);
                            }
                        }
                    }


                    List <string> listFalse = new List <string>();
                    int           iIndex    = 0;
                    List <string> listKeys  = new List <string>();
                    foreach (var sub333 in fid_tb)
                    {
                        listKeys.Add(sub333.Key);
                    }
                    foreach (string sub33 in listKeys)
                    {
                        if (!fid_tb.ContainsKey(sub33))
                        {
                            continue;
                        }
                        iIndex++;
                        string k = sub33;

                        MApiModel.api12.Rootobject v = fid_tb[sub33];
                        var    jsonData = JsonHelper.ToJson(v);
                        string res1     = _service.SyncDeliveryByIDsMN(jsonData, k);
                        if (res1 == "1")
                        {
                            //MsgHelper.ShowInformation("处理完成!");
                        }
                        else
                        {
                            listFalse.Add("第" + iIndex + "条发生错误:" + res1);
                        }
                    }

                    if (listFalse.Count > 0)
                    {
                        string mes = "";
                        foreach (var sub in listFalse)
                        {
                            mes += sub + "\r\n";
                        }

                        MsgHelper.ShowError(mes);
                    }
                }
                catch (Exception ee)
                {
                    tumMessage = ee.ToStr();
                }

                break;
            }
        }
        private void btn提交同步_Click(object sender, EventArgs e)
        {
            fid_tb.Clear();
            List <string> list = new List <string>();

            //int[] rownumber = this.gridView发货计划列表.GetSelectedRows();
            //foreach (int number in rownumber)
            //{
            //    var rowIndex = gridView发货计划列表.GetDataSourceRowIndex(number);
            //    var rowData = _dataSrouce[rowIndex];
            //    if (rowData.FSTATUS == 3 && (rowData.FSYNCSTATUS == 0 || rowData.FSYNCSTATUS == -1))
            //    {
            //        list.Add(rowData.FID);
            //    }
            //}

            List <MApiModel.api12.Datum> LItem = new List <MApiModel.api12.Datum>();
            string comid = "2";

            for (int i = 0; i < gridView发货计划列表.RowCount; i++)
            {
                bool b = gridView发货计划列表.GetRowCellValue(i, "FCHECK").ToBool();
                if (b)
                {
                    var rowIndex = gridView发货计划列表.GetDataSourceRowIndex(i);
                    var rowData  = _dataSrouce[rowIndex];
                    if (rowData.FSTATUS == 3 && (rowData.FSYNCSTATUS == 0 || rowData.FSYNCSTATUS == -1))
                    {
                        var entryList = gridControl发货计划明细.DataSource as V_ICSEOUTBILLENTRYMODEL[];
                        foreach (var subEntry in entryList)
                        {
                            v_thdModel vTHD = _service.getTHD(subEntry.thdbm);
                            comid = vTHD.DB;
                            ProductViewModel pro = _service.getProductView(subEntry.FITEMID);

                            //list.Add(rowData.FID);
                            MApiModel.api12.Datum subItem = new MApiModel.api12.Datum();
                            subItem.pzhm = rowData.FBILLNO.Replace("DP", "");
                            subItem.rq   = rowData.FBILLDATE.Year + "/" + (rowData.FBILLDATE.Month < 10 ? "0" + rowData.FBILLDATE.Month.ToStr() : rowData.FBILLDATE.Month.ToStr()) + "/" + (rowData.FBILLDATE.Day < 10 ? "0" + rowData.FBILLDATE.Day.ToStr() : rowData.FBILLDATE.Day.ToStr());
                            subItem.khhm = vTHD.khhm;
                            subItem.khmc = vTHD.khmc;

                            subItem.pzlb = "";
                            subItem.cplb = 0;
                            //subItem.pjhm = string.IsNullOrEmpty(rowData.thdbm)?"":rowData.thdbm;
                            subItem.zdr  = "300384";
                            subItem.pjhm = string.IsNullOrEmpty(vTHD.pzhm) ? "" : vTHD.pzhm;

                            // string[] strArr = pro.FSRCCODE.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries);
                            //产品品种

                            subItem.cppz = vTHD.cppz;
                            //产品规格
                            subItem.cpgg = vTHD.cpgg;
                            //产品型号
                            subItem.cpxh = vTHD.cpxh;


                            subItem.cpdj    = vTHD.cpdj;
                            subItem.cpsh    = string.IsNullOrEmpty(vTHD.cpsh) ? "" : vTHD.cpsh; // string.IsNullOrEmpty(subEntry.FCOLORNO)?"":subEntry.FCOLORNO;
                            subItem.cpcm    = string.IsNullOrEmpty(vTHD.cpcm) ? "" : vTHD.cpcm; // string.IsNullOrEmpty(subEntry.FSTOCKNUMBER)?0:int.Parse(subEntry.FSTOCKNUMBER);
                            subItem.package = vTHD.tpackage;
                            subItem.dw      = vTHD.dw;
                            subItem.ks      = int.Parse(vTHD.ks);
                            subItem.sl      = (int)subEntry.FCOMMITQTY;
                            subItem.bz      = string.IsNullOrEmpty(subEntry.FREMARK) ? "" : subEntry.FREMARK;
                            subItem.gg      = pro.FWEIGHT.ToStr();
                            subItem.ggs     = ((int)subEntry.FCOMMITQTY * pro.FWEIGHT).ToStr();
                            subItem.pjhm1   = "";
                            //
                            //subItem.package = vTHD.tpackage;
                            subItem.pjhm2    = "";
                            subItem.telphone = string.IsNullOrEmpty(rowData.FDELIVERERTEL) ? "123456789" : rowData.FDELIVERERTEL;

                            string strCarno = "";
                            strCarno += string.IsNullOrEmpty(rowData.FCARNUMBER) ? "" : "车号:" + rowData.FCARNUMBER;
                            strCarno += string.IsNullOrEmpty(rowData.FDELIVERER) ? "" : " 司机:" + rowData.FDELIVERER;
                            strCarno += string.IsNullOrEmpty(rowData.FDELIVERERTEL) ? "" : " 联系电话:" + rowData.FDELIVERERTEL;

                            subItem.carno = strCarno;

                            subItem.jsdz     = string.IsNullOrEmpty(rowData.FRECEIVER_DISTRICT_NAME) ? "广东省" : rowData.FRECEIVER_DISTRICT_NAME;
                            subItem.jsr      = subItem.telphone;
                            subItem.pjhm3    = rowData.FBILLNO.Replace("DP", "");
                            subItem.ysfs     = string.IsNullOrEmpty(rowData.FDELIVERY_METHODNAME) ? "" : rowData.FDELIVERY_METHODNAME;
                            subItem.jsfs     = "";
                            subItem.Province = string.IsNullOrEmpty(rowData.FRECEIVER_PROVINCE_NAME) ? "广东省" : rowData.FRECEIVER_PROVINCE_NAME;
                            subItem.City     = string.IsNullOrEmpty(rowData.FRECEIVER_CITY_NAME) ? "佛山市" : rowData.FRECEIVER_CITY_NAME;
                            subItem.Region   = "南海区";
                            subItem.bz       = rowData.FREMARK;
                            LItem.Add(subItem);
                        }
                    }


                    if (LItem.Count > 0)
                    {
                        // if (MsgHelper.AskQuestion("点击确认开始提交数据到厂家系统!"))
                        {
                            MApiModel.api12.Rootobject getapi6 = new MApiModel.api12.Rootobject();
                            getapi6.data  = LItem.ToArray();
                            getapi6.comid = int.Parse(comid);
                            string fid = rowData.FID;

                            if (!fid_tb.ContainsKey(fid))
                            {
                                fid_tb.Add(fid, getapi6);
                            }
                        }
                    }
                    else
                    {
                        MsgHelper.ShowError("请勾选要上传的数据。");
                    }

                    // break;
                }
            }

            if (fid_tb.Count > 0)
            {
                if (!backgroundWorker2.IsBusy)
                {
                    optype = "4";
                    backgroundWorker2.RunWorkerAsync();
                }
            }
            else
            {
                MsgHelper.ShowError("请选中符合条件的记录!");
            }
        }