Exemplo n.º 1
0
 public void UpdateWlgzCmdOutPort(yw_hddz_wlgz_cmdEntity model)
 {
     using (conn = ConnectionFactory.CreateConnection())
     {
         if (conn.State == ConnectionState.Closed)
         {
             conn.Open();
         }
         StringBuilder sql = new StringBuilder();
         sql.Append("update yw_hddz_wlgz_cmd set ");
         sql.Append(" cdzwlsj_bd  =@cdzwlsj ");
         sql.Append(" where rwbh=@rwbh and wlxh=@wlxh");
         conn.Execute(sql.ToString(), model);
     }
 }
Exemplo n.º 2
0
        public void UpdateInOrOutFence(HttpContext context)
        {
            try
            {
                string json = context.Request.Params["json"];
                writeLog(json, "fence");
                authorityCheck(context);
                TaskRequest        param = JsonConvert.DeserializeObject <TaskRequest>(json);
                yw_hddz_wlgzEntity wlgz  = new Interfaces.Service.FenceService().getWlgzByDzwlbh(param.taskNo);
                Interfaces.Service.FenceService fserv = new Interfaces.Service.FenceService();

                bool isUpdate = true;//是否需要更新
                try
                {
                    if (wlgz == null)
                    {
                        throw new Exception("没找到编号为" + param.taskNo + "的任务");
                    }

                    List <yw_hddz_wlgz_cmdEntity> list = new Interfaces.Service.FenceService().getWlgzcmdByRwbh(wlgz.rwbh);
                    foreach (var m in list)
                    {
                        if (m.wlxh == param.no)
                        {
                            if (param.listenStatus == "0")
                            {
                                if (m.jrdzwlsj != null)
                                {
                                    throw new Exception(m.rwbh + "已经有进入电子围栏时间");
                                }
                                else if (m.wlxh == 1 && m.rwlx != "1" && m.rwmc != "港区")
                                {
                                    throw new Exception("非港区的第一个任务不反写进时间");
                                }
                            }
                            if (param.listenStatus == "1")
                            {
                                if (m.rwmc == "港区")// 出港区时间 单独出来
                                {
                                    m.cdzwlsj = Convert.ToDateTime(param.crttime);
                                    fserv.UpdateWlgzCmdOutPort(m);
                                    throw new Exception(m.rwbh + "出港区时间需要单独处理");
                                }
                                else if (m.cdzwlsj != null)
                                {
                                    throw new Exception(m.rwbh + "已经有出电子围栏时间");
                                }
                            }
                            //出港区时间先不更新 2018年8月14日20:27:59
                            //if (param.listenStatus == "1" && m.rwmc == "港区")
                            //{
                            //    throw new Exception("出港区时间先不更新");
                            //}
                        }
                        else if (m.wlxh > param.no)
                        {
                            if (m.jrdzwlsj != null || m.cdzwlsj != null)
                            {
                                throw new Exception("后续节点已经有围栏出入时间,不能再写入时间");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    isUpdate = false;
                    writeLog("UpdateInOrOutFence出现异常:" + ex.Message);
                }


                if (isUpdate)
                {
                    yw_hddz_wlgz_cmdEntity cmd = new yw_hddz_wlgz_cmdEntity();
                    cmd.rwbh     = wlgz.rwbh;
                    cmd.wlxh     = param.no;
                    cmd.ywbh     = wlgz.ywbh;
                    cmd.hddz_cxh = int.Parse(wlgz.hddz_cxh);
                    if (param.listenStatus == "0")
                    {
                        cmd.jrdzwlsj     = Convert.ToDateTime(param.crttime);
                        cmd.jdzwlsj_lrsj = DateTime.Now;
                    }
                    else
                    {
                        cmd.cdzwlsj      = Convert.ToDateTime(param.crttime);
                        cmd.cdzwlsj_lrsj = DateTime.Now;
                    }
                    fserv.UpdateWlgzCmd(cmd);

                    res.result = true;
                }
                else// 不需要更新时 把result设为true
                {
                    res.result = true;
                }
            }
            catch (Exception ex)
            {
                res.result = false;
                res.msg    = ex.Message;
                writeLog("UpdateInOrOutFence出现异常:" + ex.Message);
            }
        }
Exemplo n.º 3
0
        public void UpdateWlgzCmd(yw_hddz_wlgz_cmdEntity model)
        {
            using (conn = ConnectionFactory.CreateConnection())
            {
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                StringBuilder sql = new StringBuilder();
                sql.Append("update yw_hddz_wlgz_cmd set ");
                string strWhere = "";
                if (model.jrdzwlsj != null)
                {
                    sql.Append("jrdzwlsj =@jrdzwlsj,jdzwlsj_lrsj=@jdzwlsj_lrsj,jdzwlsj_czry='北斗' ");
                    strWhere = " and jrdzwlsj is null";
                }
                else if (model.cdzwlsj != null)
                {
                    sql.Append("cdzwlsj =@cdzwlsj,cdzwlsj_lrsj=@cdzwlsj_lrsj,cdzwlsj_czry='北斗' ");
                    strWhere = " and cdzwlsj is null";
                }
                else
                {
                    throw new Exception("进出电子围栏时间必须有一个不能为空");
                }
                sql.Append(" where rwbh=@rwbh and wlxh=@wlxh");
                sql.Append(strWhere);
                conn.Execute(sql.ToString(), model);

                conn.Execute("p_hywlgz", new { ywbh = model.ywbh, cxh = model.hddz_cxh }, null, null, CommandType.StoredProcedure);
                s_log_errEntity log = new s_log_errEntity();
                log.eid        = "dzwl_" + Guid.NewGuid().ToString();
                log.cjsj       = DateTime.Now;
                log.cscs       = 0;
                log.funname    = "DataToFreshPort";
                log.mainid     = model.ywbh;
                log.parameters = model.hddz_cxh.ToString();
                log.changecols = "gq_sj,gq_cp,gq_sjlxfs,gq_rwbh,gq_c_rwbh,hgcyd_sj,hgcyd_cp,hgcyd_sjlxfs,hgcyd_rwbh,hgcyd_c_rwbh,jyd_sj,jyd_cp,jyd_sjlxfs,jyd_rwbh,jyd_c_rwbh,"
                                 + "sc_sj,sc_cp,sc_sjlxfs,sc_rwbh,sc_c_rwbh,zjfscwld_sj,zjfscwld_cp,zjfscwld_sjlxfs,zjfscwld_rwbh,zjfscwld_c_rwbh,jschfscwld_sj,jschfscwld_cp,"
                                 + "jschfscwld_sjlxfs,jschfscwld_rwbh,jschfscwld_c_rwbh,fscwld3_sj,fscwld3_cp,fscwld3_sjlxfs,fscwld3_rwbh,fscwld3_c_rwbh,fscwld4_sj,fscwld4_cp,"
                                 + "fscwld4_sjlxfs,fscwld4_rwbh,fscwld4_c_rwbh,dc_sj,dc_cp,dc_sjlxfs,dc_rwbh,cgqsj,rscsj,djydsj,tgjysj,cscsj,hdcsj,fscwl_ddsj,fscwl_lksj,fscwl2_ddsj,"
                                 + "fscwl2_lksj,fscwl3_ddsj,fscwl3_lksj,fscwl4_ddsj,fscwl4_lksj";
                log.sfcg      = 0;
                log.tablename = "yw_hddz_jzxxx";

                s_log_errEntity log1 = new s_log_errEntity();
                log1.eid        = "dzwl_" + Guid.NewGuid().ToString();
                log1.cjsj       = DateTime.Now;
                log1.cscs       = 0;
                log1.funname    = "DataToFreshPort";
                log1.mainid     = model.ywbh;
                log1.parameters = model.hddz_cxh.ToString();
                log1.changecols = "";
                log1.sfcg       = 0;
                log1.tablename  = "yw_hddz_wlgz";
                List <s_log_errEntity> list = new List <s_log_errEntity>();
                list.Add(log);
                list.Add(log1);
                string logsql = SqlFactory.GetInsertSql(log);
                conn.Execute(logsql, list);
            }
        }