InnerCarJISCO.cs 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  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)
  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.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  758. }
  759. else
  760. {
  761. if (PbCache.ResultMessage == "")
  762. {
  763. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  764. }
  765. rt = saveMethod.doError(PbCache.ResultMessage);
  766. rt.isWarn = true;
  767. PbCache.voiceType = 13;
  768. rt.WarnContent = "validWgt";
  769. return rt;
  770. }
  771. }
  772. else if (firstList.Count == 1 && firstList[0].weightType == "0")
  773. {
  774. RESTfulResult<List<PreTrackScale>> scales = preTrackScaleService.findCarScale(new PreTrackScale { predictionNo = firstList[0].predictionNo });
  775. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  776. {
  777. if (scales.Data == null || scales.Data.Count == 0)
  778. {
  779. //判断称点是否允许期限皮重
  780. if (PbCache.sportInfo.allowedTareWeight == "1")
  781. {
  782. if (AppConfigCache.TareControlType == "3")
  783. {
  784. /// 判断是否具有期限皮重权限
  785. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  786. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  787. meterBaseUnitInfo.matterNo = scales.Data[0].matterNo;
  788. meterBaseUnitInfo.matterName = scales.Data[0].matterName;
  789. meterBaseUnitInfo.forwardingUnitNo = scales.Data[0].forwardingUnitNo;
  790. meterBaseUnitInfo.forwardingUnitName = scales.Data[0].forwardingUnitName;
  791. meterBaseUnitInfo.receivingUnitNo = scales.Data[0].receivingUintNo;
  792. meterBaseUnitInfo.receivingUnitName = scales.Data[0].receivingUintName;
  793. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  794. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  795. if (tareUnitResult.Succeed)
  796. {
  797. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  798. {
  799. //匹配结净
  800. EntityBase<PreTrackScale> entityBase2 = new EntityBase<PreTrackScale>();
  801. mwaf = entityBase2.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  802. mwaf.isPreScale = "1";
  803. mwaf.weightType = "0";
  804. PbCache.voiceType = 1;
  805. rt = saveMethod.doNet(scales.Data[0], firstList[0], mwaf);
  806. 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));
  807. }
  808. else
  809. {
  810. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  811. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0", spotAreaNo = PbCache.sportInfo.spotAreaNo });
  812. if (termTareData.Succeed)
  813. {
  814. // 正常结净
  815. //给一次数据匹配委托
  816. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  817. mwaf = entityBase3.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  818. mwaf.isPreScale = "1";
  819. mwaf.weightType = "1";
  820. PbCache.voiceType = 9;
  821. rt = saveMethod.doTermTareNet(scales.Data[0], firstList[0], mwaf, "1");
  822. rt.resultInfo += ",留存期限皮成功";
  823. PbCache.ResultMessage = "计量成功,留存期限皮成功";
  824. 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));
  825. }
  826. }
  827. }
  828. }
  829. }
  830. else
  831. {
  832. //匹配结净
  833. EntityBase<PreTrackScale> entityBase2 = new EntityBase<PreTrackScale>();
  834. mwaf = entityBase2.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  835. mwaf.isPreScale = "1";
  836. mwaf.weightType = "0";
  837. PbCache.voiceType = 1;
  838. rt = saveMethod.doNet(scales.Data[0], firstList[0], mwaf);
  839. 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));
  840. }
  841. }
  842. else
  843. {
  844. mwaf.weightType = "0";
  845. PbCache.voiceType = 1;
  846. rt = saveMethod.doNet(null, firstList[0], mwaf);
  847. 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));
  848. }
  849. }
  850. else
  851. {
  852. if (PbCache.ResultMessage == "")
  853. {
  854. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  855. }
  856. PbCache.voiceType = 13;
  857. rt = saveMethod.doError(PbCache.ResultMessage);
  858. rt.isWarn = true;
  859. rt.WarnContent = "validWgt";
  860. return rt;
  861. }
  862. }
  863. // 存在多条有效的一次计量数据
  864. else if (firstList.Count > 1)
  865. {
  866. //mwaf.weightType = "1";
  867. //rt = saveMethod.doAddFirst(null, mwaf);
  868. //PbCache.LEDResultMessage = string.Format("车号{0},重量{1}吨,之前存在多个未结净的毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  869. //rt.resultInfo = "之前存在多个未结净的毛重";
  870. //PbCache.ResultMessage = "之前存在多个未结净的毛重";
  871. //PbCache.monitorResultMessage = "之前存在多个未结净的毛重";
  872. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  873. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  874. {
  875. int countTerm = 0;
  876. List<MeterWorkCarActualFirst> meterWorkCarActualFirsts = new List<MeterWorkCarActualFirst>();
  877. foreach (var item in firstList)
  878. {
  879. RESTfulResult<List<PreTrackScale>> scales = preTrackScaleService.findCarScale(new PreTrackScale { predictionNo = item.predictionNo });
  880. if (scales.Data == null || scales.Data.Count == 0)
  881. {
  882. countTerm++;
  883. }
  884. else
  885. {
  886. if (PbCache.sportInfo.allowedTareWeight == "1")
  887. {
  888. if (AppConfigCache.TareControlType == "3")
  889. {
  890. /// 判断是否具有期限皮重权限
  891. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  892. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  893. meterBaseUnitInfo.matterNo = scales.Data[0].matterNo;
  894. meterBaseUnitInfo.matterName = scales.Data[0].matterName;
  895. meterBaseUnitInfo.forwardingUnitNo = scales.Data[0].forwardingUnitNo;
  896. meterBaseUnitInfo.forwardingUnitName = scales.Data[0].forwardingUnitName;
  897. meterBaseUnitInfo.receivingUnitNo = scales.Data[0].receivingUintNo;
  898. meterBaseUnitInfo.receivingUnitName = scales.Data[0].receivingUintName;
  899. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  900. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  901. if (tareUnitResult.Succeed)
  902. {
  903. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  904. {
  905. countTerm++;
  906. }
  907. else
  908. {
  909. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  910. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0", spotAreaNo = PbCache.sportInfo.spotAreaNo });
  911. if (termTareData.Succeed)
  912. {
  913. meterWorkCarActualFirsts.Add(item);
  914. }
  915. }
  916. }
  917. }
  918. }
  919. else
  920. {
  921. countTerm++;
  922. }
  923. }
  924. }
  925. if (countTerm == 0)
  926. {
  927. rt = saveMethod.doNetAddMuchGross(meterWorkCarActualFirsts,mwaf);
  928. rt.resultInfo = "计量完成,留存期限皮成功";
  929. PbCache.voiceType = 9;
  930. PbCache.ResultMessage = "计量成功,留存期限皮成功";
  931. PbCache.monitorResultMessage = string.Format("计量成功,留存期限皮成功");
  932. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  933. }
  934. else if (countTerm == firstList.Count)
  935. {
  936. RESTfulResult<List<PreTrackScale>> scales = preTrackScaleService.findCarScale(new PreTrackScale { predictionNo = firstList[0].predictionNo });
  937. if (scales.Data == null || scales.Data.Count == 0)
  938. {
  939. mwaf.weightType = "0";
  940. PbCache.voiceType = 1;
  941. rt = saveMethod.doNet(null, firstList[0], mwaf);
  942. 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));
  943. PbCache.monitorResultMessage = string.Format("车号{0}有{1}条未结净的毛重;", PbCache.lockCarNo, firstList.Count - 1);
  944. }
  945. else
  946. {
  947. //匹配结净
  948. EntityBase<PreTrackScale> entityBase2 = new EntityBase<PreTrackScale>();
  949. mwaf = entityBase2.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  950. mwaf.isPreScale = "1";
  951. mwaf.weightType = "0";
  952. PbCache.voiceType = 1;
  953. rt = saveMethod.doNet(scales.Data[0], firstList[0], mwaf);
  954. 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));
  955. PbCache.monitorResultMessage = string.Format("车号{0}有{1}条未结净的毛重;", PbCache.lockCarNo, firstList.Count - 1);
  956. }
  957. }
  958. else
  959. {
  960. rt = saveMethod.doNetAddMuchGross(meterWorkCarActualFirsts, mwaf);
  961. PbCache.voiceType = 11;
  962. rt.resultInfo += ",存在未结净毛重";
  963. PbCache.ResultMessage = "计量成功,存在未结净毛重";
  964. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成,存在未结净毛重", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  965. PbCache.monitorResultMessage = string.Format("车号{0}使用期限皮同时结净{1}条毛重数据,还有{2}条未结净的毛重;", PbCache.lockCarNo, firstList.Count - countTerm,countTerm);
  966. }
  967. }
  968. else
  969. {
  970. if (PbCache.ResultMessage == "")
  971. {
  972. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  973. }
  974. PbCache.voiceType = 13;
  975. rt = saveMethod.doError(PbCache.ResultMessage);
  976. rt.isWarn = true;
  977. rt.WarnContent = "validWgt";
  978. return rt;
  979. }
  980. }
  981. }
  982. else
  983. {
  984. rt = saveMethod.doError("选择的委托不存在,请重新选择");
  985. PbCache.LEDResultMessage = "选择的委托不存在,请重新选择";
  986. PbCache.voiceType = 6;
  987. rt.isWarn = true;
  988. rt.WarnContent = "validIsPre";
  989. return rt;
  990. }
  991. }
  992. }
  993. else
  994. {
  995. rt = saveMethod.doError("存在多条已选择的委托,请联系计量大厅");
  996. PbCache.LEDResultMessage = "存在多条已选择的委托,请联系计量大厅";
  997. rt.isWarn = true;
  998. PbCache.voiceType = 19;
  999. rt.WarnContent = "validIsPre";
  1000. return rt;
  1001. }
  1002. }
  1003. }
  1004. else
  1005. {
  1006. rt = saveMethod.doError("存在多条上称申请数据,请联系计量大厅");
  1007. PbCache.voiceType = 20;
  1008. PbCache.LEDResultMessage = "存在多条上称申请数据,请联系计量大厅";
  1009. return rt;
  1010. }
  1011. }
  1012. // 后台失败处理
  1013. if (!rt.result)
  1014. {
  1015. rt.resultInfo = "称重数据保存失败";
  1016. PbCache.voiceType = 25;
  1017. PbCache.LEDResultMessage = "计量失败,请联系计量大厅";
  1018. PbCache.monitorResultMessage = "";
  1019. }
  1020. return rt;
  1021. }
  1022. }
  1023. }