using System; using System.Linq; using System.Text; using System.Web.Mvc; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.Comm.Cookie; using HcUtility.Comm; using HcUtility.Core; using System.Collections.Generic; using System.IO; using System.Data; using DSWeb.Areas.CommMng.DAL; using DSWeb.Areas.RptMng.Comm; using DSWeb.MvcShipping.DAL.MsSysBillNoSet; using DSWeb.TruckMng.Helper.Repository; using DSWeb.Areas.MvcShipping.DAL.MsOp_BLISSUE; using DSWeb.MvcShipping.Models.MsOp_BLISSUE; using DSWeb.Areas.OA.Models.WorkFlow; using DSWeb.EntityDA; using DSWeb.MvcShipping.DAL.MsSysParamSet; using DSWeb.Common.DB; using DSWeb.SysMng.DAL.SysRoleTaskQuery; namespace DSWeb.MvcShipping.Controllers { /// /// 提单签发管理 /// [JsonRequestBehavior] public class MsOp_BLISSUEController : Controller { // // GET: /RptMng/MsRptPcHeadQry public ActionResult Index() { return View(); } public ActionResult Index_SP ( ) { return View(); } public ActionResult DsIndex() { return View(); } public ActionResult Edit_SP ( ) { return View(); } public ActionResult DeptArrears ( ) { return View(); } public ActionResult DeptArrearsDetail ( ) { return View(); } #region 提单签发 /// /// 查询 /// /// /// /// /// /// public ContentResult GetDataList ( int start, int limit, string sort, string condition ) { var recordcount = 0; var dataList = MsOp_BLISSUEDAL.GetDataList(condition, start,limit,out recordcount, sort); //var list = dataList.Skip(0).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = recordcount, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetDataListStr(string sort, string condition) { var dataListStr = MsOp_BLISSUEDAL.GetDataListStr(condition, sort); var json = JsonConvert.Serialize(new { Success = true, Message = dataListStr.Message, data = dataListStr.Data }); return new ContentResult() { Content = json }; } public ContentResult SaveList ( string data ) { var dataList = JsonConvert.Deserialize>(data); foreach (var _d in dataList){ /* if ( !string.IsNullOrEmpty(_d.ExpDate)){ _d.ExpDate = _d.ExpDate.Replace("T", " "); } if ( !string.IsNullOrEmpty(_d.EndPortDate)) { _d.EndPortDate = _d.EndPortDate.Substring(0, 10); } if (!string.IsNullOrEmpty(_d.OrgCode)) { _d.OrgCode = CookieConfig.GetCookie_OrgCode(Request); }*/ if (_d.GID == "" || _d.GID == "*") { _d.DbOperationType = DbOperationType.DbotIns; _d.ModelUIStatus = "I"; _d.GID = PubSysDAL.GetBillNo("0404"); //获取合同号 } else { _d.DbOperationType = DbOperationType.DbotUpd; _d.ModelUIStatus = "E"; } } var result = new DBResult(); var _L = ModelObjectConvert.ToModelObjectList(dataList); //var _DL = ModelObjectConvert.ToModelObjectList(DeldataList); var modb = new ModelObjectRepository(); result = modb.SaveHead(_L); //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } private List SaveList_P ( string data ) { var dataList = JsonConvert.Deserialize>(data); var DoDataList=new List(); //T_ALL_DA T_ALL_DA = new T_ALL_DA(); foreach (var _d in dataList) { //var CT = T_ALL_DA.GetStrSQL("CT", "SELECT COUNT(*) CT FROM op_blissue WHERE BSNO='" + _d.BSNO+ "'"); //if (Convert.ToInt32(CT) == 0) //{ // var blUpSQL = " insert into Op_BLISSUE([GID],[BSNO],[BLNO],[ISSUETYPE],[OPNAME],[OPTIME]) SELECT NEWID(),BSNO,MBLNO,ISSUETYPE,'"+ Session["SHOWNAME"].ToString() + "',GETDATE() FROM v_op_blissue_bill WHERE BSNO='"+ _d.BSNO + "'"; // bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); //} //else //{ // var blUpSQL = " update Op_BLISSUE SET OPTIME=GETDATE(),OPNAME='"+ Session["SHOWNAME"].ToString() + "',BLNO='"+_d.MBLNO+"' where BSNO='"+ _d.BSNO + "'"; // bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); //} // var _data = MsOp_BLISSUEDAL.GetData(" B.BSNO='" + _d.BSNO + "' and isnull(B.MBLNO,'')<>'' "); var _data = MsOp_BLISSUEDAL.GetData(" B.BSNO='" + _d.BSNO + "' "); if(string.IsNullOrWhiteSpace( _data.BSNO)){ return DoDataList; } if (string.IsNullOrEmpty(_data.GID)) { _data.DbOperationType = DbOperationType.DbotIns; _data.ModelUIStatus = "I"; _data.GID = PubSysDAL.GetBillNo("0404"); //获取合同号 _data.PAYRMB = "0"; _data.PAYUSD = "0"; _data.OPTIME = System.DateTime.Now.ToString(); _data.OPNAME = Session["SHOWNAME"].ToString(); DoDataList.Add(_data); } else { _data.DbOperationType = DbOperationType.DbotUpd; _data.ModelUIStatus = "E"; _data.OPTIME = System.DateTime.Now.ToString(); _data.OPNAME = Session["SHOWNAME"].ToString(); if (_d.BLNO != "") _data.BLNO = _d.BLNO; //防止发生提单号变化 DoDataList.Add(_data); } } var result = new DBResult(); var _L = ModelObjectConvert.ToModelObjectList(DoDataList); var modb = new ModelObjectRepository(); result = modb.SaveHead(_L); return DoDataList; } public ContentResult Delete ( string data ) { var head = JsonConvert.Deserialize(data); var canbedel = (head.BLSTATUS == "录入状态" || head.BLSTATUS == "" || head.BLSTATUS == "驳回提交"); if (canbedel==false) { var jsonRespose = new JsonResponse { Success = false, Message = "只有录入状态/驳回提交下的特放申请才能删除!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var modb = new ModelObjectDBBill(); DBResult result = modb.Delete(head, "delete from Op_blissuelist_detail where LINKGID='" + head.GID + "'"); //MsSysBillNoSetDAL.DeleteBsNo(head.BillNo); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } #endregion /// /// 此客户未签单业务 /// /// /// /// /// /// public ContentResult GetBLListData(int start, int limit, string sort, string condition) { var _condition= " ISCANCEL<>1 and ISCANCEL<>2 and ISCANCEL<>3 and exists (select 1 from op_ctn where BSNO=op_seae.BSNO and LEN(isnull(CNTRNO,''))>6) "; if (!string.IsNullOrWhiteSpace(condition)) { _condition += " and " + condition; } if (sort == null) { sort = "[{\"property\":\"BLISSUESTATUS\",\"direction\":\"DESC\"}]"; } var dataList = MsOp_BLISSUEDAL.GetBillDataList(start, limit, _condition, sort); int count = MsOp_BLISSUEDAL.getTotalCount(_condition); // var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } #region 部门额度 public ContentResult DeptARREARSListData(int start, int limit, string condition, string sort, string printstr) { var strSql = new StringBuilder(); strSql.Append("SELECT *,(MAXARREARS-DEPTTTLDR) DEPTTTLNODR from ("); strSql.Append("SELECT [GID],[DEPT],[MAXARREARS],[COMPANYID],[CREATEUSER],[CREATETIME],[REMARKS]"); strSql.Append(",isnull((select sum(TTLDR-STLTTLDR) from v_op_gain_sum where EXISTS (select 1 from v_op_blissuelist_Detail bl"); strSql.Append("where v_op_gain_sum.BSNO=bl.bsno and bl.BLSTATUS='审核通过' and bl.MNGBLSTATUS<>'审核通过' AND SALEDEPT=ob.DEPT and "); strSql.Append("not exists (select 1 from v_op_seae_iscargo i where bl.customername=i.customername))),0) AS DEPTTTLDR"); strSql.Append(" FROM [SYS_DEPT_ARREARS] ob "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" Where " + condition); } strSql.Append(") as DP "); if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true")) { var jsonRespose = new JsonResponse { Success = true, Message = "完成", Data = strSql.ToString() }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var dbparams = new List(); var paramps_sSQL = new CustomDbParamter(); paramps_sSQL.ParameterName = "@sSQL"; paramps_sSQL.DbType = DbType.String; paramps_sSQL.Direction = ParameterDirection.Input; paramps_sSQL.Value = strSql.ToString(); dbparams.Add(paramps_sSQL); var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set"); var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true); return new ContentResult() { Content = json }; } } public ContentResult DeptARREARSDetailListData(int start, int limit, string condition, string sort, string printstr) { var strSql = new StringBuilder(); strSql.Append("SELECT b.[BSNO],[GID],[LINKGID],[BLSTATUS],[OPNAME],[OPTIME],b.[CUSTOMERNAME],b.[SALEDEPT],[MNGBLSTATUS],(g.TTLDR-g.STLTTLDR) DEPTTTLNODR"); strSql.Append(",op.MBLNO,OP.ETD"); strSql.Append("FROM [v_op_blissuelist_Detail] b left join v_op_gain_sum g on (g.bsno=b.bsno) "); strSql.Append("left join v_op_blissue_bill op on (op.BSNO=b.bsno) where b.BLSTATUS='审核通过' and b.MNGBLSTATUS<>'审核通过' "); strSql.Append(" and not exists (select 1 from v_op_seae_iscargo i where b.customername=i.customername) "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" and " + condition); } if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true")) { var jsonRespose = new JsonResponse { Success = true, Message = "完成", Data = strSql.ToString() }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var dbparams = new List(); var paramps_sSQL = new CustomDbParamter(); paramps_sSQL.ParameterName = "@sSQL"; paramps_sSQL.DbType = DbType.String; paramps_sSQL.Direction = ParameterDirection.Input; paramps_sSQL.Value = strSql.ToString(); dbparams.Add(paramps_sSQL); var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set"); var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true); return new ContentResult() { Content = json }; } } #endregion #region 特殊放单申请 /// /// 特殊放单列表 /// /// /// /// /// /// public ContentResult GetSPList ( int start, int limit, string sort, string condition ) { SysRoleTaskQueryDAL.SaveQuery(Convert.ToString(Session["USERID"]), "modMsOp_BLISSUESP", "MsOp_BLISSUESPIndex", condition); var dataList = new List(); //特放申请是客户欠费额度 var SPISCUSTBAL = MsSysParamSetDAL.GetData("PARAMNAME='SPISCUSTBAL'"); if (SPISCUSTBAL.PARAMVALUE == "1") { dataList = MsOp_BLISSUEDAL.GetSPCustList(start, limit, condition, sort, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); } else dataList = MsOp_BLISSUEDAL.GetSPList(start, limit, condition, sort, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); int count = MsOp_BLISSUEDAL.getSpTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } /// /// 特殊放单 /// /// /// /// /// /// public ContentResult GetSPData ( string handle, string condition ) { MsOp_BLISSUEListmb head = null; var list = new List(); var SPISCUSTBAL = MsSysParamSetDAL.GetData("PARAMNAME='SPISCUSTBAL'"); if (SPISCUSTBAL.PARAMVALUE == "1") { list = MsOp_BLISSUEDAL.GetSPCustList(0, 1, condition, "", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); } else list = MsOp_BLISSUEDAL.GetSPList(0,1,condition,"", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); if (list.Count > 0) head = list[0]; if (head == null) { head = new MsOp_BLISSUEListmb(); } if (handle == "add") { head.OPNAME = Convert.ToString(Session["SHOWNAME"]); head.OPTIME = System.DateTime.Now.ToShortDateString(); head.GID = ""; head.BLSTATUS = "录入状态"; head.MNGBLSTATUS = "录入状态"; } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } /// /// 目前已无应用 /// /// /// public ContentResult SaveSPList ( string data ) { var dataList = JsonConvert.Deserialize>(data); foreach (var _d in dataList) { /* if ( !string.IsNullOrEmpty(_d.ExpDate)){ _d.ExpDate = _d.ExpDate.Replace("T", " "); } if ( !string.IsNullOrEmpty(_d.EndPortDate)) { _d.EndPortDate = _d.EndPortDate.Substring(0, 10); } if (!string.IsNullOrEmpty(_d.OrgCode)) { _d.OrgCode = CookieConfig.GetCookie_OrgCode(Request); }*/ if (_d.GID == "" || _d.GID == "*") { _d.DbOperationType = DbOperationType.DbotIns; _d.ModelUIStatus = "I"; _d.GID = PubSysDAL.GetBillNo("0404"); //获取合同号 } else { _d.DbOperationType = DbOperationType.DbotUpd; _d.ModelUIStatus = "E"; } } var result = new DBResult(); var _L = ModelObjectConvert.ToModelObjectList(dataList); //var _DL = ModelObjectConvert.ToModelObjectList(DeldataList); var modb = new ModelObjectRepository(); result = modb.SaveHead(_L); //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } private List SaveList_SP ( string data ) { var dataList = JsonConvert.Deserialize>(data); var DoDataList = new List(); foreach (var _d in dataList) { var _data = MsOp_BLISSUEDAL.GetData(" B.BSNO='" + _d.BSNO + "' and isnull(B.MBLNO,'')<>'' "); if (_data.GID == "") { _d.DbOperationType = DbOperationType.DbotIns; _d.ModelUIStatus = "I"; _d.GID = PubSysDAL.GetBillNo("0404"); //获取合同号 _d.PAYRMB = "0"; _d.PAYUSD = "0"; _d.OPTIME = System.DateTime.Now.ToString(); _d.OPNAME = Session["SHOWNAME"].ToString(); DoDataList.Add(_d); } else { _data.DbOperationType = DbOperationType.DbotUpd; _data.ModelUIStatus = "E"; _data.OPTIME = System.DateTime.Now.ToString(); _data.OPNAME = Session["SHOWNAME"].ToString(); _data.BLNO = _d.BLNO; //防止发生提单号变化 DoDataList.Add(_data); } } var result = new DBResult(); var _L = ModelObjectConvert.ToModelObjectList(DoDataList); var modb = new ModelObjectRepository(); result = modb.SaveHead(_L); return DoDataList; } public ContentResult DeleteSP ( string data ) { var head_0 = JsonConvert.Deserialize(data); var head = new MsOp_BLISSUEListmb(); var list = MsOp_BLISSUEDAL.GetSPList(0,1," ob.GID='" + head_0.GID + "' ", "", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); if (list.Count > 0) head = list[0]; if (head == null) { head = new MsOp_BLISSUEListmb(); } var canbedel = (head.BLSTATUS == "录入状态" || head.BLSTATUS == "驳回提交"); if (canbedel == false) { var jsonRespose = new JsonResponse { Success = false, Message = "只有录入状态下的特殊放单才能删除!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var modb = new ModelObjectDBBill(); DBResult result = modb.Delete(head, "delete from Op_blissuelist_Detail where BSNO='" + head.GID + "'"); //MsSysBillNoSetDAL.DeleteBsNo(head.BillNo); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } /// /// 保存放单通知 /// /// /// /// /// /// public ContentResult SaveSP (string opstatus, string data ) { var headData = JsonConvert.Deserialize(data); var isPost = true; var errorstr = ""; var isuse = false; var iscreatecustno = false; var custno = ""; headData.OPNAME = Session["SHOWNAME"].ToString(); headData.OPTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (opstatus=="add") { headData.DbOperationType = DbOperationType.DbotIns; headData.ModelUIStatus = "I"; var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='特殊放单申请'", Convert.ToString(Session["COMPANYID"])); if (billnoset.BILLTYPE != "") isuse = true; else { var jsonRespose = new JsonResponse { Success = false, Message = "没有 特殊放单申请 的编码规则!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } if (headData.GID == "") { if (isuse) { custno = MsSysBillNoSetDAL.GetBillNo(billnoset, System.DateTime.Now.ToString(), System.DateTime.Now.ToString(), "", headData.OPNAME);//headData.OP iscreatecustno = true; headData.GID = custno; } } else { var ct = MsOp_BLISSUEDAL.GetRdCount(" GID='" + headData.GID + "' "); if (ct != 0) { isPost = false; errorstr = "特殊放单申请编号"; } } //headData.GID = PubSysDAL.GetBillNo("0405"); //获取合同号 headData.BLSTATUS = "录入状态"; } else { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; } T_ALL_DA T_ALL_DA = new T_ALL_DA(); var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from OP_SEAE WHERE CUSTOMERNAME='"+headData.CUSTOMERNAME+"' AND DATEDIFF([day],ISNULL(OP_SEAE.STLDATE,OP_SEAE.ETD),GETDATE())>0 "); if (BLCOUNT == "0") { headData.ISCHAOQI = "否"; } else { headData.ISCHAOQI = "是"; }; var result = new DBResult(); var modb = new ModelObjectRepository(); result = modb.Save(headData); //刷新父窗口上的父节点 if (isPost) { var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOp_BLISSUEDAL.GetSPData(" ob.GID='" + headData.GID + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { if (iscreatecustno == true) MsSysBillNoSetDAL.DeleteBsNo(custno); var jsonRespose = new JsonResponse { Success = false, Message = errorstr + "重复,不允许保存!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } /// /// 特殊放单明细表 /// /// /// /// /// /// public ContentResult GetSPDetail ( int start, int limit, string sort, string condition ) { var dataList = MsOp_BLISSUEDAL.GetSPDetail(condition,start,limit, sort); var list = dataList.Skip(0).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } #region 提交 审核 /// /// 编辑页和列表的前端均调用此方法 /// data内容为MsOp_BLISSUEListmb列表的json文本 /// /// /// /// public ContentResult SP_Start ( string USERID, string data ) //申请签入 { var _r1 = JsonConvert.Deserialize>(data); var _L = new List(); var result = new DBResult(); var cdc =new CommonDataContext(); //20230213 将此次提交的业务按customername分组 分别判断能否签出 var customernameList= _r1.Select(s=>s.CUSTOMERNAME).Distinct().ToList(); foreach (var cusomername in customernameList) { var custList = _r1.Where(x => x.CUSTOMERNAME == cusomername).ToList(); var gidlist = custList.Select(s => s.GID).ToList(); var detailList = cdc.op_blissuelist_Detail.Where(x => gidlist.Contains( x.LINKGID )).ToList(); var bsnolist = detailList.Select(s => s.BSNO).ToArray(); //var bsnostr = "'"+string.Join("','", bsnolist)+ "'"; //var _cancheckout= MsOp_BLISSUEDAL.CanCheckOut(bsnostr); //if(!_cancheckout.Success) // return BasicDataRefDAL.GetContentResult(_cancheckout); } foreach (var _p in _r1) { if (_p.BLSTATUS == "录入状态" || _p.BLSTATUS == "驳回提交") { _L.Add(_p); } else { } } var jsonRespose = new JsonResponse(); //var SHOWNAME = Convert.ToString(Session["SHOWNAME"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SP_Start(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOp_BLISSUEDAL.GetSPData(" ob.GID='" + _L[0].GID + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } /// /// 目前前端没有调用该方法 /// /// /// /// /// public ContentResult SP_StartSave(string opstatus,string USERID, string data) //申请签入 { var headData = JsonConvert.Deserialize(data); var isPost = true; var errorstr = ""; var isuse = false; var iscreatecustno = false; var custno = ""; headData.OPNAME = Session["SHOWNAME"].ToString(); headData.OPTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (opstatus == "add") { headData.DbOperationType = DbOperationType.DbotIns; headData.ModelUIStatus = "I"; var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='特殊放单申请'", Convert.ToString(Session["COMPANYID"])); if (billnoset.BILLTYPE != "") isuse = true; else { var jsonRespose2 = new JsonResponse { Success = false, Message = "没有 特殊放单申请 的编码规则!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } if (headData.GID == "") { if (isuse) { custno = MsSysBillNoSetDAL.GetBillNo(billnoset, System.DateTime.Now.ToString(), System.DateTime.Now.ToString(), "", headData.OPNAME);//headData.OP iscreatecustno = true; headData.GID = custno; } } else { var ct = MsOp_BLISSUEDAL.GetRdCount(" GID='" + headData.GID + "' "); if (ct != 0) { isPost = false; errorstr = "特殊放单申请编号"; } } //headData.GID = PubSysDAL.GetBillNo("0405"); //获取合同号 headData.BLSTATUS = "录入状态"; } else { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; } T_ALL_DA T_ALL_DA = new T_ALL_DA(); var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from OP_SEAE WHERE CUSTOMERNAME='" + headData.CUSTOMERNAME + "' AND DATEDIFF([day],ISNULL(OP_SEAE.STLDATE,OP_SEAE.ETD),GETDATE())>0 "); if (BLCOUNT == "0") { headData.ISCHAOQI = "否"; } else { headData.ISCHAOQI = "是"; }; var result = new DBResult(); var modb = new ModelObjectRepository(); result = modb.Save(headData); var _L = new List(); if (headData.BLSTATUS == "录入状态" || headData.BLSTATUS == "驳回提交") { _L.Add(headData); } else { } var jsonRespose = new JsonResponse(); //var SHOWNAME = Convert.ToString(Session["SHOWNAME"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SP_Start(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOp_BLISSUEDAL.GetSPData(" ob.GID='" + _L[0].GID + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SP_Back ( string USERID, string data ) //申请签入_撤回 { var _r1 = JsonConvert.Deserialize>(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS != "提交审核") { /* result.Success = false; result.Message = "只有录入状态的提单才能申请签入"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null };*/ } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SP_Back(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOp_BLISSUEDAL.GetSPData(" ob.GID='" + _L[0].GID + "'") }; } else { result.Success = false; result.Message = "没有可以撤回的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SP_AuditBack ( string USERID, string data, string REASON ) //申请签入_撤回 { var _r1 = JsonConvert.Deserialize>(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS == "提交审核" || _p.BLSTATUS == "审核通过") { _L.Add(_p); } else { //_L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SP_AuditBack(_L, USERID, REASON); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOp_BLISSUEDAL.GetSPData(" ob.GID='" + _L[0].GID + "'") }; } else { result.Success = false; result.Message = "没有可以驳回的特殊放单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SP_Audit ( string USERID, string data ,string REASON) //申请签入_准许签入 { var _r1 = JsonConvert.Deserialize>(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS != "提交审核") { /* result.Success = false; result.Message = "只有录入状态的提单才能申请签入"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null };*/ } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SP_Audit(_L, USERID, REASON); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOp_BLISSUEDAL.GetSPData(" ob.GID='" + _L[0].GID + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 特放复核 public ContentResult MNGSP_AuditBack(string USERID, string data) //申请签入_撤回 { var _r1 = JsonConvert.Deserialize>(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.MNGBLSTATUS == "审核通过") { _L.Add(_p); } else { //_L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.MNGSP_AuditBack(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOp_BLISSUEDAL.GetSPData(" ob.GID='" + _L[0].GID + "'") }; } else { result.Success = false; result.Message = "没有可以驳回的特殊放单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult MNGSP_Audit(string USERID, string data) //申请签入_准许签入 { var _r1 = JsonConvert.Deserialize>(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS != "审核通过") { /* result.Success = false; result.Message = "只有录入状态的提单才能申请签入"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null };*/ } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.MNGSP_Audit(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOp_BLISSUEDAL.GetSPData(" ob.GID='" + _L[0].GID + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 加入删除特殊放单明细 public ContentResult ADDSP ( string data ) { var dataList = JsonConvert.Deserialize>(data); var DoDataList = new List(); foreach (var _d in dataList) { //var _data = MsOp_BLISSUEDAL.GetData(" vb.BSNO='" + _d.BSNO + "' and isnull(vb.MBLNO,'')<>'' "); var _SPDate = new MsOp_BLISSUEListmb(); //if (_data.GID == "") //{ _SPDate.DbOperationType = DbOperationType.DbotIns; _SPDate.ModelUIStatus = "I"; _SPDate.BLSTATUS = "录入状态"; _SPDate.GID = System.Guid.NewGuid().ToString(); _SPDate.BSNO = _d.BSNO; _SPDate.OPNAME = Session["SHOWNAME"].ToString(); _SPDate.OPTIME = System.DateTime.Now.ToString(); _SPDate.DELFLAG = "0"; DoDataList.Add(_SPDate); /*} //else { _data.DbOperationType = DbOperationType.DbotUpd; _data.ModelUIStatus = "E"; _data.OPTIME = System.DateTime.Now.ToString(); _data.OPNAME = Session["SHOWNAME"].ToString(); _data.BLNO = _d.BLNO; //防止发生提单号变化 */ //DoDataList.Add(_data); //} } var result = new DBResult(); var _L = ModelObjectConvert.ToModelObjectList(DoDataList); var modb = new ModelObjectRepository(); result = modb.SaveHead(_L); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } /// /// 添加明细 /// /// /// /// public ContentResult ADDSP2 ( string LINKGID, string data ) { var dataList = JsonConvert.Deserialize>(data); //20230213 首先判断有效性 //BLNO为空不允许提交 if (dataList.Exists(x => x.BLNO == null || x.BLNO == "")) { var jsonRespose0 = new JsonResponse { Success = false, Message = "船东单号(主提单号)不能为空", Data = null }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose0) }; } var DoDataList = new List(); var DoDataListDel = new List(); var headdata = MsOp_BLISSUEDAL.GetSPData(" ob.GID='" + LINKGID + "' "); headdata.DbOperationType = DbOperationType.DbotUpd; headdata.ModelUIStatus = "E"; if (dataList != null) { foreach (var _d in dataList) { //var _data = MsOp_BLISSUEDAL.GetData(" vb.BSNO='" + _d.BSNO + "' and isnull(vb.MBLNO,'')<>'' "); var _SPDate = new MsOp_BLISSUEList_Detailmb(); //if (_data.GID == "") //{ _SPDate.DbOperationType = DbOperationType.DbotIns; //_SPDate.ModelUIStatus = "I"; _SPDate.GID = System.Guid.NewGuid().ToString(); _SPDate.LINKGID = ""; _SPDate.BSNO = _d.BSNO; DoDataList.Add(_SPDate); headdata.CUSTOMERNAME = _d.CUSTOMERNAME; headdata.STLNAME = _d.STLNAME; headdata.SALE = _d.SALE; var cdc = new CommonDataContext(); var saleinfo = cdc.VW_user_all.FirstOrDefault(x => x.SHOWNAME == _d.SALE); headdata.SALEDEPT = saleinfo.DEPTNAME; headdata.SALECORPID = saleinfo.COMPANYID; //20220922 //if (headdata.SALEDEPT==""){ // T_ALL_DA T_ALL_DA = new T_ALL_DA(); // var strDEPT = T_ALL_DA.GetStrSQL("DEPTNAME", "select top 1 DEPTNAME from VW_user where SHOWNAME='" +_d.SALE+ "'"); // headdata.SALEDEPT = strDEPT; //} // headdata.STLNAME=_d.stl /*} //else { _data.DbOperationType = DbOperationType.DbotUpd; _data.ModelUIStatus = "E"; _data.OPTIME = System.DateTime.Now.ToString(); _data.OPNAME = Session["SHOWNAME"].ToString(); _data.BLNO = _d.BLNO; //防止发生提单号变化 */ //DoDataList.Add(_data); //} } var result = new DBResult(); var _L = ModelObjectConvert.ToModelObjectList(DoDataList); var modb = new ModelObjectRepository(); result = modb.Save(headdata, ModelObjectConvert.ToModelObjectList(DoDataList) , ModelObjectConvert.ToModelObjectList(DoDataListDel) ); var _i = MsOp_BLISSUEDAL.ResetSPAmount(LINKGID,headdata); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var jsonRespose = new JsonResponse { Success = false, Message = "没有可以添加的业务", Data = null }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult DeleteDetail ( string LINKGID, string GIDList ) { var _count = 0; var corpcode = CookieConfig.GetCookie_OrgCode(Request); var userid = CookieConfig.GetCookie_UserId(Request); _count = MsOp_BLISSUEDAL.DeleteDetail(LINKGID, GIDList); var _success = false; if (_count > 0) { _success = true; } var headdata = MsOp_BLISSUEDAL.GetSPData(" ob.GID='" + LINKGID + "' "); var _i = MsOp_BLISSUEDAL.ResetSPAmount(LINKGID, headdata); var json = JsonConvert.Serialize(new { Success = _success, Message = "查询成功", totalCount = _count }); return new ContentResult() { Content = json }; } #endregion #endregion #region 提交 审核 public ContentResult SQQR ( string USERID, string data ) //申请签入 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS != "录入状态") { /* result.Success = false; result.Message = "只有录入状态的提单才能申请签入"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null };*/ } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SQQR(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SQQR_back ( string USERID, string data ) //申请签入_撤回 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS != "待签入") { /* result.Success = false; result.Message = "只有录入状态的提单才能申请签入"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null };*/ } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SQQR_back(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以撤回的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SQQR_Auditback ( string USERID, string data,string REASON ) //申请签入_撤回 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS == "待签入" || _p.BLSTATUS == "已签入") { _L.Add(_p); } else { //_L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SQQR_Auditback(_L, USERID,REASON); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以撤回的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SQQR_Audit ( string USERID, string data ) //申请签入_准许签入 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS != "待签入") { /* result.Success = false; result.Message = "只有录入状态的提单才能申请签入"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null };*/ } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SQQR_Audit(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SQFD ( string USERID, string data ) //申请签入 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS != "已签入") { /* result.Success = false; result.Message = "只有录入状态的提单才能申请签入"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null };*/ } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SQFD(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SQFD_back ( string USERID, string data ) //申请签入_撤回 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS != "申请放单") { /* result.Success = false; result.Message = "只有录入状态的提单才能申请签入"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null };*/ } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SQFD_back(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以撤回的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SQFD_Auditback ( string USERID, string data, string REASON ) //申请签入_撤回 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS == "申请放单" || _p.BLSTATUS == "准许放单") { _L.Add(_p); } else { //_L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SQFD_Auditback(_L, USERID, REASON); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以撤回的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SQFD_Audit ( string USERID, string data ) //申请签入_准许签入 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS != "申请放单") { /* result.Success = false; result.Message = "只有录入状态的提单才能申请签入"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null };*/ } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.SQFD_Audit(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 签入 签出 public ContentResult ISFDTZ(string data) //签入 { var dataList = JsonConvert.Deserialize>(data); var result = new DBResult(); T_ALL_DA T_ALL_DA = new T_ALL_DA(); var istz = true; var jsonRespose = new JsonResponse(); foreach (var item in dataList) { var ACTNAME = T_ALL_DA.GetStrSQL("ACTNAME", "SELECT ACTNAME FROM WorkLog WHERE (ACTNAME='放单通知' or ACTNAME='取消放单通知' or ACTNAME='驳回放单通知') AND BSNO='" + item.GID + "' order by OPDATE desc "); if (ACTNAME!= "放单通知") { result.Success = false; result.Message = "操作没有通知放单,是否继续"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } result.Success = true; result.Message = ""; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult QR ( string USERID, string data,string qrdate,string reason ) //签入 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { //20221121 扣单状态的业务改为可以签入 if (_p.BLSTATUS == "提单签入")//|| _p.BLSTATUS == "扣单" { /* result.Success = false; result.Message = "只有录入状态的提单才能申请签入"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null };*/ } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.QR(_L, USERID, qrdate, Convert.ToString(Session["SHOWNAME"]), reason); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 船证签入签出 public ContentResult CZQR(string CZQRDATE, string CZQRREMARK,string data) //签入 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { _L.Add(_p); } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.CZQR(_L, Convert.ToString(Session["USERID"]), CZQRDATE, CZQRREMARK); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult UnCZQR(string USERID, string data) //申请签入_撤回 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.ISVESSELPROVE == "1") { _L.Add(_p); } else { } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.UnCZQR(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以撤回的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult HQBS(string USERID, string data) //换签背书 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS == "提单签出") { /* result.Success = false; result.Message = "只有录入状态的提单才能申请签入"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null };*/ } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.HQBS(_L, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"])); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult UnHQBS(string USERID, string data) //申请签入_撤回 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.ISVESSELPROVE == "1") { _L.Add(_p); } else { } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.UnHQBS(_L, USERID, Convert.ToString(Session["SHOWNAME"])); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以撤回的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion public ContentResult QC ( string USERID, string data,string REASON,string qcdate ) //签出 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { result = CanQC(_p); if (!result.Success) { return BasicDataRefDAL.GetContentResult(result); } _L.Add(_p); } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.QC(_L, USERID, REASON, qcdate, Convert.ToString(Session["SHOWNAME"])); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } /// /// 判断一个MsOp_BLISSUEmb能否执行签出 /// /// /// public static DBResult CanQC(MsOp_BLISSUEmb _p) { var result = new DBResult(); result.OK(); //1 在其工作日志中 提单签入比提单签出的数量多1 //2 没有不成对的 【扣单】和【取消扣单】 //20221216 如果最后一次取消扣单之后没有新的扣单 则还是允许签出 //var cdc = new CommonDataContext(); //var op_blissuelist_detail = cdc.op_blissuelist_detail //var loglist = cdc.WorkLog.Where(x => x.BSNO == _p.GID).ToList(); var condition = $" (BSNO='{_p.GID}' or BSNO in(select linkgid from op_blissuelist_detail where BSNO='{_p.BSNO}'))"; var loglist = Areas.OA.DAL.WorkFlow.WorkLogDAL.GetWorkLog(condition, null); var 提单签入count = 0; var 提单签出count = 0; var 扣单count = 0; var 取消扣单count = 0; var 放单通知count = 0; var 特殊放单审核完成count = 0; var 特殊放单提交审核count = 0; foreach (var log in loglist) { if (log.ACTNAME == "提单签入") 提单签入count++; if (log.ACTNAME == "取消签入") 提单签入count--; if (log.ACTNAME == "提单签出") 提单签出count++; if (log.ACTNAME == "取消签出") 提单签出count--; if (log.ACTNAME == "扣单") 扣单count++; if (log.ACTNAME == "取消扣单") 取消扣单count++; if (log.ACTNAME == "放单通知") 放单通知count++; if (log.ACTNAME == "取消放单通知") 放单通知count--; if (log.ACTNAME == "特殊放单申请提交") 特殊放单提交审核count++; if (log.ACTNAME == "特殊放单申请 撤回"|| log.ACTNAME == "特殊放单申请 驳回") 特殊放单提交审核count--; if (log.ACTNAME == "特殊放单审核完成") 特殊放单审核完成count++; } if (_p.能直接签出()) { } else { if (提单签入count - 提单签出count != 1) { //20230215 签单方式:目放、电放、SWB三者允许不做签入即签出 result.SetErrorInfo("还未执行提单签入"); return result; } } if (扣单count - 取消扣单count != 0) { // if (loglist.Exists(x => x.ACTNAME == "取消扣单")) { var 最后取消扣单的时间Str = loglist.Where(x => x.ACTNAME == "取消扣单").Max(x => x.OPDATE); var 最后取消扣单的时间 = Convert.ToDateTime(最后取消扣单的时间Str); if (loglist.Exists(x => x.ACTNAME == "扣单" && Convert.ToDateTime(x.OPDATE)> 最后取消扣单的时间)) { //如果有晚于最后一次取消扣单的扣单 那还是扣单状态 result.SetErrorInfo("目前处于扣单状态"); return result; } } else { result.SetErrorInfo("目前处于扣单状态"); return result; } } if (特殊放单提交审核count > 0 ) { if (特殊放单审核完成count>0 ) { //&& 特殊放单审核完成count == 特殊放单提交审核count //改为允许多次提交只完成一次 } else { result.SetErrorInfo("还未执行放单通知"); return result; } } else { } if (特殊放单审核完成count != 特殊放单提交审核count && 放单通知count <= 0) { if (特殊放单审核完成count >= 1) { //改为只要审核完成一次就算完成 }else result.SetErrorInfo("还未执行放单通知"); } //如果有放单通知而没有提单签入 return result; } public ContentResult KD ( string USERID, string data,string type) //扣单 取消扣单 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (BLSTATUSTYPE.已放货或已放单 (_p.BLSTATUS)) { /* result.Success = false; result.Message = "只有录入状态的提单才能申请签入"; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null };*/ } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.KD(_L,USERID, Convert.ToString(Session["SHOWNAME"])); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult KD_NoCancel(string USERID, string data, string type) //扣单 不取消扣单 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (BLSTATUSTYPE.已放货或已放单(_p.BLSTATUS) || _p.BLSTATUS == "扣单") { } else { _L.Add(_p); } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.KD(_L, USERID, Convert.ToString(Session["SHOWNAME"])); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } /// /// 执行 放单通知 /// /// /// /// /// public ContentResult FDTZ ( string USERID, string data, string REASON ) //放单通知 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); var jsonRespose = new JsonResponse(); foreach (var _p in _r1) { if ( _p.BLSTATUS == "放单通知" || _p.BLSTATUS == "提单签出")//_p.BLSTATUS == "扣单" || { /* 这些状态的业务无法或不需要执行此操作 扣单的业务需 */ } else { _L.Add(_p); } } //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { //20230215 增加判断 如【1最后一票且欠费 2欠费超期】 则告警并退出 var bsnoStr = "'" + string.Join("','", _L.Select(s => s.BSNO)) + "'"; //var _b_head = MsOp_BLISSUEDAL.CanCheckOut(bsnoStr); //if (!_b_head.Success ) //{ // jsonRespose = new JsonResponse // { // Success = _b_head.Success, // Message = _b_head.Message, // }; // return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; //} result = MsOp_BLISSUEDAL.FDTZ(_L, USERID, REASON, Convert.ToString(Session["SHOWNAME"])); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult PLFDTZ(string USERID, string data) //放单通知 { bool BLISSUENONO = false; var BLISSUENONOPARAM = MsSysParamSetDAL.GetData("PARAMNAME='BLISSUENONO'"); if (BLISSUENONOPARAM.PARAMVALUE == "1") { BLISSUENONO = true; } var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); var nostlstr = ""; foreach (var _p in _r1) { var isnostl=false; if (_p.STLDATE != "") { var ttlnodr = _p.TTLNODR; if (ttlnodr == "") ttlnodr = "0"; if (//System.DateTime.Now >= Convert.ToDateTime(_p.STLDATE) && Convert.ToDecimal(ttlnodr) > 0 ) { isnostl=true; } } else { var ttlnodr = _p.TTLNODR; if (ttlnodr == "") ttlnodr = "0"; if (Convert.ToDecimal(ttlnodr) != 0) isnostl = true; } if (isnostl&& BLISSUENONO) { nostlstr = nostlstr + _p.BLNO + ","; } else { if (_p.BLSTATUS == "扣单" || _p.BLSTATUS == "放单通知" || _p.BLSTATUS == "提单签出") { } else { _L.Add(_p); } } } if (nostlstr != "") { nostlstr = " 其中提单号:" + nostlstr + "存在欠费,无法放单!"; } var jsonRespose = new JsonResponse(); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.FDTZ(_L, USERID,"", Convert.ToString(Session["SHOWNAME"])); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message +nostlstr, Data = nostlstr }; } else { result.Success = false; result.Message = "没有可以提交的提单" + nostlstr; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = nostlstr }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult UNFDTZ(string USERID, string data) //取消放单通知 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { _L.Add(_p); } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.UNFDTZ(_L, USERID, Convert.ToString(Session["SHOWNAME"])); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult FDTZBACK(string USERID, string data) //取消放单通知 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { _L.Add(_p); } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.FDTZBACK(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以提交的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult UnQR ( string USERID, string data ) //申请签入_撤回 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if ( BLSTATUSTYPE.CanUnQR( _p.BLSTATUS) ) { _L.Add(_p); } else { } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.UnQR(_L, USERID, Convert.ToString(Session["SHOWNAME"])); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以撤回的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult QXQC ( string USERID, string data ) //取消签出 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS == "提单签出") { _L.Add(_p); } else { } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.QXQC(_L, USERID, Convert.ToString(Session["SHOWNAME"])); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以取消签出的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult REQR ( string USERID, string data ) //重新签入 { var _r1 = SaveList_P(data); var _L = new List(); var result = new DBResult(); foreach (var _p in _r1) { if (_p.BLSTATUS == "提单签出") { _L.Add(_p); } else { } } var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (_L.Count > 0) { result = MsOp_BLISSUEDAL.REQR(_L, USERID); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以撤回的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 取消放单通知 public ContentResult GGTD(string data,string status) //状态更改 { var bodylist = JsonConvert.Deserialize >(data); var result = new DBResult(); var jsonRespose = new JsonResponse(); //var USERID=Convert.ToString(Session["USERID"]); if (bodylist.Count > 0) { result = MsOp_BLISSUEDAL.GGTD(bodylist,status, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"])); jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; } else { result.Success = false; result.Message = "没有可以更改的提单"; jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = null }; } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion public ContentResult SaveLog ( string data ) { var headData = JsonConvert.Deserialize(data); headData.GID = System.Guid.NewGuid().ToString(); //获取合同号 headData.OP = Session["SHOWNAME"].ToString(); var result = new DBResult(); var modb = new ModelObjectRepository(); result = modb.Save(headData); //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetBLINFO(string BSNO) { var dataList = MsOp_BLISSUEDAL.GetBLINFO(BSNO); var list = dataList.Skip(0).Take(999); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } /// /// /// /// /// public ContentResult GetBLINFO2 ( string BSNO ) { var dataList = MsOp_BLISSUEDAL.GetBLINFO2(BSNO); var list = dataList.Skip(0).Take(999); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetBLINFOLIST(int start, int limit, string sort, string CUSTNAME,string SALE) { var dataList = MsOp_BLISSUEDAL.GetBLINFOLIST(CUSTNAME, SALE); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } /// /// 判断能否执行提单签出 /// /// /// public ContentResult CanCheckOut(string BSNO) { var data = MsOp_BLISSUEDAL.CanCheckOut(BSNO); return BasicDataRefDAL.GetContentResult(data); } #region 特殊放单附件 public ContentResult GetFileList ( string PID ) { var dataList = MsOp_BLISSUEDAL.GetUpLoadFileList("PID='" + PID + "'"); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult SaveFile ( string bsno, string body ) { int iResult = 0; var bodyList = JsonConvert.Deserialize>(body); var result = new DBResult(); if (bodyList != null) { iResult = MsOp_BLISSUEDAL.SaveFileList(bodyList, bsno); } if (iResult == 1) { result.Success = true; result.Message = "更新成功!"; } else if (iResult == 0) { result.Success = false; result.Message = "出现错误,未更新!"; } else if (iResult == -1) { result.Success = false; result.Message = "有异常,插入失败!"; } else if (iResult == -2) { result.Success = false; result.Message = "插入异常,事务已回滚成功!"; } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, // Data = MsChFeeDAL.GetDataList(headData.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } [HttpPost] public ContentResult UploadFile ( ) { var jsonRespose = new JsonResponse { Success = false, Message = "" }; if (Request.Files.Count != 1) { jsonRespose.Success = false; jsonRespose.Message = "请选择上传的文件"; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } var file = Request.Files["LoadImage"]; var fileGID = Request.Form["fileGid"]; if (file == null) { jsonRespose.Success = false; jsonRespose.Message = "上传文件发生未知错误,请重新上传"; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } var path = Server.MapPath("../../UploadFiles/MsDriver"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var size = file.ContentLength; var name = Path.GetFileName(file.FileName); var usercode = CookieConfig.GetCookie_UserCode(Request); string fn = usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name; string filename = path + "\\" + fn; if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } file.SaveAs(filename); if (!System.IO.File.Exists(filename)) { jsonRespose.Success = false; jsonRespose.Message = "上传文件发生未知错误,请重新上传"; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } try { var message = string.Empty; var filename2 = "../../UploadFiles/MsDriver/" + fn; var isSucess = MsOp_BLISSUEDAL.UpdateFileData(Request,filename, filename2, fileGID, out message); if (!isSucess) { jsonRespose.Success = false; jsonRespose.Message = message; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } var json = JsonConvert.Serialize(new { success = true, Message = "上传成功!", data = filename }); return new ContentResult() { Content = json }; } catch (Exception e) { jsonRespose.Success = false; jsonRespose.Message = "上传文件出错,请确认文件正确性"; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult DeleteUploadFile ( string data ) { int iResult = 0; var bodyList = data; var result = new DBResult(); if (bodyList != "" || bodyList != null) { iResult = MsOp_BLISSUEDAL.DeleteUploadFile(bodyList); } if (iResult == 1) { result.Success = true; result.Message = "删除成功!"; } else if (iResult == 0) { result.Success = false; result.Message = "出现错误,未删除!"; } else if (iResult == -1) { result.Success = false; result.Message = "有异常,删除失败!"; } else if (iResult == -2) { result.Success = false; result.Message = "删除异常,事务已回滚成功!"; } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, // Data = MsChFeeDAL.GetDataList(headData.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion } }