InnerCarJISCO.cs 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070
  1. using com.hnshituo.core.webapp.vo;
  2. using Common;
  3. using Common.DbOption.work;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace MeterSceneLibrary
  9. {
  10. /// <summary>
  11. /// 酒钢厂内车辆计量业务
  12. /// </summary>
  13. public class InnerCarJISCO
  14. {
  15. // 一次计量数据
  16. private MeterWorkCarActualFirstService mwcfs = new MeterWorkCarActualFirstService();
  17. // 重量类型预处理表
  18. private MeterWorkPreWgttypeService wgttypeService = new MeterWorkPreWgttypeService();
  19. // 车辆委托表
  20. private PreTrackScaleService preTrackScaleService = new PreTrackScaleService();
  21. // 留期限皮操作
  22. private MeterBaseTermTareDataService termTareDate = new MeterBaseTermTareDataService();
  23. private MeterBaseSpotInfoService meterBaseSpotInfoService = new MeterBaseSpotInfoService();
  24. private rtInfo rt = new rtInfo();
  25. // 构建一次计量数据
  26. private MeterWorkCarActualFirst mwaf = new MeterWorkCarActualFirst();
  27. private MeterBaseCarService carService = new MeterBaseCarService();
  28. private MeterBaseSpecialUnitService meterBaseSpecialUnitService = new MeterBaseSpecialUnitService();
  29. // 结净最小值,默认取配置文件
  30. private double diffrentWgt = AppConfigCache.differenceWgt;
  31. // 根据称点查询监控信息
  32. private RESTfulResult<List<MeterWorkMonitor>> listMonitor;
  33. // 根据车号查询委托表中未使用和使用中的委托
  34. private List<PreTrackScale> listPreScale;
  35. private JISCO.SaveMethod saveMethod = new JISCO.SaveMethod();
  36. public rtInfo MeterMethod(PreTrackScale scale)
  37. {
  38. Log lg = Log.GetInstance();
  39. rt.isError = false;
  40. string ResultMessage = "";
  41. bool isError = false;
  42. //根据称点查询监控信息
  43. MeterWorkMonitorService meterWorkMonitorService = new MeterWorkMonitorService();
  44. listMonitor = meterWorkMonitorService.doQueryOneWf(new MeterWorkMonitor { pointNo = PbCache.sportInfo.baseSpotNo });
  45. mwaf.carNo = PbCache.lockCarNo;
  46. mwaf.weightType = ""; // 默认重量类型为空
  47. mwaf.actualFirstNo = DateTime.Now.ToString("yyyyMMdd");//10
  48. mwaf.meterWeight = PbCache.lockWgt;//计量重量
  49. mwaf.addWeight = PbCache.addWgt;//附加重量
  50. mwaf.createManNo = "admin";
  51. mwaf.createManName = "admin";
  52. mwaf.meterGroup = "";
  53. mwaf.meterClass = "";
  54. mwaf.createManNo = "SYSTEM";
  55. mwaf.createManName = "system";
  56. mwaf.createTime = DateTime.Now;
  57. mwaf.baseSpotNo = PbCache.sportInfo.baseSpotNo;//计量点编号
  58. mwaf.baseSpotName = PbCache.sportInfo.baseSpotName;
  59. //mwaf.memo = "";
  60. mwaf.valueFlag = "1"; //状态(0 = 作废,1 = 有效(已匹配),2 = 结净)
  61. mwaf.updateManName = "";
  62. mwaf.updateManNo = "";
  63. mwaf.updateTime = null;
  64. mwaf.checkFlag = "1"; //0未审核,1已审核
  65. mwaf.meterMode = "2"; //1:远程计量;2:智能计量;3:手工录入;4:放行智能计量;5:滞后匹配
  66. mwaf.addWeight = PbCache.addWgt;
  67. mwaf.dataSource = "1"; //数据来源(1=智能终端,2=本地计量,3=应急计量,4=手动录入(计量票据录入))
  68. PbCache.isActual = false;
  69. PbCache.isInnerCar = false;
  70. PbCache.ResultMessage = "";
  71. PbCache.monitorResultMessage = "";
  72. PbCache.LEDResultMessage = "";
  73. PbCache.yardActual = null;
  74. PbCache.yardFirst = null;
  75. // 根据车号查询重量类型预处理表
  76. RESTfulResult<List<MeterWorkPreWgttype>> rmX = wgttypeService.doQueryWf(new MeterWorkPreWgttype { carNo = PbCache.lockCarNo, valueFlag = "1" });
  77. // 不存在未使用的重量类型数据
  78. if (rmX.Succeed)
  79. {
  80. List<MeterWorkPreWgttype> list = rmX.Data;
  81. // 不存在一次预处理数据
  82. if (list == null || list.Count == 0)
  83. {
  84. /* a. 程序报警
  85. * b. 自动进行语音求助
  86. */
  87. rt = saveMethod.doError("未选择称重类型,请选择后开始计量");
  88. PbCache.voiceType = 21;
  89. PbCache.monitorResultMessage = "未选择称重类型,请选择后开始计量";
  90. PbCache.LEDResultMessage = "未选择称重类型,请选择后开始计量";
  91. PbCache.ResultMessage = "未选择称重类型,请选择后开始计量";
  92. return rt;
  93. }
  94. // 存在一条预处理数据
  95. else if (list == null || list.Count == 1)
  96. {
  97. // 历史皮重验证
  98. // 001033002:皮重
  99. rt = saveMethod.validHisTare2(list[0].weightTypeNo);
  100. if (list[0].weightTypeNo == "001033002" && PbCache.monitorResult.valid_wgt == false && listMonitor.Data[0].validWgt == "1")
  101. {
  102. PbCache.ResultMessage = "毛皮类型选错,请重新选择";
  103. PbCache.LEDResultMessage = "计量失败,毛皮类型选错,请重新选择";
  104. PbCache.voiceType = 26;
  105. rt = saveMethod.doError(PbCache.ResultMessage);
  106. rt.isWarn = true;
  107. rt.WarnContent = "validWgt";
  108. return rt;
  109. }
  110. // 001033001:毛重
  111. if (list[0].weightTypeNo == "001033001" && PbCache.monitorResult.valid_wgt == true && listMonitor.Data[0].validWgt == "1")
  112. {
  113. PbCache.ResultMessage = "毛皮类型选错,请重新选择";
  114. PbCache.LEDResultMessage = "计量失败,毛皮类型选错,请重新选择";
  115. PbCache.voiceType = 23;
  116. rt = saveMethod.doError(PbCache.ResultMessage);
  117. rt.isWarn = true;
  118. rt.WarnContent = "validWgt";
  119. return rt;
  120. }
  121. //拿到车辆
  122. RESTfulResult<List<MeterBaseCar>> resCarList = carService.doQueryCarList(new MeterBaseCar { carNo = PbCache.lockCarNo });
  123. RESTfulResult<List<MeterBaseSpecialUnit>> sunitList = meterBaseSpecialUnitService.doQueryCarList(new MeterBaseSpecialUnit { unitNo = resCarList.Data[0].usetDepartmentNo });
  124. if (resCarList.Data[0].usetDepartmentNo == "888888")
  125. {}
  126. else
  127. {
  128. if (sunitList.Data == null || sunitList.Data.Count != 1)
  129. { }
  130. else
  131. {
  132. bool isGorss = rmX.Data[0].submitFlag == "1" && rmX.Data[0].weightTypeNo == "001033001";
  133. if (isGorss || rmX.Data[0].weightTypeNo == "001033002")
  134. { }
  135. else
  136. {
  137. rt = saveMethod.doError("");
  138. rt.resultInfo = string.Format("车号{0},当前毛重{1}吨,请确认重量", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  139. PbCache.LEDResultMessage = string.Format("车号{0},当前毛重{1}吨,请确认重量", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  140. PbCache.voiceType = 12;
  141. return rt;
  142. }
  143. }
  144. }
  145. // 查已选择的委托
  146. RESTfulResult<List<PreTrackScale>> rmScale = preTrackScaleService.doQueryByFlag(new PreTrackScale { carNo = PbCache.lockCarNo, lineDesc = "1"});
  147. if (rmScale.Succeed && rmScale.Data.Count == 1 && list[0].weightTypeNo == "001033001")
  148. {
  149. // 重量类型为期限皮重
  150. if (list[0].weightTypeNo == "001033003")
  151. {
  152. // 判断这个车是否有留存期限皮重的权限
  153. MeterBaseTermTareCarService meterBaseTermTareCarService = new MeterBaseTermTareCarService();
  154. RESTfulResult<List<MeterBaseTermTareCar>> tareCarResult = meterBaseTermTareCarService.doQueryWf(new MeterBaseTermTareCar { carNo = PbCache.lockCarNo, valueFlag = "0" });
  155. if (tareCarResult.Succeed)
  156. {
  157. // 没有期限皮重权限
  158. if (tareCarResult.Data == null || tareCarResult.Data.Count == 0)
  159. {
  160. rt = saveMethod.doError("该车辆没有期限皮重权限,请联系计量大厅");
  161. PbCache.monitorResultMessage = "该车辆没有期限皮重权限";
  162. return rt;
  163. }
  164. // 有期限皮重权限
  165. else if (tareCarResult.Data.Count >= 1)
  166. {
  167. // 正常保存期限皮重
  168. rt = saveMethod.doTermTareData();
  169. }
  170. }
  171. }
  172. // 重量类型为普通毛重/皮重
  173. else if (list[0].weightTypeNo == "001033001" || list[0].weightTypeNo == "001033002")
  174. {
  175. // 查询一次计量数据表
  176. RESTfulResult<List<MeterWorkCarActualFirst>> rmFirst = mwcfs.doQueryByFlag(new MeterWorkCarActualFirst { carNo = PbCache.lockCarNo });
  177. if (rmX.Succeed)
  178. {
  179. List<MeterWorkCarActualFirst> firstList = rmFirst.Data;
  180. // 不存在有效的一次计量数据
  181. if (firstList == null || firstList.Count == 0)
  182. {
  183. // 历史皮重验证
  184. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  185. // 重量类型为皮重且在皮重误差内
  186. if (list[0].weightTypeNo == "001033002" && (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0"))
  187. {
  188. /*sds
  189. * a. 正常保存重量匹配委托
  190. * b. 提示称重完成
  191. */
  192. mwaf.weightType = "1";
  193. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  194. PbCache.voiceType = 1;
  195. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  196. }
  197. // 重量类型为皮重且在皮重误差外
  198. else if (list[0].weightTypeNo == "001033002" && PbCache.monitorResult.valid_wgt == false && listMonitor.Data[0].validWgt == "1")
  199. {
  200. if (PbCache.ResultMessage == "")
  201. {
  202. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  203. }
  204. PbCache.voiceType = 13;
  205. rt = saveMethod.doError(PbCache.ResultMessage);
  206. rt.isWarn = true;
  207. rt.WarnContent = "validWgt";
  208. return rt;
  209. }
  210. // 重量类型为毛重,在皮重误差内
  211. else if (list[0].weightTypeNo == "001033001" && PbCache.monitorResult.valid_wgt == true && listMonitor.Data[0].validWgt == "1")
  212. {
  213. if (PbCache.ResultMessage == "")
  214. {
  215. PbCache.ResultMessage = "重量类型为毛重,在皮重误差内";
  216. }
  217. PbCache.voiceType = 23;
  218. rt = saveMethod.doError(PbCache.ResultMessage);
  219. rt.isWarn = true;
  220. rt.WarnContent = "validWgt";
  221. return rt;
  222. }
  223. // 重量类型为毛重,不在皮重误差内
  224. else if (list[0].weightTypeNo == "001033001" && (PbCache.monitorResult.valid_wgt == false || listMonitor.Data[0].validWgt == "0"))
  225. {
  226. //判断称点是否允许期限皮重
  227. if (PbCache.sportInfo.allowedTareWeight == "1")
  228. {
  229. if (AppConfigCache.TareControlType == "3")
  230. {
  231. // 判断是否具有期限皮重权限
  232. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  233. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  234. meterBaseUnitInfo.matterNo = rmScale.Data[0].matterNo;
  235. meterBaseUnitInfo.matterName = rmScale.Data[0].matterName;
  236. meterBaseUnitInfo.forwardingUnitNo = rmScale.Data[0].forwardingUnitNo;
  237. meterBaseUnitInfo.forwardingUnitName = rmScale.Data[0].forwardingUnitName;
  238. meterBaseUnitInfo.receivingUnitNo = rmScale.Data[0].receivingUintNo;
  239. meterBaseUnitInfo.receivingUnitName = rmScale.Data[0].receivingUintName;
  240. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  241. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  242. if (tareUnitResult.Succeed)
  243. {
  244. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  245. {
  246. mwaf.weightType = "0";
  247. // 只保存一次计量数据
  248. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  249. PbCache.voiceType = 1;
  250. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  251. }
  252. else
  253. {
  254. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  255. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0",spotAreaNo = PbCache.sportInfo.spotAreaNo });
  256. if (termTareData.Succeed)
  257. {
  258. if (termTareData.Data == null)
  259. {
  260. mwaf.weightType = "0";
  261. // 只保存一次计量数据
  262. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  263. PbCache.voiceType = 15;
  264. rt.resultInfo = "计量成功,期限皮过期,请留存期限皮";
  265. PbCache.ResultMessage = "计量成功,期限皮过期,请留存期限皮";
  266. PbCache.monitorResultMessage = "计量成功,期限皮过期,请留存期限皮";
  267. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,计量完成,期限皮过期", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  268. }
  269. else
  270. {
  271. // 存在使用期限皮重权限,并使用期限皮重结净
  272. List<string> l = new List<string>();
  273. l.Add("create");
  274. //给一次数据匹配委托
  275. EntityBase<PreTrackScale> entityBase1 = new EntityBase<PreTrackScale>();
  276. mwaf = entityBase1.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  277. mwaf.isPreScale = "1";
  278. mwaf.weightType = "0";
  279. rt = saveMethod.doNetTermTare(rmScale.Data[0], mwaf);
  280. rt.resultInfo += ",期限皮结净";
  281. PbCache.voiceType = 16;
  282. PbCache.ResultMessage = "计量完成,期限皮结净";
  283. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,净重{2}吨,期限皮结净", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(PbCache.lockWgt - termTareData.Data.meterWeight.Value) / 1000), 2));
  284. }
  285. }
  286. }
  287. }
  288. }
  289. }
  290. else
  291. {
  292. mwaf.weightType = "0";
  293. // 只保存一次计量数据
  294. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  295. PbCache.voiceType = 1;
  296. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  297. }
  298. }
  299. else
  300. {
  301. rt = saveMethod.doError("程序处理异常");
  302. return rt;
  303. }
  304. }
  305. // 只存在一条有效的一次计量数据
  306. else if (firstList == null || firstList.Count == 1)
  307. {
  308. // 读结净最小值配置
  309. ComBaseInfoService cbis = new ComBaseInfoService();
  310. RESTfulResult<List<ComBaseInfo>> res = cbis.doQueryBaseList(new ComBaseInfo { baseCode = "001031001" });
  311. if (res.Succeed)
  312. {
  313. if (res.Data != null && res.Data.Count == 1)
  314. {
  315. try
  316. {
  317. diffrentWgt = Double.Parse(res.Data[0].baseName);
  318. }
  319. finally
  320. {
  321. }
  322. }
  323. }
  324. if (firstList[0].weightType == "0" && list[0].weightTypeNo == "001033001")
  325. {
  326. // 历史皮重验证
  327. rt = saveMethod.validHisTare2(list[0].weightTypeNo);
  328. if (PbCache.monitorResult.valid_wgt == false || listMonitor.Data[0].validWgt == "0")
  329. {
  330. //判断称点是否允许期限皮重
  331. if (PbCache.sportInfo.allowedTareWeight == "1")
  332. {
  333. if (AppConfigCache.TareControlType == "3")
  334. {
  335. // 判断收发货单位是否具有期限皮重权限
  336. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  337. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  338. meterBaseUnitInfo.matterNo = rmScale.Data[0].matterNo;
  339. meterBaseUnitInfo.matterName = rmScale.Data[0].matterName;
  340. meterBaseUnitInfo.forwardingUnitNo = rmScale.Data[0].forwardingUnitNo;
  341. meterBaseUnitInfo.forwardingUnitName = rmScale.Data[0].forwardingUnitName;
  342. meterBaseUnitInfo.receivingUnitNo = rmScale.Data[0].receivingUintNo;
  343. meterBaseUnitInfo.receivingUnitName = rmScale.Data[0].receivingUintName;
  344. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  345. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  346. if (tareUnitResult.Succeed)
  347. {
  348. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  349. {
  350. mwaf.weightType = "0";
  351. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  352. rt.resultInfo = "存在未结净毛重";
  353. PbCache.voiceType = 11;
  354. PbCache.ResultMessage = "存在未结净毛重";
  355. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  356. PbCache.monitorResultMessage = "存在未结净毛重";
  357. rt.isWarn = true;
  358. rt.WarnContent = "validWgt";
  359. }
  360. else
  361. {
  362. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  363. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0" , spotAreaNo = PbCache.sportInfo.spotAreaNo });
  364. if (termTareData.Succeed)
  365. {
  366. if (termTareData.Data == null)
  367. {
  368. mwaf.weightType = "0";
  369. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  370. rt.resultInfo = "期限皮过期,存在未结净毛重";
  371. PbCache.voiceType = 17;
  372. PbCache.ResultMessage = "期限皮过期,存在未结净毛重";
  373. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,期限皮过期,存在未结净毛重", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  374. PbCache.monitorResultMessage = "期限皮过期,存在未结净毛重";
  375. rt.isWarn = true;
  376. rt.WarnContent = "validWgt";
  377. }
  378. else
  379. {
  380. // 存在使用期限皮重权限,并使用期限皮重结净
  381. List<string> l = new List<string>();
  382. l.Add("create");
  383. //给一次数据匹配委托
  384. EntityBase<PreTrackScale> entityBase1 = new EntityBase<PreTrackScale>();
  385. mwaf = entityBase1.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  386. mwaf.isPreScale = "1";
  387. mwaf.weightType = "0";
  388. PbCache.voiceType = 16;
  389. PbCache.ResultMessage = "计量完成,期限皮结净";
  390. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,净重{2}吨,期限皮结净", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(PbCache.lockWgt - termTareData.Data.meterWeight.Value) / 1000), 2));
  391. rt = saveMethod.doNetTermTare(rmScale.Data[0], mwaf);
  392. rt.resultInfo += ",期限皮结净";
  393. }
  394. }
  395. }
  396. }
  397. }
  398. }
  399. else
  400. {
  401. mwaf.weightType = "0";
  402. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  403. rt.resultInfo = "存在未结净毛重";
  404. PbCache.voiceType = 11;
  405. PbCache.ResultMessage = "存在未结净毛重";
  406. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  407. PbCache.monitorResultMessage = "存在未结净毛重";
  408. rt.isWarn = true;
  409. rt.WarnContent = "validWgt";
  410. }
  411. return rt;
  412. }
  413. else
  414. {
  415. if (PbCache.ResultMessage == "")
  416. {
  417. PbCache.ResultMessage = "重量类型为毛重,在皮重误差内";
  418. }
  419. PbCache.voiceType = 23;
  420. rt = saveMethod.doError(PbCache.ResultMessage);
  421. rt.isWarn = true;
  422. rt.WarnContent = "validWgt";
  423. return rt;
  424. }
  425. }
  426. // 当次重量和上次重量满足结净最小值条件
  427. if (Math.Abs(rmFirst.Data[0].meterWeight.Value - PbCache.lockWgt) > diffrentWgt || listMonitor.Data[0].validPredictionDiff == "0")
  428. {
  429. // 历史皮重验证
  430. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  431. // 重量类型为皮重且在皮重误差内,正常结净
  432. if (list[0].weightTypeNo == "001033002" && (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0"))
  433. {
  434. // 正常结净
  435. //给一次数据匹配委托
  436. EntityBase<PreTrackScale> entityBase1 = new EntityBase<PreTrackScale>();
  437. mwaf = entityBase1.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  438. mwaf.isPreScale = "1";
  439. rt = saveMethod.doNet(rmScale.Data[0], firstList[0], mwaf);
  440. PbCache.voiceType = 13;
  441. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,净重{2}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(rmFirst.Data[0].meterWeight.Value - PbCache.lockWgt) / 1000), 2));
  442. }
  443. // 重量类型为皮重且不在皮重误差内
  444. else if (list[0].weightTypeNo == "001033002" && PbCache.monitorResult.valid_wgt == false && listMonitor.Data[0].validWgt == "1")
  445. {
  446. if (PbCache.ResultMessage == "")
  447. {
  448. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  449. }
  450. PbCache.voiceType = 13;
  451. rt = saveMethod.doError(PbCache.ResultMessage);
  452. return rt;
  453. }
  454. // 重量类型为毛重,不在皮重误差内,正常结净
  455. else if (list[0].weightTypeNo == "001033001" && (PbCache.monitorResult.valid_wgt == false || listMonitor.Data[0].validWgt == "0"))
  456. {
  457. if (firstList[0].weightType == "0")
  458. {
  459. //判断称点是否允许期限皮重
  460. if (PbCache.sportInfo.allowedTareWeight == "1")
  461. {
  462. if (AppConfigCache.TareControlType == "3")
  463. {
  464. /// 判断是否具有期限皮重权限
  465. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  466. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  467. meterBaseUnitInfo.matterNo = rmScale.Data[0].matterNo;
  468. meterBaseUnitInfo.matterName = rmScale.Data[0].matterName;
  469. meterBaseUnitInfo.forwardingUnitNo = rmScale.Data[0].forwardingUnitNo;
  470. meterBaseUnitInfo.forwardingUnitName = rmScale.Data[0].forwardingUnitName;
  471. meterBaseUnitInfo.receivingUnitNo = rmScale.Data[0].receivingUintNo;
  472. meterBaseUnitInfo.receivingUnitName = rmScale.Data[0].receivingUintName;
  473. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  474. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  475. if (tareUnitResult.Succeed)
  476. {
  477. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  478. {
  479. mwaf.weightType = "0";
  480. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  481. rt.resultInfo = "存在未结净毛重";
  482. PbCache.voiceType = 11;
  483. PbCache.ResultMessage = "存在未结净毛重";
  484. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  485. PbCache.monitorResultMessage = "存在未结净毛重";
  486. rt.isWarn = true;
  487. rt.WarnContent = "validWgt";
  488. }
  489. else
  490. {
  491. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  492. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0", spotAreaNo = PbCache.sportInfo.spotAreaNo });
  493. if (termTareData.Succeed)
  494. {
  495. if (termTareData.Data == null)
  496. {
  497. mwaf.weightType = "0";
  498. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  499. rt.resultInfo = "期限皮过期,存在未结净毛重";
  500. PbCache.voiceType = 17;
  501. PbCache.ResultMessage = "期限皮过期,存在未结净毛重";
  502. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,期限皮过期,存在未结净毛重", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  503. PbCache.monitorResultMessage = "期限皮过期,存在未结净毛重";
  504. rt.isWarn = true;
  505. rt.WarnContent = "validWgt";
  506. }
  507. else
  508. {
  509. // 存在使用期限皮重权限,并使用期限皮重结净
  510. List<string> l = new List<string>();
  511. l.Add("create");
  512. //给一次数据匹配委托
  513. EntityBase<PreTrackScale> entityBase1 = new EntityBase<PreTrackScale>();
  514. mwaf = entityBase1.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  515. mwaf.isPreScale = "1";
  516. mwaf.weightType = "0";
  517. PbCache.voiceType = 16;
  518. PbCache.ResultMessage = "计量完成,期限皮结净";
  519. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,净重{2}吨,期限皮结净", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(PbCache.lockWgt - termTareData.Data.meterWeight.Value) / 1000), 2));
  520. rt = saveMethod.doNetTermTare(rmScale.Data[0], mwaf);
  521. rt.resultInfo += ",期限皮结净";
  522. }
  523. }
  524. }
  525. }
  526. }
  527. }
  528. else
  529. {
  530. mwaf.weightType = "0";
  531. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  532. rt.resultInfo = "存在未结净毛重";
  533. PbCache.voiceType = 11;
  534. PbCache.ResultMessage = "存在未结净毛重";
  535. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  536. PbCache.monitorResultMessage = "存在未结净毛重";
  537. rt.isWarn = true;
  538. rt.WarnContent = "validWgt";
  539. }
  540. }
  541. else
  542. {
  543. if (PbCache.sportInfo.allowedTareWeight == "1")
  544. {
  545. if (AppConfigCache.TareControlType == "3")
  546. {
  547. // 判断是否具有期限皮重权限
  548. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  549. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  550. meterBaseUnitInfo.matterNo = rmScale.Data[0].matterNo;
  551. meterBaseUnitInfo.matterName = rmScale.Data[0].matterName;
  552. meterBaseUnitInfo.forwardingUnitNo = rmScale.Data[0].forwardingUnitNo;
  553. meterBaseUnitInfo.forwardingUnitName = rmScale.Data[0].forwardingUnitName;
  554. meterBaseUnitInfo.receivingUnitNo = rmScale.Data[0].receivingUintNo;
  555. meterBaseUnitInfo.receivingUnitName = rmScale.Data[0].receivingUintName;
  556. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  557. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  558. if (tareUnitResult.Succeed)
  559. {
  560. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  561. {
  562. // 正常结净
  563. //给一次数据匹配委托
  564. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  565. mwaf = entityBase3.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  566. mwaf.isPreScale = "1";
  567. mwaf.weightType = "0";
  568. PbCache.voiceType = 1;
  569. rt = saveMethod.doNet(rmScale.Data[0], firstList[0], mwaf);
  570. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,净重{2}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(rmFirst.Data[0].meterWeight.Value - PbCache.lockWgt) / 1000), 2));
  571. }
  572. else
  573. {
  574. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  575. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0", spotAreaNo = PbCache.sportInfo.spotAreaNo });
  576. if (termTareData.Succeed)
  577. {
  578. // 正常结净
  579. //给一次数据匹配委托
  580. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  581. mwaf = entityBase3.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  582. mwaf.isPreScale = "1";
  583. mwaf.weightType = "0";
  584. PbCache.voiceType = 9;
  585. rt = saveMethod.doTermTareNet(rmScale.Data[0], mwaf, firstList[0],"0");
  586. rt.resultInfo += ",留存期限皮成功";
  587. PbCache.ResultMessage = "计量成功,留存期限皮成功";
  588. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,净重{2}吨,留存期限皮成功", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(firstList[0].meterWeight.Value - PbCache.lockWgt) / 1000), 2));
  589. }
  590. }
  591. }
  592. }
  593. }
  594. else
  595. {
  596. // 正常结净
  597. //给一次数据匹配委托
  598. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  599. mwaf = entityBase3.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  600. mwaf.isPreScale = "1";
  601. mwaf.weightType = "0";
  602. PbCache.voiceType = 1;
  603. rt = saveMethod.doNet(rmScale.Data[0], firstList[0], mwaf);
  604. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,净重{2}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(rmFirst.Data[0].meterWeight.Value - PbCache.lockWgt) / 1000), 2));
  605. }
  606. }
  607. }
  608. // 重量类型为毛重,在皮重误差内
  609. else if (list[0].weightTypeNo == "001033001" && PbCache.monitorResult.valid_wgt == true && listMonitor.Data[0].validWgt == "1")
  610. {
  611. if (PbCache.ResultMessage == "")
  612. {
  613. PbCache.ResultMessage = "毛重接近历史皮重,请联系处理";
  614. }
  615. PbCache.voiceType = 23;
  616. rt = saveMethod.doError(PbCache.ResultMessage);
  617. return rt;
  618. }
  619. }
  620. else
  621. {
  622. rt = saveMethod.doError("第一次计量重量【" + rmFirst.Data[0].meterWeight.Value / 1000 + "T】和第二次计量重量【" + PbCache.lockWgt / 1000 + "T】接近,小于结净最小值【" + diffrentWgt / 1000 + " T】");
  623. rt.isWarn = true;
  624. PbCache.voiceType = 4;
  625. PbCache.LEDResultMessage = "计量失败,小于结净最小值,请联系计量大厅";
  626. rt.WarnContent = "validWgt";
  627. return rt;
  628. }
  629. }
  630. // 存在多条有效的一次计量数据
  631. else if (firstList == null || firstList.Count > 1)
  632. {
  633. // 历史皮重验证
  634. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  635. /* a. 程序报警a
  636. * b. 自动进行语音求助
  637. */
  638. //多条一次记录下判断是否全为毛重,是全部结净
  639. if (firstList[firstList.Count - 1].weightType == "0" && list[0].weightTypeNo == "001033002")
  640. {
  641. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  642. {
  643. mwaf.weightType = "1";
  644. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  645. PbCache.voiceType = 1;
  646. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  647. }
  648. else
  649. {
  650. if (PbCache.ResultMessage == "")
  651. {
  652. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  653. }
  654. PbCache.voiceType = 13;
  655. rt = saveMethod.doError(PbCache.ResultMessage);
  656. return rt;
  657. }
  658. }
  659. else if (firstList[firstList.Count - 1].weightType == "0" && list[0].weightTypeNo == "001033001")
  660. {
  661. if (PbCache.monitorResult.valid_wgt == false || listMonitor.Data[0].validWgt == "0")
  662. {
  663. mwaf.weightType = "0";
  664. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  665. PbCache.voiceType = 11;
  666. rt.resultInfo = string.Format("存在未结净毛重", firstList.Count);
  667. PbCache.ResultMessage = string.Format("存在未结净毛重", firstList.Count);
  668. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), firstList.Count);
  669. PbCache.monitorResultMessage = string.Format("存在未结净毛重", firstList.Count);
  670. rt.isWarn = true;
  671. rt.WarnContent = "validWgt";
  672. }
  673. else
  674. {
  675. if (PbCache.ResultMessage == "")
  676. {
  677. PbCache.ResultMessage = "毛重接近历史皮重,请联系处理";
  678. }
  679. PbCache.voiceType = 23;
  680. rt = saveMethod.doError(PbCache.ResultMessage);
  681. return rt;
  682. }
  683. }
  684. else
  685. {
  686. rt = saveMethod.doError("存在多条有效的一次计量数据,请联系计量大厅");
  687. PbCache.voiceType = 8;
  688. PbCache.LEDResultMessage = "存在多条有效的一次计量数据,请联系计量大厅";
  689. return rt;
  690. }
  691. }
  692. else
  693. {
  694. rt = saveMethod.doError("存在多条有效的一次计量数据,请联系计量大厅");
  695. PbCache.voiceType = 8;
  696. PbCache.LEDResultMessage = "存在多条有效的一次计量数据,请联系计量大厅";
  697. return rt;
  698. }
  699. }
  700. }
  701. }
  702. else
  703. {
  704. if (rmScale.Succeed && rmScale.Data.Count == 0)
  705. {
  706. // 查询一次计量数据表
  707. RESTfulResult<List<MeterWorkCarActualFirst>> rmFirst = mwcfs.doQueryByFlag(new MeterWorkCarActualFirst { carNo = PbCache.lockCarNo });
  708. if (rmFirst.Succeed)
  709. {
  710. List<MeterWorkCarActualFirst> firstList = rmFirst.Data;
  711. // 重量类型为皮重
  712. if (list[0].weightTypeNo == "001033002")
  713. {
  714. //if (PbCache.lockWgt > 25000)
  715. //{
  716. // rt = saveMethod.doError(string.Format("当前重量:{0},请确认是否,误选为皮重上秤", PbCache.lockWgt));
  717. // PbCache.voiceType = 26;
  718. // PbCache.LEDResultMessage = string.Format("当前重量:{0},请确认是否,误选为皮重上秤", PbCache.lockWgt);
  719. // return rt;
  720. //}
  721. // 历史皮重验证
  722. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  723. if (firstList == null || firstList.Count == 0)
  724. {
  725. //在皮重误差内
  726. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  727. {
  728. //正常保存一次数据
  729. mwaf.weightType = "1";
  730. PbCache.voiceType = 1;
  731. rt = saveMethod.doAddFirst(null, mwaf);
  732. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  733. }
  734. else
  735. {
  736. if (PbCache.ResultMessage == "")
  737. {
  738. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  739. }
  740. rt = saveMethod.doError(PbCache.ResultMessage);
  741. PbCache.voiceType = 13;
  742. rt.isWarn = true;
  743. rt.WarnContent = "validWgt";
  744. return rt;
  745. }
  746. }
  747. else if (firstList.Count == 1 && firstList[0].weightType != "0")
  748. {
  749. // 在皮重误差内
  750. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  751. {
  752. //保存一条作废的皮重数据
  753. mwaf.weightType = "1";
  754. mwaf.valueFlag = "0";
  755. PbCache.voiceType = 1;
  756. rt = saveMethod.doAddFirst(null, mwaf);
  757. PbCache.monitorResultMessage = string.Format("车号{0},连续保存皮重", PbCache.lockCarNo);
  758. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  759. }
  760. else
  761. {
  762. if (PbCache.ResultMessage == "")
  763. {
  764. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  765. }
  766. rt = saveMethod.doError(PbCache.ResultMessage);
  767. rt.isWarn = true;
  768. PbCache.voiceType = 13;
  769. rt.WarnContent = "validWgt";
  770. return rt;
  771. }
  772. }
  773. else if (firstList.Count == 1 && firstList[0].weightType == "0")
  774. {
  775. RESTfulResult<List<PreTrackScale>> scales = preTrackScaleService.findCarScale(new PreTrackScale { predictionNo = firstList[0].predictionNo });
  776. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  777. {
  778. if (scales.Data != null && scales.Data.Count > 0)
  779. {
  780. //判断称点是否允许期限皮重
  781. if (PbCache.sportInfo.allowedTareWeight == "1")
  782. {
  783. if (AppConfigCache.TareControlType == "3")
  784. {
  785. /// 判断是否具有期限皮重权限
  786. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  787. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  788. meterBaseUnitInfo.matterNo = scales.Data[0].matterNo;
  789. meterBaseUnitInfo.matterName = scales.Data[0].matterName;
  790. meterBaseUnitInfo.forwardingUnitNo = scales.Data[0].forwardingUnitNo;
  791. meterBaseUnitInfo.forwardingUnitName = scales.Data[0].forwardingUnitName;
  792. meterBaseUnitInfo.receivingUnitNo = scales.Data[0].receivingUintNo;
  793. meterBaseUnitInfo.receivingUnitName = scales.Data[0].receivingUintName;
  794. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  795. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  796. if (tareUnitResult.Succeed)
  797. {
  798. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  799. {
  800. //匹配结净
  801. EntityBase<PreTrackScale> entityBase2 = new EntityBase<PreTrackScale>();
  802. mwaf = entityBase2.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  803. mwaf.isPreScale = "1";
  804. mwaf.weightType = "0";
  805. PbCache.voiceType = 1;
  806. rt = saveMethod.doNet(scales.Data[0], firstList[0], mwaf);
  807. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,净重{2}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(rmFirst.Data[0].meterWeight.Value - PbCache.lockWgt) / 1000), 2));
  808. }
  809. else
  810. {
  811. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  812. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0", spotAreaNo = PbCache.sportInfo.spotAreaNo });
  813. if (termTareData.Succeed)
  814. {
  815. // 正常结净
  816. //给一次数据匹配委托
  817. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  818. mwaf = entityBase3.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  819. mwaf.isPreScale = "1";
  820. mwaf.weightType = "1";
  821. PbCache.voiceType = 9;
  822. rt = saveMethod.doTermTareNet(scales.Data[0], firstList[0], mwaf, "1");
  823. rt.resultInfo += ",留存期限皮成功";
  824. PbCache.ResultMessage = "计量成功,留存期限皮成功";
  825. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,净重{2}吨,留存期限皮成功", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(firstList[0].meterWeight.Value - PbCache.lockWgt) / 1000), 2));
  826. }
  827. }
  828. }
  829. }
  830. }
  831. else
  832. {
  833. //匹配结净
  834. EntityBase<PreTrackScale> entityBase2 = new EntityBase<PreTrackScale>();
  835. mwaf = entityBase2.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  836. mwaf.isPreScale = "1";
  837. mwaf.weightType = "0";
  838. PbCache.voiceType = 1;
  839. rt = saveMethod.doNet(scales.Data[0], firstList[0], mwaf);
  840. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,净重{2}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(rmFirst.Data[0].meterWeight.Value - PbCache.lockWgt) / 1000), 2));
  841. }
  842. }
  843. else
  844. {
  845. mwaf.weightType = "0";
  846. PbCache.voiceType = 1;
  847. rt = saveMethod.doNet(null, firstList[0], mwaf);
  848. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,净重{2}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(rmFirst.Data[0].meterWeight.Value - PbCache.lockWgt) / 1000), 2));
  849. }
  850. }
  851. else
  852. {
  853. if (PbCache.ResultMessage == "")
  854. {
  855. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  856. }
  857. PbCache.voiceType = 13;
  858. rt = saveMethod.doError(PbCache.ResultMessage);
  859. rt.isWarn = true;
  860. rt.WarnContent = "validWgt";
  861. return rt;
  862. }
  863. }
  864. // 存在多条有效的一次计量数据
  865. else if (firstList.Count > 1)
  866. {
  867. //mwaf.weightType = "1";
  868. //rt = saveMethod.doAddFirst(null, mwaf);
  869. //PbCache.LEDResultMessage = string.Format("车号{0},重量{1}吨,之前存在多个未结净的毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  870. //rt.resultInfo = "之前存在多个未结净的毛重";
  871. //PbCache.ResultMessage = "之前存在多个未结净的毛重";
  872. //PbCache.monitorResultMessage = "之前存在多个未结净的毛重";
  873. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  874. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  875. {
  876. int countTerm = 0;
  877. List<MeterWorkCarActualFirst> meterWorkCarActualFirsts = new List<MeterWorkCarActualFirst>();
  878. foreach (var item in firstList)
  879. {
  880. RESTfulResult<List<PreTrackScale>> scales = preTrackScaleService.findCarScale(new PreTrackScale { predictionNo = item.predictionNo });
  881. if (scales.Data == null || scales.Data.Count == 0)
  882. {
  883. countTerm++;
  884. }
  885. else
  886. {
  887. if (PbCache.sportInfo.allowedTareWeight == "1")
  888. {
  889. if (AppConfigCache.TareControlType == "3")
  890. {
  891. /// 判断是否具有期限皮重权限
  892. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  893. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  894. meterBaseUnitInfo.matterNo = scales.Data[0].matterNo;
  895. meterBaseUnitInfo.matterName = scales.Data[0].matterName;
  896. meterBaseUnitInfo.forwardingUnitNo = scales.Data[0].forwardingUnitNo;
  897. meterBaseUnitInfo.forwardingUnitName = scales.Data[0].forwardingUnitName;
  898. meterBaseUnitInfo.receivingUnitNo = scales.Data[0].receivingUintNo;
  899. meterBaseUnitInfo.receivingUnitName = scales.Data[0].receivingUintName;
  900. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  901. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  902. if (tareUnitResult.Succeed)
  903. {
  904. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  905. {
  906. countTerm++;
  907. }
  908. else
  909. {
  910. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  911. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0", spotAreaNo = PbCache.sportInfo.spotAreaNo });
  912. if (termTareData.Succeed)
  913. {
  914. meterWorkCarActualFirsts.Add(item);
  915. }
  916. }
  917. }
  918. }
  919. }
  920. else
  921. {
  922. countTerm++;
  923. }
  924. }
  925. }
  926. if (countTerm == 0)
  927. {
  928. rt = saveMethod.doNetAddMuchGross(meterWorkCarActualFirsts,mwaf);
  929. rt.resultInfo = "计量完成,留存期限皮成功";
  930. PbCache.voiceType = 9;
  931. PbCache.ResultMessage = "计量成功,留存期限皮成功";
  932. PbCache.monitorResultMessage = string.Format("计量成功,留存期限皮成功");
  933. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  934. }
  935. else if (countTerm == firstList.Count)
  936. {
  937. RESTfulResult<List<PreTrackScale>> scaleFirst = preTrackScaleService.findCarScale(new PreTrackScale { predictionNo = firstList[0].predictionNo });
  938. if (scaleFirst.Data == null || scaleFirst.Data.Count == 0)
  939. {
  940. mwaf.weightType = "0";
  941. PbCache.voiceType = 1;
  942. rt = saveMethod.doNet(null, firstList[0], mwaf);
  943. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,净重{2}吨,存在未结净毛重", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(firstList[0].meterWeight.Value - PbCache.lockWgt) / 1000), 2));
  944. PbCache.monitorResultMessage = string.Format("车号{0}有{1}条未结净的毛重;", PbCache.lockCarNo, firstList.Count - 1);
  945. }
  946. else
  947. {
  948. //匹配结净
  949. EntityBase<PreTrackScale> entityBase2 = new EntityBase<PreTrackScale>();
  950. mwaf = entityBase2.format<MeterWorkCarActualFirst>(scaleFirst.Data[0], mwaf);
  951. mwaf.isPreScale = "1";
  952. mwaf.weightType = "0";
  953. PbCache.voiceType = 1;
  954. rt = saveMethod.doNet(scaleFirst.Data[0], firstList[0], mwaf);
  955. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,净重{2}吨,存在未结净毛重", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), Math.Round((Math.Abs(firstList[0].meterWeight.Value - PbCache.lockWgt) / 1000), 2));
  956. PbCache.monitorResultMessage = string.Format("车号{0}有{1}条未结净的毛重;", PbCache.lockCarNo, firstList.Count - 1);
  957. }
  958. }
  959. else
  960. {
  961. rt = saveMethod.doNetAddMuchGross(meterWorkCarActualFirsts, mwaf);
  962. PbCache.voiceType = 11;
  963. rt.resultInfo += ",存在未结净毛重";
  964. PbCache.ResultMessage = "计量成功,存在未结净毛重";
  965. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成,存在未结净毛重", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  966. PbCache.monitorResultMessage = string.Format("车号{0}使用期限皮同时结净{1}条毛重数据,还有{2}条未结净的毛重;", PbCache.lockCarNo, firstList.Count - countTerm,countTerm);
  967. }
  968. }
  969. else
  970. {
  971. if (PbCache.ResultMessage == "")
  972. {
  973. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  974. }
  975. PbCache.voiceType = 13;
  976. rt = saveMethod.doError(PbCache.ResultMessage);
  977. rt.isWarn = true;
  978. rt.WarnContent = "validWgt";
  979. return rt;
  980. }
  981. }
  982. }
  983. else
  984. {
  985. rt = saveMethod.doError("选择的委托不存在,请重新选择");
  986. PbCache.LEDResultMessage = "选择的委托不存在,请重新选择";
  987. PbCache.voiceType = 6;
  988. rt.isWarn = true;
  989. rt.WarnContent = "validIsPre";
  990. return rt;
  991. }
  992. }
  993. }
  994. else
  995. {
  996. rt = saveMethod.doError("存在多条已选择的委托,请联系计量大厅");
  997. PbCache.LEDResultMessage = "存在多条已选择的委托,请联系计量大厅";
  998. rt.isWarn = true;
  999. PbCache.voiceType = 19;
  1000. rt.WarnContent = "validIsPre";
  1001. return rt;
  1002. }
  1003. }
  1004. }
  1005. else
  1006. {
  1007. rt = saveMethod.doError("存在多条上称申请数据,请联系计量大厅");
  1008. PbCache.voiceType = 20;
  1009. PbCache.LEDResultMessage = "存在多条上称申请数据,请联系计量大厅";
  1010. return rt;
  1011. }
  1012. }
  1013. // 后台失败处理
  1014. if (!rt.result)
  1015. {
  1016. rt.resultInfo = "称重数据保存失败";
  1017. PbCache.voiceType = 25;
  1018. PbCache.LEDResultMessage = "计量失败,请联系计量大厅";
  1019. PbCache.monitorResultMessage = "";
  1020. }
  1021. return rt;
  1022. }
  1023. }
  1024. }