2024-03-19 11:08:28 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using ZR.Admin.WebApi.Extensions;
|
|
|
|
|
|
using ZR.Admin.WebApi.Filters;
|
|
|
|
|
|
using ZR.Model.MES.wms;
|
2024-03-27 17:19:24 +08:00
|
|
|
|
using ZR.Model.MES.wms.Dto;
|
|
|
|
|
|
using ZR.Service.mes.wms.IService;
|
2024-03-19 11:08:28 +08:00
|
|
|
|
|
|
|
|
|
|
//创建时间:2024-03-18
|
|
|
|
|
|
namespace ZR.Admin.WebApi.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 出货单(物料+客户)
|
|
|
|
|
|
/// </summary>
|
2024-03-27 17:19:24 +08:00
|
|
|
|
// [Verify]
|
2024-03-19 11:08:28 +08:00
|
|
|
|
[Route("mes/wm/WmOutOrder")]
|
|
|
|
|
|
public class WmOutOrderController : BaseController
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 出货单(物料+客户)接口
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly IWmOutOrderService _WmOutOrderService;
|
|
|
|
|
|
|
|
|
|
|
|
public WmOutOrderController(IWmOutOrderService WmOutOrderService)
|
|
|
|
|
|
{
|
|
|
|
|
|
_WmOutOrderService = WmOutOrderService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询出货单(物料+客户)列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="parm"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("list")]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "business:wmoutorder:list")]
|
|
|
|
|
|
public IActionResult QueryWmOutOrder([FromQuery] WmOutOrderQueryDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _WmOutOrderService.GetList(parm);
|
2024-03-27 17:19:24 +08:00
|
|
|
|
|
2024-03-19 11:08:28 +08:00
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询出货单(物料+客户)详情
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ShipmentNum"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("{ShipmentNum}")]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "business:wmoutorder:query")]
|
|
|
|
|
|
public IActionResult GetWmOutOrder(string ShipmentNum)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _WmOutOrderService.GetInfo(ShipmentNum);
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加出货单(物料+客户)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "business:wmoutorder:add")]
|
|
|
|
|
|
[Log(Title = "出货单(物料+客户)", BusinessType = BusinessType.INSERT)]
|
|
|
|
|
|
public IActionResult AddWmOutOrder([FromBody] WmOutOrder_materialDto parm)
|
|
|
|
|
|
{
|
2024-03-27 17:19:24 +08:00
|
|
|
|
if (parm == null)
|
2024-03-19 11:08:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
var modal = parm.ToCreate(HttpContext);
|
|
|
|
|
|
|
|
|
|
|
|
var response = _WmOutOrderService.AddWmOutOrder(modal);
|
2024-06-07 11:04:26 +08:00
|
|
|
|
if (response == null)
|
2024-04-24 09:46:35 +08:00
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(500, "数据存在异常请检查", "数据存在异常请检查"));
|
|
|
|
|
|
}
|
2024-03-19 11:08:28 +08:00
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新出货单(物料+客户)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPut]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "business:wmoutorder:edit")]
|
|
|
|
|
|
[Log(Title = "出货单(物料+客户)", BusinessType = BusinessType.UPDATE)]
|
|
|
|
|
|
public IActionResult UpdateWmOutOrder([FromBody] WmOutOrderDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var modal = parm.Adapt<WmOutOrder>().ToUpdate(HttpContext);
|
|
|
|
|
|
var response = _WmOutOrderService.UpdateWmOutOrder(modal);
|
|
|
|
|
|
|
|
|
|
|
|
return ToResponse(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 删除出货单(物料+客户)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpDelete("{ids}")]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "business:wmoutorder:delete")]
|
|
|
|
|
|
[Log(Title = "出货单(物料+客户)", BusinessType = BusinessType.DELETE)]
|
|
|
|
|
|
public IActionResult DeleteWmOutOrder(string ids)
|
|
|
|
|
|
{
|
2024-08-05 17:25:52 +08:00
|
|
|
|
if (string.IsNullOrEmpty(ids))
|
|
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(ApiResult.Error($"删除失败Id 不能为空"));
|
|
|
|
|
|
}
|
2024-03-19 11:08:28 +08:00
|
|
|
|
|
|
|
|
|
|
var response = _WmOutOrderService.Delete(ids.Split(","));
|
2024-04-09 14:03:10 +08:00
|
|
|
|
// 删除外键 物料清单
|
|
|
|
|
|
_WmOutOrderService.Delete_fk_matrial(ids.Split(","));
|
2024-03-19 11:08:28 +08:00
|
|
|
|
return ToResponse(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取客户信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("getcustom_list")]
|
|
|
|
|
|
public IActionResult GetWmOutOrder()
|
|
|
|
|
|
{
|
2024-03-27 17:19:24 +08:00
|
|
|
|
List<WmCustom> customs = _WmOutOrderService.GetCustominfo();
|
|
|
|
|
|
|
2024-03-19 11:08:28 +08:00
|
|
|
|
return SUCCESS(customs);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询物料记录表列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="parm"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("getmaterial_list")]
|
|
|
|
|
|
public IActionResult QueryWmMaterial([FromQuery] WmMaterialQueryDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _WmOutOrderService.GetmaterialList(parm);
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-22 08:54:11 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 生成出货单的物料信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("getoutorder_matrials")]
|
2024-03-27 17:19:24 +08:00
|
|
|
|
public IActionResult Queryoutoder_matrials(string shipment_num)
|
2024-03-22 08:54:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (shipment_num == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
2024-08-05 17:25:52 +08:00
|
|
|
|
List<WmMaterialQuery_print> data = _WmOutOrderService.Queryoutoder_matrials(
|
|
|
|
|
|
shipment_num
|
|
|
|
|
|
);
|
2024-03-22 08:54:11 +08:00
|
|
|
|
return SUCCESS(data);
|
|
|
|
|
|
}
|
2024-03-23 14:31:50 +08:00
|
|
|
|
|
2024-03-22 08:54:11 +08:00
|
|
|
|
/// <summary>
|
2024-04-25 12:49:18 +08:00
|
|
|
|
/// 8.1根据出库单生成出库计划
|
2024-03-22 08:54:11 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="shipment_num"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("generate_outorderplan")]
|
2024-03-27 17:19:24 +08:00
|
|
|
|
public IActionResult Generate_outorderplan(string shipment_num)
|
2024-03-22 08:54:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (shipment_num == null)
|
|
|
|
|
|
{
|
2024-03-27 17:19:24 +08:00
|
|
|
|
return SUCCESS(null);
|
2024-03-22 08:54:11 +08:00
|
|
|
|
}
|
2024-03-26 14:19:01 +08:00
|
|
|
|
// TODO 1.返回值修改为 对象 返回是否可生成计划,计划结果:{canPlan:true,resultList:[]}
|
2024-04-25 12:49:18 +08:00
|
|
|
|
// XXX 无计划返回空即可
|
2024-08-05 17:25:52 +08:00
|
|
|
|
List<WmOutOrderPlan> WmOutOrderPlanList = _WmOutOrderService.Generate_outorderplan(
|
|
|
|
|
|
shipment_num
|
|
|
|
|
|
);
|
2024-03-22 08:54:11 +08:00
|
|
|
|
return SUCCESS(WmOutOrderPlanList);
|
|
|
|
|
|
}
|
2024-04-01 17:20:23 +08:00
|
|
|
|
|
2024-04-11 16:23:11 +08:00
|
|
|
|
/// <summary>
|
2024-04-25 12:49:18 +08:00
|
|
|
|
/// 8.2 持久化存储出库单的出库计划
|
2024-04-11 16:23:11 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="shipment_num"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("persistenceOutorderplan")]
|
2024-06-07 11:04:26 +08:00
|
|
|
|
public IActionResult PersistenceOutorderplan(string shipment_num)
|
2024-04-11 16:23:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (shipment_num == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
2024-06-07 11:04:26 +08:00
|
|
|
|
int result = _WmOutOrderService.PersistenceOutorderplan(shipment_num);
|
|
|
|
|
|
return SUCCESS(result);
|
2024-04-25 12:49:18 +08:00
|
|
|
|
}
|
2024-04-11 16:23:11 +08:00
|
|
|
|
|
2024-04-25 12:49:18 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 8.3 获取出库单的持久化存储出库计划
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="shipment_num"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("getOutOrderplan")]
|
|
|
|
|
|
public IActionResult getOutOrderplan(string shipment_num)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (shipment_num == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
int result = _WmOutOrderService.PersistenceOutorderplan(shipment_num);
|
|
|
|
|
|
return SUCCESS(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 8.4 获取出库单的已出货物
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="shipment_num"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("getOutOrderOutProduction")]
|
|
|
|
|
|
public IActionResult getOutOrderOutProduction(string shipment_num)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (shipment_num == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
int result = _WmOutOrderService.PersistenceOutorderplan(shipment_num);
|
|
|
|
|
|
return SUCCESS(result);
|
2024-04-11 16:23:11 +08:00
|
|
|
|
}
|
2024-08-05 17:25:52 +08:00
|
|
|
|
|
2024-04-25 17:35:01 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 8.5 PDA端 获取出库单的持久化存储出库计划并计算计划批次当前已出库数量
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="shipment_num">出库单号</param>
|
|
|
|
|
|
/// <param name="partnumber">物料号(零件号)</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("getOutOrderPlanAndOutProductionNum")]
|
2024-08-05 17:25:52 +08:00
|
|
|
|
public IActionResult GetOutOrderPlanAndOutProductionNum(
|
|
|
|
|
|
string shipment_num,
|
|
|
|
|
|
string partnumber
|
|
|
|
|
|
)
|
2024-04-25 17:35:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (shipment_num == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(500, "传入工单号为空!", "传入工单号为空!"));
|
|
|
|
|
|
}
|
2024-08-05 17:25:52 +08:00
|
|
|
|
var result = _WmOutOrderService.GetOutOrderPlanAndOutProductionNum(
|
|
|
|
|
|
shipment_num,
|
|
|
|
|
|
partnumber
|
|
|
|
|
|
);
|
2024-06-07 11:04:26 +08:00
|
|
|
|
if (result == null)
|
2024-04-25 17:35:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(500, "获取计划异常!", "获取计划异常!"));
|
|
|
|
|
|
}
|
|
|
|
|
|
return SUCCESS(result);
|
|
|
|
|
|
}
|
2024-04-11 16:23:11 +08:00
|
|
|
|
|
2024-03-23 14:31:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 5 成品出库
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="doMaterialOut"></param>
|
|
|
|
|
|
/// <returns>
|
2024-08-05 17:25:52 +08:00
|
|
|
|
///
|
2024-03-23 14:31:50 +08:00
|
|
|
|
/// </returns>
|
|
|
|
|
|
[HttpPost("doMaterialOut")]
|
2024-07-10 17:11:01 +08:00
|
|
|
|
[Log(Title = "成品出库", BusinessType = BusinessType.INSERT)]
|
2024-03-27 17:19:24 +08:00
|
|
|
|
public IActionResult DoMaterialOut([FromBody] WmDoMaterialOut_Dto doMaterialOut)
|
2024-03-23 14:31:50 +08:00
|
|
|
|
{
|
2024-08-05 17:25:52 +08:00
|
|
|
|
try
|
2024-03-23 14:31:50 +08:00
|
|
|
|
{
|
2024-08-05 17:25:52 +08:00
|
|
|
|
if (doMaterialOut == null || doMaterialOut.ShipmentNum == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(500, "出库数据为空!", "出库数据为空!"));
|
|
|
|
|
|
}
|
|
|
|
|
|
string createName = HttpContext.GetName();
|
|
|
|
|
|
(int, int) data = _WmOutOrderService.DoMaterialOut(doMaterialOut, createName);
|
|
|
|
|
|
return SUCCESS(data);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(500, "出库异常!" + e.Message, "出库异常!"));
|
2024-03-23 14:31:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-03-19 11:08:28 +08:00
|
|
|
|
|
2024-03-23 14:31:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 6 出库单完成
|
|
|
|
|
|
/// </summary>
|
2025-06-02 09:15:26 +08:00
|
|
|
|
/// <param name="shipmentNum"></param>
|
2024-03-23 14:31:50 +08:00
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("over_outorderplan")]
|
2024-04-09 14:03:10 +08:00
|
|
|
|
public IActionResult OverOutorderplan(string shipmentNum)
|
2024-03-23 14:31:50 +08:00
|
|
|
|
{
|
2024-04-09 14:03:10 +08:00
|
|
|
|
if (shipmentNum == null)
|
2024-03-23 14:31:50 +08:00
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-09 14:03:10 +08:00
|
|
|
|
bool status = _WmOutOrderService.OverOutorderplan(shipmentNum);
|
2024-03-23 14:31:50 +08:00
|
|
|
|
return SUCCESS(status);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-27 17:19:24 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 7 检查是否可出库
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="production_packcode">扫码结果</param>
|
|
|
|
|
|
/// <param name="shipment_num">出库单号</param>
|
2025-06-02 09:15:26 +08:00
|
|
|
|
/// <param name="partnumber">零件号匹配</param>
|
2024-03-27 17:19:24 +08:00
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("checkProductionOut")]
|
2024-08-05 17:25:52 +08:00
|
|
|
|
public IActionResult CheckProductionOut(
|
|
|
|
|
|
string partnumber,
|
|
|
|
|
|
string production_packcode = "",
|
|
|
|
|
|
string shipment_num = ""
|
|
|
|
|
|
)
|
2024-03-27 17:19:24 +08:00
|
|
|
|
{
|
2024-06-07 11:04:26 +08:00
|
|
|
|
if (string.IsNullOrEmpty(partnumber))
|
|
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(200, "请选择物料号", false));
|
2024-04-14 11:16:19 +08:00
|
|
|
|
}
|
2024-03-28 11:17:18 +08:00
|
|
|
|
string msg = "";
|
2024-08-05 17:25:52 +08:00
|
|
|
|
msg = _WmOutOrderService.CheckProductionOut(
|
|
|
|
|
|
partnumber,
|
|
|
|
|
|
production_packcode,
|
|
|
|
|
|
shipment_num
|
|
|
|
|
|
);
|
2024-06-07 11:04:26 +08:00
|
|
|
|
if (msg != "ok")
|
2024-03-28 11:17:18 +08:00
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(200, msg, false));
|
2024-03-28 09:12:17 +08:00
|
|
|
|
}
|
2024-03-28 11:17:18 +08:00
|
|
|
|
else
|
2024-03-28 09:12:17 +08:00
|
|
|
|
{
|
2024-03-28 11:17:18 +08:00
|
|
|
|
return ToResponse(new ApiResult(200, msg, true));
|
2024-06-07 11:04:26 +08:00
|
|
|
|
}
|
2024-03-27 17:19:24 +08:00
|
|
|
|
}
|
2024-03-19 11:08:28 +08:00
|
|
|
|
}
|
2024-08-05 17:25:52 +08:00
|
|
|
|
}
|