纽威
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.

95 lines
3.6 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net.Http;
  5. using System.Text;
  6. using System.Web;
  7. using System.Web.Http;
  8. using ICSSoft.ASKDataProject;
  9. using ICSSoft.ASKEntity;
  10. using Newtonsoft.Json;
  11. namespace ICSSoft.WebAPI.ASKControllers
  12. {
  13. public class ASKController : ApiController
  14. {
  15. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  16. /// <summary>
  17. /// 创建成品入库单(含连副产品)
  18. /// </summary>
  19. /// <param name="RJsonData">入库数据</param>
  20. /// <param name="LJsonData">连副产品</param>
  21. /// <returns></returns>
  22. [Route("api/ManufactureReceiveDocASK/Create")]
  23. [HttpPost]
  24. public HttpResponseMessage CreateManufactureReceiveDoc([FromBody]object JsonData)
  25. {
  26. log.Info("接口:api/ManufactureReceiveDocASK/Create");
  27. log.Info("创建成品入库单传入值:" + JsonData);
  28. HttpResponseMessage result = new HttpResponseMessage();
  29. Result res = new Result();
  30. string str = string.Empty;
  31. try
  32. {
  33. if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
  34. {
  35. try
  36. {
  37. List<ICSManufactureReceiveDoc> infos = new List<ICSManufactureReceiveDoc>();
  38. try
  39. {
  40. infos = JsonConvert.DeserializeObject<List<ICSManufactureReceiveDoc>>(JsonData.ToString());
  41. }
  42. catch (Exception ex)
  43. {
  44. log.Error("转换失败:" + ex.ToString());
  45. res.Success = false;
  46. res.Message = "JSON格式不正确!";
  47. }
  48. ManufactureReceiveDoc action = new ManufactureReceiveDoc();
  49. string resultStr = action.CreateManufactureReceiveDoc(infos);
  50. if (!string.IsNullOrWhiteSpace(resultStr))
  51. {
  52. res.Success = true;
  53. res.Message = "接口调用成功!";
  54. res.Data = resultStr;
  55. }
  56. else
  57. {
  58. res.Success = false;
  59. res.Message = resultStr;
  60. }
  61. }
  62. catch (Exception ex)
  63. {
  64. log.Error("调用后台失败:" + ex.ToString());
  65. res.Success = false;
  66. res.Message = ex.Message;
  67. }
  68. }
  69. else
  70. {
  71. res.Success = false;
  72. res.Message = "请传入参数";
  73. }
  74. }
  75. catch (Exception ex)
  76. {
  77. log.Error("参数检验失败:" + ex.ToString());
  78. res.Success = false;
  79. res.Message = ex.Message;
  80. }
  81. finally
  82. {
  83. str = JsonConvert.SerializeObject(res);
  84. result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
  85. }
  86. log.Debug("创建成品入库单返回值:" + str);
  87. return result;
  88. }
  89. }
  90. }