Browse Source

提交

shengtang
gwbvipvip 1 year ago
parent
commit
905ccc81cc
6 changed files with 154 additions and 3 deletions
  1. +45
    -0
      backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml
  2. +14
    -0
      backend/BPA.MES.Base.Application/Services/OrderService/Dtos/OrderBaseDto.cs
  3. +7
    -0
      backend/BPA.MES.Base.Application/Services/OrderService/Service/IOrderService.cs
  4. +68
    -0
      backend/BPA.MES.Base.Application/Services/OrderService/Service/OrderService.cs
  5. +11
    -0
      frontend/src/api/orderService.ts
  6. +9
    -3
      frontend/src/pages/order/index.tsx

+ 45
- 0
backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml View File

@@ -120,6 +120,21 @@
工艺状态
</summary>
</member>
<member name="F:BPA.MES.Base.Application.Const.OrderStatusEnum.NotStarted">
<summary>
未开始
</summary>
</member>
<member name="F:BPA.MES.Base.Application.Const.OrderStatusEnum.Ongoing">
<summary>
进行中
</summary>
</member>
<member name="F:BPA.MES.Base.Application.Const.OrderStatusEnum.Completed">
<summary>
完成
</summary>
</member>
<member name="T:BPA.MES.Base.Application.WorkOrderStatusEnum">
<summary>
名 称 :工单枚举
@@ -4476,6 +4491,16 @@
数量
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.OrderService.Dtos.OrderWorkLimit">
<summary>
成品数量限制
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.OrderService.Dtos.OrderWorkLimit.FinalslId">
<summary>
成品
</summary>
</member>
<member name="M:BPA.MES.Base.Application.Services.OrderService.Service.IOrderService.PagedList(BPA.MES.Base.Application.Services.OrderService.Dtos.OrderQueryPageInput)">
<summary>
分页列表
@@ -4510,6 +4535,13 @@
<param name="inputDto"></param>
<returns></returns>
</member>
<member name="M:BPA.MES.Base.Application.Services.OrderService.Service.IOrderService.GetFinalslLImit(System.String)">
<summary>
获取成品剩余制作数量
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:BPA.MES.Base.Application.Services.OrderService.Service.OrderService.PagedList(BPA.MES.Base.Application.Services.OrderService.Dtos.OrderQueryPageInput)">
<summary>
分页列表
@@ -4551,6 +4583,19 @@
<param name="inputDto"></param>
<returns></returns>
</member>
<member name="M:BPA.MES.Base.Application.Services.OrderService.Service.OrderService.VerifyOrderProduct(System.Collections.Generic.List{BPA.MES.Base.Application.Services.OrderService.Dtos.OrderInfoBaseDto})">
<summary>
生成工单时验证成品数量
</summary>
<param name="inputDto"></param>
</member>
<member name="M:BPA.MES.Base.Application.Services.OrderService.Service.OrderService.GetFinalslLImit(System.String)">
<summary>
获取成品剩余制作数量
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="T:BPA.MES.Base.Application.Services.GroupInfoDto">
<summary>
名 称 :产品分组


+ 14
- 0
backend/BPA.MES.Base.Application/Services/OrderService/Dtos/OrderBaseDto.cs View File

@@ -61,4 +61,18 @@ namespace BPA.MES.Base.Application.Services.OrderService.Dtos
public decimal Number { get; set; }
public WorkOrderStatusEnum? Status { get; set; }
}

/// <summary>
/// 成品数量限制
/// </summary>
public class OrderWorkLimit
{
/// <summary>
/// 成品
/// </summary>
public string FinalslId { get; set; }

public decimal Limit { get; set; }

}
}

+ 7
- 0
backend/BPA.MES.Base.Application/Services/OrderService/Service/IOrderService.cs View File

@@ -45,6 +45,13 @@ namespace BPA.MES.Base.Application.Services.OrderService.Service
/// <returns></returns>
Task<bool> OrderAssociationWork(List<OrderInfoBaseDto> inputDto);

/// <summary>
/// 获取成品剩余制作数量
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<List<OrderWorkLimit>> GetFinalslLImit(string OrderId);

Task<bool> CodeFirst();
}
}

