Example #1
0
        public override string Deal()
        {
            StringBuilder msg = new StringBuilder();

            try
            {
                jobBLL bll = new jobBLL();

                //读取待同步数据
                using (DataSet ds = bll.GetOcrDBCnt(MaxId))
                {
                    //查桥吊作业配置
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        QcSet.T_OCR_QCSETDataTable qc = bll.SelectQCSet();

                        //逐条写入二次开发数据库
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            try
                            {
                                MaxId = Convert.ToInt32(dr["dock_id"]);

                                bool flag = false;
                                dr["isarchived"] = "N";
                                foreach (QcSet.T_OCR_QCSETRow row in qc)
                                {
                                    if (row.TRVALCRANE_NO == dr["trval_no"].ToString() && row.STATUS == "作业中")
                                    {
                                        int dock_status = Convert.ToInt32(dr["dock_status"]);
                                        dr["driver_no"]  = row.DRIVER_ID;
                                        dr["ship_code"]  = row.SHIP_CODE;
                                        dr["c_voyage"]   = dock_status == 0 ? row.OUT_VOYAGE_CODE : row.IN_VOYAGE_CODE;
                                        dr["COMMEND_ID"] = row.COMMEND_ID;
                                        dr["BERTH_NUM"]  = row.BERTH_NUM;
                                        dr["ENAM"]       = row.VESSELALIASE;
                                        //dr["Cstatus"] = dock_status == 0 && row.SHIPMENT_DEAL == "关" ? Convert.ToInt32(Config.CStatus.LoadWaitAuto) : Convert.ToInt32(Config.CStatus.WaitHandle);
                                        //2017-9-29 叶君腾 增加卸船自动确认
                                        dr["Cstatus"]     = row.SHIPMENT_DEAL == "关" ? Convert.ToInt32(Config.CStatus.LoadWaitAuto) : Convert.ToInt32(Config.CStatus.WaitHandle);
                                        dr["SERVICECODE"] = dock_status == 0 ? row.OUTVESSELLINECODE : row.INVESSELLINECODE;


                                        if (row.WORKTYPE == "外理" || row.WORKTYPE == "现场" || row.WORKTYPE == "核封")
                                        {
                                            //外理作业模式
                                            dr["Cstatus"] = Convert.ToInt32(Config.CStatus.ExOnly);
                                        }

                                        flag = true;
                                        break;
                                    }
                                }

                                if (!flag)
                                {
                                    dr["Cstatus"]    = Convert.ToInt32(Config.CStatus.NoQcSet);
                                    dr["isarchived"] = "A";
                                    AddResult(string.Format("箱{0} {1}", dr["trval_no"].ToString(), "桥吊作业配置异常"));
                                }

                                bll.InsertCnt(dr);

                                AddResult(string.Format("箱{0} {1} {2}", dr["dock_id"].ToString(), dr["container_no"].ToString(), dr["trval_no"].ToString()));
                            }
                            catch (Exception ex)
                            {
                                AddResult(string.Format("箱{0} {1}", dr["dock_id"].ToString(), ex.Message));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AddResult(string.Format("箱 {0}", ex.Message));
            }

            return(msg.ToString());
        }
Example #2
0
        /// <summary>
        /// 第一种情况 内理不作业,外理作业 SCT港区
        /// </summary>
        public string DealExOnlySCT()
        {
            StringBuilder sb = new StringBuilder();
            int           i  = 0;

            jobBLL bll = new jobBLL();

            //查找待分发的识别记录
            //如果有箱号,调CTOS接口,找出对应的船名航次
            //如果无箱号,或者箱号无效,根据QC设置表的船对应的船东分发

            using (OCR.Model.OcrCnt.T_OCR_CNTDataTable data = cctdbDAL.SelectDispatch())
            {
                using (DataSet1.T_OCRX_VESSELDataTable rules = cctdbDAL.SelectVessel())
                {
                    foreach (OCR.Model.OcrCnt.T_OCR_CNTRow row in data)
                    {
                        try
                        {
                            QcSet.T_OCR_QCSETRow qc = bll.SelectQCSet(row.TRVAL_NO);
                            if (row.CONTAINER_NO == "未识别" && string.IsNullOrEmpty(row.RCONTAINER_NO))
                            {
                                //该模式分班轮和驳船
                                if (row.IsENAMNull() || string.IsNullOrEmpty(row.ENAM) || row.ENAM.StartsWith("8"))
                                {
                                    //找到船名航次,分发给外理
                                    row.ENAM = qc.VESSELALIASE;
                                    //查对应的驳船公司
                                    OCRX.Model.DataSet1.T_OCRX_BARGERow bg = cctdbDAL.SelectBargeByVelaliase(row.ENAM);
                                    if (row.SERVICECODE == "DOM")
                                    {
                                        row.ISARCHIVED = "Y";
                                    }
                                    else if (bg != null)
                                    {
                                        row.COMPANYCODE = bg.COMPANYCODE;
                                        row.SHIP_CODE   = qc.SHIP_CODE;
                                        row.C_VOYAGE    = row.DOCK_STATUS == 0 ? qc.OUT_VOYAGE_CODE : qc.IN_VOYAGE_CODE;

                                        //row.LINECODE = cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["CONTAINEROWNER"].ToString();
                                        row.ISARCHIVED = "Y";
                                        //row.OPERATORNAME = Config.SysUser;
                                        row.CONTAINERID = 0;
                                        bll.UpdateCntStatus(row);

                                        DataSet1.T_OCRX_CNTRow newRow = CopyRow(row);
                                        //插入新分发记录
                                        cctdbDAL.InsertCntx(newRow);
                                        //更新分发状态
                                        cctdbDAL.UpdateDispatched(row.DOCK_ID, string.Empty, row.COMPANYCODE);

                                        continue;
                                    }
                                    else
                                    {
                                        //无外理认领,归档
                                        row.ISARCHIVED = "Y";
                                    }
                                }
                                else
                                {
                                    //班轮 是否有箱主,无则等待
                                    string lineCode = qc.OWNER;
                                    if (String.IsNullOrEmpty(lineCode))
                                    {
                                        //row.CSTATUS = Convert.ToDecimal(Config.CStatus.WaitHandle);//转人工
                                        row.ISARCHIVED = "N";
                                    }
                                    else
                                    {
                                        //查找匹配外理
                                        string companyCode = GetCompanyCode(row.SERVICECODE, lineCode, rules);
                                        if (!string.IsNullOrEmpty(companyCode))
                                        {
                                            DataSet1.T_OCRX_CNTRow newRow = CopyRow(row);
                                            newRow.COMPANYCODE = companyCode;

                                            //插入新分发记录
                                            cctdbDAL.InsertCntx(newRow);
                                            //更新分发状态
                                            cctdbDAL.UpdateDispatched(row.DOCK_ID, row.LINECODE, companyCode);
                                            i++;
                                            continue;
                                            //sb.AppendLine(string.Format("数据分发 {0} {1}", row.TRVAL_NO, newRow.CONTAINER_NO));
                                        }
                                        else
                                        {
                                            //无外理认领,归档
                                            row.ISARCHIVED = "Y";
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //查箱信息
                                CtosResult cntInfo = CtosAPIBLL.CM005001(string.IsNullOrEmpty(row.RCONTAINER_NO) ? row.CONTAINER_NO : row.RCONTAINER_NO, qc.TICKET_ID);
                                if (cntInfo.ERRORCODE != CtosAPIBLL.SUCCESSCODE || cntInfo.DS.Tables[0].Rows.Count == 0)
                                {
                                    //班轮 是否有箱主,无则等待
                                    string lineCode = qc.OWNER;
                                    //查找匹配外理
                                    string companyCode = GetCompanyCode(row.SERVICECODE, lineCode, rules);
                                    row.LINECODE = lineCode;
                                    if (!string.IsNullOrEmpty(companyCode))
                                    {
                                        DataSet1.T_OCRX_CNTRow newRow = CopyRow(row);
                                        newRow.COMPANYCODE = companyCode;

                                        //插入新分发记录
                                        cctdbDAL.InsertCntx(newRow);
                                        //更新分发状态
                                        cctdbDAL.UpdateDispatched(row.DOCK_ID, row.LINECODE, companyCode);
                                        i++;
                                        continue;
                                        //sb.AppendLine(string.Format("数据分发 {0} {1}", row.TRVAL_NO, newRow.CONTAINER_NO));
                                    }
                                    else
                                    {
                                        //无外理认领,归档
                                        row.ISARCHIVED = "Y";
                                    }
                                }
                                else
                                {
                                    //该模式分班轮和驳船
                                    if (row.IsENAMNull() || string.IsNullOrEmpty(row.ENAM) || row.ENAM.StartsWith("8"))
                                    {
                                        //找到船名航次,分发给外理
                                        row.ENAM = row.DOCK_STATUS == 0 ? cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["OUTVELALIASE"].ToString() : cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["INVELALIASE"].ToString();
                                        //查对应的驳船公司
                                        OCRX.Model.DataSet1.T_OCRX_BARGERow bg = cctdbDAL.SelectBargeByVelaliase(row.ENAM);
                                        if (row.SERVICECODE == "DOM")
                                        {
                                            row.ISARCHIVED = "Y";
                                        }
                                        else if (bg != null)
                                        {
                                            row.COMPANYCODE = bg.COMPANYCODE;
                                            row.SHIP_CODE   = row.DOCK_STATUS == 0 ? cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["OUTEVESSELNAME"].ToString() : cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["INEVESSELNAME"].ToString();
                                            row.C_VOYAGE    = row.DOCK_STATUS == 0 ? cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["OUTBOUNDVOY"].ToString() : cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["INBOUNDVOY"].ToString();

                                            row.LINECODE   = cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["CONTAINEROWNER"].ToString();
                                            row.ISARCHIVED = "Y";
                                            //row.OPERATORNAME = Config.SysUser;
                                            row.CONTAINERID = 0;
                                            bll.UpdateCntStatus(row);

                                            DataSet1.T_OCRX_CNTRow newRow = CopyRow(row);
                                            //插入新分发记录
                                            cctdbDAL.InsertCntx(newRow);
                                            //更新分发状态
                                            cctdbDAL.UpdateDispatched(row.DOCK_ID, string.Empty, row.COMPANYCODE);

                                            continue;
                                        }
                                        else
                                        {
                                            //无外理认领,归档
                                            row.ISARCHIVED = "Y";
                                        }
                                    }
                                    else
                                    {
                                        //班轮 是否有箱主,无则等待
                                        string lineCode = cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["CONTAINEROWNER"].ToString();
                                        if (String.IsNullOrEmpty(lineCode))
                                        {
                                            //row.CSTATUS = Convert.ToDecimal(Config.CStatus.WaitHandle);//转人工
                                            //row.ISARCHIVED = "N";
                                            lineCode = qc.OWNER;
                                        }
                                        //else
                                        //{

                                        //查找匹配外理
                                        string companyCode = GetCompanyCode(row.SERVICECODE, lineCode, rules);
                                        row.LINECODE = lineCode;
                                        if (!string.IsNullOrEmpty(companyCode))
                                        {
                                            DataSet1.T_OCRX_CNTRow newRow = CopyRow(row);
                                            newRow.COMPANYCODE = companyCode;

                                            //插入新分发记录
                                            cctdbDAL.InsertCntx(newRow);
                                            //更新分发状态
                                            cctdbDAL.UpdateDispatched(row.DOCK_ID, row.LINECODE, companyCode);
                                            i++;
                                            continue;
                                            //sb.AppendLine(string.Format("数据分发 {0} {1}", row.TRVAL_NO, newRow.CONTAINER_NO));
                                        }
                                        else
                                        {
                                            //无外理认领,归档
                                            row.ISARCHIVED = "Y";
                                        }
                                        //}
                                    }
                                }
                            }

                            row.CONTAINERID = 0;
                            bll.UpdateCntStatus(row);

                            //DataSet1.T_OCRX_CNTRow newRow = CopyRow(row);
                            ////newRow.COMPANYCODE = companyCode;

                            ////插入新分发记录
                            //cctdbDAL.InsertCntx(newRow);
                            ////更新分发状态
                            //cctdbDAL.UpdateDispatched(row.DOCK_ID, string.Empty, row.COMPANYCODE);
                            //i++;
                            //sb.AppendLine(string.Format("数据分发 {0} {1}", row.TRVAL_NO, newRow.CONTAINER_NO));
                        }
                        catch (Exception ex) { sb.Append(ex.StackTrace); }
                    }
                }
            }

            if (i > 0)
            {
                sb.AppendFormat("数据分发 {0}条记录", i);
            }
            return(sb.ToString());
        }
Example #3
0
        public override string Deal()
        {
            StringBuilder msg = new StringBuilder();

            try
            {
                jobBLL bll = new jobBLL();

                //读取待同步数据
                using (DataSet ds = bll.GetOcrDBCnt(MaxId))
                {
                    //查桥吊作业配置
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        QcSet.T_OCR_QCSETDataTable qc = bll.SelectQCSet();

                        //逐条写入二次开发数据库
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            try
                            {
                                MaxId = Convert.ToInt64(dr["dock_id"]);

                                bool flag = false;
                                dr["isarchived"] = "N";
                                foreach (QcSet.T_OCR_QCSETRow row in qc)
                                {
                                    if (row.TRVALCRANE_NO == dr["trval_no"].ToString() && row.STATUS == "作业中")
                                    {
                                        int dock_status = Convert.ToInt32(dr["dock_status"]);
                                        dr["driver_no"]  = row.DRIVER_ID;
                                        dr["ship_code"]  = row.SHIP_CODE;
                                        dr["c_voyage"]   = dock_status == 0 ? row.OUT_VOYAGE_CODE : row.IN_VOYAGE_CODE;
                                        dr["COMMEND_ID"] = row.COMMEND_ID;
                                        dr["BERTH_NUM"]  = row.BERTH_NUM;
                                        dr["ENAM"]       = row.VESSELALIASE;
                                        //dr["Cstatus"] = dock_status == 0 && row.SHIPMENT_DEAL == "关" ? Convert.ToInt32(Config.CStatus.LoadWaitAuto) : Convert.ToInt32(Config.CStatus.WaitHandle);
                                        //2017-9-29 叶君腾 增加卸船自动确认
                                        dr["Cstatus"]     = row.SHIPMENT_DEAL == "关" ? Convert.ToInt32(Config.CStatus.LoadWaitAuto) : Convert.ToInt32(Config.CStatus.WaitHandle);
                                        dr["SERVICECODE"] = dock_status == 0 ? row.OUTVESSELLINECODE : row.INVESSELLINECODE;


                                        if (row.WORKTYPE == "外理" || row.WORKTYPE == "现场" || row.WORKTYPE == "核封")
                                        {
                                            //外理作业模式
                                            dr["Cstatus"] = Convert.ToInt32(Config.CStatus.ExOnly);
                                        }

                                        flag = true;
                                        break;
                                    }
                                }

                                if (!flag)
                                {
                                    string TicketId = ConfigurationManager.AppSettings["TICKET_ID"];
                                    if (dr["container_no"] != null && dr["container_no"].ToString() != "未识别")
                                    {
                                        CtosResult cntInfo = CtosAPIBLL.CM005001(dr["container_no"].ToString(), TicketId);
                                        if (cntInfo.ERRORCODE == CtosAPIBLL.SUCCESSCODE && cntInfo.DS.Tables[0].Rows.Count > 0)
                                        {
                                            int dock_status = Convert.ToInt32(dr["dock_status"]);
                                            dr["ship_code"] = dock_status == 0 ? cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["OUTEVESSELNAME"].ToString() : cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["INEVESSELNAME"].ToString();
                                            dr["c_voyage"]  = dock_status == 0 ? cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["OUTBOUNDVOY"].ToString() : cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["INBOUNDVOY"].ToString();
                                            //dr["COMMEND_ID"] = row.COMMEND_ID;
                                            //dr["BERTH_NUM"] = row.BERTH_NUM;
                                            dr["ENAM"] = dock_status == 0 ? cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["OUTVELALIASE"].ToString() : cntInfo.DS.Tables["CM_CONTAINERS"].Rows[0]["INVELALIASE"].ToString();
                                            //dr["Cstatus"] = dock_status == 0 && row.SHIPMENT_DEAL == "关" ? Convert.ToInt32(Config.CStatus.LoadWaitAuto) : Convert.ToInt32(Config.CStatus.WaitHandle);
                                            //2017-9-29 叶君腾 增加卸船自动确认
                                            dr["Cstatus"] = Convert.ToInt32(Config.CStatus.LoadWaitAuto);
                                            DataTable dt = OCR.BLL.jobBLL.SelectService(dr["ENAM"].ToString());
                                            dr["SERVICECODE"] = dock_status == 0 ? dt.Rows[0]["outvessellinecode"].ToString() : dt.Rows[0]["invessellinecode"].ToString();
                                            //外理作业模式
                                            dr["Cstatus"] = Convert.ToInt32(Config.CStatus.ExOnly);

                                            flag = true;
                                        }
                                    }
                                }

                                if (!flag)
                                {
                                    dr["Cstatus"]    = Convert.ToInt32(Config.CStatus.NoQcSet);
                                    dr["isarchived"] = "A";
                                    AddResult(string.Format("箱{0} {1}", dr["trval_no"].ToString(), "桥吊作业配置异常"));
                                }

                                bll.InsertCnt(dr);

                                AddResult(string.Format("箱{0} {1} {2}", dr["dock_id"].ToString(), dr["container_no"].ToString(), dr["trval_no"].ToString()));
                            }
                            catch (Exception ex)
                            {
                                SendEmail("*****@*****.**", "[OCR]分发错误", $"Error:{ex.StackTrace}");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AddResult(string.Format("箱 {0}", ex.Message));
            }

            return(msg.ToString());
        }