using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using DSWeb.Areas.CommMng.DAL; using DSWeb.Areas.TruckMng.DAL.MsWlBs; using DSWeb.Areas.TruckMng.Models.Comm; using DSWeb.Areas.TruckMng.Models.MsWlBs; using DSWeb.TruckMng.Comm.Cookie; using DSWeb.TruckMng.Helper; using DSWeb.TruckMng.Helper.Repository; using HcUtility.Comm; using DSWeb.MvcShipping.DAL.MsSysBillNoSet; using System.Text; using System.Data; using Microsoft.Practices.EnterpriseLibrary.Data; using DSWeb.Areas.RptMng.Comm; using DSWeb.SoftMng.Filter; namespace DSWeb.Areas.TruckMng.Controllers { using HcUtility.Core; [JsonRequestBehavior] public class MsWlPcController : Controller { // // GET: /TruckMng/MsWlPc/Edit public ActionResult Edit() { return View(); } public ActionResult Edit_ADL() { return View(); } // // GET: /TruckMng/MsWlPc/ [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetDataList(string refbillno) { var condition = " RefBillNo='" + refbillno + "' or BILLNO in(select PC_BILLNO from BS_PC_Status where BS_BILLNO='" + refbillno + "')";// or RefBillNoSe='" + refbillno + "'"; List list = MsWlPcDAL.GetDataList(condition,Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetDataList_ADL ( int start, int limit, string sort, string condition ) { //var condition = " RefBillNo='" + refbillno + "'";// or RefBillNoSe='" + refbillno + "'"; //List datalist = MsWlPcDAL.GetDataList_ADL(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); var dataList = MsWlPcDAL.GetDataList_ADL(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); 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 }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetListSum(string condition) { var rangstr = MsWlPcDAL.GetRangDAStr("index", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); if (!string.IsNullOrEmpty(rangstr)) { if (!string.IsNullOrEmpty(condition)) { condition = condition + " and " + rangstr; } else { condition = rangstr; } } var strSql = new StringBuilder(); strSql.Append("SELECT sum(case when isnull(isend,0)=0 then 1 else 0 end) NCOUNT,sum(case when isnull(isend,0)=0 then 0 else 1 end) PCOUNT,SUM(KGS) KGS,SUM(CBM) CBM from tMsWlPcHead"); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" where " + condition); } 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(0, 1, dbRptResult, "Result_Set", true); return new ContentResult() { Content = json }; } //用于查找可以用来添加双背的路单 [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetSBPC(string condition,string refbillno) { var _condition = " RefBillNo<>'" + refbillno + "' and BILLNO not in(select PC_BILLNO from BS_PC_Status where BS_BILLNO='" + refbillno + "') and expdate=(select NeedArriveDate from tmswlbshead where billno='" + refbillno + "')";// or RefBillNoSe='" + refbillno + "'"; if (!string.IsNullOrEmpty(condition)) { _condition = _condition + " and " + condition; } List list = MsWlPcDAL.GetDataList(_condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } // // GET:/TruckMng/MsWlPc/GetData [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetData(string handle, string condition, string refbillno) { MsWlPcHead pcHead = null; if (handle == "edit") { var list = MsWlPcDAL.GetDataList(condition,Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); if (list.Count > 0) pcHead = list[0]; } MsWlBsHead bsHead = MsWlBsDAL.GetHeadDataByBillNo(refbillno, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); if (pcHead == null) { pcHead = new MsWlPcHead(); if (!string.IsNullOrEmpty(refbillno)) { pcHead.MblNo = bsHead.MblNo; pcHead.VoyVeg = bsHead.VoyVeg; pcHead.EtDate = bsHead.EtDate; pcHead.EndPortDate = bsHead.EndPortDate; pcHead.YardCode = bsHead.SendYardCode; pcHead.YardName = bsHead.SendYardName; pcHead.DstArea = bsHead.DstArea; pcHead.DetiNation = bsHead.DetiNation; pcHead.LinkTel = bsHead.DetiLinkTel; pcHead.LinkMan = bsHead.DetiLinkMan; pcHead.DdCode = CookieConfig.GetCookie_UserCode(Request); pcHead.DdCode_Ref = CookieConfig.GetCookie_UserName(Request); pcHead.DdName = CookieConfig.GetCookie_UserName(Request); pcHead.BsType = bsHead.BsType; pcHead.BsType_Ref = bsHead.BsType_Ref; pcHead.CustLikeManCode = bsHead.CustLikeManCode; pcHead.CustLikeManName = bsHead.CustLikeManName; pcHead.CustTel = bsHead.CustTel; } } pcHead.RefCustomerName = bsHead.CustName; var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = pcHead }); return new ContentResult() { Content = json }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetData_ADL ( string handle, string condition, string refbillno ) { MsWlPcHead_ADL pcHead = null; if (handle == "edit") { var list = MsWlPcDAL.GetDataList_ADL(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); if (list.Count > 0) pcHead = list[0]; } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = pcHead }); return new ContentResult() { Content = json }; } // // GET:/TruckMng/MsWlPc/Save public ContentResult Save(string opstatus, string data, string ctnbody, string ctndelbody, string fixbody, string fixdelbody, string chfeebody, string chfeedelbody) { var head = JsonConvert.Deserialize(data); var fixBodyList = JsonConvert.Deserialize>(fixbody); var fixBodyDelList = JsonConvert.Deserialize>(fixdelbody); var chfeeBodyList = JsonConvert.Deserialize>(chfeebody); var chfeeBodyDelList = JsonConvert.Deserialize>(chfeedelbody); head.TotalMil = head.NoLoadMil + head.OverLoadMil; if (string.IsNullOrEmpty(head.ContainerType)) { head.ContainerQty = 0; } else { if (head.ContainerQty == 0) { head.ContainerQty = 1; } } if (string.IsNullOrEmpty(head.ContainerTypeSe)) { head.ContainerQtySe = 0; } else { if (head.ContainerQtySe == 0) { head.ContainerQtySe = 1; } } if(head.IsDouble=="on") { head.IsDouble = "1"; } if (opstatus == "add") { head.BillNo = PubSysDAL.GetBillNo("0111"); head.DbOperationType = DbOperationType.DbotIns; head.ModelUIStatus = "I"; head.UserCode = CookieConfig.GetCookie_UserCode(Request); head.UserName = CookieConfig.GetCookie_UserName(Request); head.OrgCode = CookieConfig.GetCookie_OrgCode(Request); head.OrgName = CookieConfig.GetCookie_OrgName(Request); head.LrDate = DateTime.Now; } else if (opstatus == "edit") { head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; } else { head.DbOperationType = DbOperationType.DbotDel; } var modb = new ModelObjectRepository(); DBResult result = modb.Save(head, ModelObjectConvert.ToModelObjectList(fixBodyList), ModelObjectConvert.ToModelObjectList(fixBodyDelList), ModelObjectConvert.ToModelObjectList(chfeeBodyList), ModelObjectConvert.ToModelObjectList(chfeeBodyDelList)); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsWlPcDAL.GetHeadDataByBillNo(head.BillNo,Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult Save_ADL ( string opstatus, string data, string ctnbody, string ctndelbody, string fixbody, string fixdelbody, string chfeebody, string chfeedelbody ) { var head = JsonConvert.Deserialize(data); var fixBodyList = JsonConvert.Deserialize>(fixbody); var fixBodyDelList = JsonConvert.Deserialize>(fixdelbody); var chfeeBodyList = JsonConvert.Deserialize>(chfeebody); var chfeeBodyDelList = JsonConvert.Deserialize>(chfeedelbody); head.TotalMil = head.NoLoadMil + head.OverLoadMil; if (string.IsNullOrEmpty(head.ContainerType)) { head.ContainerQty = 0; } else { if (head.ContainerQty == 0) { head.ContainerQty = 1; } } if (string.IsNullOrEmpty(head.ContainerTypeSe)) { head.ContainerQtySe = 0; } else { if (head.ContainerQtySe == 0) { head.ContainerQtySe = 1; } } if (head.IsDouble == "on") { head.IsDouble = "1"; } if (opstatus == "add") { //head.BillNo = PubSysDAL.GetBillNo("0111"); head.DbOperationType = DbOperationType.DbotIns; head.ModelUIStatus = "I"; head.UserCode = CookieConfig.GetCookie_UserCode(Request); head.UserName = CookieConfig.GetCookie_UserName(Request); head.OrgCode = CookieConfig.GetCookie_OrgCode(Request); head.OrgName = CookieConfig.GetCookie_OrgName(Request); head.LrDate = DateTime.Now; var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='陆运派车'", Convert.ToString(Session["COMPANYID"])); if (billnoset.BILLTYPE=="") billnoset.BILLTYPE = "0111"; if (billnoset.RULEDATETYPE == "") billnoset.RULEDATETYPE = "业务日期"; var bsdate = head.ExpDate; if (bsdate == "" || bsdate == null) bsdate = DateTime.Now.ToString("yyyy-MM-dd"); head.BillNo = MsSysBillNoSetDAL.GetBillNo(billnoset, bsdate, DateTime.Now.ToString("yyyy-MM")); //获取合同号 } else if (opstatus == "edit") { head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; } else { head.DbOperationType = DbOperationType.DbotDel; } var modb = new ModelObjectRepository(); DBResult result = modb.Save(head, ModelObjectConvert.ToModelObjectList(fixBodyList), ModelObjectConvert.ToModelObjectList(fixBodyDelList), ModelObjectConvert.ToModelObjectList(chfeeBodyList), ModelObjectConvert.ToModelObjectList(chfeeBodyDelList)); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsWlPcDAL.GetHeadDataByBillNo_ADL(head.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)) }; if (result.Success) { if (head.TruckNo != "") MsWlPcDAL.SaveTRUCKSTATUS(head.RefBillNo, "已派车"); if (string.IsNullOrEmpty(head.TruckNo)) MsWlPcDAL.SaveTRUCKSTATUS(head.RefBillNo, "待派车"); } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult Delete(string data) { var head = JsonConvert.Deserialize(data); var isfee = MsWlPcDAL.GetFeeCount(head.GId); if (isfee) { 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 tMsWlBsFixed where BillNo='" + head.BillNo + "'", "delete from ch_fee where BsNo='" + head.GId + "'", "delete from tcard_use where BillNo='" + head.BillNo + "'"); MsSysBillNoSetDAL.DeleteBsNo(head.BillNo); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } /* * RefBillNoSe, * ContainerTypeSe * ContainerQtySe,MblNoSe,VoyVegSe,"); strSql.Append(",EtDateSe,EndPortDateSe,YardCodeSe,"); strSql.Append("YardNameSe as YardCodeSe_Ref"); strSql.Append(",YardNameSe,DstAreaSe,FactoryAddrSe,DetiNationSe,LinkManSe,LinkTelSe,RtnYardCodeSe,"); strSql.Append("RtnYardNameSe as RtnYardCodeSe_Ref"); strSql.Append(",RtnYardNameSe,BillStatus,");*/ public ContentResult AddSB(string BS_BILLNO, string PC_BILLNO) { var strSql = new StringBuilder(); strSql.Append(" delete from BS_PC_Status where PC_BILLNO='" + PC_BILLNO + "'"); strSql.Append(" insert into BS_PC_Status values(newid(), '" + BS_BILLNO + "' ,'" + PC_BILLNO + "')"); strSql.Append(" update tmswlpchead set isdouble=1 "); strSql.Append(" ,RefBillNoSe='" + BS_BILLNO + "' "); strSql.Append(" ,ContainerTypeSe=(select ctnid from code_ctn where ctn=( select top 1 containertype from tMsWlBsCtn where Billno=(select gid from tMsWlBsHead where BillNo='" + BS_BILLNO + "'))) "); strSql.Append(" ,ContainerQtySe=( select top 1 ContainerQty from tMsWlBsCtn where Billno=(select gid from tMsWlBsHead where BillNo='" + BS_BILLNO + "')) "); strSql.Append(" ,MblNoSe=(select mblno from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" ,VoyVegSe=(select VoyVeg from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" ,EtDateSe=(select EtDate from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" ,EndPortDateSe=(select EndPortDate from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" ,YardCodeSe=(select YardCode from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" ,YardNameSe=(select YardName from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" ,RtnYardCodeSe=(select RtnYardCode from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" ,RtnYardNameSe=(select RtnYard from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" ,DstAreaSe=(select DstArea from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" ,FactoryAddrSe=(select FactoryAddr from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" ,DetiNationSe=(select DetiNation from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" ,LinkManSe=(select LinkMan from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" ,LinkTelSe=(select LinkTel from tMsWlBsHead where BillNo='" + BS_BILLNO + "') "); strSql.Append(" where billno='" + PC_BILLNO + "'"); var _count = 0; Database db = DatabaseFactory.CreateDatabase(); _count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString()); var jsonRespose = new JsonResponse { Success = true, Message = "添加双背路单成功" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeletePC(string BS_BILLNO, string data) { var head = JsonConvert.Deserialize(data); if (BS_BILLNO == head.RefBillNo) { return Delete(data); } else { var strSql = new StringBuilder(); strSql.Append("delete from BS_PC_Status where PC_BillNo='" + head.BillNo + "' and BS_BILLNO='" + BS_BILLNO + "'"); strSql.Append(" update tmswlpchead set isdouble=0 where billno='" + head.BillNo + "'"); var _count = 0; Database db = DatabaseFactory.CreateDatabase(); _count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString()); var jsonRespose = new JsonResponse { Success = true, Message = "删除双背路单成功" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } #region 设置主票 public ContentResult SetPGID(string GIDList, string PGID) { var _count = MsWlPcDAL.SetPGID(GIDList, PGID); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = 1, data = _count.ToString() }); return new ContentResult() { Content = json }; } #endregion #region 烟台爱德林项目 批量设置路单完成 public ContentResult SetEnd(string GIDList,string isEnd) { var _count = MsWlPcDAL.SetEnd(GIDList, isEnd); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = 1, data = _count.ToString() }); return new ContentResult() { Content = json }; } #endregion // // GET:/TruckMng/MsWlPc/GetFeeFixBodyList public ContentResult GetFeeFixBodyList(string billno) { var condition = " BillNo='" + billno + "'"; List list = MsWlPcDAL.GetBodyList(condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult DeleteFixBody(string GID) { var result = MsWlPcDAL.DeleteDetail(GID); ; var json = JsonConvert.Serialize(new { Success = result.Success, Message = result.Message }); return new ContentResult() { Content = json }; } public ContentResult GetTruckNoList(string condition,string query) { var list = MsWlPcDAL.GetTruckNoList( Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request), condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetTruckNoListRm(string TruckNo) { var condition = ""; if (string.IsNullOrEmpty(TruckNo)) { } else { condition = " TruckNo LIKE '%" + TruckNo + "%' "; } var list = MsWlPcDAL.GetTruckNoList(Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request), condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetTruckNoCanUse ( string condition, string query ) { var list = MsWlPcDAL.GetTruckNoList(Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request), " A.truckno not in (select DISTINCT truckno from tMsWlPcHead where isnull(isend,0)=0 ) " +condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetDrvNameList(string condition) { var list = MsWlPcDAL.GetDrvNameList( Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request), condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetDrvNameListRm(string DrvName) { var condition = ""; if (string.IsNullOrEmpty(DrvName)) { } else { condition = " DrvName LIKE '%" + DrvName + "%' "; } var list = MsWlPcDAL.GetDrvNameList(Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request), condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetTruckFuel(string truckNo,string loadType, decimal ton, decimal mil) { var fuel = MsWlPcDAL.GetTruckFuel(truckNo, loadType, ton, mil); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = fuel }); return new ContentResult() { Content = json }; } public ContentResult GetContainerNoList(string pcbillNo, string bsBillNo) { var list = MsWlPcDAL.GetContainerNoList(pcbillNo, bsBillNo); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetSealNoList(string bsBillNo) { var list = MsWlPcDAL.GetSealNoList(bsBillNo); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } /// /// 获取收费付费权限 /// /// /// public ContentResult GetFFSFPower ( string userid ) { int power = MsWlPcDAL.GetFFSFPower(userid); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = 1, power = power }); return new ContentResult() { Content = json }; } } }