Esempio n. 1
0
 public string Data_CHTT_ReadMXByParam(string cxdata)
 {
     token = appClass.CRM_Gettoken();
     Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX   cxmodel = Newtonsoft.Json.JsonConvert.DeserializeObject <Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX>(cxdata);
     Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX[] data    = crmModels.BC_CHTT.ReadMXbyParam(cxmodel, token);
     return(Newtonsoft.Json.JsonConvert.SerializeObject(data));
 }
Esempio n. 2
0
        public string Data_Insert_FXCH_FX(string TPM, string DXM, string CRMID)
        {
            token = appClass.CRM_Gettoken();
            WebMSG msg = new WebMSG();

            if (TPM.Length != 12)
            {
                msg.KEY = 0;
                msg.MSG = "托盘码格式错误";
                return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
            }
            //先看看这个托盘码在不在数据库里
            Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX[] model = crmModels.BC_CHTT.ReadDXMbyTPM(TPM, token);           //这个model是根据传进来的托码在发货表里面找到的数据
            if (model.Length == 0)
            {
                msg.KEY = 0;
                msg.MSG = "找不到托盘码";
                return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
            }

            DXM[] dxm = Newtonsoft.Json.JsonConvert.DeserializeObject <DXM[]>(DXM);

            //把扫进来的码统一转换成内盒码,然后看看有没有重复的码
            List <DXM> result = new List <DXM>();

            for (int i = 0; i < dxm.Length; i++)
            {
                if (dxm[i].Dxm.Length != 15)
                {
                    msg.KEY = 0;
                    msg.MSG = "箱码格式错误";
                    return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                }
                Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX modeltmp = new Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX();
                modeltmp.DXM = dxm[i].Dxm;
                Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX[] MXdata = crmModels.BC_CHTT.ReadMXbyParam(modeltmp, token);
                for (int j = 0; j < MXdata.Length; j++)
                {
                    //result[result.Count] = new DXM();
                    //result[result.Count].Dxm = MXdata[j].NHM;
                    DXM temp = new DXM();
                    temp.Dxm = MXdata[j].NHM;
                    result.Add(temp);
                }
            }

            List <DXM> checkdata = result.Distinct(new DXM.TravelTrafficInfoComparer()).ToList();

            if (result.Count != checkdata.Count)
            {
                msg.KEY = 0;
                msg.MSG = "请勿重复输入";
                return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
            }



            for (int i = 0; i < dxm.Length; i++)
            {
                //int count = crmModels.BC_FXCH.ReadCountByDXM(dxm[i].Dxm, "", token);
                //if (count != 0)
                //{
                //    msg.KEY = 0;
                //    msg.MSG = "该条码已经发货:" + dxm[i].Dxm;
                //    return Newtonsoft.Json.JsonConvert.SerializeObject(msg);
                //}

                Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX[] MXdata = crmModels.BC_CHTT.SelectCHMXbyDXM(dxm[i].Dxm, "", token);
                if (MXdata.Length == 0)
                {
                    msg.KEY = 0;
                    msg.MSG = "找不到条码:" + dxm[i].Dxm;
                    return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                }


                //校验当前人员对应的客户有没有发这箱货的权限
                int a = crmModels.BC_FXCH.Verify_IfHaveCHRight(appClass.CRM_GetStaffid(), dxm[i].Dxm, "", token);
                if (a == 0)
                {
                    msg.KEY = 0;
                    msg.MSG = "当前人员的客户没有发这箱货的权限:" + dxm[i].Dxm;
                    return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                }



                int samecount = 0;
                for (int j = 0; j < dxm.Length; j++)
                {
                    if (dxm[i].Dxm == dxm[j].Dxm)
                    {
                        samecount++;
                    }
                }
                if (samecount > 1)
                {
                    msg.KEY = 0;
                    msg.MSG = "该条码重复:" + dxm[i].Dxm;
                    return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                }
            }



            CRM_BC_FXCHTT TTmodel = new CRM_BC_FXCHTT();
            CRM_KH_KH     KHmodel = crmModels.KH_KH.ReadByCRMID(CRMID, token);

            TTmodel.KHID  = KHmodel.KHID;
            TTmodel.SDFID = crmModels.KH_KH.ReadByCRMID(KHmodel.PKHID.ToString(), token).KHID;
            TTmodel.BEIZ  = "";
            TTmodel.CJR   = appClass.CRM_GetStaffid();
            int TTid = crmModels.BC_FXCH.TTCreate(TTmodel, token);

            if (TTid == 0)
            {
                msg.KEY = 0;
                msg.MSG = "保存失败";
                return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
            }
            for (int j = 0; j < model.Length; j++)
            {
                int count = 0;
                for (int i = 0; i < dxm.Length; i++)
                {
                    if (model[j].DXM == dxm[i].Dxm)
                    {
                        count++;
                    }
                }
                if (count > 0)
                {
                    continue;
                }
                Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX[] MXdata = null;


                MXdata = crmModels.BC_CHTT.SelectCHMXbyDXM(model[j].DXM, "", token);



                for (int i = 0; i < MXdata.Length; i++)
                {
                    CRM_BC_FXCHMX MXmodel = new CRM_BC_FXCHMX();
                    MXmodel.FXCHTTID = TTid;
                    MXmodel.TPM      = MXdata[i].TPM;
                    MXmodel.DXM      = MXdata[i].DXM;
                    MXmodel.NHM      = MXdata[i].NHM;
                    MXmodel.CHARG    = MXdata[i].CHARG;
                    MXmodel.LWEDT    = MXdata[i].LWEDT;
                    int MXid = crmModels.BC_FXCH.MXCreate(MXmodel, token);
                    if (MXid == 0)
                    {
                        msg.KEY = 0;
                        msg.MSG = "保存失败,请联系管理员";
                        return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                    }
                }
            }
            msg.KEY = 1;
            msg.MSG = "保存成功";
            return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
        }