+ 68
- 0
backend/BPA.MES.Base.Application/Services/OrderService/Service/OrderService.cs View File

@@ -220,6 +220,8 @@ namespace BPA.MES.Base.Application.Services.OrderService.Service
{
var result = false;
var orderId = inputDto.Select(x => x.OrderId).First();
//验证
VerifyOrderProduct(inputDto);
_dbContext.Ado.BeginTran();

try
@@ -292,6 +294,72 @@ namespace BPA.MES.Base.Application.Services.OrderService.Service
return true;
}

/// <summary>
/// 生成工单时验证成品数量
/// </summary>
/// <param name="inputDto"></param>
private void VerifyOrderProduct(List<OrderInfoBaseDto> inputDto)
{
var orderId = inputDto.Select(x => x.OrderId).First();
var data=_dbContext.Queryable<OrderInfoEntity, Pztj_FinalsInfoEntity>((a,b)=>new JoinQueryInfos(
JoinType.Left,a.FinalslId==b.Id
)).Where((a,b)=>a.OrderId==orderId).
Select((a,b)=>new
{
orderId = a.OrderId,
ProductId = a.FinalslId,
productName = b.Name,
a.Number
}).ToList();
foreach (var item in data)
{
var productCount = inputDto.Where(x => x.FinalslId == item.ProductId).Sum(x => x.Number);
var count= item.Number - productCount;
if (count<0)
{
throw Oops.Bah($"{item.productName}成品生成工单数量大于订单数量,多【{System.Math.Abs(count)}】");
}

if (count>0)
{
throw Oops.Bah($"{item.productName}成品生成工单数量小于订单数量,差【{count}】");
}

}
}

/// <summary>
/// 获取成品剩余制作数量
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<List<OrderWorkLimit>> GetFinalslLImit(string OrderId)
{
var result = new List<OrderWorkLimit>();
var orderInfo=_dbContext.Queryable<OrderInfoEntity>().Where(x=>x.OrderId==OrderId).ToList();

var list=_dbContext.Queryable<OrderWorkEntity , Pztj_WorkInfoEntity>((a,b)=>new JoinQueryInfos(
JoinType.Left,a.WorkId==b.Id))
.Where((a, b) => a.OrderId==OrderId)
.Select((a,b)=>new OrderWorkLimit()
{
FinalslId=b.FinalId,
Limit=0
}).ToList();

foreach (var item in orderInfo)
{
var data=list.Where(x=>x.FinalslId==item.FinalslId).ToList();

result.Add(new OrderWorkLimit()
{
FinalslId=item.FinalslId,
Limit=item.Number-data.Sum(x=>x.Limit),
});
}
return result;

}

[HttpGet]
public Task<bool> CodeFirst()


+ 11
- 0
frontend/src/api/orderService.ts View File

@@ -76,6 +76,17 @@ export default {
});
},

/**
* 获取成品可制造数量
* @param parms
* @returns
*/
getFinalslLImit(parms:string) {
return request('/api/order/getfinalsllimit/'+parms, {
method: 'get',
});
},

}




+ 9
- 3
frontend/src/pages/order/index.tsx View File

@@ -222,7 +222,7 @@ export default () => {
if (res.data) {
message.success('添加成功');
actionRef.current?.reload();
setIsModalOpen(false);
setIsWorkModalOpen(false);
} else {
message.error(res.errors || '添加失败');
}
@@ -478,7 +478,7 @@ export default () => {
},
]}
>
<Select style={{ width: 200, }} disabled >
<Select style={{ width: 200, }} >
{productSelect.map((item) => (
<Select.Option key={item.key} value={item.key}>
{item.value}
@@ -522,10 +522,16 @@ export default () => {
labelCol={{ span: 8 }}
rules={[{ required: true, message: '请输入数量!', },]}
>
<Input type="number" disabled style={{ width: '110px' }} />
<Input type="number" style={{ width: '110px' }} />
</Form.Item>
<MinusCircleOutlined hidden={isRead} onClick={() => remove(name)} />
</Space>
))}
<Form.Item>
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined />}>
添加产品
</Button>
</Form.Item>
</>
)}
</Form.List>


Loading…
Cancel
Save