InnerCarJISCO.cs 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  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. // 读结净最小值配置
  310. ComBaseInfoService cbis = new ComBaseInfoService();
  311. RESTfulResult<List<ComBaseInfo>> res = cbis.doQueryBaseList(new ComBaseInfo { baseCode = "001031001" });
  312. if (res.Succeed)
  313. {
  314. if (res.Data != null && res.Data.Count == 1)
  315. {
  316. try
  317. {
  318. diffrentWgt = Double.Parse(res.Data[0].baseName);
  319. }
  320. finally
  321. {
  322. }
  323. }
  324. }
  325. //*/
  326. if (firstList[0].weightType == "0" && list[0].weightTypeNo == "001033001")
  327. {
  328. // 历史皮重验证
  329. rt = saveMethod.validHisTare2(list[0].weightTypeNo);
  330. if (PbCache.monitorResult.valid_wgt == false || listMonitor.Data[0].validWgt == "0")
  331. {
  332. //判断称点是否允许期限皮重
  333. if (PbCache.sportInfo.allowedTareWeight == "1")
  334. {
  335. if (AppConfigCache.TareControlType == "3")
  336. {
  337. // 判断收发货单位是否具有期限皮重权限
  338. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  339. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  340. meterBaseUnitInfo.matterNo = rmScale.Data[0].matterNo;
  341. meterBaseUnitInfo.matterName = rmScale.Data[0].matterName;
  342. meterBaseUnitInfo.forwardingUnitNo = rmScale.Data[0].forwardingUnitNo;
  343. meterBaseUnitInfo.forwardingUnitName = rmScale.Data[0].forwardingUnitName;
  344. meterBaseUnitInfo.receivingUnitNo = rmScale.Data[0].receivingUintNo;
  345. meterBaseUnitInfo.receivingUnitName = rmScale.Data[0].receivingUintName;
  346. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  347. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  348. if (tareUnitResult.Succeed)
  349. {
  350. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  351. {
  352. mwaf.weightType = "0";
  353. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  354. rt.resultInfo = "存在未结净毛重";
  355. PbCache.voiceType = 11;
  356. PbCache.ResultMessage = "存在未结净毛重";
  357. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  358. PbCache.monitorResultMessage = "存在未结净毛重";
  359. rt.isWarn = true;
  360. rt.WarnContent = "validWgt";
  361. }
  362. else
  363. {
  364. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  365. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0" , spotAreaNo = PbCache.sportInfo.spotAreaNo });
  366. if (termTareData.Succeed)
  367. {
  368. if (termTareData.Data == null)
  369. {
  370. mwaf.weightType = "0";
  371. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  372. rt.resultInfo = "期限皮过期,存在未结净毛重";
  373. PbCache.voiceType = 17;
  374. PbCache.ResultMessage = "期限皮过期,存在未结净毛重";
  375. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,期限皮过期,存在未结净毛重", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  376. PbCache.monitorResultMessage = "期限皮过期,存在未结净毛重";
  377. rt.isWarn = true;
  378. rt.WarnContent = "validWgt";
  379. }
  380. else
  381. {
  382. // 存在使用期限皮重权限,并使用期限皮重结净
  383. List<string> l = new List<string>();
  384. l.Add("create");
  385. //给一次数据匹配委托
  386. EntityBase<PreTrackScale> entityBase1 = new EntityBase<PreTrackScale>();
  387. mwaf = entityBase1.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  388. mwaf.isPreScale = "1";
  389. mwaf.weightType = "0";
  390. PbCache.voiceType = 16;
  391. PbCache.ResultMessage = "计量完成,期限皮结净";
  392. 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));
  393. rt = saveMethod.doNetTermTare(rmScale.Data[0], mwaf);
  394. rt.resultInfo += ",期限皮结净";
  395. }
  396. }
  397. }
  398. }
  399. }
  400. }
  401. else
  402. {
  403. mwaf.weightType = "0";
  404. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  405. rt.resultInfo = "存在未结净毛重";
  406. PbCache.voiceType = 11;
  407. PbCache.ResultMessage = "存在未结净毛重";
  408. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  409. PbCache.monitorResultMessage = "存在未结净毛重";
  410. rt.isWarn = true;
  411. rt.WarnContent = "validWgt";
  412. }
  413. return rt;
  414. }
  415. else
  416. {
  417. if (PbCache.ResultMessage == "")
  418. {
  419. PbCache.ResultMessage = "重量类型为毛重,在皮重误差内";
  420. }
  421. PbCache.voiceType = 23;
  422. rt = saveMethod.doError(PbCache.ResultMessage);
  423. rt.isWarn = true;
  424. rt.WarnContent = "validWgt";
  425. return rt;
  426. }
  427. }
  428. // 当次重量和上次重量满足结净最小值条件
  429. if (Math.Abs(rmFirst.Data[0].meterWeight.Value - PbCache.lockWgt) > diffrentWgt || listMonitor.Data[0].validPredictionDiff == "0")
  430. {
  431. // 历史皮重验证
  432. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  433. // 重量类型为皮重且在皮重误差内,正常结净
  434. if (list[0].weightTypeNo == "001033002" && (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0"))
  435. {
  436. // 正常结净
  437. //给一次数据匹配委托
  438. EntityBase<PreTrackScale> entityBase1 = new EntityBase<PreTrackScale>();
  439. mwaf = entityBase1.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  440. mwaf.isPreScale = "1";
  441. rt = saveMethod.doNet(rmScale.Data[0], firstList[0], mwaf);
  442. PbCache.voiceType = 13;
  443. 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));
  444. }
  445. // 重量类型为皮重且不在皮重误差内
  446. else if (list[0].weightTypeNo == "001033002" && PbCache.monitorResult.valid_wgt == false && listMonitor.Data[0].validWgt == "1")
  447. {
  448. if (PbCache.ResultMessage == "")
  449. {
  450. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  451. }
  452. PbCache.voiceType = 13;
  453. rt = saveMethod.doError(PbCache.ResultMessage);
  454. return rt;
  455. }
  456. // 重量类型为毛重,不在皮重误差内,正常结净
  457. else if (list[0].weightTypeNo == "001033001" && (PbCache.monitorResult.valid_wgt == false || listMonitor.Data[0].validWgt == "0"))
  458. {
  459. if (firstList[0].weightType == "0")
  460. {
  461. //判断称点是否允许期限皮重
  462. if (PbCache.sportInfo.allowedTareWeight == "1")
  463. {
  464. if (AppConfigCache.TareControlType == "3")
  465. {
  466. /// 判断是否具有期限皮重权限
  467. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  468. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  469. meterBaseUnitInfo.matterNo = rmScale.Data[0].matterNo;
  470. meterBaseUnitInfo.matterName = rmScale.Data[0].matterName;
  471. meterBaseUnitInfo.forwardingUnitNo = rmScale.Data[0].forwardingUnitNo;
  472. meterBaseUnitInfo.forwardingUnitName = rmScale.Data[0].forwardingUnitName;
  473. meterBaseUnitInfo.receivingUnitNo = rmScale.Data[0].receivingUintNo;
  474. meterBaseUnitInfo.receivingUnitName = rmScale.Data[0].receivingUintName;
  475. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  476. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  477. if (tareUnitResult.Succeed)
  478. {
  479. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  480. {
  481. mwaf.weightType = "0";
  482. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  483. rt.resultInfo = "存在未结净毛重";
  484. PbCache.voiceType = 11;
  485. PbCache.ResultMessage = "存在未结净毛重";
  486. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  487. PbCache.monitorResultMessage = "存在未结净毛重";
  488. rt.isWarn = true;
  489. rt.WarnContent = "validWgt";
  490. }
  491. else
  492. {
  493. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  494. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0", spotAreaNo = PbCache.sportInfo.spotAreaNo });
  495. if (termTareData.Succeed)
  496. {
  497. if (termTareData.Data == null)
  498. {
  499. mwaf.weightType = "0";
  500. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  501. rt.resultInfo = "期限皮过期,存在未结净毛重";
  502. PbCache.voiceType = 17;
  503. PbCache.ResultMessage = "期限皮过期,存在未结净毛重";
  504. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,期限皮过期,存在未结净毛重", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  505. PbCache.monitorResultMessage = "期限皮过期,存在未结净毛重";
  506. rt.isWarn = true;
  507. rt.WarnContent = "validWgt";
  508. }
  509. else
  510. {
  511. // 存在使用期限皮重权限,并使用期限皮重结净
  512. List<string> l = new List<string>();
  513. l.Add("create");
  514. //给一次数据匹配委托
  515. EntityBase<PreTrackScale> entityBase1 = new EntityBase<PreTrackScale>();
  516. mwaf = entityBase1.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  517. mwaf.isPreScale = "1";
  518. mwaf.weightType = "0";
  519. PbCache.voiceType = 16;
  520. PbCache.ResultMessage = "计量完成,期限皮结净";
  521. 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));
  522. rt = saveMethod.doNetTermTare(rmScale.Data[0], mwaf);
  523. rt.resultInfo += ",期限皮结净";
  524. }
  525. }
  526. }
  527. }
  528. }
  529. }
  530. else
  531. {
  532. mwaf.weightType = "0";
  533. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  534. rt.resultInfo = "存在未结净毛重";
  535. PbCache.voiceType = 11;
  536. PbCache.ResultMessage = "存在未结净毛重";
  537. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  538. PbCache.monitorResultMessage = "存在未结净毛重";
  539. rt.isWarn = true;
  540. rt.WarnContent = "validWgt";
  541. }
  542. }
  543. else
  544. {
  545. if (PbCache.sportInfo.allowedTareWeight == "1")
  546. {
  547. if (AppConfigCache.TareControlType == "3")
  548. {
  549. // 判断是否具有期限皮重权限
  550. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  551. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  552. meterBaseUnitInfo.matterNo = rmScale.Data[0].matterNo;
  553. meterBaseUnitInfo.matterName = rmScale.Data[0].matterName;
  554. meterBaseUnitInfo.forwardingUnitNo = rmScale.Data[0].forwardingUnitNo;
  555. meterBaseUnitInfo.forwardingUnitName = rmScale.Data[0].forwardingUnitName;
  556. meterBaseUnitInfo.receivingUnitNo = rmScale.Data[0].receivingUintNo;
  557. meterBaseUnitInfo.receivingUnitName = rmScale.Data[0].receivingUintName;
  558. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  559. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  560. if (tareUnitResult.Succeed)
  561. {
  562. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  563. {
  564. // 正常结净
  565. //给一次数据匹配委托
  566. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  567. mwaf = entityBase3.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  568. mwaf.isPreScale = "1";
  569. mwaf.weightType = "0";
  570. PbCache.voiceType = 1;
  571. rt = saveMethod.doNet(rmScale.Data[0], firstList[0], mwaf);
  572. 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));
  573. }
  574. else
  575. {
  576. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  577. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0", spotAreaNo = PbCache.sportInfo.spotAreaNo });
  578. if (termTareData.Succeed)
  579. {
  580. // 正常结净
  581. //给一次数据匹配委托
  582. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  583. mwaf = entityBase3.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  584. mwaf.isPreScale = "1";
  585. mwaf.weightType = "0";
  586. PbCache.voiceType = 9;
  587. rt = saveMethod.doTermTareNet(rmScale.Data[0], mwaf, firstList[0],"0");
  588. rt.resultInfo += ",留存期限皮成功";
  589. PbCache.ResultMessage = "计量成功,留存期限皮成功";
  590. 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));
  591. }
  592. }
  593. }
  594. }
  595. }
  596. else
  597. {
  598. // 正常结净
  599. //给一次数据匹配委托
  600. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  601. mwaf = entityBase3.format<MeterWorkCarActualFirst>(rmScale.Data[0], mwaf);
  602. mwaf.isPreScale = "1";
  603. mwaf.weightType = "0";
  604. PbCache.voiceType = 1;
  605. rt = saveMethod.doNet(rmScale.Data[0], firstList[0], mwaf);
  606. 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));
  607. }
  608. }
  609. }
  610. // 重量类型为毛重,在皮重误差内
  611. else if (list[0].weightTypeNo == "001033001" && PbCache.monitorResult.valid_wgt == true && listMonitor.Data[0].validWgt == "1")
  612. {
  613. if (PbCache.ResultMessage == "")
  614. {
  615. PbCache.ResultMessage = "毛重接近历史皮重,请联系处理";
  616. }
  617. PbCache.voiceType = 23;
  618. rt = saveMethod.doError(PbCache.ResultMessage);
  619. return rt;
  620. }
  621. }
  622. else
  623. {
  624. rt = saveMethod.doError("第一次计量重量【" + rmFirst.Data[0].meterWeight.Value / 1000 + "T】和第二次计量重量【" + PbCache.lockWgt / 1000 + "T】接近,小于结净最小值【" + diffrentWgt / 1000 + " T】");
  625. rt.isWarn = true;
  626. PbCache.voiceType = 4;
  627. PbCache.LEDResultMessage = "计量失败,小于结净最小值,请联系计量大厅";
  628. rt.WarnContent = "validWgt";
  629. return rt;
  630. }
  631. }
  632. // 存在多条有效的一次计量数据
  633. else if (firstList == null || firstList.Count > 1)
  634. {
  635. // 历史皮重验证
  636. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  637. /* a. 程序报警a
  638. * b. 自动进行语音求助
  639. */
  640. //多条一次记录下判断是否全为毛重,是全部结净
  641. if (firstList[firstList.Count - 1].weightType == "0" && list[0].weightTypeNo == "001033002")
  642. {
  643. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  644. {
  645. mwaf.weightType = "1";
  646. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  647. PbCache.voiceType = 1;
  648. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  649. }
  650. else
  651. {
  652. if (PbCache.ResultMessage == "")
  653. {
  654. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  655. }
  656. PbCache.voiceType = 13;
  657. rt = saveMethod.doError(PbCache.ResultMessage);
  658. return rt;
  659. }
  660. }
  661. else if (firstList[firstList.Count - 1].weightType == "0" && list[0].weightTypeNo == "001033001")
  662. {
  663. if (PbCache.monitorResult.valid_wgt == false || listMonitor.Data[0].validWgt == "0")
  664. {
  665. mwaf.weightType = "0";
  666. rt = saveMethod.doAddFirst(rmScale.Data[0], mwaf);
  667. PbCache.voiceType = 11;
  668. rt.resultInfo = string.Format("存在未结净毛重", firstList.Count);
  669. PbCache.ResultMessage = string.Format("存在未结净毛重", firstList.Count);
  670. PbCache.LEDResultMessage = string.Format("车号{0},毛重{1}吨,存在未结净毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2), firstList.Count);
  671. PbCache.monitorResultMessage = string.Format("存在未结净毛重", firstList.Count);
  672. rt.isWarn = true;
  673. rt.WarnContent = "validWgt";
  674. }
  675. else
  676. {
  677. if (PbCache.ResultMessage == "")
  678. {
  679. PbCache.ResultMessage = "毛重接近历史皮重,请联系处理";
  680. }
  681. PbCache.voiceType = 23;
  682. rt = saveMethod.doError(PbCache.ResultMessage);
  683. return rt;
  684. }
  685. }
  686. else
  687. {
  688. rt = saveMethod.doError("存在多条有效的一次计量数据,请联系计量大厅");
  689. PbCache.voiceType = 8;
  690. PbCache.LEDResultMessage = "存在多条有效的一次计量数据,请联系计量大厅";
  691. return rt;
  692. }
  693. }
  694. else
  695. {
  696. rt = saveMethod.doError("存在多条有效的一次计量数据,请联系计量大厅");
  697. PbCache.voiceType = 8;
  698. PbCache.LEDResultMessage = "存在多条有效的一次计量数据,请联系计量大厅";
  699. return rt;
  700. }
  701. }
  702. }
  703. }
  704. else
  705. {
  706. if (rmScale.Succeed && rmScale.Data.Count == 0)
  707. {
  708. // 查询一次计量数据表
  709. RESTfulResult<List<MeterWorkCarActualFirst>> rmFirst = mwcfs.doQueryByFlag(new MeterWorkCarActualFirst { carNo = PbCache.lockCarNo });
  710. if (rmFirst.Succeed)
  711. {
  712. List<MeterWorkCarActualFirst> firstList = rmFirst.Data;
  713. // 重量类型为皮重
  714. if (list[0].weightTypeNo == "001033002")
  715. {
  716. //if (PbCache.lockWgt > 25000)
  717. //{
  718. // rt = saveMethod.doError(string.Format("当前重量:{0},请确认是否,误选为皮重上秤", PbCache.lockWgt));
  719. // PbCache.voiceType = 26;
  720. // PbCache.LEDResultMessage = string.Format("当前重量:{0},请确认是否,误选为皮重上秤", PbCache.lockWgt);
  721. // return rt;
  722. //}
  723. // 历史皮重验证
  724. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  725. if (firstList == null || firstList.Count == 0)
  726. {
  727. //在皮重误差内
  728. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  729. {
  730. //正常保存一次数据
  731. mwaf.weightType = "1";
  732. PbCache.voiceType = 1;
  733. rt = saveMethod.doAddFirst(null, mwaf);
  734. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  735. }
  736. else
  737. {
  738. if (PbCache.ResultMessage == "")
  739. {
  740. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  741. }
  742. rt = saveMethod.doError(PbCache.ResultMessage);
  743. PbCache.voiceType = 13;
  744. rt.isWarn = true;
  745. rt.WarnContent = "validWgt";
  746. return rt;
  747. }
  748. }
  749. else if (firstList.Count == 1 && firstList[0].weightType != "0")
  750. {
  751. // 在皮重误差内
  752. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  753. {
  754. //保存一条作废的皮重数据
  755. mwaf.weightType = "1";
  756. mwaf.valueFlag = "0";
  757. PbCache.voiceType = 1;
  758. rt = saveMethod.doAddFirst(null, mwaf);
  759. PbCache.monitorResultMessage = string.Format("车号{0},连续保存皮重", PbCache.lockCarNo);
  760. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  761. }
  762. else
  763. {
  764. if (PbCache.ResultMessage == "")
  765. {
  766. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  767. }
  768. rt = saveMethod.doError(PbCache.ResultMessage);
  769. rt.isWarn = true;
  770. PbCache.voiceType = 13;
  771. rt.WarnContent = "validWgt";
  772. return rt;
  773. }
  774. }
  775. else if (firstList.Count == 1 && firstList[0].weightType == "0")
  776. {
  777. RESTfulResult<List<PreTrackScale>> scales = preTrackScaleService.findCarScale(new PreTrackScale { predictionNo = firstList[0].predictionNo });
  778. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  779. {
  780. if (scales.Data != null && scales.Data.Count > 0)
  781. {
  782. //判断称点是否允许期限皮重
  783. if (PbCache.sportInfo.allowedTareWeight == "1")
  784. {
  785. if (AppConfigCache.TareControlType == "3")
  786. {
  787. /// 判断是否具有期限皮重权限
  788. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  789. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  790. meterBaseUnitInfo.matterNo = scales.Data[0].matterNo;
  791. meterBaseUnitInfo.matterName = scales.Data[0].matterName;
  792. meterBaseUnitInfo.forwardingUnitNo = scales.Data[0].forwardingUnitNo;
  793. meterBaseUnitInfo.forwardingUnitName = scales.Data[0].forwardingUnitName;
  794. meterBaseUnitInfo.receivingUnitNo = scales.Data[0].receivingUintNo;
  795. meterBaseUnitInfo.receivingUnitName = scales.Data[0].receivingUintName;
  796. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  797. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  798. if (tareUnitResult.Succeed)
  799. {
  800. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  801. {
  802. //匹配结净
  803. EntityBase<PreTrackScale> entityBase2 = new EntityBase<PreTrackScale>();
  804. mwaf = entityBase2.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  805. mwaf.isPreScale = "1";
  806. mwaf.weightType = "0";
  807. PbCache.voiceType = 1;
  808. rt = saveMethod.doNet(scales.Data[0], firstList[0], mwaf);
  809. 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));
  810. }
  811. else
  812. {
  813. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  814. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0", spotAreaNo = PbCache.sportInfo.spotAreaNo });
  815. if (termTareData.Succeed)
  816. {
  817. // 正常结净
  818. //给一次数据匹配委托
  819. EntityBase<PreTrackScale> entityBase3 = new EntityBase<PreTrackScale>();
  820. mwaf = entityBase3.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  821. mwaf.isPreScale = "1";
  822. mwaf.weightType = "1";
  823. PbCache.voiceType = 9;
  824. rt = saveMethod.doTermTareNet(scales.Data[0], firstList[0], mwaf, "1");
  825. rt.resultInfo += ",留存期限皮成功";
  826. PbCache.ResultMessage = "计量成功,留存期限皮成功";
  827. 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));
  828. }
  829. }
  830. }
  831. }
  832. }
  833. else
  834. {
  835. //匹配结净
  836. EntityBase<PreTrackScale> entityBase2 = new EntityBase<PreTrackScale>();
  837. mwaf = entityBase2.format<MeterWorkCarActualFirst>(scales.Data[0], mwaf);
  838. mwaf.isPreScale = "1";
  839. mwaf.weightType = "0";
  840. PbCache.voiceType = 1;
  841. rt = saveMethod.doNet(scales.Data[0], firstList[0], mwaf);
  842. 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));
  843. }
  844. }
  845. else
  846. {
  847. mwaf.weightType = "0";
  848. PbCache.voiceType = 1;
  849. rt = saveMethod.doNet(null, firstList[0], mwaf);
  850. 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));
  851. }
  852. }
  853. else
  854. {
  855. if (PbCache.ResultMessage == "")
  856. {
  857. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  858. }
  859. PbCache.voiceType = 13;
  860. rt = saveMethod.doError(PbCache.ResultMessage);
  861. rt.isWarn = true;
  862. rt.WarnContent = "validWgt";
  863. return rt;
  864. }
  865. }
  866. // 存在多条有效的一次计量数据
  867. else if (firstList.Count > 1)
  868. {
  869. //mwaf.weightType = "1";
  870. //rt = saveMethod.doAddFirst(null, mwaf);
  871. //PbCache.LEDResultMessage = string.Format("车号{0},重量{1}吨,之前存在多个未结净的毛重,请联系", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  872. //rt.resultInfo = "之前存在多个未结净的毛重";
  873. //PbCache.ResultMessage = "之前存在多个未结净的毛重";
  874. //PbCache.monitorResultMessage = "之前存在多个未结净的毛重";
  875. rt = saveMethod.validHisTare(list[0].weightTypeNo);
  876. if (PbCache.monitorResult.valid_wgt == true || listMonitor.Data[0].validWgt == "0")
  877. {
  878. int countTerm = 0;
  879. List<MeterWorkCarActualFirst> meterWorkCarActualFirsts = new List<MeterWorkCarActualFirst>();
  880. foreach (var item in firstList)
  881. {
  882. RESTfulResult<List<PreTrackScale>> scales = preTrackScaleService.findCarScale(new PreTrackScale { predictionNo = item.predictionNo });
  883. if (scales.Data == null || scales.Data.Count == 0)
  884. {
  885. countTerm++;
  886. }
  887. else
  888. {
  889. if (PbCache.sportInfo.allowedTareWeight == "1")
  890. {
  891. if (AppConfigCache.TareControlType == "3")
  892. {
  893. /// 判断是否具有期限皮重权限
  894. MeterBaseUnitInfoService meterBaseUnitInfoService = new MeterBaseUnitInfoService();
  895. MeterBaseUnitInfo meterBaseUnitInfo = new MeterBaseUnitInfo();
  896. meterBaseUnitInfo.matterNo = scales.Data[0].matterNo;
  897. meterBaseUnitInfo.matterName = scales.Data[0].matterName;
  898. meterBaseUnitInfo.forwardingUnitNo = scales.Data[0].forwardingUnitNo;
  899. meterBaseUnitInfo.forwardingUnitName = scales.Data[0].forwardingUnitName;
  900. meterBaseUnitInfo.receivingUnitNo = scales.Data[0].receivingUintNo;
  901. meterBaseUnitInfo.receivingUnitName = scales.Data[0].receivingUintName;
  902. meterBaseUnitInfo.carNo = PbCache.lockCarNo;
  903. RESTfulResult<List<MeterBaseUnitInfo>> tareUnitResult = meterBaseUnitInfoService.doQueryWf(meterBaseUnitInfo);
  904. if (tareUnitResult.Succeed)
  905. {
  906. if (tareUnitResult.Data == null || tareUnitResult.Data.Count == 0)
  907. {
  908. countTerm++;
  909. }
  910. else
  911. {
  912. MeterBaseTermTareDataService meterBaseTermTareDataService = new MeterBaseTermTareDataService();
  913. RESTfulResult<MeterBaseTermTareData> termTareData = meterBaseTermTareDataService.doQueryPageWf(new MeterBaseTermTareData { carNo = PbCache.lockCarNo, valueFlag = "0", spotAreaNo = PbCache.sportInfo.spotAreaNo });
  914. if (termTareData.Succeed)
  915. {
  916. meterWorkCarActualFirsts.Add(item);
  917. }
  918. }
  919. }
  920. }
  921. }
  922. else
  923. {
  924. countTerm++;
  925. }
  926. }
  927. }
  928. if (countTerm == 0)
  929. {
  930. rt = saveMethod.doNetAddMuchGross(meterWorkCarActualFirsts,mwaf);
  931. rt.resultInfo = "计量完成,留存期限皮成功";
  932. PbCache.voiceType = 9;
  933. PbCache.ResultMessage = "计量成功,留存期限皮成功";
  934. PbCache.monitorResultMessage = string.Format("计量成功,留存期限皮成功");
  935. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  936. }
  937. else if (countTerm == firstList.Count)
  938. {
  939. RESTfulResult<List<PreTrackScale>> scaleFirst = preTrackScaleService.findCarScale(new PreTrackScale { predictionNo = firstList[0].predictionNo });
  940. if (scaleFirst.Data == null || scaleFirst.Data.Count == 0)
  941. {
  942. mwaf.weightType = "0";
  943. PbCache.voiceType = 1;
  944. rt = saveMethod.doNet(null, firstList[0], mwaf);
  945. 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));
  946. PbCache.monitorResultMessage = string.Format("车号{0}有{1}条未结净的毛重;", PbCache.lockCarNo, firstList.Count - 1);
  947. }
  948. else
  949. {
  950. //匹配结净
  951. EntityBase<PreTrackScale> entityBase2 = new EntityBase<PreTrackScale>();
  952. mwaf = entityBase2.format<MeterWorkCarActualFirst>(scaleFirst.Data[0], mwaf);
  953. mwaf.isPreScale = "1";
  954. mwaf.weightType = "0";
  955. PbCache.voiceType = 1;
  956. rt = saveMethod.doNet(scaleFirst.Data[0], firstList[0], mwaf);
  957. 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));
  958. PbCache.monitorResultMessage = string.Format("车号{0}有{1}条未结净的毛重;", PbCache.lockCarNo, firstList.Count - 1);
  959. }
  960. }
  961. else
  962. {
  963. rt = saveMethod.doNetAddMuchGross(meterWorkCarActualFirsts, mwaf);
  964. PbCache.voiceType = 11;
  965. rt.resultInfo += ",存在未结净毛重";
  966. PbCache.ResultMessage = "计量成功,存在未结净毛重";
  967. PbCache.LEDResultMessage = string.Format("车号{0},皮重{1}吨,计量完成,存在未结净毛重", PbCache.lockCarNo, Math.Round((PbCache.lockWgt / 1000), 2));
  968. PbCache.monitorResultMessage = string.Format("车号{0}使用期限皮同时结净{1}条毛重数据,还有{2}条未结净的毛重;", PbCache.lockCarNo, firstList.Count - countTerm,countTerm);
  969. }
  970. }
  971. else
  972. {
  973. if (PbCache.ResultMessage == "")
  974. {
  975. PbCache.ResultMessage = "重量类型为皮重且不在皮重误差内";
  976. }
  977. PbCache.voiceType = 13;
  978. rt = saveMethod.doError(PbCache.ResultMessage);
  979. rt.isWarn = true;
  980. rt.WarnContent = "validWgt";
  981. return rt;
  982. }
  983. }
  984. }
  985. else
  986. {
  987. rt = saveMethod.doError("选择的委托不存在,请重新选择");
  988. PbCache.LEDResultMessage = "选择的委托不存在,请重新选择";
  989. PbCache.voiceType = 6;
  990. rt.isWarn = true;
  991. rt.WarnContent = "validIsPre";
  992. return rt;
  993. }
  994. }
  995. }
  996. else
  997. {
  998. rt = saveMethod.doError("存在多条已选择的委托,请联系计量大厅");
  999. PbCache.LEDResultMessage = "存在多条已选择的委托,请联系计量大厅";
  1000. rt.isWarn = true;
  1001. PbCache.voiceType = 19;
  1002. rt.WarnContent = "validIsPre";
  1003. return rt;
  1004. }
  1005. }
  1006. }
  1007. else
  1008. {
  1009. rt = saveMethod.doError("存在多条上称申请数据,请联系计量大厅");
  1010. PbCache.voiceType = 20;
  1011. PbCache.LEDResultMessage = "存在多条上称申请数据,请联系计量大厅";
  1012. return rt;
  1013. }
  1014. }
  1015. // 后台失败处理
  1016. if (!rt.result)
  1017. {
  1018. rt.resultInfo = "称重数据保存失败";
  1019. PbCache.voiceType = 25;
  1020. PbCache.LEDResultMessage = "计量失败,请联系计量大厅";
  1021. PbCache.monitorResultMessage = "";
  1022. }
  1023. return rt;
  1024. }
  1025. }
  1026. }