圣珀
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.

127 lines
6.0 KiB

2 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using ICS.WCF.Base;
  8. using ICSSoft.Entity;
  9. namespace ICS.INVAndLotFreeze
  10. {
  11. public class INVFreeze
  12. {
  13. /// <summary>
  14. /// 获取物料条码信息生成条码
  15. /// </summary>
  16. public FormICSCreatedArrivalNoticeModel CustGetMaterialOutBox(PalletMox m)
  17. {
  18. FormICSCreatedArrivalNoticeModel result = new FormICSCreatedArrivalNoticeModel();
  19. try
  20. {
  21. StringBuilder strHead = new StringBuilder();
  22. strHead.AppendLine("***************接口传入参数记录****************:");
  23. strHead.AppendLine("外箱条码:" + m.CartonNO);
  24. strHead.AppendLine("栈板条码:" + m.PalletCode);
  25. strHead.AppendLine("传入站点:" + m.WorkPoint);
  26. strHead.AppendLine("***************接口传入参数记录****************:");
  27. Appconfig.WriteLogFile(strHead.ToString(), "物料栈板信息接口日志");
  28. StringBuilder resultlog = new StringBuilder();
  29. string SqlCartonNO = @"select * from ICSPallet where PalletCode = '" + m.PalletCode + "' ";
  30. DataTable flag1 = DBhlper.Query(SqlCartonNO, Appconfig.GetMESStr());
  31. if (flag1.Rows.Count <= 0)
  32. {
  33. string SqlLotNO = @"select * from ICSITEMLot2Carton where CartonNO = '" + m.CartonNO + "' ";
  34. DataTable flag2 = DBhlper.Query(SqlLotNO, Appconfig.GetMESStr());
  35. if (flag2.Rows.Count > 0)
  36. {
  37. string sql = string.Format(@"update ICSITEMLot2Carton set PalletNO='{0}'
  38. where WorkPoint = '{2}'and CartonNO='{1}'",
  39. m.PalletCode, m.CartonNO, m.WorkPoint);
  40. int dt = DBhlper.EXecute(sql, Appconfig.GetMESStr());
  41. if (dt == 0)
  42. {
  43. result.Code = -1;
  44. result.ResMsg = "栈板条码信息添加失败,请查看日志";
  45. result.ResData = "{}";
  46. result.IsCompress = false;
  47. result.IsSuccess = false;
  48. resultlog.AppendLine("物料栈板信息添加失败");
  49. resultlog.AppendLine("查询sql:" + sql);
  50. Appconfig.WriteLogFile(resultlog.ToString(), "物料栈板信息接口日志");
  51. return result;
  52. }
  53. }
  54. else
  55. {
  56. result.Code = -1;
  57. result.ResMsg = "箱号不存在,信息添加失败";
  58. result.ResData = "{}";
  59. result.IsCompress = false;
  60. result.IsSuccess = false;
  61. resultlog.AppendLine("物料栈板信息添加失败");
  62. resultlog.AppendLine("错误信息:箱号不存在,信息添加失败");
  63. Appconfig.WriteLogFile(resultlog.ToString(), "物料栈板信息接口日志");
  64. return result;
  65. }
  66. string sql2 = string.Format(@"insert into ICSPallet (Serial,PalletCode,BatchCode,palletStatus,MUSER,MUSERName,MTIME,WorkPoint)
  67. Values
  68. (NEWID(),'{0}','','','{1}','{2}',GETDATE(),'{3}')"
  69. , m.PalletCode, m.MUSER, m.MUSERName, m.WorkPoint);
  70. int dt2 = DBhlper.EXecute(sql2, Appconfig.GetMESStr());
  71. if (dt2 > 0)
  72. {
  73. result.Code = 0;
  74. result.ResMsg = "物料栈板条码创建成功";
  75. result.ResData = "{}";
  76. result.IsCompress = false;
  77. result.IsSuccess = true;
  78. }
  79. }
  80. else
  81. {
  82. result.Code = -1;
  83. result.ResMsg = "栈板已经存在,信息添加失败";
  84. result.ResData = "{}";
  85. result.IsCompress = false;
  86. result.IsSuccess = false;
  87. resultlog.AppendLine("物料栈板信息添加失败");
  88. resultlog.AppendLine("错误信息:外箱条码不存在,信息添加失败");
  89. Appconfig.WriteLogFile(resultlog.ToString(), "物料栈板信息接口日志");
  90. return result;
  91. }
  92. }
  93. catch (Exception ex)
  94. {
  95. result.Code = -1;
  96. result.ResMsg = "物料栈板信息获取失败,请查看日志";
  97. result.ResData = "{}";
  98. result.IsCompress = false;
  99. result.IsSuccess = false;
  100. StringBuilder str = new StringBuilder();
  101. str.AppendLine("物料栈板信息获取失败");
  102. str.AppendLine("外箱条码:" + m.CartonNO);
  103. str.AppendLine("栈板条码:" + m.PalletCode);
  104. str.AppendLine("传入站点:" + m.WorkPoint);
  105. str.AppendLine("失败原因:" + ex.Message);
  106. Appconfig.WriteLogFile(str.ToString(), "物料栈板信息接口日志");
  107. }
  108. return result;
  109. }
  110. /// <summary>
  111. /// 返回值
  112. /// </summary>
  113. public class FormICSCreatedArrivalNoticeModel
  114. {
  115. //0 :正常数据,-1:失败。
  116. public int Code { get; set; }
  117. public string ResMsg { get; set; }
  118. public Object ResData { get; set; }
  119. public bool IsCompress { get; set; }
  120. public bool IsSuccess { get; set; }
  121. }
  122. }
  123. }