コード例 #1
0
        /// <summary>
        ///  <!--0:入库,1:报警/点检,2:出库-->
        ///  出入库标记更新
        ///  status 状态 smallint 默认1:可用 0:不可用
        /// </summary>
        /// <param name="sysType"></param>
        /// <returns></returns>
        public bool toDoSomeThing(string tmpStrRFID, string tmpMoveFlag, string RFIDClientIP)
        {
            string sysType = "";
            m_terminaldevice tmpDevice = null;
            t_videodata tmpVideo = new t_videodata();
            try
            {
                logger.DebugFormat("*******#############IP:{0},移动标记:{1},RFID:{2}.", RFIDClientIP, tmpMoveFlag, tmpStrRFID);

                using (var db = new MysqlDbContext())
                {
                    tmpDevice = db.m_terminaldevice.Where(m => m.ModelNo.Equals("500") && m.SerialNoIPAddr.Equals(RFIDClientIP)).FirstOrDefault();

                    if (tmpDevice != null)
                    {
                        //实际入库表
                        var tmpcontStockIn = db.t_stockinctnnodetail.Where(m => m.rfid_no.Equals(tmpStrRFID) && m.status == 2).Count();
                        //库存明细表
                        var tmpcontStockOut = db.t_stockdetail.Where(m => m.rfid_no.Equals(tmpStrRFID) && m.status == 2).Count();

                        sysType = tmpDevice.param3;

                        if (!sysType.Equals("1"))
                        {
                            if (tmpcontStockIn > 0)
                            {
                                sysType = "0";
                            }
                            else
                            {
                                if (tmpcontStockOut > 0)
                                {
                                    sysType = "2";
                                }
                            }
                        }
                        logger.DebugFormat("*******############# {0},开始处理操作:{1},IP:{2}", tmpDevice.param3, tmpDevice.TerminalName, RFIDClientIP);
                    }
                    else
                    {
                        logger.ErrorFormat("*******#############****Error: 没有找到 {0} 对应的设备。", RFIDClientIP);
                        return false;
                    }
                }

                switch (sysType)
                {
                    case "0":
                        #region stock in

                        if (_tmpListScanRFID.Keys.Contains(tmpStrRFID))
                        {

                            if (_tmpListScanRFID[tmpStrRFID])
                            {
                                logger.DebugFormat("#***********已扫并处理OK,不做处理。RFID: {0}", tmpStrRFID);
                                logger.InfoFormat("#***********已扫并处理OK,不做处理。RFID: {0}", tmpStrRFID);

                                //sendTxtToLED(tmpItemRFID);
                                return true;
                            }
                            else
                            {
                                // sendTxtToLED(tmpItemRFID);// + "已扫"
                                logger.DebugFormat("#***********已扫但处理失败,重做处理。RFID: {0}", tmpStrRFID);

                            }

                        }
                        else
                        {
                            _tmpListScanRFID.Add(tmpStrRFID, false);
                        }

                        //0:入库
                        //查实际入库明细(2),有-->更新为(1);
                        using (var db = new MysqlDbContext())
                        {
                            var tmpcont = db.t_stockinctnnodetail.Where(m => m.rfid_no.Equals(tmpStrRFID) && m.status == 2).Count();

                            if (tmpcont > 0)
                            {
                                var tmpModelin = db.t_stockinctnnodetail.Where(m => m.rfid_no.Equals(tmpStrRFID) && m.status == 2).First();
                                var tmpStockIn = db.t_stockindetail.Where(m => m.stockin_id.Equals(tmpModelin.stockin_id)).First();

                                logger.DebugFormat("#开始入库**********#########共有{0}条记录.入库单号:{1},货物编号:{2},托盘号:{3},rfid_no:{4}", tmpcont, tmpModelin.stockin_id, tmpModelin.prdct_no, tmpModelin.ctnno_no, tmpStrRFID);
                                logger.Debug("*********(2--->1)[status 1:可用 0:不可用 2:卸料]**********");

                                string tmpUpdateSQL = "update t_stockinctnnodetail set STATUS='1',updtime=now(),videodevice_id='" + tmpDevice.TerminalNo + "' WHERE STATUS='2' and rfid_no=@rfid_no";
                                var tmpRetunCount = db.Database.ExecuteSqlCommand(tmpUpdateSQL, new MySqlParameter("@rfid_no", tmpStrRFID.Trim()));

                                if (tmpRetunCount > 0)
                                {
                                    logger.DebugFormat("*#入库**********#########t_stockinctnnodetail: 更新成功入库标记,共有{0}条已更新.入库单号:{1},货物编号:{2},托盘号:{3},rfid_no:{4}", tmpRetunCount, tmpModelin.stockin_id, tmpModelin.prdct_no, tmpModelin.ctnno_no, tmpStrRFID);
                                    var tmpSendLedMsg = tmpStrRFID + "入库";
                                    sendTxtToLED(tmpSendLedMsg, tmpDevice);
                                    Program.saveLog("入库", "0入库:" + tmpStrRFID, 0, 1);
                                    short tmpchannle = 0;
                                    if (short.TryParse(tmpDevice.param4, out tmpchannle))
                                    {
                                        var msg = tmpStockIn.bespeak_no + " " + tmpModelin.rfid_no + " " + tmpModelin.prdct_no + " " + tmpModelin.qty + " 入库";
                                        Program.saveVideoSet(msg, tmpchannle);
                                    }
                                    else
                                    {
                                        Program.saveLog("入库Video设置", "入库Video设置失败,没有通道号。" + tmpStrRFID, 3, 0);
                                    }

                                    return true;
                                }

                                logger.DebugFormat("*error开始入库*失败,系统错误,请联系管理员**************************************************************", tmpStrRFID);
                                Program.saveLog("入库", "0入库:" + tmpStrRFID, 0, 0);
                                return false;
                            }
                            logger.DebugFormat("*开始入库*失败,未查到[可入库/有效的]实际入库明细记录,RFID:{0}**************************************************************", tmpStrRFID);
                            return false;
                        }
                        break;
                        #endregion
                    case "2":
                        #region stock out

                        if (_tmpListScanRFID.Keys.Contains(tmpStrRFID))
                        {

                            if (_tmpListScanRFID[tmpStrRFID])
                            {
                                logger.DebugFormat("#***********已扫并处理OK,不做处理。RFID: {0}", tmpStrRFID);
                                logger.InfoFormat("#***********已扫并处理OK,不做处理。RFID: {0}", tmpStrRFID);

                                //sendTxtToLED(tmpItemRFID);
                                return true;
                            }
                            else
                            {
                                // sendTxtToLED(tmpItemRFID);// + "已扫"
                                logger.DebugFormat("#***********已扫但处理失败,重做处理。RFID: {0}", tmpStrRFID);

                            }

                        }
                        else
                        {
                            _tmpListScanRFID.Add(tmpStrRFID, false);
                        }

                        //1:出库
                        using (var db = new MysqlDbContext())
                        {
                            //库存明细表
                            //2:下架
                            //1:在库可用,0:不可用(出库更新库存时更新(2-->0)

                            //查库存明细表(1),得:仓单号.
                            //(有-->查申.货物出库明细(仓单号)
                            //      [有-->更新库存表,库存明细表(0),无-->报警]),
                            //无-->报警)
                            var tmpcont = db.t_stockdetail.Where(m => m.rfid_no.Equals(tmpStrRFID) && m.status == 2).Count();
                            if (tmpcont > 0)
                            {

                                #region 查库存明细表
                                //查库存明细表
                                var tmpstockdetailForOut = db.t_stockdetail.Where(m => m.rfid_no.Equals(tmpStrRFID) && m.status == 2).FirstOrDefault();

                                if (tmpstockdetailForOut == null)
                                {
                                    logger.DebugFormat("*****无效RFID:{0}.", tmpStrRFID);
                                    return false;
                                }
                                #endregion

                                #region 货物出库明细
                                //货物出库明细
                                t_stockoutdetail tmpStockoutDetails = null;
                                var strremark = "";
                                if (string.IsNullOrEmpty(tmpstockdetailForOut.receiptNo))
                                {
                                    #region 没有仓单号
                                    logger.DebugFormat("*开始出库**********#########没有仓单号,货物编号:{0},托盘号:{1},rfid_no:{2}", tmpstockdetailForOut.prdct_no, tmpstockdetailForOut.ctnno_no, tmpStrRFID);
                                    ////***********报警*********

                                    //var tmpNewAlerm = new t_alarmdata();
                                    //tmpNewAlerm.recd_id = DateTime.Now.ToString("yyyyMMddHHmmss") + "D" + _tmpRandom.Next(100000).ToString() + "R" + tmpStrRFID;
                                    //tmpNewAlerm.alarm_type = "Alarm_06";
                                    //tmpNewAlerm.depot_no = "0";
                                    //tmpNewAlerm.cell_no = tmpStrRFID;
                                    //tmpNewAlerm.begin_time = DateTime.Now;
                                    //tmpNewAlerm.over_time = DateTime.Now;
                                    //tmpNewAlerm.remark = "RFID:" + tmpStrRFID + "无出库指示。";
                                    //tmpNewAlerm.status = 1;
                                    //tmpNewAlerm.addtime = DateTime.Now;
                                    //tmpNewAlerm.adduser =Program._serverIP;
                                    //tmpNewAlerm.updtime = DateTime.Now;
                                    //tmpNewAlerm.upduser =Program._serverIP;
                                    //db.t_alarmdata.Add(tmpNewAlerm);
                                    //var saveflag = db.SaveChanges();

                                    //if (saveflag > 0)
                                    //{
                                    //    logger.DebugFormat("********报警 保存完成。IP:{0},移动标记:{1},RFID:{2}.SaveFlag:{3}.", RFIDClientIP, tmpMoveFlag, tmpStrRFID, saveflag);
                                    //}
                                    //else
                                    //{

                                    //    logger.DebugFormat("********报警 保存失败。IP:{0},移动标记:{1},RFID:{2}.SaveFlag:{3}", RFIDClientIP, tmpMoveFlag, tmpStrRFID, saveflag);
                                    //}
                                    //var tmpLedMsg = tmpStrRFID + "无出库指示.";
                                    //sendTxtToLED(tmpLedMsg, tmpDevice);
                                    //return false;
                                    #endregion

                                    tmpStockoutDetails = db.t_stockoutdetail.Where(m => m.rfid_no.Equals(tmpStrRFID) && m.prdct_no.Equals(tmpstockdetailForOut.prdct_no) && m.status == 2).FirstOrDefault();
                                    strremark = "RFID:" + tmpStrRFID + ",无单号,没有查到[有效的]货物出库明细记录。";
                                }
                                else
                                {
                                    tmpStockoutDetails = db.t_stockoutdetail.Where(m => m.rfid_no.Equals(tmpStrRFID) && m.receiptNo.Equals(tmpstockdetailForOut.receiptNo) && m.prdct_no.Equals(tmpstockdetailForOut.prdct_no) && m.status == 2).FirstOrDefault();
                                    strremark = "RFID:" + tmpStrRFID + ",仓单号:" + tmpstockdetailForOut.receiptNo + ",没有查到[有效的]货物出库明细记录。";
                                }
                                logger.DebugFormat("*开始出库**********#########共有{0}条记录.仓单号:{1},货物编号:{2},托盘号:{3},rfid_no:{4}", tmpcont, tmpstockdetailForOut.receiptNo, tmpstockdetailForOut.prdct_no, tmpstockdetailForOut.ctnno_no, tmpStrRFID);

                                if (tmpStockoutDetails == null)
                                {
                                    logger.DebugFormat("*error开始出库**********{0}#########没有查到[有效的]货物出库明细记录.仓单号:{1},货物编号:{2},托盘号:{3},rfid_no:{4}", tmpcont, tmpstockdetailForOut.receiptNo, tmpstockdetailForOut.prdct_no, tmpstockdetailForOut.ctnno_no, tmpStrRFID);

                                    var tmpNewAlerm = new t_alarmdata();
                                    tmpNewAlerm.recd_id = DateTime.Now.ToString("yyyyMMddHHmmss") + "D" + _tmpRandom.Next(100000).ToString() + "R" + tmpStrRFID;
                                    tmpNewAlerm.alarm_type = "Alarm_06";
                                    tmpNewAlerm.depot_no = "";
                                    tmpNewAlerm.cell_no = tmpstockdetailForOut.shelf_no;
                                    tmpNewAlerm.begin_time = DateTime.Now;
                                    tmpNewAlerm.over_time = DateTime.Now;
                                    tmpNewAlerm.remark = strremark;
                                    tmpNewAlerm.status = 1;
                                    tmpNewAlerm.param2 = tmpStrRFID;
                                    tmpNewAlerm.param4 = tmpDevice.TerminalNo;
                                    tmpNewAlerm.addtime = DateTime.Now;
                                    tmpNewAlerm.adduser = Program._serverIP;
                                    tmpNewAlerm.updtime = DateTime.Now;
                                    tmpNewAlerm.upduser = Program._serverIP;
                                    db.t_alarmdata.Add(tmpNewAlerm);
                                    var saveflag = db.SaveChanges();

                                    if (saveflag > 0)
                                    {
                                        short tmpchannle = 0;
                                        if (short.TryParse(tmpDevice.param4, out tmpchannle))
                                        {
                                            var msg3 = tmpstockdetailForOut.rfid_no + " " + tmpstockdetailForOut.shelf_no + " 无出库指示";
                                            Program.saveVideoSet(msg3, tmpchannle);
                                        }
                                        else
                                        {
                                            Program.saveLog("出库Video设置", "出库Video设置失败,没有通道号。" + tmpStrRFID, 3, 0);
                                        }
                                        logger.DebugFormat("********报警 保存完成。IP:{0},移动标记:{1},RFID:{2}.SaveFlag:{3}.", RFIDClientIP, tmpMoveFlag, tmpStrRFID, saveflag);

                                    }
                                    else
                                    {

                                        logger.DebugFormat("********报警 保存失败。IP:{0},移动标记:{1},RFID:{2}.SaveFlag:{3}", RFIDClientIP, tmpMoveFlag, tmpStrRFID, saveflag);
                                    }
                                    var tmpLedMsg = tmpStrRFID + "无出库指示.";
                                    sendTxtToLED(tmpLedMsg, tmpDevice);

                                    return false;
                                }
                                #endregion
                                #region 插入明细记录.
                                //插入明细记录.
                                var tmpExitStockDetails = db.t_stockoutctnnodetail.Find(new object[]{
                                    tmpStockoutDetails.stockout_id,
                                    tmpstockdetailForOut.prdct_no,
                                    tmpstockdetailForOut.rfid_no,
                                    tmpstockdetailForOut.ctnno_no
                                });
                                if (tmpExitStockDetails == null)
                                {
                                    var tmpNewStockDetails = new t_stockoutctnnodetail();
                                    tmpNewStockDetails.stockout_id = tmpStockoutDetails.stockout_id;

                                    tmpNewStockDetails.prdct_no = tmpstockdetailForOut.prdct_no;
                                    tmpNewStockDetails.rfid_no = tmpstockdetailForOut.rfid_no;
                                    tmpNewStockDetails.ctnno_no = tmpstockdetailForOut.ctnno_no;
                                    tmpNewStockDetails.receiptNo = tmpstockdetailForOut.receiptNo;
                                    tmpNewStockDetails.pqty = tmpstockdetailForOut.pqty;
                                    tmpNewStockDetails.qty = tmpstockdetailForOut.qty;
                                    tmpNewStockDetails.nwet = tmpstockdetailForOut.nwet;
                                    tmpNewStockDetails.gwet = tmpstockdetailForOut.gwet;
                                    tmpNewStockDetails.adduser = Program._serverIP;// "RFIDStockOut";
                                    tmpNewStockDetails.updtime = DateTime.Now;
                                    tmpNewStockDetails.upduser = Program._serverIP;
                                    tmpNewStockDetails.addtime = DateTime.Now;
                                    tmpNewStockDetails.status = 1;

                                    tmpNewStockDetails.device_id = tmpDevice.TerminalNo;

                                    db.t_stockoutctnnodetail.Add(tmpNewStockDetails);

                                    //db.SaveChanges();
                                }

                                #endregion
                                #region 更新库存
                                //更新库存
                                var tmpstock = db.t_stock.Where(m => m.prdct_no.Equals(tmpstockdetailForOut.prdct_no)).FirstOrDefault();

                                if (tmpstock != null)
                                {
                                    logger.DebugFormat("*开始出库**********#########更新库存前:箱数:{0},数量:{1},重量:{2},净重:{3}", tmpstock.pqty, tmpstock.qty, tmpstock.gwet, tmpstock.nwet);

                                    tmpstock.pqty -= tmpstockdetailForOut.pqty;
                                    tmpstock.qty -= tmpstockdetailForOut.qty;
                                    tmpstock.gwet -= tmpstockdetailForOut.gwet;
                                    tmpstock.nwet -= tmpstockdetailForOut.nwet;

                                    //if (tmpflagsave > 0)
                                    //{
                                    //    logger.DebugFormat("*开始出库*********#########Save flag:{0}.", tmpflagsave);
                                    //    logger.DebugFormat("*开始出库**********#########更新库存成功,货物编号:{0},托盘号:{1},rfid_no:{2}", tmpstockdetailForOut.prdct_no, tmpstockdetailForOut.ctnno_no, tmpStrRFID);
                                    //    logger.DebugFormat("*开始出库**********#########更新库存后:箱数:{0},数量:{1},重量:{2},净重:{3}", tmpstock.pqty, tmpstock.qty, tmpstock.gwet, tmpstock.nwet);

                                    //}
                                    //else
                                    //{
                                    //    logger.DebugFormat("*error开始出库**********#########更新库存失败,货物编号:{0},托盘号:{1},rfid_no:{2}", tmpstockdetailForOut.prdct_no, tmpstockdetailForOut.ctnno_no, tmpStrRFID);

                                    //    return false;
                                    //}
                                }
                                else
                                {
                                    logger.DebugFormat("*error开始出库**********#########没有库存,货物编号:{0},托盘号:{1},rfid_no:{2}", tmpstockdetailForOut.prdct_no, tmpstockdetailForOut.ctnno_no, tmpStrRFID);

                                    return false;
                                }

                                #endregion

                                #region 更新明细状态
                                //更新明细状态

                                string tmpUpdateSQLt_stockoutdetail = "update t_stockoutdetail set STATUS='0' WHERE STATUS='2' and rfid_no=@rfid_no";
                                string tmpUpdateSQL = "update t_stockdetail set STATUS='0' WHERE STATUS='2' and rfid_no=@rfid_no";
                                var tmpRetunCountt_stockoutdetail = db.Database.ExecuteSqlCommand(tmpUpdateSQLt_stockoutdetail, new MySqlParameter("@rfid_no", tmpStrRFID.Trim()));
                                var tmpRetunCount = db.Database.ExecuteSqlCommand(tmpUpdateSQL, new MySqlParameter("@rfid_no", tmpStrRFID.Trim()));

                                if (tmpRetunCount > 0)
                                {
                                    //logger.DebugFormat("*success出库明细**********#########t_stockdetail: 更新成功明细出库标记,共有{0}条已更新.仓单号:{1},货物编号:{2},托盘号:{3},rfid_no:{4}", tmpRetunCount, tmpstockdetailForOut.receiptNo, tmpstockdetailForOut.prdct_no, tmpstockdetailForOut.ctnno_no, tmpStrRFID);
                                    logger.DebugFormat("*success出库**********#########:更新成功,共有{0}条已更新.仓单号:{1},货物编号:{2},托盘号:{3},rfid_no:{4}", tmpRetunCount, tmpstockdetailForOut.receiptNo, tmpstockdetailForOut.prdct_no, tmpstockdetailForOut.ctnno_no, tmpStrRFID);

                                    var tmpflagsave = db.SaveChanges();

                                    var tmpLedMsg = "仓单" + tmpstockdetailForOut.receiptNo + "托盘" + tmpstockdetailForOut.ctnno_no;//shelf_no;

                                    sendTxtToLED(tmpLedMsg, tmpDevice);

                                    short tmpchannle = 0;
                                    if (short.TryParse(tmpDevice.param4, out tmpchannle))
                                    {
                                        var msg2 = tmpStockoutDetails.cash_no + " " + tmpStockoutDetails.rfid_no + " " + tmpStockoutDetails.prdct_no + " 出库";
                                        Program.saveVideoSet(msg2, tmpchannle);
                                    }
                                    else
                                    {
                                        Program.saveLog("出库Video设置", "出库Video设置失败,没有通道号。" + tmpStrRFID, 3, 0);
                                    }

                                    Program.saveLog("出库", "2出库:" + tmpStrRFID, 1, 1);

                                    return true;
                                }

                                logger.DebugFormat("*error开始出库*失败,系统错误,请联系管理员**************************************************************", tmpStrRFID);
                                Program.saveLog("出库", "2出库:" + tmpStrRFID, 1, 0);
                                return false;

                                #endregion
                            }

                            logger.DebugFormat("*error开始出库*失败,未查到[可出库/有效的]库存明细表记录,RFID:{0}**************************************************************", tmpStrRFID);
                            return false;
                        }
                        break;
                        #endregion
                    case "1":
                        var tmpShelf = "没找到对应仓位号。";
                        var tmpStockDetail = new t_stockdetail();
                        #region 报警
                        using (var db = new MysqlDbContext())
                        {
                            tmpStockDetail = db.t_stockdetail.Where(m => m.rfid_no.Equals(tmpStrRFID) && m.status == 1).FirstOrDefault();
                            if (tmpStockDetail != null)
                            {
                                if (tmpMoveFlag.Equals("1"))
                                {
                                    tmpShelf = tmpStockDetail.shelf_no;

                                    var tmpNewAlerm = new t_alarmdata();
                                    tmpNewAlerm.recd_id = DateTime.Now.ToString("yyyyMMddHHmmss") + "D" + _tmpRandom.Next(100000).ToString() + "R" + tmpStrRFID;
                                    tmpNewAlerm.alarm_type = "Alarm_04";
                                    tmpNewAlerm.depot_no = "";
                                    tmpNewAlerm.cell_no = tmpShelf;// tmpStrRFID + "," + tmpShelf;
                                    tmpNewAlerm.begin_time = DateTime.Now;
                                    tmpNewAlerm.over_time = DateTime.Now;
                                    tmpNewAlerm.param1 = tmpStrRFID;
                                    tmpNewAlerm.param4 = tmpDevice.TerminalNo;
                                    tmpNewAlerm.remark = "RFID:" + tmpStrRFID + ",移动了.仓位号:" + tmpShelf;
                                    tmpNewAlerm.status = 1;
                                    tmpNewAlerm.addtime = DateTime.Now;
                                    tmpNewAlerm.adduser = Program._serverIP;
                                    tmpNewAlerm.updtime = DateTime.Now;
                                    tmpNewAlerm.upduser = Program._serverIP;
                                    db.t_alarmdata.Add(tmpNewAlerm);
                                    var saveflag = db.SaveChanges();

                                    if (saveflag > 0)
                                    {
                                        short tmpchannle = 0;
                                        if (short.TryParse(tmpDevice.param4, out tmpchannle))
                                        {
                                            Program.saveVideoSet(tmpStrRFID + " 移动报警", tmpchannle);
                                        }
                                        else
                                        {
                                            Program.saveLog("移动报警Video设置", "移动报警Video设置失败,没有通道号。" + tmpStrRFID, 3, 0);
                                        }

                                        Program.saveLog("移动报警", "2移动报警:" + tmpStrRFID, 3, 1);
                                        logger.DebugFormat("********报警 保存完成。IP:{0},移动标记:{1},RFID:{2}.SaveFlag:{3},仓位号:{4}.", RFIDClientIP, tmpMoveFlag, tmpStrRFID, saveflag, tmpShelf);

                                    }
                                    else
                                    {
                                        Program.saveLog("移动报警", "2移动报警:" + tmpStrRFID, 3, 1);
                                        logger.DebugFormat("********报警 保存失败。IP:{0},移动标记:{1},RFID:{2}.SaveFlag:{3},仓位号:{4}", RFIDClientIP, tmpMoveFlag, tmpStrRFID, saveflag, tmpShelf);
                                    }

                                }
                            }
                            else
                            {
                                logger.DebugFormat("********报警 IP:{0},移动标记:{1},RFID:{2} 不存在有效库存记录.}.", RFIDClientIP, tmpMoveFlag, tmpStrRFID);
                                return false;
                            }
                        }
                        #endregion
                        break;
                    default:
                        break;
                }

                return false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("{0}:{1},flag:{2},rfid_no:{3}", 481, ex, sysType, tmpStrRFID);
                throw ex;
                return false;
            }
        }
