|
|
using NFine.Application.WMS;using System;using System.Collections.Generic;using System.Data;using System.IO;using System.Linq;using System.Web;using System.Web.Mvc;using NFine.Code;using System.Data.SqlClient;using NFine.Data.Extensions;using System.Data.OleDb;using System.Configuration;using ICS.Application.Entity;using Newtonsoft.Json.Linq;using Newtonsoft.Json;using System.Data.Common;using NFine.Domain._03_Entity.WMS;
namespace NFine.Web.Areas.WMS.Controllers{ public class ICSRCVIQCsController : ControllerBase {
ICSRCVIQCsApp App = new ICSRCVIQCsApp(); WMSCreateItemLotApp wMSCreateItemLotApp = new WMSCreateItemLotApp(); // GET: WMS/ICSRCVIQCs
public ActionResult ICSRCVIQCs() { return View(); } public ActionResult Rejection() { return View(); } public ActionResult WWRejection() { return View(); } public ActionResult ICSInspectionDetail() { return View(); } public ActionResult ICSLookFiles() { return View(); } public ActionResult ICSInspectionDetailNew() { return View(); } public ActionResult ICSInspectionDetailDelete() { return View(); } public ActionResult UpdateLeadTime() { return View(); } public ActionResult UpdateTrackCode() { return View(); }
public ActionResult YLICSRCVIQCs() { return View(); }
/// <summary>
/// 打印数据参数:服务器的URL+打印的文件名,转化为Base64编码
/// </summary>
protected string strPrintData; /// <summary>
/// 标识是否安装了控件
/// </summary>
protected bool bIsInstallPrintControl = true; /// <summary>
/// 打印控件的Cookie值
/// </summary>
protected string strPrintControlCookie = "";
/// <summary>
/// 获取Url中去掉文件名的路径
/// </summary>
/// <returns></returns>
private string GetUrlPath() { string strUrl = Request.Url.ToString(); int iEnd = strUrl.LastIndexOf("/"); strUrl = strUrl.Substring(0, iEnd + 1);
return strUrl; } //采购
[HttpGet] public ActionResult GetICSInspection(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//采购
[HttpGet] public ActionResult GetICSInspectionYL(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspectionYL(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
[HttpGet] public ActionResult GetInspectionFile(Pagination pagination, string JYID, string queryJson) { DataTable ListData = App.GetInspectionFile(ref pagination, queryJson, JYID); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); } //委外
[HttpGet] public ActionResult GetICSInspection2(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection2(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//工单
[HttpGet] public ActionResult GetICSInspection3(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection3(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//其他入库
[HttpGet] public ActionResult GetICSInspection4(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection4(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//生产退料
[HttpGet] public ActionResult GetICSInspection5(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection5(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//委外退料
[HttpGet] public ActionResult GetICSInspection6(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection6(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//销售退货
[HttpGet] public ActionResult GetICSInspection7(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection7(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//海格工单子线检验
[HttpGet] public ActionResult GetICSInspection25(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection25(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//不良原因
[HttpGet] public ActionResult Select_ICSBadReason(string InvCode) { var data = App.Select_ICSBadReason(InvCode); return Content(data.ToJson()); }
//不良代码
[HttpGet] public ActionResult GetSelectICSBadCode(string InvCode) { var data = App.GetSelectICSBadCode(InvCode); return Content(data.ToJson()); }
/// <summary>
/// 创建检验表
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost] [HandlerAjaxOnly] public ActionResult CreateICSInspection(string keyValue, string ICSInspections) { string msg = App.CreateICSInspection(keyValue, ICSInspections); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("添加成功!"); } }
/// <summary>
/// 创建检验表并按照结果分批
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost] [HandlerAjaxOnly] public ActionResult CreateICSInspectionAndSplit(string keyValue, string ICSInspections) { string msg = App.CreateICSInspectionAndSplit(keyValue, ICSInspections); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("添加成功!"); } }
/// <summary>
/// 在库检验保存检验结果
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost] [HandlerAjaxOnly] public ActionResult ICSWHLotInspection(string keyValue, string ICSInspections) { string msg = App.ICSWHLotInspection(keyValue, ICSInspections); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("检验结果保存成功!"); } }
/// <summary>
/// 创建检验表(海格工单子线)
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost] [HandlerAjaxOnly] public ActionResult CreateICSInspectionHG(string keyValue, string ICSInspections) { string msg = CreateICSInspectionHG1(keyValue, ICSInspections); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("添加成功!"); } } /// <summary>
/// 在库检验审核
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost] [HandlerAjaxOnly] public ActionResult ApproveWHLotInspection(string keyValue, string ICSInspections) { string msg = App.ApproveWHLotInspection(keyValue, ICSInspections); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("审核成功!"); } } /// <summary>
/// 在库检验复审
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost] [HandlerAjaxOnly] public ActionResult SecApproveWHLotInspection(string keyValue, string ICSInspections) { try { string msg = App.SecApproveWHLotInspection(keyValue, ICSInspections); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("审核成功!"); } } catch (Exception ex) { return Error(ex.Message); } }
//生成拒收单
[HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult CreateRejection(string keyValue, string Type) { try { string msg = ""; if (Type == "1") { msg = App.CreateRejection(keyValue); } else if (Type == "8") { msg = App.CreateWLYRejection(keyValue); } else if (Type == "9") { msg = App.CreateWWWLYRejection(keyValue); } else { msg = App.CreateWWRejection(keyValue); }
if (string.IsNullOrEmpty(msg)) { return Success("操作成功!"); } else { return Error("" + msg + ""); } } catch (Exception ex) { return Error(ex.Message); } }
//生成拒收单
[HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult CreateRejectionYL(string keyValue, string Type) { string msg = ""; if (Type == "1") { msg = App.CreateRejectionYL(keyValue); } else if (Type == "8") { msg = App.CreateWLYRejection(keyValue); } else if (Type == "9") { msg = App.CreateWWWLYRejection(keyValue); } else { msg = App.CreateWWRejection(keyValue); }
if (string.IsNullOrEmpty(msg)) { return Success("操作成功!"); } else { return Error("" + msg + ""); } }
/// <summary>
/// 删除拒收单
/// </summary>
/// <returns></returns>
[HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult DelectRejection(string keyValue) { string msg = App.DelectRejection(keyValue); if (string.IsNullOrEmpty(msg)) { return Success("删除成功!"); } else { return Error(msg); } }
[HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult DelectWWRejection(string keyValue) { string msg = App.DelectWWRejection(keyValue); if (string.IsNullOrEmpty(msg)) { return Success("删除成功!"); } else { return Error(msg); } }
[HttpGet] public ActionResult GetInventoryInspection(Pagination pagination, string InvCode, int SampleQuantity, string ResultINp) { DataTable ListData = App.GetInventoryInspection(ref pagination, InvCode, SampleQuantity, ResultINp); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
[HttpPost] [HandlerAjaxOnly] public ActionResult SaveICSInspectionDetail(string ICSMTDOC, string InvCode, string ResultINp) { string msg = App.SaveICSInspectionDetail(ICSMTDOC, InvCode, ResultINp); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("保存成功!"); } } /// <summary>
/// 上传文件(检验信息)
/// </summary>
/// <param name="BidCode"></param>
/// <param name="ID"></param>
/// <returns></returns>
[HttpPost] public ActionResult UpLoadFileImport(string ID, string DNCode) { string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string UploadfileName = ""; string fileName = ""; //获取上传的文件集合
try { HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files; for (int i = 0; i < httpFile.Count; i++) { //获取送货单号
//string STNO = Request.Form["STNO"].ToString();
UploadfileName = Path.GetFileNameWithoutExtension(httpFile[i].FileName) + Path.GetExtension(httpFile[i].FileName); fileName = DNCode + Path.GetExtension(httpFile[i].FileName); string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\InspectionFile\\"); if (!Directory.Exists(Paths)) { Directory.CreateDirectory(Paths); } string filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\InspectionFile\\" + UploadfileName);
int iLen = httpFile[0].ContentLength; byte[] bData = new byte[iLen]; httpFile[0].InputStream.Read(bData, 0, iLen); FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate); fs.Write(bData, 0, bData.Length); fs.Flush(); fs.Close(); fs.Dispose(); App.InsertICSInspectionFile(ID, UploadfileName, fileName); } return Success("上传成功!"); } catch (Exception ex) {
return Error(ex.Message); } }
//采购到货单检验
[HttpGet] public ActionResult GetICSInspection8(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection8(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//委外采购到货单检验
[HttpGet] public ActionResult GetICSInspection9(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection9(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//委外采购到货单检验
[HttpGet] public ActionResult GetICSInspection10(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection10(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//比博联副产品检验
[HttpGet] public ActionResult GetICSInspection101(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection101(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//在库检验
[HttpGet] public ActionResult GetICSInspection11(Pagination pagination, string MenuID, string queryJson) { try { DataTable ListData = App.GetICSInspection11(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); } catch (Exception ex) { return Error(ex.Message); } }
//采购入库单检验
[HttpGet] public ActionResult GetICSInspection22(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection22(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
//委外入库单检验
[HttpGet] public ActionResult GetICSInspection23(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSInspection23(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); } [HttpGet] public ActionResult GetInventoryInspectionNew(Pagination pagination, string InvCode, int? SampleQuantity, string ResultINp, string JYID, string LotNo) { DataTable ListData = App.GetInventoryInspectionNew(ref pagination, InvCode, SampleQuantity, ResultINp, JYID, LotNo); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetRulesDetail(string LotNo) { DataTable ListData = App.GetRulesDetail(LotNo); var JsonData = new { rows = ListData, }; return Content(JsonData.ToJson()); }
[HttpPost] [HandlerAjaxOnly] [ValidateInput(false)] public ActionResult SaveICSInspectionDetailNew(string InvCode, string JYID, string AllNumber, string YLOTQTY, string NLOTQTY, string WaiveQuantity, string BCCode, string BRCode, string ResultINp, string Lot, string Type, decimal CJQty, string ICSMTDOC) { string msg = App.SaveICSInspectionDetailNew(ICSMTDOC, InvCode, JYID, AllNumber, YLOTQTY, NLOTQTY, WaiveQuantity, BCCode, BRCode, ResultINp, Lot, Type, CJQty); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("保存成功!"); } }
[HttpPost] [HandlerAjaxOnly] [ValidateInput(false)] public ActionResult StagingICSInspectionDetailNew(string InvCode, string JYID, string AllNumber, string YLOTQTY, string NLOTQTY, string WaiveQuantity, string BCCode, string BRCode, string ResultINp, string Lot, string Type, decimal CJQty, string ICSMTDOC) { string msg = App.StagingICSInspectionDetailNew(ICSMTDOC, InvCode, JYID, AllNumber, YLOTQTY, NLOTQTY, WaiveQuantity, BCCode, BRCode, ResultINp, Lot, Type, CJQty); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("操作成功!"); } } [HttpPost] [HandlerAjaxOnly] public ActionResult UpdateICSInspectionDetailNew(string ICSMTDOC, string JYID, string ResultINp) { string msg = App.UpdateICSInspectionDetailNew(ICSMTDOC, JYID, ResultINp); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("保存成功!"); } }
/// <summary>
/// 获取动态列
/// </summary>
/// <param name="BidCode"></param>
/// <returns></returns>
public ActionResult SelectSORRFQColumnName(string InvCode, string JYID, string LotNo) { var data = App.SelectSORRFQColumnName(InvCode, JYID, LotNo); return Content(data.ToJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetDeleteRulesDetail(string InvCode, string JYID) { DataTable ListData = App.GetDeleteRulesDetail(InvCode, JYID); var JsonData = new { rows = ListData, }; return Content(JsonData.ToJson()); } [HttpPost] public ActionResult DeleteICSInspection(string DetailID) { DetailID = DetailID.Substring(1, DetailID.Length - 2); string msg = App.DeleteICSInspection(DetailID); if (string.IsNullOrWhiteSpace(msg)) { return Success("删除成功!"); } else { return Error("删除失败"); } }
/// <summary>
/// 数据导入
/// </summary>
/// <returns></returns>
[HttpPost] public string UploadFile(string LotNo) { try { HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files; if (hpFiles != null && hpFiles.Count > 0) {
string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
if (IsXls != ".xls" && IsXls != ".xlsx") {
return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
} string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
int iLen = hpFiles[0].ContentLength; if (Directory.Exists(savePath)) return "文件已存在"; byte[] bData = new byte[iLen]; hpFiles[0].InputStream.Read(bData, 0, iLen);
FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate); newFile.Write(bData, 0, bData.Length); newFile.Flush(); int _FileSizeTemp = hpFiles[0].ContentLength;
newFile.Close(); newFile.Dispose(); //bool del = false;
string mess = ""; mess = App.SetData_PR(savePath, LotNo); if (System.IO.File.Exists(savePath))//删除文件
{
System.IO.File.Delete(savePath); } return mess;
} else { return "获取文件失败"; } } catch (Exception ex) {
return ex.ToString(); } }
/// <summary>
/// 红字销售出库单检验
/// </summary>
/// <param name="pagination"></param>
/// <param name="MenuID"></param>
/// <param name="queryJson"></param>
/// <returns></returns>
[HttpGet] public ActionResult GetICSSSDInspection(Pagination pagination, string MenuID, string queryJson) { DataTable ListData = App.GetICSSSDInspection(ref pagination, MenuID, queryJson); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); } /// <summary>
/// 更新交期(咖博士使用)
/// </summary>
/// <param name="ICSMTDOC"></param>
/// <param name="JYID"></param>
/// <param name="ResultINp"></param>
/// <returns></returns>
[HttpPost] [HandlerAjaxOnly] public ActionResult UpdateLeadTime(string LeadModel) { string msg = App.UpdateLeadTime(LeadModel); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("更新成功!"); } }
/// <summary>
/// 填写快递单号(东辉使用)
/// </summary>
/// <param name="LeadModel"></param>
/// <returns></returns>
[HttpPost] [HandlerAjaxOnly] public ActionResult UpdateTrackCode(string LeadModel) { string msg = App.UpdateTrackCode(LeadModel); if (!string.IsNullOrEmpty(msg)) { return Error(msg); } else { return Success("保存成功!"); } } /// <summary>
/// 海格工单子线保存检验结果
/// </summary>
/// <param name="keyValue"></param>
/// <param name="ICSInspections"></param>
/// <returns></returns>
public string CreateICSInspectionHG1(string keyValue, string ICSInspections) { string msg = ""; try {
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; string date = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); keyValue = keyValue.TrimEnd(','); //获取需要检验的工单编码
string moCode = $"SELECT DISTINCT MOCode FROM ICSMOSubInventoryLot WHERE ID in ({keyValue});"; DataTable modt = SqlHelper.CmdExecuteDataTable(moCode);
string sql = string.Empty; JArray res = (JArray)JsonConvert.DeserializeObject(ICSInspections); foreach (var item in res) { object CARID = Guid.NewGuid(); JObject jo = (JObject)item; Dictionary<string, string> values = new Dictionary<string, string>(); foreach (JProperty prop in jo.Properties()) { string key = prop.Name; // 获取键名
JToken value = prop.Value; // 获取值(JToken类型)
string stringValue = value?.Type == JTokenType.Null ? string.Empty : value.ToString(); if (key != "JYID") { values.Add(key, "'" + stringValue + "'");
}
} values.Add("ID", "'" + CARID + "'"); values.Add("MTIME", "'" + DateTime.Now.ToString() + "'"); values.Add("MUSER", "'" + MUSER + "'"); values.Add("MUSERName", "'" + MUSERNAME + "'"); values.Add("WorkPoint", "'" + WorkPoint + "'"); values.Add("Enable", "'1'"); string sqls = string.Empty;
if (!string.IsNullOrWhiteSpace(jo["JYID"].ToString())) { sqls += @"IF EXISTS( select a.ID from ICSInspection a
INNER JOIN ICSMOSubInventoryLot c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint INNER JOIN ICSInventoryLotDetail b ON c.MOCode = b.TransCode AND c.WorkPoint = b.WorkPoint
where a.Enable = '1' AND a.Id = '{3}' AND QualifiedQuantity>'{4}') BEGIN RAISERROR('该条码已经检验生成条码,不能改变合格数量!', 16, 1); RETURN END;" +
" update ICSInspectionDetailGroup set InspectionID='{2}' WHERE InspectionID='{3}' and WorkPoint='{1}' ";
} sqls += @"update ICSInspection set Enable='0' WHERE LotNO='{0}' and Enable='1' and WorkPoint='{1}'"; sqls = string.Format(sqls, jo["LotNo"].ToString(), WorkPoint, CARID, jo["JYID"].ToString(), jo["QualifiedQuantity"].ToString()); SqlHelper.CmdExecuteNonQueryLi(sqls); sql += SqlHelper.InsertSQL("ICSInspection", values);
} //}
string lotid = string.Empty; SqlHelper.ExecuteWithTrans((dbConn, trans) => { if (SqlHelper.ExecuteNonQuery(dbConn, trans, sql) == 0) throw new Exception("新增失败");
string lotsql = string.Empty; for (int i = 0; i < modt.Rows.Count; i++) { //查询工单子件是否检验完成,检验完成根据最小检验数量生成条码
var checksql = $@"DECLARE @count1 int ,@count2 int ,@count3 int ;
set @count1=(SELECT Isnull(EATTRIBUTE6,0) as SubCount FROM ICSInventory WHERE InvCode=( SELECT InvCode FROM ICSMO WHERE MOCode='{modt.Rows[i]["MOCOde"]}' AND Workpoint='{WorkPoint}') AND WorkPoint='{WorkPoint}'); set @count2=(SELECT Count(1) Quantity FROM ICSInspection WHERE Enable='1' AND EATTRIBUTE3='{modt.Rows[i]["MOCOde"]}' AND WorkPoint='{WorkPoint}'); set @count3=(SELECT sum(b.Quantity) QualifiedQuantity FROM ICSInventoryLotDetail a INNER JOIN ICSInventoryLot b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint WHERE a.TransCode='{modt.Rows[i]["MOCOde"]}' AND a.WorkPoint='{WorkPoint}' GROUP BY a.TransCode,a.WorkPoint ); IF (@count1=@count2) BEGIN SELECT top 1 *,case when ISnull(@count3,0)>0 and QualifiedQuantity-ISnull(@count3,0)>0 THEN QualifiedQuantity-ISnull(@count3,0) when ISnull(@count3,0)=0 then QualifiedQuantity ELSE 0 end as Quantity1 FROM ICSInspection WHERE Enable='1' AND EATTRIBUTE3='{modt.Rows[i]["MOCOde"]}' AND WorkPoint='{WorkPoint}' ORDER BY QualifiedQuantity asc end ";
var checkdt = SqlHelper.CmdExecuteDataTable(dbConn, trans, checksql); if (checkdt.Rows.Count > 0) { if (checkdt.Rows[0]["Quantity1"].ToInt() > 0) { //获取id
string id = GetNewid(dbConn, trans); //生成条码打印
var lotNo = GetSerialCode(dbConn, trans, WorkPoint, "ICSInventoryLot", "LotNO", $"CP{modt.Rows[i]["MOCOde"]}0001", 4); lotsql += $@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint,TransID)
select '{lotNo}',MOCOde,'1','{MUSER}','{MUSERNAME}','{date}','{WorkPoint}',ID from ICSMO where MOCode='{modt.Rows[i]["MOCOde"]}' and Sequence='1' and WorkPoint='{WorkPoint}' insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select '{id}','{lotNo}',InvCode,'{date}','2999-12-31','{checkdt.Rows[0]["Quantity1"]}',ExtensionID,'3','{MUSER}','{MUSERNAME}', '{date}','{WorkPoint}','0' from ICSMO where MOCode='{modt.Rows[i]["MOCOde"]}' and Sequence='1' and WorkPoint='{WorkPoint}' ";
//if (SqlHelper.ExecuteNonQuery(dbConn, trans, lotsql) == 0)
// throw new Exception("新增失败");
//打印条码
lotid += $"'{id}',"; }
}
} if (!string.IsNullOrWhiteSpace(lotsql)) { if (SqlHelper.ExecuteNonQuery(dbConn, trans, lotsql) == 0) throw new Exception("新增失败"); }
}, ex => { msg = $"新增失败:{ex.Message}"; }); if (!string.IsNullOrWhiteSpace(lotid)) {
//打印条码
lotid = "\"" + lotid + "|\""; PrintItemLot("{\"Sys_LablesID\":\"D2005CFB-BFC0-4393-BB10-DC864371CEF7\"}", lotid); } } catch (Exception ex) { msg = ex.Message; }
return msg; }
public ActionResult PrintItemLot(string keyValue, string Parameter) { string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string WorkPoint = "'" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',') + "'"; string sqltxt = ""; Parameter = Parameter.Substring(1, Parameter.Length - 4); var queryParam = keyValue.ToJObject(); List<DbParameter> parameter = new List<DbParameter>(); var Sys_LablesID = queryParam["Sys_LablesID"].ToString(); List<PrintPara> parasList = new List<PrintPara>(); keyValue = keyValue.Substring(1, keyValue.Length - 2); string sqlValue = @"select LableSourceID,FileAddress,LableCode,LableName from Sys_Lables where ID='{0}'"; sqlValue = string.Format(sqlValue, Sys_LablesID); DataRow drV = SqlHelper.GetDataRowBySql(sqlValue); string LableSourceID = drV["LableSourceID"].ToString(); string FileAddress = drV["FileAddress"].ToString(); string LableCode = drV["LableCode"].ToString(); string LableName = drV["LableName"].ToString(); string sqlLableDataSource = @"SELECT ID,WorkPointCode,OtherDataBaseID,WorkPointDataFlag,
SysDataFlag,SqlTxt,SourceName,FormatSqlTxt,Paras,DbParas,LinkCols,CreateUserID, CreateDate,ModifyUserID,ModifyDate,Link2Cols FROM dbo.Sys_LableDataSource where ID='{0}'";
sqlLableDataSource = string.Format(sqlLableDataSource, LableSourceID); DataRow dr = SqlHelper.GetDataRowBySql(sqlLableDataSource); #region 打印
#endregion
var PrintValue = Parameter.Split('|'); string[] ValueParameters = PrintValue[0].Split(','); string[] PrintParas = Parameter.Split('|'); string LinkCols = string.Empty; sqltxt = dr["SqlTxt"].ToString(); LinkCols = dr["LinkCols"].ToString(); string SourceName = dr["SourceName"].ToString(); string Paras = dr["Paras"].ToString(); if (dr["Paras"].ToString() != "") { string[] ps = dr["Paras"].ToString().Split(','); for (int i = 0; i < ps.Length; i++) { if (!string.IsNullOrEmpty(ps[i])) { sqltxt = sqltxt.Replace(ps[i], PrintParas[i]); } } } if (sqltxt.Contains("[WorkPoint]")) { sqltxt = sqltxt.Replace("[WorkPoint]", WorkPoint); } string strPrintFileName = Server.MapPath("/File/LablesFile/") + "" + FileAddress + ""; PrintJson pJson = new PrintJson(Server.MapPath("./PrintTemp"), strPrintFileName); pJson.CheckRegister("苏州智合诚信息科技有限公司", "56DD3B4C172D0D140841CAC98A58A819F4E28EDA5D6E45711DDD64F6A439F68B6A7870CD7DAFD69A919CB870207FE4BB206F92BE3D53C221B019E0797E739EBA4"); //注册信息
if (LinkCols != "") { pJson.MasterOptions(1, "" + LinkCols + "", false); //主从关系
}
//pJson.CheckRegister("注册姓名", "8ECCCD6A1302DFEE1A6456A5D"); //注册信息
//pJson.AddPrintParam("ShopName", "测试酒楼");
//pJson.AddPrintParam("PrintDepositAdd", "说明:本单据为贵客押金收取凭证,盖章有效。退房时请出示,遗失者自负,请妥善保存。退房时间为12:00时,延时退房18:00时以前按半天房费收取,18:00时以后算全天房价。押金单有效期为一个月,过期作废。 贵重物品请交前台寄存,未寄存丢失自负。 谢谢!");
SetCookieAndURL(pJson);// 设置控件调用的Cookie值,判断是否安装了打印控件
string strSql = sqltxt;
//DataTable dtCashLog = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
DataSet dtCashLog = SqlHelper.GetDataSetBySql(strSql); DataTable dt1 = null; DataTable dt2 = null; DataTable dt3 = null; string strPrintTempFile = ""; if (dtCashLog.Tables.Count > 0 && dtCashLog.Tables.Count <= 1) { dt1 = dtCashLog.Tables[0]; strPrintTempFile = pJson.ShowReport(dt1); } if (dtCashLog.Tables.Count > 1 && dtCashLog.Tables.Count <= 2) { dt1 = dtCashLog.Tables[0]; dt2 = dtCashLog.Tables[1]; strPrintTempFile = pJson.ShowReport(dt1, dt2); } if (dtCashLog.Tables.Count > 2) { dt1 = dtCashLog.Tables[0]; dt2 = dtCashLog.Tables[1]; dt3 = dtCashLog.Tables[2]; strPrintTempFile = pJson.ShowReport(dt1, dt2, dt3); }
//string strPrintTempFile = pJson.ShowReport(dt1, dt2); //产生JSON文件内容
//把服务器的URL + 此文件名 传递给控件,由控件下载还原数据进行打印
string strServerURL = GetUrlPath() + "PrintTemp/"; string strData = strServerURL + strPrintTempFile;
strPrintData = PrintFunction.EnBase64(strData);
var JsonData = new { strPrintData_1 = strPrintData, bIsInstallPrintControl_1 = bIsInstallPrintControl, strPrintControlCookie_1 = strPrintControlCookie }; string sql = string.Empty; for (int i = 0; i < ValueParameters.Length; i++) { // 打印记录
sql += @"insert into Sys_LableTask (ID, LableCode, LableName, PrintTableID, PrintTableName, PrintKey, ValueParameters, PrintDate, PrintUserCode, WorkPoint)
values(newid(),'{0}','{1}','{2}','{3}','{4}',{5},getdate(),'{6}',{7})";
sql = string.Format(sql, LableCode, LableName, LableSourceID, SourceName, Paras, ValueParameters[i].ToString(), MUSER, WorkPoint); } SqlHelper.ExecuteNonQuery(sql);
//多站点
//string sql = @"UPDATE dbo.ICSInventoryLot
// SET PrintTimes=ISNULL(PrintTimes,0)+1,
// LastPrintUser='',
// LastPrintTime=GETDATE()
// WHERE ID IN (" + keyValue.TrimEnd(',') + ") and WorkPoint in ('" + WorkPoint.TrimEnd(',') + "')";
//SqlHelper.ExecuteNonQuery(sql);
return Content(JsonData.ToJson()); }
/// <summary>
/// 设置控件调用的Cookie值,判断是否安装了打印控件....
/// </summary>
/// <param name="pJson"></param>
private void SetCookieAndURL(PrintJson pJson) { bIsInstallPrintControl = false; strPrintControlCookie = ""; HttpCookie pCookieInstall = Request.Cookies["InstallPrintControl"]; if (pCookieInstall != null) { //Cookie存在
strPrintControlCookie = pCookieInstall.Value.ToString();
//以Cookie值查找在数据表中是否存在
string strSql = @"Select * From sys_SRM_CheckInstall Where Cookie = @Cookie"; SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strPrintControlCookie) }; using (SqlDataReader drCookie = DbHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie)) { if (drCookie.Read()) { //标识为已经安装
bIsInstallPrintControl = true; } drCookie.Close(); } //更新Cookie的保存时间
pCookieInstall.Expires = DateTime.Now.AddYears(10); Response.SetCookie(pCookieInstall); } else {//Cookie不存在,则新建Cookie
strPrintControlCookie = System.Guid.NewGuid().ToString(); pCookieInstall = new HttpCookie("InstallPrintControl", strPrintControlCookie); pCookieInstall.Expires = DateTime.Now.AddYears(10); Response.Cookies.Add(pCookieInstall); }
string strUrl = Server.MapPath("/PrintTemp/") + "IsCheckInstall";
pJson.SetCookieAndURL(strPrintControlCookie, strUrl); }
//导出
[HttpPost] public void ExportAll(string POCode, string VenCode, string VenName, string InvCode, string InvName, string InvStd, string BatchCode, string ReleaseState, string selEnableShow, string LotNO, string DocType, string Surveyor) { try { DataTable dt = App.GetInspectionExport(POCode, VenCode, VenName, InvCode, InvName, InvStd, BatchCode, ReleaseState, selEnableShow, LotNO, DocType, Surveyor); AsposeCell.Export(dt); } catch (Exception ex) { throw new Exception(ex.Message); }
}
[HttpPost] public void ExportAll25(string POCode, string VenCode, string VenName, string InvCode, string InvName, string InvStd, string BatchCode, string ReleaseState, string selEnableShow, string LotNO, string DocType, string Surveyor, string selIsWH, string FromTime, string ToTime) { try { DataTable dt = App.GetInspectionExport25(POCode, VenCode, VenName, InvCode, InvName, InvStd, BatchCode, ReleaseState, selEnableShow, LotNO, DocType, Surveyor, selIsWH, FromTime, ToTime); AsposeCell.Export(dt); } catch (Exception ex) { throw new Exception(ex.Message); }
} public string GetSerialCode(SqlConnection sqlConn, SqlTransaction sqlTrans, string workPointCode, string tbName, string colName, string Pre, int numLen) { string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}"; sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen }); //return Repository().FindTableBySql(sql.ToString());
return SqlHelper.ExecuteScalar(sqlConn, sqlTrans, sql).ToString(); //return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
}
public string GetNewid(SqlConnection sqlConn, SqlTransaction sqlTrans) { string sql = "select newid() AS ID"; return SqlHelper.CmdExecuteDataTable(sqlConn, sqlTrans, sql).Rows[0]["ID"].ToString();
}
}}
|