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.

719 lines
22 KiB

4 days ago
  1. using NFine.Application.SRM;
  2. using NFine.Code;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.Mvc;
  10. namespace NFine.Web.Areas.SRM.Controllers
  11. {
  12. public class PerFormanceController : ControllerBase
  13. {
  14. PerFormanceApp App = new PerFormanceApp();
  15. //
  16. // GET: /SRM/PerFormance/
  17. public ActionResult PerFormanceMark()
  18. {
  19. return View();
  20. }
  21. public ActionResult PerFormanceType()
  22. {
  23. return View();
  24. }
  25. public ActionResult PerFormanceTypeAdd()
  26. {
  27. return View();
  28. }
  29. public ActionResult PerFormanceTypeRel()
  30. {
  31. return View();
  32. }
  33. public ActionResult PerFormanceMarkSearch()
  34. {
  35. return View();
  36. }
  37. public ActionResult PerFormanceTargetAdd()
  38. {
  39. return View();
  40. }
  41. public ActionResult PerFormanceTarget()
  42. {
  43. return View();
  44. }
  45. /// <summary>
  46. /// 打分界面
  47. /// </summary>
  48. /// <returns></returns>
  49. public ActionResult PerFormanceMarkAdd()
  50. {
  51. return View();
  52. }
  53. public ActionResult PerFormanceMarkAddInv()
  54. {
  55. return View();
  56. }
  57. //供应商维护界面
  58. public ActionResult PerFormanceMarkByVendor()
  59. {
  60. return View();
  61. }
  62. //维护详情页面
  63. public ActionResult PerFormanceMarkMaintenance()
  64. {
  65. return View();
  66. }
  67. /// <summary>
  68. /// 获取绩效类型管理
  69. /// </summary>
  70. /// <param name="pagination"></param>
  71. /// <param name="queryJson"></param>
  72. /// <returns></returns>
  73. [HttpGet]
  74. [HandlerAjaxOnly]
  75. public ActionResult GetGridJson(Pagination pagination, string queryJson)
  76. {
  77. DataTable ListData = App.GetGridJson(queryJson, ref pagination);
  78. var JsonData = new
  79. {
  80. total = pagination.total,
  81. page = pagination.page,
  82. records = pagination.records,
  83. rows = ListData,
  84. };
  85. return Content(JsonData.ToJson());
  86. }
  87. /// <summary>
  88. /// 获取绩效打分
  89. /// </summary>
  90. /// <param name="pagination"></param>
  91. /// <param name="queryJson"></param>
  92. /// <returns></returns>
  93. //[HttpGet]
  94. //[HandlerAjaxOnly]
  95. //public ActionResult GetPerFormanceMark(Pagination pagination, string queryJson)
  96. //{
  97. // DataTable ListData = App.GetPerFormanceMark(queryJson, 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. [HttpGet]
  108. [HandlerAjaxOnly]
  109. public ActionResult GetPerFormanceMark(Pagination pagination, string BidCode)
  110. {
  111. DataTable ListData = App.GetPerFormanceMark(BidCode, ref pagination);
  112. var JsonData = new
  113. {
  114. total = pagination.total,
  115. page = pagination.page,
  116. records = pagination.records,
  117. rows = ListData,
  118. };
  119. return Content(JsonData.ToJson());
  120. }
  121. [HttpGet]
  122. [HandlerAjaxOnly]
  123. public ActionResult GetPerFormanceMarkByMain(Pagination pagination, string objArr,string WorkPoint)
  124. {
  125. DataTable ListData = App.GetPerFormanceMarkByMain( ref pagination, objArr, WorkPoint);
  126. var JsonData = new
  127. {
  128. total = pagination.total,
  129. page = pagination.page,
  130. records = pagination.records,
  131. rows = ListData,
  132. };
  133. return Content(JsonData.ToJson());
  134. }
  135. [HttpGet]
  136. [HandlerAjaxOnly]
  137. public ActionResult GetPerFormanceMarkByMainUpdate(Pagination pagination, string objArr, string WorkPoint)
  138. {
  139. DataTable ListData = App.GetPerFormanceMarkByMainUpdate(ref pagination, objArr, WorkPoint);
  140. var JsonData = new
  141. {
  142. total = pagination.total,
  143. page = pagination.page,
  144. records = pagination.records,
  145. rows = ListData,
  146. };
  147. return Content(JsonData.ToJson());
  148. }
  149. [HttpGet]
  150. [HandlerAjaxOnly]
  151. public ActionResult GetPerFormanceMarkGrid(Pagination pagination, string queryJson)
  152. {
  153. DataTable ListData = App.GetPerFormanceMarkGrid(queryJson, ref pagination);
  154. var JsonData = new
  155. {
  156. total = pagination.total,
  157. page = pagination.page,
  158. records = pagination.records,
  159. rows = ListData,
  160. };
  161. return Content(JsonData.ToJson());
  162. }
  163. [HttpGet]
  164. [HandlerAjaxOnly]
  165. public ActionResult GetPerFormanceMarkGridByVendor(Pagination pagination, string queryJson)
  166. {
  167. DataTable ListData = App.GetPerFormanceMarkGridByVendor(queryJson, ref pagination);
  168. var JsonData = new
  169. {
  170. total = pagination.total,
  171. page = pagination.page,
  172. records = pagination.records,
  173. rows = ListData,
  174. };
  175. return Content(JsonData.ToJson());
  176. }
  177. public ActionResult GetPerFormanceMarkBYColumn(string BidCode)
  178. {
  179. var data = App.GetPerFormanceMarkBYColumn(BidCode);
  180. return Content(data.ToJson());
  181. }
  182. [HttpGet]
  183. [HandlerAjaxOnly]
  184. public ActionResult GetEMSCORE()
  185. {
  186. try
  187. {
  188. DataRow dr = App.GetEMSCORE();
  189. var JsonData = new
  190. {
  191. MITEMSCORE = dr["MITEMSCORE"].ToString(),
  192. };
  193. return Content(JsonData.ToJson());
  194. }
  195. catch (Exception ex)
  196. {
  197. return Error(ex.Message);
  198. }
  199. }
  200. [HttpGet]
  201. [HandlerAjaxOnly]
  202. public ActionResult GetList(string MITEMCODE, string WorkPoint)
  203. {
  204. try
  205. {
  206. DataRow dr = App.GetList(MITEMCODE, WorkPoint);
  207. var JsonData = new
  208. {
  209. //CERTIFICATEITEMNAME = dr["CERTIFICATEITEMNAME"].ToString(),
  210. WorkPoint = dr["WorkPoint"].ToString(),
  211. MITEMCODE = dr["MITEMCODE"].ToString(),
  212. //CERTIFICATEITEMCODE = dr["CERTIFICATEITEMCODE"].ToString(),
  213. MITEMNAME = dr["MITEMNAME"].ToString(),
  214. MITEMDESCRIPTION = dr["MITEMDESCRIPTION"].ToString(),
  215. MITEMSCORE = dr["MITEMSCORE"].ToString(),
  216. };
  217. return Content(JsonData.ToJson());
  218. }
  219. catch (Exception ex)
  220. {
  221. return Error(ex.Message);
  222. }
  223. }
  224. /// <summary>
  225. /// 保存绩效类型
  226. /// </summary>
  227. /// <param name="keyValue"></param>
  228. /// <param name="ID"></param>
  229. /// <returns></returns>
  230. [HttpPost]
  231. [HandlerAjaxOnly]
  232. [ValidateAntiForgeryToken]
  233. public ActionResult SubmitPERFTEMPLATEMItem(string keyValue, string ID)
  234. {
  235. try
  236. {
  237. App.SubmitPERFTEMPLATEMItem(keyValue, ID);
  238. return Success("保存成功!");
  239. }
  240. catch (Exception ex)
  241. {
  242. return Error(ex.Message);
  243. }
  244. }
  245. [HttpPost]
  246. [HandlerAjaxOnly]
  247. [ValidateAntiForgeryToken]
  248. public ActionResult SavePerFormance(string keyValue)
  249. {
  250. try
  251. {
  252. App.SavePerFormance(keyValue);
  253. return Success("保存成功!");
  254. }
  255. catch (Exception ex)
  256. {
  257. return Error(ex.Message);
  258. }
  259. }
  260. [HttpGet]
  261. //[HandlerAjaxOnly]
  262. public ActionResult GetICSPERFTEMPLATEMITEM(string queryJson)
  263. {
  264. DataTable dt = App.GetICSPERFTEMPLATEMITEM(queryJson);
  265. return Content(dt.ToJson());
  266. }
  267. /// <summary>
  268. /// 绩效类别和供应商绑定
  269. /// </summary>
  270. /// <param name="keyValue"></param>
  271. /// <param name="keyValue2"></param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. [HandlerAjaxOnly]
  275. [ValidateAntiForgeryToken]
  276. public ActionResult SubmitICSPERFTEMPLATEMITEM(string keyValue, string keyValue2)
  277. {
  278. try
  279. {
  280. App.SubmitICSPERFTEMPLATEMITEM(keyValue, keyValue2);
  281. return Success("保存成功!");
  282. }
  283. catch (Exception ex)
  284. {
  285. return Error(ex.Message);
  286. }
  287. }
  288. /// <summary>
  289. /// 删除认绩效类别
  290. /// </summary>
  291. /// <param name="keyValue"></param>
  292. /// <returns></returns>
  293. [HttpPost]
  294. [HandlerAjaxOnly]
  295. [ValidateAntiForgeryToken]
  296. public ActionResult DeletePerFormanceType(string keyValue)
  297. {
  298. string msg = App.DeletePerFormanceType(keyValue);
  299. if (string.IsNullOrWhiteSpace(msg))
  300. {
  301. return Success("删除成功!");
  302. }
  303. else
  304. {
  305. return Error("删除失败");
  306. }
  307. }
  308. /// <summary>
  309. /// 绩效查询
  310. /// </summary>
  311. /// <param name="pagination"></param>
  312. /// <param name="queryJson"></param>
  313. /// <returns></returns>
  314. [HttpGet]
  315. [HandlerAjaxOnly]
  316. public ActionResult GetPerFormanceMarkSearch(Pagination pagination, string queryJson)
  317. {
  318. DataTable ListData = App.GetPerFormanceMarkSearch(queryJson, ref pagination);
  319. var JsonData = new
  320. {
  321. total = pagination.total,
  322. page = pagination.page,
  323. records = pagination.records,
  324. rows = ListData,
  325. };
  326. return Content(JsonData.ToJson());
  327. }
  328. /// 绩效查询
  329. /// </summary>
  330. /// <param name="pagination"></param>
  331. /// <param name="queryJson"></param>
  332. /// <returns></returns>
  333. [HttpGet]
  334. [HandlerAjaxOnly]
  335. public ActionResult GetPerFormanceTarget(Pagination pagination, string queryJson)
  336. {
  337. DataTable ListData = App.GetPerFormanceTarget(queryJson, ref pagination);
  338. var JsonData = new
  339. {
  340. total = pagination.total,
  341. page = pagination.page,
  342. records = pagination.records,
  343. rows = ListData,
  344. };
  345. return Content(JsonData.ToJson());
  346. }
  347. /// <summary>
  348. /// 绩效指标维护
  349. /// </summary>
  350. /// <param name="MITEMCODE"></param>
  351. /// <param name="WorkPoint"></param>
  352. /// <returns></returns>
  353. [HttpGet]
  354. [HandlerAjaxOnly]
  355. public ActionResult GetPerFormanceTargetAdd(string ID)
  356. {
  357. try
  358. {
  359. DataRow dr = App.GetPerFormanceTargetAdd(ID);
  360. var JsonData = new
  361. {
  362. NORMALTARGETCATEGORY = dr["NORMALTARGETCATEGORY"].ToString(),
  363. NORMALTARGETValue = dr["NORMALTARGETValue"].ToString(),
  364. TARGETSCORE = dr["TARGETSCORE"].ToString(),
  365. EffDate = dr["EffDate"].ToString(),
  366. DisDate = dr["DisDate"].ToString(),
  367. };
  368. return Content(JsonData.ToJson());
  369. }
  370. catch (Exception ex)
  371. {
  372. return Error(ex.Message);
  373. }
  374. }
  375. /// <summary>
  376. /// 保存绩效权值
  377. /// </summary>
  378. /// <param name="keyValue"></param>
  379. /// <returns></returns>
  380. [HttpPost]
  381. [HandlerAjaxOnly]
  382. [ValidateAntiForgeryToken]
  383. public ActionResult SubmitPerFormanceTarget(string keyValue,string ID)
  384. {
  385. try
  386. {
  387. App.SubmitPerFormanceTarget(keyValue, ID);
  388. return Success("保存成功!");
  389. }
  390. catch (Exception ex)
  391. {
  392. return Error(ex.Message);
  393. }
  394. }
  395. [HttpPost]
  396. [HandlerAjaxOnly]
  397. [ValidateAntiForgeryToken]
  398. public ActionResult DeletePerFormance(string keyValue)
  399. {
  400. string msg = App.DeletePerFormance(keyValue);
  401. if (string.IsNullOrWhiteSpace(msg))
  402. {
  403. return Success("删除成功!");
  404. }
  405. else
  406. {
  407. return Error("删除失败");
  408. }
  409. }
  410. [HttpGet]
  411. [HandlerAjaxOnly]
  412. public ActionResult GetScore(string WorkPoint)
  413. {
  414. try
  415. {
  416. decimal msg = App.GetScore(WorkPoint);
  417. var JsonData = new
  418. {
  419. SumScore = msg,
  420. };
  421. return Content(JsonData.ToJson());
  422. }
  423. catch (Exception ex)
  424. {
  425. return Error(ex.Message);
  426. }
  427. }
  428. public ActionResult GetScoreByTarget(string EffDate, string DisDate)
  429. {
  430. try
  431. {
  432. string msg = App.GetScoreByTarget(EffDate, DisDate);
  433. var JsonData = new
  434. {
  435. SumScore = msg,
  436. };
  437. return Content(JsonData.ToJson());
  438. }
  439. catch (Exception ex)
  440. {
  441. return Error(ex.Message);
  442. }
  443. }
  444. [HttpGet]
  445. [HandlerAjaxOnly]
  446. public ActionResult GetEMSCOREByTarget(string EffDate, string DisDate)
  447. {
  448. try
  449. {
  450. DataRow dr = App.GetEMSCOREByTarget(EffDate, DisDate);
  451. var JsonData = new
  452. {
  453. MITEMSCORE = dr["MITEMSCORE"].ToString(),
  454. };
  455. return Content(JsonData.ToJson());
  456. }
  457. catch (Exception ex)
  458. {
  459. return Error(ex.Message);
  460. }
  461. }
  462. /// <summary>
  463. /// 删除打分明细
  464. /// </summary>
  465. /// <param name="keyValue"></param>
  466. /// <param name="WorkPoint"></param>
  467. /// <returns></returns>
  468. [HttpPost]
  469. [HandlerAjaxOnly]
  470. [ValidateAntiForgeryToken]
  471. public ActionResult DeleteICSPERFCHECKRESULT(string keyValue)
  472. {
  473. string msg = App.DeleteICSPERFCHECKRESULT(keyValue);
  474. if (string.IsNullOrEmpty(msg))
  475. {
  476. return Success("删除成功!");
  477. }
  478. else
  479. {
  480. return Error(msg);
  481. }
  482. }
  483. public ActionResult SaveFormTiJiaoZB(string arrayShellFabricDetail,string Type)
  484. {
  485. try
  486. {
  487. App.SaveFormTiJiaoZB(arrayShellFabricDetail, Type);
  488. return Success("保存成功");
  489. }
  490. catch (Exception ex)
  491. {
  492. return Error(ex.Message);
  493. }
  494. }
  495. public ActionResult SaveFormMarkMaintenance(string queryJson)
  496. {
  497. try
  498. {
  499. App.SaveFormMarkMaintenance(queryJson);
  500. return Success("保存成功");
  501. }
  502. catch (Exception ex)
  503. {
  504. return Error(ex.Message);
  505. }
  506. }
  507. public ActionResult SaveFormOK(string json)
  508. {
  509. try
  510. {
  511. App.SaveFormOK(json);
  512. return Success("保存成功");
  513. }
  514. catch (Exception ex)
  515. {
  516. return Error(ex.Message);
  517. }
  518. }
  519. public ActionResult SaveFormNG(string json)
  520. {
  521. try
  522. {
  523. App.SaveFormOK(json);
  524. return Success("保存成功");
  525. }
  526. catch (Exception ex)
  527. {
  528. return Error(ex.Message);
  529. }
  530. }
  531. public ActionResult PERFPublish(string json)
  532. {
  533. return Content(App.PERFPublish(json));
  534. }
  535. public ActionResult PERFClose(string json)
  536. {
  537. return Content(App.PERFClose(json));
  538. }
  539. public ActionResult PERFDELETE(string json)
  540. {
  541. string msg = App.PERFdelete(json);
  542. if (string.IsNullOrEmpty(msg))
  543. {
  544. return Success("删除成功!");
  545. }
  546. else
  547. {
  548. return Error(msg);
  549. }
  550. }
  551. //[HttpGet]
  552. //[HandlerAjaxOnly]
  553. public ActionResult GetPerFormanceMarkInfo(string objArr, string WorkPoint)
  554. {
  555. DataTable ListData = App.GetPerFormanceMarkInfo(objArr, WorkPoint);
  556. var JsonData = new
  557. {
  558. rows = ListData,
  559. };
  560. return Content(JsonData.ToJson());
  561. }
  562. /// <summary>
  563. /// 上传完文件
  564. /// </summary>
  565. /// <param name="BidCode"></param>
  566. /// <param name="ID"></param>
  567. /// <returns></returns>
  568. [HttpPost]
  569. public ActionResult UpLoadFileImport(string VENDORCODE, string CERTIFICATEITEMCODE)
  570. {
  571. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  572. string FileName = "";
  573. string PathName = "";
  574. //获取上传的文件集合
  575. try
  576. {
  577. HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
  578. for (int i = 0; i < httpFile.Count; i++)
  579. {
  580. //获取送货单号
  581. //string STNO = Request.Form["STNO"].ToString();
  582. string fileName = Path.GetFileNameWithoutExtension(httpFile[i].FileName)
  583. + CERTIFICATEITEMCODE + Path.GetExtension(httpFile[i].FileName);
  584. string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\PerFormanceFile\\" + VENDORCODE + "\\");
  585. if (!Directory.Exists(Paths))
  586. {
  587. Directory.CreateDirectory(Paths);
  588. }
  589. string filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\PerFormanceFile\\" + VENDORCODE + "\\" + fileName);
  590. int iLen = httpFile[0].ContentLength;
  591. byte[] bData = new byte[iLen];
  592. httpFile[0].InputStream.Read(bData, 0, iLen);
  593. FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
  594. fs.Write(bData, 0, bData.Length);
  595. fs.Flush();
  596. fs.Close();
  597. fs.Dispose();
  598. FileName += "" + fileName + ";";
  599. PathName += "" + filePath + ";";
  600. }
  601. return Success("上传成功!");
  602. }
  603. catch (Exception ex)
  604. {
  605. return Error(ex.Message);
  606. }
  607. }
  608. [HttpPost]
  609. /// <summary>
  610. /// 文件上传到本地
  611. /// </summary>
  612. public ActionResult UploadFile()
  613. {
  614. string mess = "";
  615. try
  616. {
  617. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  618. if (hpFiles != null && hpFiles.Count > 0)
  619. {
  620. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  621. if (IsXls != ".xls" && IsXls != ".xlsx")
  622. {
  623. mess = "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  624. }
  625. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
  626. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  627. int iLen = hpFiles[0].ContentLength;
  628. if (Directory.Exists(savePath)) mess = "文件已存在";
  629. byte[] bData = new byte[iLen];
  630. hpFiles[0].InputStream.Read(bData, 0, iLen);
  631. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  632. newFile.Write(bData, 0, bData.Length);
  633. newFile.Flush();
  634. int _FileSizeTemp = hpFiles[0].ContentLength;
  635. newFile.Close();
  636. newFile.Dispose();
  637. //bool del = false;
  638. mess = App.SetData_PR(savePath);
  639. if (System.IO.File.Exists(savePath))//删除文件
  640. {
  641. System.IO.File.Delete(savePath);
  642. }
  643. }
  644. else
  645. {
  646. mess = "获取文件失败";
  647. }
  648. }
  649. catch (Exception ex)
  650. {
  651. mess = ex.Message;
  652. }
  653. var JsonData = new
  654. {
  655. mass = mess,
  656. };
  657. return Content(JsonData.ToJson());
  658. }
  659. [HttpGet]
  660. [HandlerAjaxOnly]
  661. public ActionResult GetVendorList(Pagination pagination, string queryJson, string WorkPoint,string year,string Moth,string Day)
  662. {
  663. DataTable ListData = App.GetVendorList(queryJson, ref pagination, WorkPoint, year, Moth, Day);
  664. var JsonData = new
  665. {
  666. total = pagination.total,
  667. page = pagination.page,
  668. records = pagination.records,
  669. rows = ListData,
  670. };
  671. return Content(JsonData.ToJson());
  672. }
  673. }
  674. }