You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

629 lines
26 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.Helper;
using HcUtility.Comm;
using HcUtility.Core;
using System.Collections.Generic;
using DSWeb.Areas.MvcShipping.DAL.MsOpSeaeTDSFTTemplate;
using DSWeb.Areas.MvcShipping.Models.MsOpSeaeTDExt;
using DSWeb.MvcShipping.DAL.MsOpSeaeTDExt;
using DSWeb.MvcShipping.DAL.MsOpSeaeTD;
using DSWeb.Common.DB;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOpSeaeTDExtController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ActionResult Xj()
{
return View();
}
//BjList
public ActionResult BjList()
{
return View();
}
public ActionResult BJReciveIndex()
{
return View();
}
public ActionResult test()
{
return View();
}
public ActionResult test2()
{
return View();
}
/// <summary>
///
/// </summary>
/// <param name="opstatus"></param>
/// <param name="data"></param>
/// <param name="bsstatus">0保存1提交</param>
/// <returns></returns>
public ContentResult Save(string opstatus, string data, string bsstatus)//,string data2)
{
string userid = Convert.ToString(Session["USERID"]);
var headData = JsonConvert.Deserialize<MsOpSeaeTDModel>(data);
headData.ETD = headData.ETD == "" ? null : headData.ETD;
headData.JieGangShiJian = headData.JieGangShiJian == "" ? null : headData.JieGangShiJian;
headData.JieDanShiJian = headData.JieDanShiJian == "" ? null : headData.JieDanShiJian;
headData.YOUXIAOQI = headData.YOUXIAOQI == "" ? null : headData.YOUXIAOQI;
if (opstatus == "add")
{
headData.INPUTBY = MsOpSeaeTDExtDAL.GetShowNameWithUserid(userid);
headData.INPUTBYID = userid;
headData.XJNO = MsOpSeaeTDExtDAL.CreateXJNO(userid);
if (headData.XJNO == "")
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "业务编号规则尚未设置。",
Data = headData
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
headData.INPUTDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.BSSTATUS = 0;
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.INPUTBY = MsOpSeaeTDExtDAL.GetShowNameWithUserid(userid);
headData.INPUTBYID = userid;
headData.BSSTATUS = Convert.ToInt32(bsstatus);
headData.DbOperationType = DbOperationType.DbotUpd;
}
else if (opstatus == "copy")
{
headData.INPUTBY = MsOpSeaeTDExtDAL.GetShowNameWithUserid(userid);
headData.INPUTBYID = userid;
headData.BSSTATUS = 0;
headData.XJNO = MsOpSeaeTDExtDAL.CreateXJNO(userid);
headData.INPUTDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.DbOperationType = DbOperationType.DbotIns;
}
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = headData
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
string userid = Convert.ToString(Session["USERID"]);
int totalCount = 0;
var dataList = MsOpSeaeTDExtDAL.GetDataList(condition, userid, start, limit, out totalCount);
//分页信息
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = dataList });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string handle, string condition)
{
string userid = Convert.ToString(Session["USERID"]);
if (userid == "" || userid == null)
{
var jsonRespose = new JsonResponse { Success = false, Message = "登陆状态失效,请重新登陆进行操作!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
string INPUTBY = Convert.ToString(Session["SHOWNAME"]);
MsOpSeaeTDModel head = null;
if (handle == "edit")
{
head = MsOpSeaeTDExtDAL.GetData(condition, userid);
}
if (handle == "copy")
{
head = MsOpSeaeTDExtDAL.GetData(condition, userid);
head.GID = Guid.NewGuid().ToString();
head.INPUTBY = INPUTBY;
head.INPUTBYID = userid;
head.XJNO = "";
head.INPUTDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
if (handle == "addFen")
{
}
if (handle == "add")
{
head = new MsOpSeaeTDModel();
head.GID = Guid.NewGuid().ToString();
head.PORTLOAD = "QINGDAO,CHINA";
head.PORTLOADID = "CNQWG/4258";
head.INPUTDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.PLACEDELIVERY = "QINGDAO,CHINA";
head.PLACEDELIVERYID = "CNQWG/4258";
head.TiDanFenShu = "THREE";
head.YunShuTiaoKuan = "CY-CY";
head.FuFeiFangShi = "191A7500-680D-42FC-8712-74D9C7967BE8";//FREIGHT PREPAID
head.GP20 = 0;
head.GP40 = 0;
head.HC40 = 0;
head.MARKS = "N/M";
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
//下拉框
public ContentResult GetSelDataWithName(string name, string condition = "")
{
string userid = Convert.ToString(Session["USERID"]);
string comid = Convert.ToString(Session["COMPANYID"]);
var dataList = MsOpSeaeTDExtDAL.GetSelDataWithName(name, userid, comid, condition);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = dataList });
return new ContentResult() { Content = json };
}
public ContentResult GetData_XJ(string tid)
{
string userid = Convert.ToString(Session["USERID"]);
if (tid == "*")
{
MsOpSeaeTDXJModel head = new MsOpSeaeTDXJModel();
head.XJNO = "*";
head.GID = "*";
head.GP20 = 0;
head.GP40 = 0;
head.HC40 = 0;
head.FREEDAYS = 0;
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
else
{
string condition = "t.tid = '" + tid + "'";
if (userid == "" || userid == null)
{
var jsonRespose = new JsonResponse { Success = false, Message = "登陆状态失效,请重新登陆进行操作!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
MsOpSeaeTDXJModel head = MsOpSeaeTDExtDAL.GetData_XJ(condition, userid);
if (head == null)
{
MsOpSeaeTDModel TDM = MsOpSeaeTDExtDAL.GetData("t.gid = '" + tid + "'", userid);
head = new MsOpSeaeTDXJModel();
head.GID = "*";
head.INPUTDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.XJNO = TDM.XJNO;
head.MBLNO = TDM.MBLNO;
head.PLACEDELIVERY = TDM.PLACEDELIVERY;
head.PORTDISCHARGE = TDM.PORTDISCHARGE;
head.PORTLOAD = TDM.PORTLOAD;
head.DESTINATION = TDM.DESTINATION;
head.DESCRIPTION = TDM.DESCRIPTION;
head.Remarks = TDM.DingCangYaoQiu;
head.GP20 = TDM.GP20;
head.GP40 = TDM.GP40;
head.HC40 = TDM.HC40;
head.OtherCtn = TDM.OtherCtn;
head.ETD = TDM.ETD;
head.YOUXIAOQI = TDM.YOUXIAOQI;
head.FREEDAYS = TDM.FREEDAYS;
head.FREEDAYSM = TDM.FREEDAYSM;
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
}
public ContentResult GetBodyList_XJ(string xjid)
{
string userid = Convert.ToString(Session["USERID"]);
if (xjid == "*")
{
var json2 = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = "" });
return new ContentResult() { Content = json2 };
}
List<MsOpSeaeTDXJHDModel> bodyList = MsOpSeaeTDExtDAL.GetDataList_XJ_HD("t.xjid = '" + xjid + "'", userid);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = bodyList });
return new ContentResult() { Content = json };
}
/// <summary>
///
/// </summary>
/// <param name="send"></param>
/// <param name="data"></param>
/// <param name="body"></param>
/// <param name="bsstatus">0已录入1已提交2已询价3已报价4已确认</param>
/// 前台点击发送询价时send=1 bsstatus=2
/// <returns></returns>
public ContentResult SaveXj(string send, string data, string body, string bsstatus)
{
string userid = Convert.ToString(Session["USERID"]);
string INPUTBY = Convert.ToString(Session["SHOWNAME"]);
var headData = JsonConvert.Deserialize<MsOpSeaeTDXJModel>(data);
headData.YOUXIAOQI = headData.YOUXIAOQI == "" ? null : headData.YOUXIAOQI;
headData.ETD = headData.ETD == "" ? null : headData.ETD;
List<MsOpSeaeTDXJHDModel> hdData = JsonConvert.Deserialize<List<MsOpSeaeTDXJHDModel>>(body);//询价货代列表
var modb = new ModelObjectDB();
headData.SENDDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
if (headData.GID == "*")
{
if (headData.XJNO == "*" && headData.TID == "*")
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.INPUTDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string XJNO = MsOpSeaeTDExtDAL.CreateXJNO(userid);
MsOpSeaeTDModel td = new MsOpSeaeTDModel();
if (send == "1")
{
td.BSSTATUS = 2;
headData.Sender = userid;
}
else
{
td.BSSTATUS = Convert.ToInt32(bsstatus);
if (td.BSSTATUS == 1)
{
td.XJRID = headData.XJRID;
}
}
td.GID = Guid.NewGuid().ToString();
td.GP20 = headData.GP20;
td.GP40 = headData.GP40;
td.HC40 = headData.HC40;
td.PORTDISCHARGE = headData.PORTDISCHARGE;
td.PORTLOAD = headData.PORTLOAD;
td.DESCRIPTION = headData.DESCRIPTION;
td.PLACEDELIVERY = headData.PLACEDELIVERY;
td.DESTINATION = headData.DESTINATION;
td.FREEDAYS = headData.FREEDAYS;
td.FREEDAYSM = headData.FREEDAYSM;
td.HangChengDAYS = headData.HangChengDAYS;
td.IsZhuanGang = headData.IsZhuanGang;
td.ETD = headData.ETD;
td.OtherCtn = headData.OtherCtn;
td.DingCangYaoQiu = headData.Remarks;
td.DbOperationType = DbOperationType.DbotIns;
td.INPUTDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
td.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
td.XJNO = XJNO;
td.INPUTBY = INPUTBY;
td.INPUTBYID = userid;
DBResult resultTd = modb.Save(td);
if (resultTd.Success)
{
headData.GID = Guid.NewGuid().ToString();
headData.TID = td.GID;
headData.XJNO = td.XJNO;
}
else
{
var jsonResposeT = new JsonResponse
{
Success = false,
Message = "保存生成托单失败"
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonResposeT) };
}
}
else
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.INPUTDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.GID = Guid.NewGuid().ToString();
}
}
else if (headData.GID != "*")
{
//如果是提交操作判断是否允许
if (bsstatus == "1")
{
string msg = "";
if (!MsOpSeaeTDExtDAL.AllowSubmit(headData.TID, out msg))
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = msg,
Data = headData
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
headData.DbOperationType = DbOperationType.DbotUpd;
if (send == "1")
{
headData.Sender = userid;
}
}
DBResult result = modb.Save(headData);
if (result.Success)
{
result = MsOpSeaeTDExtDAL.SaveTDXJDetail(headData, hdData);
if (result.Success)
{
MsOpSeaeTDExtDAL.InsertHDBJ(headData, hdData);
if (send == "1")
{
MsOpSeaeTDExtDAL.SendXJMail(headData, hdData);
}
if (bsstatus != "0")
{
MsOpSeaeTDModel td = MsOpSeaeTDExtDAL.GetData("t.gid='" + headData.TID + "'", userid);
td.BSSTATUS = Convert.ToInt32(bsstatus);
td.DbOperationType = DbOperationType.DbotUpd;
DBResult dbr2 = modb.Save(td);
}
//更新托单箱型
MsOpSeaeTDExtDAL.updateTDCTN(headData.GP40, headData.GP20, headData.HC40, headData.OtherCtn, headData.TID);
//MsOpSeaeTDExtDAL.UpdateBSStatus(headData.GID, 2);
}
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = headData
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//获取报价列表
public ContentResult GetBJList(string condition, int page, int limit, string sort)
{
string userid = Convert.ToString(Session["USERID"]);
int start = (page - 1) * limit + 1;
int totalCount = 0;
var dataList = MsOpSeaeTDExtDAL.GetBJList(condition, userid, start, limit, out totalCount, sort);
//分页信息
if (dataList.Count > 0)
{
var xjObj = MsOpSeaeTDExtDAL.GetData_XJ($" gid='{dataList[0].XJID}'", userid);
if (!string.IsNullOrEmpty(xjObj.YOUXIAOQI) && Convert.ToDateTime(xjObj.YOUXIAOQI) > DateTime.Now)
{
//有“询价截止前不能查看报价”权限的人,在询价截止前不能看到数据
CompanyDataContext companyDataContext = new CompanyDataContext();
var authObj = companyDataContext.UserVirtualModules.FirstOrDefault(um => um.UserId == userid && um.ModuleId == "FD94D24BA407415FAB14898EA85D51ED");
if (authObj != null && authObj.HasAuth)
{
dataList = new List<MsOpSeaeTDXJBJ>();
}
}
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = dataList });
return new ContentResult() { Content = json };
}
//获取费用列表
public ContentResult GetFeeList(string condition, int currPage, int limit, string sort, string tid)
{
string userid = Convert.ToString(Session["USERID"]);
int start = (currPage - 1) * limit + 1;
int totalCount = 0;
List<MsOpSeaeTDFee> dataList = MsOpSeaeTDExtDAL.GetFeeList(condition, userid, 1, 100, out totalCount);
//分页信息
if (dataList.Count == 0)
{
MsOpSeaeTDFee f = new MsOpSeaeTDFee();
f.GID = "*";
f.TID = tid;
f.FNAME = "海运费";
f.FBIBIE = "USD";
f.FBIAOZHUN = "票";
f.FDANJIA = "0";
f.FSHULIANG = "0";
f.FJINE = "0";
f.FHUILV = "1";
MsOpSeaeTDFee f2 = new MsOpSeaeTDFee();
f2.GID = "*";
f2.TID = tid;
f2.FNAME = "箱使费";
f2.FBIBIE = "RMB";
f2.FBIAOZHUN = "天";
f2.FDANJIA = "0";
f2.FSHULIANG = "0";
f2.FJINE = "0";
f2.FHUILV = "1";
dataList.Add(f);
dataList.Add(f2);
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = dataList });
return new ContentResult() { Content = json };
}
//费用中标 接受报价
public ContentResult ApplyFee(string gid, string tid, string op)
{
string userid = Convert.ToString(Session["USERID"]);
string msg = "";
bool rst = MsOpSeaeTDExtDAL.ApplyFee(gid, userid, tid, op, out msg);
var json = JsonConvert.Serialize(
new { Success = rst, Message = msg, data = "" });
return new ContentResult() { Content = json };
}
//费用删除
public ContentResult DelFee(string gid)
{
string userid = Convert.ToString(Session["USERID"]);
DBResult rst = MsOpSeaeTDExtDAL.DelFee(userid, gid);
var json = JsonConvert.Serialize(
new { Success = rst.Success, Message = rst.Message, data = "" });
return new ContentResult() { Content = json };
}
//费用删除
public ContentResult DelTD(string gids)
{
string userid = Convert.ToString(Session["USERID"]);
DBResult rst = MsOpSeaeTDExtDAL.DelTD(userid, gids);
var json = JsonConvert.Serialize(
new { Success = rst.Success, Message = rst.Message, data = "" });
return new ContentResult() { Content = json };
}
//保存收发通模板
public ContentResult SaveSFT(string name, string text, string type, string optype)
{
string userid = Convert.ToString(Session["USERID"]);
bool has = MsOpSeaeTDSFTTemplateDAL.GetIsExist(name, userid);
if (has)
{
var json = JsonConvert.Serialize(new { Success = false, Message = "已存在此模板名!", Data = "" });
return new ContentResult() { Content = json };
}
else
{
DBResult rst = MsOpSeaeTDExtDAL.SaveSFT(name, text, type, userid);
var json = JsonConvert.Serialize(new { Success = rst.Success, Message = rst.Message, data = "" });
return new ContentResult() { Content = json };
}
}
//获取收发通模板
public ContentResult GetSFTWithGID(string gid)
{
string userid = Convert.ToString(Session["USERID"]);
MsOpSeaeTMB mb = MsOpSeaeTDExtDAL.GetMBWithGID(gid, userid);
var json = JsonConvert.Serialize(
new { Success = mb.GID == null ? false : true, Message = "", data = mb });
return new ContentResult() { Content = json };
}
//获取收发通模板
public ContentResult GetBJDetailsList(string gid)
{
string userid = Convert.ToString(Session["USERID"]);
List<MsOpSeaeHDBJFFee> dataList = MsOpSeaeTDExtDAL.GetBJDetailsList(gid, userid);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = dataList });
return new ContentResult() { Content = json };
}
//根据供应商关系分组获取货代及联系人列表
public ContentResult GetHDListWithTCustID(string gid)
{
List<MsOpSeaeTDXJHDModel> bodyList = null;
string userid = Convert.ToString(Session["USERID"]);
string comid = Convert.ToString(Session["COMPANYID"]);
bodyList = MsOpSeaeTDExtDAL.GetHDListWithTCustID(gid, userid, comid);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = bodyList });
return new ContentResult() { Content = json };
}
//撤销提交
public ContentResult CancelTD(string tid)
{
string userid = Convert.ToString(Session["USERID"]);
if (userid == null || userid == "")
{
var json2 = JsonConvert.Serialize(
new { Success = false, Message = "登录失效!", data = "" });
return new ContentResult() { Content = json2 };
}
string msg = "";
bool rst = MsOpSeaeTDExtDAL.CancelTD(tid, out msg);
var json = JsonConvert.Serialize(
new { Success = rst, Message = msg, data = "" });
return new ContentResult() { Content = json };
}
public ContentResult CancelTDForXJ(string gid)
{
string userid = Convert.ToString(Session["USERID"]);
if (userid == null || userid == "")
{
var json2 = JsonConvert.Serialize(
new { Success = false, Message = "登录失效!", data = "" });
return new ContentResult() { Content = json2 };
}
string msg = "";
bool rst = MsOpSeaeTDExtDAL.CancelTDForXJ(gid, out msg);
var json = JsonConvert.Serialize(
new { Success = rst, Message = msg, data = "" });
return new ContentResult() { Content = json };
}
public ContentResult GetPower()
{
string userid = Convert.ToString(Session["USERID"]);
int pSend = 0;
MsOpSeaeTDExtDAL.GetPower(userid, out pSend);
var jsonRespose = new JsonResponse { Success = true, Message = "", Data = pSend.ToString() };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeletePiLiang(string gids)
{
DBResult result = MsOpSeaeTDExtDAL.DeletePiLiang(gids);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetXjMainInfo(string gid)
{
string rst = MsOpSeaeTDExtDAL.GetXjMainInfo(gid);
var jsonRespose = new JsonResponse { Success = true, Data = rst };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
}