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.
DS7/DSWeb/Areas/WMS/Controllers/WMS_DOController.cs

1020 lines
36 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.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.TruckMng.Helper.Repository;
using DSWeb.Areas.MvcShipping.DAL.MsOp_YAXIANG;
using DSWeb.MvcShipping.Models.MsOp_YAXIANG;
using DSWeb.Areas.OA.Models.WorkFlow;
using DSWeb.EntityDA;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;//编码规则
using DSWeb.Areas.SysMng.DAL.SysTask;
using DSWeb.MvcShipping.DAL.MsOpSeaiDAL;
using DSWeb.MvcShipping.Models.MsOpSeai;//海运进口业务
using DSWeb.Areas.Import.Models.Comm;//用于生成费用
using DSWeb.Areas.CommMng.Models;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;//查询OP权限
using DSWeb.MvcShipping.DAL.MsCodeOpDef;
namespace DSWeb.WMS.Controllers
{
/// <summary>
/// 仓储执行模块 邓羽 20200720
/// </summary>
[JsonRequestBehavior]
public class WMS_DOController : Controller
{
//
// GET: /RptMng/MsRptPcHeadQry
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
/// <summary>
/// 由海运进口模块调用参数是由逗号隔开的海运进口业务的BSNO
/// 如不可生成则返回错误
/// </summary>
/// <param name="BillnoList"></param>
/// <returns></returns>
public ContentResult MakeYX(string SeaiGIDListStr) {
var result = new JsonResponse
{
Success = false,
Message = "",
Data = null//fieldlist
};
var SeaiList = MsOpSeaiDAL.GetDataList(" BSNO in ("+ SeaiGIDListStr + ")",Session["USERID"].ToString(),Session["SHOWNAME"].ToString(),Session["COMPANYID"].ToString());
//1.查询这些业务是否已生成押箱业务
var ExistYX = BasicDataRefDAL.GeneralSelect("MsOp_YAXIANG_Detail","BSNO","YXNO", "BSNO in("+ SeaiGIDListStr + ")");
Database db = DatabaseFactory.CreateDatabase();
var newMessage = "";
var existMessage = "";
var NewYXNO = "";
var YXDetailList = new List<YX_DETAILmb>();
if (ExistYX.Count > 0) {
foreach (var YX in ExistYX) {
foreach (var Opseai in SeaiList) {
if (Opseai.BSNO == YX.GID) {
Opseai.SetValue("YXNO", YX.GVALUE);
}
}
}
}
var basebody = new YX_DETAILmb();
basebody.GetTableField(db);
foreach (var Opseai in SeaiList)
{
if (Opseai.GetValue("YXNO") == "")
{
if (newMessage == "")
{
NewYXNO = MsSysBillNoSetDAL.GetNewNo("押箱业务","委托编号", Session["COMPANYID"].ToString(), System.DateTime.Now.ToString("yyyy-MM-dd"));
newMessage = " 生成新的押箱单" + NewYXNO;
}
var yxdetail = new YX_DETAILmb();
basebody.Copy(yxdetail);
yxdetail.SetValue("BSNO", Opseai.BSNO);
yxdetail.setDefault();
YXDetailList.Add(yxdetail);
}
else {
if (existMessage == "")
{
existMessage = " 以下已经生成押箱单的业务未作处理:" ;
}
existMessage += " " + Opseai.CUSTNO+";";
}
}
//2.对未生成押箱业务的,生成押箱业务
if (newMessage != "")
{
var head = new YXmb();
head.GetTableField(db);
head.SetValue("GID", System.Guid.NewGuid().ToString());
head.SetValue("YXNO", NewYXNO);
head.SetValue("COMPANYID", Session["COMPANYID"].ToString());
head.SetValue("DEPTID", Session["DEPTGID"].ToString());
head.SetValue("CREATEUSER", Session["USERID"].ToString());
head.SetValue("CREATETIME", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
head.SetValue("YXSTATE", "3001");//初始状态
head.SetValue("YXMONEY", "0");//
head.SetValue("RETURNMONEY", "0");//
head.SetValue("SPENDMONEY", "0");//
//20191223 根据设定的默认值设定字段默认值
var FieldList = MsCodeOpDefDAL.GetDataList(" BSTYPE='押箱业务' ", Convert.ToString(Session["COMPANYID"]));
if (FieldList.Count > 0)
{
foreach (var field in FieldList)
{
//SetPropertyValue
head.SetValue(field.FIELDNAME, field.DEFVALUE);
}
}
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
var modb = new ModelObjectRepository();
DBResult _r = modb.Save(head,
ModelObjectConvert<YX_DETAILmb>.ToModelObjectList(YXDetailList),
ModelObjectConvert<YX_DETAILmb>.ToModelObjectList(null)
);
result.Success = true;
result.Message = newMessage + existMessage;
}
else {
result.Success = false;
result.Message = existMessage;
}
return new ContentResult() { Content = JsonConvert.Serialize(result) };
}
/// <summary>
/// 生成费用 目前产生录入状态的费用
/// </summary>
/// <param name="Head"></param>
/// <param name="Body"></param>
/// <returns></returns>
public ContentResult MakeFee(string Head, string Body)
{
Database db = DatabaseFactory.CreateDatabase();
var basebody = new YX_DETAILmb();
basebody.GetTableField(db);
var BodyList = new List<YX_DETAILmb>();
//var DelBodyList = new List<YX_DETAILmb>();
var head = new YXmb();
head.SetValue(db, Head);
var USERID = Convert.ToString(Session["USERID"]);
var enterdate = DateTime.Now;
if (Body != "")
{
var savedl = JsonConvert.Deserialize<List<Dictionary<string, string>>>(Body);
foreach (var sdl in savedl)
{
var body = new YX_DETAILmb();
basebody.Copy(body);
body.SetValue(sdl);
BodyList.Add(body);
}
}
var ChfeeList = new List<MsChFee>();
var existFeeList = new List<GeneralModel>();
existFeeList = BasicDataRefDAL.GeneralSelect(string.Format("select bsno gid,feename gvalue from ch_fee where feename in('修箱费','洗箱费','修洗箱费','超期箱使费','滞纳金') and feetype=2 and bxgid='{0}'", head.GetValue("YXNO")));
foreach (var YXDetail in BodyList) {
//修箱费
if (Convert.ToDecimal(YXDetail.GetValue("FIXFEE")) > 0 && !FeeExist(existFeeList, YXDetail.GetValue("BSNO"), "修箱费"))
{
var fee = getFee(head.GetValue("YXNO"), YXDetail.GetValue("BSNO"), "修箱费", Convert.ToDecimal(YXDetail.GetValue("FIXFEE")));
ChfeeList.Add(fee);
}
//洗箱费
if (Convert.ToDecimal(YXDetail.GetValue("WASHFEE")) > 0 && !FeeExist(existFeeList, YXDetail.GetValue("BSNO"), "洗箱费"))
{
var fee = getFee(head.GetValue("YXNO"), YXDetail.GetValue("BSNO"), "洗箱费", Convert.ToDecimal(YXDetail.GetValue("WASHFEE")));
ChfeeList.Add(fee);
}
//修洗箱费
if (Convert.ToDecimal(YXDetail.GetValue("FWFEE")) > 0 && !FeeExist(existFeeList, YXDetail.GetValue("BSNO"), "修洗箱费"))
{
var fee = getFee(head.GetValue("YXNO"), YXDetail.GetValue("BSNO"), "修洗箱费", Convert.ToDecimal(YXDetail.GetValue("FWFEE")));
ChfeeList.Add(fee);
}
//超期箱使费
if (Convert.ToDecimal(YXDetail.GetValue("OVERFEE")) > 0 && !FeeExist(existFeeList, YXDetail.GetValue("BSNO"), "超期箱使费"))
{
var fee = getFee(head.GetValue("YXNO"), YXDetail.GetValue("BSNO"), "超期箱使费", Convert.ToDecimal(YXDetail.GetValue("OVERFEE")));
ChfeeList.Add(fee);
}
//滞纳金
if (Convert.ToDecimal(YXDetail.GetValue("LATEFEE")) > 0 && !FeeExist(existFeeList, YXDetail.GetValue("BSNO"), "滞纳金"))
{
var fee = getFee(head.GetValue("YXNO"), YXDetail.GetValue("BSNO"), "滞纳金", Convert.ToDecimal(YXDetail.GetValue("LATEFEE")));
ChfeeList.Add(fee);
}
}
if (ChfeeList.Count > 0) {
foreach (var _d in ChfeeList)
{
_d.FeeStatus = 1;//生成录入状态的费用
_d.DbOperationType = DbOperationType.DbotIns;
_d.CustomerName = head.GetValue("CUSTOMERNAME");
}
}
var modb = new ModelObjectRepository();
var result = new DBResult();
if (ChfeeList.Count > 0)
{
result = modb.SaveHead(
ModelObjectConvert<MsChFee>.ToModelObjectList(ChfeeList)
);
}
else {
result.Success = false;
result.Message = "所有费用目前均已生成";
}
return new ContentResult() { Content = JsonConvert.Serialize(result) };
}
private MsChFee getFee(string YXNO, string BSNO, string FEENAME, decimal AMOUNT) {
var data = new MsChFee();
data.GId = Guid.NewGuid().ToString();
data.BsNo = BSNO;
data.UnitPrice = Convert.ToDecimal(AMOUNT);
data.Quantity = 1;
data.Amount = Convert.ToDecimal(AMOUNT);
//data.NoTaxAmount = Convert.ToDecimal(_C.prepayments);
data.FeeName = FEENAME;
//var CURRList = BasicDataRefDAL.GetcurrRefList("gid='" + _C.currid + "'");
var CURR = "RMB";
data.Currency = CURR;
data.ExChangerate = 1;
data.CARGO_GID = YXNO;//用CARGO_GID盛放YXNO
data.Remark = "押箱单号" + YXNO;//;
data.FeeType = 2;//应付
data.EnteroPerator = Session["USERID"].ToString();
data.EnterDate = DateTime.Now;
data.FeeStatus = 0;
return data;
}
private bool FeeExist(List<GeneralModel> existFeeList,string BSNO,string FEENAME)
{
foreach (var fee in existFeeList) {
if (fee.GID == BSNO && fee.GVALUE == FEENAME) {
return true;
}
}
return false;
}
#region 押箱业务 头表/明细表
//public ContentResult GetSqlStr(string YXNOList) {
// string sql = MsOp_YAXIANGDAL.gethea;
//}
public ContentResult GetDataList(int start, int limit, string condition, string sort="")
{
var dataList = MsOp_YAXIANGDAL.GetDataList(condition,Session["USERID"].ToString(), sort);
var _list = dataList.Skip(start).Take(limit);
//var list = new List<Dictionary<string, string>>();
//if (_list.Count() > 0) {
// foreach (var data in _list) {
// list.Add(data.ExtendDic);
// }
//}
var list_2 = ModelObjectBill.getDicList(ModelObjectConvert<YXmb>.ToModelObjectList(dataList));
var list_3 = list_2.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new
{
Success = true,
Message = "查询成功",
totalCount = dataList.Count(),
data = list_3.ToList()
//totalCount = dataList.Count,
//data = list.ToList()
//,fieldlist = fieldlist.ToList()
});
return new ContentResult() { Content = json };
}
public ContentResult GetData( string condition)
{
var data = MsOp_YAXIANGDAL.GetData(condition, Session["USERID"].ToString());
var result = new YXmb();
if (data.GetValue("CREATEUSER")!="")
{//代表不是新增的,存在现存数据
result = data;
}
else {
//新增数据 需设定默认值
var createtimeStr = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
result.SetValue("CREATETIME", createtimeStr);
result.SetValue("CREATEUSER", Session["USERID"].ToString());
result.SetValue("COMPANYID", Session["COMPANYID"].ToString());
result.SetValue("DEPTID", Session["DEPTGID"].ToString());
//YXMONEY SPENDMONEY RETURNMONEY
result.SetValue("YXMONEY", "0.00");
result.SetValue("SPENDMONEY", "0.00");
result.SetValue("RETURNMONEY", "0.00");
}
var json = JsonConvert.Serialize(new
{
Success = true,
Message = "查询成功",
//totalCount = 1,
data = result.ExtendDic
//,fieldlist = fieldlist.ToList()
});
return new ContentResult() { Content = json };
}
public ContentResult GetBodyList( string condition )
{
var dataList = MsOp_YAXIANGDAL.GetBodyList(condition);
var list = new List<Dictionary<string, string>>();
if (dataList.Count() > 0)
{
foreach (var data in dataList)
{
list.Add(data.ExtendDic);
}
}
var json = JsonConvert.Serialize(new
{
Success = true,
Message = "查询成功",
totalCount = list.Count,
data = list.ToList()
});
return new ContentResult() { Content = json };
}
#endregion
public ContentResult Save(string opstatus, string data, string Body, string DelBody)//
{
var modb = new ModelObjectRepository();
Database db = DatabaseFactory.CreateDatabase();
var head = new YXmb();
head.SetValue(db, data);
var basebody = new YX_DETAILmb();
basebody.GetTableField(db);
var BodyList = new List<YX_DETAILmb>();
var DelBodyList = new List<YX_DETAILmb>();
if (Body != "")
{
var savedl = JsonConvert.Deserialize<List<Dictionary<string, string>>>(Body);
foreach (var sdl in savedl)
{
var body = new YX_DETAILmb();
basebody.Copy(body);
body.SetValue(sdl);
BodyList.Add(body);
}
}
if (opstatus == "add")
{
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
head.SetValue("GID", System.Guid.NewGuid().ToString());
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='押箱业务' AND RULEBLNO='押箱编号' ", Convert.ToString(Session["COMPANYID"]));
var _date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
var YXNO = MsSysBillNoSetDAL.GetBillNo(billnoset, _date, _date, "", Session["USERID"].ToString(), Session["COMPANYID"].ToString());
}
else if (opstatus == "edit")
{
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
}
else
{
head.DbOperationType = DbOperationType.DbotDel;
}
DBResult result = modb.Save(head,
ModelObjectConvert<YX_DETAILmb>.ToModelObjectList(BodyList),
ModelObjectConvert<YX_DETAILmb>.ToModelObjectList(DelBodyList)
);
//保存完成后重新计算头表的实际扣款。
MsOp_YAXIANGDAL.ReCount(head);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOp_YAXIANGDAL.GetData(head.GetBillNoFieldName() + " = '" + head.GetBillNoValue() + "'",Session["USERID"].ToString()).ExtendDic//fieldlist
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
private static void updateMoney(string YXNO) {
var strSql = " update MsOp_YAXIANG set SPENDMONEY= ";
}
public ContentResult Delete(string data)
{
Database db = DatabaseFactory.CreateDatabase();
var head = new YXmb();
head.SetValue(db, data);
var canbedel = SysTaskDAL.TaskGetWord(head.GetValue("YXSTATE"),"candelete");
var HeadList = getCanOPList("["+data+"]");
//var canbedel = true;
if (canbedel == false && HeadList.Count>0)
{
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 MsOp_YAXIANG_DETAIL where YXNO='" + head.GetValue("YXNO") + "'");
//MsSysBillNoSetDAL.DeleteBsNo(head.BillNo);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DelDetail(string data,string GID)
{
Database db = DatabaseFactory.CreateDatabase();
var head = new YXmb();
head.SetValue(db, data);
var canbedel = SysTaskDAL.TaskGetWord(head.GetValue("YXSTATE"), "candelete");
//canbedel = true;
if (canbedel == false)
{
var jsonRespose = new JsonResponse { Success = false, Message = "此状态下的押箱业务不能进行删除!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var strSql = new StringBuilder();
var jsonRespose = new JsonResponse { Success = false, Message = "" };
strSql.Append(" delete from MsOp_YAXIANG_DETAIL where GID in (" + GID + ")");
try
{
var _r = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
MsOp_YAXIANGDAL.ReCount(head);
}
catch (Exception ee)
{
jsonRespose.Success = false;
jsonRespose.Message = ee.Message;
}
jsonRespose.Success = true;
jsonRespose.Message = "明细删除成功";
jsonRespose.Data = MsOp_YAXIANGDAL.GetData(head.GetBillNoFieldName() + " = '" + head.GetBillNoValue() + "'",Session["USERID"].ToString()).ExtendDic;
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#region 状态变更
public ContentResult PushState(string data,string Execution) {
Database db = DatabaseFactory.CreateDatabase();
var head = new YXmb();
head.SetValue(db, data);
return doPushState(head, Execution);
}
private ContentResult doPushState(YXmb head, string Execution)
{
var modb = new ModelObjectRepository();
JsonResponse result = new JsonResponse();
var STATE = head.GetValue("YXSTATE");
var newState = SysTaskDAL.DoExecution(STATE, Execution);
if (newState.STATEKEY == "0000")
{
result.Success = false;
result.Message = head.GetValue("YXSTATEREF") + "状态下的业务不能进行此操作";
}
else
{
head.SetValue("YXSTATE", newState.STATEKEY);
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
var _r = modb.Save(head);
result.Success = _r.Success;
result.Message = _r.Message;
MsOp_YAXIANGDAL.ReCount(head);
}
return new ContentResult() { Content = JsonConvert.Serialize(result) };
}
public ContentResult PushState_List(string dataList, string Execution)
{
Database db = DatabaseFactory.CreateDatabase();
var baseHead = new YXmb();
baseHead.GetTableField(db);
var HeadList = new List<YXmb>();
if (dataList != "")
{
var savedl = JsonConvert.Deserialize<List<Dictionary<string, string>>>(dataList);
foreach (var sdl in savedl)
{
var head = new YXmb();
baseHead.Copy(head);
head.SetValue(sdl);
HeadList.Add(head);
}
if (HeadList.Count > 0) {
foreach (var head in HeadList) {
doPushState(head, Execution);
}
}
}
JsonResponse result = new JsonResponse();
result.Success = true;
return new ContentResult() { Content = JsonConvert.Serialize(result) };
}
//public ContentResult SQQR ( string USERID, string data ) //申请签入
//{
// var _r1 = SaveList_P(data);
// var _L = new List<MsOp_BLISSUEmb>();
// var result = new DBResult();
// foreach (var _p in _r1) {
// if (_p.BLSTATUS != "录入状态")
// {
// }
// 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<MsOp_BLISSUEmb>();
// var result = new DBResult();
// foreach (var _p in _r1)
// {
// if (_p.BLSTATUS != "待签入")
// {
// }
// 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<MsOp_BLISSUEmb>();
// 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<MsOp_BLISSUEmb>();
// 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) };
//}
#endregion
#region 工作流控制
private List<YXmb> getCanOPList(string dataList)
{
Database db = DatabaseFactory.CreateDatabase();
var baseHead = new YXmb();
baseHead.GetTableField(db);
var HeadList = new List<YXmb>();
var dicCanedit = new Dictionary<string, string>();
var modname = "modYAXIANG";
var userid = Session["USERID"].ToString();
if (dataList != "")
{
var savedl = JsonConvert.Deserialize<List<Dictionary<string, string>>>(dataList);
if (savedl.Count > 0)
foreach (var sdl in savedl)
{
var head = new YXmb();
baseHead.Copy(head);
head.SetValue(sdl);
//此处获取编辑权限
var canedit = "F";
if (!dicCanedit.TryGetValue(head.GetValue("CREATEUSER"), out canedit))
{
if (MsBaseInfoDAL.GetCanOP(modname, userid, head.GetValue("CREATEUSER")))
{
dicCanedit.Add(head.GetValue("CREATEUSER"), "T");
}
else dicCanedit.Add(head.GetValue("CREATEUSER"), "F");
}
else
{
}
if (dicCanedit[head.GetValue("CREATEUSER")] == "T")
{
HeadList.Add(head);
}
}
}
return HeadList;
}
//提交
public ContentResult SubmitAudit(string dataList) {
Database db = DatabaseFactory.CreateDatabase();
var baseHead = new YXmb();
baseHead.GetTableField(db);
var HeadList = getCanOPList(dataList);
if (HeadList.Count>0)
foreach (var head in HeadList)
{
AuditInfomb AuditInfo = AuditInfomb.getExecutionAudit(head, "YAXIANGAudit", "3000", Session["USERID"].ToString());
if (AuditInfo.cando())
{
var _r = WorkFlowDAL.SubmitAudit(AuditInfo);
}
}
JsonResponse result = new JsonResponse();
result.Success = true;
return new ContentResult() { Content = JsonConvert.Serialize(result) };
}
//撤回
public ContentResult SubmitAuditBack(string dataList)
{
Database db = DatabaseFactory.CreateDatabase();
var baseHead = new YXmb();
baseHead.GetTableField(db);
var HeadList = getCanOPList(dataList);
if (HeadList.Count > 0)
foreach (var head in HeadList)
{
AuditInfomb AuditInfo = new AuditInfomb(head, "YAXIANGAudit", "3001", Session["USERID"].ToString());
AuditInfo.FROMSTATE = "3002"; //从状态3002 提交审核出发
var _r = WorkFlowDAL.SubmitAuditBack(AuditInfo);
}
JsonResponse result = new JsonResponse();
result.Success = true;
return new ContentResult() { Content = JsonConvert.Serialize(result) };
}
//审核通过
public ContentResult Audit(string dataList)
{
Database db = DatabaseFactory.CreateDatabase();
var baseHead = new YXmb();
baseHead.GetTableField(db);
var HeadList = new List<YXmb>();
if (dataList != "")
{
var savedl = JsonConvert.Deserialize<List<Dictionary<string, string>>>(dataList);
foreach (var sdl in savedl)
{
var head = new YXmb();
baseHead.Copy(head);
head.SetValue(sdl);
HeadList.Add(head);
}
}
foreach (var head in HeadList)
{
AuditInfomb AuditInfo = new AuditInfomb(head, "YAXIANGAudit", "3003", Session["USERID"].ToString());
AuditInfo.FROMSTATE = "3002"; //从状态3002 提交审核出发 到3003审核通过
var _r = WorkFlowDAL.Audit(AuditInfo);
}
JsonResponse result = new JsonResponse();
result.Success = true;
return new ContentResult() { Content = JsonConvert.Serialize(result) };
}
//驳回提交
public ContentResult AuditBack(string dataList,string reason)
{
Database db = DatabaseFactory.CreateDatabase();
var baseHead = new YXmb();
baseHead.GetTableField(db);
var HeadList = new List<YXmb>();
if (dataList != "")
{
var savedl = JsonConvert.Deserialize<List<Dictionary<string, string>>>(dataList);
foreach (var sdl in savedl)
{
var head = new YXmb();
baseHead.Copy(head);
head.SetValue(sdl);
HeadList.Add(head);
}
}
foreach (var head in HeadList)
{
AuditInfomb AuditInfo = new AuditInfomb(head, "YAXIANGAudit", "3003", Session["USERID"].ToString());
AuditInfo.FROMSTATE = "3003"; //从状态3002 提交审核出发 到3003审核通过
//var reason = "";
var _r = WorkFlowDAL.AuditBack(AuditInfo,"PAYMENTREMARK='"+reason+"'", reason);
}
JsonResponse result = new JsonResponse();
result.Success = true;
return new ContentResult() { Content = JsonConvert.Serialize(result) };
}
#endregion
#region 获取打印的sql文本
public ContentResult GetPrintSql(string printname,string YXNOList)
{
var jsonRespose = new JsonResponse { Success = false, Message = "" };
if (printname == "Print1")
{
var result = new PrintSql();
result.sql1 = MsOp_YAXIANGDAL.getHeadListStr(" and YXNO in("+ YXNOList + ")", Session["USERID"].ToString());
result.sql2 = MsOp_YAXIANGDAL.getBodyListStr(" and D.YXNO in(" + YXNOList + ")");
jsonRespose.Success = true;
jsonRespose.Message = "查询成功";
jsonRespose.Data = result;
}
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
}
}