Esempio n. 3
0
        public string Data_Insert_FXCH_ZZK(string JHD)
        {
            token = appClass.CRM_Gettoken();
            WebMSG msg = new WebMSG();

            MODEL_ZBCFUN_JHD_READ JHDdata = Newtonsoft.Json.JsonConvert.DeserializeObject <MODEL_ZBCFUN_JHD_READ>(JHD);

            //把扫进来的码统一转换成内盒码,然后看看有没有重复的码

            for (int i = 0; i < JHDdata.ET_ItemData.Length; i++)
            {
                List <DXM> result = new List <DXM>();
                for (int j = 0; j < JHDdata.ET_ItemData[i].TM.Length; j++)
                {
                    if (JHDdata.ET_ItemData[i].TM[j].Barcode.Length == 12)    //托码
                    {
                        //展开成内盒码进行校验
                        Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX model = new Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX();
                        model.TPM   = JHDdata.ET_ItemData[i].TM[j].Barcode;
                        model.KUNAG = JHDdata.ES_HeadData.ZZKGGKH;
                        Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX[] MXdata = crmModels.BC_CHTT.ReadMXbyParam(model, token);
                        for (int k = 0; k < MXdata.Length; k++)
                        {
                            //result[result.Count] = new DXM();
                            DXM temp = new DXM();
                            temp.Dxm = MXdata[k].NHM;
                            result.Add(temp);
                        }

                        //看看是不是已经发货了的条码
                        CRM_BC_FXCHMX cxmodel = new CRM_BC_FXCHMX();
                        cxmodel.TPM = JHDdata.ET_ItemData[i].TM[j].Barcode;
                        CRM_BC_FXCHMX[] FHdata = crmModels.BC_FXCH.ReadMXbyParam(cxmodel, token);
                        if (FHdata.Length != 0)
                        {
                            msg.KEY = 0;
                            msg.MSG = JHDdata.ET_ItemData[i].POSNR + "行项目该物流码已发货:" + JHDdata.ET_ItemData[i].TM[j].Barcode;
                            return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                        }
                    }
                    else if (JHDdata.ET_ItemData[i].TM[j].Barcode.Length == 15)    //箱码
                    {
                        Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX model = new Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX();
                        model.DXM   = JHDdata.ET_ItemData[i].TM[j].Barcode;
                        model.KUNAG = JHDdata.ES_HeadData.ZZKGGKH;
                        Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX[] MXdata = crmModels.BC_CHTT.ReadMXbyParam(model, token);
                        for (int k = 0; k < MXdata.Length; k++)
                        {
                            //result[result.Count] = new DXM();
                            DXM temp = new DXM();
                            temp.Dxm = MXdata[k].NHM;
                            result.Add(temp);
                        }

                        //看看是不是已经发货了的条码
                        CRM_BC_FXCHMX cxmodel = new CRM_BC_FXCHMX();
                        cxmodel.DXM = JHDdata.ET_ItemData[i].TM[j].Barcode;
                        CRM_BC_FXCHMX[] FHdata = crmModels.BC_FXCH.ReadMXbyParam(cxmodel, token);
                        if (FHdata.Length != 0)
                        {
                            msg.KEY = 0;
                            msg.MSG = JHDdata.ET_ItemData[i].POSNR + "行项目该物流码已发货:" + JHDdata.ET_ItemData[i].TM[j].Barcode;
                            return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                        }
                    }
                    else if (JHDdata.ET_ItemData[i].TM[j].Barcode.Length == 18)    //内盒码
                    {
                        DXM temp = new DXM();
                        temp.Dxm = JHDdata.ET_ItemData[i].TM[j].Barcode;
                        result.Add(temp);

                        //看看是不是已经发货了的条码
                        CRM_BC_FXCHMX cxmodel = new CRM_BC_FXCHMX();
                        cxmodel.NHM = JHDdata.ET_ItemData[i].TM[j].Barcode;
                        CRM_BC_FXCHMX[] FHdata = crmModels.BC_FXCH.ReadMXbyParam(cxmodel, token);
                        if (FHdata.Length != 0)
                        {
                            msg.KEY = 0;
                            msg.MSG = JHDdata.ET_ItemData[i].POSNR + "行项目该物流码已发货:" + JHDdata.ET_ItemData[i].TM[j].Barcode;
                            return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                        }
                    }
                }
                List <DXM> checkdata = result.Distinct(new DXM.TravelTrafficInfoComparer()).ToList();
                if (result.Count != checkdata.Count)
                {
                    msg.KEY = 0;
                    msg.MSG = JHDdata.ET_ItemData[i].POSNR + "行项目的物流码重复";
                    return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                }
            }



            List <ZSL_BCT110> RFCmodel = new List <ZSL_BCT110>();

            for (int i = 0; i < JHDdata.ET_ItemData.Length; i++)
            {
                for (int j = 0; j < JHDdata.ET_ItemData[i].TM.Length; j++)
                {
                    Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX[] MXdata = null;
                    if (JHDdata.ET_ItemData[i].TM[j].Barcode.Length == 12)    //托码
                    {
                        Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX model = new Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX();
                        model.TPM   = JHDdata.ET_ItemData[i].TM[j].Barcode;
                        model.KUNAG = JHDdata.ES_HeadData.ZZKGGKH;
                        MXdata      = crmModels.BC_CHTT.ReadMXbyParam(model, token);
                    }
                    else if (JHDdata.ET_ItemData[i].TM[j].Barcode.Length == 15)    //箱码
                    {
                        Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX model = new Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX();
                        model.DXM   = JHDdata.ET_ItemData[i].TM[j].Barcode;
                        model.KUNAG = JHDdata.ES_HeadData.ZZKGGKH;
                        MXdata      = crmModels.BC_CHTT.ReadMXbyParam(model, token);
                    }
                    else if (JHDdata.ET_ItemData[i].TM[j].Barcode.Length == 18)    //内盒码
                    {
                        Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX model = new Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX();
                        model.NHM   = JHDdata.ET_ItemData[i].TM[j].Barcode;
                        model.KUNAG = JHDdata.ES_HeadData.ZZKGGKH;
                        MXdata      = crmModels.BC_CHTT.ReadMXbyParam(model, token);
                    }
                    else
                    {
                        MXdata = new UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX[0];
                    }

                    for (int k = 0; k < MXdata.Length; k++)
                    {
                        ZSL_BCT110 temp = new ZSL_BCT110();
                        temp.VBELN  = MXdata[k].VBELN;
                        temp.POSNR  = MXdata[k].POSNR;
                        temp.NHM    = MXdata[k].NHM;
                        temp.DXM    = MXdata[k].DXM;
                        temp.TPM    = MXdata[k].TPM;
                        temp.VBELNN = JHDdata.ET_ItemData[i].VBELN;
                        temp.POSNRN = JHDdata.ET_ItemData[i].POSNR;
                        temp.MATNR  = JHDdata.ET_ItemData[i].MATNR;
                        temp.KUNAG  = JHDdata.ES_HeadData.KUNAG;
                        temp.LGORT  = JHDdata.ET_ItemData[i].LGORT;
                        temp.WERKS  = JHDdata.ET_ItemData[i].WERKS;
                        RFCmodel.Add(temp);
                    }
                }
            }
            //调用过账接口
            MES_RETURN RFCresult = crmModels.BarCode.JHD_UPDATE(RFCmodel.ToArray(), appClass.CRM_GetStaffid(), token);

            if (RFCresult.TYPE == "E")
            {
                msg.KEY = 0;
                msg.MSG = RFCresult.MESSAGE;
                return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
            }



            CRM_BC_FXCHTT TTmodel = new CRM_BC_FXCHTT();
            CRM_KH_KH     KHmodel = crmModels.KH_KH.ReadBySAPSN(JHDdata.ES_HeadData.KUNAG.TrimStart('0'), token);

            TTmodel.KHID    = KHmodel.KHID;
            TTmodel.SDFID   = crmModels.KH_KH.ReadByCRMID(KHmodel.PKHID.ToString(), token).KHID;
            TTmodel.KUNAG   = JHDdata.ES_HeadData.KUNAG;
            TTmodel.NAMEG   = JHDdata.ES_HeadData.NAMEG;
            TTmodel.VBELN   = JHDdata.ES_HeadData.VBELN;
            TTmodel.ZZKGGKH = JHDdata.ES_HeadData.ZZKGGKH;
            TTmodel.BEIZ    = "";
            TTmodel.CJR     = appClass.CRM_GetStaffid();
            int TTid = crmModels.BC_FXCH.TTCreate(TTmodel, token);

            if (TTid == 0)
            {
                msg.KEY = 0;
                msg.MSG = "保存失败";
                return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
            }


            for (int i = 0; i < JHDdata.ET_ItemData.Length; i++)
            {
                for (int j = 0; j < JHDdata.ET_ItemData[i].TM.Length; j++)
                {
                    Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX[] MXdata = null;
                    if (JHDdata.ET_ItemData[i].TM[j].Barcode.Length == 12)    //托码
                    {
                        Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX model = new Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX();
                        model.TPM   = JHDdata.ET_ItemData[i].TM[j].Barcode;
                        model.KUNAG = JHDdata.ES_HeadData.ZZKGGKH;
                        MXdata      = crmModels.BC_CHTT.ReadMXbyParam(model, token);
                    }
                    else if (JHDdata.ET_ItemData[i].TM[j].Barcode.Length == 15)    //箱码
                    {
                        Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX model = new Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX();
                        model.DXM   = JHDdata.ET_ItemData[i].TM[j].Barcode;
                        model.KUNAG = JHDdata.ES_HeadData.ZZKGGKH;
                        MXdata      = crmModels.BC_CHTT.ReadMXbyParam(model, token);
                    }
                    else if (JHDdata.ET_ItemData[i].TM[j].Barcode.Length == 18)    //内盒码
                    {
                        Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX model = new Sonluk.UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX();
                        model.NHM   = JHDdata.ET_ItemData[i].TM[j].Barcode;
                        model.KUNAG = JHDdata.ES_HeadData.ZZKGGKH;
                        MXdata      = crmModels.BC_CHTT.ReadMXbyParam(model, token);
                    }
                    else
                    {
                        MXdata = new UI.Model.CRM.BC_CHTTService.CRM_BC_CHMX[0];
                    }

                    for (int k = 0; k < MXdata.Length; k++)
                    {
                        CRM_BC_FXCHMX MXmodel = new CRM_BC_FXCHMX();
                        MXmodel.FXCHTTID = TTid;
                        MXmodel.TPM      = MXdata[k].TPM;
                        MXmodel.DXM      = MXdata[k].DXM;
                        MXmodel.NHM      = MXdata[k].NHM;
                        MXmodel.CHARG    = MXdata[k].CHARG;
                        MXmodel.LWEDT    = MXdata[k].LWEDT;
                        MXmodel.VBELN    = JHDdata.ET_ItemData[i].VBELN;
                        MXmodel.POSNR    = JHDdata.ET_ItemData[i].POSNR;
                        MXmodel.MATNR    = JHDdata.ET_ItemData[i].MATNR;
                        MXmodel.MAKTX    = JHDdata.ET_ItemData[i].MAKTX;
                        int MXid = crmModels.BC_FXCH.MXCreate(MXmodel, token);
                        if (MXid == 0)
                        {
                            msg.KEY = 0;
                            msg.MSG = "保存失败,请联系管理员";
                            return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                        }
                    }
                }
            }



            msg.KEY = 1;
            msg.MSG = "登记成功";
            return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
        }