FjController.cs 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. using AutoMapper;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Newtonsoft.Json;
  4. using SqlSugar;
  5. using WCS.Entity.fj;
  6. using wms.api.Job;
  7. using wms.dto;
  8. using wms.dto.request.fj;
  9. using wms.dto.request.hj;
  10. using wms.dto.request.hj.dto;
  11. using wms.dto.request.share;
  12. using wms.dto.response;
  13. using wms.dto.response.fj;
  14. using wms.service.IService;
  15. using wms.service.Service;
  16. using wms.sqlsugar.model.fj;
  17. using wms.util.Check;
  18. using wms.util.Ext;
  19. using wms.util.Http;
  20. namespace wms.api.Controllers
  21. {
  22. /// <summary>
  23. /// 分拣库控制器
  24. /// </summary>
  25. [Route("api/[controller]/[action]")]
  26. [ApiController]
  27. public class FjController : BaseController
  28. {
  29. /// <summary>
  30. /// 分拣服务 逻辑类
  31. /// </summary>
  32. private readonly IFJService _fjService;
  33. /// <summary>
  34. /// 日志
  35. /// </summary>
  36. private readonly ILogger<FjController> _logger;
  37. /// <summary>
  38. /// 映射器
  39. /// </summary>
  40. private readonly IMapper _mapper;
  41. #region 锁
  42. private static object lockerCurtainProductionOrder = new object();
  43. private static object lockerCurtainOrderStartCheck = new object();
  44. private static object lockerFjEditorialFlow = new object();
  45. private static object lockerSpoolMaterialInfoTrans = new object();
  46. private static object lockerCurtainProductionStockOut = new object();
  47. private static object lockerCurtainProductionStockOut1 = new object();
  48. private static object lockerProductionBack = new object();
  49. private static object lockerCreateMaterialPalletWarehouTask = new object();
  50. private static object lockerCreateMaterialPalletWarehouTask1 = new object();
  51. private static object lockerErrorMaterialStockOut = new object();
  52. private static object lockerBGradeMaterialStockOut = new object();
  53. private static object lockerlockerStockChange = new object();
  54. private static object lockerWetFormulaInfo = new object();
  55. private static object lockerManualBuildEmptyStock = new object();
  56. /// <summary>
  57. /// 人工组盘传输接口
  58. /// </summary>
  59. private static object lockerManualBuildStockTrans = new object();
  60. /// <summary>
  61. /// 一层工人创建创建空托盘库存
  62. /// </summary>
  63. private static object lockOneFloorWorkerBuildEmptyPalletsStock = new object();
  64. /// <summary>
  65. ///
  66. /// </summary>
  67. private static object lockGroupTask = new object();
  68. // <summary>
  69. ///
  70. /// </summary>
  71. private static object lockBingPallet = new object();
  72. // <summary>
  73. ///
  74. /// </summary>
  75. private static object lockGetTwoPallet = new object();
  76. /// <summary>
  77. /// 申请货位
  78. /// </summary>
  79. private static object lockApplyStockInLoc = new object();
  80. /// <summary>
  81. /// 完成任务
  82. /// </summary>
  83. private static object lockerCompleteTask = new object();
  84. /// <summary>
  85. /// 取消任务
  86. /// </summary>
  87. private static object lockerCancelTask = new object();
  88. /// <summary>
  89. /// 手动出库任务
  90. /// </summary>
  91. private static object lockManualTask = new object();
  92. /// <summary>
  93. /// 空托盘组申请出库
  94. /// </summary>
  95. private static object lockApplyEmptyPalletGroupOutStorage = new object();
  96. /// <summary>
  97. /// 组盘工字轮创建异常任务
  98. /// </summary>
  99. private static object palletizingCreateseErrorTasks = new object();
  100. /// <summary>
  101. /// 空托盘组申请出库
  102. /// </summary>
  103. private static object lockRingApplyStockInLoc = new object();
  104. /// <summary>
  105. /// 环形库请求码垛出库任务
  106. /// </summary>
  107. private static object lockApplyPalletizingStockOut = new object();
  108. /// <summary>
  109. /// 堆垛机从出库完成
  110. /// </summary>
  111. private static object lockerSrmPickOutCompleted = new object();
  112. private static object lockerBomInfoTrans = new object();
  113. private static object lockFJEnteMainLineRequest = new object();
  114. private static object lockAllocatedSpoolFlow = new object();
  115. #endregion 锁
  116. /// <summary>
  117. /// 分拣控制器构造函数
  118. /// </summary>
  119. /// <param name="fjService">分拣服务 逻辑类</param>
  120. /// <param name="logger">日志</param>
  121. /// <param name="mapper">映射器</param>
  122. public FjController(IFJService fjService, ILogger<FjController> logger, IMapper mapper) : base(fjService)
  123. {
  124. _fjService = fjService;
  125. _logger = logger;
  126. _mapper = mapper;
  127. }
  128. #region 暂时不用
  129. /// <summary>
  130. /// 同步物料基础信息
  131. /// </summary>
  132. /// <param name="reqDto"></param>
  133. /// <returns></returns>
  134. //[HttpPost]
  135. //public string SyncMaterInfo(SyncMaterInfoRequest reqBody)
  136. //{
  137. // var result = new SRes();
  138. // //_logger.LogInformation("请求参数:{@reqBody},{aa}", reqBody,1);
  139. // FJSyncMaterInfoResponse resbody = JsonConvert.DeserializeObject<FJSyncMaterInfoResponse>(WmsServiceExportApi(reqBody));
  140. // if (reqBody.SyncType == 1)
  141. // {
  142. // reqBody.PageIndex = 1;
  143. // while (resbody.ResData !=null && resbody.ResData.Any())
  144. // {
  145. // _fjService.SyncMaterInfo(resbody.ResData);
  146. // reqBody.PageIndex++;
  147. // resbody = JsonConvert.DeserializeObject<FJSyncMaterInfoResponse>(WmsServiceExportApi(reqBody));
  148. // }
  149. // }
  150. // else if (reqBody.SyncType == 2)
  151. // {
  152. // //拿到增量
  153. // var increconf = _fjService.GetSysConfigByCode(Const.MESMaterialInitIncrement);
  154. // if (increconf != null)
  155. // {
  156. // reqBody.StartTime = DateTime.Parse(increconf.SContent);
  157. // //reqBody.Count = int.Parse(increconf.Remark);
  158. // resbody = JsonConvert.DeserializeObject<FJSyncMaterInfoResponse>(WmsServiceExportApi(reqBody));
  159. // if (resbody.ResData.Any())
  160. // {
  161. // if (_fjService.SyncMaterInfo(resbody.ResData))
  162. // {
  163. // var lastdata = resbody.ResData.OrderBy(p => p.UpdatedTime).Last();
  164. // _fjService.UpdateSysConfigModelColumns(new sqlsugar.model.UpdateModelColumns<fjSysConfig>()
  165. // {
  166. // Columns = it => new fjSysConfig { SContent = lastdata.UpdatedTime.ToString("yyyy-MM-dd HH:mm:ss.fff") },
  167. // WhereExpression = it => it.Code == Const.MESMaterialInitIncrement
  168. // });
  169. // }
  170. // }
  171. // else
  172. // {
  173. // result.ResCode = ResponseStatusCodeEnum.NoResult.GetHashCode();
  174. // result.ResMsg = ResponseStatusCodeEnum.NoResult.GetDescription();
  175. // }
  176. // }
  177. // else
  178. // {
  179. // result.ResCode = ResponseStatusCodeEnum.AccountError.GetHashCode();
  180. // result.ResMsg = "没有配置信息" + Const.MESMaterialInitIncrement;
  181. // }
  182. // }
  183. // else
  184. // {
  185. // if (!string.IsNullOrEmpty(reqBody.MatCode))
  186. // {
  187. // resbody = JsonConvert.DeserializeObject<FJSyncMaterInfoResponse>(WmsServiceExportApi(reqBody));
  188. // if (resbody.ResData.Any())
  189. // {
  190. // if (_fjService.SyncMaterInfo(resbody.ResData))
  191. // {
  192. // }
  193. // }
  194. // }
  195. // }
  196. // return result.ToCamelCaseString();
  197. //}
  198. /// <summary>
  199. /// BOM信息传输接口
  200. /// </summary>
  201. /// <param name="reqDto"></param>
  202. /// <returns></returns>
  203. //[HttpPost]
  204. //public SRes BomInfoTrans(BomInfoTransRequest reqDto)
  205. //{
  206. // return ConcurrencyReqControl<BomInfoTransRequest, SRes>(lockerBomInfoTrans, "BomInfoTrans" + reqDto.BomCode, reqDto.BomCode, reqDto, _fjService.BomInfoTrans);
  207. //}
  208. #endregion 暂时不用
  209. /// <summary>
  210. /// 创建货位,用于少数虚拟货位及平库
  211. /// </summary>
  212. /// <param name="WarehouseCode">仓库号</param>
  213. /// <param name="Code">货位号</param>
  214. /// <returns></returns>
  215. [HttpPost]
  216. public SRes CreatWarecell(string WarehouseCode, string Code)
  217. {
  218. return _fjService.CreatWarecell(WarehouseCode, Code);
  219. }
  220. /// <summary>
  221. /// 物料主数据推送接口(湿拉)
  222. /// </summary>
  223. /// <param name="reqBody"></param>
  224. /// <returns></returns>
  225. [HttpPost]
  226. public SRes SyncMaterInfoList(FJSyncMaterInfoListRequest reqBody)
  227. {
  228. var res = new SRes();
  229. if (reqBody.ListInfo == null || !reqBody.ListInfo.Any())
  230. {
  231. res.ResCode = ResponseStatusCodeEnum.DocDetailNotExist.GetHashCode();
  232. res.ResMsg = ResponseStatusCodeEnum.DocDetailNotExist.GetDescription();
  233. return res;
  234. }
  235. _fjService.SyncMaterInfo(_mapper.Map<List<FJSyncMaterInfoResponseItem>>(reqBody.ListInfo));
  236. return res;
  237. }
  238. /// <summary>
  239. /// 物料主数据推送接口(帘线)
  240. /// </summary>
  241. /// <param name="reqBody"></param>
  242. /// <returns></returns>
  243. [HttpPost]
  244. public SRes SyncMaterInfoListForLX(SxSyncMaterInfoListRequest reqBody)
  245. {
  246. var res = new SRes();
  247. if (reqBody.ListInfo == null || !reqBody.ListInfo.Any())
  248. {
  249. res.ResCode = ResponseStatusCodeEnum.DocDetailNotExist.GetHashCode();
  250. res.ResMsg = ResponseStatusCodeEnum.DocDetailNotExist.GetDescription();
  251. return res;
  252. }
  253. _fjService.SyncMaterInfoLX(reqBody.ListInfo);
  254. return res;
  255. }
  256. /// <summary>
  257. /// 机台信息同步接口
  258. /// </summary>
  259. /// <param name=""></param>
  260. /// <returns></returns>
  261. [HttpPost(Name = "SyncMachineInfo")]
  262. public SRes SyncMachineInfo(SyncMachineInfoRequest reqDto)
  263. {
  264. //SyncMachineInfoResponse resbody = JsonConvert.DeserializeObject<SyncMachineInfoResponse>(WmsServiceExportApi(reqDto));
  265. //if (resbody.ResCode == ResponseStatusCodeEnum.Sucess.GetHashCode() && resbody.ResData != null && resbody.ResData.Any())
  266. //{
  267. return _fjService.SyncMachineInfo(reqDto);
  268. //}
  269. }
  270. /// <summary>
  271. /// 创建芯股用空托入库任务
  272. /// </summary>
  273. /// <returns></returns>
  274. [HttpPost(Name = "CreateCoreStrandEmptyPalletEnterWarehouse")]
  275. public void CreateCoreStrandEmptyPalletEnterWarehouse()
  276. {
  277. _fjService.CreateCoreStrandEmptyPalletEnterWarehouse();
  278. }
  279. /// <summary>
  280. /// 创建芯股站台用的空托出库任务
  281. /// </summary>
  282. /// <returns></returns>
  283. [HttpPost(Name = "CoreStrandSupportReplenishEmptyPallet")]
  284. public SRes CoreStrandSupportReplenishEmptyPallet()
  285. {
  286. return _fjService.CoreStrandSupportReplenishEmptyPallet();
  287. }
  288. /// <summary>
  289. /// 投料信息同步接口
  290. /// </summary>
  291. /// <param name=""></param>
  292. /// <returns></returns>
  293. [HttpPost(Name = "WetFormulaInfo")]
  294. public SRes WetFormulaInfo(WetFormulaInfoRequest reqDto)
  295. {
  296. return ConcurrencyReqControl<WetFormulaInfoRequest, SRes>(lockerWetFormulaInfo, "WetFormulaInfo", reqDto.FeedCode, reqDto, _fjService.WetFormulaInfo);
  297. }
  298. /// <summary>
  299. /// 帘线生产工单信息传输接口
  300. /// </summary>
  301. /// <param name="reqDto"></param>
  302. /// <returns></returns>
  303. [HttpPost]
  304. public SRes CurtainProductionOrder(CurtainProductionOrderRequest reqDto)
  305. {
  306. var res = ConcurrencyReqControl<CurtainProductionOrderRequest, SRes>(lockerCurtainProductionOrder, "CurtainProductionOrder", reqDto.BillCode, reqDto, _fjService.CurtainProductionOrder);
  307. try
  308. {
  309. HttpUtil.PostRequest("http://10.30.44.3:8011/api/sx/CurtainProductionOrder", JsonConvert.SerializeObject(reqDto), 30000, "UTF-8", "application/json");
  310. }
  311. catch (Exception ex)
  312. {
  313. _logger.LogInformation("调用时效工单异常" + ex.ToString());
  314. }
  315. return res;
  316. }
  317. /// <summary>
  318. /// 湿拉工单启动验证
  319. /// </summary>
  320. /// <param name="reqDto"></param>
  321. /// <returns></returns>
  322. [HttpPost]
  323. public SRes CurtainOrderStartCheck(CurtainOrderStartCheckRequest reqDto)
  324. {
  325. return ConcurrencyReqControl<CurtainOrderStartCheckRequest, SRes>(lockerCurtainOrderStartCheck, "CurtainOrderStartCheck", reqDto.BillCode, reqDto, _fjService.CurtainOrderStartCheck);
  326. }
  327. /// <summary>
  328. /// 变更流向
  329. /// </summary>
  330. /// <param name="reqDto"></param>
  331. /// <returns></returns>
  332. [HttpPost]
  333. public SRes EditorialFlow(FjEditorialFlowRequest reqDto)
  334. {
  335. return ConcurrencyReqControl<FjEditorialFlowRequest, SRes>(lockerFjEditorialFlow, "EditorialFlow", reqDto.LocCode, reqDto, _fjService.EditorialFlow);
  336. }
  337. /// <summary>
  338. /// 湿拉工字轮/芯股信息传输接口
  339. /// </summary>
  340. /// <param name="reqDto"></param>
  341. /// <returns></returns>
  342. [HttpPost]
  343. public SRes SpoolMaterialInfoTrans(SpoolMaterialInfoTransRequest reqDto)
  344. {
  345. return ConcurrencyReqControl<SpoolMaterialInfoTransRequest, SRes>(lockerSpoolMaterialInfoTrans, "SpoolMaterialInfoTrans", reqDto.SpoolCode, reqDto, _fjService.SpoolMaterialInfoTrans);
  346. }
  347. /// <summary>
  348. /// AGV上报状态变更接口
  349. /// </summary>
  350. /// <param name="reqDto"></param>
  351. /// <returns></returns>
  352. [HttpPost]
  353. public AgvCallbackResponse AgvCallback(AgvCallbackRequest reqDto)
  354. {
  355. return _fjService.AgvCallback(reqDto);
  356. //return ConcurrencyReqControl<SpoolMaterialInfoTransRequest, SRes>(lockerSpoolMaterialInfoTrans, "SpoolMaterialInfoTrans", reqDto.SpoolCode, reqDto, _fjService.SpoolMaterialInfoTrans);
  357. }
  358. /// <summary>
  359. /// 获取工字轮流向(江锦调用)
  360. /// </summary>
  361. /// <param name="reqDto"></param>
  362. /// <returns></returns>
  363. [HttpPost]
  364. public SRes<string> AllocatedSpoolFlow(AllocatedSpoolFlowRequest reqDto)
  365. {
  366. //return ConcurrencyReqControl<AllocatedSpoolFlowRequest, SRes<string>>(lockAllocatedSpoolFlow, "AllocatedSpoolFlow", reqDto.SpoolBarCode, reqDto, _fjService.AllocatedSpoolFlow);
  367. return _fjService.AllocatedSpoolFlow(reqDto);
  368. }
  369. /// <summary>
  370. /// MES获取流向异常信息
  371. /// </summary>
  372. /// <param name="reqDto"></param>
  373. /// <returns></returns>
  374. [HttpPost]
  375. public SRes GetFlowExceptionResults(GetFlowExceptionResultsRequest reqDto)
  376. {
  377. return _fjService.GetFlowExceptionResults(reqDto);
  378. }
  379. private SRes ComPushData(SRes resbody, List<long> ids)
  380. {
  381. var res = new SRes();
  382. try
  383. {
  384. if (resbody.ResCode == ResponseStatusCodeEnum.Sucess.GetHashCode())
  385. {
  386. //更新推送表数据
  387. _fjService.UpdateBillPushinfoModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  388. {
  389. Columns = it => new BillPushinfo { PostResult = 1, PostQty = it.PostQty + 1 },
  390. WhereExpression = it => ids.Contains(it.Id)
  391. });
  392. //删除单据表数据
  393. //_fjService.DeleteDoc(p => doccodelist.Contains(p.DocNo));
  394. }
  395. else
  396. {
  397. //更新推送表数据
  398. _fjService.UpdateBillPushinfoModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  399. {
  400. Columns = it => new BillPushinfo { PostResult = 2, PostQty = it.PostQty + 1 },
  401. WhereExpression = it => ids.Contains(it.Id)
  402. });
  403. }
  404. }
  405. catch (Exception ex)
  406. {
  407. res.ResCode = ResponseStatusCodeEnum.DataSaveErr.GetHashCode();
  408. res.ResMsg = ResponseStatusCodeEnum.DataSaveErr.GetDescription();
  409. _logger.LogInformation("反馈数据推送" + ex.ToString());
  410. }
  411. return res;
  412. }
  413. /// <summary>
  414. /// 湿拉工字轮入库反馈接口
  415. /// </summary>
  416. /// <returns></returns>
  417. [HttpPost(Name = "WetProductStockInFeedBack")]
  418. public SRes WetProductStockInFeedBack()
  419. {
  420. var list = _fjService.GetBillPushinfoList(p => p.PostResult != 1 && p.PostQty <= 5 && p.TypeCode == fjFackbeekType.InterfaceType_FJ_StockIn.ToString());
  421. var dtolist = _mapper.Map<List<WetProductStockInFeedBackRequestItem>>(list);
  422. var dto = new WetProductStockInFeedBackRequest() { ListInfo = dtolist };
  423. SRes resbody = JsonConvert.DeserializeObject<SRes>(WmsServiceExportApi(dto));
  424. return ComPushData(resbody, list.Select(p => p.Id).ToList());
  425. }
  426. /// <summary>
  427. /// 数据推送接口
  428. /// </summary>
  429. /// <param name="request"></param>
  430. /// <returns></returns>
  431. [HttpPost]
  432. public PushResponse FJPushErpDate(PushDate request)
  433. {
  434. var result = new PushResponse();
  435. //自动推送
  436. request.Type = FackbeekType.InterfaceType_HJ_1F_StockIn.ToString();
  437. var onefloor = _fjService.GetBillPushinfoList(p => p.PostResult != 1 && p.PostQty <= 5 && p.TypeCode == fjFackbeekType.InterfaceType_FJ_StockIn.ToString(), true);
  438. foreach (var item in onefloor.GroupBy(p => p.RFIDBarCode))
  439. {
  440. PushRequest push = new PushRequest() { ListInfo = new List<ListInfoInfo>() };
  441. push.WareCode = "fjhouse";
  442. push.WareName = "分拣库";
  443. push.LocCode = item.First().WareCellCode;
  444. push.TrayCode = "TPB";
  445. push.TrayType = "TPB";
  446. push.ListInfo = item.Select(q => new ListInfoInfo() { MatBarCode = q.CLBarCode, SpoolCode = q.HWBarCode }).ToList();
  447. var resbody = JsonConvert.DeserializeObject<PushResponse>(WmsServiceExportMq(push));
  448. var matBarCode = push.ListInfo.Select(p => p.MatBarCode).ToList();
  449. if (resbody.success == true || resbody.ResCode == 200)
  450. {
  451. _fjService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  452. {
  453. Columns = it => new BillPushinfo { PostResult = 1, PostQty = it.PostQty + 1, ResDesc = "自动推送", EditTime = DateTime.Now },
  454. WhereExpression = it => matBarCode.Contains(it.CLBarCode)
  455. });
  456. }
  457. else
  458. {
  459. _fjService.UpdatePushModelColumns(new sqlsugar.model.UpdateModelColumns<BillPushinfo>()
  460. {
  461. Columns = it => new BillPushinfo { PostResult = 2, PostQty = it.PostQty + 1, EditTime = DateTime.Now, Memo = resbody.ResMsg },
  462. WhereExpression = it => matBarCode.Contains(it.CLBarCode)
  463. });
  464. }
  465. }
  466. return result;
  467. }
  468. /// <summary>
  469. /// 帘线叫料接口
  470. /// </summary>
  471. /// <param name="reqDto"></param>
  472. /// <returns></returns>
  473. [HttpPost(Name = "CurtainProductionStockOut")]
  474. public SRes CurtainProductionStockOut(CurtainProductionStockOutRequest reqDto)
  475. {
  476. return ConcurrencyReqControl<CurtainProductionStockOutRequest, SRes>(lockerCurtainProductionStockOut, "CurtainProductionStockOut" + reqDto.BillCode, reqDto.BillCode, reqDto, _fjService.CurtainProductionStockOut);
  477. }
  478. /// <summary>
  479. /// 帘线叫料接口(人工码垛托盘)
  480. /// </summary>
  481. /// <param name="reqDto"></param>
  482. /// <returns></returns>
  483. [HttpPost(Name = "CurtainProductionStockOut1")]
  484. public SRes CurtainProductionStockOut1(CurtainProductionStockOutRequest1 reqDto)
  485. {
  486. return ConcurrencyReqControl<CurtainProductionStockOutRequest1, SRes>(lockerCurtainProductionStockOut1, "CurtainProductionStockOut1" + reqDto.BillCode, reqDto.BillCode, reqDto, _fjService.CurtainProductionStockOut1);
  487. }
  488. /// <summary>
  489. /// 帘线手动叫料接口
  490. /// </summary>
  491. /// <param name="reqDto"></param>
  492. /// <returns></returns>
  493. [HttpPost(Name = "ManualCurtainProductionStockOut")]
  494. public SRes ManualCurtainProductionStockOut(ManualCurtainProductionStockOut reqDto)
  495. {
  496. return _fjService.ManualCurtainProductionStockOut(reqDto);
  497. }
  498. /// <summary>
  499. /// 人工创建满托入库任务
  500. /// </summary>
  501. /// <param name="reqDto"></param>
  502. /// <returns></returns>
  503. [HttpPost]
  504. public SRes CreateMaterialPalletWarehouTask(CreateMaterialPalletWarehouTaskRequest reqDto)
  505. {
  506. return ConcurrencyReqControl<CreateMaterialPalletWarehouTaskRequest, SRes>(lockerCreateMaterialPalletWarehouTask, "CreateMaterialPalletWarehouTask", reqDto.SpoolNr, reqDto, _fjService.CreateMaterialPalletWarehouTask);
  507. }
  508. /// <summary>
  509. /// 芯股满托创建库存信息
  510. /// </summary>
  511. /// <param name="reqDto"></param>
  512. /// <returns></returns>
  513. [HttpPost]
  514. public SRes CreateMaterialPalletWarehouTask1(CreateMaterialPalletWarehouTask1Request reqDto)
  515. {
  516. return ConcurrencyReqControl<CreateMaterialPalletWarehouTask1Request, SRes>(lockerCreateMaterialPalletWarehouTask1, "CreateMaterialPalletWarehouTask1", reqDto.SpoolNr, reqDto, _fjService.CreateMaterialPalletWarehouTask1);
  517. }
  518. /// <summary>
  519. /// 叫料信息反馈接口
  520. /// </summary>
  521. /// <param name="billcode"></param>
  522. /// <returns></returns>
  523. [HttpPost(Name = "CurtainProductionStockOutFeedBack")]
  524. public SRes CurtainProductionStockOutFeedBack()
  525. {
  526. var list = _fjService.GetBillPushinfoList(p => p.PostResult != 1 && p.PostQty <= 5 && p.TypeCode == fjFackbeekType.InterfaceType_FJ_StockOut.ToString());
  527. var dtolist = _mapper.Map<List<CurtainProductionStockOutFeedBackRequestItem>>(list);
  528. var dto = new CurtainProductionStockOutFeedBackRequest() { ListInfo = dtolist };
  529. SRes resbody = JsonConvert.DeserializeObject<SRes>(WmsServiceExportApi(dto));
  530. return ComPushData(resbody, list.Select(p => p.Id).ToList());
  531. }
  532. /// <summary>
  533. /// 生产退料/余料接口
  534. /// </summary>
  535. /// <param name="reqDto"></param>
  536. /// <returns></returns>
  537. [HttpPost]
  538. public SRes ProductionBack(FjProductionBackRequest reqDto)
  539. {
  540. return ConcurrencyReqControl<FjProductionBackRequest, SRes>(lockerProductionBack, "ProductionBack", reqDto.BillCode, reqDto, _fjService.ProductionBack);
  541. }
  542. /// <summary>
  543. /// 余料反馈接口
  544. /// </summary>
  545. /// <param name="billcode"></param>
  546. /// <returns></returns>
  547. [HttpPost]
  548. public SRes ProductionLeftFeedBack()
  549. {
  550. var list = _fjService.GetBillPushinfoList(p => p.PostResult != 1 && p.PostQty <= 5 && p.TypeCode == fjFackbeekType.InterfaceType_FJ_LeftStockIn.ToString());
  551. var dtolist = _mapper.Map<List<ProductionLeftFeedBackRequestItem>>(list);
  552. var dto = new ProductionLeftFeedBackRequest() { ListInfo = dtolist };
  553. SRes resbody = JsonConvert.DeserializeObject<SRes>(WmsServiceExportApi(dto));
  554. return ComPushData(resbody, list.Select(p => p.Id).ToList());
  555. }
  556. /// <summary>
  557. /// 异常料出库单传输接口
  558. /// </summary>
  559. /// <param name="reqDto"></param>
  560. /// <returns></returns>
  561. [HttpPost]
  562. public SRes ErrorMaterialStockOut(FjErrorMaterialStockOutRequest reqDto)
  563. {
  564. return ConcurrencyReqControl<FjErrorMaterialStockOutRequest, SRes>(lockerErrorMaterialStockOut, "ErrorMaterialStockOut", reqDto.BillCode, reqDto, _fjService.ErrorMaterialStockOut);
  565. }
  566. /// <summary>
  567. /// 异常料出库反馈接口
  568. /// </summary>
  569. /// <param name="billcode"></param>
  570. /// <returns></returns>
  571. [HttpPost]
  572. public SRes ErrorMaterialStockOutFeedBack()
  573. {
  574. var list = _fjService.GetBillPushinfoList(p => p.PostResult != 1 && p.PostQty <= 5 && p.TypeCode == fjFackbeekType.InterfaceType_FJ_ErrStockOut.ToString());
  575. var dtolist = _mapper.Map<List<ErrorMaterialStockOutFeedBackRequestItem>>(list);
  576. var dto = new ErrorMaterialStockOutFeedBackRequest() { ListInfo = dtolist };
  577. SRes resbody = JsonConvert.DeserializeObject<SRes>(WmsServiceExportApi(dto));
  578. return ComPushData(resbody, list.Select(p => p.Id).ToList());
  579. }
  580. /// <summary>
  581. /// B站叫料单传输接口
  582. /// </summary>
  583. /// <param name="reqDto"></param>
  584. /// <returns></returns>
  585. [HttpPost]
  586. public SRes BGradeMaterialStockOut(BGradeMaterialStockOutRequest reqDto)
  587. {
  588. return ConcurrencyReqControl<BGradeMaterialStockOutRequest, SRes>(lockerBGradeMaterialStockOut, "BGradeMaterialStockOut", reqDto.BillCode, reqDto, _fjService.BGradeMaterialStockOut);
  589. }
  590. /// <summary>
  591. /// B站出库反馈接口
  592. /// </summary>
  593. /// <param name="billcode"></param>
  594. /// <returns></returns>
  595. [HttpPost]
  596. public SRes BGradeMaterialStockOutFeedBack()
  597. {
  598. var list = _fjService.GetBillPushinfoList(p => p.PostResult != 1 && p.PostQty <= 5 && p.TypeCode == fjFackbeekType.InterfaceType_FJ_BGradeStockOut.ToString());
  599. var dtolist = _mapper.Map<List<BGradeMaterialStockOutFeedBackRequestItem>>(list);
  600. var dto = new BGradeMaterialStockOutFeedBackRequest() { ListInfo = dtolist };
  601. SRes resbody = JsonConvert.DeserializeObject<SRes>(WmsServiceExportApi(dto));
  602. return ComPushData(resbody, list.Select(p => p.Id).ToList());
  603. }
  604. /// <summary>
  605. /// 库存改判
  606. /// </summary>
  607. /// <param name="reqDto"></param>
  608. /// <returns></returns>
  609. [HttpPost]
  610. public SRes StockChange(FjStockChangeRequest reqDto)
  611. {
  612. return ConcurrencyReqControl<FjStockChangeRequest, SRes>(lockerlockerStockChange, "FJStockChange", reqDto.BillCode, reqDto, _fjService.StockChange);
  613. }
  614. /// <summary>
  615. /// 改判反馈接口
  616. /// </summary>
  617. /// <param name="request"></param>
  618. /// <returns></returns>
  619. [HttpPost]
  620. public SRes StockChangeFeedBack()
  621. {
  622. var list = _fjService.GetBillPushinfoList(p => p.PostResult != 1 && p.PostQty <= 5 && p.TypeCode == fjFackbeekType.InterfaceType_FJ_StockChanage.ToString());
  623. var dtolist = _mapper.Map<List<StockChangeFeedBackRequestItem>>(list);
  624. var dto = new dto.request.fj.StockChangeFeedBackRequest() { ListInfo = dtolist };
  625. SRes resbody = JsonConvert.DeserializeObject<SRes>(WmsServiceExportApi(dto));
  626. return ComPushData(resbody, list.Select(p => p.Id).ToList());
  627. }
  628. /// <summary>
  629. /// 实时库存查询接口
  630. /// </summary>
  631. /// <param name="reqDto"></param>
  632. /// <returns></returns>
  633. [HttpPost(Name = "GetFJCurStockList")]
  634. public GetFJCurStockListResponse GetFJCurStockList(GetFJCurStockListRequest reqDto)
  635. {
  636. return _fjService.GetCurStockList(reqDto);
  637. }
  638. /// <summary>
  639. /// 回库反馈接口(出库途中改判的,入库之后再次上传入库信息)
  640. /// </summary>
  641. /// <param name="request"></param>
  642. /// <returns></returns>
  643. [HttpPost]
  644. public SRes StockChangeStockInFeedBack()
  645. {
  646. var list = _fjService.GetBillPushinfoList(p => p.PostResult != 1 && p.PostQty <= 5 && p.TypeCode == fjFackbeekType.InterfaceType_FJ_ChanageBack.ToString());
  647. var dtolist = _mapper.Map<List<StockChangeStockInFeedBackRequestItem>>(list);
  648. var dto = new StockChangeStockInFeedBackRequest() { ListInfo = dtolist };
  649. SRes resbody = JsonConvert.DeserializeObject<SRes>(WmsServiceExportApi(dto));
  650. return resbody;
  651. }
  652. /// <summary>
  653. /// 人工组盘传输接口
  654. /// </summary>
  655. /// <param name="reqDto"></param>
  656. /// <returns></returns>
  657. [HttpPost]
  658. public SRes ManualBuildStockTrans(ManualBuildStockTransRequest reqDto)
  659. {
  660. return ConcurrencyReqControl<ManualBuildStockTransRequest, SRes>(lockerManualBuildStockTrans, "ManualBuildStockTrans", reqDto.PalletCode, reqDto, _fjService.ManualBuildStockTrans);
  661. }
  662. /// <summary>
  663. /// 条码信息查询接口
  664. /// </summary>
  665. /// <param name="req"></param>
  666. /// <returns></returns>
  667. [HttpPost]
  668. public string GetMesBarCodeInfo(string req)
  669. {
  670. return "";
  671. }
  672. /// <summary>
  673. /// 空托组盘
  674. /// </summary>
  675. /// <param name="reqDto"></param>
  676. /// <returns></returns>
  677. [HttpPost]
  678. public SRes ManualBuildEmptyStock(ManualBuildEmptyStockRequest reqDto)
  679. {
  680. return ConcurrencyReqControl<ManualBuildEmptyStockRequest, SRes>(lockerManualBuildEmptyStock, "ManualBuildEmptyStock", reqDto.ContGrpBarCode, reqDto, _fjService.ManualBuildEmptyStock);
  681. }
  682. #region 一楼入库任务生成接口
  683. /// <summary>
  684. /// 一楼空托盘人工入库任务创建
  685. /// </summary>
  686. /// <param name="reqDto"></param>
  687. /// <returns></returns>
  688. [HttpPost]
  689. public SRes OneFloorWorkerBuildEmptyPalletsStock(FJBuildEmptyPalletsStockRequest reqDto)
  690. {
  691. return ConcurrencyReqControl<FJBuildEmptyPalletsStockRequest, SRes>(lockOneFloorWorkerBuildEmptyPalletsStock, "OneFloorWorkerBuildEmptyPalletsStock", reqDto.StartLoc, reqDto, _fjService.OneFloorWorkerBuildEmptyPalletsStock);
  692. }
  693. #endregion 一楼入库任务生成接口
  694. /// <summary>
  695. /// 生成组盘任务,空托盘
  696. /// </summary>
  697. /// <param name="reqDto"></param>
  698. /// <returns></returns>
  699. [HttpPost]
  700. public SRes GroupTask(FJBuildEmptyPalletsStockDto reqDto)
  701. {
  702. return ConcurrencyReqControl<FJBuildEmptyPalletsStockDto, SRes>(lockGroupTask, "GroupTask", reqDto.StartLoc, reqDto, _fjService.GroupTask);
  703. }
  704. /// <summary>
  705. /// 整托入库
  706. /// </summary>
  707. /// <param name="reqDto"></param>
  708. /// <returns></returns>
  709. [HttpPost]
  710. public SRes BingPallet(FJBingPalletDto reqDto)
  711. {
  712. return ConcurrencyReqControl<FJBingPalletDto, SRes>(lockBingPallet, "BingPallet" + reqDto.loc, reqDto.loc, reqDto, _fjService.BingPallet);
  713. }
  714. /// <summary>
  715. /// 整托入库
  716. /// </summary>
  717. /// <param name="reqDto"></param>
  718. /// <returns></returns>
  719. [HttpPost]
  720. public SRes<int> GetTwoPallet(FJGetTwoPalletDto reqDto)
  721. {
  722. return ConcurrencyReqControl<FJGetTwoPalletDto, SRes<int>>(lockGetTwoPallet, "GetTwoPallet", reqDto.WarehouseCode, reqDto, _fjService.GetTwoPallet);
  723. }
  724. /// <summary>
  725. /// 申请货位
  726. /// </summary>
  727. /// <param name="reqDto"></param>
  728. /// <returns></returns>
  729. [HttpPost]
  730. public SRes ApplyStockInLoc(FJApplyStockInLocRequest reqDto)
  731. {
  732. return ConcurrencyReqControl<FJApplyStockInLocRequest, SRes<FJApplyStockInLocResponse>>(lockApplyStockInLoc, "ApplyStockInLoc" + reqDto.PickUpEquipmentNo, reqDto.PickUpEquipmentNo, reqDto, _fjService.ApplyStockInLoc);
  733. }
  734. /// <summary>
  735. /// 空托出库任务
  736. /// </summary>
  737. /// <param name="reqDto"></param>
  738. /// <returns></returns>
  739. [HttpPost]
  740. public SRes ApplyEmptyPalletGroupOutStorage(FjApplyEmptyPalletGroupOutStorageRequest reqDto)
  741. {
  742. return ConcurrencyReqControl<FjApplyEmptyPalletGroupOutStorageRequest, SRes>(lockApplyEmptyPalletGroupOutStorage, "ApplyEmptyPalletGroupOutStorage", reqDto.AddTo, reqDto, _fjService.ApplyEmptyPalletGroupOutStorage);
  743. }
  744. /// <summary>
  745. /// 获取垛型数组
  746. /// </summary>
  747. /// <param name="req"></param>
  748. /// <returns></returns>
  749. [HttpPost]
  750. public SRes<List<BillBomsetgrp>> FjGetSetGrpList(FjGetSetGrpListRequest req)
  751. {
  752. return _fjService.FjGetSetGrpList(req);
  753. }
  754. /// <summary>
  755. /// 环形库申请货位
  756. /// </summary>
  757. /// <param name="reqDto"></param>
  758. /// <returns></returns>
  759. [HttpPost]
  760. public SRes<FJApplyStockInLocResponse> RingApplyStockInLoc(FJApplyStockInLocRequest reqDto)
  761. {
  762. return ConcurrencyReqControl<FJApplyStockInLocRequest, SRes<FJApplyStockInLocResponse>>(lockRingApplyStockInLoc, "RingApplyStockInLoc" + "Robot", "Robot", reqDto, _fjService.RingApplyStockInLoc);
  763. }
  764. /// <summary>
  765. /// WCS申请码垛出库
  766. /// </summary>
  767. /// <param name="reqDto"></param>
  768. /// <returns></returns>
  769. [HttpPost]
  770. public SRes ApplyPalletizingStockOut(RingApplyPalletizingStockOutRequest reqDto)
  771. {
  772. return ConcurrencyReqControl<RingApplyPalletizingStockOutRequest, SRes>(lockApplyPalletizingStockOut, "ApplyPalletizingStockOut" + reqDto.WareHouseCode, reqDto.WareHouseCode, reqDto, _fjService.ApplyPalletizingStockOut);
  773. }
  774. /// <summary>
  775. /// 手动出库
  776. /// </summary>
  777. /// <param name="request"></param>
  778. /// <returns></returns>
  779. [HttpPost]
  780. public string ManualTask(FJManualTaskRequest request)
  781. {
  782. lock (lockManualTask)
  783. {
  784. return _fjService.ManualTask(request);
  785. }
  786. }
  787. /// <summary>
  788. /// 堆垛机出库放货完成
  789. /// </summary>
  790. /// <param name="reqEntity"></param>
  791. /// <returns></returns>
  792. [HttpPost]
  793. public SRes<int> SrmPickOutCompleted(SrmPickOutCompletedRequest reqDto)
  794. {
  795. lock (lockerSrmPickOutCompleted)
  796. {
  797. return _fjService.SrmPickOutCompleted(reqDto);
  798. }
  799. }
  800. /// <summary>
  801. /// 码垛创建异常任务
  802. /// </summary>
  803. /// <param name="reqEntity"></param>
  804. /// <returns></returns>
  805. [HttpPost]
  806. public SRes PalletizingCreateseErrorTasks(PalletizingCreateseErrorTasksRequest reqDto)
  807. {
  808. return ConcurrencyReqControl<PalletizingCreateseErrorTasksRequest, SRes>(palletizingCreateseErrorTasks, "PalletizingCreateseErrorTasks" + reqDto.EquNo, reqDto.EquNo, reqDto, _fjService.PalletizingCreateseErrorTasks);
  809. }
  810. /// <summary>
  811. /// 获取任务信息
  812. /// </summary>
  813. /// <param name="barCode">条码</param>
  814. /// <returns></returns>
  815. [HttpPost]
  816. public SRes<WCS_TaskOld> GetTaskInfo(FJGetTaskInfoRequest dto)
  817. {
  818. return _fjService.GetTaskInfo(dto);
  819. }
  820. /// <summary>
  821. /// 完成任务
  822. /// </summary>
  823. /// <param name="reqEntity"></param>
  824. /// <returns></returns>
  825. [HttpPost]
  826. public SRes<int> CompleteTask(CompleteTaskRequest reqDto)
  827. {
  828. lock (lockerCompleteTask)
  829. {
  830. return _fjService.CompleteTask(reqDto);
  831. }
  832. }
  833. /// <summary>
  834. /// 取消任务
  835. /// </summary>
  836. /// <param name="reqDto"></param>
  837. /// <returns></returns>
  838. [HttpPost]
  839. public SRes<int> CancelTask(CompleteTaskRequest reqDto)
  840. {
  841. lock (lockerCancelTask)
  842. {
  843. return _fjService.CancelTask(reqDto);
  844. }
  845. }
  846. #region 生成货位基础配置
  847. /// <summary>
  848. /// 分拣自动生成货位信息
  849. /// </summary>
  850. [HttpPost]
  851. public void FJAutoGenerateLocation()
  852. {
  853. //_fjService.FJ1NorthAutoGenerateLocation();
  854. _fjService.FJSouthAutoGenerateLocation();
  855. }
  856. #endregion 生成货位基础配置
  857. #region 生成货位基础配置
  858. /// <summary>
  859. /// 分拣环形库自动生成库位
  860. /// </summary>
  861. [HttpPost]
  862. public void RingLibraryAutoGenerateLocation(string WareCode)
  863. {
  864. _fjService.RingLibraryAutoGenerateLocation(WareCode);
  865. }
  866. #endregion 生成货位基础配置
  867. /// <summary>
  868. /// 工字轮/芯股进入主线扫码
  869. /// </summary>
  870. [HttpPost]
  871. public SRes<SRes> EnteMainLine(FJEnteMainLineRequest reqDto)
  872. {
  873. return ConcurrencyReqControl<FJEnteMainLineRequest, SRes<SRes>>(lockFJEnteMainLineRequest, "EnteMainLine" + reqDto.equNo, reqDto.equNo, reqDto, _fjService.EnteMainLine);
  874. }
  875. [HttpPost]
  876. public string GetId()
  877. {
  878. //var list = _fjService.GetBaseMatinfoList(p => p.Id < 1000);
  879. //foreach (var item in list)
  880. //{
  881. // var id = IdFactory.NewId();
  882. // //var tempid = item.Id;
  883. // item.WarehouseId = id;
  884. // _fjService.UpdateMaterModel(item);
  885. //}
  886. return IdFactory.NewId().ToString();
  887. }
  888. #region 定时器
  889. [HttpPost]
  890. public string StartJob(DetailRequest2Str req)
  891. {
  892. var res = new SRes();
  893. var sysjob = _fjService.GetSysJobEntity(new DetailRequest2Str() { Id = req.Id });
  894. if (sysjob == null)
  895. {
  896. res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
  897. res.ResMsg = "没有找到对应的定时任务";
  898. return res.ToCamelCaseString();
  899. }
  900. JobScheduler.Start(sysjob.Code, Type.GetType("wms.api.Job.PostJob"), sysjob.CronExpression);
  901. return res.ToCamelCaseString();
  902. }
  903. /// <summary>
  904. /// 执行job
  905. /// </summary>
  906. /// <param name="reqEntity"></param>
  907. /// <returns></returns>
  908. [HttpPost]
  909. public string ExecuteJob(DetailCodeRequest reqEntity)
  910. {
  911. var res = new SRes();
  912. if (string.IsNullOrEmpty(reqEntity.Code))
  913. {
  914. res.ResCode = ResponseStatusCodeEnum.ErrParam.GetHashCode();
  915. res.ResMsg = "参数错误";
  916. return res.ToCamelCaseString();
  917. }
  918. var jobEntity = _fjService.GetSysJobEntityByCode(reqEntity.Code);
  919. if (jobEntity == null)
  920. {
  921. res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
  922. res.ResMsg = "没有找到该编码";
  923. return res.ToCamelCaseString();
  924. }
  925. var jobapilist = _fjService.GetSysApiDetail(jobEntity.Id);
  926. if (jobapilist.Any())
  927. {
  928. foreach (var item in jobapilist)
  929. {
  930. Task.Run(() => { HttpUtil.PostRequest(item.ApiUrl, item.RequestBody); });
  931. }
  932. }
  933. return res.ToCamelCaseString();
  934. }
  935. /// <summary>
  936. /// 分页Job列表
  937. /// </summary>
  938. /// <param name="reqEntity"></param>
  939. /// <returns></returns>
  940. [HttpPost]
  941. public List<dto.response.hj.SysJobDto> GetSysJobList(GetSysJobListRequest reqEntity)
  942. {
  943. var list = _fjService.GetJobList();
  944. var listdto = _mapper.Map<List<dto.response.hj.SysJobDto>>(list);
  945. if (listdto != null && listdto.Any())
  946. {
  947. for (int i = 0; i < list.Count; i++)
  948. {
  949. listdto[i].JobExecuteStatus = GetExecuteStatus(new DetailCodeRequest() { Code = listdto[i].Code });
  950. }
  951. return listdto;
  952. }
  953. return new List<dto.response.hj.SysJobDto>();
  954. }
  955. /// <summary>
  956. /// 获取执行状态
  957. /// </summary>
  958. /// <param name="reqEntity"></param>
  959. /// <returns></returns>
  960. [HttpPost]
  961. public string GetExecuteStatus(DetailCodeRequest reqEntity)
  962. {
  963. var jobInfo = _fjService.GetSysJobEntityByCode(reqEntity.Code);
  964. var jobs = JobScheduler.GetJobList(Const.JobGroupName).Result;
  965. if (jobs != null)
  966. {
  967. var temp = jobs.Where(p => p.JobName == jobInfo.Code);
  968. if (temp.Any())
  969. {
  970. return temp.First().JobStatus;
  971. }
  972. else
  973. {
  974. return "Stop";
  975. }
  976. }
  977. else
  978. {
  979. return "Stop";
  980. }
  981. }
  982. #endregion 定时器
  983. }
  984. }