InnerCarJISCO.cs 80 KB

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