validPredictionDiff.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. using com.hnshituo.core.webapp.vo;
  2. using Common;
  3. using System;
  4. using System.Collections.Generic;
  5. namespace MeterConditionLibrary
  6. {
  7. /// <summary>
  8. /// 验证预报超差,如果预报里面有毛重则验证毛重,有净重则验证净重
  9. /// 若都没得则提示
  10. /// </summary>
  11. public class validPredictionDiff
  12. {
  13. /// <summary>
  14. /// 验证预报超差,如果预报里面有毛重则验证毛重,有净重则验证净重
  15. /// </summary>
  16. /// <param name="scale">预报信息</param>
  17. /// <param name="sMeterType">计量类型,1过毛重,2过皮重,3结净</param>
  18. /// <param name="fristMeter">一次计量信息,若为结净状态才有值</param>
  19. public void ValidMethod(PreTrackScale scale, string sMeterType, MeterWorkCarActualFirst fristMeter)
  20. {
  21. //未锁定的情况下
  22. //if (!PbCache.isLockFrm)
  23. {
  24. PbCache.ResultMessage = "";
  25. if (PbCache.monitor.validPredictionDiff == "1" && !PbCache.isNotValid)
  26. {
  27. if (scale.shipmentGrossWeight != null || scale.shipmentNetWeight != null)
  28. {
  29. if (sMeterType == "1") //过毛
  30. {
  31. if (scale.shipmentGrossWeight != null && scale.shipmentGrossWeight > 0)
  32. {
  33. ValidMethods(scale, "1", fristMeter);
  34. }
  35. else
  36. {
  37. PbCache.monitorResult.valid_prediction_diff = true;
  38. }
  39. }
  40. else if (sMeterType == "3") //结净
  41. {
  42. if (scale.shipmentNetWeight != null && scale.shipmentNetWeight > 0)
  43. {
  44. ValidMethods(scale, "2", fristMeter);
  45. }
  46. else
  47. {
  48. PbCache.monitorResult.valid_prediction_diff = true;
  49. }
  50. }
  51. else
  52. {
  53. PbCache.monitorResult.valid_prediction_diff = true;
  54. }
  55. }
  56. else
  57. {
  58. PbCache.monitorResult.valid_prediction_diff = true;
  59. //PbCache.ResultMessage = "预报中未配置发运重量";
  60. }
  61. }
  62. else
  63. {
  64. PbCache.monitorResult.valid_prediction_diff = true;
  65. }
  66. }
  67. }
  68. /// <summary>
  69. ///
  70. /// </summary>
  71. /// <param name="scale">预报信息</param>
  72. /// <param name="sType">1则取预报毛重 2则取预报净重</param>
  73. /// <param name="fristMeter"></param>
  74. private void ValidMethods(PreTrackScale scale, string sType, MeterWorkCarActualFirst fristMeter)
  75. {
  76. //根据物料编号+计量类型编号
  77. string sql = @"select t1.diff_type_no diffTypeNo,
  78. t1.diff_type_name diffTypeName,
  79. t1.meter_type_no meterTypeNo,
  80. t1.meter_type_name meterTypeName,
  81. t1.rate_value rateValue,
  82. t1.fixed_weight_value fixedWeightValue,
  83. t2.meter_nature_no meterNatureNo,
  84. t2.meter_nature_name meterNatureName
  85. from meter_base_prediction_diff t1, meter_base_diff_relation t2
  86. WHERE t2.matter_no = '" + scale.matterNo + @"'
  87. AND t1.meter_type_no = '" + scale.meterTypeNo + @"'
  88. and t1.diff_no = t2.diff_no
  89. and t1.value_flag = '0'";
  90. PbModelDbService<List<MeterBasePredictionDiff>> pb = new PbModelDbService<List<MeterBasePredictionDiff>>();
  91. RESTfulResult<List<MeterBasePredictionDiff>> rm = pb.executeSqlDataWf(sql);
  92. if (rm.Succeed)
  93. {
  94. if (rm.Data != null && rm.Data.Count > 0)
  95. {
  96. List<MeterBasePredictionDiff> dt = rm.Data;
  97. //mblc[0].limit_class_no 001014002固定重量 001014001按比例
  98. if (dt[0].diffTypeNo == "001014002") //按固定重量
  99. {
  100. double maxWgt = 0, minWgt = 0, wgt = 0;
  101. if (sType == "1") //PbCache.lockWgt在预报毛重+-固定值
  102. {
  103. maxWgt = scale.shipmentGrossWeight.Value + (dt[0].fixedWeightValue == null ? 0 : dt[0].fixedWeightValue.Value);
  104. minWgt = scale.shipmentGrossWeight.Value - (dt[0].fixedWeightValue == null ? 0 : dt[0].fixedWeightValue.Value);
  105. wgt = PbCache.lockWgt;//计量重量
  106. }
  107. else //净重
  108. {
  109. maxWgt = scale.shipmentNetWeight.Value + (dt[0].fixedWeightValue == null ? 0 : dt[0].fixedWeightValue.Value);
  110. minWgt = scale.shipmentNetWeight.Value - (dt[0].fixedWeightValue == null ? 0 : dt[0].fixedWeightValue.Value);
  111. wgt = Math.Abs(PbCache.lockWgt - fristMeter.meterWeight.Value - (fristMeter.addWeight == null ? 0 : fristMeter.addWeight.Value));//当前重量-上次重量-附加重量
  112. }
  113. if (maxWgt >= wgt && wgt >= minWgt)
  114. {
  115. PbCache.monitorResult.valid_prediction_diff = true;
  116. }
  117. else
  118. { //2021年5月10日界面显示单位,调整为T
  119. PbCache.monitorResult.valid_prediction_diff = false;
  120. if (sType == "1")
  121. {
  122. PbCache.ResultMessage = "车辆重量[" + Math.Round(PbCache.lockWgt / 1000, 2) + "T]" +
  123. "与预报重量[" + Math.Round(scale.shipmentGrossWeight.Value / 1000, 2) + "T]" +
  124. "的差值超出偏差范围,偏差值[" + Math.Round((double)dt[0].fixedWeightValue.Value / 1000, 2) + "T]";
  125. }
  126. else
  127. {
  128. PbCache.ResultMessage = "车辆净重[" + Math.Round(PbCache.lockWgt / 1000 - fristMeter.meterWeight.Value / 1000 - (fristMeter.addWeight == null ? 0 : fristMeter.addWeight.Value / 1000), 2) + " T]" +
  129. "与预报净重[" + Math.Round(scale.shipmentNetWeight.Value / 1000, 2) + " T]" +
  130. "的差值超出偏差范围,偏差值[" + Math.Round((double)dt[0].fixedWeightValue.Value / 1000, 2) + "T]";
  131. }
  132. }
  133. }
  134. else if (dt[0].diffTypeNo == "001014001") //按比例10 90 100 110
  135. {
  136. double maxWgt = 0, minWgt = 0, wgt = 0;
  137. if (sType == "1") //PbCache.lockWgt在预报毛重+-固定值
  138. {
  139. maxWgt = scale.shipmentGrossWeight.Value + scale.shipmentGrossWeight.Value * (dt[0].rateValue == null ? 1 : dt[0].rateValue.Value / 100);
  140. minWgt = scale.shipmentGrossWeight.Value - scale.shipmentGrossWeight.Value * (dt[0].rateValue == null ? 1 : dt[0].rateValue.Value / 100);
  141. wgt = PbCache.lockWgt;//计量重量
  142. }
  143. else //净重+-净重*比例
  144. {
  145. maxWgt = scale.shipmentNetWeight.Value + scale.shipmentNetWeight.Value * (dt[0].rateValue == null ? 1 : dt[0].rateValue.Value / 100);
  146. minWgt = scale.shipmentNetWeight.Value - scale.shipmentNetWeight.Value * (dt[0].rateValue == null ? 1 : dt[0].rateValue.Value / 100);
  147. wgt = Math.Abs(PbCache.lockWgt - fristMeter.meterWeight.Value - (fristMeter.addWeight == null ? 0 : fristMeter.addWeight.Value));//当前重量-上次重量-附加重量
  148. }
  149. if (maxWgt >= wgt && wgt >= minWgt)
  150. {
  151. PbCache.monitorResult.valid_prediction_diff = true;
  152. }
  153. else
  154. {
  155. PbCache.monitorResult.valid_prediction_diff = false;
  156. // PbCache.ResultMessage = "车辆重量与预报重量的差值超出偏差范围,偏差比例["+ dt[0].rateValue.Value + "%]";
  157. if (sType == "1")
  158. PbCache.ResultMessage = "车辆重量[" + Math.Round(PbCache.lockWgt / 1000, 2) + " T]" +
  159. "与预报重量[" + Math.Round(scale.shipmentGrossWeight.Value / 1000, 2) + " T]" +
  160. "的差值超出偏差范围,偏差比例[" + dt[0].fixedWeightValue.Value + "%]";
  161. else
  162. PbCache.ResultMessage = "车辆净重[" + Math.Round(PbCache.lockWgt / 1000 - fristMeter.meterWeight.Value / 1000 - (fristMeter.addWeight == null ? 0 : fristMeter.addWeight.Value / 1000), 2) + " T]" +
  163. "与预报净重[" + Math.Round(scale.shipmentNetWeight.Value / 1000, 2) + " T]" +
  164. "的差值超出偏差范围,偏差比例[" + dt[0].fixedWeightValue.Value + "%]";
  165. }
  166. }
  167. else
  168. {
  169. PbCache.monitorResult.valid_prediction_diff = true;
  170. PbCache.ResultMessage = "";
  171. //PbCache.ResultMessage = "没有超差方式[" + dt.Rows[0]["DIFF_TYPE_NAME"].ToString() + "]的逻辑";
  172. }
  173. }
  174. else
  175. {
  176. PbCache.monitorResult.valid_prediction_diff = true;
  177. //PbCache.ResultMessage = "未找到物料对应的预报超差值";
  178. }
  179. }
  180. }
  181. }
  182. }