InnerCarJISCO.cs 80 KB

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