Ejemplo n.º 1
0
        private static WorkBean insertWeightToMap(WorkBean workBean, DZCBean bean)
        {
            workBean.WeiIp  = bean.Ip;
            workBean.Weight = bean.Weight;
            workBean.Data   = bean.Data;
            workBean.Unit   = bean.Unit;

            return(workBean);
        }
Ejemplo n.º 2
0
        public ResultBean insertWeightDataToWorkBean(DZCBean bean)//电子秤读到重量
        {
            ResultBean result  = new ResultBean();
            bool       success = false;
            string     msg     = "";

            ConnBean conn      = new ConnBean();
            bool     connExist = connMap.TryGetValue(bean.Ip, out conn);//通过关联表中找到读卡器IP


            if (conn != null)
            {
                if (conn.Ip3 != null)                              //读卡器IP
                {
                    WorkBean work = tryGetWorkBeanValue(conn.Ip3); //通过读卡器IP得到已经保存的刷卡信息
                    if (work != null)
                    {
                        work = insertWeightToMap(work, bean);

                        saveWork(work);//保存信息

                        success       = true;
                        msg           = "数据保存成功";
                        result.IsLow  = (bean.Weight - conn.Weight) < 0.00000001;//低重
                        result.Value1 = bean.Weight + "";
                        result.Value2 = conn.Weight + "";
                        result.Msg2   = "低重,发送报警。报警重量:" + conn.Weight + ",当前重量:" + bean.Weight;//在IsLow为true时才正确
                        result.Bean   = conn;
                    }
                    else
                    {
                        msg = "电子称 " + conn.Ip + " 未有用户刷卡,重量数据不保存";
                    }
                }
                else
                {
                    msg = "电子称 " + conn.Ip + " 关联的读卡器 " + conn.Ip3 + " 不存在";
                }
            }
            else
            {
                msg = "关联表中不存在电子秤IP:" + bean.Ip + "的报警器及读卡器关联信息";
            }
            result.Success = success;
            result.Msg     = msg;

            return(result);
        }