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

936 lines
38 KiB

1 month ago
  1. using NFine.Application;
  2. using NFine.Application.KBSSRM;
  3. using NFine.Application.ProductManage;
  4. using NFine.Code;
  5. using NFine.Data.Extensions;
  6. using NFine.Domain.Entity.ProductManage;
  7. using NPOI.SS.Formula.Functions;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Data.SqlClient;
  12. using System.IO;
  13. using System.Linq;
  14. using System.Threading;
  15. using System.Web;
  16. using System.Web.Mvc;
  17. using static NPOI.HSSF.Util.HSSFColor;
  18. namespace NFine.Web.Areas.KBSSRM.Controllers
  19. {
  20. public class CreateItemLotController : ControllerBase
  21. {
  22. private KBSCreateItemLotApp App = new KBSCreateItemLotApp();
  23. [HttpGet]
  24. [HandlerAjaxOnly]
  25. public ActionResult GetGridJson(Pagination pagination, string queryJson)
  26. {
  27. DataTable ListData = App.GetGridJson(queryJson, ref pagination);
  28. var JsonData = new
  29. {
  30. total = pagination.total,
  31. page = pagination.page,
  32. records = pagination.records,
  33. rows = ListData,
  34. };
  35. return Content(JsonData.ToJson());
  36. }
  37. [HttpGet]
  38. [HandlerAjaxOnly]
  39. public ActionResult GetGridJsonByBB(Pagination pagination, string queryJson)
  40. {
  41. DataTable ListData = App.GetGridJsonByBB(queryJson, ref pagination);
  42. var JsonData = new
  43. {
  44. total = pagination.total,
  45. page = pagination.page,
  46. records = pagination.records,
  47. rows = ListData,
  48. };
  49. return Content(JsonData.ToJson());
  50. }
  51. [HttpGet]
  52. [HandlerAjaxOnly]
  53. public ActionResult GetGridJsonWeiWai(Pagination pagination, string queryJson)
  54. {
  55. DataTable ListData = App.GetGridJsonWeiWai(queryJson, ref pagination);
  56. var JsonData = new
  57. {
  58. total = pagination.total,
  59. page = pagination.page,
  60. records = pagination.records,
  61. rows = ListData,
  62. };
  63. return Content(JsonData.ToJson());
  64. }
  65. [HttpGet]
  66. [HandlerAjaxOnly]
  67. public ActionResult GetGridJsonWeiWaiByBB(Pagination pagination, string queryJson)
  68. {
  69. DataTable ListData = App.GetGridJsonWeiWaiByBB(queryJson, ref pagination);
  70. var JsonData = new
  71. {
  72. total = pagination.total,
  73. page = pagination.page,
  74. records = pagination.records,
  75. rows = ListData,
  76. };
  77. return Content(JsonData.ToJson());
  78. }
  79. [HttpGet]
  80. [HandlerAjaxOnly]
  81. public ActionResult GetSubGridJson(string POCode, string PORow,string WorkPoint, Pagination pagination)
  82. {
  83. DataTable ListData = App.GetSubGridJson(POCode, PORow, WorkPoint ,ref pagination);
  84. var JsonData = new
  85. {
  86. total = pagination.total,
  87. page = pagination.page,
  88. records = pagination.records,
  89. rows = ListData,
  90. };
  91. return Content(JsonData.ToJson());
  92. }
  93. [HttpGet]
  94. [HandlerAjaxOnly]
  95. public ActionResult GetSubGridJsonByWeiWai(string POCode, string PORow, string WorkPoint, Pagination pagination)
  96. {
  97. DataTable ListData = App.GetSubGridJsonByWeiWai(POCode, PORow, WorkPoint, ref pagination);
  98. var JsonData = new
  99. {
  100. total = pagination.total,
  101. page = pagination.page,
  102. records = pagination.records,
  103. rows = ListData,
  104. };
  105. return Content(JsonData.ToJson());
  106. }
  107. public ActionResult Index()
  108. {
  109. return View();
  110. }
  111. public ActionResult Form2()
  112. {
  113. return View();
  114. }
  115. public ActionResult IndexByBB()
  116. {
  117. return View();
  118. }
  119. public ActionResult FormByYL()
  120. {
  121. return View();
  122. }
  123. //[HttpGet]
  124. //[HandlerAjaxOnly]
  125. //public ActionResult GetFormJson(string keyValue)
  126. //{
  127. // //var data = maintainAppApp.GetForm(keyValue);
  128. // //return Content(data.ToJson());
  129. //}
  130. [HttpPost]
  131. [HandlerAjaxOnly]
  132. [ValidateAntiForgeryToken]
  133. public ActionResult SubmitForm(string POCode, string PORow, string keyValue, string WorkPoint, string IsEable)
  134. {
  135. int i = App.CreateItemLotNo(POCode, PORow, keyValue, WorkPoint, IsEable);
  136. if (i > 0)
  137. {
  138. return Success("生成成功!");
  139. }
  140. else
  141. {
  142. return Error("生成失败!");
  143. }
  144. }
  145. [HttpPost]
  146. [HandlerAjaxOnly]
  147. [ValidateAntiForgeryToken]
  148. public ActionResult BatchSubmitForm(string keyValue)
  149. {
  150. int i = App.BatchSubmitForm(keyValue);
  151. if (i > 0)
  152. {
  153. return Success("生成成功!");
  154. }
  155. else
  156. {
  157. return Error("生成失败!");
  158. }
  159. }
  160. [HttpPost]
  161. [HandlerAjaxOnly]
  162. [ValidateAntiForgeryToken]
  163. public ActionResult SubmitFormWeiWai(string OOCode, string Sequence, string keyValue, string WorkPoint, string IsEable)
  164. {
  165. int i = App.SubmitFormWeiWai(OOCode, Sequence, keyValue, WorkPoint, IsEable);
  166. if (i > 0)
  167. {
  168. return Success("生成成功!");
  169. }
  170. else
  171. {
  172. return Error("生成失败!");
  173. }
  174. }
  175. /// <summary>
  176. /// 点击生成条码查询
  177. /// </summary>
  178. /// <param name="POCode">采购订单</param>
  179. /// <param name="PORow">采购行</param>
  180. /// <param name="WorkPoint">多站点</param>
  181. /// <returns></returns>
  182. [HttpGet]
  183. [HandlerAjaxOnly]
  184. public ActionResult GetSubGridJsonByCreate(string POCode, string PORow, string WorkPoint)
  185. {
  186. DataTable ListData = App.GetSubGridJsonByCreate(POCode, PORow,WorkPoint);
  187. var JsonData = new
  188. {
  189. rows = ListData,
  190. };
  191. return Content(JsonData.ToJson());
  192. }
  193. /// <summary>
  194. /// 点击生成条码查询
  195. /// </summary>
  196. /// <param name="POCode">采购订单</param>
  197. /// <param name="PORow">采购行</param>
  198. /// <param name="WorkPoint">多站点</param>
  199. /// <returns></returns>
  200. [HttpGet]
  201. [HandlerAjaxOnly]
  202. public ActionResult GetSubGridJsonByCreateWeiWai(string OOCode, string Sequence, string WorkPoint)
  203. {
  204. DataTable ListData = App.GetSubGridJsonByCreateWeiWai(OOCode, Sequence, WorkPoint);
  205. var JsonData = new
  206. {
  207. rows = ListData,
  208. };
  209. return Content(JsonData.ToJson());
  210. }
  211. [HttpGet]
  212. [HandlerAjaxOnly]
  213. public ActionResult GetVendorLotNo(string InvCode, string WorkPoint)
  214. {
  215. DataTable ListData = App.GetVendorLotNo(InvCode, WorkPoint);
  216. var JsonData = new
  217. {
  218. VendorLotNo = ListData.Rows[0][0].ToString(),
  219. };
  220. return Content(JsonData.ToJson());
  221. }
  222. [HttpPost]
  223. [HandlerAjaxOnly]
  224. [ValidateAntiForgeryToken]
  225. public ActionResult DeleteItemLot(string keyValue, string WorkPoint)
  226. {
  227. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  228. WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
  229. string msg = App.DeleteItemLot(keyValue, WorkPoint);
  230. if (string.IsNullOrWhiteSpace(msg))
  231. {
  232. return Success("删除成功!");
  233. }
  234. else
  235. {
  236. return Error(msg);
  237. }
  238. }
  239. /// <summary>
  240. /// 打印数据参数:服务器的URL+打印的文件名,转化为Base64编码
  241. /// </summary>
  242. protected string strPrintData;
  243. /// <summary>
  244. /// 标识是否安装了控件
  245. /// </summary>
  246. protected bool bIsInstallPrintControl = true;
  247. /// <summary>
  248. /// 打印控件的Cookie值
  249. /// </summary>
  250. protected string strPrintControlCookie = "";
  251. /// <summary>
  252. /// 获取Url中去掉文件名的路径
  253. /// </summary>
  254. /// <returns></returns>
  255. private string GetUrlPath()
  256. {
  257. string strUrl = Request.Url.ToString();
  258. int iEnd = strUrl.LastIndexOf("/");
  259. strUrl = strUrl.Substring(0, iEnd + 1);
  260. return strUrl;
  261. }
  262. /// <summary>
  263. /// 设置控件调用的Cookie值,判断是否安装了打印控件
  264. /// </summary>
  265. /// <param name="pJson"></param>
  266. private void SetCookieAndURL(PrintJson pJson)
  267. {
  268. bIsInstallPrintControl = false;
  269. strPrintControlCookie = "";
  270. HttpCookie pCookieInstall = Request.Cookies["InstallPrintControl"];
  271. if (pCookieInstall != null)
  272. { //Cookie存在
  273. strPrintControlCookie = pCookieInstall.Value.ToString();
  274. //以Cookie值查找在数据表中是否存在
  275. string strSql = @"Select * From sys_SRM_CheckInstall Where Cookie = @Cookie";
  276. SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strPrintControlCookie) };
  277. using (SqlDataReader drCookie = DbHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie))
  278. {
  279. if (drCookie.Read())
  280. { //标识为已经安装
  281. bIsInstallPrintControl = true;
  282. }
  283. drCookie.Close();
  284. }
  285. //更新Cookie的保存时间
  286. pCookieInstall.Expires = DateTime.Now.AddYears(10);
  287. Response.SetCookie(pCookieInstall);
  288. }
  289. else
  290. {//Cookie不存在,则新建Cookie
  291. strPrintControlCookie = System.Guid.NewGuid().ToString();
  292. pCookieInstall = new HttpCookie("InstallPrintControl", strPrintControlCookie);
  293. pCookieInstall.Expires = DateTime.Now.AddYears(10);
  294. Response.Cookies.Add(pCookieInstall);
  295. }
  296. string strUrl = Server.MapPath("/PrintTemp/") + "IsCheckInstall";
  297. pJson.SetCookieAndURL(strPrintControlCookie, strUrl);
  298. }
  299. /// <summary>
  300. /// 生成条码打印
  301. /// </summary>
  302. /// <param name="keyValue">ID</param>
  303. /// <param name="WorkPoint">多站点</param>
  304. /// <returns></returns>
  305. [HttpPost]
  306. [HandlerAjaxOnly]
  307. public ActionResult PrintItemLot(string keyValue, string WorkPoint,string Type)
  308. {
  309. // string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  310. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  311. WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
  312. string strPrintFileName = Server.MapPath("/ReportFile/") + "lot.fr3";
  313. PrintJson pJson = new PrintJson(Server.MapPath("./PrintTemp"), strPrintFileName);
  314. pJson.CheckRegister("苏州智合诚信息科技有限公司", "56DD3B4C172D0D140841CAC98A58A819F4E28EDA5D6E45711DDD64F6A439F68B6A7870CD7DAFD69A919CB870207FE4BB206F92BE3D53C221B019E0797E739EBA4"); //注册信息
  315. //pJson.CheckRegister("注册姓名", "8ECCCD6A1302DFEE1A6456A5D"); //注册信息
  316. //pJson.AddPrintParam("ShopName", "测试酒楼");
  317. //pJson.AddPrintParam("PrintDepositAdd", "说明:本单据为贵客押金收取凭证,盖章有效。退房时请出示,遗失者自负,请妥善保存。退房时间为12:00时,延时退房18:00时以前按半天房费收取,18:00时以后算全天房价。押金单有效期为一个月,过期作废。 贵重物品请交前台寄存,未寄存丢失自负。 谢谢!");
  318. SetCookieAndURL(pJson);// 设置控件调用的Cookie值,判断是否安装了打印控件
  319. string strSql = "";
  320. if (Type=="1")
  321. {
  322. strSql = @"SELECT distinct b.ExtensionID,a.InvCode,a.LotNo AS QRLotNo,b.POCode,CONVERT(varchar(100),b.CreateDateTime, 23) PODate,g.BatchCode,a.Quantity,c.InvName,
  323. c.InvStd,
  324. c.ClassName,c.InvDesc,
  325. b.VenCode,h.VenName,c.InvUnit,f.WarehouseName,
  326. a.LotNO AS QRLotNo,CONVERT(varchar(100), a.ProductDate, 23) as PRODUCTDATE,CONVERT(varchar(100), b.PlanArriveDate, 23) as PreArriveDate
  327. ,CAST(b.VenCode+'_'+a.InvCode+'_'+CAST(a.Quantity AS NVARCHAR(20))+'_'+c.InvUnit+g.BatchCode+'_'+CONVERT(varchar(100), a.ProductDate, 23)+'_' +a.LotNo AS NVARCHAR(100)) AS erweima
  328. ,a.EATTRIBUTE2,a.EATTRIBUTE3,CONVERT(varchar(100),dateadd(day,c.EffectiveDays,a.ProductDate), 23) AS exprdate,i.asnCode,b.EATTRIBUTE3 as DXEATTRIBUTE3
  329. ,a.EATTRIBUTE4 as DXEATTRIBUTE4,b.EATTRIBUTE4 as PODXEATTRIBUTE4,c1.LocationCode
  330. ,c.EATTRIBUTE11,c.EATTRIBUTE12,c.EATTRIBUTE13,c.EATTRIBUTE14,c.EATTRIBUTE15
  331. ,c.EATTRIBUTE16,c.EATTRIBUTE17,c.EATTRIBUTE18,
  332. CASE WHEN c.EATTRIBUTE19='1'THEN''WHEN c.EATTRIBUTE19='0'THEN'' END EATTRIBUTE19,ISNULL(a.EATTRIBUTE6,'') as isSJBGInvCode,a.EATTRIBUTE8, CASE WHEN c.InvIQC='0' THEN '免'ELSE '' END AS InvIQC,k.ContainerCode
  333. FROM dbo.ICSInventoryLot a
  334. left join ICSExtension g on a.ExtensionID=g.ID and a.WorkPoint=g.WorkPoint
  335. left join ICSInventoryLotDetail e on a.lotNo=e.LotNo and a.WorkPoint=e.WorkPoint
  336. LEFT JOIN dbo.ICSPurchaseOrder b ON b.POCode=e.TransCode AND b.Sequence=e.TransSequence AND a.WorkPoint=b.WorkPoint
  337. LEFT JOIN dbo.ICSInventory c ON a.InvCode=c.InvCode AND a.WorkPoint=c.WorkPoint
  338. left join dbo.ICSInventoryBatchEnable d on c.InvCode=d.InvCode and c.WorkPoint=d.WorkPoint AND d.BatchEnable=1
  339. left join ICSWarehouse f on d.WHCode=f.WarehouseCode and d.WorkPoint=f.WorkPoint
  340. left join ICSVendor h on b.VenCode=h.VenCode and b.WorkPoint=h.WorkPoint
  341. LEFT JOIN icsasndetail i ON a.lotNO=i.LotNO AND a.workPoint=i.workPoint
  342. LEFT JOIN dbo.ICSContainerLot j ON a. lotno=j.LotNo AND a. WorkPoint=j. WorkPoint
  343. LEFT JOIN dbo.IcSContainer k ON j.ContainerID=k.ID AND i. WorkPoint=k.WorkPoint
  344. LEFT JOIN (
  345. SELECT
  346. InvCode,
  347. WarehouseCode,
  348. LocationCode,
  349. MTIME,
  350. WorkPoint,
  351. new_index
  352. FROM
  353. (
  354. SELECT
  355. b.InvCode,
  356. b.WarehouseCode,
  357. b.LocationCode,
  358. b.MTIME,
  359. b.WorkPoint,
  360. ROW_NUMBER() OVER (
  361. PARTITION BY b.InvCode
  362. ORDER BY b.MTIME ASC
  363. ) AS new_index
  364. FROM
  365. ICSWareHouseLotInfo b WITH (NOLOCK)
  366. WHERE
  367. b.quantity > 0
  368. ) AS subquery
  369. WHERE
  370. new_index = 1
  371. ) c1 ON c1.invcode = a.invcode AND c1.WorkPoint = a.WorkPoint
  372. LEFT JOIN (
  373. SELECT
  374. InvCode,
  375. WarehouseCode,
  376. LocationCode,
  377. MTIME,
  378. WorkPoint
  379. FROM
  380. (
  381. SELECT
  382. b.InvCode,
  383. b.WarehouseCode,
  384. b.LocationCode,
  385. b.MTIME,
  386. b.WorkPoint
  387. FROM dbo.ICSWarehouse a
  388. LEFT JOIN dbo.ICSWareHouseLotInfo b ON a.WarehouseCode=b.WarehouseCode AND a.WorkPoint=b.WorkPoint
  389. WHERE
  390. b.quantity > 0
  391. and a.WarehouseCode='YL020'
  392. ) AS subquery
  393. ) c2 ON c2.invcode = a.invcode AND c2.WorkPoint = a.WorkPoint
  394. where a.ID IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint in ('" + WorkPoint.Trim(',') + "')";
  395. }
  396. if (Type == "2")
  397. {
  398. #region 旧SQL(修改原因:会导致死锁)
  399. // strSql = @"SELECT distinct b.ExtensionID,a.InvCode,a.LotNo AS QRLotNo,b.OOCode as POCode,CONVERT(varchar(100),b.CreateDateTime, 23) PODate,g.BatchCode,a.Quantity,c.InvName,
  400. //c.InvStd,
  401. //c.ClassName,c.InvDesc,
  402. //b.VenCode,h.VenName,c.InvUnit,f.WarehouseName,
  403. //a.LotNO AS QRLotNo,CONVERT(varchar(100), a.ProductDate, 23) as PRODUCTDATE,CONVERT(varchar(100), b.PlanArriveDate, 23) as PreArriveDate
  404. //,CAST(b.VenCode+'_'+a.InvCode+'_'+CAST(a.Quantity AS NVARCHAR(20))+'_'+c.InvUnit+g.BatchCode+'_'+CONVERT(varchar(100), a.ProductDate, 23)+'_' +a.LotNo AS NVARCHAR(100)) AS erweima
  405. //,a.EATTRIBUTE3,CONVERT(varchar(100),dateadd(day,c.EffectiveDays,a.ProductDate), 23) AS exprdate,i.OASNCode as asnCode,b.EATTRIBUTE3 as DXEATTRIBUTE3
  406. //,a.EATTRIBUTE4 as DXEATTRIBUTE4,b.EATTRIBUTE4 as PODXEATTRIBUTE4,c1.LocationCode,
  407. //c.EATTRIBUTE11,c.EATTRIBUTE12,c.EATTRIBUTE13,c.EATTRIBUTE14,c.EATTRIBUTE15
  408. //,c.EATTRIBUTE16,c.EATTRIBUTE17,c.EATTRIBUTE18,
  409. //CASE WHEN c.EATTRIBUTE19='1'THEN'食品级物料'WHEN c.EATTRIBUTE19='0'THEN'非食品级物料' END EATTRIBUTE19,ISNULL(a.EATTRIBUTE6,'') as isSJBGInvCode,a.EATTRIBUTE8, CASE WHEN c.InvIQC='0' THEN '免'ELSE '' END AS InvIQC
  410. //,a.InvCode+'~'+' '+'~'+' '+'~'+b.OOCode+'~'+' '+'~'+h.VenName as NKSM,k.ContainerCode
  411. //FROM dbo.ICSInventoryLot a
  412. //left join ICSExtension g on a.ExtensionID=g.ID and a.WorkPoint=g.WorkPoint
  413. //left join ICSInventoryLotDetail e on a.lotNo=e.LotNo and a.WorkPoint=e.WorkPoint
  414. //LEFT JOIN dbo.ICSOutsourcingOrder b ON b.OOCode=e.TransCode AND b.Sequence=e.TransSequence AND a.WorkPoint=b.WorkPoint
  415. //LEFT JOIN dbo.ICSInventory c ON a.InvCode=c.InvCode AND a.WorkPoint=c.WorkPoint
  416. //left join dbo.ICSInventoryBatchEnable d on c.InvCode=d.InvCode and c.WorkPoint=d.WorkPoint AND d.BatchEnable=1
  417. //left join ICSWarehouse f on d.WHCode=f.WarehouseCode and d.WorkPoint=f.WorkPoint
  418. //left join ICSVendor h on b.VenCode=h.VenCode and b.WorkPoint=h.WorkPoint
  419. //LEFT JOIN ICSOASNDetail i ON a.lotNO=i.LotNO AND a.workPoint=i.workPoint
  420. //LEFT JOIN dbo.ICSContainerLot j ON a. lotno=j.LotNo AND a. WorkPoint=j. WorkPoint
  421. //LEFT JOIN dbo.IcSContainer k ON j.ContainerID=k.ID AND i. WorkPoint=k.WorkPoint
  422. //LEFT JOIN (
  423. // SELECT
  424. // InvCode,
  425. // WarehouseCode,
  426. // LocationCode,
  427. // MTIME,
  428. // WorkPoint,
  429. // new_index
  430. //FROM
  431. // (
  432. // SELECT
  433. // b.InvCode,
  434. // b.WarehouseCode,
  435. // b.LocationCode,
  436. // b.MTIME,
  437. // b.WorkPoint,
  438. // ROW_NUMBER() OVER (
  439. // PARTITION BY b.InvCode
  440. // ORDER BY b.MTIME ASC
  441. // ) AS new_index
  442. // FROM
  443. // ICSWareHouseLotInfo b WITH (NOLOCK)
  444. // WHERE
  445. // b.quantity > 0
  446. // ) AS subquery
  447. //WHERE
  448. // new_index = 1
  449. //) c1 ON c1.invcode = a.invcode
  450. //AND c1.WorkPoint = a.WorkPoint
  451. //where a.ID IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint in ('" + WorkPoint.Trim(',') + "')";
  452. #endregion
  453. strSql = @" SELECT
  454. InvCode,
  455. WarehouseCode,
  456. LocationCode,
  457. MTIME,
  458. WorkPoint,
  459. new_index
  460. into #Temp
  461. FROM
  462. (
  463. SELECT
  464. b.InvCode,
  465. b.WarehouseCode,
  466. b.LocationCode,
  467. b.MTIME,
  468. b.WorkPoint,
  469. ROW_NUMBER() OVER (
  470. PARTITION BY b.InvCode
  471. ORDER BY b.MTIME ASC
  472. ) AS new_index
  473. FROM
  474. ICSWareHouseLotInfo b WITH (NOLOCK)
  475. WHERE
  476. b.quantity > 0
  477. ) AS subquery
  478. WHERE
  479. new_index = 1
  480. SELECT distinct b.ExtensionID,a.InvCode,a.LotNo AS QRLotNo,b.OOCode as POCode,CONVERT(varchar(100),b.CreateDateTime, 23) PODate,g.BatchCode,a.Quantity,c.InvName,
  481. c.InvStd,
  482. c.ClassName,c.InvDesc,
  483. b.VenCode,h.VenName,c.InvUnit,f.WarehouseName,
  484. a.LotNO AS QRLotNo,CONVERT(varchar(100), a.ProductDate, 23) as PRODUCTDATE,CONVERT(varchar(100), b.PlanArriveDate, 23) as PreArriveDate
  485. ,CAST(b.VenCode+'_'+a.InvCode+'_'+CAST(a.Quantity AS NVARCHAR(20))+'_'+c.InvUnit+g.BatchCode+'_'+CONVERT(varchar(100), a.ProductDate, 23)+'_' +a.LotNo AS NVARCHAR(100)) AS erweima
  486. ,CAST(ISNULL(a.InvCode,'') + '~'+ISNULL(c.EATTRIBUTE14,'')+'~'+ISNULL(a.lotno,'')+'~' + ISNULL(b.OOCode,'') + '~' + ISNULL(b.VenCode,'') AS VARCHAR(500)) AS erweima2
  487. ,a.EATTRIBUTE3,CONVERT(varchar(100),dateadd(day,c.EffectiveDays,a.ProductDate), 23) AS exprdate,i.OASNCode as asnCode,b.EATTRIBUTE3 as DXEATTRIBUTE3
  488. ,a.EATTRIBUTE4 as DXEATTRIBUTE4,b.EATTRIBUTE4 as PODXEATTRIBUTE4,c1.LocationCode,
  489. c.EATTRIBUTE11,c.EATTRIBUTE12,c.EATTRIBUTE13,c.EATTRIBUTE14,c.EATTRIBUTE15
  490. ,c.EATTRIBUTE16,c.EATTRIBUTE17,c.EATTRIBUTE18,
  491. CASE WHEN c.EATTRIBUTE19='1'THEN''WHEN c.EATTRIBUTE19='0'THEN'' END EATTRIBUTE19,ISNULL(a.EATTRIBUTE6,'') as isSJBGInvCode,a.EATTRIBUTE8, CASE WHEN c.InvIQC='0' THEN '免'ELSE '' END AS InvIQC
  492. ,a.InvCode+'~'+' '+'~'+' '+'~'+b.OOCode+'~'+' '+'~'+h.VenName as NKSM,k.ContainerCode
  493. FROM dbo.ICSInventoryLot a
  494. left join ICSExtension g on a.ExtensionID=g.ID and a.WorkPoint=g.WorkPoint
  495. left join ICSInventoryLotDetail e on a.lotNo=e.LotNo and a.WorkPoint=e.WorkPoint
  496. LEFT JOIN dbo.ICSOutsourcingOrder b ON b.OOCode=e.TransCode AND b.Sequence=e.TransSequence AND a.WorkPoint=b.WorkPoint
  497. LEFT JOIN dbo.ICSInventory c ON a.InvCode=c.InvCode AND a.WorkPoint=c.WorkPoint
  498. left join dbo.ICSInventoryBatchEnable d on c.InvCode=d.InvCode and c.WorkPoint=d.WorkPoint AND d.BatchEnable=1
  499. left join ICSWarehouse f on d.WHCode=f.WarehouseCode and d.WorkPoint=f.WorkPoint
  500. left join ICSVendor h on b.VenCode=h.VenCode and b.WorkPoint=h.WorkPoint
  501. LEFT JOIN ICSOASNDetail i ON a.lotNO=i.LotNO AND a.workPoint=i.workPoint
  502. LEFT JOIN dbo.ICSContainerLot j ON a. lotno=j.LotNo AND a. WorkPoint=j. WorkPoint
  503. LEFT JOIN dbo.IcSContainer k ON j.ContainerID=k.ID AND i. WorkPoint=k.WorkPoint
  504. LEFT JOIN #Temp c1 ON c1.invcode = a.invcode
  505. AND c1.WorkPoint = a.WorkPoint
  506. where a.ID IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint in ('" + WorkPoint.Trim(',') + "') drop table #Temp ";
  507. }
  508. //string strSql = @"Select * From CashLog";
  509. DataTable dtCashLog = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
  510. string strPrintTempFile = pJson.ShowReport(dtCashLog); //产生JSON文件内容
  511. //string strPrintTempFile = pJson.ExportReportPdf(dtCashLog, null, null, null, null, null, "D:/基础版/NFine.Framework/NFine.Web/File/PDF"); //导出PDF文件
  512. //把服务器的URL + 此文件名 传递给控件,由控件下载还原数据进行打印
  513. string strServerURL = GetUrlPath() + "PrintTemp/";
  514. string strData = strServerURL + strPrintTempFile;
  515. strPrintData = PrintFunction.EnBase64(strData);
  516. var JsonData = new
  517. {
  518. strPrintData_1 = strPrintData,
  519. bIsInstallPrintControl_1 = bIsInstallPrintControl,
  520. strPrintControlCookie_1 = strPrintControlCookie
  521. };
  522. //多站点
  523. string sql = @"UPDATE dbo.ICSInventoryLot
  524. SET PrintTimes=ISNULL(PrintTimes,0)+1,
  525. LastPrintUser='',
  526. LastPrintTime=GETDATE()
  527. WHERE ID IN (" + keyValue.TrimEnd(',') + ") and WorkPoint in ('" + WorkPoint.TrimEnd(',') + "')";
  528. SqlHelper.ExecuteNonQuery(sql);
  529. return Content(JsonData.ToJson());
  530. }
  531. [HttpPost]
  532. [HandlerAjaxOnly]
  533. public ActionResult PrintPurchaseOrder(string keyValue,string Type)
  534. {
  535. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  536. string strSql = string.Empty;
  537. DataTable dtOrder = null;
  538. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  539. string strPrintFileName = Server.MapPath("/ReportFile/") + "PurchaseOrder.fr3";
  540. PrintJson pJson = new PrintJson(Server.MapPath("./PrintTemp"), strPrintFileName);
  541. pJson.CheckRegister("苏州智合诚信息科技有限公司", "56DD3B4C172D0D140841CAC98A58A819F4E28EDA5D6E45711DDD64F6A439F68B6A7870CD7DAFD69A919CB870207FE4BB206F92BE3D53C221B019E0797E739EBA4"); //注册信息
  542. pJson.MasterOptions(1, "POCode", false); //主从关系
  543. SetCookieAndURL(pJson);// 设置控件调用的Cookie值,判断是否安装了打印控件
  544. if (Type == "1")
  545. {
  546. strSql = @"SELECT DISTINCT POCode,a.VenCode,VenName,a.CreateDateTime,CreatePerson,c.F_RealName
  547. FROM dbo.ICSPurchaseOrder a
  548. LEFT JOIN ICSVendor b ON a.VenCode = b.VenCode AND a.WorkPoint = b.WorkPoint
  549. LEFT JOIN sys_srm_user c ON a.CreatePerson=c.F_account AND a.workpoint=c.F_location
  550. WHERE POCode IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint=" + WorkPoint.TrimEnd(',') + "";
  551. dtOrder = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
  552. strSql = @" SELECT a.InvCode,b.INVNAME,b.INVSTD,b.InvUnit,a.Quantity,a.UnitPrice,
  553. CAST(a.UnitPrice*a.Quantity AS DECIMAL(18,4)) AS TaxPrice,a.PlanArriveDate
  554. ,a.Sequence,a.POCode
  555. FROM dbo.ICSPurchaseOrder a
  556. LEFT JOIN dbo.ICSINVENTORY b ON a.InvCode=b.INVCODE AND a.WorkPoint=b.WorkPoint
  557. WHERE a.POCode IN (" + keyValue.TrimEnd(',') + @") and a.WorkPoint=" + WorkPoint.TrimEnd(',') + @"
  558. ORDER BY CONVERT(int,convert(numeric(4,0),a.Sequence ))";
  559. }
  560. else
  561. {
  562. strSql = @" SELECT DISTINCT a.OOCode as POCode ,a.VenCode,VenName,a.CreateDateTime,CreatePerson,c.F_RealName
  563. FROM dbo.ICSOutsourcingOrder a
  564. LEFT JOIN ICSVendor b ON a.VenCode = b.VenCode AND a.WorkPoint = b.WorkPoint
  565. LEFT JOIN sys_srm_user c ON a.CreatePerson=c.F_account AND a.workpoint=c.F_location
  566. WHERE OOCode IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint=" + WorkPoint.TrimEnd(',') + "";
  567. dtOrder = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
  568. strSql = @" SELECT a.InvCode,b.INVNAME,b.INVSTD,b.InvUnit,a.Quantity,a.UnitPrice,
  569. CAST(a.UnitPrice*a.Quantity AS DECIMAL(18,4)) AS TaxPrice,a.PlanArriveDate
  570. ,a.Sequence,a.OOCode as POCode
  571. FROM dbo.ICSOutsourcingOrder a
  572. LEFT JOIN dbo.ICSINVENTORY b ON a.InvCode=b.INVCODE AND a.WorkPoint=b.WorkPoint
  573. WHERE a.OOCode IN (" + keyValue.TrimEnd(',') + @") and a.WorkPoint=" + WorkPoint.TrimEnd(',') + @"
  574. ORDER BY CONVERT(int,convert(numeric(4,0),a.Sequence ))";
  575. }
  576. DataTable dtOderDetail = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
  577. string strPrintTempFile = pJson.ShowReport(dtOrder, dtOderDetail); //产生JSON文件内容
  578. //把服务器的URL + 此文件名 传递给控件,由控件下载还原数据进行打印
  579. string strServerURL = GetUrlPath() + "PrintTemp/";
  580. string strData = strServerURL + strPrintTempFile;
  581. strPrintData = PrintFunction.EnBase64(strData);
  582. var JsonData = new
  583. {
  584. strPrintData_1 = strPrintData,
  585. bIsInstallPrintControl_1 = bIsInstallPrintControl,
  586. strPrintControlCookie_1 = strPrintControlCookie
  587. };
  588. return Content(JsonData.ToJson());
  589. }
  590. /// <summary>
  591. /// 写日志(用于跟踪)
  592. /// </summary>
  593. private void WriteLog(string strMessage)
  594. {
  595. string strLogFile = Server.MapPath("./Cookie_Log.txt");
  596. StreamWriter swLogFile = null;
  597. try
  598. {
  599. if (!System.IO.File.Exists(strLogFile))
  600. {
  601. swLogFile = System.IO.File.CreateText(strLogFile);
  602. }
  603. else
  604. {
  605. swLogFile = System.IO.File.AppendText(strLogFile);
  606. }
  607. swLogFile.WriteLine(strMessage);
  608. }
  609. catch
  610. {
  611. }
  612. finally
  613. {
  614. if (swLogFile != null)
  615. swLogFile.Close();
  616. }
  617. }
  618. /// <summary>
  619. ///判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
  620. /// </summary>
  621. /// <param name="strCookie"></param>
  622. private void UpdateCheckInstall(string strCookie)
  623. {
  624. bool bIsExist = false;
  625. //判断记录是否存在
  626. GetLastAccessTime(strCookie, ref bIsExist);
  627. string strSql = "";
  628. SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strCookie) };
  629. if (bIsExist)
  630. { //存在则更新最后访问的时间
  631. strSql = @"Update sys_SRM_CheckInstall
  632. Set LastAccessTime = getDate()
  633. Where Cookie = @Cookie";
  634. }
  635. else
  636. { //不存在则新建一条记录
  637. strSql = @"Insert into sys_SRM_CheckInstall(Cookie, LastAccessTime)
  638. Values( @Cookie, getDate() )";
  639. }
  640. DbHelper.ExecuteNonQuery(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie);
  641. }
  642. public DateTime ToDateTime(object SrcValue)
  643. {
  644. if (Convert.IsDBNull(SrcValue) == true)
  645. return DateTime.MinValue;
  646. else
  647. {
  648. try
  649. {
  650. return Convert.ToDateTime(SrcValue);
  651. }
  652. catch
  653. {
  654. return DateTime.MinValue;
  655. }
  656. }
  657. }
  658. /// <summary>
  659. /// 获取此Cookie的最后访问时间
  660. /// </summary>
  661. /// <param name="strCookie"></param>
  662. /// <returns></returns>
  663. private DateTime GetLastAccessTime(string strCookie, ref bool bIsExist)
  664. {
  665. DateTime dtLastAccessTime = DateTime.MinValue;
  666. bIsExist = false;
  667. string strSql = @"Select * From sys_SRM_CheckInstall Where Cookie = @Cookie";
  668. SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strCookie) };
  669. using (SqlDataReader drCookie = DbHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie))
  670. {
  671. if (drCookie.Read())
  672. {
  673. dtLastAccessTime = ToDateTime(drCookie["LastAccessTime"]);
  674. bIsExist = true;
  675. }
  676. drCookie.Close();
  677. }
  678. return dtLastAccessTime;
  679. }
  680. [HttpGet]
  681. [HandlerAjaxOnly]
  682. public ActionResult IsCheckInstall(string checkInstall)
  683. {
  684. string strValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss 访问,");
  685. if (Request.QueryString["cookie"] != null)
  686. { //有控件上传的Cookie值
  687. string strCookie = Request.QueryString["cookie"].ToString();
  688. //判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
  689. UpdateCheckInstall(strCookie);
  690. strValue = strValue + "上传的cookie:" + strCookie;
  691. }
  692. else if (checkInstall != null)
  693. {//Ajax检查控件是否安装了,防止那种客户把打印控件卸装了,打印时无法检测到的情况
  694. string strCookie = checkInstall;
  695. //读取最后访问的时间
  696. string strResult = "PrintControlInstall";
  697. bool bIsExist = false;
  698. DateTime dtLastAccessTime = GetLastAccessTime(strCookie, ref bIsExist);
  699. if (!bIsExist || dtLastAccessTime.AddSeconds(30) < DateTime.Now)
  700. {
  701. strResult = "NOT";
  702. }
  703. Response.Clear();
  704. Response.Write(strResult);
  705. strValue = strValue + "检测安装的值:" + strCookie;
  706. }
  707. WriteLog(strValue);
  708. return null;
  709. }
  710. [HttpGet]
  711. [HandlerAjaxOnly]
  712. public ActionResult IsCheckInstall()
  713. {
  714. string strValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss 访问,");
  715. if (Request.QueryString["cookie"] != null)
  716. { //有控件上传的Cookie值
  717. string strCookie = Request.QueryString["cookie"].ToString();
  718. //判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
  719. UpdateCheckInstall(strCookie);
  720. strValue = strValue + "上传的cookie:" + strCookie;
  721. }
  722. else if (Request.QueryString["checkInstall"] != null)
  723. {//Ajax检查控件是否安装了,防止那种客户把打印控件卸装了,打印时无法检测到的情况
  724. string strCookie = Request.QueryString["checkInstall"];
  725. //读取最后访问的时间
  726. string strResult = "PrintControlInstall";
  727. bool bIsExist = false;
  728. DateTime dtLastAccessTime = GetLastAccessTime(strCookie, ref bIsExist);
  729. if (!bIsExist || dtLastAccessTime.AddSeconds(30) < DateTime.Now)
  730. {
  731. strResult = "NOT";
  732. }
  733. Response.Clear();
  734. Response.Write(strResult);
  735. strValue = strValue + "检测安装的值:" + strCookie;
  736. }
  737. WriteLog(strValue);
  738. return null;
  739. }
  740. [HttpGet]
  741. public ActionResult SelectICSExtensionEnable(string BeginTime, string EndTime)
  742. {
  743. var data = App.SelectICSExtensionEnable(BeginTime, EndTime);
  744. return Content(data.ToJson());
  745. }
  746. [HttpGet]
  747. public ActionResult SelectICSInventoryEnable(string BeginTime)
  748. {
  749. var data = App.SelectICSInventoryEnable(BeginTime);
  750. return Content(data.ToJson());
  751. }
  752. [HttpGet]
  753. public ActionResult SelectICSColumnEnableForLotEnable(string WorkPoint)
  754. {
  755. var data = App.SelectICSColumnEnableForLotEnable(WorkPoint);
  756. return Content(data.ToJson());
  757. }
  758. public ActionResult GetQiSetNum(string keyValue)
  759. {
  760. var rows = App.GetQiSetNum(keyValue);
  761. return Content(rows.ToJson());
  762. }
  763. /// <summary>
  764. /// 查询是否启用序列号
  765. /// </summary>
  766. /// <param name="InvCode"></param>
  767. /// <param name="WorkPoint"></param>
  768. /// <returns></returns>
  769. [HttpGet]
  770. [HandlerAjaxOnly]
  771. public ActionResult GetInventoryIsEnable(string InvCode, string WorkPoint)
  772. {
  773. DataTable ListData = App.GetInventoryIsEnable(InvCode, WorkPoint);
  774. var JsonData = new
  775. {
  776. ContainerEnable = ListData.Rows[0][0].ToString(),
  777. };
  778. return Content(JsonData.ToJson());
  779. }
  780. [HttpGet]
  781. public ActionResult GetInvBatchEnable(string InvCode)
  782. {
  783. var data = App.GetInvBatchEnable(InvCode);
  784. return Content(data.ToJson());
  785. }
  786. [HttpGet]
  787. public ActionResult GetInvBatchCardControl(string InvCode,string BatchCode,string PRODUCTDATE)
  788. {
  789. bool flag = App.GetInvBatchCardControl(InvCode, BatchCode, PRODUCTDATE);
  790. var JsonData = new
  791. {
  792. Flag = flag,
  793. };
  794. return Content(JsonData.ToJson());
  795. }
  796. public ActionResult GetWWComplete(string BeginTime, string EndTime)
  797. {
  798. var data = App.GetWWComplete(BeginTime, EndTime);
  799. return Content(data.ToJson());
  800. }
  801. [HttpGet]
  802. [HandlerAjaxOnly]
  803. public ActionResult GetLoadShowForColumn(string WorkPoint)
  804. {
  805. DataTable ListData = App.GetLoadShowForColumn(WorkPoint);
  806. var JsonData = new
  807. {
  808. rows = ListData,
  809. };
  810. return Content(JsonData.ToJson());
  811. }
  812. public ActionResult ISPOBack()
  813. {
  814. string result = App.ISPOBack();
  815. var JsonData = new
  816. {
  817. result = result
  818. };
  819. return Content(JsonData.ToJson());
  820. }
  821. public ActionResult ISEableDDSX(string VenCode, string InvCode, string WorkPoint, string PODate, string POCode, string Sequence)
  822. {
  823. string result = App.ISEableDDSX( VenCode,InvCode,WorkPoint,PODate, POCode, Sequence);
  824. var JsonData = new
  825. {
  826. result = result
  827. };
  828. return Content(JsonData.ToJson());
  829. }
  830. [HttpGet]
  831. public ActionResult SeachCreateLotOrderByPO()
  832. {
  833. var data = App.SeachCreateLotOrderByPO();
  834. return Content(data.ToJson());
  835. }
  836. [HttpGet]
  837. public ActionResult SeachCreateLotOrderByOO()
  838. {
  839. var data = App.SeachCreateLotOrderByOO();
  840. return Content(data.ToJson());
  841. }
  842. //比博独有校验交期是否维护
  843. public ActionResult SeachPoArriveDate(string Code,string Row,string Type)
  844. {
  845. bool Flag = App.SeachPoArriveDate(Code, Row,Type);
  846. var JsonData = new
  847. {
  848. Flag = Flag
  849. };
  850. return Content(JsonData.ToJson());
  851. }
  852. }
  853. }