Beispiel #1
0
        public string Data_Cacu_Distance(int KHID, string lat, string lon)
        {
            string token = appClass.CRM_Gettoken();

            CRM_KH_DZList[] DZdata = crmModels.KH_DZ.ReadByKHID(KHID, token);
            if (DZdata.Length == 0)
            {
                return("");
            }
            CRM_KH_DZList minModel = new CRM_KH_DZList();
            double        min      = double.MaxValue;

            for (int i = 0; i < DZdata.Length; i++)
            {
                double distance = GetDistance(Convert.ToDouble(DZdata[i].ED), Convert.ToDouble(DZdata[i].JD), Convert.ToDouble(lat), Convert.ToDouble(lon));
                if (distance < min)
                {
                    min      = distance;
                    minModel = DZdata[i];
                }
            }
            string[] s = new string[2];
            s[0] = Newtonsoft.Json.JsonConvert.SerializeObject(minModel);
            s[1] = min.ToString().Split('.')[0];


            //string[][] data = crmModels.KQ_QD.Verify_QD(staffid, lat, lon, accu, token);

            string ss = Newtonsoft.Json.JsonConvert.SerializeObject(s);

            return(ss);
        }
Beispiel #2
0
        public string Data_Insert_QiandaoAndBFDJ(string bfdata, string qddata, string sf, string cs)
        {
            string token = appClass.CRM_Gettoken();

            int[]       data = { 0, 0 };
            CRM_BF_BFDJ bf   = Newtonsoft.Json.JsonConvert.DeserializeObject <CRM_BF_BFDJ>(bfdata);
            CRM_KQ_QD   qd   = Newtonsoft.Json.JsonConvert.DeserializeObject <CRM_KQ_QD>(qddata);

            if (bf.BFKH != 0)
            {
                //先校验当前位置在不在客户的签到地址范围内
                CRM_KH_DZList[] KHDZmodel = crmModels.KH_DZ.ReadByKHID(bf.BFKH, token);
                if (KHDZmodel.Length == 0)
                {
                    data[0] = -2;
                    return(Newtonsoft.Json.JsonConvert.SerializeObject(data));
                }
                CRM_KH_DZList minModel = new CRM_KH_DZList();
                double        min      = double.MaxValue;
                for (int x = 0; x < KHDZmodel.Length; x++)
                {
                    double dist = GetDistance(Convert.ToDouble(qd.QDWD), Convert.ToDouble(qd.QDJD), Convert.ToDouble(KHDZmodel[x].ED), Convert.ToDouble(KHDZmodel[x].JD));
                    if (dist <= KHDZmodel[x].DZRC)     //在范围内
                    {
                        qd.QDGSHXMID = KHDZmodel[x].DZID;
                        qd.KQJL      = dist.ToString();
                        //break;
                    }
                    else
                    {
                        if (dist < min)   //不在范围内的话就取出距离最近的那个签到点
                        {
                            min      = dist;
                            minModel = KHDZmodel[x];
                        }
                    }
                }
                if (qd.QDGSHXMID == 0)     //不在范围内
                {
                    qd.QDGSHXMID = minModel.DZID;
                    qd.KQJL      = min.ToString();
                    qd.ISACTIVE  = 0;
                }
            }


            bf.JHBFKSSJ = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            bf.JHBFJSSJ = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            qd.QDGSID   = crmModels.BF_BF.Create_BFDJ(bf, token);
            qd.SF       = crmModels.HG_DICT.ReadByDICNAME(sf, 1, token);
            qd.CS       = crmModels.HG_DICT.ReadByDICNAME(cs, 2, token);
            int i = crmModels.KQ_QD.Create(qd, token);

            if (qd.ISACTIVE == 0)
            {
                data[0] = -1;
                data[1] = qd.QDGSID;
                return(Newtonsoft.Json.JsonConvert.SerializeObject(data));
            }
            else
            {
                data[0] = 1;
                data[1] = qd.QDGSID;
                return(Newtonsoft.Json.JsonConvert.SerializeObject(data));;
            }
        }