FjController.cs 44 KB

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