InStockOperateService.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. using DapperORMCore.Context.DataContext;
  2. using DapperORMCore.Dapper.BaseModel;
  3. using DapperORMCore.Model.CoreModel;
  4. using DapperORMCore.Repository.IRepositorys;
  5. using Microsoft.Extensions.Configuration;
  6. using NXWMS.DataAccess.Entity;
  7. using NXWMS.IService.NXPDA.InStock;
  8. using NXWMS.IService.NXWMS.Instock;
  9. using NXWMS.Model.AppModels.Condition.Balance;
  10. using NXWMS.Model.AppModels.Condition.Base;
  11. using NXWMS.Model.AppModels.Condition.NXPDA.InStock;
  12. using NXWMS.Model.AppModels.Result.Balance;
  13. using NXWMS.Model.AppModels.Result.Base;
  14. using NXWMS.Model.Common;
  15. using NXWMS.Service;
  16. using NXWMS.String.Enums;
  17. using System;
  18. using System.Collections.Generic;
  19. using System.Linq;
  20. using System.Text;
  21. using System.Threading.Tasks;
  22. using WestDistance.DapperORM.Repository.Repositorys;
  23. namespace NXWMS.Service.NXPDA.InStock
  24. {
  25. /// <summary>
  26. /// 库存操作接口
  27. /// </summary>
  28. [AutoInject(typeof(IInStockOperateService), InjectType.Scope)]
  29. public class InStockOperateService : ServiceBase, IInStockOperateService
  30. {
  31. /// <summary>
  32. /// 系统操作仓储中转
  33. /// </summary>
  34. private IDataRepositoryContext _dataContext;
  35. /// <summary>
  36. /// SQL节点仓储
  37. /// </summary>
  38. private ISQLNodeRepository _iSQLNodeRepository;
  39. private IWmsInReceiptService _inReceiptService;
  40. private IWmsInPutawayService _wmsInPutaway;
  41. /// <summary>
  42. /// 配置
  43. /// </summary>
  44. private IConfiguration _configuration;
  45. public InStockOperateService(IDataRepositoryContext dataRepositoryContext, IWmsInReceiptService inReceiptService, IWmsInPutawayService wmsInPutaway, IConfiguration configuration, ISQLNodeRepository iSQLNodeRepository)
  46. {
  47. this._dataContext = dataRepositoryContext;
  48. this._configuration = configuration;
  49. this._iSQLNodeRepository = iSQLNodeRepository;
  50. this._inReceiptService = inReceiptService;
  51. this._wmsInPutaway = wmsInPutaway;
  52. }
  53. public OperateResultInfo CommitReceiptDetail(CommitReceiptDetailCondition info)
  54. {
  55. if (string.IsNullOrWhiteSpace(info.MaterielBarCode))
  56. {
  57. return FailStatus("参数错误!");
  58. }
  59. try
  60. {
  61. _dataContext.BeginTran();
  62. var receiptDTLResult = new DataRepository<WMS_IN_RECEIPT_DTL>(_dataContext).Query("MATERIEL_BARCODE", info.MaterielBarCode.ToString()).FirstOrDefault();
  63. if (receiptDTLResult == null)
  64. {
  65. throw new Exception("物品条码不存在,请检查!");
  66. }
  67. var binResult = new DataRepository<BAS_BIN>(_dataContext).Query("BIN_CODE", info.BinCode.ToString()).FirstOrDefault();
  68. if (binResult == null)
  69. {
  70. throw new Exception("库位编码不存在,请检查!");
  71. }
  72. var userResult = new DataRepository<SYS_USER>(_dataContext).Query("USER_ID", info.OperationUserId.ToString()).FirstOrDefault();
  73. if (userResult == null)
  74. {
  75. throw new Exception("用户编码不存在,请检查!");
  76. }
  77. var materielResult = new DataRepository<BAS_MATERIEL>(_dataContext).Query("MATERIEL_CODE", receiptDTLResult.MATERIEL_CODE.ToString()).FirstOrDefault();
  78. if (materielResult == null)
  79. {
  80. throw new Exception("物料编码不存在,请检查!");
  81. }
  82. var now = DateTime.Now;
  83. receiptDTLResult.ARRIVAL_QTY = info.ActualQTY;
  84. receiptDTLResult.RECEIPT_DTL_STATUS = 55;
  85. receiptDTLResult.UPDATE_TIME = now;
  86. receiptDTLResult.UPDATE_BY = info.OperationUserId;
  87. new DataRepository<WMS_IN_RECEIPT_RECORD>(_dataContext).Update(receiptDTLResult, "RECEIPT_DTL_ID", "NEWID");
  88. var result = new DataRepository<WMS_IN_RECEIPT>(_dataContext).Query("RECEIPT_NO", info.ReceiptCode.ToString()).FirstOrDefault();
  89. if (result == null)
  90. {
  91. throw new Exception("收货单号不存在,请检查!");
  92. }
  93. result.RECEIPT_STATUS = 55;
  94. result.UPDATE_BY = info.OperationUserId;
  95. result.UPDATE_TIME = now;
  96. new DataRepository<WMS_IN_RECEIPT>(_dataContext).Update(result, "RECEIPT_ID", "NEWID");
  97. _dataContext.Commit();
  98. return SuccessStatus();
  99. }
  100. catch (Exception ex)
  101. {
  102. _dataContext.Rollback();
  103. return FailStatus("提交失败!" + ex.Message);
  104. }
  105. //var sql = $@"SELECT TrayCode=WMS_STK_TRAY.TRAY_CODE,PalletCode=WMS_STK_TRAY.PALLET_CODE,TraysType=WMS_STK_TRAY.TRAYS_TYPE,
  106. // TrayLoadedType = WMS_STK_TRAY.TRAY_LOADED_TYPE,TrayStatus=WMS_STK_TRAY.TRAY_STATUS,
  107. // MaterielCode=WMS_STK_TRAY_DTL.MATERIEL_CODE,QTY = WMS_STK_TRAY_DTL.QTY,TrayDtlStatus=WMS_STK_TRAY_DTL.TRAY_DTL_STATUS,
  108. // MaterielSpec=WMS_STK_TRAY_DTL_EXT.MATERIEL_SPEC,PackageCode=WMS_STK_TRAY_DTL_EXT.PACKAGE_CODE,UnitCode=WMS_STK_TRAY_DTL_EXT.UNIT_CODE,
  109. // BatchNo=WMS_STK_TRAY_DTL_EXT.BATCH_NO,SupplierCode=WMS_STK_TRAY_DTL_EXT.SUPPLIER_CODE,SupplierName=WMS_STK_TRAY_DTL_EXT.SUPPLIER_NAME,
  110. // ProductDate=WMS_STK_TRAY_DTL_EXT.PRODUCT_DATE,ExpDate=WMS_STK_TRAY_DTL_EXT.EXP_DATE,QualityStatus=WMS_STK_TRAY_DTL_EXT.QUALITY_STATUS,
  111. // ItemStatus=WMS_STK_TRAY_DTL_EXT.ITEM_STATUS,EctendTimeLen=WMS_STK_TRAY_DTL_EXT.ECTEND_TIME_LEN,
  112. // LockFlag=WMS_STK_TRAY_DTL_EXT.LOCK_FLAG,InspectionResult=WMS_STK_TRAY_DTL_EXT.INSPECTION_RESULT FROM WMS_STK_TRAY
  113. // JOIN WMS_STK_TRAY_DTL ON WMS_STK_TRAY.TRAY_ID=WMS_STK_TRAY_DTL.TRAY_ID
  114. // LEFT JOIN WMS_STK_TRAY_DTL_EXT ON WMS_STK_TRAY_DTL_EXT.TRAY_DTL_ID=WMS_STK_TRAY_DTL.TRAY_DTL_ID
  115. // WHERE WMS_STK_TRAY.TRAY_CODE='{receiptDTLResult.TrayCode}' ";
  116. //var receiptRecordResult = new WMS_IN_RECEIPT_RECORD
  117. //{
  118. // BIN_CODE = binResult.BIN_CODE,
  119. // BIN_NAME = binResult.BIN_NAME,
  120. // RECEIPT_ID = receiptDTLResult.RECEIPT_ID,
  121. // EXP_DATE= receiptDTLResult.EXP_DATE,
  122. // MATERIEL_CODE= receiptDTLResult.MATERIEL_CODE,
  123. // PACKAGE_CODE= receiptDTLResult.PACKAGE_CODE,
  124. // PALLET_CODE= receiptDTLResult.PACKAGE_CODE,
  125. // PRODUCT_DATE= receiptDTLResult.PRODUCT_DATE,
  126. // RECEIPT_DTL_ID= receiptDTLResult.RECEIPT_DTL_ID,
  127. // RECEIPT_RECORD_STATUS = 0,
  128. // REGION_CODE= binResult.REGION_CODE,
  129. // RECEIPTER= userResult.USER_NAME,
  130. // //TRAY_CODE
  131. //};
  132. }
  133. public OperateResultInfo SaveReceipt(SaveReceiptDetailCondition info)
  134. {
  135. var stkTrayResult = new WmsStkTrayResult();
  136. stkTrayResult.CREATE_BY = info.OperationUserId;
  137. stkTrayResult.PALLET_CODE = info.PallteCode;
  138. stkTrayResult.TRAYS_TYPE = 3;
  139. stkTrayResult.TRAY_LOADED_TYPE = 1;
  140. stkTrayResult.TRAY_STATUS = 0;
  141. stkTrayResult.UPDATE_BY = info.OperationUserId;
  142. stkTrayResult.WmsStkTrayDtlList = new List<WmsStkTrayDtlResult>();
  143. foreach (var item in info.details)
  144. {
  145. var strSQL = $@"SELECT * FROM [dbo].[WMS_IN_RECEIPT_DTL] as a left join [dbo].[WMS_IN_RECEIPT] as b on a.RECEIPT_ID=b.RECEIPT_ID where a.RECEIPT_DTL_ID='{item.ReceiptDtlId}' and a.MATERIEL_CODE='{item.MaterielCode}'";
  146. var inReceiptDtl = new DataRepository<WMS_IN_RECEIPT_DTL>(_dataContext).Query(strSQL).FirstOrDefault();
  147. stkTrayResult.WmsStkTrayDtlList.Add(new WmsStkTrayDtlResult()
  148. {
  149. CREATE_BY = info.OperationUserId,
  150. UPDATE_BY = info.OperationUserId,
  151. DATA_VERSION = 0,
  152. MATERIEL_BARCODE = item.Barcode,
  153. MATERIEL_CODE=item.MaterielCode,
  154. MATERIEL_ID = item.MaterieId,
  155. QTY = item.Qty,
  156. WmsInReceiptRecord = new Model.AppModels.Result.Instock.WmsInReceiptRecordResult()
  157. {
  158. PALLET_CODE = info.PallteCode,
  159. RECEIPT_NO = item.ReceiptNo,
  160. RECEIPT_TIME = DateTime.Now,
  161. MATERIEL_CODE=item.MaterielCode,
  162. PRODUCT_DATE = inReceiptDtl.PRODUCT_DATE.Value,
  163. EXP_DATE = inReceiptDtl.EXP_DATE.Value,
  164. RECEIPT_DTL_ID = inReceiptDtl.RECEIPT_DTL_ID,
  165. RECEIPT_ID = inReceiptDtl.RECEIPT_ID,
  166. RECEIPT_QTY=item.Qty
  167. },
  168. WmsStkTrayDtlExtMd = new WmsStkTrayDtlExtResult()
  169. {
  170. PRODUCT_DATE = inReceiptDtl.PRODUCT_DATE.Value,
  171. EXP_DATE = inReceiptDtl.EXP_DATE.Value,
  172. UNIT_CODE = inReceiptDtl.UNIT_CODE,
  173. SUPPLIER_CODE = inReceiptDtl.SUPPLIER_CODE,
  174. SUPPLIER_NAME = inReceiptDtl.SUPPLIER_NAME,
  175. }
  176. }); ;
  177. //var now = DateTime.Now;
  178. //var ids = info.MaterielBarCodes.Split(',');
  179. //var affterCount = 0;
  180. //foreach (var item in ids)
  181. //{
  182. // var resultTemp = new DataRepository<WMS_IN_RECEIPT_DTL>(_dataContext).Query("MATERIEL_BARCODE", item.ToString()).FirstOrDefault();
  183. // if (resultTemp == null)
  184. // {
  185. // throw new Exception("收货明细单状态出现变更,当前操作失效 " + item.ToString());
  186. // }
  187. // resultTemp.RECEIPT_DTL_STATUS = 99;
  188. // resultTemp.UPDATE_BY = info.OperationUserId;
  189. // resultTemp.UPDATE_TIME = now;
  190. // affterCount = affterCount + new DataRepository<WMS_IN_RECEIPT_DTL>(_dataContext).Update(resultTemp, "RECEIPT_DTL_ID", "NEWID");
  191. //}
  192. //if (affterCount != ids.Length)
  193. //{
  194. // _dataContext.Rollback();
  195. // return FailMessageStatus("数据操作失败!");
  196. //}
  197. //_dataContext.Commit();
  198. //if (!new DataRepository<WMS_IN_RECEIPT_DTL>(_dataContext).Query("RECEIPT_ID", result.RECEIPT_ID.ToString()).
  199. // Where(s => s.RECEIPT_DTL_STATUS != 99).Any())
  200. //{
  201. // result.RECEIPT_STATUS = 99;
  202. // result.UPDATE_BY = info.OperationUserId;
  203. // result.UPDATE_TIME = now;
  204. // new DataRepository<WMS_IN_RECEIPT>(_dataContext).Update(result, "RECEIPT_ID", "NEWID");
  205. //}
  206. //return SuccessStatus();
  207. }
  208. return _inReceiptService.AddWmsInReceiptTrayData(stkTrayResult);
  209. }
  210. public OperateResultInfo CommitPutAwayDetail(CommitPutAwayDetailCondition info)
  211. {
  212. if (string.IsNullOrWhiteSpace(info.MaterielBarCode))
  213. {
  214. return FailMessageStatus("参数错误!");
  215. }
  216. try
  217. {
  218. _dataContext.BeginTran();
  219. var receiptDTLResult = new DataRepository<WMS_IN_PUTAWAY_DTL>(_dataContext).Query("MATERIEL_BARCODE", info.MaterielBarCode.ToString()).FirstOrDefault();
  220. if (receiptDTLResult == null)
  221. {
  222. throw new Exception("物品条码不存在,请检查!");
  223. }
  224. var binResult = new DataRepository<BAS_BIN>(_dataContext).Query("BIN_CODE", info.BinCode.ToString()).FirstOrDefault();
  225. if (binResult == null)
  226. {
  227. throw new Exception("库位编码不存在,请检查!");
  228. }
  229. var userResult = new DataRepository<SYS_USER>(_dataContext).Query("USER_ID", info.OperationUserId.ToString()).FirstOrDefault();
  230. if (userResult == null)
  231. {
  232. throw new Exception("用户编码不存在,请检查!");
  233. }
  234. var materielResult = new DataRepository<BAS_MATERIEL>(_dataContext).Query("MATERIEL_CODE", receiptDTLResult.MATERIEL_CODE.ToString()).FirstOrDefault();
  235. if (materielResult == null)
  236. {
  237. throw new Exception("物料编码不存在,请检查!");
  238. }
  239. var now = DateTime.Now;
  240. receiptDTLResult.PUTAWAY_QTY = info.ActualQTY;
  241. receiptDTLResult.PUTAWAY_DTL_STATUS = 11;
  242. receiptDTLResult.UPDATE_TIME = now;
  243. receiptDTLResult.UPDATE_BY = info.OperationUserId;
  244. new DataRepository<WMS_IN_RECEIPT_RECORD>(_dataContext).Update(receiptDTLResult, "RECEIPT_DTL_ID", "NEWID");
  245. var result = new DataRepository<WMS_IN_PUTAWAY>(_dataContext).Query("RECEIPT_NO", info.PutAwayNo.ToString()).FirstOrDefault();
  246. if (result == null)
  247. {
  248. throw new Exception("收货单号不存在,请检查!");
  249. }
  250. result.PUTAWAY_STATUS = 55;
  251. result.UPDATE_BY = info.OperationUserId;
  252. result.UPDATE_TIME = now;
  253. new DataRepository<WMS_IN_PUTAWAY>(_dataContext).Update(result, "PUTAWAY_ID", "NEWID");
  254. _dataContext.Commit();
  255. return SuccessStatus();
  256. }
  257. catch (Exception ex)
  258. {
  259. _dataContext.Rollback();
  260. return FailMessageStatus("提交失败!" + ex.Message);
  261. }
  262. }
  263. public OperateResultInfo SavePutAway(SavePutAwayDetailCondition info)
  264. {
  265. return this._wmsInPutaway.ManualPutAwayPallet(new Model.AppModels.Result.Instock.WmsInPutAwayResult()
  266. {
  267. PalletCode = info.PalletCode,
  268. TrayCode = info.TrayCode,
  269. EbinCode = info.BinCode,
  270. PutawayType =1
  271. }, PutAwayMethodsEnum.PDA手动上架);
  272. //if (string.IsNullOrWhiteSpace(info.PutAwayNo))
  273. //{
  274. // return FailMessageStatus("参数错误!");
  275. //}
  276. //var result = new DataRepository<WMS_IN_PUTAWAY>(_dataContext).Query("PUTAWAY_NO", info.PutAwayNo.ToString()).FirstOrDefault();
  277. //if (result.PUTAWAY_STATUS >= 99)
  278. //{
  279. // return FailMessageStatus("单据状态已经变更,当前所有操作失效!");
  280. //}
  281. //try
  282. //{
  283. // _dataContext.BeginTran();
  284. // var now = DateTime.Now;
  285. // var ids = info.MaterielBarCodes.Split(',');
  286. // var affterCount = 0;
  287. // foreach (var item in ids)
  288. // {
  289. // var resultTemp = new DataRepository<WMS_IN_PUTAWAY_DTL>(_dataContext).Query("MATERIEL_BARCODE", item.ToString()).FirstOrDefault();
  290. // if (resultTemp == null)
  291. // {
  292. // throw new Exception("收货明细单状态出现变更,当前操作失效 " + item.ToString());
  293. // }
  294. // resultTemp.PUTAWAY_DTL_STATUS = 99;
  295. // resultTemp.UPDATE_BY = info.OperationUserId;
  296. // resultTemp.UPDATE_TIME = now;
  297. // affterCount = affterCount + new DataRepository<WMS_IN_PUTAWAY_DTL>(_dataContext).Update(resultTemp, "RECEIPT_DTL_ID", "NEWID");
  298. // }
  299. // if (affterCount != ids.Length)
  300. // {
  301. // _dataContext.Rollback();
  302. // return FailMessageStatus("数据操作失败!");
  303. // }
  304. // _dataContext.Commit();
  305. // if (!new DataRepository<WMS_IN_PUTAWAY_DTL>(_dataContext).Query("RECEIPT_ID", result.PUTAWAY_ID.ToString()).
  306. // Where(s => s.PUTAWAY_DTL_STATUS != 99).Any())
  307. // {
  308. // result.PUTAWAY_STATUS = 99;
  309. // result.UPDATE_BY = info.OperationUserId;
  310. // result.UPDATE_TIME = now;
  311. // new DataRepository<WMS_IN_RECEIPT>(_dataContext).Update(result, "RECEIPT_ID", "NEWID");
  312. // }
  313. // return SuccessStatus();
  314. //}
  315. //catch (Exception ex)
  316. //{
  317. // _dataContext.Rollback();
  318. // return FailMessageStatus("提交失败!" + ex.Message);
  319. //}
  320. }
  321. public OperateResultInfo CommitInspectionDetail(CommitInspectionDetailCondition info)
  322. {
  323. if (string.IsNullOrWhiteSpace(info.MaterielBarCode))
  324. {
  325. return FailMessageStatus("参数错误!");
  326. }
  327. try
  328. {
  329. _dataContext.BeginTran();
  330. var result = new DataRepository<WMS_QA_INSPECTION_DTL>(_dataContext).Query("MATERIEL_BARCODE", info.MaterielBarCode.ToString()).FirstOrDefault();
  331. if (result == null)
  332. {
  333. throw new Exception("物品条码不存在,请检查!");
  334. }
  335. var binResult = new DataRepository<BAS_BIN>(_dataContext).Query("BIN_CODE", info.BinCode.ToString()).FirstOrDefault();
  336. if (binResult == null)
  337. {
  338. throw new Exception("库位编码不存在,请检查!");
  339. }
  340. var userResult = new DataRepository<SYS_USER>(_dataContext).Query("USER_ID", info.OperationUserId.ToString()).FirstOrDefault();
  341. if (userResult == null)
  342. {
  343. throw new Exception("用户编码不存在,请检查!");
  344. }
  345. var materielResult = new DataRepository<BAS_MATERIEL>(_dataContext).Query("MATERIEL_CODE", result.MATERIEL_CODE.ToString()).FirstOrDefault();
  346. if (materielResult == null)
  347. {
  348. throw new Exception("物料编码不存在,请检查!");
  349. }
  350. var now = DateTime.Now;
  351. result.INSPECTION_DTL_STATUS = 55;
  352. result.UPDATE_TIME = now;
  353. result.UPDATE_BY = info.OperationUserId;
  354. new DataRepository<WMS_QA_INSPECTION_DTL>(_dataContext).Update(result, "RECEIPT_DTL_ID", "NEWID");
  355. //确认托盘号
  356. var receiptResult = new DataRepository<WMS_IN_RECEIPT_RECORD>(_dataContext).
  357. Query("MATERIEL_BARCODE", info.MaterielBarCode.ToString()).FirstOrDefault();
  358. var inspectionResult = new DataRepository<WMS_QA_INSPECTION>(_dataContext).Query("RECEIPT_ID",
  359. receiptResult.RECEIPT_ID.ToString()).FirstOrDefault();
  360. if (inspectionResult == null)
  361. {
  362. throw new Exception("收货单号不存在,请检查!");
  363. }
  364. inspectionResult.INSPECTION_STATUS = 55;
  365. inspectionResult.UPDATE_BY = info.OperationUserId;
  366. inspectionResult.UPDATE_TIME = now;
  367. new DataRepository<WMS_QA_INSPECTION>(_dataContext).Update(result, "PUTAWAY_ID", "NEWID");
  368. _dataContext.Commit();
  369. return SuccessStatus();
  370. }
  371. catch (Exception ex)
  372. {
  373. _dataContext.Rollback();
  374. return FailStatus("提交失败!" + ex.Message);
  375. }
  376. }
  377. /// <summary>
  378. /// 保存检查结果
  379. /// </summary>
  380. /// <param name="info"></param>
  381. /// <returns></returns>
  382. public OperateResultInfo SaveInspection(SaveInspectionDetailCondition info)
  383. {
  384. try
  385. {
  386. var repository = new DataRepository<object>(_dataContext);
  387. _dataContext.BeginTran();
  388. string strSqlInspection = $@" update WMS_QA_INSPECTION set INVENTORY_STATUS=77 where INSPECTION_NO='{info.InspectionCode}'";
  389. repository.Execute(strSqlInspection);
  390. foreach (var item in info.Detail)
  391. {
  392. var strSqlInspectionDetail = $@"updtae WMS_QA_INSPECTION_DTL_ID set INSPECTION_RESULT={item.InspectionResult} ,INSPECTION_DTL_STATUS=77 where ";
  393. repository.Execute(strSqlInspectionDetail);
  394. var strSQLReceipt = $@"update WMS_IN_RECEIPT_DTL set INSPECTION_RESULT={item.InspectionResult} where RECEIPT_DTL_ID =(select BILL_DTL_ID from VW_WMS_QA_INSPECTION_DTL where INSPECTION_DTL_ID={item.InspectionDtlId})";
  395. repository.Execute(strSQLReceipt);
  396. }
  397. _dataContext.Commit();
  398. }
  399. catch (Exception ex)
  400. {
  401. _dataContext.Rollback();
  402. return FailStatus("提交失败!" + ex.Message);
  403. }
  404. finally
  405. {
  406. }
  407. //主表
  408. //if (string.IsNullOrWhiteSpace(info.PalletCode))
  409. //{
  410. // return FailMessageStatus("参数错误!");
  411. //}
  412. ////确认托盘号
  413. //var receiptResult = new DataRepository<WMS_IN_RECEIPT_RECORD>(_dataContext).
  414. // Query("PALLET_CODE", info.PalletCode.ToString()).
  415. // Where(s => s.RECEIPT_RECORD_STATUS == 0 && s.INSPECTION_RESULT == "Wait").
  416. // FirstOrDefault();
  417. //var inspectionResult = new DataRepository<WMS_QA_INSPECTION>(_dataContext).Query("RECEIPT_ID",
  418. // receiptResult.RECEIPT_ID.ToString()).FirstOrDefault();
  419. //if (inspectionResult.INSPECTION_STATUS >= 99)
  420. //{
  421. // return FailMessageStatus("单据状态已经变更,当前所有操作失效!");
  422. //}
  423. //try
  424. //{
  425. // _dataContext.BeginTran();
  426. // var now = DateTime.Now;
  427. // var ids = info.MaterielBarCodes.Split(',');
  428. // var affterCount = 0;
  429. // foreach (var item in ids)
  430. // {
  431. // var resultTemp = new DataRepository<WMS_QA_INSPECTION_DTL>(_dataContext).Query("MATERIEL_BARCODE", item.ToString()).FirstOrDefault();
  432. // if (resultTemp == null)
  433. // {
  434. // throw new Exception("收货明细单状态出现变更,当前操作失效 " + item.ToString());
  435. // }
  436. // resultTemp.INSPECTION_DTL_STATUS = 99;
  437. // resultTemp.UPDATE_BY = info.OperationUserId;
  438. // resultTemp.UPDATE_TIME = now;
  439. // affterCount = affterCount + new DataRepository<WMS_QA_INSPECTION_DTL>(_dataContext).Update(resultTemp, "RECEIPT_DTL_ID", "NEWID");
  440. // }
  441. // if (affterCount != ids.Length)
  442. // {
  443. // _dataContext.Rollback();
  444. // return FailMessageStatus("数据操作失败!");
  445. // }
  446. // _dataContext.Commit();
  447. // if (!new DataRepository<WMS_QA_INSPECTION_DTL>(_dataContext).Query("INSPECTION_ID", inspectionResult.INSPECTION_ID.ToString()).
  448. // Where(s => s.INSPECTION_DTL_STATUS != 99).Any())
  449. // {
  450. // inspectionResult.INSPECTION_STATUS = 99;
  451. // inspectionResult.UPDATE_BY = info.OperationUserId;
  452. // inspectionResult.UPDATE_TIME = now;
  453. // new DataRepository<WMS_QA_INSPECTION>(_dataContext).Update(inspectionResult, "INSPECTION_ID", "NEWID");
  454. // }
  455. // return SuccessStatus();
  456. //}
  457. //catch (Exception ex)
  458. //{
  459. // _dataContext.Rollback();
  460. // return FailStatus("提交失败!" + ex.Message);
  461. //}
  462. return SuccessStatus();
  463. }
  464. }
  465. }