HjController.cs 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  1. using AutoMapper;
  2. using CSRedis;
  3. using Microsoft.AspNetCore.Http;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Newtonsoft.Json;
  6. using Org.BouncyCastle.Crypto;
  7. using System.Collections.Generic;
  8. using System.Diagnostics;
  9. using System.Linq;
  10. using wms.api.Job;
  11. using wms.dto;
  12. using wms.dto.request;
  13. using wms.dto.request.hj;
  14. using wms.dto.request.hj.dto;
  15. using wms.dto.request.share;
  16. using wms.dto.response;
  17. using wms.dto.response.hj;
  18. using wms.dto.response.share;
  19. using wms.service;
  20. using wms.service.IService;
  21. using wms.sqlsugar;
  22. using wms.sqlsugar.model.hj;
  23. using wms.util;
  24. using wms.util.Check;
  25. using wms.util.Ext;
  26. using wms.util.Http;
  27. namespace wms.api.Controllers
  28. {
  29. /// <summary>
  30. /// 合金库控制器
  31. /// </summary>
  32. [Route("api/[controller]/[action]")]
  33. [ApiController]
  34. public class HjController : BaseController
  35. {
  36. private readonly IHJService _hJService;
  37. private readonly ILogger<HjController> _logger;
  38. private readonly IMapper _mapper;
  39. static object lockerCopperLineReceiveInstr = new object();
  40. static object lockerWetLineBackInApply = new object();
  41. static object lockerStockChange = new object();
  42. static object lockerSpecialPickMaterApply = new object();
  43. static object lockerSyncMaterInfoList = new object();
  44. static object lockerApplyStockOutTask = new object();
  45. static object lockerWetLinePickMaterApply = new object();
  46. static object lockerCompleteTask = new object();
  47. static object lockerApplyStockInLoc = new object();
  48. static object lockerMoveTask = new object();
  49. static object lockerSrmPickOutCompleted = new object();
  50. static object lockWcsUploadInfo = new object();
  51. static object lockerMannel = new object();
  52. static object lockerCarryTask = new object();
  53. static object lockerStockInfo = new object();
  54. static object lockerPdaTaskInfo = new object();
  55. static object lockerCancelOrComplet = new object();
  56. Repository<SysJob> _sysJobrepository => new Repository<SysJob>();
  57. public HjController(IHJService hJService, ILogger<HjController> logger, IMapper mapper) :base(hJService, logger)
  58. {
  59. _hJService = hJService;
  60. _logger= logger;
  61. _mapper = mapper;
  62. }
  63. #region 业务方法
  64. /// <summary>
  65. /// 更新任务进程
  66. /// </summary>
  67. /// <param name="reqEntity"></param>
  68. /// <returns></returns>
  69. [HttpPost]
  70. public SRes<int> WcsTaskCallBack(WcsTaskCallBackRequest reqEntity)
  71. {
  72. return _hJService.WcsTaskCallBack(reqEntity);
  73. }
  74. /// <summary>
  75. /// 获取巷道
  76. /// </summary>
  77. /// <param name="reqEntity"></param>
  78. /// <returns></returns>
  79. [HttpPost]
  80. public SRes<string> GetTunnelPriorityList(GetTunnelPriorityListRequest reqEntity)
  81. {
  82. return _hJService.GetTunnelPriorityList(reqEntity);
  83. }
  84. /// <summary>
  85. /// 分配货位
  86. /// </summary>
  87. /// <param name="reqEntity"></param>
  88. /// <returns></returns>
  89. [HttpPost]
  90. public SRes<ApplyStockInLocResponse> ApplyStockInLoc(ApplyStockInLocRequest reqEntity)
  91. {
  92. return ConcurrencyReqControl<ApplyStockInLocRequest, SRes<ApplyStockInLocResponse>>(lockerApplyStockInLoc, "ApplyStockInLoc" + reqEntity.TunnelNum, "分配货位" + reqEntity.PickUpEquipmentNo, reqEntity, _hJService.ApplyStockInLoc);
  93. }
  94. /// <summary>
  95. /// 完成任务
  96. /// </summary>
  97. /// <param name="reqEntity"></param>
  98. /// <returns></returns>
  99. [HttpPost]
  100. public SRes<int> CompleteTask(CompleteTaskRequest reqDto)
  101. {
  102. lock (lockerCompleteTask)
  103. {
  104. return _hJService.CompleteTask(reqDto);
  105. }
  106. }
  107. /// <summary>
  108. /// 申请移库任务
  109. /// </summary>
  110. /// <param name="reqEntity"></param>
  111. /// <returns></returns>
  112. [HttpPost]
  113. public SRes<AddWcsMoveTaskResponse> AddWcsMoveTask(AddWcsMoveTaskRequest reqEntity)
  114. {
  115. lock (lockerMoveTask)
  116. {
  117. return _hJService.AddWcsMoveTask(reqEntity);
  118. }
  119. }
  120. /// <summary>
  121. /// 堆垛机出库放货完成
  122. /// </summary>
  123. /// <param name="reqEntity"></param>
  124. /// <returns></returns>
  125. [HttpPost]
  126. public SRes<int> SrmPickOutCompleted(SrmPickOutCompletedRequest reqDto)
  127. {
  128. lock (lockerSrmPickOutCompleted)
  129. {
  130. return _hJService.SrmPickOutCompleted(reqDto);
  131. }
  132. }
  133. /// <summary>
  134. /// WCS信息上传
  135. /// </summary>
  136. /// <param name="reqEntity"></param>
  137. /// <returns></returns>
  138. [HttpPost]
  139. public SRes WcsUploadInfo(WcsUploadInfoRequest reqDto)
  140. {
  141. lock (lockWcsUploadInfo)
  142. {
  143. //if (reqDto.Weight > 1)
  144. //{
  145. // var webBaseUrl = AppSettings.GetConfig("maxweight");
  146. //}
  147. return _hJService.WcsUploadInfo(reqDto);
  148. }
  149. }
  150. /// <summary>
  151. /// 物料主数据推送接口
  152. /// </summary>
  153. /// <param name="reqBody"></param>
  154. /// <returns></returns>
  155. [HttpPost]
  156. public SRes SyncMaterInfoList(HJSyncMaterInfoListRequest reqDto)
  157. {
  158. var res = new SRes();
  159. if (string.IsNullOrEmpty(reqDto.ReqId))
  160. {
  161. res.ResCode = ResponseStatusCodeEnum.NotReqId.GetHashCode();
  162. res.ResMsg = ResponseStatusCodeEnum.NotReqId.GetDescription();
  163. return res;
  164. }
  165. if (reqDto.ListInfo == null || !reqDto.ListInfo.Any())
  166. {
  167. res.ResCode = ResponseStatusCodeEnum.DocDetailNotExist.GetHashCode();
  168. res.ResMsg = ResponseStatusCodeEnum.DocDetailNotExist.GetDescription();
  169. return res;
  170. }
  171. return ConcurrencyReqControl<HJSyncMaterInfoListRequest, SRes>(lockerSyncMaterInfoList, "SyncMaterInfoList", "物料主数据推送" + reqDto.ReqId, reqDto, _hJService.SyncMaterInfo);
  172. }
  173. /// <summary>
  174. /// 镀铜满轮入库/550工字轮入库反馈接口
  175. /// </summary>
  176. /// <param name="billcode"></param>
  177. /// <returns></returns>
  178. [HttpPost(Name = "CopperLineStockInFeedBack")]
  179. public CopperLineStockInFeedBackResponse CopperLineStockInFeedBack(string billcode)
  180. {
  181. var list = _hJService.GetBillFeedbackList(p => p.BillCode == billcode && p.ApiCode == "CopperLineStockInFeedBack" && p.PostResult == 0 ||( p.PostResult == 2 && p.PostNum < 5));
  182. if (!list.Any())
  183. {
  184. return new CopperLineStockInFeedBackResponse() { ResCode = ResponseStatusCodeEnum.NoResult.GetHashCode(), ResMsg = ResponseStatusCodeEnum.NoResult.GetDescription() };
  185. }
  186. var dtolist = _mapper.Map<List<CopperLineStockInFeedBackItem>>(list);
  187. CopperLineStockInFeedBackRequest dto = new CopperLineStockInFeedBackRequest();
  188. dto.ListInfo = dtolist;
  189. CopperLineStockInFeedBackResponse resbody = JsonConvert.DeserializeObject<CopperLineStockInFeedBackResponse>(WmsServiceExportApi(dto));
  190. List<long> ids = list.Select(p => p.Id).ToList();
  191. List<string> doccodelist = list.Select(p => p.BillCode).ToList();
  192. if (resbody.ResCode == ResponseStatusCodeEnum.Sucess.GetHashCode())
  193. {
  194. //更新推送表数据
  195. _hJService.UpdateBillFeedbackPushModelColumns(new sqlsugar.model.UpdateModelColumns<hjBillFeedbackPush>()
  196. {
  197. Columns = it => new hjBillFeedbackPush { PostResult = 1, PostNum = it.PostNum + 1 },
  198. WhereExpression = it => ids.Contains(it.Id)
  199. });
  200. //删除单据表数据
  201. _hJService.DeleteDoc(p => doccodelist.Contains(p.DocNo));
  202. }
  203. else
  204. {
  205. //更新推送表数据
  206. _hJService.UpdateBillFeedbackPushModelColumns(new sqlsugar.model.UpdateModelColumns<hjBillFeedbackPush>()
  207. {
  208. Columns = it => new hjBillFeedbackPush { PostResult = 2, PostNum = it.PostNum + 1 },
  209. WhereExpression = it => ids.Contains(it.Id)
  210. });
  211. }
  212. return resbody;
  213. }
  214. /// <summary>
  215. /// 湿拉生产退料/余料反馈接口
  216. /// </summary>
  217. /// <param name="billcode"></param>
  218. /// <returns></returns>
  219. [HttpPost(Name = "WetLineBackInFeedBack")]
  220. public WetLineBackInFeedBackResponse WetLineBackInFeedBack(string billcode)
  221. {
  222. var list = _hJService.GetBillFeedbackList(p => p.BillCode == billcode && p.ApiCode == "WetLineBackInFeedBack" && p.PostResult == 0 || (p.PostResult == 2 && p.PostNum < 5));
  223. var dtolist = _mapper.Map<List<WetLineBackInFeedBackRequestItem>>(list);
  224. var dto = new WetLineBackInFeedBackRequest() { ListInfo = dtolist };
  225. WetLineBackInFeedBackResponse resbody = JsonConvert.DeserializeObject<WetLineBackInFeedBackResponse>(WmsServiceExportApi(dtolist));
  226. List<long> ids = list.Select(p => p.Id).ToList();
  227. List<string> doccodelist = list.Select(p => p.BillCode).ToList();
  228. if (resbody.ResCode == ResponseStatusCodeEnum.Sucess.GetHashCode())
  229. {
  230. //更新推送表数据
  231. _hJService.UpdateBillFeedbackPushModelColumns(new sqlsugar.model.UpdateModelColumns<hjBillFeedbackPush>()
  232. {
  233. Columns = it => new hjBillFeedbackPush { PostResult = 1, PostNum = it.PostNum + 1 },
  234. WhereExpression = it => ids.Contains(it.Id)
  235. });
  236. //删除单据表数据
  237. _hJService.DeleteDoc(p => doccodelist.Contains(p.DocNo));
  238. }
  239. else
  240. {
  241. //更新推送表数据
  242. _hJService.UpdateBillFeedbackPushModelColumns(new sqlsugar.model.UpdateModelColumns<hjBillFeedbackPush>()
  243. {
  244. Columns = it => new hjBillFeedbackPush { PostResult = 2, PostNum = it.PostNum + 1 },
  245. WhereExpression = it => ids.Contains(it.Id)
  246. });
  247. }
  248. return resbody;
  249. }
  250. /// <summary>
  251. /// 改判反馈接口
  252. /// </summary>
  253. /// <param name="billcode"></param>
  254. /// <returns></returns>
  255. [HttpPost(Name = "StockChangeFeedBack")]
  256. public StockChangeFeedBackResponse StockChangeFeedBack(string billcode)
  257. {
  258. var list = _hJService.GetBillFeedbackList(p => p.BillCode == billcode);
  259. var dtolist = _mapper.Map<List<StockChangeRequestItem>>(list);
  260. StockChangeFeedBackRequest dto = new StockChangeFeedBackRequest() { BillCode = billcode };
  261. dto.ListInfo = dtolist;
  262. StockChangeFeedBackResponse resbody = JsonConvert.DeserializeObject<StockChangeFeedBackResponse>(WmsServiceExportApi(dto));
  263. List<long> ids = list.Select(p => p.Id).ToList();
  264. List<string> doccodelist = list.Select(p => p.BillCode).ToList();
  265. if (resbody.ResCode == ResponseStatusCodeEnum.Sucess.GetHashCode())
  266. {
  267. //更新推送表数据
  268. _hJService.UpdateBillFeedbackPushModelColumns(new sqlsugar.model.UpdateModelColumns<hjBillFeedbackPush>()
  269. {
  270. Columns = it => new hjBillFeedbackPush { PostResult = 1, PostNum = it.PostNum + 1 },
  271. WhereExpression = it => ids.Contains(it.Id)
  272. });
  273. //删除单据表数据
  274. _hJService.DeleteDoc(p => doccodelist.Contains(p.DocNo));
  275. }
  276. else
  277. {
  278. //更新推送表数据
  279. _hJService.UpdateBillFeedbackPushModelColumns(new sqlsugar.model.UpdateModelColumns<hjBillFeedbackPush>()
  280. {
  281. Columns = it => new hjBillFeedbackPush { PostResult = 2, PostNum = it.PostNum + 1 },
  282. WhereExpression = it => ids.Contains(it.Id)
  283. });
  284. }
  285. return resbody;
  286. }
  287. /// <summary>
  288. /// 特殊料反馈接口
  289. /// </summary>
  290. /// <param name="billcode"></param>
  291. /// <returns></returns>
  292. [HttpPost(Name = "SpecialPickMaterFeedBack")]
  293. public SpecialPickMaterFeedBackResponse SpecialPickMaterFeedBack(string billcode)
  294. {
  295. var list = _hJService.GetBillFeedbackList(p => p.BillCode == billcode && p.ApiCode == "SpecialPickMaterFeedBack" && p.PostResult == 0 || (p.PostResult == 2 && p.PostNum < 5));
  296. var dtolist = _mapper.Map<List<SpecialPickMaterFeedBackRequestItem>>(list);
  297. SpecialPickMaterFeedBackRequest dto = new SpecialPickMaterFeedBackRequest() { ListInfo = dtolist };
  298. SpecialPickMaterFeedBackResponse resbody = JsonConvert.DeserializeObject<SpecialPickMaterFeedBackResponse>(WmsServiceExportApi(dtolist));
  299. List<long> ids = list.Select(p => p.Id).ToList();
  300. List<string> doccodelist = list.Select(p => p.BillCode).ToList();
  301. if (resbody.ResCode == ResponseStatusCodeEnum.Sucess.GetHashCode())
  302. {
  303. //更新推送表数据
  304. _hJService.UpdateBillFeedbackPushModelColumns(new sqlsugar.model.UpdateModelColumns<hjBillFeedbackPush>()
  305. {
  306. Columns = it => new hjBillFeedbackPush { PostResult = 1, PostNum = it.PostNum + 1 },
  307. WhereExpression = it => ids.Contains(it.Id)
  308. });
  309. //删除单据表数据
  310. _hJService.DeleteDoc(p => doccodelist.Contains(p.DocNo));
  311. }
  312. else
  313. {
  314. //更新推送表数据
  315. _hJService.UpdateBillFeedbackPushModelColumns(new sqlsugar.model.UpdateModelColumns<hjBillFeedbackPush>()
  316. {
  317. Columns = it => new hjBillFeedbackPush { PostResult = 2, PostNum = it.PostNum + 1 },
  318. WhereExpression = it => ids.Contains(it.Id)
  319. });
  320. }
  321. return resbody;
  322. }
  323. /// <summary>
  324. /// 移库货位上报MES接口
  325. /// </summary>
  326. /// <param name="billcode"></param>
  327. /// <returns></returns>
  328. [HttpPost(Name = "MoveStockFeedBack")]
  329. public MoveStockFeedBackResponse MoveStockFeedBack(string billcode)
  330. {
  331. var list = _hJService.GetBillFeedbackList1(p => p.DocsNo == billcode && p.TypeCode == "MoveStockFeedBack" && p.PostResult == 0 || (p.PostResult == 2 && p.PostQty < 5));
  332. var dtolist = _mapper.Map<List<MoveStockFeedBackRequestItem>>(list);
  333. MoveStockFeedBackRequest dto = new MoveStockFeedBackRequest() { ListInfo = dtolist };
  334. MoveStockFeedBackResponse resbody = JsonConvert.DeserializeObject<MoveStockFeedBackResponse>(WmsServiceExportApi(dto));
  335. List<long> ids = list.Select(p => p.Id).ToList();
  336. List<string> doccodelist = list.Select(p => p.DocsNo).ToList();
  337. if (resbody.ResCode == ResponseStatusCodeEnum.Sucess.GetHashCode())
  338. {
  339. //更新推送表数据
  340. _hJService.UpdateBillFeedbackPushModelColumns(new sqlsugar.model.UpdateModelColumns<hjBillFeedbackPush>()
  341. {
  342. Columns = it => new hjBillFeedbackPush { PostResult = 1, PostNum = it.PostNum + 1 },
  343. WhereExpression = it => ids.Contains(it.Id)
  344. });
  345. }
  346. else
  347. {
  348. //更新推送表数据
  349. _hJService.UpdateBillFeedbackPushModelColumns(new sqlsugar.model.UpdateModelColumns<hjBillFeedbackPush>()
  350. {
  351. Columns = it => new hjBillFeedbackPush { PostResult = 2, PostNum = it.PostNum + 1 },
  352. WhereExpression = it => ids.Contains(it.Id)
  353. });
  354. }
  355. return resbody;
  356. }
  357. /// <summary>
  358. /// 条码信息查询接口
  359. /// </summary>
  360. /// <param name="billcode"></param>
  361. /// <returns></returns>
  362. [HttpPost(Name = "GetBarCodeInfo")]
  363. public GetBarCodeInfoResponse GetBarCodeInfo(GetBarCodeInfoRequest barcode)
  364. {
  365. GetBarCodeInfoResponse resbody = JsonConvert.DeserializeObject<GetBarCodeInfoResponse>(WmsServiceExportApi(barcode));
  366. return resbody;
  367. }
  368. /// <summary>
  369. /// 镀铜补空/取满指令接收接口(包含550工字轮)
  370. /// </summary>
  371. /// <param name="reqDto"></param>
  372. /// <returns></returns>
  373. [HttpPost(Name = "CopperLineReceiveInstr")]
  374. public SRes CopperLineReceiveInstr(CopperLineNewRequest reqDtoList)
  375. {
  376. var res = new SRes();
  377. if (reqDtoList != null && reqDtoList.data!= null && reqDtoList.data.Any())
  378. {
  379. foreach (var reqDto in reqDtoList.data)
  380. {
  381. res = ConcurrencyReqControl<CopperLineRequest, SRes>(lockerCopperLineReceiveInstr, "CopperLineReceiveInstr" + reqDto.WbCode, reqDto.WbCode, reqDto, _hJService.CopperLineReceiveInstr);
  382. if (res.ResCode != ResponseStatusCodeEnum.Sucess.GetHashCode())
  383. {
  384. continue;
  385. }
  386. }
  387. }
  388. return res;
  389. }
  390. /// <summary>
  391. /// 镀铜补空/取满指令接收接口(手持机用)
  392. /// </summary>
  393. /// <param name="reqDto"></param>
  394. /// <returns></returns>
  395. [HttpPost(Name = "PdaCopperLineReceiveInstr")]
  396. public SRes PdaCopperLineReceiveInstr(CopperLineRequest reqDto)
  397. {
  398. return ConcurrencyReqControl<CopperLineRequest, SRes>(lockerCopperLineReceiveInstr, "CopperLineReceiveInstr" + reqDto.WbCode, reqDto.WbCode, reqDto, _hJService.PdaCopperLineReceiveInstr);
  399. }
  400. /// <summary>
  401. /// 申请出库任务
  402. /// </summary>
  403. /// <param name="reqDto"></param>
  404. /// <returns></returns>
  405. [HttpPost]
  406. public ApplyStockOutTaskResponse ApplyStockOutTask(ApplyStockOutTaskRequest reqDto)
  407. {
  408. var result = new ApplyStockOutTaskResponse();
  409. if (reqDto.OutType == 2)
  410. {
  411. if (string.IsNullOrEmpty(reqDto.Tunnel))
  412. {
  413. return new ApplyStockOutTaskResponse()
  414. {
  415. ResCode = ResponseStatusCodeEnum.ErrParam.GetHashCode(),
  416. ResMsg = "巷道值没有传值"
  417. };
  418. }
  419. var req = new ApplyEmptySpoolRequest() { Tunnel = int.Parse(reqDto.Tunnel),OutEndPostion = reqDto.OutEndPostion };
  420. return ConcurrencyReqControl<ApplyEmptySpoolRequest, ApplyStockOutTaskResponse>(lockerApplyStockOutTask, "ApplyStockOutTask" + reqDto.OutEndPostion, reqDto.OutEndPostion, req, _hJService.ApplyEmptySpoolService);
  421. }
  422. return result;
  423. }
  424. /// <summary>
  425. /// 获取巷道空轮数量
  426. /// </summary>
  427. /// <returns></returns>
  428. [HttpPost]
  429. public SRes<GetTunnelEmptyConResponse> GetTunnelEmptyConCount(GetTunnelEmptyConCountRequest reqDto)
  430. {
  431. return _hJService.GetTunnelEmptyConCount(reqDto);
  432. }
  433. /// <summary>
  434. /// 库存改判
  435. /// </summary>
  436. /// <param name="reqDto"></param>
  437. /// <returns></returns>
  438. [HttpPost(Name = "StockChange")]
  439. public StockChangeResponse StockChange(StockChangeRequest reqDto)
  440. {
  441. return ConcurrencyReqControl<StockChangeRequest, StockChangeResponse>(lockerStockChange, "StockChange" + reqDto.BillCode, reqDto.BillCode, reqDto, _hJService.StockChange);
  442. }
  443. /// <summary>
  444. /// 特殊出库领料申请接口
  445. /// </summary>
  446. /// <param name="reqDto"></param>
  447. /// <returns></returns>
  448. [HttpPost(Name = "SpecialPickMaterApply")]
  449. public SpecialPickMaterApplyResponse SpecialPickMaterApply(SpecialPickMaterApplyRequest reqDto)
  450. {
  451. return ConcurrencyReqControl<SpecialPickMaterApplyRequest, SpecialPickMaterApplyResponse>(lockerSpecialPickMaterApply, "SpecialPickMaterApply" + reqDto.MatBarCode, reqDto.MatBarCode, reqDto, _hJService.SpecialPickMaterApply);
  452. }
  453. /// <summary>
  454. /// 实时库存查询接口
  455. /// </summary>
  456. /// <param name="reqDto"></param>
  457. /// <returns></returns>
  458. [HttpPost]
  459. public GetCurStockListResponse GetCurStockList(GetCurStockListRequest reqDto)
  460. {
  461. return _hJService.GetCurStockList(reqDto);
  462. }
  463. #endregion
  464. #region RCS调用接口
  465. /// <summary>
  466. /// 镀铜一楼res下任务
  467. /// </summary>
  468. /// <param name="reqDto"></param>
  469. /// <returns></returns>
  470. [HttpPost]
  471. public GenAgvSchedulingTaskResponse CopperLineAgvTaskToRcs(GenAgvSchedulingTaskRequest reqDto)
  472. {
  473. var result = new GenAgvSchedulingTaskResponse();
  474. //GenAgvSchedulingTaskRequest resReq = new GenAgvSchedulingTaskRequest();
  475. var apiurl = wms.util.AppSettings.GetConfig("RcsCreateTaskPushUrl");
  476. var strRes = HttpUtil.PostRequest(apiurl, JsonConvert.SerializeObject(reqDto), 30000);
  477. if (string.IsNullOrEmpty(strRes))
  478. {
  479. result.message = "返回空";
  480. return result;
  481. }
  482. return JsonConvert.DeserializeObject<GenAgvSchedulingTaskResponse>(strRes);
  483. }
  484. /// <summary>
  485. /// 镀铜一楼res继续任务
  486. /// </summary>
  487. /// <param name="reqDto"></param>
  488. /// <returns></returns>
  489. [HttpPost]
  490. public GenAgvSchedulingTaskResponse CopperLineContinueTaskToRcs(GenAgvSchedulingTaskRequest reqDto)
  491. {
  492. var result = new GenAgvSchedulingTaskResponse();
  493. //GenAgvSchedulingTaskRequest resReq = new GenAgvSchedulingTaskRequest()
  494. //{ };
  495. var apiurl = wms.util.AppSettings.GetConfig("RcsContinuePushUrl");
  496. var strRes = HttpUtil.PostRequest(apiurl, JsonConvert.SerializeObject(reqDto), 30000);
  497. if (string.IsNullOrEmpty(strRes))
  498. {
  499. result.message = "返回空";
  500. return result;
  501. }
  502. return JsonConvert.DeserializeObject<GenAgvSchedulingTaskResponse>(strRes);
  503. }
  504. /// <summary>
  505. /// 镀铜二楼IWMS下发满轮出库
  506. /// </summary>
  507. /// <param name="reqDto"></param>
  508. /// <returns></returns>
  509. [HttpPost]
  510. public SRes CopperLineAgvTaskStockOutToIWms(CopperLineAgvTaskStockOutToIWmsRequest reqDto)
  511. {
  512. var result = new SRes();
  513. CopperLineAgvTaskStockOutToIWmsRequest resReq = new CopperLineAgvTaskStockOutToIWmsRequest()
  514. {
  515. matCode = "",
  516. wbCode = "满轮接驳口",
  517. inSpoolFull = "1",
  518. wetInto = true,
  519. wetIntoSpec = false,
  520. isSurplus = "",
  521. isRework = "",
  522. matNo = "",
  523. spoolNo = "",
  524. gradeCode = "",
  525. taskNo = Guid.NewGuid().ToString(),
  526. };
  527. var apiurl = wms.util.AppSettings.GetConfig("IWmsStockOutPushUrl");
  528. var strRes = HttpUtil.PostRequest(apiurl, JsonConvert.SerializeObject(reqDto), 30000);
  529. if (string.IsNullOrEmpty(strRes))
  530. {
  531. //result.message = "返回空";
  532. return result;
  533. }
  534. return JsonConvert.DeserializeObject<SRes>(strRes);
  535. }
  536. /// <summary>
  537. /// 镀铜二楼IWMS下发空轮/退料/余料入库
  538. /// </summary>
  539. /// <param name="reqDto"></param>
  540. /// <returns></returns>
  541. [HttpPost]
  542. public SRes CopperLineAgvTaskStockInToIWms(CopperLineAgvTaskStockInToIWmsRequest reqDto)
  543. {
  544. var result = new SRes();
  545. CopperLineAgvTaskStockInToIWmsRequest resReq = new CopperLineAgvTaskStockInToIWmsRequest()
  546. {
  547. matCode = "",
  548. workAreaCode = "11",
  549. outSpoolFull = "1",
  550. taskNo = Guid.NewGuid().ToString()
  551. };
  552. var apiurl = wms.util.AppSettings.GetConfig("IWmsStockInPushUrl");
  553. var strRes = HttpUtil.PostRequest(apiurl, JsonConvert.SerializeObject(reqDto), 30000);
  554. if (string.IsNullOrEmpty(strRes))
  555. {
  556. //result.message = "返回空";
  557. return result;
  558. }
  559. return JsonConvert.DeserializeObject<SRes>(strRes);
  560. }
  561. /// <summary>
  562. /// AGV执行回调
  563. /// </summary>
  564. /// <param name="reqDto"></param>
  565. /// <returns></returns>
  566. [HttpPost]
  567. public agvCallbackResponse agvCallback(agvCallbackRequest reqDto)
  568. {
  569. var res = new agvCallbackResponse() { code = "0",message = "成功" };
  570. return res;
  571. }
  572. /// <summary>
  573. /// 复核异常上报接口
  574. /// </summary>
  575. /// <param name="request"></param>
  576. /// <returns></returns>
  577. [HttpPost]
  578. public RfidCheckDiffResponse RfidCheckDiff(RfidCheckDiffRequest request)
  579. {
  580. var res = new RfidCheckDiffResponse();
  581. //异常
  582. _hJService.RfidCheckDiffService(request);
  583. _logger.LogInformation("复核异常上报接口RfidCheckDiff接收数据:" + JsonConvert.SerializeObject(request));
  584. return res;
  585. }
  586. /// <summary>
  587. /// 湿拉生产退料/余料/空轮申请接口
  588. /// </summary>
  589. /// <param name="request"></param>
  590. /// <returns></returns>
  591. [HttpPost]
  592. public SRes WetLineBackInApply(WetLineBackInApplyRequest reqDto)
  593. {
  594. return ConcurrencyReqControl<WetLineBackInApplyRequest, SRes>(lockerWetLineBackInApply, "WetLineBackInApply" + reqDto.MatBarCode, reqDto.MatBarCode, reqDto, _hJService.WetLineBackInApplyService);
  595. //接收指令
  596. //入库逻辑
  597. //下发wcs任务
  598. }
  599. /// <summary>
  600. /// 湿拉产线领料申请接口WetLinePickMaterApply
  601. /// </summary>
  602. /// <param name="request"></param>
  603. /// <returns></returns>
  604. [HttpPost]
  605. public SRes WetLinePickMaterApply(WetLinePickMaterApplyRequest reqDto)
  606. {
  607. return ConcurrencyReqControl<WetLinePickMaterApplyRequest, SRes>(lockerWetLinePickMaterApply, "WetLinePickMaterApply" + reqDto.MatCode, reqDto.MatCode, reqDto, _hJService.WetLinePickMaterApplyService);
  608. }
  609. #endregion
  610. #region 定时任务业务
  611. /// <summary>
  612. /// 添加定时任务
  613. /// </summary>
  614. /// <param name="request"></param>
  615. /// <returns></returns>
  616. [HttpPost]
  617. public string AddJob(AddJobRequest request)
  618. {
  619. request.Id = IdFactory.NewId();
  620. return _hJService.AddJob(request);
  621. }
  622. /// <summar y>
  623. /// 编辑定时任务
  624. /// </summary>
  625. /// <returns></returns>
  626. [HttpPost]
  627. public string UpdateJobEntity(AddJobRequest request)
  628. {
  629. return _hJService.UpdateJobEntity(request);
  630. }
  631. /// <summary>
  632. /// 获取job根据id
  633. /// </summary>
  634. /// <returns></returns>
  635. [HttpPost]
  636. public string GetSysJobById(long id)
  637. {
  638. return JsonConvert.SerializeObject(_hJService.GetSysJobById(id));
  639. }
  640. /// <summary>
  641. /// 启用job
  642. /// </summary>
  643. /// <param name="id"></param>
  644. /// <returns></returns>
  645. [HttpPost]
  646. public string StartJob(DetailRequest2Str req)
  647. {
  648. var res = new SRes();
  649. var sysjob = _sysJobrepository.GetById(req.Id);
  650. if (sysjob == null)
  651. {
  652. res.ResCode = 0;
  653. res.ResMsg = "没有找到对应的定时任务";
  654. return res.ToCamelCaseString();
  655. }
  656. JobScheduler.Start(sysjob.Code, Type.GetType("wms.api.Job.PostJob"), sysjob.CronExpression);
  657. return res.ToCamelCaseString();
  658. }
  659. /// <summary>
  660. /// 执行job
  661. /// </summary>
  662. /// <param name="reqEntity"></param>
  663. /// <returns></returns>
  664. [HttpPost]
  665. public string ExecuteJob(DetailCodeRequest reqEntity)
  666. {
  667. var res = new SRes();
  668. if (string.IsNullOrEmpty(reqEntity.Code))
  669. {
  670. res.ResCode = 0;
  671. res.ResMsg = "参数错误";
  672. return res.ToCamelCaseString();
  673. }
  674. var jobEntity = _sysJobrepository.GetSingle(p => p.Code == reqEntity.Code);
  675. if (jobEntity == null)
  676. {
  677. res.ResCode = 0;
  678. res.ResMsg = "没有找到该编码";
  679. return res.ToCamelCaseString();
  680. }
  681. var jobapilist = _hJService.GetSysApiDetail(jobEntity.Id);
  682. if (jobapilist.Any())
  683. {
  684. foreach (var item in jobapilist)
  685. {
  686. Task.Run(() => { HttpUtil.PostRequest(item.ApiUrl, item.RequestBody); });
  687. }
  688. }
  689. return res.ToCamelCaseString();
  690. }
  691. /// <summary>
  692. /// 分页Job列表
  693. /// </summary>
  694. /// <param name="reqEntity"></param>
  695. /// <returns></returns>
  696. [HttpPost]
  697. public List<dto.response.hj.SysJobDto> GetSysJobList(GetSysJobListRequest reqEntity)
  698. {
  699. var list = _sysJobrepository.GetList();
  700. var listdto = _mapper.Map<List<dto.response.hj.SysJobDto>>(list);
  701. if (listdto != null && listdto.Any())
  702. {
  703. for (int i = 0; i < list.Count; i++)
  704. {
  705. listdto[i].JobExecuteStatus = GetExecuteStatus(new DetailCodeRequest() { Code = listdto[i].Code });
  706. }
  707. return listdto;
  708. }
  709. return new List<dto.response.hj.SysJobDto>();
  710. }
  711. /// <summary>
  712. /// 获取执行状态
  713. /// </summary>
  714. /// <param name="reqEntity"></param>
  715. /// <returns></returns>
  716. [HttpPost]
  717. public string GetExecuteStatus(DetailCodeRequest reqEntity)
  718. {
  719. var jobInfo = _sysJobrepository.GetFirst(p=>p.Code == reqEntity.Code);
  720. var jobs = JobScheduler.GetJobList(Const.JobGroupName).Result;
  721. if (jobs != null)
  722. {
  723. var temp = jobs.Where(p => p.JobName == jobInfo.Code);
  724. if (temp.Any())
  725. {
  726. return temp.First().JobStatus;
  727. }
  728. else
  729. {
  730. return "Stop";
  731. }
  732. }
  733. else
  734. {
  735. return "Stop";
  736. }
  737. }
  738. [HttpPost]
  739. public string GetId()
  740. {
  741. return IdFactory.NewId().ToString();
  742. }
  743. #endregion
  744. #region 库存管理
  745. /// <summary>
  746. /// 手动出库确定
  747. /// </summary>
  748. /// <param name="request"></param>
  749. /// <returns></returns>
  750. [HttpPost]
  751. public string ManualTask(ManualTaskRequest request)
  752. {
  753. lock (lockerMannel)
  754. {
  755. return _hJService.ManualTask(request);
  756. }
  757. }
  758. #endregion
  759. #region 合金PDA
  760. /// <summary>
  761. /// 合金解绑
  762. /// </summary>
  763. /// <param name="request"></param>
  764. /// <returns></returns>
  765. [HttpPost]
  766. public SRes<int> Unbounding(UnboundRequest request)
  767. {
  768. return _hJService.Unbounding(request);
  769. }
  770. #region pda出库
  771. /// <summary>
  772. /// pda指定出库确定
  773. /// </summary>
  774. /// <param name="request"></param>
  775. /// <returns></returns>
  776. [HttpPost]
  777. public string PdaManualTask(ManualTaskRequest request)
  778. {
  779. request.BusType = TaskBusType.TaskBusType_HJ_PdaManualOut.GetHashCode().ToString();
  780. return _hJService.ManualTask(request);
  781. }
  782. /// <summary>
  783. /// pda质检领料出库确定
  784. /// </summary>
  785. /// <param name="request"></param>
  786. /// <returns></returns>
  787. [HttpPost]
  788. public string PdaQualityTask(ManualTaskRequest request)
  789. {
  790. request.BusType = TaskBusType.TaskBusType_HJ_QualityOut.GetHashCode().ToString();
  791. return _hJService.ManualTask(request);
  792. }
  793. /// <summary>
  794. /// pda呆滞料出库确定
  795. /// </summary>
  796. /// <param name="request"></param>
  797. /// <returns></returns>
  798. [HttpPost]
  799. public string PdaInactionStockTask(ManualTaskRequest request)
  800. {
  801. request.BusType = TaskBusType.TaskBusType_HJ_DullMaterOut.GetHashCode().ToString();
  802. return _hJService.ManualTask(request);
  803. }
  804. #endregion
  805. /// <summary>
  806. /// pda单据查询
  807. /// </summary>
  808. /// <param name="request"></param>
  809. /// <returns></returns>
  810. [HttpPost]
  811. public string GetDocumentsAll(DocumentsRequest request)
  812. {
  813. return _hJService.GetPageDocumentsList(request).ToCamelCaseString();
  814. }
  815. /// <summary>
  816. /// pda单据明细查询(传单号)
  817. /// </summary>
  818. /// <param name="request"></param>
  819. /// <returns></returns>
  820. [HttpPost]
  821. public string GetDocumentDetails(DocumentsRequest request)
  822. {
  823. return _hJService.GetDocumentDetailListByDocsNo(request).ToCamelCaseString();
  824. }
  825. /// <summary>
  826. /// 获取物料信息,根据RFID
  827. /// </summary>
  828. /// <param name="request"></param>
  829. /// <returns></returns>
  830. [HttpPost]
  831. public SRes<MaterInfo> GetMaterInfoByRfid(PdaRfidRequest request)
  832. {
  833. return _hJService.MaterInfoByRfid(request);
  834. }
  835. /// <summary>
  836. /// 提交(组盘)
  837. /// </summary>
  838. /// <param name="request"></param>
  839. /// <returns></returns>
  840. [HttpPost]
  841. public string PdaGroupStock(PdaRfidRequest request)
  842. {
  843. lock (lockerStockInfo)
  844. {
  845. return _hJService.PdaGroupStock(request);
  846. }
  847. }
  848. /// <summary>
  849. /// pda 下发任务
  850. /// </summary>
  851. /// <param name="request"></param>
  852. /// <returns></returns>
  853. [HttpPost]
  854. public string PdaInsterInTask(PdaRfidRequest request)
  855. {
  856. lock (lockerPdaTaskInfo)
  857. {
  858. return _hJService.PdaInsertTask(request);
  859. }
  860. }
  861. /// <summary>
  862. /// 获取设备报警信息
  863. /// </summary>
  864. /// <param name="request"></param>
  865. /// <returns></returns>
  866. [HttpPost]
  867. public string GetEquipErrorInfo(ErrorInfoRequest request)
  868. {
  869. var it = RedisHelper.Get("equoneRGV3");
  870. return it;
  871. }
  872. /// <summary>
  873. /// 获取物料报警信息
  874. /// </summary>
  875. /// <param name="request"></param>
  876. /// <returns></returns>
  877. [HttpPost]
  878. public string GetMaterErrorInfo(ErrorInfoRequest request)
  879. {
  880. return "";
  881. }
  882. /// <summary>
  883. /// 获取业务报警信息
  884. /// </summary>
  885. /// <param name="request"></param>
  886. /// <returns></returns>
  887. [HttpPost]
  888. public string GetBusinessErrorInfo(ErrorInfoRequest request)
  889. {
  890. return "";
  891. }
  892. /// <summary>
  893. /// agv空轮搬运任务(一楼空轮初始化)
  894. /// </summary>
  895. /// <param name="request"></param>
  896. /// <returns></returns>
  897. [HttpPost]
  898. public string AgvTaskInfo(AgvTaskInfoRequest request)
  899. {
  900. return _hJService.AgvCarryTaskInfo(request);
  901. }
  902. #endregion
  903. /// <summary>
  904. /// 取消/完成任务验证(只验证不做业务处理,开放wcs系统调用)
  905. /// </summary>
  906. /// <param name="request"></param>
  907. /// <returns></returns>
  908. [HttpPost]
  909. public SRes CancelTaskVerify(CancelTaskRequest request)
  910. {
  911. lock (lockerCancelOrComplet)
  912. {
  913. return _hJService.CancelTaskVerify(request);
  914. }
  915. }
  916. /// <summary>
  917. /// 执行任务(开放wcs调用,前端不调用)
  918. /// </summary>
  919. /// <param name="request"></param>
  920. /// <returns></returns>
  921. [HttpPost]
  922. public SRes CarryTaskInfo(CancelTaskRequest request)
  923. {
  924. lock (lockerCarryTask)
  925. {
  926. return _hJService.CarryTaskInfo(request);
  927. }
  928. }
  929. /// <summary>du
  930. /// 异常任务的库存处理
  931. /// </summary>
  932. /// <returns></returns>
  933. [HttpPost]
  934. public SRes GetErrorTaskInfo()
  935. {
  936. var res = new SRes();
  937. //获取货位锁是出库锁,当前时间差大于等于1
  938. var list = _hJService.GetOutStateList();
  939. //根据条码捞取历史任务表中的数据
  940. var barcode = list.Select(p => p.ContGrpBarCode).ToList();
  941. var task = _hJService.GetTaskHistoryByCode(barcode);
  942. if (task.Any())
  943. {
  944. foreach (var item in task)
  945. {
  946. if (item.Type != TaskType.OutDepot)
  947. {
  948. continue;
  949. }
  950. if (item.Status != dto.TaskStatus.Finish)
  951. {
  952. continue;
  953. }
  954. var info = CompleteTask(new CompleteTaskRequest() { TaskNum = item.ID, OperationType = 2, WCSUpdateName = "wcs" });
  955. if (info.ResCode != ResponseStatusCodeEnum.Sucess.GetHashCode())
  956. {
  957. res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
  958. res.ResMsg = ResponseStatusCodeEnum.Fail.GetDescription();
  959. return res;
  960. }
  961. }
  962. }
  963. return res;
  964. }
  965. #region 推送数据
  966. /// <summary>
  967. /// 数据推送接口
  968. /// </summary>
  969. /// <param name="request"></param>
  970. /// <returns></returns>
  971. [HttpPost]
  972. public PushResponse PushErpDate(PushDate request)
  973. {
  974. var result = new PushResponse();
  975. if (request.init == 1)
  976. {
  977. //手动推送
  978. if (!request.CLBarCode.Any())
  979. {
  980. result.ResCode = ResponseStatusCodeEnum.ErrParam.GetHashCode();
  981. result.ResMsg = ResponseStatusCodeEnum.ErrParam.GetDescription();
  982. return result;
  983. }
  984. var list = _hJService.GetPushDatelistMannel(request);
  985. if (!list.Any())
  986. {
  987. result.ResCode = ResponseStatusCodeEnum.NoResult.GetHashCode();
  988. result.ResMsg = ResponseStatusCodeEnum.NoResult.GetDescription();
  989. return result;
  990. }
  991. if (list.Where(p => p.TypeCode == FackbeekType.InterfaceType_HJ_1F_StockIn.ToString()).ToList().Any())
  992. {
  993. PushRequest push = new PushRequest();
  994. var onefloor = list.Where(p => p.TypeCode == FackbeekType.InterfaceType_HJ_1F_StockIn.ToString()).ToList();
  995. var info = _mapper.Map<List<ListInfo>>(onefloor);
  996. push.list = info;
  997. var resbody = JsonConvert.DeserializeObject<PushResponse>(WmsServiceExportApi(push));
  998. var matBarCode = info.Select(p => p.MatBarCode).ToList();
  999. if (resbody.success == true)
  1000. {
  1001. _hJService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  1002. {
  1003. Columns = it => new BillPushinfo { PostResult = 1, PostQty = it.PostQty + 1, ResDesc = "手动推送成功", EditTime = DateTime.Now },
  1004. WhereExpression = it => matBarCode.Contains(it.CLBarCode)
  1005. });
  1006. }
  1007. else
  1008. {
  1009. _hJService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  1010. {
  1011. Columns = it => new BillPushinfo { PostResult = 2, PostQty = it.PostQty + 1, ResDesc = "手动推送失败", EditTime = DateTime.Now },
  1012. WhereExpression = it => matBarCode.Contains(it.CLBarCode)
  1013. });
  1014. }
  1015. }
  1016. //退料
  1017. //if (list.Where(p => p.TypeCode == FackbeekType.InterfaceType_HJ_2F_BackStockIn.ToString()).ToList().Any())
  1018. //{
  1019. // WetLineBackInFeedBackRequest wetLineBack = new WetLineBackInFeedBackRequest();
  1020. // var back = _mapper.Map<List<WetLineBackInFeedBackRequestItem>>(list);
  1021. // back.ForEach(p =>
  1022. // {
  1023. // p.BusType = "1";
  1024. // p.WareName = "合金库";
  1025. // });
  1026. // wetLineBack.ListInfo = back;
  1027. // var resbody = JsonConvert.DeserializeObject<WetLineBackInFeedBackResponse>(WmsServiceExportApi(wetLineBack));
  1028. // var rfid = back.Select(p => p.RFID).ToList();
  1029. // if (resbody.ResCode == ResponseStatusCodeEnum.Sucess.GetHashCode())
  1030. // {
  1031. // _hJService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  1032. // {
  1033. // Columns = it => new BillPushinfo { PostResult = 1, PostQty = it.PostQty + 1, ResDesc = "手动推送" },
  1034. // WhereExpression = it => rfid.Contains(it.RFIDBarCode)
  1035. // });
  1036. // }
  1037. // else
  1038. // {
  1039. // _hJService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  1040. // {
  1041. // Columns = it => new BillPushinfo { PostResult = 2, PostQty = it.PostQty + 1 },
  1042. // WhereExpression = it => rfid.Contains(it.RFIDBarCode)
  1043. // });
  1044. // }
  1045. //}
  1046. ////余料
  1047. //if (list.Where(p => p.TypeCode == FackbeekType.InterfaceType_HJ_2F_LeftStockIn.ToString()).ToList().Any())
  1048. //{
  1049. // WetLineBackInFeedBackRequest wetLineBack = new WetLineBackInFeedBackRequest();
  1050. // var back = _mapper.Map<List<WetLineBackInFeedBackRequestItem>>(list);
  1051. // back.ForEach(p =>
  1052. // {
  1053. // p.BusType = "2";
  1054. // p.WareName = "合金库";
  1055. // });
  1056. // wetLineBack.ListInfo = back;
  1057. // var resbody = JsonConvert.DeserializeObject<WetLineBackInFeedBackResponse>(WmsServiceExportApi(wetLineBack));
  1058. // var rfid = back.Select(p => p.RFID).ToList();
  1059. // if (resbody.ResCode == ResponseStatusCodeEnum.Sucess.GetHashCode())
  1060. // {
  1061. // _hJService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  1062. // {
  1063. // Columns = it => new BillPushinfo { PostResult = 1, PostQty = it.PostQty + 1, ResDesc = "手动推送" },
  1064. // WhereExpression = it => rfid.Contains(it.RFIDBarCode)
  1065. // });
  1066. // }
  1067. // else
  1068. // {
  1069. // _hJService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  1070. // {
  1071. // Columns = it => new BillPushinfo { PostResult = 2, PostQty = it.PostQty + 1 },
  1072. // WhereExpression = it => rfid.Contains(it.RFIDBarCode)
  1073. // });
  1074. // }
  1075. //}
  1076. }
  1077. else
  1078. {
  1079. //自动推送
  1080. var list = _hJService.GetPushDatelistAuto(request);
  1081. if (!list.Any())
  1082. {
  1083. return new PushResponse() { ResCode = ResponseStatusCodeEnum.NoResult.GetHashCode(), ResMsg = ResponseStatusCodeEnum.NoResult.GetDescription() };
  1084. }
  1085. if (list.Where(p => p.TypeCode == FackbeekType.InterfaceType_HJ_1F_StockIn.ToString()).ToList().Any())
  1086. {
  1087. var onefloor = list.Where(p => p.TypeCode == FackbeekType.InterfaceType_HJ_1F_StockIn.ToString()).ToList();
  1088. PushRequest push = new PushRequest();
  1089. var info = _mapper.Map<List<ListInfo>>(onefloor);
  1090. push.list = info;
  1091. var resbody = JsonConvert.DeserializeObject<PushResponse>(WmsServiceExportApi(push));
  1092. var matBarCode = info.Select(p => p.MatBarCode).ToList();
  1093. if (resbody.success == true)
  1094. {
  1095. _hJService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  1096. {
  1097. Columns = it => new BillPushinfo { PostResult = 1, PostQty = it.PostQty + 1, ResDesc = "自动推送" ,EditTime = DateTime.Now},
  1098. WhereExpression = it => matBarCode.Contains(it.CLBarCode)
  1099. });
  1100. }
  1101. else
  1102. {
  1103. _hJService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  1104. {
  1105. Columns = it => new BillPushinfo { PostResult = 2, PostQty = it.PostQty + 1, EditTime = DateTime.Now },
  1106. WhereExpression = it => matBarCode.Contains(it.CLBarCode)
  1107. });
  1108. }
  1109. }
  1110. //退料
  1111. //if (list.Where(p => p.TypeCode == FackbeekType.InterfaceType_HJ_2F_BackStockIn.ToString()).ToList().Any())
  1112. //{
  1113. // WetLineBackInFeedBackRequest wetLineBack = new WetLineBackInFeedBackRequest();
  1114. // var back = _mapper.Map<List<WetLineBackInFeedBackRequestItem>>(list);
  1115. // back.ForEach(p =>
  1116. // {
  1117. // p.BusType = "1";
  1118. // p.WareName = "合金库";
  1119. // });
  1120. // wetLineBack.ListInfo = back;
  1121. // var resbody = JsonConvert.DeserializeObject<WetLineBackInFeedBackResponse>(WmsServiceExportApi(wetLineBack));
  1122. // var rfid = back.Select(p => p.RFID).ToList();
  1123. // if (resbody.ResCode == ResponseStatusCodeEnum.Sucess.GetHashCode())
  1124. // {
  1125. // _hJService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  1126. // {
  1127. // Columns = it => new BillPushinfo { PostResult = 1, PostQty = it.PostQty + 1, ResDesc = "自动推送" },
  1128. // WhereExpression = it => rfid.Contains(it.RFIDBarCode)
  1129. // });
  1130. // }
  1131. // else
  1132. // {
  1133. // _hJService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  1134. // {
  1135. // Columns = it => new BillPushinfo { PostResult = 2, PostQty = it.PostQty + 1 },
  1136. // WhereExpression = it => rfid.Contains(it.RFIDBarCode)
  1137. // });
  1138. // }
  1139. //}
  1140. ////余料
  1141. //if (list.Where(p => p.TypeCode == FackbeekType.InterfaceType_HJ_2F_LeftStockIn.ToString()).ToList().Any())
  1142. //{
  1143. // WetLineBackInFeedBackRequest wetLineBack = new WetLineBackInFeedBackRequest();
  1144. // var back = _mapper.Map<List<WetLineBackInFeedBackRequestItem>>(list);
  1145. // back.ForEach(p =>
  1146. // {
  1147. // p.BusType = "2";
  1148. // p.WareName = "合金库";
  1149. // });
  1150. // wetLineBack.ListInfo = back;
  1151. // var resbody = JsonConvert.DeserializeObject<WetLineBackInFeedBackResponse>(WmsServiceExportApi(wetLineBack));
  1152. // var rfid = back.Select(p => p.RFID).ToList();
  1153. // if (resbody.ResCode == ResponseStatusCodeEnum.Sucess.GetHashCode())
  1154. // {
  1155. // _hJService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  1156. // {
  1157. // Columns = it => new BillPushinfo { PostResult = 1, PostQty = it.PostQty + 1, ResDesc = "自动推送" },
  1158. // WhereExpression = it => rfid.Contains(it.RFIDBarCode)
  1159. // });
  1160. // }
  1161. // else
  1162. // {
  1163. // _hJService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  1164. // {
  1165. // Columns = it => new BillPushinfo { PostResult = 2, PostQty = it.PostQty + 1 },
  1166. // WhereExpression = it => rfid.Contains(it.RFIDBarCode)
  1167. // });
  1168. // }
  1169. //}
  1170. }
  1171. return result;
  1172. }
  1173. #endregion
  1174. #region 异常处理
  1175. /// <summary>
  1176. /// 强制取消任务
  1177. /// </summary>
  1178. /// <param name="request"></param>
  1179. /// <returns></returns>
  1180. [HttpPost]
  1181. public SRes ForceCancelTask(WebErrorRequest request)
  1182. {
  1183. return _hJService.ForceCancelTask(request);
  1184. }
  1185. /// <summary>
  1186. /// 删除库存信息
  1187. /// </summary>
  1188. /// <param name="request"></param>
  1189. /// <returns></returns>
  1190. [HttpPost]
  1191. public SRes DeleteStockInfo(DetailCodeRequest request)
  1192. {
  1193. return _hJService.DeleteStockInfo(request);
  1194. }
  1195. /// <summary>
  1196. /// 修改库存状态
  1197. /// </summary>
  1198. /// <param name="request"></param>
  1199. /// <returns></returns>
  1200. [HttpPost]
  1201. public SRes UpdateStockState(DetailCodeRequestdto request)
  1202. {
  1203. return _hJService.UpdateStockState(request);
  1204. }
  1205. /// <summary>
  1206. /// 修改货位状态
  1207. /// </summary>
  1208. /// <param name="request"></param>
  1209. /// <returns></returns>
  1210. [HttpPost]
  1211. public SRes UpdateCellState(DetailCodeRequestdto request)
  1212. {
  1213. return _hJService.UpdateCellState(request);
  1214. }
  1215. /// <summary>
  1216. /// 货位数据互换
  1217. /// </summary>
  1218. /// <param name="request"></param>
  1219. /// <returns></returns>
  1220. [HttpPost]
  1221. public SRes DataSwapCell(DataSwapCellRequest request)
  1222. {
  1223. return _hJService.DataSwapCell(request);
  1224. }
  1225. /// <summary>
  1226. /// 补数据
  1227. /// </summary>
  1228. /// <param name="request"></param>
  1229. /// <returns></returns>
  1230. [HttpPost]
  1231. public SRes DataBasePatch(DetailCodeRequest request)
  1232. {
  1233. return _hJService.DataBasePatch(request);
  1234. }
  1235. #endregion
  1236. }
  1237. }