validMatTime.cs 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using com.hnshituo.core.webapp.vo;
  9. namespace MeterConditionLibrary
  10. {
  11. /// <summary>
  12. /// 物料计量时间段配置表
  13. /// 这个只限制毛重计量
  14. /// </summary>
  15. public class validMatTime
  16. {
  17. Log lg = Log.GetInstance();
  18. /// <summary>
  19. /// 验证物料计量时间段配置表 只验证毛重计量
  20. /// </summary>
  21. /// <param name="scale">预报信息</param>
  22. /// <param name="sMeterType">计量类型,1过毛重,2过皮重,3结净</param>
  23. public void ValidMethod(PreTrackScale scale, string sMeterType)
  24. {
  25. //未锁定的情况下
  26. //if (!PbCache.isLockFrm)
  27. {
  28. if (sMeterType == "1")
  29. {
  30. //验证物料计量时间段
  31. if (PbCache.monitor.validMatTime == "1" && !PbCache.isNotValid)
  32. {
  33. string sql = @"SELECT T1.START_TIME startTime,
  34. T1.END_TIME endTime
  35. FROM METER_BASE_TIMES_INFO T1, METER_BASE_MATTER_TIMES T2
  36. WHERE T1.TIMES_NO = T2.TIMES_NO
  37. AND T1.VALID_FLAG = '1'
  38. AND T2.MATTER_NO = '" + scale.matterNo + "'";
  39. PbModelDbService<List<MeterBaseTimesInfo>> pb = new PbModelDbService<List<MeterBaseTimesInfo>>();
  40. RESTfulResult<List<MeterBaseTimesInfo>> rm = pb.executeSqlDataWf(sql);
  41. if (rm.Succeed)
  42. {
  43. if (rm.Data != null && rm.Data.Count > 0)
  44. {
  45. List<MeterBaseTimesInfo> dt = rm.Data;
  46. string str = DateTime.Now.ToString("HH:mm:ss");
  47. if (str.CompareTo(dt[0].startTime) >= 0 && str.CompareTo(dt[0].endTime) <= 0)
  48. {
  49. PbCache.monitorResult.valid_mat_time = true;
  50. }
  51. else
  52. {
  53. PbCache.monitorResult.valid_mat_time = false;
  54. PbCache.ResultMessage = "当前时间段不允许计量该物料";
  55. }
  56. }
  57. else
  58. {
  59. PbCache.monitorResult.valid_mat_time = true;
  60. //PbCache.ResultMessage = "未找到物料配置的时间范围";
  61. }
  62. }
  63. else
  64. {
  65. PbCache.monitorResult.valid_mat_time = false;
  66. PbCache.ResultMessage = "称重数据保存失败";
  67. lg.WriteLog(3, "计量失败:" + rm.ResultMessage);
  68. //PbCache.ResultMessage = "未找到物料配置的时间范围";
  69. }
  70. }
  71. else
  72. {
  73. PbCache.monitorResult.valid_mat_time = true;
  74. }
  75. }
  76. else
  77. {
  78. PbCache.monitorResult.valid_mat_time = true;
  79. }
  80. }
  81. }
  82. }
  83. }