InnerCarJISCO.cs 79 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  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. // 根据车号查询重量类型预处理表
  74. RESTfulResult<List<MeterWorkPreWgttype>> rmX = wgttypeService.doQueryWf(new MeterWorkPreWgttype { carNo = PbCache.lockCarNo, valueFlag = "1" });
  75. // 不存在未使用的重量类型数据
  76. if (rmX.Succeed)
  77. {
  78. List<MeterWorkPreWgttype> list = rmX.Data;
  79. // 不存在一次预处理数据
  80. if (list == null || list.Count == 0)
  81. {
  82. /* a. 程序报警
  83. * b. 自动进行语音求助
  84. */
  85. rt = saveMethod.doError("未选择称重类型,请选择后开始计量");
  86. PbCache.voiceType = 21;
  87. PbCache.monitorResultMessage = "未选择称重类型,请选择后开始计量";
  88. PbCache.LEDResultMessage = "未选择称重类型,请选择后开始计量";
  89. PbCache.ResultMessage = "未选择称重类型,请选择后开始计量";
  90. return rt;
  91. }
  92. // 存在一条预处理数据
  93. else if (list == null || list.Count == 1)
  94. {
  95. // 历史皮重验证
  96. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  97. if (list[0].weightTypeNo == "001033002" && PbCache.monitorResult.valid_wgt == false && listMonitor.Data[0].validWgt == "1")
  98. {
  99. if (PbCache.ResultMessage == "")
  100. {
  101. PbCache.ResultMessage = "当前皮重不符合历史皮重";
  102. }
  103. PbCache.voiceType = 13;
  104. rt = saveMethod.doError(PbCache.ResultMessage);
  105. rt.isWarn = true;
  106. rt.WarnContent = "validWgt";
  107. return rt;
  108. }
  109. if (list[0].weightTypeNo == "001033001" && PbCache.monitorResult.valid_wgt == true && listMonitor.Data[0].validWgt == "1")
  110. {
  111. if (PbCache.ResultMessage == "")
  112. {
  113. PbCache.ResultMessage = "当前毛重接近历史皮重";
  114. }
  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)
  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" });
  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.validHisTare(list[0].weightTypeNo);
  328. if (PbCache.monitorResult.valid_wgt == true && listMonitor.Data[0].validWgt == "1")
  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" });
  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. RESTfulResult<List<PreTrackScale>> scales = preTrackScaleService.doQueryWf(new PreTrackScale { predictionNo = firstList[0].predictionNo });
  460. //判断称点是否允许期限皮重
  461. if (PbCache.sportInfo.allowedTareWeight == "1")
  462. {
  463. if (AppConfigCache.TareControlType == "3")
  464. {
  465. /// 判断是否具有期限皮重权限
  466. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  467. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  468. meterBaseUnitInfo.matterNo = scales.Data[0].matterNo;
  469. meterBaseUnitInfo.matterName = scales.Data[0].matterName;
  470. meterBaseUnitInfo.forwardingUnitNo = scales.Data[0].forwardingUnitNo;
  471. meterBaseUnitInfo.forwardingUnitName = scales.Data[0].forwardingUnitName;
  472. meterBaseUnitInfo.receivingUnitNo = scales.Data[0].receivingUintNo;
  473. meterBaseUnitInfo.receivingUnitName = scales.Data[0].receivingUintName;
  474. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  475. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  476. if (tareUnitResult.Succeed)
  477. {
  478. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  479. {
  480. mwaf.weightType = "0";
  481. rt = saveMethod.doAddFirst(scales.Data[0], mwaf);
  482. rt.resultInfo = "存在未结净毛重";
  483. PbCache.voiceType = 11;
  484. PbCache.ResultMessage = "存在未结净毛重";
  485. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  486. PbCache.monitorResultMessage = "存在未结净毛重";
  487. rt.isWarn = true;
  488. rt.WarnContent = "validWgt";
  489. }
  490. else
  491. {
  492. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  493. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0" });
  494. if (termTareData.Succeed)
  495. {
  496. if (termTareData.Data == null)
  497. {
  498. mwaf.weightType = "0";
  499. rt = saveMethod.doAddFirst(scales.Data[0], mwaf);
  500. rt.resultInfo = "期限皮过期,存在未结净毛重";
  501. PbCache.voiceType = 17;
  502. PbCache.ResultMessage = "期限皮过期,存在未结净毛重";
  503. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,期限皮过期,存在未结净毛重", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  504. PbCache.monitorResultMessage = "期限皮过期,存在未结净毛重";
  505. rt.isWarn = true;
  506. rt.WarnContent = "validWgt";
  507. }
  508. else
  509. {
  510. // 存在使用期限皮重权限,并使用期限皮重结净
  511. List<string> l = new List<string>();
  512. l.Add("create");
  513. //给一次数据匹配委托
  514. EntityBase<PreTrackScale> entityBase1 = new EntityBase<PreTrackScale>();
  515. mwaf = entityBase1.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  516. mwaf.isPreScale = "1";
  517. mwaf.weightType = "0";
  518. PbCache.voiceType = 16;
  519. PbCache.ResultMessage = "计量完成,期限皮结净";
  520. 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));
  521. rt = saveMethod.doNetTermTare(scales.Data[0], mwaf);
  522. rt.resultInfo += ",期限皮结净";
  523. }
  524. }
  525. }
  526. }
  527. }
  528. }
  529. else
  530. {
  531. mwaf.weightType = "0";
  532. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  533. rt.resultInfo = "存在未结净毛重";
  534. PbCache.voiceType = 11;
  535. PbCache.ResultMessage = "存在未结净毛重";
  536. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  537. PbCache.monitorResultMessage = "存在未结净毛重";
  538. rt.isWarn = true;
  539. rt.WarnContent = "validWgt";
  540. }
  541. }
  542. else
  543. {
  544. if (PbCache.sportInfo.allowedTareWeight == "1")
  545. {
  546. if (AppConfigCache.TareControlType == "3")
  547. {
  548. // 判断是否具有期限皮重权限
  549. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  550. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  551. meterBaseUnitInfo.matterNo = rmScale.Data[0].matterNo;
  552. meterBaseUnitInfo.matterName = rmScale.Data[0].matterName;
  553. meterBaseUnitInfo.forwardingUnitNo = rmScale.Data[0].forwardingUnitNo;
  554. meterBaseUnitInfo.forwardingUnitName = rmScale.Data[0].forwardingUnitName;
  555. meterBaseUnitInfo.receivingUnitNo = rmScale.Data[0].receivingUintNo;
  556. meterBaseUnitInfo.receivingUnitName = rmScale.Data[0].receivingUintName;
  557. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  558. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  559. if (tareUnitResult.Succeed)
  560. {
  561. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  562. {
  563. // 正常结净
  564. //给一次数据匹配委托
  565. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  566. mwaf = entityBase3.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  567. mwaf.isPreScale = "1";
  568. mwaf.weightType = "0";
  569. PbCache.voiceType = 1;
  570. rt = saveMethod.doNet(rmScale.Data[0], firstList[0], mwaf);
  571. 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));
  572. }
  573. else
  574. {
  575. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  576. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0" });
  577. if (termTareData.Succeed)
  578. {
  579. // 正常结净
  580. //给一次数据匹配委托
  581. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  582. mwaf = entityBase3.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  583. mwaf.isPreScale = "1";
  584. mwaf.weightType = "0";
  585. PbCache.voiceType = 9;
  586. rt = saveMethod.doTermTareNet(rmScale.Data[0], mwaf, firstList[0],"0");
  587. rt.resultInfo += ",留存期限皮成功";
  588. PbCache.ResultMessage = "计量成功,留存期限皮成功";
  589. 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));
  590. }
  591. }
  592. }
  593. }
  594. }
  595. else
  596. {
  597. // 正常结净
  598. //给一次数据匹配委托
  599. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  600. mwaf = entityBase3.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  601. mwaf.isPreScale = "1";
  602. mwaf.weightType = "0";
  603. PbCache.voiceType = 1;
  604. rt = saveMethod.doNet(rmScale.Data[0], firstList[0], mwaf);
  605. 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));
  606. }
  607. }
  608. }
  609. // 重量类型为毛重,在皮重误差内
  610. else if (list[0].weightTypeNo == "001033001" && PbCache.monitorResult.valid_wgt == true && listMonitor.Data[0].validWgt == "1")
  611. {
  612. if (PbCache.ResultMessage == "")
  613. {
  614. PbCache.ResultMessage = "毛重接近历史皮重,请联系处理";
  615. }
  616. PbCache.voiceType = 23;
  617. rt = saveMethod.doError(PbCache.ResultMessage);
  618. return rt;
  619. }
  620. }
  621. else
  622. {
  623. rt = saveMethod.doError("第一次计量重量【" + rmFirst.Data[0].meterWeight.Value / 1000 + "T】和第二次计量重量【" + PbCache.lockWgt / 1000 + "T】接近,小于结净最小值【" + diffrentWgt / 1000 + " T】");
  624. rt.isWarn = true;
  625. PbCache.voiceType = 4;
  626. PbCache.LEDResultMessage = "计量失败,小于结净最小值,请联系计量大厅";
  627. rt.WarnContent = "validWgt";
  628. return rt;
  629. }
  630. }
  631. // 存在多条有效的一次计量数据
  632. else if (firstList == null || firstList.Count > 1)
  633. {
  634. // 历史皮重验证
  635. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  636. /* a. 程序报警a
  637. * b. 自动进行语音求助
  638. */
  639. //多条一次记录下判断是否全为毛重,是全部结净
  640. if (firstList[firstList.Count - 1].weightType == "0" && list[0].weightTypeNo == "001033002")
  641. {
  642. if (PbCache.monitorResult.valid_wgt == false && listMonitor.Data[0].validWgt == "1")
  643. {
  644. mwaf.weightType = "1";
  645. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  646. PbCache.voiceType = 1;
  647. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  648. }
  649. else
  650. {
  651. if (PbCache.ResultMessage == "")
  652. {
  653. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  654. }
  655. PbCache.voiceType = 13;
  656. rt = saveMethod.doError(PbCache.ResultMessage);
  657. return rt;
  658. }
  659. }
  660. else if (firstList[firstList.Count - 1].weightType == "0" && list[0].weightTypeNo == "001033001")
  661. {
  662. if (PbCache.monitorResult.valid_wgt == false && listMonitor.Data[0].validWgt == "1")
  663. {
  664. mwaf.weightType = "0";
  665. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  666. PbCache.voiceType = 11;
  667. rt.resultInfo = string.Format("存在未结净毛重", firstList.Count);
  668. PbCache.ResultMessage = string.Format("存在未结净毛重", firstList.Count);
  669. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), firstList.Count);
  670. PbCache.monitorResultMessage = string.Format("存在未结净毛重", firstList.Count);
  671. rt.isWarn = true;
  672. rt.WarnContent = "validWgt";
  673. }
  674. else
  675. {
  676. if (PbCache.ResultMessage == "")
  677. {
  678. PbCache.ResultMessage = "毛重接近历史皮重,请联系处理";
  679. }
  680. PbCache.voiceType = 23;
  681. rt = saveMethod.doError(PbCache.ResultMessage);
  682. return rt;
  683. }
  684. }
  685. else
  686. {
  687. rt = saveMethod.doError("存在多条有效的一次计量数据,请联系计量大厅");
  688. PbCache.voiceType = 8;
  689. PbCache.LEDResultMessage = "存在多条有效的一次计量数据,请联系计量大厅";
  690. return rt;
  691. }
  692. }
  693. else
  694. {
  695. rt = saveMethod.doError("存在多条有效的一次计量数据,请联系计量大厅");
  696. PbCache.voiceType = 8;
  697. PbCache.LEDResultMessage = "存在多条有效的一次计量数据,请联系计量大厅";
  698. return rt;
  699. }
  700. }
  701. }
  702. }
  703. else
  704. {
  705. if (rmScale.Succeed && rmScale.Data.Count == 0)
  706. {
  707. // 查询一次计量数据表
  708. RESTfulResult<List<MeterWorkCarActualFirst>> rmFirst = mwcfs.doQueryByFlag(new MeterWorkCarActualFirst { carNo = PbCache.lockCarNo });
  709. if (rmFirst.Succeed)
  710. {
  711. List<MeterWorkCarActualFirst> firstList = rmFirst.Data;
  712. // 重量类型为皮重
  713. if (list[0].weightTypeNo == "001033002")
  714. {
  715. //if (PbCache.lockWgt > 25000)
  716. //{
  717. // rt = saveMethod.doError(string.Format("当前重量:{0},请确认是否,误选为皮重上秤", PbCache.lockWgt));
  718. // PbCache.voiceType = 26;
  719. // PbCache.LEDResultMessage = string.Format("当前重量:{0},请确认是否,误选为皮重上秤", PbCache.lockWgt);
  720. // return rt;
  721. //}
  722. // 历史皮重验证
  723. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  724. if (firstList == null || firstList.Count == 0)
  725. {
  726. //在皮重误差内
  727. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  728. {
  729. //正常保存一次数据
  730. mwaf.weightType = "1";
  731. PbCache.voiceType = 1;
  732. rt = saveMethod.doAddFirst(null, mwaf);
  733. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  734. }
  735. else
  736. {
  737. if (PbCache.ResultMessage == "")
  738. {
  739. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  740. }
  741. rt = saveMethod.doError(PbCache.ResultMessage);
  742. PbCache.voiceType = 13;
  743. rt.isWarn = true;
  744. rt.WarnContent = "validWgt";
  745. return rt;
  746. }
  747. }
  748. else if (firstList.Count == 1 && firstList[0].weightType != "0")
  749. {
  750. // 在皮重误差内
  751. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  752. {
  753. //保存一条作废的皮重数据
  754. mwaf.weightType = "1";
  755. mwaf.valueFlag = "0";
  756. PbCache.voiceType = 1;
  757. rt = saveMethod.doAddFirst(null, mwaf);
  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.doQueryWf(new PreTrackScale { predictionNo = firstList[0].predictionNo });
  776. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  777. {
  778. //判断称点是否允许期限皮重
  779. if (PbCache.sportInfo.allowedTareWeight == "1")
  780. {
  781. if (AppConfigCache.TareControlType == "3")
  782. {
  783. /// 判断是否具有期限皮重权限
  784. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  785. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  786. meterBaseUnitInfo.matterNo = scales.Data[0].matterNo;
  787. meterBaseUnitInfo.matterName = scales.Data[0].matterName;
  788. meterBaseUnitInfo.forwardingUnitNo = scales.Data[0].forwardingUnitNo;
  789. meterBaseUnitInfo.forwardingUnitName = scales.Data[0].forwardingUnitName;
  790. meterBaseUnitInfo.receivingUnitNo = scales.Data[0].receivingUintNo;
  791. meterBaseUnitInfo.receivingUnitName = scales.Data[0].receivingUintName;
  792. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  793. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  794. if (tareUnitResult.Succeed)
  795. {
  796. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  797. {
  798. //匹配结净
  799. EntityBase<PreTrackScale> entityBase2 = new EntityBase<PreTrackScale>();
  800. mwaf = entityBase2.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  801. mwaf.isPreScale = "1";
  802. mwaf.weightType = "0";
  803. PbCache.voiceType = 1;
  804. rt = saveMethod.doNet(scales.Data[0], firstList[0], mwaf);
  805. 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));
  806. }
  807. else
  808. {
  809. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  810. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0" });
  811. if (termTareData.Succeed)
  812. {
  813. // 正常结净
  814. //给一次数据匹配委托
  815. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  816. mwaf = entityBase3.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  817. mwaf.isPreScale = "1";
  818. mwaf.weightType = "1";
  819. PbCache.voiceType = 9;
  820. rt = saveMethod.doTermTareNet(scales.Data[0], firstList[0], mwaf,"1");
  821. rt.resultInfo += ",留存期限皮成功";
  822. PbCache.ResultMessage = "计量成功,留存期限皮成功";
  823. 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));
  824. }
  825. }
  826. }
  827. }
  828. }
  829. else
  830. {
  831. //匹配结净
  832. EntityBase<PreTrackScale> entityBase2 = new EntityBase<PreTrackScale>();
  833. mwaf = entityBase2.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  834. mwaf.isPreScale = "1";
  835. mwaf.weightType = "0";
  836. PbCache.voiceType = 1;
  837. rt = saveMethod.doNet(scales.Data[0], firstList[0], mwaf);
  838. 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));
  839. }
  840. }
  841. else
  842. {
  843. if (PbCache.ResultMessage == "")
  844. {
  845. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  846. }
  847. PbCache.voiceType = 13;
  848. rt = saveMethod.doError(PbCache.ResultMessage);
  849. rt.isWarn = true;
  850. rt.WarnContent = "validWgt";
  851. return rt;
  852. }
  853. }
  854. // 存在多条有效的一次计量数据
  855. else if (firstList.Count > 1)
  856. {
  857. //mwaf.weightType = "1";
  858. //rt = saveMethod.doAddFirst(null, mwaf);
  859. //PbCache.LEDResultMessage = string.Format("车号{0},重量{1}吨,之前存在多个未结净的毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  860. //rt.resultInfo = "之前存在多个未结净的毛重";
  861. //PbCache.ResultMessage = "之前存在多个未结净的毛重";
  862. //PbCache.monitorResultMessage = "之前存在多个未结净的毛重";
  863. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  864. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  865. {
  866. int countTerm = 0;
  867. List<MeterWorkCarActualFirst> meterWorkCarActualFirsts = new List<MeterWorkCarActualFirst>();
  868. foreach (var item in firstList)
  869. {
  870. RESTfulResult<List<PreTrackScale>> scales = preTrackScaleService.doQueryWf(new PreTrackScale { predictionNo = item.predictionNo });
  871. if (PbCache.sportInfo.allowedTareWeight == "1")
  872. {
  873. if (AppConfigCache.TareControlType == "3")
  874. {
  875. /// 判断是否具有期限皮重权限
  876. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  877. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  878. meterBaseUnitInfo.matterNo = scales.Data[0].matterNo;
  879. meterBaseUnitInfo.matterName = scales.Data[0].matterName;
  880. meterBaseUnitInfo.forwardingUnitNo = scales.Data[0].forwardingUnitNo;
  881. meterBaseUnitInfo.forwardingUnitName = scales.Data[0].forwardingUnitName;
  882. meterBaseUnitInfo.receivingUnitNo = scales.Data[0].receivingUintNo;
  883. meterBaseUnitInfo.receivingUnitName = scales.Data[0].receivingUintName;
  884. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  885. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  886. if (tareUnitResult.Succeed)
  887. {
  888. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  889. {
  890. countTerm++;
  891. }
  892. else
  893. {
  894. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  895. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0" });
  896. if (termTareData.Succeed)
  897. {
  898. meterWorkCarActualFirsts.Add(item);
  899. }
  900. }
  901. }
  902. }
  903. }
  904. else
  905. {
  906. countTerm++;
  907. }
  908. }
  909. if (countTerm == 0)
  910. {
  911. rt = saveMethod.doNetAddMuchGross(meterWorkCarActualFirsts,mwaf);
  912. rt.resultInfo = "计量完成,留存期限皮成功";
  913. PbCache.voiceType = 9;
  914. PbCache.ResultMessage = "计量成功,留存期限皮成功";
  915. PbCache.monitorResultMessage = string.Format("计量成功,留存期限皮成功");
  916. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  917. }
  918. else if (countTerm == firstList.Count)
  919. {
  920. RESTfulResult<List<PreTrackScale>> scales = preTrackScaleService.doQueryWf(new PreTrackScale { predictionNo = firstList[0].predictionNo });
  921. //匹配结净
  922. EntityBase<PreTrackScale> entityBase2 = new EntityBase<PreTrackScale>();
  923. mwaf = entityBase2.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  924. mwaf.isPreScale = "1";
  925. mwaf.weightType = "0";
  926. PbCache.voiceType = 1;
  927. rt = saveMethod.doNet(scales.Data[0], firstList[0], mwaf);
  928. 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));
  929. PbCache.monitorResultMessage = string.Format("车号{0}有{1}条未结净的毛重;", PbCache.lockCarNo,firstList.Count-1);
  930. }
  931. else
  932. {
  933. rt = saveMethod.doNetAddMuchGross(meterWorkCarActualFirsts, mwaf);
  934. PbCache.voiceType = 11;
  935. rt.resultInfo += ",存在未结净毛重";
  936. PbCache.ResultMessage = "计量成功,存在未结净毛重";
  937. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成,存在未结净毛重", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  938. PbCache.monitorResultMessage = string.Format("车号{0}使用期限皮同时结净{1}条毛重数据,还有{2}条未结净的毛重;", PbCache.lockCarNo, firstList.Count - countTerm,countTerm);
  939. }
  940. }
  941. else
  942. {
  943. if (PbCache.ResultMessage == "")
  944. {
  945. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  946. }
  947. PbCache.voiceType = 13;
  948. rt = saveMethod.doError(PbCache.ResultMessage);
  949. rt.isWarn = true;
  950. rt.WarnContent = "validWgt";
  951. return rt;
  952. }
  953. }
  954. }
  955. else
  956. {
  957. rt = saveMethod.doError("委托匹配异常,无法计量,请联系处理");
  958. PbCache.LEDResultMessage = "委托匹配异常,无法计量,请联系处理";
  959. PbCache.voiceType = 6;
  960. rt.isWarn = true;
  961. rt.WarnContent = "validIsPre";
  962. return rt;
  963. }
  964. }
  965. }
  966. else
  967. {
  968. rt = saveMethod.doError("存在多条已选择的委托,请联系计量大厅");
  969. PbCache.LEDResultMessage = "存在多条已选择的委托,请联系计量大厅";
  970. rt.isWarn = true;
  971. PbCache.voiceType = 19;
  972. rt.WarnContent = "validIsPre";
  973. return rt;
  974. }
  975. }
  976. }
  977. else
  978. {
  979. rt = saveMethod.doError("存在多条上称申请数据,请联系计量大厅");
  980. PbCache.voiceType = 20;
  981. PbCache.LEDResultMessage = "存在多条上称申请数据,请联系计量大厅";
  982. return rt;
  983. }
  984. }
  985. // 后台失败处理
  986. if (!rt.result)
  987. {
  988. rt.resultInfo = "称重数据保存失败";
  989. PbCache.voiceType = 25;
  990. PbCache.LEDResultMessage = "计量失败,请联系计量大厅";
  991. PbCache.monitorResultMessage = "";
  992. }
  993. return rt;
  994. }
  995. }
  996. }