コード例 #2
0
ファイル: AutoGetJob.cs プロジェクト: xlgwr/SocketRFIDService
        public void Execute(IJobExecutionContext context)
        {
            logger.DebugFormat("*********开始运行 手动点检 job:{0}.下次job时间:{1}.", context.JobDetail.Key, context.NextFireTimeUtc);

            try
            {
                using (var db = new MysqlDbContext())
                {
                    //var tmpcont = db.m_users.Count();
                    //logger.DebugFormat("********************{0} 个用户.",tmpcont);
                    var m1odelchecktime1 = db.m_parameter.Where(m => m.paramkey.Equals("SetCheck") && m.paramtype == 1).FirstOrDefault();
                    if (m1odelchecktime1 != null)
                    {
                        logger.DebugFormat("*************开始手动点检,点检时间:{0}。***************", m1odelchecktime1.paramvalue);

                        //check add today
                        #region check add today

                        var sqlExit = "select count(*) from t_checkresult a where DATE_FORMAT(a.addtime,'%Y%m%d')=DATE_FORMAT(now(),'%Y%m%d') and a.check_date='" + m1odelchecktime1.paramvalue + "'";
                        var tmpExit = db.Database.SqlQuery<int>(sqlExit).FirstOrDefault();

                        if (tmpExit > 0)
                        {
                            logger.DebugFormat("*************系统已经手动点检过1,点检时间:{0}。***************", m1odelchecktime1.paramvalue);
                            Program._checkAutoRfid.Clear();
                            Program._checkAutoCount = 1;
                            m1odelchecktime1.paramtype = 0;
                            var saveflag2 = db.SaveChanges();
                            if (saveflag2 > 0)
                            {
                                Program.saveLog("手动点检", "2系统已经手动点检过:" + m1odelchecktime1.paramvalue, 3, 1);

                                logger.DebugFormat("********手动点检标记 更新完成。{0}.", m1odelchecktime1.paramvalue);

                            }
                            else
                            {
                                Program.saveLog("手动点检", "2系统已经手动点检过:" + m1odelchecktime1.paramvalue, 3, 0);

                                logger.DebugFormat("********手动点检标记 更新失败。{0}.", m1odelchecktime1.paramvalue);
                            }
                            return;
                        }
                        #endregion

                        switch (Program._checkCount)
                        {
                            case 0:
                                Program._checkCurrRfid.Clear();
                                Program._checkCount = 1;
                                break;
                            case 1:
                                #region save checklog
                                var m2odelofStockDetails2 = db.t_stockdetail.Where(m => m.status == 1).ToList();
                                if (m2odelofStockDetails2.Count > 0)
                                {
                                    var tmpGuidId = DateTime.Now.ToString("yyyyMMddHHmmss") + "D" + Program._tmpRandom.Next(100000).ToString(); //Guid.NewGuid().ToString();
                                    //主
                                    var tmpNewt_checkresult = new t_checkresult();
                                    tmpNewt_checkresult.bespeak_no = "";

                                    tmpNewt_checkresult.check_id = tmpGuidId;
                                    tmpNewt_checkresult.check_date = m1odelchecktime1.paramvalue;
                                    tmpNewt_checkresult.user_no = "";// Program._serverIP; //"";//点检
                                    tmpNewt_checkresult.user_nm = "";//tmpStrRFID;
                                    tmpNewt_checkresult.status = 1; //1表示正常点检  0表示报警点检
                                    tmpNewt_checkresult.checktype = 0;//1表示手动点检  0手动点检

                                    tmpNewt_checkresult.remark = "";// "手动点检:" + m1odelchecktime1.paramvalue + ",收到 RFID:" + item.rfid_no;

                                    tmpNewt_checkresult.addtime = DateTime.Now;
                                    tmpNewt_checkresult.adduser = Program._serverIP;
                                    tmpNewt_checkresult.updtime = DateTime.Now;
                                    tmpNewt_checkresult.upduser = Program._serverIP;

                                    db.t_checkresult.Add(tmpNewt_checkresult);
                                    foreach (var item in m2odelofStockDetails2)
                                    {
                                        var tmpNewt_checkdetailresult = new t_checkdetailresult();

                                        #region 明细表
                                        //明细表
                                        tmpNewt_checkdetailresult.check_id = tmpGuidId;
                                        tmpNewt_checkdetailresult.out_item_no = "1";
                                        tmpNewt_checkdetailresult.rfid_no = item.rfid_no;

                                        tmpNewt_checkdetailresult.prdct_no = item.prdct_no;
                                        tmpNewt_checkdetailresult.receiptNo = item.receiptNo;
                                        tmpNewt_checkdetailresult.qty = item.qty;
                                        tmpNewt_checkdetailresult.nwet = item.nwet;
                                        tmpNewt_checkdetailresult.gwet = item.gwet;

                                        tmpNewt_checkdetailresult.cell_no = item.shelf_no;
                                        tmpNewt_checkdetailresult.remark = "";// "手动点检:" + m1odelchecktime1.paramvalue + ",收到 RFID:" + item.rfid_no;

                                        tmpNewt_checkdetailresult.addtime = DateTime.Now;
                                        tmpNewt_checkdetailresult.adduser = Program._serverIP;//Program._serverIP;
                                        tmpNewt_checkdetailresult.updtime = DateTime.Now;
                                        tmpNewt_checkdetailresult.upduser = Program._serverIP;

                                        #endregion
                                        if (Program._checkCurrRfid.Keys.Contains(item.rfid_no))
                                        {

                                            tmpNewt_checkdetailresult.status = 0;//0:正常,1:点检报警,2:补点
                                            db.t_checkdetailresult.Add(tmpNewt_checkdetailresult);

                                        }
                                        else
                                        {
                                            //点检报警
                                            #region 明细表

                                            tmpNewt_checkdetailresult.status = 1;//0:正常,1:点检报警,2:补点
                                            db.t_checkdetailresult.Add(tmpNewt_checkdetailresult);
                                            #endregion

                                            #region 报警
                                            //报警
                                            var tmpNewAlerm = new t_alarmdata();
                                            tmpNewAlerm.recd_id = tmpGuidId + "R" + item.rfid_no;
                                            tmpNewAlerm.alarm_type = "Alarm_05";
                                            tmpNewAlerm.depot_no = "";// _tmpPreCheckTime;
                                            tmpNewAlerm.cell_no = item.shelf_no;//tmpRfidShelf;
                                            tmpNewAlerm.begin_time = DateTime.Now;
                                            tmpNewAlerm.over_time = DateTime.Now;
                                            tmpNewAlerm.param1 = m1odelchecktime1.paramvalue;
                                            tmpNewAlerm.param2 = item.rfid_no;
                                            tmpNewAlerm.remark = "";//"手动点检报警:RFID:" + item.rfid_no + ",仓位号:" + item.shelf_no + ",没有点检到。点检时间:" + m1odelchecktime1.paramvalue;
                                            tmpNewAlerm.status = 1;
                                            tmpNewAlerm.addtime = DateTime.Now;
                                            tmpNewAlerm.adduser = Program._serverIP;
                                            tmpNewAlerm.updtime = DateTime.Now;
                                            tmpNewAlerm.upduser = Program._serverIP;
                                            db.t_alarmdata.Add(tmpNewAlerm);

                                            Program.saveLog("手动点检报警", "2手动点检报警:" + m1odelchecktime1.paramvalue, 3, 1);
                                            logger.DebugFormat("********手动点检报警 保存完成。RFID:{0}.仓位号:{1}.", item.rfid_no, item.shelf_no);

                                            #endregion

                                        }
                                    }
                                    //change flag;
                                    m1odelchecktime1.paramtype = 0;
                                    var saveflag2 = db.SaveChanges();
                                    if (saveflag2 > 0)
                                    {
                                        Program.saveLog("手动点检", "2手动点检标记更新:" + m1odelchecktime1.paramvalue, 3, 1);

                                        logger.DebugFormat("********手动点检标记 更新完成。{0}.", m1odelchecktime1.paramvalue);

                                    }
                                    else
                                    {
                                        Program.saveLog("手动点检", "2手动点检标记更新:" + m1odelchecktime1.paramvalue, 3, 0);

                                        logger.DebugFormat("********手动点检标记 更新失败。{0}.", m1odelchecktime1.paramvalue);
                                    }
                                }
                                #endregion
                                //end
                                Program._checkCurrRfid.Clear();
                                Program._checkCount = 0;
                                break;
                            default:
                                break;
                        }

                    }
                    else
                    {
                        Program._checkCurrRfid.Clear();
                        Program._checkCount = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("######运行出错误:{0}", ex);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: xlgwr/SocketRFIDService
        public static void testDB()
        {
            try
            {
                using (var db = new MysqlDbContext())
                {
                    //var tmpNewt_checkresult = new t_checkresult();
                    //var tmpNewt_checkdetailresult = new t_checkdetailresult();

                    //var tmpGuidId = Guid.NewGuid().ToString();
                    //#region 主表
                    //tmpNewt_checkresult.check_id = tmpGuidId;
                    //tmpNewt_checkresult.check_date = DateTime.Now;
                    //tmpNewt_checkresult.bespeak_no = "RFID";
                    //tmpNewt_checkresult.bespeak_date = "8:00:00";
                    //tmpNewt_checkresult.user_no = "点检";
                    //tmpNewt_checkresult.user_nm = "点检";
                    //tmpNewt_checkresult.status = 1;
                    //tmpNewt_checkresult.remark = "点检";

                    //tmpNewt_checkresult.addtime = DateTime.Now;
                    //tmpNewt_checkresult.adduser = "******";
                    //tmpNewt_checkresult.updtime = DateTime.Now;
                    //tmpNewt_checkresult.upduser = "******";

                    //db.t_checkresult.Add(tmpNewt_checkresult);
                    //var saveflag2 = db.SaveChanges();
                    //#endregion

                    var tmpLog = new t_syslogrecd();
                    //tmpLog.log_id = new Random(10000).Next(1000000);
                    tmpLog.operatorid = "SocketRFID";
                    tmpLog.message = "RFID采集";
                    tmpLog.type = 1;
                    tmpLog.result = 1;
                    tmpLog.mod_id = "StocketRFID";
                    tmpLog.adduser = "******";
                    tmpLog.addtime = DateTime.Now;
                    tmpLog.org_no = "dd";
                    db.t_syslogrecd.Add(tmpLog);
                    var saveflag2 = db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: xlgwr/SocketRFIDService
        /// <summary>
        /// 保存日记
        /// </summary>
        /// <param name="message">RFID</param>
        /// <param name="mod_id">操作名称</param>
        /// <param name="types">0:入库、1:出库、2:上架、3:基本信息)</param>
        /// <param name="result">0/1</param>
        public static void saveLog(string mod_id, string message, short types, short result)
        {
            try
            {
                //init mysql db
                using (var db = new MysqlDbContext())
                {

                    var tmpLog = new t_syslogrecd();
                    var guid = Guid.NewGuid();
                    var rand = new Random();
                    tmpLog.log_id = DateTime.Now.ToString("yyyyMMddHHmmss") + "R" + rand.Next(100000).ToString();

                    tmpLog.operatorid = "SocketRFID";
                    tmpLog.message = message;// "RFID采集";
                    tmpLog.type = types;
                    tmpLog.result = result;
                    tmpLog.mod_id = mod_id;//"StocketRFID";
                    tmpLog.adduser = _serverIP;
                    tmpLog.addtime = DateTime.Now;
                    tmpLog.org_no = "SocketRFID";
                    db.t_syslogrecd.Add(tmpLog);

                    db.SaveChanges();

                    logger.DebugFormat("*******SAVE LOG******");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: xlgwr/SocketRFIDService
        public static void saveVideoSet(string message, short channel)
        {
            try
            {
                //init mysql db
                using (var db = new MysqlDbContext())
                {

                    var tmpt_videodata = new t_videodata();
                    var guid = Guid.NewGuid();
                    var rand = new Random();
                    tmpt_videodata.video_no = DateTime.Now.ToString("yyyyMMddHHmmss") + "R" + rand.Next(100000).ToString();

                    tmpt_videodata.message = message;
                    tmpt_videodata.font_size = 20;
                    tmpt_videodata.font_type = 20;
                    tmpt_videodata.site = 0;
                    tmpt_videodata.Channel = channel;
                    tmpt_videodata.adduser = _serverIP;
                    tmpt_videodata.addtime = DateTime.Now;
                    tmpt_videodata.Version = "V1";
                    tmpt_videodata.status = 0;
                    tmpt_videodata.remark = "";
                    db.t_videodata.Add(tmpt_videodata);

                    db.SaveChanges();

                    logger.DebugFormat("*******SAVE Video Set******");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }