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